package com.zcloud.service.map.impl;

import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.map.MapEightMapper;
import com.zcloud.service.map.MapEightService;
import com.zcloud.util.Tools;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 说明：实时地图八项工作
 * 作者：luoxiaobao
 * 时间：2022-09-21
 * 官网：www.zcloudchina.com
 */
@Service
@Transactional //开启事物
public class MapEightServiceImpl implements MapEightService {

    @Autowired
    private MapEightMapper mapEightMapper;

    @Override
    public List<String> getCorpinfoIds(PageData pd) {
        String area = pd.getString("AREA");
        if (StringUtils.isNotBlank(area)) {
            String[] ArrayDATA_IDS = area.split(",");
            return mapEightMapper.getCorpinfoIds(ArrayDATA_IDS);
        }
        String gangkou = pd.getString("GANGKOU");
        if (StringUtils.equals("00003", gangkou)) {
            String[] ArrayDATA_IDS = new String[]{"1", "2"};
            return mapEightMapper.getCorpinfoIds(ArrayDATA_IDS);
        }
        return new ArrayList<>();
    }

    @Override
    public Object getEcharts(PageData pd) {
        Map<String, Object> returnMap = new HashMap<>();
        String errInfo = "success";

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        calendar.add(Calendar.DAY_OF_MONTH, -4);
        String dateStr = sdf.format(calendar.getTime());
        List<Map<String, Object>> list = mapEightMapper.getEcharts(pd);
        List<String> clickDate = new ArrayList<>();
        List<String> dhzyCount = new ArrayList<>();
        List<String> dbzyCount = new ArrayList<>();
        List<String> yxgjzyCount = new ArrayList<>();
        List<String> gczyCount = new ArrayList<>();
        List<String> dzzyCount = new ArrayList<>();
        List<String> lsydCount = new ArrayList<>();
        //用于排序，并整理数据
        for (int i = 0; i < 5; i++) {
            for (Map<String, Object> map : list) {
                if (StringUtils.equals(dateStr, map.get("clickDate").toString())) {
                    clickDate.add(map.get("clickDate").toString());
                    dhzyCount.add(map.get("dhzyCount").toString());
                    dbzyCount.add(map.get("dbzyCount").toString());
                    yxgjzyCount.add(map.get("yxgjzyCount").toString());
                    gczyCount.add(map.get("gczyCount").toString());
                    dzzyCount.add(map.get("dzzyCount").toString());
                    lsydCount.add(map.get("lsydCount").toString());
                }
            }
            calendar.add(Calendar.DAY_OF_MONTH, +1);
            dateStr = sdf.format(calendar.getTime());
        }
        List<String> name = new ArrayList<>();
        List<List<String>> date = new ArrayList<>();
        name.add("动火作业");
        date.add(dhzyCount);
        name.add("盲板作业");
        date.add(dbzyCount);
        name.add("有限空间作业");
        date.add(yxgjzyCount);
        name.add("高处作业");
        date.add(gczyCount);
        name.add("吊装作业");
        date.add(dzzyCount);
        name.add("临时用电");
        date.add(lsydCount);
        returnMap.put("clickDate", clickDate);
        returnMap.put("name", name);
        returnMap.put("date", date);
        returnMap.put("result", errInfo);
        return returnMap;
    }

    @Override
    public PageData statisticsHighRiskWorkByState(PageData pd) throws Exception {
        return mapEightMapper.statisticsHighRiskWorkByState(pd);
    }

    @Override
    public List<PageData> listHighRiskWork(Page page) throws Exception {
        return mapEightMapper.realTimeHighRiskWorklistPage(page);
    }

    @Override
    public List<PageData> listAllHighRiskWorkLocation(PageData pd) throws Exception {
        List<PageData> r = new ArrayList<>();
        String typeStr = pd.getString("TYPE");
        //动火
        if (StringUtils.equals(typeStr, "HOTWORK")) {
//            r = mapEightMapper.getHOTWORKHighRiskWorkLocation(pd);
            r = mapEightMapper.getHOTWORKHighRiskWorkLocationCfd(pd);
            //临时用电
        } else if (StringUtils.equals(typeStr, "ELECTRICITY")) {
            r = mapEightMapper.getELECTRICITYHighRiskWorkLocationOrder(pd);
            //盲板
        } else if (StringUtils.equals(typeStr, "BLINDBOARD")) {
            r = mapEightMapper.getBLINDBOARDHighRiskWorkLocationOrder(pd);
            // 高处
        } else if (StringUtils.equals(typeStr, "HIGHWORK")) {
            r = mapEightMapper.getHIGHWORKHighRiskWorkLocationOrder(pd);
            //有限空间
        } else if (StringUtils.equals(typeStr, "CONFINEDSPACE")) {
            r = mapEightMapper.getCONFINEDSPACEHighRiskWorkLocationOrder(pd);
            //吊装
        } else if (StringUtils.equals(typeStr, "HOISTING")) {
            r = mapEightMapper.getHOISTINGHighRiskWorkLocationOrder(pd);
        }
        return r;
    }


