Преглед на файлове

样品单、交接单变更逻辑更改.增加流程回退、驳回

caozj преди 1 година
родител
ревизия
074379e97a

+ 59 - 4
hx-sale/src/main/java/com/fjhx/sale/flow/ContractUpdateFlow.java

@@ -3,11 +3,11 @@ package com.fjhx.sale.flow;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson2.JSON;
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.toolkit.*;
-import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.area.utils.CustomizeAreaUtil;
 import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.utils.Assert;
+import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
 import com.fjhx.item.entity.product.po.ProductInfoEhsdJson;
 import com.fjhx.sale.entity.contract.dto.ContractDto;
@@ -24,7 +24,9 @@ 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.BaseIdPo;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -42,7 +44,6 @@ import java.util.stream.Collectors;
  * 合同变更流程
  */
 @Component
-@DS(SourceConstant.SALE)
 public class ContractUpdateFlow extends FlowDelegate {
 
     @Autowired
@@ -137,7 +138,7 @@ public class ContractUpdateFlow extends FlowDelegate {
                 }
             }
         }
-        return contractFlow.start(contract);
+        return update(contract);
     }
 
     /**
@@ -228,4 +229,58 @@ public class ContractUpdateFlow extends FlowDelegate {
             contractShipmentService.update(Wrappers.<ContractShipment>update().lambda().set(ContractShipment::getContractId,businessId).in(ContractShipment::getId,oldContractShipmentIds));
         }
     }
+
+    /**
+     * 变更
+     * @param contract
+     * @return
+     */
+    public Long update(ContractDto contract) {
+        // 赋值城市省份信息
+        CustomizeAreaUtil.setAreaId(contract);
+        SysUser loginUser = SecurityUtils.getLoginUser().getUser();
+        contract.setUserName(loginUser.getNickName());
+        contract.setBuyCityId(contract.getCityId());
+        contract.setBuyCountryId(contract.getCountryId());
+        contract.setBuyProvinceId(contract.getProvinceId());
+        contract.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey());
+//        contract.setRate(ExchangeRateUtil.getCnyToCodeRate(contract.getCurrency()));
+        contractService.save(contract);
+
+        // 保存合同产品
+        List<ContractProduct> contractProductList = contract.getContractProductList();
+        if (CollectionUtils.isNotEmpty(contractProductList)) {
+            for (ContractProduct c : contractProductList) {
+                c.setContractId(contract.getId());
+//                ObsFileUtil.saveFile(c.getFileList(), c.getId());
+            }
+            contractProductService.saveBatch(contractProductList);
+        }
+
+        // 保存收费项目
+        List<ContractProject> contractProjectList = contract.getContractProjectList();
+        if (CollectionUtils.isNotEmpty(contractProjectList)) {
+            for (ContractProject c : contractProjectList) {
+                c.setContractId(contract.getId());
+            }
+            contractProjectService.saveBatch(contractProjectList);
+        }
+
+        // 保存自定义出货
+        List<ContractShipment> contractShipmentList = contract.getContractShipmentList();
+        if (CollectionUtils.isNotEmpty(contractShipmentList)) {
+            for (ContractShipment c : contractShipmentList) {
+                c.setContractId(contract.getId());
+            }
+            contractShipmentService.saveBatch(contractShipmentList);
+        }
+
+        // 交接单附件列表
+        ObsFileUtil.saveFile(contract.getFileList(), contract.getId(), 1);
+
+        // 包装指示附件列表
+        ObsFileUtil.saveFile(contract.getPackageFileList(), contract.getId(), 2);
+
+        return contract.getId();
+    }
 }

+ 75 - 1
hx-sale/src/main/java/com/fjhx/sale/flow/EhsdPurchaseFlow.java

@@ -130,8 +130,82 @@ public class EhsdPurchaseFlow extends FlowDelegate {
         return purchase.getId();
     }
 
