/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.ruralprojectrecords.web;

import com.google.common.collect.Lists;
import com.jeeplus.common.config.Global;
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.utils.excel.ImportExcel;
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.ruralprojectrecords.entity.RuralProjectRecords;
import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecordsAlter;
import com.jeeplus.modules.ruralprojectrecords.enums.AlterStatusEnum;
import com.jeeplus.modules.ruralprojectrecords.enums.ProjectStatusEnum;
import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsAlterService;
import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
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.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.WorkClientAttachment;
import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
import com.jeeplus.modules.workfullmanage.service.WorkFullRecordService;
import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.beanutils.BeanUtils;
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 javax.validation.ConstraintViolationException;
import java.lang.reflect.InvocationTargetException;
import java.util.*;

/**
 * 项目登记Controller
 * @author ppt
 * @version 2018-05-02
 */
@Controller
@RequestMapping(value = "${adminPath}/ruralProject/ruralProjectRecordsAlter")
public class RuralProjectRecordsAlterController extends BaseController {

	@Autowired
	private RuralProjectRecordsAlterService projectRecordsAlterService;
	@Autowired
	private RuralProjectRecordsService projectRecordsService;

	@Autowired
	private WorkContractInfoService contractInfoService;
	@Autowired
	private ActTaskService actTaskService;
	@Autowired
	private WorkFullRecordService workFullRecordService;

	@Autowired
	private WorkProjectNotifyService workProjectNotifyService;
	@Autowired
	private ActivityService activityService;
	
