package com.rongwei.sfcommon.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rongwe.scentity.domian.HiddenDangerTrackDo;
import com.rongwe.scentity.domian.ThemeCheckDo;
import com.rongwe.scentity.domian.ThemeCheckItemDo;
import com.rongwe.scentity.vo.ExportHiddenDangerVo;
import com.rongwei.rwadmincommon.system.domain.SysDictDo;
import com.rongwei.rwadmincommon.system.service.SysDictService;
import com.rongwei.rwcommon.base.BaseDo;
import com.rongwei.rwcommon.base.R;
import com.rongwei.rwcommon.utils.SecurityUtil;
import com.rongwei.rwcommon.utils.StringUtils;
import com.rongwei.safecommon.utils.CXCommonUtils;
import com.rongwei.safecommon.utils.ExportExcelByEasyExcel;
import com.rongwei.sfcommon.sys.dao.DangerousDao;
import com.rongwei.sfcommon.sys.dao.SaveCheckCommonDao;
import com.rongwei.sfcommon.sys.service.SafeCheckSendNotifyService;
import com.rongwei.sfcommon.sys.service.ThemeCheckItemService;
import com.rongwei.sfcommon.sys.service.ThemeCheckService;
import com.rongwei.sfcommon.sys.service.ThemeCheckWorkparkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

import static com.rongwei.safecommon.utils.SaveConstans.COMPANY_MAP;
import static com.rongwei.safecommon.utils.SaveConstans.DEFAULT_SEPARATOR;
import static com.rongwei.safecommon.utils.SaveConstans.DatePattern.DATE_PATTERN_YMD;
import static com.rongwei.safecommon.utils.SaveConstans.DictType.*;
import static com.rongwei.safecommon.utils.SaveConstans.FileSuffix.XLSX;
import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.*;
import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.*;
import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.*;
import static com.rongwei.safecommon.utils.SaveConstans.RoleCode.*;
import static com.rongwei.sfcommon.utils.MlConstants.DANGER_SOURCE_POINTCHECK;

/**
 * SafeCheckSendNotifyServiceImpl class
 *
 * @author XH
 * @since 2023/12/19
 */
@Service
@Slf4j
public class SafeCheckSendNotifyServiceImpl implements SafeCheckSendNotifyService {

    /**
     * 隐患跟踪任务整改提醒内容
     */
    public static final String RECTIFICATION_MAIL_CONTENT = "总编号：【%s】\n 发现时间：【%tF】\n 发现人：【%s】\n 发现项：【%s】\n限整改期：【%tF】";

    /**
     * 隐患跟踪任务验证完成提醒内容
     */
    public static final String VERIFICATION_REMIND_MAIL_CONTENT = "【%s】 已整改完成，请您验证关闭";

    public static final String VERIFICATION_REMIND_TEMP = "总编号:【%s】 【%s】\n";

    /**
     * 隐患跟踪任务验证重新整改内容
     */
    public static final String RECTIFICATE_MAIL_CONTENT = "总编号：【%s】 \n 发现时间：【%tF】 \n 发现人：【%s】 \n 发现项：【%s】 \n 限整改期：【%tF】 \n 整改验证未通过，请您重新整改 ";
    /**
     * 隐患跟踪任务验证完成提醒内容
     */
    public static final String VERIFICATION_SYSTEM_CONTENT = "【%s】 整改确认未通过，请您重新验证";
    /**
     * 隐患跟踪任务验证完成提醒内容
     */
    public static final String AFFIRM_REMIND_MAIL_CONTENT = "【%s】 已验证完成，请您确认关闭";

    @Autowired
    private DangerousDao dangerousDao;

    @Autowired
    private ThemeCheckService themeCheckService;

    @Autowired
    private HiddenDangerTrackServiceImpl hiddenDangerTrackService;

    @Autowired
    private ThemeCheckWorkparkService themeCheckWorkparkService;

    @Autowired
    private ThemeCheckItemService themeCheckItemService;

    @Autowired
    private SaveCheckCommonDao saveCheckCommonDao;

    @Autowired
    private SysDictService sysDictService;


