|
@@ -1,14 +1,15 @@
|
|
|
package com.fjhx.sale.flow;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
|
-import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.enums.CodingRuleEnum;
|
|
|
import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
+import com.fjhx.common.service.file.FtpFileService;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
|
import com.fjhx.flow.enums.FlowStatusEnum;
|
|
@@ -16,7 +17,6 @@ import com.fjhx.sale.entity.contract.dto.ContractDto;
|
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
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.service.contract.ContractProductService;
|
|
|
import com.fjhx.sale.service.contract.ContractProjectService;
|
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
@@ -30,6 +30,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -57,6 +58,8 @@ public class ContractFlow extends FlowDelegate {
|
|
|
|
|
|
@Autowired
|
|
|
private ContractShipmentService contractShipmentService;
|
|
|
+ @Autowired
|
|
|
+ private FtpFileService ftpFileService;
|
|
|
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
@@ -76,7 +79,7 @@ public class ContractFlow extends FlowDelegate {
|
|
|
|
|
|
contract.setFlowId(flowId);
|
|
|
|
|
|
- if(StringUtils.isEmpty(contract.getCurrency())){
|
|
|
+ if (StringUtils.isEmpty(contract.getCurrency())) {
|
|
|
throw new ServiceException("币种不能为空");
|
|
|
}
|
|
|
contract.setCode(codingRuleService.createCode(CodingRuleEnum.CONTRACT.getKey(), contract.getBuyCorporationId()));
|
|
@@ -123,53 +126,42 @@ public class ContractFlow extends FlowDelegate {
|
|
|
contract.setBuyCountryId(contract.getCountryId());
|
|
|
contract.setBuyProvinceId(contract.getProvinceId());
|
|
|
contract.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey());
|
|
|
-// contract.setRate(ExchangeRateUtil.getCnyToCodeRate(contract.getCurrency()));
|
|
|
contractService.saveOrUpdate(contract);
|
|
|
|
|
|
// 保存合同产品
|
|
|
List<ContractProduct> contractProductList = contract.getContractProductList();
|
|
|
- //重新发起删除被删掉的产品
|
|
|
- contractProductService.editLinked(contractProductList, ContractProduct::getContractId, contract.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(contractProductList)) {
|
|
|
- for (ContractProduct c : contractProductList) {
|
|
|
- c.setContractId(contract.getId());
|
|
|
+ contractProductList = ObjectUtil.isEmpty(contractProductList) ? new ArrayList<>() : contractProductList;
|
|
|
+ for (ContractProduct c : contractProductList) {
|
|
|
+ //对新数据创建id
|
|
|
+ c.setId(ObjectUtil.isEmpty(c.getId()) ? IdWorker.getId() : c.getId());
|
|
|
+ //赋值合同Id
|
|
|
+ c.setContractId(contract.getId());
|
|
|
+ //保存设计稿图
|
|
|
+ ObsFileUtil.editFile(c.getFileList(), c.getId());
|
|
|
+ //保存生产源文件
|
|
|
+ String prodFilePath = c.getProdFilePath();
|
|
|
+ if (ObjectUtil.isNotEmpty(prodFilePath) && prodFilePath.startsWith("/temp")) {
|
|
|
+ String targetFolderPath = String.format("/contractProduct/%s", c.getId());
|
|
|
+ ftpFileService.moveFolder(prodFilePath, targetFolderPath);
|
|
|
+ c.setProdFilePath(targetFolderPath);
|
|
|
}
|
|
|
- contractProductService.saveOrUpdateBatch(contractProductList);
|
|
|
}
|
|
|
+ contractProductService.editLinked(contractProductList, ContractProduct::getContractId, contract.getId());
|
|
|
|
|
|
// 保存收费项目
|
|
|
List<ContractProject> contractProjectList = contract.getContractProjectList();
|
|
|
- //重新发起删除被删掉的收费项目
|
|
|
- contractProjectService.editLinked(contractProjectList, ContractProject::getContractId, contract.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(contractProjectList)) {
|
|
|
- for (ContractProject c : contractProjectList) {
|
|
|
- c.setContractId(contract.getId());
|
|
|
- }
|
|
|
- contractProjectService.saveOrUpdateBatch(contractProjectList);
|
|
|
- }
|
|
|
-
|
|
|
- // 保存自定义出货
|
|
|
- List<ContractShipment> contractShipmentList = contract.getContractShipmentList();
|
|
|
- //重新发起删除被删掉的出货计划
|
|
|
- contractShipmentService.editLinked(contractShipmentList, ContractShipment::getContractId, contract.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(contractShipmentList)) {
|
|
|
- for (ContractShipment c : contractShipmentList) {
|
|
|
- c.setContractId(contract.getId());
|
|
|
- }
|
|
|
- contractShipmentService.saveOrUpdateBatch(contractShipmentList);
|
|
|
+ contractProjectList = ObjectUtil.isEmpty(contractProjectList) ? new ArrayList<>() : contractProjectList;
|
|
|
+ for (ContractProject c : contractProjectList) {
|
|
|
+ c.setContractId(contract.getId());
|
|
|
}
|
|
|
-
|
|
|
- // 交接单附件列表
|
|
|
- ObsFileUtil.editFile(contract.getFileList(), contract.getId(), 1);
|
|
|
-
|
|
|
- // 包装指示附件列表
|
|
|
- ObsFileUtil.editFile(contract.getPackageFileList(), contract.getId(), 2);
|
|
|
+ contractProjectService.editLinked(contractProjectList, ContractProject::getContractId, contract.getId());
|
|
|
|
|
|
return contract.getId();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 重新发起
|
|
|
+ *
|
|
|
* @param flowId
|
|
|
* @param businessId
|
|
|
* @param flowStatus
|
|
@@ -180,7 +172,7 @@ public class ContractFlow extends FlowDelegate {
|
|
|
public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
|
|
|
//删除采购合同
|
|
|
ContractDto contractDto = submitData.toJavaObject(ContractDto.class);
|
|
|
- if(ObjectUtils.isEmpty(contractDto)){
|
|
|
+ if (ObjectUtils.isEmpty(contractDto)) {
|
|
|
throw new ServiceException("合同数据不能为空");
|
|
|
}
|
|
|
start(contractDto);
|
|
@@ -188,18 +180,19 @@ public class ContractFlow extends FlowDelegate {
|
|
|
|
|
|
/**
|
|
|
* 驳回
|
|
|
+ *
|
|
|
* @param flowId
|
|
|
* @param businessId
|
|
|
* @param flowStatus
|
|
|
*/
|
|
|
@Override
|
|
|
public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
|
|
|
- contractService.update(q -> q
|
|
|
- .eq(Contract::getId, businessId)
|
|
|
- .set(Contract::getStatus, 20)//20为驳回
|
|
|
- .set(Contract::getUpdateTime, new Date())
|
|
|
- .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
- );
|
|
|
+ contractService.update(q -> q
|
|
|
+ .eq(Contract::getId, businessId)
|
|
|
+ .set(Contract::getStatus, 20)//20为驳回
|
|
|
+ .set(Contract::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
|
|
|
}
|
|
|
|