From e67870fff62635cd14beb0d5988f08aeef4b22fa Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 07 四月 2025 21:27:06 +0800 Subject: [PATCH] 添加远程关阀式终止灌溉计划,未测试 --- pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java | 234 +++++++++++++++++++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoIntakeVc.java | 27 ++ pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java | 266 +++++++++++++------------- pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java | 21 ++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml | 9 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/dto/ValveOpen.java | 5 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java | 12 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java | 16 + 8 files changed, 452 insertions(+), 138 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java index 183454d..55372ef 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java @@ -2,10 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; -import com.dy.pipIrrGlobal.voRm.VoCommand; -import com.dy.pipIrrGlobal.voRm.VoRtuAndVc; -import com.dy.pipIrrGlobal.voRm.VoUnclosedParam; -import com.dy.pipIrrGlobal.voRm.VoUnclosedValve; +import com.dy.pipIrrGlobal.voRm.*; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -84,4 +81,11 @@ * @return */ String getTimeByCommId(Long commId); + + /** + * 鏍规嵁鍛戒护鏃ュ織ID鑾峰彇鍙栨按鍙e強铏氭嫙鍗′俊鎭紝缁堟鐏屾簤璁″垝鏃朵娇鐢紝鐢ㄦ潵鎵ц杩滅▼鍏抽榾 + * @param commandId + * @return + */ + VoIntakeVc getIntakeVc(Long commandId); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoIntakeVc.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoIntakeVc.java new file mode 100644 index 0000000..51a78be --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoIntakeVc.java @@ -0,0 +1,27 @@ +package com.dy.pipIrrGlobal.voRm; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2025-04-07 21:08 + * @LastEditTime 2025-04-07 21:08 + * @Description 鍙栨按鍙c�佽櫄鎷熷崱瑙嗗浘瀵硅薄锛岀粓姝㈢亴婧夎鍒掓椂浣跨敤锛岀敤鏉ユ墽琛岃繙绋嬪叧闃� + */ + +@Data +@JsonPropertyOrder({"intakeId", "vcId"}) +public class VoIntakeVc { + public static final long serialVersionUID = 202411281712001L; + + /** + * 鍙栨按鍙D + */ + private Long intakeId; + + /** + * 铏氭嫙鍗D + */ + private Long vcId; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml index 992a58e..14eefe6 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml @@ -393,4 +393,13 @@ FROM rm_command_history WHERE com_id = #{commId} </select> + + <!--鏍规嵁鍛戒护鏃ュ織ID鑾峰彇鍙栨按鍙e強铏氭嫙鍗′俊鎭紝缁堟鐏屾簤璁″垝鏃朵娇鐢紝鐢ㄦ潵鎵ц杩滅▼鍏抽榾--> + <select id="getIntakeVc" resultType="com.dy.pipIrrGlobal.voRm.VoIntakeVc"> + SELECT + intake_id AS intakeId, + (SELECT id FROM se_virtual_card WHERE vc_num = param ->> '$.icCardNo') AS vcId + FROM rm_command_history WHERE com_id = #{commandId} + LIMIT 0, 1 + </select> </mapper> \ No newline at end of file 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 a36dfaa..e940483 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,11 +7,15 @@ 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.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.util.IDLongGenerator; import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.command.ComSupport; import com.dy.pipIrrGlobal.command.dto.Param; @@ -32,6 +36,7 @@ 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.ValveOpen; import com.dy.pipIrrWechat.result.WechatResultCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -423,4 +428,233 @@ 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()); + } + } + + /** + * 濡傛灉鍐滄埛閫夋嫨浜嗚櫄鎷熷崱锛屽垯浣跨敤璇ヨ櫄鎷熷崱 + * 濡傛灉鍐滄埛鏈�夋嫨铏氭嫙鍗★紝鍒欐牴鎹彇姘村彛ID鑾峰彇涓庝箣缁戝畾鐨勮櫄鎷熷崱 + * 濡傛灉鍙栨按鍙f病鏈変笌涔嬬粦瀹氱殑铏氭嫙鍗★紝鍒欐彁绀哄啘鎴烽�夋嫨涓�寮犺櫄鎷熷崱 + */ + 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; + + /** + * 鏋勯�犲懡浠ゃ�佸彂閫佸懡浠ゅ苟澶勭悊璇锋眰缁撴灉鍙婃墽琛岀粨鏋� + * 1 鍑嗗鍙傛暟 + * 2 璋冪敤鍏叡鏂规硶 + */ + 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); + + 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; + + /** + * 鏋勯�犲懡浠ゃ�佸彂閫佸懡浠ゅ苟澶勭悊璇锋眰缁撴灉鍙婃墽琛岀粨鏋� + * 1 鍑嗗鍙傛暟 + * 2 璋冪敤鍏叡鏂规硶 + */ + 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; + } + } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java index bfe5672..c327f54 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java @@ -85,141 +85,143 @@ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } - Long intakeId = valve.getIntakeId(); - String intakeName = valve.getIntakeName(); - Long vcId = valve.getVcId(); - Boolean forceOpen = valve.getForceOpen(); - Long operator = valve.getOperator(); - Long comId = new IDLongGenerator().generate(); - - if(intakeId == null && intakeName == null) { - return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage()); + Map map_result = commandSv.openWx(valve, null, null); + if(map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); } + return BaseResponseUtils.buildSuccess(map_result.get("content")) ; - // intakeName鎹ntakeId - if(intakeId == null) { - intakeId = commandSv.getIntakeIdByName(intakeName); - if(intakeId == null) { - return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage()); - } - } - - /** - * 濡傛灉鍐滄埛閫夋嫨浜嗚櫄鎷熷崱锛屽垯浣跨敤璇ヨ櫄鎷熷崱 - * 濡傛灉鍐滄埛鏈�夋嫨铏氭嫙鍗★紝鍒欐牴鎹彇姘村彛ID鑾峰彇涓庝箣缁戝畾鐨勮櫄鎷熷崱 - * 濡傛灉鍙栨按鍙f病鏈変笌涔嬬粦瀹氱殑铏氭嫙鍗★紝鍒欐彁绀哄啘鎴烽�夋嫨涓�寮犺櫄鎷熷崱 - */ - if (vcId == null) { - vcId = commandSv.getVcIdByIntakeId(intakeId); - if (vcId == null) { - return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); - } - } - - // 铏氭嫙鍗D鎹㈣櫄鎷熷崱瀵硅薄 - VoVirtualCard vc = commandSv.getVcById(vcId); - if (vc == null) { - return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); - } - - // 铏氭嫙鍗$姸鎬佷负浣跨敤涓紝涓斾笉鏄己鍒跺紑闃�鏃舵彁绀� - if (vc.getInUse() && !forceOpen) { - return BaseResponseUtils.buildCodeMsg(WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getCode(), WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage()); - } - - // 鑾峰彇姘翠环 - Double waterPrice = commandSv.getPrice(); - if(waterPrice == null) { - return BaseResponseUtils.buildErrorMsg(WechatResultCode.NO_WATER_PRICE.getMessage()); - } - - // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚 - JSONObject job_rtu = getRtu(intakeId, null); - if (job_rtu == null) { - return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage()); - } - String rtuAddr = job_rtu.getString("rtuAddr"); - String protocol = job_rtu.getString("protocol"); - //String orgTag = job_rtu.getString("orgTag"); - //if(orgTag == null) { - // return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_SET_DATA_SOURCE.getMessage()); + //Long intakeId = valve.getIntakeId(); + //String intakeName = valve.getIntakeName(); + //Long vcId = valve.getVcId(); + //Boolean forceOpen = valve.getForceOpen(); + //Long operator = valve.getOperator(); + //Long comId = new IDLongGenerator().generate(); + // + //if(intakeId == null && intakeName == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage()); //} - //comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); - comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw); - - // 鐢熸垚璁㈠崟鍙� - String orderNo = generateOrderNo(); - if(orderNo == null) { - 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; - - /** - * 鏋勯�犲懡浠ゃ�佸彂閫佸懡浠ゅ苟澶勭悊璇锋眰缁撴灉鍙婃墽琛岀粨鏋� - * 1 鍑嗗鍙傛暟 - * 2 璋冪敤鍏叡鏂规硶 - */ - 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); - return dealWithCommandResult(myParam); - - } 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; - - /** - * 鏋勯�犲懡浠ゃ�佸彂閫佸懡浠ゅ苟澶勭悊璇锋眰缁撴灉鍙婃墽琛岀粨鏋� - * 1 鍑嗗鍙傛暟 - * 2 璋冪敤鍏叡鏂规硶 - */ - 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); - } else { - return BaseResponseUtils.buildErrorMsg("绯荤粺鏆備笉鏀寔璇ュ崗璁�"); - } + // + //// intakeName鎹ntakeId + //if(intakeId == null) { + // intakeId = commandSv.getIntakeIdByName(intakeName); + // if(intakeId == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_INTAKE.getMessage()); + // } + //} + // + ///** + // * 濡傛灉鍐滄埛閫夋嫨浜嗚櫄鎷熷崱锛屽垯浣跨敤璇ヨ櫄鎷熷崱 + // * 濡傛灉鍐滄埛鏈�夋嫨铏氭嫙鍗★紝鍒欐牴鎹彇姘村彛ID鑾峰彇涓庝箣缁戝畾鐨勮櫄鎷熷崱 + // * 濡傛灉鍙栨按鍙f病鏈変笌涔嬬粦瀹氱殑铏氭嫙鍗★紝鍒欐彁绀哄啘鎴烽�夋嫨涓�寮犺櫄鎷熷崱 + // */ + //if (vcId == null) { + // vcId = commandSv.getVcIdByIntakeId(intakeId); + // if (vcId == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); + // } + //} + // + //// 铏氭嫙鍗D鎹㈣櫄鎷熷崱瀵硅薄 + //VoVirtualCard vc = commandSv.getVcById(vcId); + //if (vc == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage()); + //} + // + //// 铏氭嫙鍗$姸鎬佷负浣跨敤涓紝涓斾笉鏄己鍒跺紑闃�鏃舵彁绀� + //if (vc.getInUse() && !forceOpen) { + // return BaseResponseUtils.buildCodeMsg(WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getCode(), WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage()); + //} + // + //// 鑾峰彇姘翠环 + //Double waterPrice = commandSv.getPrice(); + //if(waterPrice == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.NO_WATER_PRICE.getMessage()); + //} + // + //// 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚 + //JSONObject job_rtu = getRtu(intakeId, null); + //if (job_rtu == null) { + // 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) { + // 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; + // + // /** + // * 鏋勯�犲懡浠ゃ�佸彂閫佸懡浠ゅ苟澶勭悊璇锋眰缁撴灉鍙婃墽琛岀粨鏋� + // * 1 鍑嗗鍙傛暟 + // * 2 璋冪敤鍏叡鏂规硶 + // */ + // 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); + // return dealWithCommandResult(myParam); + // + //} 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; + // + // /** + // * 鏋勯�犲懡浠ゃ�佸彂閫佸懡浠ゅ苟澶勭悊璇锋眰缁撴灉鍙婃墽琛岀粨鏋� + // * 1 鍑嗗鍙傛暟 + // * 2 璋冪敤鍏叡鏂规硶 + // */ + // 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); + //} else { + // return BaseResponseUtils.buildErrorMsg("绯荤粺鏆備笉鏀寔璇ュ崗璁�"); + //} } /** diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/dto/ValveOpen.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/dto/ValveOpen.java index d86edd3..0c36cf7 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/dto/ValveOpen.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/dto/ValveOpen.java @@ -25,4 +25,9 @@ */ private Boolean forceOpen = false; + /** + * 寮�闃�绫诲瀷锛�1-杞亴 + */ + private Byte openType; + } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java index e052a51..4f02d79 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java @@ -6,11 +6,14 @@ import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule; import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate; import com.dy.pipIrrGlobal.pojoIr.IrPlanSchedule; +import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule; import com.dy.pipIrrGlobal.voIr.VoPlanSimple; import com.dy.pipIrrGlobal.voIr.VoPlans; +import com.dy.pipIrrGlobal.voRm.VoIntakeVc; import com.dy.pipIrrWechat.command.CommandSv; import com.dy.pipIrrWechat.command.dto.AutomaticClose; +import com.dy.pipIrrWechat.command.dto.ValveOpen; import com.dy.pipIrrWechat.irrigatePlan.dto.IrrigatePlan; import com.dy.pipIrrWechat.irrigatePlan.dto.IrrigateSchedule; import com.dy.pipIrrWechat.irrigatePlan.dto.PlanSimple; @@ -308,7 +311,7 @@ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String terminateStartTimeStr = "2000-01-01 00:00:00"; Date terminateStartTime = Date.from(LocalDateTime.parse(terminateStartTimeStr, formatter).atZone(ZoneId.systemDefault()).toInstant()); - Integer terminateDuration = 100000; + Integer terminateDuration = 9999; // 鑾峰彇鍙粓姝㈡搷浣滆鍒掔殑鐏屾簤寮�濮嬫椂闂� Date planStartTime = irrigatePlanSv.getToTerminatePlan(planId); @@ -355,6 +358,22 @@ } } else { // 鎵ц杩滅▼鍏抽榾 + List<Long> commandIds = irrigatePlanSv.getTerminateCommandIds(planId); + for(Long commandId : commandIds) { + VoIntakeVc intakeVc = irrigatePlanSv.getIntakeVc(commandId); + Long intakeId = intakeVc.getIntakeId(); + Long vdId = intakeVc.getVcId(); + + ValveOpen valve = new ValveOpen(); + valve.setIntakeId(intakeId); + valve.setVcId(vdId); + valve.setForceOpen(true); + valve.setOperator(operatorId); + valve.setOpenType(Byte.valueOf("1")); + + commandSv.openWx(valve, planId, operateType); + } + } return BaseResponseUtils.buildSuccess(); diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java index 4ac5574..abe5155 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java @@ -1,6 +1,7 @@ package com.dy.pipIrrWechat.irrigatePlan; import com.dy.pipIrrGlobal.daoIr.*; +import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan; import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule; import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate; @@ -8,6 +9,7 @@ import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule; import com.dy.pipIrrGlobal.voIr.VoPlanSimple; import com.dy.pipIrrGlobal.voIr.VoPlans; +import com.dy.pipIrrGlobal.voRm.VoIntakeVc; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,6 +54,9 @@ @Autowired private IrIntakeOperateMapper irIntakeOperateMapper; + @Autowired + private RmCommandHistoryMapper rmdCommandHistoryMapper; + /** * 娣诲姞鐏屾簤璁″垝 * @param po @@ -81,7 +86,7 @@ } /** - * 鏍规嵁璁″垝ID鑾峰彇寰呯粓姝㈢殑鍛戒护ID + * 鏍规嵁璁″垝ID鑾峰彇寰呯粓姝㈢殑鍛戒护ID鍒楄〃 * @param planId * @return */ @@ -90,6 +95,15 @@ } /** + * 鏍规嵁鍛戒护鏃ュ織ID鑾峰彇鍙栨按鍙e強铏氭嫙鍗′俊鎭紝缁堟鐏屾簤璁″垝鏃朵娇鐢紝鐢ㄦ潵鎵ц杩滅▼鍏抽榾 + * @param commandId + * @return + */ + public VoIntakeVc getIntakeVc(Long commandId) { + return rmdCommandHistoryMapper.getIntakeVc(commandId); + } + + /** * 淇敼鐏屾簤璁″垝 * @param po * @return -- Gitblit v1.8.0