Showing
4 changed files
with
45 additions
and
2 deletions
| ... | ... | @@ -23,7 +23,7 @@ import io.swagger.annotations.ApiOperation; |
| 23 | 23 | import com.lframework.starter.common.utils.CollectionUtil; |
| 24 | 24 | import io.swagger.annotations.Api; |
| 25 | 25 | import com.lframework.starter.web.core.controller.DefaultBaseController; |
| 26 | -import com.lframework.starter.web.core.annotations.security.HasPermission; | |
| 26 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 27 | 27 | import org.springframework.validation.annotation.Validated; |
| 28 | 28 | import org.springframework.web.bind.annotation.*; |
| 29 | 29 | |
| ... | ... | @@ -139,4 +139,15 @@ public class ShipmentsPlanDetailController extends DefaultBaseController { |
| 139 | 139 | shipmentsPlanDetailService.batchDelete(ids); |
| 140 | 140 | return InvokeResultBuilder.success(); |
| 141 | 141 | } |
| 142 | + | |
| 143 | + /** | |
| 144 | + * 检查是否有过时的数据 | |
| 145 | + * 删除三天还未生成发货单的数据 | |
| 146 | + * | |
| 147 | + */ | |
| 148 | + @Scheduled(cron = "0 30 1 * * ?") | |
| 149 | + @GetMapping("/checkOutdated") | |
| 150 | + public void checkOutdated() { | |
| 151 | + shipmentsPlanDetailService.checkOutdated(); | |
| 152 | + } | |
| 142 | 153 | } | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/shipments/ShipmentsOrderInfoServiceImpl.java
| ... | ... | @@ -321,7 +321,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr |
| 321 | 321 | list.add(detail); |
| 322 | 322 | } |
| 323 | 323 | if (MapUtils.isEmpty(detailMap)) { |
| 324 | - throw new DefaultClientException("发货明细数据不存在!"); | |
| 324 | + throw new DefaultClientException("发货明细数据不存在或存在需要手动发货的数据!"); | |
| 325 | 325 | } |
| 326 | 326 | // todo 如果客户很多,则此处需要优化 |
| 327 | 327 | for (Map.Entry<String, List<ShipmentsPlanDetail>> entry : detailMap.entrySet()) { | ... | ... |
| ... | ... | @@ -37,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 37 | 37 | import javax.annotation.Resource; |
| 38 | 38 | import java.math.BigDecimal; |
| 39 | 39 | import java.time.LocalDate; |
| 40 | +import java.time.LocalDateTime; | |
| 40 | 41 | import java.time.LocalTime; |
| 41 | 42 | import java.util.*; |
| 42 | 43 | import java.util.function.Function; |
| ... | ... | @@ -479,6 +480,30 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP |
| 479 | 480 | } |
| 480 | 481 | } |
| 481 | 482 | |
| 483 | + @Override | |
| 484 | + public void checkOutdated() { | |
| 485 | + LocalTime now = LocalTime.now(); | |
| 486 | + // 获取三天前的时间 | |
| 487 | + LocalDateTime threeDaysAgoTime = LocalDate.now().minusDays(3).atStartOfDay(); | |
| 488 | + // 根据时间获取还未发货的有效数据 | |
| 489 | + LambdaQueryWrapper<ShipmentsPlanDetail> queryWrapper = Wrappers.lambdaQuery(ShipmentsPlanDetail.class); | |
| 490 | + queryWrapper.eq(ShipmentsPlanDetail::getDelFlag, Boolean.FALSE) | |
| 491 | + .eq(ShipmentsPlanDetail::getPreShipments, Boolean.FALSE) | |
| 492 | + .lt(ShipmentsPlanDetail::getCreateTime, threeDaysAgoTime) | |
| 493 | + .and(wq -> wq | |
| 494 | + .isNull(ShipmentsPlanDetail::getShipmentOrderId) // shipmentOrderId is null | |
| 495 | + .or() // 或者 | |
| 496 | + .eq(ShipmentsPlanDetail::getShipmentOrderId, "") // shipmentOrderId = '' | |
| 497 | + ); | |
| 498 | + List<ShipmentsPlanDetail> detailList = getBaseMapper().selectList(queryWrapper); | |
| 499 | + if (CollectionUtils.isEmpty(detailList)) { | |
| 500 | + return; | |
| 501 | + } | |
| 502 | + // 删除数据 | |
| 503 | + List<String> ids = detailList.stream().map(ShipmentsPlanDetail::getId).collect(Collectors.toList()); | |
| 504 | + getBaseMapper().deleteBatchIds(ids); | |
| 505 | + } | |
| 506 | + | |
| 482 | 507 | |
| 483 | 508 | /** |
| 484 | 509 | * 封装发货计划明细数据 | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/service/shipments/ShipmentsPlanDetailService.java
| ... | ... | @@ -139,4 +139,11 @@ public interface ShipmentsPlanDetailService extends BaseMpService<ShipmentsPlanD |
| 139 | 139 | * @param status 状态 |
| 140 | 140 | */ |
| 141 | 141 | void checkDataIntegrity(String planId, String status); |
| 142 | + | |
| 143 | + /** | |
| 144 | + * 检查是否有过时的数据 | |
| 145 | + * 删除三天还未生成发货单的数据 | |
| 146 | + * | |
| 147 | + */ | |
| 148 | + void checkOutdated(); | |
| 142 | 149 | } | ... | ... |