    /**
     * 生产
     * 日常点巡检异常问题提醒 用来区分 消息提醒的角色
     */
    public static final String PRODUCTION = "production";
    /**
     * 维修
     * 日常点巡检异常问题提醒 用来区分 消息提醒的角色
     */
    public static final String MAINTAIN = "maintain";

    @Override
    public void inspectionTasks() {
        // 获取所有待检查的检查任务
        List<ThemeCheckItemDo> prepare = themeCheckItemService.list(new LambdaQueryWrapper<ThemeCheckItemDo>()
                .eq(BaseDo::getDeleted, "0").eq(ThemeCheckItemDo::getCheckstatus, "prepare"));
        if (prepare.isEmpty()) {
            log.debug("暂无待检测的任务");
            return;
        }
        // 获取检查计划id
        List<String> themeCheckId = prepare.stream().map(ThemeCheckItemDo::getThemecheckid).collect(Collectors.toList());
        Collection<ThemeCheckDo> themeCheckDos = themeCheckService.listByIds(themeCheckId);
        // 发送提醒的map
        Map<String, String> sendNotifyMap = new HashMap<>();
        prepare.forEach(themeCheckItemDo -> {
            ThemeCheckDo themeCheckDo = themeCheckDos.stream().filter(info -> info.getId().equals(themeCheckItemDo.getThemecheckid())).findFirst().orElse(null);
            if(themeCheckDo==null){
                return;
            }
            // 任务名称  计划检查时间 区域
            sendNotifyMap.put(String.format(INSPECTION_TASKS_CONTENT,themeCheckDo.getCheckname(),themeCheckDo.getPlanstarttime(),
                            themeCheckDo.getPlanstarttime(),themeCheckItemDo.getCheckworkspart(),themeCheckItemDo.getId()),
                    themeCheckItemDo.getCheckerid());
        });
        sendInspectionTasksNotify(sendNotifyMap);
    }

    /**
     * 危险作业每日处罚提醒
     */
    public void dangerousDailyNotify() {
        List<Map<String, Object>> dangerous = dangerousDao.getDangerousDailyNotify();
        if (dangerous != null) {
            for (Map<String, Object> item : dangerous) {
                String punishPersonnelId = (String) item.get("PUNISHPERSONNELID");
                List<String> personnelIdList = new ArrayList<>();
                personnelIdList.add(punishPersonnelId);
                String jobType = item.get("JOBTYPE") == null ? "" : item.get("JOBTYPE").toString();
                String assignmentTimeStart = item.get("ASSIGNMENTTIMESTART") == null ? "" : item.get("ASSIGNMENTTIMESTART").toString();
                String assignmentTimeEnd = item.get("ASSIGNMENTTIMEEND") == null ? "" : item.get("ASSIGNMENTTIMEEND").toString();
                String penaltyAmount = item.get("PENALTYAMOUNT") == null ? "" : item.get("PENALTYAMOUNT").toString();
                String modifyDate = item.get("MODIFYDATE") == null ? "" : item.get("MODIFYDATE").toString();
                CXCommonUtils.sendNotify(DANGEROUS_TITLE, String.format(DANGEROUS_CONTENT,
                                jobType, assignmentTimeStart, assignmentTimeEnd, penaltyAmount, modifyDate),
                        "", personnelIdList, (String) item.get("ID"), DANGEROUS);
            }
        }
    }

    /**
     * 危险作业处罚提醒
     */
    @Override
    public R sendDangerousTimelyNotify(String id) {
        Map<String, Object> dangerous = dangerousDao.getDangerousNotify(id);
        if (dangerous != null) {
            String punishPersonnelId = (String) dangerous.get("PUNISHPERSONNELID");
            List<String> personnelIdList = new ArrayList<>();
            personnelIdList.add(punishPersonnelId);
            String jobType = dangerous.get("JOBTYPE") == null ? "" : dangerous.get("JOBTYPE").toString();
            String assignmentTimeStart = dangerous.get("ASSIGNMENTTIMESTART") == null ? "" : dangerous.get("ASSIGNMENTTIMESTART").toString();
            String assignmentTimeEnd = dangerous.get("ASSIGNMENTTIMEEND") == null ? "" : dangerous.get("ASSIGNMENTTIMEEND").toString();
            String penaltyAmount = dangerous.get("PENALTYAMOUNT") == null ? "" : dangerous.get("PENALTYAMOUNT").toString();
            String modifyDate = dangerous.get("MODIFYDATE") == null ? "" : dangerous.get("MODIFYDATE").toString();
            CXCommonUtils.sendNotify(DANGEROUS_TITLE, String.format(DANGEROUS_CONTENT,
                            jobType, assignmentTimeStart, assignmentTimeEnd, penaltyAmount, modifyDate),
                    "", personnelIdList, (String) dangerous.get("ID"), DANGEROUS);
        }
        return R.ok();
    }

