package com.malk.tuosi.schedule;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.malk.server.common.McR;
import com.malk.server.dingtalk.DDR;
import com.malk.tuosi.entity.*;
import com.malk.tuosi.mapper.*;
import com.malk.tuosi.service.TBService;
import com.malk.utils.UtilHttp;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.StreamSupport;

@Slf4j
@RestController
@RequestMapping("/scheduleTask")
public class ScheduleTask {
    @Autowired
    private TBService tbService;
    @Autowired
    private ConfirmDesignYearMapper confirmDesignYearMapper;
    @Autowired
    private YearPersonalConfirmMapper yearPersonalConfirmMapper;
    @Autowired
    private EmployeeWeeklyTasksMapper employeeWeeklyTasksMapper;
    @Autowired
    private AnnualSeasonalSampleMapper annualSeasonalSampleMapper;
    @Autowired
    private NewprocessImplementationMapper newprocessImplementationMapper;
    @Autowired
    private DesigndeparttMonthConfirmMapper designdeparttMonthConfirmMapper;

    /*每15分钟定时同步任务状态*/
    @SneakyThrows
    @GetMapping("/renwulist")
//    @Scheduled(cron = "0 */15 * * * ?")
    public McR RenWuList(){
        //计数项目任务
        HashMap header = new HashMap();
        header.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
        McR Token = tbService.AppAccessToken();
        Object token = Token.getData();
        header.put("Authorization","Bearer " + token);
        header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
        header.put("X-Tenant-Type","organization");
        String projectId = "6878b323386fac7ab9dbe5e9";
        String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) null);
        Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
        int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//1450
        //查询项目任务
        HashMap param = new HashMap();
        param.put("pageSize",100);
        ArrayList list = new ArrayList();//分页标全部存在list
        ArrayList<String> allIds = new ArrayList<>();//全部任务id存在allIds
        String pageToken = "";//初始值
        for (int i=0;i<result/100 + 1;i++){
            param.put("pageToken",pageToken);
            String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/query", header, param);
            List<String> batchIds = extractIdsFromJson(doGet1);//提取当前批次的id
            allIds.addAll(batchIds);//添加到总列表
            ObjectMapper mapper = new ObjectMapper();
            String nextPageToken = mapper.readTree(doGet1).get("nextPageToken").asText();
            if (nextPageToken != null && !nextPageToken.trim().isEmpty()) {
                // 不为空，使用nextPageToken
                list.add(nextPageToken);
                pageToken = nextPageToken;
            }else {
                // 为空，不进行处理
            }
        }
        //查询任务详情
        int k =0;
        for (int i = 0; i < allIds.size(); i++) {
            k++;
            HashMap params = new HashMap();
            params.put("taskId",allIds.get(i));
            String doGet2 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header, params);
            String tfsId = new ObjectMapper().readTree(doGet2).get("result").get(0).get("tfsId").asText();//任务状态ID
            String renWuName = new ObjectMapper().readTree(doGet2).get("result").get(0).get("content").asText();//任务名称
            String title = StreamSupport.stream(new ObjectMapper().readTree(doGet2)
                            .get("result").get(0).get("customfields").spliterator(), false)
                    .filter(field -> "689d4ebf343c05fe73700c93".equals(field.get("cfId").asText()))
                    .findFirst()
                    .map(field -> field.get("value").get(0).get("title").asText())
                    .orElse(null);//CRM单据ID
            //搜索项目工作流状态
            HashMap params_A = new HashMap();
            params_A.put("tfsIds",tfsId);
            String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/taskflowstatus/search", header, params_A);
            String name = new ObjectMapper().readTree(doGet3).get("result").get(0).get("name").asText();//当前任务状态
            //调用回传TB的接口更新状态
            HashMap head = new HashMap();
            head.put("crmuserid","620131c2fe8d7eb6b8dfbf76");//TODO：这里不清楚权限，用张昆
            head.put("TargetSystem","CRM");
            HashMap body_B = new HashMap();
            HashMap params_B = new HashMap();
            params_B.put("crmid",title);
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            String currentTime = LocalDateTime.now().format(formatter);
            params_B.put("jssj",currentTime);
            params_B.put("ddzt",name);
            body_B.put("params",params_B);
            String s = UtilHttp.doPost("http://ounuo.ip.raresoft.net:8888/api/dd/selfchange", head, null, body_B);
            System.out.println(k+"-"+ allIds.size());
            log.info("任务名称：{}，任务状态：{}，CRM单据ID：{}，------同步完成",renWuName,name,title);
        }
        log.info("任务同步完毕！");
        return McR.success(result);
    }

    /*额外方法：从项目任务查询的100条任务提取result中所有的id*/
    private static List<String> extractIdsFromJson(String jsonString) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode rootNode = mapper.readTree(jsonString);
        JsonNode resultArray = rootNode.get("result");

        // 预分配100容量（每批大约100条数据）
        List<String> ids = new ArrayList<>(100);

        if (resultArray != null && resultArray.isArray()) {
            for (JsonNode item : resultArray) {
                if (item.has("id")) {
                    String id = item.get("id").asText();
                    ids.add(id);
                }
            }
        }
        return ids;
    }

    /*todo:设计类别年确认情况*/
