|
|
@@ -0,0 +1,96 @@
|
|
|
+package com.malk.eastar.schedule;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.malk.eastar.service.EastarTbService;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.aliwork.YDSearch;
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.utils.PublicUtil;
|
|
|
+import com.malk.utils.UtilDateTime;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @EnableScheduling 开启定时任务 [配置参考McScheduleTask]
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Configuration
|
|
|
+@EnableScheduling
|
|
|
+@ConditionalOnProperty(name = {"enable.scheduling"})
|
|
|
+public class ScheduleTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YDClient ydClient;
|
|
|
+ @Autowired
|
|
|
+ private EastarTbService eastarTbService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 8 * * ?")
|
|
|
+ public void syncMer() {
|
|
|
+ log.info("客户公海同步");
|
|
|
+ try {
|
|
|
+ long endTime= UtilDateTime.getLocalDateTimeTimeStamp(LocalDate.now().minusDays(30).atTime(LocalTime.MIN));
|
|
|
+ List<Map> list= (List<Map>) ydClient.queryData(YDParam.builder().formUuid("FORM-9261FABA687B4D1D917617F53B4A5DB7UN16").searchCondition(JSONObject.toJSONString(
|
|
|
+ Arrays.asList(
|
|
|
+ new YDSearch("radioField_md6q7oxa","私","公私海", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ),
|
|
|
+ new YDSearch("radioField_md6q7ox8","新","新老客户", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ),
|
|
|
+ new YDSearch("dateField_l3tw3kfn",endTime,"截至跟进时间",YDSearch.Type.DATE_FIELD,YDSearch.Operator.LT)
|
|
|
+ )
|
|
|
+ )).build(), YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
+ for(Map map:list){
|
|
|
+ log.info("客户:{}释放为公海", UtilMap.getMap(map,"formData").get("textField_lqanqe6j"));
|
|
|
+ ydClient.operateData(YDParam.builder().formInstId(UtilMap.getString(map,"formInstanceId")).updateFormDataJson(
|
|
|
+ JSONObject.toJSONString(UtilMap.map("radioField_md6q7oxa, employeeField_lqanqe6n, employeeField_lqx3act6","公","[]","[]"))
|
|
|
+ ).build(), YDConf.FORM_OPERATION.update);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 30 6 * * ?")
|
|
|
+ public void syncTaskCount() {
|
|
|
+ log.info("同步任务状态数量");
|
|
|
+ try {
|
|
|
+ List<Map> list= (List<Map>) ydClient.queryData(YDParam.builder().formUuid("FORM-D8DFF1F8C07A4869BCC850090F3A3B4EE0AV").searchCondition(JSONObject.toJSONString(
|
|
|
+ Arrays.asList(
|
|
|
+ new YDSearch("selectField_me2hylde",Arrays.asList("立项阶段","样品阶段","生产阶段","包装阶段","出货阶段","收尾阶段"),"项目状态", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.CONTAINS)
|
|
|
+ )
|
|
|
+ )).build(), YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
+ for(Map map:list){
|
|
|
+ Map formData =UtilMap.getMap(map,"formData");
|
|
|
+ log.info("任务数量同步:项目:{} ", formData.get("textField_me87x1nz"));
|
|
|
+ String pid=UtilMap.getString(formData,"textField_me2hyldc");
|
|
|
+ String tbPid=UtilMap.getString(formData,"textField_mecmytpo");
|
|
|
+ if(PublicUtil.isNull(tbPid)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String fid=UtilMap.getString(map,"formInstanceId");
|
|
|
+ List<UtilMap.assDetail> assDetails=UtilMap.getAssFieldValue(formData,"associationFormField_me9n24kk_id");
|
|
|
+ if(assDetails!=null&&assDetails.size()>0){
|
|
|
+ String tastTypeName= assDetails.get(0).title; // 项目任务类型
|
|
|
+ eastarTbService.taskCount(pid,tbPid,fid,tastTypeName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|