package com.xxl.job.executor.service.jobhandler;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.jeeplus.domain.*;
import com.jeeplus.flowable.feign.*;
import com.jeeplus.sys.feign.*;
import com.jeeplus.sys.service.dto.UserDTO;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.executor.feign.*;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * XxlJob开发示例（Bean模式）
 * <p>
 * 开发步骤：
 * 1、任务开发：在Spring Bean实例中，开发Job方法；
 * 2、注解配置：为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")"，注解value值对应的是调度中心新建任务的JobHandler属性的值。
 * 3、执行日志：需要通过 "XxlJobHelper.log" 打印执行日志；
 * 4、任务结果：默认任务结果为 "成功" 状态，不需要主动设置；如有诉求，比如设置任务结果为失败，可以通过 "XxlJobHelper.handleFail/handleSuccess" 自主设置任务结果；
 *
 * @author xuxueli 2019-12-11 21:52:51
 */
@Component
public class SampleXxlJob {
    private static Logger logger = LoggerFactory.getLogger ( SampleXxlJob.class );

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("demoJobHandler")
    public void demoJobHandler() throws Exception {
        XxlJobHelper.log ( "XXL-JOB, Hello World." );

        for (int i = 0; i < 5; i++) {
            XxlJobHelper.log ( "beat at:" + i );
            TimeUnit.SECONDS.sleep ( 2 );
        }
        // default success
    }

    /**
     * 4、冻结账号发送短信（Bean模式）
     */
    @XxlJob("freezeAccount")
    public void freezeAccount() throws Exception {
        //每天晚上十二点查询实习生的实习状态为结束，并且报销登记流程走完的实习生用户信息
        String json = SpringUtil.getBean ( HumanFeignApi.class ).getTimeOutReimburseRegisters();
        List<RegistrationInfo> infos = JSON.parseObject(json, new TypeReference<List<RegistrationInfo>>() {});
        //如果没删除则删除
        for (RegistrationInfo info : infos){
            SpringUtil.getBean(IUserApi.class).deleteById(info.getUserId());
        }

    }

    /**
     * Flowable历史数据归档定时任务（Bean模式）
     * 每月执行一次，调用存储过程 sp_flow_archive，将3个月前已结束的流程数据从热表迁移到冷表（归档表）
     * 建议在每月1号凌晨低峰期执行，避免影响业务
     * XXL-Job配置: cron表达式如 "0 0 2 1 * ?"（每月1号凌晨2点）
     */
    @XxlJob("flowArchiveJob")
    public void flowArchiveJob() throws Exception {
        XxlJobHelper.log("开始执行Flowable历史数据归档...");
        try {
            Map result = SpringUtil.getBean(FlowableFeignApi.class).triggerArchive();
            XxlJobHelper.log("归档结果: " + JSON.toJSONString(result));
            if (result != null && Integer.valueOf(200).equals(result.get("code"))) {
                XxlJobHelper.log("Flowable历史数据归档执行成功");
            } else {
                XxlJobHelper.log("Flowable历史数据归档执行失败: " + result);
                XxlJobHelper.handleFail("归档执行失败: " + result);
            }
        } catch (Exception e) {
            XxlJobHelper.log("Flowable历史数据归档执行异常: " + e.getMessage());
            XxlJobHelper.handleFail("归档执行异常: " + e.getMessage());
        }
    }

    //根据实习结束时间修改实习状态并禁止登录
    @XxlJob("updateStatus")
    public void updateStatus(){
        String json = SpringUtil.getBean ( HumanFeignApi.class ).getAllRegister();
        List<RegistrationInfo> infos = JSON.parseObject(json, new TypeReference<List<RegistrationInfo>>() {});
        if (CollectionUtil.isNotEmpty(infos)){
            for (RegistrationInfo info : infos) {
                //修改实习状态
                SpringUtil.getBean ( HumanFeignApi.class ).updatePracticeStatus(info.getId());
                //用户禁止登录
                UserDTO dto = SpringUtil.getBean(IUserApi.class).selectByMobile(info.getMobilePhone());
                if (dto != null){
                    dto.setLoginFlag("0");
                    SpringUtil.getBean(IUserApi.class).updateUser(dto);
                }

            }
        }

    }

    /**
     * 5、正式工冻结账号发送短信（Bean模式）
     */
    @XxlJob("formalAccount")
    public void formalAccount() throws Exception {
        //每天晚上十二点查询实习生的实习状态为结束，并且报销登记流程走完的实习生用户信息
        String json = SpringUtil.getBean ( HumanFeignApi.class ).getFormalUserInfo();
        List<EnrollmentRegistrationInfo> infos = JSON.parseObject(json, new TypeReference<List<EnrollmentRegistrationInfo>>() {});
        //如果没删除则删除
        for (EnrollmentRegistrationInfo info : infos){
            SpringUtil.getBean(IUserApi.class).deleteById(info.getUserId());
            //操作钉钉确认离职
            SpringUtil.getBean(IHumanApi.class).dingConfirmResign(info.getDdId(),info.getMobilePhone());
        }

    }

