From 915221c09726c4105ecadd58aed1ea1cc860d504 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期五, 07 六月 2024 14:06:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 305 insertions(+), 34 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java index b6036ba..7e7def7 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java @@ -18,13 +18,15 @@ import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper; import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; +import com.dy.pipIrrGlobal.voRm.VoUnclosedParam; import com.dy.pipIrrGlobal.voRm.VoUnclosedValve; import com.dy.pipIrrGlobal.voSe.VoVirtualCard; import com.dy.pipIrrRemote.common.CommandSv; +import com.dy.pipIrrRemote.common.dto.DtoBase; import com.dy.pipIrrRemote.common.dto.ValveClose; import com.dy.pipIrrRemote.common.dto.ValveOpen; +import com.dy.pipIrrRemote.common.enums.LastOperateENUM; import com.dy.pipIrrRemote.result.RemoteResultCode; -import com.dy.pipIrrSell.virtualCard.enums.LastOperateENUM; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -58,7 +60,7 @@ private String rtuResultSendWebUrl = "http://127.0.0.1:8081/remote/comRes/receive" ; /** - * 灏忕▼搴忚繙绋嬪紑闃� + * 骞冲彴杩滅▼寮�闃� * @param valve * @param bindingResult * @return @@ -93,8 +95,6 @@ if(!setuped) { setUp(); } -// 鍙栨按鍙D鎹㈠彇姘村彛瀵硅薄 -// 濡傛灉鍙栨按鍙d负鎵撳紑鐘舵�侊紝鍒欎笉鍏佽琚紑闃� // 铏氭嫙鍗D鎹㈣櫄鎷熷崱瀵硅薄 VoVirtualCard vc = commandSv.getVcById(vcId); @@ -155,10 +155,10 @@ // 鍥炶皟澶辫触 if(!response_CallBack.getCode().equals("0001")) { // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触 - rmCommandHistory = new RmCommandHistory(); - rmCommandHistory.setId(comId); - rmCommandHistory.setResult((byte)0); - commandSv.updateCommandResult(rmCommandHistory); + //rmCommandHistory = new RmCommandHistory(); + //rmCommandHistory.setId(comId); + //rmCommandHistory.setResult((byte)0); + //commandSv.updateCommandResult(rmCommandHistory); return BaseResponseUtils.buildFail(response_CallBack.getMsg()); //return BaseResponseUtils.buildFail(response_CallBack.getContent().toString()); } @@ -177,16 +177,23 @@ * 鎵ц鎴愬姛 * 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� */ - SeVirtualCard virtualCard = new SeVirtualCard(); - virtualCard.setId(vcId); - virtualCard.setInUse((byte) 1); - virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); - virtualCard.setLastOperateTime(new Date()); - seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + //SeVirtualCard virtualCard = new SeVirtualCard(); + //virtualCard.setId(vcId); + //virtualCard.setInUse((byte) 1); + //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + //virtualCard.setLastOperateTime(new Date()); + //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); // 鍥炶皟杩斿洖鐨勫唴瀹� - Data myData = (Data)response_CallBack.getContent(); - return BaseResponseUtils.buildSuccess(myData) ; + //Data myData = (Data)response_CallBack.getContent(); + //return BaseResponseUtils.buildSuccess(myData); + + JSONObject job_response = new JSONObject(); + job_response.put("rtuAddr", rtuAddr); + job_response.put("vcNum", vc.getVcNum()); + job_response.put("orderNo", orderNo); + //job_response.put("operator", operator); + return BaseResponseUtils.buildSuccess(job_response); } else { // 璇锋眰澶辫触 JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param"); @@ -220,15 +227,45 @@ // 澶勭悊鍥炶皟 BaseResponse response_CallBack = dealWithCallBack(comId); - //鍥炶皟澶辫触 + //鍥炶皟寮傚父 if(!response_CallBack.getCode().equals("0001")) { // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触 rmCommandHistory = new RmCommandHistory(); rmCommandHistory.setId(comId); rmCommandHistory.setResult((byte)0); commandSv.updateCommandResult(rmCommandHistory); - return BaseResponseUtils.buildFail(response_CallBack.getMsg()); - //return BaseResponseUtils.buildFail(response_CallBack.getContent().toString()); + return BaseResponseUtils.buildFail(response_CallBack.getContent().toString()); + } + + // 鍥炶皟瓒呮椂 + if(response_CallBack.getContent().toString().equals(RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage())) { + /** + * 鍥炶皟瓒呮椂锛屾殏鏃惰涓烘墽琛屽け璐� + * 鍛戒护缃负澶辫触 + * 铏氭嫙鍗′緷鏃т繚鎸佷娇鐢ㄤ腑鐨勭姸鎬� + * 涓嶈繑鍥炲叧闃�鍙傛暟 + */ + + rmCommandHistory = new RmCommandHistory(); + rmCommandHistory.setId(comId); + rmCommandHistory.setResult((byte)0); + commandSv.updateCommandResult(rmCommandHistory); + + //SeVirtualCard virtualCard = new SeVirtualCard(); + //virtualCard.setId(vcId); + //virtualCard.setInUse((byte) 1); + //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + //virtualCard.setLastOperateTime(new Date()); + //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + + //JSONObject job_response = new JSONObject(); + //job_response.put("message", RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage()); + //job_response.put("rtuAddr", rtuAddr); + //job_response.put("vcNum", vc.getVcNum()); + //job_response.put("orderNo", orderNo); + //return BaseResponseUtils.buildSuccess(job_response); + return BaseResponseUtils.buildFail(RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage()); + } // 鍥炶皟鎴愬姛锛屽啀鍒ゆ柇鎵ц鏄惁鎴愬姛 @@ -253,8 +290,17 @@ seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); // 鍥炶皟杩斿洖鐨勫唴瀹� - Data myData = (Data)response_CallBack.getContent(); - return BaseResponseUtils.buildSuccess(myData) ; + //Data myData = (Data)response_CallBack.getContent(); + //return BaseResponseUtils.buildSuccess(myData) ; + + JSONObject job_response = new JSONObject(); + job_response.put("message", "ok"); + job_response.put("rtuAddr", rtuAddr); + job_response.put("vcNum", vc.getVcNum()); + job_response.put("orderNo", orderNo); + //job_response.put("operator", operator); + return BaseResponseUtils.buildSuccess(job_response); + } else { // 璇锋眰澶辫触 JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param"); @@ -266,7 +312,7 @@ } /** - * 灏忕▼搴忚繙绋嬪叧闃� + * 骞冲彴杩滅▼鍏抽榾_鍙傛暟妯″紡 * @param valve * @param bindingResult * @return @@ -330,10 +376,10 @@ // 鍥炶皟澶辫触 if(!response_CallBack.getCode().equals("0001")) { // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触 - rmCommandHistory = new RmCommandHistory(); - rmCommandHistory.setId(comId); - rmCommandHistory.setResult((byte)0); - commandSv.updateCommandResult(rmCommandHistory); + //rmCommandHistory = new RmCommandHistory(); + //rmCommandHistory.setId(comId); + //rmCommandHistory.setResult((byte)0); + //commandSv.updateCommandResult(rmCommandHistory); return BaseResponseUtils.buildFail(response_CallBack.getMsg()); //return BaseResponseUtils.buildError(WechatResultCode.GET_RESULT_ERROR.getMessage()); } @@ -352,13 +398,13 @@ * 鎵ц鎴愬姛 * 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� */ - Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); - SeVirtualCard virtualCard = new SeVirtualCard(); - virtualCard.setId(vcId); - virtualCard.setInUse((byte) 0); - virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); - virtualCard.setLastOperateTime(new Date()); - seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + //Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); + //SeVirtualCard virtualCard = new SeVirtualCard(); + //virtualCard.setId(vcId); + //virtualCard.setInUse((byte) 0); + //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + //virtualCard.setLastOperateTime(new Date()); + //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); // 鍥炶皟杩斿洖鐨勫唴瀹� Data myData = (Data)response_CallBack.getContent(); @@ -394,13 +440,149 @@ // 澶勭悊鍥炶皟 BaseResponse response_CallBack = dealWithCallBack(comId); - // 鍥炶皟澶辫触 + // 鍥炶皟寮傚父 if(!response_CallBack.getCode().equals("0001")) { // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触 rmCommandHistory = new RmCommandHistory(); rmCommandHistory.setId(comId); rmCommandHistory.setResult((byte)0); commandSv.updateCommandResult(rmCommandHistory); + return BaseResponseUtils.buildFail(response_CallBack.getContent().toString()); + } + + // 鍥炶皟瓒呮椂 + if(response_CallBack.getContent().toString().equals(RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage())) { + /** + * 鍥炶皟瓒呮椂锛屾殏鏃惰涓烘墽琛屽け璐� + * 鍛戒护缃负澶辫触 + * 铏氭嫙鍗′緷鏃т繚鎸佷娇鐢ㄤ腑鐨勭姸鎬� + */ + + rmCommandHistory = new RmCommandHistory(); + rmCommandHistory.setId(comId); + rmCommandHistory.setResult((byte)0); + commandSv.updateCommandResult(rmCommandHistory); + + //Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); + //SeVirtualCard virtualCard = new SeVirtualCard(); + //virtualCard.setId(vcId); + //virtualCard.setInUse((byte) 0); + //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + //virtualCard.setLastOperateTime(new Date()); + //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + return BaseResponseUtils.buildFail(RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage()); + } + + // 鍥炶皟鎴愬姛锛屽啀鍒ゆ柇鎵ц鏄惁鎴愬姛 + JSONObject job_content = (JSONObject)JSON.toJSON(response_CallBack.getContent()); + System.out.println(job_content); + JSONObject job_subData = (JSONObject) job_content.getJSONObject("subData").getJSONObject("subData"); + System.out.println(job_subData); + Boolean dealResult = job_subData.getBoolean("success"); + if(!dealResult) { + return BaseResponseUtils.buildFail(response_CallBack.getContent().toString()); + } + + /** + * 鎵ц鎴愬姛 + * 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� + */ + Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); + SeVirtualCard virtualCard = new SeVirtualCard(); + virtualCard.setId(vcId); + virtualCard.setInUse((byte) 0); + virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + virtualCard.setLastOperateTime(new Date()); + seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + + // 鍥炶皟杩斿洖鐨勫唴瀹� + Data myData = (Data)response_CallBack.getContent(); + return BaseResponseUtils.buildSuccess(myData) ; + } else { + // 璇锋眰澶辫触 + JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param"); + return BaseResponseUtils.buildFail(job_param.getString("message")); + } + } else { + return BaseResponseUtils.buildFail("绯荤粺鏆備笉鏀寔璇ュ崗璁�"); + } + } + + /** + * 骞冲彴杩滅▼鍏抽榾_鍙栨按鍙fā寮� + * @param dtoBase + * @param bindingResult + * @return + */ + @PostMapping(path = "close_intake", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> closeByIntake(@RequestBody @Valid DtoBase dtoBase, BindingResult bindingResult) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyMMddHHmmss"); + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Long intakeId = dtoBase.getIntakeId(); + Long operator = dtoBase.getOperator(); + + VoUnclosedParam voUnclosedParam = commandSv.getUncloseParam(intakeId); + if(voUnclosedParam == null) { + return BaseResponseUtils.buildSuccess(RemoteResultCode.VALVE_CLOSED.getMessage()); + } + String rtuAddr = voUnclosedParam.getRtuAddr(); + String vcNum = voUnclosedParam.getVcNum(); + String orderNo = voUnclosedParam.getOrderNo(); + Long comId = idLongGenerator.generate(); + + // 鑾峰彇绯荤粺鍙傛暟 + if(!setuped) { + setUp(); + } + + // 闃�鎺у櫒鍦板潃鎹㈠彇姘村彛ID鍜岄�氳鍗忚 + JSONObject job_rtu = getRtu(null, rtuAddr); + if(job_rtu == null) { + return BaseResponseUtils.buildError(RemoteResultCode.RTU_NOT_EXIST.getMessage()); + } + //Long intakeId = job_rtu.getLong("intakeId"); + String protocol = job_rtu.getString("protocol"); + + String commandCode = null; + if(protocol.equals("p206V202404")) { + // 鑾峰彇鍔熻兘鐮� + commandCode = CodeV202404.cd_93; + + // 鍒涘缓瑙嗗浘 + ComCd93_A3Vo param = new ComCd93_A3Vo(); + param.controllerType = controllerType; + param.projectNo = projectNo; + param.icCardNo = vcNum; + param.orderNo = orderNo; + + // 鏋勯�犲懡浠� + Command com = command(comId, commandCode, rtuAddr, protocol, rtuResultSendWebUrl, param); + + // 鍙戦�佸懡浠� + JSONObject response_SendCom= (JSONObject) JSON.toJSON(sendCom2Mw(com)); + if(response_SendCom != null && response_SendCom.getString("code").equals("0001")) { + // 璇锋眰鎴愬姛 + + // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 + String commandName = CodeV202404.getCodeName(commandCode); + RmCommandHistory rmCommandHistory = getComHistory(comId, commandCode, commandName, intakeId, rtuAddr, protocol, param, operator); + commandSv.insert(rmCommandHistory); + + // 澶勭悊鍥炶皟 + BaseResponse response_CallBack = dealWithCallBack(comId); + + // 鍥炶皟澶辫触 + if(!response_CallBack.getCode().equals("0001")) { + // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触 + //rmCommandHistory = new RmCommandHistory(); + //rmCommandHistory.setId(comId); + //rmCommandHistory.setResult((byte)0); + //commandSv.updateCommandResult(rmCommandHistory); return BaseResponseUtils.buildFail(response_CallBack.getMsg()); //return BaseResponseUtils.buildError(WechatResultCode.GET_RESULT_ERROR.getMessage()); } @@ -419,6 +601,95 @@ * 鎵ц鎴愬姛 * 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� */ + //Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); + //SeVirtualCard virtualCard = new SeVirtualCard(); + //virtualCard.setId(vcId); + //virtualCard.setInUse((byte) 0); + //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + //virtualCard.setLastOperateTime(new Date()); + //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + + // 鍥炶皟杩斿洖鐨勫唴瀹� + Data myData = (Data)response_CallBack.getContent(); + return BaseResponseUtils.buildSuccess(myData) ; + } else { + // 璇锋眰澶辫触 + JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param"); + return BaseResponseUtils.buildFail(job_param.getString("message")); + } + } else if(protocol.equals("p206V1_0_1")) { + // 鑾峰彇鍔熻兘鐮� + commandCode = CodeV1_0_1.cd_93; + + // 鍒涘缓瑙嗗浘 + Com98Vo param = new Com98Vo() ; + param.icCardNo = vcNum; + param.orderNo = orderNo; + + // 鏋勯�犲懡浠� + Command com = command(comId, commandCode, rtuAddr, protocol, rtuResultSendWebUrl, param); + + // 鍙戦�佸懡浠� + JSONObject response_SendCom= (JSONObject) JSON.toJSON(sendCom2Mw(com)); + if(response_SendCom != null && response_SendCom.getString("code").equals("0001")) { + //if(1 > 0) { + // 璇锋眰鎴愬姛 + + // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 + String commandName = CodeV1_0_1.getCodeName(commandCode); + RmCommandHistory rmCommandHistory = getComHistory(comId, commandCode, commandName, intakeId, rtuAddr, protocol, param, operator); + commandSv.insert(rmCommandHistory); + + // 澶勭悊鍥炶皟 + BaseResponse response_CallBack = dealWithCallBack(comId); + + // 鍥炶皟寮傚父 + if(!response_CallBack.getCode().equals("0001")) { + // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触 + rmCommandHistory = new RmCommandHistory(); + rmCommandHistory.setId(comId); + rmCommandHistory.setResult((byte)0); + commandSv.updateCommandResult(rmCommandHistory); + return BaseResponseUtils.buildFail(response_CallBack.getContent().toString()); + } + + // 鍥炶皟瓒呮椂 + if(response_CallBack.getContent().toString().equals(RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage())) { + /** + * 鍥炶皟瓒呮椂锛屾殏鏃惰涓烘墽琛屽け璐� + * 鍛戒护缃负澶辫触 + * 铏氭嫙鍗′緷鏃т繚鎸佷娇鐢ㄤ腑鐨勭姸鎬� + */ + + rmCommandHistory = new RmCommandHistory(); + rmCommandHistory.setId(comId); + rmCommandHistory.setResult((byte)0); + commandSv.updateCommandResult(rmCommandHistory); + + //Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); + //SeVirtualCard virtualCard = new SeVirtualCard(); + //virtualCard.setId(vcId); + //virtualCard.setInUse((byte) 0); + //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + //virtualCard.setLastOperateTime(new Date()); + //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + return BaseResponseUtils.buildFail(RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage()); + } + + // 鍥炶皟鎴愬姛锛屽啀鍒ゆ柇鎵ц鏄惁鎴愬姛 + JSONObject job_content = (JSONObject)JSON.toJSON(response_CallBack.getContent()); + System.out.println(job_content); + JSONObject job_subData = (JSONObject) job_content.getJSONObject("subData").getJSONObject("subData"); + System.out.println(job_subData); + Boolean dealResult = job_subData.getBoolean("success"); + if(!dealResult) { + return BaseResponseUtils.buildFail(response_CallBack.getContent().toString()); + } + + /** + * 鎵ц鎴愬姛 + * 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� + */ Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); SeVirtualCard virtualCard = new SeVirtualCard(); virtualCard.setId(vcId); -- Gitblit v1.8.0