From b218f31bb202cffa656fa4ee09bdd8d67f8ed0ef Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期二, 13 五月 2025 17:29:42 +0800 Subject: [PATCH] 1、根据江海调整,功能码92、A2的应答中的日期时间去除; 2、表阀一体机的开关阀上行数据(84、85)处理逻辑进行修改。 --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd92/CdCtrl.java | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 171 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd92/CdCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd92/CdCtrl.java new file mode 100644 index 0000000..5c62c48 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/cd92/CdCtrl.java @@ -0,0 +1,171 @@ +package com.dy.pipIrrRemote.monitor.p202404V201.cd92; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.dy.common.aop.SsoAop; +import com.dy.common.mw.protocol.Command; +import com.dy.common.mw.protocol.p206V202404.upVos.DataCd92_A2Vo; +import com.dy.common.util.Callback; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.pipIrrGlobal.voSe.VoVirtualCard; +import com.dy.pipIrrRemote.common.dto.DtoBase; +import com.dy.pipIrrRemote.monitor.common.ComCtrl; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.http.MediaType; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: liurunyu + * @Date: 2025/5/13 08:33 + * @Description + */ +@Slf4j +@Tag(name = "杩滅▼鍛戒护", description = "骞冲彴杩滅▼寮�闃�") +@RestController("cd92Ctrl") +@RequestMapping(path = "p202404V201/cd92") +@RequiredArgsConstructor +@Scope("prototype") //鍥犱负鏈夊璞$被灞炴�э紝鎵�浠ラ噰鐢ㄥ師鍨嬫ā寮忥紝姣忔璇锋眰鏂板缓涓�涓疄渚嬪璞� +public class CdCtrl extends ComCtrl { + + private static final String RtuSuccessMsg = "鎺у埗鍣ㄦ帴鏀跺苟鎵ц鍛戒护鎴愬姛锛屾棤杩斿洖鏁版嵁"; + + private static final String ComCode = "92" ; + + @Autowired + private CdSv sv ; + /** + * 鍚戣澶囷紙鎺у埗鍣級鍙戦�佸懡浠� + * @param dto 鍓嶇鍙戞潵鐨勫�煎璞� + * @param bindingResult 瀵筪to楠岃瘉鐨勭粨鏋� + * @return 杩斿洖鍓嶇 + */ + @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Object> send(@RequestBody @Valid CdDto dto, BindingResult bindingResult) { + BaseResponse<Object> res ; + //鍙戦�佸懡浠ゅ墠-1锛氶獙璇� + res = super.pre1(sv, ComCode, dto, bindingResult); + if(res == null) { + //鍙戦�佸懡浠ゅ墠-2锛氳幏寰楁暟鎹� + res = super.pre2(sv, ComCode, dto, bindingResult); + if (res == null) { + if(dto.vtCardId == null || "".equals(dto.vtCardId.trim())){ + Long vtId = sv.selectVcIdByIntakeId(dto.getIntakeId()) ; + if(vtId == null) { + return BaseResponseUtils.buildErrorMsg("璇烽�夋嫨涓�寮犺櫄鎷熷崱"); + }else{ + dto.vtCardId = vtId.toString() ; + } + } + VoVirtualCard vcPo = sv.selectClientVtCardById(Long.parseLong(dto.vtCardId.trim())) ; + if(vcPo == null){ + return BaseResponseUtils.buildErrorMsg("鏈嶅姟绔嚭閿欙紝鏈緱鍒板啘鎴疯櫄鎷熷崱") ; + } + if(vcPo.getInUse().booleanValue()){ + return BaseResponseUtils.buildErrorMsg("鍐滄埛璇ヨ櫄鎷熷崱宸茬粡琚崰鐢紝涓嶈兘鍐嶅簲鐢ㄥ叾寮�闃�") ; + } + if(vcPo.getMoney() <= 0.0){ + return BaseResponseUtils.buildErrorMsg("鍐滄埛璇ヨ櫄鎷熷崱涓墿浣欓噾棰濅负0锛屼笉鑳藉啀搴旂敤鍏跺紑闃�") ; + } + Double waterPrice = sv.selectWaterPrice() ; + if(waterPrice == null){ + return BaseResponseUtils.buildErrorMsg("鏈嶅姟绔嚭閿欙紝鏈緱鍒版按浠�") ; + } + CdParam comParam = CdParam.builder().commandCode(ComCode).projectNo(projectNo).controllerType(controllerType) + .icCardNo("" + vcPo.getVcNum())//鐢ㄦ埛鍗″簭鍒楀彿锛�17浣嶆暟瀛楋級锛�6瀛楄妭BCD锛�2瀛楄妭HEX锛� + .waterRemain(0.0)//鐢ㄦ埛鍓╀綑姘撮噺, 涓や釜灏忔暟鐐�, 鍗曚綅m3, 0~99999999.99 + .moneyRemain(vcPo.getMoney())//鐢ㄦ埛鍓╀綑姘撮噺, 涓や釜灏忔暟鐐�, 鍗曚綅m3, 0~99999999.99 + .waterPrice(waterPrice)//姘撮噺鍗曚环 鍗曚綅:鍏�, 2涓皬鏁扮偣 + .elePrice(0.0)//鐢甸噺鍗曚环 鍗曚綅:鍏�, 2涓皬鏁扮偣 + .orderNo(RandomStringUtils.randomNumeric(16))//璁㈠崟鍙凤紙16浣嶆暟瀛楋級 + .build(); + //鍙戦�佸懡浠ゅ墠-3锛氫繚瀛樺懡浠ゆ棩蹇� + res = super.pre3(sv, dto.getIntakeId(), dto.getOperator(), ComCode, comParam); + if (res == null) { + //鍙戦�佸懡浠ゅ墠-4锛氬噯澶嘑eature + super.pre4(); + try { + //鍒涘缓澶栭儴鍛戒护锛堝彂缁欐帶鍒跺櫒锛� + Command com = sv.createOuterCommand(ctrlPo.getRtuAddr(), "" + comId, ComCode); + com.rtuResultSendWebUrl = rtuResultSendWebUrl; + com.param = comParam; + //鍙戦�佸懡浠� + res = super.doSend(sv, com); + if (res == null) { + //鍙戦�佸懡浠ゅ悗 + res = super.after(ComCode, new Callback() { + @Override + public void call(Object obj) { + Boolean success = (Boolean) obj; + if(success){ + // 娣诲姞甯哥敤鍙栨按鍙f垨鏇存柊浣跨敤淇℃伅 + sv.addOrUpdateOftenUseIntake(dto.getOperator(), dto.getIntakeId()) ; + //寮�闃�鎴愬姛锛岃櫄鎷熷崱璁板綍涓婃爣璁板凡琚崰鐢� + sv.setVcUsed(vcPo.getId(), dto.getIntakeId()); + } + } + @Override + public void call(Object... objs) { + } + @Override + public void exception(Exception e) { + } + }); + } + } catch (Exception e) { + res = BaseResponseUtils.buildFail("鏈嶅姟绔瀯閫犲苟鍚戦�氫俊涓棿浠跺彂閫佽姹傛椂寮傚父" + (e.getMessage() == null ? "" : e.getMessage())); + } finally { + //鏈�缁� + super.end(); + } + } + } + } + return res ; + } + + @Override + protected String checkDto(DtoBase dto) { + return null; + } + + @Override + protected String dealComResult(String code, JSONObject resultData, Callback callback){ + String msg; + if(resultData != null){ + JSONObject codeData = resultData.getJSONObject("data") ; + if(codeData == null){ + msg = RtuSuccessMsg ; + }else { + String json = codeData.toJSONString(); + DataCd92_A2Vo cvo = JSON.parseObject(json, DataCd92_A2Vo.class) ; + if(cvo != null){ + if(callback != null){ + if(cvo.opResult != null && cvo.opResult.byteValue() == (byte)0){ + callback.call(true);//寮�闃�鎴愬姛 + }else{ + callback.call(false);//寮�闃�澶辫触 + } + } + msg = cvo.toStr(false) ; + }else{ + msg = RtuSuccessMsg ; + } + } + }else{ + msg = RtuSuccessMsg ; + } + return msg; + } +} -- Gitblit v1.8.0