|
@@ -8,9 +8,12 @@ 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;
|
|
|
+import com.fjhx.flow.core.FlowThreadLocalUtil;
|
|
|
+import com.fjhx.flow.enums.HandleTypeEnum;
|
|
|
import com.fjhx.sale.entity.contract.dto.ContractDto;
|
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
@@ -20,6 +23,7 @@ import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
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.BasePo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
@@ -68,7 +72,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("币种不能为空");
|
|
|
}
|
|
|
// 保存合同产品
|
|
@@ -162,4 +166,89 @@ public class ContractFlow extends FlowDelegate {
|
|
|
return contractId;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 重新发起
|
|
|
+ */
|
|
|
+ public void reStart() {
|
|
|
+ JSONObject submitData = FlowThreadLocalUtil.getCurrentData();
|
|
|
+ ContractDto contract = submitData.toJavaObject(ContractDto.class);
|
|
|
+ Long contractId = contract.getId();
|
|
|
+ Assert.notEmpty(contractId, "合同id不能为空");
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(contract.getCurrency())) {
|
|
|
+ throw new ServiceException("币种不能为空");
|
|
|
+ }
|
|
|
+ // 保存合同产品
|
|
|
+ List<ContractProduct> contractProductList = contract.getContractProductList();
|
|
|
+
|
|
|
+ // 赋值待处理数量
|
|
|
+ if (CollectionUtils.isNotEmpty(contractProductList)) {
|
|
|
+ contractProductList.forEach(item -> item.setExpendQuantity(item.getQuantity()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //-----
|
|
|
+ // 赋值城市省份信息
|
|
|
+ CustomizeAreaUtil.setAreaId(contract);
|
|
|
+
|
|
|
+ contract.setId(contractId);
|
|
|
+// contract.setCode(codingRuleService.createCode(CodingRuleEnum.CONTRACT.getKey(), contract.getBuyCorporationId()));
|
|
|
+ contract.setUserName(SecurityUtils.getUsername());
|
|
|
+ contract.setStatus(FlowStatusEnum.UNDER_REVIEW.getKey());
|
|
|
+ contract.setBuyCityId(contract.getCityId());
|
|
|
+ contract.setBuyCountryId(contract.getCountryId());
|
|
|
+ contract.setBuyProvinceId(contract.getProvinceId());
|
|
|
+ contract.setRate(ExchangeRateUtil.getCnyToCodeRate(contract.getCurrency()));
|
|
|
+ contractService.updateById(contract);
|
|
|
+
|
|
|
+ // 保存合同产品
|
|
|
+ if (CollectionUtils.isNotEmpty(contractProductList)) {
|
|
|
+ for (ContractProduct c : contractProductList) {
|
|
|
+ Assert.notEmpty(c.getId(), "合同明细id不能为空");
|
|
|
+ c.setContractId(contractId);
|
|
|
+ ObsFileUtil.editFile(c.getFileList(), c.getId());
|
|
|
+ }
|
|
|
+ contractProductService.updateBatchById(contractProductList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存收费项目
|
|
|
+ List<ContractProject> contractProjectList = contract.getContractProjectList();
|
|
|
+ if (CollectionUtils.isNotEmpty(contractProjectList)) {
|
|
|
+ for (ContractProject c : contractProjectList) {
|
|
|
+ Assert.notEmpty(c.getId(), "收费项目明细id不能为空");
|
|
|
+ c.setContractId(contractId);
|
|
|
+ }
|
|
|
+ contractProjectService.updateBatchById(contractProjectList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存自定义出货
|
|
|
+ List<ContractShipment> contractShipmentList = contract.getContractShipmentList();
|
|
|
+ if (CollectionUtils.isNotEmpty(contractShipmentList)) {
|
|
|
+ for (ContractShipment c : contractShipmentList) {
|
|
|
+ Assert.notEmpty(c.getId(), "自定义出货明细id不能为空");
|
|
|
+ c.setContractId(contractId);
|
|
|
+ }
|
|
|
+ contractShipmentService.updateBatchById(contractShipmentList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 交接单附件列表
|
|
|
+ ObsFileUtil.editFile(contract.getFileList(), contractId, 1);
|
|
|
+
|
|
|
+ // 包装指示附件列表
|
|
|
+ ObsFileUtil.editFile(contract.getPackageFileList(), contractId, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 驳回方法
|
|
|
+ */
|
|
|
+ public void reject() {
|
|
|
+ if (HandleTypeEnum.REJECT.equals(FlowThreadLocalUtil.getHandleTypeEnum())) {
|
|
|
+ contractService.update(q -> q
|
|
|
+ .eq(Contract::getId, FlowThreadLocalUtil.getBusinessId())
|
|
|
+ .set(Contract::getStatus, 20)//20为驳回
|
|
|
+ .set(Contract::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|