|  | @@ -0,0 +1,739 @@
 | 
												
													
														
															|  | 
 |  | +/**
 | 
												
													
														
															|  | 
 |  | + * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 | 
												
													
														
															|  | 
 |  | + */
 | 
												
													
														
															|  | 
 |  | +package com.jeeplus.modules.projectConstruction.web;
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +import com.google.common.collect.Lists;
 | 
												
													
														
															|  | 
 |  | +import com.google.common.collect.Maps;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.config.Global;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.json.AjaxJson;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.oss.OSSClientUtil;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.persistence.Page;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.utils.DateUtils;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.utils.MyBeanUtils;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.utils.StringUtils;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.utils.excel.ExportExcel;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.common.web.BaseController;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.act.entity.Act;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.act.service.ActTaskService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.act.utils.ActUtils;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectType.entity.ProjectTemplateType;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectType.service.ProjectResultsFileTemplateService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectType.service.ProjectTypeService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectcontentinfo.entity.*;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectcontentinfo.service.*;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectcontroltable.entity.ProjectControlTable;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectcontroltable.service.ProjectControlTableService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectrecord.entity.ProjectRecordTreeData;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectrecord.entity.ProjectRecords;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectrecord.enums.ProjectStatusEnum;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectrecord.service.ProjectRecordsService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.projectrecord.service.early.ProjectEarlyReviewService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.sys.entity.MainDictDetail;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.sys.entity.Office;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.sys.entity.Role;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.sys.entity.User;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.sys.service.DictService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.sys.utils.DictUtils;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.sys.utils.UserUtils;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workactivity.entity.Activity;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workactivity.service.ActivityService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workclientinfo.entity.WorkClientInfo;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workclientinfo.entity.WorkClientLinkman;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workclientinfo.service.WorkClientInfoService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workcontent.entity.WorkContentClaim;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workcontent.entity.WorkContentContractSum;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workcontent.service.WorkContentAltermanageService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workcontent.web.WorkContentTypeController;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workreview.entity.WorkReviewAudit;
 | 
												
													
														
															|  | 
 |  | +import com.jeeplus.modules.workreview.service.WorkReviewStandardService;
 | 
												
													
														
															|  | 
 |  | +import org.activiti.engine.HistoryService;
 | 
												
													
														
															|  | 
 |  | +import org.activiti.engine.history.HistoricProcessInstance;
 | 
												
													
														
															|  | 
 |  | +import org.activiti.engine.runtime.ProcessInstance;
 | 
												
													
														
															|  | 
 |  | +import org.activiti.engine.task.Task;
 | 
												
													
														
															|  | 
 |  | +import org.apache.shiro.authz.annotation.Logical;
 | 
												
													
														
															|  | 
 |  | +import org.apache.shiro.authz.annotation.RequiresPermissions;
 | 
												
													
														
															|  | 
 |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
												
													
														
															|  | 
 |  | +import org.springframework.stereotype.Controller;
 | 
												
													
														
															|  | 
 |  | +import org.springframework.ui.Model;
 | 
												
													
														
															|  | 
 |  | +import org.springframework.web.bind.annotation.*;
 | 
												
													
														
															|  | 
 |  | +import org.springframework.web.multipart.MultipartFile;
 | 
												
													
														
															|  | 
 |  | +import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +import javax.servlet.http.HttpServletRequest;
 | 
												
													
														
															|  | 
 |  | +import javax.servlet.http.HttpServletResponse;
 | 
												
													
														
															|  | 
 |  | +import java.io.UnsupportedEncodingException;
 | 
												
													
														
															|  | 
 |  | +import java.net.URLDecoder;
 | 
												
													
														
															|  | 
 |  | +import java.util.*;
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +/**
 | 
												
													
														
															|  | 
 |  | + * 施工合同管理Controller
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | + */
 | 
												
													
														
															|  | 
 |  | +@Controller
 | 
												
													
														
															|  | 
 |  | +@RequestMapping(value = "${adminPath}/project/constructionContract")
 | 
												
													
														
															|  | 
 |  | +public class ContractController extends BaseController {
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @Autowired
 | 
												
													
														
															|  | 
 |  | +    private WorkClientInfoService workClientInfoService;
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @Autowired
 | 
												
													
														
															|  | 
 |  | +    private ProjectRecordsService projectRecordsService;
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @Autowired
 | 
												
													
														
															|  | 
 |  | +    private WorkContractInfoService contractInfoService;
 | 
												
													
														
															|  | 
 |  | +    @Autowired
 | 
												
													
														
															|  | 
 |  | +    private ActTaskService actTaskService;
 | 
												
													
														
															|  | 
 |  | +    @Autowired
 | 
												
													
														
															|  | 
 |  | +    private ActivityService activityService;
 | 
												
													
														
															|  | 
 |  | +    @Autowired
 | 
												
													
														
															|  | 
 |  | +    private ProjectReportDataService projectReportDataService;
 | 
												
													
														
															|  | 
 |  | +    @Autowired
 | 
												
													
														
															|  | 
 |  | +    private ProjectcontentinfoService projectcontentinfoService;
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    private static String template_path = Global.getProjectTemplatePath()+"咨询工作方案.xlsx";
 | 
												
													
														
															|  | 
 |  | +    private static String template_name = "咨询工作方案.xlsx";
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @ModelAttribute
 | 
												
													
														
															|  | 
 |  | +    public ProjectRecords get(@RequestParam(required=false) String id) {
 | 
												
													
														
															|  | 
 |  | +        ProjectRecords entity = null;
 | 
												
													
														
															|  | 
 |  | +        if (StringUtils.isNotBlank(id)){
 | 
												
													
														
															|  | 
 |  | +            entity = projectRecordsService.get(id);
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        if (entity == null){
 | 
												
													
														
															|  | 
 |  | +            entity = new ProjectRecords();
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return entity;
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 项目列表页面
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:constructionContract:list")
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = {"list", ""})
 | 
												
													
														
															|  | 
 |  | +    public String list(ProjectRecords projectRecords, HttpServletRequest request, HttpServletResponse response, Model model) {
 | 
												
													
														
															|  | 
 |  | +        if(UserUtils.isManager()){
 | 
												
													
														
															|  | 
 |  | +            model.addAttribute("flag","1");
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        Page<ProjectRecords> page = projectRecordsService.findPage(new Page<ProjectRecords>(request, response), projectRecords);
 | 
												
													
														
															|  | 
 |  | +        //无合同状态下,获取委托方的名称
 | 
												
													
														
															|  | 
 |  | +        List<ProjectRecords> list = page.getList();
 | 
												
													
														
															|  | 
 |  | +        for (int i = 0; i < list.size(); i++) {
 | 
												
													
														
															|  | 
 |  | +            ProjectRecords records1 = list.get(i);
 | 
												
													
														
															|  | 
 |  | +            if (records1.getWorkContractInfo() == null) {
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.queryLinkmanInfos(records1);
 | 
												
													
														
															|  | 
 |  | +                if (records1.getWorkClientLinkmanList() != null && records1.getWorkClientLinkmanList().size() > 0) {
 | 
												
													
														
															|  | 
 |  | +                    WorkClientLinkman linkman = records1.getWorkClientLinkmanList().get(0);
 | 
												
													
														
															|  | 
 |  | +                    WorkContractInfo contractInfo = new WorkContractInfo();
 | 
												
													
														
															|  | 
 |  | +                    contractInfo.setClient(linkman.getClientId());
 | 
												
													
														
															|  | 
 |  | +                    records1.setWorkContractInfo(contractInfo);
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("page", page);
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectConstruction/projectConstructionList";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 项目列表页面
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "getProjectList")
 | 
												
													
														
															|  | 
 |  | +    @ResponseBody
 | 
												
													
														
															|  | 
 |  | +    public Map<String,List> getProjectList(ProjectRecords projectRecords, HttpServletRequest request, HttpServletResponse response, Model model) {
 | 
												
													
														
															|  | 
 |  | +        if(UserUtils.isManager()){
 | 
												
													
														
															|  | 
 |  | +            model.addAttribute("flag","1");
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        Page<ProjectRecords> page = projectRecordsService.findPage(new Page<ProjectRecords>(request, response), projectRecords);
 | 
												
													
														
															|  | 
 |  | +        //无合同状态下,获取委托方的名称
 | 
												
													
														
															|  | 
 |  | +        List<ProjectRecords> list = page.getList();
 | 
												
													
														
															|  | 
 |  | +        List<ProjectRecordTreeData> projectRecordTreeDataList = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  | +        Map<String,List> map = new HashMap<>();
 | 
												
													
														
															|  | 
 |  | +        for (int i = 0; i < list.size(); i++) {
 | 
												
													
														
															|  | 
 |  | +            ProjectRecordTreeData projectRecordTreeData = new ProjectRecordTreeData();
 | 
												
													
														
															|  | 
 |  | +            ProjectRecords records1 = list.get(i);
 | 
												
													
														
															|  | 
 |  | +            if (records1.getWorkContractInfo() == null) {
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.queryLinkmanInfos(records1);
 | 
												
													
														
															|  | 
 |  | +                if (records1.getWorkClientLinkmanList() != null && records1.getWorkClientLinkmanList().size() > 0) {
 | 
												
													
														
															|  | 
 |  | +                    WorkClientLinkman linkman = records1.getWorkClientLinkmanList().get(0);
 | 
												
													
														
															|  | 
 |  | +                    WorkContractInfo contractInfo = new WorkContractInfo();
 | 
												
													
														
															|  | 
 |  | +                    contractInfo.setClient(linkman.getClientId());
 | 
												
													
														
															|  | 
 |  | +                    records1.setWorkContractInfo(contractInfo);
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            //将界面需要展示数据放入类中
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setId(records1.getId());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setProjectName(records1.getProjectName());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setProjectId(records1.getProjectId());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setContractName(records1.getWorkContractInfo().getName());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setProjectStatus(records1.getProjectStatus());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setProjectRegistrant(records1.getProjectRegistrant());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setCreateDate(records1.getCreateDate());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setCreateId(records1.getCreateBy().getId());
 | 
												
													
														
															|  | 
 |  | +            //父节点的pid设置为0
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setPid("0");
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setClientName(records1.getWorkContractInfo().getClient().getName());
 | 
												
													
														
															|  | 
 |  | +            //遍历项目负责人信息
 | 
												
													
														
															|  | 
 |  | +            List<User> masterUserList = records1.getProjectLeaders();
 | 
												
													
														
															|  | 
 |  | +            List<String> masterList = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  | +            for (User masterUser:masterUserList) {
 | 
												
													
														
															|  | 
 |  | +                masterList.add(masterUser.getName());
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            //项目负责人list数据转String
 | 
												
													
														
															|  | 
 |  | +            String projectLeader = masterList.toString().replaceAll("(?:\\[|null|\\]| +)", "");
 | 
												
													
														
															|  | 
 |  | +            System.out.println(projectLeader);
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setProjectLeader(projectLeader);
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeData.setLoginId(UserUtils.getUser().getId());
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeDataList.add(projectRecordTreeData);
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +            //根据项目id查询相关的项目阶段内容
 | 
												
													
														
															|  | 
 |  | +            List<ProjectRecordTreeData> reportDataList = projectReportDataService.getProjectRecordDataList(records1.getId());
 | 
												
													
														
															|  | 
 |  | +            if(0 != reportDataList.size()){
 | 
												
													
														
															|  | 
 |  | +                Projectcontentinfo select = new Projectcontentinfo();
 | 
												
													
														
															|  | 
 |  | +                select.setProject(records1);
 | 
												
													
														
															|  | 
 |  | +                select.setParentIds("0,");
 | 
												
													
														
															|  | 
 |  | +                List<Projectcontentinfo> p = projectcontentinfoService.findListByProject(select);
 | 
												
													
														
															|  | 
 |  | +                for (ProjectRecordTreeData reportData : reportDataList) {
 | 
												
													
														
															|  | 
 |  | +                    //添加工作内容id
 | 
												
													
														
															|  | 
 |  | +                    if(p.size()>0){
 | 
												
													
														
															|  | 
 |  | +                        reportData.setContentPId(p.get(0).getId());
 | 
												
													
														
															|  | 
 |  | +                        reportData.setParentIds("0,");
 | 
												
													
														
															|  | 
 |  | +                        reportData.setDictType("");
 | 
												
													
														
															|  | 
 |  | +                    }
 | 
												
													
														
															|  | 
 |  | +                    //添加登陆者id
 | 
												
													
														
															|  | 
 |  | +                    reportData.setLoginId(UserUtils.getUser().getId());
 | 
												
													
														
															|  | 
 |  | +                    reportData.setCreateId(records1.getCreateBy().getId());
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            projectRecordTreeDataList.addAll(reportDataList);
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        map.put("data",projectRecordTreeDataList);
 | 
												
													
														
															|  | 
 |  | +        return map;
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 查看,增加,编辑项目表单页面
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "form")
 | 
												
													
														
															|  | 
 |  | +    public String form(ProjectRecords projectRecords, Model model) {
 | 
												
													
														
															|  | 
 |  | +        /*if (projectRecords!=null&&StringUtils.isNotBlank(projectRecords.getId())) {
 | 
												
													
														
															|  | 
 |  | +            projectRecords = projectRecordsService.get(projectRecords.getId());
 | 
												
													
														
															|  | 
 |  | +            projectRecordsService.queryProjectDetail(projectRecords);
 | 
												
													
														
															|  | 
 |  | +        }else {
 | 
												
													
														
															|  | 
 |  | +            projectRecords.setCreateBy(UserUtils.getUser());
 | 
												
													
														
															|  | 
 |  | +            projectRecords.setCreateDate(new Date());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("projectRecords", projectRecords);*/
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectConstruction/projectConstructionForm";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 查看
 | 
												
													
														
															|  | 
 |  | +     * @param projectRecords
 | 
												
													
														
															|  | 
 |  | +     * @param model
 | 
												
													
														
															|  | 
 |  | +     * @return
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions(value={"project:projectRecords:view"})
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "view")
 | 
												
													
														
															|  | 
 |  | +    public String view(ProjectRecords projectRecords, Model model) {
 | 
												
													
														
															|  | 
 |  | +        if (projectRecords!=null&&StringUtils.isNotBlank(projectRecords.getId())) {
 | 
												
													
														
															|  | 
 |  | +            projectRecordsService.queryProjectDetail(projectRecords);
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("projectRecords", projectRecords);
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectrecord/projectRecordsView";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 保存项目
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions(value={"project:projectRecords:add","project:projectRecords:edit"},logical=Logical.OR)
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "save")
 | 
												
													
														
															|  | 
 |  | +    public String save(ProjectRecords projectRecords, Model model, RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        if (!beanValidator(model, projectRecords)){
 | 
												
													
														
															|  | 
 |  | +            return form(projectRecords, model);
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +//            projectRecords.setProjectStatus(ProjectStatusEnum.IN_APRL.getValue());
 | 
												
													
														
															|  | 
 |  | +            if (!projectRecords.getIsNewRecord()) {//编辑表单保存
 | 
												
													
														
															|  | 
 |  | +                ProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
 | 
												
													
														
															|  | 
 |  | +                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.saveProject(t,ProjectStatusEnum.IN_APRL);//保存
 | 
												
													
														
															|  | 
 |  | +            } else {//新增表单保存
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.saveProject(projectRecords,ProjectStatusEnum.IN_APRL);//保存
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "保存项目成功");
 | 
												
													
														
															|  | 
 |  | +        }catch (Exception e){
 | 
												
													
														
															|  | 
 |  | +            logger.error("保存项目异常:",e);
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "保存项目异常:"+e.getMessage());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 保存项目
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions(value={"project:projectRecords:add","project:projectRecords:edit"},logical=Logical.OR)
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "tstore")
 | 
												
													
														
															|  | 
 |  | +    public String tStore(ProjectRecords projectRecords, Model model, RedirectAttributes redirectAttributes) throws Exception{
 | 
												
													
														
															|  | 
 |  | +        if (!beanValidator(model, projectRecords)){
 | 
												
													
														
															|  | 
 |  | +            return form(projectRecords, model);
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +//            projectRecords.setProjectStatus(ProjectStatusEnum.TSTORE.getValue());
 | 
												
													
														
															|  | 
 |  | +            if (!projectRecords.getIsNewRecord()) {//编辑表单保存
 | 
												
													
														
															|  | 
 |  | +                ProjectRecords t = projectRecordsService.get(projectRecords.getId());//从数据库取出记录的值
 | 
												
													
														
															|  | 
 |  | +                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.saveProject(t,ProjectStatusEnum.TSTORE);//保存
 | 
												
													
														
															|  | 
 |  | +            } else {//新增表单保存
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.saveProject(projectRecords,ProjectStatusEnum.TSTORE);//保存
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "暂存项目成功");
 | 
												
													
														
															|  | 
 |  | +        }catch (Exception e){
 | 
												
													
														
															|  | 
 |  | +            logger.error("暂存项目异常:",e);
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "暂存项目异常:"+e.getMessage());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 编辑项目表单页面
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions(value={"project:projectRecords:edit"},logical=Logical.OR)
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "modify")
 | 
												
													
														
															|  | 
 |  | +    public String modify(ProjectRecords projectRecords, Model model,RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        projectRecords=projectRecordsService.get(projectRecords.getId());
 | 
												
													
														
															|  | 
 |  | +        ProcessInstance processInstance = actTaskService.getProcIns(projectRecords.getProcessInstanceId());
 | 
												
													
														
															|  | 
 |  | +        if (processInstance!=null) {
 | 
												
													
														
															|  | 
 |  | +            Task taskInfok = actTaskService.getCurrentTaskInfo(processInstance);
 | 
												
													
														
															|  | 
 |  | +            Act act = new Act();
 | 
												
													
														
															|  | 
 |  | +            act.setTaskId(taskInfok.getId());
 | 
												
													
														
															|  | 
 |  | +            act.setTaskName(taskInfok.getName());
 | 
												
													
														
															|  | 
 |  | +            act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
 | 
												
													
														
															|  | 
 |  | +            act.setProcDefId(taskInfok.getProcessDefinitionId());
 | 
												
													
														
															|  | 
 |  | +            act.setProcInsId(taskInfok.getProcessInstanceId());
 | 
												
													
														
															|  | 
 |  | +            act.setTask(taskInfok);
 | 
												
													
														
															|  | 
 |  | +            projectRecords.setAct(act);
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        projectRecordsService.queryProjectDetail(projectRecords);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("projectRecords", projectRecords);
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectrecord/projectRecordsModify";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 删除项目
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:projectRecords:del")
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "delete")
 | 
												
													
														
															|  | 
 |  | +    public String delete(ProjectRecords projectRecords, RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        int status = projectRecords.getProjectStatus();
 | 
												
													
														
															|  | 
 |  | +        if(status==ProjectStatusEnum.TSTORE.getValue()||status==ProjectStatusEnum.REJECTED.getValue()||status==ProjectStatusEnum.RECALL.getValue()){
 | 
												
													
														
															|  | 
 |  | +            projectRecordsService.delete(projectRecords);
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "删除项目成功");
 | 
												
													
														
															|  | 
 |  | +            return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +        }else {
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "删除项目失败,只有“暂存”、“驳回”、“撤回”状态的项目才能删除");
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 批量删除项目
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:projectRecords:del")
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "deleteAll")
 | 
												
													
														
															|  | 
 |  | +    public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        String idArray[] =ids.split(",");
 | 
												
													
														
															|  | 
 |  | +        for(String id : idArray){
 | 
												
													
														
															|  | 
 |  | +            projectRecordsService.delete(projectRecordsService.get(id));
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        addMessage(redirectAttributes, "删除项目成功");
 | 
												
													
														
															|  | 
 |  | +        return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 导出excel文件
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:projectRecords:export")
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "export", method= RequestMethod.POST)
 | 
												
													
														
															|  | 
 |  | +    public String exportFile(ProjectRecords projectRecords, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            String fileName = "项目"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
 | 
												
													
														
															|  | 
 |  | +            Page<ProjectRecords> page = projectRecordsService.findPage(new Page<ProjectRecords>(request, response, -1), projectRecords);
 | 
												
													
														
															|  | 
 |  | +            new ExportExcel("项目", ProjectRecords.class).setDataList(page.getList()).write(response, fileName).dispose();
 | 
												
													
														
															|  | 
 |  | +            return null;
 | 
												
													
														
															|  | 
 |  | +        } catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "导出项目记录失败!失败信息:"+e.getMessage());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 下载导入项目数据模板
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:projectRecords:import")
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "import/template")
 | 
												
													
														
															|  | 
 |  | +    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            String fileName = "项目数据导入模板.xlsx";
 | 
												
													
														
															|  | 
 |  | +            List<ProjectRecords> list = Lists.newArrayList();
 | 
												
													
														
															|  | 
 |  | +            new ExportExcel("项目数据", ProjectRecords.class, 1).setDataList(list).write(response, fileName).dispose();
 | 
												
													
														
															|  | 
 |  | +            return null;
 | 
												
													
														
															|  | 
 |  | +        } catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping("getContractInfo")
 | 
												
													
														
															|  | 
 |  | +    @ResponseBody
 | 
												
													
														
															|  | 
 |  | +    public WorkContractInfo queryContractInfo(WorkContractInfo  contractInfo){
 | 
												
													
														
															|  | 
 |  | +        WorkContractInfo workContractInfo = contractInfoService.get(contractInfo.getId());
 | 
												
													
														
															|  | 
 |  | +        if(workContractInfo==null){
 | 
												
													
														
															|  | 
 |  | +            return workContractInfo;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        workContractInfo.setConstructionProjectTypeStr(DictUtils.getDictLabel(String.valueOf(workContractInfo.getConstructionProjectType()),"construction_project_type",""));
 | 
												
													
														
															|  | 
 |  | +        if(workContractInfo.getWorkClientInfoList()!=null&&!workContractInfo.getWorkClientInfoList().isEmpty()){
 | 
												
													
														
															|  | 
 |  | +            StringBuilder workClinetInfoIds = new StringBuilder();
 | 
												
													
														
															|  | 
 |  | +            for (WorkClientInfo workClientInfo : workContractInfo.getWorkClientInfoList()) {
 | 
												
													
														
															|  | 
 |  | +                workClinetInfoIds.append(workClientInfo.getId()).append(",");
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            workClinetInfoIds.deleteCharAt(workClinetInfoIds.length()-1);
 | 
												
													
														
															|  | 
 |  | +            workContractInfo.setWorkClinetInfoIds(workClinetInfoIds.toString());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return  workContractInfo;
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    //	审批页面
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "projectRecordsAudit")
 | 
												
													
														
															|  | 
 |  | +    public String workContractInfoAudit(Act act, ProjectRecords projectRecords, Model model) {
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        if (act.getProcInsId() != null) {
 | 
												
													
														
															|  | 
 |  | +            if (actTaskService.getProcIns(act.getProcInsId()) != null) {
 | 
												
													
														
															|  | 
 |  | +                act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
 | 
												
													
														
															|  | 
 |  | +            } else {
 | 
												
													
														
															|  | 
 |  | +                act.setFinishedProcIns(actTaskService.getFinishedProcIns(act.getProcInsId()));
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        if (act != null && StringUtils.isNotBlank(act.getTaskId())) {
 | 
												
													
														
															|  | 
 |  | +            projectRecords.setAct(act);
 | 
												
													
														
															|  | 
 |  | +            model.addAttribute("processInstanceId", projectRecords.getProcessInstanceId());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        if (projectRecords!=null&&StringUtils.isNotBlank(projectRecords.getId())) {
 | 
												
													
														
															|  | 
 |  | +            projectRecordsService.queryProjectDetail(projectRecords);
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("projectRecords", projectRecords);
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectrecord/projectRecordsAudit";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "getProcess")
 | 
												
													
														
															|  | 
 |  | +    public String getProcess(ProjectRecords projectRecords, Model model,HttpServletRequest request){
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("processInstanceId", projectRecords.getProcessInstanceId());
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectrecord/projectRecordsTask";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "revoke")
 | 
												
													
														
															|  | 
 |  | +    public String revoke(HttpServletRequest request, RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        HashMap<String, String> requestMap = findRequestMap(request);
 | 
												
													
														
															|  | 
 |  | +        String processInstanceId = requestMap.get("processInstanceId");
 | 
												
													
														
															|  | 
 |  | +        String id = requestMap.get("id");
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            ProjectRecords projectRecords = projectRecordsService.get(id);
 | 
												
													
														
															|  | 
 |  | +            if(5==projectRecords.getProjectStatus()){
 | 
												
													
														
															|  | 
 |  | +                addMessage(redirectAttributes, "项目登记已审批通过,无法撤回");
 | 
												
													
														
															|  | 
 |  | +                return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            projectRecordsService.cancelProcess(projectRecords);
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "撤回该项目登记成功");
 | 
												
													
														
															|  | 
 |  | +        }catch (Exception e){
 | 
												
													
														
															|  | 
 |  | +            logger.info(e.getMessage());
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "撤回该项目登记失败");
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return "redirect:" + Global.getAdminPath() + "/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 查询待办任务
 | 
												
													
														
															|  | 
 |  | +     *
 | 
												
													
														
															|  | 
 |  | +     * @param act
 | 
												
													
														
															|  | 
 |  | +     * @param model
 | 
												
													
														
															|  | 
 |  | +     * @return
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping("/toDoList")
 | 
												
													
														
															|  | 
 |  | +    public String queryToList(Act act, Model model) {
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        //合同申请流程
 | 
												
													
														
															|  | 
 |  | +        act.setProcDefKey(ActUtils.PD_PROJECTRECORD[0]);
 | 
												
													
														
															|  | 
 |  | +        List<Act> list = actTaskService.todoList(act);
 | 
												
													
														
															|  | 
 |  | +        Office office = UserUtils.getSelectCompany();
 | 
												
													
														
															|  | 
 |  | +        String companyId = office==null?"":office.getId();
 | 
												
													
														
															|  | 
 |  | +        List<Activity> activities = activityService.groupByActivityMenu("7854872f45b84acd893010e66a3db2c8",companyId);
 | 
												
													
														
															|  | 
 |  | +        for (Activity activity:activities){
 | 
												
													
														
															|  | 
 |  | +            act.setProcDefKey(activity.getProcessKey());
 | 
												
													
														
															|  | 
 |  | +            list.addAll(actTaskService.todoList(act));
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        Role role = UserUtils.getSelectRole().get(0);
 | 
												
													
														
															|  | 
 |  | +        List<ProjectRecords> lists = new ArrayList<ProjectRecords>();
 | 
												
													
														
															|  | 
 |  | +        for (Act a : list) {
 | 
												
													
														
															|  | 
 |  | +            if (a.getTask().getTaskDefinitionKey()!=null) {
 | 
												
													
														
															|  | 
 |  | +                ProjectRecords projectRecords = projectRecordsService.getByProcessInstanceId(a.getProcInsId());
 | 
												
													
														
															|  | 
 |  | +                if (projectRecords==null){continue;}
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.queryContractInfos(projectRecords);
 | 
												
													
														
															|  | 
 |  | +                projectRecords.setAuditType("项目登记");
 | 
												
													
														
															|  | 
 |  | +                if(projectRecords.getProjectStatus()!= ProjectStatusEnum.RECALL.getValue()) {
 | 
												
													
														
															|  | 
 |  | +                    User user1 = UserUtils.get(projectRecords.getCreateBy().getId());
 | 
												
													
														
															|  | 
 |  | +                    if (projectRecords != null && user1.getCompany().getId().equals(companyId)) {
 | 
												
													
														
															|  | 
 |  | +                        projectRecords.setCreateBy(user1);
 | 
												
													
														
															|  | 
 |  | +                        if (a.getVars().getMap().get("applyUserId") != null) {
 | 
												
													
														
															|  | 
 |  | +                            User user = UserUtils.get(a.getVars().getMap().get("applyUserId").toString());
 | 
												
													
														
															|  | 
 |  | +                            if (user != null) {
 | 
												
													
														
															|  | 
 |  | +                                a.getVars().getMap().put("applyUserId", UserUtils.get(a.getVars().getMap().get("applyUserId").toString()).getName());
 | 
												
													
														
															|  | 
 |  | +                            }
 | 
												
													
														
															|  | 
 |  | +                        }
 | 
												
													
														
															|  | 
 |  | +                        projectRecords.setAct(a);
 | 
												
													
														
															|  | 
 |  | +                        lists.add(projectRecords);
 | 
												
													
														
															|  | 
 |  | +                    }
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        /*------变更--------*/
 | 
												
													
														
															|  | 
 |  | +        act.setProcDefKey("projectAlter");
 | 
												
													
														
															|  | 
 |  | +        List<Act> list3 = actTaskService.todoList(act);
 | 
												
													
														
															|  | 
 |  | +        Office office3 = UserUtils.getSelectCompany();
 | 
												
													
														
															|  | 
 |  | +        String companyId3 = office3==null?"":office3.getId();
 | 
												
													
														
															|  | 
 |  | +        List<Activity> activities3 = activityService.groupByActivityMenu("807c6d4b5623474792fe78ff1fd1cdff",companyId3);
 | 
												
													
														
															|  | 
 |  | +        for (Activity activity:activities3){
 | 
												
													
														
															|  | 
 |  | +            act.setProcDefKey(activity.getProcessKey());
 | 
												
													
														
															|  | 
 |  | +            list3.addAll(actTaskService.todoList(act));
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        for (Act a : list3) {
 | 
												
													
														
															|  | 
 |  | +            ProjectRecords projectRecords = projectRecordsService.getByAlterProcessInstanceId(a.getTask().getProcessInstanceId());
 | 
												
													
														
															|  | 
 |  | +            if (projectRecords!=null){
 | 
												
													
														
															|  | 
 |  | +                projectRecordsService.queryContractInfos(projectRecords);
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            if (projectRecords != null && projectRecords.getCompany().getId().equals(companyId3)&& projectRecords.getProjectStatus()==ProjectStatusEnum.ON_CHANGE.getValue()) {
 | 
												
													
														
															|  | 
 |  | +                if (a.getVars().getMap().get("applyUserId") != null) {
 | 
												
													
														
															|  | 
 |  | +                    User user = UserUtils.get(a.getVars().getMap().get("applyUserId").toString());
 | 
												
													
														
															|  | 
 |  | +                    if (user != null) {
 | 
												
													
														
															|  | 
 |  | +                        a.getVars().getMap().put("applyUserId", UserUtils.get(a.getVars().getMap().get("applyUserId").toString()).getName());
 | 
												
													
														
															|  | 
 |  | +                    }
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +                projectRecords.setAct(a);
 | 
												
													
														
															|  | 
 |  | +                projectRecords.setAuditType("项目变更");
 | 
												
													
														
															|  | 
 |  | +                lists.add(projectRecords);
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        //排除 重新申请|撤销
 | 
												
													
														
															|  | 
 |  | +        Iterator<ProjectRecords> it = lists.iterator();
 | 
												
													
														
															|  | 
 |  | +        while(it.hasNext()){
 | 
												
													
														
															|  | 
 |  | +            ProjectRecords w = it.next();
 | 
												
													
														
															|  | 
 |  | +            if(w.getAct()!=null && w.getAct().getTaskDefKey().equals("reapply")){
 | 
												
													
														
															|  | 
 |  | +                it.remove();
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("list", lists);
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectrecord/projectRecordsToDoList";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 审批
 | 
												
													
														
															|  | 
 |  | +     * @param projectRecords
 | 
												
													
														
															|  | 
 |  | +     * @param model
 | 
												
													
														
															|  | 
 |  | +     * @param upload_files
 | 
												
													
														
															|  | 
 |  | +     * @param redirectAttributes
 | 
												
													
														
															|  | 
 |  | +     * @return
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping("saveAudit")
 | 
												
													
														
															|  | 
 |  | +    public String saveAudit(ProjectRecords projectRecords, Model model,
 | 
												
													
														
															|  | 
 |  | +                            @RequestParam(value = "upload_files", required = false) MultipartFile[] upload_files,
 | 
												
													
														
															|  | 
 |  | +                            RedirectAttributes redirectAttributes)  {
 | 
												
													
														
															|  | 
 |  | +        String home = projectRecords.getHome();
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            String taskDefKey = projectRecords.getAct().getTaskDefKey();
 | 
												
													
														
															|  | 
 |  | +            //当状态为未通过时,重新修改数据
 | 
												
													
														
															|  | 
 |  | +            if ("modifyApply".equals(taskDefKey)) {
 | 
												
													
														
															|  | 
 |  | +                projectRecords.getAct().setComment("重新申请");
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            List<User> users = UserUtils.getByProssType(projectRecords.getProcessInstanceId(),1);
 | 
												
													
														
															|  | 
 |  | +            String flag = projectRecords.getAct().getFlag();
 | 
												
													
														
															|  | 
 |  | +            if ("yes".equals(flag) && (users==null || users.size()==0)){
 | 
												
													
														
															|  | 
 |  | +                addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员!");
 | 
												
													
														
															|  | 
 |  | +            }else {
 | 
												
													
														
															|  | 
 |  | +                String str = projectRecordsService.auditSave(projectRecords,users);
 | 
												
													
														
															|  | 
 |  | +                addMessage(redirectAttributes, str);
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +        }catch (Exception e){
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "项目登记流程审批失败");
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        if (StringUtils.isNotBlank(home) && "home".equals(home)){
 | 
												
													
														
															|  | 
 |  | +            return "redirect:" + Global.getAdminPath() + "/home/?repage";
 | 
												
													
														
															|  | 
 |  | +        }else {
 | 
												
													
														
															|  | 
 |  | +            return "redirect:" + Global.getAdminPath() + "/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 查询已办列表
 | 
												
													
														
															|  | 
 |  | +     * @return
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping("/queryCompleteList")
 | 
												
													
														
															|  | 
 |  | +    public String queryCompleteList(Act act,HttpServletRequest request,HttpServletResponse response,Model model){
 | 
												
													
														
															|  | 
 |  | +        act.setProcDefKey("projectAudit");
 | 
												
													
														
															|  | 
 |  | +        List<ProjectRecords> list = projectRecordsService.historicList(act);
 | 
												
													
														
															|  | 
 |  | +        Office office = UserUtils.getSelectCompany();
 | 
												
													
														
															|  | 
 |  | +        String companyId = office==null?"":office.getId();
 | 
												
													
														
															|  | 
 |  | +        List<Activity> activities = activityService.groupByActivityMenu("7854872f45b84acd893010e66a3db2c8",companyId);
 | 
												
													
														
															|  | 
 |  | +        for (Activity activity:activities){
 | 
												
													
														
															|  | 
 |  | +            act.setProcDefKey(activity.getProcessKey());
 | 
												
													
														
															|  | 
 |  | +            list.addAll(projectRecordsService.historicList(act));
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        //合同变更
 | 
												
													
														
															|  | 
 |  | +        act.setProcDefKey("projectAlter");
 | 
												
													
														
															|  | 
 |  | +        List<Activity> activities3 = activityService.groupByActivityMenu("807c6d4b5623474792fe78ff1fd1cdff",companyId);
 | 
												
													
														
															|  | 
 |  | +        for (Activity activity:activities3){
 | 
												
													
														
															|  | 
 |  | +            act.setProcDefKey(activity.getProcessKey());
 | 
												
													
														
															|  | 
 |  | +            list.addAll(projectRecordsService.historicAlterList(act));
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("list",list);
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectrecord/projectRecordsHistoricList";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 选择合同
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "selectcontract")
 | 
												
													
														
															|  | 
 |  | +    public String selectcontractId(WorkContractInfo contract, String url,String type,String isTotal, String fieldLabels, String fieldKeys, String searchLabel, String searchKey, HttpServletRequest request, HttpServletResponse response, Model model) {
 | 
												
													
														
															|  | 
 |  | +        if(!"1".equals(UserUtils.getSelectCompany().getId())){
 | 
												
													
														
															|  | 
 |  | +            contract.setOfficeId(UserUtils.getSelectOffice().getId());
 | 
												
													
														
															|  | 
 |  | +            contract.setChargeCompany(UserUtils.getSelectOffice().getId());
 | 
												
													
														
															|  | 
 |  | +            contract.setCreateBy(UserUtils.getUser());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        contract.setContractState("5");
 | 
												
													
														
															|  | 
 |  | +        Page<WorkContractInfo> page = contractInfoService.findPageReceipts(new Page<WorkContractInfo>(request, response),  contract);
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            fieldLabels = URLDecoder.decode(fieldLabels, "UTF-8");
 | 
												
													
														
															|  | 
 |  | +            fieldKeys = URLDecoder.decode(fieldKeys, "UTF-8");
 | 
												
													
														
															|  | 
 |  | +            searchLabel = URLDecoder.decode(searchLabel, "UTF-8");
 | 
												
													
														
															|  | 
 |  | +            searchKey = URLDecoder.decode(searchKey, "UTF-8");
 | 
												
													
														
															|  | 
 |  | +        } catch (UnsupportedEncodingException e) {
 | 
												
													
														
															|  | 
 |  | +            e.printStackTrace();
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("labelNames", fieldLabels.split("\\|"));
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("labelValues", fieldKeys.split("\\|"));
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("fieldLabels", fieldLabels);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("fieldKeys", fieldKeys);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("url", url);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("searchLabel", searchLabel);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("searchKey", searchKey);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("type", type);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("isTotal", isTotal);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("obj", contract);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("page", page);
 | 
												
													
														
															|  | 
 |  | +        return "modules/sys/gridselectContractDetail";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "detailList")
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:projectRecordsDetail:list")
 | 
												
													
														
															|  | 
 |  | +    public String detailList(ProjectRecords projectRecords, HttpServletRequest request, HttpServletResponse response, Model model) {
 | 
												
													
														
															|  | 
 |  | +        if(UserUtils.isManager()){
 | 
												
													
														
															|  | 
 |  | +            model.addAttribute("flag","1");
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        Page<ProjectRecords> page = projectRecordsService.findPageDetail(new Page<ProjectRecords>(request, response), projectRecords);
 | 
												
													
														
															|  | 
 |  | +        model.addAttribute("page", page);
 | 
												
													
														
															|  | 
 |  | +        return "modules/projectrecord/projectRecordsDetailList";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 导出excel文件
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:projectRecordsDetail:export")
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "exportDetail", method=RequestMethod.POST)
 | 
												
													
														
															|  | 
 |  | +    public String exportDetailFile(ProjectRecords projectRecords, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            String fileName = "项目"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
 | 
												
													
														
															|  | 
 |  | +            Page<ProjectRecords> page = projectRecordsService.findPageDetail(new Page<ProjectRecords>(request, response, -1), projectRecords);
 | 
												
													
														
															|  | 
 |  | +            new ExportExcel("项目", ProjectRecords.class).setDataList(page.getList()).write(response, fileName).dispose();
 | 
												
													
														
															|  | 
 |  | +            return null;
 | 
												
													
														
															|  | 
 |  | +        } catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | +            addMessage(redirectAttributes, "导出项目记录失败!失败信息:"+e.getMessage());
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return "redirect:"+Global.getAdminPath()+"/project/projectRecords/?repage";
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 下载导入项目数据模板
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequiresPermissions("project:projectRecords:edit")
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "downloadTemplate")
 | 
												
													
														
															|  | 
 |  | +    public void downloadTemplate(HttpServletRequest request,HttpServletResponse response) {
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            new OSSClientUtil().downByStream(template_path,template_name,response,request.getHeader("USER-AGENT"));
 | 
												
													
														
															|  | 
 |  | +        } catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | +            logger.error("项目计划模板下载失败!",e);
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * 项目登记新增客户管理
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "linkManSave")
 | 
												
													
														
															|  | 
 |  | +    @ResponseBody
 | 
												
													
														
															|  | 
 |  | +    public Object linkManSave(WorkClientInfo workClientInfo,
 | 
												
													
														
															|  | 
 |  | +                              Model model, RedirectAttributes redirectAttributes,
 | 
												
													
														
															|  | 
 |  | +                              HttpServletRequest request
 | 
												
													
														
															|  | 
 |  | +    ) throws Exception{
 | 
												
													
														
															|  | 
 |  | +        Map<String,Object> map = new HashMap<>();
 | 
												
													
														
															|  | 
 |  | +        try {
 | 
												
													
														
															|  | 
 |  | +            //保存当前人的公司
 | 
												
													
														
															|  | 
 |  | +            workClientInfo.setCompanyId(UserUtils.getSelectCompany().getId());
 | 
												
													
														
															|  | 
 |  | +            workClientInfo.setOfficeId(UserUtils.getSelectOffice().getId());
 | 
												
													
														
															|  | 
 |  | +            workClientInfoService.save(workClientInfo);//保存
 | 
												
													
														
															|  | 
 |  | +            WorkClientLinkman linkman = workClientInfo.getWorkClientLinkmanList().get(0);
 | 
												
													
														
															|  | 
 |  | +            map.put("id",linkman.getId());
 | 
												
													
														
															|  | 
 |  | +            map.put("clientId",workClientInfo.getId());
 | 
												
													
														
															|  | 
 |  | +            map.put("clientName",workClientInfo.getName());
 | 
												
													
														
															|  | 
 |  | +            map.put("linkName",linkman.getName());
 | 
												
													
														
															|  | 
 |  | +            map.put("linkMobile",linkman.getLinkMobile());
 | 
												
													
														
															|  | 
 |  | +            map.put("linkPhone",linkman.getLinkPhone());
 | 
												
													
														
															|  | 
 |  | +            map.put("str","新增客户信息成功!");
 | 
												
													
														
															|  | 
 |  | +        }catch (Exception e){
 | 
												
													
														
															|  | 
 |  | +            e.printStackTrace();
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return map;
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     *选择合同-Ajax自动映射联系人
 | 
												
													
														
															|  | 
 |  | +     * @param clientId
 | 
												
													
														
															|  | 
 |  | +     * @return
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    @ResponseBody
 | 
												
													
														
															|  | 
 |  | +    @RequestMapping(value = "getLinkManByClientId")
 | 
												
													
														
															|  | 
 |  | +    public Map<String, Object> queryWorkClientLinkMen(String clientId){
 | 
												
													
														
															|  | 
 |  | +        WorkClientLinkman linkman = workClientInfoService.queryLinkManByClientId(clientId);
 | 
												
													
														
															|  | 
 |  | +        if (linkman != null) {
 | 
												
													
														
															|  | 
 |  | +            WorkClientInfo workClientInfo = workClientInfoService.get(clientId);
 | 
												
													
														
															|  | 
 |  | +            Map<String, Object> map = new HashMap<>();
 | 
												
													
														
															|  | 
 |  | +            map.put("id", linkman.getId());
 | 
												
													
														
															|  | 
 |  | +            map.put("clientId", workClientInfo.getId());
 | 
												
													
														
															|  | 
 |  | +            map.put("clientName", workClientInfo.getName());
 | 
												
													
														
															|  | 
 |  | +            map.put("uscCode",workClientInfo.getUscCode());
 | 
												
													
														
															|  | 
 |  | +            map.put("linkName", linkman.getName());
 | 
												
													
														
															|  | 
 |  | +            map.put("linkMobile", linkman.getLinkMobile());
 | 
												
													
														
															|  | 
 |  | +            map.put("linkPhone", linkman.getLinkPhone());
 | 
												
													
														
															|  | 
 |  | +            return map;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        return null;
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +}
 |