    @Override
    public List<PageData> listAll(PageData pd) {
        return mapEightMapper.listAll(pd);
    }

    @Override
    public List<PageData> listAllMeasures(PageData pd) {
        return mapEightMapper.listAllMeasures(pd);
    }


    @Override
    public Map<String, Object> getById(PageData pd) {
        Map<String, Object> map = new HashMap<String, Object>();
        String errInfo = "success";
        String typeStr = pd.getString("TYPE");
        String idStr = pd.getString("id");
        List<PageData> pageDataList = new ArrayList<>();
        if (StringUtils.equals(typeStr, "HOTWORK")) {
            pd.put("HOTWORKAPPLICATION_ID", idStr);
            pd = mapEightMapper.findByIdHOTWORK(pd);
            pd = dianhuo(pd);
            List<PageData> list = mapEightMapper.getList(pd);
            //这里封装前台要的参数
            pd = shenpi(pd, list);
            map.put("measuresList", mapEightMapper.listAllMeasuresHOTWORK(pd));
            map.put("gasList", mapEightMapper.listAllHOTWORK(pd));
            List<PageData> safetymethodrecordList = mapEightMapper.listAllcuoshiHOTWORK(pd);//其它安全措施明细集合
            map.put("safetymethodrecordList", safetymethodrecordList);
            List<PageData> delayedList = mapEightMapper.listAlldelayed(pd);
            map.put("delayedList", delayedList);
        } else if (StringUtils.equals(typeStr, "ELECTRICITY")) {
            pd.put("ELECTRICITY_ID", idStr);
            pd = mapEightMapper.findByIdELECTRICITY(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresELECTRICITY(pd));
        } else if (StringUtils.equals(typeStr, "BLINDBOARD")) {
            pd.put("BLINDBOARD_ID", idStr);
            pd = mapEightMapper.findByIdBLINDBOARD(pd);
            PageData Info = mapEightMapper.findByIdJWD(pd);
            pd.put("TYPE", 105);//盲板位置图
            pd.put("FOREIGN_KEY", pd.getString("BLINDBOARD_ID"));
            List<PageData> ImgList = mapEightMapper.listAllBLINDBOARD(pd);
            map.put("Info", Info);//获取经纬度
            map.put("ImgList", ImgList);
        } else if (StringUtils.equals(typeStr, "HIGHWORK")) {
            pd.put("HIGHWORK_ID", idStr);
            pd = mapEightMapper.findByIdHIGHWORK(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresHIGHWORK(pd));
        } else if (StringUtils.equals(typeStr, "CONFINEDSPACE")) {
            pd.put("CONFINEDSPACE_ID", idStr);
            pd = mapEightMapper.findByIdCONFINEDSPACE(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresCONFINEDSPACE(pd));
            map.put("gasList", mapEightMapper.listAllCONFINEDSPACE(pd));
        } else if (StringUtils.equals(typeStr, "HOISTING")) {
            pd.put("HOISTING_ID", idStr);
            pd = mapEightMapper.findByIdHOISTING(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresHOISTING(pd));
        }
        map.put("pd", pd);
        map.put("result", errInfo);
        return map;
    }

