|
@@ -12,9 +12,7 @@ import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.flow.core.FlowDelegate;
|
|
|
-import com.fjhx.flow.core.FlowThreadLocalUtil;
|
|
|
import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
-import com.fjhx.flow.enums.HandleTypeEnum;
|
|
|
import com.fjhx.sale.entity.serviceContract.dto.ServiceContractDto;
|
|
|
import com.fjhx.sale.entity.serviceContract.po.ServiceContract;
|
|
|
import com.fjhx.sale.entity.serviceContract.po.ServiceContractPay;
|
|
@@ -65,30 +63,10 @@ public class ServiceContractFlow extends FlowDelegate {
|
|
|
public Long start(Long flowId, JSONObject submitData) {
|
|
|
ServiceContractDto contract = submitData.toJavaObject(ServiceContractDto.class);
|
|
|
|
|
|
- //赋值城市省份信息
|
|
|
- CustomizeAreaUtil.setAreaId(contract);
|
|
|
-
|
|
|
- contract.setBuyCityId(contract.getCityId());
|
|
|
- contract.setBuyCountryId(contract.getCountryId());
|
|
|
- contract.setBuyProvinceId(contract.getProvinceId());
|
|
|
-
|
|
|
//添加服务合同编码
|
|
|
contract.setCode(codingRuleService.createCode(CodingRuleEnum.SERVICE_CONTRACT.getKey(), contract.getBuyCorporationId()));
|
|
|
-// contract.setCode(CodeEnum.SALE_QUOTATION.getCode());
|
|
|
- //添加服务合同状态
|
|
|
- contract.setStatus(ServiceContractEnum.UNDER_REVIEW.getKey());
|
|
|
- //添加服务合同信息
|
|
|
- serviceContractService.save(contract);
|
|
|
- List<ServiceContractProduct> serviceContractProductList = contract.getServiceContractProductList();
|
|
|
- if (CollectionUtils.isNotEmpty(serviceContractProductList)) {//保存报价产品信息
|
|
|
- serviceContractProductList.forEach(serviceContractProduct -> serviceContractProduct.setServiceContractId(contract.getId()));
|
|
|
- serviceContractProductService.saveBatch(serviceContractProductList);
|
|
|
- }
|
|
|
- List<ServiceContractPay> serviceContractPayList = contract.getServiceContractPayList();
|
|
|
- if (CollectionUtils.isNotEmpty(serviceContractPayList)) {//保存报价项目信息
|
|
|
- serviceContractPayList.forEach(contractPay -> contractPay.setServiceContractId(contract.getId()));
|
|
|
- serviceContractPayService.saveBatch(serviceContractPayList);
|
|
|
- }
|
|
|
+ //调用公共代码
|
|
|
+ contract = commStart(contract, 0);
|
|
|
|
|
|
return contract.getId();
|
|
|
}
|
|
@@ -117,22 +95,30 @@ public class ServiceContractFlow extends FlowDelegate {
|
|
|
public void defaultMethod(Long flowId, Long businessId, FlowStatusEnum flowStatusEnum, JSONObject submitData) {
|
|
|
//重新发起
|
|
|
if (FlowStatusEnum.READY_START.equals(flowStatusEnum)) {
|
|
|
- reStart(submitData);
|
|
|
+ ServiceContractDto contract = submitData.toJavaObject(ServiceContractDto.class);
|
|
|
+
|
|
|
+ commStart(contract, 1);
|
|
|
}
|
|
|
//驳回
|
|
|
if (FlowStatusEnum.REJECT.equals(flowStatusEnum)) {
|
|
|
- reject();
|
|
|
+ serviceContractService.update(q -> q
|
|
|
+ .eq(ServiceContract::getId, businessId)
|
|
|
+ .set(ServiceContract::getStatus, FlowStatusEnum1.REJECT.getKey())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 重新发起
|
|
|
+ * 开始公共代码抽取
|
|
|
+ *
|
|
|
+ * @param opType 操作类型 0直接发起 1重新发起
|
|
|
*/
|
|
|
- private void reStart(JSONObject submitData) {
|
|
|
- ServiceContractDto contract = submitData.toJavaObject(ServiceContractDto.class);
|
|
|
-
|
|
|
- Assert.notEmpty(contract.getId(), "服务合同id不能为空");
|
|
|
-
|
|
|
+ private ServiceContractDto commStart(ServiceContractDto contract, Integer opType) {
|
|
|
+ if (opType == 1) {
|
|
|
+ Assert.notEmpty(contract.getId(), "服务合同id不能为空");
|
|
|
+ }
|
|
|
//赋值城市省份信息
|
|
|
CustomizeAreaUtil.setAreaId(contract);
|
|
|
|
|
@@ -143,40 +129,29 @@ public class ServiceContractFlow extends FlowDelegate {
|
|
|
//添加服务合同状态
|
|
|
contract.setStatus(ServiceContractEnum.UNDER_REVIEW.getKey());
|
|
|
//添加服务合同信息
|
|
|
- serviceContractService.updateById(contract);
|
|
|
-
|
|
|
- //操作报价产品信息
|
|
|
+ serviceContractService.saveOrUpdate(contract);
|
|
|
List<ServiceContractProduct> serviceContractProductList = contract.getServiceContractProductList();
|
|
|
- //先处理被删除的数据
|
|
|
- serviceContractProductService.editLinked(serviceContractProductList, ServiceContractProduct::getServiceContractId, contract.getId());
|
|
|
- //编辑or添加报价产品信息
|
|
|
- if (CollectionUtils.isNotEmpty(serviceContractProductList)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(serviceContractProductList)) {//保存报价产品信息
|
|
|
+ if (opType == 1) {
|
|
|
+ //先处理被删除的数据
|
|
|
+ serviceContractProductService.editLinked(serviceContractProductList, ServiceContractProduct::getServiceContractId, contract.getId());
|
|
|
+ }
|
|
|
+
|
|
|
serviceContractProductList.forEach(serviceContractProduct -> serviceContractProduct.setServiceContractId(contract.getId()));
|
|
|
serviceContractProductService.saveOrUpdateBatch(serviceContractProductList);
|
|
|
}
|
|
|
-
|
|
|
- //操作报价项目信息
|
|
|
List<ServiceContractPay> serviceContractPayList = contract.getServiceContractPayList();
|
|
|
- //先处理被删除的数据
|
|
|
- serviceContractPayService.editLinked(serviceContractPayList, ServiceContractPay::getServiceContractId, contract.getId());
|
|
|
- //编辑or添加报价产品信息
|
|
|
- if (CollectionUtils.isNotEmpty(serviceContractPayList)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(serviceContractPayList)) {//保存报价项目信息
|
|
|
+ if (opType == 1) {
|
|
|
+ //先处理被删除的数据
|
|
|
+ serviceContractPayService.editLinked(serviceContractPayList, ServiceContractPay::getServiceContractId, contract.getId());
|
|
|
+ }
|
|
|
+
|
|
|
serviceContractPayList.forEach(contractPay -> contractPay.setServiceContractId(contract.getId()));
|
|
|
serviceContractPayService.saveOrUpdateBatch(serviceContractPayList);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 驳回方法
|
|
|
- */
|
|
|
- public void reject() {
|
|
|
- if (HandleTypeEnum.REJECT.equals(FlowThreadLocalUtil.getHandleTypeEnum())) {
|
|
|
- serviceContractService.update(q -> q
|
|
|
- .eq(ServiceContract::getId, FlowThreadLocalUtil.getBusinessId())
|
|
|
- .set(ServiceContract::getStatus, FlowStatusEnum1.REJECT.getKey())
|
|
|
- .set(BasePo::getUpdateTime, new Date())
|
|
|
- .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
- );
|
|
|
- }
|
|
|
+ return contract;
|
|
|
}
|
|
|
+
|
|
|
}
|