//    @Scheduled(cron = "0 */15 * * * ?")
    @PostMapping("/confirmDesignYear")
    @SneakyThrows
    McR confirmDesignYear() throws JsonProcessingException {
        //1、统计符合条件的任务个数
        HashMap header = new HashMap();
        header.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
        McR Token = tbService.AppAccessToken();
        Object token = Token.getData();
        header.put("Authorization","Bearer " + token);
        header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
        header.put("X-Tenant-Type","organization");
        HashMap param = new HashMap();
        String q = "cf:691c29c1f8cbae320a1c8e75 != 无 AND cf:691c29c1f8cbae320a1c8e75 != 扩版 AND cf:691c29c1f8cbae320a1c8e75 !=null AND scenarioId = 6878b3d8f40485da4c5f99a2 AND tfsId = 6878b38d6e46cb7d4fec9592 AND cf:687df8813d5081f8c81cf375 = 公司 AND tagId != 68f5840f90efa8d7498bd5e9 AND tagId != 68f58407a89ee3bbe639f85c";
        param.put("q",q);
        String projectId = "6878b323386fac7ab9dbe5e9";
        String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
        Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
        int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//187
        //2、分页查询
        HashMap param1 = new HashMap();
        param1.put("pageSize",100);
        String pageToken = "";//初始值
        for (int i=0;i<result/100 + 1;i++){
            ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
            param1.put("q",q);
            param1.put("pageToken",pageToken);
            String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);
            List<String> batchIds = extractIdsFromJson(doGet1);
            allIds.addAll(batchIds);//添加到总列表
            ObjectMapper mapper = new ObjectMapper();
            String nextPageToken = mapper.readTree(doGet1).get("nextPageToken").asText();
            if (nextPageToken != null && !nextPageToken.trim().isEmpty()) {
                pageToken = nextPageToken;
            }else {
                // 为空，不进行处理
            }
        //3、查询任务详情
            ArrayList errorList = new ArrayList();
            for (int j = 0; j < allIds.size(); j++) {
                HashMap params3 = new HashMap();
                params3.put("taskId", allIds.get(j));
                String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header, params3);
                String taskId = "";//任务id
                String taskName = "";//任务名称
                String designlevel = "";//设计等级
                String tasktype = "确认稿单";//任务类型
                taskId = new ObjectMapper().readTree(doGet3).get("result").get(0).get("id").asText();
                taskName = new ObjectMapper().readTree(doGet3).get("result").get(0).get("content").asText();
                JSONArray customfields = JSON.parseObject(doGet3).getJSONArray("result").getJSONObject(0).getJSONArray("customfields");
                for (int p = 0; p < customfields.size(); p++) {
                    JSONObject field = customfields.getJSONObject(p);
                    String cfId = field.getString("cfId");
                    JSONArray valueArray = field.getJSONArray("value");
                    if (valueArray != null && !valueArray.isEmpty()) {
                        String value = valueArray.getJSONObject(0).getString("title");
                        //根据cfId匹配
                        switch (cfId){
                            case "691c29c1f8cbae320a1c8e75":
                                designlevel = value;
                                break;
                        }
                    }
                }
                /*todo:给实体赋值*/
                ConfirmDesignYear confirmDesignYear = new ConfirmDesignYear();
                confirmDesignYear.setTaskId(taskId);
                confirmDesignYear.setTaskName(taskName);
                confirmDesignYear.setDesignLevel(designlevel);
                confirmDesignYear.setTaskType(tasktype);
        //4、插入数据库
                QueryWrapper<ConfirmDesignYear> queryWrapper = new QueryWrapper<>();
                List<ConfirmDesignYear> confirmDesignYearList = null;
                try {
                    queryWrapper.eq("task_id", taskId);

                    confirmDesignYearList = confirmDesignYearMapper.selectList(queryWrapper);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                UpdateWrapper<ConfirmDesignYear> updateWrapper = new UpdateWrapper<>();
                updateWrapper.eq("task_id", taskId);
                if (confirmDesignYearList != null && confirmDesignYearList.size() > 0) {
                    updateWrapper.set("task_name", taskName);
                    updateWrapper.set("design_level", designlevel);
                    updateWrapper.set("task_type", tasktype);
                    confirmDesignYearMapper.update(null, updateWrapper);
                }else {
                    int insert = confirmDesignYearMapper.insert(confirmDesignYear);
                    Map<String, Object> response = new HashMap<>();
                    if(insert > 0){
                        response.put("success", true);
                        response.put("message", "用户创建成功");
                        response.put("data", "");
                        log.info("任务创建成功，任务名称：{}，任务id：{}", confirmDesignYear.getTaskName(),confirmDesignYear.getTaskId());
                    }
                }

            }

        }

        return McR.success();
    }

    /*todo：本年度个人确认稿数据(人员)*//*todo:确认稿件数量（总数量）*//*todo:同期确认稿数量（时间）*/
