|
@@ -11,6 +11,7 @@ import com.lframework.starter.common.utils.StringUtil; |
|
@@ -11,6 +11,7 @@ import com.lframework.starter.common.utils.StringUtil; |
|
11
|
import com.lframework.starter.web.core.components.redis.RedisHandler;
|
11
|
import com.lframework.starter.web.core.components.redis.RedisHandler;
|
|
12
|
import com.lframework.starter.web.core.components.security.SecurityUtil;
|
12
|
import com.lframework.starter.web.core.components.security.SecurityUtil;
|
|
13
|
import com.lframework.starter.web.core.utils.*;
|
13
|
import com.lframework.starter.web.core.utils.*;
|
|
|
|
14
|
+import com.lframework.starter.web.inner.entity.SysDataDicItem;
|
|
14
|
import com.lframework.starter.web.inner.entity.SysDept;
|
15
|
import com.lframework.starter.web.inner.entity.SysDept;
|
|
15
|
import com.lframework.starter.web.inner.entity.SysUserDept;
|
16
|
import com.lframework.starter.web.inner.entity.SysUserDept;
|
|
16
|
import com.lframework.starter.web.inner.service.system.SysDeptService;
|
17
|
import com.lframework.starter.web.inner.service.system.SysDeptService;
|
|
@@ -19,8 +20,7 @@ import com.lframework.starter.web.inner.service.system.SysUserService; |
|
@@ -19,8 +20,7 @@ import com.lframework.starter.web.inner.service.system.SysUserService; |
|
19
|
import com.lframework.xingyun.basedata.entity.Workshop;
|
20
|
import com.lframework.xingyun.basedata.entity.Workshop;
|
|
20
|
import com.lframework.xingyun.basedata.service.customer.CustomerService;
|
21
|
import com.lframework.xingyun.basedata.service.customer.CustomerService;
|
|
21
|
import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
|
22
|
import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
|
|
22
|
-import com.lframework.xingyun.sc.entity.CustomerCredit;
|
|
|
|
23
|
-import com.lframework.xingyun.sc.entity.OrderInfoChangeRecord;
|
23
|
+import com.lframework.xingyun.sc.entity.*;
|
|
24
|
import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
|
24
|
import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
|
|
25
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
25
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
|
26
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
26
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
|
@@ -28,17 +28,20 @@ import com.lframework.starter.common.utils.ObjectUtil; |
|
@@ -28,17 +28,20 @@ import com.lframework.starter.common.utils.ObjectUtil; |
|
28
|
import com.lframework.starter.web.core.annotations.oplog.OpLog;
|
28
|
import com.lframework.starter.web.core.annotations.oplog.OpLog;
|
|
29
|
import com.lframework.starter.common.utils.Assert;
|
29
|
import com.lframework.starter.common.utils.Assert;
|
|
30
|
import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
|
30
|
import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
|
|
31
|
-import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
|
|
|
|
32
|
-import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
|
|
|
|
33
|
import com.lframework.xingyun.sc.enums.OrderSpecChangeStatus;
|
31
|
import com.lframework.xingyun.sc.enums.OrderSpecChangeStatus;
|
|
34
|
import com.lframework.xingyun.sc.handlers.MessageHandler;
|
32
|
import com.lframework.xingyun.sc.handlers.MessageHandler;
|
|
35
|
import com.lframework.xingyun.sc.handlers.TransactorHandler;
|
33
|
import com.lframework.xingyun.sc.handlers.TransactorHandler;
|
|
|
|
34
|
+import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
|
|
36
|
import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
|
35
|
import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
|
|
37
|
import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
|
36
|
import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
|
|
38
|
import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
|
37
|
import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
|
|
|
|
38
|
+import com.lframework.xingyun.sc.service.statistics.OrderDetailReportService;
|
|
39
|
import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderLineVo;
|
39
|
import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderLineVo;
|
|
40
|
import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderInfoVo;
|
40
|
import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderInfoVo;
|
|
|
|
41
|
+import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo;
|
|
41
|
import com.lframework.xingyun.sc.vo.order.change.*;
|
42
|
import com.lframework.xingyun.sc.vo.order.change.*;
|
|
|
|
43
|
+import com.lframework.xingyun.sc.vo.statistics.orderDetail.CreateOrderDetailReportVo;
|
|
|
|
44
|
+import com.lframework.xingyun.sc.vo.statistics.orderDetail.QueryOrderDetailReportVo;
|
|
42
|
import org.apache.commons.collections4.CollectionUtils;
|
45
|
import org.apache.commons.collections4.CollectionUtils;
|
|
43
|
import org.apache.commons.lang3.BooleanUtils;
|
46
|
import org.apache.commons.lang3.BooleanUtils;
|
|
44
|
import org.apache.commons.lang3.StringUtils;
|
47
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -49,6 +52,7 @@ import org.springframework.stereotype.Service; |
|
@@ -49,6 +52,7 @@ import org.springframework.stereotype.Service; |
|
49
|
|
52
|
|
|
50
|
import javax.annotation.Resource;
|
53
|
import javax.annotation.Resource;
|
|
51
|
import java.math.BigDecimal;
|
54
|
import java.math.BigDecimal;
|
|
|
|
55
|
+import java.math.RoundingMode;
|
|
52
|
import java.util.*;
|
56
|
import java.util.*;
|
|
53
|
import java.util.stream.Collectors;
|
57
|
import java.util.stream.Collectors;
|
|
54
|
|
58
|
|
|
@@ -85,6 +89,10 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
|
@@ -85,6 +89,10 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
|
85
|
private SysUserDeptService sysUserDeptService;
|
89
|
private SysUserDeptService sysUserDeptService;
|
|
86
|
@Resource
|
90
|
@Resource
|
|
87
|
private SysDeptService sysDeptService;
|
91
|
private SysDeptService sysDeptService;
|
|
|
|
92
|
+ @Resource
|
|
|
|
93
|
+ private OrderDetailReportService orderDetailReportService;
|
|
|
|
94
|
+ @Resource
|
|
|
|
95
|
+ private ContractDistributorStandardService contractDistributorStandardService;
|
|
88
|
|
96
|
|
|
89
|
|
97
|
|
|
90
|
@Override
|
98
|
@Override
|
|
@@ -377,6 +385,30 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
|
@@ -377,6 +385,30 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
|
377
|
if (record.getAfterTotalQuantity() != null) {
|
385
|
if (record.getAfterTotalQuantity() != null) {
|
|
378
|
orderInfo.setTotalQuantity(new BigDecimal(record.getAfterTotalQuantity()));
|
386
|
orderInfo.setTotalQuantity(new BigDecimal(record.getAfterTotalQuantity()));
|
|
379
|
}
|
387
|
}
|
|
|
|
388
|
+ //新增订单明细报表
|
|
|
|
389
|
+ QueryOrderDetailReportVo vo = new QueryOrderDetailReportVo();
|
|
|
|
390
|
+ vo.setShowOrder(0);
|
|
|
|
391
|
+ vo.setOrderNoPrecise(record.getOrderNo());
|
|
|
|
392
|
+ vo.setType("PRODUCTION");
|
|
|
|
393
|
+ List<OrderDetailReport> query = orderDetailReportService.query(vo);
|
|
|
|
394
|
+ OrderDetailReport orderDetailReport = query.get(0);
|
|
|
|
395
|
+ //先全部冲红
|
|
|
|
396
|
+ QueryPurchaseOrderLineVo vo1 = new QueryPurchaseOrderLineVo();
|
|
|
|
397
|
+ vo1.setPurchaseOrderId(record.getOrderId());
|
|
|
|
398
|
+ List<PurchaseOrderLine> purchaseOrderLineList = purchaseOrderLineService.query(vo1);
|
|
|
|
399
|
+ PurchaseOrderInfo purchaseOrderInfo = purchaseOrderInfoService.findById(record.getOrderId());
|
|
|
|
400
|
+ ContractDistributorStandard standard = contractDistributorStandardService.findById(purchaseOrderInfo.getContractId());
|
|
|
|
401
|
+ if (CollectionUtils.isNotEmpty(purchaseOrderLineList)) {
|
|
|
|
402
|
+ for (PurchaseOrderLine line : purchaseOrderLineList) {
|
|
|
|
403
|
+ createOrderDetailReport(line, orderDetailReport, purchaseOrderInfo, standard,"offset");
|
|
|
|
404
|
+ }
|
|
|
|
405
|
+ }
|
|
|
|
406
|
+ List<PurchaseOrderLine> afterChangeSpecList = record.getAfterChangeSpecList();
|
|
|
|
407
|
+ if (CollectionUtils.isNotEmpty(afterChangeSpecList)) {
|
|
|
|
408
|
+ for (PurchaseOrderLine line : afterChangeSpecList) {
|
|
|
|
409
|
+ createOrderDetailReport(line, orderDetailReport, orderInfo, standard, null);
|
|
|
|
410
|
+ }
|
|
|
|
411
|
+ }
|
|
380
|
purchaseOrderInfoService.update(orderInfo);
|
412
|
purchaseOrderInfoService.update(orderInfo);
|
|
381
|
// 更新订货单物料行数据
|
413
|
// 更新订货单物料行数据
|
|
382
|
purchaseOrderLineService.update(record.getOrderId(), record.getAfterChangeSpecList());
|
414
|
purchaseOrderLineService.update(record.getOrderId(), record.getAfterChangeSpecList());
|
|
@@ -471,4 +503,82 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
|
@@ -471,4 +503,82 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR |
|
471
|
}
|
503
|
}
|
|
472
|
}
|
504
|
}
|
|
473
|
}
|
505
|
}
|
|
|
|
506
|
+
|
|
|
|
507
|
+ private void createOrderDetailReport(PurchaseOrderLine line, OrderDetailReport orderDetailReport,
|
|
|
|
508
|
+ PurchaseOrderInfo orderInfo, ContractDistributorStandard standard, String type1) {
|
|
|
|
509
|
+ CreateOrderDetailReportVo vo = new CreateOrderDetailReportVo();
|
|
|
|
510
|
+ if ("offset".equals(type1)) {
|
|
|
|
511
|
+ vo.setPurchaseOrderLineId(line.getId());
|
|
|
|
512
|
+ } else {
|
|
|
|
513
|
+ if (StringUtils.isNotEmpty(line.getAfterId())) {
|
|
|
|
514
|
+ vo.setPurchaseOrderLineId(line.getAfterId());
|
|
|
|
515
|
+ } else {
|
|
|
|
516
|
+ vo.setPurchaseOrderLineId(line.getId());
|
|
|
|
517
|
+ }
|
|
|
|
518
|
+ }
|
|
|
|
519
|
+ vo.setOrderNo(orderDetailReport.getOrderNo());
|
|
|
|
520
|
+ vo.setOrderDate(orderDetailReport.getOrderDate());
|
|
|
|
521
|
+ vo.setWorkshopId(orderDetailReport.getWorkshopId());
|
|
|
|
522
|
+ vo.setDeptName(orderDetailReport.getDeptName());
|
|
|
|
523
|
+ vo.setRegionName(orderDetailReport.getRegionName());
|
|
|
|
524
|
+ vo.setOrderingUnitName(orderDetailReport.getOrderingUnitName());
|
|
|
|
525
|
+ vo.setIndustry(line.getIndustry());
|
|
|
|
526
|
+ vo.setBrand(line.getBrand());
|
|
|
|
527
|
+ vo.setThickness(line.getThickness());
|
|
|
|
528
|
+ vo.setThicknessTolPos(line.getThicknessTolPos());
|
|
|
|
529
|
+ vo.setThicknessTolNeg(line.getThicknessTolNeg());
|
|
|
|
530
|
+ vo.setWidth(line.getWidth());
|
|
|
|
531
|
+ vo.setWidthTolPos(line.getWidthTolPos());
|
|
|
|
532
|
+ vo.setWidthTolNeg(line.getWidthTolNeg());
|
|
|
|
533
|
+ vo.setLength(line.getLength());
|
|
|
|
534
|
+ vo.setLengthTolPos(line.getLengthTolPos());
|
|
|
|
535
|
+ vo.setLengthTolNeg(line.getLengthTolNeg());
|
|
|
|
536
|
+ vo.setStatus(line.getStatus());
|
|
|
|
537
|
+ vo.setQuantity(line.getQuantity());
|
|
|
|
538
|
+ String assessmentExceedsAgreement;
|
|
|
|
539
|
+ BigDecimal salesPrice = line.getSalesPrice();
|
|
|
|
540
|
+ if (line.getSalesPrice() != null && StringUtils.isNotEmpty(line.getAssessmentExceedsAgreement())) {
|
|
|
|
541
|
+ assessmentExceedsAgreement = line.getAssessmentExceedsAgreement().trim();
|
|
|
|
542
|
+ try {
|
|
|
|
543
|
+ BigDecimal exceedsAgreement = new BigDecimal(assessmentExceedsAgreement);
|
|
|
|
544
|
+ BigDecimal divisor = new BigDecimal("1000");
|
|
|
|
545
|
+ BigDecimal adjustment = exceedsAgreement.divide(divisor, 4, RoundingMode.HALF_UP); // 保留4位小数
|
|
|
|
546
|
+ BigDecimal subtract = salesPrice.subtract(adjustment);
|
|
|
|
547
|
+ vo.setSuggestedPrice(subtract.toPlainString());
|
|
|
|
548
|
+ } catch (NumberFormatException e) {
|
|
|
|
549
|
+ // 日志记录或按业务处理:超协价格式无效,忽略计算
|
|
|
|
550
|
+ log.error("超协价格式错误,使用原始销售价。value=" + assessmentExceedsAgreement);
|
|
|
|
551
|
+ }
|
|
|
|
552
|
+ }
|
|
|
|
553
|
+ vo.setDeliveryDate(line.getDeliveryDate());
|
|
|
|
554
|
+ vo.setAssessmentExceedsAgreement(line.getAssessmentExceedsAgreement());
|
|
|
|
555
|
+ if (line.getSalesPrice() != null) {
|
|
|
|
556
|
+ vo.setSalesPrice(line.getSalesPrice().toPlainString());
|
|
|
|
557
|
+ }
|
|
|
|
558
|
+ vo.setPriceListNo(orderInfo.getPriceListNo());
|
|
|
|
559
|
+ if (line.getPackagingFee() != null) {
|
|
|
|
560
|
+ vo.setPackagingFee(line.getPackagingFee().toPlainString());
|
|
|
|
561
|
+ }
|
|
|
|
562
|
+ vo.setInvoicingStatus(orderInfo.getInvoicingStatus());
|
|
|
|
563
|
+ vo.setPieceWeightHeader(orderInfo.getPieceWeightHeader());
|
|
|
|
564
|
+ vo.setSurface(orderInfo.getSurface());
|
|
|
|
565
|
+ vo.setTolerance(orderInfo.getTolerance());
|
|
|
|
566
|
+ vo.setPerformance(orderInfo.getPerformance());
|
|
|
|
567
|
+ vo.setPackaging(orderInfo.getPackaging());
|
|
|
|
568
|
+ vo.setRemarks(orderInfo.getRemarks());
|
|
|
|
569
|
+ //加工合同就是回程运费
|
|
|
|
570
|
+ String type = standard.getType();
|
|
|
|
571
|
+ if ("PROCESS_STD_AGMT".equals(type)) {
|
|
|
|
572
|
+ vo.setReturnShippingCost(orderInfo.getShippingCost());
|
|
|
|
573
|
+ } else {
|
|
|
|
574
|
+ vo.setShippingCost(orderInfo.getShippingCost());
|
|
|
|
575
|
+ }
|
|
|
|
576
|
+ vo.setCustomerType(orderDetailReport.getCustomerType());
|
|
|
|
577
|
+ vo.setQuality(line.getQuality());
|
|
|
|
578
|
+ vo.setContractType(orderDetailReport.getContractType());
|
|
|
|
579
|
+ vo.setStockUpCompanyName(orderInfo.getStockUpCompanyName());
|
|
|
|
580
|
+ //vo.setOrderType();
|
|
|
|
581
|
+ vo.setShowOrder(2);
|
|
|
|
582
|
+ orderDetailReportService.create(vo);
|
|
|
|
583
|
+ }
|
|
474
|
} |
584
|
} |