    /**
     * 评估-保存未关联项目的报告中的报告号
     * @throws Exception
     */
    @XxlJob("reportCancellation")
    public void reportCancellation(){
        //查询未关联项目的报告
        String projectList = SpringUtil.getBean(IAssessApi.class).getProjectList();
        List<ProgramProjectListInfo> infos = JSON.parseObject(projectList, new TypeReference<List<ProgramProjectListInfo>>() {});
        if (CollectionUtil.isNotEmpty(infos)){
            for (ProgramProjectListInfo info : infos) {
                ProgramReportCancellationDTO dto = new ProgramReportCancellationDTO();
                String id = UUID.randomUUID().toString().replace("-", "");
                String number = info.getReportNo().substring(7,11);
                dto.setId(id);
                dto.setCreateById("1");
                dto.setCreateTime(new Date());
                dto.setUpdateById("1");
                dto.setUpdateTime(new Date());
                dto.setInFlag("2");
                dto.setNumber(number);
                dto.setReportNo(info.getReportNo());

                String value = JSON.toJSONString(dto);
                //保存数据
                SpringUtil.getBean(IAssessApi.class).insertReportNo(value);
            }
        }
        //查询已作废的项目
        String list=SpringUtil.getBean(IAssessApi.class).getCancelledProject();
        List<ProgramProjectListInfo> listInfos = JSON.parseObject(list, new TypeReference<List<ProgramProjectListInfo>>() {});
        if (CollectionUtil.isNotEmpty(listInfos)){
            for (ProgramProjectListInfo info : listInfos) {
                ProgramReportCancellationDTO dto = new ProgramReportCancellationDTO();
                String id = UUID.randomUUID().toString().replace("-", "");
                String number = info.getReportNo().substring(7, 11);
                dto.setId(id);
                dto.setCreateById("1");
                dto.setCreateTime(new Date());
                dto.setUpdateById("1");
                dto.setUpdateTime(new Date());
                dto.setInFlag("1");
                dto.setNumber(number);
                dto.setReportNo(info.getReportNo());

                String value = JSON.toJSONString(dto);
                //保存数据
                SpringUtil.getBean(IAssessApi.class).insertReportNo(value);
            }
        }
    }


    /**
     * 6、给所有的财务员工及评估员工发送完善个人信息待办
     */
    @XxlJob("processForUser")
    public void processForUser() throws Exception {
        //查询出所有的评估员工及财务员工的用户信息
        List<UserDTO> allUserInfos = SpringUtil.getBean(IUserApi.class).getAllUserInfos();
        //查询出 入职登记表中所有的有效的数据
        List<String> allUserIdInSuccess = SpringUtil.getBean(HumanFeignApi.class).getAllUserIdInSuccess();
        //两者匹配看是对应否在库中已经登记过信息，如果没有，那么则发送待办
        // 使用流操作过滤掉 allUserIdInSuccess 中存在的用户数据
        List<UserDTO> filteredUsers = allUserInfos.stream()
                .filter(user -> !allUserIdInSuccess.contains(user.getId()))
                .collect(Collectors.toList());


        for (int i=0;i<filteredUsers.size();i++){
            //发起完善个人信息流程
            Map map = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("完善个人信息");
            String procDefId = map.get("id")+"";

            EnrollmentRegistrationInfo report = new EnrollmentRegistrationInfo();
            String id = UUID.randomUUID().toString().replace("-", "");
            report.setId(id);
            report.setCreateById("1");
            report.setCreateTime(new Date());
            report.setUpdateById("1");
            report.setUpdateTime(new Date());
            report.setType("2");
            report.setUserId(filteredUsers.get(i).getId());

            report.setProcessDefinitionId(procDefId);

            String value = JSON.toJSONString(report);
            //先保存数据
            SpringUtil.getBean ( HumanFeignApi.class ).insertIntoEnrollmentRegistrationInfo(value);



            Map<String ,Map<String,String >>  allMap = new HashMap<>();

            String procDefKey = map.get("key")+"";
            String businessTable = "human_resources_enrollment_registration";

            String businessId = id;
            String title = "管理员发起了- [" + filteredUsers.get(i).getName() + "完善个人信息]";

            String assignee = filteredUsers.get(i).getId();
            String recordType = "";

            Map<String, String> newMap = pingMap(procDefId, procDefKey, businessTable, businessId, title, assignee, recordType);
            allMap.put("完善个人信息",newMap);
            SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
        }

    }