	@ModelAttribute
	public RuralProjectRecordsAlter get(@RequestParam(required=false) String id) {
		RuralProjectRecordsAlter entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = projectRecordsAlterService.get(id);
		}
		if (entity == null){
			entity = new RuralProjectRecordsAlter();
		}
		return entity;
	}
	
	/**
	 * 项目列表页面
	 */
	@RequiresPermissions("project:projectRecords:list")
	@RequestMapping(value = {"list", ""})
	public String list(RuralProjectRecordsAlter projectRecordsAlter, HttpServletRequest request, HttpServletResponse response, Model model) {
        if(UserUtils.isManager()){
            model.addAttribute("flag","1");
        }
		Page<RuralProjectRecordsAlter> page = projectRecordsAlterService.findPage(new Page<RuralProjectRecordsAlter>(request, response), projectRecordsAlter);
		model.addAttribute("page", page);
		return "modules/ruralprojectrecords/ruralProjectRecordsAlterList";
	}

	/**
	 * 查看，增加，编辑项目表单页面
	 */
	@RequiresPermissions(value={"project:projectRecords:add","project:projectRecords:edit"},logical=Logical.OR)
	@RequestMapping(value = "form")
	public String form(RuralProjectRecordsAlter projectRecordsAlter, Model model, RedirectAttributes redirectAttributes) {
        RuralProjectRecords projectRecords = new RuralProjectRecords();
        if (projectRecordsAlter.getAlterBeforeRecords()!=null&&StringUtils.isNotBlank(projectRecordsAlter.getAlterBeforeRecords().getId())){
            projectRecords = projectRecordsService.get(projectRecordsAlter.getAlterBeforeRecords().getId());
            //设置详细信息
            projectRecordsService.queryProjectDetail(projectRecords);
        }
		if (projectRecordsAlter!=null&&StringUtils.isNotBlank(projectRecordsAlter.getId())) {
		    projectRecordsAlter=projectRecordsAlterService.get(projectRecordsAlter.getId());
            projectRecordsAlter.setAlterBeforeRecords(projectRecords);
			//设置合同信息
            projectRecordsAlterService.queryProjectAlterDetail(projectRecordsAlter);
		}else {
            //判断项目状态
            if (projectRecords.getProjectStatus()!= ProjectStatusEnum.SIGNED.getValue()){
                addMessage(redirectAttributes, "状态异常，不能发起项目变更");
                return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
            }
            try {
                BeanUtils.copyProperties(projectRecordsAlter,projectRecords);
                projectRecordsAlter.setId(null);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
            projectRecordsAlter.setAlterBeforeRecords(projectRecords);
            if(projectRecordsAlter.getWorkAttachments()!=null)projectRecordsAlter.setWorkAttachments(new ArrayList<WorkClientAttachment>());
            projectRecordsAlter.setCreateBy(UserUtils.getUser());
            projectRecordsAlter.setCreateDate(new Date());
		}
		model.addAttribute("ruralProjectRecordsAlter", projectRecordsAlter);
		return "modules/ruralprojectrecords/ruralProjectRecordsAlterForm";
	}

    /**
	 * 编辑项目表单页面
	 */
	@RequiresPermissions(value={"project:projectRecords:edit"},logical=Logical.OR)
	@RequestMapping(value = "modify")
	public String modify(RuralProjectRecordsAlter projectRecordsAlter, Model model, RedirectAttributes redirectAttributes) {
	    if(StringUtils.isBlank(projectRecordsAlter.getId())){
            projectRecordsAlter = projectRecordsAlterService.getByProcessInstanceId(projectRecordsAlter.getAct().getProcInsId());
            projectRecordsAlterService.queryProjectAlterDetail(projectRecordsAlter);
        }
        RuralProjectRecords projectRecords = new RuralProjectRecords();
        if (projectRecordsAlter.getAlterBeforeRecords()!=null&&StringUtils.isNotBlank(projectRecordsAlter.getAlterBeforeRecords().getId())){
            projectRecords = projectRecordsService.get(projectRecordsAlter.getAlterBeforeRecords().getId());
            //设置项目组成员
            projectRecordsService.queryUserNames(projectRecords);
            projectRecordsAlter.setAlterBeforeRecords(projectRecords);
        }
        projectRecordsAlter=projectRecordsAlterService.get(projectRecordsAlter.getId());
        ProcessInstance processInstance = actTaskService.getProcIns(projectRecordsAlter.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);
            projectRecordsAlter.setAct(act);
        }

        projectRecordsAlter.setAlterBeforeRecords(projectRecords);
        //设置合同信息
        projectRecordsAlterService.queryProjectAlterDetail(projectRecordsAlter);
		model.addAttribute("projectRecordsAlter", projectRecordsAlter);
		return "modules/ruralprojectrecords/ruralProjectRecordsAlterModify";
	}

	/**
	 * 查看
	 * @param projectRecordsAlter
	 * @param model
	 * @return
	 */
	@RequiresPermissions(value={"project:projectRecords:view"})
	@RequestMapping(value = "view")
	public String view(RuralProjectRecordsAlter projectRecordsAlter, Model model) {
	    RuralProjectRecords projectRecords = null;
        if (projectRecordsAlter.getAlterBeforeRecords()!=null&&StringUtils.isNotBlank(projectRecordsAlter.getAlterBeforeRecords().getId())){
            projectRecords = projectRecordsService.get(projectRecordsAlter.getAlterBeforeRecords().getId());
            //设置详细信息
            projectRecordsService.queryProjectDetail(projectRecords);
            projectRecordsAlter.setAlterBeforeRecords(projectRecords);
        }
		if (projectRecords!=null&&StringUtils.isNotBlank(projectRecords.getId())) {
			//设置合同信息
            projectRecordsAlterService.queryProjectAlterDetail(projectRecordsAlter);
		}
		model.addAttribute("projectRecordsAlter", projectRecordsAlter);
		return "modules/ruralprojectrecords/ruralProjectRecordsAlterView";
	}

	/**
	 * 保存项目
	 */
	@RequiresPermissions(value={"project:projectRecords:add","project:projectRecords:edit"},logical=Logical.OR)
	@RequestMapping(value = "save")
	public String save(RuralProjectRecordsAlter projectRecords, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, projectRecords)){
			return form(projectRecords, model,redirectAttributes);
		}
        try {
            if(!projectRecords.getIsNewRecord()){//编辑表单保存
                RuralProjectRecordsAlter t = projectRecordsAlterService.get(projectRecords.getId());//从数据库取出记录的值
                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
                projectRecordsAlterService.saveProject(t, AlterStatusEnum.IN_APRL);//保存
            }else{//新增表单保存
                projectRecordsAlterService.saveProject(projectRecords, AlterStatusEnum.IN_APRL);//保存
            }
            addMessage(model,"保存项目变更成功");
        } catch (Exception e) {
            logger.error("保存项目变更异常：",e);
            addMessage(model,"保存项目变更异常:"+e.getMessage());
        }
		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
	}

	/**
	 * 保存项目
	 */
	@RequiresPermissions(value={"project:projectRecords:add","project:projectRecords:edit"},logical=Logical.OR)
	@RequestMapping(value = "tstore")
	public String tStore(RuralProjectRecordsAlter projectRecords, Model model, RedirectAttributes redirectAttributes) throws Exception{
		if (!beanValidator(model, projectRecords)){
			return form(projectRecords, model,redirectAttributes);
		}
        try {
            if(!projectRecords.getIsNewRecord()){//编辑表单保存
                RuralProjectRecordsAlter t = projectRecordsAlterService.get(projectRecords.getId());//从数据库取出记录的值
                MyBeanUtils.copyBeanNotNull2Bean(projectRecords, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
                projectRecordsAlterService.saveProject(t, AlterStatusEnum.TSTORE);//保存
            }else{//新增表单保存
                projectRecordsAlterService.saveProject(projectRecords, AlterStatusEnum.TSTORE);//保存
            }
            addMessage(model,"暂存项目变更成功");
        } catch (Exception e) {
            logger.error("暂存项目变更异常：",e);
            addMessage(model,"暂存项目变更异常:"+e.getMessage());
        }
		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
	}
	
	/**
	 * 删除项目
	 */
	@RequiresPermissions("project:projectRecords:del")
	@RequestMapping(value = "delete")
	public String delete(RuralProjectRecordsAlter projectRecords, RedirectAttributes redirectAttributes) {
		int status = projectRecords.getProjectStatus();
		if(status== AlterStatusEnum.TSTORE.getValue()||status== AlterStatusEnum.REJECTED.getValue()||status== AlterStatusEnum.RECALL.getValue()){
			projectRecordsAlterService.delete(projectRecords);
			addMessage(redirectAttributes, "删除项目变更记录成功");
			return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecords/?repage";
		}else {
			addMessage(redirectAttributes, "删除项目变更记录失败，只有“暂存”、“驳回”、“撤回”状态的项目才能删除");
		}
		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
	}
	
	/**
	 * 批量删除项目
	 */
	@RequiresPermissions("project:projectRecords:del")
	@RequestMapping(value = "deleteAll")
	public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
		String idArray[] =ids.split(",");
		for(String id : idArray){
			projectRecordsAlterService.delete(projectRecordsAlterService.get(id));
		}
		addMessage(redirectAttributes, "删除项目成功");
		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
	}
	
	/**
	 * 导出excel文件
	 */
	@RequiresPermissions("project:projectRecords:export")
    @RequestMapping(value = "export", method=RequestMethod.POST)
    public String exportFile(RuralProjectRecordsAlter projectRecords, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
		try {
            String fileName = "项目"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
            Page<RuralProjectRecordsAlter> page = projectRecordsAlterService.findPage(new Page<RuralProjectRecordsAlter>(request, response, -1), projectRecords);
    		new ExportExcel("项目", RuralProjectRecords.class).setDataList(page.getList()).write(response, fileName).dispose();
    		return null;
		} catch (Exception e) {
			addMessage(redirectAttributes, "导出项目记录失败！失败信息："+e.getMessage());
		}
		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
    }

	/**
	 * 导入Excel数据

	 */
	@RequiresPermissions("project:projectRecords:import")
    @RequestMapping(value = "import", method=RequestMethod.POST)
    public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
		try {
			int successNum = 0;
			int failureNum = 0;
			StringBuilder failureMsg = new StringBuilder();
			ImportExcel ei = new ImportExcel(file, 1, 0);
			List<RuralProjectRecordsAlter> list = ei.getDataList(RuralProjectRecordsAlter.class);
			for (RuralProjectRecordsAlter projectRecords : list){
				try{
					projectRecordsAlterService.save(projectRecords);
					successNum++;
				}catch(ConstraintViolationException ex){
					failureNum++;
				}catch (Exception ex) {
					failureNum++;
				}
			}
			if (failureNum>0){
				failureMsg.insert(0, "，失败 "+failureNum+" 条项目记录。");
			}
			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条项目记录"+failureMsg);
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入项目失败！失败信息："+e.getMessage());
		}
		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
    }
	
	/**
	 * 下载导入项目数据模板
	 */
	@RequiresPermissions("project:projectRecords:import")
    @RequestMapping(value = "import/template")
    public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
		try {
            String fileName = "项目数据导入模板.xlsx";
    		List<RuralProjectRecordsAlter> list = Lists.newArrayList();
    		new ExportExcel("项目数据", RuralProjectRecordsAlter.class, 1).setDataList(list).write(response, fileName).dispose();
    		return null;
		} catch (Exception e) {
			addMessage(redirectAttributes, "导入模板下载失败！失败信息："+e.getMessage());
		}
		return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
    }
	
	
	
	@RequestMapping("getContractInfo")
	@ResponseBody
	public WorkContractInfo queryContractInfo(WorkContractInfo  contractInfo){
		WorkContractInfo workContractInfo = contractInfoService.get(contractInfo.getId());
		workContractInfo.setConstructionProjectTypeStr(DictUtils.getDictLabel(String.valueOf(workContractInfo.getConstructionProjectType()),"construction_project_type",""));
		return  workContractInfo;
	}

	//	审批页面
	@RequestMapping(value = "projectRecordsAudit")
	public String projectRecordsAudit(Act act, RuralProjectRecordsAlter projectRecordsAlter, Model model) {
		projectRecordsAlter = projectRecordsAlterService.getByProcessInstanceId(act.getProcInsId());
        RuralProjectRecords projectRecords = null;
        if (projectRecordsAlter.getAlterBeforeRecords()!=null&&StringUtils.isNotBlank(projectRecordsAlter.getAlterBeforeRecords().getId())){
            projectRecords = projectRecordsService.get(projectRecordsAlter.getAlterBeforeRecords().getId());
            //设置详细信息
            projectRecordsService.queryProjectDetail(projectRecords);
            projectRecordsAlter.setAlterBeforeRecords(projectRecords);
        }
		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())) {
			projectRecordsAlter.setAct(act);
			model.addAttribute("processInstanceId", projectRecordsAlter.getProcessInstanceId());
		}
		if (projectRecordsAlter!=null&&StringUtils.isNotBlank(projectRecordsAlter.getId())) {
            projectRecordsAlterService.queryProjectAlterDetail(projectRecordsAlter);

        }
		model.addAttribute("projectRecordsAlter", projectRecordsAlter);
		return "modules/ruralprojectrecords/ruralProjectRecordsAlterAudit";
	}

    @RequestMapping(value = "getProcess")
	public String getProcess(RuralProjectRecordsAlter projectRecords, Model model, HttpServletRequest request){
		model.addAttribute("processInstanceId", projectRecords.getProcessInstanceId());
		return "modules/ruralprojectrecords/ruralProjectRecordsTask";
	}

	@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 {
            RuralProjectRecordsAlter projectRecordsAlter = projectRecordsAlterService.get(id);
            if(5==projectRecordsAlter.getProjectStatus()){
                addMessage(redirectAttributes, "项目变更已审批通过，无法撤回");
                return "redirect:"+Global.getAdminPath()+"/ruralProject/ruralProjectRecordsAlter/?repage";
            }
            projectRecordsAlterService.cancelProcess(projectRecordsAlter);
			addMessage(redirectAttributes, "撤回该项目变更成功");
		}catch (Exception e){
			logger.info(e.getMessage());
			addMessage(redirectAttributes, "撤回项目变更失败");
		}
		return "redirect:" + Global.getAdminPath() + "/ruralProject/ruralProjectRecordsAlter/?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<RuralProjectRecordsAlter> lists = new ArrayList<RuralProjectRecordsAlter>();
		for (Act a : list) {
			if (a.getTask().getTaskDefinitionKey()!=null && !"modifyApply".equals(a.getTask().getTaskDefinitionKey())) {
				RuralProjectRecordsAlter projectRecords = projectRecordsAlterService.getByProcessInstanceId(a.getProcInsId());
				if (projectRecords==null){continue;}
				projectRecords.setAuditType("项目登记");
				if(projectRecords.getProjectStatus()!= AlterStatusEnum.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);
					}
				}
			}
		}

		//排除 重新申请|撤销
		Iterator<RuralProjectRecordsAlter> it = lists.iterator();
		while(it.hasNext()){
			RuralProjectRecordsAlter w = it.next();
			if(w.getAct()!=null && w.getAct().getTaskDefKey().equals("reapply")){
				it.remove();
			}
		}

		model.addAttribute("list", lists);
		return "modules/ruralprojectrecords/ruralProjectRecordsToDoList";
	}

	/**
	 * 审批
	 * @param projectRecords
	 * @param model
	 * @param upload_files
	 * @param redirectAttributes
	 * @return
	 */
	@RequestMapping("saveAudit")
	public String saveAudit(RuralProjectRecordsAlter 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 = projectRecordsAlterService.auditSave(projectRecords,users);
				addMessage(redirectAttributes, str);
			}
		}catch (Exception e){
			addMessage(redirectAttributes, "审批失败:"+e);
		}

        if (StringUtils.isNotBlank(home) && "home".equals(home)){
            return "redirect:" + Global.getAdminPath() + "/home/?repage";
        }else {
            return "redirect:" + Global.getAdminPath() + "/ruralProject/ruralProjectRecordsAlter/?repage";
        }
	}

	/**
	 * 查询已办列表
	 * @return
	 */
	@RequestMapping("/queryCompleteList")
	public String queryCompleteList(Act act,HttpServletRequest request,HttpServletResponse response,Model model){
		act.setProcDefKey("projectAudit");
		List<RuralProjectRecordsAlter> list = projectRecordsAlterService.historicList(act);
		Office office = UserUtils.getSelectCompany();
		String companyId = office==null?"":office.getId();
		List<Activity> activities = activityService.groupByActivityMenu("ggh3125f1f194c82bdea93555c750906",companyId);
		for (Activity activity:activities){
			act.setProcDefKey(activity.getProcessKey());
			list.addAll(projectRecordsAlterService.historicList(act));
		}
		model.addAttribute("list",list);
		return "modules/ruralprojectrecords/projectRecordsHistoricList";
	}
}