Browse Source

优化代码

Your Name 2 years ago
parent
commit
0e842ca442

+ 18 - 2
service-job/src/main/java/com/java110/job/msgNotify/WechatTemplateImpl.java

@@ -204,7 +204,7 @@ public class WechatTemplateImpl implements IWechatTemplate {
         JSONObject template = null;
         for (int templateIndex = 0; templateIndex < templateLists.size(); templateIndex++) {
             template = templateLists.getJSONObject(templateIndex);
-            if (title.equals(template.getString("title"))) {
+            if (title.equals(template.getString("title")) && templateHasKey(template.getString("content"), keys)) {
                 return template.getString("template_id");
             }
         }
@@ -217,7 +217,7 @@ public class WechatTemplateImpl implements IWechatTemplate {
         templateLists = templateListObj.getJSONArray("template_list");
         for (int templateIndex = 0; templateIndex < templateLists.size(); templateIndex++) {
             template = templateLists.getJSONObject(templateIndex);
-            if (title.equals(template.getString("title"))) {
+            if (title.equals(template.getString("title")) && templateHasKey(template.getString("content"), keys)) {
                 return template.getString("template_id");
             }
         }
@@ -226,6 +226,22 @@ public class WechatTemplateImpl implements IWechatTemplate {
         return "-1";
     }
 
+    /**
+     * 关键字是否都包含
+     * @param content
+     * @param keys
+     * @return
+     */
+    private boolean templateHasKey(String content, String[] keys) {
+        for (String key : keys) {
+            if (!content.contains(key)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
     public String getAccessToken(String communityId) {
         SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
         smallWeChatDto.setWeChatType(SmallWeChatDto.WECHAT_TYPE_PUBLIC);

+ 24 - 24
service-store/src/main/java/com/java110/store/cmd/smallWechat/SaveSmallWechatCmd.java

@@ -297,30 +297,30 @@ public class SaveSmallWechatCmd extends Cmd {
 //        }
 
         //报修通知-上门维修现场收费通知业主 通知--模板ID
-        smallWechatAttrPo = new SmallWechatAttrPo();
-        smallWechatAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
-        smallWechatAttrPo.setCommunityId(reqJson.getString("objId"));
-        smallWechatAttrPo.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_TEMPLATE);
-        smallWechatAttrPo.setValue("这里请填写流程待审批通知模板ID");
-        smallWechatAttrPo.setWechatId(wechatId);
-        flag = smallWechatAttrV1InnerServiceSMOImpl.saveSmallWechatAttr(smallWechatAttrPo);
-
-        if (flag < 1) {
-            throw new CmdException("保存数据失败");
-        }
-
-        //报修通知-上门维修现场收费通知业主 通知--模板ID
-        smallWechatAttrPo = new SmallWechatAttrPo();
-        smallWechatAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
-        smallWechatAttrPo.setCommunityId(reqJson.getString("objId"));
-        smallWechatAttrPo.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_FINISH_TEMPLATE);
-        smallWechatAttrPo.setValue("这里请填写流程审批通知模板ID");
-        smallWechatAttrPo.setWechatId(wechatId);
-        flag = smallWechatAttrV1InnerServiceSMOImpl.saveSmallWechatAttr(smallWechatAttrPo);
-
-        if (flag < 1) {
-            throw new CmdException("保存数据失败");
-        }
+//        smallWechatAttrPo = new SmallWechatAttrPo();
+//        smallWechatAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+//        smallWechatAttrPo.setCommunityId(reqJson.getString("objId"));
+//        smallWechatAttrPo.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_TEMPLATE);
+//        smallWechatAttrPo.setValue("这里请填写流程待审批通知模板ID");
+//        smallWechatAttrPo.setWechatId(wechatId);
+//        flag = smallWechatAttrV1InnerServiceSMOImpl.saveSmallWechatAttr(smallWechatAttrPo);
+//
+//        if (flag < 1) {
+//            throw new CmdException("保存数据失败");
+//        }
+//
+//        //报修通知-上门维修现场收费通知业主 通知--模板ID
+//        smallWechatAttrPo = new SmallWechatAttrPo();
+//        smallWechatAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+//        smallWechatAttrPo.setCommunityId(reqJson.getString("objId"));
+//        smallWechatAttrPo.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_FINISH_TEMPLATE);
+//        smallWechatAttrPo.setValue("这里请填写流程审批通知模板ID");
+//        smallWechatAttrPo.setWechatId(wechatId);
+//        flag = smallWechatAttrV1InnerServiceSMOImpl.saveSmallWechatAttr(smallWechatAttrPo);
+//
+//        if (flag < 1) {
+//            throw new CmdException("保存数据失败");
+//        }
 
 
         cmdDataFlowContext.setResponseEntity(ResultVo.success());