Your Name лет назад: 2
Родитель
Сommit
144c48fc3c

+ 10 - 27
service-job/src/main/java/com/java110/job/adapt/Repair/MachineAddOwnerRepairAdapt.java

@@ -23,6 +23,7 @@ import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
 import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO;
 import com.java110.intf.user.IStaffAppAuthInnerServiceSMO;
 import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.msgNotify.MsgNotifyFactory;
 import com.java110.po.owner.RepairPoolPo;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.MappingConstant;
@@ -173,42 +174,24 @@ public class MachineAddOwnerRepairAdapt extends DatabusAdaptImpl {
         basePrivilegeDto.setStoreId(communityMemberDtos.get(0).getMemberId());
         basePrivilegeDto.setCommunityId(communityMemberDtos.get(0).getCommunityId());
         List<UserDto> userDtos = privilegeInnerServiceSMO.queryPrivilegeUsers(basePrivilegeDto);
-        String url = sendMsgUrl + accessToken;
         List<String> userIds = new ArrayList<>();
         for (UserDto userDto : userDtos) {
             if (userIds.contains(userDto.getUserId())) {
                 continue;
             }
-            userIds.add(userDto.getUserId());
-            //根据 userId 查询到openId
-            StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
-            staffAppAuthDto.setStaffId(userDto.getUserId());
-            staffAppAuthDto.setAppType("WECHAT");
-            List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
-            if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
-                continue;
-            }
-            String openId = staffAppAuthDtos.get(0).getOpenId();
-            Data data = new Data();
-            PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
-            templateMessage.setTemplate_id(templateId);
-            templateMessage.setTouser(openId);
-            data.setFirst(new Content("业主" + paramIn.getString("repairName") + "提交了新的报修工单,报修信息如下:"));
-            data.setKeyword1(new Content(paramIn.getString("repairTypeName")));
+
+            JSONObject content = new JSONObject();
+            content.put("repairTypeName",paramIn.getString("repairTypeName"));
             if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
-                data.setKeyword2(new Content(paramIn.getString("repairObjName")));
+                content.put("repairObjName",paramIn.getString("repairObjName"));
             } else {
-                data.setKeyword2(new Content(communityDto.getName() + paramIn.getString("repairObjName")));
+                content.put("repairObjName",communityDto.getName() + paramIn.getString("repairObjName"));
             }
-            data.setKeyword3(new Content(paramIn.getString("context")));
-            data.setRemark(new Content("请您及时确认信息,并安排相关人员进行处理,感谢您的使用!"));
-            templateMessage.setData(data);
-            //获取员工公众号地址
+            content.put("repairName",paramIn.getString("repairName"));
             String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN,"STAFF_WECHAT_URL");
-            templateMessage.setUrl(wechatUrl);
-            logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
-            ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
-            logger.info("微信模板返回内容:{}", responseEntity);
+            content.put("url",wechatUrl);
+
+            MsgNotifyFactory.sendAddOwnerRepairMsg(communityDto.getCommunityId(),userDto.getUserId(),content);
         }
     }
 }

+ 14 - 0
service-job/src/main/java/com/java110/job/msgNotify/IMsgNotify.java

@@ -47,4 +47,18 @@ public interface IMsgNotify {
      * }
      */
     ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content,String role);
+
+    /**
+     * 业主报修时
+     * @param communityId 小区
+     * @param userId 用户
+     * @param content {
+     *                repairTypeName,
+     *                repairObjName,
+     *                repairName,
+     *                url
+     * }
+     * @return
+     */
+    ResultVo sendAddOwnerRepairMsg(String communityId, String userId, JSONObject content);
 }

+ 17 - 0
service-job/src/main/java/com/java110/job/msgNotify/MsgNotifyFactory.java

@@ -72,6 +72,23 @@ public class MsgNotifyFactory {
         return msgNotify.sendPayFeeMsg(communityId, userId, content, role);
     }
 
+    /**
+     * 业主报修时
+     * @param communityId 小区
+     * @param userId 用户
+     * @param content {
+     *                repairTypeName,
+     *                repairObjName,
+     *                repairName,
+     *                url
+     * }
+     * @return
+     */
+    public static ResultVo sendAddOwnerRepairMsg(String communityId,String userId,JSONObject content){
+        IMsgNotify msgNotify = getMsgNotify();
+        return msgNotify.sendAddOwnerRepairMsg(communityId, userId, content);
+    }
+
     /**
      * 获取通知适配器
      *

+ 5 - 0
service-job/src/main/java/com/java110/job/msgNotify/ali/AliMsgNotifyImpl.java

@@ -21,4 +21,9 @@ public class AliMsgNotifyImpl implements IMsgNotify {
     public ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content,String role) {
         return null;
     }
+
+    @Override
+    public ResultVo sendAddOwnerRepairMsg(String communityId, String userId, JSONObject content) {
+        return null;
+    }
 }

+ 5 - 0
service-job/src/main/java/com/java110/job/msgNotify/tencent/TencentMsgNotifyImpl.java

@@ -21,4 +21,9 @@ public class TencentMsgNotifyImpl implements IMsgNotify {
     public ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content,String role) {
         return null;
     }
+
+    @Override
+    public ResultVo sendAddOwnerRepairMsg(String communityId, String userId, JSONObject content) {
+        return null;
+    }
 }

+ 51 - 1
service-job/src/main/java/com/java110/job/msgNotify/wechat/WechatMsgNotifyImpl.java

@@ -60,7 +60,7 @@ public class WechatMsgNotifyImpl implements IMsgNotify {
         templateKeys.put(SPEC_CD_OWE_FEE_TEMPLATE, new String[]{"缴费类型","房号","总金额","缴费周期"});
         templateKeys.put(SPEC_CD_WECHAT_PROCESS_TEMPLATE, new String[]{"流程名称", "发起时间", "发起人"});
         templateKeys.put(SPEC_CD_WECHAT_SUCCESS_TEMPLATE, new String[]{"缴费房间", "费用类型", "缴费时间", "缴费金额"});
-
+        templateKeys.put(SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE, new String[]{"报修类型","报修地址","报修问题"});
 
     }
 
@@ -230,4 +230,54 @@ public class WechatMsgNotifyImpl implements IMsgNotify {
 
 
     }
+
+    /**
+     * 业主报修时
+     * @param communityId 小区
+     * @param userId 用户
+     * @param content {
+     *                repairTypeName,
+     *                repairObjName,
+     *                repairName,
+     *                url
+     * }
+     * @return
+     */
+    @Override
+    public ResultVo sendAddOwnerRepairMsg(String communityId, String userId, JSONObject content) {
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+
+        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+        staffAppAuthDto.setStaffId(userId);
+        staffAppAuthDto.setAppType("WECHAT");
+        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+        if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+            throw new IllegalArgumentException("员工未认证,没有获取到微信openId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("开发者账户编码映射未配置域为=" + MappingConstant.WECHAT_DOMAIN + ",键为=" + SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+        Data data = new Data();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.setKeyword1(new Content(content.getString("repairTypeName")));
+        data.setKeyword2(new Content(content.getString("repairObjName")));
+        data.setKeyword3(new Content(content.getString("repairName")));
+        templateMessage.setData(data);
+        templateMessage.setUrl(content.getString("url"));
+        logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+        logger.info("微信模板返回内容:{}", responseEntity);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+    }
 }

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

@@ -187,17 +187,17 @@ public class SaveSmallWechatCmd extends Cmd {
             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_WORK_ORDER_REMIND_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_WORK_ORDER_REMIND_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));