//    @Scheduled(cron = "0 */15 * * * ?")
    @PostMapping("/yearPersonalconfirm")
    @SneakyThrows
    McR yearPersonalconfirm(){
        //1、统计符合条件的任务个数
        Map header = new HashMap<>();
        header.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
        McR Token = tbService.AppAccessToken();
        Object token = Token.getData();
        header.put("Authorization","Bearer " + token);
        header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
        header.put("X-Tenant-Type","organization");
        HashMap param = new HashMap();
        String q = "cf:691c29c1f8cbae320a1c8e75 != 无 AND cf:691c29c1f8cbae320a1c8e75 != 扩版 AND cf:691c29c1f8cbae320a1c8e75 !=null AND scenarioId = 6878b3d8f40485da4c5f99a2 AND tfsId = 6878b38d6e46cb7d4fec9592 AND cf:687df8813d5081f8c81cf375 = 公司 AND tagId != 68f5840f90efa8d7498bd5e9 AND tagId != 68f58407a89ee3bbe639f85c";
        param.put("q",q);
        String projectId = "6878b323386fac7ab9dbe5e9";
        String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
        Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
        int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//57
        //2、分页查询
        HashMap param1 = new HashMap();
        param1.put("pageSize",100);
        String pageToken = "";//初始值
        for (int i=0;i<result/100 + 1;i++){
            ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
            param1.put("q",q);
            param1.put("pageToken",pageToken);
            String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);
            List<String> batchIds = extractIdsFromJson(doGet1);
            allIds.addAll(batchIds);//添加到总列表
            ObjectMapper mapper = new ObjectMapper();
            String nextPageToken = mapper.readTree(doGet1).get("nextPageToken").asText();
            if (nextPageToken != null && !nextPageToken.trim().isEmpty()) {
                pageToken = nextPageToken;
            }else {
                // 为空，不进行处理
            }
            //3、查询任务详情
            String deadline = "";//完成时间
            String deadlineTime = "";
            for (int j = 0; j < allIds.size(); j++) {
                String taskId1 = allIds.get(j);
                HashMap params3 = new HashMap();
                //补充：查询任务前先看下这个是否是新版本的工作流
                String doneGet = UtilHttp.doGet("https://open.teambition.com/api/v3/task/" + taskId1 + "/node/list", header, new HashMap());
                JSONObject response = JSON.parseObject(doneGet);
                JSONArray resultArray = response.getJSONArray("result");
                String targetId = "68ff1fa5935b53b5d64ecb6a";//【确认稿单的工作流节点：确认工艺等级完成(6)】
                String targetId_deadline = "6875c736476bc6384b458cfc";//【完成时间节点】

                for (int k = 0; k < resultArray.size(); k++) {
                    JSONObject node = resultArray.getJSONObject(k);
//                    if(targetId_deadline.equals(node.getString("id"))){
//                        deadline = node.getString("accomplished");
//                    }
                    if (targetId.equals(node.getString("id"))) {

                        for(int k1 = 0; k1 < resultArray.size(); k1++){
                            JSONObject node1 = resultArray.getJSONObject(k1);
                            if(targetId_deadline.equals(node1.getString("id"))){
                                deadline = node1.getString("accomplished");
                                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
                                SimpleDateFormat defaultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                //【时间转换】TB中获取的时间为UTC：世界标准时间，在标准时间上加上8小时，即东八区时间，也就是北京时间。
                                String timeStr = deadline.replace("Z", " UTC");
                                try {
                                    Date zhuangtaiDate = format.parse(timeStr);
                                    deadlineTime = defaultFormat.format(zhuangtaiDate);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                        params3.put("taskId", allIds.get(j));
                        String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header, params3);
                        String taskId = "";//任务id
                        String taskName = "";//任务名称
                        String designPerson = "";//设计人员
                        Integer coefficient = null;//系数
                        String customerName = "";//客户名称
                        String designlevel = "";//设计等级
                        taskId = new ObjectMapper().readTree(doGet3).get("result").get(0).get("id").asText();
                        taskName = new ObjectMapper().readTree(doGet3).get("result").get(0).get("content").asText();
                        JSONArray customfields = JSON.parseObject(doGet3).getJSONArray("result").getJSONObject(0).getJSONArray("customfields");
                        for (int p = 0; p < customfields.size(); p++) {
                            JSONObject field = customfields.getJSONObject(p);
                            String cfId = field.getString("cfId");
                            JSONArray valueArray = field.getJSONArray("value");
                            if (valueArray != null && !valueArray.isEmpty()) {
                                String value = valueArray.getJSONObject(0).getString("title");
                                //根据cfId匹配
                                switch (cfId){
                                    case "691c29c1f8cbae320a1c8e75":
                                        designlevel = value;
                                        break;
                                    case "687df3b60ae1530fa2704499":
                                        customerName = value;
                                        break;
                                    case "695deb1a3fbe995aeeb1b590":
                                        designPerson = value;
                                        break;
                                }
                            }
                        }
                        /*todo:给实体赋值*/
                        YearPersonalConfirm yearPersonalConfirm = new YearPersonalConfirm();
                        yearPersonalConfirm.setTaskId(taskId);
                        yearPersonalConfirm.setTaskName(taskName);
                        yearPersonalConfirm.setDesignPerson(designPerson);
                        if("一级设计".equals(designlevel)){
                            coefficient = 5;
                        }else if("二级设计".equals(designlevel)){
                            coefficient = 3;
                        }else if("三级设计".equals(designlevel)){
                            coefficient = 1;
                        }else if("四级设计".equals(designlevel)){
                            coefficient = 0;
                        }
                        yearPersonalConfirm.setCoefficient(coefficient);
                        yearPersonalConfirm.setCustomerName(customerName);
                        yearPersonalConfirm.setDesignLevel(designlevel);
                        yearPersonalConfirm.setDeadline(deadlineTime);
                        //4、插入数据库
                        QueryWrapper<YearPersonalConfirm> queryWrapper = new QueryWrapper<>();
                        List<YearPersonalConfirm> YearPersonalConfirmList = null;
                        try {
                            queryWrapper.eq("task_id", taskId);

                            YearPersonalConfirmList = yearPersonalConfirmMapper.selectList(queryWrapper);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        UpdateWrapper<YearPersonalConfirm> updateWrapper = new UpdateWrapper<>();
                        updateWrapper.eq("task_id", taskId);
                        if (YearPersonalConfirmList != null && YearPersonalConfirmList.size() > 0) {
                            updateWrapper.set("task_name", taskName);
                            updateWrapper.set("design_person", designPerson);
                            updateWrapper.set("coefficient", coefficient);
                            updateWrapper.set("customer_name", customerName);
                            updateWrapper.set("design_level", designlevel);
                            updateWrapper.set("deadline",deadlineTime);
                            yearPersonalConfirmMapper.update(null, updateWrapper);
                        }else {
                            int insert = yearPersonalConfirmMapper.insert(yearPersonalConfirm);
                            Map<String, Object> response1 = new HashMap<>();
                            if(insert > 0){
                                response1.put("success", true);
                                response1.put("message", "用户创建成功");
                                response1.put("data", "");
                                log.info("任务创建成功，任务名称：{}，任务id：{}", yearPersonalConfirm.getTaskName(),yearPersonalConfirm.getTaskId());
                            }
                        }

                    }
                }

            }

        }
        return McR.success();
    }


    /*todo:员工每周任务*/
    @PostMapping("/employeeWeeklyTasks")
    @SneakyThrows
    McR employeeWeeklyTasks(){
        //1、统计符合条件的任务个数
        Map header = new HashMap<>();
        header.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
        McR Token = tbService.AppAccessToken();
        Object token = Token.getData();
        header.put("Authorization","Bearer " + token);
        header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
        header.put("X-Tenant-Type","organization");
        HashMap param = new HashMap();
        String q = "cf:691c29c1f8cbae320a1c8e75 != 无 AND cf:691c29c1f8cbae320a1c8e75 != 扩版 AND scenarioId = 6878b39a27ae5f3cac355fb9 AND tfsId = 6878b384d3c6329fa3728bc5 AND cf:687df8813d5081f8c81cf375 = 公司 AND tagId != 68f5840f90efa8d7498bd5e9 AND tagId != 68f58407a89ee3bbe639f85c";
        param.put("q",q);
        String projectId = "6878b323386fac7ab9dbe5e9";
        String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
        Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
        int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//8
        //2、分页查询
        HashMap param1 = new HashMap();
        param1.put("pageSize",100);
        String pageToken = "";//初始值
        for (int i=0;i<result/100 + 1;i++) {
            ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
            param1.put("q", q);
            param1.put("pageToken", pageToken);
            String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);
            List<String> batchIds = extractIdsFromJson(doGet1);
            allIds.addAll(batchIds);//添加到总列表
            ObjectMapper mapper = new ObjectMapper();
            String nextPageToken = mapper.readTree(doGet1).get("nextPageToken").asText();
            if (nextPageToken != null && !nextPageToken.trim().isEmpty()) {
                pageToken = nextPageToken;
            } else {
                // 为空，不进行处理
            }
            //3、查询任务详情
            String deadlineTime_START = "";
            String deadlineTime_END = "";
            for (int j = 0; j < allIds.size(); j++) {
                String taskId1 = allIds.get(j);
                HashMap params3 = new HashMap();
                //补充：查询任务前先看下这个是否是新版本的工作流
                String doneGet = UtilHttp.doGet("https://open.teambition.com/api/v3/task/" + taskId1 + "/node/list", header, new HashMap());
                JSONObject response = JSON.parseObject(doneGet);
                JSONArray resultArray = response.getJSONArray("result");
                String targetId = "6875f58cf512415e5944c652";//【设计单的工作流节点：设计接单（1）】
                for (int k = 0; k < resultArray.size(); k++) {
                    JSONObject node = resultArray.getJSONObject(k);
                    if (targetId.equals(node.getString("id"))) {
                        params3.put("taskId", allIds.get(j));
                        String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header, params3);
                        String taskId = "";//任务id
                        String taskName = "";//任务名称
                        String manager = "";//负责人
                        String time_start = "";//开始时间
                        String time_end = "";//结束时间
                        String task_type = "设计单";//任务类型
                        String status = "";//是否完成
                        time_start = node.getString("startDate");
                        time_end = node.getString("dueDate");
                        status = node.getString("status");
                        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
                        SimpleDateFormat defaultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        //【时间转换】TB中获取的时间为UTC：世界标准时间，在标准时间上加上8小时，即东八区时间，也就是北京时间。
                        String timeStr = time_start.replace("Z", " UTC");
                        String timeStr_A = time_end.replace("Z", " UTC");
                        try {
                            Date zhuangtaiDate = format.parse(timeStr);
                            Date zhuangtaiDate_A = format.parse(timeStr_A);
                            deadlineTime_START = defaultFormat.format(zhuangtaiDate);
                            deadlineTime_END = defaultFormat.format(zhuangtaiDate_A);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        taskId = new ObjectMapper().readTree(doGet3).get("result").get(0).get("id").asText();
                        taskName = new ObjectMapper().readTree(doGet3).get("result").get(0).get("content").asText();
                        JSONArray customfields = JSON.parseObject(doGet3).getJSONArray("result").getJSONObject(0).getJSONArray("customfields");
                        for (int p = 0; p < customfields.size(); p++) {
                            JSONObject field = customfields.getJSONObject(p);
                            String cfId = field.getString("cfId");
                            JSONArray valueArray = field.getJSONArray("value");
                            if (valueArray != null && !valueArray.isEmpty()) {
//                                String value = valueArray.getJSONObject(0).getString("title");
                                //根据cfId匹配
                                switch (cfId){
                                    case "66bb1a56f7e230ed6843796e":
                                        for(int a=0;a< valueArray.size();a++){
                                            String value = valueArray.getJSONObject(a).getString("title");
                                            manager = value;
                                            /*todo:给实体赋值*/
                                            EmployeeWeeklyTasks employeeWeeklyTasks = new EmployeeWeeklyTasks();
                                            employeeWeeklyTasks.setTaskId(taskId);
                                            employeeWeeklyTasks.setTaskName(taskName);
                                            employeeWeeklyTasks.setManager(manager);
                                            employeeWeeklyTasks.setTaskType(task_type);
                                            employeeWeeklyTasks.setTimeEnd(deadlineTime_END);
                                            employeeWeeklyTasks.setTimeStart(deadlineTime_START);
                                            employeeWeeklyTasks.setStatus(status);
                                            //4、插入数据库
                                            QueryWrapper<EmployeeWeeklyTasks> queryWrapper = new QueryWrapper<>();
                                            List<EmployeeWeeklyTasks> EmployeeWeeklyTasksList = null;
                                            try {
                                                String finalManager = manager;
                                                queryWrapper.eq("task_id", taskId).and(q1-> q1.eq("manager", finalManager));

                                                EmployeeWeeklyTasksList = employeeWeeklyTasksMapper.selectList(queryWrapper);
                                            } catch (Exception e) {
                                                e.printStackTrace();
                                            }
                                            UpdateWrapper<EmployeeWeeklyTasks> updateWrapper = new UpdateWrapper<>();
                                            updateWrapper.eq("task_id", taskId);
                                            if (EmployeeWeeklyTasksList != null && EmployeeWeeklyTasksList.size() > 0) {
                                                updateWrapper.set("task_name", taskName);
                                                updateWrapper.set("manager", manager);
                                                updateWrapper.set("time_start", deadlineTime_START);
                                                updateWrapper.set("time_end", deadlineTime_END);
                                                updateWrapper.set("task_type", task_type);
                                                updateWrapper.set("status",status);
                                                employeeWeeklyTasksMapper.update(null, updateWrapper);
                                            }else {
                                                int insert = employeeWeeklyTasksMapper.insert(employeeWeeklyTasks);
                                                Map<String, Object> response1 = new HashMap<>();
                                                if(insert > 0){
                                                    response1.put("success", true);
                                                    response1.put("message", "用户创建成功");
                                                    response1.put("data", "");
                                                    log.info("任务创建成功，任务名称：{}，任务id：{}", employeeWeeklyTasks.getTaskName(),employeeWeeklyTasks.getTaskId());
                                                }
                                            }
                                        }
//                                        manager = value;
                                        break;
                                }
                            }
                        }


                    }
                }

            }
        }

        return McR.success();
    }

    /*todo:年度季节品类打样数量*/
    @PostMapping("/annualSeasonalSample")
    @SneakyThrows
    McR annualSeasonalSample(){
        //1、统计符合条件的任务个数
        Map header = new HashMap<>();
        header.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
        McR Token = tbService.AppAccessToken();
        Object token = Token.getData();
        header.put("Authorization","Bearer " + token);
        header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
        header.put("X-Tenant-Type","organization");
        HashMap param = new HashMap();
        String q = "cf:691c29c1f8cbae320a1c8e75 != 无 AND cf:691c29c1f8cbae320a1c8e75 != 扩版 AND cf:691c29c1f8cbae320a1c8e75 != null AND scenarioId = 6878b3c0669d175c3c6bc679 AND tfsId = 6878b38c6e46cb7d4fec9479 AND cf:687df8813d5081f8c81cf375 = 公司 AND tagId != 68f5840f90efa8d7498bd5e9 AND tagId != 68f58407a89ee3bbe639f85c";
        param.put("q",q);
        String projectId = "6878b323386fac7ab9dbe5e9";
        String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
        Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
        int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//57
        //2、分页查询
        HashMap param1 = new HashMap();
        param1.put("pageSize",100);
        String pageToken = "";//初始值
        for (int i=0;i<result/100 + 1;i++) {
            ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
            param1.put("q", q);
            param1.put("pageToken", pageToken);
            String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);
            List<String> batchIds = extractIdsFromJson(doGet1);
            allIds.addAll(batchIds);//添加到总列表
            ObjectMapper mapper = new ObjectMapper();
            String nextPageToken = mapper.readTree(doGet1).get("nextPageToken").asText();
            if (nextPageToken != null && !nextPageToken.trim().isEmpty()) {
                pageToken = nextPageToken;
            } else {
                // 为空，不进行处理
            }
            //3、查询任务详情
            for (int j = 0; j < allIds.size(); j++) {
                String taskId1 = allIds.get(j);
                HashMap params3 = new HashMap();
                //补充：查询任务前先看下这个是否是新版本的工作流
                String doneGet = UtilHttp.doGet("https://open.teambition.com/api/v3/task/" + taskId1 + "/node/list", header, new HashMap());
                JSONObject response = JSON.parseObject(doneGet);
                JSONArray resultArray = response.getJSONArray("result");
                String targetId = "691a7ca6cf5e007fcba62a05";//【打样机的工作流节点：确认工艺等级完成】
                for (int k = 0; k < resultArray.size(); k++) {
                    JSONObject node = resultArray.getJSONObject(k);
                    if (targetId.equals(node.getString("id"))) {
                        params3.put("taskId", allIds.get(j));
                        String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header, params3);
                        String taskId = "";//任务id
                        String taskName = "";//任务名称
                        String customer = "";//客户
                        String designType = "";//设计类别
                        String designlevel = "";//设计等级
                        taskId = new ObjectMapper().readTree(doGet3).get("result").get(0).get("id").asText();
                        taskName = new ObjectMapper().readTree(doGet3).get("result").get(0).get("content").asText();
                        JSONArray customfields = JSON.parseObject(doGet3).getJSONArray("result").getJSONObject(0).getJSONArray("customfields");
                        for (int p = 0; p < customfields.size(); p++) {
                            JSONObject field = customfields.getJSONObject(p);
                            String cfId = field.getString("cfId");
                            JSONArray valueArray = field.getJSONArray("value");
                            if (valueArray != null && !valueArray.isEmpty()) {
                                String value = valueArray.getJSONObject(0).getString("title");
                                //根据cfId匹配
                                switch (cfId){
                                    case "691c29c1f8cbae320a1c8e75":
                                        designlevel = value;
                                        break;
                                    case "687df3b60ae1530fa2704499":
                                        customer = value;
                                        break;
                                    case "687e0308e3f7ce8174a19cfc":
                                        designType = value;
                                        break;
                                }
                            }
                        }
                        /*todo:给实体赋值*/
                        AnnualSeasonalSample annualSeasonalSample = new AnnualSeasonalSample();
                        annualSeasonalSample.setTaskId(taskId);
                        annualSeasonalSample.setTaskName(taskName);
                        annualSeasonalSample.setCustomer(customer);
                        annualSeasonalSample.setDesignType(designType);
                        annualSeasonalSample.setDesignLevel(designlevel);
                        //4、插入数据库
                        QueryWrapper<AnnualSeasonalSample> queryWrapper = new QueryWrapper<>();
                        List<AnnualSeasonalSample> AnnualSeasonalSampleList = null;
                        try {
                            queryWrapper.eq("task_id", taskId);

                            AnnualSeasonalSampleList = annualSeasonalSampleMapper.selectList(queryWrapper);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        UpdateWrapper<AnnualSeasonalSample> updateWrapper = new UpdateWrapper<>();
                        updateWrapper.eq("task_id", taskId);
                        if (AnnualSeasonalSampleList != null && AnnualSeasonalSampleList.size() > 0) {
                            updateWrapper.set("task_name", taskName);
                            updateWrapper.set("customer", customer);
                            updateWrapper.set("design_type", designType);
                            updateWrapper.set("design_level", designlevel);
                            annualSeasonalSampleMapper.update(null, updateWrapper);
                        }else {
                            int insert = annualSeasonalSampleMapper.insert(annualSeasonalSample);
                            Map<String, Object> response1 = new HashMap<>();
                            if(insert > 0){
                                response1.put("success", true);
                                response1.put("message", "用户创建成功");
                                response1.put("data", "");
                                log.info("任务创建成功，任务名称：{}，任务id：{}", annualSeasonalSample.getTaskName(),annualSeasonalSample.getTaskId());
                            }
                        }
                    }
                }
            }

        }
        return McR.success();
    }

    /*todo:新工艺落地情况*/
    @SneakyThrows
    @PostMapping("/newprocessImplementation")
    McR newprocessImplementation(){
        //1、统计符合条件的任务个数
        Map header = new HashMap<>();
        header.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
        McR Token = tbService.AppAccessToken();
        Object token = Token.getData();
        header.put("Authorization","Bearer " + token);
        header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
        header.put("X-Tenant-Type","organization");
        HashMap param = new HashMap();
        String q = "cf:691c29c1f8cbae320a1c8e75 != 无 AND cf:691c29c1f8cbae320a1c8e75 != 扩版 AND cf:691c29c1f8cbae320a1c8e75 != null AND( (scenarioId = 6878b3d8f40485da4c5f99a2 AND tfsId = 6878b38d6e46cb7d4fec9592) OR (scenarioId = 6878b3c0669d175c3c6bc679 AND tfsId = 6878b38c6e46cb7d4fec9479) )AND cf:687df8813d5081f8c81cf375 = 公司 AND tagId != 68f5840f90efa8d7498bd5e9 AND tagId != 68f58407a89ee3bbe639f85c";
        param.put("q",q);
        String projectId = "6878b323386fac7ab9dbe5e9";
        String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
        Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
        int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//个数
        //2、分页查询
        HashMap param1 = new HashMap();
        param1.put("pageSize",100);
        String pageToken = "";//初始值
        for (int i=0;i<result/100 + 1;i++) {
            ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
            param1.put("q", q);
            param1.put("pageToken", pageToken);
            String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);
            List<String> batchIds = extractIdsFromJson(doGet1);
            allIds.addAll(batchIds);//添加到总列表
            ObjectMapper mapper = new ObjectMapper();
            String nextPageToken = mapper.readTree(doGet1).get("nextPageToken").asText();
            if (nextPageToken != null && !nextPageToken.trim().isEmpty()) {
                pageToken = nextPageToken;
            } else {
                // 为空，不进行处理
            }
            //3、查询任务详情
            for (int j = 0; j < allIds.size(); j++) {
                String taskId1 = allIds.get(j);
                HashMap params3 = new HashMap();
                //补充：查询任务前先看下这个是否是新版本的工作流
                String doneGet = UtilHttp.doGet("https://open.teambition.com/api/v3/task/" + taskId1 + "/node/list", header, new HashMap());
                JSONObject response = JSON.parseObject(doneGet);
                JSONArray resultArray = response.getJSONArray("result");
                String targetId = "689ededdb384ba716895010c";//【确认稿单的工作流节点：确认工艺等级完成（3）】
                String targetId2 = "68ff1fa5935b53b5d64ecb6a";//【确认稿单的工作流节点：确认工艺等级完成（6）】
                String targetId3 = "691a7ca6cf5e007fcba62a05";//【打样机的工作流节点：确认工艺等级完成】
                String targetId4 = "691a7ca6cf5e007fcba62a06";//【打样机的工作流节点：确认工艺等级完成（1）】
                for (int k = 0; k < resultArray.size(); k++) {
                    JSONObject node = resultArray.getJSONObject(k);
                    if (targetId.equals(node.getString("id")) || targetId2.equals(node.getString("id")) ||
                        targetId3.equals(node.getString("id")) || targetId4.equals(node.getString("id"))) {
                        params3.put("taskId", allIds.get(j));
                        String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header, params3);
                        String taskId = "";//任务id
                        String taskName = "";//任务名称
                        String customer = "";//客户
                        String designType = "";//设计类别
                        String designlevel = "";//设计等级
                        taskId = new ObjectMapper().readTree(doGet3).get("result").get(0).get("id").asText();
                        taskName = new ObjectMapper().readTree(doGet3).get("result").get(0).get("content").asText();
                        JSONArray customfields = JSON.parseObject(doGet3).getJSONArray("result").getJSONObject(0).getJSONArray("customfields");
                        for (int p = 0; p < customfields.size(); p++) {
                            JSONObject field = customfields.getJSONObject(p);
                            String cfId = field.getString("cfId");
                            JSONArray valueArray = field.getJSONArray("value");
                            if (valueArray != null && !valueArray.isEmpty()) {
                                String value = valueArray.getJSONObject(0).getString("title");
                                //根据cfId匹配
                                switch (cfId){
                                    case "691c29c1f8cbae320a1c8e75":
                                        designlevel = value;
                                        break;
                                    case "687df3b60ae1530fa2704499":
                                        customer = value;
                                        break;
                                    case "687e0308e3f7ce8174a19cfc":
                                        designType = value;
                                        break;
                                }
                            }
                        }
                        /*todo:给实体赋值*/
                        NewprocessImplementation newprocessImplementation = new NewprocessImplementation();
                        newprocessImplementation.setTaskId(taskId);
                        newprocessImplementation.setTaskName(taskName);
                        newprocessImplementation.setCustomer(customer);
                        newprocessImplementation.setDesignType(designType);
                        newprocessImplementation.setDesignLevel(designlevel);
                        //4、插入数据库
                        QueryWrapper<NewprocessImplementation> queryWrapper = new QueryWrapper<>();
                        List<NewprocessImplementation> NewprocessImplementationList = null;
                        try {
                            queryWrapper.eq("task_id", taskId);

                            NewprocessImplementationList = newprocessImplementationMapper.selectList(queryWrapper);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        UpdateWrapper<NewprocessImplementation> updateWrapper = new UpdateWrapper<>();
                        updateWrapper.eq("task_id", taskId);
                        if (NewprocessImplementationList != null && NewprocessImplementationList.size() > 0) {
                            updateWrapper.set("task_name", taskName);
                            updateWrapper.set("customer", customer);
                            updateWrapper.set("design_type", designType);
                            updateWrapper.set("design_level", designlevel);
                            newprocessImplementationMapper.update(null, updateWrapper);
                        }else {
                            int insert = newprocessImplementationMapper.insert(newprocessImplementation);
                            Map<String, Object> response1 = new HashMap<>();
                            if(insert > 0){
                                response1.put("success", true);
                                response1.put("message", "用户创建成功");
                                response1.put("data", "");
                                log.info("任务创建成功，任务名称：{}，任务id：{}", newprocessImplementation.getTaskName(),newprocessImplementation.getTaskId());
                            }
                        }
                    }
                }
            }
        }
        return McR.success();
    }

    /*todo:设计部月确认稿数量*/
    @SneakyThrows
    @PostMapping("/designdeparttMonthConfirm")
    McR DesigndeparttMonthConfirm(){
        //1、统计符合条件的任务个数
        Map header = new HashMap<>();
        header.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
        McR Token = tbService.AppAccessToken();
        Object token = Token.getData();
        header.put("Authorization","Bearer " + token);
        header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
        header.put("X-Tenant-Type","organization");
        HashMap param = new HashMap();
        String q = "cf:691c29c1f8cbae320a1c8e75 != 无 AND cf:691c29c1f8cbae320a1c8e75 != 扩版 AND cf:691c29c1f8cbae320a1c8e75 != null AND ((scenarioId = 6878b3d8f40485da4c5f99a2 AND tfsId =  689ededd07e4bad72e58f33b) OR (scenarioId = 6878b3d8f40485da4c5f99a2 AND tfsId =  6895659041ab7094b84f7239) OR(scenarioId = 6878b3d8f40485da4c5f99a2 AND tfsId =  6895659041ab7094b84f723b) OR(scenarioId = 6878b3d8f40485da4c5f99a2 AND tfsId =  6878b38d6e46cb7d4fec9592)) AND cf:687df8813d5081f8c81cf375 = 公司 AND tagId != 68f5840f90efa8d7498bd5e9 AND tagId != 68f58407a89ee3bbe639f85c";
        param.put("q",q);
        String projectId = "6878b323386fac7ab9dbe5e9";
        String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
        Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
        int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//个数
        //2、分页查询
        HashMap param1 = new HashMap();
        param1.put("pageSize",100);
        String pageToken = "";//初始值
        for (int i=0;i<result/100 + 1;i++) {
            ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
            param1.put("q", q);
            param1.put("pageToken", pageToken);
            String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);
            List<String> batchIds = extractIdsFromJson(doGet1);
            allIds.addAll(batchIds);//添加到总列表
            ObjectMapper mapper = new ObjectMapper();
            String nextPageToken = mapper.readTree(doGet1).get("nextPageToken").asText();
            if (nextPageToken != null && !nextPageToken.trim().isEmpty()) {
                pageToken = nextPageToken;
            } else {
                // 为空，不进行处理
            }
            //3、查询任务详情
            String deadlineTime_END = "";
            for (int j = 0; j < allIds.size(); j++) {
                String taskId1 = allIds.get(j);
                HashMap params3 = new HashMap();
                //补充：查询任务前先看下这个是否是新版本的工作流
                String doneGet = UtilHttp.doGet("https://open.teambition.com/api/v3/task/" + taskId1 + "/node/list", header, new HashMap());
                JSONObject response = JSON.parseObject(doneGet);
                JSONArray resultArray = response.getJSONArray("result");
                String targetId = "689ededdb384ba716895010c";//【确认稿单的工作流节点：确认工艺等级完成（3）】
                String targetId2 = "68ff1fa5935b53b5d64ecb6a";//【确认稿单的工作流节点：确认工艺等级完成（6）】
                for (int k = 0; k < resultArray.size(); k++) {
                    JSONObject node = resultArray.getJSONObject(k);
                    if (targetId.equals(node.getString("id")) || targetId2.equals(node.getString("id"))) {
                        params3.put("taskId", allIds.get(j));
                        String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header, params3);
                        String taskId = "";//任务id
                        String taskName = "";//任务名称
                        String customer = "";//客户
                        String designType = "";//设计类别
                        String designlevel = "";//设计等级
                        String time_end = "";//结束时间
                        time_end = node.getString("dueDate");
                        if(time_end != null){
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
                            SimpleDateFormat defaultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            //【时间转换】TB中获取的时间为UTC：世界标准时间，在标准时间上加上8小时，即东八区时间，也就是北京时间
                            String timeStr_A = time_end.replace("Z", " UTC");
                            try {
                                Date zhuangtaiDate_A = format.parse(timeStr_A);
                                deadlineTime_END = defaultFormat.format(zhuangtaiDate_A);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        taskId = new ObjectMapper().readTree(doGet3).get("result").get(0).get("id").asText();
                        taskName = new ObjectMapper().readTree(doGet3).get("result").get(0).get("content").asText();
                        JSONArray customfields = JSON.parseObject(doGet3).getJSONArray("result").getJSONObject(0).getJSONArray("customfields");
                        for (int p = 0; p < customfields.size(); p++) {
                            JSONObject field = customfields.getJSONObject(p);
                            String cfId = field.getString("cfId");
                            JSONArray valueArray = field.getJSONArray("value");
                            if (valueArray != null && !valueArray.isEmpty()) {
                                String value = valueArray.getJSONObject(0).getString("title");
                                //根据cfId匹配
                                switch (cfId){
                                    case "691c29c1f8cbae320a1c8e75":
                                        designlevel = value;
                                        break;
                                    case "687df3b60ae1530fa2704499":
                                        customer = value;
                                        break;
                                    case "687e0308e3f7ce8174a19cfc":
                                        designType = value;
                                        break;
                                }
                            }
                        }
                        /*todo:给实体赋值*/
                        DesigndeparttMonthConfirm designdeparttMonthConfirm = new DesigndeparttMonthConfirm();
                        designdeparttMonthConfirm.setTaskId(taskId);
                        designdeparttMonthConfirm.setTaskName(taskName);
                        designdeparttMonthConfirm.setCustomer(customer);
                        designdeparttMonthConfirm.setDesignType(designType);
                        designdeparttMonthConfirm.setDesignLevel(designlevel);
                        designdeparttMonthConfirm.setDateLineEnd(deadlineTime_END);
                        //4、插入数据库
                        QueryWrapper<DesigndeparttMonthConfirm> queryWrapper = new QueryWrapper<>();
                        List<DesigndeparttMonthConfirm> DesigndeparttMonthConfirmList = null;
                        try {
                            queryWrapper.eq("task_id", taskId);

                            DesigndeparttMonthConfirmList = designdeparttMonthConfirmMapper.selectList(queryWrapper);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        UpdateWrapper<DesigndeparttMonthConfirm> updateWrapper = new UpdateWrapper<>();
                        updateWrapper.eq("task_id", taskId);
                        if (DesigndeparttMonthConfirmList != null && DesigndeparttMonthConfirmList.size() > 0) {
                            updateWrapper.set("task_name", taskName);
                            updateWrapper.set("customer", customer);
                            updateWrapper.set("design_type", designType);
                            updateWrapper.set("design_level", designlevel);
                            updateWrapper.set("date_line_end",deadlineTime_END);
                            designdeparttMonthConfirmMapper.update(null, updateWrapper);
                        }else {
                            int insert = designdeparttMonthConfirmMapper.insert(designdeparttMonthConfirm);
                            Map<String, Object> response1 = new HashMap<>();
                            if(insert > 0){
                                response1.put("success", true);
                                response1.put("message", "用户创建成功");
                                response1.put("data", "");
                                log.info("任务创建成功，任务名称：{}，任务id：{}", designdeparttMonthConfirm.getTaskName(),designdeparttMonthConfirm.getTaskId());
                            }
                        }
                    }
                }
            }
        }
        return McR.success();
    }

}
