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

import com.google.common.collect.Maps;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.web.BaseController;
import com.jeeplus.modules.act.entity.Act;
import com.jeeplus.modules.act.service.ActTaskService;
import com.jeeplus.modules.alterinfo.entity.AlterInfo;
import com.jeeplus.modules.caseinfo.service.CaseInfoService;
import com.jeeplus.modules.iim.service.MailBoxService;
import com.jeeplus.modules.leaveapply.entity.LeaveApply;
import com.jeeplus.modules.leaveapply.entity.LeaveDetail;
import com.jeeplus.modules.leaveapply.service.LeaveApplyService;
import com.jeeplus.modules.leaveapply.service.LeaveDetailService;
import com.jeeplus.modules.leavetype.dao.LeaveTypeDao;
import com.jeeplus.modules.leavetype.entity.LeaveType;
import com.jeeplus.modules.leavetype.service.LeaveTypeService;
import com.jeeplus.modules.oa.service.LeaveService;
import com.jeeplus.modules.oa.service.OaNotifyService;
import com.jeeplus.modules.oa_evection.service.oa_evection.OaEvectionService;
import com.jeeplus.modules.oaall.service.OaAllService;
import com.jeeplus.modules.oabuy.service.OaBuyService;
import com.jeeplus.modules.oaperformance.service.OaPerformanceService;
import com.jeeplus.modules.officeintroduce.dao.OfficeintroduceDao;
import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
import com.jeeplus.modules.projectcontentinfo.entity.Projectcontentinfo;
import com.jeeplus.modules.projectcontentinfo.service.ProjectReportChangeService;
import com.jeeplus.modules.projectcontentinfo.service.ProjectReportDataService;
import com.jeeplus.modules.projectcontentinfo.service.ProjectReportRecordService;
import com.jeeplus.modules.projectcontentinfo.service.ProjectcontentinfoService;
import com.jeeplus.modules.projectrecord.entity.ProjectRecords;
import com.jeeplus.modules.projectrecord.entity.ProjectRecordsAlter;
import com.jeeplus.modules.projectrecord.service.ProjectRecordsAlterService;
import com.jeeplus.modules.projectrecord.service.ProjectRecordsService;
import com.jeeplus.modules.pushinfo.service.PushinfoService;
import com.jeeplus.modules.sys.entity.Office;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.service.CompanyService;
import com.jeeplus.modules.sys.service.OfficeService;
import com.jeeplus.modules.sys.service.WorkattachmentService;
import com.jeeplus.modules.sys.utils.DictUtils;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.utils.ErrorCode;
import com.jeeplus.modules.workadministrativeatamp.entity.WorkAdministrativeAtamp;
import com.jeeplus.modules.workadministrativeatamp.service.WorkAdministrativeAtampService;
import com.jeeplus.modules.workapprovalcopy.entity.ApprovalCopy;
import com.jeeplus.modules.workaskcheckprice.service.WorkAskCheckPriceService;
import com.jeeplus.modules.workattendance.entity.WorkAttendanceCount;
import com.jeeplus.modules.workattendance.entity.WorkAttendanceInfo;
import com.jeeplus.modules.workattendance.service.WorkAttendanceCountService;
import com.jeeplus.modules.workattendance.service.WorkAttendanceInfoService;
import com.jeeplus.modules.workbidingdocument.service.WorkBidingDocumentService;
import com.jeeplus.modules.workbidingproject.service.WorkBidingProjectService;
import com.jeeplus.modules.workbidproject.entity.WorkBidProject;
import com.jeeplus.modules.workbidproject.service.WorkBidProjectService;
import com.jeeplus.modules.workborrowmangement.service.WorkBorrowBackService;
import com.jeeplus.modules.workcalendar.service.WorkCalendarService;
import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
import com.jeeplus.modules.workcontent.web.WorkContentTypeController;
import com.jeeplus.modules.workcontractinfo.entity.WorkContractInfo;
import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
import com.jeeplus.modules.workcontractrecord.service.WorkContractRecordService;
import com.jeeplus.modules.workdailyroutine.service.WorkDailyRoutineDetailService;
import com.jeeplus.modules.workdailyroutine.service.WorkDailyRoutineService;
import com.jeeplus.modules.workengineeringproject.service.WorkEngineeringProjectService;
import com.jeeplus.modules.workfield.entity.WorkField;
import com.jeeplus.modules.workfield.service.WorkFieldService;
import com.jeeplus.modules.workfullconstructsheet.service.WorkFullConstructsheetService;
import com.jeeplus.modules.workfulldesignchange.service.WorkFullDesignchangeService;
import com.jeeplus.modules.workfullexecute.service.WorkFullExecuteService;
import com.jeeplus.modules.workfullmanage.service.WorkFullManageService;
import com.jeeplus.modules.workfullmanage.service.WorkFullPayService;
import com.jeeplus.modules.workfullmanage.service.WorkFullRecordService;
import com.jeeplus.modules.workfullmeetingminutes.service.WorkFullMeetingminutesService;
import com.jeeplus.modules.workfullproprietorsheet.service.WorkFullProprietorsheetService;
import com.jeeplus.modules.workfullsupervisorsheet.service.WorkFullSupervisorsheetService;
import com.jeeplus.modules.workgoout.service.GoOutService;
import com.jeeplus.modules.workincomingmessage.entity.WorkIncomingMessage;
import com.jeeplus.modules.workincomingmessage.service.WorkIncomingMessageService;
import com.jeeplus.modules.workinvoice.entity.WorkInvoice;
import com.jeeplus.modules.workinvoice.service.WorkInvoiceService;
import com.jeeplus.modules.workinvoicealter.service.WorkInvoiceAlterService;
import com.jeeplus.modules.workinvoicedetail.service.WorkInvoiceDetailService;
import com.jeeplus.modules.workinvoicereturn.entity.WorkInvoiceReturn;
import com.jeeplus.modules.workinvoicereturn.service.WorkInvoiceReturnService;
import com.jeeplus.modules.workinvoicereturnalter.service.WorkInvoiceReturnAlterService;
import com.jeeplus.modules.workitemcollar.service.WorkItemCollarService;
import com.jeeplus.modules.workout.entity.WorkOut;
import com.jeeplus.modules.workout.service.WorkOutService;
import com.jeeplus.modules.workovertime.entity.WorkOvertime;
import com.jeeplus.modules.workovertime.service.WorkOvertimeService;
import com.jeeplus.modules.workovertimeform.service.WorkOvertimeFormService;
import com.jeeplus.modules.workpayment.service.WorkPaymentService;
import com.jeeplus.modules.workpettycash.service.WorkPettyCashService;
import com.jeeplus.modules.workproject.service.WorkProjectService;
import com.jeeplus.modules.workprojectcompletion.service.WorkProjectCompletionService;
import com.jeeplus.modules.workprojectdeposit.service.WorkProjectDepositService;
import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
import com.jeeplus.modules.workreceiptsrevise.entity.WorkReceiptsRevise;
import com.jeeplus.modules.workreceiptsrevise.service.WorkReceiptsReviseService;
import com.jeeplus.modules.workreceiptssettle.entity.WorkReceiptsSettle;
import com.jeeplus.modules.workreceiptssettle.entity.WorkReceiptsSettleDetail;
import com.jeeplus.modules.workreceiptssettle.service.WorkReceiptsSettleService;
import com.jeeplus.modules.workreimbur.service.WorkReimburService;
import com.jeeplus.modules.workreimbursement.entity.WorkReimbursement;
import com.jeeplus.modules.workreimbursement.service.WorkReimbursementService;
import com.jeeplus.modules.workreimbursement.utils.VarStr;
import com.jeeplus.modules.workresignation.service.WorkResignationService;
import com.jeeplus.modules.workreview.entity.WorkReviewAudit;
import com.jeeplus.modules.workreview.service.WorkReviewStandardService;
import com.jeeplus.modules.workscrap.service.WorkScrapService;
import com.jeeplus.modules.worksealform.service.WorkSealFormService;
import com.jeeplus.modules.worksendmessage.entity.WorkSendMessage;
import com.jeeplus.modules.worksendmessage.service.WorkSendMessageService;
import com.jeeplus.modules.workstaff.entity.WorkStaffBasicInfo;
import com.jeeplus.modules.workstock.service.WorkStockService;
import com.jeeplus.modules.workstockcontract.service.WorkStockContractService;
import com.jeeplus.modules.workvisa.service.WorkVisaService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.activiti.engine.ActivitiObjectNotFoundException;
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.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 流程个人任务相关Controller
 * @author jeeplus
 * @version 2013-11-03
 */
@SuppressWarnings("all")
@Controller
@RequestMapping(value = "${frontPath}/business")
public class BusinessManagementController extends BaseController {

    @Autowired
    private PushinfoService pushinfoService;
    @Autowired
    private WorkattachmentService workattachmentService;
    @Autowired
    private WorkFullManageService workFullManageService;
    @Autowired
    private CaseInfoService caseInfoService;
    @Autowired
    private LeaveTypeService leaveTypeService;
    @Autowired
    private OfficeService officeService;
    @Autowired
    private WorkBidingDocumentService workBidingDocumentService;
    @Autowired
    private WorkFullExecuteService workFullExecuteService;
    @Autowired
    private WorkFullMeetingminutesService workFullMeetingminutesService;
    @Autowired
    private WorkFullDesignchangeService workFullDesignchangeService;
    @Autowired
    private WorkFullProprietorsheetService workFullProprietorsheetService;
    @Autowired
    private OaBuyService oaBuyService;
    @Autowired
    private OaPerformanceService oaPerformanceService;
    @Autowired
    private WorkContractRecordService workContractRecordService;
    @Autowired
    private WorkCalendarService workCalendarService;
    @Autowired
    private WorkFullSupervisorsheetService workFullSupervisorsheetService;
    @Autowired
    private WorkFullConstructsheetService workFullConstructsheetService;
    @Autowired
    private WorkProjectNotifyService workProjectNotifyService;
    @Autowired
    private WorkBidProjectService workBidProjectService;
    @Autowired
    private WorkProjectDepositService workProjectDepositService;
    @Autowired
    private LeaveTypeDao leaveTypeDao;
    @Autowired
    private WorkEngineeringProjectService workEngineeringProjectService;
    @Autowired
    private WorkFullRecordService workFullRecordService;
    @Autowired
    private WorkInvoiceService workInvoiceService;
    @Autowired
    private WorkReimbursementService workReimbursementService;
    @Autowired
    private OaNotifyService oaNotifyService;
    @Autowired
    private MailBoxService mailBoxService;
    @Autowired
    private WorkProjectCompletionService workProjectCompletionService;
    @Autowired
    private WorkContractInfoService workContractInfoService;
    @Autowired
    private WorkFullPayService workFullPayService;
    @Autowired
    private WorkAskCheckPriceService workAskCheckPriceService;
    @Autowired
    private WorkVisaService workVisaService;
    @Autowired
    private CompanyService companyService;
    @Autowired
    private LeaveService leaveService;
    @Autowired
    private GoOutService goOutService;
    @Autowired
    private WorkProjectService workProjectService;

    @Autowired
    private WorkSealFormService workSealFormService;
    @Autowired
    private WorkOvertimeFormService workOvertimeFormService;
    @Autowired
    private OaEvectionService oaEvectionService;
    @Autowired
    private WorkBidingProjectService workBidingProjectService;
    @Autowired
    private OaAllService oaAllService;
    @Autowired
    private WorkPettyCashService workPettyCashService;
    @Autowired
    private WorkPaymentService workPaymentService;
    @Autowired
    private WorkInvoiceAlterService workInvoiceAlterService;

