Blame view

service-job/src/main/java/com/java110/job/adapt/complaint/SendComplaintNotifyStaffAdapt.java 3.76 KB
88e030b7   王彪总   init project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  package com.java110.job.adapt.complaint;
  
  import com.alibaba.fastjson.JSONObject;
  import com.java110.core.log.LoggerFactory;
  import com.java110.dto.complaint.ComplaintDto;
  import com.java110.dto.complaint.ComplaintTypeDto;
  import com.java110.dto.complaint.ComplaintTypeUserDto;
  import com.java110.dto.system.Business;
  import com.java110.intf.store.IComplaintTypeUserV1InnerServiceSMO;
  import com.java110.intf.store.IComplaintTypeV1InnerServiceSMO;
  import com.java110.intf.store.IComplaintV1InnerServiceSMO;
  import com.java110.job.adapt.DatabusAdaptImpl;
  import com.java110.job.msgNotify.IMsgNotify;
  import com.java110.job.msgNotify.MsgNotifyFactory;
  import com.java110.utils.cache.MappingCache;
  import com.java110.utils.constant.MappingConstant;
  import com.java110.utils.util.ListUtil;
  import com.java110.utils.util.StringUtil;
  import org.slf4j.Logger;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import java.util.List;
  
  /**
   * 投诉单推送消息给员工
   */
  
  @Component(value = "sendComplaintNotifyStaffAdapt")
  public class SendComplaintNotifyStaffAdapt extends DatabusAdaptImpl {
  
      private static Logger logger = LoggerFactory.getLogger(SendComplaintNotifyStaffAdapt.class);
  
  
      @Autowired
      private IComplaintV1InnerServiceSMO complaintV1InnerServiceSMOImpl;
  
      @Autowired
      private IComplaintTypeV1InnerServiceSMO complaintTypeV1InnerServiceSMOImpl;
  
      @Autowired
      private IComplaintTypeUserV1InnerServiceSMO complaintTypeUserV1InnerServiceSMOImpl;
  
  
      @Override
      public void execute(Business business, List<Business> businesses) throws Exception {
          JSONObject data = business.getData();
  
          String complaintId = data.getString("complaintId");
  
          if (StringUtil.isEmpty(complaintId)) {
              return;
          }
  
  
          ComplaintDto complaintDto = new ComplaintDto();
          complaintDto.setComplaintId(complaintId);
          List<ComplaintDto> complaintDtos = complaintV1InnerServiceSMOImpl.queryComplaints(complaintDto);
  
          if (ListUtil.isNull(complaintDtos)) {
              return;
          }
  
          ComplaintTypeDto complaintTypeDto = new ComplaintTypeDto();
          complaintTypeDto.setTypeCd(complaintDtos.get(0).getTypeCd());
          List<ComplaintTypeDto> complaintTypeDtos = complaintTypeV1InnerServiceSMOImpl.queryComplaintTypes(complaintTypeDto);
  
          if(ListUtil.isNull(complaintTypeDtos)){
              return;
          }
  
          ComplaintTypeUserDto complaintTypeUserDto = new ComplaintTypeUserDto();
          complaintTypeUserDto.setTypeCd(complaintDtos.get(0).getTypeCd());
          List<ComplaintTypeUserDto> complaintTypeUserDtos = complaintTypeUserV1InnerServiceSMOImpl.queryComplaintTypeUsers(complaintTypeUserDto);
  
          if (ListUtil.isNull(complaintTypeUserDtos)) {
              return;
          }
  
          JSONObject content = new JSONObject();
          content.put("complaintName", complaintDtos.get(0).getComplaintName());
          content.put("orderId", complaintId);
  
          String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
          content.put("url", wechatUrl);
          IMsgNotify msgNotify = null;
          if(ComplaintTypeDto.NOTIFY_WAY_SMS.equals(complaintTypeDtos.get(0).getNotifyWay())) {
              msgNotify = MsgNotifyFactory.getMsgNotify(MsgNotifyFactory.NOTIFY_WAY_ALI);
          }else if(ComplaintTypeDto.NOTIFY_WAY_WECHAT.equals(complaintTypeDtos.get(0).getNotifyWay())){
              msgNotify = MsgNotifyFactory.getMsgNotify(MsgNotifyFactory.NOTIFY_WAY_WECHAT);
          }else{
              return;
          }
  
          for(ComplaintTypeUserDto tmpComplaintTypeUserDto:complaintTypeUserDtos) {
               msgNotify.sendComplaintMsg(tmpComplaintTypeUserDto.getCommunityId(), tmpComplaintTypeUserDto.getStaffId(), content);
          }
  
      }
  
  }