From a20310f135ebf1c8ccff2b619f3eff3d704436a0 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期四, 08 十二月 2022 13:12:03 +0800
Subject: [PATCH] Merge branch 'xinghong-dev' of http://git.homecommunity.cn/supervip/MicroCommunity
---
service-job/src/main/java/com/java110/job/adapt/Repair/MachineDistributeLeaflets.java | 208 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 163 insertions(+), 45 deletions(-)
diff --git a/service-job/src/main/java/com/java110/job/adapt/Repair/MachineDistributeLeaflets.java b/service-job/src/main/java/com/java110/job/adapt/Repair/MachineDistributeLeaflets.java
old mode 100644
new mode 100755
index 023a69f..967c5fc
--- a/service-job/src/main/java/com/java110/job/adapt/Repair/MachineDistributeLeaflets.java
+++ b/service-job/src/main/java/com/java110/job/adapt/Repair/MachineDistributeLeaflets.java
@@ -1,9 +1,13 @@
package com.java110.job.adapt.Repair;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.java110.core.factory.CommunitySettingFactory;
import com.java110.core.factory.WechatFactory;
+import com.java110.core.log.LoggerFactory;
import com.java110.dto.community.CommunityDto;
+import com.java110.dto.file.FileRelDto;
import com.java110.dto.owner.OwnerAppUserDto;
import com.java110.dto.repair.RepairDto;
import com.java110.dto.repair.RepairUserDto;
@@ -15,18 +19,23 @@
import com.java110.entity.wechat.Content;
import com.java110.entity.wechat.Data;
import com.java110.entity.wechat.PropertyFeeTemplateMessage;
+import com.java110.intf.common.IFileRelInnerServiceSMO;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.community.IRepairInnerServiceSMO;
import com.java110.intf.community.IRepairUserInnerServiceSMO;
import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO;
-import com.java110.intf.user.*;
+import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
+import com.java110.intf.user.IStaffAppAuthInnerServiceSMO;
+import com.java110.intf.user.IUserInnerServiceSMO;
import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.po.owner.RepairUserPo;
import com.java110.utils.cache.MappingCache;
+import com.java110.utils.util.ImageUtils;
import com.java110.utils.util.StringUtil;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@@ -72,23 +81,48 @@
@Autowired
private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMO;
+ @Autowired
+ private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
+
//妯℃澘淇℃伅鎺ㄩ�佸湴鍧�
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) {
+ JSONObject data = business.getData();
+ JSONArray businessRepairUsers = new JSONArray();
+ System.out.println("鏀跺埌鏃ュ織锛�>>>>>>>>>>>>>" + data.toJSONString());
+ if (data.containsKey(RepairUserPo.class.getSimpleName())) {
+ Object bObj = data.get(RepairUserPo.class.getSimpleName());
+ if (bObj instanceof JSONObject) {
+ businessRepairUsers.add(bObj);
+ } else if (bObj instanceof List) {
+ businessRepairUsers = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+ } else {
+ businessRepairUsers = (JSONArray) bObj;
+ }
+ } else {
+ if (data instanceof JSONObject) {
+ businessRepairUsers.add(data);
+ }
+ }
+ for (int bOwnerRepairIndex = 0; bOwnerRepairIndex < businessRepairUsers.size(); bOwnerRepairIndex++) {
+ JSONObject businessRepairUser = businessRepairUsers.getJSONObject(bOwnerRepairIndex);
+ doDealOwnerRepair(businesses, businessRepairUser);
+ }
+ }
+
+ private void doDealOwnerRepair(List<Business> businesses, JSONObject businessRepairUser) {
RepairUserDto repairUserDto = new RepairUserDto();
- repairUserDto.setbId(business.getbId());
- repairUserDto.setStatusCd("0");
+ repairUserDto.setRuId(businessRepairUser.getString("ruId"));
List<RepairUserDto> repairUserDtos = repairUserInnerServiceSMO.queryRepairUsers(repairUserDto);
- //鑾峰彇鍛樺伐澶勭悊鐘舵��(10001 澶勭悊涓紱10002 缁撳崟锛�10003 閫�鍗曪紱10004 杞崟锛�10005 鎻愪氦)
+ //鑾峰彇鍛樺伐澶勭悊鐘舵��(10001 澶勭悊涓紱10002 缁撳崟锛�10003 閫�鍗曪紱10004 杞崟锛�10005 鎻愪氦锛�10006 宸叉淳鍗曪紱10007 宸茶瘎浠凤紱10008 宸插洖璁匡紱10009 寰呮敮浠橈紱11000 寰呰瘎浠凤紱12000 宸叉敮浠橈紱12001 鏆傚仠)
String state = repairUserDtos.get(0).getState();
if (!state.equals("10005")) {
//鑾峰彇鎶ヤ慨id
String repairId = repairUserDtos.get(0).getRepairId();
RepairDto repairDto = new RepairDto();
repairDto.setRepairId(repairId);
- repairDto.setStatusCd("0");
List<RepairDto> repairDtos = repairInnerServiceSMO.queryRepairs(repairDto);
//鏌ヨ鎶ヤ慨鐘舵��(1000 鏈淳鍗曪紱1100 鎺ュ崟锛�1200 閫�鍗曪紱1300 杞崟锛�1400 鐢宠鏀粯锛�1500 鏀粯澶辫触锛�1700 寰呰瘎浠凤紱1800 鐢佃瘽鍥炶锛�1900 鍔炵悊瀹屾垚锛�2000 鏈姙鐞嗙粨鍗�)
String repairState = repairDtos.get(0).getState();
@@ -111,68 +145,58 @@
CommunityDto communityDto = new CommunityDto();
communityDto.setCommunityId(communityId);
List<CommunityDto> communityDtos = communityInnerServiceSMO.queryCommunitys(communityDto);
- //娲惧崟鏂瑰紡(100琛ㄧず鎶㈠崟锛�200琛ㄧず鎸囨淳锛�300琛ㄧず杞)
- String repairWay = repairDtos.get(0).getRepairWay();
- if (repairState.equals("1100") && repairWay.equals("200")) {
- //鑾峰彇缁翠慨鍛樺伐鐨刬d
- String staffId = repairUserDtos.get(1).getStaffId();
- //鑾峰彇鐢ㄦ埛id
- String preStaffId = repairUserDtos.get(0).getPreStaffId();
+ if (repairState.equals("1100") && businessRepairUser.getString("state").equals("10006")) { //娲惧崟
JSONObject paramIn = new JSONObject();
+ for (Business business : businesses) {
+ String businessTypeCd = business.getBusinessTypeCd();
+ if (!StringUtil.isEmpty(businessTypeCd) && businessTypeCd.equals("130200030001")) {
+ JSONObject data = business.getData();
+ if (!StringUtil.isEmpty(data.getString("state")) && data.getString("state").equals("10001")) {
+ paramIn.put("staffId", data.getString("staffId"));
+ paramIn.put("staffName", data.getString("staffName"));
+ } else if (data.getString("state").equals("10006")) {
+ paramIn.put("preStaffId", data.getString("preStaffId"));
+ paramIn.put("preStaffName", data.getString("preStaffName"));
+ }
+ }
+ }
paramIn.put("repairName", repairName);
paramIn.put("repairObjName", repairObjName);
paramIn.put("tel", tel);
paramIn.put("communityId", communityId);
paramIn.put("context", context);
paramIn.put("time", time);
- paramIn.put("staffId", staffId);
paramIn.put("repairObjId", repairObjId);
- paramIn.put("preStaffId", preStaffId);
+ paramIn.put("repairId", repairId);
//缁欑淮淇笀鍌呮帹閫佷俊鎭�
sendMsg(paramIn, communityDtos.get(0));
//娲惧崟鎴愬姛缁欎笟涓绘帹閫佷俊鎭�
publishMsg(paramIn, communityDtos.get(0));
- } else if (repairState.equals("1100") && repairWay.equals("100")) {
- String staffId = "";
- if (repairUserDtos.size() > 1) {
- staffId = repairUserDtos.get(1).getStaffId();
- } else {
- //鑾峰彇缁翠慨鍛樺伐鐨刬d
- staffId = repairUserDtos.get(0).getStaffId();
- }
- //鑾峰彇鐢ㄦ埛id
- String preStaffId = repairUserDtos.get(0).getPreStaffId();
+ //涓轰紒涓氬井淇$兢鍙戞秷鎭�
+ sendMsgToWechatGroup(paramIn, communityDtos.get(0));
+ } else if (repairState.equals("1100") && !businessRepairUser.getString("state").equals("10006")) {
JSONObject paramIn = new JSONObject();
- paramIn.put("staffId", staffId);
+ paramIn.put("staffId", businessRepairUser.getString("staffId"));
paramIn.put("context", context);
paramIn.put("time", time);
paramIn.put("repairObjId", repairObjId);
- paramIn.put("preStaffId", preStaffId);
+ paramIn.put("preStaffId", businessRepairUser.getString("preStaffId"));
paramIn.put("repairName", repairName);
paramIn.put("tel", tel);
paramIn.put("repairObjName", repairObjName);
+ //鎶㈠崟鎴愬姛缁欑淮淇笀鍌呮帹閫佷俊鎭�
+ publishMessage(paramIn, communityDtos.get(0));
//鎶㈠崟鎴愬姛缁欎笟涓绘帹閫佷俊鎭�
publishMsg(paramIn, communityDtos.get(0));
- if (repairUserDtos.size() > 1) {
- //缁欑淮淇笀鍌呮帹閫佷俊鎭�
- sendMsg(paramIn, communityDtos.get(0));
- }else {
- //鎶㈠崟鎴愬姛缁欑淮淇笀鍌呮帹閫佷俊鎭�
- publishMessage(paramIn, communityDtos.get(0));
- }
} else if (repairState.equals("1300")) { //杞崟
- //鑾峰彇缁翠慨鍛樺伐id
- String staffId = repairUserDtos.get(0).getStaffId();
- //鑾峰彇涓婄骇鐢ㄦ埛濮撳悕
- String preStaffName = repairUserDtos.get(0).getPreStaffName();
JSONObject paramIn = new JSONObject();
paramIn.put("repairName", repairName);
paramIn.put("repairObjName", repairObjName);
paramIn.put("tel", tel);
paramIn.put("context", context);
paramIn.put("time", time);
- paramIn.put("staffId", staffId);
- paramIn.put("preStaffName", preStaffName);
+ paramIn.put("staffId", businessRepairUser.getString("staffId"));
+ paramIn.put("preStaffName", businessRepairUser.getString("preStaffName"));
//缁欑淮淇笀鍌呮帹閫佷俊鎭�
sendMessage(paramIn, communityDtos.get(0));
}
@@ -231,7 +255,8 @@
data.setKeyword4(new Content(paramIn.getString("context") + "\r\n" + "鎶ヤ慨浣嶇疆锛�" + paramIn.getString("repairObjName")));
data.setRemark(new Content(paramIn.getString("preStaffName") + "杞崟缁欐偍锛岃鍙婃椂鐧诲綍鍏紬鍙锋帴鍗曠‘璁わ紒"));
templateMessage.setData(data);
- String wechatUrl = MappingCache.getValue("OWNER_WECHAT_URL");
+ //鑾峰彇鍛樺伐鍏紬鍙峰湴鍧�
+ String wechatUrl = MappingCache.getValue("STAFF_WECHAT_URL");
templateMessage.setUrl(wechatUrl);
logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
@@ -283,6 +308,7 @@
//鏍规嵁 userId 鏌ヨ鍒皁penId
StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
staffAppAuthDto.setStaffId(paramIn.getString("staffId"));
+ staffAppAuthDto.setStaffName(paramIn.getString("staffName"));
staffAppAuthDto.setAppType("WECHAT");
List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
if (staffAppAuthDtos.size() > 0) {
@@ -298,13 +324,98 @@
data.setKeyword4(new Content(paramIn.getString("context") + "\r\n" + "鎶ヤ慨浣嶇疆锛�" + address));
data.setRemark(new Content("璇峰強鏃剁櫥褰曞叕浼楀彿鎺ュ崟纭锛�"));
templateMessage.setData(data);
- String wechatUrl = MappingCache.getValue("OWNER_WECHAT_URL");
+ //鑾峰彇鍛樺伐鍏紬鍙峰湴鍧�
+ String wechatUrl = MappingCache.getValue("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);
}
}
+
+
+ private void sendMsgToWechatGroup(JSONObject paramIn, CommunityDto communityDto) {
+
+ //鏌ヨ鍏紬鍙烽厤缃�
+ String url = CommunitySettingFactory.getRemark(communityDto.getCommunityId(), "WECHAT_SEND_REPAIR_URL");
+ if (StringUtil.isEmpty(url)) {
+ return;
+ }
+
+ JSONObject rebootParam = new JSONObject();
+ rebootParam.put("msgtype", "markdown");
+ JSONObject rebootMarkdown = new JSONObject();
+ rebootParam.put("markdown", rebootMarkdown);
+
+
+ //鑾峰彇鍏蜂綋浣嶇疆
+ String address = "";
+ if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
+ address = paramIn.getString("repairObjName");
+ } else {
+ address = communityDto.getName() + paramIn.getString("repairObjName");
+ }
+
+ //鏍规嵁 userId 鏌ヨ鍒皁penId
+ UserDto userDto = new UserDto();
+ userDto.setUserId(paramIn.getString("staffId"));
+ List<UserDto> userDtos = userInnerServiceSMO.getUsers(userDto);
+ String staffName = "";
+ if (userDtos != null && userDtos.size() > 0) {
+ staffName = userDtos.get(0).getName();
+ }
+ String content = staffName + " 鎮ㄦ湁鏂扮殑缁翠慨浠诲姟锛岀淮淇俊鎭涓嬶細\n";
+
+ content += ("> 鏍囬锛�<font color=\"comment\">" + paramIn.getString("repairName") + "</font> \n");
+ content += ("> 鐢佃瘽锛�<font color=\"comment\">" + paramIn.getString("tel") + "</font> \n");
+ content += ("> 鏃堕棿锛�<font color=\"comment\">" + paramIn.getString("time") + "</font> \n");
+ content += ("> 鍐呭锛�<font color=\"comment\">" + paramIn.getString("context") + "</font> \n");
+ content += ("> 浣嶇疆锛�<font color=\"comment\">" + address + "</font> \n");
+ content += ("> 鍗曞彿锛�<font color=\"comment\">" + paramIn.getString("repairId") + "</font> \n");
+
+ rebootMarkdown.put("content", content);
+ logger.info("鍙戦�佹秷鎭唴瀹�:{}", content);
+ ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, rebootParam.toJSONString(), String.class);
+ logger.info("浼佷笟寰俊杩斿洖鍐呭:{}", responseEntity);
+
+
+ if (responseEntity.getStatusCode() != HttpStatus.OK) {
+ return;
+ }
+
+ String imgUrl = MappingCache.getValue("IMG_PATH");
+ FileRelDto fileRelDto = new FileRelDto();
+ fileRelDto.setObjId(paramIn.getString("repairId"));
+ List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto);
+
+ if (fileRelDtos == null || fileRelDtos.size() < 1) {
+ return;
+ }
+
+ rebootParam = JSONObject.parseObject(" {\n" +
+ " \"msgtype\":\"image\",\n" +
+ " \"image\":{\n" +
+ " }\n" +
+ " }");
+
+
+ JSONObject image = rebootParam.getJSONObject("image");
+
+ String imageUrl = "";
+ for (FileRelDto tmpFileRelDto : fileRelDtos) {
+
+ if (!tmpFileRelDto.getRelTypeCd().equals(FileRelDto.REL_TYPE_CD_REPAIR)) { //缁翠慨鍥剧墖
+ continue;
+ }
+ imageUrl = imgUrl + tmpFileRelDto.getFileRealName();
+ image.put("base64", ImageUtils.getBase64ByImgUrl(imageUrl));
+ image.put("md5", ImageUtils.getMd5ByImgUrl(imageUrl));
+ responseEntity = outRestTemplate.postForEntity(url, rebootParam.toJSONString(), String.class);
+ logger.debug("杩斿洖淇℃伅锛�" + responseEntity);
+ }
+
+ }
+
/**
* 娲惧崟(鎶㈠崟)鎴愬姛鍚庣粰涓氫富鎺ㄩ�佷俊鎭�
@@ -371,7 +482,14 @@
data.setKeyword4(new Content(paramIn.getString("time")));
data.setRemark(new Content("鎮ㄧ殑鎶ヤ慨宸插彈鐞嗭紝璇蜂繚鎸佺數璇濈晠閫氾紝浠ヤ究缁翠慨浜哄憳鍙婃椂璺熸偍鍙栧緱鑱旂郴锛佹劅璋㈡偍鐨勪娇鐢紒"));
templateMessage.setData(data);
+ //鑾峰彇涓氫富鍏紬鍙峰湴鍧�
String wechatUrl = MappingCache.getValue("OWNER_WECHAT_URL");
+ if (!StringUtil.isEmpty(wechatUrl) && wechatUrl.contains("?")) {
+ wechatUrl += ("&wAppId=" + weChatDto.getAppId());
+ } else {
+ wechatUrl += ("?wAppId=" + weChatDto.getAppId());
+ }
+
templateMessage.setUrl(wechatUrl);
logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
@@ -386,8 +504,7 @@
* @param paramIn
* @param communityDto
*/
- private void
- publishMessage(JSONObject paramIn, CommunityDto communityDto) {
+ private void publishMessage(JSONObject paramIn, CommunityDto communityDto) {
//鏌ヨ鍏紬鍙烽厤缃�
SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
smallWeChatDto.setWeChatType("1100");
@@ -439,7 +556,8 @@
data.setKeyword4(new Content(paramIn.getString("context") + "\r\n" + "鎶ヤ慨浣嶇疆锛�" + address));
data.setRemark(new Content("璇峰強鏃朵笌瀹㈡埛鍙栧緱鑱旂郴锛�"));
templateMessage.setData(data);
- String wechatUrl = MappingCache.getValue("OWNER_WECHAT_URL");
+ //鑾峰彇鍛樺伐鍏紬鍙峰湴鍧�
+ String wechatUrl = MappingCache.getValue("STAFF_WECHAT_URL");
templateMessage.setUrl(wechatUrl);
logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
--
Gitblit v1.8.0