/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.projectcontentinfo.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.persistence.Page;
import com.jeeplus.common.utils.MyBeanUtils;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.web.BaseController;
import com.jeeplus.modules.act.entity.Act;
import com.jeeplus.modules.act.service.ActTaskService;
import com.jeeplus.modules.projectcontentinfo.entity.ProjectBasedData;
import com.jeeplus.modules.projectcontentinfo.entity.ProjectContentData;
import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
import com.jeeplus.modules.projectcontentinfo.entity.Projectcontentinfo;
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.ProjectRecords;
import com.jeeplus.modules.projectrecord.enums.ProjectStatusEnum;
import com.jeeplus.modules.projectrecord.service.ProjectRecordsService;
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.workclientinfo.entity.WorkClientLinkman;
import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
import com.jeeplus.modules.workgoout.entity.GoOut;
import com.jeeplus.modules.workreview.entity.WorkReviewAudit;
import com.jeeplus.modules.workreview.entity.WorkReviewStandard;
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.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.Socket;
import java.util.*;

/**
 * 工作内容管理Controller
 * @author yangfan
 * @version 2018-06-04
 */
@Controller
@RequestMapping(value = "${adminPath}/projectcontentinfo/projectcontentinfo")
public class ProjectcontentinfoController extends BaseController {

	@Autowired
	private ProjectcontentinfoService projectcontentinfoService;
	@Autowired
	private ProjectRecordsService projectRecordsService;
	@Autowired
	private ProjectBasedDataService projectBasedDataService;
	@Autowired
	private ProjectContentDataService projectContentDataService;
	@Autowired
	private ProjectReportDataService projectReportDataService;
	@Autowired
	private ProjectReportChangeService projectReportChangeService;
	@Autowired
	private ProjectControlTableService projectControlTableService;
	@Autowired
	private WorkReviewStandardService workReviewStandardService;
	@Autowired
	private ActTaskService actTaskService;
	@Autowired
	protected HistoryService historyService;

