Showing
1 changed file
with
140 additions
and
5 deletions
| @@ -24,11 +24,13 @@ import com.lframework.starter.web.core.components.resp.PageResult; | @@ -24,11 +24,13 @@ import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 24 | import com.lframework.starter.common.utils.ObjectUtil; | 24 | import com.lframework.starter.common.utils.ObjectUtil; |
| 25 | import com.lframework.starter.common.utils.Assert; | 25 | import com.lframework.starter.common.utils.Assert; |
| 26 | import com.lframework.xingyun.sc.entity.ContractStdProcessingLine; | 26 | import com.lframework.xingyun.sc.entity.ContractStdProcessingLine; |
| 27 | +import com.lframework.xingyun.sc.entity.PurchaseOrderInfo; | ||
| 27 | import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; | 28 | import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; |
| 28 | import com.lframework.xingyun.sc.mappers.ContractDistributorStandardMapper; | 29 | import com.lframework.xingyun.sc.mappers.ContractDistributorStandardMapper; |
| 29 | import com.lframework.xingyun.sc.service.contract.ContractDistributorLineService; | 30 | import com.lframework.xingyun.sc.service.contract.ContractDistributorLineService; |
| 30 | import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService; | 31 | import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService; |
| 31 | import com.lframework.xingyun.sc.service.contract.ContractStdProcessingLineService; | 32 | import com.lframework.xingyun.sc.service.contract.ContractStdProcessingLineService; |
| 33 | +import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService; | ||
| 32 | import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractDistributorLineVo; | 34 | import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractDistributorLineVo; |
| 33 | import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractDistributorStandardVo; | 35 | import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractDistributorStandardVo; |
| 34 | import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractStdProcessingLineVo; | 36 | import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractStdProcessingLineVo; |
| @@ -36,9 +38,11 @@ import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractDistributorSta | @@ -36,9 +38,11 @@ import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractDistributorSta | ||
| 36 | import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractDistributorLineVo; | 38 | import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractDistributorLineVo; |
| 37 | import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractDistributorStandardVo; | 39 | import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractDistributorStandardVo; |
| 38 | import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractStdProcessingLineVo; | 40 | import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractStdProcessingLineVo; |
| 41 | +import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderInfoVo; | ||
| 42 | +import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderLineVo; | ||
| 43 | +import lombok.extern.slf4j.Slf4j; | ||
| 39 | import org.apache.commons.collections4.CollectionUtils; | 44 | import org.apache.commons.collections4.CollectionUtils; |
| 40 | import org.apache.commons.lang3.StringUtils; | 45 | import org.apache.commons.lang3.StringUtils; |
| 41 | -import org.apache.ibatis.annotations.Param; | ||
| 42 | import org.springframework.beans.factory.annotation.Autowired; | 46 | import org.springframework.beans.factory.annotation.Autowired; |
| 43 | import org.springframework.cache.annotation.CacheEvict; | 47 | import org.springframework.cache.annotation.CacheEvict; |
| 44 | import org.springframework.cache.annotation.Cacheable; | 48 | import org.springframework.cache.annotation.Cacheable; |
| @@ -50,14 +54,12 @@ import java.io.Serializable; | @@ -50,14 +54,12 @@ import java.io.Serializable; | ||
| 50 | import java.math.BigDecimal; | 54 | import java.math.BigDecimal; |
| 51 | import java.time.LocalDate; | 55 | import java.time.LocalDate; |
| 52 | import java.time.LocalDateTime; | 56 | import java.time.LocalDateTime; |
| 53 | -import java.util.ArrayList; | ||
| 54 | -import java.util.List; | ||
| 55 | -import java.util.Map; | ||
| 56 | -import java.util.Set; | 57 | +import java.util.*; |
| 57 | import java.util.function.Function; | 58 | import java.util.function.Function; |
| 58 | import java.util.stream.Collectors; | 59 | import java.util.stream.Collectors; |
| 59 | 60 | ||
| 60 | @Service | 61 | @Service |
| 62 | +@Slf4j | ||
| 61 | public class ContractDistributorStandardServiceImpl extends | 63 | public class ContractDistributorStandardServiceImpl extends |
| 62 | BaseMpServiceImpl<ContractDistributorStandardMapper, ContractDistributorStandard> implements ContractDistributorStandardService { | 64 | BaseMpServiceImpl<ContractDistributorStandardMapper, ContractDistributorStandard> implements ContractDistributorStandardService { |
| 63 | 65 | ||
| @@ -72,6 +74,8 @@ public class ContractDistributorStandardServiceImpl extends | @@ -72,6 +74,8 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 72 | private FlowTaskWrapperMapper flowTaskWrapperMapper; | 74 | private FlowTaskWrapperMapper flowTaskWrapperMapper; |
| 73 | @Resource | 75 | @Resource |
| 74 | private ContractStdProcessingLineService contractStdProcessingLineService; | 76 | private ContractStdProcessingLineService contractStdProcessingLineService; |
| 77 | + @Resource | ||
| 78 | + private PurchaseOrderInfoService purchaseOrderInfoService; | ||
| 75 | 79 | ||
| 76 | 80 | ||
| 77 | @Override | 81 | @Override |
| @@ -465,6 +469,134 @@ public class ContractDistributorStandardServiceImpl extends | @@ -465,6 +469,134 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 465 | 469 | ||
| 466 | // 开启审核 | 470 | // 开启审核 |
| 467 | flowInstanceWrapperService.startInstance(FORMAL_FLAG, data.getId(), FORMAL_FLAG, data); | 471 | flowInstanceWrapperService.startInstance(FORMAL_FLAG, data.getId(), FORMAL_FLAG, data); |
| 472 | + | ||
| 473 | + // 创建订货单 | ||
| 474 | + createPurchaseOrderInfo(data, "formal"); | ||
| 475 | + } | ||
| 476 | + | ||
| 477 | + /** | ||
| 478 | + * 创建订货单 | ||
| 479 | + * | ||
| 480 | + * @param contractDistributorStandard | ||
| 481 | + */ | ||
| 482 | + private void createPurchaseOrderInfo(ContractDistributorStandard contractDistributorStandard, String uploadFrom) { | ||
| 483 | + Wrapper<PurchaseOrderInfo> orderInfoWrapper = Wrappers.lambdaQuery(PurchaseOrderInfo.class) | ||
| 484 | + .eq(PurchaseOrderInfo::getContractId, contractDistributorStandard.getId()); | ||
| 485 | + List<PurchaseOrderInfo> purchaseOrderInfoList = purchaseOrderInfoService.list(orderInfoWrapper); | ||
| 486 | + log.info("合同类型:{},合同已生成订货单数量:{}", contractDistributorStandard.getType(), CollectionUtils.isEmpty(purchaseOrderInfoList) ? 0 : purchaseOrderInfoList.size()); | ||
| 487 | + if (Arrays.asList("DISTRIB_STD", "DRAFT_DIST_AGMT", "INTL_STD_CONTRACT", "INTL_OPEN_SPEC_AGMT", "PROCESS_STD_AGMT").contains(contractDistributorStandard.getType()) | ||
| 488 | + && CollectionUtils.isNotEmpty(purchaseOrderInfoList)) { | ||
| 489 | + log.info("已经生成过发货单了,不允许继续生成!"); | ||
| 490 | + return; | ||
| 491 | + } | ||
| 492 | + | ||
| 493 | + if (Arrays.asList("DIST_STOCK_CONTRACT", "INTL_INVENTORY_AGMT").contains(contractDistributorStandard.getType()) | ||
| 494 | + && "formal".equals(uploadFrom) | ||
| 495 | + && CollectionUtils.isNotEmpty(purchaseOrderInfoList)) { | ||
| 496 | + log.info("已经生成过发货单了,不允许继续生成!"); | ||
| 497 | + return; | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + if (Arrays.asList("DIST_STOCK_CONTRACT", "INTL_INVENTORY_AGMT").contains(contractDistributorStandard.getType()) | ||
| 501 | + && "standard".equals(uploadFrom) | ||
| 502 | + && CollectionUtils.isNotEmpty(purchaseOrderInfoList) && purchaseOrderInfoList.size() >= 2) { | ||
| 503 | + log.info("已经生成过发货单了,不允许继续生成!"); | ||
| 504 | + return; | ||
| 505 | + } | ||
| 506 | + | ||
| 507 | + Wrapper<ContractDistributorLine> lineWrapper = Wrappers.lambdaQuery(ContractDistributorLine.class) | ||
| 508 | + .eq(ContractDistributorLine::getContractId, contractDistributorStandard.getId()) | ||
| 509 | + .orderByAsc(ContractDistributorLine::getShowOrder); | ||
| 510 | + List<ContractDistributorLine> contractDistributorLineList = contractDistributorLineService.list(lineWrapper); | ||
| 511 | + | ||
| 512 | + Wrapper<ContractStdProcessingLine> stdLineWrapper = Wrappers.lambdaQuery(ContractStdProcessingLine.class) | ||
| 513 | + .eq(ContractStdProcessingLine::getContractId, contractDistributorStandard.getId()) | ||
| 514 | + .orderByAsc(ContractStdProcessingLine::getShowOrder); | ||
| 515 | + List<ContractStdProcessingLine> contractStdProcessingLineList = contractStdProcessingLineService.list(stdLineWrapper); | ||
| 516 | + | ||
| 517 | + CreatePurchaseOrderInfoVo createPurchaseOrderInfoVo = new CreatePurchaseOrderInfoVo(); | ||
| 518 | + createPurchaseOrderInfoVo.setContractId(contractDistributorStandard.getId()); | ||
| 519 | + createPurchaseOrderInfoVo.setOrderNo(contractDistributorStandard.getCode()); | ||
| 520 | + createPurchaseOrderInfoVo.setSupplyUnit(contractDistributorStandard.getSupplier()); | ||
| 521 | + createPurchaseOrderInfoVo.setOrderingUnit(contractDistributorStandard.getBuyer()); | ||
| 522 | + createPurchaseOrderInfoVo.setOrderDate(contractDistributorStandard.getOrderDate()); | ||
| 523 | + createPurchaseOrderInfoVo.setSettlementTerms(contractDistributorStandard.getPaymentTerms()); | ||
| 524 | + createPurchaseOrderInfoVo.setDeliveryMethod(contractDistributorStandard.getTransportMode()); | ||
| 525 | + createPurchaseOrderInfoVo.setTotalQuantity(contractDistributorStandard.getTotalQuantity()); | ||
| 526 | + createPurchaseOrderInfoVo.setContractCreateById(contractDistributorStandard.getCreateById()); | ||
| 527 | + createPurchaseOrderInfoVo.setDeptId(contractDistributorStandard.getDeptId()); | ||
| 528 | + createPurchaseOrderInfoVo.setWorkshopId(contractDistributorStandard.getWorkshopId()); | ||
| 529 | + createPurchaseOrderInfoVo.setType("NO_PRODUCTION"); | ||
| 530 | + createPurchaseOrderInfoVo.setExamineStatus("AUDIT"); | ||
| 531 | + | ||
| 532 | + // 经销标准合同/外贸标准合同/加工标准合同 需要生产 | ||
| 533 | + if (Arrays.asList("DISTRIB_STD", "INTL_STD_CONTRACT", "PROCESS_STD_AGMT").contains(contractDistributorStandard.getType())) { | ||
| 534 | + createPurchaseOrderInfoVo.setType("PRODUCTION"); | ||
| 535 | + } | ||
| 536 | + | ||
| 537 | + // 经销未锁规合同/外贸未锁规格合同 标准订单需要生产 | ||
| 538 | + if (Arrays.asList("DRAFT_DIST_AGMT", "INTL_OPEN_SPEC_AGMT").contains(contractDistributorStandard.getType()) | ||
| 539 | + && "STANDARD".equals(contractDistributorStandard.getStatus()) && StringUtils.isNotBlank(contractDistributorStandard.getParentId())) { | ||
| 540 | + createPurchaseOrderInfoVo.setType("PRODUCTION"); | ||
| 541 | + } | ||
| 542 | + | ||
| 543 | + // 经销库存合同/外贸库存合同 第一次下发订单需要生产 | ||
| 544 | + if (Arrays.asList("DIST_STOCK_CONTRACT", "INTL_INVENTORY_AGMT").contains(contractDistributorStandard.getType()) | ||
| 545 | + && CollectionUtils.isEmpty(purchaseOrderInfoList)) { | ||
| 546 | + createPurchaseOrderInfoVo.setType("PRODUCTION"); | ||
| 547 | + } | ||
| 548 | + | ||
| 549 | + List<CreatePurchaseOrderLineVo> createPurchaseOrderLineVoList = new ArrayList<>(); | ||
| 550 | + if (CollectionUtils.isNotEmpty(contractDistributorLineList)) { | ||
| 551 | + contractDistributorLineList.forEach(contractDistributorLine -> { | ||
| 552 | + CreatePurchaseOrderLineVo createPurchaseOrderLineVo = new CreatePurchaseOrderLineVo(); | ||
| 553 | + createPurchaseOrderLineVo.setIndustry(contractDistributorLine.getIndustry()); | ||
| 554 | + createPurchaseOrderLineVo.setQuality(contractDistributorLine.getQuality()); | ||
| 555 | + createPurchaseOrderLineVo.setBrand(contractDistributorLine.getBrand()); | ||
| 556 | + createPurchaseOrderLineVo.setThickness(contractDistributorLine.getThickness()); | ||
| 557 | + createPurchaseOrderLineVo.setThicknessTolPos(contractDistributorLine.getThicknessTolPos()); | ||
| 558 | + createPurchaseOrderLineVo.setThicknessTolNeg(contractDistributorLine.getThicknessTolNeg()); | ||
| 559 | + createPurchaseOrderLineVo.setWidth(contractDistributorLine.getWidth()); | ||
| 560 | + createPurchaseOrderLineVo.setWidthTolPos(contractDistributorLine.getWidthTolPos()); | ||
| 561 | + createPurchaseOrderLineVo.setWidthTolNeg(contractDistributorLine.getWidthTolNeg()); | ||
| 562 | + createPurchaseOrderLineVo.setLength(contractDistributorLine.getLength()); | ||
| 563 | + createPurchaseOrderLineVo.setLengthTolPos(contractDistributorLine.getLengthTolPos()); | ||
| 564 | + createPurchaseOrderLineVo.setLengthTolNeg(contractDistributorLine.getLengthTolNeg()); | ||
| 565 | + createPurchaseOrderLineVo.setStatus(contractDistributorLine.getStatus()); | ||
| 566 | + createPurchaseOrderLineVo.setQuantity(contractDistributorLine.getQuantity()); | ||
| 567 | + createPurchaseOrderLineVo.setSalesPrice(contractDistributorLine.getUnitPrice()); | ||
| 568 | + createPurchaseOrderLineVo.setDeliveryDate(contractDistributorLine.getDeliveryDate()); | ||
| 569 | + createPurchaseOrderLineVo.setShowOrder(contractDistributorLine.getShowOrder()); | ||
| 570 | + createPurchaseOrderLineVoList.add(createPurchaseOrderLineVo); | ||
| 571 | + }); | ||
| 572 | + } | ||
| 573 | + | ||
| 574 | + if (CollectionUtils.isNotEmpty(contractStdProcessingLineList)) { | ||
| 575 | + contractStdProcessingLineList.forEach(contractStdProcessingLine -> { | ||
| 576 | + CreatePurchaseOrderLineVo createPurchaseOrderLineVo = new CreatePurchaseOrderLineVo(); | ||
| 577 | + createPurchaseOrderLineVo.setIndustry(contractStdProcessingLine.getIndustry()); | ||
| 578 | + createPurchaseOrderLineVo.setQuality(contractStdProcessingLine.getQuality()); | ||
| 579 | + createPurchaseOrderLineVo.setBrand(contractStdProcessingLine.getProductGrade()); | ||
| 580 | + createPurchaseOrderLineVo.setThickness(contractStdProcessingLine.getThickness()); | ||
| 581 | + createPurchaseOrderLineVo.setThicknessTolPos(contractStdProcessingLine.getThicknessTolPos()); | ||
| 582 | + createPurchaseOrderLineVo.setThicknessTolNeg(contractStdProcessingLine.getThicknessTolNeg()); | ||
| 583 | + createPurchaseOrderLineVo.setWidth(contractStdProcessingLine.getWidth()); | ||
| 584 | + createPurchaseOrderLineVo.setWidthTolPos(contractStdProcessingLine.getWidthTolPos()); | ||
| 585 | + createPurchaseOrderLineVo.setWidthTolNeg(contractStdProcessingLine.getWidthTolNeg()); | ||
| 586 | + createPurchaseOrderLineVo.setLength(contractStdProcessingLine.getLength()); | ||
| 587 | + createPurchaseOrderLineVo.setLengthTolPos(contractStdProcessingLine.getLengthTolPos()); | ||
| 588 | + createPurchaseOrderLineVo.setLengthTolNeg(contractStdProcessingLine.getLengthTolNeg()); | ||
| 589 | + createPurchaseOrderLineVo.setStatus(contractStdProcessingLine.getProductStatus()); | ||
| 590 | + createPurchaseOrderLineVo.setQuantity(contractStdProcessingLine.getProductQuantity()); | ||
| 591 | + createPurchaseOrderLineVo.setSalesPrice(contractStdProcessingLine.getUnitPrice()); | ||
| 592 | + createPurchaseOrderLineVo.setDeliveryDate(contractStdProcessingLine.getDeliveryDate()); | ||
| 593 | + createPurchaseOrderLineVo.setShowOrder(contractStdProcessingLine.getShowOrder()); | ||
| 594 | + createPurchaseOrderLineVoList.add(createPurchaseOrderLineVo); | ||
| 595 | + }); | ||
| 596 | + } | ||
| 597 | + | ||
| 598 | + createPurchaseOrderInfoVo.setCreatePurchaseOrderLineVoList(createPurchaseOrderLineVoList); | ||
| 599 | + purchaseOrderInfoService.create(createPurchaseOrderInfoVo); | ||
| 468 | } | 600 | } |
| 469 | 601 | ||
| 470 | private void clearChildContractDistributorStandardCache(String id) { | 602 | private void clearChildContractDistributorStandardCache(String id) { |
| @@ -517,6 +649,9 @@ public class ContractDistributorStandardServiceImpl extends | @@ -517,6 +649,9 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 517 | 649 | ||
| 518 | // 开启审核 | 650 | // 开启审核 |
| 519 | flowInstanceWrapperService.startInstance(STANDARD_FLAG, data.getId(), STANDARD_FLAG, data); | 651 | flowInstanceWrapperService.startInstance(STANDARD_FLAG, data.getId(), STANDARD_FLAG, data); |
| 652 | + | ||
| 653 | + // 创建订货单 | ||
| 654 | + createPurchaseOrderInfo(data, "standard"); | ||
| 520 | } | 655 | } |
| 521 | 656 | ||
| 522 | @OpLog(type = OtherOpLogType.class, name = "上传双方盖章合同附件,ID:{}", params = {"#id"}) | 657 | @OpLog(type = OtherOpLogType.class, name = "上传双方盖章合同附件,ID:{}", params = {"#id"}) |