From c19de84fa332a00c651f28e3a52292fd14f143a1 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 23 九月 2025 17:30:07 +0800
Subject: [PATCH] 陆常丽反应软件系统财务对账时而数据不准确,分析源码,找到bug原因是,财务对账统计只有用户点击后才会触发统计功能,把历史上及当天进行了统计,如果当天统计时未下班,例如是中午触发统计了,而下午又进行了充值售水,但下班后未再点击触发对账统计,那么今天的对账统计完成了但数据不对。编写自动任务,在下半夜进行对账统计。
---
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java | 485 ++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 404 insertions(+), 81 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
index 2cd24f0..f4df780 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
@@ -7,15 +7,21 @@
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol.p206V1.CodeV1;
import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
+import com.dy.common.mw.protocol.p206V1.downVos.Com97Vo;
+import com.dy.common.mw.protocol.p206V1.downVos.Com98Vo;
import com.dy.common.mw.protocol.p206V1.downVos.ComA1Vo;
import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2;
+import com.dy.common.mw.protocol.p206V202404.CodeV202404;
import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404;
+import com.dy.common.mw.protocol.p206V202404.downVos.ComCd92_A2Vo;
+import com.dy.common.mw.protocol.p206V202404.downVos.ComCd93_A3Vo;
import com.dy.common.util.IDLongGenerator;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.command.ComSupport;
import com.dy.pipIrrGlobal.command.dto.Param;
import com.dy.pipIrrGlobal.daoIr.IrIntakeOperateMapper;
+import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper;
import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
import com.dy.pipIrrGlobal.daoPr.PrIntakeVcMapper;
import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper;
@@ -32,6 +38,9 @@
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
import com.dy.pipIrrWechat.command.dto.AutomaticClose;
+import com.dy.pipIrrWechat.command.dto.ValveClose;
+import com.dy.pipIrrWechat.command.dto.ValveOpen;
+import com.dy.pipIrrWechat.irrigation.IrrigationSv;
import com.dy.pipIrrWechat.result.WechatResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -39,6 +48,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@@ -63,6 +73,8 @@
private final RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper;
//private final PrCommonIntakesMapper prCommonIntakesMapper;
private final IrIntakeOperateMapper irIntakeOperateMapper;
+ private final IrrigationSv irrigationSv;
+ private final PrIntakeControllerMapper prIntakeControllerMapper;
@Value("${mw.rtuCallbackUrl_wx}")
private String rtuCallbackUrl_wx;
@@ -76,7 +88,7 @@
private String pro_mw = "mw";
private String key_mw = "comSendUrl";
@Autowired
- public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper,RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, RmIrrigateProfileMapper rmIrrigateProfileMapper, Environment env, IrIntakeOperateMapper irIntakeOperateMapper) {
+ public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper,RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, RmIrrigateProfileMapper rmIrrigateProfileMapper, Environment env, IrIntakeOperateMapper irIntakeOperateMapper, IrrigationSv irrigationSv, PrIntakeControllerMapper prIntakeControllerMapper) {
this.rmCommandHistoryMapper = rmCommandHistoryMapper;
this.rmOpenCloseValveLastMapper = rmOpenCloseValveLastMapper;
//this.prCommonIntakesMapper = prCommonIntakesMapper;
@@ -88,29 +100,19 @@
this.rmIrrigateProfileMapper = rmIrrigateProfileMapper;
this.env = env;
this.irIntakeOperateMapper = irIntakeOperateMapper;
+ this.irrigationSv = irrigationSv;
+ this.prIntakeControllerMapper = prIntakeControllerMapper;
}
- /**
- * 铏氭嫙鍗D鎹㈣櫄鎷熷崱瀵硅薄
- * @param vcId
- * @return
- */
+
public VoVirtualCard getVcById(Long vcId) {
return seVirtualCardMapper.getVcById(vcId);
}
- /**
- * 鑾峰彇姘翠环
- * @return
- */
+
public Double getPrice() {
return prWaterPriceMapper.getPrice();
}
- /**
- * 鏍规嵁鎿嶄綔鍛業D鑾峰彇鏈叧闃�璁板綍锛堝寘鍚湪绾挎儏鍐碉級
- * @param operator
- * @return
- */
public List<VoUnclosedValve> getUnclosedValves(Long operator) {
Command com = new Command() ;
com.id = Command.defaultId;
@@ -118,6 +120,7 @@
com.type = "innerCommand";
comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
+ String aa = response.toJSONString();
JSONArray jsonArray = new JSONArray();
if(response != null && response.getString("code").equals("0001")) {
@@ -133,10 +136,6 @@
//System.out.println(jsonArray.toJSONString());
}
- /**
- * 鑾峰彇鏈叧闃�鐨凴TU鍦板潃鍜岃櫄鎷熷崱缂栧彿瀵规暟缁�
- * 閬嶅巻鏁扮粍鑾峰彇鏈�鍚庡懡浠ゆ棩蹇桰D闆嗗悎
- */
List<VoRtuAndVc> rtus = rmCommandHistoryMapper.getUnclosedRtus(operator);
String comIds = "";
if(rtus != null && rtus.size() > 0) {
@@ -158,78 +157,37 @@
return new ArrayList<>();
}
- /**
- * 涓烘寚瀹氾紙闃�鎺у櫒鍦板潃銆佹按鍗$紪鍙枫�佹棤鍏抽榾璁板綍锛夊紑鍏抽榾鏈�鏂拌褰曟坊鍔犲叧闃�鏃堕棿锛屼娇涔嬩笉鍦ㄦ湭鍏抽榾璁板綍涓樉绀�
- * @param rtuAddr
- * @param icCardNo
- * @return
- */
public Integer addClostTime(String rtuAddr, String icCardNo) {
return rmOpenCloseValveLastMapper.addCloseTime(rtuAddr, icCardNo);
}
- /**
- * 鏍规嵁鍙栨按鍙D鑾峰彇涓庝箣缁戝畾铏氭嫙鍗D
- * @param intakeId
- * @return
- */
public Long getVcIdByIntakeId(Long intakeId) {
return prIntakeVcMapper.getVcIdByIntakeId(intakeId);
}
- /**
- * 鏍规嵁姘村崱缂栧彿鑾峰彇姘村崱瀵硅薄锛岃繙绋嬪厖鍊间娇鐢�
- * @param cardId
- * @return
- */
public SeClientCard geClientCardByCardId(Long cardId) {
return seClientCardMapper.selectByPrimaryKey(cardId);
}
- /**
- * 娣诲姞鍛戒护鏃ュ織
- * @param po 鍛戒护鏃ュ織瀵硅薄
- * @return 瀛楃涓茬被鍨嬬殑涓婚敭
- */
public Long insert(RmCommandHistory po) {
rmCommandHistoryMapper.insert(po);
return po.getComId();
}
- /**
- * 淇敼鍛戒护鏃ュ織淇℃伅
- * @param po 鍛戒护鏃ュ織瀵硅薄
- * @return 褰卞搷璁板綍鏁伴噺
- */
public Integer update(RmCommandHistory po) {
return rmCommandHistoryMapper.updateByPrimaryKeySelective(po);
}
- /**
- * 鍙栨按鍙e悕绉版崲鍙栨按鍙D锛屾壂鐮佸紑闃�浣跨敤
- * @param intakeName
- * @return
- */
public Long getIntakeIdByName(String intakeName) {
return prIntakeMapper.getIntakeIdByName(intakeName);
}
- /**
- * 鏍规嵁閰嶇疆绫诲瀷鑾峰彇閰嶇疆鍊�
- * @param type
- * @return
- */
QueryResultVo<List<VoIrrigaterProfile>> getIrrPro(Integer type) {
QueryResultVo<List<VoIrrigaterProfile>> rsVo = new QueryResultVo<>() ;
rsVo.obj = rmIrrigateProfileMapper.getIrrPro(type);
return rsVo ;
}
- /**
- * 娣诲姞鍙栨按鍙f搷浣滆褰曪紝杞亴杩囩▼鍛戒护涓嬪彂鏃朵娇鐢�
- * @param po
- * @return
- */
public Long addIntakeOperate(IrIntakeOperate po) {
irIntakeOperateMapper.insert(po);
return po.getId();
@@ -245,11 +203,7 @@
// return irIntakeOperateMapper.updateByCommandId(commandId, commandResult);
//}
- /**
- * 瀹氭椂鍏抽榾寮忚鍒掑紑闃�
- * @param automaticClose
- * @return
- */
+ @Transactional(rollbackFor = Exception.class)
public Map planedOpenTimedClose(AutomaticClose automaticClose, Long planId, Byte operatetype, Date startTime, Integer duration) {
Long intakeId = automaticClose.getIntakeId();
Long vcId = automaticClose.getVcId();
@@ -258,8 +212,10 @@
Long operator = automaticClose.getOperator();
Byte openType = automaticClose.getOpenType();
Long comId = new IDLongGenerator().generate();
+ String intakeName = Optional.ofNullable(prIntakeControllerMapper.getIntakeNameById(intakeId)).orElse("");
// 濡傛灉鏄疆鐏�
+ Long operateId = null;
if(openType != null && openType == 1) {
IrIntakeOperate irIntakeOperate = new IrIntakeOperate();
irIntakeOperate.setPlanId(planId);
@@ -269,8 +225,8 @@
irIntakeOperate.setStartTime(startTime);
irIntakeOperate.setDuration(duration);
- Long id = addIntakeOperate(irIntakeOperate);
- if(id == null) {
+ operateId = addIntakeOperate(irIntakeOperate);
+ if(operateId == null) {
Map map = new HashMap<>();
map.put("success", false);
map.put("msg", "娣诲姞鍙栨按鍙f搷浣滆褰曞け璐�");
@@ -285,11 +241,6 @@
Integer hour = Integer.parseInt(String.format("%tH", plannedOpenTime));
Integer minute = Integer.parseInt(String.format("%tM", plannedOpenTime));
- /**
- * 濡傛灉鍐滄埛閫夋嫨浜嗚櫄鎷熷崱锛屽垯浣跨敤璇ヨ櫄鎷熷崱
- * 濡傛灉鍐滄埛鏈�夋嫨铏氭嫙鍗★紝鍒欐牴鎹彇姘村彛ID鑾峰彇涓庝箣缁戝畾鐨勮櫄鎷熷崱
- * 濡傛灉鍙栨按鍙f病鏈変笌涔嬬粦瀹氱殑铏氭嫙鍗★紝鍒欐彁绀哄啘鎴烽�夋嫨涓�寮犺櫄鎷熷崱
- */
if(vcId == null) {
vcId = getVcIdByIntakeId(intakeId);
if(vcId == null) {
@@ -297,7 +248,7 @@
Map map = new HashMap<>();
map.put("success", false);
- map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")");
+ map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeName + ")");
map.put("content", null);
return map;
}
@@ -310,16 +261,25 @@
Map map = new HashMap<>();
map.put("success", false);
- map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")");
+ map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeName + ")");
map.put("content", null);
return map;
}
String vcNum = vc.getVcNum().toString();
Double moneyRemain = vc.getMoney();
+ if(moneyRemain < 100) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, "铏氭嫙鍗′綑棰濅笉瓒筹紝璇峰厖鍊�" + "(" + intakeName + ")");
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "铏氭嫙鍗′綑棰濅笉瓒筹紝璇峰厖鍊�");
+ map.put("content", null);
+ return map;
+ }
// 鑾峰彇姘翠环
Double waterPrice = getPrice();
if(waterPrice == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_WATER_PRICE.getMessage() + "(" + intakeName + ")");
Map map = new HashMap<>();
map.put("success", false);
map.put("msg", WechatResultCode.NO_WATER_PRICE.getMessage());
@@ -330,7 +290,7 @@
// 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚
JSONObject job_rtu = getRtu(intakeId, null);
if(job_rtu == null) {
- irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.RTU_NOT_EXIST.getMessage() + "(" + intakeId + ")");
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.RTU_NOT_EXIST.getMessage() + "(" + intakeName + ")");
Map map = new HashMap<>();
map.put("success", false);
@@ -346,11 +306,22 @@
// 鐢熸垚璁㈠崟鍙�
String orderNo = generateOrderNo();
if(orderNo == null) {
- irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_ORDER_NUMBER.getMessage() + "(" + intakeId + ")");
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_ORDER_NUMBER.getMessage() + "(" + intakeName + ")");
Map map = new HashMap<>();
map.put("success", false);
map.put("msg", WechatResultCode.NO_ORDER_NUMBER.getMessage());
+ map.put("content", null);
+ return map;
+ }
+
+ // 鍒ゆ柇闃�鎺у櫒鏄惁宸茬粡寮�闃�
+ Boolean isOpen = irrigationSv.getOpenCloseStatus(rtuAddr);
+ if(isOpen) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, intakeName + " 闃�闂ㄤ负鎵撳紑鐘舵��");
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", intakeName + " 闃�闂ㄤ负鎵撳紑鐘舵��");
map.put("content", null);
return map;
}
@@ -379,11 +350,6 @@
param.setMinute(minute);
param.setOrderNo(orderNo);
- /**
- * 鏋勯�犲懡浠ゃ�佸彂閫佸懡浠ゅ苟澶勭悊璇锋眰缁撴灉鍙婃墽琛岀粨鏋�
- * 1 鍑嗗鍙傛暟
- * 2 璋冪敤鍏叡鏂规硶
- */
Param myParam = new Param();
myParam.setComId(comId);
myParam.setComType((byte)1);
@@ -399,6 +365,15 @@
myParam.setOpenType(openType);
BaseResponse<Boolean> result = dealWithCommandResult(myParam);
+ // 濡傛灉鍛戒护鎵ц澶辫触锛屽垯鍐嶆鎵ц鍛戒护
+ if(!result.isSuccess()) {
+ Long newComId = new IDLongGenerator().generate();
+ myParam.setComId(newComId);
+ result = dealWithCommandResult(myParam);
+
+ // 鏍规嵁operateId淇敼鍙栨按鍙f搷浣滆褰曚腑鐨刢ommandId
+ irIntakeOperateMapper.updateCommandId(newComId, operateId);
+ }
Map map = new HashMap<>();
map.put("success", result.isSuccess());
@@ -415,4 +390,352 @@
return map;
}
}
+
+ public Map openWx(ValveOpen valve, Long planId, Byte operatetype) {
+ Long intakeId = valve.getIntakeId();
+ String intakeName = valve.getIntakeName();
+ Long vcId = valve.getVcId();
+ Boolean forceOpen = valve.getForceOpen();
+ Long operator = valve.getOperator();
+ Byte openType = valve.getOpenType();
+ Long comId = new IDLongGenerator().generate();
+
+ // 濡傛灉鏄疆鐏�
+ if(openType != null && openType == 1) {
+ IrIntakeOperate irIntakeOperate = new IrIntakeOperate();
+ irIntakeOperate.setPlanId(planId);
+ irIntakeOperate.setOperateType(operatetype);
+ irIntakeOperate.setCommandId(comId);
+ irIntakeOperate.setIntakeId(intakeId);
+
+ Long id = addIntakeOperate(irIntakeOperate);
+ if(id == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "娣诲姞鍙栨按鍙f搷浣滆褰曞け璐�");
+ map.put("content", null);
+ return map;
+ }
+ }
+
+ if(intakeId == null && intakeName == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage());
+ }
+
+ // intakeName鎹ntakeId
+ if(intakeId == null) {
+ intakeId = getIntakeIdByName(intakeName);
+ if(intakeId == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage());
+ }
+ }
+
+ if (vcId == null) {
+ vcId = getVcIdByIntakeId(intakeId);
+ if (vcId == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage());
+ }
+ }
+
+ // 铏氭嫙鍗D鎹㈣櫄鎷熷崱瀵硅薄
+ VoVirtualCard vc = getVcById(vcId);
+ if (vc == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.PLEASE_SELECT_A_VC.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage());
+ }
+
+ // 铏氭嫙鍗$姸鎬佷负浣跨敤涓紝涓斾笉鏄己鍒跺紑闃�鏃舵彁绀�
+ if (vc.getInUse() && !forceOpen) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildCodeMsg(WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getCode(), WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage());
+ }
+
+ // 鑾峰彇姘翠环
+ Double waterPrice = getPrice();
+ if(waterPrice == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_WATER_PRICE.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.NO_WATER_PRICE.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.NO_WATER_PRICE.getMessage());
+ }
+
+ // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚
+ JSONObject job_rtu = getRtu(intakeId, null);
+ if (job_rtu == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.RTU_NOT_EXIST.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.RTU_NOT_EXIST.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage());
+ }
+ String rtuAddr = job_rtu.getString("rtuAddr");
+ String protocol = job_rtu.getString("protocol");
+
+ comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
+
+ // 鐢熸垚璁㈠崟鍙�
+ String orderNo = generateOrderNo();
+ if(orderNo == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.NO_ORDER_NUMBER.getMessage() + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.NO_ORDER_NUMBER.getMessage() + "(" + intakeId + ")");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.NO_ORDER_NUMBER.getMessage());
+ }
+
+ String commandCode = null;
+ if (protocol.equals(ProtocolConstantV206V202404.protocolName)) {
+ // 鑾峰彇鍔熻兘鐮�
+ commandCode = CodeV202404.cd_A2;
+
+ // 鍒涘缓瑙嗗浘
+ ComCd92_A2Vo param = new ComCd92_A2Vo();
+ param.controllerType = controllerType;
+ param.projectNo = projectNo;
+ param.icCardNo = vc.getVcNum().toString();
+ param.waterRemain = 0.0;
+ param.moneyRemain = vc.getMoney();
+ param.waterPrice = waterPrice;
+ param.elePrice = 0.0;
+ param.orderNo = orderNo;
+
+ Param myParam = new Param();
+ myParam.setComId(comId);
+ myParam.setComType((byte)1);
+ myParam.setCommandCode(commandCode);
+ myParam.setCommandName(CodeV202404.getCodeName(commandCode));
+ myParam.setIntakeId(intakeId);
+ myParam.setRtuAddr(rtuAddr);
+ myParam.setProtocol(protocol);
+ myParam.setVcId(vcId);
+ myParam.setParam(param);
+ myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx);
+ myParam.setOperator(operator);
+ //BaseResponse<Boolean> result = dealWithCommandResult(myParam);
+
+ BaseResponse<Boolean> result = dealWithCommandResult(myParam);
+ // 濡傛灉鍛戒护鎵ц澶辫触锛屽垯鍐嶆鎵ц鍛戒护
+ if(!result.isSuccess()) {
+ myParam.setComId(new IDLongGenerator().generate());
+ result = dealWithCommandResult(myParam);
+ }
+
+ Map map = new HashMap<>();
+ map.put("success", result.isSuccess());
+ map.put("msg", result.getMsg());
+ map.put("content", result.getContent());
+ return map;
+
+ } else if (protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) {
+ // 鑾峰彇鍔熻兘鐮�
+ commandCode = CodeV1.cd_97;
+
+ // 鍒涘缓瑙嗗浘
+ Com97Vo param = new Com97Vo();
+ param.icCardNo = vc.getVcNum().toString();
+ param.moneyRemain = vc.getMoney();
+ param.waterPrice = waterPrice;
+ param.orderNo = orderNo;
+
+ Param myParam = new Param();
+ myParam.setComId(comId);
+ myParam.setComType((byte)1);
+ myParam.setCommandCode(commandCode);
+ myParam.setCommandName(CodeV1.getCodeName(commandCode));
+ myParam.setIntakeId(intakeId);
+ myParam.setRtuAddr(rtuAddr);
+ myParam.setProtocol(protocol);
+ myParam.setVcId(vcId);
+ myParam.setParam(param);
+ myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx);
+ myParam.setOperator(operator);
+ //return dealWithCommandResult(myParam);
+ BaseResponse<Boolean> result = dealWithCommandResult(myParam);
+
+ Map map = new HashMap<>();
+ map.put("success", result.isSuccess());
+ map.put("msg", result.getMsg());
+ map.put("content", result.getContent());
+ return map;
+ } else {
+ //return BaseResponseUtils.buildErrorMsg("绯荤粺鏆備笉鏀寔璇ュ崗璁�");
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, "绯荤粺鏆備笉鏀寔璇ュ崗璁�" + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "绯荤粺鏆備笉鏀寔璇ュ崗璁�");
+ map.put("content", null);
+ return map;
+ }
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ public Map closeWx(ValveClose valve, Long planId, Byte operatetype) {
+ String rtuAddr = valve.getRtuAddr();
+ String vcNum = valve.getVcNum();
+ Long vcId = Optional.ofNullable(seVirtualCardMapper.getVcIdByNum(vcNum)).orElse(0L);
+ String orderNo = valve.getOrderNo();
+ Long operator = valve.getOperator();
+ Byte openType = valve.getOpenType();
+ Long comId = new IDLongGenerator().generate();
+
+ // 闃�鎺у櫒鍦板潃鎹㈠彇姘村彛ID鍜岄�氳鍗忚
+ JSONObject job_rtu = getRtu(null, rtuAddr);
+ if (job_rtu == null) {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, WechatResultCode.RTU_NOT_EXIST.getMessage());
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.RTU_NOT_EXIST.getMessage());
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage());
+ }
+ Long intakeId = job_rtu.getLong("intakeId");
+ String protocol = job_rtu.getString("protocol");
+
+ // 濡傛灉鏄疆鐏�
+ if(openType != null && openType == 1) {
+ IrIntakeOperate irIntakeOperate = new IrIntakeOperate();
+ irIntakeOperate.setPlanId(planId);
+ irIntakeOperate.setOperateType(operatetype);
+ irIntakeOperate.setCommandId(comId);
+ irIntakeOperate.setIntakeId(intakeId);
+ irIntakeOperate.setCommandResult((byte)1);
+
+ Long id = addIntakeOperate(irIntakeOperate);
+ if(id == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "娣诲姞鍙栨按鍙f搷浣滆褰曞け璐�");
+ map.put("content", null);
+ return map;
+ }
+ }
+
+ comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
+
+ String commandCode = null;
+ if (protocol.equals(ProtocolConstantV206V202404.protocolName)) {
+ // 鑾峰彇鍔熻兘鐮�
+ commandCode = CodeV202404.cd_A3;
+
+ // 鍒涘缓瑙嗗浘
+ ComCd93_A3Vo param = new ComCd93_A3Vo();
+ param.controllerType = controllerType;
+ param.projectNo = projectNo;
+ param.icCardNo = vcNum;
+ param.orderNo = orderNo;
+
+ Param myParam = new Param();
+ myParam.setComId(comId);
+ myParam.setComType((byte)2);
+ myParam.setCommandCode(commandCode);
+ myParam.setCommandName(CodeV202404.getCodeName(commandCode));
+ myParam.setIntakeId(intakeId);
+ myParam.setRtuAddr(rtuAddr);
+ myParam.setProtocol(protocol);
+ myParam.setVcId(vcId);
+ myParam.setParam(param);
+ myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx);
+ myParam.setOperator(operator);
+ //return dealWithCommandResult(myParam);
+ BaseResponse<Boolean> result = dealWithCommandResult(myParam);
+
+ Map map = new HashMap<>();
+ map.put("success", result.isSuccess());
+ map.put("msg", result.getMsg());
+ map.put("content", result.getContent());
+ return map;
+ } else if (protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) {
+ // 鑾峰彇鍔熻兘鐮�
+ commandCode = CodeV1.cd_98;
+
+ // 鍒涘缓瑙嗗浘
+ Com98Vo param = new Com98Vo();
+ param.icCardNo = vcNum;
+ param.orderNo = orderNo;
+
+ Param myParam = new Param();
+ myParam.setComId(comId);
+ myParam.setComType((byte)2);
+ myParam.setCommandCode(commandCode);
+ myParam.setCommandName(CodeV1.getCodeName(commandCode));
+ myParam.setIntakeId(intakeId);
+ myParam.setRtuAddr(rtuAddr);
+ myParam.setProtocol(protocol);
+ myParam.setVcId(vcId);
+ myParam.setParam(param);
+ myParam.setRtuResultSendWebUrl(rtuCallbackUrl_wx);
+ myParam.setOperator(operator);
+ //return dealWithCommandResult(myParam);
+
+ BaseResponse<Boolean> result = dealWithCommandResult(myParam);
+ // 濡傛灉鍛戒护鎵ц澶辫触锛屽垯鍐嶆鎵ц鍛戒护
+ if(!result.isSuccess()) {
+ myParam.setComId(new IDLongGenerator().generate());
+ result = dealWithCommandResult(myParam);
+ }
+
+ Map map = new HashMap<>();
+ map.put("success", result.isSuccess());
+ map.put("msg", result.getMsg());
+ map.put("content", result.getContent());
+ return map;
+
+ } else {
+ irIntakeOperateMapper.updateByCommandId(comId, (byte)2, "绯荤粺鏆備笉鏀寔璇ュ崗璁�" + "(" + intakeId + ")");
+
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "绯荤粺鏆備笉鏀寔璇ュ崗璁�");
+ map.put("content", null);
+ return map;
+ //return BaseResponseUtils.buildErrorMsg("绯荤粺鏆備笉鏀寔璇ュ崗璁�");
+ }
+
+ }
}
--
Gitblit v1.8.0