    /**
     * 检查任务提醒
     */
    public void sendInspectionTasksNotify(Map<String, String> sendNotifyMap) {
        sendNotifyMap.forEach((k, v) -> CXCommonUtils.sendNotify(INSPECTION_TASKS_TITLE, k.split(DEFAULT_SEPARATOR)[0], "",
                Arrays.asList(v), k.split(DEFAULT_SEPARATOR)[1], INSPECTIONTASKS));
    }

    /**
     * 隐患任务提醒
     */
    public void sendDangerTasksNotify(List<HiddenDangerTrackDo> hiddenDangerTrackDos) {
        hiddenDangerTrackDos.forEach((k) -> CXCommonUtils.sendNotify(DANGER_TASKS_TITLE,
                String.format(DANGER_TASKS_CONTENT,k.getWorkshop(),k.getRectificationdate())
                , "",
                new ArrayList<String>() {{
                    add(k.getTrackuserid());
                }}, k.getId(), DANGERTASKS));
    }

    @Override
    public void rectificationSystem() {
        List<HiddenDangerTrackDo> hiddenDangerTrackList = hiddenDangerTrackService.list(new LambdaQueryWrapper<HiddenDangerTrackDo>()
                .eq(BaseDo::getDeleted, 0)
                .eq(HiddenDangerTrackDo::getStatus, 20)
                .isNotNull(HiddenDangerTrackDo::getTrackuserid)
        );
        rectificationNotify(hiddenDangerTrackList);
    }

    @Override
    public void verifySystem() {
        List<HiddenDangerTrackDo> hiddenDangerTrackList = hiddenDangerTrackService.list(new LambdaQueryWrapper<HiddenDangerTrackDo>()
                .eq(BaseDo::getDeleted, 0)
                .eq(HiddenDangerTrackDo::getStatus, 30)
                .isNotNull(HiddenDangerTrackDo::getShopfacilitatorid)
        );
        verifyNotify(hiddenDangerTrackList);
    }

    @Override
    public void affirmSystem() {
        List<HiddenDangerTrackDo> hiddenDangerTrackDos = hiddenDangerTrackService.list(new LambdaQueryWrapper<HiddenDangerTrackDo>()
                .eq(BaseDo::getDeleted, 0)
                .eq(HiddenDangerTrackDo::getStatus, 40)
                .isNotNull(HiddenDangerTrackDo::getSafetypromoterid)
        );
        affirmNotify(hiddenDangerTrackDos);
    }

    @Override
    public R sendBackSystem(Map<String, String> map) {
        String id = map.getOrDefault("id", "");
        if (StringUtils.isBlank(id)) {
            log.error("任务ID为空");
            return R.ok();
        }
        HiddenDangerTrackDo hiddenDangerTrackDo = hiddenDangerTrackService.getById(id);
        if (null == hiddenDangerTrackDo) {
            log.error("无法通过id:{}获取到任务列表", id);
            return R.ok();
        }
        //发送人
        List<String> userId = new ArrayList<>();
        //发送内容
        String context = null;
        //发送标题
        String title = null;
        String state = map.getOrDefault("state", "");
        if (StringUtils.isBlank(state)){
            log.error("状态为空");
            return R.ok();
        }
        //判断发送验证还是整改
        if ("20".equals(state)){
            userId = Arrays.asList(hiddenDangerTrackDo.getTrackuserid().split(","));
            context = String.format(RECTIFICATE_MAIL_CONTENT,hiddenDangerTrackDo.getCode(),
                    hiddenDangerTrackDo.getFindtime(),hiddenDangerTrackDo.getFindusername(),
                    hiddenDangerTrackDo.getHiddendangercontent(),hiddenDangerTrackDo.getRectificationdate());
            title = RECTIFICATION_MAIL_TITLE;

        } else if ("30".equals(state)) {
            userId = Arrays.asList(hiddenDangerTrackDo.getShopfacilitatorid().split(","));
            String verificationRemindTemp = String.format(VERIFICATION_REMIND_TEMP,hiddenDangerTrackDo.getCode(),
                    hiddenDangerTrackDo.getHiddendangercontent());
            context =String.format(VERIFICATION_SYSTEM_CONTENT,verificationRemindTemp);
            title = VERIFICATION_MAIL_TITLE;
        }
        if (userId.size()==0){
            log.error("无法找到接收人！");
        }
        CXCommonUtils.sendNotify(title,
                context,null,userId,hiddenDangerTrackDo.getId(),DANGERTASKS);
        return R.ok();
    }

