Forráskód Böngészése

柘中定时发送消息,审核人接收信息:测试修改

yusm 4 hónapja
szülő
commit
175cf6b620

+ 36 - 90
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -472,45 +472,13 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
             targetUserList.add(owner);
             WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
             if (wxCorpInfo != null) {
-                String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
-                ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
                 //推送到企业微信
-                JSONObject json=new JSONObject();
-                JSONArray dataJson=new JSONArray();
-                JSONObject jsonObj=new JSONObject();
-                jsonObj.put("key", "报销人");
-                jsonObj.put("value",("$userName="+owner.getCorpwxUserid()+"$"));
-                JSONObject jsonObj1=new JSONObject();
-                jsonObj1.put("key", "填报日期");
-                jsonObj1.put("value",sheet.getCreateDate()==null?"":sheet.getCreateDate());
-                JSONObject jsonObj2=new JSONObject();
-                jsonObj2.put("key", "票据类型");
-                jsonObj2.put("value",mainType.getName());
-                JSONObject jsonObj3=new JSONObject();
-                jsonObj2.put("key", "提示");
-                jsonObj2.put("value","请及时填写报销单信息");
-                dataJson.add(jsonObj);
-                dataJson.add(jsonObj1);
-                dataJson.add(jsonObj2);
-                dataJson.add(jsonObj3);
-                json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
-                json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
-                json.put("content_item",dataJson);
-                wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
+                StringBuilder stringBuilder = new StringBuilder();
+                stringBuilder.append("$userName="+owner.getCorpwxUserid()+"$")
+                        .append(":有票据类型为机械费用的报销单待填写");
+                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,owner.getCorpwxUserid(), stringBuilder.toString(), "expense",
+                        WxCorpInfoServiceImpl.TEXT_CARD_MSG_EXPENSE_UN);
             }
-
-            List<Information> informationList=new ArrayList<>();
-            for (User item : targetUserList) {
-                Information information=new Information();
-                information.setUserId(item.getId());
-                information.setTime(LocalDateTime.now());
-                information.setMsg("机械费用报销待报销人填写信息");
-                information.setType(3);
-                information.setContent(sheet.getCreateDate()+"");
-                informationList.add(information);
-            }
-            informationService.saveBatch(informationList);
-
         }
         //柘中报销人填写报销单信息,完善填报金额,第一审核人,第二审核人信息,给第一审核人发送信息
         if (!isNew&& auditSetting != null && auditSetting.getAuditType() == 2&&sheet.getReviewProcess()==0){
@@ -521,49 +489,15 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
             targetUserList.add(firstChecker);
             WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
             if (wxCorpInfo != null) {
-                String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
                 User targetUser = userMapper.selectById(sheet.getOwnerId());
-                ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
                 //推送到企业微信
-                JSONObject json=new JSONObject();
-                JSONArray dataJson=new JSONArray();
-                JSONObject jsonObj=new JSONObject();
-                jsonObj.put("key", "报销人");
-                jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
-                JSONObject jsonObj1=new JSONObject();
-                jsonObj1.put("key", "填报日期");
-                jsonObj1.put("value",sheet.getCreateDate());
-                JSONObject jsonObj2=new JSONObject();
-                jsonObj2.put("key", "票据类型");
-                jsonObj2.put("value",mainType.getName());
-                JSONObject jsonObj3=new JSONObject();
-                jsonObj3.put("key", "金额");
-                jsonObj3.put("value",sheet.getTotalAmount());
-                JSONObject jsonObj4=new JSONObject();
-                jsonObj4.put("key", "备注");
-                jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
-                dataJson.add(jsonObj);
-                dataJson.add(jsonObj1);
-                dataJson.add(jsonObj2);
-                dataJson.add(jsonObj3);
-                dataJson.add(jsonObj4);
-                json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
-                json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
-                json.put("content_item",dataJson);
-                wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
-            }
+                StringBuilder stringBuilder = new StringBuilder();
+                stringBuilder.append("报销人:").append("$userName="+targetUser.getCorpwxUserid()+"$")
+                        .append(",填写了机械费用报销单的信息,请及时审核");
 
-            List<Information> informationList=new ArrayList<>();
-            for (User item : targetUserList) {
-                Information information=new Information();
-                information.setUserId(item.getId());
-                information.setTime(LocalDateTime.now());
-                information.setMsg("费用报销待审核");
-                information.setType(3);
-                information.setContent(sheet.getCreateDate()+"");
-                informationList.add(information);
+                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,firstChecker.getCorpwxUserid(), stringBuilder.toString(), "expense",
+                        WxCorpInfoServiceImpl.TEXT_CARD_MSG_EXPENSE_NEED);
             }
