From f5a7f6c30bc5fb13eb538b5856a663b1ba0667b6 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期一, 27 五月 2024 16:09:06 +0800 Subject: [PATCH] 2024-05-27 朱宝民 远程开关阀、RTU在线情况 --- pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardCtrl.java | 377 ++++++------ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java | 30 + pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/result/RemoteResultCode.java | 7 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java | 27 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java | 296 ++++++++-- pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaSettingsMapper.java | 35 + pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java | 17 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java | 73 ++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeVirtualCard.java | 16 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveOpen.java | 27 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java | 15 pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/enums/LastOperateENUM.java | 4 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/ComSupport.java | 79 ++ pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveClose.java | 46 + pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/DtoBase.java | 4 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 | 59 - pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardSv.java | 19 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmCommandHistoryMapper.java | 14 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeVirtualCardMapper.java | 27 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java | 32 pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml | 57 + pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaSettingsMapper.xml | 96 +++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrWaterPriceMapper.xml | 120 ++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrWaterPriceMapper.java | 33 + pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml | 6 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaSettings.java | 61 ++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrWaterPrice.java | 75 ++ pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/Addr.java | 4 29 files changed, 1,304 insertions(+), 354 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaSettingsMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaSettingsMapper.java new file mode 100644 index 0000000..ff3f969 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaSettingsMapper.java @@ -0,0 +1,35 @@ +package com.dy.pipIrrGlobal.daoBa; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dy.pipIrrGlobal.pojoBa.BaSettings; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @author ZhuBaoMin + * @date 2024-05-27 9:17 + * @LastEditTime 2024-05-27 9:17 + * @Description + */ + +@Mapper +public interface BaSettingsMapper extends BaseMapper<BaSettings> { + int deleteByPrimaryKey(Long id); + + int insert(BaSettings record); + + int insertSelective(BaSettings record); + + BaSettings selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(BaSettings record); + + int updateByPrimaryKey(BaSettings record); + + /** + * 鏍规嵁閰嶇疆椤硅幏鍙栭厤缃」鍊� + * @param itemName + * @return + */ + String getItemValue(@Param("itemName") String itemName); +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrWaterPriceMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrWaterPriceMapper.java new file mode 100644 index 0000000..8fc03db --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrWaterPriceMapper.java @@ -0,0 +1,33 @@ +package com.dy.pipIrrGlobal.daoPr; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dy.pipIrrGlobal.pojoPr.PrWaterPrice; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author ZhuBaoMin + * @date 2024-05-24 9:28 + * @LastEditTime 2024-05-24 9:28 + * @Description + */ + +@Mapper +public interface PrWaterPriceMapper extends BaseMapper<PrWaterPrice> { + int deleteByPrimaryKey(Long id); + + int insert(PrWaterPrice record); + + int insertSelective(PrWaterPrice record); + + PrWaterPrice selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(PrWaterPrice record); + + int updateByPrimaryKey(PrWaterPrice record); + + /** + * 鑾峰彇姘翠环 + * @return + */ + Double getPrice(); +} \ 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 index 9e104c3..e4db94c 100644 --- 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 @@ -2,12 +2,15 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; +import com.dy.pipIrrGlobal.voRm.VoUnclosedValve; import org.apache.ibatis.annotations.Mapper; + +import java.util.List; /** * @author ZhuBaoMin - * @date 2024-05-22 14:29 - * @LastEditTime 2024-05-22 14:29 + * @date 2024-05-24 10:46 + * @LastEditTime 2024-05-24 10:46 * @Description */ @@ -24,4 +27,11 @@ int updateByPrimaryKeySelective(RmCommandHistory record); int updateByPrimaryKey(RmCommandHistory record); + + /** + * 鏍规嵁鎿嶄綔鍛業D鑾峰彇鏈叧闃�璁板綍 + * @param operator 鎿嶄綔鍛業D + * @return 鏈叧闃�璁板綍 + */ + List<VoUnclosedValve> getUnclosedValves(Long operator); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeVirtualCardMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeVirtualCardMapper.java index d042d95..2ccecae 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeVirtualCardMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeVirtualCardMapper.java @@ -2,13 +2,16 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; +import com.dy.pipIrrGlobal.voSe.VoVirtualCard; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author ZhuBaoMin - * @date 2024-04-22 9:38 - * @LastEditTime 2024-04-22 9:38 + * @date 2024-05-23 16:44 + * @LastEditTime 2024-05-23 16:44 * @Description */ @@ -33,4 +36,24 @@ * @return 绗﹀悎鏉′欢璁板綍鏁� */ int getRecordCountByName(@Param("clientId") Long clientId, @Param("vcName") String vcName); + + /** + * 鑾峰彇鍏ㄩ儴铏氭嫙鍗� + * @return + */ + List<VoVirtualCard> getVCs(); + + /** + * 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞� + * @param vcId + * @return + */ + VoVirtualCard getVcById(@Param("vcId") Long vcId); + + /** + * 鏍规嵁铏氭嫙鍗$紪鍙疯幏鍙栬櫄鎷熷崱ID + * @param vcNum + * @return + */ + Long getVcIdByNum(@Param("vcNum") String vcNum); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaSettings.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaSettings.java new file mode 100644 index 0000000..6600891 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaSettings.java @@ -0,0 +1,61 @@ +package com.dy.pipIrrGlobal.pojoBa; + +/** + * @author ZhuBaoMin + * @date 2024-05-27 9:17 + * @LastEditTime 2024-05-27 9:17 + * @Description + */ + +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.dy.common.po.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.*; + +/** + * 绯荤粺閰嶇疆琛� + */ + +@TableName(value="ba_settings", autoResultMap = true) +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "绯荤粺閰嶇疆瀹炰綋") +public class BaSettings implements BaseEntity { + public static final long serialVersionUID = 202405271036001L; + + /** + * 涓婚敭 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @TableId(type = IdType.INPUT) + @Schema(description = "瀹炰綋id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Long id; + + /** + * 閰嶇疆椤� + */ + @Schema(description = "閰嶇疆椤�", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotBlank(message = "閰嶇疆椤逛笉鑳戒负绌�") + private String itemName; + + /** + * 閰嶇疆椤瑰�� + */ + @Schema(description = "閰嶇疆椤瑰��", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotBlank(message = "閰嶇疆椤瑰�间笉鑳戒负绌�") + private String itemValue; + + /** + * 澶囨敞淇℃伅 + */ + @Schema(description = "澶囨敞淇℃伅", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private String remarks; +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrWaterPrice.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrWaterPrice.java new file mode 100644 index 0000000..7a4eef4 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrWaterPrice.java @@ -0,0 +1,75 @@ +package com.dy.pipIrrGlobal.pojoPr; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.dy.common.po.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.*; + +import java.util.Date; + +/** + * @author ZhuBaoMin + * @date 2024-05-24 9:28 + * @LastEditTime 2024-05-24 9:28 + * @Description + */ +/** + * 姘翠环琛� + */ + +@TableName(value="pr_water_price", autoResultMap = true) +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "姘翠环瀹炰綋") +public class PrWaterPrice implements BaseEntity { + public static final long serialVersionUID = 202405240934001L; + + /** + * 涓婚敭 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @TableId(type = IdType.INPUT) + @Schema(description = "瀹炰綋id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Long id; + + /** + * 姘翠环 + */ + @Schema(description = "姘翠环", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "姘翠环涓嶈兘涓虹┖") + private Double price; + + /** + * 椤圭洰缂栧彿 + */ + @Schema(description = "椤圭洰缂栧彿", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Long projectId; + + /** + * 鎿嶄綔浜虹紪鍙� + */ + @Schema(description = "鎿嶄綔浜篒D", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "鎿嶄綔浜篒D涓嶈兘涓虹┖") + private Long operator; + + /** + * 鎿嶄綔鏃堕棿 + */ + @Schema(description = "鎿嶄綔鏃堕棿", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Date operateTime; + + /** + * 閫昏緫鍒犻櫎鏍囪瘑;0-鏈垹闄わ紝1-鍒犻櫎 + */ + @Schema(description = "鍒犻櫎鏍囪瘑", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Byte deleted; + +} \ 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 index 1baa9a3..6f97065 100644 --- 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 @@ -1,5 +1,12 @@ package com.dy.pipIrrGlobal.pojoRm; +/** + * @author ZhuBaoMin + * @date 2024-05-24 10:46 + * @LastEditTime 2024-05-24 10:46 + * @Description + */ + import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.writer.ObjectWriterImplToString; @@ -16,22 +23,15 @@ 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 class RmCommandHistory implements BaseEntity { public static final long serialVersionUID = 202401151517005L; /** @@ -64,18 +64,6 @@ */ @NotBlank(message = "閫氳鍗忚涓嶈兘涓虹┖") private String protocol; - - /** - * 鍛戒护绫诲瀷 - */ - @NotBlank(message = "鍛戒护绫诲瀷涓嶈兘涓虹┖") - private String commandType; - - /** - * 鍥炶皟URL - */ - @NotBlank(message = "鍥炶皟URL涓嶈兘涓虹┖") - private String callback; /** * 鍙傛暟鏁版嵁 diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeVirtualCard.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeVirtualCard.java index 442703b..5bb4a02 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeVirtualCard.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeVirtualCard.java @@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.*; @@ -17,9 +16,12 @@ /** * @author ZhuBaoMin - * @date 2024-03-05 20:45 - * @LastEditTime 2024-03-05 20:45 + * @date 2024-05-23 16:44 + * @LastEditTime 2024-05-23 16:44 * @Description + */ +/** + * 铏氭嫙鍗¤〃 */ @TableName(value="se_virtual_card", autoResultMap = true) @@ -41,11 +43,11 @@ private Long id; /** - * 铏氭嫙鍗″悕绉� + * 铏氭嫙鍗$紪鍙� */ - @Schema(description = "鍐滄埛ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @NotBlank(message = "铏氭嫙鍗″悕绉颁笉鑳戒负绌�") - private String vcName; + @Schema(description = "铏氭嫙鍗$紪鍙�", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "铏氭嫙鍗$紪鍙蜂笉鑳戒负绌�") + private Long vcNum; /** * 鍐滄埛ID diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java new file mode 100644 index 0000000..65dc623 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java @@ -0,0 +1,30 @@ +package com.dy.pipIrrGlobal.voRm; + +import com.dy.common.po.BaseEntity; +import lombok.Data; + +import java.util.Date; + +/** + * @author ZhuBaoMin + * @date 2024-05-24 16:30 + * @LastEditTime 2024-05-24 16:30 + * @Description 鏈叧闃�瀵硅薄瑙嗗浘 + */ + +@Data +public class VoUnclosedValve implements BaseEntity { + private static final long serialVersionUID = 202405241634001L; + + private String commandCode; + + private String intakeNum; + + private String rtuAddr; + + private String orderNo; + + private String vcNum; + + private Date openTime; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java new file mode 100644 index 0000000..6024046 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java @@ -0,0 +1,27 @@ +package com.dy.pipIrrGlobal.voSe; + +import com.dy.common.po.BaseEntity; +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-05-24 8:14 + * @LastEditTime 2024-05-24 8:14 + * @Description 铏氭嫙鍗¤鍥惧璞� + */ + +@Data +public class VoVirtualCard implements BaseEntity { + private static final long serialVersionUID = 202405240815001L; + + private String id; + + private String vcNum; + + private Double money; + + private Byte inUse; + + private String inUseName; + +} diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaSettingsMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaSettingsMapper.xml new file mode 100644 index 0000000..582ac92 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaSettingsMapper.xml @@ -0,0 +1,96 @@ +<?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.daoBa.BaSettingsMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaSettings"> + <!--@mbg.generated--> + <!--@Table ba_settings--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="item_name" jdbcType="VARCHAR" property="itemName" /> + <result column="item_value" jdbcType="VARCHAR" property="itemValue" /> + <result column="remarks" jdbcType="VARCHAR" property="remarks" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, item_name, item_value, remarks + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from ba_settings + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from ba_settings + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaSettings"> + <!--@mbg.generated--> + insert into ba_settings (id, item_name, item_value, + remarks) + values (#{id,jdbcType=BIGINT}, #{itemName,jdbcType=VARCHAR}, #{itemValue,jdbcType=VARCHAR}, + #{remarks,jdbcType=VARCHAR}) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaSettings"> + <!--@mbg.generated--> + insert into ba_settings + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="itemName != null"> + item_name, + </if> + <if test="itemValue != null"> + item_value, + </if> + <if test="remarks != null"> + remarks, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="itemName != null"> + #{itemName,jdbcType=VARCHAR}, + </if> + <if test="itemValue != null"> + #{itemValue,jdbcType=VARCHAR}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaSettings"> + <!--@mbg.generated--> + update ba_settings + <set> + <if test="itemName != null"> + item_name = #{itemName,jdbcType=VARCHAR}, + </if> + <if test="itemValue != null"> + item_value = #{itemValue,jdbcType=VARCHAR}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaSettings"> + <!--@mbg.generated--> + update ba_settings + set item_name = #{itemName,jdbcType=VARCHAR}, + item_value = #{itemValue,jdbcType=VARCHAR}, + remarks = #{remarks,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + </update> + + <!--鏍规嵁閰嶇疆椤硅幏鍙栭厤缃」鍊�--> + <select id="getItemValue" resultType="java.lang.String"> + SELECT IFNULL(item_value, '') AS itemValue FROM ba_settings WHERE item_name = #{itemName} LIMIT 0,1 + </select> +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrWaterPriceMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrWaterPriceMapper.xml new file mode 100644 index 0000000..c97eba4 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrWaterPriceMapper.xml @@ -0,0 +1,120 @@ +<?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.daoPr.PrWaterPriceMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrWaterPrice"> + <!--@mbg.generated--> + <!--@Table pr_water_price--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="price" jdbcType="FLOAT" property="price" /> + <result column="project_id" jdbcType="BIGINT" property="projectId" /> + <result column="operator" jdbcType="BIGINT" property="operator" /> + <result column="operate_time" jdbcType="TIMESTAMP" property="operateTime" /> + <result column="deleted" jdbcType="TINYINT" property="deleted" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, price, project_id, `operator`, operate_time, deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from pr_water_price + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from pr_water_price + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrWaterPrice"> + <!--@mbg.generated--> + insert into pr_water_price (id, price, project_id, + `operator`, operate_time, deleted + ) + values (#{id,jdbcType=BIGINT}, #{price,jdbcType=FLOAT}, #{projectId,jdbcType=BIGINT}, + #{operator,jdbcType=BIGINT}, #{operateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT} + ) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrWaterPrice"> + <!--@mbg.generated--> + insert into pr_water_price + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="price != null"> + price, + </if> + <if test="projectId != null"> + project_id, + </if> + <if test="operator != null"> + `operator`, + </if> + <if test="operateTime != null"> + operate_time, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="price != null"> + #{price,jdbcType=FLOAT}, + </if> + <if test="projectId != null"> + #{projectId,jdbcType=BIGINT}, + </if> + <if test="operator != null"> + #{operator,jdbcType=BIGINT}, + </if> + <if test="operateTime != null"> + #{operateTime,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrWaterPrice"> + <!--@mbg.generated--> + update pr_water_price + <set> + <if test="price != null"> + price = #{price,jdbcType=FLOAT}, + </if> + <if test="projectId != null"> + project_id = #{projectId,jdbcType=BIGINT}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operateTime != null"> + operate_time = #{operateTime,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=TINYINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrWaterPrice"> + <!--@mbg.generated--> + update pr_water_price + set price = #{price,jdbcType=FLOAT}, + project_id = #{projectId,jdbcType=BIGINT}, + `operator` = #{operator,jdbcType=BIGINT}, + operate_time = #{operateTime,jdbcType=TIMESTAMP}, + deleted = #{deleted,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + </update> + + <!--鑾峰彇姘翠环--> + <select id="getPrice" resultType="java.lang.Double"> + SELECT IFNULL(price,0.0) FROM pr_water_price WHERE deleted = 0 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 index 37c0c6c..f656fde 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml @@ -9,11 +9,7 @@ <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" /> @@ -22,8 +18,8 @@ </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 + id, command_code, command_name, rtuAddr, protocol, param, send_time, `operator`, + `result`, result_time, result_text </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <!--@mbg.generated--> @@ -40,15 +36,13 @@ <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) + rtuAddr, protocol, 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}) + #{rtuaddr,jdbcType=VARCHAR}, #{protocol,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--> @@ -68,12 +62,6 @@ </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, @@ -109,12 +97,6 @@ </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}, @@ -152,12 +134,6 @@ <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> @@ -186,8 +162,6 @@ 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}, @@ -196,4 +170,21 @@ result_text = #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} where id = #{id,jdbcType=BIGINT} </update> + + <!--鏍规嵁鎿嶄綔鍛業D鑾峰彇鏈叧闃�璁板綍--> + <select id="getUnclosedValves" resultType="com.dy.pipIrrGlobal.voRm.VoUnclosedValve"> + SELECT + com.command_code AS commandCode, + inta.name AS intakeNum, + com.rtuAddr, + com.param ->>'$.orderNo' AS orderNo, + com.param ->>'$.icCardNo' AS vcNum, + com.send_time AS openTime + FROM rm_command_history com + INNER JOIN pr_controller con ON com.rtuAddr = con.rtuAddr + INNER JOIN pr_intake inta ON con.intakeId = inta.id + WHERE (com.command_code = '92' OR com.command_code = 'A2') AND com.operator = #{operator} + AND NOT EXISTS (SELECT * FROM rm_command_history WHERE (command_code = '93' OR command_code = 'A3') AND param ->>'$.orderNo' = com.param ->>'$.orderNo') + ORDER BY com.send_time DESC + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml index c50fd4a..d0bfda8 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml @@ -5,7 +5,7 @@ <!--@mbg.generated--> <!--@Table se_virtual_card--> <id column="id" jdbcType="BIGINT" property="id" /> - <result column="vc_name" jdbcType="VARCHAR" property="vcName" /> + <result column="vc_num" jdbcType="BIGINT" property="vcNum" /> <result column="client_id" jdbcType="BIGINT" property="clientId" /> <result column="money" jdbcType="FLOAT" property="money" /> <result column="last_operate" jdbcType="TINYINT" property="lastOperate" /> @@ -15,7 +15,7 @@ </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> - id, vc_name, client_id, money, last_operate, last_operate_time, in_use, create_time + id, vc_num, client_id, money, last_operate, last_operate_time, in_use, create_time </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <!--@mbg.generated--> @@ -31,10 +31,10 @@ </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeVirtualCard"> <!--@mbg.generated--> - insert into se_virtual_card (id, vc_name, client_id, + insert into se_virtual_card (id, vc_num, client_id, money, last_operate, last_operate_time, in_use, create_time) - values (#{id,jdbcType=BIGINT}, #{vcName,jdbcType=VARCHAR}, #{clientId,jdbcType=BIGINT}, + values (#{id,jdbcType=BIGINT}, #{vcNum,jdbcType=BIGINT}, #{clientId,jdbcType=BIGINT}, #{money,jdbcType=FLOAT}, #{lastOperate,jdbcType=TINYINT}, #{lastOperateTime,jdbcType=TIMESTAMP}, #{inUse,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}) </insert> @@ -45,8 +45,8 @@ <if test="id != null"> id, </if> - <if test="vcName != null"> - vc_name, + <if test="vcNum != null"> + vc_num, </if> <if test="clientId != null"> client_id, @@ -71,8 +71,8 @@ <if test="id != null"> #{id,jdbcType=BIGINT}, </if> - <if test="vcName != null"> - #{vcName,jdbcType=VARCHAR}, + <if test="vcNum != null"> + #{vcNum,jdbcType=BIGINT}, </if> <if test="clientId != null"> #{clientId,jdbcType=BIGINT}, @@ -98,8 +98,8 @@ <!--@mbg.generated--> update se_virtual_card <set> - <if test="vcName != null"> - vc_name = #{vcName,jdbcType=VARCHAR}, + <if test="vcNum != null"> + vc_num = #{vcNum,jdbcType=BIGINT}, </if> <if test="clientId != null"> client_id = #{clientId,jdbcType=BIGINT}, @@ -125,7 +125,7 @@ <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeVirtualCard"> <!--@mbg.generated--> update se_virtual_card - set vc_name = #{vcName,jdbcType=VARCHAR}, + set vc_num = #{vcNum,jdbcType=BIGINT}, client_id = #{clientId,jdbcType=BIGINT}, money = #{money,jdbcType=FLOAT}, last_operate = #{lastOperate,jdbcType=TINYINT}, @@ -149,4 +149,39 @@ </if> </where> </select> + + <!--鑾峰彇鍏ㄩ儴铏氭嫙鍗�--> + <select id="getVCs" resultType="com.dy.pipIrrGlobal.voSe.VoVirtualCard"> + SELECT + CAST(id AS char) AS id, + vc_num AS vcNum, + money, + in_use AS inUse, + (CASE + WHEN in_use = 0 THEN "鏈娇鐢�" + WHEN in_use = 1 THEN "浣跨敤涓�" + END) AS inUseName + FROM se_virtual_card + ORDER BY in_use, money + </select> + + <!--鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞�--> + <select id="getVcById" resultType="com.dy.pipIrrGlobal.voSe.VoVirtualCard"> + SELECT + CAST(id AS char) AS id, + vc_num AS vcNum, + money, + in_use AS inUse, + (CASE + WHEN in_use = 0 THEN "鏈娇鐢�" + WHEN in_use = 1 THEN "浣跨敤涓�" + END) AS inUseName + FROM se_virtual_card + WHERE id = #{vcId} + </select> + + <!--鏍规嵁铏氭嫙鍗$紪鍙疯幏鍙栬櫄鎷熷崱ID--> + <select id="getVcIdByNum" resultType="java.lang.Long"> + SELECT id FROM se_virtual_card WHERE vc_num = #{vcNum} + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml index a41ff4b..4bd9060 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/pom.xml @@ -9,6 +9,12 @@ <version>1.0.0</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>com.dy</groupId> + <artifactId>pipIrr-web-sell</artifactId> + <version>1.0.0</version> + <scope>compile</scope> + </dependency> </dependencies> <parent> 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 54c73f5..37c766b 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.daoRm", "com.dy.pipIrrGlobal.daoPr"}) +@MapperScan(basePackages={"com.dy.pipIrrGlobal.daoRm", "com.dy.pipIrrGlobal.daoPr", "com.dy.pipIrrGlobal.daoSe", "com.dy.pipIrrGlobal.daoBa"}) 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 index ccba930..7994a33 100644 --- 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 @@ -4,20 +4,32 @@ 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.Data; 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.common.webUtil.BaseResponseUtils; +import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper; import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; +import com.dy.pipIrrRemote.result.RemoteResultCode; +import jakarta.annotation.PostConstruct; 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.Component; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; /** * @author ZhuBaoMin @@ -25,7 +37,8 @@ * @LastEditTime 2024-05-21 15:30 * @Description */ -//@RequiredArgsConstructor + +@Component public class ComSupport { //@NotNull //private final CommandSv commandSv; @@ -37,17 +50,44 @@ 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 Integer projectNo = 100 ;//椤圭洰缂栫爜 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; + + // 瀛樺偍瀹炰緥鍖栫殑 CompletableFuture<Data> 瀵硅薄 + protected static Map<String, Object> features = new HashMap<>(); + protected static Boolean setuped = false; @Autowired private RestTemplate restTemplate; + + @Autowired + private BaSettingsMapper baSettingsMapper; + public static ComSupport comSupport; + + /** + * 寮曞叆BaSettingsMapper + */ + @PostConstruct + public void init() { + comSupport = this; + comSupport.baSettingsMapper = this.baSettingsMapper; + } + + /** + * 鑾峰彇绯荤粺閰嶇疆鍙傛暟 + */ + public void setUp() { + protocolName = comSupport.baSettingsMapper.getItemValue("protocolName"); + controllerType = comSupport.baSettingsMapper.getItemValue("controllerType"); + projectNo = Integer.parseInt(comSupport.baSettingsMapper.getItemValue("projectNo")); + setuped = true; + } protected ComCdXyVo comCdXyVo(){ ComCdXyVo comVo = new ComCdXyVo() ; @@ -70,8 +110,6 @@ 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); @@ -99,6 +137,36 @@ com.param = param ; return com ; + } + + /** + * 澶勭悊鍥炶皟鍐呭 + * @param comId + * @return + */ + protected BaseResponse<Data> dealWithCallBack(String comId) { + CompletableFuture<Data> featureObject = new CompletableFuture<>(); + features.put(comId, featureObject); + try { + CompletableFuture<Data> feature = (CompletableFuture<Data>) features.get(comId); + System.out.println("receive result ID:" + comId); + Data resultData = feature.get(30, TimeUnit.SECONDS); + features.remove(comId); + String commandId = resultData.getCommandId(); + if(commandId.equals(comId)) { + return BaseResponseUtils.buildSuccess(resultData); + }else { + return BaseResponseUtils.buildSuccess(); + } + } catch (InterruptedException e) { + e.printStackTrace(); + return BaseResponseUtils.buildFail(RemoteResultCode.GET_RESULT_ERROR.getMessage()); + } catch (ExecutionException e) { + e.printStackTrace(); + return BaseResponseUtils.buildFail(RemoteResultCode.GET_RESULT_ERROR.getMessage()); + } catch (TimeoutException e) { + return BaseResponseUtils.buildFail(RemoteResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage()); + } } /** @@ -140,4 +208,5 @@ } return response.getBody(); } + } 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/common/CommandResultCtrl.java similarity index 66% rename from pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/CommandResultCtrl.java rename to pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java index 4e605a7..1ef8c8d 100644 --- 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/common/CommandResultCtrl.java @@ -1,4 +1,4 @@ -package com.dy.pipIrrRemote.rtu; +package com.dy.pipIrrRemote.common; import com.dy.common.mw.protocol.Data; import com.dy.common.webUtil.BaseResponse; @@ -10,6 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.concurrent.CompletableFuture; + /** * @author ZhuBaoMin * @date 2024-05-23 8:19 @@ -20,10 +22,17 @@ @Slf4j @RestController @RequestMapping(path="comRes") -public class CommandResultCtrl { +public class CommandResultCtrl extends ComSupport { @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE) public BaseResponse<String> receive(@RequestBody Data data) { - log.info(data.toString()) ; + String comId = "0"; + if(data.getCommandId() != null) { + comId = data.getCommandId(); + } + CompletableFuture<Data> feature = (CompletableFuture<Data>) features.get(comId); + if(feature != null) { + feature.complete(data); + } return BaseResponseUtils.buildSuccess("ok"); } } 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 index 4ce8d37..efd5f6c 100644 --- 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 @@ -2,10 +2,14 @@ import com.dy.pipIrrGlobal.daoPr.PrControllerMapper; import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; +import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper; import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; +import com.dy.pipIrrGlobal.voRm.VoUnclosedValve; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; + +import java.util.List; /** * @author ZhuBaoMin @@ -20,6 +24,7 @@ public class CommandSv { private final RmCommandHistoryMapper rmCommandHistoryMapper; private final PrControllerMapper prControllerMapper; + private final SeVirtualCardMapper seVirtualCardMapper; /** * 鏍规嵁鍙栨按鍙D鑾峰彇闃�鎺у櫒鍦板潃 @@ -48,4 +53,16 @@ public Integer update(RmCommandHistory po) { return rmCommandHistoryMapper.updateByPrimaryKeySelective(po); } + + + /** + * 鏍规嵁鎿嶄綔鍛業D鑾峰彇鏈叧闃�璁板綍 + * @param operator + * @return + */ + public List<VoUnclosedValve> getUnclosedValves(Long operator) { + return rmCommandHistoryMapper.getUnclosedValves(operator); + } + + } 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/common/dto/Addr.java similarity index 80% rename from pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/Addr.java rename to pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/Addr.java index 561d13a..75e4a76 100644 --- 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/common/dto/Addr.java @@ -1,4 +1,4 @@ -package com.dy.pipIrrRemote.rtu.dto; +package com.dy.pipIrrRemote.common.dto; import jakarta.validation.constraints.NotBlank; import lombok.Data; @@ -7,7 +7,7 @@ * @author ZhuBaoMin * @date 2024-05-22 16:56 * @LastEditTime 2024-05-22 16:56 - * @Description + * @Description 璁剧疆鍛戒护瀛愮被-璁剧疆璁惧缁堢鍦板潃 */ @Data 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/common/dto/DtoBase.java similarity index 86% rename from pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/dto/DtoBase.java rename to pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/DtoBase.java index 6f05d1f..347169c 100644 --- 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/common/dto/DtoBase.java @@ -1,4 +1,4 @@ -package com.dy.pipIrrRemote.rtu.dto; +package com.dy.pipIrrRemote.common.dto; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -7,7 +7,7 @@ * @author ZhuBaoMin * @date 2024-05-22 16:54 * @LastEditTime 2024-05-22 16:54 - * @Description + * @Description 璁剧疆鍛戒护鍩虹被 */ @Data diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveClose.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveClose.java new file mode 100644 index 0000000..2693079 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveClose.java @@ -0,0 +1,46 @@ +package com.dy.pipIrrRemote.common.dto; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-05-24 17:25 + * @LastEditTime 2024-05-24 17:25 + * @Description 璁剧疆鍛戒护瀛愮被-杩滅▼鍏抽榾浼犺緭瀵硅薄 + */ + +@Data +public class ValveClose { + public static final long serialVersionUID = 202405241727001L; + + /** + * 闃�鎺у櫒鍦板潃 + */ + @NotBlank(message = "闃�鎺у櫒鍦板潃涓嶈兘涓虹┖") + private String rtuAddr; + /** + * 铏氭嫙鍗$紪鍙� + */ + @NotBlank(message = "铏氭嫙鍗$紪鍙蜂笉鑳戒负绌�") + private String vcNum; + + /** + * 寮�闃�鏃剁敓鎴愮殑璁㈠崟鍙� + */ + @NotBlank(message = "璁㈠崟鍙蜂笉鑳戒负绌�") + private String orderNo; + + /** + * 鐢ㄦ埛绫诲瀷 1-骞冲彴锛�2-APP + */ + @NotNull(message = "鎿嶄綔绫诲瀷涓嶈兘涓虹┖") + private Integer userType; + + /** + * 鎿嶄綔浜� + */ + @NotNull(message = "鎿嶄綔浜轰笉鑳戒负绌�") + private Long operator; +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveOpen.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveOpen.java new file mode 100644 index 0000000..2074ba3 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/ValveOpen.java @@ -0,0 +1,27 @@ +package com.dy.pipIrrRemote.common.dto; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-05-23 15:30 + * @LastEditTime 2024-05-23 15:30 + * @Description 璁剧疆鍛戒护瀛愮被-杩滅▼寮�闃�浼犺緭瀵硅薄 + */ + +@Data +public class ValveOpen extends DtoBase{ + public static final long serialVersionUID = 202405231531001L; + + /** + * 铏氭嫙鍗D + */ + private Long vcId; + + /** + * 鐢ㄦ埛绫诲瀷 1-骞冲彴锛�2-APP + */ + @NotNull(message = "鎿嶄綔绫诲瀷涓嶈兘涓虹┖") + private Integer userType; +} 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 b6ccda8..7977415 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 @@ -13,11 +13,10 @@ @AllArgsConstructor public enum RemoteResultCode { /** - * 杩滅▼鎿嶄綔 + * Valve */ - DIVIDE_FAIL(10001, "鍒嗘按鎴挎坊鍔犲け璐�"), - DELETE_DIVIDE_FAIL(10001, "鍒嗘按鎴垮垹闄ゅけ璐�"), - NO_DIVIDES(10001, "鏃犵鍚堟潯浠剁殑鍒嗘按鎴胯褰�"), + GET_RESULT_IN_ONE_MINUTE(10001,"1鍒嗛挓鍚庡幓鏌ョ湅缁撴灉"), + GET_RESULT_ERROR(10002, "鑾峰彇缁撴灉寮傚父"), /** * RTU 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 index 32f9a91..b550305 100644 --- 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 @@ -1,7 +1,10 @@ package com.dy.pipIrrRemote.rtu; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.dy.common.aop.SsoAop; import com.dy.common.mw.protocol.Command; +import com.dy.common.mw.protocol.Data; 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; @@ -10,21 +13,22 @@ import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; import com.dy.pipIrrRemote.common.ComSupport; import com.dy.pipIrrRemote.common.CommandSv; +import com.dy.pipIrrRemote.common.dto.Addr; +import com.dy.pipIrrRemote.common.dto.DtoBase; 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 org.springframework.web.bind.annotation.*; 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 @@ -43,6 +47,24 @@ protected static String controllerType = "57"; /** + * 鏌ヨ鎵�鏈塕TU鍦ㄧ嚎鎯呭喌 + * @return + */ + @GetMapping(path = "get_online") + @SsoAop() + public BaseResponse<Boolean> get_online() { + Command com = new Command() ; + com.id = Command.defaultId; + com.code = "LCD0001"; + com.type = "innerCommand"; + + JSONObject response = (JSONObject)JSON.toJSON(sendCom2Mw(com)); + JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment"); + + return BaseResponseUtils.buildSuccess(attachment) ; + } + + /** * 璁剧疆璁惧缁堢鍦板潃 * @param addr 璁剧疆璁惧缁堢鍦板潃浼犲叆瀵硅薄 * @param bindingResult @@ -56,10 +78,10 @@ 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(); + String commandCode = CodeV202404.cd_10; // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃 String rtuAddr = commandSv.getRtuAddrByIntakeId(intakeId); @@ -70,18 +92,49 @@ // 鍒涘缓瑙嗗浘 ComCd10Vo param = new ComCd10Vo() ; param.controllerType = controllerType; - param.projectNo = Integer.parseInt(commandCode); + param.projectNo =projectNo; param.rtuNewAddr = newRtuAddr; // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); String comId = commandSv.insert(rmCommandHistory); + System.out.println(comId); // 鏋勯�犲懡浠� Command com = command(comId, commandCode, rtuAddr, param); - return sendCom2Mw(com); + sendCom2Mw(com); + + CompletableFuture<Data> featureObject = new CompletableFuture<>(); + features.put(comId, featureObject); + try { + CompletableFuture<Data> feature = (CompletableFuture<Data>) features.get(comId); + Data resultData = feature.get(30, TimeUnit.SECONDS); + features.remove(comId); + String commandId = resultData.getCommandId(); + if(commandId.equals(comId)) { + //futureValue = new CompletableFuture<>(); + return BaseResponseUtils.buildSuccess((JSONObject)JSON.toJSON(resultData.subData)); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } catch (TimeoutException e) { + return BaseResponseUtils.buildFail("1鍒嗛挓鍚庡幓鏌ョ湅缁撴灉"); + } + + + //return BaseResponseUtils.buildSuccess(resultData.toJson()); + + return BaseResponseUtils.buildSuccess() ; } + /** + * 娓呴櫎璁惧缁堢鐢ㄦ按璁板綍 + * @param po + * @param bindingResult + * @return + */ @PostMapping(path = "clear_usage_record", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() @@ -103,7 +156,7 @@ // 鍒涘缓瑙嗗浘 ComCdXyVo param = new ComCdXyVo(); param.controllerType = controllerType; - param.projectNo = Integer.parseInt(commandCode); + param.projectNo = projectNo; // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java index e986f2e..b2af522 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java @@ -1,18 +1,27 @@ 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.mw.protocol.Command; +import com.dy.common.mw.protocol.Data; +import com.dy.common.mw.protocol.p206V202404.CodeV202404; +import com.dy.common.mw.protocol.p206V202404.downVos.ComCd92_A2Vo; +import com.dy.common.mw.protocol.p206V202404.downVos.ComCd93_A3Vo; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; -import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper; +import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper; +import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper; +import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory; +import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; +import com.dy.pipIrrGlobal.voRm.VoUnclosedValve; +import com.dy.pipIrrGlobal.voSe.VoVirtualCard; +import com.dy.pipIrrRemote.common.ComSupport; +import com.dy.pipIrrRemote.common.CommandSv; +import com.dy.pipIrrRemote.common.dto.ValveClose; +import com.dy.pipIrrRemote.common.dto.ValveOpen; +import com.dy.pipIrrRemote.result.RemoteResultCode; 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 com.dy.pipIrrSell.virtualCard.enums.LastOperateENUM; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -22,13 +31,12 @@ import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; -import java.util.HashMap; -import java.util.Map; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.List; import java.util.Objects; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; +import java.util.Random; /** * @author ZhuBaoMin @@ -42,67 +50,241 @@ @RestController @RequestMapping(path="valve") @RequiredArgsConstructor -public class ValveCtrl { +public class ValveCtrl extends ComSupport { private final RestTemplateUtils restTemplateUtils; - - private CompletableFuture<String> futureValue = new CompletableFuture<>(); + private final CommandSv commandSv; + private final SeVirtualCardMapper seVirtualCardMapper; + private final PrWaterPriceMapper prWaterPriceMapper; + private final RmCommandHistoryMapper rmCommandHistoryMapper; /** - * 杩滅▼寮�鍏抽榾 - * @param po 寮�鍏抽榾浼犲叆瀵硅薄 + * 杩滅▼寮�闃�锛堝钩鍙般�丄PP锛� + * @param valve * @param bindingResult * @return */ - @Operation(summary = "杩滅▼寮�鍏抽榾", description = "杩滅▼寮�鍏抽榾") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) - @PostMapping(path = "operate", consumes = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(path = "open", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> open(@RequestBody @Valid DTOValve po, BindingResult bindingResult) throws ExecutionException, InterruptedException { + public BaseResponse<Boolean> open(@RequestBody @Valid ValveOpen valve, BindingResult bindingResult) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyMMddHHmmss"); 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鍒嗛挓鍚庡幓鏌ョ湅缁撴灉"); + Long intakeId = valve.getIntakeId(); + Long vcId = valve.getVcId(); + Integer userType = valve.getUserType(); + Long operator = valve.getOperator(); + String comId = null; + + // 鑾峰彇绯荤粺鍙傛暟 + if(!setuped) { + setUp(); } - futureValue = new CompletableFuture<>(); - Map<String, Object> param = new HashMap<>(); - param.put("controllerType", "01"); - param.put("projectNo", 100); - param.put("rtuNewAddr", "202405061656120001"); + // 铏氭嫙鍗D鎹㈣櫄鎷熷崱瀵硅薄 + VoVirtualCard vc = seVirtualCardMapper.getVcById(vcId); + // 鑾峰彇姘翠环 + Double waterPrice = prWaterPriceMapper.getPrice(); - 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); + // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃 + String rtuAddr = commandSv.getRtuAddrByIntakeId(intakeId); + if(rtuAddr == null || rtuAddr.length() == 0) { + return BaseResponseUtils.buildError(RemoteResultCode.RTU_ADDR_CANNOT_BE_NULL.getMessage()); + } - Map<String, String> headerParams = new HashMap<>(); + // 鐢熸垚璁㈠崟鍙� + LocalDateTime dateTime = LocalDateTime.now(); + Random random = new Random(); + String CHARACTERS = "0123456789"; + StringBuilder sb = new StringBuilder(4); + for (int i = 0; i < 4; i++) { + int index = random.nextInt(CHARACTERS.length()); + sb.append(CHARACTERS.charAt(index)); + } + String orderNo = dtf.format(dateTime) + sb.toString(); - JSONObject job_result = restTemplateUtils.post("http://localhost:8070/accMw/com/send", JSON.toJSONString(postParams), headerParams); + String commandCode = null; + if(protocolName.equals("p206V202404")) { + // 鑾峰彇鍔熻兘鐮� + if(userType == 1) { + // 骞冲彴寮�闃� + commandCode = CodeV202404.cd_92; + }else { + // APP寮�闃� + commandCode = CodeV202404.cd_A2; + } - return BaseResponseUtils.buildSuccess(a) ; + // 鍒涘缓瑙嗗浘 + ComCd92_A2Vo param = new ComCd92_A2Vo(); + param.controllerType = controllerType; + param.projectNo = projectNo; + param.icCardNo = vc.getVcNum(); + param.waterRemain = 0.0; + param.moneyRemain = vc.getMoney(); + param.waterPrice = waterPrice; + param.elePrice = 0.0; + param.orderNo = orderNo; + + // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 + RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); + comId = commandSv.insert(rmCommandHistory); + + // 鏋勯�犲苟鍙戦�佸懡浠� + Command com = command(comId, commandCode, rtuAddr, param); + sendCom2Mw(com); + } else { + // 鑾峰彇鍔熻兘鐮� + if(userType == 1) { + // 骞冲彴寮�闃� + commandCode = "92"; + }else { + // APP寮�闃� + commandCode = "97"; + } + + // 鍒涘缓瑙嗗浘 + ComCd92_A2Vo param = new ComCd92_A2Vo(); + + // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 + RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); + comId = commandSv.insert(rmCommandHistory); + + // 鏋勯�犲苟鍙戦�佸懡浠� + Command com = command(comId, commandCode, rtuAddr, param); + sendCom2Mw(com); + } + + // 澶勭悊鍥炶皟 + BaseResponse response = dealWithCallBack(comId); + if(!response.getCode().equals("0001")) { + return BaseResponseUtils.buildError(RemoteResultCode.GET_RESULT_ERROR.getMessage()); + } + + // 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� + SeVirtualCard virtualCard = new SeVirtualCard(); + virtualCard.setId(vcId); + virtualCard.setInUse((byte) 1); + virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode()); + virtualCard.setLastOperateTime(new Date()); + seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + + Data myData = (Data)response.getContent(); + return BaseResponseUtils.buildSuccess(myData) ; } - @GetMapping("/setValue") - public String setValue(String name) { - futureValue.complete(name); - return "Value set"; + /** + * 杩滅▼鍏抽榾锛堝钩鍙般�丄PP锛� + * @param valve + * @param bindingResult + * @return + */ + @PostMapping(path = "close", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> close(@RequestBody @Valid ValveClose valve, BindingResult bindingResult) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyMMddHHmmss"); + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + String rtuAddr = valve.getRtuAddr(); + String vcNum = valve.getVcNum(); + String orderNo = valve.getOrderNo(); + Integer userType = valve.getUserType(); + Long operator = valve.getOperator(); + String comId = null; + + // 鑾峰彇绯荤粺鍙傛暟 + if(!setuped) { + setUp(); + } + + String commandCode = null; + if(protocolName.equals("p206V202404")) { + // 鑾峰彇鍔熻兘鐮� + if (userType == 1) { + // 骞冲彴鍏抽榾 + commandCode = CodeV202404.cd_93; + } else { + // APP鍏抽榾 + commandCode = CodeV202404.cd_A3; + } + + // 鍒涘缓瑙嗗浘 + ComCd93_A3Vo param = new ComCd93_A3Vo(); + param.controllerType = controllerType; + param.projectNo = projectNo; + param.icCardNo = vcNum; + param.orderNo = orderNo; + + // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 + RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); + comId = commandSv.insert(rmCommandHistory); + + // 鏋勯�犲苟鍙戦�佸懡浠� + Command com = command(comId, commandCode, rtuAddr, param); + sendCom2Mw(com); + } else { + // 鑾峰彇鍔熻兘鐮� + if (userType == 1) { + // 骞冲彴鍏抽榾 + commandCode = "93"; + } else { + // APP鍏抽榾 + commandCode = "98"; + } + + // 鍒涘缓瑙嗗浘 + ComCd93_A3Vo param = new ComCd93_A3Vo(); + param.controllerType = controllerType; + param.projectNo = projectNo; + param.icCardNo = vcNum; + param.orderNo = orderNo; + + // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 + RmCommandHistory rmCommandHistory = getComHistory(commandCode, rtuAddr, param, operator); + comId = commandSv.insert(rmCommandHistory); + + // 鏋勯�犲苟鍙戦�佸懡浠� + Command com = command(comId, commandCode, rtuAddr, param); + sendCom2Mw(com); + } + + // 澶勭悊鍥炶皟 + BaseResponse response = dealWithCallBack(comId); + if(!response.getCode().equals("0001")) { + return BaseResponseUtils.buildError(RemoteResultCode.GET_RESULT_ERROR.getMessage()); + } + + // 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� + Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum); + SeVirtualCard virtualCard = new SeVirtualCard(); + virtualCard.setId(vcId); + virtualCard.setInUse((byte) 0); + virtualCard.setLastOperate(LastOperateENUM.CLOSE_VALVE.getCode()); + virtualCard.setLastOperateTime(new Date()); + seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard); + + Data myData = (Data)response.getContent(); + return BaseResponseUtils.buildSuccess(myData) ; + } + + /** + * 鏍规嵁鎿嶄綔鍛業D鑾峰彇鏈叧闃�璁板綍 + * @param operator + * @return + */ + @GetMapping(path = "/get") + @SsoAop() + public BaseResponse<List<VoUnclosedValve>> getUnclosedValves(@RequestParam Long operator){ + try { + List<VoUnclosedValve> res = rmCommandHistoryMapper.getUnclosedValves(operator); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇鏈叧闃�璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardCtrl.java index a1c8156..22f2cca 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardCtrl.java @@ -1,52 +1,17 @@ package com.dy.pipIrrSell.virtualCard; -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; -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.pipIrrGlobal.pojoSe.SeVcRefund; -import com.dy.pipIrrGlobal.pojoSe.SeVcRefundItem; -import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; -import com.dy.pipIrrSell.result.SellResultCode; +import com.dy.pipIrrGlobal.voSe.VoVirtualCard; import com.dy.pipIrrSell.util.PayHelper; -import com.dy.pipIrrSell.virtualCard.dto.DtoAudit; -import com.dy.pipIrrSell.virtualCard.dto.DtoRefund; -import com.dy.pipIrrSell.virtualCard.dto.DtoRegist; -import com.dy.pipIrrSell.virtualCard.enums.LastOperateENUM; -import com.dy.pipIrrSell.virtualCard.enums.RefundItemStateENUM; -import com.dy.pipIrrSell.virtualCard.enums.RefundStateENUM; -import com.dy.pipIrrSell.wechatpay.dto.Refund; -import com.dy.pipIrrSell.wechatpay.dto.ToRefund; -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.validation.annotation.Validated; -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 org.springframework.web.bind.annotation.*; -import javax.crypto.NoSuchPaddingException; -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.SignatureException; -import java.security.spec.InvalidKeySpecException; -import java.util.Date; import java.util.List; -import java.util.Objects; /** * @author ZhuBaoMin @@ -66,51 +31,81 @@ private final PayHelper payHelper; /** + * 鑾峰彇鍏ㄩ儴铏氭嫙鍗� + * @return + */ + @GetMapping(path = "/get") + @SsoAop() + public BaseResponse<List<VoVirtualCard>> getVCs(){ + try { + List<VoVirtualCard> res = virtualCardSv.getVCs(); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞� + * @param vcId + * @return + */ + @GetMapping(path = "/getVcById") + @SsoAop() + public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){ + try { + return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId)); + } catch (Exception e) { + log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** * 铏氭嫙鍗¤处鍙锋敞鍐� * @param po * @param bindingResult * @return */ - @Operation(summary = "娉ㄥ唽铏氭嫙鍗�", description = "娉ㄥ唽铏氭嫙鍗�") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) - @PostMapping(path = "add_vc") - @SsoAop() - //public BaseResponse<Boolean> addVC(@RequestParam("clientId") @NotNull(message = "鍐滄埛缂栧彿涓嶈兘涓虹┖") Long clientId){ - public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult){ - if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); - } - Long clientId = po.getClientId(); - String vcName = po.getVcName(); - - // 鍚嶇О楠岄噸 - Integer rc = virtualCardSv.getRecordCountByName(po); - if(rc != null && rc > 0) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NAME_ESIST.getMessage()); - } - - SeVirtualCard seVirtualCard = new SeVirtualCard(); - seVirtualCard.setVcName(vcName); - seVirtualCard.setClientId(clientId); - seVirtualCard.setMoney(0d); - seVirtualCard.setLastOperate(LastOperateENUM.OPEN_ACCOUNT.getCode()); - seVirtualCard.setLastOperateTime(new Date()); - seVirtualCard.setInUse((byte) 0); - seVirtualCard.setCreateTime(new Date()); - Long rec = virtualCardSv.insertVirtualCard(seVirtualCard); - if(rec == null) { - return BaseResponseUtils.buildFail(SellResultCode.WALLET_OPEN_ACCOUNT_FAIL.getMessage()); - } - return BaseResponseUtils.buildSuccess(true) ; - } - + //@Operation(summary = "娉ㄥ唽铏氭嫙鍗�", description = "娉ㄥ唽铏氭嫙鍗�") + //@ApiResponses(value = { + // @ApiResponse( + // responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + // description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + // content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + // schema = @Schema(implementation = Boolean.class))} + // ) + //}) + //@PostMapping(path = "add_vc") + //@SsoAop() + //public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult){ + // if(bindingResult != null && bindingResult.hasErrors()){ + // return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + // } + // Long clientId = po.getClientId(); + // String vcName = po.getVcName(); + // + // // 鍚嶇О楠岄噸 + // Integer rc = virtualCardSv.getRecordCountByName(po); + // if(rc != null && rc > 0) { + // return BaseResponseUtils.buildFail(SellResultCode.CARD_NAME_ESIST.getMessage()); + // } + // + // SeVirtualCard seVirtualCard = new SeVirtualCard(); + // seVirtualCard.setVcName(vcName); + // seVirtualCard.setClientId(clientId); + // seVirtualCard.setMoney(0d); + // seVirtualCard.setLastOperate(LastOperateENUM.OPEN_ACCOUNT.getCode()); + // seVirtualCard.setLastOperateTime(new Date()); + // seVirtualCard.setInUse((byte) 0); + // seVirtualCard.setCreateTime(new Date()); + // Long rec = virtualCardSv.insertVirtualCard(seVirtualCard); + // if(rec == null) { + // return BaseResponseUtils.buildFail(SellResultCode.WALLET_OPEN_ACCOUNT_FAIL.getMessage()); + // } + // return BaseResponseUtils.buildSuccess(true) ; + //} /** * 鐢ㄦ埛鐢宠閫�娆� @@ -118,57 +113,57 @@ * @param bindingResult * @return */ - @Operation(summary = "铏氭嫙鍗$敵璇烽��娆�", description = "铏氭嫙鍗$敵璇烽��娆�") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) - @PostMapping(path = "add_refund", consumes = MediaType.APPLICATION_JSON_VALUE) - @Transactional(rollbackFor = Exception.class) - @SsoAop() - public BaseResponse<Boolean> addRefund(@RequestBody @Valid DtoRefund po, BindingResult bindingResult){ - if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); - } - - Long virtualId = po.getVirtualId(); - Integer refundAmount = po.getRefundAmount(); - - // 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞� - SeVirtualCard seVirtualCard = virtualCardSv.selectVirtuCardById(virtualId); - if(seVirtualCard == null) { - return BaseResponseUtils.buildFail(SellResultCode.VIRTUAL_CARD_NOT_EXIST.getMessage()); - } - Long clientId = seVirtualCard.getClientId(); - Double money = seVirtualCard.getMoney(); - - // 楠岃瘉閫�娆鹃噾棰濇槸鍚﹀ぇ浜庝綑棰� - if(refundAmount > money) { - return BaseResponseUtils.buildFail(SellResultCode.REFUND_AMOUNT_CANNOT_GREATER_THAN_MONEY.getMessage()); - } - - // 璁$畻娑堣垂鍚庝綑棰� - Double afterRefund = money - refundAmount; - - SeVcRefund seVcRefund = new SeVcRefund(); - seVcRefund.setVcId(virtualId); - seVcRefund.setClientId(clientId); - seVcRefund.setMoney(money); - seVcRefund.setRefundAmount(refundAmount); - seVcRefund.setAfterRefund(afterRefund); - seVcRefund.setApplicationTime(new Date()); - seVcRefund.setRefundStatus(RefundStateENUM.TO_AUDIT.getCode()); - - Long rec = virtualCardSv.addRefund(seVcRefund); - if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.APPLICATION_REFUND_FAIL.getMessage()); - } - return BaseResponseUtils.buildSuccess(true) ; - } + //@Operation(summary = "铏氭嫙鍗$敵璇烽��娆�", description = "铏氭嫙鍗$敵璇烽��娆�") + //@ApiResponses(value = { + // @ApiResponse( + // responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + // description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + // content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + // schema = @Schema(implementation = Boolean.class))} + // ) + //}) + //@PostMapping(path = "add_refund", consumes = MediaType.APPLICATION_JSON_VALUE) + //@Transactional(rollbackFor = Exception.class) + //@SsoAop() + //public BaseResponse<Boolean> addRefund(@RequestBody @Valid DtoRefund po, BindingResult bindingResult){ + // if(bindingResult != null && bindingResult.hasErrors()){ + // return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + // } + // + // Long virtualId = po.getVirtualId(); + // Integer refundAmount = po.getRefundAmount(); + // + // // 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞� + // SeVirtualCard seVirtualCard = virtualCardSv.selectVirtuCardById(virtualId); + // if(seVirtualCard == null) { + // return BaseResponseUtils.buildFail(SellResultCode.VIRTUAL_CARD_NOT_EXIST.getMessage()); + // } + // Long clientId = seVirtualCard.getClientId(); + // Double money = seVirtualCard.getMoney(); + // + // // 楠岃瘉閫�娆鹃噾棰濇槸鍚﹀ぇ浜庝綑棰� + // if(refundAmount > money) { + // return BaseResponseUtils.buildFail(SellResultCode.REFUND_AMOUNT_CANNOT_GREATER_THAN_MONEY.getMessage()); + // } + // + // // 璁$畻娑堣垂鍚庝綑棰� + // Double afterRefund = money - refundAmount; + // + // SeVcRefund seVcRefund = new SeVcRefund(); + // seVcRefund.setVcId(virtualId); + // seVcRefund.setClientId(clientId); + // seVcRefund.setMoney(money); + // seVcRefund.setRefundAmount(refundAmount); + // seVcRefund.setAfterRefund(afterRefund); + // seVcRefund.setApplicationTime(new Date()); + // seVcRefund.setRefundStatus(RefundStateENUM.TO_AUDIT.getCode()); + // + // Long rec = virtualCardSv.addRefund(seVcRefund); + // if(rec == 0) { + // return BaseResponseUtils.buildFail(SellResultCode.APPLICATION_REFUND_FAIL.getMessage()); + // } + // return BaseResponseUtils.buildSuccess(true) ; + //} /** * 瀹℃牳閫�娆剧敵璇� @@ -176,68 +171,68 @@ * @param bindingResult * @return */ - @Operation(summary = "瀹℃牳閫�娆剧敵璇�", description = "瀹℃牳閫�娆剧敵璇�") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) - @PostMapping(path = "audit_refund", consumes = MediaType.APPLICATION_JSON_VALUE) - @Transactional(rollbackFor = Exception.class) - @SsoAop() - public BaseResponse<Boolean> auditRefund(@RequestBody @Valid DtoAudit po, BindingResult bindingResult) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, SignatureException, InvalidKeyException { - if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); - } - - // 鏍规嵁閫�娆綢D鑾峰彇閫�娆惧璞★紝骞舵洿鏂板鏍镐汉銆佸鏍告椂闂淬�佸鏍稿娉ㄣ�侀��娆剧姸鎬佸瓧娈� - SeVcRefund seVcRefund = virtualCardSv.selectRefundByRefundId(po.getRefundId()); - Long virtualId = seVcRefund.getVcId(); - Integer refundAmount = seVcRefund.getRefundAmount(); - seVcRefund.setAuditor(po.getAuditor()); - seVcRefund.setAuditTime(new Date()); - seVcRefund.setRemarks(po.getRemarks()); - seVcRefund.setRefundStatus(RefundStateENUM.TO_REFUND.getCode()); - Integer rec = virtualCardSv.updateRefund(seVcRefund); - if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.AUDIT_REFUND_FAIL.getMessage()); - } - - // 瀹屾垚瀹℃牳鍚庤幏鍙栧緟閫�娆捐鍗曞垪琛� - List<ToRefund> list_ToRefund = payHelper.getToRefunds(virtualId, refundAmount); - if(list_ToRefund == null || list_ToRefund.size() <=0) - return BaseResponseUtils.buildFail(SellResultCode.NOT_SUFFICIENT_FUNDS.getMessage()); - - //閬嶅巻寰呴��娆惧垪琛� - JSONArray array_ToRefund = (JSONArray) JSON.toJSON(list_ToRefund); - for(int i = 0; i < array_ToRefund.size(); i++) { - JSONObject job_ToRefund = array_ToRefund.getJSONObject(i); - String orderNumber_ToRefund = job_ToRefund.getString("orderNumber"); - Integer refundAmount_ToRefund = job_ToRefund.getInteger("refundAmount"); - - // 鐢熸垚閫�娆惧垎椤硅褰� - SeVcRefundItem seVcRefundItem = new SeVcRefundItem(); - seVcRefundItem.setRefundId(po.getRefundId()); - seVcRefundItem.setOrderNumber(orderNumber_ToRefund); - String refundNumber = virtualCardSv.generateRefundNumber(orderNumber_ToRefund); - seVcRefundItem.setRefundNumber(refundNumber); - seVcRefundItem.setRefundAmount(refundAmount_ToRefund); - seVcRefundItem.setCreateTime(new Date()); - seVcRefundItem.setRefundStatus(RefundItemStateENUM.NO_REFUND.getCode()); - Long refundItemId = virtualCardSv.addRefundItem(seVcRefundItem); - - // 璋冪敤寰俊閫�娆剧敵璇锋帴鍙� - Refund refund = new Refund(); - refund.setTradeNo(orderNumber_ToRefund); - refund.setRefundNo(refundNumber); - refund.setRefund(refundAmount_ToRefund); - BaseResponse rep = payHelper.refunds(refund); - } - - return BaseResponseUtils.buildSuccess(true) ; - } + //@Operation(summary = "瀹℃牳閫�娆剧敵璇�", description = "瀹℃牳閫�娆剧敵璇�") + //@ApiResponses(value = { + // @ApiResponse( + // responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + // description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + // content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + // schema = @Schema(implementation = Boolean.class))} + // ) + //}) + //@PostMapping(path = "audit_refund", consumes = MediaType.APPLICATION_JSON_VALUE) + //@Transactional(rollbackFor = Exception.class) + //@SsoAop() + //public BaseResponse<Boolean> auditRefund(@RequestBody @Valid DtoAudit po, BindingResult bindingResult) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, SignatureException, InvalidKeyException { + // if(bindingResult != null && bindingResult.hasErrors()){ + // return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + // } + // + // // 鏍规嵁閫�娆綢D鑾峰彇閫�娆惧璞★紝骞舵洿鏂板鏍镐汉銆佸鏍告椂闂淬�佸鏍稿娉ㄣ�侀��娆剧姸鎬佸瓧娈� + // SeVcRefund seVcRefund = virtualCardSv.selectRefundByRefundId(po.getRefundId()); + // Long virtualId = seVcRefund.getVcId(); + // Integer refundAmount = seVcRefund.getRefundAmount(); + // seVcRefund.setAuditor(po.getAuditor()); + // seVcRefund.setAuditTime(new Date()); + // seVcRefund.setRemarks(po.getRemarks()); + // seVcRefund.setRefundStatus(RefundStateENUM.TO_REFUND.getCode()); + // Integer rec = virtualCardSv.updateRefund(seVcRefund); + // if(rec == 0) { + // return BaseResponseUtils.buildFail(SellResultCode.AUDIT_REFUND_FAIL.getMessage()); + // } + // + // // 瀹屾垚瀹℃牳鍚庤幏鍙栧緟閫�娆捐鍗曞垪琛� + // List<ToRefund> list_ToRefund = payHelper.getToRefunds(virtualId, refundAmount); + // if(list_ToRefund == null || list_ToRefund.size() <=0) + // return BaseResponseUtils.buildFail(SellResultCode.NOT_SUFFICIENT_FUNDS.getMessage()); + // + // //閬嶅巻寰呴��娆惧垪琛� + // JSONArray array_ToRefund = (JSONArray) JSON.toJSON(list_ToRefund); + // for(int i = 0; i < array_ToRefund.size(); i++) { + // JSONObject job_ToRefund = array_ToRefund.getJSONObject(i); + // String orderNumber_ToRefund = job_ToRefund.getString("orderNumber"); + // Integer refundAmount_ToRefund = job_ToRefund.getInteger("refundAmount"); + // + // // 鐢熸垚閫�娆惧垎椤硅褰� + // SeVcRefundItem seVcRefundItem = new SeVcRefundItem(); + // seVcRefundItem.setRefundId(po.getRefundId()); + // seVcRefundItem.setOrderNumber(orderNumber_ToRefund); + // String refundNumber = virtualCardSv.generateRefundNumber(orderNumber_ToRefund); + // seVcRefundItem.setRefundNumber(refundNumber); + // seVcRefundItem.setRefundAmount(refundAmount_ToRefund); + // seVcRefundItem.setCreateTime(new Date()); + // seVcRefundItem.setRefundStatus(RefundItemStateENUM.NO_REFUND.getCode()); + // Long refundItemId = virtualCardSv.addRefundItem(seVcRefundItem); + // + // // 璋冪敤寰俊閫�娆剧敵璇锋帴鍙� + // Refund refund = new Refund(); + // refund.setTradeNo(orderNumber_ToRefund); + // refund.setRefundNo(refundNumber); + // refund.setRefund(refundAmount_ToRefund); + // BaseResponse rep = payHelper.refunds(refund); + // } + // + // return BaseResponseUtils.buildSuccess(true) ; + //} } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardSv.java index a6bd13c..d25ae40 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardSv.java @@ -11,6 +11,7 @@ import com.dy.pipIrrGlobal.pojoSe.SeVcRefundItem; import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; import com.dy.pipIrrGlobal.voSe.VoOrders; +import com.dy.pipIrrGlobal.voSe.VoVirtualCard; import com.dy.pipIrrSell.result.SellResultCode; import com.dy.pipIrrSell.virtualCard.dto.DtoRegist; import com.dy.pipIrrSell.virtualCard.dto.DtoVirtualCard; @@ -46,6 +47,24 @@ @Autowired private SeVcRefundItemMapper seVcRefundItemMapper; + + /** + * 鑾峰彇鍏ㄩ儴铏氭嫙鍗� + * @return + */ + public List<VoVirtualCard> getVCs() { + return seVirtualCardMapper.getVCs(); + } + + /** + * 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞� + * @param vcId + * @return + */ + public VoVirtualCard getVcById(Long vcId) { + return seVirtualCardMapper.getVcById(vcId); + } + /** * 娉ㄥ唽铏氭嫙鍗� * @param po diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/enums/LastOperateENUM.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/enums/LastOperateENUM.java index b29688d..5d0411c 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/enums/LastOperateENUM.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/enums/LastOperateENUM.java @@ -18,7 +18,9 @@ CONSUME((byte)3, "娑堣垂"), APPLY_REFUND((byte)4, "鐢宠閫�娆�"), AUDIT_REFUND((byte)5, "閫�娆惧鏍�"), - REFUND((byte)6, "閫�娆�"); + REFUND((byte)6, "閫�娆�"), + OPEN_VALVE((byte)7, "寮�闃�"), + CLOSE_VALVE((byte)8, "鍏抽榾"); private final Byte code; private final String message; -- Gitblit v1.8.0