	@ModelAttribute("projectcontentinfo")
	public Projectcontentinfo get(@RequestParam(required=false) String id) {
		Projectcontentinfo entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = projectcontentinfoService.get(id);
		}
		if (entity == null){
			entity = new Projectcontentinfo();
		}
		return entity;
	}


	@RequiresPermissions("projectcontentinfo:projectcontentinfo:index")
	@RequestMapping(value = {""})
	public String index(Projectcontentinfo projectcontentinfo, Model model) {
//        model.addAttribute("list", officeService.findAll());
		model.addAttribute("projectId", projectcontentinfo.getProject().getId());
		model.addAttribute("id", projectcontentinfo.getId());
		model.addAttribute("view", projectcontentinfo.getView());
		return "modules/projectcontentinfo/projectcontentinfoIndex";
	}
	@RequestMapping(value = {"report"})
	public String report(Projectcontentinfo projectcontentinfo, Model model) {
//        model.addAttribute("list", officeService.findAll());
		ProjectReportData projectReportData = projectReportDataService.get(projectcontentinfo.getInfoId());
		Act act = projectReportDataService.getByAct(projectReportData.getProcessInstanceId());
		projectReportData.setAct(act);
		projectcontentinfo.setProjectReportData(projectReportData);
		List<Projectcontentinfo> projectcontentinfos = projectcontentinfoService.getByChangeInfoId(projectReportData.getId());
		Projectcontentinfo contentinfo = projectcontentinfos.get(0);
		contentinfo.setProjectReportData(projectReportData);
		WorkReviewAudit workReviewAudit = new WorkReviewAudit();
		String type = "";
		if ("master".equals(act.getTaskDefKey())){
			type = "2";
		}else if("bmzr".equals(act.getTaskDefKey())){
			type = "3";
		}else if("bzshbyg".equals(act.getTaskDefKey())){
			type = "4";
		}else if("bzshb".equals(act.getTaskDefKey())){
			type = "4";
		}
		workReviewAudit.setCompanyId(UserUtils.getSelectCompany().getId());
		workReviewAudit.setType(type);
		workReviewAudit.setReportId(projectReportData.getId());
		List<WorkReviewAudit> workReviewAudits = workReviewStandardService.findAuditList(workReviewAudit);
		projectcontentinfo.setHome("home");
		model.addAttribute("type", type);
		model.addAttribute("list", workReviewAudits);
		model.addAttribute("projectId", projectcontentinfo.getProject().getId());
		model.addAttribute("projectcontentinfo", projectcontentinfo);
		return "modules/projectcontentinfo/reportAudit";
	}
	@RequestMapping(value = {"reportView"})
	public String reportView(Projectcontentinfo projectcontentinfo, Model model) {
//        model.addAttribute("list", officeService.findAll());
		ProjectReportData projectReportData = projectReportDataService.get(projectcontentinfo.getInfoId());
		Act act = projectReportDataService.getByAct(projectReportData.getProcessInstanceId());
		projectReportData.setAct(act);
		projectcontentinfo.setProjectReportData(projectReportData);
		projectcontentinfo.setHome("home");
		String msg = "false";
		String number = "false";
		if (("master".equals(act.getTaskDefKey())) || ("bmzr".equals(act.getTaskDefKey())) || ("bzshb".equals(act.getTaskDefKey()))){
			List<Projectcontentinfo> projectcontentinfos = projectcontentinfoService.getByChangeInfoId(projectReportData.getId());
			Projectcontentinfo contentinfo = projectcontentinfos.get(0);
			contentinfo.setProjectReportData(projectReportData);
			WorkReviewAudit workReviewAudit = new WorkReviewAudit();
			String type = "";
			if ("master".equals(act.getTaskDefKey())){
				type = "2";
			}else if("bmzr".equals(act.getTaskDefKey())){
				type = "3";
			}else if("bzshbyg".equals(act.getTaskDefKey())){
				type = "4";
			}else if("bzshb".equals(act.getTaskDefKey())){
				type = "4";
			}
			workReviewAudit.setCompanyId(UserUtils.getSelectCompany().getId());
			workReviewAudit.setType(type);
			workReviewAudit.setReportId(projectReportData.getId());
			List<WorkReviewAudit> workReviewAudits = workReviewStandardService.findAuditList(workReviewAudit);
			projectcontentinfo.setHome("home");
			model.addAttribute("type", type);
			model.addAttribute("list", workReviewAudits);
			if (workReviewAudits!=null && workReviewAudits.size()!=0) {
				for (WorkReviewAudit workReviewAudit1 : workReviewAudits) {
					if (StringUtils.isBlank(workReviewAudit1.getRemarks())) {
						msg = "true";
					}
				}
			}
		}else if ("glyda".equals(act.getTaskDefKey())){
			if (StringUtils.isBlank(projectcontentinfo.getProjectReportData().getNumber())){
				number = "true";
			}
		}
		model.addAttribute("msg", msg);
		model.addAttribute("number", number);
		model.addAttribute("projectId", projectcontentinfo.getProject().getId());
		model.addAttribute("projectcontentinfo", projectcontentinfo);
		return "modules/projectcontentinfo/reportAuditView";
	}
	@RequestMapping(value = {"reportChange"})
	public String reportChange(Projectcontentinfo projectcontentinfo, Model model) {
//        model.addAttribute("list", officeService.findAll());
		ProjectReportData projectReportData = projectReportChangeService.get(projectcontentinfo.getInfoId());
		Act act = projectReportChangeService.getByAct(projectReportData.getProcessInstanceId());
		projectReportData.setAct(act);
		projectcontentinfo.setProjectReportData(projectReportData);
		List<Projectcontentinfo> projectcontentinfos = projectcontentinfoService.getByChangeInfoId(projectReportData.getId());
		Projectcontentinfo contentinfo = projectcontentinfos.get(0);
		contentinfo.setProjectReportData(projectReportData);
		WorkReviewAudit workReviewAudit = new WorkReviewAudit();
		String type = "";
		if ("master".equals(act.getTaskDefKey())){
			type = "1";
		}else if("bmzr".equals(act.getTaskDefKey())){
			type = "2";
		}else if("bzshb".equals(act.getTaskDefKey())){
			type = "3";
		}else if("fgld".equals(act.getTaskDefKey())){
			type = "4";
		}
		workReviewAudit.setCompanyId(UserUtils.getSelectCompany().getId());
		workReviewAudit.setType(type);
		workReviewAudit.setReportId(projectReportData.getId());
		List<WorkReviewAudit> workReviewAudits = workReviewStandardService.findAuditList(workReviewAudit);
		projectcontentinfo.setHome("home");
		model.addAttribute("type", type);
		model.addAttribute("list", workReviewAudits);
		model.addAttribute("projectId", projectcontentinfo.getProject().getId());
		model.addAttribute("projectcontentinfo", projectcontentinfo);
		return "modules/projectcontentinfo/reportChangeAudit";
	}
	@RequestMapping(value = {"reportChangeView"})
	public String reportChangeView(Projectcontentinfo projectcontentinfo,String treeId, Model model) {
//        model.addAttribute("list", officeService.findAll());
		ProjectReportData projectReportData = projectReportChangeService.get(projectcontentinfo.getInfoId());
		Act act = projectReportChangeService.getByAct(projectReportData.getProcessInstanceId());
		projectReportData.setAct(act);
		projectcontentinfo.setProjectReportData(projectReportData);
		projectcontentinfo.setHome("home");
		String msg = "false";
		String number = "false";
		if (("master".equals(act.getTaskDefKey())) || ("bmzr".equals(act.getTaskDefKey())) || ("bzshb".equals(act.getTaskDefKey()))){
			List<Projectcontentinfo> projectcontentinfos = projectcontentinfoService.getByChangeInfoId(projectReportData.getId());
			Projectcontentinfo contentinfo = projectcontentinfos.get(0);
			contentinfo.setProjectReportData(projectReportData);
			WorkReviewAudit workReviewAudit = new WorkReviewAudit();
			String type = "";
			if ("master".equals(act.getTaskDefKey())){
				type = "1";
			}else if("bmzr".equals(act.getTaskDefKey())){
				type = "2";
			}else if("bzshb".equals(act.getTaskDefKey())){
				type = "3";
			}else if("fgld".equals(act.getTaskDefKey())){
				type = "4";
			}
			workReviewAudit.setCompanyId(UserUtils.getSelectCompany().getId());
			workReviewAudit.setReportId(projectReportData.getId());
			workReviewAudit.setType(type);
			List<WorkReviewAudit> workReviewAudits = workReviewStandardService.findAuditList(workReviewAudit);
			if (workReviewAudits!=null && workReviewAudits.size()!=0) {
				for (WorkReviewAudit workReviewAudit1 : workReviewAudits) {
					if (StringUtils.isBlank(workReviewAudit1.getRemarks())) {
						msg = "true";
					}
				}
			}
		}else if ("glyda".equals(act.getTaskDefKey())){
			if (StringUtils.isBlank(projectcontentinfo.getProjectReportData().getNumber())){
				number = "true";
			}
		}
		model.addAttribute("msg", msg);
		model.addAttribute("number", number);
		model.addAttribute("projectId", projectcontentinfo.getProject().getId());
		model.addAttribute("treeId", treeId);
		model.addAttribute("projectcontentinfo", projectcontentinfo);
		return "modules/projectcontentinfo/reportChangeAuditView";
	}

	/**
	 * 工作内容管理列表页面
	 */
	@RequiresPermissions("projectcontentinfo:projectcontentinfo:index")
	@RequestMapping(value = {"list"})
	public String list(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model,RedirectAttributes attr) {
		model.addAttribute("container", "1");
		if (StringUtils.isNotBlank(projectcontentinfo.getChange())){
			model.addAttribute("change", "change");
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getId())){
			model.addAttribute("id", projectcontentinfo.getId());
		}else if(projectcontentinfo.getProject()!=null && StringUtils.isNotBlank(projectcontentinfo.getProject().getId())){
			projectcontentinfo.setParentIds("0,");
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getDictType())){
			model.addAttribute("dictType", projectcontentinfo.getDictType());
		}else {
			model.addAttribute("dictType", "");
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getEdit())){
			model.addAttribute("msg", true);
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getParentIds())){
			model.addAttribute("parentIds", projectcontentinfo.getParentIds());
			//项目列表页面
			ProjectRecords records = projectRecordsService.getQueryProjectUsers(projectcontentinfo.getProject().getId());
			if (!projectRecordsService.getByUsers(records)){
				model.addAttribute("change", "no");
			}
			model.addAttribute("projectRecords", records);
			if (projectcontentinfo.getParentIds().equals("0,")) {
				Projectcontentinfo select = new Projectcontentinfo();
				select.setProject(records);
				select.setParentIds("0,");
				Projectcontentinfo p = projectcontentinfoService.findListByProject(select).get(0);
				model.addAttribute("id",p.getId());
				ProjectBasedData projectBasedData = new ProjectBasedData();
				projectBasedData.setProject(records);
				List<ProjectBasedData> projectBasedDatas = projectBasedDataService.findList(projectBasedData);
				model.addAttribute("projectBasedDatas", projectBasedDatas);
				ProjectContentData projectContentData = new ProjectContentData();
				projectContentData.setProject(records);
				List<ProjectContentData> projectContentDatas = projectContentDataService.findList(projectContentData);
				model.addAttribute("projectContentDatas", projectContentDatas);
				ProjectReportData projectReportData = new ProjectReportData();
				projectReportData.setProject(records);
				List<ProjectReportData> projectReportDatas = projectReportDataService.findList(projectReportData);
				model.addAttribute("projectReportDatas", projectReportDatas);
				return "modules/projectcontentinfo/projectcontentinfoForm";
			}else if (StringUtils.isNotBlank(projectcontentinfo.getType()) && projectcontentinfo.getType().equals("1")){
				if (StringUtils.isBlank(projectcontentinfo.getDictType())){
					//依据性资料列表页面
					ProjectBasedData projectBasedData = projectcontentinfo.getProjectBasedData()==null?new ProjectBasedData():projectcontentinfo.getProjectBasedData();
					projectBasedData.setProject(records);
					Page<ProjectBasedData> page = projectBasedDataService.findPage(new Page<ProjectBasedData>(request, response),projectBasedData);
					model.addAttribute("page", page);
					return "modules/projectcontentinfo/basedDataList";
				}else {
					if (StringUtils.isBlank(projectcontentinfo.getInfoId())){
						ProjectBasedData projectBasedData = projectcontentinfo.getProjectBasedData()==null?new ProjectBasedData():projectcontentinfo.getProjectBasedData();
						projectBasedData.setProject(records);
						projectBasedData.setType(projectcontentinfo.getDictType());
						Page<ProjectBasedData> page = projectBasedDataService.findPage(new Page<ProjectBasedData>(request, response),projectBasedData);
						model.addAttribute("page", page);
						//依据性资料字典类型列表页面 例：政府批文
						return "modules/projectcontentinfo/basedDataList";
					}else{
						ProjectBasedData basedData = projectBasedDataService.get(projectcontentinfo.getInfoId());
						projectcontentinfo.setProjectBasedData(basedData);
						model.addAttribute("projectcontentinfo", projectcontentinfo);
						if (basedData!=null && basedData.getCreateBy()!=null && StringUtils.isNotBlank(basedData.getCreateBy().getId()) && basedData.getCreateBy().getId().equals(UserUtils.getUser().getId()) && StringUtils.isBlank(projectcontentinfo.getChange())){
							//详情页面
							return "modules/projectcontentinfo/basedDataForm";
						}else {
							return "modules/projectcontentinfo/basedDataView";
						}

					}
				}
			}else if (StringUtils.isNotBlank(projectcontentinfo.getType()) && projectcontentinfo.getType().equals("8")){
				if (StringUtils.isNotBlank(projectcontentinfo.getView()) && "change".equals(projectcontentinfo.getView()) ){
					//报告变更
					ProjectReportData projectReportData = projectcontentinfo.getProjectReportData()==null?new ProjectReportData():projectcontentinfo.getProjectReportData();
					projectReportData.setProject(records);
					Page<ProjectReportData> page = projectReportChangeService.findPage(new Page<ProjectReportData>(request, response),projectReportData);
					model.addAttribute("page", page);
					return "modules/projectcontentinfo/reportChangeList";
				}else if (StringUtils.isNotBlank(projectcontentinfo.getView()) && "invalid".equals(projectcontentinfo.getView())){
					//报告作废
					ProjectReportData projectReportData = projectcontentinfo.getProjectReportData()==null?new ProjectReportData():projectcontentinfo.getProjectReportData();
					projectReportData.setProject(records);
					Page<ProjectReportData> page = projectReportDataService.findInvalidPage(new Page<ProjectReportData>(request, response),projectReportData);
					model.addAttribute("page", page);
					model.addAttribute("invalid", "invalid");
					return "modules/projectcontentinfo/reportInvalidList";
				}else{
					if (StringUtils.isBlank(projectcontentinfo.getInfoId())){
						//工作内容字典类型列表页面 例：中竞发咨字[2018]001号
						ProjectReportData projectReportData = projectcontentinfo.getProjectReportData()==null?new ProjectReportData():projectcontentinfo.getProjectReportData();
						projectReportData.setProject(records);
						Page<ProjectReportData> page = projectReportDataService.findPage(new Page<ProjectReportData>(request, response),projectReportData);
						model.addAttribute("page", page);
						return "modules/projectcontentinfo/reportList";
					}else{
						//详情页面
						ProjectReportData projectReportData = projectReportDataService.get(projectcontentinfo.getInfoId());
						projectcontentinfo.setProjectReportData(projectReportData);
						model.addAttribute("projectcontentinfo", projectcontentinfo);
						if (projectReportData!=null && projectReportData.getCreateBy()!=null && StringUtils.isNotBlank(projectReportData.getCreateBy().getId()) && projectReportData.getCreateBy().getId().equals(UserUtils.getUser().getId())){
							if (projectReportData.getStatus().equals("1") || projectReportData.getStatus().equals("3") && StringUtils.isBlank(projectcontentinfo.getChange())){
								//详情页面
								return "modules/projectcontentinfo/reportForm";
							}else {
								return "modules/projectcontentinfo/reportView";
							}
						}else {
							return "modules/projectcontentinfo/reportView";
						}
					}
				}
			}else if("10".equals(projectcontentinfo.getType())){
				//控制表格详情页
				ProjectControlTable controlTable = projectControlTableService.getById(projectcontentinfo.getInfoId());
				projectControlTableService.getDetailInfo(controlTable);
				model.addAttribute("projectControlTable", controlTable);
				return "modules/projectcontroltable/projectControlTableFormView";
			}else if (StringUtils.isNotBlank(projectcontentinfo.getType())){
				if (StringUtils.isBlank(projectcontentinfo.getDictType())){
					//工作内容列表页面
					ProjectContentData projectContentData = projectcontentinfo.getProjectContentData();
					if(projectContentData==null){
						projectContentData = new ProjectContentData();
					}
					projectContentData.setParentType(Integer.valueOf(projectcontentinfo.getType())-1);
					projectContentData.setProject(records);
					Page<ProjectContentData> page = projectContentDataService.findPage(new Page<ProjectContentData>(request, response),projectContentData);
					model.addAttribute("page", page);
					return "modules/projectcontentinfo/workContentList";
				}else {
					if (StringUtils.isBlank(projectcontentinfo.getInfoId())){
						//工作内容字典类型列表页面 例：可行性研究
						ProjectContentData projectContentData = projectcontentinfo.getProjectContentData();
						if(projectContentData==null){
							projectContentData = new ProjectContentData();
						}
						projectContentData.setProject(records);
						projectContentData.setType(projectcontentinfo.getDictType());
						Page<ProjectContentData> page = projectContentDataService.findPage(new Page<ProjectContentData>(request, response),projectContentData);
						model.addAttribute("page", page);
						return "modules/projectcontentinfo/workContentList";
					}else{
						//详情页面
						ProjectContentData projectContentData = projectContentDataService.get(projectcontentinfo.getInfoId());
						projectcontentinfo.setProjectContentData(projectContentData);
						projectcontentinfo.setEdit("edit");
						if(projectContentData!=null&&StringUtils.isNotBlank(projectContentData.getId())){
							List<ProjectControlTable> controlData = projectControlTableService.getControlData(projectContentData.getId(),"");
							projectContentData.setProjectControlTableList(controlData);
							projectContentDataService.queryBasedData(projectContentData);
						}
						model.addAttribute("projectcontentinfo", projectcontentinfo);
						if (projectContentData!=null && projectContentData.getCreateBy()!=null && StringUtils.isNotBlank(projectContentData.getCreateBy().getId()) && projectContentData.getCreateBy().getId().equals(UserUtils.getUser().getId()) && StringUtils.isBlank(projectcontentinfo.getChange())){
							//详情页面
							return "modules/projectcontentinfo/workContentForm";
						}else {
							return "modules/projectcontentinfo/workContentView";
						}
					}
				}
			}
		}
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		projectRecords.setProjectStatus(ProjectStatusEnum.SIGNED.getValue());
		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/projectcontentinfo/projectcontentinfoList";

	}

	/**
	 * 工作内容管理列表页面
	 */
	@RequestMapping(value = {"reportlist"})
	public String reportlist(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model,RedirectAttributes attr) {
		model.addAttribute("change", "change");
		if ("1".equals(projectcontentinfo.getType()) || "10".equals(projectcontentinfo.getType())){
			Boolean change = projectcontentinfoService.getOrChange(projectcontentinfo.getId());
			if (change){
				if (projectcontentinfo.getType().equals("1")) {
					projectcontentinfo.setType("-1");
				}
			}else {
				projectcontentinfo = projectcontentinfoService.getChange(projectcontentinfo.getId());
			}
			model.addAttribute("id", projectcontentinfo.getId());
		}else {
			if (StringUtils.isNotBlank(projectcontentinfo.getId())) {
				projectcontentinfo = projectcontentinfoService.getChange(projectcontentinfo.getId());
				model.addAttribute("id", projectcontentinfo.getId());
			}
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getParentIds())){
			model.addAttribute("parentIds", projectcontentinfo.getParentIds());
			//项目列表页面
			ProjectRecords records = projectRecordsService.getQueryProjectUsers(projectcontentinfo.getProject().getId());
			model.addAttribute("projectRecords", records);
			if (StringUtils.isNotBlank(projectcontentinfo.getType()) && projectcontentinfo.getType().equals("1")){
				if (StringUtils.isNotBlank(projectcontentinfo.getDictType()) && "0".equals(projectcontentinfo.getDictType())){
					String url = projectcontentinfo.getRemarks();
					model.addAttribute("urlInfo", url);
					model.addAttribute("urlName", projectcontentinfo.getName());
					return "modules/projectcontentinfo/viewUrlData";
				}else {
					return null;
				}

			}else if (StringUtils.isNotBlank(projectcontentinfo.getType()) && projectcontentinfo.getType().equals("2")){
				if (StringUtils.isNotBlank(projectcontentinfo.getDictType())) {
					WorkReviewAudit workReviewAudit = new WorkReviewAudit();
					workReviewAudit.setCompanyId(UserUtils.getSelectCompany().getId());
					workReviewAudit.setType(projectcontentinfo.getDictType());
					workReviewAudit.setReportId(projectcontentinfo.getInfoId());
					List<WorkReviewAudit> workReviewAudits = workReviewStandardService.findAuditList(workReviewAudit);
					model.addAttribute("type", projectcontentinfo.getDictType());
					model.addAttribute("list", workReviewAudits);
					return "modules/projectcontentinfo/workReviewStandardList";
				}else {
					return null;
				}
			}else if (StringUtils.isNotBlank(projectcontentinfo.getType())){
				if (StringUtils.isBlank(projectcontentinfo.getInfoId())){
					return null;
				}else if ("-1".equals(projectcontentinfo.getType())){
					projectcontentinfo.setType("1");
					ProjectBasedData basedData = projectBasedDataService.get(projectcontentinfo.getInfoId());
					projectcontentinfo.setProjectBasedData(basedData);
					model.addAttribute("projectcontentinfo", projectcontentinfo);
					return "modules/projectcontentinfo/basedDataView";
				}else if ("10".equals(projectcontentinfo.getType())){
					//控制表格详情页
					ProjectControlTable controlTable = projectControlTableService.getById(projectcontentinfo.getInfoId());
					projectControlTableService.getDetailInfo(controlTable);
					model.addAttribute("projectControlTable", controlTable);
					return "modules/projectcontroltable/projectControlTableFormView";
				}else{
					//详情页面
					ProjectContentData projectContentData = projectContentDataService.get(projectcontentinfo.getLinkId());
					//详情页面
					projectcontentinfo.setEdit("edit");
					if(projectContentData!=null&&StringUtils.isNotBlank(projectContentData.getId())){
						List<ProjectControlTable> controlData = projectControlTableService.getControlData(projectContentData.getId(),"");
						projectContentData.setProjectControlTableList(controlData);
						projectContentDataService.queryBasedData(projectContentData);
					}
					Projectcontentinfo contentinfo = projectcontentinfoService.getByInfoId(projectContentData.getId());
					contentinfo.setProjectContentData(projectContentData);
					model.addAttribute("projectcontentinfo", contentinfo);
					return "modules/projectcontentinfo/workContentView";
				}
			}
		}
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		projectRecords.setProjectStatus(ProjectStatusEnum.SIGNED.getValue());
		Page<ProjectRecords> page = projectRecordsService.findPage(new Page<ProjectRecords>(request, response), projectRecords);
		model.addAttribute("page", page);
		return "modules/projectcontentinfo/projectcontentinfoList";
	}

	@RequestMapping(value = {"form"})
	public String form(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model,RedirectAttributes attr) {
		String dictType = projectcontentinfo.getDictType();
		ProjectRecords records = projectRecordsService.getQueryProjectUsers(projectcontentinfo.getProject().getId());
		projectcontentinfo.setProject(records);
		if (projectcontentinfo.getView().contains("basedData")){
			ProjectBasedData basedData = null;
			if (StringUtils.isNotBlank(projectcontentinfo.getInfoId())){
				basedData = projectBasedDataService.get(projectcontentinfo.getInfoId());
			}else if (projectcontentinfo.getProjectBasedData()!=null && StringUtils.isNotBlank(projectcontentinfo.getProjectBasedData().getId())) {
				basedData = projectBasedDataService.get(projectcontentinfo.getProjectBasedData().getId());
			}
			if(basedData==null){
				basedData = new ProjectBasedData();
			}
			if (StringUtils.isNotBlank(dictType)){
				basedData.setType(dictType);
			}

			if (basedData.getUploadUser()==null || StringUtils.isBlank(basedData.getUploadUser().getId())){
				basedData.setUploadUser(UserUtils.getUser());
			}
			if (basedData.getUploadDate()==null){
				basedData.setUploadDate(new Date());
			}
			projectcontentinfo.setProjectBasedData(basedData);
			model.addAttribute("projectcontentinfo", projectcontentinfo);
			if (projectcontentinfo.getView().equals("basedDataView")){
				return "modules/projectcontentinfo/basedDataView";
			}else {
				if (basedData!=null && basedData.getCreateBy()!=null && StringUtils.isNotBlank(basedData.getCreateBy().getId()) && basedData.getCreateBy().getId().equals(UserUtils.getUser().getId())){
					return "modules/projectcontentinfo/basedDataForm";
				}else if(basedData==null || StringUtils.isBlank(basedData.getId())) {
					return "modules/projectcontentinfo/basedDataForm";
				}else {
					return "modules/projectcontentinfo/basedDataView";
				}
			}

		}else if (projectcontentinfo.getView().contains("content")){
			ProjectContentData projectContentData = new ProjectContentData();
			projectContentData.setType(dictType);
			if (StringUtils.isNotBlank(projectcontentinfo.getInfoId())){
				projectContentData = projectContentDataService.get(projectcontentinfo.getInfoId());
			}else if (projectcontentinfo.getProjectContentData()!=null && StringUtils.isNotBlank(projectcontentinfo.getProjectContentData().getId())) {
				projectContentData = projectContentDataService.get(projectcontentinfo.getProjectContentData().getId());
			}
			projectContentData.setMaster(UserUtils.getUser());
			if(StringUtils.isNotBlank(projectContentData.getId())){
				List<ProjectControlTable> controlData = projectControlTableService.getControlData(projectContentData.getId(),"");
				projectContentData.setProjectControlTableList(controlData);
				projectContentDataService.queryBasedData(projectContentData);
			}
			projectcontentinfo.setProjectContentData(projectContentData);
			model.addAttribute("projectcontentinfo", projectcontentinfo);
			if (projectcontentinfo.getView().equals("contentView")){
				return "modules/projectcontentinfo/workContentView";
			}else {
				if (projectContentData != null && projectContentData.getCreateBy() != null && StringUtils.isNotBlank(projectContentData.getCreateBy().getId()) && projectContentData.getCreateBy().getId().equals(UserUtils.getUser().getId())) {
					return "modules/projectcontentinfo/workContentForm";
				} else if (projectContentData == null || StringUtils.isBlank(projectContentData.getId())) {
					return "modules/projectcontentinfo/workContentForm";
				} else {
					return "modules/projectcontentinfo/workContentView";
				}
			}
		}else if (projectcontentinfo.getView().contains("report")){
			ProjectReportData projectReportData = new ProjectReportData();
			projectReportData.setType(dictType);
			if (projectcontentinfo.getView().equals("reportChangeForm")){
				projectReportData = projectReportChangeService.get(projectcontentinfo.getProjectReportData().getId());
			}else if(projectcontentinfo.getView().equals("reportChangeViewGzr")){
				projectReportData = projectReportChangeService.get(projectcontentinfo.getProjectReportData().getId());
				if(StringUtils.isNotBlank(projectReportData.getProcessInstanceId())){
					Act act = getByAct(projectReportData.getProcessInstanceId());
					projectReportData.setAct(act);
				}
				ProjectReportData beforeEntity = projectReportChangeService.getBefore(projectReportData.getBeforeEntity().getId());
				projectReportData.setBeforeEntity(beforeEntity);
			}else if(projectcontentinfo.getView().equals("reportChangeView")){
				projectReportData = projectReportChangeService.get(projectcontentinfo.getProjectReportData().getId());
				ProjectReportData beforeEntity = projectReportChangeService.getBefore(projectReportData.getBeforeEntity().getId());
				projectReportData.setBeforeEntity(beforeEntity);
			}else if(projectcontentinfo.getView().equals("reportChangeModify")){
				projectReportData = projectReportChangeService.get(projectcontentinfo.getProjectReportData().getId());
				ProjectReportData beforeEntity = projectReportDataService.get(projectReportData.getReportId());
				projectReportData.setBeforeEntity(beforeEntity);
			}else if(projectcontentinfo.getView().equals("reportViewGzr")){
				if (StringUtils.isNotBlank(projectcontentinfo.getInfoId())){
					projectReportData = projectReportDataService.get(projectcontentinfo.getInfoId());
					if(StringUtils.isNotBlank(projectReportData.getProcessInstanceId())){
						Act act = getByAct(projectReportData.getProcessInstanceId());
						projectReportData.setAct(act);
					}
				}else if (projectcontentinfo.getProjectReportData()!=null && StringUtils.isNotBlank(projectcontentinfo.getProjectReportData().getId())) {
					projectReportData = projectReportDataService.get(projectcontentinfo.getProjectReportData().getId());
				}else {
					projectReportData.setNumber("");
				}
			}else {
				if (StringUtils.isNotBlank(projectcontentinfo.getInfoId())){
					projectReportData = projectReportDataService.get(projectcontentinfo.getInfoId());
				}else if (projectcontentinfo.getProjectReportData()!=null && StringUtils.isNotBlank(projectcontentinfo.getProjectReportData().getId())) {
					projectReportData = projectReportDataService.get(projectcontentinfo.getProjectReportData().getId());
				}else {
					projectReportData.setNumber("");
				}
			}

			if (projectReportData.getMaster()==null || StringUtils.isBlank(projectReportData.getMaster().getId())){
				projectReportData.setMaster(UserUtils.getUser());
			}
			if (StringUtils.isBlank(projectReportData.getStatus())){
				projectReportData.setFileStatus("1");
			}
			projectcontentinfo.setProjectReportData(projectReportData);
			model.addAttribute("projectcontentinfo", projectcontentinfo);
			if (projectcontentinfo.getView().equals("reportView")){
				return "modules/projectcontentinfo/reportView";
			}else  if(projectcontentinfo.getView().equals("reportViewGzr")){
				if (StringUtils.isNotBlank(projectReportData.getProcessInstanceId())){
					Act act = projectReportDataService.getByAct(projectReportData.getProcessInstanceId());
					if (act!=null && StringUtils.isNotBlank(act.getTaskDefKey()) && act.getTaskDefKey().equals("gzr")){
						model.addAttribute("gzr", "gzr");
					}
				}
				return "modules/projectcontentinfo/reportView";
			}else if (projectcontentinfo.getView().equals("reportChange")) {
				projectReportData.setReportId(projectReportData.getId());
				projectReportData.setId("");
				projectReportData.setMaster(UserUtils.getUser());
				projectReportData.setReportDate(new Date());
				projectReportData.setRemarks("");
				return "modules/projectcontentinfo/reportChange";
			}else if (projectcontentinfo.getView().equals("reportChangeView")) {
				return "modules/projectcontentinfo/reportChangeView";
			}else  if(projectcontentinfo.getView().equals("reportChangeViewGzr")){
				if (StringUtils.isNotBlank(projectReportData.getProcessInstanceId())){
					Act act = projectReportChangeService.getByAct(projectReportData.getProcessInstanceId());
					if (act!=null && StringUtils.isNotBlank(act.getTaskDefKey()) && act.getTaskDefKey().equals("gzr")){
						model.addAttribute("gzr", "gzr");
					}
				}
				return "modules/projectcontentinfo/reportChangeView";
			}else if (projectcontentinfo.getView().equals("reportChangeForm")) {
				return "modules/projectcontentinfo/reportChange";
			}else if (projectcontentinfo.getView().equals("reportInvalid")) {
				if(StringUtils.isBlank(projectReportData.getInvalidStatus())){
					projectReportData.setRemarks("");
				}
				return "modules/projectcontentinfo/reportInvalid";
			}else if (projectcontentinfo.getView().equals("reportModify")){
				ProcessInstance processInstance = actTaskService.getProcIns(projectReportData.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);
					projectReportData.setAct(act);
					return "modules/projectcontentinfo/reportModifyApply";
				}
			}else if (projectcontentinfo.getView().equals("reportInvalidModify")){
				ProcessInstance processInstance = actTaskService.getProcIns(projectReportData.getInvalidProcessInstanceId());
				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);
					projectReportData.setAct(act);
					return "modules/projectcontentinfo/reportInvalidModifyApply";
				}
			}else if (projectcontentinfo.getView().equals("reportChangeModify")){
				ProcessInstance processInstance = actTaskService.getProcIns(projectReportData.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);
					projectReportData.setAct(act);
					return "modules/projectcontentinfo/reportChangeModifyApply";
				}
			} else{
				if (projectReportData != null && projectReportData.getCreateBy() != null && StringUtils.isNotBlank(projectReportData.getCreateBy().getId()) && projectReportData.getCreateBy().getId().equals(UserUtils.getUser().getId())) {
					return "modules/projectcontentinfo/reportForm";
				} else if (projectReportData == null || StringUtils.isBlank(projectReportData.getId())) {
					return "modules/projectcontentinfo/reportForm";
				} else {
					return "modules/projectcontentinfo/reportView";
				}
			}
		}
		return "";
	}

	@RequestMapping(value = {"save"})
	public String save(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model
			,RedirectAttributes redirectAttributes){
		try{
			String str = projectcontentinfoService.saveData(projectcontentinfo,1);
			if( projectcontentinfo.getProjectContentData() != null && StringUtils.isNotBlank(projectcontentinfo.getProjectContentData().getType())){
				ProjectContentData projectContentData = projectcontentinfo.getProjectContentData();
				projectContentData.setId("");
				//生成动态汇总
				if("41".equals(projectcontentinfo.getProjectContentData().getType())){
					projectContentData.setType("400");
					projectContentData.setName(projectContentData.getName()+"动态汇总");
					projectcontentinfo.setProjectContentData(projectContentData);
					projectcontentinfoService.saveData(projectcontentinfo,1);
				}
			}
			addMessage(redirectAttributes, "保存工作内容信息"+(str.equals("true")?"成功":"失败"));
			if (str.equals("true")){
				if (projectcontentinfo.getProjectBasedData()!=null){
					//依据性资料列表页面
					ProjectBasedData projectBasedData = new ProjectBasedData();
					projectBasedData.setProject(projectBasedData.getProject());
					List<ProjectBasedData> list = projectBasedDataService.findList(projectBasedData);
					model.addAttribute("list", list);
					if (StringUtils.isNotBlank(projectcontentinfo.getEdit()) && projectcontentinfo.getEdit().equals("edit")){
						return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&edit=edit";
					}
					return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId();
					//return "modules/projectcontentinfo/basedDataList";
				}else if (projectcontentinfo.getProjectContentData()!=null){
					ProjectContentData projectContentData = new ProjectContentData();
					projectContentData.setProject(projectcontentinfo.getProject());
					List<ProjectContentData> list = projectContentDataService.findList(projectContentData);
					model.addAttribute("list", list);
					if (StringUtils.isNotBlank(projectcontentinfo.getEdit()) && projectcontentinfo.getEdit().equals("edit")){
						return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&edit=edit";
					}
					return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId()+"&project.id="+projectcontentinfo.getProject().getId();
				}else if (projectcontentinfo.getProjectReportData()!=null){
					/*ProjectReportData projectReportData = projectcontentinfo.getProjectReportData();
					projectReportData.setProject(projectReportData.getProject());
					List<ProjectReportData> list = projectReportDataService.findList(projectReportData);
					model.addAttribute("list", list);*/
					if (StringUtils.isNotBlank(projectcontentinfo.getEdit()) && projectcontentinfo.getEdit().equals("edit")){
						return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&edit=edit";
					}
					return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId();
				}
			}
		}catch (Exception e){
			logger.error("ProjectcontentinfoController save Exception e"+e);
		}
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		addMessage(redirectAttributes, "保存工作内容信息失败");
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?project.id="+projectRecords.getId();
	}

	//
	@RequestMapping(value = {"saveReport"})
	public String saveReport(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response,
							 Model model,RedirectAttributes redirectAttributes)  {
		try{
			String str = projectcontentinfoService.saveData(projectcontentinfo,2);
			addMessage(redirectAttributes, "发起报告审批"+(str.equals("true")?"成功":"失败"));
			ProjectReportData projectReportData = projectcontentinfo.getProjectReportData();
			if (projectReportData!=null){
				//List<ProjectReportData> list = projectReportDataService.findList(projectReportData);
				//model.addAttribute("list", list);
				if (StringUtils.isNotBlank(projectcontentinfo.getEdit()) && projectcontentinfo.getEdit().equals("edit")){
					return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&edit=edit";
				}
				return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId();
			}
		}catch (Exception e){
			logger.error("ProjectcontentinfoController save Exception e"+e);
		}
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		addMessage(redirectAttributes, "发起报告审批失败");
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?project.id="+projectRecords.getId();
	}

	//发起变更
	@RequestMapping(value = {"saveChange"})
	public String saveChange(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response,
							 Model model,RedirectAttributes redirectAttributes) {
		try{
			Boolean b = projectcontentinfoService.saveChange(projectcontentinfo,1);
			if (b){
				addMessage(redirectAttributes, "报告变更已暂存");
				return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId()+"&view=change";
			}
		}catch (Exception e){
			logger.error("ProjectcontentinfoController save Exception e"+e);
		}
		model.addAttribute("msg", "false");
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		addMessage(redirectAttributes, "报告变更暂存失败");
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?project.id="+projectRecords.getId();
	}
	//发起变更
	@RequestMapping(value = {"saveChangeAudit"})
	public String saveChangeAudit(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response,
								  Model model,RedirectAttributes redirectAttributes) {
//		try{
			Boolean b = projectcontentinfoService.saveChange(projectcontentinfo,2);
			if (b){
				addMessage(redirectAttributes, "发起报告变更成功");
				return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId()+"&view=change";
			}
//		}catch (Exception e){
//			logger.error("ProjectcontentinfoController save Exception e"+e);
//		}
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		addMessage(redirectAttributes, "发起报告变更失败");
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?project.id="+projectRecords.getId();
	}
	//报告流程审批
	@RequestMapping(value = {"reportAudit"})
	public String reportAudit(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model,
							  RedirectAttributes redirectAttributes) throws Exception {
		ProjectReportData projectReportData = projectcontentinfo.getProjectReportData();
		ProjectReportData t = projectReportDataService.get(projectReportData.getId());//从数据库取出记录的值
		try {
			MyBeanUtils.copyBeanNotNull2Bean(projectReportData, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
		} catch (Exception e) {
			e.printStackTrace();
		}
		String taskDefKey =  t.getAct().getTaskDefKey();
		List<User> users = null;
		ProjectRecords projectRecord = projectRecordsService.getMasters(projectcontentinfo.getProject().getId());
		if ("master".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),2);
			if (users==null )
				users = UserUtils.getByRoleActivityEnname("bzshb",3,t.getOfficeId(),"12",t.getCreateBy());
		}else if ("bzshb".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),5);
			if (users==null )
				users = UserUtils.getByRoleActivityEnname("gzr",3,t.getOfficeId(),"12",t.getCreateBy());
		}else if ("gzr".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),5);
			if (users==null )
				users = UserUtils.getByRoleActivityEnname("gzr",3,t.getOfficeId(),"12",t.getCreateBy());
		}else if ("modifyApply".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),1);
		}
		String flag = t.getAct().getFlag();
		if ("yes".equals(flag) && (users==null || users.size()==0)){
			addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员！");
		}else {
			if ("modifyApply".equals(taskDefKey)){
				projectcontentinfoService.saveData(projectcontentinfo,3);
			}
			String str = projectReportDataService.auditSave(t, users);
			addMessage(redirectAttributes, str);
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getHome()) && projectcontentinfo.getHome().equals("home")){
			return "redirect:" + Global.getAdminPath() + "/home/?repage";
		}else {
			if (StringUtils.isNotBlank(projectcontentinfo.getEdit()) && projectcontentinfo.getEdit().equals("edit")){
				return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&edit=edit";
			}
			return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId();
		}

	}
	//报告变更审批
	@RequestMapping(value = {"reportChangeAudit"})
	public String reportChangeAudit(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model,
									RedirectAttributes redirectAttributes) throws Exception {
		ProjectReportData projectReportData = projectcontentinfo.getProjectReportData();
		ProjectRecords projectRecord = projectRecordsService.getMasters(projectcontentinfo.getProject().getId());
		ProjectReportData t = projectReportChangeService.get(projectReportData.getId());//从数据库取出记录的值
		try {
			MyBeanUtils.copyBeanNotNull2Bean(projectReportData, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
		} catch (Exception e) {
			e.printStackTrace();
		}
		String taskDefKey =  t.getAct().getTaskDefKey();
		List<User> users = null;
		if ("master".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),2);
			if (users==null )
				users = UserUtils.getByRoleActivityEnname("bzshb",3,t.getOfficeId(),"12",t.getCreateBy());
		} else if ("bzshb".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),5);
			if (users==null )
				users = UserUtils.getByRoleActivityEnname("gzr",3,t.getOfficeId(),"12",t.getCreateBy());
		}else if ("gzr".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),5);
			if (users==null )
				users = UserUtils.getByRoleActivityEnname("gzr",3,t.getOfficeId(),"12",t.getCreateBy());
		}else if ("modifyApply".equals(taskDefKey)){
			users = UserUtils.getByProssType(t.getProcessInstanceId(),1);
		}
		String flag = t.getAct().getFlag();
		if ("yes".equals(flag) && (users==null || users.size()==0)){
			addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员！");
		}else {
			if ("modifyApply".equals(taskDefKey)){
				projectcontentinfoService.saveChange(projectcontentinfo,3);
			}
			String str = projectReportChangeService.auditSave(t, users);
			addMessage(redirectAttributes, str);
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getHome()) && projectcontentinfo.getHome().equals("home")){
			return "redirect:" + Global.getAdminPath() + "/home/?repage";
		}else {
			//报告变更
			return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId()+"&view=change";
		}
	}

	//报告流程审批
	@RequestMapping(value = {"reportInvalidAudit"})
	public String reportInvalidAudit(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response,
									 Model model,RedirectAttributes redirectAttributes) {
		try {
			ProjectReportData projectReportData = projectcontentinfo.getProjectReportData();
			ProjectReportData t = projectReportDataService.get(projectReportData.getId());//从数据库取出记录的值
			try {
				MyBeanUtils.copyBeanNotNull2Bean(projectReportData, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
			} catch (Exception e) {
				e.printStackTrace();
			}
			List<User> users = UserUtils.getByProssType(t.getInvalidProcessInstanceId(),1);
			String flag = projectReportData.getAct().getFlag();
			if ("yes".equals(flag) && (users==null || users.size()==0)){
				addMessage(redirectAttributes, "审批失败,审批人为空,请联系管理员！");
			}else {
				String str = projectReportDataService.auditInvalidSave(t,users);
				addMessage(redirectAttributes, str);
			}
		}catch (Exception e){
			addMessage(redirectAttributes, "审批失败");
		}
		if (StringUtils.isNotBlank(projectcontentinfo.getHome()) && projectcontentinfo.getHome().equals("home")){
			return "redirect:" + Global.getAdminPath() + "/home/?repage";
		}else {
			return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId()+"&view=invalid";
		}
	}

	//发起作废
	@RequestMapping(value = {"saveInvalid"})
	public String saveInvalid(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response,
							  Model model,RedirectAttributes redirectAttributes) {
		try{
			String str = projectcontentinfoService.saveInvalid(projectcontentinfo,1);
			if ("true".equals(str)){
				addMessage(redirectAttributes, "发起作废成功");
			}else {
				addMessage(redirectAttributes, str);
			}
			return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId()+"&view=invalid";
		}catch (Exception e){
			addMessage(redirectAttributes, "发起作废失败");
			logger.error("ProjectcontentinfoController save Exception e"+e);
		}
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		addMessage(redirectAttributes, "发起作废失败");
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?project.id="+projectRecords.getId();
	}
	//发起作废
	@RequestMapping(value = {"saveInvalidAudit"})
	public String saveInvalidAudit(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model,RedirectAttributes redirectAttributes) {
		try{
			String str = projectcontentinfoService.saveInvalid(projectcontentinfo,2);
			if ("true".equals(str)){
				addMessage(redirectAttributes, "发起作废成功");
			}else{
				addMessage(redirectAttributes, str);
			}
			return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?id="+projectcontentinfo.getId()+"&view=invalid";
		}catch (Exception e){
			logger.error("ProjectcontentinfoController save Exception e"+e);
		}
		if(UserUtils.isManager()){
			model.addAttribute("flag","1");
		}
		addMessage(redirectAttributes, "发起作废失败，系统内部错误");
		ProjectRecords projectRecords = projectcontentinfo.getProject()==null?new ProjectRecords():projectcontentinfo.getProject();
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/?project.id="+projectRecords.getId();
	}

	/**
	 * 删除依据性资料
	 */
	@RequestMapping(value = "delete")
	@ResponseBody
	public Map<String,Object> delete(Projectcontentinfo projectcontentinfo, RedirectAttributes redirectAttributes) {
		Map<String,Object> j= new HashMap<>();
		try {
			if (projectcontentinfo.getProjectBasedData()!=null){
				addMessage(redirectAttributes, "删除依据性资料成功");
			}else if (projectcontentinfo.getProjectContentData()!=null){
				addMessage(redirectAttributes, "删除内容成功");
			}else if (projectcontentinfo.getProjectReportData()!=null){
				addMessage(redirectAttributes, "删除报告成功");
			}
			projectcontentinfoService.deleteInfoId(projectcontentinfo.getType(),projectcontentinfo.getInfoId());
			j.put("status",true);
		}catch (Exception e){
			j.put("status",false);
			addMessage(redirectAttributes, "删除失败");
		}
		return j;
	}
	/**
	 * 分配文号
	 */
	@RequestMapping(value = "reportNumber")
	@ResponseBody
	public Map<String,Object> reportNumber(@RequestParam(required=false)String infoId,@RequestParam(required=false)String number,@RequestParam(required=false)String type, RedirectAttributes redirectAttributes) {
		Map<String,Object> j= new HashMap<>();
		try {
			if (type.equals("1")){
				projectReportDataService.reportNumber(infoId,number);
			}else {
				projectReportChangeService.reportNumber(infoId,number);
			}
			addMessage(redirectAttributes, "分配文号成功");
			j.put("status",true);
		}catch (Exception e){
			j.put("status",false);
			addMessage(redirectAttributes, "分配文号失败");
		}
		return j;
	}
	/**
	 * 删除报告变更
	 */
	@RequestMapping(value = "deleteChange")
	public String deleteChange(Projectcontentinfo projectcontentinfo, RedirectAttributes redirectAttributes) {
		try {
			addMessage(redirectAttributes, "删除报告变更成功");
			projectcontentinfoService.deleteInfoIdChange(projectcontentinfo.getInfoId());
		}catch (Exception e){
			logger.error("Exception e"+e);
			addMessage(redirectAttributes, "删除报告变更失败");
		}
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&view=change";

	}
	/**
	 * 删除报告作废
	 */
	@RequestMapping(value = "deleteInvalid")
	public String deleteInvalid(Projectcontentinfo projectcontentinfo, RedirectAttributes redirectAttributes) {
		try {
			addMessage(redirectAttributes, "删除报告作废成功");
			projectcontentinfoService.deleteInfoIdInvalid(projectcontentinfo.getInfoId());
		}catch (Exception e){
			logger.error("Exception e"+e);
			addMessage(redirectAttributes, "删除报告作废失败");
		}
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&view=invalid";

	}

	/**
	 * 报告作废：强制撤回
	 */
	@RequestMapping("cancelInvalidate")
	public String cancelInvalidate(Projectcontentinfo projectcontentinfo,RedirectAttributes redirectAttributes){
		try {
			ProjectReportData reportData = projectReportDataService.get(projectcontentinfo.getInfoId());
			if(reportData.getStatus().equals("5")){
				addMessage(redirectAttributes, "报告已审批通过，无法撤回");
			}else{
				projectReportDataService.cancelInvalidate(reportData);
				addMessage(redirectAttributes, "报告撤回成功");
			}
		}catch (Exception e){
			logger.error("Exception e"+e);
			addMessage(redirectAttributes, "报告撤回失败");
		}
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId();

	}
	/**
	 * 报告作废：强制撤回d
	 */
	@RequestMapping("cancelInvalid")
	public String cancelInvalid(Projectcontentinfo projectcontentinfo,RedirectAttributes redirectAttributes){
		try {
			ProjectReportData reportData = projectReportDataService.get(projectcontentinfo.getInfoId());
			if(reportData.getInvalidStatus().equals("5")){
				addMessage(redirectAttributes, "报告作废已审批通过，无法撤回");
			}else{
				projectReportDataService.cancelInvalid(reportData);
				addMessage(redirectAttributes, "报告作废撤回成功");
			}
		}catch (Exception e){
			logger.error("Exception e"+e);
			addMessage(redirectAttributes, "报告作废撤回失败");
		}
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&view=invalid";

	}
	/**
	 * 报告变更作废：强制撤回
	 */
	@RequestMapping("cancelInvalidateChange")
	public String cancelInvalidateChange(Projectcontentinfo projectcontentinfo,RedirectAttributes redirectAttributes){
		try {
			ProjectReportData reportData = projectReportChangeService.get(projectcontentinfo.getInfoId());
			if(reportData.getStatus().equals("5")){
				addMessage(redirectAttributes, "报告变更已审批通过，无法撤回");
			}else{
				projectReportChangeService.cancelInvalidate(reportData);
				addMessage(redirectAttributes, "报告变更撤销回成功");
			}
		}catch (Exception e){
			logger.error("Exception e"+e);
			addMessage(redirectAttributes, "报告变更撤销失败");
		}
		return "redirect:"+Global.getAdminPath()+"/projectcontentinfo/projectcontentinfo/list?id="+projectcontentinfo.getId()+"&view=change";

	}

	/**
	 * 获取机构JSON数据。
	 *
	 * @param extId    排除的ID
	 * @param type     类型（1：公司；2：部门/小组/其它：3：用户）
	 * @param grade    显示级别
	 * @param response
	 * @return
	 */
	@RequiresPermissions("user")
	@ResponseBody
	@RequestMapping(value = "treeData")
	public List<Map<String, Object>> treeData(@RequestParam(required = false) String projectId,@RequestParam(required = false) String extId, @RequestParam(required = false) String type,
											  @RequestParam(required = false) Long grade, @RequestParam(required = false) Boolean isAll, HttpServletResponse response) {
		List<Map<String, Object>> mapList = Lists.newArrayList();
		Projectcontentinfo projectcontentinfo = new Projectcontentinfo();
		projectcontentinfo.setProject(new ProjectRecords(projectId));
		List<Projectcontentinfo> list = projectcontentinfoService.findList(projectcontentinfo);
		for (int i = 0; i < list.size(); i++) {
			Projectcontentinfo e = list.get(i);
			if ((StringUtils.isBlank(extId) || (extId != null && !extId.equals(e.getId()) && e.getParentIds().indexOf("," + extId + ",") == -1))
					) {
				Map<String, Object> map = Maps.newHashMap();
				map.put("id", e.getId());
				map.put("pId", e.getParentId());
				map.put("pIds", e.getParentIds());
				map.put("name", e.getName());
				if (type != null && "3".equals(type)) {
					map.put("isParent", true);
				}
				mapList.add(map);
			}
		}
		return mapList;
	}
	/**
	 * 获取机构JSON数据。
	 *
	 * @param extId    排除的ID
	 * @param type     类型（1：公司；2：部门/小组/其它：3：用户）
	 * @param grade    显示级别
	 * @param response
	 * @return
	 */
	@RequiresPermissions("user")
	@ResponseBody
	@RequestMapping(value = "treeDataReport")
	public List<Map<String, Object>> treeDataReport(@RequestParam(required = false) String treeId,@RequestParam(required = false) String infoId,@RequestParam(required = false) String projectId,@RequestParam(required = false) String extId, @RequestParam(required = false) String type,
													@RequestParam(required = false) Long grade, @RequestParam(required = false) Boolean isAll, HttpServletResponse response) {
		List<Map<String, Object>> mapList = Lists.newArrayList();
		Projectcontentinfo projectcontentinfo = new Projectcontentinfo();
		projectcontentinfo.setProject(new ProjectRecords(projectId));
		if (StringUtils.isNotBlank(treeId)){
			projectcontentinfo.setInfoId(treeId);
		}else {
			projectcontentinfo.setInfoId(infoId);
		}

		List<Projectcontentinfo> list = projectcontentinfoService.findListByReport(projectcontentinfo);
		for (int i = 0; i < list.size(); i++) {
			Projectcontentinfo e = list.get(i);
			if ((StringUtils.isBlank(extId) || (extId != null && !extId.equals(e.getId()) && e.getParentIds().indexOf("," + extId + ",") == -1))
					) {

				Map<String, Object> map = Maps.newHashMap();
				if (!"3".equals(e.getType())){
					map.put("id", e.getId());
					map.put("pId", e.getParentId());
					map.put("type", e.getType());
					map.put("urlInfo", e.getRemarks());
					map.put("dictType", e.getDictType());
					map.put("pIds", e.getParentIds());
					map.put("name", e.getName());
					map.put("read", "read");
				}else{
					Projectcontentinfo contentinfo = projectcontentinfoService.findByBasedInfo(e);
					map.put("id", contentinfo.getId());
					map.put("pId", e.getId());
					map.put("type", contentinfo.getType());
					map.put("urlInfo", contentinfo.getRemarks());
					map.put("dictType", contentinfo.getDictType());
					map.put("pIds", e.getParentIds());
					map.put("name", contentinfo.getName());
					map.put("read", "read");
				}
				if (type != null && "3".equals(type)) {
					map.put("isParent", true);
				}
				if ("4".equals(e.getType())){
					List<Projectcontentinfo> contentinfoParents = projectcontentinfoService.findByParentIds(e);
					Map<String,String> mapParent = new HashMap<>();
					for (Projectcontentinfo contentinfo:contentinfoParents){
						if (StringUtils.isBlank(contentinfo.getInfoId())){
							Map<String, Object> maps = Maps.newHashMap();
							maps.put("id", contentinfo.getId());
							maps.put("pId", e.getId());
							maps.put("type", contentinfo.getType());
							maps.put("urlInfo", contentinfo.getRemarks());
							maps.put("dictType", contentinfo.getDictType());
							maps.put("pIds", e.getParentIds()+e.getId()+",");
							maps.put("name", contentinfo.getName());
							maps.put("read", "");
							if (type != null && "3".equals(type)) {
								maps.put("isParent", true);
							}
							mapParent.put(StringUtils.isBlank(contentinfo.getDictType())?"0":contentinfo.getDictType(),e.getParentIds()+e.getId()+","+contentinfo.getId()+",");
							mapList.add(maps);
						}
					}
					for (Projectcontentinfo contentinfo:contentinfoParents){
						if (StringUtils.isNotBlank(contentinfo.getDictType()) && StringUtils.isNotBlank(contentinfo.getInfoId())){
							Map<String, Object> maps = Maps.newHashMap();
							String parentIds = mapParent.get("1".equals(contentinfo.getType())?"0":contentinfo.getDictType());
							String parentIdarr[] = parentIds.split(",");
							String parentId = parentIdarr[parentIdarr.length-1];
							maps.put("id", contentinfo.getId());
							maps.put("pId", parentId);
							maps.put("type", contentinfo.getType());
							maps.put("urlInfo", contentinfo.getRemarks());
							maps.put("dictType", contentinfo.getDictType());
							maps.put("pIds", parentIds);
							maps.put("name", contentinfo.getName());
							maps.put("read", "read");
							if (type != null && "3".equals(type)) {
								maps.put("isParent", true);
							}
							mapList.add(maps);
						}
					}
				}
				mapList.add(map);
			}
		}
		return mapList;
	}

	/**
	 * 读取单个实体流程
	 * @return
	 */
	@RequestMapping(value = "getProcessOne")
	public String getProcessOne(Projectcontentinfo projectcontentinfo,String type,Model model) {
		if ("2".equals(type)){          //审批中流程
			ProjectReportData projectReportData = projectReportDataService.get(projectcontentinfo.getProjectReportData().getId());
			model.addAttribute("processInstanceId", projectReportData.getProcessInstanceId());
		}else if("3".equals(type)){     //变更中流程
			ProjectReportData projectReportData = projectReportChangeService.get(projectcontentinfo.getProjectReportData().getId());
			model.addAttribute("processInstanceId", projectReportData.getProcessInstanceId());
		} else if("8".equals(type)){         //变更中流程
			ProjectReportData projectReportData = projectReportDataService.get(projectcontentinfo.getProjectReportData().getId());
			model.addAttribute("processInstanceId", projectReportData.getUpId());
		}else if("6".equals(type) || "7".equals(type)){      //作废流程
			ProjectReportData projectReportData = projectReportDataService.get(projectcontentinfo.getProjectReportData().getId());
			model.addAttribute("processInstanceId", projectReportData.getInvalidProcessInstanceId());
		}else if("5".equals(type)){
			ProjectReportData projectReportData = projectReportDataService.get(projectcontentinfo.getProjectReportData().getId());
			if(projectReportData.getUpId() != null){
				model.addAttribute("processInstanceId", projectReportData.getUpId());
			}else {
				model.addAttribute("processInstanceId", projectReportData.getProcessInstanceId());
			}
		}
		return "modules/workreimbursement/workReimbursementTrack";
	}

	@RequestMapping(value = "ajaxsaveBaseData")
	@ResponseBody
	public AjaxJson ajaxsave(Projectcontentinfo projectcontentinfo, HttpServletRequest request, HttpServletResponse response, Model model) {
		AjaxJson ajaxJson = new AjaxJson();
		try{
			String str = projectcontentinfoService.saveData(projectcontentinfo,1);
			if (str.equals("true")){
				ajaxJson.setMsg("保存依据资料成功！");
				ProjectBasedData basedData = projectcontentinfo.getProjectBasedData();
				ProjectBasedData projectBasedData = new ProjectBasedData();
				projectBasedData.setId(basedData.getId());
				projectBasedData.setNumber(basedData.getNumber());
				projectBasedData.setName(basedData.getName());
				projectBasedData.setUploadUser(basedData.getUploadUser());
				projectBasedData.setUploadDate(basedData.getUploadDate());
				projectBasedData.setType(basedData.getType());
				projectBasedData.setTypeLabel(DictUtils.getDictLabel(basedData.getType(),"project_document_type",""));
				ajaxJson.getBody().put("workBasedData",projectBasedData);
			}
		}catch (Exception e){
			logger.error("ProjectcontentinfoController save Exception e",e);
			ajaxJson.setSuccess(false);
		}
		return ajaxJson;
	}

	@RequestMapping("ajaxContentdelete")
	@ResponseBody
	public AjaxJson ajaxContentdelete(String contentId,String reportId,String projectId){
		AjaxJson ajaxJson = new AjaxJson();
		if(StringUtils.isNotBlank(contentId)){
			projectContentDataService.deleteContent(contentId,reportId,projectId,"1");
		}
		return  ajaxJson;
	}
	@RequestMapping("ajaxContentChangedelete")
	@ResponseBody
	public AjaxJson ajaxContentChangedelete(String contentId,String reportId,String projectId){
		AjaxJson ajaxJson = new AjaxJson();
		if(StringUtils.isNotBlank(contentId)){
			projectContentDataService.deleteContent(contentId,reportId,projectId,"2");
		}
		return  ajaxJson;
	}

	@RequestMapping("form1")
	public String form1(String id,Model model){
		ProjectReportData projectReportData = projectReportDataService.get(id);
		Projectcontentinfo projectcontentinfo = new Projectcontentinfo();
		projectcontentinfo.setProjectReportData(projectReportData);
		model.addAttribute("projectcontentinfo", projectcontentinfo);
		return "modules/projectcontentinfo/reportView";
	}

	public Act getByAct(String processInstanceId){
		Act act = new Act();
		HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
		ProcessInstance processInstance = actTaskService.getProcIns(processInstanceId);
		if (processInstance!=null) {
			List<Task> taskList = actTaskService.getCurrentTaskList(processInstance);
			if(taskList!=null && taskList.size()>1){
				for (Task taskInfok:taskList) {
					if (taskInfok.getAssignee().equals(UserUtils.getUser().getId())) {
						act.setTaskId(taskInfok.getId());
						act.setTaskName(taskInfok.getName());
						act.setTaskDefKey(taskInfok.getTaskDefinitionKey());
						act.setProcDefId(taskInfok.getProcessDefinitionId());
						act.setProcInsId(taskInfok.getProcessInstanceId());
						act.setTask(taskInfok);
					}
				}
			}else {
				Task task = actTaskService.getCurrentTaskInfo(processInstance);
				act.setTaskId(task.getId());
				act.setTaskName(task.getName());
				act.setTaskDefKey(task.getTaskDefinitionKey());
				act.setProcDefId(task.getProcessDefinitionId());
				act.setProcInsId(task.getProcessInstanceId());
				act.setTask(task);
			}
		}
		return  act;
	}

}