From 9b87b24503626f4f47300c4dc7cdc2a9c13d1ef7 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Wed, 20 Jan 2021 14:08:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=8A=9F=E8=83=BD=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/PartyBuildingProperties.java | 10 ++- .../apis/casescore/CaseScoreController.java | 81 ++++++++++++++++--- .../pojo/dtos/casescore/CaseScoreDTO.java | 27 +++++++ src/main/resources/application.yml | 16 ++-- 4 files changed, 115 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/cm/bigdata/config/properties/PartyBuildingProperties.java b/src/main/java/com/cm/bigdata/config/properties/PartyBuildingProperties.java index ea99e83..cbad9d9 100644 --- a/src/main/java/com/cm/bigdata/config/properties/PartyBuildingProperties.java +++ b/src/main/java/com/cm/bigdata/config/properties/PartyBuildingProperties.java @@ -23,7 +23,7 @@ public class PartyBuildingProperties { private String logoUrl; private String populationUrl; private String deptassesstUrl; - + private String sendUrl; public Integer getPort() { return port; @@ -80,4 +80,12 @@ public class PartyBuildingProperties { public void setDeptassesstUrl(String deptassesstUrl) { this.deptassesstUrl = deptassesstUrl; } + + public String getSendUrl() { + return sendUrl == null ? "" : sendUrl; + } + + public void setSendUrl(String sendUrl) { + this.sendUrl = sendUrl; + } } diff --git a/src/main/java/com/cm/bigdata/controller/apis/casescore/CaseScoreController.java b/src/main/java/com/cm/bigdata/controller/apis/casescore/CaseScoreController.java index daa85d2..983993e 100644 --- a/src/main/java/com/cm/bigdata/controller/apis/casescore/CaseScoreController.java +++ b/src/main/java/com/cm/bigdata/controller/apis/casescore/CaseScoreController.java @@ -4,14 +4,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cm.bigdata.config.properties.PartyBuildingProperties; import com.cm.bigdata.config.properties.ScoreProperties; -import com.cm.bigdata.dao.casesupervise.ICaseSuperviseDao; -import com.cm.bigdata.pojo.dtos.boss.BossDTO; import com.cm.bigdata.pojo.dtos.casescore.CaseScoreDTO; -import com.cm.bigdata.pojo.dtos.casesupervise.CaseSuperviseDTO; -import com.cm.bigdata.pojo.dtos.configforscore.ConfigForScoreDTO; import com.cm.bigdata.pojo.dtos.scoredetail.ScoreDetailDTO; -import com.cm.bigdata.pojo.dtos.worknote.WorkNoteForScoreDTO; -import com.cm.bigdata.pojo.dtos.ztree.DictDTO; import com.cm.bigdata.pojo.vos.casesupervise.CaseSuperviseVO; import com.cm.bigdata.pojo.vos.scoredetail.ScoreDetailVO; import com.cm.bigdata.service.casesupervise.ICaseSuperviseService; @@ -21,7 +15,6 @@ import com.cm.bigdata.utils.DateRange; import com.cm.bigdata.utils.DateUtils; import com.cm.common.base.AbstractController; import com.cm.common.constants.ISystemConstant; -import com.cm.common.exception.SearchException; import com.cm.common.plugin.oauth.token.ClientTokenManager; import com.cm.common.plugin.pojo.bos.ClientTokenBO; import com.cm.common.pojo.ListPage; @@ -102,6 +95,8 @@ public class CaseScoreController extends AbstractController { } PageHelper.startPage(page.getPage(), page.getRows()); caseScoreDTOS = JSONArray.parseArray(str, CaseScoreDTO.class); + // 推送用map + Map tempMap = new HashMap<>(); for(CaseScoreDTO caseScoreDTO: caseScoreDTOS) { int count = caseScoreDTO.getCloseTimeout().size() + caseScoreDTO.getInspectTimeout().size(); // 保存考核详情 @@ -110,8 +105,31 @@ public class CaseScoreController extends AbstractController { if(count > 0) { saveCaseSupervise(quarter, caseScoreDTO, year); } - } + if(caseScoreDTO.getInspectPushUserIds().size() > 0) { + String userId = null; + for(int i=0;i map1 = caseScoreDTO.getInspectPushUserIds().get(i); + if(i == 0) { + userId = map1.get("inspectUserId").toString(); + tempMap.put(userId, 1); + } + if(i+1 >= caseScoreDTO.getInspectPushUserIds().size()) { + break; + } + Map map2 = caseScoreDTO.getInspectPushUserIds().get(i+1); + if(userId.equals(map2.get("inspectUserId"))) { + tempMap.put(userId, Integer.valueOf(tempMap.get(userId).toString()) + 1); + userId = map2.get("inspectUserId").toString(); + }else { + userId = map2.get("inspectUserId").toString(); + tempMap.put(userId, 1); + } + } + } + } + // 向App推送消息 + sendMsgToApp(tempMap); return new SuccessResultList<>(caseScoreDTOS, page.getPage(), page.getTotal()); } @@ -122,13 +140,13 @@ public class CaseScoreController extends AbstractController { */ public int dateAbout(Map params) { // 设置日期格式 - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); if(!StringUtils.isEmpty(params.get("year"))) { year = Integer.valueOf(params.get("year").toString()); } - String startDate = year + "-01-01 00:00:00"; + String startDate = year + "-01-01"; String endDate = df.format(new Date()); if(!StringUtils.isEmpty(params.get("startDate"))) { startDate = df.format(params.get("startDate")); @@ -139,8 +157,8 @@ public class CaseScoreController extends AbstractController { if(!StringUtils.isEmpty(params.get("quarter"))) { if(5 == Integer.valueOf(params.get("quarter").toString())) { - startDate = year + "-01-01 00:00:00"; - endDate = year + "-12-31 23:59:59"; + startDate = year + "-01-01"; + endDate = year + "-12-31"; }else { DateRange currentQuarter = DateUtils.returnQuarterCurrent(year, Integer.valueOf(params.get("quarter").toString())); startDate = df.format(currentQuarter.getStart()); @@ -215,4 +233,43 @@ public class CaseScoreController extends AbstractController { LOG.debug("定时请求督查数据结束"); } + /** + * 消息推送用 + * @param sendMap + */ + public void sendMsgToApp(Map sendMap) { + List> resultList = new ArrayList<>(); + List userIds = new ArrayList<>(); + for(Map.Entry entry : sendMap.entrySet()) { + String mapKey = entry.getKey(); + userIds.add(mapKey); + } + Map msgMap = new HashMap<>(); + msgMap.put("userIds", userIds); + msgMap.put("title", "系统消息"); + msgMap.put("msg","你有未及时检查案件"); + msgMap.put("target", "uncheck"); + resultList.add(msgMap); + Map resultMap = new HashMap<>(); + resultMap.put("noticies", resultList); + String sendJson = JSONObject.toJSONString(resultMap); + sendMsg(JSONObject.parseObject(sendJson)); + } + + private void sendMsg(JSONObject jsonObject) { + ClientTokenBO token = ClientTokenManager.getInstance().getClientToken(); + RestTemplate restTemplate = new RestTemplate(); + String url = partyBuildingProperties.getSendUrl(); + url += "/resource/message/noticewithtarget"; + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) + .queryParam("access_token", token.getAccessToken()); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON_UTF8); + + HttpEntity entity = new HttpEntity<>(jsonObject, headers); + ResponseEntity responseEntity = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.POST, entity, JSONObject.class); + } + } \ No newline at end of file diff --git a/src/main/java/com/cm/bigdata/pojo/dtos/casescore/CaseScoreDTO.java b/src/main/java/com/cm/bigdata/pojo/dtos/casescore/CaseScoreDTO.java index c37f85e..4ca0b30 100644 --- a/src/main/java/com/cm/bigdata/pojo/dtos/casescore/CaseScoreDTO.java +++ b/src/main/java/com/cm/bigdata/pojo/dtos/casescore/CaseScoreDTO.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @@ -31,6 +32,10 @@ public class CaseScoreDTO { private List closeTimeout; @ApiModelProperty(name = "inspectTimeout", value = "未及时结案案件") private List inspectTimeout; + @ApiModelProperty(name = "closePushUserIds", value = "未及时处理案件user集合") + private List> closePushUserIds; + @ApiModelProperty(name = "inspectPushUserIds", value = "未及时结案案件user集合") + private List> inspectPushUserIds; public String getAreaId() { return areaId == null ? "" : areaId; @@ -93,4 +98,26 @@ public class CaseScoreDTO { public void setInspectTimeout(List inspectTimeout) { this.inspectTimeout = inspectTimeout; } + + public List> getClosePushUserIds() { + if (closePushUserIds == null) { + return new ArrayList<>(); + } + return closePushUserIds; + } + + public void setClosePushUserIds(List> closePushUserIds) { + this.closePushUserIds = closePushUserIds; + } + + public List> getInspectPushUserIds() { + if (inspectPushUserIds == null) { + return new ArrayList<>(); + } + return inspectPushUserIds; + } + + public void setInspectPushUserIds(List> inspectPushUserIds) { + this.inspectPushUserIds = inspectPushUserIds; + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index beabbf3..9f5163a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ server: - port: 8080 - url: http://192.168.0.120:8080/bigdata + port: 8087 + url: http://192.168.0.111:8087/bigdata title: bigdata servlet: context-path: /bigdata @@ -71,11 +71,13 @@ file: # 安全 security: oauth2: - oauth-server: http://49.233.36.36:8868/usercenter + oauth-server: http://192.168.0.103:7001/usercenter oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url} client: - client-id: 23ee73bf31b54084b2eb977d58435be0 - client-secret: dnljSTJGLzdWSjBudTNyV2MxUXNudStsbndpMFpwbHRKRnlzRkFjNTgrVW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== + # client-id: 23ee73bf31b54084b2eb977d58435be0 + # client-secret: dnljSTJGLzdWSjBudTNyV2MxUXNudStsbndpMFpwbHRKRnlzRkFjNTgrVW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== + client-id: 26c7aaa37d0f4137a0b4d3bd696d2afd + client-secret: QWZXc0kvVzd2eXlaMXRYdUFlUVFUb2x4K1Y3Um1jNnFQSklZSkNFZ3lXQW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== user-authorization-uri: ${security.oauth2.oauth-server}/oauth_client/authorize access-token-uri: ${security.oauth2.oauth-server}/oauth_client/token grant-type: authorization_code @@ -125,13 +127,15 @@ server-other: port: 8085 titile: 党建 - servicecity-url: http://192.168.0.111:8084/servicecity + # servicecity-url: http://192.168.0.111:8084/servicecity + servicecity-url: http://192.168.0.109:8083/servicecity party-url: http://192.168.0.111:8085/partybuilding deptassesst-Url: http://192.168.0.111:8084/servicecity #party-url: http://192.168.0.109:8082/partybuilding logo-url: http://192.168.0.111:8085/partybuilding population-url: http://192.168.0.111:8086/population #servicecity-url: http://219.147.99.164:8082/servicecity + send-url: http://192.168.0.103:7002/social # 考核相关配置 score: