Merge remote-tracking branch 'origin/master'
| | |
| | | public static final String cd_83 = "83" ; //遥测终端定点上报 |
| | | public static final String cd_84 = "84" ; //刷卡开泵/阀上报 |
| | | public static final String cd_85 = "85" ; //刷卡关泵/阀上报 |
| | | public static final String cd_9A = "9A" ; //清除年用水量和年用电量 |
| | | public static final String cd_9A = "9A" ; //查询年用水量 |
| | | public static final String cd_26 = "26" ; //设置设备终端年用水量 |
| | | public static final String cd_21 = "21" ; //设置设备终端IP地址 |
| | | public static final String cd_86 = "86" ; //查询设备终端IP地址 |
| | |
| | | (code.equals(cd_83) ? "遥测终端定点上报" : |
| | | (code.equals(cd_84) ? "刷卡开泵/阀上报" : |
| | | (code.equals(cd_85) ? "刷卡关泵/阀上报" : |
| | | (code.equals(cd_9A) ? "清除年用水量和年用电量" : |
| | | (code.equals(cd_9A) ? "查询年用水量" : |
| | | (code.equals(cd_26) ? "设置设备终端年用水量" : |
| | | (code.equals(cd_21) ? "设置设备终端IP地址" : |
| | | (code.equals(cd_86) ? "查询设备终端IP地址" : |
| | |
| | | public class ComCd26Vo { |
| | | public String controllerType;//控制器类型 01(0x01):测控一体阀;57(0x57):井电控制器 |
| | | public Integer projectNo ;//控制器类型 0x01:测控一体阀;0x57:井电控制器 |
| | | public Integer ipChannel ;//IP通道号 0x01:1通道 0x02:2通道. |
| | | public Integer maxAmountYear ;//设备终端年用水量 单位:m3 整数,取值范围0~99999999 |
| | | } |
| | |
| | | |
| | | |
| | | byte[] bs1 = new byte[7] ; |
| | | index ++ ; |
| | | index = 0; |
| | | GlCreate.createPw(bs1, index); |
| | | |
| | | index += 2 ; |
| | |
| | | |
| | | |
| | | byte[] bs1 = new byte[7] ; |
| | | index ++ ; |
| | | index = 0 ; |
| | | GlCreate.createPw(bs1, index); |
| | | |
| | | index += 2 ; |
| | |
| | | bytes = ByteUtil.bytesMerge(bytes, bsRg) ; |
| | | |
| | | byte[] bs1 = new byte[7] ; |
| | | index ++ ; |
| | | index = 0 ; |
| | | GlCreate.createPw(bs1, index); |
| | | |
| | | index += 2 ; |
| | |
| | | if(cvo == null){ |
| | | throw new Exception("json转ComCd22Vo为null") ; |
| | | } |
| | | if(cvo.ipChannel != 1 && cvo.ipChannel !=2){ |
| | | throw new Exception("IP通道号只能是1或2") ; |
| | | } |
| | | |
| | | if(cvo.maxAmountYear < 0 || cvo.maxAmountYear > 99999999){ |
| | | throw new Exception("设备终端年用水量必须是0~99999999范围内的整数") ; |
| | | } |
| | | |
| | | byte[] bs = new byte[15] ; |
| | | byte[] bs = new byte[14] ; |
| | | int index = 0 ; |
| | | bs[index] = (byte)(Integer.parseInt(cvo.controllerType, 16)); |
| | | |
| | | index ++ ; |
| | | bs[index] = cvo.projectNo.byteValue() ; |
| | | |
| | | index ++ ; |
| | | bs[index] = cvo.ipChannel.byteValue() ; |
| | | |
| | | index ++ ; |
| | | String strTemp = "" + cvo.maxAmountYear ; |
| | |
| | | cdData.ip = ByteUtil.bytes2String_BE(bs, index, index + ipLen - 1) ; |
| | | |
| | | index += ipLen ; |
| | | cdData.port = Integer.parseInt(ByteUtil.bytes2String_LE(bs, index, index + portLen - 1)) ; |
| | | cdData.port = Integer.parseInt(ByteUtil.bytes2String_BE(bs, index, index + portLen - 1)) ; |
| | | } |
| | | |
| | | } |
| | |
| | | short portLen = ByteUtilUnsigned.byte2Byte(bs, index) ; |
| | | |
| | | index++ ; |
| | | cdData.domain = ByteUtil.bytes2String_LE(bs, index, index + domainLen - 1) ; |
| | | cdData.domain = ByteUtil.bytes2String_BE(bs, index, index + domainLen - 1) ; |
| | | |
| | | index += domainLen ; |
| | | cdData.port = Integer.parseInt(ByteUtil.bytes2String_LE(bs, index, index + portLen - 1)) ; |
| | | cdData.port = Integer.parseInt(ByteUtil.bytes2String_BE(bs, index, index + portLen - 1)) ; |
| | | } |
| | | |
| | | } |
| | |
| | | for(int i = 0 ; i < bTempLen; i++){ |
| | | bs[index++] = bTemp[i] ; |
| | | count ++ ; |
| | | if(count >= 4){ |
| | | if(count >= 5){ |
| | | break ; |
| | | } |
| | | } |
| | | for(; count < 4; count++){ |
| | | for(; count < 5; count++){ |
| | | bs[index++] = 0 ; |
| | | } |
| | | |
| | |
| | | cdData.orderNo = ByteUtil.BCD2String_BE(bs, index, index + 7) ; |
| | | |
| | | index += 8 ; |
| | | cdData.opDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | | index += 6 ; |
| | | cdData.opType = bs[index]; |
| | | |
| | | index ++ ; |
| | |
| | | if(!NumUtil.isPlusIntNumber(cvo.orderNo)){ |
| | | throw new Exception("订单号必须是16位数字") ; |
| | | } |
| | | if(cvo.orderNo.length() != 12){ |
| | | if(cvo.orderNo.length() != 16){ |
| | | throw new Exception("订单号必须是16位数字") ; |
| | | } |
| | | |
| | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V202404.*; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd9AVo; |
| | | import com.dy.common.mw.protocol.p206V202404.upVos.DataCdXyVo; |
| | | import com.dy.common.util.ByteUtil; |
| | | import org.apache.logging.log4j.LogManager; |
| | |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | DataV202404 dV1 = (DataV202404)data.getSubData() ; |
| | | DataCdXyVo cdData = new DataCdXyVo(CodeV202404.getCodeName(dataCode)) ; |
| | | DataCd9AVo cdData = new DataCd9AVo(CodeV202404.getCodeName(dataCode)) ; |
| | | dV1.subData = cdData ; |
| | | int index = ProtocolConstantV206V202404.dataIndex ; |
| | | cdData.controllerType = ByteUtil.bytes2Hex(bs, false, index, 1) ; |
| | |
| | | cdData.projectNo = (int)bs[index]; |
| | | |
| | | index++ ; |
| | | byte result = bs[index]; |
| | | if(result == 1){ |
| | | cdData.success = true ; |
| | | }else{ |
| | | cdData.success = false ; |
| | | } |
| | | cdData.maxAmountYear = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | } |
| | | |
| | | } |
| | |
| | | cdData.success = false ; |
| | | } |
| | | |
| | | if(!cdData.success){ |
| | | return ; |
| | | } |
| | | |
| | | index++ ; |
| | | GlParse.parseRtuDt(bs, index); |
| | | |
| | |
| | | index += 8 ; |
| | | cdData.startDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | | if(cdData.opResult == (byte)0x81){ |
| | | //失败了,下面就没有数据了 |
| | | return ; |
| | | } |
| | | |
| | | index += 6 ; |
| | | cdData.endDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | |
| | | sb.append(" 水表工作电压 : ") ; |
| | | sb.append(waterMeterWorkVolt == null?"未知":waterMeterWorkVolt) ; |
| | | sb.append("\n") ; |
| | | sb.append(" 信号强度 : ") ; |
| | | sb.append(csq == null?"未知":csq) ; |
| | | sb.append("\n") ; |
| | | return sb.toString() + super.toString() ; |
| | | } |
| | | |
| | |
| | | public Integer projectNo ;//控制器类型 0x01:测控一体阀;0x57:井电控制器 |
| | | public String icCardNo ;//IC卡编号(17位数字) |
| | | public String orderNo ;//订单号(16位数字) |
| | | public String opDt ;//开泵/阀时间(yyyy-mm-dd HH:MM:SS) |
| | | public Byte opType ;//开阀类型: 01:平台开泵/阀 02:用户开泵/阀 |
| | | public Byte opResult ;//开启泵/阀结果: 0x00:成功 0x81:失败 |
| | | |
| | |
| | | sb.append(" 订单号 : ") ; |
| | | sb.append(orderNo == null?"未知":orderNo) ; |
| | | sb.append("\n") ; |
| | | sb.append(" 开泵/阀时间 : ") ; |
| | | sb.append(opDt == null?"未知":opDt) ; |
| | | sb.append("\n") ; |
| | | sb.append(" 开启泵/阀类型 : ") ; |
| | | sb.append(opType == null?"未知":(opType.byteValue() == 0x01 ? "平台":"用户")) ; |
| | | sb.append("\n") ; |
| | | sb.append(" 开启泵/阀结果 : ") ; |
| | | sb.append(opResult == null?"未知":(opResult.byteValue() == 0x00 ? "成功":"失败")) ; |
| | | sb.append(opResult == null?"未知":(opResult.byteValue() == 0x01 ? "成功":"失败")) ; |
| | | sb.append("\n") ; |
| | | return sb.toString() ; |
| | | } |
| | |
| | | sb.append(opType == null?"未知":(opType.byteValue() == 0x00 ? "刷卡":(opType.byteValue() == 0x01 ? "平台":(opType.byteValue() == 0x02 ? "APP":(opType.byteValue() == 0x03 ? "非法卡":(opType.byteValue() == 0x04 ? "水表异常":(opType.byteValue() == 0x05 ? "电表异常":(opType.byteValue() == 0x06 ? "剩余水量不足":(opType.byteValue() == 0x07 ? "剩余金额不足":(opType.byteValue() == 0x08 ? "无流量":(opType.byteValue() == 0x09 ? "掉电再上电":"未知"))))))))))) ; |
| | | sb.append("\n") ; |
| | | sb.append(" 关启泵/阀结果 : ") ; |
| | | sb.append(opResult == null?"未知":(opResult.byteValue() == 0x00 ? "成功":"失败")) ; |
| | | sb.append(opResult == null?"未知":(opResult.byteValue() == 0x01 ? "成功":"失败")) ; |
| | | sb.append("\n") ; |
| | | sb.append(" IC卡地址 : ") ; |
| | | sb.append(icCardAddr == null?"未知":icCardAddr) ; |
New file |
| | |
| | | package com.dy.common.mw.protocol.p206V202404.upVos; |
| | | |
| | | import lombok.Data; |
| | | |
| | | //查询设备年用水量 |
| | | @Data |
| | | public class DataCd9AVo { |
| | | |
| | | public String controllerType;//控制器类型 01(0x01):测控一体阀;57(0x57):井电控制器 |
| | | public Integer projectNo ;//控制器类型 0x01:测控一体阀;0x57:井电控制器 |
| | | public Integer maxAmountYear ;//设备终端年用水量 单位:m3 整数,取值范围0~99999999 |
| | | |
| | | public String comName ;//命令名称 |
| | | |
| | | public DataCd9AVo(String comName){ |
| | | this.comName = comName ; |
| | | } |
| | | |
| | | public String toString(){ |
| | | StringBuffer sb = new StringBuffer() ; |
| | | sb.append(" " + comName + " : \n") ; |
| | | sb.append(" 控制器类型 : ") ; |
| | | sb.append(controllerType == null?"未知":(controllerType.equals("01")?"测控一体阀":(controllerType.equals("57")?"井电控制器":"未知"))) ; |
| | | sb.append("\n") ; |
| | | sb.append(" 项目编号 : ") ; |
| | | sb.append(projectNo == null?"未知":projectNo) ; |
| | | sb.append("\n") ; |
| | | sb.append(" 年用水量 : ") ; |
| | | sb.append(maxAmountYear == null?"未知":maxAmountYear) ; |
| | | sb.append("\n") ; |
| | | return sb.toString() ; |
| | | } |
| | | |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | Integer deleteIntakeId(@Param("controllerId") Long controllerId); |
| | | |
| | | /** |
| | | * 根据取水口ID获取阀控器地址 |
| | | * @param intakeId 取水口ID |
| | | * @return 阀控器地址 |
| | | */ |
| | | String getRtuAddrByIntakeId(Long intakeId); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.daoRm; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-22 14:29 |
| | | * @LastEditTime 2024-05-22 14:29 |
| | | * @Description |
| | | */ |
| | | |
| | | @Mapper |
| | | public interface RmCommandHistoryMapper extends BaseMapper<RmCommandHistory> { |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(RmCommandHistory record); |
| | | |
| | | int insertSelective(RmCommandHistory record); |
| | | |
| | | RmCommandHistory selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(RmCommandHistory record); |
| | | |
| | | int updateByPrimaryKey(RmCommandHistory record); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.pojoRm; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; |
| | | import com.dy.common.po.BaseEntity; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.*; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-21 16:53 |
| | | * @LastEditTime 2024-05-21 16:53 |
| | | * @Description 命令日志实体类 |
| | | */ |
| | | /** |
| | | * 命令日志表 |
| | | */ |
| | | |
| | | @TableName(value = "rm_command_history", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class RmCommandHistory implements BaseEntity{ |
| | | public static final long serialVersionUID = 202401151517005L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | @TableId(type = IdType.INPUT) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 功能码 |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | @NotBlank(message = "功能码不能为空") |
| | | private String commandCode; |
| | | |
| | | /** |
| | | * 操作内容 |
| | | */ |
| | | private String commandName; |
| | | |
| | | /** |
| | | * 阀控器地址 |
| | | */ |
| | | @NotBlank(message = "阀控器地址不能为空") |
| | | private String rtuaddr; |
| | | |
| | | /** |
| | | * 通讯协议 |
| | | */ |
| | | @NotBlank(message = "通讯协议不能为空") |
| | | private String protocol; |
| | | |
| | | /** |
| | | * 命令类型 |
| | | */ |
| | | @NotBlank(message = "命令类型不能为空") |
| | | private String commandType; |
| | | |
| | | /** |
| | | * 回调URL |
| | | */ |
| | | @NotBlank(message = "回调URL不能为空") |
| | | private String callback; |
| | | |
| | | /** |
| | | * 参数数据 |
| | | */ |
| | | @TableField(typeHandler = JacksonTypeHandler.class) |
| | | private JSONObject param; |
| | | |
| | | /** |
| | | * 发送命令时间 |
| | | */ |
| | | @NotNull(message = "发送命令时间不能为空") |
| | | private Date sendTime; |
| | | |
| | | /** |
| | | * 操作人 |
| | | */ |
| | | @JSONField(serializeUsing = ObjectWriterImplToString.class) |
| | | @NotNull(message = "操作人不能为空") |
| | | private Long operator; |
| | | |
| | | /** |
| | | * 命令结果;0-失败,1-成功 |
| | | */ |
| | | |
| | | private Byte result; |
| | | |
| | | /** |
| | | * 收到命令结果时间 |
| | | */ |
| | | private Date resultTime; |
| | | |
| | | /** |
| | | * 命令结果内容 |
| | | */ |
| | | @TableField(typeHandler = JacksonTypeHandler.class) |
| | | private JSONObject resultText; |
| | | |
| | | } |
| | |
| | | username: root |
| | | password: dysql,;.abc!@# |
| | | druid: |
| | | # 数据源名称:当存在多个数据源时,设置名字可以很方便的来进行区分,默认自动生成名称,格式是:"DataSource-" + System.identityHashCode(this) |
| | | name: druid-mysql-pj |
| | | #配置初始化大小、最小、最大 |
| | | initialSize: 1 |
| | | minIdle: 1 |
| | |
| | | username: root |
| | | password: dysql,;.abc!@# |
| | | druid: |
| | | # 数据源名称:当存在多个数据源时,设置名字可以很方便的来进行区分,默认自动生成名称,格式是:"DataSource-" + System.identityHashCode(this) |
| | | name: druid-mysql-ym |
| | | #配置初始化大小、最小、最大 |
| | | initialSize: 1 |
| | | minIdle: 1 |
| | | maxActive: 100 |
| | | #配置获取连接等待超时的时间,单位是毫秒 |
| | | maxWait: 6000 |
| | | initialSize: 10 |
| | | minIdle: 10 |
| | | maxActive: 200 |
| | | # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁 |
| | | maxWait: 60000 |
| | | #配置间隔多久进行一次检测,检测需要关闭的空闲连接,单位毫秒。 默认是60s,太长可能会导致无法及时检测到连接中断 |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | #配置一个连接在连接池中的最小生存时间、最大生存时间,超过最大生存时间会被移除,单位毫秒。 |
| | |
| | | <select id="getBindedCount" resultType="java.lang.Integer"> |
| | | SELECT COUNT(*) AS recordCount FROM pr_controller WHERE rtuAddr = (SELECT rtuAddr FROM pr_controller_tramp WHERE id = ${controllerId}) AND intakeId IS NOT NULL |
| | | </select> |
| | | |
| | | <!--根据取水口ID获取阀控器地址--> |
| | | <select id="getRtuAddrByIntakeId" resultType="java.lang.String"> |
| | | SELECT rtuAddr FROM pr_controller WHERE deleted = 0 AND intakeId = #{intakeId} LIMIT 0,1 |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table rm_command_history--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="command_code" jdbcType="VARCHAR" property="commandCode" /> |
| | | <result column="command_name" jdbcType="VARCHAR" property="commandName" /> |
| | | <result column="rtuAddr" jdbcType="VARCHAR" property="rtuaddr" /> |
| | | <result column="protocol" jdbcType="VARCHAR" property="protocol" /> |
| | | <result column="command_type" jdbcType="VARCHAR" property="commandType" /> |
| | | <result column="callBack" jdbcType="VARCHAR" property="callback" /> |
| | | <!-- <result column="param" jdbcType="VARCHAR" property="param" />--> |
| | | <result column="param" property="param" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" /> |
| | | |
| | | <result column="send_time" jdbcType="TIMESTAMP" property="sendTime" /> |
| | | <result column="operator" jdbcType="BIGINT" property="operator" /> |
| | | <result column="result" jdbcType="TINYINT" property="result" /> |
| | | <result column="result_time" jdbcType="TIMESTAMP" property="resultTime" /> |
| | | <result column="result_text" property="resultText" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, command_code, command_name, rtuAddr, protocol, command_type, callBack, param, |
| | | send_time, `operator`, `result`, result_time, result_text |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from rm_command_history |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from rm_command_history |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> |
| | | <!--@mbg.generated--> |
| | | insert into rm_command_history (id, command_code, command_name, |
| | | rtuAddr, protocol, command_type, |
| | | callBack, param, send_time, |
| | | `operator`, `result`, result_time, |
| | | result_text) |
| | | values (#{id,jdbcType=BIGINT}, #{commandCode,jdbcType=VARCHAR}, #{commandName,jdbcType=VARCHAR}, |
| | | #{rtuaddr,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, #{commandType,jdbcType=VARCHAR}, |
| | | #{callback,jdbcType=VARCHAR}, #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, #{sendTime,jdbcType=TIMESTAMP}, |
| | | #{operator,jdbcType=BIGINT}, #{result,jdbcType=TINYINT}, #{resultTime,jdbcType=TIMESTAMP}, |
| | | #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> |
| | | <!--@mbg.generated--> |
| | | insert into rm_command_history |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="commandCode != null"> |
| | | command_code, |
| | | </if> |
| | | <if test="commandName != null"> |
| | | command_name, |
| | | </if> |
| | | <if test="rtuaddr != null"> |
| | | rtuAddr, |
| | | </if> |
| | | <if test="protocol != null"> |
| | | protocol, |
| | | </if> |
| | | <if test="commandType != null"> |
| | | command_type, |
| | | </if> |
| | | <if test="callback != null"> |
| | | callBack, |
| | | </if> |
| | | <if test="param != null"> |
| | | param, |
| | | </if> |
| | | <if test="sendTime != null"> |
| | | send_time, |
| | | </if> |
| | | <if test="operator != null"> |
| | | `operator`, |
| | | </if> |
| | | <if test="result != null"> |
| | | `result`, |
| | | </if> |
| | | <if test="resultTime != null"> |
| | | result_time, |
| | | </if> |
| | | <if test="resultText != null"> |
| | | result_text, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="commandCode != null"> |
| | | #{commandCode,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="commandName != null"> |
| | | #{commandName,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="rtuaddr != null"> |
| | | #{rtuaddr,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="protocol != null"> |
| | | #{protocol,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="commandType != null"> |
| | | #{commandType,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="callback != null"> |
| | | #{callback,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="param != null"> |
| | | #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, |
| | | </if> |
| | | <if test="sendTime != null"> |
| | | #{sendTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="operator != null"> |
| | | #{operator,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="result != null"> |
| | | #{result,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="resultTime != null"> |
| | | #{resultTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="resultText != null"> |
| | | #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> |
| | | <!--@mbg.generated--> |
| | | update rm_command_history |
| | | <set> |
| | | <if test="commandCode != null"> |
| | | command_code = #{commandCode,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="commandName != null"> |
| | | command_name = #{commandName,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="rtuaddr != null"> |
| | | rtuAddr = #{rtuaddr,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="protocol != null"> |
| | | protocol = #{protocol,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="commandType != null"> |
| | | command_type = #{commandType,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="callback != null"> |
| | | callBack = #{callback,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="param != null"> |
| | | param = #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, |
| | | </if> |
| | | <if test="sendTime != null"> |
| | | send_time = #{sendTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="operator != null"> |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="result != null"> |
| | | `result` = #{result,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="resultTime != null"> |
| | | result_time = #{resultTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="resultText != null"> |
| | | result_text = #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> |
| | | <!--@mbg.generated--> |
| | | update rm_command_history |
| | | set command_code = #{commandCode,jdbcType=VARCHAR}, |
| | | command_name = #{commandName,jdbcType=VARCHAR}, |
| | | rtuAddr = #{rtuaddr,jdbcType=VARCHAR}, |
| | | protocol = #{protocol,jdbcType=VARCHAR}, |
| | | command_type = #{commandType,jdbcType=VARCHAR}, |
| | | callBack = #{callback,jdbcType=VARCHAR}, |
| | | param = #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, |
| | | send_time = #{sendTime,jdbcType=TIMESTAMP}, |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | `result` = #{result,jdbcType=TINYINT}, |
| | | result_time = #{resultTime,jdbcType=TIMESTAMP}, |
| | | result_text = #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | username: root |
| | | password: dysql,;.abc!@# |
| | | druid: |
| | | # 说明: 如果你没有指定useSSL=true ,启动项目会报红警告, 环境的问题,要灵活处理 |
| | | #数据源名称:当存在多个数据源时,设置名字可以很方便的来进行区分,默认自动生成名称,格式是:"DataSource-" + System.identityHashCode(this) |
| | | #name: name: druid-mysql-mw-rtu 单数据源不起作用,所以注释掉 |
| | | #配置初始化大小、最小、最大 |
| | | initialSize: 10 |
| | | minIdle: 10 |
| | | maxActive: 200 |
| | | # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁 |
| | | maxWait: 60000 |
| | |
| | | AppenderRef: #Root的子节点,用来指定该日志输出到哪个Appender. |
| | | - ref: CONSOLE #输出日志时,首先由本level判断是否输出,然后再由上面的Appenders.Console.ThresholdFilter.level判断是否输出 |
| | | - ref: ROLLING_FILE #输出日志时,首先由本level判断是否输出,然后再由上面的Appenders.RollingFile.ThresholdFilter.level判断是否输出 |
| | | # 为包配置特殊的Log级别,方便调试, |
| | | # 为类包路径配置特殊的Log级别,方便调试, |
| | | # 不受Loggers.Root.level限制 |
| | | Logger: |
| | | - name: com.dy.pipIrrGlobal.daoBa |
| | |
| | | package com.dy.pipIrrMwTestWeb; |
| | | |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.pipIrrMwTestWeb.test.CommandCtrl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.CommandLineRunner; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| | |
| | | @GetMapping(path = "test") |
| | | public BaseResponse<String> test() { |
| | | //return this.connect() ;//连接通信中间件测试 |
| | | //return this.cdXY(CodeV202404.cd_30) ;//发送固定参数XY的命令 |
| | | //return this.cdXY(CodeV202404.cd_9C) ;//发送固定参数XY的命令 |
| | | //return this.cd55(1) ; |
| | | //return this.cd15() ; |
| | | //return this.cd16() ; |
| | | //return this.cd21() ; |
| | | //return this.cd22() ; |
| | | //return this.cd23() ; |
| | | //return this.cd24() ; |
| | | //return this.cd26() ; |
| | | //return this.cd31() ; |
| | | return this.cd92() ; |
| | | //return this.cd86() ; |
| | | //return this.cd87() ; |
| | | //return this.cd92() ; |
| | | //return this.cd93() ; |
| | | return this.cd9C() ; |
| | | } |
| | | |
| | | /** |
| | |
| | | comVo.controllerType = CommandCtrl.controllerType ; |
| | | comVo.projectNo = CommandCtrl.projectNo ; |
| | | comVo.channel = 1 ;//IP通道号(取值范围 1、2). |
| | | comVo.ip = "111.222.123.321" ;//IP(例如 125.235.35.89) |
| | | comVo.port = 60000 ;///端口号(0~65536) |
| | | comVo.ip = "8.140.180.59" ;//IP(例如 125.235.35.89) |
| | | comVo.port = 6001 ;///端口号(0~65536) |
| | | |
| | | return this.sendCom2Mw(this.command(CodeV202404.cd_21, comVo, null)) ; |
| | | } |
| | |
| | | ComCd22Vo comVo = new ComCd22Vo() ; |
| | | comVo.controllerType = CommandCtrl.controllerType ; |
| | | comVo.projectNo = CommandCtrl.projectNo ; |
| | | comVo.maxAmountYear = 12345 ;//机井年最大用水量单位:m3 整数,取值范围0~99999999 |
| | | comVo.limitLevel = 123.4; //水位下限 单位:m 取值范围:0~9999.99 |
| | | comVo.maxAmountYear = 99998888 ;//机井年最大用水量单位:m3 整数,取值范围0~99999999 |
| | | comVo.limitLevel = 9978.60; //水位下限 单位:m 取值范围:0~9999.99 |
| | | |
| | | return this.sendCom2Mw(this.command(CodeV202404.cd_22, comVo, null)) ; |
| | | } |
| | |
| | | comVo.controllerType = CommandCtrl.controllerType ; |
| | | comVo.projectNo = CommandCtrl.projectNo ; |
| | | comVo.channel = 1 ;//IP通道号(取值范围 1、2). |
| | | comVo.domain = "www.baidu.com" ;//域名(例如 dayuyanjiuyuan.to),最大长度42字符 |
| | | comVo.port = 60000 ;///端口号(0~65536) |
| | | comVo.domain = "dayuyanjiuyuan.top" ;//域名(例如 dayuyanjiuyuan.top),最大长度42字符 |
| | | comVo.port = 6001 ;///端口号(0~65536) |
| | | |
| | | return this.sendCom2Mw(this.command(CodeV202404.cd_23, comVo, null)) ; |
| | | } |
| | |
| | | ComCd24Vo comVo = new ComCd24Vo() ; |
| | | comVo.controllerType = CommandCtrl.controllerType ; |
| | | comVo.projectNo = CommandCtrl.projectNo ; |
| | | comVo.registerNo = "102030405060708090" ;//域名(例如 dayuyanjiuyuan.to),最大长度42字符 |
| | | comVo.registerNo = "10203040506070809000" ;// |
| | | |
| | | return this.sendCom2Mw(this.command(CodeV202404.cd_24, comVo, null)) ; |
| | | } |
| | |
| | | ComCd26Vo comVo = new ComCd26Vo() ; |
| | | comVo.controllerType = CommandCtrl.controllerType ; |
| | | comVo.projectNo = CommandCtrl.projectNo ; |
| | | comVo.ipChannel = 1 ;//IP通道号 0x01:1通道 0x02:2通道. |
| | | comVo.maxAmountYear = 123456 ;//设备终端年用水量 单位:m3 整数,取值范围0~99999999 |
| | | comVo.maxAmountYear = 200 ;//设备终端年用水量 单位:m3 整数,取值范围0~99999999 |
| | | |
| | | return this.sendCom2Mw(this.command(CodeV202404.cd_26, comVo, null)) ; |
| | | } |
| | |
| | | |
| | | return this.sendCom2Mw(this.command(CodeV202404.cd_93, comVo, null)) ; |
| | | } |
| | | |
| | | //平台/APP远程关闭水泵/阀门(AFN=0x93H/AFN=0xA3H) |
| | | private BaseResponse cd9C(){ |
| | | ComCd9CVo comVo = new ComCd9CVo() ; |
| | | comVo.controllerType = CommandCtrl.controllerType ; |
| | | comVo.projectNo = CommandCtrl.projectNo ; |
| | | comVo.icCardAddr = "04BEA5BB" ;// |
| | | |
| | | return this.sendCom2Mw(this.command(CodeV202404.cd_9C, comVo, null)) ; |
| | | } |
| | | //平台/APP远程关闭水泵/阀门(AFN=0x93H/AFN=0xA3H) |
| | | private BaseResponse cdA3(){ |
| | | ComCd93_A3Vo comVo = new ComCd93_A3Vo() ; |
| | |
| | | String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoPr.PrControllerMapper; |
| | | import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper; |
| | |
| | | import com.dy.pipIrrGlobal.pojoPr.PrController; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrIntakeController; |
| | | import com.dy.pipIrrGlobal.voPr.VoController; |
| | | import com.dy.pipIrrProject.result.ProjectResultCode; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestClientException; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | |
| | | import static com.dy.common.mw.protocol.CommandType.innerCommand; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.dy</groupId> |
| | | <artifactId>pipIrr-web-project</artifactId> |
| | | <version>1.0.0</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <parent> |
| | | <artifactId>pipIrr-web</artifactId> |
| | |
| | | }) |
| | | } |
| | | ) |
| | | @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa"}) |
| | | @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoRm", "com.dy.pipIrrGlobal.daoPr"}) |
| | | public class PipIrrRemoteApplication { |
| | | |
| | | public static void main(String[] args) { |
New file |
| | |
| | | package com.dy.pipIrrRemote.common; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.mw.protocol.CommandType; |
| | | import com.dy.common.mw.protocol.p206V202404.CodeV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; |
| | | import com.dy.common.mw.protocol.p206V202404.downVos.ComCdXyVo; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.util.UriComponentsBuilder; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-21 15:30 |
| | | * @LastEditTime 2024-05-21 15:30 |
| | | * @Description |
| | | */ |
| | | //@RequiredArgsConstructor |
| | | public class ComSupport { |
| | | //@NotNull |
| | | //private final CommandSv commandSv; |
| | | |
| | | protected static String mwUrlTest = "http://127.0.0.1:8070/rtuMw/com/test" ; |
| | | protected static String mwUrlSendCom = "http://127.0.0.1:8070/rtuMw/com/send" ; |
| | | |
| | | //protected static String rtuAddr = "37142501020100215" ; |
| | | protected static String rtuResultSendWebUrl = "http://127.0.0.1:8081/remote/comRes/receive" ; |
| | | |
| | | protected static String controllerType = "57" ;//控制器类型 |
| | | protected static Integer projectNo = 10 ;//项目编码 |
| | | |
| | | protected static String icCardAddr = "04BEA5BB" ;//IC卡地址 |
| | | protected static String icCardNo = "37142501020500001" ;//IC卡编号(用户卡序列号) |
| | | |
| | | protected String protocolName = ProtocolConstantV206V202404.protocolName; |
| | | protected String commandTypeInner = CommandType.innerCommand; |
| | | protected String commandTypeOuter = CommandType.outerCommand; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | protected ComCdXyVo comCdXyVo(){ |
| | | ComCdXyVo comVo = new ComCdXyVo() ; |
| | | comVo.controllerType = controllerType ; |
| | | comVo.projectNo = projectNo ; |
| | | return comVo ; |
| | | } |
| | | |
| | | /** |
| | | * 创建命令日志对象 |
| | | * @param commandCode 功能码 |
| | | * @param rtuAddr 阀控器地址 |
| | | * @param param 参数数据 |
| | | * @param operator 操作员 |
| | | * @return 零零日志对象 |
| | | */ |
| | | protected RmCommandHistory getComHistory(String commandCode, String rtuAddr, Object param, Long operator ) { |
| | | RmCommandHistory rmCommandHistory = new RmCommandHistory(); |
| | | rmCommandHistory.setCommandCode(commandCode); |
| | | rmCommandHistory.setCommandName(CodeV202404.getCodeName(commandCode)); |
| | | rmCommandHistory.setRtuaddr(rtuAddr); |
| | | rmCommandHistory.setProtocol(protocolName); |
| | | rmCommandHistory.setCommandType(commandTypeOuter); |
| | | rmCommandHistory.setCallback(rtuResultSendWebUrl); |
| | | rmCommandHistory.setParam((JSONObject) JSON.toJSON(param)); |
| | | rmCommandHistory.setSendTime(new Date()); |
| | | rmCommandHistory.setOperator(operator); |
| | | return rmCommandHistory; |
| | | } |
| | | |
| | | /** |
| | | * 构造命令对象 |
| | | * @param comId 命令ID |
| | | * @param commandCode 功能码 |
| | | * @param rtuAddr RTU地址 |
| | | * @param param 参数数据 |
| | | * @return 构造好的命令对象 |
| | | */ |
| | | protected Command command(String comId, String commandCode, String rtuAddr, Object param){ |
| | | Command com = new Command() ; |
| | | com.id = comId==null?Command.defaultId:(comId.trim().equals("")?Command.defaultId:comId); |
| | | com.code = commandCode ; |
| | | com.rtuAddr = rtuAddr ; |
| | | |
| | | com.protocol = protocolName; |
| | | com.type = commandTypeOuter; |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl ; |
| | | |
| | | com.param = param ; |
| | | |
| | | return com ; |
| | | } |
| | | |
| | | /** |
| | | * 连接通信中间件测试 |
| | | * @return |
| | | */ |
| | | protected BaseResponse sendTest(){ |
| | | String url = UriComponentsBuilder.fromUriString(mwUrlTest) |
| | | .build() |
| | | .toUriString(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(headers); |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | | // 通过Get方式调用接口 |
| | | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return response.getBody(); |
| | | } |
| | | |
| | | /** |
| | | * 发送命令 |
| | | * @return |
| | | */ |
| | | protected BaseResponse sendCom2Mw(Command com){ |
| | | String url = UriComponentsBuilder.fromUriString(mwUrlSendCom) |
| | | .build() |
| | | .toUriString(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity<Command> httpEntity = new HttpEntity<>(com, headers); |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | | // 通过Post方式调用接口 |
| | | response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return response.getBody(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.common; |
| | | |
| | | import com.dy.pipIrrGlobal.daoPr.PrControllerMapper; |
| | | import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-21 17:14 |
| | | * @LastEditTime 2024-05-21 17:14 |
| | | * @Description 命令日志服务类 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class CommandSv { |
| | | private final RmCommandHistoryMapper rmCommandHistoryMapper; |
| | | private final PrControllerMapper prControllerMapper; |
| | | |
| | | /** |
| | | * 根据取水口ID获取阀控器地址 |
| | | * @param intakeId 取水口ID |
| | | * @return 阀控器地址 |
| | | */ |
| | | public String getRtuAddrByIntakeId(Long intakeId) { |
| | | return prControllerMapper.getRtuAddrByIntakeId(intakeId); |
| | | } |
| | | |
| | | /** |
| | | * 添加命令日志 |
| | | * @param po 命令日志对象 |
| | | * @return 字符串类型的主键 |
| | | */ |
| | | public String insert(RmCommandHistory po) { |
| | | rmCommandHistoryMapper.insert(po); |
| | | return (po.getId()).toString(); |
| | | } |
| | | |
| | | /** |
| | | * 修改命令日志信息 |
| | | * @param po 命令日志对象 |
| | | * @return 影响记录数量 |
| | | */ |
| | | public Integer update(RmCommandHistory po) { |
| | | return rmCommandHistoryMapper.updateByPrimaryKeySelective(po); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.config; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-07 17:09 |
| | | * @LastEditTime 2024-05-07 17:09 |
| | | * @Description |
| | | */ |
| | | @Configuration |
| | | public class RestTemplateConfig { |
| | | |
| | | @Bean |
| | | public RestTemplate restTemplate() { |
| | | return new RestTemplate(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.config; |
| | | |
| | | import com.dy.common.webFilter.DevOfDataSourceNameSetFilter; |
| | | import com.dy.common.webFilter.UserTokenFilter; |
| | | import jakarta.servlet.Filter; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-07 14:51 |
| | | * @LastEditTime 2024-05-07 14:51 |
| | | * @Description |
| | | */ |
| | | @Configuration |
| | | public class WebFilterConfiguration { |
| | | |
| | | @Value("${pipIrr.global.dev}") |
| | | public String isDevStage ;//是否为开发阶段 |
| | | @Value("${pipIrr.global.dsName}") |
| | | public String dsName ;//开发阶段的数据源名称 |
| | | |
| | | /** |
| | | * DevOfDataSourceNameSetFilter与UserTokenFilter只能一个被配置上, |
| | | * 所以他们的order都是1 |
| | | */ |
| | | private static final int order_UserTokenFilter = 1 ;//与下面 |
| | | private static final int order_DevOfDataSourceNameSetFilter = 1 ; |
| | | |
| | | |
| | | @Bean |
| | | public FilterRegistrationBean<? extends Filter> RegFilter() { |
| | | FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(); |
| | | if(this.isDevStage != null && !this.isDevStage.trim().equals("") && this.isDevStage.trim().equalsIgnoreCase("true")){ |
| | | filterRegistrationBean.setFilter(new DevOfDataSourceNameSetFilter()); |
| | | filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则 |
| | | filterRegistrationBean.addInitParameter("dataSourceName",dsName);//设置init参数 |
| | | filterRegistrationBean.setName("DevOfDataSourceNameSetFilter");//设置过滤器名称 |
| | | filterRegistrationBean.setOrder(order_DevOfDataSourceNameSetFilter);//执行次序 |
| | | }else{ |
| | | filterRegistrationBean.setFilter(new UserTokenFilter()); |
| | | filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则 |
| | | filterRegistrationBean.setName("UserTokenFilter");//设置过滤器名称 |
| | | filterRegistrationBean.setOrder(order_UserTokenFilter);//执行次序 |
| | | } |
| | | return filterRegistrationBean; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.config; |
| | | |
| | | import com.dy.common.webListener.GenerateIdSetSuffixListener; |
| | | import jakarta.servlet.ServletContextListener; |
| | | import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-07 14:52 |
| | | * @LastEditTime 2024-05-07 14:52 |
| | | * @Description |
| | | */ |
| | | @Configuration |
| | | public class WebListenerConfiguration { |
| | | |
| | | /** |
| | | * 启动顺序 |
| | | */ |
| | | //private static final int order_config = 0 ; |
| | | private static final int order_idSetSuffix = 1 ; |
| | | //private static final int order_init = 2 ; |
| | | |
| | | /* |
| | | * 解析各种***.config配置的ConfigListener,暂时不采用此种配置方式 |
| | | * |
| | | @Bean |
| | | public ConfigListener getGlConfigListener(){ |
| | | return new ConfigListener() ; |
| | | } |
| | | /** |
| | | * 外部提供Listener |
| | | * @param listener 外部提供Listener |
| | | * @return 注册Bean |
| | | @Bean |
| | | public ServletListenerRegistrationBean<? extends ServletContextListener> regConfigListener(ConfigListener listener) { |
| | | ServletListenerRegistrationBean<ConfigListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | listenerRegistrationBean.setListener(listener); |
| | | listenerRegistrationBean.setOrder(order_config); |
| | | return listenerRegistrationBean; |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * 内部提供listener,该listener在系统启动时,根据配置 设置ID产生器的后缀 |
| | | * @return 注册Bean |
| | | */ |
| | | @Bean |
| | | public ServletListenerRegistrationBean<? extends ServletContextListener> regSsoListener() { |
| | | ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener()); |
| | | listenerRegistrationBean.setOrder(order_idSetSuffix); |
| | | return listenerRegistrationBean; |
| | | } |
| | | |
| | | // /** |
| | | // * 内部提供listener,该listener在系统启动时,初始化数据库数据 |
| | | // * @return 注册Bean |
| | | // */ |
| | | // @Bean |
| | | // public ServletListenerRegistrationBean<? extends ServletContextListener> regInitListener() { |
| | | // ServletListenerRegistrationBean<InitListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | // listenerRegistrationBean.setListener(new InitListener()); |
| | | // listenerRegistrationBean.setOrder(order_init); |
| | | // return listenerRegistrationBean; |
| | | // } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.result; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-07 14:54 |
| | | * @LastEditTime 2024-05-07 14:54 |
| | | * @Description |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum RemoteResultCode { |
| | | /** |
| | | * 远程操作 |
| | | */ |
| | | DIVIDE_FAIL(10001, "分水房添加失败"), |
| | | DELETE_DIVIDE_FAIL(10001, "分水房删除失败"), |
| | | NO_DIVIDES(10001, "无符合条件的分水房记录"), |
| | | |
| | | /** |
| | | * RTU |
| | | */ |
| | | RTU_ADDR_CANNOT_BE_NULL(20001, "阀控器地址不能为空"); |
| | | |
| | | private final Integer code; |
| | | private final String message; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.rtu; |
| | | |
| | | import com.dy.common.mw.protocol.Data; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | 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 ZhuBaoMin |
| | | * @date 2024-05-23 8:19 |
| | | * @LastEditTime 2024-05-23 8:19 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path="comRes") |
| | | public class CommandResultCtrl { |
| | | @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | public BaseResponse<String> receive(@RequestBody Data data) { |
| | | log.info(data.toString()) ; |
| | | return BaseResponseUtils.buildSuccess("ok"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.rtu; |
| | | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.mw.protocol.p206V202404.CodeV202404; |
| | | import com.dy.common.mw.protocol.p206V202404.downVos.ComCd10Vo; |
| | | import com.dy.common.mw.protocol.p206V202404.downVos.ComCdXyVo; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; |
| | | import com.dy.pipIrrRemote.common.ComSupport; |
| | | import com.dy.pipIrrRemote.common.CommandSv; |
| | | import com.dy.pipIrrRemote.result.RemoteResultCode; |
| | | import com.dy.pipIrrRemote.rtu.dto.Addr; |
| | | import com.dy.pipIrrRemote.rtu.dto.DtoBase; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | 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; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-21 14:31 |
| | | * @LastEditTime 2024-05-21 14:31 |
| | | * @Description 设备终端控制类 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path="rtu") |
| | | @RequiredArgsConstructor |
| | | public class RtuCtrl extends ComSupport { |
| | | private final CommandSv commandSv; |
| | | |
| | | protected static String controllerType = "57"; |
| | | |
| | | /** |
| | | * 设置设备终端地址 |
| | | * @param addr 设置设备终端地址传入对象 |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "set_addr", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> setAddr(@RequestBody @Valid Addr addr, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | String commandCode = CodeV202404.cd_10; |
| | | Long intakeId = addr.getIntakeId(); |
| | | String newRtuAddr = addr.getNewRtuAddr(); |
| | | Long operator = addr.getOperator(); |
| | | |
| | | // 取水口ID换阀控器地址 |
| | | String rtuAddr = commandSv.getRtuAddrByIntakeId(intakeId); |
| | | if(rtuAddr == null || rtuAddr.length() == 0) { |
| | | return BaseResponseUtils.buildError(RemoteResultCode.RTU_ADDR_CANNOT_BE_NULL.getMessage()); |
| | | } |
| | | |
| | | // 创建视图 |
| | | ComCd10Vo param = new ComCd10Vo() ; |
| | | param.controllerType = controllerType; |
| | | param.projectNo = Integer.parseInt(commandCode); |
| | | param.rtuNewAddr = newRtuAddr; |
| | | |
| | | // 创建命令日志对象并添加到数据库中 |
| | | RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); |
| | | String comId = commandSv.insert(rmCommandHistory); |
| | | |
| | | // 构造命令 |
| | | Command com = command(comId, commandCode, rtuAddr, param); |
| | | return sendCom2Mw(com); |
| | | } |
| | | |
| | | @PostMapping(path = "clear_usage_record", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> clearUsageRecord(@RequestBody @Valid DtoBase po, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | String commandCode = CodeV202404.cd_97; |
| | | Long intakeId = po.getIntakeId(); |
| | | Long operator = po.getOperator(); |
| | | |
| | | // 取水口ID换阀控器地址 |
| | | String rtuAddr = commandSv.getRtuAddrByIntakeId(intakeId); |
| | | if(rtuAddr == null || rtuAddr.length() == 0) { |
| | | return BaseResponseUtils.buildError(RemoteResultCode.RTU_ADDR_CANNOT_BE_NULL.getMessage()); |
| | | } |
| | | |
| | | // 创建视图 |
| | | ComCdXyVo param = new ComCdXyVo(); |
| | | param.controllerType = controllerType; |
| | | param.projectNo = Integer.parseInt(commandCode); |
| | | |
| | | // 创建命令日志对象并添加到数据库中 |
| | | RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); |
| | | String comId = commandSv.insert(rmCommandHistory); |
| | | |
| | | // 构造命令 |
| | | Command com = command(comId, commandCode, rtuAddr, param); |
| | | return sendCom2Mw(com); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.rtu.dto; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-22 16:56 |
| | | * @LastEditTime 2024-05-22 16:56 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | public class Addr extends DtoBase { |
| | | public static final long serialVersionUID = 202405221656001L; |
| | | |
| | | /** |
| | | * 新的阀控器地址 |
| | | */ |
| | | @NotBlank(message = "新的阀控器地址不能为空") |
| | | private String newRtuAddr; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.rtu.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 DtoBase { |
| | | public static final long serialVersionUID = 202405221655001L; |
| | | |
| | | /** |
| | | * 取水口ID |
| | | */ |
| | | @NotNull(message = "取水口不能为空") |
| | | private Long intakeId; |
| | | |
| | | /** |
| | | * 操作人 |
| | | */ |
| | | @NotNull(message = "操作人不能为空") |
| | | private Long operator; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.utils; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.*; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-07 17:07 |
| | | * @LastEditTime 2024-05-07 17:07 |
| | | * @Description |
| | | */ |
| | | @Component |
| | | public class RestTemplateUtils { |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | public JSONObject get(String url, Map<String, Object> queryParams) throws IOException { |
| | | return get(url, queryParams, new HashMap<>(1)); |
| | | } |
| | | |
| | | public JSONObject get(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException { |
| | | String tempUrl = setParamsByAppendUrl(queryParams, url); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headerParams.forEach(headers::add); |
| | | HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers); |
| | | ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class); |
| | | return JSONObject.parseObject(response.getBody()); |
| | | } |
| | | |
| | | public JSONObject get2(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException { |
| | | String tempUrl = setParamsByPath(queryParams, url); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headerParams.forEach(headers::add); |
| | | HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers); |
| | | ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class, queryParams); |
| | | return JSONObject.parseObject(response.getBody()); |
| | | } |
| | | |
| | | public JSONObject post(String url, String json, Map<String, String> headerParams) { |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headerParams.forEach(headers::add); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.add("Accept", MediaType.APPLICATION_JSON.toString()); |
| | | HttpEntity<String> httpEntity = new HttpEntity<>(json, headers); |
| | | ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | return JSONObject.parseObject(response.getBody()); |
| | | } |
| | | |
| | | private String setParamsByPath(Map<String, Object> queryParams, String url) { |
| | | // url?id={id}&name={name} |
| | | if (queryParams == null || queryParams.isEmpty()) { |
| | | return url; |
| | | } |
| | | StringBuilder sb = new StringBuilder(); |
| | | try { |
| | | for (Map.Entry<String, Object> entry : queryParams.entrySet()) { |
| | | sb.append("&").append(entry.getKey()).append("=").append("{").append(entry.getKey()).append("}"); |
| | | } |
| | | if (!url.contains("?")) { |
| | | sb.deleteCharAt(0).insert(0, "?"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return url + sb; |
| | | } |
| | | |
| | | private String setParamsByAppendUrl(Map<String, Object> queryParams, String url) { |
| | | // url?id=1&name=zzc |
| | | if (queryParams == null || queryParams.isEmpty()) { |
| | | return url; |
| | | } |
| | | StringBuilder sb = new StringBuilder(); |
| | | try { |
| | | for (Map.Entry<String, Object> entry : queryParams.entrySet()) { |
| | | sb.append("&").append(entry.getKey()).append("="); |
| | | sb.append(entry.getValue()); |
| | | } |
| | | if (!url.contains("?")) { |
| | | sb.deleteCharAt(0).insert(0, "?"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return url + sb; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.valve; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.pipIrrRemote.utils.RestTemplateUtils; |
| | | import com.dy.pipIrrRemote.valve.dto.DTOValve; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.ExecutionException; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.TimeoutException; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-07 14:59 |
| | | * @LastEditTime 2024-05-07 14:59 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "分水房管理", description = "分水房操作") |
| | | @RestController |
| | | @RequestMapping(path="valve") |
| | | @RequiredArgsConstructor |
| | | public class ValveCtrl { |
| | | private final RestTemplateUtils restTemplateUtils; |
| | | |
| | | private CompletableFuture<String> futureValue = new CompletableFuture<>(); |
| | | |
| | | /** |
| | | * 远程开关阀 |
| | | * @param po 开关阀传入对象 |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @Operation(summary = "远程开关阀", description = "远程开关阀") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "操作结果:true:成功,false:失败(BaseResponse.content)", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = Boolean.class))} |
| | | ) |
| | | }) |
| | | @PostMapping(path = "operate", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> open(@RequestBody @Valid DTOValve po, BindingResult bindingResult) throws ExecutionException, InterruptedException { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | String a = null; |
| | | try { |
| | | a = futureValue.get(10, TimeUnit.SECONDS); |
| | | } catch (TimeoutException e) { |
| | | return BaseResponseUtils.buildFail("1分钟后去查看结果"); |
| | | } |
| | | futureValue = new CompletableFuture<>(); |
| | | |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("controllerType", "01"); |
| | | param.put("projectNo", 100); |
| | | param.put("rtuNewAddr", "202405061656120001"); |
| | | |
| | | Map<String, Object> postParams = new HashMap<>(); |
| | | postParams.put("id", 2024050616450001L); |
| | | postParams.put("protocol", "p1"); |
| | | postParams.put("rtuAddr", "20001"); |
| | | postParams.put("type", "outerCommand"); |
| | | postParams.put("code", "10"); |
| | | postParams.put("noRtMwDealRes", false); |
| | | postParams.put("rtuResultSendWebUrl", "127.0.0.1/remote/"); |
| | | postParams.put("param", param); |
| | | |
| | | Map<String, String> headerParams = new HashMap<>(); |
| | | |
| | | JSONObject job_result = restTemplateUtils.post("http://localhost:8070/accMw/com/send", JSON.toJSONString(postParams), headerParams); |
| | | |
| | | return BaseResponseUtils.buildSuccess(a) ; |
| | | } |
| | | |
| | | @GetMapping("/setValue") |
| | | public String setValue(String name) { |
| | | futureValue.complete(name); |
| | | return "Value set"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.valve.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | import org.hibernate.validator.constraints.Range; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-05-07 15:05 |
| | | * @LastEditTime 2024-05-07 15:05 |
| | | * @Description 远程开阀、远程关阀传入对象 |
| | | */ |
| | | |
| | | @Data |
| | | @Schema(name = "开关阀传入对象") |
| | | public class DTOValve { |
| | | public static final long serialVersionUID = 202405071506001L; |
| | | |
| | | /** |
| | | * 取水口ID |
| | | */ |
| | | @Schema(description = "取水口ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @NotNull(message = "取水口不能为空") |
| | | private Long intakeId; |
| | | |
| | | /** |
| | | * 虚拟卡ID |
| | | */ |
| | | @Schema(description = "虚拟卡ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @NotNull(message = "虚拟卡不能为空") |
| | | private Long vcId; |
| | | |
| | | /** |
| | | * 操作类型,1-开阀,2-关阀 |
| | | */ |
| | | @Schema(description = "操作类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @NotNull(message = "操作类型不能为空") |
| | | @Range(min = 1, max = 2) |
| | | private Integer operateType; |
| | | |
| | | /** |
| | | * 操作人 |
| | | */ |
| | | @Schema(description = "操作人", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @NotNull(message = "操作人不能为空") |
| | | private Long operator; |
| | | } |
| | |
| | | management: |
| | | server: |
| | | port: ${pipIrr.remote.actutorPort} |
| | | #web服务端口,tomcat默认是8080 |
| | | #web服务端口,tomcat默认是8081 |
| | | server: |
| | | port: ${pipIrr.remote.webPort} |
| | | servlet: |
| | |
| | | |
| | | return restTemplate; |
| | | } |
| | | |
| | | //简单RestTemplate实例 |
| | | @Bean |
| | | public RestTemplate simpleRestTemplate() { |
| | | return new RestTemplate(); |
| | | } |
| | | } |