Răsfoiți Sursa

样品单、交接单变更逻辑更改

caozj 1 an în urmă
părinte
comite
2a50ed4f9a

+ 16 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/ContractFlow.java

@@ -10,6 +10,8 @@ import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.service.coding.CodingRuleService;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
+import com.fjhx.flow.core.FlowThreadLocalUtil;
+import com.fjhx.flow.enums.HandleTypeEnum;
 import com.fjhx.sale.entity.contract.dto.ContractDto;
 import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.contract.po.ContractProduct;
@@ -19,6 +21,7 @@ import com.fjhx.sale.service.contract.ContractProductService;
 import com.fjhx.sale.service.contract.ContractProjectService;
 import com.fjhx.sale.service.contract.ContractService;
 import com.fjhx.sale.service.contract.ContractShipmentService;
+import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
@@ -163,4 +166,17 @@ public class ContractFlow extends FlowDelegate {
         return contractId;
     }
 
+    /**
+     * 驳回方法
+     */
+    public void reject() {
+        if (HandleTypeEnum.REJECT.equals(FlowThreadLocalUtil.getHandleTypeEnum())) {
+            contractService.update(q -> q
+                    .eq(Contract::getId, FlowThreadLocalUtil.getBusinessId())
+                    .set(Contract::getStatus, 20)//20为驳回
+                    .set(Contract::getUpdateTime, new Date())
+                    .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+            );
+        }
+    }
 }

+ 22 - 6
hx-sale/src/main/java/com/fjhx/sale/flow/ContractUpdateFlow.java

@@ -14,6 +14,9 @@ import com.fjhx.sale.entity.contract.po.ContractProduct;
 import com.fjhx.sale.entity.contract.po.ContractProject;
 import com.fjhx.sale.entity.contract.po.ContractShipment;
 import com.fjhx.sale.entity.sample.po.Sample;
+import com.fjhx.sale.entity.sample.po.SampleProduct;
+import com.fjhx.sale.entity.sample.po.SampleProject;
+import com.fjhx.sale.entity.sample.po.SampleShipment;
 import com.fjhx.sale.service.contract.ContractProductService;
 import com.fjhx.sale.service.contract.ContractProjectService;
 import com.fjhx.sale.service.contract.ContractService;
