From d33e2d4a6e82487532251e8ec6e32b06de442d9f Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期一, 07 八月 2023 21:57:27 +0800
Subject: [PATCH] 优化代码
---
service-job/src/main/java/com/java110/job/adapt/Repair/MachineDistributeLeaflets.java | 608 ++++++++++++++++++++++--------------------------------
1 files changed, 252 insertions(+), 356 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
index 1366744..88edfcd 100755
--- 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,24 +1,21 @@
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.machine.MachinePrinterDto;
+import com.java110.dto.printerRule.PrinterRuleDto;
+import com.java110.dto.printerRule.PrinterRuleMachineDto;
+import com.java110.dto.printerRule.PrinterRuleRepairDto;
import com.java110.dto.repair.RepairDto;
import com.java110.dto.repair.RepairUserDto;
-import com.java110.dto.smallWeChat.SmallWeChatDto;
-import com.java110.dto.smallWechatAttr.SmallWechatAttrDto;
-import com.java110.dto.staffAppAuth.StaffAppAuthDto;
+import com.java110.dto.wechat.SmallWeChatDto;
import com.java110.dto.user.UserDto;
-import com.java110.entity.order.Business;
-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.dto.system.Business;
+import com.java110.intf.common.*;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.community.IRepairInnerServiceSMO;
import com.java110.intf.community.IRepairUserInnerServiceSMO;
@@ -28,7 +25,15 @@
import com.java110.intf.user.IStaffAppAuthInnerServiceSMO;
import com.java110.intf.user.IUserInnerServiceSMO;
import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.msgNotify.MsgNotifyFactory;
+import com.java110.job.printer.IPrinter;
+import com.java110.po.owner.RepairUserPo;
import com.java110.utils.cache.MappingCache;
+import com.java110.utils.cache.UrlCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.util.Assert;
import com.java110.utils.util.ImageUtils;
import com.java110.utils.util.StringUtil;
import org.slf4j.Logger;
@@ -82,176 +87,144 @@
@Autowired
private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
- //妯℃澘淇℃伅鎺ㄩ�佸湴鍧�
- private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
+
+ @Autowired
+ private IPrinterRuleRepairV1InnerServiceSMO printerRuleRepairV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IPrinterRuleV1InnerServiceSMO printerRuleV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IPrinterRuleMachineV1InnerServiceSMO printerRuleMachineV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IMachinePrinterV1InnerServiceSMO machinePrinterV1InnerServiceSMOImpl;
+
@Override
public void execute(Business business, List<Business> businesses) {
- RepairUserDto repairUserDto = new RepairUserDto();
- repairUserDto.setbId(business.getbId());
- repairUserDto.setStatusCd("0");
- List<RepairUserDto> repairUserDtos = repairUserInnerServiceSMO.queryRepairUsers(repairUserDto);
- //鑾峰彇鍛樺伐澶勭悊鐘舵��(10001 澶勭悊涓紱10002 缁撳崟锛�10003 閫�鍗曪紱10004 杞崟锛�10005 鎻愪氦)
- 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();
- //鑾峰彇鑱旂郴浜哄鍚�
- String repairName = repairDtos.get(0).getRepairName();
- //鑾峰彇鑱旂郴浜虹數璇�
- String tel = repairDtos.get(0).getTel();
- //鑾峰彇浣嶇疆淇℃伅
- String repairObjName = repairDtos.get(0).getRepairObjName();
- //鎶ヤ慨瀵硅薄ID
- String repairObjId = repairDtos.get(0).getRepairObjId();
- //鑾峰彇鎶ヤ慨鍐呭
- String context = repairDtos.get(0).getContext();
- //鑾峰彇娲惧崟鏃堕棿
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String time = format.format(repairUserDtos.get(0).getCreateTime());
- //鑾峰彇灏忓尯id
- String communityId = repairDtos.get(0).getCommunityId();
- //鏌ヨ灏忓尯淇℃伅
- 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();
- JSONObject paramIn = new JSONObject();
- 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));
- //涓轰紒涓氬井淇$兢鍙戞秷鎭�
- sendMsgToWechatGroup(paramIn, communityDtos.get(0));
- } else if (repairState.equals("1100") && (repairWay.equals("100") || repairWay.equals("300"))) {
- 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();
- JSONObject paramIn = new JSONObject();
- paramIn.put("staffId", staffId);
- paramIn.put("context", context);
- paramIn.put("time", time);
- paramIn.put("repairObjId", repairObjId);
- paramIn.put("preStaffId", preStaffId);
- paramIn.put("repairName", repairName);
- paramIn.put("tel", tel);
- paramIn.put("repairObjName", repairObjName);
- //鎶㈠崟鎴愬姛缁欎笟涓绘帹閫佷俊鎭�
- 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);
- //缁欑淮淇笀鍌呮帹閫佷俊鎭�
- sendMessage(paramIn, communityDtos.get(0));
+ 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);
}
}
- /**
- * 杞崟缁欑淮淇笀鍌呮帹閫佷俊鎭�
- *
- * @param paramIn
- * @param communityDto
- */
- private void sendMessage(JSONObject paramIn, CommunityDto communityDto) {
- //鏌ヨ鍏紬鍙烽厤缃�
- SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
- smallWeChatDto.setWeChatType("1100");
- smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
- smallWeChatDto.setObjId(communityDto.getCommunityId());
- List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
- if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
- logger.info("鏈厤缃井淇″叕浼楀彿淇℃伅,瀹氭椂浠诲姟鎵ц缁撴潫");
+ private void doDealOwnerRepair(List<Business> businesses, JSONObject businessRepairUser) {
+ RepairUserDto repairUserDto = new RepairUserDto();
+ repairUserDto.setRuId(businessRepairUser.getString("ruId"));
+ List<RepairUserDto> repairUserDtos = repairUserInnerServiceSMO.queryRepairUsers(repairUserDto);
+ //鑾峰彇鍛樺伐澶勭悊鐘舵��(10001 澶勭悊涓紱10002 缁撳崟锛�10003 閫�鍗曪紱10004 杞崟锛�10005 鎻愪氦锛�10006 宸叉淳鍗曪紱10007 宸茶瘎浠凤紱10008 宸插洖璁匡紱10009 寰呮敮浠橈紱11000 寰呰瘎浠凤紱12000 宸叉敮浠橈紱12001 鏆傚仠)
+ String state = repairUserDtos.get(0).getState();
+ if (RepairUserDto.STATE_SUBMIT.equals(state)) {
return;
}
- SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
- SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
- smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
- smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
- smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE);
- List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
- if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
- logger.info("鏈厤缃井淇″叕浼楀彿娑堟伅妯℃澘");
- return;
+ //鑾峰彇鎶ヤ慨id
+ String repairId = repairUserDtos.get(0).getRepairId();
+ RepairDto repairDto = new RepairDto();
+ repairDto.setRepairId(repairId);
+ List<RepairDto> repairDtos = repairInnerServiceSMO.queryRepairs(repairDto);
+ //鏌ヨ鎶ヤ慨鐘舵��(1000 鏈淳鍗曪紱1100 鎺ュ崟锛�1200 閫�鍗曪紱1300 杞崟锛�1400 鐢宠鏀粯锛�1500 鏀粯澶辫触锛�1700 寰呰瘎浠凤紱1800 鐢佃瘽鍥炶锛�1900 鍔炵悊瀹屾垚锛�2000 鏈姙鐞嗙粨鍗�)
+ String repairState = repairDtos.get(0).getState();
+ //鑾峰彇鑱旂郴浜哄鍚�
+ String repairName = repairDtos.get(0).getRepairName();
+ //鑾峰彇鑱旂郴浜虹數璇�
+ String tel = repairDtos.get(0).getTel();
+ //鑾峰彇浣嶇疆淇℃伅
+ String repairObjName = repairDtos.get(0).getRepairObjName();
+ //鎶ヤ慨瀵硅薄ID
+ String repairObjId = repairDtos.get(0).getRepairObjId();
+ //鑾峰彇鎶ヤ慨鍐呭
+ String context = repairDtos.get(0).getContext();
+ //鑾峰彇娲惧崟鏃堕棿
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String time = format.format(repairUserDtos.get(0).getCreateTime());
+ //鑾峰彇灏忓尯id
+ String communityId = repairDtos.get(0).getCommunityId();
+ //鏌ヨ灏忓尯淇℃伅
+ CommunityDto communityDto = new CommunityDto();
+ communityDto.setCommunityId(communityId);
+ List<CommunityDto> communityDtos = communityInnerServiceSMO.queryCommunitys(communityDto);
+ 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("repairObjId", repairObjId);
+ paramIn.put("repairId", repairId);
+ //缁欑淮淇笀鍌呮帹閫佷俊鎭�
+ sendStaffMsg(paramIn, communityDtos.get(0));
+ //娲惧崟鎴愬姛缁欎笟涓绘帹閫佷俊鎭�
+ sendOwnerMsg(paramIn, communityDtos.get(0));
+
+ // 鑷姩鎵撳嵃灏忕エ
+ autoPrintRepair(repairUserDtos.get(0).getRuId(), repairDtos.get(0).getRepairType(), communityDtos.get(0));
+
+ //涓轰紒涓氬井淇$兢鍙戞秷鎭�
+ sendMsgToWechatGroup(paramIn, communityDtos.get(0));
+
+
+ } else if (repairState.equals("1100") && !businessRepairUser.getString("state").equals("10006")) {
+ JSONObject paramIn = new JSONObject();
+ paramIn.put("staffId", businessRepairUser.getString("staffId"));
+ paramIn.put("context", context);
+ paramIn.put("time", time);
+ paramIn.put("repairObjId", repairObjId);
+ paramIn.put("preStaffId", businessRepairUser.getString("preStaffId"));
+ paramIn.put("repairName", repairName);
+ paramIn.put("tel", tel);
+ paramIn.put("repairObjName", repairObjName);
+ //鎶㈠崟鎴愬姛缁欑淮淇笀鍌呮帹閫佷俊鎭�
+ sendStaffMsg(paramIn, communityDtos.get(0));
+ //鎶㈠崟鎴愬姛缁欎笟涓绘帹閫佷俊鎭�
+ sendOwnerMsg(paramIn, communityDtos.get(0));
+ } else if (repairState.equals("1300")) { //杞崟
+ 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", businessRepairUser.getString("staffId"));
+ paramIn.put("preStaffName", businessRepairUser.getString("preStaffName"));
+ //缁欑淮淇笀鍌呮帹閫佷俊鎭�
+ sendStaffMsg(paramIn, communityDtos.get(0));
}
- String templateId = smallWechatAttrDtos.get(0).getValue();
- String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
- if (StringUtil.isEmpty(accessToken)) {
- logger.info("鎺ㄩ�佸井淇℃ā鏉�,鑾峰彇accessToken澶辫触:{}", accessToken);
- return;
- }
- String url = sendMsgUrl + accessToken;
- //鏍规嵁 userId 鏌ヨ鍒皁penId
- StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
- staffAppAuthDto.setStaffId(paramIn.getString("staffId"));
- staffAppAuthDto.setAppType("WECHAT");
- List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
- if (staffAppAuthDtos.size() > 0) {
- 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("鎮ㄦ湁鏂扮殑缁翠慨浠诲姟锛岀淮淇俊鎭涓嬶細"));
- data.setKeyword1(new Content(paramIn.getString("repairName")));
- data.setKeyword2(new Content(paramIn.getString("tel")));
- data.setKeyword3(new Content(paramIn.getString("time")));
- 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("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);
- }
+
}
+
/**
* 娲惧崟缁欑淮淇笀鍌呮帹閫佷俊鎭�
@@ -259,7 +232,32 @@
* @param paramIn
* @param communityDto
*/
- private void sendMsg(JSONObject paramIn, CommunityDto communityDto) {
+ private void sendStaffMsg(JSONObject paramIn, CommunityDto communityDto) {
+ JSONObject content = new JSONObject();
+ content.put("repairName", paramIn.getString("repairName"));
+ content.put("tel", paramIn.getString("tel"));
+ content.put("time", paramIn.getString("time"));
+ String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
+ content.put("url", wechatUrl);
+ //鑾峰彇鍏蜂綋浣嶇疆
+ String address = "";
+ if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
+ address = paramIn.getString("repairObjName");
+ } else {
+ address = communityDto.getName() + paramIn.getString("repairObjName");
+ }
+ content.put("address", address);
+ MsgNotifyFactory.sendDistributeRepairStaffMsg(communityDto.getCommunityId(), paramIn.getString("staffId"), content);
+ }
+
+
+ /**
+ * 娲惧崟(鎶㈠崟)鎴愬姛鍚庣粰涓氫富鎺ㄩ�佷俊鎭�
+ *
+ * @param paramIn
+ * @param communityDto
+ */
+ private void sendOwnerMsg(JSONObject paramIn, CommunityDto communityDto) {
//鏌ヨ鍏紬鍙烽厤缃�
SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
smallWeChatDto.setWeChatType("1100");
@@ -270,57 +268,36 @@
logger.info("鏈厤缃井淇″叕浼楀彿淇℃伅,瀹氭椂浠诲姟鎵ц缁撴潫");
return;
}
- SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
- SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
- smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
- smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
- smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE);
- List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
- if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
- logger.info("鏈厤缃井淇″叕浼楀彿娑堟伅妯℃澘");
+ //鏌ヨ缁翠慨鍛樺伐淇℃伅
+ UserDto userDto = new UserDto();
+ userDto.setUserId(paramIn.getString("staffId"));
+ userDto.setStatusCd("0");
+ List<UserDto> users = userInnerServiceSMO.getUsers(userDto);
+ //鑾峰彇缁翠慨鍛樺伐濮撳悕
+ String name = users.get(0).getName();
+ //鑾峰彇缁翠慨鍛樺伐鑱旂郴鏂瑰紡
+ String tel = users.get(0).getTel();
+ //鑾峰彇鐢ㄦ埛id
+ String preStaffId = paramIn.getString("preStaffId");
+ if (StringUtil.isEmpty(preStaffId)) {
return;
}
- String templateId = smallWechatAttrDtos.get(0).getValue();
- String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
- if (StringUtil.isEmpty(accessToken)) {
- logger.info("鎺ㄩ�佸井淇℃ā鏉�,鑾峰彇accessToken澶辫触:{}", accessToken);
- return;
- }
- //鑾峰彇鍏蜂綋浣嶇疆
- String address = "";
- if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
- address = paramIn.getString("repairObjName");
- } else {
- address = communityDto.getName() + paramIn.getString("repairObjName");
- }
- String url = sendMsgUrl + accessToken;
- //鏍规嵁 userId 鏌ヨ鍒皁penId
- StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
- staffAppAuthDto.setStaffId(paramIn.getString("staffId"));
- staffAppAuthDto.setAppType("WECHAT");
- List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
- if (staffAppAuthDtos.size() > 0) {
- 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("鎮ㄦ湁鏂扮殑缁翠慨浠诲姟锛岀淮淇俊鎭涓嬶細"));
- data.setKeyword1(new Content(paramIn.getString("repairName")));
- data.setKeyword2(new Content(paramIn.getString("tel")));
- data.setKeyword3(new Content(paramIn.getString("time")));
- data.setKeyword4(new Content(paramIn.getString("context") + "\r\n" + "鎶ヤ慨浣嶇疆锛�" + address));
- data.setRemark(new Content("璇峰強鏃剁櫥褰曞叕浼楀彿鎺ュ崟纭锛�"));
- templateMessage.setData(data);
- //鑾峰彇鍛樺伐鍏紬鍙峰湴鍧�
- 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);
- }
- }
+ JSONObject content = new JSONObject();
+ content.put("name", name);
+ content.put("tel", tel);
+ content.put("time", paramIn.getString("time"));
+ String wechatUrl = UrlCache.getOwnerUrl();
+ if (!StringUtil.isEmpty(wechatUrl) && wechatUrl.contains("?")) {
+ wechatUrl += ("&wAppId=" + smallWeChatDtos.get(0).getAppId());
+ } else {
+ wechatUrl += ("?wAppId=" + smallWeChatDtos.get(0).getAppId());
+ }
+ content.put("url", wechatUrl);
+
+ MsgNotifyFactory.sendDistributeRepairOwnerMsg(communityDto.getCommunityId(), preStaffId, content);
+
+ }
private void sendMsgToWechatGroup(JSONObject paramIn, CommunityDto communityDto) {
@@ -371,7 +348,7 @@
return;
}
- String imgUrl = MappingCache.getValue("IMG_PATH");
+ String imgUrl = MappingCache.getValue(MappingConstant.FILE_DOMAIN, "IMG_PATH");
FileRelDto fileRelDto = new FileRelDto();
fileRelDto.setObjId(paramIn.getString("repairId"));
List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto);
@@ -399,156 +376,75 @@
image.put("base64", ImageUtils.getBase64ByImgUrl(imageUrl));
image.put("md5", ImageUtils.getMd5ByImgUrl(imageUrl));
responseEntity = outRestTemplate.postForEntity(url, rebootParam.toJSONString(), String.class);
- logger.debug("杩斿洖淇℃伅锛�"+responseEntity);
+ logger.debug("杩斿洖淇℃伅锛�" + responseEntity);
}
}
/**
- * 娲惧崟(鎶㈠崟)鎴愬姛鍚庣粰涓氫富鎺ㄩ�佷俊鎭�
+ * // 鑷姩鎵撳嵃灏忕エ
*
- * @param paramIn
+ * @param ruId
+ * @param repairType
* @param communityDto
*/
- private void publishMsg(JSONObject paramIn, CommunityDto communityDto) {
- //鏌ヨ鍏紬鍙烽厤缃�
- SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
- smallWeChatDto.setWeChatType("1100");
- smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
- smallWeChatDto.setObjId(communityDto.getCommunityId());
- List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
- if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
- logger.info("鏈厤缃井淇″叕浼楀彿淇℃伅,瀹氭椂浠诲姟鎵ц缁撴潫");
- return;
- }
- SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
- SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
- smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
- smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
- smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_SCHEDULE_TEMPLATE);
- List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
- if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
- logger.info("鏈厤缃井淇″叕浼楀彿娑堟伅妯℃澘");
- return;
- }
- String templateId = smallWechatAttrDtos.get(0).getValue();
- String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
- if (StringUtil.isEmpty(accessToken)) {
- logger.info("鎺ㄩ�佸井淇℃ā鏉�,鑾峰彇accessToken澶辫触:{}", accessToken);
- return;
- }
- //鏌ヨ缁翠慨鍛樺伐淇℃伅
- UserDto userDto = new UserDto();
- userDto.setUserId(paramIn.getString("staffId"));
- userDto.setStatusCd("0");
- List<UserDto> users = userInnerServiceSMO.getUsers(userDto);
- //鑾峰彇缁翠慨鍛樺伐濮撳悕
- String name = users.get(0).getName();
- //鑾峰彇缁翠慨鍛樺伐鑱旂郴鏂瑰紡
- String tel = users.get(0).getTel();
- //鑾峰彇鐢ㄦ埛id
- String preStaffId = paramIn.getString("preStaffId");
- if (!StringUtil.isEmpty(preStaffId)) {
- OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
- ownerAppUserDto.setUserId(preStaffId);
- ownerAppUserDto.setAppType("WECHAT");
- //鏌ヨ缁戝畾涓氫富
- List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMO.queryOwnerAppUsers(ownerAppUserDto);
- if (ownerAppUserDtos.size() > 0) {
- //鑾峰彇openId
- String openId = ownerAppUserDtos.get(0).getOpenId();
- String url = sendMsgUrl + accessToken;
- Data data = new Data();
- PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
- templateMessage.setTemplate_id(templateId);
- templateMessage.setTouser(openId);
- data.setFirst(new Content("鎮ㄧ殑鎶ヤ慨鍙楃悊鎴愬姛锛岀淮淇汉鍛樹俊鎭涓嬶細"));
- data.setKeyword1(new Content(paramIn.getString("context")));
- data.setKeyword2(new Content(name));
- data.setKeyword3(new Content(tel));
- 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());
- }
+ private void autoPrintRepair(String ruId, String repairType, CommunityDto communityDto) {
- templateMessage.setUrl(wechatUrl);
- logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
- ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
- logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+ PrinterRuleRepairDto printerRuleRepairDto = new PrinterRuleRepairDto();
+ printerRuleRepairDto.setCommunityId(communityDto.getCommunityId());
+ printerRuleRepairDto.setRepairType(repairType);
+ List<PrinterRuleRepairDto> printerRuleRepairDtos = printerRuleRepairV1InnerServiceSMOImpl.queryPrinterRuleRepairs(printerRuleRepairDto);
+
+ if (printerRuleRepairDtos == null || printerRuleRepairDtos.size() < 1) {
+ return;
+ }
+
+ PrinterRuleDto printerRuleDto = new PrinterRuleDto();
+ printerRuleDto.setRuleId(printerRuleRepairDtos.get(0).getRuleId());
+ printerRuleDto.setCommunityId(communityDto.getCommunityId());
+ printerRuleDto.setState(PrinterRuleDto.STATE_NORMAL);
+ int count = printerRuleV1InnerServiceSMOImpl.queryPrinterRulesCount(printerRuleDto);
+
+ if (count < 1) {
+ return;
+ }
+
+ PrinterRuleMachineDto printerRuleMachineDto = new PrinterRuleMachineDto();
+ printerRuleMachineDto.setCommunityId(communityDto.getCommunityId());
+ printerRuleMachineDto.setRuleId(printerRuleRepairDtos.get(0).getRuleId());
+ List<PrinterRuleMachineDto> printerRuleMachineDtos = printerRuleMachineV1InnerServiceSMOImpl.queryPrinterRuleMachines(printerRuleMachineDto);
+ if (printerRuleMachineDtos == null || printerRuleMachineDtos.size() < 1) {
+ return;
+ }
+
+ for (PrinterRuleMachineDto tmpPrinterRuleMachineDto : printerRuleMachineDtos) {
+ try {
+ doPrint(tmpPrinterRuleMachineDto, ruId);
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
+
+
}
- /**
- * 鎶㈠崟鎴愬姛鍚庣粰缁翠慨甯堝倕鎺ㄩ�佷俊鎭�
- *
- * @param paramIn
- * @param communityDto
- */
- private void publishMessage(JSONObject paramIn, CommunityDto communityDto) {
- //鏌ヨ鍏紬鍙烽厤缃�
- SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
- smallWeChatDto.setWeChatType("1100");
- smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
- smallWeChatDto.setObjId(communityDto.getCommunityId());
- List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
- if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
- logger.info("鏈厤缃井淇″叕浼楀彿淇℃伅,瀹氭椂浠诲姟鎵ц缁撴潫");
- return;
+
+ private void doPrint(PrinterRuleMachineDto tmpPrinterRuleMachineDto, String ruId) {
+ MachinePrinterDto machinePrinterDto = new MachinePrinterDto();
+ machinePrinterDto.setCommunityId(tmpPrinterRuleMachineDto.getCommunityId());
+ machinePrinterDto.setMachineId(tmpPrinterRuleMachineDto.getMachineId());
+ List<MachinePrinterDto> machinePrinterDtos = machinePrinterV1InnerServiceSMOImpl.queryMachinePrinters(machinePrinterDto);
+
+ Assert.listOnlyOne(machinePrinterDtos, "浜戞墦鍗版満涓嶅瓨鍦�");
+
+ IPrinter printer = ApplicationContextFactory.getBean(machinePrinterDtos.get(0).getImplBean(), IPrinter.class);
+
+ if (printer == null) {
+ throw new CmdException("鎵撳嵃鏈哄紓甯革紝鏈寘鍚�傞厤鍣�");
}
- SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
- SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
- smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
- smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
- smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE);
- List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
- if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
- logger.info("鏈厤缃井淇″叕浼楀彿娑堟伅妯℃澘");
- return;
- }
- String templateId = smallWechatAttrDtos.get(0).getValue();
- String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
- if (StringUtil.isEmpty(accessToken)) {
- logger.info("鎺ㄩ�佸井淇℃ā鏉�,鑾峰彇accessToken澶辫触:{}", accessToken);
- return;
- }
- //鑾峰彇鍏蜂綋浣嶇疆
- String address = "";
- if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
- address = paramIn.getString("repairObjName");
- } else {
- address = communityDto.getName() + paramIn.getString("repairObjName");
- }
- //鏍规嵁 userId 鏌ヨ鍒皁penId
- StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
- staffAppAuthDto.setStaffId(paramIn.getString("staffId"));
- staffAppAuthDto.setAppType("WECHAT");
- List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
- String openId = staffAppAuthDtos.get(0).getOpenId();
- String url = sendMsgUrl + accessToken;
- Data data = new Data();
- PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
- templateMessage.setTemplate_id(templateId);
- templateMessage.setTouser(openId);
- data.setFirst(new Content("鎭枩鎮ㄦ姠鍗曟垚鍔燂紝鎶ヤ慨淇℃伅濡備笅锛�"));
- data.setKeyword1(new Content(paramIn.getString("repairName")));
- data.setKeyword2(new Content(paramIn.getString("tel")));
- data.setKeyword3(new Content(paramIn.getString("time")));
- data.setKeyword4(new Content(paramIn.getString("context") + "\r\n" + "鎶ヤ慨浣嶇疆锛�" + address));
- data.setRemark(new Content("璇峰強鏃朵笌瀹㈡埛鍙栧緱鑱旂郴锛�"));
- templateMessage.setData(data);
- //鑾峰彇鍛樺伐鍏紬鍙峰湴鍧�
- 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);
+
+ printer.printRepair(ruId, tmpPrinterRuleMachineDto.getCommunityId(), Integer.parseInt(tmpPrinterRuleMachineDto.getQuantity()), machinePrinterDtos.get(0));
+
}
}
--
Gitblit v1.8.0