1、协议细化,处理小数;
2、水肥机、气象站、墒情站实体增加属性fboxId(FBox序列号);
18个文件已修改
23个文件已添加
2个文件已删除
| | |
| | | public Short protocolVersion; |
| | | |
| | | /** |
| | | * RTU å°å |
| | | * RTUå°å å FBox设å¤å· |
| | | */ |
| | | public String rtuAddr ; |
| | | |
| | |
| | | public String orgTag ;//ç»ç»æ è¯ |
| | | public String protocol ;//åè®®åç§° |
| | | public String devId ;//设å¤ï¼FBoxï¼ID |
| | | public String type;//æµç«ç±»å |
| | | public String type;//æ°æ®ï¼å½ä»¤ï¼ç±»å |
| | | public Integer no;//æµç«ç¼å· |
| | | |
| | | public boolean isEmpty(){ |
| | |
| | | public static final String cd_Stir = "01" ;//æ
æå¯åå½ä»¤ |
| | | public static final String cd_Inject = "02" ;//注è¥å¯åå½ä»¤ |
| | | public static final String cd_Irr = "03" ;//çæºå¯åå½ä»¤ |
| | | public static final String cd_Param = "10" ;//设å®åæ° |
| | | public static final String cd_Param = "10" ;//è®¾ç½®åæ° |
| | | |
| | | public static String getCodeName(String code) { |
| | | String name = (code.equals(cd_Fault) ? "æ
éè§£é¤" : |
| | | (code.equals(cd_Stir) ? "æ
æå¯å" : |
| | | (code.equals(cd_Inject) ? "注è¥å¯å" : |
| | | (code.equals(cd_Irr) ? "çæºå¯å" : |
| | | (code.equals(cd_Param) ? "è®¾ç½®åæ°" : |
| | | ""))))) ; |
| | | if(name == null || name.equals("")){ |
| | | name = code ; |
| | | } |
| | | return name ; |
| | | } |
| | | } |
| | |
| | | DevRunInfo stInfo = null ; |
| | | switch (subTopic.type) { |
| | | case ProtocolConstantSdV1.SubTopicWeather -> { |
| | | vo = JSON.parseObject(strTxt, WeatherVo.class); |
| | | WeatherVo wvo = JSON.parseObject(strTxt, WeatherVo.class); |
| | | //è°æ´å°æ° |
| | | wvo.airTemperature = (wvo.airTemperature == null ? null: (wvo.airTemperature / 10.0F)) ; |
| | | wvo.airHumidity = (wvo.airHumidity == null ? null: (wvo.airHumidity / 10.0F)) ; |
| | | wvo.rainfall = (wvo.rainfall == null ? null: (wvo.rainfall / 10.0F)) ; |
| | | wvo.windSpeed = (wvo.windSpeed == null ? null: (wvo.windSpeed / 10.0F)) ; |
| | | vo = wvo ; |
| | | break; |
| | | } |
| | | case ProtocolConstantSdV1.SubTopicSoil -> { |
| | | vo = JSON.parseObject(strTxt, SoilVo.class); |
| | | SoilVo svo = JSON.parseObject(strTxt, SoilVo.class); |
| | | //è°æ´å°æ° |
| | | svo.soilHumidity1 = (svo.soilHumidity1 == null ? null: (svo.soilHumidity1 / 10.0F)) ; |
| | | svo.soilHumidity2 = (svo.soilHumidity2 == null ? null: (svo.soilHumidity2 / 10.0F)) ; |
| | | svo.soilHumidity3 = (svo.soilHumidity3 == null ? null: (svo.soilHumidity3 / 10.0F)) ; |
| | | svo.soilHumidity4 = (svo.soilHumidity4 == null ? null: (svo.soilHumidity4 / 10.0F)) ; |
| | | svo.soilHumidity5 = (svo.soilHumidity5 == null ? null: (svo.soilHumidity5 / 10.0F)) ; |
| | | svo.soilTemperature1 = (svo.soilTemperature1 == null ? null: (svo.soilTemperature1 / 10.0F)) ; |
| | | svo.soilTemperature2 = (svo.soilTemperature2 == null ? null: (svo.soilTemperature2 / 10.0F)) ; |
| | | svo.soilTemperature3 = (svo.soilTemperature3 == null ? null: (svo.soilTemperature3 / 10.0F)) ; |
| | | svo.soilTemperature4 = (svo.soilTemperature4 == null ? null: (svo.soilTemperature4 / 10.0F)) ; |
| | | svo.soilTemperature5 = (svo.soilTemperature5 == null ? null: (svo.soilTemperature5 / 10.0F)) ; |
| | | vo = svo ; |
| | | break; |
| | | } |
| | | case ProtocolConstantSdV1.SubTopicManure -> { |
| | | vo = JSON.parseObject(strTxt, ManureVo.class); |
| | | ManureVo stVo = (ManureVo)vo ; |
| | | ManureVo mvo = JSON.parseObject(strTxt, ManureVo.class); |
| | | //è°æ´å°æ° |
| | | mvo.manureFlow = (mvo.manureFlow == null ? null: (mvo.manureFlow / 10.0F)) ; |
| | | vo = mvo ; |
| | | |
| | | stInfo = new DevRunInfo() ; |
| | | stInfo.devId = msg.deviceId ; |
| | | stInfo.stirRunning = (stVo.stirRunning==null?false:(stVo.stirRunning.byteValue()==1?true:false)) ; //æ
æè¿è¡ trueæ¯ falseå¦ |
| | | stInfo.injectRunning = (stVo.injectRunning==null?false:(stVo.injectRunning.byteValue()==1?true:false)) ; //注è¥è¿è¡ trueæ¯ falseå¦ |
| | | stInfo.irrRunning = (stVo.irrRunning==null?false:(stVo.irrRunning.byteValue()==1?true:false)) ; //çæºè¿è¡ trueæ¯ falseå¦ |
| | | stInfo.alarm = (stVo.alarm==null?false:(stVo.alarm.byteValue()==1?true:false)) ; //æ¥è¦ trueæ¯ falseå¦ |
| | | stInfo.stirRunning = (mvo.stirRunning1 ==null?false:(mvo.stirRunning1.byteValue()==1?true:false)) ; //æ
æè¿è¡ trueæ¯ falseå¦ |
| | | stInfo.injectRunning = (mvo.injectRunning==null?false:(mvo.injectRunning.byteValue()==1?true:false)) ; //注è¥è¿è¡ trueæ¯ falseå¦ |
| | | stInfo.irrRunning = (mvo.irrRunning==null?false:(mvo.irrRunning.byteValue()==1?true:false)) ; //çæºè¿è¡ trueæ¯ falseå¦ |
| | | stInfo.alarm = (mvo.alarm==null?false:(mvo.alarm.byteValue()==1?true:false)) ; //æ¥è¦ trueæ¯ falseå¦ |
| | | break; |
| | | } |
| | | default -> { |
| | |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class ParamSetVo implements Vo4Down { |
| | | /** |
| | | * åä½ç§ |
| | | */ |
| | | @JSONField(name = "æ
æè®¾å®æ¶é´") |
| | | public Integer stirDuration ; |
| | | |
| | | /** |
| | | * åä½ç§ |
| | | */ |
| | | @JSONField(name = "注è¥è®¾å®æ¶é´") |
| | | public Integer injectDuration ; |
| | | |
| | |
| | | |
| | | public Integer no ;//æµç«ç¼å·ï¼å
¶ä¸å¨JSONæ°æ®ä¸ï¼å
¶å¨ä¸»é¢ä¸ |
| | | |
| | | @JSONField(name = "æ
æè¿è¡") |
| | | public Byte stirRunning ;//æ
æè¿è¡ |
| | | /** |
| | | * æ
ææº1æ¯å¦è¿è¡ï¼ï¼æ°´è¥æºè¿å¯å卿
ææº2ãæ
ææº3ãæ
ææº4 ......ï¼ è¿è¡æ¶1ï¼åæ¢0. |
| | | */ |
| | | @JSONField(name = "æ
æè¿è¡1") |
| | | public Byte stirRunning1;//æ
æ1è¿è¡ç¶æ |
| | | /** |
| | | * æ
ææº2æ¯å¦è¿è¡ï¼ï¼æ°´è¥æºè¿å¯å卿
ææº2ãæ
ææº3ãæ
ææº4 ......ï¼ è¿è¡æ¶1ï¼åæ¢0. |
| | | * (å½å大禹åºç¨ä¸åå¨) |
| | | */ |
| | | @JSONField(name = "æ
æè¿è¡2") |
| | | public Byte stirRunning2;//æ
æ2è¿è¡ç¶æ |
| | | /** |
| | | * æ
ææº3æ¯å¦è¿è¡ï¼ï¼æ°´è¥æºè¿å¯å卿
ææº2ãæ
ææº3ãæ
ææº4 ......ï¼ è¿è¡æ¶1ï¼åæ¢0. |
| | | * (å½å大禹åºç¨ä¸åå¨) |
| | | */ |
| | | @JSONField(name = "æ
æè¿è¡3") |
| | | public Byte stirRunning3;//æ
æ3è¿è¡ç¶æ |
| | | /** |
| | | * æ
ææº4æ¯å¦è¿è¡ï¼ï¼æ°´è¥æºè¿å¯å卿
ææº2ãæ
ææº3ãæ
ææº4 ......ï¼ è¿è¡æ¶1ï¼åæ¢0. |
| | | * (å½å大禹åºç¨ä¸åå¨) |
| | | */ |
| | | @JSONField(name = "æ
æè¿è¡4") |
| | | public Byte stirRunning4;//æ
æ4è¿è¡ç¶æ |
| | | |
| | | /** |
| | | * ä¸ä¸ªæ°´è¥æºåªæä¸ä¸ªæ³¨è¥æ³µ |
| | | */ |
| | | @JSONField(name = "注è¥è¿è¡") |
| | | public Byte injectRunning ;//注è¥è¿è¡ |
| | | public Byte injectRunning ;//注è¥è¿è¡ç¶æ |
| | | |
| | | @JSONField(name = "çæºè¿è¡") |
| | | public Byte irrRunning ;//çæºè¿è¡ |
| | | public Byte irrRunning ;//çæºè¿è¡ç¶æ |
| | | |
| | | /** |
| | | * 1:æ³¨è¥æ³µææ
éã0:æ³¨è¥æ³µæ²¡ææ
é |
| | | */ |
| | | @JSONField(name = "æ¥è¦") |
| | | public Byte alarm ;//æ¥è¦ |
| | | public Byte alarm ;//æ³¨è¥æ³µæ
é |
| | | |
| | | /** |
| | | * è¥ææµéï¼åä½å |
| | | */ |
| | | @JSONField(name = "è¥ææµé") |
| | | public Float manureFlow ; |
| | | |
| | | /** |
| | | * åä½ç§ |
| | | */ |
| | | @JSONField(name = "注è¥ç»è¿æ¶é´") |
| | | public Integer manureTime ; |
| | | |
| | | /** |
| | | * åä½ç§ |
| | | */ |
| | | @JSONField(name = "æ
æç»è¿æ¶é´") |
| | | public Integer stirTime ; |
| | | |
| | |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("æ°´è¥æ°æ®=>") ; |
| | | sb.append(" æ¶æ¯IDï¼" + messageId + ", ") ; |
| | | sb.append(" æ
æè¿è¡ï¼" + stirRunning + ", ") ; |
| | | sb.append(" æ
æè¿è¡ï¼" + stirRunning1 + ", ") ; |
| | | sb.append(" 注è¥è¿è¡ï¼" + injectRunning + ", ") ; |
| | | sb.append(" çæºè¿è¡ï¼" + irrRunning + ", ") ; |
| | | sb.append(" æ¥è¦ï¼" + alarm + ", ") ; |
| | |
| | | public Integer no ;//æµç«ç¼å·ï¼å
¶ä¸å¨JSONæ°æ®ä¸ï¼å
¶å¨ä¸»é¢ä¸ |
| | | |
| | | @JSONField(name = "å壤湿度1") |
| | | public Integer soilHumidity1 ; |
| | | public Float soilHumidity1 ; |
| | | |
| | | @JSONField(name = "å壤湿度2") |
| | | public Integer soilHumidity2 ; |
| | | public Float soilHumidity2 ; |
| | | |
| | | @JSONField(name = "å壤湿度3") |
| | | public Integer soilHumidity3 ; |
| | | public Float soilHumidity3 ; |
| | | |
| | | @JSONField(name = "å壤湿度4") |
| | | public Integer soilHumidity4 ; |
| | | public Float soilHumidity4 ; |
| | | |
| | | @JSONField(name = "å壤湿度5") |
| | | public Integer soilHumidity5 ; |
| | | public Float soilHumidity5 ; |
| | | |
| | | @JSONField(name = "å壤湿度1") |
| | | public Integer soilTemperature1 ; |
| | | public Float soilTemperature1 ; |
| | | |
| | | @JSONField(name = "å壤温度2") |
| | | public Integer soilTemperature2 ; |
| | | public Float soilTemperature2 ; |
| | | |
| | | @JSONField(name = "å壤温度3") |
| | | public Integer soilTemperature3 ; |
| | | public Float soilTemperature3 ; |
| | | |
| | | @JSONField(name = "å壤温度4") |
| | | public Integer soilTemperature4 ; |
| | | public Float soilTemperature4 ; |
| | | |
| | | @JSONField(name = "å壤温度5") |
| | | public Integer soilTemperature5 ; |
| | | public Float soilTemperature5 ; |
| | | |
| | | @JSONField(name = "flexem_timestamp") |
| | | public Long devDt ;//è®¾å¤æ¶é´ |
| | |
| | | //public Integer atmosphericPressure ; |
| | | |
| | | @JSONField(name = "ç©ºæ°æ¸©åº¦") |
| | | public Integer airTemperature ; |
| | | public Float airTemperature ; |
| | | |
| | | @JSONField(name = "ç©ºæ°æ¹¿åº¦") |
| | | public Integer airHumidity ; |
| | | public Float airHumidity ; |
| | | |
| | | @JSONField(name = "ç´«å¤çº¿") |
| | | public Integer ultraviolet ; |
| | |
| | | public Integer lightIntensity ; |
| | | |
| | | @JSONField(name = "é¨é") |
| | | public Integer rainfall ; |
| | | public Float rainfall ; |
| | | |
| | | @JSONField(name = "é£é") |
| | | public Integer windSpeed ; |
| | | public Float windSpeed ; |
| | | |
| | | @JSONField(name = "é£å") |
| | | public Integer windDirection ; |
New file |
| | |
| | | package com.dy.pipIrrGlobal.command; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.mw.protocol.CommandBackParam; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.CodeSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.pipIrrGlobal.daoPr.PrStManureMapper; |
| | | import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrStManure; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; |
| | | import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/6 11:41 |
| | | * @Description |
| | | */ |
| | | public class Command4MqttSv extends Web2RtuMw { |
| | | |
| | | |
| | | /** |
| | | * 仿°æ®åºä¸æ¥è¯¢æ°´è¥æºå¯¹è±¡ |
| | | * @param prStManureDao |
| | | * @param manureId |
| | | * @return |
| | | */ |
| | | public PrStManure getManure(PrStManureMapper prStManureDao, Long manureId){ |
| | | return prStManureDao.selectByPrimaryKey(manureId); |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥åè®®æ¯å¦æ¯æ |
| | | * @param ctrlPo |
| | | * @return |
| | | */ |
| | | public String checkProtocol(PrStManure ctrlPo){ |
| | | return null ; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åè®®è·åå½ä»¤åç§° |
| | | * @param nowComCode |
| | | * @param protocol |
| | | * @return |
| | | */ |
| | | public String getCommandName(String nowComCode, String protocol, Short protocolVer){ |
| | | if(protocol.equals(ProtocolConstantSdV1.protocolName) |
| | | && protocolVer.equals(ProtocolConstantSdV1.protocolVer)) { |
| | | return CodeSdV1.getCodeName(nowComCode) ; |
| | | } |
| | | return null ; |
| | | } |
| | | |
| | | /** |
| | | * ä¿åå½ä»¤åå²è®°å½ |
| | | * @param rmCommandHistoryDao |
| | | * @param comId |
| | | * @param protocol |
| | | * @param commandCode |
| | | * @param commandName |
| | | * @param manureId |
| | | * @param rtuAddr |
| | | * @param param |
| | | * @param operator |
| | | * @return |
| | | */ |
| | | public RmCommandHistory saveComHistoryPo(RmCommandHistoryMapper rmCommandHistoryDao, |
| | | Long comId, |
| | | String protocol, |
| | | String commandCode, |
| | | String commandName, |
| | | Long manureId, |
| | | String rtuAddr, |
| | | Object param, |
| | | Long operator) { |
| | | RmCommandHistory po = new RmCommandHistory(); |
| | | po.setComId(comId); |
| | | po.setCommandCode(commandCode); |
| | | po.setCommandName(commandName); |
| | | po.setIntakeId(manureId); |
| | | po.setRtuAddr(rtuAddr); |
| | | po.setProtocol(protocol); |
| | | po.setParam((JSONObject) JSON.toJSON(param)); |
| | | po.setSendTime(new Date()); |
| | | po.setOperator(operator); |
| | | int count = rmCommandHistoryDao.insertSelective(po) ; |
| | | if(count == 0){ |
| | | po = null ; |
| | | } |
| | | return po; |
| | | } |
| | | |
| | | /** |
| | | * å¤çéä¿¡ä¸é´ä»¶è¿åçå½ä»¤å¤çç»æ |
| | | * @param res |
| | | * @return |
| | | */ |
| | | public String dealMwDealResponse(BaseResponse res){ |
| | | if(res != null){ |
| | | Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ; |
| | | CommandBackParam bakParam = JSON.parseObject((reCom== null || reCom.param == null) ? null : JSON.toJSONString(reCom.param), CommandBackParam.class) ; |
| | | if(res.isSuccess()){ |
| | | if(bakParam != null){ |
| | | if(bakParam.getSuccess().booleanValue()){ |
| | | //éä¿¡ä¸é´ä»¶æåå¤çäºå½ä»¤ |
| | | //çå¾
æ§å¶å¨æ¥æ¶å¹¶æ§è¡å½ä»¤åçåºçï¼ç¶åéä¿¡ä¸é´ä»¶éç¥æ¬æ¨¡å |
| | | return null ; |
| | | }else{ |
| | | return "éä¿¡ä¸é´ä»¶å¤çå½ä»¤å¤±è´¥ï¼å¤±è´¥ä¿¡æ¯ï¼" + bakParam.getMessage(); |
| | | } |
| | | }else{ |
| | | return "éä¿¡ä¸é´ä»¶è¿åå½ä»¤ç»æä¸ä¸å
å«CommandBackParamç±»ååæ°"; |
| | | } |
| | | }else{ |
| | | if(bakParam != null){ |
| | | if(bakParam.getSuccess().booleanValue()){ |
| | | //éä¿¡ä¸é´ä»¶æåå¤çäºå½ä»¤ |
| | | //çå¾
æ§å¶å¨æ¥æ¶å¹¶æ§è¡å½ä»¤åçåºçï¼ç¶åéä¿¡ä¸é´ä»¶éç¥æ¬æ¨¡å |
| | | return "éä¿¡ä¸é´ä»¶å¤çå½ä»¤å¤±è´¥ï¼å¤±è´¥ä¿¡æ¯ï¼" + (res.getMsg() == null? "" : ("ï¼" + res.getMsg())) ; |
| | | }else{ |
| | | return "éä¿¡ä¸é´ä»¶å¤çå½ä»¤å¤±è´¥ï¼å¤±è´¥ä¿¡æ¯ï¼" + bakParam.getMessage(); |
| | | } |
| | | }else{ |
| | | return "éä¿¡ä¸é´ä»¶å¤çå½ä»¤å¤±è´¥ï¼å¤±è´¥ä¿¡æ¯ï¼" + (res.getMsg() == null? "" : ("ï¼" + res.getMsg())) ; |
| | | } |
| | | } |
| | | }else{ |
| | | return "éä¿¡ä¸é´ä»¶è¿åå½ä»¤ç»æä¸ºnull"; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | public Long id; |
| | | |
| | | /** |
| | | * FBoxåºåå· |
| | | */ |
| | | @Schema(description = "FBoxåºåå·", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | public String fboxId ; |
| | | |
| | | /** |
| | | * æ°´è¥ç«ç¼å· |
| | | */ |
| | | @Schema(description = "æ°´è¥ç«ç¼å·", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | |
| | | public Long id; |
| | | |
| | | /** |
| | | * FBoxåºåå· |
| | | */ |
| | | @Schema(description = "FBoxåºåå·", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | public String fboxId ; |
| | | |
| | | /** |
| | | * 墿
ç«ç¼å· |
| | | */ |
| | | @Schema(description = "墿
ç«ç¼å·", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | |
| | | public Long id; |
| | | |
| | | /** |
| | | * FBoxåºåå· |
| | | */ |
| | | @Schema(description = "FBoxåºåå·", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | public String fboxId ; |
| | | |
| | | /** |
| | | * æ°è±¡ç«ç¼å· |
| | | */ |
| | | @Schema(description = "æ°è±¡ç«ç¼å·", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | |
| | | <!--@Table pr_st_manure--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="no" jdbcType="INTEGER" property="no" /> |
| | | <result column="fbox_id" jdbcType="VARCHAR" property="fboxId" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result column="lng" jdbcType="DOUBLE" property="lng" /> |
| | | <result column="lat" jdbcType="DOUBLE" property="lat" /> |
| | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `no`, `name`, lng, lat, remark, deleted |
| | | id, fbox_id,`no`, `name`, lng, lat, remark, deleted |
| | | </sql> |
| | | <sql id="part_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `no`, `name`, lng, lat, remark |
| | | id, fbox_id, `no`, `name`, lng, lat, remark |
| | | </sql> |
| | | <sql id="simple_Column_List"> |
| | | <!--@mbg.generated--> |
| | |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStManure"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_st_manure (id, `no`, `name`, lng, |
| | | insert into pr_st_manure (id, fbox_id, `no`, `name`, lng, |
| | | lat, remark, deleted) |
| | | values (#{id,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, |
| | | #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remark,jdbcType=VARCHAR}, |
| | | #{deleted,jdbcType=TINYINT}) |
| | | values (#{id,jdbcType=BIGINT}, #{fboxId,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, |
| | | #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, |
| | | #{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStManure"> |
| | | <!--@mbg.generated--> |
| | |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="fboxId != null"> |
| | | fbox_id, |
| | | </if> |
| | | <if test="no != null"> |
| | | `no`, |
| | |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="fboxId != null"> |
| | | #{fboxId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="no != null"> |
| | | #{no,jdbcType=INTEGER}, |
| | |
| | | <!--@mbg.generated--> |
| | | update pr_st_manure |
| | | <set> |
| | | <if test="fboxId != null"> |
| | | fbox_id = #{fboxId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="no != null"> |
| | | `no` = #{no,jdbcType=INTEGER}, |
| | | </if> |
| | |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStManure"> |
| | | <!--@mbg.generated--> |
| | | update pr_st_manure |
| | | set `no` = #{no,jdbcType=INTEGER}, |
| | | set fbox_id = #{fboxId,jdbcType=INTEGER}, |
| | | `no` = #{no,jdbcType=INTEGER}, |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | lng = #{lng,jdbcType=DOUBLE}, |
| | | lat = #{lat,jdbcType=DOUBLE}, |
| | |
| | | <!--@Table pr_st_soil--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="no" jdbcType="INTEGER" property="no" /> |
| | | <result column="fbox_id" jdbcType="VARCHAR" property="fboxId" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result column="lng" jdbcType="DOUBLE" property="lng" /> |
| | | <result column="lat" jdbcType="DOUBLE" property="lat" /> |
| | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `no`, `name`, lng, lat, remark, deleted |
| | | id, fbox_id,`no`, `name`, lng, lat, remark, deleted |
| | | </sql> |
| | | <sql id="part_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `no`, `name`, lng, lat, remark |
| | | id, fbox_id, `no`, `name`, lng, lat, remark |
| | | </sql> |
| | | <sql id="simple_Column_List"> |
| | | <!--@mbg.generated--> |
| | |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStSoil"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_st_soil (id, `no`, `name`, lng, |
| | | insert into pr_st_soil (id, fbox_id, `no`, `name`, lng, |
| | | lat, remark, deleted) |
| | | values (#{id,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, |
| | | #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remark,jdbcType=VARCHAR}, |
| | | #{deleted,jdbcType=TINYINT}) |
| | | values (#{id,jdbcType=BIGINT}, #{fboxId,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, |
| | | #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, |
| | | #{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStSoil"> |
| | | <!--@mbg.generated--> |
| | |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="fboxId != null"> |
| | | fbox_id, |
| | | </if> |
| | | <if test="no != null"> |
| | | `no`, |
| | |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="fboxId != null"> |
| | | #{fboxId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="no != null"> |
| | | #{no,jdbcType=INTEGER}, |
| | |
| | | <!--@mbg.generated--> |
| | | update pr_st_soil |
| | | <set> |
| | | <if test="fboxId != null"> |
| | | fbox_id = #{fboxId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="no != null"> |
| | | `no` = #{no,jdbcType=INTEGER}, |
| | | </if> |
| | |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStSoil"> |
| | | <!--@mbg.generated--> |
| | | update pr_st_soil |
| | | set `no` = #{no,jdbcType=INTEGER}, |
| | | set fbox_id = #{fboxId,jdbcType=INTEGER}, |
| | | `no` = #{no,jdbcType=INTEGER}, |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | lng = #{lng,jdbcType=DOUBLE}, |
| | | lat = #{lat,jdbcType=DOUBLE}, |
| | |
| | | <!--@Table pr_st_weather--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="no" jdbcType="INTEGER" property="no" /> |
| | | <result column="fbox_id" jdbcType="VARCHAR" property="fboxId" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result column="lng" jdbcType="DOUBLE" property="lng" /> |
| | | <result column="lat" jdbcType="DOUBLE" property="lat" /> |
| | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `no`, `name`, lng, lat, remark, deleted |
| | | id, fbox_id,`no`, `name`, lng, lat, remark, deleted |
| | | </sql> |
| | | <sql id="part_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `no`, `name`, lng, lat, remark |
| | | id, fbox_id, `no`, `name`, lng, lat, remark |
| | | </sql> |
| | | <sql id="simple_Column_List"> |
| | | <!--@mbg.generated--> |
| | |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStWeather"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_st_weather (id, `no`, `name`, lng, |
| | | insert into pr_st_weather (id, fbox_id, `no`, `name`, lng, |
| | | lat, remark, deleted) |
| | | values (#{id,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, |
| | | #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remark,jdbcType=VARCHAR}, |
| | | #{deleted,jdbcType=TINYINT}) |
| | | values (#{id,jdbcType=BIGINT}, #{fboxId,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, |
| | | #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, |
| | | #{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStWeather"> |
| | | <!--@mbg.generated--> |
| | |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="fboxId != null"> |
| | | fbox_id, |
| | | </if> |
| | | <if test="no != null"> |
| | | `no`, |
| | |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="fboxId != null"> |
| | | #{fboxId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="no != null"> |
| | | #{no,jdbcType=INTEGER}, |
| | |
| | | <!--@mbg.generated--> |
| | | update pr_st_weather |
| | | <set> |
| | | <if test="fboxId != null"> |
| | | fbox_id = #{fboxId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="no != null"> |
| | | `no` = #{no,jdbcType=INTEGER}, |
| | | </if> |
| | |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStWeather"> |
| | | <!--@mbg.generated--> |
| | | update pr_st_weather |
| | | set `no` = #{no,jdbcType=INTEGER}, |
| | | set fbox_id = #{fboxId,jdbcType=INTEGER}, |
| | | `no` = #{no,jdbcType=INTEGER}, |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | lng = #{lng,jdbcType=DOUBLE}, |
| | | lat = #{lat,jdbcType=DOUBLE}, |
| | |
| | | * @return ç»æ |
| | | */ |
| | | private BaseResponse<Command> dealMqttCommand(Command command){ |
| | | String rtuAddr = command.getRtuAddr() ; |
| | | String rtuAddr = command.getRtuAddr() ;//FBox设å¤å· |
| | | if(rtuAddr == null || rtuAddr.trim().equals("")){ |
| | | return BaseResponseUtils.buildError(ReturnCommand.errored("åºéï¼è®¾å¤ID为空ï¼", command.getId(), command.getCode())) ; |
| | | return BaseResponseUtils.buildError(ReturnCommand.errored("åºéï¼FBox设å¤ID为空ï¼", command.getId(), command.getCode())) ; |
| | | } |
| | | if(!ServerProperties.mqttUnitEnable.booleanValue()){ |
| | | return BaseResponseUtils.buildError(ReturnCommand.errored("åºéï¼MQTTè¿æ¥æ¨¡åé
ç½®æªå¯å¨ï¼", command.getId(), command.getCode())) ; |
| | | } |
| | | if(MqttManager.getInstance().poolIsClose()){ |
| | | return BaseResponseUtils.buildError(ReturnCommand.errored("åºéï¼MQTTè¿æ¥æ± æ°´å建æåï¼", command.getId(), command.getCode())) ; |
| | | return BaseResponseUtils.buildError(ReturnCommand.errored("åºéï¼MQTTè¿æ¥æ± æªå建æåï¼", command.getId(), command.getCode())) ; |
| | | } |
| | | |
| | | //çæå¼æ¥ä»»å¡ |
New file |
| | |
| | | package com.dy.pipIrrRemote.common.dto; |
| | | |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-22 16:54 |
| | | * @LastEditTime 2024-05-22 16:54 |
| | | * @Description 设置å½ä»¤åºç±» |
| | | */ |
| | | |
| | | @Data |
| | | public class Dto4MqttBase { |
| | | public static final long serialVersionUID = 202506201459001L; |
| | | |
| | | /** |
| | | * æ°´è¥æºID |
| | | */ |
| | | @NotNull(message = "æ°´è¥æºä¸è½ä¸ºç©º") |
| | | public Long manureId; |
| | | |
| | | /** |
| | | * æ°´è¥æºåç§° |
| | | */ |
| | | public String manureName; |
| | | |
| | | /** |
| | | * æä½äºº |
| | | */ |
| | | @NotNull(message = "æä½äººä¸è½ä¸ºç©º") |
| | | public Long operator; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.common; |
| | | |
| | | import lombok.Data; |
| | | import lombok.experimental.SuperBuilder; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/9 16:11 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @SuperBuilder |
| | | public class Cd4MqttParameter { |
| | | //å½ä»¤åè½ç |
| | | public String commandCode; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.common; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.util.IDLongGenerator; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrGlobal.command.ComResultWait; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrStManure; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.Objects; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/9 14:53 |
| | | * @Description |
| | | */ |
| | | public abstract class Com4MqttCtrl { |
| | | |
| | | @Autowired |
| | | protected Environment env ; |
| | | |
| | | @Autowired |
| | | protected RestTemplate restTemplate ; |
| | | |
| | | @Value("${mw.waitMwRtnResultTimeout}") |
| | | protected int waitMwRtnResultTimeout ; |
| | | |
| | | @Value("${mw.rtuCallbackUrl_rm}") |
| | | protected String rtuResultSendWebUrl; |
| | | |
| | | //æ°´è¥æºå¯¹è±¡ |
| | | protected PrStManure ctrlPo ; |
| | | //弿¥çå¾
å¨ |
| | | protected CompletableFuture<JSONObject> feature; |
| | | //å½ä»¤åç§° |
| | | protected String comName ; |
| | | //å½ä»¤æ¥å¿id |
| | | protected Long comId ; |
| | | |
| | | /** |
| | | * åéå½ä»¤å-1ï¼éªè¯ |
| | | * @param comSv |
| | | * @param comCode |
| | | * @param dto |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | public BaseResponse<Object> pre1(Com4MqttSv comSv, String comCode, Dto4MqttBase dto, BindingResult bindingResult) { |
| | | if (bindingResult != null && bindingResult.hasErrors()) { |
| | | return BaseResponseUtils.buildError(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | String msg = this.checkDto(dto) ; |
| | | if(msg != null){ |
| | | return BaseResponseUtils.buildError("æå¡ç«¯åºéï¼" + msg) ; |
| | | } |
| | | return null ; |
| | | } |
| | | |
| | | /** |
| | | * åéå½ä»¤å-2ï¼è·å¾æ°æ® |
| | | * @param comSv |
| | | * @param protocol |
| | | * @param protocolVer |
| | | * @param comCode |
| | | * @param dto |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | public BaseResponse<Object> pre2(Com4MqttSv comSv, String protocol, Short protocolVer, String comCode, Dto4MqttBase dto, BindingResult bindingResult) { |
| | | //å¾å°æ°´è¥æºå¯¹è±¡ |
| | | ctrlPo = comSv.getManure(dto.getManureId()); |
| | | if (ctrlPo == null) { |
| | | return BaseResponseUtils.buildError("æå¡ç«¯åºéï¼ä»æ°æ®åºä¸æªå¾å°æ°´è¥æºæ°æ®") ; |
| | | } |
| | | //æ£æ¥åè®® |
| | | String msg = comSv.checkProtocol(ctrlPo) ; |
| | | if(msg != null) { |
| | | return BaseResponseUtils.buildError("æå¡ç«¯åºéï¼" + msg) ; |
| | | } |
| | | //å¾å°åè½ç 对åºçå½ä»¤åç§° |
| | | comName = comSv.getCommandName(comCode, protocol, protocolVer) ; |
| | | if(comName == null) { |
| | | return BaseResponseUtils.buildError("æå¡ç«¯åºéï¼æªå¾å°åè½ç 对åºå½ä»¤åç§°") ; |
| | | } |
| | | return null ; |
| | | } |
| | | /** |
| | | * åéå½ä»¤å-3ï¼ä¿åå½ä»¤æ¥å¿ |
| | | * @param comSv sv对象 |
| | | * @param manureId æ°´è¥æºID |
| | | * @param operator å½åç¨ç»å½ç¨æ·id(æä½äºº) |
| | | * @param protocol åè®® |
| | | * @param protocolVerion åè®® |
| | | * @param comCode åè½ç |
| | | * @param param å½ä»¤åæ° |
| | | * @return |
| | | */ |
| | | public BaseResponse<Object> pre3(Com4MqttSv comSv, Long manureId, Long operator, String protocol, Short protocolVerion, String comCode, Cd4MqttParameter param) { |
| | | comId = new IDLongGenerator().generate(); |
| | | //çæå¹¶ä¿åå½ä»¤æ¥å¿ |
| | | RmCommandHistory po = comSv.saveComHistoryPo(comId, |
| | | protocol + protocolVerion , |
| | | comCode, |
| | | comName, |
| | | manureId, |
| | | ctrlPo.fboxId , |
| | | param, |
| | | operator); |
| | | if(po == null){ |
| | | return BaseResponseUtils.buildError("æå¡ç«¯åºéï¼æªè½çæå¹¶ä¿åå½ä»¤æ¥å¿") ; |
| | | } |
| | | return null ; |
| | | } |
| | | /** |
| | | * åéå½ä»¤å-4ï¼åå¤Feature |
| | | * @return |
| | | */ |
| | | public void pre4() { |
| | | feature = new CompletableFuture<>(); |
| | | ComResultWait.put(comId, feature); |
| | | } |
| | | |
| | | /** |
| | | * åéå½ä»¤ |
| | | * @param comSv |
| | | * @param com |
| | | * @return |
| | | */ |
| | | public BaseResponse<Object> doSend(Com4MqttSv comSv, Command com){ |
| | | //å¾å°éä¿¡ä¸é´ä»¶åéå½ä»¤çweb URL |
| | | String rqUrl = comSv.get2MwRequestUrl(env, comSv.ContextComSend) ; |
| | | //åéä¿¡ä¸é´ä»¶åéwebè¯·æ± |
| | | BaseResponse res = comSv.sendPostRequest2Mw(restTemplate, rqUrl, com) ; |
| | | //å¤çéä¿¡ä¸é´ä»¶å¯¹web请æ±çååº |
| | | String msg = comSv.dealMwDealResponse(res) ; |
| | | if(msg != null) { |
| | | return BaseResponseUtils.buildError(msg) ; |
| | | }else{ |
| | | return null ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åéå½ä»¤å |
| | | * @return |
| | | */ |
| | | public BaseResponse<Object> after(String comCode, Callback callback) { |
| | | try{ |
| | | //çå¾
éä¿¡ä¸é´ä»¶éç¥æ°´è¥æºæ§è¡å½ä»¤ä¸è¡æ°æ®ï¼å½ä»¤ç»æï¼ |
| | | JSONObject resultData = feature.get(waitMwRtnResultTimeout, TimeUnit.SECONDS); |
| | | return BaseResponseUtils.buildSuccess(this.dealComResult(comCode, resultData, callback)); |
| | | }catch (Exception e){ |
| | | return BaseResponseUtils.buildFail("çå¾
éä¿¡ä¸é´ä»¶éç¥å½ä»¤ç»æè¶
æ¶"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åéå½ä»¤æå |
| | | * @return |
| | | */ |
| | | public void end(){ |
| | | try { |
| | | //æåæ¸
é¤CompletableFutureç¼å |
| | | if(ComResultWait.contain(comId)){ |
| | | ComResultWait.remove(comId); |
| | | } |
| | | }catch (Exception ee){} |
| | | } |
| | | |
| | | /** |
| | | * éªè¯ |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | protected abstract String checkDto(Dto4MqttBase dto) ; |
| | | |
| | | |
| | | /** |
| | | * çæå½ä»¤è¿åä¿¡æ¯ |
| | | */ |
| | | protected abstract String dealComResult(String code, JSONObject resultData, Callback callback); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.common; |
| | | |
| | | import com.dy.pipIrrGlobal.command.Command4MqttSv; |
| | | import com.dy.pipIrrGlobal.daoPr.PrStManureMapper; |
| | | import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrStManure; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/5/9 14:45 |
| | | * @Description |
| | | */ |
| | | public class Com4MqttSv extends Command4MqttSv { |
| | | |
| | | @Autowired |
| | | protected PrStManureMapper prStManureDao ; |
| | | @Autowired |
| | | protected RmCommandHistoryMapper rmCommandHistoryDao ; |
| | | |
| | | public PrStManure getManure(Long manureId){ |
| | | return this.getManure(prStManureDao, manureId); |
| | | } |
| | | /** |
| | | * å建å½ä»¤æ¥å¿å¯¹è±¡ |
| | | * |
| | | * @param comId ä¸»é® |
| | | * @param commandCode åè½ç |
| | | * @param rtuAddr éæ§å¨å°å |
| | | * @param protocol é讯åè®®åç§° |
| | | * @param param åæ°æ°æ® |
| | | * @param operator æä½å |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public RmCommandHistory saveComHistoryPo(Long comId, |
| | | String protocol, |
| | | String commandCode, |
| | | String commandName, |
| | | Long manureId, |
| | | String rtuAddr, |
| | | Object param, |
| | | Long operator) { |
| | | return this.saveComHistoryPo(rmCommandHistoryDao, comId, protocol, commandCode, commandName, manureId, rtuAddr, param, operator) ; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.fault; |
| | | |
| | | 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.protocol4Mqtt.pSdV1.CodeSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo; |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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/6/16 17:35 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "è¿ç¨å½ä»¤", description = "æ¸
餿
é") |
| | | @RestController("mqttSd1FaultCtrl") |
| | | @RequestMapping(path = "mqttSd1/faultCtrl") |
| | | @RequiredArgsConstructor |
| | | @Scope("prototype") //å 为æå¯¹è±¡ç±»å±æ§ï¼æä»¥éç¨å忍¡å¼ï¼æ¯æ¬¡è¯·æ±æ°å»ºä¸ä¸ªå®ä¾å¯¹è±¡ |
| | | public class CdCtrl extends Com4MqttCtrl { |
| | | |
| | | private static final String RtuSuccessMsg = "æ§å¶å¨æ¥æ¶å¹¶æ§è¡å½ä»¤æåï¼æ è¿åæ°æ®"; |
| | | |
| | | private static final String Protocol = ProtocolConstantSdV1.protocolName ; |
| | | private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ; |
| | | private static final String ComCode = CodeSdV1.cd_Fault ; |
| | | |
| | | |
| | | @Autowired |
| | | private CdSv sv ; |
| | | /** |
| | | * å设å¤ï¼Mqttä¸é´ä»¶->FBoxï¼åéå½ä»¤ |
| | | * @param dto åç«¯åæ¥çå¼å¯¹è±¡ |
| | | * @param bindingResult 对dtoéªè¯çç»æ |
| | | * @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, Protocol, ProtocolVersion, ComCode, dto, bindingResult); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-3ï¼ä¿åå½ä»¤æ¥å¿ |
| | | CdParam comParam = CdParam.builder().commandCode(ComCode).build(); |
| | | res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-4ï¼åå¤Feature |
| | | super.pre4(); |
| | | try { |
| | | //å建å¤é¨å½ä»¤ï¼åç»æ§å¶å¨ï¼ |
| | | Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode); |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | com.param = comParam ; |
| | | //åéå½ä»¤ |
| | | res = super.doSend(sv, com); |
| | | if (res == null) { |
| | | //åéå½ä»¤å |
| | | res = super.after(ComCode, null); |
| | | } |
| | | } catch (Exception e) { |
| | | res = BaseResponseUtils.buildFail("æå¡ç«¯æé å¹¶åéä¿¡ä¸é´ä»¶åéè¯·æ±æ¶å¼å¸¸" + (e.getMessage() == null ? "" : e.getMessage())); |
| | | } finally { |
| | | //æç» |
| | | super.end(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return res ; |
| | | } |
| | | |
| | | @Override |
| | | protected String checkDto(Dto4MqttBase dto) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected String dealComResult(String code, JSONObject resultData, Callback callback){ |
| | | String msg; |
| | | if(resultData != null){ |
| | | log.info(resultData.toString()); |
| | | JSONObject codeData = resultData.getJSONObject("data") ; |
| | | if(codeData == null){ |
| | | msg = RtuSuccessMsg ; |
| | | }else { |
| | | String json = codeData.toJSONString(); |
| | | ManureVo cvo = JSON.parseObject(json, ManureVo.class) ; |
| | | if(cvo != null){ |
| | | msg = cvo.toString() ; |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | } |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | return msg; |
| | | }} |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.fault; |
| | | |
| | | import com.dy.pipIrrRemote.common.dto.DtoBase; |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=true) |
| | | public class CdDto extends DtoBase { |
| | | public static final long serialVersionUID = 202506161739001L; |
| | | public class CdDto extends Dto4MqttBase { |
| | | public static final long serialVersionUID = 202506501650001L; |
| | | } |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.fault; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import lombok.experimental.SuperBuilder; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | public class CdParam { |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @SuperBuilder |
| | | public class CdParam extends Cd4MqttParameter { |
| | | } |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.fault; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.ComSv; |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttSv; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Service("faultSv") |
| | | public class CdSv extends ComSv { |
| | | @Service("mqttSd1FaultSv") |
| | | public class CdSv extends Com4MqttSv { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.inject; |
| | | |
| | | 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.protocol4Mqtt.pSdV1.CodeSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo; |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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/6/16 17:35 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "è¿ç¨å½ä»¤", description = "æ¸
餿
é") |
| | | @RestController("mqttSd1InjectCtrl") |
| | | @RequestMapping(path = "mqttSd1/injectCtrl") |
| | | @RequiredArgsConstructor |
| | | @Scope("prototype") //å 为æå¯¹è±¡ç±»å±æ§ï¼æä»¥éç¨å忍¡å¼ï¼æ¯æ¬¡è¯·æ±æ°å»ºä¸ä¸ªå®ä¾å¯¹è±¡ |
| | | public class CdCtrl extends Com4MqttCtrl { |
| | | |
| | | private static final String RtuSuccessMsg = "æ§å¶å¨æ¥æ¶å¹¶æ§è¡å½ä»¤æåï¼æ è¿åæ°æ®"; |
| | | |
| | | private static final String Protocol = ProtocolConstantSdV1.protocolName ; |
| | | private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ; |
| | | private static final String ComCode = CodeSdV1.cd_Inject ; |
| | | |
| | | |
| | | @Autowired |
| | | private CdSv sv ; |
| | | /** |
| | | * å设å¤ï¼Mqttä¸é´ä»¶->FBoxï¼åéå½ä»¤ |
| | | * @param dto åç«¯åæ¥çå¼å¯¹è±¡ |
| | | * @param bindingResult 对dtoéªè¯çç»æ |
| | | * @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, Protocol, ProtocolVersion, ComCode, dto, bindingResult); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-3ï¼ä¿åå½ä»¤æ¥å¿ |
| | | CdParam comParam = CdParam.builder().commandCode(ComCode).build(); |
| | | res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-4ï¼åå¤Feature |
| | | super.pre4(); |
| | | try { |
| | | //å建å¤é¨å½ä»¤ï¼åç»æ§å¶å¨ï¼ |
| | | Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode); |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | com.param = comParam ; |
| | | //åéå½ä»¤ |
| | | res = super.doSend(sv, com); |
| | | if (res == null) { |
| | | //åéå½ä»¤å |
| | | res = super.after(ComCode, null); |
| | | } |
| | | } catch (Exception e) { |
| | | res = BaseResponseUtils.buildFail("æå¡ç«¯æé å¹¶åéä¿¡ä¸é´ä»¶åéè¯·æ±æ¶å¼å¸¸" + (e.getMessage() == null ? "" : e.getMessage())); |
| | | } finally { |
| | | //æç» |
| | | super.end(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return res ; |
| | | } |
| | | |
| | | @Override |
| | | protected String checkDto(Dto4MqttBase dto) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected String dealComResult(String code, JSONObject resultData, Callback callback){ |
| | | String msg; |
| | | if(resultData != null){ |
| | | log.info(resultData.toString()); |
| | | JSONObject codeData = resultData.getJSONObject("data") ; |
| | | if(codeData == null){ |
| | | msg = RtuSuccessMsg ; |
| | | }else { |
| | | String json = codeData.toJSONString(); |
| | | ManureVo cvo = JSON.parseObject(json, ManureVo.class) ; |
| | | if(cvo != null){ |
| | | msg = cvo.toString() ; |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | } |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | return msg; |
| | | }} |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.inject; |
| | | |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=true) |
| | | public class CdDto extends Dto4MqttBase { |
| | | public static final long serialVersionUID = 202506201653001L; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.inject; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import lombok.experimental.SuperBuilder; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @SuperBuilder |
| | | public class CdParam extends Cd4MqttParameter { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.inject; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttSv; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Service("mqttSd1InjectSv") |
| | | public class CdSv extends Com4MqttSv { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.irr; |
| | | |
| | | 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.protocol4Mqtt.pSdV1.CodeSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo; |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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/6/16 17:35 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "è¿ç¨å½ä»¤", description = "æ¸
餿
é") |
| | | @RestController("mqttSd1IrrCtrl") |
| | | @RequestMapping(path = "mqttSd1/irrCtrl") |
| | | @RequiredArgsConstructor |
| | | @Scope("prototype") //å 为æå¯¹è±¡ç±»å±æ§ï¼æä»¥éç¨å忍¡å¼ï¼æ¯æ¬¡è¯·æ±æ°å»ºä¸ä¸ªå®ä¾å¯¹è±¡ |
| | | public class CdCtrl extends Com4MqttCtrl { |
| | | |
| | | private static final String RtuSuccessMsg = "æ§å¶å¨æ¥æ¶å¹¶æ§è¡å½ä»¤æåï¼æ è¿åæ°æ®"; |
| | | |
| | | private static final String Protocol = ProtocolConstantSdV1.protocolName ; |
| | | private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ; |
| | | private static final String ComCode = CodeSdV1.cd_Irr ; |
| | | |
| | | |
| | | @Autowired |
| | | private CdSv sv ; |
| | | /** |
| | | * å设å¤ï¼Mqttä¸é´ä»¶->FBoxï¼åéå½ä»¤ |
| | | * @param dto åç«¯åæ¥çå¼å¯¹è±¡ |
| | | * @param bindingResult 对dtoéªè¯çç»æ |
| | | * @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, Protocol, ProtocolVersion, ComCode, dto, bindingResult); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-3ï¼ä¿åå½ä»¤æ¥å¿ |
| | | CdParam comParam = CdParam.builder().commandCode(ComCode).build(); |
| | | res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-4ï¼åå¤Feature |
| | | super.pre4(); |
| | | try { |
| | | //å建å¤é¨å½ä»¤ï¼åç»æ§å¶å¨ï¼ |
| | | Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode); |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | com.param = comParam ; |
| | | //åéå½ä»¤ |
| | | res = super.doSend(sv, com); |
| | | if (res == null) { |
| | | //åéå½ä»¤å |
| | | res = super.after(ComCode, null); |
| | | } |
| | | } catch (Exception e) { |
| | | res = BaseResponseUtils.buildFail("æå¡ç«¯æé å¹¶åéä¿¡ä¸é´ä»¶åéè¯·æ±æ¶å¼å¸¸" + (e.getMessage() == null ? "" : e.getMessage())); |
| | | } finally { |
| | | //æç» |
| | | super.end(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return res ; |
| | | } |
| | | |
| | | @Override |
| | | protected String checkDto(Dto4MqttBase dto) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected String dealComResult(String code, JSONObject resultData, Callback callback){ |
| | | String msg; |
| | | if(resultData != null){ |
| | | log.info(resultData.toString()); |
| | | JSONObject codeData = resultData.getJSONObject("data") ; |
| | | if(codeData == null){ |
| | | msg = RtuSuccessMsg ; |
| | | }else { |
| | | String json = codeData.toJSONString(); |
| | | ManureVo cvo = JSON.parseObject(json, ManureVo.class) ; |
| | | if(cvo != null){ |
| | | msg = cvo.toString() ; |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | } |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | return msg; |
| | | }} |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.irr; |
| | | |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=true) |
| | | public class CdDto extends Dto4MqttBase { |
| | | public static final long serialVersionUID = 202506201654001L; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.irr; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import lombok.experimental.SuperBuilder; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @SuperBuilder |
| | | public class CdParam extends Cd4MqttParameter { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.irr; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttSv; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Service("mqttSd1IrrSv") |
| | | public class CdSv extends Com4MqttSv { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet; |
| | | |
| | | 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.protocol4Mqtt.pSdV1.CodeSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo; |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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/6/16 17:35 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "è¿ç¨å½ä»¤", description = "æ¸
餿
é") |
| | | @RestController("mqttSd1ParamCtrl") |
| | | @RequestMapping(path = "mqttSd1/paramCtrl") |
| | | @RequiredArgsConstructor |
| | | @Scope("prototype") //å 为æå¯¹è±¡ç±»å±æ§ï¼æä»¥éç¨å忍¡å¼ï¼æ¯æ¬¡è¯·æ±æ°å»ºä¸ä¸ªå®ä¾å¯¹è±¡ |
| | | public class CdCtrl extends Com4MqttCtrl { |
| | | |
| | | private static final String RtuSuccessMsg = "æ§å¶å¨æ¥æ¶å¹¶æ§è¡å½ä»¤æåï¼æ è¿åæ°æ®"; |
| | | |
| | | private static final String Protocol = ProtocolConstantSdV1.protocolName ; |
| | | private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ; |
| | | private static final String ComCode = CodeSdV1.cd_Param ; |
| | | |
| | | |
| | | @Autowired |
| | | private CdSv sv ; |
| | | /** |
| | | * å设å¤ï¼Mqttä¸é´ä»¶->FBoxï¼åéå½ä»¤ |
| | | * @param dto åç«¯åæ¥çå¼å¯¹è±¡ |
| | | * @param bindingResult 对dtoéªè¯çç»æ |
| | | * @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, Protocol, ProtocolVersion, ComCode, dto, bindingResult); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-3ï¼ä¿åå½ä»¤æ¥å¿ |
| | | CdParam comParam = CdParam.builder().commandCode(ComCode).build(); |
| | | res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-4ï¼åå¤Feature |
| | | super.pre4(); |
| | | try { |
| | | //å建å¤é¨å½ä»¤ï¼åç»æ§å¶å¨ï¼ |
| | | Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode); |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | com.param = comParam ; |
| | | //åéå½ä»¤ |
| | | res = super.doSend(sv, com); |
| | | if (res == null) { |
| | | //åéå½ä»¤å |
| | | res = super.after(ComCode, null); |
| | | } |
| | | } catch (Exception e) { |
| | | res = BaseResponseUtils.buildFail("æå¡ç«¯æé å¹¶åéä¿¡ä¸é´ä»¶åéè¯·æ±æ¶å¼å¸¸" + (e.getMessage() == null ? "" : e.getMessage())); |
| | | } finally { |
| | | //æç» |
| | | super.end(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return res ; |
| | | } |
| | | |
| | | @Override |
| | | protected String checkDto(Dto4MqttBase dto) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected String dealComResult(String code, JSONObject resultData, Callback callback){ |
| | | String msg; |
| | | if(resultData != null){ |
| | | log.info(resultData.toString()); |
| | | JSONObject codeData = resultData.getJSONObject("data") ; |
| | | if(codeData == null){ |
| | | msg = RtuSuccessMsg ; |
| | | }else { |
| | | String json = codeData.toJSONString(); |
| | | ManureVo cvo = JSON.parseObject(json, ManureVo.class) ; |
| | | if(cvo != null){ |
| | | msg = cvo.toString() ; |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | } |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | return msg; |
| | | }} |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet; |
| | | |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=true) |
| | | public class CdDto extends Dto4MqttBase { |
| | | public static final long serialVersionUID = 202506201656001L; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import lombok.experimental.SuperBuilder; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @SuperBuilder |
| | | public class CdParam extends Cd4MqttParameter { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttSv; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Service("mqttSd1ParamSv") |
| | | public class CdSv extends Com4MqttSv { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.stir; |
| | | |
| | | 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.protocol4Mqtt.pSdV1.CodeSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1; |
| | | import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo; |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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/6/16 17:35 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "è¿ç¨å½ä»¤", description = "æ¸
餿
é") |
| | | @RestController("mqttSd1StirCtrl") |
| | | @RequestMapping(path = "mqttSd1/stirCtrl") |
| | | @RequiredArgsConstructor |
| | | @Scope("prototype") //å 为æå¯¹è±¡ç±»å±æ§ï¼æä»¥éç¨å忍¡å¼ï¼æ¯æ¬¡è¯·æ±æ°å»ºä¸ä¸ªå®ä¾å¯¹è±¡ |
| | | public class CdCtrl extends Com4MqttCtrl { |
| | | |
| | | private static final String RtuSuccessMsg = "æ§å¶å¨æ¥æ¶å¹¶æ§è¡å½ä»¤æåï¼æ è¿åæ°æ®"; |
| | | |
| | | private static final String Protocol = ProtocolConstantSdV1.protocolName ; |
| | | private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ; |
| | | private static final String ComCode = CodeSdV1.cd_Stir ; |
| | | |
| | | |
| | | @Autowired |
| | | private CdSv sv ; |
| | | /** |
| | | * å设å¤ï¼Mqttä¸é´ä»¶->FBoxï¼åéå½ä»¤ |
| | | * @param dto åç«¯åæ¥çå¼å¯¹è±¡ |
| | | * @param bindingResult 对dtoéªè¯çç»æ |
| | | * @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, Protocol, ProtocolVersion, ComCode, dto, bindingResult); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-3ï¼ä¿åå½ä»¤æ¥å¿ |
| | | CdParam comParam = CdParam.builder().commandCode(ComCode).build(); |
| | | res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam); |
| | | if (res == null) { |
| | | //åéå½ä»¤å-4ï¼åå¤Feature |
| | | super.pre4(); |
| | | try { |
| | | //å建å¤é¨å½ä»¤ï¼åç»æ§å¶å¨ï¼ |
| | | Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode); |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | com.param = comParam ; |
| | | //åéå½ä»¤ |
| | | res = super.doSend(sv, com); |
| | | if (res == null) { |
| | | //åéå½ä»¤å |
| | | res = super.after(ComCode, null); |
| | | } |
| | | } catch (Exception e) { |
| | | res = BaseResponseUtils.buildFail("æå¡ç«¯æé å¹¶åéä¿¡ä¸é´ä»¶åéè¯·æ±æ¶å¼å¸¸" + (e.getMessage() == null ? "" : e.getMessage())); |
| | | } finally { |
| | | //æç» |
| | | super.end(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return res ; |
| | | } |
| | | |
| | | @Override |
| | | protected String checkDto(Dto4MqttBase dto) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected String dealComResult(String code, JSONObject resultData, Callback callback){ |
| | | String msg; |
| | | if(resultData != null){ |
| | | log.info(resultData.toString()); |
| | | JSONObject codeData = resultData.getJSONObject("data") ; |
| | | if(codeData == null){ |
| | | msg = RtuSuccessMsg ; |
| | | }else { |
| | | String json = codeData.toJSONString(); |
| | | ManureVo cvo = JSON.parseObject(json, ManureVo.class) ; |
| | | if(cvo != null){ |
| | | msg = cvo.toString() ; |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | } |
| | | }else{ |
| | | msg = RtuSuccessMsg ; |
| | | } |
| | | return msg; |
| | | }} |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.stir; |
| | | |
| | | import com.dy.pipIrrRemote.common.dto.Dto4MqttBase; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=true) |
| | | public class CdDto extends Dto4MqttBase { |
| | | public static final long serialVersionUID = 202506201655001L; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.stir; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import lombok.experimental.SuperBuilder; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @SuperBuilder |
| | | public class CdParam extends Cd4MqttParameter { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.monitor.mqttSd1.stir; |
| | | |
| | | import com.dy.pipIrrRemote.monitor.common.Com4MqttSv; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2025/6/16 17:36 |
| | | * @Description |
| | | */ |
| | | @Slf4j |
| | | @Service("mqttSd1StirSv") |
| | | public class CdSv extends Com4MqttSv { |
| | | } |