    /**
     * 3、检查超过一定期限未提交实习日志且为【实习状态的】实习生信息 发送通知给杨娟（Bean模式）
     */
    @XxlJob("timeOutRegisters")
    public void timeOutRegisters() throws Exception {
        //
        String json = SpringUtil.getBean ( HumanFeignApi.class ).getTimeOutRegisters();
        List<RegistrationInfo> infos = JSON.parseObject(json, new TypeReference<List<RegistrationInfo>>() {});

        for (RegistrationInfo info : infos) {
            //对数据进行发送通知
            String taskName = null;
            String titleStr = null;

            taskName = "实习日志超时提醒";
            titleStr = "实习生-"+ info.getName()+"已超过7天未发起日志填写。";


//            Set<String> noticeUserSet = new HashSet<String>();

//            noticeUserSet.add("1603618333764468738");

            //根据岗位获取人员信息
            String postInfo = SpringUtil.getBean(IPostApi.class).getPostDTOByNameJSON("考勤统计人");
            PostDTOXXL dtoxxl = JSON.parseObject(postInfo, new TypeReference<PostDTOXXL>() {});

            List<String> ids = SpringUtil.getBean(IUserApi.class).findIdListFlowAbleByPostId(dtoxxl.getId());

            List<String> noticeUserList = new ArrayList<String>(ids);
            if(noticeUserList.size()>0){
                MyNoticeList myNotice = new MyNoticeList();
                myNotice.setCreateById("1");
                myNotice.setCreateTime(new Date());
                myNotice.setUpdateById("1");
                myNotice.setUpdateTime(new Date());
                myNotice.setDelFlag(0);
                //根据procInsId获取taskId
                String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(info.getProcInsId());
                myNotice.setTaskId(currentTask);
                myNotice.setDefId(info.getId());
                myNotice.setTitle(titleStr);
                myNotice.setTaskName(taskName);
                myNotice.setLink("结束");
                myNotice.setType("0");
                myNotice.setCreateUser("管理员");
                myNotice.setCreateTime(new Date());

                for (String noticeUserId : noticeUserList) {
                    myNotice.setNoticeId(noticeUserId);
                    String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(info.getCreateById());
                    UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
                    myNotice.setNoticeName(createUser.getName());
                    //根据taskName和通知人 查询重复数量
                    String myNoticeInfo = JSON.toJSONString(myNotice);
                    Map<String,String> map = new HashMap();
                    map.put("myNoticeInfo", myNoticeInfo);
                    String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
                    MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});

                    if(null == repetitionCountBymyNotice){
                        // 生成id
                        String id = UUID.randomUUID().toString().replace("-", "");
                        myNotice.setId(id);
                        myNotice.setRepetitionCount(0);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
                    }else{
                        myNotice.setId(repetitionCountBymyNotice.getId());
                        myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
                    }
                }
            }
        }
    }


    /**
     * 预开票项目未完成关联发送通知
     */
    @XxlJob("noCompleteCollection")
    public void noCompleteCollection() throws Exception {
        //
        String json = SpringUtil.getBean ( FinanceFeignApi.class ).getCompleteCollection();
        List<CwProjectRecordsList> infos = JSON.parseObject(json, new TypeReference<List<CwProjectRecordsList>>() {});

        for (CwProjectRecordsList info : infos) {
            //对数据进行发送通知
            String taskName = null;
            String titleStr = null;

            taskName = "预开票项目未关联";
            titleStr = "预开票项目-"+ info.getProjectName()+"还未完成关联";

            Set<String> noticeUserSet = new HashSet<String>();

            //根据岗位获取人员信息
            String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(info.getCreateById());
            UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});

            if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
                noticeUserSet.add(createUser.getId());
            }
            List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
            if(noticeUserList.size()>0){
                MyNoticeList myNotice = new MyNoticeList();
                myNotice.setCreateById("1");
                myNotice.setCreateTime(new Date());
                myNotice.setUpdateById("1");
                myNotice.setUpdateTime(new Date());
                myNotice.setDelFlag(0);
                //根据procInsId获取taskId
//                String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(info.getProcInsId());
                myNotice.setTaskId("");
                myNotice.setDefId(info.getId());
                myNotice.setTitle(titleStr);
                myNotice.setTaskName(taskName);
                myNotice.setLink("结束");
                myNotice.setType("0");
                myNotice.setCreateUser("管理员");
                myNotice.setCreateTime(new Date());

                for (String noticeUserId : noticeUserList) {
                    myNotice.setNoticeId(noticeUserId);
                    myNotice.setNoticeName(createUser.getName());
                    //根据taskName和通知人 查询重复数量
                    String myNoticeInfo = JSON.toJSONString(myNotice);
                    Map<String,String> map = new HashMap();
                    map.put("myNoticeInfo", myNoticeInfo);
                    String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
                    MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});

                    if(null == repetitionCountBymyNotice){
                        // 生成id
                        String id = UUID.randomUUID().toString().replace("-", "");
                        myNotice.setId(id);
                        myNotice.setRepetitionCount(0);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
                    }else{
                        myNotice.setId(repetitionCountBymyNotice.getId());
                        myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
                    }
                }
            }
        }
    }

    /**
     * 1、评估项目超期定时任务
     */
    @XxlJob("projectArchiveTask")
    public void projectArchiveTask() {
        String json = SpringUtil.getBean ( AssessFeignApi.class ).getOverdueFilingProjectList();
        List<ProgramProjectListInfo> projectList = JSON.parseObject(json, new TypeReference<List<ProgramProjectListInfo>>() {});

//        List<ProgramProjectListInfo> projectList = pgProjectListService.getOverdueFilingProjectList();
        //遍历查询的项目，对所有项目的归档状态进行调整。添加超期归档状态值（over_archive_status：0：未超期；1：已超期），归档状态，若是0或者空值则调整为6。若为其他值则不进行调整
        for (ProgramProjectListInfo info : projectList) {
            //判定是否以发起归档申请（即归档状态是否为空或者0）
            String archiveStatus = "";
            if(StringUtils.isBlank(info.getArchiveStatus()) || "0".equals(info.getArchiveStatus())){
                archiveStatus = "6";
            }else{
                archiveStatus = info.getArchiveStatus();
            }
            //修改报告归档 归档状态信息
            SpringUtil.getBean ( IAssessApi.class ).updateArchiveStatus(info.getArchiveId(),archiveStatus,"1");
            //对数据进行发送通知
            String taskName = null;
            String titleStr = null;

            //如果当前时间大于过期时间
            //Date类的一个方法，如果info.getAdventDateDate()早于 new Date() 返回true，否则返回false
            if(info.getAgreeTime().before(new Date())){
                taskName = "评估-超期归档";
                titleStr = "项目【"+ info.getName()+"】归档已超期。超期时间："+dateToString(info.getAgreeTime()) +"。";
            }else{
                taskName = "评估-超期归档";
                titleStr = "项目【"+ info.getName()+"】即将归档超期。超期时间："+dateToString(info.getAgreeTime());
            }


            //计算两日期之间的天数
            int interval = Integer.parseInt(this.getInterval(info.getAgreeTime(), new Date()));
            if(interval > 0){
                titleStr = titleStr + "已超期：" + interval + "天。请尽快归还";
            }

            Set<String> noticeUserSet = new HashSet<String>();
            if(StringUtils.isNotBlank(info.getCreateBy())){

                String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(info.getCreateBy());
                UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
//                UserDTO createUser = SpringUtil.getBean ( IUserApi.class ).getById(info.getCreateBy());
                if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
                    noticeUserSet.add(createUser.getId());
                }
            }
            List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
            if(noticeUserList.size()>0){
                MyNoticeList myNotice = new MyNoticeList();
                myNotice.setCreateById("1");
                myNotice.setCreateTime(new Date());
                myNotice.setUpdateById("1");
                myNotice.setUpdateTime(new Date());
                myNotice.setDelFlag(0);
                //根据procInsId获取taskId
                String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(info.getProcInsId());
                myNotice.setTaskId(currentTask);
                myNotice.setDefId(info.getProcessDefinitionId());
                myNotice.setTitle(titleStr);
                myNotice.setTaskName(taskName);
                myNotice.setLink("结束");
                myNotice.setType("0");
                myNotice.setCreateUser("管理员");
                myNotice.setCreateTime(new Date());

                for (String noticeUserId : noticeUserList) {
                    myNotice.setNoticeId(noticeUserId);
                    String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(info.getCreateBy());
                    UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
                    myNotice.setNoticeName(createUser.getName());
                    //根据taskName和通知人 查询重复数量
                    String myNoticeInfo = JSON.toJSONString(myNotice);
                    Map<String,String> map = new HashMap();
                    map.put("myNoticeInfo", myNoticeInfo);
                    String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
                    MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});

                    if(null == repetitionCountBymyNotice){
                        // 生成id
                        String id = UUID.randomUUID().toString().replace("-", "");
                        myNotice.setId(id);
                        myNotice.setRepetitionCount(0);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
                    }else{
                        myNotice.setId(repetitionCountBymyNotice.getId());
                        myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
                    }
                }
            }
        }
    }

    /**
     * 查询开票日期未填写的项目信息,提醒用户补充
     */
    @XxlJob("projectInvoiceDateIsNull")
    public void projectInvoiceDateIsNull() {
        //查询开票日期为空的项目
        String json = SpringUtil.getBean ( AssessFeignApi.class ).getInvoiceDateIsNullProjectList();
        List<ProgramProjectListInfo> projectList = JSON.parseObject(json, new TypeReference<List<ProgramProjectListInfo>>() {});
        //遍历项目信息，判断开票日期进行提醒
        for (ProgramProjectListInfo info : projectList) {
            //对数据进行发送通知
            String taskName = "评估-补充开票日期";
            String titleStr = "项目【"+ info.getName()+"】开票日期未填写。";
            Set<String> noticeUserSet = new HashSet<String>();
            if(StringUtils.isNotBlank(info.getCreateBy())){

                String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(info.getCreateBy());
                UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
                if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
                    noticeUserSet.add(createUser.getId());
                }
            }
            List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
            if(noticeUserList.size()>0){
                MyNoticeList myNotice = new MyNoticeList();
                myNotice.setCreateById("1");
                myNotice.setCreateTime(new Date());
                myNotice.setUpdateById("1");
                myNotice.setUpdateTime(new Date());
                myNotice.setDelFlag(0);
                //根据procInsId获取taskId
                String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(info.getProcInsIdArchive());
                Map mapInfo = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("评估-项目归档");
                String procDefId = mapInfo.get("id")+"";
                myNotice.setTaskId(currentTask);
                myNotice.setDefId(procDefId);
                myNotice.setTitle(titleStr);
                myNotice.setTaskName(taskName);
                myNotice.setLink("结束");
                myNotice.setType("0");
                myNotice.setCreateUser("管理员");
                myNotice.setCreateTime(new Date());

                for (String noticeUserId : noticeUserList) {
                    myNotice.setNoticeId(noticeUserId);
                    String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(info.getCreateBy());
                    UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
                    myNotice.setNoticeName(createUser.getName());
                    //根据taskName和通知人 查询重复数量
                    String myNoticeInfo = JSON.toJSONString(myNotice);
                    Map<String,String> map = new HashMap();
                    map.put("myNoticeInfo", myNoticeInfo);
                    String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
                    MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});

                    if(null == repetitionCountBymyNotice){
                        // 生成id
                        String id = UUID.randomUUID().toString().replace("-", "");
                        myNotice.setId(id);
                        myNotice.setRepetitionCount(0);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
                    }else{
                        myNotice.setId(repetitionCountBymyNotice.getId());
                        myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
                    }
                }
            }
        }
    }


    /**
     * 项目-数电发票报销-修改老数据

     */
    @XxlJob("updateCcpmReimbursement")
    public void updateCcpmReimbursement(){
        SpringUtil.getBean ( CcpmFeignApi.class ).updateOldData();
    }


    /**
     * 会计-数电发票报销-修改老数据

     */
    @XxlJob("updateCwReimbursement")
    public void updateCwReimbursement(){
        SpringUtil.getBean ( FinanceFeignApi.class ).updateOldData();
    }


    /**
     * 评估-数电发票报销-修改老数据

     */
    @XxlJob("updateAssessReimbursement")
    public void updateAssessReimbursement(){
        SpringUtil.getBean ( AssessFeignApi.class ).updateOldData();
    }


    /**
     * 中审-数电发票报销-修改老数据

     */
    @XxlJob("updateZsReimbursement")
    public void updateZsReimbursement(){
        SpringUtil.getBean ( ZsFeignApi.class ).updateOldData();
    }


    /**
     * 培训-数电发票报销-修改老数据

     */
    @XxlJob("updateConsultancyReimbursement")
    public void updateConsultancyReimbursement(){
        SpringUtil.getBean ( ConsultancyFeignApi.class ).updateOldData();
    }




    public static String dateToString(Date date) {
        SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd");//日期格式
        return sformat.format(date);
    }

    /**
     * 计算两日期相差天数
     * @param beginDate
     * @param endDate
     * @return
     * @throws Exception
     */
    public String getInterval(Date beginDate, Date endDate){
        long day = 0;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        try {
            if(beginDate != null){
                String begin = sdf.format(beginDate);
                beginDate  = sdf.parse(begin);
            }
            if(endDate!= null){
                String end= sdf.format(endDate);
                endDate= sdf.parse(end);
            }
        } catch (Exception e){
            e.getMessage();
        }
        day = (endDate.getTime()-beginDate.getTime())/(24*60*60*1000);
        return String.valueOf(day);
    }

    /**
     * 2、分片广播任务
     */
    @XxlJob("shardingJobHandler")
    public void shardingJobHandler() throws Exception {

        // 分片参数
        int shardIndex = XxlJobHelper.getShardIndex ( );
        int shardTotal = XxlJobHelper.getShardTotal ( );

        XxlJobHelper.log ( "分片参数：当前分片序号 = {}, 总分片数 = {}", shardIndex, shardTotal );

        // 业务逻辑
        for (int i = 0; i < shardTotal; i++) {
            if ( i == shardIndex ) {
                XxlJobHelper.log ( "第 {} 片, 命中分片开始处理", i );
            } else {
                XxlJobHelper.log ( "第 {} 片, 忽略", i );
            }
        }

    }


    /**
     * 3、命令行任务
     */
    @XxlJob("commandJobHandler")
    public void commandJobHandler() throws Exception {
        String command = XxlJobHelper.getJobParam ( );
        int exitValue = -1;

        BufferedReader bufferedReader = null;
        try {
            // command process
            ProcessBuilder processBuilder = new ProcessBuilder ( );
            processBuilder.command ( command );
            processBuilder.redirectErrorStream ( true );

            Process process = processBuilder.start ( );
            //Process process = Runtime.getRuntime().exec(command);

            BufferedInputStream bufferedInputStream = new BufferedInputStream ( process.getInputStream ( ) );
            bufferedReader = new BufferedReader ( new InputStreamReader ( bufferedInputStream ) );

            // command log
            String line;
            while ((line = bufferedReader.readLine ( )) != null) {
                XxlJobHelper.log ( line );
            }

            // command exit
            process.waitFor ( );
            exitValue = process.exitValue ( );
        } catch (Exception e) {
            XxlJobHelper.log ( e );
        } finally {
            if ( bufferedReader != null ) {
                bufferedReader.close ( );
            }
        }

        if ( exitValue == 0 ) {
            // default success
        } else {
            XxlJobHelper.handleFail ( "command exit value(" + exitValue + ") is failed" );
        }

    }


    /**
     * 4、跨平台Http任务
     * 参数示例：
     * "url: http://www.baidu.com\n" +
     * "method: get\n" +
     * "data: content\n";
     */
    @XxlJob("httpJobHandler")
    public void httpJobHandler() throws Exception {

        // param parse
        String param = XxlJobHelper.getJobParam ( );
        if ( param == null || param.trim ( ).length ( ) == 0 ) {
            XxlJobHelper.log ( "param[" + param + "] invalid." );

            XxlJobHelper.handleFail ( );
            return;
        }

        String[] httpParams = param.split ( "\n" );
        String url = null;
        String method = null;
        String data = null;
        for (String httpParam : httpParams) {
            if ( httpParam.startsWith ( "url:" ) ) {
                url = httpParam.substring ( httpParam.indexOf ( "url:" ) + 4 ).trim ( );
            }
            if ( httpParam.startsWith ( "method:" ) ) {
                method = httpParam.substring ( httpParam.indexOf ( "method:" ) + 7 ).trim ( ).toUpperCase ( );
            }
            if ( httpParam.startsWith ( "data:" ) ) {
                data = httpParam.substring ( httpParam.indexOf ( "data:" ) + 5 ).trim ( );
            }
        }

        // param valid
        if ( url == null || url.trim ( ).length ( ) == 0 ) {
            XxlJobHelper.log ( "url[" + url + "] invalid." );

            XxlJobHelper.handleFail ( );
            return;
        }
        if ( method == null || !Arrays.asList ( "GET", "POST" ).contains ( method ) ) {
            XxlJobHelper.log ( "method[" + method + "] invalid." );

            XxlJobHelper.handleFail ( );
            return;
        }
        boolean isPostMethod = method.equals ( "POST" );

        // request
        HttpURLConnection connection = null;
        BufferedReader bufferedReader = null;
        try {
            // connection
            URL realUrl = new URL ( url );
            connection = (HttpURLConnection) realUrl.openConnection ( );

            // connection setting
            connection.setRequestMethod ( method );
            connection.setDoOutput ( isPostMethod );
            connection.setDoInput ( true );
            connection.setUseCaches ( false );
            connection.setReadTimeout ( 5 * 1000 );
            connection.setConnectTimeout ( 3 * 1000 );
            connection.setRequestProperty ( "connection", "Keep-Alive" );
            connection.setRequestProperty ( "Content-Type", "application/json;charset=UTF-8" );
            connection.setRequestProperty ( "Accept-Charset", "application/json;charset=UTF-8" );

            // do connection
            connection.connect ( );

            // data
            if ( isPostMethod && data != null && data.trim ( ).length ( ) > 0 ) {
                DataOutputStream dataOutputStream = new DataOutputStream ( connection.getOutputStream ( ) );
                dataOutputStream.write ( data.getBytes ( "UTF-8" ) );
                dataOutputStream.flush ( );
                dataOutputStream.close ( );
            }

            // valid StatusCode
            int statusCode = connection.getResponseCode ( );
            if ( statusCode != 200 ) {
                throw new RuntimeException ( "Http Request StatusCode(" + statusCode + ") Invalid." );
            }

            // result
            bufferedReader = new BufferedReader ( new InputStreamReader ( connection.getInputStream ( ), "UTF-8" ) );
            StringBuilder result = new StringBuilder ( );
            String line;
            while ((line = bufferedReader.readLine ( )) != null) {
                result.append ( line );
            }
            String responseMsg = result.toString ( );

            XxlJobHelper.log ( responseMsg );

            return;
        } catch (Exception e) {
            XxlJobHelper.log ( e );

            XxlJobHelper.handleFail ( );
            return;
        } finally {
            try {
                if ( bufferedReader != null ) {
                    bufferedReader.close ( );
                }
                if ( connection != null ) {
                    connection.disconnect ( );
                }
            } catch (Exception e2) {
                XxlJobHelper.log ( e2 );
            }
        }

    }

    /**
     * 5、生命周期任务示例：任务初始化与销毁时，支持自定义相关逻辑；
     */
    @XxlJob(value = "demoJobHandler2", init = "init", destroy = "destroy")
    public void demoJobHandler2() throws Exception {
        XxlJobHelper.log ( "XXL-JOB, Hello World." );
    }

    public void init() {
        logger.info ( "init" );
    }

    public void destroy() {
        logger.info ( "destroy" );
    }




    /**
     * 6、会计暂时未归档提醒定时任务
     * 提前两周、一周分别进行一次提醒
     */
    @XxlJob("notFiledYetReportArchiveListTask")
    public void notFiledYetReportArchiveListTask() {
        SpringUtil.getBean ( FinanceFeignApi.class ).getNotFiledYetList();
    }

    public Map<String,String> pingMap(String procDefId,String procDefKey,String businessTable,
                                      String businessId,String title,String assignee,String recordType){
        Map<String,String> map = new HashMap();
        map.put("procDefId", procDefId);
        map.put("procDefKey", procDefKey);
        map.put("businessTable", businessTable);
        map.put("businessId", businessId);
        map.put("title", title);
        map.put("assignee", assignee);
        map.put("recordType", recordType);
        return map;
    }


    /**
     * 处理电子发票
     * @throws Exception
     */
    @XxlJob("disposeElectronicEngineeringInvoice")
    public void disposeElectronicEngineeringInvoice(){
        //处理评估公司数电发票报销数据
        //String projectList = SpringUtil.getBean(IAssessApi.class).getProjectList();

        SpringUtil.getBean ( FinanceFeignApi.class ).disposeElectronicEngineeringInvoice();
    }




    /**
     * 会计-超期收款发票通知
     */
    @XxlJob("exceedCwFinance")
    public void exceedCwFinance(){
        String exceedCwFinance = SpringUtil.getBean(FinanceFeignApi.class).getExceedCwFinance();
        List<CwFinanceInvoiceList> invoiceList = JSON.parseObject(exceedCwFinance, new TypeReference<List<CwFinanceInvoiceList>>() {});
        for (CwFinanceInvoiceList invoice : invoiceList) {
            //对数据进行发送通知
            String taskName = null;
            String titleStr = null;
            String title = null; //查询是否已经通知时使用的title

            int interval = Integer.parseInt(this.getInterval(invoice.getBillingDate(), new Date()));

            taskName = "超期收款发票";
            if (StringUtils.isNotBlank(invoice.getProgramName())){
                titleStr = "发票编号为"+ invoice.getNo()+"的项目["+invoice.getProgramName()+"],开票金额为:"+invoice.getAccount() +"元,已超期"+interval+"天,请尽快收款";
                title = "发票编号为"+ invoice.getNo()+"的项目["+invoice.getProgramName()+"],开票金额为:"+invoice.getAccount() +"元";
            }else {
                titleStr = "发票编号为"+ invoice.getNo()+",开票金额为:"+invoice.getAccount() +"元,已超期"+interval+"天,请尽快收款";
                title = "发票编号为"+ invoice.getNo()+",开票金额为:"+invoice.getAccount() +"元";
            }
            Set<String> noticeUserSet = new HashSet<String>();

            //获取人员信息
            String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(invoice.getCreateBy().getId());
            UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});

            if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
                noticeUserSet.add(createUser.getId());
            }
            List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
            if(noticeUserList.size()>0){
                MyNoticeList myNotice = new MyNoticeList();
                myNotice.setCreateById("1");
                myNotice.setCreateTime(new Date());
                myNotice.setUpdateById("1");
                myNotice.setUpdateTime(new Date());
                myNotice.setDelFlag(0);
                //根据procInsId获取taskId
//                String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(info.getProcInsId());
                myNotice.setTaskId("");
                myNotice.setDefId(invoice.getId());
                myNotice.setTitle(titleStr);
                myNotice.setTaskName(taskName);
                myNotice.setLink("结束");
                myNotice.setType("0");
                myNotice.setCreateUser("管理员");
                myNotice.setCreateTime(new Date());

                for (String noticeUserId : noticeUserList) {
                    myNotice.setNoticeId(noticeUserId);
                    myNotice.setNoticeName(createUser.getName());
                    myNotice.setTitle(title);
                    //根据taskName和通知人 查询重复数量
                    String myNoticeInfo = JSON.toJSONString(myNotice);
                    Map<String,String> map = new HashMap();
                    map.put("myNoticeInfo", myNoticeInfo);
                    String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getCountBymyNoticeTitle(map);
                    MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});

                    if(null == repetitionCountBymyNotice){
                        // 生成id
                        String id = UUID.randomUUID().toString().replace("-", "");
                        myNotice.setId(id);
                        myNotice.setRepetitionCount(0);
                        myNotice.setTitle(titleStr);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
                    }else{
                        if(null != repetitionCountBymyNotice.getRepetitionCount() && "0".equals(repetitionCountBymyNotice.getType())){
                            myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount() + 1);
                        }else{
                            myNotice.setRepetitionCount(0);
                        }
                        myNotice.setId(repetitionCountBymyNotice.getId());
                        myNotice.setTitle(titleStr);
                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).updateTitleMyNotice2(map);
                    }
                }
            }
        }
    }

    /**
     * 评估-超期收款发票通知
     */
    @XxlJob("exceedFinance")
    public void exceedFinance(){
        String exceedFinance = SpringUtil.getBean(AssessFeignApi.class).getExceedFinance();
        List<FinanceInvoiceList> invoiceList = JSON.parseObject(exceedFinance, new TypeReference<List<FinanceInvoiceList>>() {});
        for (FinanceInvoiceList invoice : invoiceList) {
            //对数据进行发送通知
            String taskName = null;
            String titleStr = null;
            String title = null; //查询是否已经通知时使用的title

            int interval = Integer.parseInt(this.getInterval(invoice.getBillingDate(), new Date()));

            taskName = "评估发票超期收款";
            if (StringUtils.isNotBlank(invoice.getProgramName())){
                titleStr = "发票编号为"+ invoice.getNo()+"的项目["+invoice.getProgramName()+"],开票金额为:"+invoice.getAccount() +"元,已超期"+interval+"天,请尽快收款";
                title = "发票编号为"+ invoice.getNo()+"的项目["+invoice.getProgramName()+"],开票金额为:"+invoice.getAccount() +"元";

            }else {
                titleStr = "发票编号为"+ invoice.getNo()+",开票金额为:"+invoice.getAccount() +"元,已超期"+interval+"天,请尽快收款";
                title = "发票编号为"+ invoice.getNo()+",开票金额为:"+invoice.getAccount() +"元";

            }

            Set<String> noticeUserSet = new HashSet<String>();

            //获取人员信息
            String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(invoice.getCreateBy().getId());
            UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});

            if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
                noticeUserSet.add(createUser.getId());
            }
            List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
            if(noticeUserList.size()>0){
                MyNoticeList myNotice = new MyNoticeList();
                myNotice.setCreateById("1");
                myNotice.setCreateTime(new Date());
                myNotice.setUpdateById("1");
                myNotice.setUpdateTime(new Date());
                myNotice.setDelFlag(0);
                //根据procInsId获取taskId
//                String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(info.getProcInsId());
                myNotice.setTaskId("");
                myNotice.setDefId(invoice.getId());
                myNotice.setTitle(titleStr);
                myNotice.setTaskName(taskName);
                myNotice.setLink("结束");
                myNotice.setType("0");
                myNotice.setCreateUser("管理员");
                myNotice.setCreateTime(new Date());

                for (String noticeUserId : noticeUserList) {
                    myNotice.setNoticeId(noticeUserId);
                    myNotice.setNoticeName(createUser.getName());
                    myNotice.setTitle(title);

                    //根据taskName和通知人 查询重复数量
                    String myNoticeInfo = JSON.toJSONString(myNotice);
                    Map<String,String> map = new HashMap();
                    map.put("myNoticeInfo", myNoticeInfo);
                    String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getCountBymyNoticeTitle(map);
                    MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});

                    if(null == repetitionCountBymyNotice){
                        // 生成id
                        String id = UUID.randomUUID().toString().replace("-", "");
                        myNotice.setId(id);
                        myNotice.setRepetitionCount(0);
                        myNotice.setTitle(titleStr);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
                    }else{
                        if(null != repetitionCountBymyNotice.getRepetitionCount() && "0".equals(repetitionCountBymyNotice.getType())){
                            myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount() + 1);
                        }else{
                            myNotice.setRepetitionCount(0);
                        }
                        myNotice.setId(repetitionCountBymyNotice.getId());
                        myNotice.setTitle(titleStr);

                        myNoticeInfo = JSON.toJSONString(myNotice);
                        map.put("myNoticeInfo", myNoticeInfo);
                        SpringUtil.getBean ( IFlowableApi.class ).updateTitleMyNotice2(map);
                    }
                }
            }
        }
    }


    /**
     * 用户是否超过90天未修改密码
     */
    @XxlJob("exceedUpPassword")
    public void exceedUpPassword(){
        //获取所有的用户信息
        List<UserDTO> allUserInfoNoTenId = SpringUtil.getBean(IUserApi.class).getAllUserInfoNoTenId();
        //将超过90天还未修改密码的用户提示修改密码
        for (UserDTO userDTO : allUserInfoNoTenId) {
            UserDTO dto = new UserDTO();
            dto.setId(userDTO.getId());

            //upPassword为1,判断修改密码时间是否存在,存在则判断是否大于90天,不存在则生成修改密码时间,upPassword为0,则生成修改密码时间
            if (StringUtils.isNotBlank(userDTO.getUpPassword())){
                if (userDTO.getUpPassword().equals("1")){
                    if (ObjectUtils.isNotEmpty(userDTO.getUpdatePasswordDate())) {
                        int interval = Integer.parseInt(this.getInterval(userDTO.getUpdatePasswordDate(), new Date()));
                        if (interval >= 90){
                            dto.setUpPassword("0");
                            SpringUtil.getBean(IUserApi.class).updateUserById(dto);
                        }
                    }else {
                        dto.setUpdatePasswordDate(new Date());
                        SpringUtil.getBean(IUserApi.class).updateUserById(dto);
                    }
                }else {

                    if (ObjectUtils.isEmpty(userDTO.getUpdatePasswordDate())){
                        dto.setUpdatePasswordDate(new Date());
                        SpringUtil.getBean(IUserApi.class).updateUserById(dto);
                    }
                }
            }


        }
    }

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("syncDingTalkInfo")
    public void syncDingTalkInfo() {
        SpringUtil.getBean(IHumanApi.class).syncDingTalkInfo();
    }

    /**
     * 修改会计报告-修改审定金额-按钮是否显示
     */
    @XxlJob("modifyReportEditFlag")
    public void modifyReportEditFlag() {

        SpringUtil.getBean(IUserApi.class).logoutByUserAll();

    }


    /**
     * 用于发票开票获取数电票信息处理
     * 和开票系统相关的定时任务
     */
    @XxlJob("processInvoiceDownloadTasks")
    public void processInvoiceDownloadTasks() {
        try {
            SpringUtil.getBean(IFinanceApi.class).processInvoiceDownloadTasks();
        } catch (Exception e) {
            logger.warn("调用 finance 失败，可能服务不存在", e);
        }
        try {
            SpringUtil.getBean(IAssessApi.class).processInvoiceDownloadTasks();
        } catch (Exception e) {
            logger.warn("调用 assess 失败，可能服务不存在", e);
        }
    }

    /**
     * 用于发票开票红冲定时任务信息处理
     * 和开票系统相关的定时任务
     */
    @XxlJob("processRedInvoiceScheduledTask")
    public void processRedInvoiceScheduledTask() {
        try {
            SpringUtil.getBean(IFinanceApi.class).processRedInvoiceScheduledTask();
        } catch (Exception e) {
            logger.warn("调用 finance 失败，可能服务不存在", e);
        }
        try {
            SpringUtil.getBean(IAssessApi.class).processRedInvoiceScheduledTask();
        } catch (Exception e) {
            logger.warn("调用 assess 失败，可能服务不存在", e);
        }
    }


    /**
     * 用于发票开票时报9998错误时进行重新处理的方法
     * 和开票系统相关的定时任务
     */
    @XxlJob("redInvoiceRetryScheduledTask")
    public void redInvoiceRetryScheduledTask() {
        try {
            SpringUtil.getBean(IFinanceApi.class).redInvoiceRetryScheduledTask();
        } catch (Exception e) {
            logger.warn("调用 finance 失败，可能服务不存在", e);
        }
        try {
            SpringUtil.getBean(IAssessApi.class).redInvoiceRetryScheduledTask();
        } catch (Exception e) {
            logger.warn("调用 assess 失败，可能服务不存在", e);
        }
    }


    /**
     * 评估合同超过3个月未归档自动提醒
     */
    @XxlJob("getThreeMonthsUnarchivedContracts")
    public void getThreeMonthsUnarchivedContracts() {
        try {
            SpringUtil.getBean(IAssessApi.class).getThreeMonthsUnarchivedContracts();
        } catch (Exception e) {
            logger.warn("调用失败，可能服务不存在", e);
        }
    }


    /**
     * 查询即将过期的物资
     */
    @XxlJob("nearExpiryList")
    public void nearExpiryList() {
        try {
            SpringUtil.getBean(IPsiManagementApi.class).nearExpiryList();
        } catch (Exception e) {
            logger.warn("调用失败，可能服务不存在", e);
        }
    }

}
