|
@@ -14,7 +14,10 @@ import org.springframework.web.client.RestTemplate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
@@ -28,9 +31,9 @@ import java.util.List;
|
|
public class SendUskyJob {
|
|
public class SendUskyJob {
|
|
|
|
|
|
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
- //private static final String USKY_URL = "https://gateway.usky.cn/prod-api/system/mceReceive/addMce";
|
|
|
|
- private static final String USKY_URL = "http://172.16.66.143:9886/mceReceive/addMce";
|
|
|
|
- private static final String USKY_TEST_URL = "http://192.168.10.165:13200/offline-api/system/mceReceive/addMce";
|
|
|
|
|
|
+ // private static final String USKY_URL = "https://gateway.usky.cn/prod-api/system/mceReceive/addMceNew";
|
|
|
|
+ private static final String USKY_URL = "http://172.16.66.143:9886/mceReceive/addMceNew";
|
|
|
|
+ private static final String USKY_TEST_URL = "http://192.168.10.165:13200/offline-api/system/mceReceive/addMceNew";
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
@@ -76,14 +79,30 @@ public class SendUskyJob {
|
|
int successCount = 0;
|
|
int successCount = 0;
|
|
int failCount = 0;
|
|
int failCount = 0;
|
|
for (Notify send : unSend) {
|
|
for (Notify send : unSend) {
|
|
|
|
+ String subject = send.getSubject();
|
|
|
|
+ String approvalResult = "";
|
|
|
|
+ switch (subject) {
|
|
|
|
+ case "申请已通过":
|
|
|
|
+ approvalResult = "审批通过";
|
|
|
|
+ break;
|
|
|
|
+ case "新的审批任务":
|
|
|
|
+ case "催办":
|
|
|
|
+ approvalResult = "审批中";
|
|
|
|
+ break;
|
|
|
|
+ case "申请拒绝":
|
|
|
|
+ approvalResult = "审批驳回";
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
JSONObject sendJson = new JSONObject()
|
|
JSONObject sendJson = new JSONObject()
|
|
.put("infoTypeName", "OA审批")
|
|
.put("infoTypeName", "OA审批")
|
|
.put("infoType", 3)
|
|
.put("infoType", 3)
|
|
- .put("infoTitle", "OA审批")
|
|
|
|
- .put("infoContent", send.getContent() + "。 url:" + send.getUrl())
|
|
|
|
|
|
+ .put("infoTitle", send.getSender() + send.getSubject())
|
|
|
|
+ .put("infoContent", extractContentInBrackets(send.getContent()))
|
|
.put("userName", send.getSender())
|
|
.put("userName", send.getSender())
|
|
- .put("userNames", Arrays.asList(send.getReceiver()))
|
|
|
|
- .put("id", send.getId());
|
|
|
|
|
|
+ .put("userNames", Collections.singletonList(send.getReceiver()))
|
|
|
|
+ .put("id", send.getId())
|
|
|
|
+ .put("approvalResult", approvalResult);
|
|
|
|
|
|
String sendJsonString = sendJson.toString();
|
|
String sendJsonString = sendJson.toString();
|
|
log.info("准备发送 {} 的消息:{} ", send.getSender(), sendJsonString);
|
|
log.info("准备发送 {} 的消息:{} ", send.getSender(), sendJsonString);
|
|
@@ -109,4 +128,20 @@ public class SendUskyJob {
|
|
}
|
|
}
|
|
log.info("更新消息状态完成,共更新 {} 条消息", unSend.size());
|
|
log.info("更新消息状态完成,共更新 {} 条消息", unSend.size());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 提取【】内的内容
|
|
|
|
+ public static String extractContentInBrackets(String content) {
|
|
|
|
+ // 定义正则表达式,匹配【】内的内容
|
|
|
|
+ String regex = "【(.*?)】";
|
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
|
+ Matcher matcher = pattern.matcher(content);
|
|
|
|
+
|
|
|
|
+ if (matcher.find()) {
|
|
|
|
+ // 返回匹配到的第一个结果
|
|
|
|
+ return matcher.group(1);
|
|
|
|
+ } else {
|
|
|
|
+ // 如果没有匹配到,返回空字符串或其他默认值
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|