浏览代码

问题处理

yzc 1 年之前
父节点
当前提交
350940a0fb

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

@@ -100,6 +100,7 @@ public class EhsdPurchaseFlow extends FlowDelegate {
     @Override
     public Long start(Long flowId, JSONObject submitData) {
         EhsdPurchaseDto purchase = submitData.toJavaObject(EhsdPurchaseDto.class);
+        purchase.setId(null);
         purchase.setFlowId(flowId);
 
         //手动创建 编号规则

+ 90 - 43
hx-sale/src/main/java/com/fjhx/sale/flow/SampleUpdateFlow.java

@@ -10,7 +10,7 @@ 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.sale.entity.contract.po.Contract;
+import com.fjhx.flow.enums.FlowStatusEnum;
 import com.fjhx.sale.entity.sample.dto.SampleDto;
 import com.fjhx.sale.entity.sample.po.Sample;
 import com.fjhx.sale.entity.sample.po.SampleProduct;
@@ -20,12 +20,15 @@ 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;
 import org.springframework.stereotype.Component;
 
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -85,7 +88,7 @@ public class SampleUpdateFlow extends FlowDelegate {
         }
         //查询原样品单
         Sample oldSample = sampleService.getById(newSample.getOldSampleId());
-        if(ObjectUtil.isEmpty(oldSample)){
+        if (ObjectUtil.isEmpty(oldSample)) {
             throw new ServiceException("查询不到原样品单信息");
         }
         //更新原样品单状态为变更中
@@ -93,12 +96,12 @@ public class SampleUpdateFlow extends FlowDelegate {
         sampleService.updateById(oldSample);
         //查询旧样品单的订单产品
         List<SampleProduct> oldSampleProductList = sampleProductService.list(q -> q.eq(SampleProduct::getSampleId, oldSampleId));
-        if(CollectionUtils.isEmpty(oldSampleProductList)){
+        if (CollectionUtils.isEmpty(oldSampleProductList)) {
             throw new ServiceException("原样品单没有产品");
         }
-        Map<Long,List<SampleProduct>> oldSampleMap = oldSampleProductList.stream().collect(Collectors.groupingBy(SampleProduct::getId));
+        Map<Long, List<SampleProduct>> oldSampleMap = oldSampleProductList.stream().collect(Collectors.groupingBy(SampleProduct::getId));
         List<SampleProduct> newSampleProductList = newSample.getSampleProductList();
-        if(CollectionUtils.isEmpty(newSampleProductList)){
+        if (CollectionUtils.isEmpty(newSampleProductList)) {
             throw new ServiceException("变更样品单产品不能为空");
         }
         /**
@@ -116,24 +119,24 @@ public class SampleUpdateFlow extends FlowDelegate {
         /**
          * 计算新样品单的剩余数量
          */
-        for(SampleProduct newCp:newSampleProductList){
+        for (SampleProduct newCp : newSampleProductList) {
             newCp.setExpendQuantity(newCp.getQuantity());
-            if(ObjectUtil.isNotEmpty(newCp.getId())){//如果新样品单产品ID不为空
+            if (ObjectUtil.isNotEmpty(newCp.getId())) {//如果新样品单产品ID不为空
                 //取出旧样品单
-                SampleProduct oldSampleProduct = oldSampleMap.getOrDefault(newCp.getId(),null).get(0);
+                SampleProduct oldSampleProduct = oldSampleMap.getOrDefault(newCp.getId(), null).get(0);
                 //取出旧样品单包装方式
                 JSONObject oldJson = JSONObject.parseObject(oldSampleProduct.getEhsdJson());
-                String oldPackMethod = oldJson.getOrDefault("packMethod",null)==null?null:oldJson.getOrDefault("packMethod",null).toString();
+                String oldPackMethod = oldJson.getOrDefault("packMethod", null) == null ? null : oldJson.getOrDefault("packMethod", null).toString();
                 //取出新样品单包装方式
                 JSONObject newJson = JSONObject.parseObject(newCp.getEhsdJson());
-                String newPackMethod = newJson.getOrDefault("packMethod",null)==null?null:oldJson.getOrDefault("packMethod",null).toString();
+                String newPackMethod = newJson.getOrDefault("packMethod", null) == null ? null : oldJson.getOrDefault("packMethod", null).toString();
                 /**
                  * 商品英文名、尺寸、包装方式、数量 没有变更---取原本的剩余数量
                  */
-                if(oldSampleProduct.getQuantity().compareTo(newCp.getQuantity())==0
+                if (oldSampleProduct.getQuantity().compareTo(newCp.getQuantity()) == 0
                         && StringUtils.equals(oldSampleProduct.getProductName(), newCp.getProductName())
-                        && StringUtils.equals(oldSampleProduct.getProductModel(),newCp.getProductModel())
-                        && StringUtils.equals(oldPackMethod,newPackMethod)){
+                        && StringUtils.equals(oldSampleProduct.getProductModel(), newCp.getProductModel())
+                        && StringUtils.equals(oldPackMethod, newPackMethod)) {
                     //取出旧的剩余数量
                     newCp.setExpendQuantity(oldSampleProduct.getExpendQuantity());
                 }
@@ -160,7 +163,7 @@ public class SampleUpdateFlow extends FlowDelegate {
         if (ObjectUtils.isEmpty(newSample)) {
             throw new ServiceException("样品单不存在");
         }
-        long  oldSampleId = newSample.getOldSampleId();//取出旧的样品单ID
+        long oldSampleId = newSample.getOldSampleId();//取出旧的样品单ID
         Sample oldSample = sampleService.getById(oldSampleId);
         if (oldSample == null) {
             throw new ServiceException("原样品单不存在");
@@ -177,15 +180,15 @@ public class SampleUpdateFlow extends FlowDelegate {
         sampleService.updateSample(temOldUpSample);
         sampleService.updateSample(temNewUpSample);
         //查询新数据产品、收费、出货
-        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> 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());
+        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());
 
         /**
          * 处理新样品单---
@@ -198,16 +201,16 @@ public class SampleUpdateFlow extends FlowDelegate {
         newSample.setIsShow(0);//显示新样品单
         sampleService.updateSample(newSample);
         //修改样品单产品相关数据
-        if(CollectionUtils.isNotEmpty(newSampleProductIds)){
-            sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId,oldSampleId).in(SampleProduct::getId,newSampleProductIds));
+        if (CollectionUtils.isNotEmpty(newSampleProductIds)) {
+            sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId, oldSampleId).in(SampleProduct::getId, newSampleProductIds));
         }
         //修改样品单收费相关数据
-        if(CollectionUtils.isNotEmpty(newSampleProjectIds)){
-            sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId,oldSampleId).in(SampleProject::getId,newSampleProjectIds));
+        if (CollectionUtils.isNotEmpty(newSampleProjectIds)) {
+            sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId, oldSampleId).in(SampleProject::getId, newSampleProjectIds));
         }
         //修改样品单出货相关数据
-        if(CollectionUtils.isNotEmpty(newSampleShipmentIds)){
-            sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId,oldSampleId).in(SampleShipment::getId,newSampleShipmentIds));
+        if (CollectionUtils.isNotEmpty(newSampleShipmentIds)) {
+            sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId, oldSampleId).in(SampleShipment::getId, newSampleShipmentIds));
         }
         /**
          * 处理旧的样品单---
@@ -219,26 +222,27 @@ public class SampleUpdateFlow extends FlowDelegate {
         oldSample.setIsShow(1);//隐藏旧的样品单
         sampleService.updateSample(oldSample);
         //修改样品单产品相关数据
-        if(CollectionUtils.isNotEmpty(oldSampleProductIds)){
-            sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId,businessId).in(SampleProduct::getId,oldSampleProductIds));
+        if (CollectionUtils.isNotEmpty(oldSampleProductIds)) {
+            sampleProductService.update(Wrappers.<SampleProduct>update().lambda().set(SampleProduct::getSampleId, businessId).in(SampleProduct::getId, oldSampleProductIds));
         }
         //修改样品单收费相关数据
-        if(CollectionUtils.isNotEmpty(oldSampleProjectIds)){
-            sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId,businessId).in(SampleProject::getId,oldSampleProjectIds));
+        if (CollectionUtils.isNotEmpty(oldSampleProjectIds)) {
+            sampleProjectService.update(Wrappers.<SampleProject>update().lambda().set(SampleProject::getSampleId, businessId).in(SampleProject::getId, oldSampleProjectIds));
         }
         //修改样品单出货相关数据
-        if(CollectionUtils.isNotEmpty(oldSampleShipmentIds)){
-            sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId,businessId).in(SampleShipment::getId,oldSampleShipmentIds));
+        if (CollectionUtils.isNotEmpty(oldSampleShipmentIds)) {
+            sampleShipmentService.update(Wrappers.<SampleShipment>update().lambda().set(SampleShipment::getSampleId, businessId).in(SampleShipment::getId, oldSampleShipmentIds));
         }
-        ObsFileUtil.exchangeBusinessId(oldSampleId,businessId);
+        ObsFileUtil.exchangeBusinessId(oldSampleId, businessId);
     }
 
     /**
      * 变更数据
+     *
      * @param sample
      * @return
      */
-    public Long update(SampleDto sample){
+    public Long update(SampleDto sample) {
         //赋值城市省份信息
         CustomizeAreaUtil.setAreaId(sample);
         sample.setBuyCityId(sample.getCityId());
@@ -250,8 +254,8 @@ public class SampleUpdateFlow extends FlowDelegate {
 
         sampleService.save(sample);
         List<SampleProduct> sampleProductList = sample.getSampleProductList();
-        if(CollectionUtils.isNotEmpty(sampleProductList)){//保存样品单产品
-            for(SampleProduct c : sampleProductList){
+        if (CollectionUtils.isNotEmpty(sampleProductList)) {//保存样品单产品
+            for (SampleProduct c : sampleProductList) {
                 c.setId(IdWorker.getId());
                 c.setSampleId(sample.getId());
                 c.setExpendQuantity(c.getQuantity());
@@ -259,25 +263,68 @@ public class SampleUpdateFlow extends FlowDelegate {
             sampleProductService.saveBatch(sampleProductList);
         }
         List<SampleProject> sampleProjectList = sample.getSampleProjectList();
-        if(CollectionUtils.isNotEmpty(sampleProjectList)){//保存收费项目
-            for(SampleProject c : sampleProjectList){
+        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){
+        if (CollectionUtils.isNotEmpty(sampleShipmentList)) {//保存自定义出货
+            for (SampleShipment c : sampleShipmentList) {
                 c.setId(IdWorker.getId());
                 c.setSampleId(sample.getId());
             }
             sampleShipmentService.saveBatch(sampleShipmentList);
         }
         //交接单附件
-        ObsFileUtil.copyFileAndSave(sample.getFileList(),sample.getId(),1);
+        ObsFileUtil.copyFileAndSave(sample.getFileList(), sample.getId(), 1);
         //包装附件
-        ObsFileUtil.copyFileAndSave(sample.getPackageFileList(),sample.getId(),2);
+        ObsFileUtil.copyFileAndSave(sample.getPackageFileList(), sample.getId(), 2);
         return sample.getId();
     }
+
+    /**
+     * 重新发起
+     *
+     * @param flowId     流程id
+     * @param businessId 业务id
+     * @param flowStatus 流程状态枚举
+     * @param submitData 发起参数
+     */
+    @Override
+    public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
+        super.relaunch(flowId, businessId, flowStatus, submitData);
+
+        SampleDto sample = submitData.toJavaObject(SampleDto.class);
+        update(sample);
+    }
+
+    /**
+     * 驳回
+     *
+     * @param flowId     流程id
+     * @param businessId 业务id
+     * @param flowStatus 流程状态枚举
+     */
+    @Override
+    public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
+        super.reject(flowId, businessId, flowStatus);
+
+        Sample sample = sampleService.getById(businessId);
+        sampleService.update(q -> q
+                .eq(Sample::getId, businessId)
+                .set(Sample::getStatus, FlowStatusEnum1.REJECT.getKey())
+                .set(Sample::getUpdateTime, new Date())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+        );
+        //恢复原合同状态
+        sampleService.update(q -> q
+                .eq(Sample::getId, sample.getOldSampleId())
+                .set(Sample::getStatus, FlowStatusEnum1.PASS.getKey())
+                .set(Sample::getUpdateTime, new Date())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+        );
+    }
 }