|
@@ -1,10 +1,12 @@
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.alipay.sofa.runtime.api.annotation.SofaService;
|
|
import com.alipay.sofa.runtime.api.annotation.SofaService;
|
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
import com.winsea.svc.base.base.entity.CommonDepartment;
|
|
import com.winsea.svc.base.base.entity.CommonDepartment;
|
|
import com.winsea.svc.base.base.util.DateUtils;
|
|
import com.winsea.svc.base.base.util.DateUtils;
|
|
|
|
+import com.winsea.svc.base.workflow.entity.Workflow;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
|
|
import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
@@ -66,6 +68,8 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
@Autowired
|
|
@Autowired
|
|
private ITranCarInfoService tranCarInfoService;
|
|
private ITranCarInfoService tranCarInfoService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private INewWorkflowService workflowService;
|
|
|
|
+ @Autowired
|
|
private IPriceConfirmationSheetService priceConfirmationSheetService;
|
|
private IPriceConfirmationSheetService priceConfirmationSheetService;
|
|
@Value("${file-root-path}")
|
|
@Value("${file-root-path}")
|
|
private String localPath;
|
|
private String localPath;
|
|
@@ -82,8 +86,12 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
// 主表信息新增
|
|
// 主表信息新增
|
|
// 新增主键id
|
|
// 新增主键id
|
|
contractManagementInfo.setId(IdGenerator.generateUUID());
|
|
contractManagementInfo.setId(IdGenerator.generateUUID());
|
|
- contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_WAIT.getFlag());
|
|
|
|
- contractManagementInfo.setStatus(StatusEnum.CONTRACT_WAIT.getName());
|
|
|
|
|
|
+
|
|
|
|
+ // 期货插入状态
|
|
|
|
+ if("2".equals(contractManagementInfo.getGoodsType())){
|
|
|
|
+ contractManagementInfo.setStatusFlag(StatusEnum.CONTRACT_WAIT.getFlag());
|
|
|
|
+ contractManagementInfo.setStatus(StatusEnum.CONTRACT_WAIT.getName());
|
|
|
|
+ }
|
|
//判断合同编号是否唯一
|
|
//判断合同编号是否唯一
|
|
List<ContractManagementInfo> contractManagementInfos =
|
|
List<ContractManagementInfo> contractManagementInfos =
|
|
contractManagementInfoService.selectList(new EntityWrapper<ContractManagementInfo>()
|
|
contractManagementInfoService.selectList(new EntityWrapper<ContractManagementInfo>()
|
|
@@ -115,6 +123,63 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
boolean one = this.insert(contractManagementInfo);
|
|
boolean one = this.insert(contractManagementInfo);
|
|
boolean two = contractGoodsInfoService.insert(contractGoodsInfo);
|
|
boolean two = contractGoodsInfoService.insert(contractGoodsInfo);
|
|
boolean three = contractProcessInfoService.insert(contractProcessInfo);
|
|
boolean three = contractProcessInfoService.insert(contractProcessInfo);
|
|
|
|
+
|
|
|
|
+ // 根据类型进入审核
|
|
|
|
+ if("1".equals(contractManagementInfo.getGoodsType())) {
|
|
|
|
+ if ("1".equals(contractManagementInfo.getContractType())) {
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(contractManagementInfo.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(contractManagementInfo.getCompId(), "SALE-CONTRACT-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ contractManagementInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.activateInstance(contractManagementInfo.getWorkflowId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(contractManagementInfo.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(contractManagementInfo.getCompId(), "BUY-CONTRACT-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ contractManagementInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.activateInstance(contractManagementInfo.getWorkflowId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// 假如 都成功返回ok
|
|
// 假如 都成功返回ok
|
|
if (one && two && three) {
|
|
if (one && two && three) {
|
|
// 插入操作历史
|
|
// 插入操作历史
|
|
@@ -182,6 +247,62 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
warehouseBaseInfo.setPersonPhone(contractManagementInfo.getPersonPhone());
|
|
warehouseBaseInfo.setPersonPhone(contractManagementInfo.getPersonPhone());
|
|
warehouseBaseInfoService.updateById(warehouseBaseInfo);
|
|
warehouseBaseInfoService.updateById(warehouseBaseInfo);
|
|
}
|
|
}
|
|
|
|
+ // 根据类型进入审核
|
|
|
|
+ if("1".equals(contractManagementInfo.getGoodsType())) {
|
|
|
|
+ if ("1".equals(contractManagementInfo.getContractType())) {
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(contractManagementInfo.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(contractManagementInfo.getCompId(), "SALE-CONTRACT-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ contractManagementInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.activateInstance(contractManagementInfo.getWorkflowId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ boolean isStartWorkflow = StringUtils.isBlank(contractManagementInfo.getWorkflowId());
|
|
|
|
+ // 不是退回的单子
|
|
|
|
+ if (isStartWorkflow) {
|
|
|
|
+ Workflow workflow = workflowService
|
|
|
|
+ .findLatestWorkflowByBusinessCodeByApp(contractManagementInfo.getCompId(), "BUY-CONTRACT-APPROVE");
|
|
|
|
+ // 没配置审核流程,直接结束并处理信息
|
|
|
|
+ if (workflow == null) {
|
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ // 开启审核流
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ // 设置状态 已提交审核
|
|
|
|
+ contractManagementInfo.setWorkflowId(workflow.getId());
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.startInstance(workflow.getId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 退回的单子 再启用
|
|
|
|
+ else {
|
|
|
|
+
|
|
|
|
+ this.updateById(contractManagementInfo);
|
|
|
|
+ workflowService.activateInstance(contractManagementInfo.getWorkflowId(), contractManagementInfo.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// 货物信息编辑
|
|
// 货物信息编辑
|
|
boolean two = contractGoodsInfoService.updateById(contractManagementInfo.getContractGoodsInfo());
|
|
boolean two = contractGoodsInfoService.updateById(contractManagementInfo.getContractGoodsInfo());
|
|
//流程编辑
|
|
//流程编辑
|
|
@@ -311,6 +432,13 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
|
|
ContractProcessInfo contractProcessInfo = contractProcessInfoService.selectOne(new EntityWrapper<ContractProcessInfo>().eq(ContractGoodsInfo.QueryFiles.CONTRACT_ID, id));
|
|
ContractProcessInfo contractProcessInfo = contractProcessInfoService.selectOne(new EntityWrapper<ContractProcessInfo>().eq(ContractGoodsInfo.QueryFiles.CONTRACT_ID, id));
|
|
contractManagementInfo.setContractGoodsInfo(contractGoodsInfo);
|
|
contractManagementInfo.setContractGoodsInfo(contractGoodsInfo);
|
|
contractManagementInfo.setContractProcessInfo(contractProcessInfo);
|
|
contractManagementInfo.setContractProcessInfo(contractProcessInfo);
|
|
|
|
+ String taskId = "";
|
|
|
|
+ // 只有待审核状态才有taskId
|
|
|
|
+ if (StringUtils.isNotBlank(contractManagementInfo.getWorkflowId())) {
|
|
|
|
+ JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(contractManagementInfo.getWorkflowId()), contractManagementInfo.getId());
|
|
|
|
+ taskId = jsonObject.getString("taskId");
|
|
|
|
+ contractManagementInfo.setTaskId(taskId);
|
|
|
|
+ }
|
|
return contractManagementInfo;
|
|
return contractManagementInfo;
|
|
}
|
|
}
|
|
|
|
|