+
+    /**
+     * 公共代码块--变更
+     */
+    public EhsdPurchaseDto updateStart(EhsdPurchaseDto purchase) {
+        //赋值城市省份信息
+        CustomizeAreaUtil.setAreaId(purchase);
+        purchase.setSellCityId(purchase.getCityId());
+        purchase.setSellCountryId(purchase.getCountryId());
+        purchase.setSellProvinceId(purchase.getProvinceId());
+
+
+        purchase.setStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
+        String nickName = SecurityUtils.getLoginUser().getUser().getNickName();
+        purchase.setUserName(nickName);
+        purchaseService.save(purchase);
+        List<EhsdPurchaseProduct> purchaseProductList = purchase.getPurchaseProductList();
+        List<EhsdPurchaseProject> purchaseProjectList = purchase.getPurchaseProjectList();
+        List<EhsdPurchaseArrival> purchaseArrivalList = purchase.getPurchaseArrivalList();
+        List<EhsdPurchaseProductMountings> addMountingsList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(purchaseProductList)) {
+            for (EhsdPurchaseProduct s : purchaseProductList) {//产品
+                long id ;
+                if(ObjectUtils.isNotEmpty(s.getId())){
+                    id = s.getId();
+                }else{
+                    id = IdWorker.getId();
+                }
+                s.setId(id);
+                s.setPurchaseId(purchase.getId());
+                List<EhsdPurchaseProductMountings> purchaseProductMountingsList = s.getPurchaseProductMountingsList();
+                if (CollectionUtils.isNotEmpty(purchaseProductMountingsList)) {//产品配件
+                    purchaseProductMountingsList.forEach(obj -> obj.setPurchaseProductId(id));
+                    addMountingsList.addAll(purchaseProductMountingsList);
+                }
+                ObsFileUtil.saveFile(s.getFileList(), s.getId());
+
+                if ("0".equals(purchase.getDataResource())) {
+                    //计算采购数量是否大于申购数量
+                    List<EhsdPurchaseProduct> purchaseDetailList1 = purchaseProductService.list(q -> q.eq(EhsdPurchaseProduct::getSubscribeDetailId,
+                            s.getSubscribeDetailId()));
+                    //求和
+                    BigDecimal purchaseCount = purchaseDetailList1.stream()
+                            .map(EhsdPurchaseProduct::getQuantity)
+                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+                    //计算历史采购数量+本次采购数量之和
+                    BigDecimal count = purchaseCount.add(s.getQuantity());
+                    //判断采购数量是否大于申购数量
+                    SubscribeDetail subscribeDetail = subscribeDetailService.getById(s.getSubscribeDetailId());
+                    if (count.compareTo(subscribeDetail.getCount()) > 0) {
+                        throw new ServiceException("采购数量不能大于申购数量");
+                    }
+                }
+            }
+            purchaseProductService.saveBatch(purchaseProductList);
+            purchaseProductMountingsService.saveBatch(addMountingsList);
+        }
+        if (CollectionUtils.isNotEmpty(purchaseProjectList)) {//到货
+            for (EhsdPurchaseProject s : purchaseProjectList) {
+                s.setPurchaseId(purchase.getId());
+            }
+            purchaseProjectService.saveBatch(purchaseProjectList);
+        }
+        if (CollectionUtils.isNotEmpty(purchaseArrivalList)) {//收费项目
+            for (EhsdPurchaseArrival s : purchaseArrivalList) {
+                s.setPurchaseId(purchase.getId());
+            }
+            purchaseArrivalService.saveBatch(purchaseArrivalList);
+        }
+        return purchase;
+    }
+
+
+
     /**
-     * 公共代码块
+     * 公共代码块--发起
      */
     public EhsdPurchaseDto connStart(EhsdPurchaseDto purchase) {
         //赋值城市省份信息

+ 1 - 1
hx-sale/src/main/java/com/fjhx/sale/flow/EhsdPurchaseUpdateFlow.java

@@ -114,7 +114,7 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
         purchaseArrivalList.forEach(item -> item.setId(null));
 
         //调用采购发起公共代码块
-        purchase = ehsdPurchaseFlow.connStart(purchase);
+        purchase = ehsdPurchaseFlow.updateStart(purchase);
 
         return purchase.getId();
     }

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

@@ -87,16 +87,16 @@ public class SaleQuotationFlow extends FlowDelegate {
         //添加报价状态
         saleQuotation.setStatus(SaleQuotationEnum.UNDER_REVIEW.getKey());
         //添加报价单信息
-        saleQuotationService.save(saleQuotation);
+        saleQuotationService.saveOrUpdate(saleQuotation);
         List<QuotationProduct> quotationProductList = saleQuotation.getQuotationProductList();
         if(CollectionUtils.isNotEmpty(quotationProductList)){//保存报价产品信息
             quotationProductList.forEach(quotationProduct -> quotationProduct.setSaleQuotationId(saleQuotation.getId()));
-            quotationProductService.saveBatch(quotationProductList);
+            quotationProductService.saveOrUpdateBatch(quotationProductList);
         }
         List<QuotationPay> quotationPayList = saleQuotation.getQuotationPayList();
         if(CollectionUtils.isNotEmpty(quotationPayList)){//保存报价项目信息
             quotationPayList.forEach(quotationPay -> quotationPay.setSaleQuotationId(saleQuotation.getId()));
-            quotationPayService.saveBatch(quotationPayList);
+            quotationPayService.saveOrUpdateBatch(quotationPayList);
         }
         return saleQuotation.getId();
     }

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

