wuxw hai 1 ano
pai
achega
252dd4303a

+ 2 - 0
java110-bean/src/main/java/com/java110/dto/data/DatabusDataDto.java

@@ -29,6 +29,8 @@ public class DatabusDataDto extends PageDto implements Serializable {
     //todo 工作单通知适配器
     public static final String BUSINESS_TYPE_OA_WORK_TASK = "oaWorkTaskToStaff";
 
+    public static final String BUSINESS_TYPE_REPAIR_URGE = "repairUrge";
+
     // 费用公摊
     public static final String BUSINESS_TYPE_SHARE_READING = "floorShareReading";
 

+ 54 - 0
java110-bean/src/main/java/com/java110/dto/notice/NoticeStaffDto.java

@@ -0,0 +1,54 @@
+package com.java110.dto.notice;
+
+import java.io.Serializable;
+
+public class NoticeStaffDto implements Serializable {
+
+    private String communityId;
+    private String staffId;
+    private String title;
+
+    private String notifyUserName;
+
+    public NoticeStaffDto() {
+    }
+
+    public NoticeStaffDto(String communityId, String staffId, String title, String notifyUserName) {
+        this.communityId = communityId;
+        this.staffId = staffId;
+        this.title = title;
+        this.notifyUserName = notifyUserName;
+    }
+
+    public String getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(String communityId) {
+        this.communityId = communityId;
+    }
+
+    public String getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(String staffId) {
+        this.staffId = staffId;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getNotifyUserName() {
+        return notifyUserName;
+    }
+
+    public void setNotifyUserName(String notifyUserName) {
+        this.notifyUserName = notifyUserName;
+    }
+}

+ 8 - 0
service-community/src/main/java/com/java110/community/cmd/repair/PhoneUrgeRepairCmd.java

@@ -7,6 +7,7 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.data.DatabusDataDto;
 import com.java110.dto.privilege.BasePrivilegeDto;
 import com.java110.dto.repair.RepairDto;
 import com.java110.dto.repair.RepairUserDto;
@@ -15,11 +16,13 @@ import com.java110.dto.user.UserDto;
 import com.java110.intf.community.IRepairEventV1InnerServiceSMO;
 import com.java110.intf.community.IRepairInnerServiceSMO;
 import com.java110.intf.community.IRepairUserInnerServiceSMO;
+import com.java110.intf.job.IDataBusInnerServiceSMO;
 import com.java110.intf.order.IPrivilegeInnerServiceSMO;
 import com.java110.intf.user.IUserV1InnerServiceSMO;
 import com.java110.po.repairEvent.RepairEventPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.ListUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -47,6 +50,9 @@ public class PhoneUrgeRepairCmd extends Cmd {
     @Autowired
     private IRepairUserInnerServiceSMO repairUserInnerServiceSMOImpl;
 
+    @Autowired
+    private IDataBusInnerServiceSMO dataBusInnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
         Assert.hasKeyAndValue(reqJson, "repairId", "未包含工单ID");
@@ -81,6 +87,8 @@ public class PhoneUrgeRepairCmd extends Cmd {
 
 
         repairEventV1InnerServiceSMOImpl.saveRepairEvent(repairEventPo);
+
+        dataBusInnerServiceSMOImpl.databusData(new DatabusDataDto(DatabusDataDto.BUSINESS_TYPE_REPAIR_URGE, BeanConvertUtil.beanCovertJson(repairEventPo)));
     }
 
     private void queryStaff(RepairEventPo repairEventPo, RepairDto repairDto) {

+ 0 - 2
service-job/src/main/java/com/java110/job/adapt/Repair/MachineReturnRepairAdapt.java

@@ -87,8 +87,6 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
     @Autowired
     private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMO;
 
-    //模板信息推送地址
-    private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
 
     @Override
     public void execute(Business business, List<Business> businesses) throws Exception {

+ 74 - 0
service-job/src/main/java/com/java110/job/adapt/Repair/RepairUrgeAdapt.java

@@ -0,0 +1,74 @@
+package com.java110.job.adapt.Repair;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.notice.NoticeStaffDto;
+import com.java110.dto.repair.RepairDto;
+import com.java110.dto.repair.RepairSettingDto;
+import com.java110.dto.repairEvent.RepairEventDto;
+import com.java110.dto.system.Business;
+import com.java110.intf.community.IRepairEventV1InnerServiceSMO;
+import com.java110.intf.community.IRepairInnerServiceSMO;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.msgNotify.IMsgNotify;
+import com.java110.job.msgNotify.MsgNotifyFactory;
+import com.java110.po.owner.RepairUserPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.ListUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 报修催单
+ */
+@Component(value = "repairUrgeAdapt")
+public class RepairUrgeAdapt extends DatabusAdaptImpl {
+
+    @Autowired
+    private IRepairEventV1InnerServiceSMO repairEventV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IRepairInnerServiceSMO repairInnerServiceSMOImpl;
+
+    @Override
+    public void execute(Business business, List<Business> businesses) throws Exception {
+        JSONObject data = business.getData();
+        System.out.println("repairUrgeAdapt 收到日志:>>>>>>>>>>>>>" + data.toJSONString());
+        Assert.hasKeyAndValue(data, "eventId", "未包含时间ID");
+        RepairEventDto repairEventDto = new RepairEventDto();
+        repairEventDto.setEventId(data.getString("eventId"));
+
+        List<RepairEventDto> repairEventDtos = repairEventV1InnerServiceSMOImpl.queryRepairEvents(repairEventDto);
+        if (ListUtil.isNull(repairEventDtos)) {
+            return;
+        }
+
+        //获取报修id
+        String repairId = repairEventDtos.get(0).getRepairId();
+        RepairDto repairDto = new RepairDto();
+        repairDto.setRepairId(repairId);
+        repairDto.setStatusCd("0");
+        List<RepairDto> repairDtos = repairInnerServiceSMOImpl.queryRepairs(repairDto);
+
+        Assert.listOnlyOne(repairDtos, "不存在这条报修信息");
+
+        IMsgNotify msgNotify = null;
+        if (RepairSettingDto.NOTIFY_WAY_SMS.equals(repairDtos.get(0).getNotifyWay())) {
+            msgNotify = MsgNotifyFactory.getMsgNotify(MsgNotifyFactory.NOTIFY_WAY_ALI);
+        } else if (RepairSettingDto.NOTIFY_WAY_WECHAT.equals(repairDtos.get(0).getNotifyWay())) {
+            msgNotify = MsgNotifyFactory.getMsgNotify(MsgNotifyFactory.NOTIFY_WAY_WECHAT);
+        } else {
+            return;
+        }
+
+        msgNotify.sendStaffMsg(
+                new NoticeStaffDto(repairDtos.get(0).getCommunityId(),
+                        repairEventDtos.get(0).getStaffId(),
+                        repairDtos.get(0).getRepairSettingTypeName() + "工单催单",
+                        repairDtos.get(0).getRepairName())
+        );
+    }
+}

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

@@ -1,6 +1,7 @@
 package com.java110.job.msgNotify;
 
 import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.notice.NoticeStaffDto;
 import com.java110.vo.ResultVo;
 
 import java.util.List;
@@ -163,4 +164,12 @@ public interface IMsgNotify {
      * @return
      */
     ResultVo sendComplaintMsg(String communityId, String userId, JSONObject content);
+
+    /**
+     * 通知员工
+     *
+     * @param noticeStaffDto
+     * @return
+     */
+    ResultVo sendStaffMsg(NoticeStaffDto noticeStaffDto);
 }

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

@@ -13,6 +13,7 @@ import com.java110.core.factory.AliSendMessageFactory;
 import com.java110.core.factory.CommunitySettingFactory;
 import com.java110.core.factory.LogFactory;
 import com.java110.core.log.LoggerFactory;
+import com.java110.dto.notice.NoticeStaffDto;
 import com.java110.dto.owner.OwnerDto;
 import com.java110.dto.user.StaffAppAuthDto;
 import com.java110.dto.user.UserDto;
@@ -560,4 +561,60 @@ public class AliMsgNotifyImpl implements IMsgNotify {
         }
         return new ResultVo(ResultVo.CODE_OK, "成功");
     }
+
+    @Override
+    public ResultVo sendStaffMsg(NoticeStaffDto noticeStaffDto) {
+        String userId = noticeStaffDto.getStaffId();
+        if (StringUtil.isEmpty(userId) || userId.startsWith("-")) {
+            throw new IllegalArgumentException("员工不存在,userId = " + userId);
+        }
+
+
+        UserDto userDto = new UserDto();
+        userDto.setUserId(userId);
+        List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
+        if (ListUtil.isNull(userDtos)) {
+            throw new IllegalArgumentException("员工不存在");
+        }
+
+
+        String accessKeyId = CommunitySettingFactory.getValue(noticeStaffDto.getCommunityId(), "ALI_ACCESS_KEY_ID");
+        String accessSecret = CommunitySettingFactory.getValue(noticeStaffDto.getCommunityId(), "ALI_ACCESS_SECRET");
+        String region = CommunitySettingFactory.getValue(noticeStaffDto.getCommunityId(), "ALI_REGION");
+        String signName = CommunitySettingFactory.getValue(noticeStaffDto.getCommunityId(), "ALI_SIGN_NAME");
+        String templateCode = CommunitySettingFactory.getValue(noticeStaffDto.getCommunityId(), "ALI_TITLE_TEMPLATE_CODE");
+        DefaultProfile profile = DefaultProfile.getProfile(region,
+                accessKeyId,
+                accessSecret);
+        IAcsClient client = new DefaultAcsClient(profile);
+
+        CommonRequest request = new CommonRequest();
+        request.setSysMethod(MethodType.POST);
+        request.setSysDomain("dysmsapi.aliyuncs.com");
+        request.setSysVersion("2017-05-25");
+        request.setSysAction("SendSms");
+        request.putQueryParameter("RegionId", region);
+        request.putQueryParameter("PhoneNumbers", userDtos.get(0).getTel());
+        request.putQueryParameter("SignName", signName);
+        request.putQueryParameter("TemplateCode", templateCode);
+
+
+        JSONObject param = new JSONObject();
+        param.put("title", noticeStaffDto.getTitle());
+        request.putQueryParameter("TemplateParam", param.toString());
+
+        String resParam = "";
+        try {
+            CommonResponse response = client.getCommonResponse(request);
+            logger.debug("发送验证码信息:{}", response.getData());
+            resParam = response.getData();
+        } catch (Exception e) {
+            e.printStackTrace();
+            resParam = e.getMessage();
+            throw new IllegalArgumentException("短信工单失败" + e.getMessage());
+        } finally {
+            LogFactory.saveOutLog("SMS", param.toString(), new ResponseEntity(resParam, HttpStatus.OK));
+        }
+        return new ResultVo(ResultVo.CODE_OK, "成功");
+    }
 }

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

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.java110.core.client.RestTemplate;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.mapping.Mapping;
+import com.java110.dto.notice.NoticeStaffDto;
 import com.java110.dto.owner.OwnerAppUserDto;
 import com.java110.dto.privilege.RoleCommunityDto;
 import com.java110.dto.user.StaffAppAuthDto;
@@ -102,7 +103,7 @@ public class WechatMsgNotifyImpl implements IMsgNotify {
         staffAppAuthDto.setStaffId(userId);
         staffAppAuthDto.setAppType("WECHAT");
         List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
-        if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+        if (ListUtil.isNull(staffAppAuthDtos)) {
             throw new IllegalArgumentException("员工未认证,没有获取到微信openId");
         }
         String openId = staffAppAuthDtos.get(0).getOpenId();
@@ -370,6 +371,53 @@ public class WechatMsgNotifyImpl implements IMsgNotify {
         return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
     }
 
+    /**
+     * 通知员工
+     *
+     * @param noticeStaffDto
+     * @return
+     */
+    @Override
+    public ResultVo sendStaffMsg(NoticeStaffDto noticeStaffDto) {
+
+        String accessToken = wechatTemplateImpl.getAccessToken(noticeStaffDto.getCommunityId());
+
+        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+        staffAppAuthDto.setStaffId(noticeStaffDto.getStaffId());
+        staffAppAuthDto.setAppType("WECHAT");
+        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+        if (ListUtil.isNull(staffAppAuthDtos)) {
+            throw new IllegalArgumentException("员工未认证,没有获取到微信openId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_PROCESS_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("开发者账户编码映射未配置域为=" + MappingConstant.WECHAT_DOMAIN + ",键为=" + SPEC_CD_WECHAT_PROCESS_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(noticeStaffDto.getCommunityId(), mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_PROCESS_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+
+        JSONObject data = new JSONObject();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.put("thing2", new Content(noticeStaffDto.getTitle()));
+        data.put("time10", new Content(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)));
+        data.put("thing9", new Content(noticeStaffDto.getNotifyUserName()));
+        templateMessage.setData(data);
+        //获取员工公众号地址
+        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);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+    }
+
     /**
      * 派单给业主通知
      *

+ 24 - 0
service-job/src/main/java/com/java110/job/msgNotify/workLicense/WorkLicenseMsgNotifyImpl.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.java110.core.client.RestTemplate;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.mapping.Mapping;
+import com.java110.dto.notice.NoticeStaffDto;
 import com.java110.dto.owner.OwnerAppUserDto;
 import com.java110.dto.user.UserDto;
 import com.java110.dto.wechat.Content;
@@ -499,4 +500,27 @@ public class WorkLicenseMsgNotifyImpl implements IMsgNotify {
         ResultVo resultVo = sendIotImpl.post(PLAY_TTS_URL, paramIn);
         return resultVo;
     }
+
+    @Override
+    public ResultVo sendStaffMsg(NoticeStaffDto noticeStaffDto) {
+        String userId = noticeStaffDto.getStaffId();
+        if (StringUtil.isEmpty(userId) || userId.startsWith("-")) {
+            throw new IllegalArgumentException("员工不存在,userId = " + userId);
+        }
+
+
+        UserDto userDto = new UserDto();
+        userDto.setUserId(userId);
+        List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
+        if (ListUtil.isNull(userDtos)) {
+            throw new IllegalArgumentException("员工不存在");
+        }
+
+
+        JSONObject paramIn = new JSONObject();
+        paramIn.put("staffTel", userDtos.get(0).getTel());
+        paramIn.put("ttsText", "尊敬的员工,您有一个" + noticeStaffDto.getTitle() + ",请您及时处理");
+        ResultVo resultVo = sendIotImpl.post(PLAY_TTS_URL, paramIn);
+        return resultVo;
+    }
 }