    @Override
    public Object getEchartsOrder(PageData pd) {
        Map<String, Object> returnMap = new HashMap<>();
        String errInfo = "success";

        //根据条件增加参数或减少参数   都没有 直接返回空
        if (StringUtils.isBlank(pd.getString("CORPINFO_ID"))) {
            List<String> ArrayDATA_IDS = getCorpinfoIds(pd);
            if (ArrayDATA_IDS.size() == 0) {
                returnMap.put("result", errInfo);
                return returnMap;
            } else {
                pd.put("ids", ArrayDATA_IDS);
                pd.remove("CORPINFO_ID");
            }
        }

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        calendar.add(Calendar.DAY_OF_MONTH, -4);
        String dateStr = sdf.format(calendar.getTime());
        List<Map<String, Object>> list = mapEightMapper.getEchartsOrder(pd);
        List<String> clickDate = new ArrayList<>();
        List<String> dhzyCount = new ArrayList<>();
        List<String> dbzyCount = new ArrayList<>();
        List<String> yxgjzyCount = new ArrayList<>();
        List<String> gczyCount = new ArrayList<>();
        List<String> dzzyCount = new ArrayList<>();
        List<String> lsydCount = new ArrayList<>();
        List<String> dtzyCount = new ArrayList<>();
        List<String> dlzyCount = new ArrayList<>();
        //用于排序，并整理数据
        for (int i = 0; i < 5; i++) {
            for (Map<String, Object> map : list) {
                if (StringUtils.equals(dateStr, map.get("clickDate").toString())) {
                    clickDate.add(map.get("clickDate").toString());
                    dhzyCount.add(map.get("dhzyCount").toString());
                    dbzyCount.add(map.get("dbzyCount").toString());
                    yxgjzyCount.add(map.get("yxgjzyCount").toString());
                    gczyCount.add(map.get("gczyCount").toString());
                    dzzyCount.add(map.get("dzzyCount").toString());
                    lsydCount.add(map.get("lsydCount").toString());
                    dtzyCount.add(map.get("dtzyCount").toString());
                    dlzyCount.add(map.get("dlzyCount").toString());
                }
            }
            calendar.add(Calendar.DAY_OF_MONTH, +1);
            dateStr = sdf.format(calendar.getTime());
        }
        List<String> name = new ArrayList<>();
        List<List<String>> date = new ArrayList<>();
        name.add("动火作业");
        date.add(dhzyCount);
        name.add("盲板作业");
        date.add(dbzyCount);
        name.add("有限空间作业");
        date.add(yxgjzyCount);
        name.add("高处作业");
        date.add(gczyCount);
        name.add("吊装作业");
        date.add(dzzyCount);
        name.add("临时用电");
        date.add(lsydCount);
        name.add("动土作业");
        date.add(dtzyCount);
        name.add("断路作业");
        date.add(dlzyCount);
        returnMap.put("clickDate", clickDate);
        returnMap.put("name", name);
        returnMap.put("date", date);
        returnMap.put("result", errInfo);
        return returnMap;
    }

    @Override
    public PageData statisticsHighRiskWorkByStateOrder(PageData pd) throws Exception {
        //根据条件增加参数或减少参数   都没有 直接返回空

        return mapEightMapper.statisticsHighRiskWorkByStateOrder(pd);
    }

    @Override
    public List<PageData> listHighRiskWorkOrder(Page page) throws Exception {
        return mapEightMapper.realTimeHighRiskWorklistPageOrder(page);
    }

    @Override
    public List<PageData> listAllHighRiskWorkLocationOrder(PageData pd) throws Exception {
        List<PageData> r = new ArrayList<>();
        String typeStr = pd.getString("TYPE");
        //动火
        if (StringUtils.equals(typeStr, "HOTWORK")) {
            r = mapEightMapper.getHOTWORKHighRiskWorkLocation(pd);
            //临时用电
        } else if (StringUtils.equals(typeStr, "ELECTRICITY")) {
            r = mapEightMapper.getELECTRICITYHighRiskWorkLocationOrder(pd);
            //盲板
        } else if (StringUtils.equals(typeStr, "BLINDBOARD")) {
            r = mapEightMapper.getBLINDBOARDHighRiskWorkLocationOrder(pd);
            // 高处
        } else if (StringUtils.equals(typeStr, "HIGHWORK")) {
            r = mapEightMapper.getHIGHWORKHighRiskWorkLocationOrder(pd);
            //有限空间
        } else if (StringUtils.equals(typeStr, "CONFINEDSPACE")) {
            r = mapEightMapper.getCONFINEDSPACEHighRiskWorkLocationOrder(pd);
            //吊装
        } else if (StringUtils.equals(typeStr, "HOISTING")) {
            r = mapEightMapper.getHOISTINGHighRiskWorkLocationOrder(pd);
            //动土
        } else if (StringUtils.equals(typeStr, "BREAKGROUND")) {
            r = mapEightMapper.getBREAKGROUNDHighRiskWorkLocationOrder(pd);
            //断路
        } else if (StringUtils.equals(typeStr, "CUTROAD")) {
            r = mapEightMapper.getCUTROADHighRiskWorkLocationOrder(pd);
        }
        return r;
    }

