Преглед изворни кода

项目登记流程调用中的伪状态问题

user5 пре 4 година
родитељ
комит
974cfc0c00

+ 39 - 10
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralCostProjectRecordsController.java

@@ -204,8 +204,16 @@ public class RuralCostProjectRecordsController extends BaseController {
 //            projectRecords.setProjectStatus(ProjectStatusEnum.IN_APRL.getValue());
             if (!projectRecords.getIsNewRecord()) {//编辑表单保存
                 RuralProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
-                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
-                projectRecordsService.saveProject(t, ProjectStatusEnum.IN_APRL);//保存
+				if(t.getProjectStatus() == 3 || t.getProjectStatus() == 1) {
+					MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+					projectRecordsService.saveProject(t, ProjectStatusEnum.IN_APRL);//保存
+				}else if(t.getProjectStatus() == 2){
+					addMessage(redirectAttributes, "项目已送审,无法重复送审");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}else if(t.getProjectStatus() == 5){
+					addMessage(redirectAttributes, "项目已登记完成,无法再次送审");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}
             } else {//新增表单保存
 				//添加查询类型(造价审核)
 				projectRecords.setProjectType("2");
@@ -231,8 +239,16 @@ public class RuralCostProjectRecordsController extends BaseController {
 //            projectRecords.setProjectStatus(ProjectStatusEnum.TSTORE.getValue());
             if (!projectRecords.getIsNewRecord()) {//编辑表单保存
                 RuralProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
-                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
-                projectRecordsService.saveProject(t, ProjectStatusEnum.TSTORE);//保存
+				if(t.getProjectStatus() == 1) {
+					MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+					projectRecordsService.saveProject(t, ProjectStatusEnum.TSTORE);//保存
+				}else if(t.getProjectStatus() == 2){
+					addMessage(redirectAttributes, "项目已送审,无法暂存");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}else if(t.getProjectStatus() == 5){
+					addMessage(redirectAttributes, "项目已登记完成,无法暂存");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}
             } else {//新增表单保存
             	// 添加查询类型(工程咨询)
 				projectRecords.setProjectType("2");
@@ -442,12 +458,14 @@ public class RuralCostProjectRecordsController extends BaseController {
 		HashMap<String, String> requestMap = findRequestMap(request);
 		String processInstanceId = requestMap.get("processInstanceId");
 		String id = requestMap.get("id");
+		//获取项目状态
+		Integer projectStatus = Integer.parseInt(requestMap.get("projectStatus"));
 		try {
-            RuralProjectRecords projectRecords = projectRecordsService.get(id);
-            if(5==projectRecords.getProjectStatus()){
-                addMessage(redirectAttributes, "项目登记已审批通过,无法撤回");
-                return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralCostProjectRecords/?repage";
-            }
+			RuralProjectRecords projectRecords = projectRecordsService.get(id);
+			if(projectRecords.getProjectStatus() != projectStatus){
+				addMessage(redirectAttributes, "项目登记不是送审状态,无法撤回");
+				return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+			}
             projectRecordsService.cancelProcess(projectRecords);
 			addMessage(redirectAttributes, "撤回该项目登记成功");
 		}catch (Exception e){
@@ -556,7 +574,7 @@ public class RuralCostProjectRecordsController extends BaseController {
 	@RequestMapping("saveAudit")
 	public String saveAudit(RuralProjectRecords projectRecords, Model model,
 							@RequestParam(value = "upload_files", required = false) MultipartFile[] upload_files,
-							RedirectAttributes redirectAttributes)  {
+							RedirectAttributes redirectAttributes,Integer saveAuditFlag)  {
 		String home = projectRecords.getHome();
 		try {
 			String taskDefKey = projectRecords.getAct().getTaskDefKey();
@@ -569,6 +587,17 @@ public class RuralCostProjectRecordsController extends BaseController {
 			if ("yes".equals(flag) && (users==null || users.size()==0)){
 				addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
 			}else {
+				RuralProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
+				if(null != saveAuditFlag){
+					if(1 == saveAuditFlag && t.getProjectStatus() != 4 && t.getProjectStatus() != 5){
+						addMessage(redirectAttributes, "项目已送审,请勿重复送审");
+						return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+					}
+				}
+				if(t.getProjectStatus() == 5){
+					addMessage(redirectAttributes, "项目已登记完成,无法再次送审");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}
 				String str = projectRecordsService.auditSave(projectRecords,users);
 				addMessage(redirectAttributes, str);
 			}

+ 37 - 7
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectRecordsController.java

@@ -180,8 +180,16 @@ public class RuralProjectRecordsController extends BaseController {
 //            projectRecords.setProjectStatus(ProjectStatusEnum.IN_APRL.getValue());
             if (!projectRecords.getIsNewRecord()) {//编辑表单保存
                 RuralProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
-                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
-                projectRecordsService.saveProject(t, ProjectStatusEnum.IN_APRL);//保存
+				if(t.getProjectStatus() == 3 || t.getProjectStatus() == 1) {
+					MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+					projectRecordsService.saveProject(t, ProjectStatusEnum.IN_APRL);//保存
+				}else if(t.getProjectStatus() == 2){
+					addMessage(redirectAttributes, "项目已送审,无法重复送审");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}else if(t.getProjectStatus() == 5){
+					addMessage(redirectAttributes, "项目已登记完成,无法再次送审");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}
             } else {//新增表单保存
 				//添加查询类型(工程咨询)
 				projectRecords.setProjectType("1");
@@ -207,8 +215,16 @@ public class RuralProjectRecordsController extends BaseController {
 //            projectRecords.setProjectStatus(ProjectStatusEnum.TSTORE.getValue());
             if (!projectRecords.getIsNewRecord()) {//编辑表单保存
                 RuralProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
-                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
-                projectRecordsService.saveProject(t, ProjectStatusEnum.TSTORE);//保存
+				if(t.getProjectStatus() == 1) {
+					MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
+					projectRecordsService.saveProject(t, ProjectStatusEnum.TSTORE);//保存
+				}else if(t.getProjectStatus() == 2){
+					addMessage(redirectAttributes, "项目已送审,无法暂存");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}else if(t.getProjectStatus() == 5){
+					addMessage(redirectAttributes, "项目已登记完成,无法暂存");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}
             } else {//新增表单保存
             	// 添加查询类型(工程咨询)
 				projectRecords.setProjectType("1");
@@ -422,10 +438,12 @@ public class RuralProjectRecordsController extends BaseController {
 		HashMap<String, String> requestMap = findRequestMap(request);
 		String processInstanceId = requestMap.get("processInstanceId");
 		String id = requestMap.get("id");
+		//获取项目状态
+		Integer projectStatus = Integer.parseInt(requestMap.get("projectStatus"));
 		try {
             RuralProjectRecords projectRecords = projectRecordsService.get(id);
-            if(5==projectRecords.getProjectStatus()){
-                addMessage(redirectAttributes, "项目登记已审批通过,无法撤回");
+            if(projectRecords.getProjectStatus() != projectStatus){
+                addMessage(redirectAttributes, "项目登记不是送审状态,无法撤回");
                 return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
             }
             projectRecordsService.cancelProcess(projectRecords);
@@ -536,7 +554,7 @@ public class RuralProjectRecordsController extends BaseController {
 	@RequestMapping("saveAudit")
 	public String saveAudit(RuralProjectRecords projectRecords, Model model,
 							@RequestParam(value = "upload_files", required = false) MultipartFile[] upload_files,
-							RedirectAttributes redirectAttributes)  {
+							RedirectAttributes redirectAttributes,Integer saveAuditFlag)  {
 		String home = projectRecords.getHome();
 		try {
 			String taskDefKey = projectRecords.getAct().getTaskDefKey();
@@ -549,6 +567,18 @@ public class RuralProjectRecordsController extends BaseController {
 			if ("yes".equals(flag) && (users==null || users.size()==0)){
 				addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
 			}else {
+				RuralProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
+				if(null != saveAuditFlag){
+					if(1 == saveAuditFlag && t.getProjectStatus() != 4 && t.getProjectStatus() != 5){
+						addMessage(redirectAttributes, "项目已送审,请勿重复送审");
+						return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+					}
+				}
+				if(t.getProjectStatus() == 5){
+					addMessage(redirectAttributes, "项目已登记完成,无法再次送审");
+					return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
+				}
+
 				String str = projectRecordsService.auditSave(projectRecords,users);
 				addMessage(redirectAttributes, str);
 			}

+ 1 - 1
src/main/webapp/webpage/modules/ruralprojectrecords/cost/ruralCostProjectRecordsList.jsp

@@ -327,7 +327,7 @@
                         }
                         if(d.cancancel != undefined && d.cancancel =="1")
                         {
-                            xml+="<a href=\"${ctx}/ruralProject/ruralCostProjectRecords/revoke?id=" + d.id + "&processInstanceId=" + d.procId + "\" onclick=\"return confirmx('确认要撤回该项目审批吗?', this.href)\" class=\"op-btn op-btn-cancel\" ><i class=\"glyphicon glyphicon-share-alt\"></i> 撤回</a>";
+                            xml+="<a href=\"${ctx}/ruralProject/ruralCostProjectRecords/revoke?id=" + d.id + "&processInstanceId=" + d.procId + "&projectStatus="+d.projectStatus+"\" onclick=\"return confirmx('确认要撤回该项目审批吗?', this.href)\" class=\"op-btn op-btn-cancel\" ><i class=\"glyphicon glyphicon-share-alt\"></i> 撤回</a>";
                         }
                         if(d.canedit3 != undefined && d.canedit3 =="1")
                         {

+ 1 - 0
src/main/webapp/webpage/modules/ruralprojectrecords/cost/ruralCostProjectRecordsModify.jsp

@@ -558,6 +558,7 @@
             <form:hidden id="flag" path="act.flag"/>
 		    <form:hidden path="workContractInfo.client.id" id="contractClientId" value="${workContractInfo.client.id}"/>
             <input type="hidden" id="flagFile" value="">
+            <input type="hidden" id="saveAuditFlag" name="saveAuditFlag" value="1">
 
             <input type="hidden" id="workClientLinkmanInfo" value="${projectRecords.workClientLinkmanList}">
             <div class="form-group layui-row first">

+ 1 - 1
src/main/webapp/webpage/modules/ruralprojectrecords/ruralProjectRecordsList.jsp

@@ -358,7 +358,7 @@
                         }
                         if(d.cancancel != undefined && d.cancancel =="1")
                         {
-                            xml+="<a href=\"${ctx}/ruralProject/ruralProjectRecords/revoke?id=" + d.id + "&processInstanceId=" + d.procId + "\" onclick=\"return confirmx('确认要撤回该项目审批吗?', this.href)\" class=\"op-btn op-btn-cancel\" ><i class=\"glyphicon glyphicon-share-alt\"></i> 撤回</a>";
+                            xml+="<a href=\"${ctx}/ruralProject/ruralProjectRecords/revoke?id=" + d.id + "&processInstanceId=" + d.procId + "&projectStatus="+d.projectStatus+"\" onclick=\"return confirmx('确认要撤回该项目审批吗?', this.href)\" class=\"op-btn op-btn-cancel\" ><i class=\"glyphicon glyphicon-share-alt\"></i> 撤回</a>";
                         }
                         if(d.canedit3 != undefined && d.canedit3 =="1")
                         {

+ 1 - 0
src/main/webapp/webpage/modules/ruralprojectrecords/ruralProjectRecordsModify.jsp

@@ -548,6 +548,7 @@
             <form:hidden id="flag" path="act.flag"/>
 		    <form:hidden path="workContractInfo.client.id" id="contractClientId" value="${workContractInfo.client.id}"/>
             <input type="hidden" id="flagFile" value="">
+            <input type="hidden" id="saveAuditFlag" name="saveAuditFlag" value="1">
 
             <input type="hidden" id="workClientLinkmanInfo" value="${projectRecords.workClientLinkmanList}">
             <div class="form-group layui-row first">