|
|
@@ -0,0 +1,125 @@
|
|
|
+package com.malk.taisen.Timers;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.aliwork.YDSearch;
|
|
|
+import com.malk.service.aliwork.YDService;
|
|
|
+import com.malk.service.dingtalk.DDClient;
|
|
|
+import com.malk.service.dingtalk.DDClient_Notice;
|
|
|
+import com.malk.taisen.service.RtrServer;
|
|
|
+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.util.*;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Configuration
|
|
|
+@EnableScheduling
|
|
|
+@ConditionalOnProperty(name = {"enable.scheduling"}, havingValue = "false")
|
|
|
+public class RtrAutoTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RtrServer rtrServer;
|
|
|
+ @Autowired
|
|
|
+ private YDService ydService;
|
|
|
+ @Autowired
|
|
|
+ private DDClient_Notice ddClientNotice;
|
|
|
+ @Autowired
|
|
|
+ private DDClient ddClient;
|
|
|
+
|
|
|
+ private String url="https://tysonchina.aliwork.com/APP_N9NPHVTQLPBPO8MR6WFG/formDetail/FORM-E8E54176A4D446C182EB6A3C012A0284AGQN?formInstId=";
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 30 2,12,18,22 15 * ?")
|
|
|
+ public void rtrAutoPostSap() {
|
|
|
+ log.info("财务计提&摊销自动执行任务...");
|
|
|
+ // 获取当前时间
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ // 获取当月第一天 00:00:00
|
|
|
+ LocalDateTime firstDayOfMonth = now.withDayOfMonth(1).atStartOfDay();
|
|
|
+ // 获取当月最后一天 23:59:59.999999999
|
|
|
+ LocalDateTime lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth())
|
|
|
+ .atTime(23, 59, 59, 999999999);
|
|
|
+ // 转换为时间戳(毫秒)
|
|
|
+ long startTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(firstDayOfMonth);
|
|
|
+ long endTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(lastDayOfMonth);
|
|
|
+ YDSearch yidaSearch=new YDSearch("selectField_miwh5y55","待自动过账","状态", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ);
|
|
|
+ YDSearch yidaSearch2=new YDSearch("dateField_miwh5y85",Arrays.asList(startTimestamp,endTimestamp),"时间", YDSearch.Type.DATE_FIELD,YDSearch.Operator.BETWEEN);
|
|
|
+ List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-E8E54176A4D446C182EB6A3C012A0284AGQN")
|
|
|
+ .searchFieldJson(JSONObject.toJSONString(Arrays.asList(yidaSearch,yidaSearch2))).build());
|
|
|
+ for(Map map:list){
|
|
|
+ log.info("RTR 财务计提{}",map.get("instanceId"));
|
|
|
+ rtrServer.RtrInsetSAP0005("YWJT","FORM-E8E54176A4D446C182EB6A3C012A0284AGQN", String.valueOf(map.get("instanceId")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 30 9 14 * ?")
|
|
|
+ public void rtrMsgSend() {
|
|
|
+ log.info("财务计提&摊销手动推送提醒...");
|
|
|
+ // 获取当前时间
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ // 获取当月第一天 00:00:00
|
|
|
+ LocalDateTime firstDayOfMonth = now.withDayOfMonth(1).atStartOfDay();
|
|
|
+ // 获取当月最后一天 23:59:59.999999999
|
|
|
+ LocalDateTime lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth())
|
|
|
+ .atTime(23, 59, 59, 999999999);
|
|
|
+ // 转换为时间戳(毫秒)
|
|
|
+ long startTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(firstDayOfMonth);
|
|
|
+ long endTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(lastDayOfMonth);
|
|
|
+ YDSearch yidaSearch=new YDSearch("selectField_miwh5y55","待手动过账","状态", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ);
|
|
|
+ YDSearch yidaSearch2=new YDSearch("dateField_miwh5y85",Arrays.asList(startTimestamp,endTimestamp),"时间", YDSearch.Type.DATE_FIELD,YDSearch.Operator.BETWEEN);
|
|
|
+ List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-E8E54176A4D446C182EB6A3C012A0284AGQN")
|
|
|
+ .searchFieldJson(JSONObject.toJSONString(Arrays.asList(yidaSearch,yidaSearch2))).build());
|
|
|
+ for(Map map:list){
|
|
|
+ log.info("RTR 财务计提提醒{}",map.get("instanceId"));
|
|
|
+ List<String> uids= UtilMap.getList(map,"employeeField_mejfoon1_id");
|
|
|
+ if(uids.size()>0){
|
|
|
+ sendMsg(uids,"财务计提&摊销凭证手动推送提醒","单据【"+map.get("textField_miwh5y6z")+"】前往推送凭证",url+map.get("instanceId"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendMsg(List<String> uid,String title,String text,String messageUrl){
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
+ map.put("picUrl","@lALOACZwe2Rk");
|
|
|
+ map.put("title",title);
|
|
|
+ map.put("text",text);
|
|
|
+ map.put("messageUrl",messageUrl);
|
|
|
+ JSONObject msgMap=new JSONObject().fluentPut("msgtype","link").fluentPut("link",map);
|
|
|
+ System.out.println(msgMap);
|
|
|
+ ddClientNotice.sendNotification(ddClient.getAccessToken(),uid,null,false,
|
|
|
+ msgMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 临时
|
|
|
+ @Scheduled(cron = "0 30 10/2 7 1 ?")
|
|
|
+ public void test() {
|
|
|
+ log.info("财务计提&摊销自动执行任务...");
|
|
|
+ // 获取当前时间
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ // 获取当月第一天 00:00:00
|
|
|
+ LocalDateTime firstDayOfMonth = now.withDayOfMonth(1).atStartOfDay();
|
|
|
+ // 获取当月最后一天 23:59:59.999999999
|
|
|
+ LocalDateTime lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth())
|
|
|
+ .atTime(23, 59, 59, 999999999);
|
|
|
+ // 转换为时间戳(毫秒)
|
|
|
+ long startTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(firstDayOfMonth);
|
|
|
+ long endTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(lastDayOfMonth);
|
|
|
+ YDSearch yidaSearch=new YDSearch("selectField_miwh5y55","待自动过账","状态", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ);
|
|
|
+ YDSearch yidaSearch2=new YDSearch("dateField_miwh5y85",Arrays.asList(startTimestamp,endTimestamp),"时间", YDSearch.Type.DATE_FIELD,YDSearch.Operator.BETWEEN);
|
|
|
+ List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-E8E54176A4D446C182EB6A3C012A0284AGQN")
|
|
|
+ .searchFieldJson(JSONObject.toJSONString(Arrays.asList(yidaSearch,yidaSearch2))).build());
|
|
|
+ for(Map map:list){
|
|
|
+ log.info("RTR 财务计提{}",map.get("instanceId"));
|
|
|
+ rtrServer.RtrInsetSAP0005("YWJT","FORM-E8E54176A4D446C182EB6A3C012A0284AGQN", String.valueOf(map.get("instanceId")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|