    @Override
    public Map<String, Object> getByIdOrder(PageData pd) {
        Map<String, Object> map = new HashMap<String, Object>();
        String errInfo = "success";
        String typeStr = pd.getString("TYPE");
        String idStr = pd.getString("id");
        List<PageData> pageDataList = new ArrayList<>();
        if (StringUtils.equals(typeStr, "HOTWORK")) {
            pd.put("HOTWORKAPPLICATION_ID", idStr);
            pd = mapEightMapper.findByIdHOTWORK(pd);
            pd = dianhuo(pd);
            List<PageData> list = mapEightMapper.getList(pd);
            //这里封装前台要的参数
            pd = shenpi(pd, list);
            map.put("measuresList", mapEightMapper.listAllMeasuresHOTWORK(pd));
            map.put("gasList", mapEightMapper.listAllHOTWORK(pd));
        } else if (StringUtils.equals(typeStr, "ELECTRICITY")) {
            pd.put("ELECTRICITY_ID", idStr);
            pd = mapEightMapper.findByIdELECTRICITYOrder(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresELECTRICITYOrder(pd));
            map.put("gasList", mapEightMapper.listAllGasELECTRICTITYOrder(pd));
            map.put("imgList1", mapEightMapper.findByELECTRICTITYAcceptuserId(pd));
            map.put("imgList", mapEightMapper.findByELECTRICTITYAcceptuserIds(pd));
        } else if (StringUtils.equals(typeStr, "BLINDBOARD")) {
            pd.put("BLINDBOARD_ID", idStr);
            pd = mapEightMapper.findByIdBLINDBOARDOrder(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresBLINDBOARDOrder(pd));
            PageData Info = mapEightMapper.findByIdJWDOrder(pd);
            pd.put("TYPE", 105);//盲板位置图
            pd.put("FOREIGN_KEY", pd.getString("BLINDBOARD_ID"));
            List<PageData> ImgList = mapEightMapper.listAllBLINDBOARD(pd);
            map.put("Info", Info);//获取经纬度
            map.put("ImgList", ImgList);
            map.put("imgList1", mapEightMapper.findByBLINDBOARDAcceptuserId(pd));
            map.put("imgList", mapEightMapper.findByBLINDBOARDAcceptuserIds(pd));
        } else if (StringUtils.equals(typeStr, "HIGHWORK")) {
            pd.put("HIGHWORK_ID", idStr);
            pd = mapEightMapper.findByIdHIGHWORKOrder(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresHIGHWORKOrder(pd));
            map.put("imgList1", mapEightMapper.findByHIGHWORKAcceptuserId(pd));
            map.put("imgList", mapEightMapper.findByHIGHWORKAcceptuserIds(pd));
        } else if (StringUtils.equals(typeStr, "CONFINEDSPACE")) {
            pd.put("CONFINEDSPACE_ID", idStr);
            pd = mapEightMapper.findByIdCONFINEDSPACEOrder(pd);    //根据ID读取
            map.put("measuresList", mapEightMapper.listAllMeasuresCONFINEDSPACEOrder(pd));
            map.put("gasList", mapEightMapper.listAllCONFINEDSPACEOrder(pd));
            map.put("gas", mapEightMapper.findByIdCONFINEDSPACEGasWH(pd));
            map.put("imgList", mapEightMapper.findByIdCONFINEDSPACEAcceptusers(pd));
            map.put("imgList1", mapEightMapper.findByIdCONFINEDSPACEAcceptuser(pd));
        } else if (StringUtils.equals(typeStr, "HOISTING")) {
            pd.put("HOISTING_ID", idStr);
            pd = mapEightMapper.findByIdHOISTINGOrder(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresHOISTINGOrder(pd));
            map.put("imgList1", mapEightMapper.findByHOISTINGAcceptuserId(pd));
            map.put("imgList", mapEightMapper.findByHOISTINGAcceptuserIds(pd));
        } else if (StringUtils.equals(typeStr, "BREAKGROUND")) {
            pd.put("BREAKGROUND_ID", idStr);
            pd = mapEightMapper.findByIdBREAKGROUNDOrder(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresBREAKGROUNDOrder(pd));
            map.put("imgList1", mapEightMapper.findByBREAKGROUNDAcceptuserId(pd));
            map.put("imgList", mapEightMapper.findByBREAKGROUNDAcceptuserIds(pd));
        } else if (StringUtils.equals(typeStr, "CUTROAD")) {
            pd.put("CUTROAD_ID", idStr);
            pd = mapEightMapper.findByIdCUTROADOrder(pd);
            map.put("measuresList", mapEightMapper.listAllMeasuresCUTROADOrder(pd));
            map.put("imgList1", mapEightMapper.findByCUTROADAcceptuserId(pd));
            map.put("imgList", mapEightMapper.findByCUTROADAcceptuserIds(pd));
        }
        map.put("pd", pd);
        map.put("result", errInfo);
        return map;
    }

