Pārlūkot izejas kodu

企业微信发送模板消息bug修改
手动推送工时功能对接

yurk 2 gadi atpakaļ
vecāks
revīzija
5573e50e45

+ 13 - 13
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -5144,16 +5144,18 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         LocalDate start = LocalDate.parse(dateStr,df);
         LocalDate end = LocalDate.parse(dateStr,df);
         TimeType timeType = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", companyId));
-        List<HashMap<String, Object>> allReportByProject = reportMapper.geReportByProject(start.format(df),companyId,end.format(df));
+        List<HashMap<String, Object>> allReportByProject = reportMapper.geReportByProject("2022-10-01",7,"2022-10-31");
         String url=timeType.getPushReportUrl();
-        //认证的账号和密码
-        HttpHeaders headers=new HttpHeaders();
+        if(timeType.getPushReportUrl()==null||timeType.getPushReportUrl().equals("")){
+            msg.setError("推送失败,请联系服务商完善推送地址!");
+            return msg;
+        }
         JSONObject param = new JSONObject();
         JSONArray array=new JSONArray();
         allReportByProject.forEach(rl->{
             JSONObject object=new JSONObject();
-            object.put("projectMainCode",rl.get("projectMainCode"));
-            object.put("projectMainName",rl.get("projectMainName"));
+            object.put("projectMainCode",rl.get("projectMainCode")==null?"":rl.get("projectMainCode"));
+            object.put("projectMainName",rl.get("projectMainName")==null?"":rl.get("projectMainName"));
             object.put("projectCode",rl.get("projectCode"));
             object.put("project",rl.get("project"));
             object.put("duration",rl.get("duration"));
@@ -5162,13 +5164,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             object.put("month",rl.get("month"));
             array.add(object);
         });
-        JSONObject header=new JSONObject();
-        param.put("IT_TAB",array);
-        JSONObject item=new JSONObject();
-        item.put("headers",header);
-        item.put("body",param);
+        HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.APPLICATION_JSON);
-        HttpEntity<String> requestEntity = new HttpEntity<String>(item.toJSONString(), headers);
+        param.put("data",array);
+        HttpEntity<String> requestEntity = new HttpEntity<String>(param.toJSONString(),headers);
         //过滤掉账号认证失败的时候抛出的401异常
         restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
             @Override
@@ -5183,13 +5182,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         if (response.getStatusCode() == HttpStatus.OK) {
             String resp = response.getBody();
             JSONObject obj = JSONObject.parseObject(resp);
-            if (obj.getString("msg").equals("SUCCESS")) {
+            if (obj.getString("message").equals("SUCCESS")) {
                 msg.data=obj;
                 return msg;
             } else {
                 //抛出异常
                 try {
-                    throw new Exception(obj.getString("msg"));
+                    msg.setError(obj.getString("data"));
+                    throw new Exception(obj.getString("data"));
                 } catch (Exception e) {
                     e.printStackTrace();
                 }

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -357,7 +357,10 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     @Override
     public void sendWXCorpTemplateMsg(WxCorpInfo corpInfo, String corpUserid, JSONObject msg) {
         try {
-            /*if (isDev) return;*/
+            if (isDev) return;
+            if(corpUserid==null||corpInfo.equals("")){
+                return;
+            }
             String accessToken = getCorpAccessToken(corpInfo);
             String url=URL_SEND_WXCORP_MSG.replaceAll("ACCESS_TOKEN", accessToken);
             HttpHeaders headers = new HttpHeaders();