|
@@ -1,10 +1,8 @@
|
|
|
package com.ankaibei.workFlow.webadmin.ankaibei.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ankaibei.workFlow.common.core.constant.ErrorCodeEnum;
|
|
|
import com.ankaibei.workFlow.common.core.object.ResponseResult;
|
|
|
import com.ankaibei.workFlow.common.core.object.TokenData;
|
|
|
import com.ankaibei.workFlow.common.flow.constant.FlowConstant;
|
|
@@ -16,7 +14,7 @@ import com.ankaibei.workFlow.common.flow.vo.TaskInfoVo;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.entity.*;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.enums.CodeEnum;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.enums.DataIsDeleteEnum;
|
|
|
-import com.ankaibei.workFlow.webadmin.ankaibei.enums.ProjectPeriodEnum;
|
|
|
+import com.ankaibei.workFlow.webadmin.ankaibei.enums.ProjectStageEnum;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.enums.ProjectStatusEnum;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.mapper.*;
|
|
|
import com.ankaibei.workFlow.webadmin.ankaibei.service.ProjectInfoService;
|
|
@@ -70,27 +68,27 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
|
|
|
UserInfoEntity userInfoEntity = userInfoMapper.findByUserIdEquals((map.get("projectPrincipal")));
|
|
|
map1.put("projectPrincipal", userInfoEntity != null ? userInfoEntity.getShowName() : null);
|
|
|
String projectStage = map.get("projectStage");
|
|
|
- switch (ProjectPeriodEnum.getEnumByCode(projectStage)) {
|
|
|
+ switch (ProjectStageEnum.getEnumByCode(projectStage)) {
|
|
|
case BUSINESS_RESEARCHB:
|
|
|
- map1.put("projectStage", ProjectPeriodEnum.BUSINESS_RESEARCHB.getReason());
|
|
|
+ map1.put("projectStage", ProjectStageEnum.BUSINESS_RESEARCHB.getReason());
|
|
|
break;
|
|
|
case PRE_SALES:
|
|
|
- map1.put("projectStage", ProjectPeriodEnum.PRE_SALES.getReason());
|
|
|
+ map1.put("projectStage", ProjectStageEnum.PRE_SALES.getReason());
|
|
|
break;
|
|
|
case PROJECT_START:
|
|
|
- map1.put("projectStage", ProjectPeriodEnum.PROJECT_START.getReason());
|
|
|
+ map1.put("projectStage", ProjectStageEnum.PROJECT_START.getReason());
|
|
|
break;
|
|
|
case DELIVERY:
|
|
|
- map1.put("projectStage", ProjectPeriodEnum.DELIVERY.getReason());
|
|
|
+ map1.put("projectStage", ProjectStageEnum.DELIVERY.getReason());
|
|
|
break;
|
|
|
case CHECK_AND_ACCEPT:
|
|
|
- map1.put("projectStage", ProjectPeriodEnum.CHECK_AND_ACCEPT.getReason());
|
|
|
+ map1.put("projectStage", ProjectStageEnum.CHECK_AND_ACCEPT.getReason());
|
|
|
break;
|
|
|
case POST_PROJECT_THE_RECEIVABLE:
|
|
|
- map1.put("projectStage", ProjectPeriodEnum.POST_PROJECT_THE_RECEIVABLE.getReason());
|
|
|
+ map1.put("projectStage", ProjectStageEnum.POST_PROJECT_THE_RECEIVABLE.getReason());
|
|
|
break;
|
|
|
case CLOSE:
|
|
|
- map1.put("projectStage", ProjectPeriodEnum.CLOSE.getReason());
|
|
|
+ map1.put("projectStage", ProjectStageEnum.CLOSE.getReason());
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -132,7 +130,7 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
|
|
|
Optional<UserInfoEntity> projectPrincipal = userInfoMapper.findById(projectInfoEntity1.getProjectPrincipal());
|
|
|
UserInfoEntity userInfoEntity = projectPrincipal.orElse(null);
|
|
|
projectInfoEntity1.setProjectPrincipal(userInfoEntity != null ? userInfoEntity.getShowName() : null);
|
|
|
- projectInfoEntity1.setProjectStageStr(ProjectPeriodEnum.getEnumByCode(projectInfoEntity1.getProjectStage()).getReason());
|
|
|
+ projectInfoEntity1.setProjectStageStr(ProjectStageEnum.getEnumByCode(projectInfoEntity1.getProjectStage()).getReason());
|
|
|
return new ResMsg(CodeEnum.OK, projectInfoEntity1);
|
|
|
}
|
|
|
|
|
@@ -144,64 +142,99 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
|
|
|
return new ResMsg(CodeEnum.TNE_PROJECT_NAME_ALREADY_EXISTS);
|
|
|
}
|
|
|
}
|
|
|
- projectInfoEntity.setProjectStage(ProjectPeriodEnum.BUSINESS_RESEARCHB.getCode());
|
|
|
+ //直接保存
|
|
|
+ projectInfoEntity.setProjectStage(ProjectStageEnum.BUSINESS_RESEARCHB.getCode());
|
|
|
projectInfoEntity.setProjectStatus(ProjectStatusEnum.NORMAL.getCode());
|
|
|
+ projectInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
|
|
|
projectInfoEntity.setCreateDate(new Date());
|
|
|
+ ProjectInfoEntity save = projectInfoMapper.save(projectInfoEntity);
|
|
|
+ return new ResMsg(CodeEnum.OK, save);
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- *调用新增项目信息申请流程的启动
|
|
|
- *获取流程开始节点之后的第一个任务节点的数据
|
|
|
- *param processDefinitionKey 新建项目信息审批流程--流程标识。
|
|
|
- */
|
|
|
- String processDefinitionKey = "ProjectAddApplyFlow";
|
|
|
- ResponseResult<FlowEntry> flowEntryResult = flowTaskStart.verifyAndGetFlowEntry(processDefinitionKey);
|
|
|
- if (!flowEntryResult.isSuccess()) {
|
|
|
- return ResMsg.newInstance(CodeEnum.FAIL, flowEntryResult);
|
|
|
+ /**
|
|
|
+ * 保存后提交
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResMsg submitProjectBySave(ProjectInfoEntity projectInfoEntity) {
|
|
|
+ ResMsg resMsg = addProject(projectInfoEntity);
|
|
|
+ if (!"200".equals(resMsg.getCode())) {
|
|
|
+ return resMsg;
|
|
|
}
|
|
|
- FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish();
|
|
|
- String initTaskInfo = flowEntryPublish.getInitTaskInfo();
|
|
|
- com.ankaibei.workFlow.common.flow.vo.TaskInfoVo taskInfo = StrUtil.isBlank(initTaskInfo)
|
|
|
- ? null : JSON.parseObject(initTaskInfo, TaskInfoVo.class);
|
|
|
- if (ObjectUtils.isNotEmpty(taskInfo)) {
|
|
|
- String loginName = TokenData.takeFromRequest().getLoginName();
|
|
|
- taskInfo.setAssignedMe(StrUtil.equalsAny(
|
|
|
- taskInfo.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR));
|
|
|
+ ProjectInfoEntity data = (ProjectInfoEntity) resMsg.getData();
|
|
|
+ resMsg = projectFlowStart(data);
|
|
|
+ if (!"200".equals(resMsg.getCode())) {
|
|
|
+ return resMsg;
|
|
|
+ }
|
|
|
+ return new ResMsg(CodeEnum.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量提交项目
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResMsg submitProjectBatch(ArrayList<ProjectInfoEntity> list) {
|
|
|
+ //直接提交
|
|
|
+ for (ProjectInfoEntity info : list) {
|
|
|
+ info = projectInfoMapper.getById(info.getProjectId());
|
|
|
+ ResMsg resMsg = projectFlowStart(info);
|
|
|
+ if (!"200".equals(resMsg.getCode())) {
|
|
|
+ return resMsg;
|
|
|
+ }
|
|
|
}
|
|
|
- //用户在表单页面配置的操作按钮
|
|
|
- FlowTaskCommentDto flowTaskCommentDto = new FlowTaskCommentDto();
|
|
|
- //提交后进行到第二个节点
|
|
|
- flowTaskCommentDto.setApprovalType("agree");
|
|
|
- HashMap<String, Object> stringObjectHashMap = new HashMap<>();
|
|
|
- stringObjectHashMap.put("project_name", projectInfoEntity.getProjectName());
|
|
|
- stringObjectHashMap.put("project_stage", projectInfoEntity.getProjectStage());
|
|
|
- stringObjectHashMap.put("project_status", projectInfoEntity.getProjectStatus());
|
|
|
- stringObjectHashMap.put("project_type", projectInfoEntity.getProjectType());
|
|
|
- stringObjectHashMap.put("relevance_client", projectInfoEntity.getRelevanceClient());
|
|
|
- stringObjectHashMap.put("peoject_money", projectInfoEntity.getPeojectMoney());
|
|
|
- stringObjectHashMap.put("staff_cost", projectInfoEntity.getStaffCost());
|
|
|
- stringObjectHashMap.put("project_cost", projectInfoEntity.getProjectCost());
|
|
|
- stringObjectHashMap.put("total_cost", projectInfoEntity.getTotalCost());
|
|
|
- stringObjectHashMap.put("linkman_phone", projectInfoEntity.getLinkmanPhone());
|
|
|
- stringObjectHashMap.put("project_principal", projectInfoEntity.getProjectPrincipal());
|
|
|
- stringObjectHashMap.put("project_node", projectInfoEntity.getProjectNode());
|
|
|
- stringObjectHashMap.put("project_describe", projectInfoEntity.getProjectDescribe());
|
|
|
- stringObjectHashMap.put("create_date", projectInfoEntity.getCreateDate());
|
|
|
- ProjectInfoEntity save = projectInfoMapper.save(projectInfoEntity);
|
|
|
- stringObjectHashMap.put("project_id", save.getProjectId());
|
|
|
- JSONObject masterData = (JSONObject) JSONObject.toJSON(stringObjectHashMap);
|
|
|
- Map<String, String> map = flowTaskStart.startAndTakeUserTaskSS(processDefinitionKey, flowTaskCommentDto, null, masterData, null, null).getData();
|
|
|
- save.setProcessDefinitionId(map.get("processDefinitionId"));
|
|
|
- save.setProcessInstanceId(map.get("processInstanceId"));
|
|
|
- save.setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
|
|
|
- save.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
|
|
|
- projectInfoMapper.save(save);
|
|
|
return new ResMsg(CodeEnum.OK);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑项目后保存
|
|
|
+ *
|
|
|
+ * @param entity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public ResMsg updateProject(ProjectInfoEntity projectInfoEntity) {
|
|
|
+ public ResMsg updateProject(ProjectInfoEntity entity) {
|
|
|
+ //获取原数据对象
|
|
|
+ ProjectInfoEntity byId = projectInfoMapper.getById(entity.getProjectId());
|
|
|
+ String flowStatus = byId.getFlowTaskStatus().toString();
|
|
|
+ //将修改的信息赋值给原数据对象
|
|
|
+ byId.setProjectName(entity.getProjectName());//项目名称
|
|
|
+ byId.setProjectPeriod(entity.getProjectPeriod());//项目周期
|
|
|
+ byId.setProjectType(entity.getProjectType());//项目类型
|
|
|
+ byId.setProjectStage(entity.getProjectStage());//项目阶段
|
|
|
+ byId.setProjectMoney(entity.getProjectMoney());//项目金额
|
|
|
+ byId.setStaffCost(entity.getStaffCost());//人员成本
|
|
|
+ byId.setProjectCost(entity.getProjectCost());//项目费用
|
|
|
+ byId.setTotalCost(entity.getTotalCost());//总成本
|
|
|
+ byId.setRelevanceClient(entity.getRelevanceClient());//关联客户
|
|
|
+ byId.setLinkmanPhone(entity.getLinkmanPhone());//客户电话
|
|
|
+ byId.setProjectPrincipal(entity.getProjectPrincipal());//项目负责人
|
|
|
+ byId.setProjectDescribe(entity.getProjectDescribe());//项目描述
|
|
|
+ byId.setProjectStatus(entity.getProjectStatus());//项目状态
|
|
|
+ if (FlowTaskStatus.REFUSED.equals(flowStatus)) {
|
|
|
+ // 更新流程状态和流程信息,以便建立下一个流程实例
|
|
|
+ byId.setFlowTaskStatus(FlowTaskStatus.DRAFT);//流程状态
|
|
|
+ byId.setProcessDefinitionId(null);//流程定义id
|
|
|
+ byId.setProcessInstanceId(null);//流程实例id
|
|
|
+ }
|
|
|
+ ProjectInfoEntity save = projectInfoMapper.save(byId);
|
|
|
+ return new ResMsg(CodeEnum.OK, save);
|
|
|
+ }
|
|
|
|
|
|
- projectInfoMapper.updateProject(projectInfoEntity.getProjectStage(), projectInfoEntity.getProjectStatus(), projectInfoEntity.getProjectId());
|
|
|
+ @Override
|
|
|
+ public ResMsg submitProjectByUpdate(ProjectInfoEntity projectInfoEntity) {
|
|
|
+ //先更新数据
|
|
|
+ ResMsg resMsg = updateProject(projectInfoEntity);
|
|
|
+ ProjectInfoEntity save = (ProjectInfoEntity) resMsg.getData();
|
|
|
+ if (!"200".equals(resMsg.getCode())) {
|
|
|
+ return resMsg;
|
|
|
+ }
|
|
|
+ //再进行提交
|
|
|
+ ResMsg resMsg1 = projectFlowStart(save);
|
|
|
+ if (!"200".equals(resMsg1.getCode())) {
|
|
|
+ return resMsg1;
|
|
|
+ }
|
|
|
return new ResMsg(CodeEnum.OK);
|
|
|
}
|
|
|
|
|
@@ -407,8 +440,59 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
|
|
|
|
|
|
@Override
|
|
|
public ProjectInfoEntity getProjectInfoByCode(String projectCode) {
|
|
|
- ProjectInfoEntity pro = projectInfoMapper.findProjectInfoByCode(projectCode);
|
|
|
- return pro;
|
|
|
+ ProjectInfoEntity pro = projectInfoMapper.findProjectInfoByCode(projectCode);
|
|
|
+ return pro;
|
|
|
+ }
|
|
|
+
|
|
|
+ //提交项目--创建流程实例
|
|
|
+ public ResMsg projectFlowStart(ProjectInfoEntity projectInfoEntity) {
|
|
|
+ /**
|
|
|
+ *调用新增项目信息申请流程的启动
|
|
|
+ *获取流程开始节点之后的第一个任务节点的数据
|
|
|
+ *param processDefinitionKey 新建项目信息审批流程--流程标识。
|
|
|
+ */
|
|
|
+ String processDefinitionKey = "ProjectAddApplyFlow";
|
|
|
+ ResponseResult<FlowEntry> flowEntryResult = flowTaskStart.verifyAndGetFlowEntry(processDefinitionKey);
|
|
|
+ if (!flowEntryResult.isSuccess()) {
|
|
|
+ return ResMsg.newInstance(CodeEnum.FAIL, flowEntryResult);
|
|
|
+ }
|
|
|
+ FlowEntryPublish flowEntryPublish = flowEntryResult.getData().getMainFlowEntryPublish();
|
|
|
+ String initTaskInfo = flowEntryPublish.getInitTaskInfo();
|
|
|
+ com.ankaibei.workFlow.common.flow.vo.TaskInfoVo taskInfo = StrUtil.isBlank(initTaskInfo)
|
|
|
+ ? null : JSON.parseObject(initTaskInfo, TaskInfoVo.class);
|
|
|
+ if (ObjectUtils.isNotEmpty(taskInfo)) {
|
|
|
+ String loginName = TokenData.takeFromRequest().getLoginName();
|
|
|
+ taskInfo.setAssignedMe(StrUtil.equalsAny(
|
|
|
+ taskInfo.getAssignee(), loginName, FlowConstant.START_USER_NAME_VAR));
|
|
|
+ } //用户在表单页面配置的操作按钮
|
|
|
+ FlowTaskCommentDto flowTaskCommentDto = new FlowTaskCommentDto();
|
|
|
+ //提交后进行到第二个节点
|
|
|
+ flowTaskCommentDto.setApprovalType("agree");
|
|
|
+ HashMap<String, Object> stringObjectHashMap = new HashMap<>();
|
|
|
+ stringObjectHashMap.put("project_name", projectInfoEntity.getProjectName());
|
|
|
+ stringObjectHashMap.put("project_stage", projectInfoEntity.getProjectStage());
|
|
|
+ stringObjectHashMap.put("project_status", projectInfoEntity.getProjectStatus());
|
|
|
+ stringObjectHashMap.put("project_type", projectInfoEntity.getProjectType());
|
|
|
+ stringObjectHashMap.put("relevance_client", projectInfoEntity.getRelevanceClient());
|
|
|
+ stringObjectHashMap.put("project_money", projectInfoEntity.getProjectMoney());
|
|
|
+ stringObjectHashMap.put("staff_cost", projectInfoEntity.getStaffCost());
|
|
|
+ stringObjectHashMap.put("project_cost", projectInfoEntity.getProjectCost());
|
|
|
+ stringObjectHashMap.put("total_cost", projectInfoEntity.getTotalCost());
|
|
|
+ stringObjectHashMap.put("linkman_phone", projectInfoEntity.getLinkmanPhone());
|
|
|
+ stringObjectHashMap.put("project_principal", projectInfoEntity.getProjectPrincipal());
|
|
|
+ stringObjectHashMap.put("project_node", projectInfoEntity.getProjectNode());
|
|
|
+ stringObjectHashMap.put("project_describe", projectInfoEntity.getProjectDescribe());
|
|
|
+ stringObjectHashMap.put("create_date", projectInfoEntity.getCreateDate());
|
|
|
+ stringObjectHashMap.put("project_id", projectInfoEntity.getProjectId());
|
|
|
+ JSONObject masterData = (JSONObject) JSONObject.toJSON(stringObjectHashMap);
|
|
|
+ Map<String, String> map = flowTaskStart.startAndTakeUserTaskSS(processDefinitionKey, flowTaskCommentDto, null, masterData, null, null).getData();
|
|
|
+ projectInfoEntity.setProcessDefinitionId(map.get("processDefinitionId"));
|
|
|
+ projectInfoEntity.setProcessInstanceId(map.get("processInstanceId"));
|
|
|
+ projectInfoEntity.setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
|
|
|
+ projectInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
|
|
|
+ projectInfoMapper.save(projectInfoEntity);
|
|
|
+
|
|
|
+ return new ResMsg(CodeEnum.OK);
|
|
|
}
|
|
|
|
|
|
/**
|