|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.malk.server.common.McR;
|
|
import com.malk.server.common.McR;
|
|
@@ -16,11 +17,10 @@ import com.malk.tuosi.service.TBService;
|
|
|
import com.malk.utils.UtilHttp;
|
|
import com.malk.utils.UtilHttp;
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import lombok.var;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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 org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
@@ -28,6 +28,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
import java.util.stream.StreamSupport;
|
|
import java.util.stream.StreamSupport;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -48,11 +49,13 @@ public class ScheduleTask {
|
|
|
private NewprocessImplementationMapper newprocessImplementationMapper;
|
|
private NewprocessImplementationMapper newprocessImplementationMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DesigndeparttMonthConfirmMapper designdeparttMonthConfirmMapper;
|
|
private DesigndeparttMonthConfirmMapper designdeparttMonthConfirmMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ChangeDocumentSourceMapper changeDocumentSourceMapper;
|
|
|
|
|
|
|
|
/*每15分钟定时同步任务状态*/
|
|
/*每15分钟定时同步任务状态*/
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
@GetMapping("/renwulist")
|
|
@GetMapping("/renwulist")
|
|
|
-// @Scheduled(cron = "0 */15 * * * ?")
|
|
|
|
|
|
|
+ @Scheduled(cron = "0 0 */3 * * ?")
|
|
|
public McR RenWuList(){
|
|
public McR RenWuList(){
|
|
|
//计数项目任务
|
|
//计数项目任务
|
|
|
HashMap header = new HashMap();
|
|
HashMap header = new HashMap();
|
|
@@ -148,7 +151,7 @@ public class ScheduleTask {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*todo:设计类别年确认情况*/
|
|
/*todo:设计类别年确认情况*/
|
|
|
-// @Scheduled(cron = "0 */15 * * * ?")
|
|
|
|
|
|
|
+ @Scheduled(cron = "0 30 3 * * ?")
|
|
|
@PostMapping("/confirmDesignYear")
|
|
@PostMapping("/confirmDesignYear")
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
McR confirmDesignYear() throws JsonProcessingException {
|
|
McR confirmDesignYear() throws JsonProcessingException {
|
|
@@ -161,12 +164,12 @@ public class ScheduleTask {
|
|
|
header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
|
|
header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
|
|
|
header.put("X-Tenant-Type","organization");
|
|
header.put("X-Tenant-Type","organization");
|
|
|
HashMap param = new HashMap();
|
|
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";
|
|
|
|
|
|
|
+ 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 AND created >= 2026-01-01";
|
|
|
param.put("q",q);
|
|
param.put("q",q);
|
|
|
String projectId = "6878b323386fac7ab9dbe5e9";
|
|
String projectId = "6878b323386fac7ab9dbe5e9";
|
|
|
- String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
|
|
|
|
|
|
|
+ String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);//todo:[计数项目任务]
|
|
|
Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
|
|
Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
|
|
|
- int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//187
|
|
|
|
|
|
|
+ int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//23
|
|
|
//2、分页查询
|
|
//2、分页查询
|
|
|
HashMap param1 = new HashMap();
|
|
HashMap param1 = new HashMap();
|
|
|
param1.put("pageSize",100);
|
|
param1.put("pageSize",100);
|
|
@@ -175,7 +178,7 @@ public class ScheduleTask {
|
|
|
ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
|
|
ArrayList<String> allIds = new ArrayList<>();//todo:->>>>>>>>>全部任务id存在allIds
|
|
|
param1.put("q",q);
|
|
param1.put("q",q);
|
|
|
param1.put("pageToken",pageToken);
|
|
param1.put("pageToken",pageToken);
|
|
|
- String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);
|
|
|
|
|
|
|
+ String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header, param1);//todo:[查询项目任务]
|
|
|
List<String> batchIds = extractIdsFromJson(doGet1);
|
|
List<String> batchIds = extractIdsFromJson(doGet1);
|
|
|
allIds.addAll(batchIds);//添加到总列表
|
|
allIds.addAll(batchIds);//添加到总列表
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
@@ -250,12 +253,12 @@ public class ScheduleTask {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ log.info("设计类别年确认情况已同步数据库");
|
|
|
return McR.success();
|
|
return McR.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*todo:本年度个人确认稿数据(人员)*//*todo:确认稿件数量(总数量)*//*todo:同期确认稿数量(时间)*/
|
|
/*todo:本年度个人确认稿数据(人员)*//*todo:确认稿件数量(总数量)*//*todo:同期确认稿数量(时间)*/
|
|
|
-// @Scheduled(cron = "0 */15 * * * ?")
|
|
|
|
|
|
|
+ @Scheduled(cron = "0 0 3 * * ?")
|
|
|
@PostMapping("/yearPersonalconfirm")
|
|
@PostMapping("/yearPersonalconfirm")
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
McR yearPersonalconfirm(){
|
|
McR yearPersonalconfirm(){
|
|
@@ -268,12 +271,12 @@ public class ScheduleTask {
|
|
|
header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
|
|
header.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
|
|
|
header.put("X-Tenant-Type","organization");
|
|
header.put("X-Tenant-Type","organization");
|
|
|
HashMap param = new HashMap();
|
|
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";
|
|
|
|
|
|
|
+ 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 AND created >= 2026-01-01";
|
|
|
param.put("q",q);
|
|
param.put("q",q);
|
|
|
String projectId = "6878b323386fac7ab9dbe5e9";
|
|
String projectId = "6878b323386fac7ab9dbe5e9";
|
|
|
String doGet = UtilHttp.doGet("https://open.teambition.com/api/v3/project/" + projectId + "/task/count", (Map) header, (Map) param);
|
|
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);
|
|
Matcher m = Pattern.compile("\"result\":(\\d+)").matcher(doGet);
|
|
|
- int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//57
|
|
|
|
|
|
|
+ int result = m.find() ? Integer.parseInt(m.group(1)) : 0;//23
|
|
|
//2、分页查询
|
|
//2、分页查询
|
|
|
HashMap param1 = new HashMap();
|
|
HashMap param1 = new HashMap();
|
|
|
param1.put("pageSize",100);
|
|
param1.put("pageSize",100);
|
|
@@ -303,6 +306,7 @@ public class ScheduleTask {
|
|
|
JSONObject response = JSON.parseObject(doneGet);
|
|
JSONObject response = JSON.parseObject(doneGet);
|
|
|
JSONArray resultArray = response.getJSONArray("result");
|
|
JSONArray resultArray = response.getJSONArray("result");
|
|
|
String targetId = "68ff1fa5935b53b5d64ecb6a";//【确认稿单的工作流节点:确认工艺等级完成(6)】
|
|
String targetId = "68ff1fa5935b53b5d64ecb6a";//【确认稿单的工作流节点:确认工艺等级完成(6)】
|
|
|
|
|
+ String targetId2 = "689ededdb384ba716895010c";//【确认稿单的工作流节点:确认工艺等级完成(3)】
|
|
|
String targetId_deadline = "6875c736476bc6384b458cfc";//【完成时间节点】
|
|
String targetId_deadline = "6875c736476bc6384b458cfc";//【完成时间节点】
|
|
|
|
|
|
|
|
for (int k = 0; k < resultArray.size(); k++) {
|
|
for (int k = 0; k < resultArray.size(); k++) {
|
|
@@ -310,22 +314,22 @@ public class ScheduleTask {
|
|
|
// if(targetId_deadline.equals(node.getString("id"))){
|
|
// if(targetId_deadline.equals(node.getString("id"))){
|
|
|
// deadline = node.getString("accomplished");
|
|
// deadline = node.getString("accomplished");
|
|
|
// }
|
|
// }
|
|
|
- if (targetId.equals(node.getString("id"))) {
|
|
|
|
|
|
|
+ if (targetId.equals(node.getString("id")) || targetId2.equals(node.getString("id"))) {
|
|
|
|
|
|
|
|
for(int k1 = 0; k1 < resultArray.size(); k1++){
|
|
for(int k1 = 0; k1 < resultArray.size(); k1++){
|
|
|
JSONObject node1 = resultArray.getJSONObject(k1);
|
|
JSONObject node1 = resultArray.getJSONObject(k1);
|
|
|
if(targetId_deadline.equals(node1.getString("id"))){
|
|
if(targetId_deadline.equals(node1.getString("id"))){
|
|
|
deadline = node1.getString("accomplished");
|
|
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();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ 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));
|
|
params3.put("taskId", allIds.get(j));
|
|
@@ -333,6 +337,7 @@ public class ScheduleTask {
|
|
|
String taskId = "";//任务id
|
|
String taskId = "";//任务id
|
|
|
String taskName = "";//任务名称
|
|
String taskName = "";//任务名称
|
|
|
String designPerson = "";//设计人员
|
|
String designPerson = "";//设计人员
|
|
|
|
|
+ String department = "";//所属部门
|
|
|
Integer coefficient = null;//系数
|
|
Integer coefficient = null;//系数
|
|
|
String customerName = "";//客户名称
|
|
String customerName = "";//客户名称
|
|
|
String designlevel = "";//设计等级
|
|
String designlevel = "";//设计等级
|
|
@@ -359,6 +364,7 @@ public class ScheduleTask {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/*todo:给实体赋值*/
|
|
/*todo:给实体赋值*/
|
|
|
YearPersonalConfirm yearPersonalConfirm = new YearPersonalConfirm();
|
|
YearPersonalConfirm yearPersonalConfirm = new YearPersonalConfirm();
|
|
|
yearPersonalConfirm.setTaskId(taskId);
|
|
yearPersonalConfirm.setTaskId(taskId);
|
|
@@ -377,6 +383,10 @@ public class ScheduleTask {
|
|
|
yearPersonalConfirm.setCustomerName(customerName);
|
|
yearPersonalConfirm.setCustomerName(customerName);
|
|
|
yearPersonalConfirm.setDesignLevel(designlevel);
|
|
yearPersonalConfirm.setDesignLevel(designlevel);
|
|
|
yearPersonalConfirm.setDeadline(deadlineTime);
|
|
yearPersonalConfirm.setDeadline(deadlineTime);
|
|
|
|
|
+ if(!designPerson.equals("")){
|
|
|
|
|
+ department = UserGetDeprt(designPerson);
|
|
|
|
|
+ }
|
|
|
|
|
+ yearPersonalConfirm.setDepartment(department);
|
|
|
//4、插入数据库
|
|
//4、插入数据库
|
|
|
QueryWrapper<YearPersonalConfirm> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<YearPersonalConfirm> queryWrapper = new QueryWrapper<>();
|
|
|
List<YearPersonalConfirm> YearPersonalConfirmList = null;
|
|
List<YearPersonalConfirm> YearPersonalConfirmList = null;
|
|
@@ -397,6 +407,7 @@ public class ScheduleTask {
|
|
|
updateWrapper.set("customer_name", customerName);
|
|
updateWrapper.set("customer_name", customerName);
|
|
|
updateWrapper.set("design_level", designlevel);
|
|
updateWrapper.set("design_level", designlevel);
|
|
|
updateWrapper.set("deadline",deadlineTime);
|
|
updateWrapper.set("deadline",deadlineTime);
|
|
|
|
|
+ updateWrapper.set("department",department);
|
|
|
yearPersonalConfirmMapper.update(null, updateWrapper);
|
|
yearPersonalConfirmMapper.update(null, updateWrapper);
|
|
|
}else {
|
|
}else {
|
|
|
int insert = yearPersonalConfirmMapper.insert(yearPersonalConfirm);
|
|
int insert = yearPersonalConfirmMapper.insert(yearPersonalConfirm);
|
|
@@ -420,6 +431,7 @@ public class ScheduleTask {
|
|
|
|
|
|
|
|
|
|
|
|
|
/*todo:员工每周任务*/
|
|
/*todo:员工每周任务*/
|
|
|
|
|
+ @Scheduled(cron = "0 30 2 * * ?")
|
|
|
@PostMapping("/employeeWeeklyTasks")
|
|
@PostMapping("/employeeWeeklyTasks")
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
McR employeeWeeklyTasks(){
|
|
McR employeeWeeklyTasks(){
|
|
@@ -568,6 +580,7 @@ public class ScheduleTask {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*todo:年度季节品类打样数量*/
|
|
/*todo:年度季节品类打样数量*/
|
|
|
|
|
+ @Scheduled(cron = "0 0 2 * * ?")
|
|
|
@PostMapping("/annualSeasonalSample")
|
|
@PostMapping("/annualSeasonalSample")
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
McR annualSeasonalSample(){
|
|
McR annualSeasonalSample(){
|
|
@@ -691,6 +704,7 @@ public class ScheduleTask {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*todo:新工艺落地情况*/
|
|
/*todo:新工艺落地情况*/
|
|
|
|
|
+ @Scheduled(cron = "0 30 1 * * ?")
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
@PostMapping("/newprocessImplementation")
|
|
@PostMapping("/newprocessImplementation")
|
|
|
McR newprocessImplementation(){
|
|
McR newprocessImplementation(){
|
|
@@ -817,6 +831,7 @@ public class ScheduleTask {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*todo:设计部月确认稿数量*/
|
|
/*todo:设计部月确认稿数量*/
|
|
|
|
|
+ @Scheduled(cron = "0 0 1 * * ?")
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
@PostMapping("/designdeparttMonthConfirm")
|
|
@PostMapping("/designdeparttMonthConfirm")
|
|
|
McR DesigndeparttMonthConfirm(){
|
|
McR DesigndeparttMonthConfirm(){
|
|
@@ -955,4 +970,270 @@ public class ScheduleTask {
|
|
|
return McR.success();
|
|
return McR.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /*todo:文件来源变更统计*/
|
|
|
|
|
+ @SneakyThrows
|
|
|
|
|
+ @PostMapping("/changedocumentsource")
|
|
|
|
|
+ McR changedocumentsource(){
|
|
|
|
|
+ //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:687df8813d5081f8c81cf375 != null";
|
|
|
|
|
+ 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;//个数4300
|
|
|
|
|
+ //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);
|
|
|
|
|
+ Map header2 = new HashMap<>();
|
|
|
|
|
+ header2.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
|
|
|
|
|
+ McR Token2 = tbService.AppAccessToken();
|
|
|
|
|
+ Object token2 = Token2.getData();
|
|
|
|
|
+ header2.put("Authorization","Bearer " + token2);
|
|
|
|
|
+ header2.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
|
|
|
|
|
+ header2.put("X-Tenant-Type","organization");
|
|
|
|
|
+ String doGet1 = UtilHttp.doGet("https://open.teambition.com/api/v3/project/6878b323386fac7ab9dbe5e9/task/query", header2, 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、列出任务动态(taskid && actions = “customfield.update.v2”)
|
|
|
|
|
+ for (int j = 0; j < allIds.size(); j++) {
|
|
|
|
|
+ String renwutime = "";
|
|
|
|
|
+ HashMap params3 = new HashMap();
|
|
|
|
|
+ params3.put("actions", "customfield.update.v2");
|
|
|
|
|
+ params3.put("pageSize",100);
|
|
|
|
|
+ Map header3 = new HashMap<>();
|
|
|
|
|
+ header3.put("x-operator-id","622ee3450cf3bb5e1a486f1f");
|
|
|
|
|
+ McR Token3 = tbService.AppAccessToken();
|
|
|
|
|
+ Object token3 = Token3.getData();
|
|
|
|
|
+ header3.put("Authorization","Bearer " + token3);
|
|
|
|
|
+ header3.put("X-Tenant-Id","61a8c26719c3b5ffe9c4cffb");
|
|
|
|
|
+ header3.put("X-Tenant-Type","organization");
|
|
|
|
|
+ String doGet3 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/"+ allIds.get(j) +"/activity/list", header3, params3);
|
|
|
|
|
+ System.out.println("doGet3" + doGet3);
|
|
|
|
|
+ JsonNode resultNode = new ObjectMapper().readTree(doGet3).get("result");
|
|
|
|
|
+ if(resultNode == null || resultNode.isEmpty() ){
|
|
|
|
|
+ //为空不做处理
|
|
|
|
|
+ }else {
|
|
|
|
|
+ for (JsonNode item : resultNode) {
|
|
|
|
|
+ String contentStr = item.get("content").asText();
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ JsonNode content = objectMapper.readTree(contentStr);
|
|
|
|
|
+ JsonNode customfieldName = content.get("customfieldName");
|
|
|
|
|
+ if (customfieldName != null && "文件来源".equals(customfieldName.asText())) {
|
|
|
|
|
+ //写入数据库
|
|
|
|
|
+ /*todo:给实体赋值*/
|
|
|
|
|
+ String taskId = allIds.get(j);//任务id
|
|
|
|
|
+ String taskName = "";//任务名称
|
|
|
|
|
+ String renwuTime = "";//创建时间
|
|
|
|
|
+ String customer = "";//客户名称
|
|
|
|
|
+ String ywPerson = "";//业务人员
|
|
|
|
|
+ String zdrPerson = "";//制单人
|
|
|
|
|
+ String zyjl = "";//业务经理
|
|
|
|
|
+ String designcatogry = "";//设计类别
|
|
|
|
|
+
|
|
|
|
|
+ HashMap param_A = new HashMap();
|
|
|
|
|
+ param_A.put("taskId",taskId);
|
|
|
|
|
+ String doGet4 = UtilHttp.doGet("https://open.teambition.com/api/v3/task/query", header3, param_A);//查询任务详情
|
|
|
|
|
+
|
|
|
|
|
+ JSONArray customfields = JSON.parseObject(doGet4).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 "687df3b60ae1530fa2704499":
|
|
|
|
|
+ customer = value;//客户名称
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "688191972ab6c4f412ea2bb9":
|
|
|
|
|
+ ywPerson = value;//业务人员
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "687df458b9c2f9f90865c13b":
|
|
|
|
|
+ zyjl = value;//业务经理
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "687e0308e3f7ce8174a19cfc":
|
|
|
|
|
+ designcatogry = value;//设计类别
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "688191a2d18cef625eccade6":
|
|
|
|
|
+ zdrPerson = value;//制单人
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ObjectMapper objectMapper4 = new ObjectMapper();
|
|
|
|
|
+ JsonNode rootNode = objectMapper4.readTree(doGet4);
|
|
|
|
|
+ for(JsonNode resultNode4 : rootNode.path("result")) {
|
|
|
|
|
+ taskName = resultNode4.path("content").asText();//任务名称
|
|
|
|
|
+
|
|
|
|
|
+ renwuTime = resultNode4.path("created").asText();//创建时间
|
|
|
|
|
+ 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 = renwuTime.replace("Z", " UTC");
|
|
|
|
|
+ try {
|
|
|
|
|
+ Date zhuangtaiDate = format.parse(timeStr);
|
|
|
|
|
+ renwutime = defaultFormat.format(zhuangtaiDate);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// String creatorId = resultNode4.path("creatorId").asText();//创建人id
|
|
|
|
|
+// List<String> involveMembers = new ArrayList<>();
|
|
|
|
|
+// involveMembers.add(creatorId);
|
|
|
|
|
+// zdrPerson = tbService.TBtoDinguserId(involveMembers);//创建人
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ChangeDocumentSource changeDocumentSource = new ChangeDocumentSource();
|
|
|
|
|
+ changeDocumentSource.setTaskId(taskId);
|
|
|
|
|
+ changeDocumentSource.setTaskName(taskName);
|
|
|
|
|
+ changeDocumentSource.setRenwuTime(renwutime);
|
|
|
|
|
+ changeDocumentSource.setCustomer(customer);
|
|
|
|
|
+ changeDocumentSource.setYwPerson(ywPerson);
|
|
|
|
|
+ changeDocumentSource.setZdrPerson(zdrPerson);
|
|
|
|
|
+ changeDocumentSource.setZyjl(zyjl);
|
|
|
|
|
+ changeDocumentSource.setDesigncatogry(designcatogry);
|
|
|
|
|
+ //4、插入数据库
|
|
|
|
|
+ QueryWrapper<ChangeDocumentSource> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ List<ChangeDocumentSource> changeDocumentSourceList = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ queryWrapper.eq("task_id", taskId);
|
|
|
|
|
+
|
|
|
|
|
+ changeDocumentSourceList = changeDocumentSourceMapper.selectList(queryWrapper);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ UpdateWrapper<ChangeDocumentSource> updateWrapper = new UpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.eq("task_id", taskId);
|
|
|
|
|
+ if (changeDocumentSourceList != null && changeDocumentSourceList.size() > 0) {
|
|
|
|
|
+ updateWrapper.set("renwu_time", renwutime);
|
|
|
|
|
+ updateWrapper.set("customer",customer);
|
|
|
|
|
+ updateWrapper.set("yw_person",ywPerson);
|
|
|
|
|
+ updateWrapper.set("zdr_person",zdrPerson);
|
|
|
|
|
+ updateWrapper.set("zyjl",zyjl);
|
|
|
|
|
+ updateWrapper.set("designcatogry",designcatogry);
|
|
|
|
|
+ changeDocumentSourceMapper.update(null, updateWrapper);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ int insert = changeDocumentSourceMapper.insert(changeDocumentSource);
|
|
|
|
|
+ Map<String, Object> response = new HashMap<>();
|
|
|
|
|
+ if(insert > 0){
|
|
|
|
|
+ response.put("success", true);
|
|
|
|
|
+ response.put("message", "用户创建成功");
|
|
|
|
|
+ response.put("data", "");
|
|
|
|
|
+ log.info("任务创建成功,任务名称:{},任务id:{}", changeDocumentSource.getTaskName(),changeDocumentSource.getTaskId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ break;//跳出循环,开始下一个任务
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("[任务动态同步完毕!]");
|
|
|
|
|
+ return McR.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*todo:人员获取部门*/
|
|
|
|
|
+ @SneakyThrows
|
|
|
|
|
+ @PostMapping("/UserGetDeprt")
|
|
|
|
|
+ String UserGetDeprt(@RequestParam String User){
|
|
|
|
|
+ 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();
|
|
|
|
|
+ param.put("query",User);
|
|
|
|
|
+ String doGet = UtilHttp.doGet("https://open.teambition.com/api/org/member/search", (Map) header, (Map) param);
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(doGet);
|
|
|
|
|
+ JSONArray resultArray = jsonObject.getJSONArray("result");
|
|
|
|
|
+ String userId = "";
|
|
|
|
|
+ String value = "";
|
|
|
|
|
+ if (resultArray != null && !resultArray.isEmpty()) {
|
|
|
|
|
+ JSONObject firstUser = resultArray.getJSONObject(0);
|
|
|
|
|
+ userId = firstUser.getString("userId");
|
|
|
|
|
+ System.out.println("提取到的userId: " + userId);
|
|
|
|
|
+ List<String> involveMembers = new ArrayList<>();
|
|
|
|
|
+ involveMembers.add(userId);
|
|
|
|
|
+ HashMap param2 = new HashMap();
|
|
|
|
|
+ param2.put("tbUserIds",involveMembers);
|
|
|
|
|
+ String s = UtilHttp.doGet("https://open.teambition.com/api/idmap/dingtalk/getDingUserId", header, param2);
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ var rootNode = objectMapper.readTree(s);
|
|
|
|
|
+ List<String> userIdList = objectMapper.convertValue(
|
|
|
|
|
+ rootNode.get("result"),
|
|
|
|
|
+ new TypeReference<List<Map<String, String>>>() {
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(map -> map.get("dingtalkUserId"))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ System.out.println(userIdList);
|
|
|
|
|
+ HashMap head = new HashMap();
|
|
|
|
|
+ McR Token2 = tbService.OuNuoXinAccessToken();
|
|
|
|
|
+ Object Data = Token2.getData();
|
|
|
|
|
+ head.put("x-acs-dingtalk-access-token",Data);
|
|
|
|
|
+ HashMap boddy = new HashMap();
|
|
|
|
|
+ boddy.put("userIdList",userIdList);
|
|
|
|
|
+ boddy.put("fieldFilterList", Arrays.asList("sys00-mainDept"));
|
|
|
|
|
+ boddy.put("appAgentId","4115325431");
|
|
|
|
|
+ boddy.put("text2SelectConvert",true);
|
|
|
|
|
+ String ddt = UtilHttp.doPost("https://api.dingtalk.com/v1.0/hrm/rosters/lists/query",head,null,boddy);
|
|
|
|
|
+ // 使用Fastjson解析
|
|
|
|
|
+ JSONObject jsonObj = JSON.parseObject(ddt);
|
|
|
|
|
+ JSONArray resultArray2 = jsonObj.getJSONArray("result");
|
|
|
|
|
+
|
|
|
|
|
+ if (resultArray2 != null && !resultArray2.isEmpty()) {
|
|
|
|
|
+ JSONObject firstResult = resultArray2.getJSONObject(0);
|
|
|
|
|
+ JSONArray fieldDataList = firstResult.getJSONArray("fieldDataList");
|
|
|
|
|
+
|
|
|
|
|
+ if (fieldDataList != null && !fieldDataList.isEmpty()) {
|
|
|
|
|
+ // 遍历fieldDataList找到主部门字段(如果有多个字段的话)
|
|
|
|
|
+ for (int i = 0; i < fieldDataList.size(); i++) {
|
|
|
|
|
+ JSONObject fieldData = fieldDataList.getJSONObject(i);
|
|
|
|
|
+ String fieldCode = fieldData.getString("fieldCode");
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是主部门字段
|
|
|
|
|
+ if ("sys00-mainDept".equals(fieldCode)) {
|
|
|
|
|
+ JSONArray fieldValueList = fieldData.getJSONArray("fieldValueList");
|
|
|
|
|
+ if (fieldValueList != null && !fieldValueList.isEmpty()) {
|
|
|
|
|
+ JSONObject firstValue = fieldValueList.getJSONObject(0);
|
|
|
|
|
+ value = firstValue.getString("value");
|
|
|
|
|
+ System.out.println("提取到的部门: " + value);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|