@@ -163,6 +166,19 @@ public class ContractUpdateFlow extends FlowDelegate {
         //替换新旧数据ID为临时ID
         contractService.updateContract(temOldUpContract);
         contractService.updateContract(temNewUpContract);
+
+        //查询新数据产品、收费、出货
+        List<Long> newContractProductIds = contractProductService.list(Wrappers.<ContractProduct>query().lambda().select(ContractProduct::getId).eq(ContractProduct::getContractId,businessId)).stream().map(ContractProduct::getId).collect(Collectors.toList());
+        List<Long> newContractProjectIds = contractProjectService.list(Wrappers.<ContractProject>query().lambda().select(ContractProject::getId).eq(ContractProject::getContractId,businessId)).stream().map(ContractProject::getId).collect(Collectors.toList());
+        List<Long> newContractShipmentIds = contractShipmentService.list(Wrappers.<ContractShipment>query().lambda().select(ContractShipment::getId).eq(ContractShipment::getContractId,businessId)).stream().map(ContractShipment::getId).collect(Collectors.toList());
+
+
+        //查询旧数据产品、收费、出货
+        List<Long> oldContractProductIds = contractProductService.list(Wrappers.<ContractProduct>query().lambda().select(ContractProduct::getId).eq(ContractProduct::getContractId,oldContractId)).stream().map(ContractProduct::getId).collect(Collectors.toList());
+        List<Long> oldContractProjectIds = contractProjectService.list(Wrappers.<ContractProject>query().lambda().select(ContractProject::getId).eq(ContractProject::getContractId,oldContractId)).stream().map(ContractProject::getId).collect(Collectors.toList());
+        List<Long> oldContractShipmentIds = contractShipmentService.list(Wrappers.<ContractShipment>query().lambda().select(ContractShipment::getId).eq(ContractShipment::getContractId,oldContractId)).stream().map(ContractShipment::getId).collect(Collectors.toList());
+
+
         /**
          * 处理新合同---
          */
@@ -172,11 +188,11 @@ public class ContractUpdateFlow extends FlowDelegate {
         newContract.setUpId(temNewId);
         contractService.updateContract(newContract);
         //修改合同产品相关数据
-        contractProductService.update(Wrappers.<ContractProduct>update().lambda().set(ContractProduct::getContractId,oldContractId).eq(ContractProduct::getContractId,businessId));
+        contractProductService.update(Wrappers.<ContractProduct>update().lambda().set(ContractProduct::getContractId,oldContractId).in(ContractProduct::getContractId,newContractProductIds));
         //修改合同收费相关数据
-        contractProjectService.update(Wrappers.<ContractProject>update().lambda().set(ContractProject::getContractId,oldContractId).eq(ContractProject::getContractId,businessId));
+        contractProjectService.update(Wrappers.<ContractProject>update().lambda().set(ContractProject::getContractId,oldContractId).in(ContractProject::getContractId,newContractProjectIds));
         //修改合同出货相关数据
-        contractShipmentService.update(Wrappers.<ContractShipment>update().lambda().set(ContractShipment::getContractId,oldContractId).eq(ContractShipment::getContractId,businessId));
+        contractShipmentService.update(Wrappers.<ContractShipment>update().lambda().set(ContractShipment::getContractId,oldContractId).in(ContractShipment::getContractId,newContractShipmentIds));
         /**
          * 处理旧的合同---
          */
@@ -186,10 +202,10 @@ public class ContractUpdateFlow extends FlowDelegate {
         newContract.setUpId(temOldId);
         contractService.updateContract(oldContract);
         //修改合同产品相关数据
-        contractProductService.update(Wrappers.<ContractProduct>update().lambda().set(ContractProduct::getContractId,businessId).eq(ContractProduct::getContractId,oldContractId));
+        contractProductService.update(Wrappers.<ContractProduct>update().lambda().set(ContractProduct::getContractId,businessId).in(ContractProduct::getContractId,oldContractProductIds));
         //修改合同收费相关数据
-        contractProjectService.update(Wrappers.<ContractProject>update().lambda().set(ContractProject::getContractId,businessId).eq(ContractProject::getContractId,oldContractId));
+        contractProjectService.update(Wrappers.<ContractProject>update().lambda().set(ContractProject::getContractId,businessId).in(ContractProject::getContractId,oldContractProjectIds));
         //修改合同出货相关数据
-        contractShipmentService.update(Wrappers.<ContractShipment>update().lambda().set(ContractShipment::getContractId,businessId).eq(ContractShipment::getContractId,oldContractId));
+        contractShipmentService.update(Wrappers.<ContractShipment>update().lambda().set(ContractShipment::getContractId,businessId).in(ContractShipment::getContractId,oldContractShipmentIds));
     }
 }

+ 23 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/SaleQuotationFlow.java

@@ -10,7 +10,10 @@ import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.enums.CodingRuleEnum;
 import com.fjhx.common.service.coding.CodingRuleService;
 import com.fjhx.flow.core.FlowDelegate;
+import com.fjhx.flow.core.FlowThreadLocalUtil;
 import com.fjhx.flow.enums.FlowStatusEnum;
+import com.fjhx.flow.enums.HandleTypeEnum;
+import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.quotation.po.QuotationPay;
 import com.fjhx.sale.entity.quotation.po.QuotationProduct;
 import com.fjhx.sale.entity.sale.dto.SaleQuotationDto;
@@ -19,10 +22,13 @@ import com.fjhx.sale.enums.SaleQuotationEnum;
 import com.fjhx.sale.service.quotation.QuotationPayService;
 import com.fjhx.sale.service.quotation.QuotationProductService;
 import com.fjhx.sale.service.sale.SaleQuotationService;
+import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -34,6 +40,9 @@ public class SaleQuotationFlow extends FlowDelegate {
     @Autowired
     private CodingRuleService codingRuleService;
 
+    @Autowired
+    private SaleQuotationService saleQuotationService;
+
     @Override
     public String getFlowKey() {
         return "sale_quotation_flow";
@@ -96,4 +105,18 @@ public class SaleQuotationFlow extends FlowDelegate {
         saleQuotationService.updateById(contract);
     }
 
+    /**
+     * 驳回方法
+     */
+    public void reject() {
+        if (HandleTypeEnum.REJECT.equals(FlowThreadLocalUtil.getHandleTypeEnum())) {
+            saleQuotationService.update(q -> q
+                    .eq(SaleQuotation::getId, FlowThreadLocalUtil.getBusinessId())
+                    .set(SaleQuotation::getStatus, 20)//20为驳回
+                    .set(SaleQuotation::getUpdateTime, new Date())
+                    .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+            );
+        }
+    }
+
 }

+ 18 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/SampleFlow.java

@@ -14,6 +14,9 @@ import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.service.coding.CodingRuleService;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
+import com.fjhx.flow.core.FlowThreadLocalUtil;
+import com.fjhx.flow.enums.HandleTypeEnum;
+import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.sample.dto.SampleDto;
 import com.fjhx.sale.entity.sample.po.Sample;
 import com.fjhx.sale.entity.sample.po.SampleProduct;
@@ -23,6 +26,7 @@ import com.fjhx.sale.service.sample.SampleProductService;
 import com.fjhx.sale.service.sample.SampleProjectService;
 import com.fjhx.sale.service.sample.SampleService;
 import com.fjhx.sale.service.sample.SampleShipmentService;
+import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -146,4 +150,18 @@ public class SampleFlow extends FlowDelegate {
         sampleService.updateById(sample);
     }
 
+    /**
+     * 驳回方法
+     */
+    public void reject() {
+        if (HandleTypeEnum.REJECT.equals(FlowThreadLocalUtil.getHandleTypeEnum())) {
+            sampleService.update(q -> q
+                    .eq(Sample::getId, FlowThreadLocalUtil.getBusinessId())
+                    .set(Sample::getStatus, 20)//20为驳回
+                    .set(Sample::getUpdateTime, new Date())
+                    .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+            );
+        }
+    }
+
 }

+ 19 - 6
hx-sale/src/main/java/com/fjhx/sale/flow/SampleUpdateFlow.java

@@ -164,12 +164,24 @@ public class SampleUpdateFlow extends FlowDelegate {
         newSample.setApprovedDate(new Date());
         newSample.setUpId(temNewId);
         sampleService.updateSample(newSample);
+        //查询新数据产品、收费、出货
+        List<Long> newSampleProductIds = sampleProductService.list(Wrappers.<SampleProduct>query().lambda().select(SampleProduct::getId).eq(SampleProduct::getSampleId,businessId)).stream().map(SampleProduct::getId).collect(Collectors.toList());
+        List<Long> newSampleProjectIds = sampleProjectService.list(Wrappers.<SampleProject>query().lambda().select(SampleProject::getId).eq(SampleProject::getSampleId,businessId)).stream().map(SampleProject::getId).collect(Collectors.toList());
+        List<Long> newSampleShipmentIds = sampleShipmentService.list(Wrappers.<SampleShipment>query().lambda().select(SampleShipment::getId).eq(SampleShipment::getSampleId,businessId)).stream().map(SampleShipment::getId).collect(Collectors.toList());
+
+
+        //查询旧数据产品、收费、出货
+        List<Long> oldSampleProductIds = sampleProductService.list(Wrappers.<SampleProduct>query().lambda().select(SampleProduct::getId).eq(SampleProduct::getSampleId,oldSampleId)).stream().map(SampleProduct::getId).collect(Collectors.toList());
+        List<Long> oldSampleProjectIds = sampleProjectService.list(Wrappers.<SampleProject>query().lambda().select(SampleProject::getId).eq(SampleProject::getSampleId,oldSampleId)).stream().map(SampleProject::getId).collect(Collectors.toList());
+        List<Long> oldSampleShipmentIds = sampleShipmentService.list(Wrappers.<SampleShipment>query().lambda().select(SampleShipment::getId).eq(SampleShipment::getSampleId,oldSampleId)).stream().map(SampleShipment::getId).collect(Collectors.toList());
+
+
         //修改样品单产品相关数据
-        sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId,oldSampleId).eq(SampleProduct::getSampleId,businessId));
+        sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId,oldSampleId).in(SampleProduct::getId,newSampleProductIds));
         //修改样品单收费相关数据