    @Override
    public R submitSystem(Map<String, String> map) {
        String id = map.getOrDefault("id", "");
        if (StringUtils.isBlank(id)) {
            log.error("任务ID为空");
            return R.ok();
        }
        HiddenDangerTrackDo hiddenDangerTrackDo = hiddenDangerTrackService.getById(id);
        if (null == hiddenDangerTrackDo) {
            log.error("无法通过id:{}获取到任务列表", id);
            return R.ok();
        }
        //发送人
        List<String> userId = new ArrayList<>();
        //发送内容
        String context = null;
        //发送标题
        String title = null;
        String state = map.getOrDefault("state", "");
        if (StringUtils.isBlank(state)){
            log.error("状态为空");
            return R.ok();
        }
        if ("30".equals(state)){
            userId = Arrays.asList(hiddenDangerTrackDo.getShopfacilitatorid().split(","));
            title = VERIFICATION_MAIL_TITLE;
            String format = String.format(VERIFICATION_REMIND_TEMP, hiddenDangerTrackDo.getCode(),
                    hiddenDangerTrackDo.getHiddendangercontent());
            context = String.format(VERIFICATION_REMIND_MAIL_CONTENT, format);
        } else if ("40".equals(state)) {
            userId = Arrays.asList(hiddenDangerTrackDo.getSafetypromoterid().split(","));
            title = AFFIRM_MAIL_TITLE;
            String format = String.format(VERIFICATION_REMIND_TEMP, hiddenDangerTrackDo.getCode(),
                    hiddenDangerTrackDo.getHiddendangercontent());
            context = String.format(AFFIRM_REMIND_MAIL_CONTENT, format);
        }
        if (userId.size() == 0) {
            log.error("无法找到接收人！");
        }
        CXCommonUtils.sendNotify(title,
                context, null, userId, hiddenDangerTrackDo.getId(), DANGERTASKS);
        return R.ok();
    }

