| | |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | private final ContractPaymentScheduleProcessMapper scheduleProcessMapper; |
| | | private final ContractOutBoundMapper contractOutBoundMapper; |
| | | private final DeliveryOverdueMapper deliveryOverdueMapper; |
| | | private final StringRedisTemplate redisTemplate; |
| | | |
| | | @Value("${dept.smj}") |
| | | private String smj; |
| | | |
| | | @Value("${dept.sgb}") |
| | | private String sgb; |
| | | |
| | | @Value("${dept.jxc}") |
| | | private String jxc; |
| | | |
| | | @Value("${dept.tfgs}") |
| | | private String tfgs; |
| | | |
| | | @Value("${dept.ymj}") |
| | | private String ymj; |
| | | |
| | | @Override |
| | | public R add(OutBoundAddDTO addDTO) { |
| | |
| | | //出库 |
| | | addDTO.getSubjectMatterList().stream().forEach(outSubjectMatterAddDTO -> { |
| | | OutBound outBound = BeanUtil.copyProperties(outSubjectMatterAddDTO, OutBound.class); |
| | | outBound.setBatchNumber(batchNumber); |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)){ |
| | | outBound.setBatchNumber(generateSMJContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",sgb)){ |
| | | outBound.setBatchNumber(generateGYBContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",ymj)){ |
| | | outBound.setBatchNumber(generateYMJContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",tfgs)){ |
| | | outBound.setBatchNumber(generateTFContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",jxc)){ |
| | | outBound.setBatchNumber(generateJXCContractNo()); |
| | | } |
| | | outBound.setBusGuestName(addDTO.getBusGuestName()); |
| | | outBound.setBusGuestId(addDTO.getBusGuestId()); |
| | | outBound.setOutBoundTime(addDTO.getOutBoundTime()); |
| | |
| | | contractOutBound.setInvoiceStatus("0"); |
| | | contractOutBound.setInvoiceNum(new BigDecimal("0")); |
| | | contractOutBoundMapper.insert(contractOutBound); |
| | | if (StrUtil.isEmpty(contract.getContractCategory())) { |
| | | if (DateUtil.compare(addDTO.getOutBoundTime(), contract.getExpirationDate()) > 0) { |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | // 1. 确定用于比较的基准日期(优先级:计划交货日期 > 合同到期日期) |
| | | Date deadline = subjectMatter.getPlannedDeliveryDate(); |
| | | if (ObjUtil.isNull(deadline)) { |
| | | deadline = contract.getExpirationDate(); |
| | | } |
| | | |
| | | // 2. 统一判断是否逾期 |
| | | // 注意:需确保 deadline 不为 null,防止空指针异常 |
| | | if (deadline != null && DateUtil.compare(addDTO.getOutBoundTime(), deadline) > 0) { |
| | | saveOverdueOutBound(contract, addDTO, subjectMatter); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | contractSubjectMatterMapper.updateById(subjectMatter); |
| | | // |
| | | OutBound outBound = new OutBound(); |
| | | outBound.setBatchNumber(batchNumber); |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)){ |
| | | outBound.setBatchNumber(generateSMJContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",sgb)){ |
| | | outBound.setBatchNumber(generateGYBContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",ymj)){ |
| | | outBound.setBatchNumber(generateYMJContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",tfgs)){ |
| | | outBound.setBatchNumber(generateTFContractNo()); |
| | | } |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",jxc)){ |
| | | outBound.setBatchNumber(generateJXCContractNo()); |
| | | } |
| | | outBound.setOutBoundNum(outSubjectMatterAddDTO.getOutBoundNum()); |
| | | outBound.setOutBoundAttNames(addDTO.getOutBoundAttNames()); |
| | | outBound.setOutBoundAttPaths(addDTO.getOutBoundAttPaths()); |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 生成格式为: yyyyMMdd + 4位序列号 (例如: 20260629000001) |
| | | */ |
| | | public String generateSMJContractNo() { |
| | | // 1. 获取当前日期字符串 |
| | | String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); |
| | | |
| | | // 2. 构建 Redis Key,按天隔离,例如: order:no:20260629 |
| | | String key = "ZB-SMJ-CK:" + dateStr; |
| | | |
| | | // 3. Redis 原子递增,设置过期时间为2天(防止Key堆积,同时覆盖跨天边界情况) |
| | | Long sequence = redisTemplate.opsForValue().increment(key, 1); |
| | | redisTemplate.expire(key, 1, java.util.concurrent.TimeUnit.DAYS); |
| | | |
| | | // 4. 格式化序列号,不足6位前补0 |
| | | String seqStr = String.format("%04d", sequence); |
| | | |
| | | // 5. 拼接返回 |
| | | return "ZB-SMJ-CK-"+dateStr + seqStr; |
| | | } |
| | | |
| | | public String generateYMJContractNo() { |
| | | // 1. 获取当前日期字符串 |
| | | String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); |
| | | |
| | | // 2. 构建 Redis Key,按天隔离,例如: order:no:20260629 |
| | | String key = "ZB-YMJ-CK:" + dateStr; |
| | | |
| | | // 3. Redis 原子递增,设置过期时间为2天(防止Key堆积,同时覆盖跨天边界情况) |
| | | Long sequence = redisTemplate.opsForValue().increment(key, 1); |
| | | redisTemplate.expire(key, 1, java.util.concurrent.TimeUnit.DAYS); |
| | | |
| | | // 4. 格式化序列号,不足6位前补0 |
| | | String seqStr = String.format("%04d", sequence); |
| | | |
| | | // 5. 拼接返回 |
| | | return "ZB-YMJ-CK-"+dateStr + seqStr; |
| | | } |
| | | |
| | | public String generateJXCContractNo() { |
| | | // 1. 获取当前日期字符串 |
| | | String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); |
| | | |
| | | // 2. 构建 Redis Key,按天隔离,例如: order:no:20260629 |
| | | String key = "ZB-JXC-CK:" + dateStr; |
| | | |
| | | // 3. Redis 原子递增,设置过期时间为2天(防止Key堆积,同时覆盖跨天边界情况) |
| | | Long sequence = redisTemplate.opsForValue().increment(key, 1); |
| | | redisTemplate.expire(key, 1, java.util.concurrent.TimeUnit.DAYS); |
| | | |
| | | // 4. 格式化序列号,不足6位前补0 |
| | | String seqStr = String.format("%04d", sequence); |
| | | |
| | | // 5. 拼接返回 |
| | | return "ZB-JXC-CK-"+dateStr + seqStr; |
| | | } |
| | | |
| | | public String generateTFContractNo() { |
| | | // 1. 获取当前日期字符串 |
| | | String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); |
| | | |
| | | // 2. 构建 Redis Key,按天隔离,例如: order:no:20260629 |
| | | String key = "ZB-TF-CK:" + dateStr; |
| | | |
| | | // 3. Redis 原子递增,设置过期时间为2天(防止Key堆积,同时覆盖跨天边界情况) |
| | | Long sequence = redisTemplate.opsForValue().increment(key, 1); |
| | | redisTemplate.expire(key, 1, java.util.concurrent.TimeUnit.DAYS); |
| | | |
| | | // 4. 格式化序列号,不足6位前补0 |
| | | String seqStr = String.format("%04d", sequence); |
| | | |
| | | // 5. 拼接返回 |
| | | return "ZB-TF-CK-"+dateStr + seqStr; |
| | | } |
| | | |
| | | public String generateGYBContractNo() { |
| | | // 1. 获取当前日期字符串 |
| | | String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); |
| | | |
| | | // 2. 构建 Redis Key,按天隔离,例如: order:no:20260629 |
| | | String key = "ZB-GYB-CK:" + dateStr; |
| | | |
| | | // 3. Redis 原子递增,设置过期时间为2天(防止Key堆积,同时覆盖跨天边界情况) |
| | | Long sequence = redisTemplate.opsForValue().increment(key, 1); |
| | | redisTemplate.expire(key, 1, java.util.concurrent.TimeUnit.DAYS); |
| | | |
| | | // 4. 格式化序列号,不足6位前补0 |
| | | String seqStr = String.format("%04d", sequence); |
| | | |
| | | // 5. 拼接返回 |
| | | return "ZB-GYB-CK-"+dateStr + seqStr; |
| | | } |
| | | } |