diff --git a/src/main/java/com/xqopen/kehui/project/action/ProjectInitComtroller.java b/src/main/java/com/xqopen/kehui/project/action/ProjectInitComtroller.java index c749023..78b5cf4 100644 --- a/src/main/java/com/xqopen/kehui/project/action/ProjectInitComtroller.java +++ b/src/main/java/com/xqopen/kehui/project/action/ProjectInitComtroller.java @@ -1,5 +1,6 @@ package com.xqopen.kehui.project.action; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.support.spring.FastJsonJsonView; @@ -12,6 +13,9 @@ import com.xqopen.kehui.common.entity.SystemUserLogin; import com.xqopen.kehui.common.service.*; import com.xqopen.kehui.exception.ErrorCode; import com.xqopen.kehui.exception.XQException; +import com.xqopen.kehui.flows.dto.FlowsRecordList; +import com.xqopen.kehui.flows.dto.FlowsRecordResp; +import com.xqopen.kehui.flows.dto.FlowsTaskItem; import com.xqopen.kehui.flows.service.BaseActivitiApi; import com.xqopen.kehui.flows.service.IFlowsCategoryService; import com.xqopen.kehui.flows.service.IFlowsService; @@ -125,34 +129,34 @@ public class ProjectInitComtroller implements ProjectInitApi { } JSONObject ext = infoReq.getExt(); JSONArray jsonArray = ext.getJSONArray("membersList"); - if(ObjectUtils.isEmpty(ext.get("imprintDate"))){ + if (ObjectUtils.isEmpty(ext.get("imprintDate"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("openRange"))){ + if (ObjectUtils.isEmpty(ext.get("openRange"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("executeDepts"))){ + if (ObjectUtils.isEmpty(ext.get("executeDepts"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("permissionsPeople"))){ + if (ObjectUtils.isEmpty(ext.get("permissionsPeople"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("cC"))){ + if (ObjectUtils.isEmpty(ext.get("cC"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("difficultyFactor"))){ + if (ObjectUtils.isEmpty(ext.get("difficultyFactor"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("gross"))){ + if (ObjectUtils.isEmpty(ext.get("gross"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("budget"))){ + if (ObjectUtils.isEmpty(ext.get("budget"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("scheme"))){ + if (ObjectUtils.isEmpty(ext.get("scheme"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } - if(ObjectUtils.isEmpty(ext.get("goal"))){ + if (ObjectUtils.isEmpty(ext.get("goal"))) { throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null); } List membersList = ext.getJSONArray("membersList").toJavaList(ProjectMembers.class); @@ -680,6 +684,23 @@ public class ProjectInitComtroller implements ProjectInitApi { return ApiResponse.fillFail("操作失败!"); } + /** + * 通过账号id拿到人事对象 + * + * @param userId + * @return + */ + private PersonalMember getPersonalByUserLogin(Long userId) { + EntityWrapper userLoginEntityWrapper = new EntityWrapper<>(); + userLoginEntityWrapper.eq(SystemUserLogin.ID_, userId); + userLoginEntityWrapper.eq(SystemUserLogin.IS_DELETED, false); + SystemUserLogin systemUserLogin = userLoginService.selectOne(userLoginEntityWrapper); + EntityWrapper personalMemberEntityWrapper = new EntityWrapper<>(); + personalMemberEntityWrapper.eq(PersonalMember.ID_, systemUserLogin.getUserinfoId()); + personalMemberEntityWrapper.eq(PersonalMember.IS_DELETED, false); + return personalMemberService.selectOne(personalMemberEntityWrapper); + } + /** * 审核方法体 * @@ -693,13 +714,11 @@ public class ProjectInitComtroller implements ProjectInitApi { if (!ObjectUtils.isEmpty(ext)) { if (!ObjectUtils.isEmpty(map)) { String taskName = String.valueOf(map.get("taskName")); - ext.put("taskName", taskName); - ext.put("endExecutor", map.get("endExecutor")); //添加审核意见 - Object projectManagerOpinion = map.get("projectManagerOpinion") != null ? ext.put("projectManagerOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; - Object projectAdminOpinion = map.get("projectAdminOpinion") != null ? ext.put("projectAdminOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; - Object branchLeaderOpinion = map.get("branchLeaderOpinion") != null ? ext.put("branchLeaderOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; - Object mainLeaderOpinion = map.get("mainLeaderOpinion") != null ? ext.put("mainLeaderOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; +// Object projectManagerOpinion = map.get("projectManagerOpinion") != null ? ext.put("projectManagerOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; +// Object projectAdminOpinion = map.get("projectAdminOpinion") != null ? ext.put("projectAdminOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; +// Object branchLeaderOpinion = map.get("branchLeaderOpinion") != null ? ext.put("branchLeaderOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; +// Object mainLeaderOpinion = map.get("mainLeaderOpinion") != null ? ext.put("mainLeaderOpinion", String.valueOf(map.get("projectManagerOpinion"))) : null; if (ext.containsKey("endHistorical")) {//结项历史委托 String endHistorical = String.valueOf(ext.get("endHistorical")); if (!endHistorical.contains(String.valueOf(map.get("userId")))) { @@ -707,6 +726,58 @@ public class ProjectInitComtroller implements ProjectInitApi { ext.put("endHistorical", endHistorical); } } + + //流转记录 + FlowsRecordResp record = new FlowsRecordResp(); + List ls = new ArrayList<>(); + FlowsRecordList taskItemsList = new FlowsRecordList(); + List taskItems = new ArrayList<>(); + String examine = String.valueOf(map.get("examine")); + String opinion = String.valueOf(map.get("opinion")); + if (ext.containsKey("endRecord")) { + record = ((JSONObject) ext.get("endRecord")).toJavaObject(FlowsRecordResp.class);; + ls = record.getLs(); + taskItemsList=ls.get(0); + taskItems = taskItemsList.getTaskItems(); + Collections.reverse(taskItems); +// taskItemsList = l.getTaskItems(); + FlowsTaskItem taskItem = taskItems.get(taskItems.size()-1); + taskItem.setDueDate(new Date()); + taskItem.setActionName("0".equals(examine) ? "同意" : "驳回"); + if (StringUtils.isEmpty(opinion) ||"null".equals(opinion)) {//审批意见 + taskItem.setActionReason("0".equals(examine) ? "同意" : "驳回"); + } else taskItem.setActionReason(String.valueOf(map.get("opinion"))); + taskItems.set(taskItems.size() - 1, taskItem); + FlowsTaskItem taskItem1 = new FlowsTaskItem(); + taskItem1.setNodeName(taskName); + taskItem1.setAssigneeName(getPersonalByUserLogin(Long.parseLong(String.valueOf(map.get("endExecutor")))).getPersonName()); + taskItems.add(taskItem1); + Collections.reverse(taskItems); + taskItemsList.setTaskItems(taskItems); + ls.set(0, taskItemsList); + record.setLs(ls); + } else { + FlowsTaskItem taskItem = new FlowsTaskItem(); + taskItem.setDueDate(new Date()); + taskItem.setAssigneeName(getPersonalByUserLogin(Long.parseLong(ext.getString("endExecutor"))).getPersonName()); + taskItem.setNodeName(ext.getString("taskName")); + taskItem.setActionName("0".equals(examine) ? "同意" : "驳回"); + if (StringUtils.isEmpty(opinion) || "null".equals(opinion)) {//审批意见 + taskItem.setActionReason("0".equals(examine) ? "同意" : "驳回"); + } else taskItem.setActionReason(String.valueOf(map.get("opinion"))); + taskItems.add(taskItem); + FlowsTaskItem taskItem1 = new FlowsTaskItem(); + taskItem1.setNodeName(taskName); + taskItem1.setAssigneeName(getPersonalByUserLogin(Long.parseLong(String.valueOf(map.get("endExecutor")))).getPersonName()); + taskItems.add(taskItem1); + Collections.reverse(taskItems);//倒转 + taskItemsList.setTaskItems(taskItems); + ls.add(taskItemsList); + record.setLs(ls); + } + ext.put("endRecord", record); + ext.put("taskName", taskName); + ext.put("endExecutor", map.get("endExecutor")); projectInfo.setExt(ext); return infoService.updateById(projectInfo); }