瀏覽代碼

销售合同变更 历史数据还存在问题处理

yzc 1 年之前
父節點
當前提交
e886131fc2

+ 20 - 2
hx-sale/src/main/java/com/fjhx/sale/flow/ContractFlow.java

@@ -8,6 +8,7 @@ import com.fjhx.area.utils.CustomizeAreaUtil;
 import com.fjhx.common.enums.CodingRuleEnum;
 import com.fjhx.common.enums.FlowStatusEnum;
 import com.fjhx.common.service.coding.CodingRuleService;
+import com.fjhx.common.utils.Assert;
 import com.fjhx.common.utils.ExchangeRateUtil;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
@@ -28,6 +29,8 @@ import org.springframework.stereotype.Component;
 
 import java.util.Date;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * 外销合同流程
@@ -68,7 +71,7 @@ public class ContractFlow extends FlowDelegate {
     @Override
     public Long start(Long flowId, JSONObject submitData) {
         ContractDto contract = submitData.toJavaObject(ContractDto.class);
-        if(StringUtils.isEmpty(contract.getCurrency())){
+        if (StringUtils.isEmpty(contract.getCurrency())) {
             throw new ServiceException("币种不能为空");
         }
         // 保存合同产品
@@ -113,7 +116,22 @@ public class ContractFlow extends FlowDelegate {
         CustomizeAreaUtil.setAreaId(contract);
 
         contract.setId(contractId);
-        contract.setCode(codingRuleService.createCode(CodingRuleEnum.CONTRACT.getKey(), contract.getBuyCorporationId()));
+
+        //如果是变更 用用来合同号加后缀
+        if (ObjectUtils.isNotEmpty(contract.getOldContractId())) {
+            Contract oldContract = contractService.getById(contract.getOldContractId());
+            Assert.notEmpty(oldContract, "查询不到原合同信息");
+            String code = oldContract.getCode();
+            Matcher matcher = Pattern.compile(".*\\((.*?)\\)$").matcher(code);
+            int index = 2;
+            if (matcher.find()) {
+                index = (Integer.parseInt(matcher.group(1)) + 1);
+                code = code.substring(0, code.lastIndexOf("("));
+            }
+            contract.setCode(code + "(" + index + ")");
+        } else {
+            contract.setCode(codingRuleService.createCode(CodingRuleEnum.CONTRACT.getKey(), contract.getBuyCorporationId()));
+        }
         contract.setUserName(SecurityUtils.getUsername());
         contract.setStatus(FlowStatusEnum.UNDER_REVIEW.getKey());
         contract.setBuyCityId(contract.getCityId());

+ 0 - 12
hx-sale/src/main/java/com/fjhx/sale/flow/ContractUpdateFlow.java

@@ -19,8 +19,6 @@ import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 /**
@@ -93,16 +91,6 @@ public class ContractUpdateFlow extends FlowDelegate {
 
         }
 
-        //变更后往合同编号后面加后缀
-        String code = contract.getCode();
-        Matcher matcher = Pattern.compile(".*\\((.*?)\\)$").matcher(code);
-        int index = 2;
-        if (matcher.find()) {
-            index = (Integer.parseInt(matcher.group(1)) + 1);
-            code = code.substring(0, code.lastIndexOf("("));
-        }
-        contract.setCode(code + "(" + index + ")");
-
         return contractFlow.start(contract);
     }
 

+ 2 - 1
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractProductServiceImpl.java

@@ -114,7 +114,8 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
      */
     public Page<ContractProductVo> commPage(IWrapper<ContractProduct> wrapper, ContractProductSelectDto dto) {
         wrapper.orderByDesc("t1", ContractProduct::getCreateTime);
-        wrapper.between("t2", Contract::getStatus, FlowStatusEnum.PASS.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
+//        wrapper.between("t2", Contract::getStatus, FlowStatusEnum.PASS.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
+        wrapper.eq("t2", Contract::getStatus, FlowStatusEnum.PASS.getKey());
         if (ObjectUtil.isNotEmpty(dto.getDataType()) && dto.getDataType() == 0) {//合同交接单
             wrapper.ne("t1", ContractProduct::getExpendQuantity, BigDecimal.ZERO);
         }