    /**
     * 点巡检隐患任务提醒
     *
     * @param map
     * @return
     */
    @Override
    public R hiddenDangerTask() {
        List<HiddenDangerTrackDo> hiddenDangerTrackDos = hiddenDangerTrackService.list(new LambdaQueryWrapper<HiddenDangerTrackDo>()
                .eq(BaseDo::getDeleted, "0")
                .eq(HiddenDangerTrackDo::getSource, "1")
                .eq(HiddenDangerTrackDo::getDangersource, DANGER_SOURCE_POINTCHECK)
                .last(" AND  DATEDIFF(NOW(),FINDTIME) BETWEEN 0 AND 7  "));
        if (hiddenDangerTrackDos.isEmpty()) {
            return R.ok();
        }
        LocalDate date = LocalDate.now(); // 获取当前日期
        DayOfWeek dayOfWeek = date.getDayOfWeek(); // 获取日期对应的星期几
        // 周五发送维修和生产提醒 周三发送生产提醒
        if (dayOfWeek != DayOfWeek.WEDNESDAY && dayOfWeek != DayOfWeek.FRIDAY) {
            return R.ok();
        }
        // 获取数据字典
        List<SysDictDo> dicts = sysDictService.list(new LambdaQueryWrapper<SysDictDo>().eq(BaseDo::getDeleted, "0").in(SysDictDo::getDicttype,
                TASK_SOURCE_TYPE, HIDDEN_DANGER_TYPE, HIDDEN_DANGER_STATUS));
        hiddenDangerTrackDos.forEach(info -> {
            if (StringUtils.isNotBlank(info.getDangersource())) {
                info.setDangersource(dicts.stream().filter(dict -> TASK_SOURCE_TYPE.equals(dict.getDicttype()) &&
                                info.getDangersource().equals(dict.getValue())).map(SysDictDo::getName)
                        .collect(Collectors.joining(",")));
            }

            if (StringUtils.isNotBlank(info.getHiddendangertype())) {
                info.setHiddendangertype(dicts.stream().filter(dict -> HIDDEN_DANGER_TYPE.equals(dict.getDicttype()) &&
                                info.getHiddendangertype().equals(dict.getValue())).map(SysDictDo::getName)
                        .collect(Collectors.joining(",")));
            }

            if (StringUtils.isNotBlank(info.getStatus())) {
                info.setStatus(dicts.stream().filter(dict -> HIDDEN_DANGER_STATUS.equals(dict.getDicttype()) &&
                                info.getStatus().equals(dict.getValue())).map(SysDictDo::getName)
                        .collect(Collectors.joining(",")));
            }
        });

        // 对业务数据按照厂区进行分组
        Map<String, List<HiddenDangerTrackDo>> collect = hiddenDangerTrackDos.stream().collect(Collectors.groupingBy(HiddenDangerTrackDo::getTenantid));
        collect.forEach((k, v) -> {
            // 周三和周五生成 生产提醒维修提醒
            if (DayOfWeek.WEDNESDAY == dayOfWeek) {
                // 生产提醒
                sendNotify(HIDDEN_DANGER_TASK_PRODUCTION, k, v);
            }else{
                // 生产提醒
                sendNotify(HIDDEN_DANGER_TASK_PRODUCTION, k, v);
                // 维修提醒
                sendNotify(HIDDEN_DANGER_TASK_MAINTAIN, k, v);
            }
        });
        return R.ok();
    }

    /**
     * 发送消息提醒
     */
    public void sendNotify(String notifyType, String tenantId, List<HiddenDangerTrackDo> dangerTrackDos) {
        // 已读以往提醒信息
        saveCheckCommonDao.updateNotifyState(notifyType, tenantId);

        /****************************获取提醒人信息*******************************/
        List<String> recipientIds = new ArrayList<>();
        if (HIDDEN_DANGER_TASK_MAINTAIN.equals(notifyType)) {
            // 维修 对应工厂的设备部部长 + 设备部维修主管
            recipientIds = saveCheckCommonDao.getUserIdByRoleCodeAndOrgIdAndTenantId(Arrays.asList(HOED, EDMS), null, tenantId);
        } else {
            // 生产 根据 隐患地点 取对应部门车间的 车间主任、车间维修主管 角色中人员
            List<String> orgId = dangerTrackDos.stream().map(HiddenDangerTrackDo::getDangerworkpark).distinct().collect(Collectors.toList());
            if(!orgId.isEmpty()){
                recipientIds.addAll(saveCheckCommonDao.getUserIdByRoleCodeAndOrgIdAndTenantId(Arrays.asList(WMS, LCZG), orgId, tenantId));
            }
            // 整改状态为“待整改”记录中的 指派跟踪人
            recipientIds.addAll(dangerTrackDos.stream().filter(info -> "待整改".equals(info.getStatus()))
                    .map(HiddenDangerTrackDo::getTrackuserid)
                    .filter(StringUtils::isNotBlank)
                    .distinct()
                    .collect(Collectors.toList()));
        }
        if (recipientIds.isEmpty()) {
            return;
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_PATTERN_YMD);
        // 附件生成
        List<ExportHiddenDangerVo> exportData = dangerTrackDos.stream().map((data) -> {
            ExportHiddenDangerVo exportHiddenDangerVo = new ExportHiddenDangerVo();
            exportHiddenDangerVo.setTenantId(COMPANY_MAP.get(data.getTenantid()));
            exportHiddenDangerVo.setStatus(data.getStatus());
            exportHiddenDangerVo.setCode(data.getCode());
            exportHiddenDangerVo.setHiddendangertype(data.getHiddendangertype());
            exportHiddenDangerVo.setHiddendangercontent(data.getHiddendangercontent());
            exportHiddenDangerVo.setTrackusername(data.getTrackusername());
            exportHiddenDangerVo.setFindUser(data.getFindusername());
            exportHiddenDangerVo.setFindDate(data.getFindtime() == null ? "" : simpleDateFormat.format(data.getFindtime()));
            exportHiddenDangerVo.setRectificationdate(data.getRectificationdate() == null ? "" : simpleDateFormat.format(data.getRectificationdate()));
            exportHiddenDangerVo.setCompletionschedule(data.getCompletionschedule());
            exportHiddenDangerVo.setFinishdate(data.getFinishdate() == null ? "" : simpleDateFormat.format(data.getFinishdate()));
            exportHiddenDangerVo.setDangersource(data.getDangersource());
            return exportHiddenDangerVo;
        }).collect(Collectors.toList());

        // 消息提醒ID
        String notifyId = SecurityUtil.getUUID();

        String fileNameAndId = ExportExcelByEasyExcel.generateExcel("file",WEEK_HIDDEN_DANGER_TASK + simpleDateFormat.format(new Date()) + XLSX ,
                notifyId, exportData, ExportHiddenDangerVo.class);
        if(StringUtils.isBlank(fileNameAndId)){
            return;
        }
        CXCommonUtils.sendNotify(notifyId, tenantId, WEEK_HIDDEN_DANGER_TASK,
                String.format(HIDDEN_DANGER_TASK_CONTENT, dangerTrackDos.size()), fileNameAndId, recipientIds, null,
                notifyType, false);
    }


