Kaynağa Gözat

项目作废添加是否被调用判断

user5 3 yıl önce
ebeveyn
işleme
d40cec555a

+ 19 - 0
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectRecordsController.java

@@ -41,9 +41,11 @@ import com.jeeplus.modules.workclientinfo.entity.WorkClientLinkman;
 import com.jeeplus.modules.workclientinfo.service.WorkClientInfoService;
 import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
 import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
+import com.jeeplus.modules.workinvoice.service.WorkInvoiceService;
 import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
 import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
 import com.jeeplus.modules.workreimbursement.entity.WorkReimbursement;
+import com.jeeplus.modules.workreimbursement.service.WorkReimbursementService;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.activiti.engine.task.Task;
 import org.apache.shiro.authz.annotation.Logical;
@@ -95,6 +97,11 @@ public class RuralProjectRecordsController extends BaseController {
 	@Autowired
 	private WorkProjectNotifyService workProjectNotifyService;
 
+	@Autowired
+	private WorkInvoiceService workInvoiceService;
+	@Autowired
+	private WorkReimbursementService workReimbursementService;
+
 	private static String template_path = Global.getProjectTemplatePath()+"咨询工作方案.xlsx";
 	private static String template_name = "咨询工作方案.xlsx";
 
@@ -434,6 +441,18 @@ public class RuralProjectRecordsController extends BaseController {
 	@RequiresPermissions("ruralProject:ruralProjectRecords:del")
 	@RequestMapping(value = "delete")
 	public String delete(RuralProjectRecords projectRecords, RedirectAttributes redirectAttributes) {
+		//判断该项目是否在发票或者报销中被引用,如果被引用则不允许作废
+		//查询报告中调用的次数(若被调用的发票也被作废 则可进行作废)
+		Integer cancellationRelationCount = workInvoiceService.getProjectRelationListByProjectId(projectRecords.getId());
+		//查询报销中调用的次数(若被调用的报销被作废,则可进行作废)
+		Integer cancellationReimbursementCount = workReimbursementService.getWorkAccountByProjectId(projectRecords.getId());
+		if(cancellationRelationCount>0 || cancellationReimbursementCount>0){
+			addMessage(redirectAttributes, "项目在开票或报销中已被使用,无法作废");
+			if("1".equals(projectRecords.getProjectType())){
+				return "redirect:" + Global.getAdminPath() + "/ruralProject/ruralProjectRecords/?repage";
+			}
+			return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralCostProjectRecords/?repage";
+		}
 		projectRecordsService.delete(projectRecords);
 		addMessage(redirectAttributes, "作废项目成功");
 		if (StringUtils.isNotBlank(projectRecords.getHome()) && "home".equals(projectRecords.getHome())){