@@ -82,7 +82,7 @@ public class SampleFlow extends FlowDelegate {
     public Long start(Long flowId, JSONObject submitData) {
         SampleDto sample = submitData.toJavaObject(SampleDto.class);
         sample.setCode(codingRuleService.createCode(CodingRuleEnum.SAMPLE.getKey(),sample.getBuyCorporationId()));
-        long id = start(sample,0);
+        long id = start(sample);
         return id;
     }
 
@@ -102,7 +102,7 @@ public class SampleFlow extends FlowDelegate {
         if(ObjectUtils.isEmpty(sample)){
             throw new ServiceException("样品单数据不能为空");
         }
-        start(sample,0);
+        start(sample);
     }
 
     /**
@@ -123,7 +123,7 @@ public class SampleFlow extends FlowDelegate {
         }
     }
 
-    public Long start(SampleDto sample,int type){
+    public Long start(SampleDto sample){
         //赋值城市省份信息
         CustomizeAreaUtil.setAreaId(sample);
         sample.setBuyCityId(sample.getCityId());

+ 53 - 1
hx-sale/src/main/java/com/fjhx/sale/flow/SampleUpdateFlow.java

@@ -4,8 +4,10 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.toolkit.*;
+import com.fjhx.area.utils.CustomizeAreaUtil;
 import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.enums.FlowStatusEnum1;
+import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
 import com.fjhx.sale.entity.sample.dto.SampleDto;
 import com.fjhx.sale.entity.sample.po.Sample;
@@ -17,6 +19,7 @@ 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.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -124,7 +127,7 @@ public class SampleUpdateFlow extends FlowDelegate {
                 }
             }
         }
-        return sampleFlow.start(newSample,1);
+        return update(newSample);
     }
 
     /**
@@ -211,4 +214,53 @@ public class SampleUpdateFlow extends FlowDelegate {
         }
 
     }
+
+    /**
+     * 变更数据
+     * @param sample
+     * @return
+     */
+    public Long update(SampleDto sample){
+        //赋值城市省份信息
+        CustomizeAreaUtil.setAreaId(sample);
+        sample.setBuyCityId(sample.getCityId());
+        sample.setBuyCountryId(sample.getCountryId());
+        sample.setBuyProvinceId(sample.getProvinceId());
+//        sample.setCode(CodeEnum.SAMPLE_CODE.getCode());
+        sample.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey());
+        sample.setUserName(SecurityUtils.getUsername());
+
+        sampleService.save(sample);
+        List<SampleProduct> sampleProductList = sample.getSampleProductList();
+        if(CollectionUtils.isNotEmpty(sampleProductList)){//保存样品单产品
+            for(SampleProduct c : sampleProductList){
+                c.setId(IdWorker.getId());
+                c.setSampleId(sample.getId());
+                c.setExpendQuantity(c.getQuantity());
+                ObsFileUtil.saveFile(c.getFileList(),c.getId());
+            }
+            sampleProductService.saveBatch(sampleProductList);
+        }
+        List<SampleProject> sampleProjectList = sample.getSampleProjectList();
+        if(CollectionUtils.isNotEmpty(sampleProjectList)){//保存收费项目
+            for(SampleProject c : sampleProjectList){
+                c.setId(IdWorker.getId());
+                c.setSampleId(sample.getId());
+            }
+            sampleProjectService.saveBatch(sampleProjectList);
+        }
+        List<SampleShipment> sampleShipmentList = sample.getSampleShipmentList();
+        if(CollectionUtils.isNotEmpty(sampleShipmentList)){//保存自定义出货
+            for(SampleShipment c : sampleShipmentList){
+                c.setId(IdWorker.getId());
+                c.setSampleId(sample.getId());
+            }
+            sampleShipmentService.saveBatch(sampleShipmentList);
+        }
+        //交接单附件
+        ObsFileUtil.saveFile(sample.getFileList(),sample.getId(),1);
+        //包装附件
+        ObsFileUtil.saveFile(sample.getPackageFileList(),sample.getId(),2);
+        return sample.getId();
+    }
 }

+ 1 - 1
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -284,7 +284,7 @@
     </select>
 
     <update id="updateContract" parameterType="com.fjhx.sale.entity.contract.po.Contract">
-        update contract 123123
+        update contract
         <set>
             <if test="id != null and id != '' ">id = #{id},</if>
             <if test="status != null and status != ''">status = #{status},</if>