    @Autowired
    private WorkReimburService workReimburService;
    @Autowired
    private OfficeintroduceDao officeintroduceDao;
    @Autowired
    private ActTaskService actTaskService;
    @Autowired
    protected HistoryService historyService;
    @Autowired
    protected WorkInvoiceDetailService workInvoiceDetailService;
    @Autowired
    private ProjectRecordsService projectRecordsService;
    @Autowired
    private ProjectRecordsAlterService projectRecordsAlterService;
    @Autowired
    private ProjectReportDataService projectReportDataService;
    @Autowired
    private ProjectcontentinfoService projectcontentinfoService;
    @Autowired
    private ProjectReportChangeService projectReportChangeService;
    @Autowired
    private WorkInvoiceReturnService workInvoiceReturnService;
    @Autowired
    private WorkInvoiceReturnAlterService workInvoiceReturnAlterService;
    @Autowired
    private WorkReviewStandardService workReviewStandardService;
    @Autowired
    private ProjectReportRecordService projectReportRecordService;
    @Autowired
    private WorkReceiptsSettleService workReceiptsSettleService;
    @Autowired
    private WorkReceiptsReviseService workReceiptsReviseService;
    @Autowired
    private WorkIncomingMessageService workIncomingMessageService;
    @Autowired
    private WorkAdministrativeAtampService workAdministrativeAtampService;
    @Autowired
    private WorkDailyRoutineDetailService workDailyRoutineDetailService;
    @Autowired
    private WorkDailyRoutineService workDailyRoutineService;
    @Autowired
    private WorkBorrowBackService workBorrowBackService;
    @Autowired
    private WorkStockContractService workStockContractService;
    @Autowired
    private WorkSendMessageService workSendMessageService;
    @Autowired
    private WorkStockService workStockService;
    @Autowired
    private WorkScrapService workScrapService;
    @Autowired
    private WorkItemCollarService workItemCollarService;
    @Autowired
    private WorkAttendanceCountService workAttendanceCountService;
    @Autowired
    private WorkAttendanceInfoService workAttendanceInfoService;
    @Autowired
    private WorkOvertimeService workOvertimeService;
    @Autowired
    private WorkOutService workOutService;
    @Autowired
    private WorkFieldService workFieldService;
    @Autowired
    private WorkResignationService workResignationService;
    @Autowired
    private LeaveApplyService leaveApplyService;
    @Autowired
    private LeaveDetailService leaveDetailService;

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    private SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    @RequestMapping(value={"businessTodoList"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson businessTodoList(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HashMap requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            if (StringUtils.isBlank(request.getParameter("pageNo")) || StringUtils.isBlank(request.getParameter("pageSize"))){
                j.setSuccess(false);
                j.setErrorCode(ErrorCode.code_2001);
                j.setMsg("读取待办任务失败");
            }
            int pageNo = Integer.parseInt(request.getParameter("pageNo"));
            int pageSize = Integer.parseInt(request.getParameter("pageSize"));
            WorkProjectNotify workProjectNotify = new WorkProjectNotify();
            workProjectNotify.setUser(UserUtils.getUser());
            workProjectNotify.setCompanyId(UserUtils.getSelectCompany().getId());
            workProjectNotify.setRemarks("待审批");
            Page<WorkProjectNotify> page = workProjectNotifyService.findPageByAPP(new Page<WorkProjectNotify>(request, response),workProjectNotify);
            List<WorkProjectNotify> list = page.getList();
            List list1 = new ArrayList();
            if(list==null){
                j.setSuccess(false);
                j.setErrorCode(ErrorCode.code_2005);
                j.setMsg("获取列表失败");
                j.put("data", list1);
            }else {
                j.put("maxNum", page.getCount());
                Map<String,String> mapDict = com.jeeplus.common.utils.StringUtils.getByDictMap();
                if (pageNo <= page.getTotalPage()) {
                    for (int i=0;i< list.size();i++) {
                        WorkProjectNotify projectNotify = list.get(i);
                        User createBy = UserUtils.get(projectNotify.getCreateBy().getId())==null?new User():UserUtils.get(projectNotify.getCreateBy().getId());
                        Map<String,Object> map = new HashMap<>();
                        map.put("notifyId",projectNotify.getNotifyId());
                        map.put("title","["+mapDict.get(projectNotify.getType()+"")+"]"+projectNotify.getTitle());
                        map.put("createDate",sdf.format(projectNotify.getCreateDate()));
                        map.put("userId",createBy.getId());
                        map.put("userName",createBy.getName());
                        map.put("userPhoto",createBy.getPhoto());
                        map.put("type",projectNotify.getType());
                        map.put("status",projectNotify.getStatus());
                        map.put("id",projectNotify.getId());
                        map.put("appAudit", 0);
                        map.put("appShow", 0);
                        //报销
                        if ("13".equals(projectNotify.getType())){
                            WorkReimbursement workReimbursement = workReimbursementService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workReimbursement.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (!act.getTaskDefKey().equals("cw") && !act.getTaskDefKey().equals("cn") && !act.getTaskDefKey().equals("modifyApply")) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }//合同申请
                        else if ("16".equals(projectNotify.getType())){
                            WorkContractInfo workContractInfo =workContractInfoService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workContractInfo.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (!act.getTaskDefKey().equals("gzr") && !act.getTaskDefKey().equals("modifyApply")) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }//发票管理
                        else if ("21".equals(projectNotify.getType())){
                            WorkInvoice workInvoice = workInvoiceService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workInvoice.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (act.getTaskDefKey().equals("bmzr") || act.getTaskDefKey().equals("scbzr") ) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }/*else if ("24".equals(projectNotify.getType())){

                        }else if ("25".equals(projectNotify.getType())){

                        }else if ("26".equals(projectNotify.getType())){

                        }else if ("27".equals(projectNotify.getType())){

                        }else if ("28".equals(projectNotify.getType())){

                        }else if ("29".equals(projectNotify.getType())){

                        }else if ("32".equals(projectNotify.getType())){

                        }else if ("33".equals(projectNotify.getType())){

                        }else if ("34".equals(projectNotify.getType())){

                        }else if ("35".equals(projectNotify.getType())){

                        }else if ("36".equals(projectNotify.getType())){

                        }else if ("37".equals(projectNotify.getType())){

                        }*/else if ("38".equals(projectNotify.getType())){

                        }//项目登记
                        else if ("39".equals(projectNotify.getType())){
                            map.put("appAudit", 2);
                        }//退票申请
                        else if ("40".equals(projectNotify.getType())){
                            WorkInvoiceReturn workInvoiceReturn = workInvoiceReturnService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workInvoiceReturn.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (act.getTaskDefKey().equals("bmzr") || act.getTaskDefKey().equals("fgld") ) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }//项目变更
                        else if ("41".equals(projectNotify.getType())){
                            map.put("appAudit", 2);
                        }else if ("42".equals(projectNotify.getType())){

                        }//合同作废
                        else if ("43".equals(projectNotify.getType())){
                            map.put("appAudit", 1);
                        }//合同变更
                        else if ("44".equals(projectNotify.getType())){
                            WorkContractInfo workContractInfo =workContractInfoService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workContractInfo.getAlterProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (!act.getTaskDefKey().equals("gzr") && !act.getTaskDefKey().equals("modifyApply")) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }//工作内容报告
                        else if ("45".equals(projectNotify.getType())){
                            ProjectReportData projectReportData = projectReportDataService.get(projectNotify.getNotifyId());
                            Act act = getByAct(projectReportData.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (act.getTaskDefKey().equals("glyda")){
                                    map.put("appAudit", 2);
                                }else if (act.getTaskDefKey().equals("fgzlfz")) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }
                        else if ("46".equals(projectNotify.getType())){
                            ProjectReportData projectReportData = projectReportChangeService.get(projectNotify.getNotifyId());
                            Act act = getByAct(projectReportData.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (act.getTaskDefKey().equals("glyda")){
                                    map.put("appAudit", 2);
                                }else if (act.getTaskDefKey().equals("fgzlfz")) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }else if ("47".equals(projectNotify.getType())){

                        }//发票变更
                        else if ("48".equals(projectNotify.getType())){

                        }else if ("49".equals(projectNotify.getType())){

                        }//投标管理
                        else if ("50".equals(projectNotify.getType())){
                            WorkBidProject workBidProject = workBidProjectService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workBidProject.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (act.getTaskDefKey().equals("fgld") || act.getTaskDefKey().equals("scyfglbzr") || act.getTaskDefKey().equals("zjl") || act.getTaskDefKey().equals("scyfglbzrs")) {
                                    map.put("appAudit", 1);
                                    if (act.getTaskDefKey().equals("scyfglbzr")){
                                        map.put("appShow", 1);
                                    }
                                }else if (act.getTaskDefKey().equals("scyfglbzrss")){
                                    map.put("appAudit", 2);
                                    map.put("appShow", 1);
                                }
                            }
                        }else if ("51".equals(projectNotify.getType())){

                        }//收入结算
                        else if ("52".equals(projectNotify.getType())){
                            WorkReceiptsSettle workReceiptsSettle = workReceiptsSettleService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workReceiptsSettle.getProcessInstanceId());
                            if (act != null && StringUtils.isNotBlank(act.getTaskDefKey())) {
                                if (act.getTaskDefKey().equals("scfgld") || act.getTaskDefKey().equals("cwzg") || act.getTaskDefKey().equals("zjl") || act.getTaskDefKey().equals("cwfgld") ) {
                                    map.put("appAudit", 1);
                                }
                            }
                        }//收入调整
                        else if ("53".equals(projectNotify.getType())){
                            WorkReceiptsRevise workReceiptsRevise = workReceiptsReviseService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workReceiptsRevise.getProcessInstanceId());
                            if (!act.getTaskDefKey().equals("modifyApply")){
                                map.put("appAudit", 1);
                            }
                        }//收入调整作废
                        else if ("54".equals(projectNotify.getType())){

                        }
                        //收文申请
                        else if ("55".equals(projectNotify.getType())){
                            WorkIncomingMessage workIncomingMessage = workIncomingMessageService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workIncomingMessage.getProcessInstanceId());
                            if (act.getTaskDefKey().equals("zjl")){
                                map.put("appAudit", 2);
                            }else if (act.getTaskDefKey().equals("xzzg")){
                                map.put("appAudit", 0);
                            }
                        }
                        //行政盖章
                        else if ("56".equals(projectNotify.getType())){
                            WorkAdministrativeAtamp workAdministrativeAtamp = workAdministrativeAtampService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workAdministrativeAtamp.getProcessInstanceId());
                            if (!act.getTaskDefKey().equals("modifyApply")){
                                if(!act.getTaskDefKey().equals("gzr")) {
                                    map.put("appAudit", 1);
                                }else {
                                    map.put("appAudit", 0);
                                }
                            }
                        }
                        //采购合同
                        else if ("57".equals(projectNotify.getType())){

                        }
                        //日常事务
                        else if ("58".equals(projectNotify.getType())){

                        }
                        //借用申请
                        else if ("59".equals(projectNotify.getType())){

                        }
                        //归还借用
                        else if ("60".equals(projectNotify.getType())){

                        }
                        //采购申请
                        else if ("61".equals(projectNotify.getType())){

                        }
                        //发文申请
                        else if ("62".equals(projectNotify.getType())){
                            WorkSendMessage workSendMessage = workSendMessageService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workSendMessage.getProcessInstanceId());
                            if (!act.getTaskDefKey().equals("modifyApply")){
                                map.put("appAudit", 1);
                            }
                        }
                        //报废申请
                        else if ("63".equals(projectNotify.getType())){

                        }
                        //领用申请
                        else if ("64".equals(projectNotify.getType())){

                        }
                        //领用申请
                        else if ("84".equals(projectNotify.getType())){
                            WorkAttendanceCount workAttendanceCount = workAttendanceCountService.get(workProjectNotify.getNotifyId());
                            map.put("appAudit", 1);
                        }
                        else if ("77".equals(projectNotify.getType())){
                            WorkOvertime workOvertime = workOvertimeService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workOvertime.getProcessInstanceId());
                            if (!act.getTaskDefKey().equals("modifyApply")){
                                map.put("appAudit", 1);
                            }
                        }
                        else if ("78".equals(projectNotify.getType())){
                            WorkOut workOut = workOutService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workOut.getProcessInstanceId());
                            if (!act.getTaskDefKey().equals("modifyApply")){
                                map.put("appAudit", 1);
                            }
                        }
                        else if ("79".equals(projectNotify.getType())){
                            WorkField workField = workFieldService.get(projectNotify.getNotifyId());
                            Act act = getByAct(workField.getProcessInstanceId());
                            if (!act.getTaskDefKey().equals("modifyApply")){
                                map.put("appAudit", 1);
                            }
                        }
                        else if ("80".equals(projectNotify.getType())||"81".equals(projectNotify.getType())||"82".equals(projectNotify.getType())){
                            LeaveApply leaveApply = leaveApplyService.get(projectNotify.getNotifyId());
                            Act act = getByAct(leaveApply.getProcessInstanceId());
                            if (!act.getTaskDefKey().equals("modifyApply")){
                                map.put("appAudit", 1);
                            }
                        }
                        else if ("83".equals(projectNotify.getType())){
                            WorkAttendanceInfo workAttendanceInfo = workAttendanceInfoService.getAudit(projectNotify.getNotifyId());
                            map.put("appAudit", 1);
                        }
                        list1.add(map);
                    }
                    j.put("data",list1);
                }else{
                    j.put("data",new ArrayList<>());
                }
                j.setErrorCode(ErrorCode.code_1004);
                j.setMsg("获取待办任务成功");
                j.put("maxNum",page.getCount());
            }
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取待办任务失败");
            j.put("maxNum", 0);
            j.put("data", "");
            logger.info("---------e:"+e.getMessage());
        }
        return j;
    }

    /**
     * 获取已办任务
     * @param
     * @return
     */
    @RequestMapping(value = "businessHistoric", method = RequestMethod.GET)
    @ResponseBody
    public AjaxJson historicList(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
        HashMap<String, String> requestMap = findRequestMap(request);
        String pageNo  = requestMap.get("pageNo");
        String types  = requestMap.get("types");
        String status  = requestMap.get("status");
        String userName  = URLDecoder.decode(requestMap.get("userName")==null?"":requestMap.get("userName"), "UTF-8");
        String startDate = URLDecoder.decode(requestMap.get("startDate")==null?"":requestMap.get("startDate"), "UTF-8");
        String endDate = URLDecoder.decode(requestMap.get("endDate")==null?"":requestMap.get("endDate"), "UTF-8");
        String title = URLDecoder.decode(requestMap.get("title")==null?"":requestMap.get("title"), "UTF-8");
        String content = URLDecoder.decode(requestMap.get("content")==null?"":requestMap.get("content"), "UTF-8");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        AjaxJson j = new AjaxJson();
        try {
            WorkProjectNotify notify = new WorkProjectNotify();
            User user = UserUtils.getUser();
            notify.setRemarks("待审批");
            if(com.jeeplus.common.utils.StringUtils.isBlank(notify.getStatus())){
                notify.setStatus("-1");
            }
            notify.setUser(user);
            notify.setCompanyId(UserUtils.getSelectCompany().getId());
            if (StringUtils.isNotBlank(types)){
                notify.setTypes(types);
            }
            if (StringUtils.isNotBlank(status)){
                notify.setStatus(status);
            }
            if (StringUtils.isNotBlank(userName)){
                notify.setUserName(userName);
            }
            try {
                if (StringUtils.isNotBlank(startDate)){
                    notify.setStartDate(sdf.parse(startDate));
                }
                if (StringUtils.isNotBlank(endDate)){
                    notify.setEndDate(sdf.parse(endDate));
                }
            }catch (Exception e){
                j.setSuccess(false);
                j.setErrorCode(ErrorCode.code_2002);
                j.setMsg("获取列表失败，时间参数格式不正确");
                return j;
            }

            if (StringUtils.isNotBlank(title)){
                notify.setTitle(title);
            }
            if (StringUtils.isNotBlank(content)){
                notify.setContent(content);
            }
            Page<WorkProjectNotify> page = workProjectNotifyService.findPageByAPP(new Page<WorkProjectNotify>(request, response),notify);
            List<WorkProjectNotify> list = page.getList();
            List list1 = new ArrayList();
            if(list==null){
                j.setSuccess(false);
                j.setErrorCode(ErrorCode.code_2005);
                j.setMsg("获取列表失败");
                j.put("data", list1);
            }else {
                j.put("maxNum", page.getCount());
                if(Integer.parseInt(pageNo)<=page.getTotalPage()) {
                    for (int i=0;i< list.size();i++) {
                        WorkProjectNotify projectNotify = list.get(i);
                        User createBy = UserUtils.get(projectNotify.getCreateBy().getId())==null?new User():UserUtils.get(projectNotify.getCreateBy().getId());
                        Date createDate = projectNotify.getCreateDate() == null ? new Date() : projectNotify.getCreateDate();
                        Map<String, Object> map = new HashMap<>();
                        map.put("title",projectNotify.getTitle());
                        map.put("createDate",sdf.format(createDate));
                        map.put("userId",createBy.getId());
                        map.put("userName",createBy.getName());
                        map.put("userPhoto",createBy.getPhoto());
                        map.put("type",projectNotify.getType());
                        map.put("status",projectNotify.getStatus());
                        map.put("notifyId",projectNotify.getNotifyId());
                        map.put("id",projectNotify.getId());
                        map.put("appAudit", 0);
                        list1.add(map);
                    }
                    j.put("data",list1);
                }else{
                    j.put("data",new ArrayList<>());
                }
                j.setErrorCode(ErrorCode.code_1004);
                j.setMsg("获取待办任务成功");
                j.put("maxNum",page.getCount());
            }
        }catch (Exception e){
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取待办任务失败");
            j.put("maxNum",0);
            j.put("data",new ArrayList());
            logger.info("---------e:"+e.getMessage());
        }
        return j;
    }

    /**
     * 读取待办
     * @param
     * @return
     */
    @Transactional
    @RequestMapping(value = "readBusiness", method=RequestMethod.POST)
    @ResponseBody
    public AjaxJson readBusiness(HttpServletRequest request, HttpServletResponse response) {
        AjaxJson j = new AjaxJson();
        try {
            HashMap<String, String> requestMap = findRequestMap(request);
            String notifyId  = requestMap.get("notifyId");
            WorkProjectNotify workProjectNotify = workProjectNotifyService.get(notifyId);
            if (workProjectNotify.getRemarks().equals("待通知")){
                UserUtils.pushMeIm("");
                /*List<WebSocket> toUserConnList = ChatServerPool.getWebSocketByUser(UserUtils.getUser().getId());
                for (WebSocket toUserConn:toUserConnList) {
                    String message = "{\"useType\":\"sys_me\"}";
                    ChatServerPool.sendMessageToUser(toUserConn, message);//同时向本人发送消息
                }*/
            }
            if ("0".equals(workProjectNotify.getStatus())){
                workProjectNotify.setStatus("2");
                workProjectNotify.preUpdate();
                workProjectNotifyService.save(workProjectNotify);
            }
            j.setErrorCode(ErrorCode.code_1004);
            j.setMsg("读取待办任务成功");
        }catch (Exception e){
            j.setSuccess(false);
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("读取待办任务失败");
            logger.info("---------e:"+e.getMessage());
        }
        return j;
    }
    /**
     * 读取待办
     * @param
     * @return
     */
    @Transactional
    @RequestMapping(value = "findTreeInfo", method=RequestMethod.GET)
    @ResponseBody
    public AjaxJson findTreeInfo(HttpServletRequest request, HttpServletResponse response) {
        AjaxJson j = new AjaxJson();
        try {
            HashMap<String, String> requestMap = findRequestMap(request);
            String treeId  = requestMap.get("treeId");
            Projectcontentinfo projectcontentinfo = projectcontentinfoService.getChange(treeId);
            if (projectcontentinfo!=null && StringUtils.isNotBlank(projectcontentinfo.getId())){
                WorkReviewAudit workReviewAudit = new WorkReviewAudit();
                workReviewAudit.setCompanyId(UserUtils.getSelectCompany().getId());
                workReviewAudit.setType(projectcontentinfo.getDictType());
                workReviewAudit.setReportId(projectcontentinfo.getInfoId());
                List<WorkReviewAudit> workReviewAudits = workReviewStandardService.findAuditList(workReviewAudit);
                j.put("data",workReviewAudits);
            }else {
                j.put("data",new ArrayList<>());
            }
            j.setErrorCode(ErrorCode.code_1004);
            j.setMsg("读取报告复核详情成功");
        }catch (Exception e){
            j.setSuccess(false);
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("读取报告复核详情失败");
            logger.info("---------e:"+e.getMessage());
        }
        return j;
    }

    /**
     * 读取待办
     * @param
     * @return
     */
    @Transactional
    @RequestMapping(value = "findBusiness", method=RequestMethod.GET)
    @ResponseBody
    public AjaxJson findBusiness(HttpServletRequest request, HttpServletResponse response) {
        AjaxJson j = new AjaxJson();
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            HashMap<String, String> requestMap = findRequestMap(request);
            String id  = requestMap.get("id");
            String appAudit = requestMap.get("appAudit");
            if (StringUtils.isBlank(appAudit) || StringUtils.isBlank(id)){
                j.setSuccess(false);
                j.setErrorCode(ErrorCode.code_2001);
                j.setMsg("读取待办详情失败");
            }
            WorkProjectNotify workProjectNotify = workProjectNotifyService.get(id);
            if (workProjectNotify.getRemarks().equals("待通知")){
                /*List<WebSocket> toUserConnList = ChatServerPool.getWebSocketByUser(UserUtils.getUser().getId());
                for (WebSocket toUserConn:toUserConnList) {
                    String message = "{\"useType\":\"sys_me\"}";
                    ChatServerPool.sendMessageToUser(toUserConn, message);//同时向本人发送消息
                }*/
                UserUtils.pushMeIm("");
            }
            if ("0".equals(workProjectNotify.getStatus())){
                workProjectNotify.setStatus("2");
                workProjectNotify.preUpdate();
                workProjectNotifyService.save(workProjectNotify);
            }
            Map<String,Object> map = new HashMap<>();
            String notifyId = workProjectNotify.getNotifyId();
            String type = workProjectNotify.getType();
            //报销
            if ("13".equals(workProjectNotify.getType())){
                WorkReimbursement workReimbursement = workReimbursementService.get(notifyId);
                map.put("notifyId",workReimbursement.getId());
                //是否项目报销
                map.put("ext","0".equals(workReimbursement.getExt())?"项目报销":"非项目报销");
                //报销申请编号
                map.put("number",workReimbursement.getNumber());
                //报销项目
                map.put("projectName",workReimbursement.getProject().getProjectName());
                //项目负责人
                map.put("masterName",workReimbursement.getProjectMasterName());
                //报销人
                map.put("submitterName",workReimbursement.getSubmitterName());
                //所属部门
                map.put("officeName",workReimbursement.getOfficeName());
                //报销日期
                map.put("submitterDate",workReimbursement.getSubmitterDate()==null?"":sdf.format(workReimbursement.getSubmitterDate()));
                //银行卡号
                map.put("bankCard",workReimbursement.getBankCard());
                //报销费用摘要
                map.put("workAccountList",workReimbursement.getWorkAccountList());
                //报销费用合计（元）
                map.put("money",workReimbursement.getMoney());
            }//合同申请
            else if ("16".equals(type)){
                WorkContractInfo workContractInfo =workContractInfoService.get(notifyId);
                //合同来源
                map.put("ext","1".equals(workContractInfo.getExt())?"非投标项目":"投标项目");
                //合同编号
                map.put("contractNum",workContractInfo.getContractNum());
                //投标名称
                map.put("projectName",workContractInfo.getProject()==null?"":workContractInfo.getProject().getProjectName());
                //投标编号
                map.put("projectNum",workContractInfo.getProject()==null?"":workContractInfo.getProject().getProjectNumber());
                //合同名称
                map.put("contractName",workContractInfo.getName());
                //总合同名称
                WorkContractInfo totalContract =StringUtils.isBlank(workContractInfo.getTotalContractId())?null:workContractInfoService.get(workContractInfo.getTotalContractId());
                map.put("totalContractName",totalContract==null?"":totalContract.getName());
                //部门名称
                map.put("officeName",StringUtils.isBlank(workContractInfo.getOfficeId())?"":officeService.get(workContractInfo.getOfficeId())==null?"":officeService.get(workContractInfo.getOfficeId()).getName());
                //合同金额（元）
                map.put("contractPrice",workContractInfo.getContractPrice());
                //签订日期
                map.put("contractDate",workContractInfo.getContractDate()==null?"":sdf.format(workContractInfo.getContractDate()));
                //主委托方
                map.put("clientName",workContractInfo.getClient()==null?"":workContractInfo.getClient().getName());
                //合同终止日期
                map.put("effectiveDate",workContractInfo.getEffectiveDate()==null?"":sdf.format(workContractInfo.getEffectiveDate()));
                //合同生效日期
                map.put("closingDate",workContractInfo.getClosingDate()==null?"":sdf.format(workContractInfo.getClosingDate()));
                //投资额（万元）
                map.put("investmentAmount",workContractInfo.getInvestmentAmount());
                //对方合同编号
                map.put("contractOpposite",workContractInfo.getAnotherContractNum());
                //工程分类
                map.put("contractType", DictUtils.getMainDictLabel(workContractInfo.getContractType(),"contract_type",""));
                //归档状态
                map.put("recordState", StringUtils.isBlank(workContractInfo.getRecordState())?"未归档":DictUtils.getDictLabel(workContractInfo.getRecordState(),"record_state",""));
                //付款摘要
                map.put("summaryPayment",workContractInfo.getSummaryPayment());
                //合同特别条款
                map.put("contractSpecial",workContractInfo.getContractSpecial());
                //合同类型说明
                map.put("contractTypeDoc",workContractInfo.getContractTypeDoc());
                //备注信息
                map.put("remarks",workContractInfo.getRemarks());
                //委托方列表
                map.put("workClientInfoList",workContractInfo.getWorkClientInfoList());
                //附件列表
                map.put("workAttachments",workContractInfo.getWorkAttachments());
                map.put("notifyId",workContractInfo.getId());
            }//发票管理
            else if ("21".equals(type)){
                WorkInvoice workInvoice = workInvoiceService.get(notifyId);
                //项目编号
                map.put("projectNum",workInvoice.getProject()==null?"":workInvoice.getProject().getProjectId());
                //发票申请编号
                map.put("invoiceNum",workInvoice.getNumber());
                //项目名称
                map.put("projectName",workInvoice.getProject()==null?"":workInvoice.getProject().getProjectName());
                //合同名称
                map.put("contractName",workInvoice.getProject().getWorkContractInfo().getName());
                //主委托方
                map.put("contractClientName",workInvoice.getProject().getWorkContractInfo().getClient().getName());
                //所属部门
                map.put("officeName",workInvoice.getOffice().getName());
                try{
                    //创建人
                    map.put("createBy",UserUtils.get(workInvoice.getCreateBy().getId()).getName());
                }catch (Exception e){
                    map.put("createBy","");
                }

                //创建日期
                map.put("createDate",workInvoice.getCreateDate()==null?"":sdf.format(workInvoice.getCreateDate()));
                //总/分公司开票
                map.put("ext","0".equals(workInvoice.getExt())?"分公司开票":"总公司开票");
                //发票类型
                map.put("invoiceType","1".equals(workInvoice.getInvoiceType())?"专票":"普票");
                //实际开票单位
                map.put("clientName",workInvoice.getClient().getName());
                //实际开票单位
                map.put("orUnicode",workInvoice.getOrUnicode());
                //地址
                map.put("address",workInvoice.getAddress());
                //电话
                map.put("telephone",workInvoice.getTelephone());
                //开户银行
                map.put("bank",workInvoice.getBank());
                //银行账号
                map.put("bankNumber",workInvoice.getBankNumber());
                //价税合计
                map.put("money",workInvoice.getMoney());
                //开票内容要求
                map.put("content",workInvoice.getContent());
                //开票人
                map.put("drawerName",StringUtils.isBlank(workInvoice.getDrawerName())||"null".equals(workInvoice.getDrawerName())?"":workInvoice.getDrawerName());
                //开票时间
                map.put("invoiceDate",workInvoice.getInvoiceDate()==null?"":sdf.format(workInvoice.getInvoiceDate()));
                //领票日期
                map.put("takeDate",workInvoice.getTakeDate()==null?"":sdf.format(workInvoice.getTakeDate()));
                map.put("notifyId",workInvoice.getId());
            }/*else if ("24".equals(type)){

            }else if ("25".equals(type)){

            }else if ("26".equals(type)){

            }else if ("27".equals(type)){

            }else if ("28".equals(type)){

            }else if ("29".equals(type)){

            }else if ("32".equals(type)){

            }else if ("33".equals(type)){

            }else if ("34".equals(type)){

            }else if ("35".equals(type)){

            }else if ("36".equals(type)){

            }else if ("37".equals(type)){

            }*/else if ("38".equals(type)){

            }//项目登记
            else if ("39".equals(type)){
                ProjectRecords projectRecords = projectRecordsService.get(notifyId);
                projectRecordsService.queryProjectDetail(projectRecords);
                //合同编号
                map.put("contractNum",projectRecords.getContractNumber());
                //项目编号
                map.put("projectNum",projectRecords.getProjectId());
                //合同名称
                map.put("contractName",projectRecords.getContractName());
                //合同金额
                map.put("contractPrice",projectRecords.getContractPrice());
                //主委托方
                map.put("clientName",projectRecords.getClientName());
                //工程分类
                map.put("contractType",projectRecords.getContractType());
                //项目名称
                map.put("projectName",projectRecords.getProjectName());
                //规模类型
                map.put("scaleType",projectRecords.getScaleType());
                //规模单位
                map.put("scaleUnit",projectRecords.getScaleUnit());
                //规模数量
                map.put("scaleQuantity",projectRecords.getScaleQuantity());
                //项目所在地
                map.put("area",projectRecords.getArea().getName());
                //建设地点
                map.put("projectSite",projectRecords.getProjectSite());
                //创建人
                User createBy = projectRecords.getCreateBy()==null||StringUtils.isBlank(projectRecords.getCreateBy().getId())?null:UserUtils.get(projectRecords.getCreateBy().getId());
                map.put("createBy",createBy==null?"":createBy.getName());
                //创建日期
                map.put("createDate",projectRecords.getCreateDate()==null?"":sdf.format(projectRecords.getCreateDate()));
                //委托方联系人信息
                map.put("workClientLinkmanList",projectRecords.getWorkClientLinkmanList());
                //施工方联系人信息
                map.put("workConstructionLinkmanList",projectRecords.getWorkConstructionLinkmanList());
                //特殊要求
                map.put("remarks",projectRecords.getRemarks());
                //工程概况
                map.put("projectDesc",projectRecords.getProjectDesc());
                //项目负责人
                map.put("leaderNameStr",projectRecords.getProjectLeaders());
                //附件信息
                map.put("workAttachments",projectRecords.getWorkAttachments());
                map.put("notifyId",projectRecords.getId());
            }//退票申请
            else if ("40".equals(type)){
                WorkInvoiceReturn workInvoiceReturn = workInvoiceReturnService.get(notifyId);
                    //被退票号
                try {
                    map.put("invoiceDetail",workInvoiceReturn.getInvoiceDetail().getNumber());
                }catch (Exception e){
                    map.put("invoiceDetail","");
                }
                //退票申请编号
                map.put("returnNumber",workInvoiceReturn.getReturnNumber());
                //项目名称
                try {
                    map.put("projectName",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getProject().getProjectName());
                }catch (Exception e){
                    map.put("projectName","");
                }
                //项目编号
                try {
                    map.put("projectNum",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getProject().getProjectId());
                }catch (Exception e){
                    map.put("projectNum","");
                }
                //合同名称
                try {
                    map.put("contractName",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getProject().getWorkContractInfo().getName());
                }catch (Exception e){
                    map.put("contractName","");
                }
                //所属部门
                try {
                    map.put("officeName",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getOffice().getName());
                }catch (Exception e){
                    map.put("officeName","");
                }
                //委托方
                try {
                    map.put("contractClientName",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getProject().getWorkContractInfo().getClient().getName());
                }catch (Exception e){
                    map.put("contractClientName","");
                }
                //项目负责人
                try {
                    map.put("masterName",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getProject().getLeaderNameStr());
                }catch (Exception e){
                    map.put("masterName","");
                }
                //发票类型
                try {
                    map.put("invoiceType","1".equals(workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getInvoiceType())?"专票":"普票");
                }catch (Exception e){
                    map.put("invoiceType","");
                }
                //实际开票单位
                try {
                    map.put("clientName",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getClient().getName());
                }catch (Exception e){
                    map.put("clientName","");
                }
                //纳税人识别号
                try {
                    map.put("uscCode",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getClient().getUscCode());
                }catch (Exception e){
                    map.put("uscCode","");
                }
                //地址
                try {
                    map.put("address",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getClient().getAddress());
                }catch (Exception e){
                    map.put("address","");
                }
                //电话
                try {
                    map.put("telephone",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getClient().getTelephone());
                }catch (Exception e){
                    map.put("telephone","");
                }
                //开户银行
                try {
                    map.put("bank",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getBank());
                }catch (Exception e){
                    map.put("bank","");
                }
                //银行账号
                try {
                    map.put("bankNumber",workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getBankNumber());
                }catch (Exception e){
                    map.put("bankNumber","");
                }
                //开票时间
                try {
                    map.put("invoiceDate",sdf.format(workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getInvoiceDate()));
                }catch (Exception e){
                    map.put("invoiceDate","");
                }
                //价税合计
                map.put("totalMoney",workInvoiceReturn.getInvoiceDetail().getTotalMoney());
                //税率
                map.put("tax",workInvoiceReturn.getInvoiceDetail().getTax());
                //金额
                map.put("taxMoney",workInvoiceReturn.getInvoiceDetail().getTaxMoney());
                //税额
                map.put("taxRate",workInvoiceReturn.getInvoiceDetail().getTaxRate());
                //创建人
                try {
                    map.put("createBy",UserUtils.get(workInvoiceReturn.getCreateBy().getId()).getName());
                }catch (Exception e){
                    map.put("createBy","");
                }
                //创建日期
                map.put("createDate",workInvoiceReturn.getCreateDate()==null?"":sdf.format(workInvoiceReturn.getCreateDate()));
                //退票原因
                map.put("reason",workInvoiceReturn.getReason());
                String cancleReturn = "";
                if(StringUtils.isNotBlank(workInvoiceReturn.getCancleReturn())) {
                    if ("1".equals(workInvoiceReturn.getCancleReturn())) {
                        cancleReturn = "退票";
                    } else if ("2".equals(workInvoiceReturn.getCancleReturn())) {
                        cancleReturn = "作废";
                    }
                }
                String returnType = "";
                if(StringUtils.isNotBlank(workInvoiceReturn.getReturnType())) {
                    if ("1".equals(workInvoiceReturn.getReturnType())) {
                        returnType = "是";
                    } else if ("2".equals(workInvoiceReturn.getReturnType())) {
                        returnType = "否";
                    }
                }
                //作废/退票
                map.put("cancleReturn",cancleReturn);
                //原票是否退回
                map.put("returnType",returnType);
                //发票代码
                map.put("code",workInvoiceReturn.getCode());
                //发票号
                map.put("number",workInvoiceReturn.getNumber());
                //退票人
                map.put("uname",workInvoiceReturn.getUname());
                //退票日期
                map.put("returnDate",workInvoiceReturn.getReturnDate()==null?"":sdf.format(workInvoiceReturn.getReturnDate()));
                map.put("notifyId",workInvoiceReturn.getId());
            }//项目变更
            else if ("41".equals(type)){
                ProjectRecordsAlter projectRecordsAlter = projectRecordsAlterService.get(notifyId);
                ProjectRecords projectRecords = new ProjectRecords();
                projectRecordsAlterService.queryProjectAlterDetail(projectRecordsAlter);
                if (projectRecordsAlter.getAlterBeforeRecords()!=null&& com.jeeplus.common.utils.StringUtils.isNotBlank(projectRecordsAlter.getAlterBeforeRecords().getId())){
                    projectRecords = projectRecordsService.get(projectRecordsAlter.getAlterBeforeRecords().getId());
                    //设置详细信息
                    projectRecordsService.queryProjectDetail(projectRecords);
                }
                projectRecordsAlter.setAlterBeforeRecords(projectRecords);
                //合同编号
                map.put("contractNum",projectRecordsAlter.getContractNumber());
                //项目编号
                map.put("projectNum",projectRecordsAlter.getProjectId());
                //合同名称
                map.put("contractName",projectRecordsAlter.getContractName());
                //合同金额
                map.put("contractPrice",projectRecordsAlter.getContractPrice());
                //主委托方
                map.put("clientName",projectRecordsAlter.getClientName());
                //工程分类
                map.put("contractType",projectRecordsAlter.getContractType());
                //项目名称
                map.put("projectName",projectRecordsAlter.getProjectName());
                //规模类型
                map.put("scaleType",projectRecordsAlter.getScaleType());
                //规模单位
                map.put("scaleUnit",projectRecordsAlter.getScaleUnit());
                //规模数量
                map.put("scaleQuantity",projectRecordsAlter.getScaleQuantity());
                //项目所在地
                map.put("area",projectRecordsAlter.getArea().getName());
                //建设地点
                map.put("projectSite",projectRecordsAlter.getProjectSite());
                //创建人
                User createBy = projectRecordsAlter.getCreateBy()==null||StringUtils.isBlank(projectRecordsAlter.getCreateBy().getId())?null:UserUtils.get(projectRecordsAlter.getCreateBy().getId());
                map.put("createBy",createBy==null?"":createBy.getName());
                //创建日期
                map.put("createDate",projectRecordsAlter.getCreateDate()==null?"":sdf.format(projectRecordsAlter.getCreateDate()));
                //委托方联系人信息
                map.put("workClientLinkmanList",projectRecordsAlter.getWorkClientLinkmanList());
                //施工方联系人信息
                map.put("workConstructionLinkmanList",projectRecordsAlter.getWorkConstructionLinkmanList());
                //特殊要求
                map.put("remarks",projectRecordsAlter.getRemarks());
                //工程概况
                map.put("projectDesc",projectRecordsAlter.getProjectDesc());
                //项目负责人
                map.put("leaderNameStr",projectRecordsAlter.getProjectLeaders());
                List<WorkClientAttachment> list = new ArrayList<>();
                if (projectRecordsAlter.getAlterBeforeRecords().getWorkAttachments()!=null && projectRecordsAlter.getAlterBeforeRecords().getWorkAttachments().size()!=0){
                    list.addAll(projectRecordsAlter.getAlterBeforeRecords().getWorkAttachments());
                }
                if (projectRecordsAlter.getWorkAttachments()!=null && projectRecordsAlter.getWorkAttachments().size()!=0) {
                    list.addAll(projectRecordsAlter.getWorkAttachments());
                }
                //附件信息
                map.put("workAttachments",list);
                //变更原因
                map.put("alterReason",projectRecordsAlter.getAlterReason());
                map.put("notifyId",projectRecordsAlter.getId());
            }else if ("42".equals(type)){

            }//合同作废
            //合同变更
            else if ("44".equals(type) || "43".equals(type)){
                WorkContractInfo workContractInfo =workContractInfoService.get(notifyId);
                //合同来源
                map.put("ext","1".equals(workContractInfo.getExt())?"非投标项目":"投标项目");
                //变更编号
                map.put("contractNum",workContractInfo.getContractNum());
                //投标名称
                map.put("projectName","1".equals(workContractInfo.getExt())?"":workContractInfo.getProject().getProjectName());
                //投标编号
                map.put("projectNum","1".equals(workContractInfo.getExt())?"":workContractInfo.getProject().getProjectNumber());
                //合同名称
                map.put("contractName",workContractInfo.getName());
                //总合同名称
                WorkContractInfo totalContract =StringUtils.isBlank(workContractInfo.getTotalContractId())?null:workContractInfoService.get(workContractInfo.getTotalContractId());
                map.put("totalContractName",totalContract==null?"":totalContract.getName());
                //部门名称
                map.put("officeName",StringUtils.isBlank(workContractInfo.getOfficeId())?"":officeService.get(workContractInfo.getOfficeId())==null?"":officeService.get(workContractInfo.getOfficeId()).getName());
                //合同金额（元）
                map.put("contractPrice",workContractInfo.getContractPrice());
                //签订日期
                map.put("contractDate",workContractInfo.getContractDate()==null?"":sdf.format(workContractInfo.getContractDate()));
                //主委托方
                map.put("clientName",workContractInfo.getClient()==null?"":workContractInfo.getClient().getName());
                //合同生效日期
                map.put("effectiveDate",workContractInfo.getEffectiveDate()==null?"":sdf.format(workContractInfo.getEffectiveDate()));
                //合同生效日期
                map.put("closingDate",workContractInfo.getClosingDate()==null?"":sdf.format(workContractInfo.getClosingDate()));
                //投资额（万元）
                map.put("investmentAmount",workContractInfo.getInvestmentAmount());
                //对方合同编号
                map.put("contractOpposite",workContractInfo.getAnotherContractNum());
                //工程分类
                map.put("contractType", DictUtils.getMainDictLabel(workContractInfo.getContractType(),"contract_type",""));
                //归档状态
                map.put("recordState", DictUtils.getDictLabel(workContractInfo.getRecordState(),"record_state",""));
                //付款摘要
                map.put("summaryPayment",workContractInfo.getSummaryPayment());
                //合同特别条款
                map.put("contractSpecial",workContractInfo.getContractSpecial());
                //合同类型说明
                map.put("contractTypeDoc",workContractInfo.getContractTypeDoc());
                //备注信息
                map.put("remarks",workContractInfo.getRemarks());
                if ("44".equals(type)){
                    //变更原因
                    map.put("contractCategory",workContractInfo.getContractCategory());
                    //变更人
                    User alterBy = workContractInfo.getCreateBy()!=null?UserUtils.get(workContractInfo.getCreateBy().getId()):null;
                    map.put("alterBy",alterBy==null?"":alterBy.getName());
                    //变更日期
                    map.put("alterDate",workContractInfo.getUpdateDate()==null?"":sdf.format(workContractInfo.getUpdateDate()));
                    //附件列表
                    map.put("workAttachments",workContractInfo.getWorkAttachmentAlters()==null?workContractInfo.getWorkAttachments():workContractInfo.getWorkAttachmentAlters());
                }else if ("43".equals(type)){
                    AlterInfo alterInfo = workContractInfo.getAlterInfo();
                    if (alterInfo!=null){
                        //作废原因
                        map.put("contractCategory",alterInfo.getReason());
                        //作废人
                        User alterBy = alterInfo.getCreateBy()!=null?UserUtils.get(alterInfo.getCreateBy().getId()):null;
                        map.put("alterBy",alterBy==null?"":alterBy.getName());
                        //作废日期
                        map.put("alterDate",alterInfo.getUpdateDate()==null?"":sdf.format(alterInfo.getUpdateDate()));
                    }else {
                        //作废原因
                        map.put("contractCategory","");
                        //作废人
                        map.put("alterBy","");
                        //作废日期
                        map.put("alterDate","");
                    }
                    //附件列表
                    map.put("workAttachments",workContractInfo.getWorkAttachments());
                }

                //委托方列表
                map.put("workClientInfoList",workContractInfo.getWorkClientInfoList());
                map.put("notifyId",workContractInfo.getId());
            }//工作内容报告
            else if ("45".equals(type)){
                ProjectReportData projectReportData = projectReportDataService.get(notifyId);
                //报告名称
                map.put("reportName",projectReportData.getName());
                //报告编号
                map.put("reportNumber",projectReportData.getNumber());
                //工作内容类型
                map.put("type", WorkContentTypeController.getContentTypeName(projectReportData.getType(),""));
                //成果类型
                map.put("achievementType",DictUtils.getMainDictLabel(projectReportData.getAchievementType(),"achievement_type",""));
                //复核标准
                map.put("reviewStandard",DictUtils.getDictLabel(projectReportData.getReviewStandard(),"reviewStandard",""));
                //报告日期
                map.put("reportDate",projectReportData.getReportDate()==null?"":sdf.format(projectReportData.getReportDate()));
               /* //签字造价师1
                map.put("signCostOneName",projectReportData.getSignCostOneName());
                //签字造价师2
                map.put("signCostTwoName",projectReportData.getSignCostTwoName());*/
                //负责人
                map.put("masterName",projectReportData.getMasterName());
                //归档状态
                map.put("recordState",DictUtils.getDictLabel(projectReportData.getFileStatus(),"record_state",""));
                //报告文件
                map.put("workAttachments",projectReportData.getWorkAttachments());
                Projectcontentinfo projectcontentinfo = new Projectcontentinfo();
                projectcontentinfo.setInfoId(projectReportData.getId());
                projectcontentinfo.setType("2");
                projectcontentinfo.setProject(projectReportData.getProject());
                List<Projectcontentinfo> list = projectcontentinfoService.findListByReport(projectcontentinfo);
                List<Projectcontentinfo> trees = new ArrayList<>();
                for (Projectcontentinfo projectcontentinfo1:list){
                    if (!"复核底稿".equals(projectcontentinfo1.getName())){
                        trees.add(projectcontentinfo1);
                    }
                }
                map.put("notifyId",projectReportData.getId());
                //报告文件
                map.put("trees",trees);
            }
            else if ("46".equals(type)){
                ProjectReportData projectReportData = projectReportChangeService.get(notifyId);
                //报告名称
                map.put("reportName",projectReportData.getName());
                //报告编号
                map.put("reportNumber",projectReportData.getNumber());
                //工作内容类型
                map.put("type", WorkContentTypeController.getContentTypeName(projectReportData.getType(),""));
                //变更编号
                map.put("changeNumber",projectReportData.getNumber());
                //成果类型
                map.put("achievementType",DictUtils.getMainDictLabel(projectReportData.getAchievementType(),"achievement_type",""));
                //复核标准
                map.put("reviewStandard",DictUtils.getDictLabel(projectReportData.getReviewStandard(),"reviewStandard",""));
                //报告日期
                map.put("reportDate",projectReportData.getReportDate()==null?"":sdf.format(projectReportData.getReportDate()));
               /* //签字造价师1
                map.put("signCostOneName",projectReportData.getSignCostOneName());
                //签字造价师2
                map.put("signCostTwoName",projectReportData.getSignCostTwoName());*/
                //负责人
                map.put("masterName",projectReportData.getMasterName());
                //归档状态
                map.put("recordState",DictUtils.getDictLabel(projectReportData.getFileStatus(),"record_state",""));
                //报告文件
                map.put("workAttachments",projectReportData.getWorkAttachments());
                //作废原因
                map.put("contractCategory",projectReportData.getRemarks());
                //作废人
                User alterBy = projectReportData.getCreateBy()!=null?UserUtils.get(projectReportData.getCreateBy().getId()):null;
                map.put("alterBy",alterBy==null?"":alterBy.getName());
                //作废日期
                map.put("alterDate",projectReportData.getUpdateDate()==null?"":sdf.format(projectReportData.getUpdateDate()));
                Projectcontentinfo projectcontentinfo = new Projectcontentinfo();
                projectcontentinfo.setInfoId(projectReportData.getId());
                projectcontentinfo.setType("2");
                projectcontentinfo.setProject(projectReportData.getProject());
                List<Projectcontentinfo> list = projectcontentinfoService.findListByReport(projectcontentinfo);
                map.put("notifyId",projectReportData.getId());
                List<Projectcontentinfo> trees = new ArrayList<>();
                for (Projectcontentinfo projectcontentinfo1:list){
                    if (!"复核底稿".equals(projectcontentinfo1.getName())){
                        trees.add(projectcontentinfo1);
                    }
                }
                //报告文件
                map.put("trees",trees);
            }else if ("47".equals(type)){

            }//发票变更
            else if ("48".equals(type)){

            }else if ("49".equals(type)){

            }//投标管理
            else if ("50".equals(type)){
                WorkBidProject workBidProject = workBidProjectService.get(notifyId);
                map.put("projectName",workBidProject.getProjectName());
                map.put("projectNumber",workBidProject.getProjectNumber());
                map.put("projectType", DictUtils.getMainDictLabel(workBidProject.getProjectType(),"contract_type",""));
                map.put("typeExplain",workBidProject.getTypeExplain());
                map.put("projectSource",DictUtils.getMainDictLabel(workBidProject.getProjectSource(),"bidProjectSource",""));
                map.put("sourceExplain",workBidProject.getSourceExplain());
                map.put("projectScale",workBidProject.getProjectScale());
                map.put("scaleType",DictUtils.getMainDictLabel(workBidProject.getScaleType(),"scale_type",""));
                map.put("scaleUnit",DictUtils.getMainDictLabel(workBidProject.getScaleUnit(),"scale_unit",""));
                map.put("investMoney",workBidProject.getInvestMoney());
                if("1".equals(workBidProject.getIsExt())){
                    map.put("bidCompany",workBidProject.getExtCompany());
                }else{
                    map.put("bidCompany",workBidProject.getBidCompany().getName());
                }
                map.put("bidNumber",workBidProject.getBidNumber());
                map.put("workClientLinkmanList",workBidProject.getWorkClientLinkmanList());
                map.put("workClientLinkmanLists",workBidProject.getWorkClientLinkmanLists());
                map.put("registrationDate",workBidProject.getRegistrationDate()==null?"":sdf.format(workBidProject.getRegistrationDate()));
                map.put("bidDate",workBidProject.getBidDate()==null?"":sdf.format(workBidProject.getBidDate()));
                map.put("trialDate",workBidProject.getTrialDate()==null?"":sdf.format(workBidProject.getTrialDate()));
                map.put("trialType",DictUtils.getDictLabel(workBidProject.getTrialType(),"trial_type",""));
                map.put("documentCost",workBidProject.getDocumentCost());
                map.put("bidBond",workBidProject.getBidBond());
                map.put("bondStyle",DictUtils.getMainDictLabel(workBidProject.getBondStyle(),"bond_style",""));
                map.put("giveDate",workBidProject.getGiveDate()==null?"":sdf.format(workBidProject.getGiveDate()));
                map.put("refundDate",workBidProject.getRefundDate()==null?"":sdf.format(workBidProject.getRefundDate()));
                map.put("officeName",workBidProject.getOffice().getName());
                map.put("isBid",DictUtils.getDictLabel(workBidProject.getIsBid(),"is_bid",""));
                map.put("businessType",DictUtils.getMainDictLabel(workBidProject.getBusinessType(),"business_type",""));
                map.put("subcontractCompany",workBidProject.getSubcontractCompany());
                map.put("projectSituation",workBidProject.getProjectSituation());
                map.put("serviceContent",workBidProject.getServiceContent());
                map.put("remarks",workBidProject.getRemarks());
                map.put("isSubcontract",DictUtils.getDictLabel(workBidProject.getIsSubcontract(),"is_subcontract",""));
                map.put("workAttachments",workBidProject.getWorkAttachments());
                map.put("workAttachmentsprice",workBidProject.getWorkAttachmentsprice());
                map.put("workAttachmentsbid",workBidProject.getWorkAttachmentsbid());
                map.put("workAttachmentsopenbid",workBidProject.getWorkAttachmentsopenbid());
                map.put("notifyId",workBidProject.getId());
            }else if ("51".equals(type)){

            }//收入结算
            else if ("52".equals(type)){
                WorkReceiptsSettle workReceiptsSettle = workReceiptsSettleService.get(notifyId);
                map.put("notifyId",workReceiptsSettle.getId());
                //结算部门
                map.put("officeName",workReceiptsSettle.getOffice().getName());
                //结算单号
                map.put("num",workReceiptsSettle.getNum());
                //结算人
                map.put("createBy",workReceiptsSettle.getCreateBy().getName());
                //结算日期
                map.put("createDate",workReceiptsSettle.getCreateDate()==null?"":sdf.format(workReceiptsSettle.getCreateDate()));
                //备注
                map.put("remarks",workReceiptsSettle.getRemarks());
                List<WorkReceiptsSettleDetail> settleDetailList = workReceiptsSettle.getSettleDetailList();
                BigDecimal total = new BigDecimal("0.00");
                if (settleDetailList!=null && settleDetailList.size()!=0){
                    for (WorkReceiptsSettleDetail receiptsSettleDetail:settleDetailList){
                        try {
                            if (receiptsSettleDetail.getInvoice()!=null && StringUtils.isNotBlank(receiptsSettleDetail.getInvoice().getTotalMoney())){
                                total = total.add(new BigDecimal(receiptsSettleDetail.getInvoice().getTotalMoney()));
                            }
                        }catch (Exception e){
                            logger.info("Exception e:"+e);
                        }

                    }
                }
                //价税合计总额
                map.put("totalMoney",total);
            }//收入调整
            else if ("53".equals(type)){
                WorkReceiptsRevise workReceiptsRevise = workReceiptsReviseService.get(notifyId);
                map.put("notifyId",workReceiptsRevise.getId());
                //调整部门
                map.put("officeName",workReceiptsRevise.getOfficeName());
                //调整编号
                map.put("officeNum",workReceiptsRevise.getOfficeNum());
                //调整日期
                map.put("reviseDate",workReceiptsRevise.getReviseDate()==null?"":sdf.format(workReceiptsRevise.getReviseDate()));
                //调整人
                map.put("userName",workReceiptsRevise.getUserName());
                //调整类型
                map.put("reviseType",DictUtils.getDictLabel(workReceiptsRevise.getReviseType(),"revise_type",""));
                //调出合同
                try {
                    map.put("contractName",workReceiptsRevise.getWorkContractInfo().getName());
                }catch (Exception e){
                    map.put("contractName","");
                }
                //调入部门
                try{
                    map.put("inreviseOfficeName",workReceiptsRevise.getInreviseOffice().getName());
                }catch (Exception e){
                    map.put("inreviseOfficeName","");
                }
                //调整金额
                map.put("reviseMoney",workReceiptsRevise.getReviseMoney());
                //备注
                map.put("remarks",workReceiptsRevise.getRemarks());
            }//收入调整作废
            else if ("54".equals(type)){

            }//收文申请
            else if ("55".equals(type)){
                WorkIncomingMessage workIncomingMessage = workIncomingMessageService.get(notifyId);
                map.put("notifyId",workIncomingMessage.getId());
                //来文标题
                map.put("title",workIncomingMessage.getTitle());
                //收文编号
                map.put("num",workIncomingMessage.getNum());
                //来文字号
                map.put("wordSize",workIncomingMessage.getWordSize());
                //来文日期
                map.put("incomeDate",workIncomingMessage.getIncomeDate()==null?"":sdf.format(workIncomingMessage.getIncomeDate()));
                //来文单位
                map.put("incomePart",workIncomingMessage.getIncomePart());
                //份数
                map.put("counts",workIncomingMessage.getCounts());
                //拟办意见
                map.put("remarks",workIncomingMessage.getRemarks());
                //领导批示
                map.put("opinion",workIncomingMessage.getOpinion());
                //处理人
                map.put("users",workIncomingMessage.getHandlerList());
                //附件
                map.put("workAttachments",workIncomingMessage.getWorkAttachments());
            }
            //行政盖章
            else if ("56".equals(type)){
                WorkAdministrativeAtamp workAdministrativeAtamp = workAdministrativeAtampService.get(notifyId);
                map.put("notifyId",workAdministrativeAtamp.getId());
                //文档类型
                map.put("docType",DictUtils.getMainDictLabel(workAdministrativeAtamp.getDocType(),"doc_type",""));
                //申请编号
                map.put("num",workAdministrativeAtamp.getNum());
                //签章公司
                map.put("comSign",workAdministrativeAtamp.getComSign().getName());
                //申请人
                map.put("submiter",workAdministrativeAtamp.getSubmiter().getName());
                //申请日期
                map.put("submitDate",workAdministrativeAtamp.getSubmitDate()==null?"":sdf.format(workAdministrativeAtamp.getSubmitDate()));
                //印章类型
                map.put("sealType",DictUtils.getMainDictLabel(workAdministrativeAtamp.getSealType(),"seal_type",""));
                //说明
                map.put("remarks",workAdministrativeAtamp.getRemarks());
                //附件类型
                map.put("workAttachments",workAdministrativeAtamp.getWorkAttachments());
            }
            //采购合同
            else if ("57".equals(type)){

            }
            //日常事务
            else if ("58".equals(type)){

            }
            //借用申请
            else if ("59".equals(type)){

            }
            //归还借用
            else if ("60".equals(type)){

            }
            //采购申请
            else if ("61".equals(type)){

            }
            //发文申请
            else if ("62".equals(type)){
                WorkSendMessage workSendMessage = workSendMessageService.get(notifyId);
                workSendMessageService.queryDetails(workSendMessage);
                map.put("notifyId",workSendMessage.getId());
                //发文标题
                map.put("title",workSendMessage.getTitle());
                //发文文号
                map.put("num",workSendMessage.getNum());
                //发文类型
                map.put("docType",DictUtils.getMainDictLabel(workSendMessage.getDocType(),"doc_type",""));
                //发文日期
                map.put("createDate",workSendMessage.getCreateDate()==null?"":sdf.format(workSendMessage.getCreateDate()));
                //拟稿人
                map.put("person",workSendMessage.getPerson());
                //发文摘要
                map.put("summary",workSendMessage.getSummary());
                //备注
                map.put("remarks",workSendMessage.getRemarks());
                //发文范围-部门
                map.put("officeList",workSendMessage.getOfficeList());
                //发文范围-用户
                map.put("userList",workSendMessage.getUserList());
                //附件
                map.put("workAttachments",workSendMessage.getWorkAttachments());
            }
            //报废申请
            else if ("63".equals(type)){

            } //加班
            else if ("77".equals(type)){
                WorkOvertime workOvertime = workOvertimeService.get(notifyId);
                //发起人
                map.put("creatBy",workOvertime.getCreateBy().getName());
                //开始时间
                map.put("startDate",workOvertime.getStartDate()==null?"":sdfs.format(workOvertime.getStartDate()));
                //开始时间上午下午
                map.put("startType",DictUtils.getDictLabel(workOvertime.getStartType(),"am_pm",""));
                //结束时间
                map.put("endDate",workOvertime.getEndDate()==null?"":sdfs.format(workOvertime.getEndDate()));
                //结束时间上午下午
                map.put("endType",DictUtils.getDictLabel(workOvertime.getEndType(),"am_pm",""));
                //加班原因
                map.put("reason",workOvertime.getReason());
                //图片列表
                map.put("workAttachments",workOvertime.getWorkAttachments());
            }//出差
            else if ("78".equals(type)){
                WorkOut workOut = workOutService.get(notifyId);
                //发起人
                map.put("creatBy",workOut.getCreateBy().getName());
                //开始时间
                map.put("startDate",workOut.getStartDate()==null?"":sdfs.format(workOut.getStartDate()));
                //开始时间上午下午
                map.put("startType",DictUtils.getDictLabel(workOut.getStartType(),"am_pm",""));
                //结束时间
                map.put("endDate",workOut.getEndDate()==null?"":sdfs.format(workOut.getEndDate()));
                //结束时间上午下午
                map.put("endType",DictUtils.getDictLabel(workOut.getEndType(),"am_pm",""));
                //出差原因
                map.put("reason",workOut.getReason());
                //出差天数
                map.put("days",workOut.getDays());
                //出差地点
                map.put("address",workOut.getAddress());
                //图片列表
                map.put("workAttachments",workOut.getWorkAttachments());
            }
            //外勤
            else if ("79".equals(type)){
                WorkField workField = workFieldService.get(notifyId);
                //发起人
                map.put("creatBy",workField.getCreateBy().getName());
                //开始时间
                map.put("startDate",workField.getStartDate()==null?"":sdfs.format(workField.getStartDate()));
                //开始时间上午下午
                map.put("startType",DictUtils.getDictLabel(workField.getStartType(),"am_pm",""));
                //结束时间
                map.put("endDate",workField.getEndDate()==null?"":sdfs.format(workField.getEndDate()));
                //结束时间上午下午
                map.put("endType",DictUtils.getDictLabel(workField.getEndType(),"am_pm",""));
                //出差原因
                map.put("reason",workField.getReason());
                //出差天数
                map.put("reason",workField.getDays());
                //图片列表
                map.put("workAttachments",workField.getWorkAttachments());
            }
            //外勤
            else if ("80".equals(type)||"81".equals(type)||"82".equals(type)){
                LeaveApply leaveApply = leaveApplyService.get(notifyId);
                //发起人
                User user = UserUtils.get(leaveApply.getCreateBy().getId());
                map.put("creatBy",user.getName());
                //请假天数
                map.put("longTime",leaveApply.getLongTime());
                LeaveDetail detail=new LeaveDetail();
                detail.setLeaveId(leaveApply.getId());
                List<LeaveDetail> leaveDetails = leaveDetailService.findList(detail);
                //leaveId;		// 请假id
                //	days;		// 请假天数
                //	flat;		// 1请假2续假
                //	leaveTypeId;		// 请假类型
                //	counts;		//累计次数
                //	sumDays;	// 累计天数
                //	startTime;		// 开始时间
                //	startType;		// 开始类型 1上午 2下午
                //	endTime;		// 结束时间
                //	endType;		// 结束类型 1上午 2下午
                //请假详情
                map.put("leaveDetails",leaveDetails);
                //请假原因
                map.put("reason",leaveApply.getReason());
                //附件
                map.put("workAttachments",leaveApply.getWorkAttachments());
            }
            //补卡类型
            else if ("83".equals(type)){
                WorkAttendanceInfo workAttendanceInfo = workAttendanceInfoService.getAudit(notifyId);
                //补卡类型
                map.put("type",DictUtils.getDictLabel(workAttendanceInfo.getType(),"attendance_type",""));
                //上午/下午
                map.put("morningAfternoon",workAttendanceInfo.getType().equals("1")?"":DictUtils.getDictLabel(workAttendanceInfo.getMorningAfternoon(),"am_pm",""));
                //考勤类型
                map.put("attendanceType",DictUtils.getDictLabel(workAttendanceInfo.getAttendanceType(),"attendance_info_type",""));
                //补卡时间
                map.put("updateDate",workAttendanceInfo.getUpdateDate()==null?"":sdfs.format(workAttendanceInfo.getUpdateDate()));
                //补卡原因
                map.put("updateDate",workAttendanceInfo.getRemarks());
            }
            //领用申请
            else if ("64".equals(type)){

            }
            j.put("data",map);
            j.setErrorCode(ErrorCode.code_1004);
            j.setMsg("读取待办详情成功");
        }catch (Exception e){
            j.setSuccess(false);
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("读取待办详情失败");
            logger.info("---------e:"+e.getMessage());
        }
        return j;
    }

    @Transactional
    @RequestMapping(value = "findInfo", method=RequestMethod.GET)
    @ResponseBody
    public AjaxJson findInfo(HttpServletRequest request, HttpServletResponse response) {
        AjaxJson j = new AjaxJson();
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            HashMap<String, String> requestMap = findRequestMap(request);
            String id = requestMap.get("id");
            String type = requestMap.get("type");
            if (StringUtils.isBlank(id)) {
                j.setSuccess(false);
                j.setErrorCode(ErrorCode.code_2001);
                j.setMsg("读取待办详情失败");
            }
            Map<String,Object> map = new HashMap<>();
            //加班
            if ("77".equals(type)) {
                WorkOvertime workOvertime = workOvertimeService.get(id);
                //发起人
                map.put("creatBy", workOvertime.getCreateBy().getName());
                //开始时间
                map.put("startDate", workOvertime.getStartDate() == null ? "" : sdfs.format(workOvertime.getStartDate()));
                //开始时间上午下午
                map.put("startType", DictUtils.getDictLabel(workOvertime.getStartType(), "am_pm", ""));
                //结束时间
                map.put("endDate", workOvertime.getEndDate() == null ? "" : sdfs.format(workOvertime.getEndDate()));
                //结束时间上午下午
                map.put("endType", DictUtils.getDictLabel(workOvertime.getEndType(), "am_pm", ""));
                //加班原因
                map.put("reason", workOvertime.getReason());
                //图片列表
                map.put("workAttachments", workOvertime.getWorkAttachments());
            }//出差
            else if ("78".equals(type)) {
                WorkOut workOut = workOutService.get(id);
                //发起人
                map.put("creatBy", workOut.getCreateBy().getName());
                //开始时间
                map.put("startDate", workOut.getStartDate() == null ? "" : sdfs.format(workOut.getStartDate()));
                //开始时间上午下午
                map.put("startType", DictUtils.getDictLabel(workOut.getStartType(), "am_pm", ""));
                //结束时间
                map.put("endDate", workOut.getEndDate() == null ? "" : sdfs.format(workOut.getEndDate()));
                //结束时间上午下午
                map.put("endType", DictUtils.getDictLabel(workOut.getEndType(), "am_pm", ""));
                //出差原因
                map.put("reason", workOut.getReason());
                //出差天数
                map.put("days", workOut.getDays());
                //出差地点
                map.put("address", workOut.getAddress());
                //图片列表
                map.put("workAttachments", workOut.getWorkAttachments());
            }
            //外勤
            else if ("79".equals(type)) {
                WorkField workField = workFieldService.get(id);
                //发起人
                map.put("creatBy", workField.getCreateBy().getName());
                //开始时间
                map.put("startDate", workField.getStartDate() == null ? "" : sdfs.format(workField.getStartDate()));
                //开始时间上午下午
                map.put("startType", DictUtils.getDictLabel(workField.getStartType(), "am_pm", ""));
                //结束时间
                map.put("endDate", workField.getEndDate() == null ? "" : sdfs.format(workField.getEndDate()));
                //结束时间上午下午
                map.put("endType", DictUtils.getDictLabel(workField.getEndType(), "am_pm", ""));
                //出差原因
                map.put("reason", workField.getReason());
                //出差天数
                map.put("days", workField.getDays());
                //图片列表
                map.put("workAttachments", workField.getWorkAttachments());
            }
            //外勤
            else if ("80".equals(type) || "81".equals(type) || "82".equals(type)) {
                LeaveApply leaveApply = leaveApplyService.get(id);
                //发起人
                User user = UserUtils.get(leaveApply.getCreateBy().getId());
                map.put("creatBy", user.getName());
                //请假天数
                map.put("longTime", leaveApply.getLongTime());
                LeaveDetail detail = new LeaveDetail();
                detail.setLeaveId(leaveApply.getId());
                List<LeaveDetail> leaveDetails = leaveDetailService.findList(detail);
                //leaveId;		// 请假id
                //	days;		// 请假天数
                //	flat;		// 1请假2续假
                //	leaveTypeId;		// 请假类型
                //	counts;		//累计次数
                //	sumDays;	// 累计天数
                //	startTime;		// 开始时间
                //	startType;		// 开始类型 1上午 2下午
                //	endTime;		// 结束时间
                //	endType;		// 结束类型 1上午 2下午
                //请假详情
                map.put("leaveDetails", leaveDetails);
                //请假原因
                map.put("reason", leaveApply.getReason());
                //图片列表
                map.put("workAttachments", leaveApply.getWorkAttachments());

            }
            //补卡类型
            else if ("83".equals(type)) {
                WorkAttendanceInfo workAttendanceInfo = workAttendanceInfoService.getAudit(id);
                //补卡类型
                map.put("type", DictUtils.getDictLabel(workAttendanceInfo.getType(), "attendance_type", ""));
                //上午/下午
                map.put("morningAfternoon", workAttendanceInfo.getType().equals("1") ? "" : DictUtils.getDictLabel(workAttendanceInfo.getMorningAfternoon(), "am_pm", ""));
                //考勤类型
                map.put("attendanceType", DictUtils.getDictLabel(workAttendanceInfo.getAttendanceType(), "attendance_info_type", ""));
                //补卡时间
                map.put("updateDate", workAttendanceInfo.getUpdateDate() == null ? "" : sdfs.format(workAttendanceInfo.getUpdateDate()));
                //补卡原因
                map.put("updateDate", workAttendanceInfo.getRemarks());
            }
            j.put("data",map);
            j.setErrorCode(ErrorCode.code_1004);
            j.setMsg("读取待办详情成功");
        }catch (Exception e){
            j.setSuccess(false);
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("读取待办详情失败");
            logger.info("---------e:"+e.getMessage());
        }
        return j;
    }


    /**
     * 审核同意/失败
     * @param
     * @return
     */
    @Transactional
    @RequestMapping(value = "saveAudit", method=RequestMethod.GET)
    @ResponseBody
    public AjaxJson saveAudit(HttpServletRequest request, HttpServletResponse response) {
        HashMap<String, String> requestMap = findRequestMap(request);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String notifyId = requestMap.get("notifyId");
        String type = requestMap.get("type");
        String flag = requestMap.get("flag");
        String appAudit = requestMap.get("appAudit");
        AjaxJson j = new AjaxJson();
        if (StringUtils.isBlank(appAudit) || StringUtils.isBlank(flag) || StringUtils.isBlank(notifyId)  || StringUtils.isBlank(type)){
            j.setSuccess(false);
            j.setErrorCode(ErrorCode.code_2001);
            j.setMsg("读取待办详情失败");
        }else if(!appAudit.equals("1") && !appAudit.equals("2")){
            j.setSuccess(false);
            j.setErrorCode(ErrorCode.code_2001);
            j.setMsg("无审批权限");
        }
        j.setMsg("流程审核成功");
        j.setSuccess(true);
        j.setErrorCode(ErrorCode.code_1004);
        try {
            Map<String,Object> map = new HashMap<>();
            //报销
            if ("13".equals(type)){
                WorkReimbursement workReimbursement = workReimbursementService.get(notifyId);
                Act act = getByAct(workReimbursement.getProcessInstanceId());
                act.setFlag(flag);
                workReimbursement.setAct(act);
                List<User> users = new ArrayList<>();
                if ("bmzr".equals(act.getTaskDefKey())){
                    users = UserUtils.getByRoleActivityEnname("fgld",2,workReimbursement.getOfficeId(),"8",workReimbursement.getCreateBy());
                }else  if ("fgld".equals(act.getTaskDefKey())){
                    users = UserUtils.getByRoleActivityEnname("cwzg",3,workReimbursement.getOfficeId(),"8",workReimbursement.getCreateBy());
                }else  if ("cw".equals(act.getTaskDefKey())){
                    users = UserUtils.getByRoleActivityEnname("zjl",3,workReimbursement.getOfficeId(),"8",workReimbursement.getCreateBy());
                }else  if ("zjl".equals(act.getTaskDefKey())){
                    users = UserUtils.getByRoleActivityEnname("cwfgld",3,workReimbursement.getOfficeId(),"8",workReimbursement.getCreateBy());
                }else  if ("cwzj".equals(act.getTaskDefKey())){
                    users = UserUtils.getByRoleActivityEnname("cn",3,workReimbursement.getOfficeId(),"8",workReimbursement.getCreateBy());
                }else  if ("modifyApply".equals(act.getTaskDefKey())){
                    users = UserUtils.getByRoleActivityEnname("bmzr",2,workReimbursement.getOfficeId(),"8",workReimbursement.getCreateBy());
                }
                if ( "yes".equals(flag) && users==null){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,下一步审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    workReimbursementService.auditSave(workReimbursement, users);
                }
            }//合同申请
            else if ("16".equals(type)){
                WorkContractInfo workContractInfo =workContractInfoService.get(notifyId);
                Act act = getByAct(workContractInfo.getProcessInstanceId());
                act.setFlag(flag);
                workContractInfo.setAct(act);
                // 对不同环节的业务逻辑进行操作
                List<User> users = null;
                String taskDefKey = workContractInfo.getAct().getTaskDefKey();
                if ("bmzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getProcessInstanceId(),2);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("scyfglbzr",3,workContractInfo.getOfficeId(),"2",workContractInfo.getCreateBy());
                }else  if ("ywbzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getProcessInstanceId(),3);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("scfgld",3,workContractInfo.getOfficeId(),"2",workContractInfo.getCreateBy());
                }else  if ("fgld".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getProcessInstanceId(),4);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("gzr",1,workContractInfo.getOfficeId(),"2",workContractInfo.getCreateBy());
                }else  if ("gzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getProcessInstanceId(),4);
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getProcessInstanceId(),1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workContractInfoService.auditSave(workContractInfo, VarStr.CONTRACT_STATUS,users);
                }
            }//发票管理
            else if ("21".equals(type)){
                WorkInvoice workInvoice = workInvoiceService.get(notifyId);
                Act act = getByAct(workInvoice.getProcessInstanceId());
                act.setFlag(flag);
                workInvoice.setAct(act);
                // 对不同环节的业务逻辑进行操作
                String taskDefKey = workInvoice.getAct().getTaskDefKey();
                List<User> users = null;
                if ("bmzr".equals(taskDefKey)){
                    if(("1").equals(workInvoice.getExt())) {
                        users = UserUtils.getByProssType(workInvoice.getProcessInstanceId(), 2);
                        if (users == null)
                            users = UserUtils.getByRoleActivityEnname("scfgld", 1, workInvoice.getOfficeId(), "5", workInvoice.getCreateBy());
                    }else{
                        users = UserUtils.getByProssType(workInvoice.getProcessInstanceId(),3);
                        if (users==null )
                            users = UserUtils.getByRoleActivityEnname("fpgly",3,workInvoice.getOfficeId(),"5",workInvoice.getCreateBy());
                    }
                }else  if ("scbzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workInvoice.getProcessInstanceId(),3);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("fpgly",1,workInvoice.getOfficeId(),"5",workInvoice.getCreateBy());
                }else  if ("fpgly".equals(taskDefKey)){
                    if(("1").equals(workInvoice.getExt())) {
                        users = UserUtils.getByProssType(workInvoice.getProcessInstanceId(), 3);
                    }else{
                        users = UserUtils.getByProssType(workInvoice.getProcessInstanceId(),2);
                    }
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workInvoice.getProcessInstanceId(), 1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = "";
                    if(("1").equals(workInvoice.getExt())){
                        str = workInvoiceService.auditSave(workInvoice,users);
                    }else if(("0").equals(workInvoice.getExt())){
                        str = workInvoiceService.auditSaveBranch(workInvoice,users);
                    }
                }
            }/*else if ("24".equals(type)){

            }else if ("25".equals(type)){

            }else if ("26".equals(type)){

            }else if ("27".equals(type)){

            }else if ("28".equals(type)){

            }else if ("29".equals(type)){

            }else if ("32".equals(type)){

            }else if ("33".equals(type)){

            }else if ("34".equals(type)){

            }else if ("35".equals(type)){

            }else if ("36".equals(type)){

            }else if ("37".equals(type)){

            }*/
            //案例登记
            else if ("38".equals(type)){

            }//项目登记
            else if ("39".equals(type)){
                String userIds = requestMap.get("userIds");
                ProjectRecords projectRecords = projectRecordsService.get(notifyId);
                if ("2".equals(appAudit) && StringUtils.isBlank(userIds)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("参数为空");
                    j.setSuccess(false);
                    return j;
                }else if("2".equals(appAudit) && StringUtils.isNotBlank(userIds)){
                    List<User> leaders = new ArrayList<>();
                    String[] ids = userIds.split(",");
                    for (String userId:ids){
                        leaders.add(new User(userId));
                    }
                    projectRecords.setProjectLeaders(leaders);
                }
                Act act = getByAct(projectRecords.getProcessInstanceId());
                act.setFlag(flag);
                projectRecords.setAct(act);
                List<User> users = UserUtils.getByProssType(projectRecords.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    projectRecordsService.auditSave(projectRecords, users);
                }
            }//退票申请
            else if ("40".equals(type)){
                WorkInvoiceReturn workInvoiceReturn = workInvoiceReturnService.get(notifyId);
                Act act = getByAct(workInvoiceReturn.getProcessInstanceId());
                act.setFlag(flag);
                workInvoiceReturn.setAct(act);
                // 对不同环节的业务逻辑进行操作
                String taskDefKey = workInvoiceReturn.getAct().getTaskDefKey();
                List<User> users = null;
                WorkInvoice workInvoice = new WorkInvoice();
                if(workInvoiceReturn.getInvoiceDetail()!=null){
                    if(workInvoiceReturn.getInvoiceDetail().getWorkInvoice()!=null){
                        if(com.jeeplus.common.utils.StringUtils.isNotBlank(workInvoiceReturn.getInvoiceDetail().getWorkInvoice().getId())){
                            workInvoice = workInvoiceService.get(workInvoiceReturn.getInvoiceDetail().getWorkInvoice());
                        }
                    }
                }
                if ("bmzr".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workInvoiceReturn.getProcessInstanceId(), 2);
                    if (users == null)
                        users =  UserUtils.getByRoleActivityEnname("fgld",2,workInvoiceReturn.getOfficeId(),"6",workInvoiceReturn.getCreateBy());
                } else if ("fgld".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workInvoiceReturn.getProcessInstanceId(), 3);
                    if (users == null) {
                        if(workInvoice!=null) {
                            //1总公司0分公司
                            if ("1".equals(workInvoice.getExt())) {
                                users = UserUtils.getByRoleActivityEnname("fpgly", 1, workInvoiceReturn.getOfficeId(), "6", workInvoiceReturn.getCreateBy());
                            } else if ("0".equals(workInvoice.getExt())) {
                                users = UserUtils.getByRoleActivityEnname("fpgly", 3, workInvoiceReturn.getOfficeId(), "6", workInvoiceReturn.getCreateBy());
                            }
                        }
                    }
                } else if ("fpgly".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workInvoiceReturn.getProcessInstanceId(), 4);
                    if (users == null){
                        if(workInvoice!=null){
                            //1总公司0分公司
                            if("1".equals(workInvoice.getExt())){
                                users = UserUtils.getByRoleActivityEnname("zghj",1,workInvoiceReturn.getOfficeId(),"6",workInvoiceReturn.getCreateBy());
                            }else if("0".equals(workInvoice.getExt())){
                                users = UserUtils.getByRoleActivityEnname("zghj",3,workInvoiceReturn.getOfficeId(),"6",workInvoiceReturn.getCreateBy());
                            }
                        }
                    }
                } else if ("zgkj".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workInvoiceReturn.getProcessInstanceId(), 4);
                } else if ("modifyApply".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workInvoiceReturn.getProcessInstanceId(), 1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workInvoiceReturnService.auditSave(workInvoiceReturn,users);
                }
            }//项目变更
            else if ("41".equals(type)){
                ProjectRecordsAlter projectRecordsAlter = projectRecordsAlterService.get(notifyId);
                projectRecordsAlterService.queryProjectAlterDetail(projectRecordsAlter);
                String userIds = requestMap.get("userIds");
                if ("2".equals(appAudit) && StringUtils.isBlank(userIds)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("参数为空");
                    j.setSuccess(false);
                    return j;
                }else if("2".equals(appAudit) && StringUtils.isNotBlank(userIds)){
                    List<User> leaders = new ArrayList<>();
                    String[] ids = userIds.split(",");
                    for (String userId:ids){
                        leaders.add(new User(userId));
                    }
                    projectRecordsAlter.setProjectLeaders(leaders);
                }
                Act act = getByAct(projectRecordsAlter.getProcessInstanceId());
                act.setFlag(flag);
                projectRecordsAlter.setAct(act);
                List<User> users = UserUtils.getByProssType(projectRecordsAlter.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    projectRecordsAlterService.auditSave(projectRecordsAlter, users);
                }
            }//合同归档
            else if ("42".equals(type)){

            }//合同作废
            else if ("43".equals(type)){

            }//合同变更
            else if ("44".equals(type)){
                WorkContractInfo workContractInfo =workContractInfoService.get(notifyId);
                Act act = getByAct(workContractInfo.getAlterProcessInstanceId());
                act.setFlag(flag);
                workContractInfo.setAct(act);
                // 对不同环节的业务逻辑进行操作
                String taskDefKey = workContractInfo.getAct().getTaskDefKey();
                List<User> users = null;
                if ("bmzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getAlterProcessInstanceId(),2);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("scyfglbzr",3,workContractInfo.getOfficeId(),"2",workContractInfo.getCreateBy());
                }else  if ("ywbzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getAlterProcessInstanceId(),3);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("scfgld",3,workContractInfo.getOfficeId(),"2",workContractInfo.getCreateBy());
                }else  if ("fgld".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getAlterProcessInstanceId(),4);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("gzr",1,workContractInfo.getOfficeId(),"2",workContractInfo.getCreateBy());
                }else  if ("gzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getAlterProcessInstanceId(),4);
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workContractInfo.getAlterProcessInstanceId(),1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workContractInfoService.auditAlterSave(workContractInfo,users);
                }
            }//工作内容报告
            else if ("45".equals(type)){
                ProjectReportData t = projectReportDataService.get(notifyId);
                String number = requestMap.get("number");
                if ("2".equals(appAudit) && StringUtils.isBlank(number)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("参数为空");
                    j.setSuccess(false);
                    return j;
                }else if("2".equals(appAudit) && StringUtils.isNotBlank(number)){
                    projectReportDataService.reportNumber(t.getId(),number);
                }

                Act act = getByAct(t.getProcessInstanceId());
                act.setFlag(flag);
                t.setAct(act);
                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("bmzr",2,t.getOfficeId(),"12",t.getCreateBy());
                }else if ("bmzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),3);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("bzshb",3,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("bzshb".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),4);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("fgld",2,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("fgld".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),5);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("zlfgld",3,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("fgzlfz".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),6);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("bggdgly",3,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("glyda".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),7);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("gzr",3,t.getOfficeId(),"12",t.getCreateBy());
                }else if ("gzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),7);
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    projectReportDataService.auditSave(t, users);
                }

            }
            else if ("46".equals(type)){
                ProjectReportData t = projectReportChangeService.get(notifyId);
                String number = requestMap.get("number");
                if ("2".equals(appAudit) && StringUtils.isBlank(number)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("参数为空");
                    j.setSuccess(false);
                    return j;
                }else if("2".equals(appAudit) && StringUtils.isNotBlank(number)){
                    projectReportDataService.reportNumber(t.getId(),number);
                }
                Act act = getByAct(t.getProcessInstanceId());
                act.setFlag(flag);
                t.setAct(act);
                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("bmzr",2,t.getOfficeId(),"12",t.getCreateBy());
                }else if ("bmzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),3);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("bzshb",3,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("bzshb".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),4);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("fgld",2,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("fgld".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),5);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("zlfgld",3,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("fgzlfz".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),6);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("bggdgly",3,t.getOfficeId(),"12",t.getCreateBy());
                }else  if ("glyda".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),7);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("gzr",3,t.getOfficeId(),"12",t.getCreateBy());
                }else if ("gzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),7);
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(t.getProcessInstanceId(),1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = projectReportChangeService.auditSave(t,users);
                }
                projectReportChangeService.reportNumber(t.getId(),number);
            }else if ("47".equals(type)){

            }//发票变更
            else if ("48".equals(type)){

            }else if ("49".equals(type)){

            }//投标管理
            else if ("50".equals(type)){
                WorkBidProject workBidProject = workBidProjectService.get(notifyId);
                String isSubcontract = requestMap.get("isSubcontract");
                if ("2".equals(appAudit) && StringUtils.isBlank(isSubcontract)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("参数为空");
                    j.setSuccess(false);
                    return j;
                }else if("2".equals(appAudit) && StringUtils.isNotBlank(isSubcontract)){
                    workBidProject.setIsSubcontract(isSubcontract);
                }
                Act act = getByAct(workBidProject.getProcessInstanceId());
                act.setFlag(flag);
                workBidProject.setAct(act);
                // 对不同环节的业务逻辑进行操作
                String taskDefKey = workBidProject.getAct().getTaskDefKey();
                List<User> users = null;
                if ("fgld".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 2);
                    if (users == null)
                        users = UserUtils.getByRoleActivityEnname("scyfglbzr", 3, workBidProject.getOfficeId(), "16", workBidProject.getCreateBy());
                } else if ("scyfglbzr".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 3);
                    if (users == null)
                        users = UserUtils.getByRoleActivityEnname("zjl", 1, workBidProject.getOfficeId(), "16", workBidProject.getCreateBy());
                } else if ("zjl".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 4);
                    if (users == null)
                        users = UserUtils.getByRoleActivityEnname("tbzy", 3, workBidProject.getOfficeId(), "16", workBidProject.getCreateBy());
                } else if ("tbzy".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 5);
                    if (users == null)
                        users = UserUtils.getByRoleActivityEnname("scyfglbzr", 3, workBidProject.getOfficeId(), "16", workBidProject.getCreateBy());
                } else if ("scyfglbzrs".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 6);
                    if (users == null)
                        users = UserUtils.getByRoleActivityEnname("gzr", 1, workBidProject.getOfficeId(), "16", workBidProject.getCreateBy());
                } else if ("gzr".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 6);
                } else if ("sqr".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 8);
                    if (users == null)
                        users = UserUtils.getByRoleActivityEnname("scyfglbzr", 3, workBidProject.getOfficeId(), "16", workBidProject.getCreateBy());
                } else if ("scyfglbzrss".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 8);
                } else if ("modifyApply".equals(taskDefKey)) {
                    users = UserUtils.getByProssType(workBidProject.getProcessInstanceId(), 1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workBidProjectService.auditSave(workBidProject,users);
                }
            }else if ("51".equals(type)){

            }//收入结算
            else if ("52".equals(type)){
                WorkReceiptsSettle workReceiptsSettle = workReceiptsSettleService.get(notifyId);
                Act act = getByAct(workReceiptsSettle.getProcessInstanceId());
                act.setFlag(flag);
                act.setComment("");
                workReceiptsSettle.setAct(act);
                String taskDefKey = workReceiptsSettle.getAct().getTaskDefKey();
                List<User> users = null;
                if ("scfgld".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workReceiptsSettle.getProcessInstanceId(),2);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("fpgly",3,workReceiptsSettle.getOffice().getId(),"7",workReceiptsSettle.getCreateBy());
                }else  if ("fpgly".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workReceiptsSettle.getProcessInstanceId(),3);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("cwzg", 1, workReceiptsSettle.getOffice().getId(), "7", workReceiptsSettle.getCreateBy());
                }else  if ("cwzg".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workReceiptsSettle.getProcessInstanceId(),4);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("zjl",1,workReceiptsSettle.getOffice().getId(),"7",workReceiptsSettle.getCreateBy());
                }else  if ("zjl".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workReceiptsSettle.getProcessInstanceId(),5);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("cwfgld",1,workReceiptsSettle.getOffice().getId(),"7",workReceiptsSettle.getCreateBy());
                }else  if ("cwfgld".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workReceiptsSettle.getProcessInstanceId(),6);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("cn",1,workReceiptsSettle.getOffice().getId(),"7",workReceiptsSettle.getCreateBy());
                }else if ("cn".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workReceiptsSettle.getProcessInstanceId(),6);
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workReceiptsSettle.getProcessInstanceId(),1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workReceiptsSettleService.auditSave(workReceiptsSettle,users);
                }

            }//收入调整
            else if ("53".equals(type)){
                WorkReceiptsRevise workReceiptsRevise = workReceiptsReviseService.get(notifyId);
                Act act = getByAct(workReceiptsRevise.getProcessInstanceId());
                act.setFlag(flag);
                workReceiptsRevise.setAct(act);
                List<User> users = UserUtils.getByProssType(workReceiptsRevise.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workReceiptsReviseService.auditSave(workReceiptsRevise,users);
                }

            }//收入调整作废
            else if ("54".equals(type)){
            }
            //收文申请
            else if ("55".equals(type)){
                WorkIncomingMessage workIncomingMessage = workIncomingMessageService.get(notifyId);
                // 领导批示
                String opinion = URLDecoder.decode(requestMap.get("opinion")==null?"":requestMap.get("opinion"), "UTF-8");
                // 处理人 例子id1,id2,id3
                String handler = requestMap.get("handler");
                if ("2".equals(appAudit) && StringUtils.isBlank(opinion) && StringUtils.isBlank(handler)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("参数为空");
                    j.setSuccess(false);
                    return j;
                }else if("2".equals(appAudit) &&StringUtils.isNotBlank(opinion) && StringUtils.isNotBlank(handler)){
                    workIncomingMessage.setOpinion(opinion);
                    workIncomingMessage.setHandler(handler);
                }
                Act act = getByAct(workIncomingMessage.getProcessInstanceId());
                act.setFlag(flag);
                workIncomingMessage.setAct(act);
                String taskDefKey = workIncomingMessage.getAct().getTaskDefKey();
                List<User> users = null;
                if ("zjl".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workIncomingMessage.getProcessInstanceId(),2);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("xzzg",3,workIncomingMessage.getOffice().getId(),"11",workIncomingMessage.getCreateBy());
                }else if ("xzzg".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workIncomingMessage.getProcessInstanceId(),2);
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workIncomingMessage.getProcessInstanceId(),1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workIncomingMessageService.auditSave(workIncomingMessage,users);
                }
            }
            //行政盖章
            else if ("56".equals(type)){
                WorkAdministrativeAtamp workAdministrativeAtamp = workAdministrativeAtampService.get(notifyId);
                Act act = getByAct(workAdministrativeAtamp.getProcessInstanceId());
                act.setFlag(flag);
                workAdministrativeAtamp.setAct(act);
                // 对不同环节的业务逻辑进行操作
                String taskDefKey = workAdministrativeAtamp.getAct().getTaskDefKey();
                List<User> users = null;
                if ("bmzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workAdministrativeAtamp.getProcessInstanceId(),2);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("xzbzr",3,workAdministrativeAtamp.getComSign().getId(),"11",workAdministrativeAtamp.getCreateBy());
                }else  if ("xzbzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workAdministrativeAtamp.getProcessInstanceId(),3);
                    if (users==null )
                        users = UserUtils.getByRoleActivityEnname("gzr",3,workAdministrativeAtamp.getComSign().getId(),"11",workAdministrativeAtamp.getCreateBy());
                }else if ("gzr".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workAdministrativeAtamp.getProcessInstanceId(),3);
                }else if ("modifyApply".equals(taskDefKey)){
                    users = UserUtils.getByProssType(workAdministrativeAtamp.getProcessInstanceId(),1);
                }
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else{
                    String str = workAdministrativeAtampService.auditSave(workAdministrativeAtamp,users);
                }
            }
            //采购合同
            else if ("57".equals(type)){

            }
            //日常事务
            else if ("58".equals(type)){

            }
            //借用申请
            else if ("59".equals(type)){

            }
            //归还借用
            else if ("60".equals(type)){

            }
            //采购申请
            else if ("61".equals(type)){

            }
            //发文申请
            else if ("62".equals(type)){
                WorkSendMessage workSendMessage = workSendMessageService.get(notifyId);
                Act act = getByAct(workSendMessage.getProcessInstanceId());
                act.setFlag(flag);
                workSendMessage.setAct(act);
                List<User> users = UserUtils.getByProssType(workSendMessage.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workSendMessageService.auditSave(workSendMessage,users);
                }
            }
            //报废申请
            else if ("63".equals(type)){

            }
            //领用申请
            else if ("64".equals(type)){

            } //加班
            else if ("77".equals(type)){
                WorkOvertime workOvertime = workOvertimeService.get(notifyId);
                Act act = getByAct(workOvertime.getProcessInstanceId());
                act.setFlag(flag);
                workOvertime.setAct(act);
                List<User> users = UserUtils.getByProssType(workOvertime.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workOvertimeService.auditSave(workOvertime,users);
                }
            }//出差
            else if ("78".equals(type)){
                WorkOut workOut = workOutService.get(notifyId);
                Act act = getByAct(workOut.getProcessInstanceId());
                act.setFlag(flag);
                workOut.setAct(act);
                List<User> users = UserUtils.getByProssType(workOut.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workOutService.auditSave(workOut,users);
                }
            }//外勤
            else if ("79".equals(type)){
                WorkField workField = workFieldService.get(notifyId);
                Act act = getByAct(workField.getProcessInstanceId());
                act.setFlag(flag);
                workField.setAct(act);
                List<User> users = UserUtils.getByProssType(workField.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = workFieldService.auditSave(workField,users);
                }
            }//请假
            else if ("80".equals(type)){
                LeaveApply leaveApply = leaveApplyService.get(notifyId);
                Act act = getByAct(leaveApply.getProcessInstanceId());
                act.setFlag(flag);
                leaveApply.setAct(act);
                List<User> users = UserUtils.getByProssType(leaveApply.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = leaveApplyService.auditSave(leaveApply,users);
                }
            }//销假
            else if ("81".equals(type)){
                LeaveApply leaveApply = leaveApplyService.get(notifyId);
                Act act = getByAct(leaveApply.getProcessInstanceId());
                act.setFlag(flag);
                leaveApply.setAct(act);
                List<User> users = UserUtils.getByProssType(leaveApply.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = leaveApplyService.auditBackSave(leaveApply,users);
                }
            }//续假
            else if ("82".equals(type)){
                LeaveApply leaveApply = leaveApplyService.get(notifyId);
                Act act = getByAct(leaveApply.getProcessInstanceId());
                act.setFlag(flag);
                leaveApply.setAct(act);
                List<User> users = UserUtils.getByProssType(leaveApply.getProcessInstanceId(),1);
                if ("yes".equals(flag) && (users==null || users.size()==0)){
                    j.setErrorCode(ErrorCode.code_2001);
                    j.setMsg("审批失败,审批人为空,请联系管理员！");
                    j.setSuccess(false);
                    return j;
                }else {
                    String str = leaveApplyService.auditExtendSave(leaveApply,users);
                }
            }
            //补卡申请
            else if ("83".equals(type)){
                WorkAttendanceInfo workAttendanceInfo = workAttendanceInfoService.getAudit(notifyId);
                workAttendanceInfoService.saveAudit(notifyId,workAttendanceInfo.getIds(),flag);
            }
            j.put("data",map);
            //actTaskService.isProcessEnd(procInsId);
            logger.error("f/business/saveAudit?notifyId="+notifyId+"&type="+type+"&flag="+flag+"&appAudit="+appAudit+"&isSubcontract="+requestMap.get("isSubcontract"));
        }catch (ActivitiObjectNotFoundException e){
            logger.error("ActivitiObjectNotFoundException e:"+e);
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("流程审核失败");
            j.setSuccess(false);
            j.setMsg("流程已审批，不能重新审批！");
        }catch (Exception e){
            logger.error("Exception e:"+e);
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("流程审核失败");
            j.setSuccess(false);
            logger.error("Exception e:"+e);
            j.setMsg("审核意见失败！！");
        }
        return j;
    }


    @RequestMapping(value={"workBusinessShow"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson workBusinessShow(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        AjaxJson j = new AjaxJson();
        try {
            User user = UserUtils.getUser();
            WorkProjectNotify workProjectNotify = new WorkProjectNotify();
            workProjectNotify.setUser(user);
            workProjectNotify.setCompanyId(UserUtils.getSelectCompany().getId());
            workProjectNotify.setRemarks("待审批");
            List<WorkProjectNotify> list = workProjectNotifyService.findListByAPP(workProjectNotify);
            if(list==null){
                j.setSuccess(false);
                j.setErrorCode(ErrorCode.code_2005);
                j.setMsg("获取显示失败");
                j.put("data", "1");
            }else {
                if (list.size()==0){
                    j.put("data", "1");
                }else {
                    j.put("count", "0");
                }
                j.setErrorCode(ErrorCode.code_1004);
                j.setMsg("获取显示成功");
            }
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取显示失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"saveWorkOvertime"}, method={RequestMethod.POST})
    @ResponseBody
    public AjaxJson saveWorkOvertime(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            //2018-08-19,1
            String start = requestMap.get("start");
            String end = requestMap.get("end");
            String reason = requestMap.get("reason");
            String stratDate = start.split(",")[0];
            String stratType = start.split(",")[1];
            String endDate = end.split(",")[0];
            String endType = end.split(",")[1];
            if(stratDate==null || stratType==null || endDate == null || endType==null){
                j.setErrorCode(ErrorCode.code_2004);
                j.setMsg("参数异常");
                j.put("data", "");
                return j;
            }
            WorkOvertime workOvertime = new WorkOvertime();
            workOvertime.setStartDate(sdf.parse(stratDate));
            workOvertime.setEndDate(sdf.parse(endDate));
            workOvertime.setStartType(stratType);
            workOvertime.setEndType(endType);
            workOvertime.setReason(reason);
            Map<String, Object> variables = Maps.newHashMap();
            workOvertime.setCompanyId(UserUtils.getSelectCompany().getId());
            workOvertime.setOfficeId(UserUtils.getSelectOffice().getId());
            WorkStaffBasicInfo workStaffBasicInfo=leaveApplyService.getBasicInfo();
            workOvertime.setWorkStaffBasicInfo(workStaffBasicInfo);
            String str = workOvertimeService.save(workOvertime, variables,"");
            j.setMsg(str);
            j.getBody().put("id",workOvertime.getId());
            j.setMsg("加班申请已提交");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("加班申请失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"findWorkOvertimes"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson findWorkOvertimes(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            WorkOvertime workOvertime = new WorkOvertime();
            WorkStaffBasicInfo workStaffBasicInfo = leaveApplyService.getBasicInfo();
            workOvertime.setWorkStaffBasicInfo(workStaffBasicInfo);
            List<Map<String,Object>> maps = new ArrayList<>();
            List<WorkOvertime> workOvertimes = workOvertimeService.findList(workOvertime);
            if (workOvertimes!=null && workOvertimes.size()!=0) {
                for (WorkOvertime overtime : workOvertimes) {
                    Map<String,Object> map = new HashMap<>();
                    maps.add(map);
                    map.put("id",overtime.getId());
                    if (overtime.getStartDate()!=null) {
                        //开始时间
                        map.put("start", sdf.format(overtime.getStartDate()) + " " + DictUtils.getDictLabel(overtime.getStartType(), "am_pm", ""));
                    }
                    if (overtime.getEndDate()!=null) {
                        //结束时间
                        map.put("end", sdf.format(overtime.getEndDate()) + " " + DictUtils.getDictLabel(overtime.getEndType(), "am_pm", ""));
                    }
                    //审批状态
                    map.put("status",DictUtils.getDictLabel(overtime.getStatus(),"audit_state",""));
                    //创建时间
                    map.put("createDate",sdfs.format(overtime.getCreateDate()));
                }
            }
            j.getBody().put("date",maps);
            j.setMsg("加班列表获取成功");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("数据异常");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"saveWorkOut"}, method={RequestMethod.POST})
    @ResponseBody
    public AjaxJson saveWorkOut(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            //2018-08-19,1
            String start = requestMap.get("start");
            String end = requestMap.get("end");
            String reason = requestMap.get("reason");
            String address = requestMap.get("address");
            String days = requestMap.get("days");
            String stratDate = start.split(",")[0];
            String stratType = start.split(",")[1];
            String endDate = end.split(",")[0];
            String endType = end.split(",")[1];
            if(stratDate==null || stratType==null || endDate == null || endType==null){
                j.setErrorCode(ErrorCode.code_2004);
                j.setMsg("参数异常");
                j.put("data", "");
                return j;
            }
            WorkOut workOut = new WorkOut();
            workOut.setStartDate(sdf.parse(stratDate));
            workOut.setEndDate(sdf.parse(endDate));
            workOut.setStartType(stratType);
            workOut.setEndType(endType);
            workOut.setReason(reason);
            workOut.setAddress(address);
            workOut.setDays(days);
            Map<String, Object> variables = Maps.newHashMap();
            workOut.setCompanyId(UserUtils.getSelectCompany().getId());
            workOut.setOfficeId(UserUtils.getSelectOffice().getId());
            WorkStaffBasicInfo workStaffBasicInfo=leaveApplyService.getBasicInfo();
            workOut.setWorkStaffBasicInfo(workStaffBasicInfo);
            String str = workOutService.save(workOut, variables,"");
            j.setMsg(str);
            j.getBody().put("id",workOut.getId());
            j.setMsg("出差申请已提交");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("出差申请失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"findWorkOuts"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson findWorkOuts(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            WorkOut out = new WorkOut();
            WorkStaffBasicInfo workStaffBasicInfo = leaveApplyService.getBasicInfo();
            out.setWorkStaffBasicInfo(workStaffBasicInfo);
            List<Map<String,Object>> maps = new ArrayList<>();
            List<WorkOut> workOuts = workOutService.findList(out);
            if (workOuts!=null && workOuts.size()!=0) {
                for (WorkOut workOut : workOuts) {
                    Map<String,Object> map = new HashMap<>();
                    maps.add(map);
                    map.put("id",workOut.getId());
                    if (workOut.getStartDate()!=null) {
                        //开始时间
                        map.put("start", sdf.format(workOut.getStartDate()) + " " + DictUtils.getDictLabel(workOut.getStartType(), "am_pm", ""));
                    }
                    if (workOut.getEndDate()!=null) {
                        //结束时间
                        map.put("end", sdf.format(workOut.getEndDate()) + " " + DictUtils.getDictLabel(workOut.getEndType(), "am_pm", ""));
                    }
                    //审批状态
                    map.put("status",DictUtils.getDictLabel(workOut.getStatus(),"audit_state",""));
                    //创建时间
                    map.put("createDate",sdfs.format(workOut.getCreateDate()));
                }
            }
            j.getBody().put("date",maps);
            j.setMsg("出差列表获取成功");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("数据异常");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"saveWorkField"}, method={RequestMethod.POST})
    @ResponseBody
    public AjaxJson saveWorkField(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            //2018-08-19,1
            String start = requestMap.get("start");
            String end = requestMap.get("end");
            String reason = requestMap.get("reason");
            String days = requestMap.get("days");
            String stratDate = start.split(",")[0];
            String stratType = start.split(",")[1];
            String endDate = end.split(",")[0];
            String endType = end.split(",")[1];
            if(stratDate==null || stratType==null || endDate == null || endType==null){
                j.setErrorCode(ErrorCode.code_2004);
                j.setMsg("参数异常");
                j.put("data", "");
                return j;
            }
            WorkField workField = new WorkField();
            workField.setStartDate(sdf.parse(stratDate));
            workField.setEndDate(sdf.parse(endDate));
            workField.setStartType(stratType);
            workField.setEndType(endType);
            workField.setReason(reason);
            workField.setDays(days);
            Map<String, Object> variables = Maps.newHashMap();
            workField.setCompanyId(UserUtils.getSelectCompany().getId());
            workField.setOfficeId(UserUtils.getSelectOffice().getId());
            WorkStaffBasicInfo workStaffBasicInfo=leaveApplyService.getBasicInfo();
            workField.setWorkStaffBasicInfo(workStaffBasicInfo);
            String str = workFieldService.save(workField, variables,"");
            j.setMsg(str);
            j.getBody().put("id",workField.getId());
            j.setMsg("外勤申请已提交");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("外勤申请失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"findWorkFields"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson findWorkFields(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            WorkField field = new WorkField();
            WorkStaffBasicInfo workStaffBasicInfo = leaveApplyService.getBasicInfo();
            field.setWorkStaffBasicInfo(workStaffBasicInfo);
            List<Map<String,Object>> maps = new ArrayList<>();
            List<WorkField> workFields = workFieldService.findList(field);
            if (workFields!=null && workFields.size()!=0) {
                for (WorkField workField : workFields) {
                    Map<String,Object> map = new HashMap<>();
                    maps.add(map);
                    map.put("id",workField.getId());
                    if (workField.getStartDate()!=null) {
                        //开始时间
                        map.put("start", sdf.format(workField.getStartDate()) + " " + DictUtils.getDictLabel(workField.getStartType(), "am_pm", ""));
                    }
                    //结束时间
                    if (workField.getEndDate()!=null) {
                        map.put("end", sdf.format(workField.getEndDate()) + " " + DictUtils.getDictLabel(workField.getEndType(), "am_pm", ""));
                    }
                    //审批状态
                    map.put("status",DictUtils.getDictLabel(workField.getStatus(),"audit_state",""));
                    //创建时间
                    map.put("createDate",sdfs.format(workField.getCreateDate()));
                }
            }
            j.getBody().put("date",maps);
            j.setMsg("外勤列表获取成功");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("数据异常");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"saveLeave"}, method={RequestMethod.POST})
    @ResponseBody
    public AjaxJson saveLeave(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            //2018-08-19,1
            String reason = URLDecoder.decode(requestMap.get("reason")==null?"":requestMap.get("reason"), "UTF-8");
            String longTime = requestMap.get("longTime");
            String leaveDetails = requestMap.get("leaveDetails");
            String leaveId = requestMap.get("leaveId");
            String type = requestMap.get("type");
            LeaveApply leaveApply = new LeaveApply();
            if (StringUtils.isNotBlank(leaveId)){
                leaveApply =  leaveApplyService.get(leaveId);
            }else {
                leaveApply.setApplyer(UserUtils.getUser().getId());
                leaveApply.setOfficeId(UserUtils.getSelectOffice().getId());
                leaveApply.setCompanyId(UserUtils.getSelectCompany().getId());
                leaveApply.setBranchOffice(UserUtils.getSelectBranchOffice());
                leaveApply.setApplyTime(new Date());
            }
            leaveApply.setReason(reason);
            leaveApply.setLongTime(longTime);
            WorkStaffBasicInfo workStaffBasicInfo=leaveApplyService.getBasicInfo();
            if(workStaffBasicInfo==null){
                j.setErrorCode(ErrorCode.code_1004);
                j.setMsg("人员档案不存在！");
                return j;
            }
            leaveApply.setBasicInfo(workStaffBasicInfo);
            List<LeaveDetail> leaveDetailList = new ArrayList<>();
            JSONArray json = JSONArray.fromObject(leaveDetails);
            int count=0;
            if (type.equals("0")){
                count = -1;
            }
            if(json.size()>0){
                for(int i=0;i<json.size();i++){
                    // 遍历 jsonarray 数组，把每一个对象转成 json 对象
                    JSONObject job = json.getJSONObject(i);
                    // 得到 每个对象中的属性值
                    String days = job.get("days").toString();
                    String flat = job.get("flat").toString();
                    if("2".equals(flat)){
                        count++;
                    }
                    String leaveTypeId = job.get("leaveTypeId").toString();
                    String start = job.get("start").toString();
                    String end = job.get("end").toString();
                    String stratDate = start.split(",")[0];
                    String stratType = start.split(",")[1];
                    String endDate = end.split(",")[0];
                    String endType = end.split(",")[1];
                    if(stratDate==null || stratType==null || endDate == null || endType==null){
                        j.setErrorCode(ErrorCode.code_2004);
                        j.setMsg("参数异常");
                        j.put("data", "");
                        return j;
                    }
                    LeaveDetail leaveDetail = new LeaveDetail();
                    leaveDetail.setDays(days);
                    leaveDetail.setFlat(flat);
                    leaveDetail.setLeaveType(new LeaveType(leaveTypeId));
                    leaveDetail.setStartTime(sdf.parse(stratDate));
                    leaveDetail.setEndTime(sdf.parse(endDate));
                    leaveDetail.setStartType(stratType);
                    leaveDetail.setEndType(endType);
                    leaveDetailList.add(leaveDetail);
                }
            }
            String str = "";
            String strInfo = "";
            leaveApply.setLeaveDetailList(leaveDetailList);
            String validate=leaveApplyService.validate(leaveApply);
            if(!"".equals(validate)){
                    j.setMsg("请假时间存在重复");//时间重叠
            }else{
                if (count==0) {
                    leaveApply.setStatus("2");
                    str = leaveApplyService.saveBorrow(leaveApply);
                    strInfo = "请假";
                }else if(count == -1){
                    leaveApply.setStatus("6");
                    str = leaveApplyService.saveBack(leaveApply);
                    strInfo = "销假";
                }else{
                    leaveApply.setStatus("10");
                    str = leaveApplyService.extendSave(leaveApply);//保存
                    strInfo = "续假";
                }
                j.setMsg(str);
            }
            j.getBody().put("id",leaveApply.getId());
            j.setMsg(strInfo+"申请已提交");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("请假/续假/销假申请失败");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"findLeaves"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson findLeaves(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            LeaveApply apply = new LeaveApply();
            WorkStaffBasicInfo workStaffBasicInfo = leaveApplyService.getBasicInfo();
            apply.setStaffId(workStaffBasicInfo.getId());
            List<Map<String,Object>> maps = new ArrayList<>();
            List<LeaveApply> leaveApplies = leaveApplyService.findList(apply);
            if (leaveApplies!=null && leaveApplies.size()!=0) {
                for (LeaveApply leaveApply : leaveApplies) {
                    Map<String,Object> map = new HashMap<>();
                    LeaveDetail detail=new LeaveDetail();
                    detail.setLeaveId(leaveApply.getId());
                    List<LeaveDetail> leaveDetails = leaveDetailService.findList(detail);
                    Set<String> set = new HashSet<>();
                    if (leaveDetails!=null && leaveApplies.size()!=0){
                        for (LeaveDetail leaveDetail :leaveDetails){
                            LeaveType leaveType = leaveDetail.getLeaveType();
                            String leaveTypeName = leaveType.getName();
                            set.add(leaveTypeName);
                        }
                    }
                    String typeName = "";
                    for (String name:set){
                        typeName += name +",";
                    }
                    if (StringUtils.isNotBlank(typeName)){
                        typeName.substring(0,typeName.length() - 1);
                    }
                    maps.add(map);
                    map.put("id",leaveApply.getId());
                    //请假类型
                    map.put("typeName",typeName);
                    //审批状态
                    map.put("status",DictUtils.getDictLabel(leaveApply.getStatus(),"leave_audit",""));
                    //创建时间
                    map.put("createDate",sdfs.format(leaveApply.getCreateDate()));
                }
            }
            j.getBody().put("date",maps);
            j.setMsg("请假列表获取成功");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("数据异常");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"aduitShow"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson aduitShow(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        AjaxJson j = new AjaxJson();
        try {
            Office company = UserUtils.getSelectCompany();
            ApprovalCopy approvalCopy = new ApprovalCopy();
            approvalCopy.setCCId(UserUtils.getUser().getId());
            approvalCopy.setDelFlag("0");
            approvalCopy.setReadFlag("0");

            j.setMsg("获取显示成功");
            j.setErrorCode(ErrorCode.code_1004);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取显示失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"workShow"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson workShow(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        AjaxJson j = new AjaxJson();
        try {
            Office company = UserUtils.getSelectCompany();
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取显示失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"workAuditUsers"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson workAuditUsers(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            //type 1:全平台   2:合同模块 	3:合同归档 	4:项目登记 	5:开票管理
            // 6:退票管理 	7:收入管理 	8:报销管理 	9:月度计划管理 10:案例管理 11:行政管理 12 报告管理13 采购合同管理 14采购管理  15报废管理
            //16借用管理  17 领用管理 18劳动关系管理 19 加班申请 20 出差申请 21外勤申请 22 转正申请 23 职级调整 24 部门调整 25 请假申请
            //26 补卡申请 27 考勤审批
            String type = requestMap.get("type");
            if (StringUtils.isBlank(type)) {
                j.setErrorCode(ErrorCode.code_2004);
                j.setMsg("获取部门负责人失败,参数不能为空");
                j.put("data", "");
            }
            User user = UserUtils.getUser();
            List<User> bmzrs = UserUtils.getByRoleActivityEnname("bmzr",2,user.getOffice().getId(),type,user);
            j.setErrorCode(ErrorCode.code_1004);
            j.put("data",bmzrs);
            j.setMsg("获取部门负责人成功");
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取部门负责人失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    @RequestMapping(value={"dictShow"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson dictShow(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        AjaxJson j = new AjaxJson();
        try {
           List<Map<String,Object>> list = new ArrayList<>();
           Map<String,Object> map1 = new HashMap<>();
           map1.put("type","13");
           map1.put("title","报销申请");
           list.add(map1);
            Map<String,Object> map2 = new HashMap<>();
            map2.put("type","16");
            map2.put("title","合同登记");
           list.add(map2);
            Map<String,Object> map3 = new HashMap<>();
            map3.put("type","21");
            map3.put("title","发票申请");
           list.add(map3);
            /*Map<String,Object> map4 = new HashMap<>();
            map4.put("type","24");
            map4.put("title","请假申请");
           list.add(map4);
            Map<String,Object> map5 = new HashMap<>();
            map5.put("type","25");
            map5.put("title","加班申请");
           list.add(map5);
            Map<String,Object> map6 = new HashMap<>();
            map6.put("type","26");
            map6.put("title","出差申请");
           list.add(map6);
            Map<String,Object> map7 = new HashMap<>();
            map7.put("type","27");
            map7.put("title","用印申请");
           list.add(map7);
            Map<String,Object> map8 = new HashMap<>();
            map8.put("type","28");
            map8.put("title","外出申请");
           list.add(map8);
            Map<String,Object> map9 = new HashMap<>();
            map9.put("type","29");
            map9.put("title","保证金管理");
           list.add(map9);
            Map<String,Object> map10 = new HashMap<>();
            map10.put("type","32");
            map10.put("title","通用审批申请");
           list.add(map10);
            Map<String,Object> map11 = new HashMap<>();
            map11.put("type","33");
            map11.put("title","备用金申请");
           list.add(map11);
            Map<String,Object> map12 = new HashMap<>();
            map12.put("type","34");
            map12.put("title","付款申请");
           list.add(map12);
            Map<String,Object> map13 = new HashMap<>();
            map13.put("type","35");
            map13.put("title","采购申请");
           list.add(map13);
            Map<String,Object> map14 = new HashMap<>();
            map14.put("type","36");
            map14.put("title","绩效自评");
           list.add(map14);
            Map<String,Object> map15 = new HashMap<>();
            map15.put("type","37");
            map15.put("title","报销申请");
           list.add(map15);
           */
            Map<String,Object> map16 = new HashMap<>();
            map16.put("type","38");
            map16.put("title","案例登记");
           list.add(map16);
            Map<String,Object> map17 = new HashMap<>();
            map17.put("type","39");
            map17.put("title","项目登记");
           list.add(map17);
            Map<String,Object> map18 = new HashMap<>();
            map18.put("type","40");
            map18.put("title","退票申请");
           list.add(map18);
            Map<String,Object> map19 = new HashMap<>();
            map19.put("type","41");
            map19.put("title","项目变更");
           list.add(map19);
            Map<String,Object> map20 = new HashMap<>();
            map20.put("type","42");
            map20.put("title","合同归档");
           list.add(map20);
            Map<String,Object> map21 = new HashMap<>();
            map21.put("type","43");
            map21.put("title","合同作废");
           list.add(map21);
            Map<String,Object> map22 = new HashMap<>();
            map22.put("type","44");
            map22.put("title","合同变更");
           list.add(map22);
            Map<String,Object> map23 = new HashMap<>();
            map23.put("type","45");
            map23.put("title","报告申请");
           list.add(map23);
            Map<String,Object> map24 = new HashMap<>();
            map24.put("type","46");
            map24.put("title","报告变更");
           list.add(map24);
            Map<String,Object> map25 = new HashMap<>();
            map25.put("type","47");
            map25.put("title","报告作废");
           list.add(map25);
            Map<String,Object> map26 = new HashMap<>();
            map26.put("type","48");
            map26.put("title","发票变更");
           list.add(map26);
            Map<String,Object> map27 = new HashMap<>();
            map27.put("type","49");
            map27.put("title","退票变更");
           list.add(map27);
            Map<String,Object> map28 = new HashMap<>();
            map28.put("type","50");
            map28.put("title","投标登记");
           list.add(map28);
            Map<String,Object> map29 = new HashMap<>();
            map29.put("type","51");
            map29.put("title","报告归档");
           list.add(map29);
            Map<String,Object> map30 = new HashMap<>();
            map30.put("type","52");
            map30.put("title","收入结算");
           list.add(map30);
            Map<String,Object> map31 = new HashMap<>();
            map31.put("type","53");
            map31.put("title","收入调整");
           list.add(map31);
            Map<String,Object> map32 = new HashMap<>();
            map32.put("type","54");
            map32.put("title","调整作废");
           list.add(map32);
           j.put("data",list);
            Map<String,Object> map33 = new HashMap<>();
            map33.put("type","55");
            map33.put("title","收文申请");
           list.add(map33);
            Map<String,Object> map34 = new HashMap<>();
            map34.put("type","56");
            map34.put("title","行政盖章");
            list.add(map34);
            Map<String,Object> map40 = new HashMap<>();
            map40.put("type","57");
            map40.put("title","采购合同");
            list.add(map40);
            Map<String,Object> map36 = new HashMap<>();
            map36.put("type","58");
            map36.put("title","日常事务");
            list.add(map36);
            Map<String,Object> map37 = new HashMap<>();
            map37.put("type","59");
            map37.put("title","借用申请");
            list.add(map37);
            Map<String,Object> map38 = new HashMap<>();
            map38.put("type","60");
            map38.put("title","归还借用");
            list.add(map38);
            Map<String,Object> map41 = new HashMap<>();
            map41.put("type","61");
            map41.put("title","采购申请");
            list.add(map41);
            Map<String,Object> map35 = new HashMap<>();
            map35.put("type","62");
            map35.put("title","发文申请");
            list.add(map35);
            Map<String,Object> map42 = new HashMap<>();
            map42.put("type","63");
            map42.put("title","报废申请");
            list.add(map42);
            Map<String,Object> map39 = new HashMap<>();
            map39.put("type","64");
            map39.put("title","领用申请");
            list.add(map39);
            Map<String,Object> map43 = new HashMap<>();
            map43.put("type","66");
            map43.put("title","转正申请");
            list.add(map43);
            Map<String,Object> map44 = new HashMap<>();
            map44.put("type","67");
            map44.put("title","劳动关系");
            list.add(map44);
            Map<String,Object> map45 = new HashMap<>();
            map45.put("type","68");
            map45.put("title","部门调转");
            list.add(map45);
            Map<String,Object> map46 = new HashMap<>();
            map46.put("type","69");
            map46.put("title","日常事务");
            list.add(map46);
            Map<String,Object> map47 = new HashMap<>();
            map47.put("type","70");
            map47.put("title","职级调整");
            list.add(map47);
            Map<String,Object> map48 = new HashMap<>();
            map48.put("type","71");
            map48.put("title","离职申请");
            list.add(map48);
            Map<String,Object> map49 = new HashMap<>();
            map49.put("type","72");
            map49.put("title","合同完成");
            list.add(map49);
            Map<String,Object> map50 = new HashMap<>();
            map50.put("type","74");
            map50.put("title","系统预警");
            list.add(map50);
            Map<String,Object> map51 = new HashMap<>();
            map51.put("type","75");
            map51.put("title","加入企业");
            list.add(map51);
            Map<String,Object> map52 = new HashMap<>();
            map52.put("type","76");
            map52.put("title","案例申请");
            list.add(map52);
            Map<String,Object> map53 = new HashMap<>();
            map53.put("type","77");
            map53.put("title","加班申请");
            list.add(map53);
            Map<String,Object> map54 = new HashMap<>();
            map54.put("type","78");
            map54.put("title","出差申请");
            list.add(map54);
            Map<String,Object> map55 = new HashMap<>();
            map55.put("type","79");
            map55.put("title","外勤申请");
            list.add(map55);
            Map<String,Object> map56 = new HashMap<>();
            map56.put("type","80");
            map56.put("title","请假申请");
            list.add(map56);
            Map<String,Object> map58 = new HashMap<>();
            map58.put("type","81");
            map58.put("title","销假申请");
            list.add(map58);
            Map<String,Object> map57 = new HashMap<>();
            map57.put("type","82");
            map57.put("title","续假申请");
            list.add(map57);
            Map<String,Object> map59 = new HashMap<>();
            map59.put("type","83");
            map59.put("title","补卡申请");
            list.add(map59);
            Map<String,Object> map60 = new HashMap<>();
            map60.put("type","84");
            map60.put("title","考勤审批");
            list.add(map60);
           j.put("data",list);
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取显示失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

    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);
            }
        }
        act.setComment("app审批");
        return  act;
    }

    @RequestMapping(value={"leaveType"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson leaveType(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        AjaxJson j = new AjaxJson();
        try {
            LeaveType leaveType=new LeaveType();
            leaveType.setIsEnd("1");
            leaveType.setCompanyId(UserUtils.getSelectCompany().getId());
            leaveType.setState("0");
            List<LeaveType> list = leaveTypeService.findList(leaveType);
            List<LeaveType> newList=new ArrayList<>();
            for(LeaveType leaveType1:list){
                if(!"0".equals(leaveType1.getParentId())){
                        leaveType1.setName(leaveType1.getParentName()+"-"+leaveType1.getName());
                }
                newList.add(leaveType1);
            }
            j.setErrorCode(ErrorCode.code_1004);
            j.put("data",newList);
            j.setMsg("获取假期类型成功");
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取假期类型失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }
    @RequestMapping(value={"holidays"}, method={RequestMethod.GET})
    @ResponseBody
    public AjaxJson holidays(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception
    {
        HashMap<String, String> requestMap = findRequestMap(request);
        AjaxJson j = new AjaxJson();
        try {
            //2018-08-19,1
            String startDate = requestMap.get("startDate");
            String endDate = requestMap.get("endDate");
            String startType = requestMap.get("startType");
            String endType = requestMap.get("endType");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
            Date dBegin = null;
            Date dEnd=null;
            String year=endDate.substring(0,4);
            AjaxJson ajaxJson = new AjaxJson();
            workCalendarService.queryHoliday(year, ajaxJson);
            Map<String, String> map = ajaxJson.getBody();
            String holidays = map.get("holidays");
            if(holidays==null||"".equals(holidays)){
               //未发布法定节假日
                j.setErrorCode(ErrorCode.code_1004);
                j.put("data",-1);
                j.setMsg("未发布法定节假日");
                return j;
            }
            String workdays = map.get("workdays");
            int count = 0;
            try {
                dBegin = sdf.parse(startDate);
                dEnd = sdf.parse(endDate);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            List<Date> lDate = DateUtils.findDates(dBegin, dEnd);
            for (Date d : lDate) {
                System.out.println(sf.format(d));
                if (holidays.contains(sf.format(d))) {
                    continue;
                } else if (workdays.contains(sf.format(d))) {
                    count++;
                } else if (!DateUtils.isWeek(sf.format(d))) {
                    count++;
                }
            }
            double c=count-1;
            if(count!=0){
                if("1".equals(startType) && "1".equals(endType) ){
                   c=c+0.5;
                }else if("1".equals(startType) && "2".equals(endType)){
                   c=c+1;
                }else if("2".equals(startType) && "2".equals(endType)){
                    c=c+0.5;
                } else if("2".equals(startType) && "1".equals(endType)){
                    c=c;
                }
            }else{
                c=0;
            }
            j.setErrorCode(ErrorCode.code_1004);
            j.put("data",c);
            j.setMsg("获取请假天数成功");
        } catch (Exception e) {
            j.setErrorCode(ErrorCode.code_2004);
            j.setMsg("获取请假天数失败");
            j.put("data", "");
            logger.info("---------e:" + e.getMessage());
        }
        return j;
    }

}
