|
@@ -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());
|