-            informationService.saveBatch(informationList);
         }
         return msg;
     }
@@ -835,7 +769,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 User secondChecker = userMapper.selectById(sheet.getSecondCheckerId());
                 targetUserList.add(secondChecker);
                 WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
-                if (wxCorpInfo != null) {
+                if (wxCorpInfo != null&&user.getCompanyId()!=Constant.ZHE_ZHONG_COMPANY_ID) {
                     String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
                     User targetUser = userMapper.selectById(sheet.getOwnerId());
                     ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
@@ -866,19 +800,28 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                     json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
                     json.put("content_item",dataJson);
                     wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
-                }
 
-                List<Information> informationList=new ArrayList<>();
-                for (User item : targetUserList) {
-                    Information information=new Information();
-                    information.setUserId(item.getId());
-                    information.setTime(LocalDateTime.now());
-                    information.setMsg("费用报销待审核");
-                    information.setType(3);
-                    information.setContent(sheet.getCreateDate()+"");
-                    informationList.add(information);
+                    List<Information> informationList=new ArrayList<>();
+                    for (User item : targetUserList) {
+                        Information information=new Information();
+                        information.setUserId(item.getId());
+                        information.setTime(LocalDateTime.now());
+                        information.setMsg("费用报销待审核");
+                        information.setType(3);
+                        information.setContent(sheet.getCreateDate()+"");
+                        informationList.add(information);
+                    }
+                    informationService.saveBatch(informationList);
+                }{
+                    User targetUser = userMapper.selectById(sheet.getOwnerId());
+                    //推送到企业微信
+                    StringBuilder stringBuilder = new StringBuilder();
+                    stringBuilder.append("报销人:").append("$userName="+targetUser.getCorpwxUserid()+"$")
+                            .append(",填写了机械费用报销单的信息,请及时审核");
+
+                    wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,secondChecker.getCorpwxUserid(), stringBuilder.toString(), "expense",
+                            WxCorpInfoServiceImpl.TEXT_CARD_MSG_EXPENSE_NEED);
                 }
-                informationService.saveBatch(informationList);
             }
             else if(sheet.getReviewProcess()!=null&&sheet.getReviewProcess()==1){
                 sheet.setReviewProcess(2);
@@ -946,8 +889,11 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         }
         stringBuilder.append("的费用报销申请。");
         if (sheet.getStatus() == 2) {
-            //驳回加原因
-            stringBuilder.append("原因: ").append(denyReason);
+            if (org.apache.commons.lang3.StringUtils.isNotEmpty(denyReason))
+            {
+                //驳回加原因
+                stringBuilder.append("原因: ").append(denyReason);
+            }
         }
 
         String ownerId = sheet.getOwnerId();

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

@@ -115,6 +115,9 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     public static final int TEXT_CARD_MSG_TASK_FILE_UPDATE = 24;//任务文件更新
     public static final int TEXT_CARD_MSG_TASK_FILE_REJECT = 25;//任务文件驳回
 
+    public static final int TEXT_CARD_MSG_EXPENSE_NEED = 26;//费用报销待审核
+    public static final int TEXT_CARD_MSG_EXPENSE_UN = 27;//费用报销待填写
+
     private static Object userLock = new Object();
 
     @Value("${suitId}")
