Commit 614fafa0d6af724e43cbc5699750c06f003a9788
1 parent
b2821c68
fix: 修复导出/编辑利润率/审核列表
Showing
7 changed files
with
138 additions
and
18 deletions
src/main/java/com/order/erp/AdminApplication.java
... | ... | @@ -11,6 +11,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; |
11 | 11 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
12 | 12 | import org.springframework.context.annotation.Bean; |
13 | 13 | import org.springframework.scheduling.annotation.EnableAsync; |
14 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
14 | 15 | import org.springframework.transaction.annotation.EnableTransactionManagement; |
15 | 16 | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
16 | 17 | |
... | ... | @@ -23,6 +24,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; |
23 | 24 | @EnableAsync |
24 | 25 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.order.erp"}) |
25 | 26 | @MapperScan("com.order.erp.**.mapper") |
27 | +@EnableScheduling | |
26 | 28 | @EnableTransactionManagement |
27 | 29 | @EnableSwagger2 |
28 | 30 | public class AdminApplication { | ... | ... |
src/main/java/com/order/erp/domain/vo/order/OrderProfitAnalysisFieldVO.java
... | ... | @@ -6,7 +6,6 @@ import lombok.experimental.SuperBuilder; |
6 | 6 | import java.io.Serializable; |
7 | 7 | |
8 | 8 | /** |
9 | - * | |
10 | 9 | * @author makejava |
11 | 10 | * @since 2023-09-08 15:26:47 |
12 | 11 | */ |
... | ... | @@ -75,7 +74,7 @@ public class OrderProfitAnalysisFieldVO implements Serializable { |
75 | 74 | /** |
76 | 75 | * 默认 0 公式1,1 公式2 |
77 | 76 | */ |
78 | - private int profitType; | |
77 | + private String profitType; | |
79 | 78 | |
80 | 79 | |
81 | 80 | } | ... | ... |
src/main/java/com/order/erp/domain/vo/order/OrderProfitAnalysisVO.java
src/main/java/com/order/erp/job/OrderJob.java
0 → 100644
1 | +package com.order.erp.job; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |
6 | +import com.order.erp.common.constant.Constant; | |
7 | +import com.order.erp.common.utils.DateUtils; | |
8 | +import com.order.erp.common.utils.TransactionHelper; | |
9 | +import com.order.erp.domain.OrderStatusEnum; | |
10 | +import com.order.erp.domain.dto.BaseDO; | |
11 | +import com.order.erp.domain.dto.order.*; | |
12 | +import com.order.erp.domain.vo.order.OrderInfoResultVO; | |
13 | +import com.order.erp.service.order.*; | |
14 | +import lombok.extern.slf4j.Slf4j; | |
15 | +import org.joda.time.DateTime; | |
16 | +import org.springframework.scheduling.annotation.Scheduled; | |
17 | +import org.springframework.stereotype.Component; | |
18 | + | |
19 | +import javax.annotation.Resource; | |
20 | +import java.util.List; | |
21 | +import java.util.Objects; | |
22 | +import java.util.Set; | |
23 | +import java.util.stream.Collectors; | |
24 | + | |
25 | +/** | |
26 | + * @author: xms | |
27 | + * @description: TODO | |
28 | + * @date: 2023/6/25 10:35 | |
29 | + * @version: 1.0 | |
30 | + */ | |
31 | +@Slf4j | |
32 | +@Component | |
33 | +public class OrderJob { | |
34 | + | |
35 | + @Resource | |
36 | + private OrderBaseInfoService orderBaseInfoService; | |
37 | + | |
38 | + @Resource | |
39 | + private OrderProfitAnalysisService profitAnalysisService; | |
40 | + | |
41 | + @Resource | |
42 | + private OrderCompletionReportService reportService; | |
43 | + | |
44 | + @Resource | |
45 | + private OrderTrackStageService trackStageService; | |
46 | + | |
47 | + @Resource | |
48 | + private OrderInspectionStageService inspectionStageService; | |
49 | + | |
50 | + @Resource | |
51 | + private TransactionHelper transactionHelper; | |
52 | + | |
53 | + /** | |
54 | + * 每隔5分执行一次 | |
55 | + */ | |
56 | + @Scheduled(cron = "0 */5 * * * ?") | |
57 | +// @Scheduled(cron = "*/5 * * * * ?") | |
58 | + public void checkCompleteExecute() { | |
59 | + log.info("执行开始时间:{}", DateTime.now().toString("yyyy-MM-dd HH:mm:ss")); | |
60 | + LambdaQueryWrapper<OrderBaseInfoDO> queryWrapper = new LambdaQueryWrapper<OrderBaseInfoDO>() | |
61 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
62 | + .ge(OrderBaseInfoDO::getCreateTime, DateUtils.format(DateTime.now().minusMonths(Constant.ONE).toDate(), DateUtils.DATE_TIME)) | |
63 | + .le(OrderBaseInfoDO::getCreateTime, DateUtils.format(DateTime.now().toDate(), DateUtils.DATE_TIME)) | |
64 | + .ne(OrderBaseInfoDO::getOrderStatus, OrderStatusEnum.ORDER_FINISH.getStatus()); | |
65 | + List<OrderBaseInfoDO> ordersDOS = orderBaseInfoService.list(queryWrapper); | |
66 | + | |
67 | + List<OrderInfoResultVO> orderInfoResultVOS = orderBaseInfoService.wrapperOrderResultList(false, ordersDOS); | |
68 | + if (CollectionUtils.isNotEmpty(orderInfoResultVOS)) { | |
69 | + Set<Long> orderIds = orderInfoResultVOS.stream().filter(x -> Objects.nonNull(x.getSchedule()) && Constant.ONE == x.getSchedule()).map(OrderInfoResultVO::getId).collect(Collectors.toSet()); | |
70 | + LambdaUpdateWrapper<OrderBaseInfoDO> orderBaseUpdateWrapper = new LambdaUpdateWrapper<OrderBaseInfoDO>() | |
71 | + .in(OrderBaseInfoDO::getId, orderIds).set(OrderBaseInfoDO::getOrderStatus, OrderStatusEnum.ORDER_FINISH.getStatus()); | |
72 | + | |
73 | + LambdaUpdateWrapper<OrderCompletionReportDO> reportUpdateWrapper = new LambdaUpdateWrapper<OrderCompletionReportDO>() | |
74 | + .in(OrderCompletionReportDO::getOrderId, orderIds).set(OrderCompletionReportDO::getOrderStatus, OrderStatusEnum.ORDER_FINISH.getStatus()); | |
75 | + | |
76 | + LambdaUpdateWrapper<OrderProfitAnalysisDO> profitUpdateWrapper = new LambdaUpdateWrapper<OrderProfitAnalysisDO>() | |
77 | + .in(OrderProfitAnalysisDO::getOrderId, orderIds).set(OrderProfitAnalysisDO::getOrderStatus, OrderStatusEnum.ORDER_FINISH.getStatus()); | |
78 | + | |
79 | + LambdaUpdateWrapper<OrderTrackStageDO> trackUpdateWrapper = new LambdaUpdateWrapper<OrderTrackStageDO>() | |
80 | + .in(OrderTrackStageDO::getOrderId, orderIds).set(OrderTrackStageDO::getOrderStatus, OrderStatusEnum.ORDER_FINISH.getStatus()); | |
81 | + | |
82 | + LambdaUpdateWrapper<OrderInspectionStageDO> inspectUpdateWrapper = new LambdaUpdateWrapper<OrderInspectionStageDO>() | |
83 | + .in(OrderInspectionStageDO::getOrderId, orderIds).set(OrderInspectionStageDO::getOrderStatus, OrderStatusEnum.ORDER_FINISH.getStatus()); | |
84 | + | |
85 | + transactionHelper.run(() -> { | |
86 | + orderBaseInfoService.update(orderBaseUpdateWrapper); | |
87 | + reportService.update(reportUpdateWrapper); | |
88 | + profitAnalysisService.update(profitUpdateWrapper); | |
89 | + trackStageService.update(trackUpdateWrapper); | |
90 | + inspectionStageService.update(inspectUpdateWrapper); | |
91 | + }); | |
92 | + } | |
93 | + log.info("执行结束时间:{}", DateTime.now().toString("yyyy-MM-dd HH:mm:ss")); | |
94 | + } | |
95 | + | |
96 | +} | ... | ... |
src/main/java/com/order/erp/service/order/OrderBaseInfoService.java
... | ... | @@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; |
4 | 4 | import com.order.erp.common.constant.ServerResult; |
5 | 5 | import com.order.erp.common.excel4j.exceptions.Excel4JException; |
6 | 6 | import com.order.erp.domain.dto.order.OrderBaseInfoDO; |
7 | -import com.order.erp.domain.vo.order.OrderAddVO; | |
8 | -import com.order.erp.domain.vo.order.OrderBaseInfoQueryVO; | |
9 | -import com.order.erp.domain.vo.order.OrderUnlockFieldApplyVO; | |
10 | -import com.order.erp.domain.vo.order.OrderUpdateVO; | |
7 | +import com.order.erp.domain.vo.order.*; | |
11 | 8 | |
12 | 9 | import javax.servlet.http.HttpServletResponse; |
13 | 10 | import java.io.IOException; |
... | ... | @@ -38,6 +35,11 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { |
38 | 35 | */ |
39 | 36 | ServerResult list(OrderBaseInfoQueryVO orderBaseInfoQueryVO); |
40 | 37 | |
38 | + /** | |
39 | + * @param orderBaseInfoDOList | |
40 | + * @return | |
41 | + */ | |
42 | + List<OrderInfoResultVO> wrapperOrderResultList(Boolean locked, List<OrderBaseInfoDO> orderBaseInfoDOList); | |
41 | 43 | |
42 | 44 | /** |
43 | 45 | * @param orderBaseInfoQueryVO | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
... | ... | @@ -140,8 +140,20 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
140 | 140 | |
141 | 141 | Page<OrderInfoResultVO> webVOPage = new Page<>(); |
142 | 142 | List<OrderBaseInfoDO> orderBaseInfoDOList = iPage.getRecords(); |
143 | + webVOPage.setRecords(wrapperOrderResultList(true, orderBaseInfoDOList)); | |
144 | + BeanUtils.copyProperties(page, webVOPage, "records"); | |
145 | + return ServerResult.success(webVOPage); | |
146 | + } | |
147 | + | |
148 | + /** | |
149 | + * @param orderBaseInfoDOList | |
150 | + * @return | |
151 | + */ | |
152 | + @Override | |
153 | + public List<OrderInfoResultVO> wrapperOrderResultList(Boolean locked, List<OrderBaseInfoDO> orderBaseInfoDOList) { | |
154 | + List<OrderInfoResultVO> resultVOList = new ArrayList<>(); | |
143 | 155 | if (CollectionUtils.isNotEmpty(orderBaseInfoDOList)) { |
144 | - List<OrderInfoResultVO> resultVOList = orderBaseInfoDOList.stream().map(x -> { | |
156 | + resultVOList = orderBaseInfoDOList.stream().map(x -> { | |
145 | 157 | OrderInfoResultVO resultVO = new OrderInfoResultVO(); |
146 | 158 | BeanUtils.copyProperties(x, resultVO); |
147 | 159 | return resultVO; |
... | ... | @@ -159,16 +171,16 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
159 | 171 | // 填充质检信息 |
160 | 172 | fillInspectionStageInfo(resultVOList); |
161 | 173 | |
162 | - // 填充字段锁定信息 | |
163 | - fillLockFields(resultVOList); | |
174 | + if (locked) { | |
175 | + // 填充字段锁定信息 | |
176 | + fillLockFields(resultVOList); | |
177 | + } | |
164 | 178 | |
165 | 179 | // 填充进度 |
166 | 180 | fillSchedules(resultVOList); |
167 | 181 | |
168 | - webVOPage.setRecords(resultVOList); | |
169 | 182 | } |
170 | - BeanUtils.copyProperties(page, webVOPage, "records"); | |
171 | - return ServerResult.success(webVOPage); | |
183 | + return resultVOList; | |
172 | 184 | } |
173 | 185 | |
174 | 186 | @Override |
... | ... | @@ -530,7 +542,16 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
530 | 542 | * @param userId |
531 | 543 | * @return |
532 | 544 | */ |
533 | - private OrderFieldLockApplyDO buildProfitFieldLockApplyDO(OrderProfitAnalysisVO profitAnalysisVO, Long userId) { | |
545 | + private OrderFieldLockApplyDO buildProfitFieldLockApplyDO(OrderBaseInfoDO orderBaseInfoDO, OrderProfitAnalysisVO profitAnalysisVO, Long userId) { | |
546 | + if (Objects.nonNull(profitAnalysisVO.getCustomerPrice())) { | |
547 | + profitAnalysisVO.setCustomerTotalPrice(profitAnalysisVO.getCustomerPrice() * orderBaseInfoDO.getOrderCount()); | |
548 | + } | |
549 | + if (Objects.nonNull(profitAnalysisVO.getPacketPrice())) { | |
550 | + profitAnalysisVO.setPacketTotalPrice(profitAnalysisVO.getPacketPrice() * orderBaseInfoDO.getOrderCount()); | |
551 | + } | |
552 | + if (Objects.nonNull(profitAnalysisVO.getProductionDepartmentPrice())) { | |
553 | + profitAnalysisVO.setProductionDepartmentTotalPrice(profitAnalysisVO.getProductionDepartmentPrice() * orderBaseInfoDO.getOrderCount()); | |
554 | + } | |
534 | 555 | OrderProfitAnalysisFieldVO profitAnalysisFieldVO = profitAnalysis2profitAnalysisField(profitAnalysisVO); |
535 | 556 | return OrderFieldLockApplyDO.builder() |
536 | 557 | .applyUserId(userId) |
... | ... | @@ -554,7 +575,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
554 | 575 | && Objects.nonNull(profitAnalysisVO.getPacketTotalPrice()) |
555 | 576 | && Objects.nonNull(profitAnalysisVO.getProductionDepartmentTotalPrice())) { |
556 | 577 | profitRate = ProfitUtils.calculateProfitRate(ProfitCalculateVO.builder() |
557 | - .profitType(profitAnalysisVO.getProfitType()) | |
578 | + .profitType(StringUtils.isBlank(profitAnalysisVO.getProfitType()) ? Constant.ZERO : Integer.parseInt(profitAnalysisVO.getProfitType())) | |
558 | 579 | .customerTotalPrice(profitAnalysisVO.getCustomerTotalPrice()) |
559 | 580 | .exchangeRate(profitAnalysisVO.getExchangeRate()) |
560 | 581 | .packetTotalPrice(profitAnalysisVO.getPacketTotalPrice()) |
... | ... | @@ -1205,7 +1226,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
1205 | 1226 | } |
1206 | 1227 | if (Objects.nonNull(updateVO.getProfitAnalysisInfo())) { |
1207 | 1228 | checkApply(updateVO.getOrderId(), userId); |
1208 | - OrderFieldLockApplyDO orderFieldLockApplyDO = buildProfitFieldLockApplyDO(updateVO.getProfitAnalysisInfo(), userId); | |
1229 | + OrderFieldLockApplyDO orderFieldLockApplyDO = buildProfitFieldLockApplyDO(orderBaseInfoDo, updateVO.getProfitAnalysisInfo(), userId); | |
1209 | 1230 | orderFieldLockApplyService.save(orderFieldLockApplyDO); |
1210 | 1231 | |
1211 | 1232 | orderBaseInfoDo.setOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus()); | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderFieldLockApplyServiceImpl.java
... | ... | @@ -456,7 +456,7 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
456 | 456 | profitAnalysisDO.setProductionDepartmentTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) : null); |
457 | 457 | profitAnalysisDO.setProductionDepartmentCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getProductionDepartmentCurrency()) ? profitAnalysisFieldVO.getProductionDepartmentCurrency() : null); |
458 | 458 | profitAnalysisDO.setProfitRate(Objects.nonNull(profitAnalysisFieldVO.getProfitRate()) ? Double.valueOf(profitAnalysisFieldVO.getProfitRate()) : null); |
459 | - profitAnalysisDO.setProfitType(profitAnalysisFieldVO.getProfitType()); | |
459 | + profitAnalysisDO.setProfitType(StringUtils.isBlank(profitAnalysisFieldVO.getProfitType()) ? Constant.ZERO : Integer.parseInt(profitAnalysisFieldVO.getProfitType())); | |
460 | 460 | profitAnalysisService.updateById(profitAnalysisDO); |
461 | 461 | } |
462 | 462 | orderBaseInfoDO.setOrderStatus(OrderStatusEnum.PROFIT_AUDIT_PASS.getStatus()); |
... | ... | @@ -490,7 +490,7 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
490 | 490 | private OrderProfitAnalysisDO profitField2profitDo(OrderProfitAnalysisFieldVO profitAnalysisFieldVO) { |
491 | 491 | return OrderProfitAnalysisDO.builder() |
492 | 492 | .orderId(profitAnalysisFieldVO.getOrderId()) |
493 | - .profitType(profitAnalysisFieldVO.getProfitType()) | |
493 | + .profitType(StringUtils.isBlank(profitAnalysisFieldVO.getProfitType()) ? Constant.ZERO : Integer.parseInt(profitAnalysisFieldVO.getProfitType())) | |
494 | 494 | .customerPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerPrice()) : null) |
495 | 495 | .customerTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerTotalPrice()) : null) |
496 | 496 | .customerCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getCustomerCurrency()) ? profitAnalysisFieldVO.getCustomerCurrency() : null) | ... | ... |