Commit 0687f858034257781e2ce5c942bd876fbef4a4c3
1 parent
623dfede
feat: 利润分析/项目报告书编辑
Showing
4 changed files
with
270 additions
and
47 deletions
src/main/java/com/order/erp/domain/vo/order/OrderCompletionReportFieldVO.java
src/main/java/com/order/erp/domain/vo/order/OrderProfitAnalysisFieldVO.java
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
... | ... | @@ -27,8 +27,6 @@ import com.order.erp.domain.OrderStatusEnum; |
27 | 27 | import com.order.erp.domain.dto.BaseDO; |
28 | 28 | import com.order.erp.domain.dto.order.*; |
29 | 29 | import com.order.erp.domain.excel.OrderExcelVO; |
30 | -import com.order.erp.domain.vo.IndexDataVO; | |
31 | -import com.order.erp.domain.vo.OrderCountVO; | |
32 | 30 | import com.order.erp.domain.vo.order.*; |
33 | 31 | import com.order.erp.mapper.order.OrderBaseInfoMapper; |
34 | 32 | import com.order.erp.service.order.*; |
... | ... | @@ -42,7 +40,10 @@ import javax.annotation.Resource; |
42 | 40 | import javax.servlet.http.HttpServletResponse; |
43 | 41 | import java.io.File; |
44 | 42 | import java.io.IOException; |
45 | -import java.util.*; | |
43 | +import java.util.List; | |
44 | +import java.util.Map; | |
45 | +import java.util.Objects; | |
46 | +import java.util.Set; | |
46 | 47 | import java.util.function.Function; |
47 | 48 | import java.util.stream.Collectors; |
48 | 49 | |
... | ... | @@ -241,6 +242,23 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
241 | 242 | } |
242 | 243 | |
243 | 244 | /** |
245 | + * @param orderId | |
246 | + * @param userId | |
247 | + */ | |
248 | + private void checkApply(Long orderId, Long userId) { | |
249 | + List<OrderFieldLockApplyDO> applyDOS = orderFieldLockApplyService.list(new LambdaQueryWrapper<OrderFieldLockApplyDO>() | |
250 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
251 | + .eq(OrderFieldLockApplyDO::getOrderId, orderId) | |
252 | + .eq(OrderFieldLockApplyDO::getApplyUserId, userId) | |
253 | + .eq(OrderFieldLockApplyDO::getType, ApplyTypeEnum.FIELD_EDIT_APPLY.getType()) | |
254 | + .eq(OrderFieldLockApplyDO::getStatus, ApplyStatusEnum.WAIT_AUDIT.getStatus())); | |
255 | + if (CollectionUtils.isNotEmpty(applyDOS)) { | |
256 | + throw new BusinessException(ServerResultCode.APPLY_UNLOCK_FIELD_EXIST); | |
257 | + } | |
258 | + } | |
259 | + | |
260 | + | |
261 | + /** | |
244 | 262 | * @param fieldVO |
245 | 263 | * @param userId |
246 | 264 | * @return |
... | ... | @@ -259,6 +277,84 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
259 | 277 | .build(); |
260 | 278 | } |
261 | 279 | |
280 | + | |
281 | + /** | |
282 | + * @param reportVO | |
283 | + * @param userId | |
284 | + * @return | |
285 | + */ | |
286 | + private OrderFieldLockApplyDO buildReportFieldLockApplyDO(OrderCompletionReportVO reportVO, Long userId) { | |
287 | + OrderCompletionReportFieldVO reportFieldVO = report2reportField(reportVO); | |
288 | + return OrderFieldLockApplyDO.builder() | |
289 | + .applyUserId(userId) | |
290 | + .auditUserId(null) | |
291 | + .fields(JSONObject.toJSONString(reportFieldVO)) | |
292 | + .orderId(reportFieldVO.getOrderId()) | |
293 | + .type(ApplyTypeEnum.ORDER_REPORT_APPLY.getType()) | |
294 | + .remark(ApplyTypeEnum.ORDER_REPORT_APPLY.getDesc()) | |
295 | + .status(ApplyStatusEnum.WAIT_AUDIT.getStatus()) | |
296 | + .build(); | |
297 | + } | |
298 | + | |
299 | + /** | |
300 | + * @param reportVO | |
301 | + * @return | |
302 | + */ | |
303 | + private OrderCompletionReportFieldVO report2reportField(OrderCompletionReportVO reportVO) { | |
304 | + return OrderCompletionReportFieldVO.builder() | |
305 | + .orderId(reportVO.getOrderId()) | |
306 | + .ideaManualRate(Objects.nonNull(reportVO.getIdeaManualRate()) ? reportVO.getIdeaManualRate().toString() : null) | |
307 | + .ideaSource(StringUtils.isNotBlank(reportVO.getIdeaSource()) ? reportVO.getIdeaSource() : null) | |
308 | + .manualPreform(StringUtils.isNotBlank(reportVO.getManualPreform()) ? reportVO.getManualPreform() : null).build(); | |
309 | + } | |
310 | + | |
311 | + | |
312 | + /** | |
313 | + * @param profitAnalysisVO | |
314 | + * @param userId | |
315 | + * @return | |
316 | + */ | |
317 | + private OrderFieldLockApplyDO buildProfitFieldLockApplyDO(OrderProfitAnalysisVO profitAnalysisVO, Long userId) { | |
318 | + OrderProfitAnalysisFieldVO profitAnalysisFieldVO = profitAnalysis2profitAnalysisField(profitAnalysisVO); | |
319 | + return OrderFieldLockApplyDO.builder() | |
320 | + .applyUserId(userId) | |
321 | + .auditUserId(null) | |
322 | + .fields(JSONObject.toJSONString(profitAnalysisFieldVO)) | |
323 | + .orderId(profitAnalysisFieldVO.getOrderId()) | |
324 | + .type(ApplyTypeEnum.ORDER_PROFIT_APPLY.getType()) | |
325 | + .remark(ApplyTypeEnum.ORDER_PROFIT_APPLY.getDesc()) | |
326 | + .status(ApplyStatusEnum.WAIT_AUDIT.getStatus()) | |
327 | + .build(); | |
328 | + } | |
329 | + | |
330 | + /** | |
331 | + * @param profitAnalysisVO | |
332 | + * @return | |
333 | + */ | |
334 | + private OrderProfitAnalysisFieldVO profitAnalysis2profitAnalysisField(OrderProfitAnalysisVO profitAnalysisVO) { | |
335 | + Double profitRate = null; | |
336 | + if (Objects.nonNull(profitAnalysisVO.getCustomerTotalPrice()) | |
337 | + && Objects.nonNull(profitAnalysisVO.getExchangeRate()) | |
338 | + && Objects.nonNull(profitAnalysisVO.getPacketTotalPrice()) | |
339 | + && Objects.nonNull(profitAnalysisVO.getProductionDepartmentTotalPrice())) { | |
340 | + profitRate = ProfitUtils.calculateProfitRate(ProfitCalculateVO.builder() | |
341 | + .customerTotalPrice(profitAnalysisVO.getCustomerTotalPrice()) | |
342 | + .exchangeRate(profitAnalysisVO.getExchangeRate()) | |
343 | + .packetTotalPrice(profitAnalysisVO.getPacketTotalPrice()) | |
344 | + .productionDepartmentTotalPrice(profitAnalysisVO.getProductionDepartmentTotalPrice()).build()); | |
345 | + } | |
346 | + return OrderProfitAnalysisFieldVO.builder() | |
347 | + .orderId(profitAnalysisVO.getOrderId()) | |
348 | + .customerPrice(Objects.nonNull(profitAnalysisVO.getCustomerPrice()) ? profitAnalysisVO.getCustomerPrice().toString() : null) | |
349 | + .customerTotalPrice(Objects.nonNull(profitAnalysisVO.getCustomerTotalPrice()) ? profitAnalysisVO.getCustomerTotalPrice().toString() : null) | |
350 | + .packetPrice(Objects.nonNull(profitAnalysisVO.getPacketPrice()) ? profitAnalysisVO.getPacketPrice().toString() : null) | |
351 | + .packetTotalPrice(Objects.nonNull(profitAnalysisVO.getPacketTotalPrice()) ? profitAnalysisVO.getPacketTotalPrice().toString() : null) | |
352 | + .productionDepartmentPrice(Objects.nonNull(profitAnalysisVO.getProductionDepartmentPrice()) ? profitAnalysisVO.getProductionDepartmentPrice().toString() : null) | |
353 | + .productionDepartmentTotalPrice(Objects.nonNull(profitAnalysisVO.getProductionDepartmentTotalPrice()) ? profitAnalysisVO.getProductionDepartmentTotalPrice().toString() : null) | |
354 | + .exchangeRate(Objects.nonNull(profitAnalysisVO.getExchangeRate()) ? profitAnalysisVO.getExchangeRate().toString() : null) | |
355 | + .profitRate(Objects.nonNull(profitRate) ? profitRate.toString() : null).build(); | |
356 | + } | |
357 | + | |
262 | 358 | /** |
263 | 359 | * @param orderInfoResultVOList |
264 | 360 | */ |
... | ... | @@ -434,6 +530,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
434 | 530 | * @return 实例对象 |
435 | 531 | */ |
436 | 532 | @Override |
533 | + @Transactional | |
437 | 534 | public ServerResult add(OrderAddVO orderAddVO) { |
438 | 535 | OrderBaseInfoVO baseInfoVO = orderAddVO.getBaseInfo(); |
439 | 536 | if (Objects.isNull(baseInfoVO)) { |
... | ... | @@ -495,43 +592,38 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
495 | 592 | * @return 实例对象 |
496 | 593 | */ |
497 | 594 | @Override |
595 | + @Transactional | |
498 | 596 | public ServerResult edit(OrderUpdateVO updateVO) { |
499 | 597 | //todo 校验 |
500 | 598 | if (Objects.isNull(updateVO.getOrderId())) { |
501 | 599 | return ServerResult.fail("id 不能为空"); |
502 | 600 | } |
601 | + Long userId = dataScope.getLoginUserId(); | |
602 | + OrderBaseInfoDO orderBaseInfoDo = getById(updateVO.getOrderId()); | |
603 | + if (Objects.isNull(orderBaseInfoDo)) { | |
604 | + throw new BusinessException(ServerResultCode.ORDER_BASE_INFO_EMPTY); | |
605 | + } | |
503 | 606 | if (Objects.nonNull(updateVO.getBaseInfo())) { |
504 | - OrderBaseInfoDO orderBaseInfoDo = BeanUtil.copyProperties(updateVO.getBaseInfo(), OrderBaseInfoDO.class); | |
607 | + orderBaseInfoDo = BeanUtil.copyProperties(updateVO.getBaseInfo(), OrderBaseInfoDO.class); | |
505 | 608 | orderBaseInfoDo.setId(updateVO.getOrderId()); |
506 | - updateById(orderBaseInfoDo); | |
609 | + | |
507 | 610 | } |
508 | 611 | if (Objects.nonNull(updateVO.getProfitAnalysisInfo())) { |
509 | - OrderProfitAnalysisDO profitAnalysisDO = profitAnalysisService.getOne(new LambdaQueryWrapper<OrderProfitAnalysisDO>() | |
510 | - .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
511 | - .eq(OrderProfitAnalysisDO::getOrderId, updateVO.getOrderId())); | |
512 | - if (Objects.nonNull(profitAnalysisDO)) { | |
513 | - BeanUtils.copyProperties(updateVO.getProfitAnalysisInfo(), profitAnalysisDO); | |
514 | - profitAnalysisDO.setOrderId(updateVO.getOrderId()); | |
515 | - profitAnalysisDO.setOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus()); | |
516 | - profitAnalysisDO.setProfitRate(ProfitUtils.calculateProfitRate(ProfitCalculateVO.builder() | |
517 | - .customerTotalPrice(profitAnalysisDO.getCustomerTotalPrice()) | |
518 | - .exchangeRate(profitAnalysisDO.getExchangeRate()) | |
519 | - .packetTotalPrice(profitAnalysisDO.getPacketTotalPrice()) | |
520 | - .productionDepartmentTotalPrice(profitAnalysisDO.getProductionDepartmentTotalPrice()).build())); | |
521 | - profitAnalysisService.updateById(profitAnalysisDO); | |
522 | - } | |
612 | + checkApply(updateVO.getOrderId(), userId); | |
613 | + OrderFieldLockApplyDO orderFieldLockApplyDO = buildProfitFieldLockApplyDO(updateVO.getProfitAnalysisInfo(), userId); | |
614 | + orderFieldLockApplyService.save(orderFieldLockApplyDO); | |
615 | + | |
616 | + orderBaseInfoDo.setOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus()); | |
617 | + updateById(orderBaseInfoDo); | |
523 | 618 | } |
524 | 619 | |
525 | 620 | if (Objects.nonNull(updateVO.getReportInfo())) { |
526 | - OrderCompletionReportDO reportDO = reportService.getOne(new LambdaQueryWrapper<OrderCompletionReportDO>() | |
527 | - .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
528 | - .eq(OrderCompletionReportDO::getOrderId, updateVO.getOrderId())); | |
529 | - if (Objects.nonNull(reportDO)) { | |
530 | - BeanUtils.copyProperties(updateVO.getReportInfo(), reportDO); | |
531 | - reportDO.setOrderId(updateVO.getOrderId()); | |
532 | - reportDO.setOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); | |
533 | - reportService.updateById(reportDO); | |
534 | - } | |
621 | + checkApply(updateVO.getOrderId(), userId); | |
622 | + OrderFieldLockApplyDO orderFieldLockApplyDO = buildReportFieldLockApplyDO(updateVO.getReportInfo(), userId); | |
623 | + orderFieldLockApplyService.save(orderFieldLockApplyDO); | |
624 | + | |
625 | + orderBaseInfoDo.setOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); | |
626 | + updateById(orderBaseInfoDo); | |
535 | 627 | } |
536 | 628 | |
537 | 629 | if (Objects.nonNull(updateVO.getTrackStageInfo())) { |
... | ... | @@ -543,8 +635,14 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
543 | 635 | trackStageDO.setOrderId(updateVO.getOrderId()); |
544 | 636 | trackStageDO.setOrderStatus(OrderStatusEnum.TRACK_ING.getStatus()); |
545 | 637 | trackStageService.updateById(trackStageDO); |
638 | + } else { | |
639 | + BeanUtils.copyProperties(updateVO.getTrackStageInfo(), trackStageDO); | |
640 | + trackStageDO.setOrderId(updateVO.getOrderId()); | |
641 | + trackStageDO.setOrderStatus(OrderStatusEnum.TRACK_ING.getStatus()); | |
642 | + trackStageService.save(trackStageDO); | |
546 | 643 | } |
547 | - | |
644 | + orderBaseInfoDo.setOrderStatus(OrderStatusEnum.TRACK_ING.getStatus()); | |
645 | + updateById(orderBaseInfoDo); | |
548 | 646 | } |
549 | 647 | |
550 | 648 | if (Objects.nonNull(updateVO.getInspectionStageInfo())) { |
... | ... | @@ -556,8 +654,14 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
556 | 654 | inspectionStageDO.setOrderId(updateVO.getOrderId()); |
557 | 655 | inspectionStageDO.setOrderStatus(OrderStatusEnum.INSPECT_ING.getStatus()); |
558 | 656 | inspectionStageService.updateById(inspectionStageDO); |
657 | + } else { | |
658 | + BeanUtils.copyProperties(updateVO.getInspectionStageInfo(), inspectionStageDO); | |
659 | + inspectionStageDO.setOrderId(updateVO.getOrderId()); | |
660 | + inspectionStageDO.setOrderStatus(OrderStatusEnum.INSPECT_ING.getStatus()); | |
661 | + inspectionStageService.save(inspectionStageDO); | |
559 | 662 | } |
560 | - | |
663 | + orderBaseInfoDo.setOrderStatus(OrderStatusEnum.INSPECT_ING.getStatus()); | |
664 | + updateById(orderBaseInfoDo); | |
561 | 665 | } |
562 | 666 | |
563 | 667 | return ServerResult.success(); |
... | ... | @@ -619,13 +723,14 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
619 | 723 | |
620 | 724 | /** |
621 | 725 | * 根据订单状态统计订单数量 |
726 | + * | |
622 | 727 | * @param orderStatus |
623 | 728 | * @return |
624 | 729 | */ |
625 | 730 | @Override |
626 | 731 | public long countByOrderStatus(Integer orderStatus) { |
627 | - return this.count(new LambdaQueryWrapper<OrderBaseInfoDO>().eq(OrderBaseInfoDO::getOrderStatus,orderStatus) | |
628 | - .eq(OrderBaseInfoDO::getEnableFlag,Constant.ENABLE_TEN)); | |
732 | + return this.count(new LambdaQueryWrapper<OrderBaseInfoDO>().eq(OrderBaseInfoDO::getOrderStatus, orderStatus) | |
733 | + .eq(OrderBaseInfoDO::getEnableFlag, Constant.ENABLE_TEN)); | |
629 | 734 | } |
630 | 735 | |
631 | 736 | @Override |
... | ... | @@ -640,7 +745,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
640 | 745 | |
641 | 746 | @Override |
642 | 747 | public long countAll() { |
643 | - return this.count(new LambdaQueryWrapper<OrderBaseInfoDO>().eq(OrderBaseInfoDO::getEnableFlag,Constant.ENABLE_TEN)); | |
748 | + return this.count(new LambdaQueryWrapper<OrderBaseInfoDO>().eq(OrderBaseInfoDO::getEnableFlag, Constant.ENABLE_TEN)); | |
644 | 749 | } |
645 | 750 | |
646 | 751 | @Override | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderFieldLockApplyServiceImpl.java
... | ... | @@ -17,15 +17,12 @@ import com.order.erp.common.exception.BusinessException; |
17 | 17 | import com.order.erp.config.DataScope; |
18 | 18 | import com.order.erp.domain.ApplyStatusEnum; |
19 | 19 | import com.order.erp.domain.ApplyTypeEnum; |
20 | +import com.order.erp.domain.OrderStatusEnum; | |
20 | 21 | import com.order.erp.domain.dto.BaseDO; |
21 | -import com.order.erp.domain.dto.order.OrderAuditLogDO; | |
22 | -import com.order.erp.domain.dto.order.OrderFieldLockApplyDO; | |
23 | -import com.order.erp.domain.dto.order.OrderFieldLockRecordDO; | |
22 | +import com.order.erp.domain.dto.order.*; | |
24 | 23 | import com.order.erp.domain.vo.order.*; |
25 | 24 | import com.order.erp.mapper.order.OrderFieldLockApplyMapper; |
26 | -import com.order.erp.service.order.OrderAuditLogService; | |
27 | -import com.order.erp.service.order.OrderFieldLockApplyService; | |
28 | -import com.order.erp.service.order.OrderFieldLockRecordService; | |
25 | +import com.order.erp.service.order.*; | |
29 | 26 | import lombok.extern.slf4j.Slf4j; |
30 | 27 | import org.springframework.beans.BeanUtils; |
31 | 28 | import org.springframework.stereotype.Service; |
... | ... | @@ -58,6 +55,15 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
58 | 55 | @Resource |
59 | 56 | private OrderAuditLogService auditLogService; |
60 | 57 | |
58 | + @Resource | |
59 | + private OrderBaseInfoService orderBaseInfoService; | |
60 | + | |
61 | + @Resource | |
62 | + private OrderCompletionReportService reportService; | |
63 | + | |
64 | + @Resource | |
65 | + private OrderProfitAnalysisService profitAnalysisService; | |
66 | + | |
61 | 67 | /** |
62 | 68 | * 通过ID查询单条数据 |
63 | 69 | * <p> |
... | ... | @@ -166,7 +172,18 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
166 | 172 | public void doRefuse(OrderFieldLockApplyDO applyDO, Long auditUserId) { |
167 | 173 | applyDO.setAuditUserId(auditUserId); |
168 | 174 | applyDO.setStatus(ApplyStatusEnum.AUDIT_REFUSE.getStatus()); |
175 | + OrderBaseInfoDO orderBaseInfoDO = orderBaseInfoService.getById(applyDO.getOrderId()); | |
176 | + if (Objects.isNull(orderBaseInfoDO)) { | |
177 | + throw new BusinessException(ServerResultCode.ORDER_BASE_INFO_EMPTY); | |
178 | + } | |
179 | + if (ApplyTypeEnum.ORDER_REPORT_APPLY.getType().equals(applyDO.getType())) { | |
169 | 180 | |
181 | + orderBaseInfoDO.setOrderStatus(OrderStatusEnum.REPORT_AUDIT_REFUSE.getStatus()); | |
182 | + orderBaseInfoService.updateById(orderBaseInfoDO); | |
183 | + } else if (ApplyTypeEnum.ORDER_PROFIT_APPLY.getType().equals(applyDO.getType())) { | |
184 | + orderBaseInfoDO.setOrderStatus(OrderStatusEnum.PROFIT_AUDIT_REFUSE.getStatus()); | |
185 | + orderBaseInfoService.updateById(orderBaseInfoDO); | |
186 | + } | |
170 | 187 | OrderAuditLogDO auditLogDO = OrderAuditLogDO.builder().applyId(applyDO.getId()).orderId(applyDO.getOrderId()).optType(ApplyStatusEnum.AUDIT_REFUSE.getDesc()).build(); |
171 | 188 | |
172 | 189 | applyService.updateById(applyDO); |
... | ... | @@ -179,12 +196,12 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
179 | 196 | */ |
180 | 197 | @Transactional(rollbackFor = Exception.class) |
181 | 198 | public void doPass(OrderFieldLockApplyDO applyDO, Long auditUserId) { |
182 | - OrderFieldLockRecordDO recordDO = null; | |
199 | + | |
183 | 200 | if (ApplyTypeEnum.FIELD_EDIT_APPLY.getType().equals(applyDO.getType())) { |
184 | 201 | applyDO.setAuditUserId(auditUserId); |
185 | 202 | applyDO.setStatus(ApplyStatusEnum.AUDIT_PASS.getStatus()); |
186 | 203 | |
187 | - recordDO = fieldLockRecordService.getOne(new LambdaQueryWrapper<OrderFieldLockRecordDO>() | |
204 | + OrderFieldLockRecordDO recordDO = fieldLockRecordService.getOne(new LambdaQueryWrapper<OrderFieldLockRecordDO>() | |
188 | 205 | .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) |
189 | 206 | .eq(OrderFieldLockRecordDO::getOrderId, applyDO.getOrderId()) |
190 | 207 | .eq(OrderFieldLockRecordDO::getUserId, applyDO.getApplyUserId())); |
... | ... | @@ -195,22 +212,112 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
195 | 212 | .fields(applyDO.getFields()).build(); |
196 | 213 | } |
197 | 214 | recordDO.setFields(applyDO.getFields()); |
215 | + | |
216 | + if (Objects.isNull(recordDO.getId())) { | |
217 | + fieldLockRecordService.save(recordDO); | |
218 | + } else { | |
219 | + fieldLockRecordService.updateById(recordDO); | |
220 | + } | |
221 | + } else if (ApplyTypeEnum.ORDER_REPORT_APPLY.getType().equals(applyDO.getType())) { | |
222 | + applyDO.setAuditUserId(auditUserId); | |
223 | + applyDO.setStatus(ApplyStatusEnum.AUDIT_PASS.getStatus()); | |
224 | + | |
225 | + OrderCompletionReportFieldVO reportFieldVO = JSONObject.parseObject(applyDO.getFields(), OrderCompletionReportFieldVO.class); | |
226 | + | |
227 | + OrderBaseInfoDO orderBaseInfoDO = orderBaseInfoService.getById(applyDO.getOrderId()); | |
228 | + if (Objects.isNull(orderBaseInfoDO)) { | |
229 | + throw new BusinessException(ServerResultCode.ORDER_BASE_INFO_EMPTY); | |
230 | + } | |
231 | + | |
232 | + OrderCompletionReportDO reportDO = reportService.getOne(new LambdaQueryWrapper<OrderCompletionReportDO>() | |
233 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
234 | + .eq(OrderCompletionReportDO::getOrderId, applyDO.getOrderId())); | |
235 | + if (Objects.isNull(reportDO)) { | |
236 | + reportDO = reportField2reportDo(reportFieldVO); | |
237 | + reportDO.setOrderStatus(OrderStatusEnum.REPORT_AUDIT_PASS.getStatus()); | |
238 | + reportService.save(reportDO); | |
239 | + } else { | |
240 | + reportDO.setOrderStatus(OrderStatusEnum.REPORT_AUDIT_PASS.getStatus()); | |
241 | + reportDO.setIdeaManualRate(Objects.nonNull(reportFieldVO.getIdeaManualRate()) ? Double.valueOf(reportFieldVO.getIdeaManualRate()) : null); | |
242 | + reportDO.setIdeaSource(reportFieldVO.getIdeaSource()); | |
243 | + reportDO.setManualPreform(reportFieldVO.getManualPreform()); | |
244 | + reportService.updateById(reportDO); | |
245 | + } | |
246 | + orderBaseInfoDO.setOrderStatus(OrderStatusEnum.REPORT_AUDIT_PASS.getStatus()); | |
247 | + orderBaseInfoService.updateById(orderBaseInfoDO); | |
248 | + } else if (ApplyTypeEnum.ORDER_PROFIT_APPLY.getType().equals(applyDO.getType())) { | |
249 | + applyDO.setAuditUserId(auditUserId); | |
250 | + applyDO.setStatus(ApplyStatusEnum.AUDIT_PASS.getStatus()); | |
251 | + | |
252 | + OrderProfitAnalysisFieldVO profitAnalysisFieldVO = JSONObject.parseObject(applyDO.getFields(), OrderProfitAnalysisFieldVO.class); | |
253 | + | |
254 | + OrderBaseInfoDO orderBaseInfoDO = orderBaseInfoService.getById(applyDO.getOrderId()); | |
255 | + if (Objects.isNull(orderBaseInfoDO)) { | |
256 | + throw new BusinessException(ServerResultCode.ORDER_BASE_INFO_EMPTY); | |
257 | + } | |
258 | + | |
259 | + OrderProfitAnalysisDO profitAnalysisDO = profitAnalysisService.getOne(new LambdaQueryWrapper<OrderProfitAnalysisDO>() | |
260 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
261 | + .eq(OrderProfitAnalysisDO::getOrderId, applyDO.getOrderId())); | |
262 | + if (Objects.isNull(profitAnalysisDO)) { | |
263 | + profitAnalysisDO = profitField2profitDo(profitAnalysisFieldVO); | |
264 | + profitAnalysisDO.setOrderStatus(OrderStatusEnum.PROFIT_AUDIT_PASS.getStatus()); | |
265 | + profitAnalysisService.save(profitAnalysisDO); | |
266 | + } else { | |
267 | + profitAnalysisDO.setOrderStatus(OrderStatusEnum.PROFIT_AUDIT_PASS.getStatus()); | |
268 | + profitAnalysisDO.setCustomerPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerPrice()) : null); | |
269 | + profitAnalysisDO.setCustomerTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerTotalPrice()) : null); | |
270 | + profitAnalysisDO.setExchangeRate(Objects.nonNull(profitAnalysisFieldVO.getExchangeRate()) ? Double.valueOf(profitAnalysisFieldVO.getExchangeRate()) : null); | |
271 | + profitAnalysisDO.setPacketPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketPrice()) : null); | |
272 | + profitAnalysisDO.setPacketTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketTotalPrice()) : null); | |
273 | + profitAnalysisDO.setProductionDepartmentPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentPrice()) : null); | |
274 | + profitAnalysisDO.setProductionDepartmentTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) : null); | |
275 | + profitAnalysisDO.setProfitRate(Objects.nonNull(profitAnalysisFieldVO.getProfitRate()) ? Double.valueOf(profitAnalysisFieldVO.getProfitRate()) : null); | |
276 | + profitAnalysisService.updateById(profitAnalysisDO); | |
277 | + } | |
278 | + orderBaseInfoDO.setOrderStatus(OrderStatusEnum.PROFIT_AUDIT_PASS.getStatus()); | |
279 | + orderBaseInfoService.updateById(orderBaseInfoDO); | |
198 | 280 | } |
199 | 281 | |
200 | 282 | OrderAuditLogDO auditLogDO = OrderAuditLogDO.builder().applyId(applyDO.getId()).orderId(applyDO.getOrderId()).optType(ApplyStatusEnum.AUDIT_PASS.getDesc()).build(); |
201 | 283 | |
202 | 284 | applyService.updateById(applyDO); |
203 | 285 | |
204 | - if (Objects.isNull(recordDO.getId())) { | |
205 | - fieldLockRecordService.save(recordDO); | |
206 | - } else { | |
207 | - fieldLockRecordService.updateById(recordDO); | |
208 | - } | |
209 | - | |
210 | 286 | auditLogService.save(auditLogDO); |
211 | 287 | } |
212 | 288 | |
213 | 289 | /** |
290 | + * @param reportFieldVO | |
291 | + * @return | |
292 | + */ | |
293 | + private OrderCompletionReportDO reportField2reportDo(OrderCompletionReportFieldVO reportFieldVO) { | |
294 | + return OrderCompletionReportDO.builder() | |
295 | + .ideaManualRate(StringUtils.isNotBlank(reportFieldVO.getIdeaManualRate()) ? Double.valueOf(reportFieldVO.getIdeaManualRate()) : null) | |
296 | + .ideaSource(reportFieldVO.getIdeaSource()) | |
297 | + .manualPreform(reportFieldVO.getManualPreform()) | |
298 | + .orderId(reportFieldVO.getOrderId()) | |
299 | + .build(); | |
300 | + } | |
301 | + | |
302 | + /** | |
303 | + * @param profitAnalysisFieldVO | |
304 | + * @return | |
305 | + */ | |
306 | + private OrderProfitAnalysisDO profitField2profitDo(OrderProfitAnalysisFieldVO profitAnalysisFieldVO) { | |
307 | + return OrderProfitAnalysisDO.builder() | |
308 | + .orderId(profitAnalysisFieldVO.getOrderId()) | |
309 | + .customerPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerPrice()) : null) | |
310 | + .customerTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerTotalPrice()) : null) | |
311 | + .exchangeRate(Objects.nonNull(profitAnalysisFieldVO.getExchangeRate()) ? Double.valueOf(profitAnalysisFieldVO.getExchangeRate()) : null) | |
312 | + .packetPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketPrice()) : null) | |
313 | + .packetTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketTotalPrice()) : null) | |
314 | + .productionDepartmentPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentPrice()) : null) | |
315 | + .productionDepartmentTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) : null) | |
316 | + .profitRate(Objects.nonNull(profitAnalysisFieldVO.getProfitRate()) ? Double.valueOf(profitAnalysisFieldVO.getProfitRate()) : null) | |
317 | + .build(); | |
318 | + } | |
319 | + | |
320 | + /** | |
214 | 321 | * 修改数据 |
215 | 322 | * |
216 | 323 | * @param orderFieldLockApplyVO 实例对象 |
... | ... | @@ -255,6 +362,7 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
255 | 362 | |
256 | 363 | /** |
257 | 364 | * 通过订单id逻辑删除 |
365 | + * | |
258 | 366 | * @param orderId |
259 | 367 | * @return |
260 | 368 | */ | ... | ... |