@@ -333,7 +336,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         try {
             log.info("发送企业微信消息===" + corpUserid);
             System.out.println("发送企业微信消息===" + corpUserid);
-            if (isDev) return;
+//            if (isDev) return;
             String accessToken = getCorpAccessToken(corpInfo);
             String url = URL_SEND_WXCORP_MSG.replaceAll("ACCESS_TOKEN", accessToken);
             HttpHeaders headers = new HttpHeaders();
@@ -387,6 +390,10 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         title = "费用报销审核通过";
                     } else if (msgType.equals(TEXT_CARD_MSG_EXPENSE_DENY)) {
                         title = "费用报销审核驳回";
+                    } else if (msgType.equals(TEXT_CARD_MSG_EXPENSE_NEED)) {
+                        title = "费用报销待审核";
+                    }else if (msgType.equals(TEXT_CARD_MSG_EXPENSE_UN)) {
+                        title = "费用报销待填写";
                     }
                 }
                 else if ("task".equals(pageRouter)) {

+ 6 - 44
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -1204,55 +1204,17 @@ public class TimingTask {
         if (isDev) return;
         List<ExpenseSheet> expenseSheetList = expenseSheetMapper.selectList(new QueryWrapper<ExpenseSheet>().eq("status", 4).eq("company_id", Constant.ZHE_ZHONG_COMPANY_ID));
         if (!expenseSheetList.isEmpty()) {
-            List<Information> informationList=new ArrayList<>();
+            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", Constant.ZHE_ZHONG_COMPANY_ID));
             for (ExpenseSheet sheet : expenseSheetList) {
-                List<User> targetUserList = new ArrayList<>();
                 User owner = userMapper.selectById(sheet.getOwnerId());
-                targetUserList.add(owner);
-                WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", Constant.ZHE_ZHONG_COMPANY_ID));
-                if (wxCorpInfo != null) {
-                    String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
-                    ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
-                    //推送到企业微信
-                    JSONObject json=new JSONObject();
-                    JSONArray dataJson=new JSONArray();
-                    JSONObject jsonObj=new JSONObject();
-                    jsonObj.put("key", "报销人");
-                    jsonObj.put("value",("$userName="+owner.getCorpwxUserid()+"$"));
-                    JSONObject jsonObj1=new JSONObject();
-                    jsonObj1.put("key", "填报日期");
-                    jsonObj1.put("value",sheet.getCreateDate()==null?"":sheet.getCreateDate());
-                    JSONObject jsonObj2=new JSONObject();
-                    jsonObj2.put("key", "票据类型");
-                    jsonObj2.put("value",mainType.getName());
-                    JSONObject jsonObj3=new JSONObject();
-                    jsonObj2.put("key", "提示");
-                    jsonObj2.put("value","请及时填写报销单信息");
-                    dataJson.add(jsonObj);
-                    dataJson.add(jsonObj1);
-                    dataJson.add(jsonObj2);
-                    dataJson.add(jsonObj3);
-                    json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
-                    json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
-                    json.put("content_item",dataJson);
-                    wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
-                }
-
-                for (User item : targetUserList) {
-                    Information information=new Information();
-                    information.setUserId(item.getId());
-                    information.setTime(LocalDateTime.now());
-                    information.setMsg("机械费用报销待报销人填写信息");
-                    information.setType(3);
-                    information.setContent(sheet.getCreateDate()+"");
-                    informationList.add(information);
-                }
+                StringBuilder stringBuilder = new StringBuilder();
+                stringBuilder.append("$userName="+owner.getCorpwxUserid()+"$")
+                        .append(":有票据类型为机械费用的报销单待填写");
+                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,owner.getCorpwxUserid(), stringBuilder.toString(), "expense",
+                        WxCorpInfoServiceImpl.TEXT_CARD_MSG_EXPENSE_UN);
             }
-            informationService.saveBatch(informationList);
         }
-
     }
-
     //每天2点10分 自动审核超过指定天数的日报
     @Scheduled(cron = "0 10 2 ? * *")
     private void autoApprove() {