    private PageData shenpi(PageData pd, List<PageData> list) {
        List<PageData> specialUserList = new ArrayList<>();
        for (PageData userPageData : list) {
            String type = userPageData.get("STATE").toString();
            if ("0".equals(type)) { // 申请办理人
                pd.put("APPLY_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("APPLY_USER_NAME", userPageData.getString("userName"));
                pd.put("APPLY_USER_ID", userPageData.getString("USER_ID"));
            } else if ("1".equals(type)) { // 动火单位确认人
                pd.put("HOT_WORK_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("HOT_WORK_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("HOT_WORK_USER_ID", userPageData.getString("USER_ID"));
                pd.put("HOT_WORK_USER_NAME", userPageData.getString("userName"));
                pd.put("HOT_WORK_USER_PHONE", userPageData.getString("userPhone"));
                pd.put("HOT_WORK_USER_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("HOT_WORK_USER_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("2".equals(type)) { // 项目发包单位
                pd.put("PROJECT_UNIT_LEADER_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("PROJECT_UNIT_LEADER_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("PROJECT_UNIT_LEADER_ID", userPageData.getString("USER_ID"));
                pd.put("PROJECT_UNIT_LEADER_NAME", userPageData.getString("userName"));
                pd.put("PROJECT_UNIT_LEADER_PHONE", userPageData.getString("userPhone"));
                pd.put("PROJECT_UNIT_LEADER_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("PROJECT_UNIT_LEADER_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("3".equals(type)) { // 现场管辖单位负责人
                pd.put("UNIT_LEADER_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("UNIT_LEADER_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("UNIT_LEADER_ID", userPageData.getString("USER_ID"));
                pd.put("UNIT_LEADER_NAME", userPageData.getString("userName"));
                pd.put("UNIT_LEADER_PHONE", userPageData.getString("userPhone"));
                pd.put("UNIT_LEADER_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("UNIT_LEADER_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("4".equals(type)) { //动火许可签发单位负责人
                pd.put("ISSUING_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("ISSUING_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("ISSUING_USER_ID", userPageData.getString("USER_ID"));
                pd.put("ISSUING_USER_NAME", userPageData.getString("userName"));
                pd.put("ISSUING_USER_PHONE", userPageData.getString("userPhone"));
                pd.put("ISSUING_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("ISSUING_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("5".equals(type)) { // 安全总监审批
                pd.put("SAFETY_DIRECTOR_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("SAFETY_DIRECTOR_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("SAFETY_DIRECTOR_USER_ID", userPageData.getString("USER_ID"));
                pd.put("SAFETY_DIRECTOR_USER_NAME", userPageData.getString("userName"));
                pd.put("SAFETY_DIRECTOR_PHONE", userPageData.getString("userPhone"));
                pd.put("SAFETY_DIRECTOR_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("SAFETY_DIRECTOR_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("6".equals(type)) { // 现场负责人接收
                pd.put("SITE_LEADER_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("SITE_LEADER_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("SITE_LEADER_ID", userPageData.getString("USER_ID"));
                pd.put("SITE_LEADER_NAME", userPageData.getString("userName"));
                pd.put("SITE_LEADER_PHONE", userPageData.getString("userPhone"));
                pd.put("SITE_DIRECTOR_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("SITE_DIRECTOR_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("7".equals(type)) { // 动火前
                pd.put("HOT_WORK_PERSON_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("HOT_WORK_PERSON_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("HOT_WORK_PERSON_USER_NAME", userPageData.getString("userName"));
                pd.put("HOT_WORK_PERSON_PHONE", userPageData.getString("userPhone"));
                pd.put("HOT_WORK_PERSON_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("HOT_WORK_PERSON_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("8".equals(type)) { // 现在负责人
                pd.put("PERSON_CONFIRM_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("PERSON_CONFIRM_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("PERSON_CONFIRM_USER_NAME", userPageData.getString("userName"));
                pd.put("PERSON_CONFIRM_PHONE", userPageData.getString("userPhone"));
                pd.put("PERSON_CONFIRM_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("PERSON_CONFIRM_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("9".equals(type)) { // 动火后
                pd.put("HOT_WORK_AFTER_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("HOT_WORK_AFTER_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("HOT_WORK_AFTER_USER_NAME", userPageData.getString("userName"));
                pd.put("HOT_WORK_AFTER_PHONE", userPageData.getString("userPhone"));
                pd.put("HOT_WORK_AFTER_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("HOT_WORK_AFTER_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("10".equals(type)) { // 延时监火
                pd.put("TIME_LAPSE_FIREMAN_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("TIME_LAPSE_FIREMAN_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("TIME_LAPSE_FIREMAN_NAME", userPageData.getString("userName"));
                pd.put("TIME_LAPSE_FIREMAN_PHONE", userPageData.getString("userPhone"));
                pd.put("TIME_LAPSE_FIREMAN_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("TIME_LAPSE_FIREMAN_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("21".equals(type)) { // 动火操作人
                String userName = userPageData.getString("userName2") + ",";
                String oldName = Tools.isEmpty(pd.get("HOT_WORK_OPERATOR_NAME")) ? "" : pd.get("HOT_WORK_OPERATOR_NAME").toString();
                pd.put("HOT_WORK_OPERATOR_NAME", oldName + userName);
            } else if ("22".equals(type)) { // 动火操作人
                pd.put("SUPERVISOR_OF_HOT_WORK_UNIT", userPageData.getString("USER_ID"));
                String userName = userPageData.getString("userName2") + ",";
                String oldName = Tools.isEmpty(pd.get("HOT_WORK_OPERATOR_NAME")) ? "" : pd.get("HOT_WORK_OPERATOR_NAME").toString();
                pd.put("SUPERVISOR_OF_HOT_WORK_UNIT_NAME", oldName + userName);
            } else if ("24".equals(type)) { // 需要气体检测
                pd.put("GAS_TESTING_DEPARTMENT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("GAS_TESTING_DEPARTMENT_NAME", userPageData.getString("deptName"));
                pd.put("GAS_TESTING_USER_ID", userPageData.getString("USER_ID"));
                pd.put("GAS_TESTING_USER_NAME", userPageData.getString("userName"));
                pd.put("GAS_TESTING_USER_PHONE", userPageData.getString("userPhone"));
                pd.put("GAS_TESTING_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("GAS_TESTING_PRINCIPAL_TIME", userPageData.getString("OPERATTIME"));
            } else if ("30".equals(type)) { // 特级动火 动火负责人确认
                pd.put("projectCompetent_DEPT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("projectCompetent_DEPT_NAME", userPageData.getString("deptName"));
                pd.put("projectCompetent_USER_NAME", userPageData.getString("userName"));
                pd.put("projectCompetent_USER_ID", userPageData.getString("USER_ID"));
                pd.put("projectCompetent_PHONE", userPageData.getString("userPhone"));
                pd.put("projectCompetent_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("projectCompetent_TYPE", userPageData.getString("TYPE"));
                // APP回显使用

                pd.put("CHARGECONFIRM_DEPT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("CHARGECONFIRM_DEPT_NAME", userPageData.getString("deptName"));
                pd.put("CHARGECONFIRM_USER_ID", userPageData.getString("USER_ID"));
                pd.put("CHARGECONFIRM_USER_NAME", userPageData.getString("userName"));
                pd.put("CHARGECONFIRM_USER_PHONE", userPageData.getString("userPhone"));
            } else if ("31".equals(type)) { // 特级动火 动火负责人确认
                pd.put("projectSupervisor_DEPT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("projectSupervisor_DEPT_NAME", userPageData.getString("deptName"));
                pd.put("projectSupervisor_USER_NAME", userPageData.getString("userName"));
                pd.put("projectSupervisor_PHONE", userPageData.getString("userPhone"));
                pd.put("projectCompetent_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("projectSupervisor_TYPE", userPageData.getString("TYPE"));
            } else if ("32".equals(type)) { // 特级动火 动火负责人确认
                pd.put("projectPreliminarily_DEPT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("projectPreliminarily_DEPT_NAME", userPageData.getString("deptName"));
                pd.put("projectPreliminarily_USER_NAME", userPageData.getString("userName"));
                pd.put("projectPreliminarily_PHONE", userPageData.getString("userPhone"));
                pd.put("projectPreliminarily_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("projectPreliminarily_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("projectPreliminarily_TYPE", userPageData.getString("TYPE"));
            } else if ("33".equals(type)) { // 特级动火 动火负责人确认
                pd.put("inspectorGeneral_DEPT_ID", userPageData.getString("DEPARTMENT_ID"));
                pd.put("inspectorGeneral_DEPT_NAME", userPageData.getString("deptName"));
                pd.put("inspectorGeneral_USER_NAME", userPageData.getString("userName"));
                pd.put("inspectorGeneral_PHONE", userPageData.getString("userPhone"));
                pd.put("inspectorGeneral_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("inspectorGeneral_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("inspectorGeneral_TYPE", userPageData.getString("TYPE"));
            } else if ("34".equals(type)) { //分公司主要负责人
                pd.put("OFFICE_RESPOMSIBLE_DEPT_NAME", userPageData.getString("REGULATORY_DEPT_NAME"));
                pd.put("OFFICE_RESPOMSIBLE_USER_NAME", userPageData.getString("REGULATORY_USER_NAME"));
                pd.put("OFFICE_RESPOMSIBLE_PHONE", userPageData.getString("userPhone"));
                pd.put("OFFICE_RESPOMSIBLE_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("OFFICE_RESPOMSIBLE_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("OFFICE_RESPOMSIBLE_TYPE", userPageData.getString("TYPE"));
            } else if ("35".equals(type)) { // 特级动火 安全监督部初审
                pd.put("SUPERVISION_DEPARTMENT_DEPT_NAME", userPageData.getString("REGULATORY_DEPT_NAME"));
                pd.put("SUPERVISION_DEPARTMENT_USER_NAME", userPageData.getString("REGULATORY_USER_NAME"));
                pd.put("SUPERVISION_DEPARTMENT_PHONE", userPageData.getString("userPhone"));
                pd.put("SUPERVISION_DEPARTMENT_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("SUPERVISION_DEPARTMENT_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("SUPERVISION_DEPARTMENT_TYPE", userPageData.getString("TYPE"));
            } else if ("36".equals(type)) { // 特级动火 安委会办公室审批
                pd.put("SECURITY_COMMITTEE_DEPT_NAME", userPageData.getString("REGULATORY_DEPT_NAME"));
                pd.put("SECURITY_COMMITTEE_USER_NAME", userPageData.getString("REGULATORY_USER_NAME"));
                pd.put("SECURITY_COMMITTEE_PHONE", userPageData.getString("userPhone"));
                pd.put("SECURITY_COMMITTEE_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("SECURITY_COMMITTEE_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("SECURITY_COMMITTEE_TYPE", userPageData.getString("TYPE"));
            } else if ("37".equals(type)) { // 特级动火 安全总监签批
                pd.put("SAFETY_DIRECTOR_DEPT_NAME", userPageData.getString("REGULATORY_DEPT_NAME"));
                pd.put("SAFETY_DIRECTOR_USER_NAME", userPageData.getString("REGULATORY_USER_NAME"));
                pd.put("SAFETY_DIRECTOR_PHONE", userPageData.getString("userPhone"));
                pd.put("SAFETY_DIRECTOR_PRINCIPAL", userPageData.getString("AUTOGRAPH"));
                pd.put("SAFETY_DIRECTOR_OPERATTIME", userPageData.getString("OPERATTIME"));
                pd.put("SAFETY_DIRECTOR_TYPE", userPageData.getString("TYPE"));
            }
        }
        pd.put("specialUserList", specialUserList);
        return pd;
    }

    private PageData dianhuo(PageData pd) {
        if (StringUtils.isBlank(pd.getString("HOT_WORK_METHOD_NAME"))) {
            String zidian = pd.getString("HOT_WORK_METHOD_ID");
            List<String> shuzu = Arrays.asList(zidian.split(","));
            List<String> wenzi = mapEightMapper.getListDongHuo(shuzu);
            String pinjie = String.join(",", wenzi);
            pd.put("HOT_WORK_METHOD_NAME", pinjie);
        }
        return pd;
    }
}