    /**
     * 隐患任务整改提醒
     *
     * @param hiddenDangerTrackList
     * @return
     * @date 2023/12/20 9:54
     * @author shangmi
     */

    public void rectificationNotify(List<HiddenDangerTrackDo> hiddenDangerTrackList){
        hiddenDangerTrackList.forEach(hiddenDangerTrack -> {
            List<String> userIds = Arrays.asList(hiddenDangerTrack.getTrackuserid().split(","));
            CXCommonUtils.sendNotify(RECTIFICATION_MAIL_TITLE,
                    String.format(RECTIFICATION_MAIL_CONTENT,hiddenDangerTrack.getCode(),hiddenDangerTrack.getFindtime(),
                            hiddenDangerTrack.getFindusername(),hiddenDangerTrack.getHiddendangercontent(),
                            hiddenDangerTrack.getRectificationdate()),null,userIds,hiddenDangerTrack.getId(),DANGERTASKS);
        });

    }


    /**
     * 隐患任务验证提醒
     *
     * @param hiddenDangerTrackList
     * @return
     * @date 2023/12/20 9:54
     * @author shangmi
     *
     */

    public void verifyNotify(List<HiddenDangerTrackDo> hiddenDangerTrackList){
        hiddenDangerTrackList.forEach(hiddenDangerTrack -> {
            List<String> userIds = Arrays.asList(hiddenDangerTrack.getShopfacilitatorid().split(","));
            String format = String.format(VERIFICATION_REMIND_TEMP, hiddenDangerTrack.getCode(), hiddenDangerTrack.getHiddendangercontent());
            CXCommonUtils.sendNotify(VERIFICATION_MAIL_TITLE,
                    String.format(VERIFICATION_REMIND_MAIL_CONTENT,format),null,userIds,hiddenDangerTrack.getId(),DANGERTASKS);
        });

    }

    /**
     * 隐患任务确认提醒
     *
     * @param hiddenDangerTrackList
     * @return
     * @date 2023/12/20 9:54
     * @author shangmi
     *
     */

    public void affirmNotify(List<HiddenDangerTrackDo> hiddenDangerTrackList){
        hiddenDangerTrackList.forEach(hiddenDangerTrack -> {
            List<String> userIds = Arrays.asList(hiddenDangerTrack.getSafetypromoterid().split(","));
            String format = String.format(VERIFICATION_REMIND_TEMP, hiddenDangerTrack.getCode(), hiddenDangerTrack.getHiddendangercontent());
            CXCommonUtils.sendNotify(AFFIRM_MAIL_TITLE,
                    String.format(AFFIRM_REMIND_MAIL_CONTENT,format),null,userIds,hiddenDangerTrack.getId(),DANGERTASKS);
        });

    }
}
