From d652d3939627ca588f6eabbb4d009a12bb43a51e Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期四, 23 五月 2024 08:50:01 +0800
Subject: [PATCH] 2024-05-23 朱宝民 远程模块测试
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java | 2
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/result/RemoteResultCode.java | 7
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/DtoBase.java | 28 ++
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/PipIrrRemoteApplication.java | 2
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml | 199 ++++++++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/Addr.java | 22 +
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java | 51 +++
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java | 116 ++++++++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java | 27 +
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java | 116 ++++++++
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml | 5
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrControllerMapper.java | 7
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java | 12
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/CommandResultCtrl.java | 29 ++
pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml | 8
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/test/CommandCtrl.java | 8
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/ComSupport.java | 143 ++++++++++
17 files changed, 765 insertions(+), 17 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrControllerMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrControllerMapper.java
index f9dbdc5..4c3f20a 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrControllerMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrControllerMapper.java
@@ -86,4 +86,11 @@
* @return
*/
Integer deleteIntakeId(@Param("controllerId") Long controllerId);
+
+ /**
+ * 鏍规嵁鍙栨按鍙D鑾峰彇闃�鎺у櫒鍦板潃
+ * @param intakeId 鍙栨按鍙D
+ * @return 闃�鎺у櫒鍦板潃
+ */
+ String getRtuAddrByIntakeId(Long intakeId);
}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java
new file mode 100644
index 0000000..9e104c3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java
@@ -0,0 +1,27 @@
+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);
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java
new file mode 100644
index 0000000..1baa9a3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java
@@ -0,0 +1,116 @@
+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;
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml
index 1c5ffbd..40f061c 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml
@@ -251,4 +251,9 @@
<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>
+
+ <!--鏍规嵁鍙栨按鍙D鑾峰彇闃�鎺у櫒鍦板潃-->
+ <select id="getRtuAddrByIntakeId" resultType="java.lang.String">
+ SELECT rtuAddr FROM pr_controller WHERE deleted = 0 AND intakeId = #{intakeId} LIMIT 0,1
+ </select>
</mapper>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml
new file mode 100644
index 0000000..37c0c6c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml
@@ -0,0 +1,199 @@
+<?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>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/test/CommandCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/test/CommandCtrl.java
index bd3c3b7..9be33c9 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/test/CommandCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/test/CommandCtrl.java
@@ -3,9 +3,10 @@
import com.dy.common.mw.protocol.p206V202404.CodeV202404;
import com.dy.common.mw.protocol.p206V202404.downVos.*;
import com.dy.common.webUtil.BaseResponse;
-import com.dy.common.webUtil.BaseResponseUtils;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
/**
* @Author: liurunyu
@@ -21,12 +22,13 @@
@GetMapping(path = "test")
public BaseResponse<String> test() {
//return this.connect() ;//杩炴帴閫氫俊涓棿浠舵祴璇�
- return this.cdXY(CodeV202404.cd_30) ;//鍙戦�佸浐瀹氬弬鏁癤Y鐨勫懡浠�
+ //return this.cdXY(CodeV202404.cd_30) ;//鍙戦�佸浐瀹氬弬鏁癤Y鐨勫懡浠�
//return this.cd55(1) ;
//return this.cd15() ;
//return this.cd16() ;
//return this.cd22() ;
//return this.cd31() ;
+ return this.cd10();
}
/**
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
index c4bd05d..b5fb236 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
@@ -244,4 +244,6 @@
String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
}
+
+
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java
index 090d07f..32ae257 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java
@@ -2,10 +2,6 @@
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;
@@ -13,24 +9,16 @@
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
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml
index 1363c26..a41ff4b 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml
@@ -2,6 +2,14 @@
<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>
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/PipIrrRemoteApplication.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/PipIrrRemoteApplication.java
index e5bb6de..54c73f5 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/PipIrrRemoteApplication.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/PipIrrRemoteApplication.java
@@ -18,7 +18,7 @@
})
}
)
-@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) {
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/ComSupport.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/ComSupport.java
new file mode 100644
index 0000000..ccba930
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/ComSupport.java
@@ -0,0 +1,143 @@
+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();
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java
new file mode 100644
index 0000000..4ce8d37
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java
@@ -0,0 +1,51 @@
+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;
+
+ /**
+ * 鏍规嵁鍙栨按鍙D鑾峰彇闃�鎺у櫒鍦板潃
+ * @param intakeId 鍙栨按鍙D
+ * @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);
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/result/RemoteResultCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/result/RemoteResultCode.java
index 1db000d..b6ccda8 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/result/RemoteResultCode.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/result/RemoteResultCode.java
@@ -17,7 +17,12 @@
*/
DIVIDE_FAIL(10001, "鍒嗘按鎴挎坊鍔犲け璐�"),
DELETE_DIVIDE_FAIL(10001, "鍒嗘按鎴垮垹闄ゅけ璐�"),
- NO_DIVIDES(10001, "鏃犵鍚堟潯浠剁殑鍒嗘按鎴胯褰�");
+ NO_DIVIDES(10001, "鏃犵鍚堟潯浠剁殑鍒嗘按鎴胯褰�"),
+
+ /**
+ * RTU
+ */
+ RTU_ADDR_CANNOT_BE_NULL(20001, "闃�鎺у櫒鍦板潃涓嶈兘涓虹┖");
private final Integer code;
private final String message;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/CommandResultCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/CommandResultCtrl.java
new file mode 100644
index 0000000..4e605a7
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/CommandResultCtrl.java
@@ -0,0 +1,29 @@
+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");
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java
new file mode 100644
index 0000000..32f9a91
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java
@@ -0,0 +1,116 @@
+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();
+
+ // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃
+ 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();
+
+ // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃
+ 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);
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/Addr.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/Addr.java
new file mode 100644
index 0000000..561d13a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/Addr.java
@@ -0,0 +1,22 @@
+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;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/DtoBase.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/DtoBase.java
new file mode 100644
index 0000000..6f05d1f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/DtoBase.java
@@ -0,0 +1,28 @@
+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;
+
+ /**
+ * 鍙栨按鍙D
+ */
+ @NotNull(message = "鍙栨按鍙d笉鑳戒负绌�")
+ private Long intakeId;
+
+ /**
+ * 鎿嶄綔浜�
+ */
+ @NotNull(message = "鎿嶄綔浜轰笉鑳戒负绌�")
+ private Long operator;
+}
--
Gitblit v1.8.0