Browse Source

Merge remote-tracking branch 'origin/dev_bugfix_ljj' into dev

dev_shibei_match
zxc 4 years ago
parent
commit
00abdbf771
  1. 74
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java
  2. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectCategoryDailyDao.xml
  3. 19
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventDao.xml

74
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java

@ -2,7 +2,6 @@ package com.epmet.commons.tools.utils;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.dto.form.DingTalkTextMsg;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.google.common.collect.Lists;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
@ -13,13 +12,9 @@ import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ArrayBlockingQueue;
/**
@ -104,7 +99,7 @@ public class DingdingMsgSender {
}
private Thread getThread() {
Thread sendMsgThread = new Thread("MsgSender-Thread") {
return new Thread("MsgSender-Thread") {
@Override
public void run() {
while (running) {
@ -112,7 +107,6 @@ public class DingdingMsgSender {
}
}
};
return sendMsgThread;
}
@ -139,77 +133,19 @@ public class DingdingMsgSender {
try {
String stringToSign = timestamp + "\n" + param.getSecret();
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(param.getSecret().getBytes("UTF-8"), "HmacSHA256"));
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
mac.init(new SecretKeySpec(param.getSecret().getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
byte[] signData = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8));
String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8");
String url = param.getWebHook();
url = url.concat("&timestamp=" + timestamp + "&sign=" + sign);
String jsonStrParam = param.getMsgContent();
result = this.sendPostByJSON(url, jsonStrParam);
result = HttpClientManager.getInstance().sendPostByJSON(url, jsonStrParam);
} catch (Exception e) {
logger.warn("sendPostByJSON error", e);
}
return result;
}
/**
* 发送POST 请求
*
* @param url 发送请求的 URL
* @param param 请求参数JSON格式
* @return
*/
public Result<String> sendPostByJSON(String url, String param) throws IOException {
if (StringUtils.isEmpty(url) || StringUtils.isEmpty(param)) {
throw new IllegalArgumentException("参数不能为空");
}
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
logger.warn("sendPostByJSON error", e);
return new Result<String>().error(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage());
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
}
}
return new Result<String>().ok(result);
}
public static void main(String[] args) {
for (int i = 0; i < 50; i++) {

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectCategoryDailyDao.xml

@ -91,6 +91,7 @@
UNION ALL
SELECT
c.CUSTOMER_ID,
c.CUSTOMER_ID AS categoryOriginCustomerId,
left(c.CATEGORY_CODE, 4) AS CATEGORY_CODE,
'1' AS `LEVEL`,
p.AGENCY_ID AS orgId,

19
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventDao.xml

@ -5,8 +5,8 @@
<!-- 查询报事列表 -->
<resultMap id="eventUnDisposedListMap" type="com.epmet.dto.result.EventListResultDTO">
<id property="eventId" column="eventId"/>
<result property="eventContent" column="eventContent"/>
<result property="eventId" column="eventId"/>
<result property="eventTime" column="eventTime"/>
<result property="isProject" column="isProject"/>
<result property="redDot" column="redDot"/>
@ -36,20 +36,29 @@
and ro.ORG_ID = #{orgId}
<if test='eventType == "undisposed" '>
AND ro.ORG_READ = 'un_read'
ORDER BY re.CREATED_TIME
</if>
<if test='eventType == "processed" '>
AND ro.ORG_READ = 'read'
AND re.`STATUS` = 'processing'
ORDER BY re.LATEST_OPERATED_TIME DESC
</if>
<if test='eventType == "transferred" '>
AND ro.ORG_READ = 'read'
AND re.`STATUS` = 'closed_case'
ORDER BY re.CLOSE_CASE_TIME DESC
</if>
)t
LEFT JOIN resi_event_attachment rea ON (rea.RESI_EVENT_ID = t.eventId AND rea.DEL_FLAG = '0' AND rea.ATTACHMENT_TYPE = 'image' AND (rea.SORT = 3 OR rea.SORT = 1 OR rea.SORT = 2))
LEFT JOIN resi_event_attachment rea
ON (rea.RESI_EVENT_ID = t.eventId)
where rea.DEL_FLAG = '0'
AND rea.ATTACHMENT_TYPE = 'image'
<if test='eventType == "undisposed" '>
ORDER BY t.eventTime,rea.sort asc
</if>
<if test='eventType == "processed" '>
ORDER BY t.eventTime DESC,rea.sort asc
</if>
<if test='eventType == "transferred" '>
ORDER BY t.eventTime DESC,rea.sort asc
</if>
</select>

Loading…
Cancel
Save