-        sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId,oldSampleId).eq(SampleProject::getSampleId,businessId));
+        sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId,oldSampleId).eq(SampleProject::getId,newSampleProjectIds));
         //修改样品单出货相关数据
-        sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId,oldSampleId).eq(SampleShipment::getSampleId,businessId));
+        sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId,oldSampleId).eq(SampleShipment::getId,newSampleShipmentIds));
         /**
          * 处理旧的样品单---
          */
@@ -177,12 +189,13 @@ public class SampleUpdateFlow extends FlowDelegate {
         oldSample.setStatus(FlowStatusEnum1.UPDATE.getKey());
         oldSample.setIsChange("1");
         oldSample.setUpId(temOldId);
+        oldSample.setOldSampleId(oldSampleId);
         sampleService.updateSample(oldSample);
         //修改样品单产品相关数据
-        sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId,businessId).eq(SampleProduct::getSampleId,oldSampleId));
+        sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId,businessId).in(SampleProduct::getId,oldSampleProductIds));
         //修改样品单收费相关数据
-        sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId,businessId).eq(SampleProject::getSampleId,oldSampleId));
+        sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId,businessId).in(SampleProject::getId,oldSampleProjectIds));
         //修改样品单出货相关数据
-        sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId,businessId).eq(SampleShipment::getSampleId,oldSampleId));
+        sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId,businessId).in(SampleShipment::getId,oldSampleShipmentIds));
     }
 }