|
@@ -0,0 +1,83 @@
|
|
|
+package com.malk.mc.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.malk.mc.service.McYdService;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.common.McR;
|
|
|
+import com.malk.server.dingtalk.DDConf;
|
|
|
+import com.malk.server.dingtalk.DDR_New;
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.service.dingtalk.DDClient;
|
|
|
+import com.malk.utils.UtilHttp;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
+import org.slf4j.MDC;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class McYdServiceImpl implements McYdService {
|
|
|
+ @Autowired
|
|
|
+ private YDClient ydClient;
|
|
|
+ @Autowired
|
|
|
+ private DDClient ddClient;
|
|
|
+ @Autowired
|
|
|
+ private DDConf ddConf;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public void updateFormDataVersion(Map map) {
|
|
|
+ String pid = Objects.nonNull(map.get("pid")) ? map.get("pid").toString() : "";
|
|
|
+ String formInstId = Objects.nonNull(map.get("formInstId")) ? map.get("formInstId").toString() : "";
|
|
|
+ String formUuid = Objects.nonNull(map.get("formUuid")) ? map.get("formUuid").toString() : "";
|
|
|
+ if (Strings.isNotBlank(pid)){
|
|
|
+ MDC.put("MDC_KEY_PID",pid);
|
|
|
+ if (Strings.isNotBlank(formInstId) && Strings.isBlank(formUuid)){
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstId(formInstId)
|
|
|
+ .useLatestVersion(true)
|
|
|
+ .updateFormDataJson("{}").build(), YDConf.FORM_OPERATION.update);
|
|
|
+ }else if (Strings.isBlank(formInstId) && Strings.isNotBlank(formUuid)){
|
|
|
+ int i = 1;
|
|
|
+ int pageSize = 100;
|
|
|
+ DDR_New ddrNew;
|
|
|
+ do {
|
|
|
+ ddrNew = ydClient.queryData(YDParam.builder()
|
|
|
+ .formUuid(formUuid)
|
|
|
+ .pageNumber(i)
|
|
|
+ .pageSize(100)
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_search_form_id);
|
|
|
+
|
|
|
+ List<String> formInstIdList = (List<String>) ddrNew.getData();
|
|
|
+ for (String id : formInstIdList) {
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstId(id)
|
|
|
+ .useLatestVersion(true)
|
|
|
+ .updateFormDataJson("{}").build(), YDConf.FORM_OPERATION.update);
|
|
|
+ }
|
|
|
+ }while (ddrNew.getTotalCount() > ddrNew.getPageNumber() * pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ //发送工作通知给当前登陆人
|
|
|
+ if (Objects.nonNull(map.get("userId"))){
|
|
|
+ String userId = map.get("userId").toString();
|
|
|
+ Map param2 = new HashMap();
|
|
|
+ param2.put("access_token",ddClient.getAccessToken());
|
|
|
+ Map body3 = new HashMap();
|
|
|
+ body3.put("agent_id",ddConf.getAgentId());
|
|
|
+ body3.put("userid_list",userId);
|
|
|
+ Map msg = new HashMap();
|
|
|
+ msg.put("msgtype","text");
|
|
|
+ //获取当前时间 精确到秒
|
|
|
+ String time = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss");
|
|
|
+ msg.put("text", UtilMap.map("content","表单实例版本已更新 时间:" + time));
|
|
|
+ body3.put("msg",msg);
|
|
|
+ UtilHttp.doPost("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2",null,param2,body3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|