From 15bf8d8550804f1e853d52a898ebcca7674a5e39 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期一, 15 一月 2024 17:01:34 +0800 Subject: [PATCH] 流量监测站查询、修改 根据流量监测站编号获取绑定记录 --- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/QueryVoFlowMeter.java | 27 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowMonitoringMapper.java | 36 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowmeterMapper.java | 23 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoFlowMeter.java | 51 ++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowSv.java | 11 pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java | 60 ++- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterSv.java | 43 ++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowmeterMapper.xml | 42 ++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrMonitoringFlowmeterMapper.xml | 15 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrMonitoringFlowmeterMapper.java | 10 pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowCtrl.java | 93 +++- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java | 7 pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringSv.java | 69 +++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml | 409 +++++++++++++--------- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringCtrl.java | 139 +++++++ 15 files changed, 802 insertions(+), 233 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowMonitoringMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowMonitoringMapper.java index 1c33361..cdd3082 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowMonitoringMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowMonitoringMapper.java @@ -1,7 +1,14 @@ package com.dy.pipIrrGlobal.daoPr; +import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring; +import com.dy.pipIrrGlobal.pojoPr.PrIntake; +import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring; +import com.dy.pipIrrGlobal.voPr.VoIntake; import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * @author ZhuBaoMin @@ -24,6 +31,7 @@ /** * 鏍规嵁鐩戞祴绔欑紪鍙峰垹闄ょ洃娴嬬珯 + * * @param flowMonitoringId * @return */ @@ -31,8 +39,34 @@ /** * 鏍规嵁鐩戞祴绔欑紪鍙疯幏鍙栨湭鍒犻櫎鐨勭洃娴嬬珯鏁伴噺 + * * @param flowMonitoringId * @return */ - Integer getRecordCountOfFlowMonitoring(@Param("flowMonitoringId") Long flowMonitoringId); + Integer getRecordCountOfFlowMonitoringByFlowMonitoringId(@Param("flowMonitoringId") Long flowMonitoringId); + + /** + * 鏍规嵁鐩戞祴绔� 鍚嶇О 缁戝畾鐘舵�� 鑾峰彇鏈垹闄ょ殑鐩戞祴绔欐暟閲� + * + * @param params + * @return + */ + Integer getRecordCountOfFlowMonitoring(Map<?, ?> params); + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇娴侀噺鐩戞祴绔欏疄浣撹褰� + * + * @param params + * @return 瀹炰綋闆嗗悎 + */ + List<VoFlowMonitoring> getPrFlowMonitoring(Map<?, ?> params); + + /** + * 鏌ヨ鍏ㄩ儴娴侀噺鐩戞祴绔欏疄浣撹褰� + * + * @return 瀹炰綋闆嗗悎 + */ + List<PrFlowMonitoring> selectAll(); + + } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowmeterMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowmeterMapper.java index e4a7ada..3cdb561 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowmeterMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrFlowmeterMapper.java @@ -1,7 +1,12 @@ package com.dy.pipIrrGlobal.daoPr; import com.dy.pipIrrGlobal.pojoPr.PrFlowmeter; +import com.dy.pipIrrGlobal.voPr.VoFlowMeter; +import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring; import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * @author ZhuBaoMin @@ -34,5 +39,21 @@ * @param flowmeterId * @return */ - Integer getRecordCountOfFlowmeter(@Param("flowmeterId") Long flowmeterId); + Integer getRecordCountOfFlowmeterByCode(@Param("flowmeterId") Long flowmeterId); + + /** + * 鏍规嵁娴侀噺璁� 缂栧彿 鍦ㄧ嚎鐘舵�� 鑾峰彇鏈垹闄ょ殑娴侀噺璁℃暟閲� + * + * @param params + * @return + */ + Integer getRecordCountOfFlowMeterByOthers(Map<?, ?> params); + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇娴侀噺璁″疄浣撹褰� + * + * @param params + * @return 瀹炰綋闆嗗悎 + */ + List<VoFlowMeter> getFlowMeters(Map<?, ?> params); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrMonitoringFlowmeterMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrMonitoringFlowmeterMapper.java index f6cdffd..4c14a98 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrMonitoringFlowmeterMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrMonitoringFlowmeterMapper.java @@ -3,6 +3,9 @@ import com.dy.pipIrrGlobal.pojoPr.PrMonitoringFlowmeter; import org.apache.ibatis.annotations.Param; +import java.util.List; +import java.util.Map; + /** * @author ZhuBaoMin * @date 2024-01-05 10:18 @@ -30,4 +33,11 @@ * @return 绗﹀悎鏉′欢璁板綍鏁伴噺 */ Integer getBindRecordCount(@Param("monitoringId") Long monitoringId, @Param("flowmeterId") Long flowmeterId, @Param("operateType") Byte operateType); + + /** + * 鏍规嵁 娴侀噺鐩戞祴绔欑紪鍙� 鑾峰彇 缁戝畾璁板綍 鎸夋搷浣滄椂闂撮檷搴� + * @param monitoringId 鐩戞祴绔欑紪鍙� + * @return 缁戝畾璁板綍 + */ + List<Map<String, Object>> getBingRecordsByMonitoringId(Long monitoringId); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoFlowMeter.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoFlowMeter.java new file mode 100644 index 0000000..562c4c0 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoFlowMeter.java @@ -0,0 +1,51 @@ +package com.dy.pipIrrGlobal.voPr; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.dy.common.po.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @author :WuZeYu + * @Date :2024/1/15 10:58 + * @LastEditTime :2024/1/15 10:58 + * @Description + */ +@Data +@Schema(title = "娴侀噺璁¤鍥惧璞�") +public class VoFlowMeter implements BaseEntity { + private static final long serialVersionUID = 1L; + + @Schema(title = "ID") + @ExcelProperty("ID") + @ColumnWidth(10) + private Long id; + + @Schema(title = "绠$綉娴侀噺璁$紪鍙�") + @ExcelProperty("绠$綉娴侀噺璁$紪鍙�") + @ColumnWidth(15) + private String code; + + @Schema(title = "鍦ㄧ嚎鐘舵��") + @ExcelProperty("鍦ㄧ嚎鐘舵��") + @ColumnWidth(1) + private Integer onlineState; + + @Schema(title = "绠$綉娴侀噺鐩戞祴绔欏悕绉�") + @ExcelProperty("绠$綉娴侀噺鐩戞祴绔欏悕绉�") + @ColumnWidth(15) + private String name; + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @Schema(title = "鎿嶄綔鏃堕棿") + @ExcelProperty("鎿嶄綔鏃堕棿") + @ColumnWidth(30) + private Date operateDt; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml index 19cecd7..2914ee1 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml @@ -1,185 +1,256 @@ <?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.PrFlowMonitoringMapper"> - <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> - <!--@mbg.generated--> - <!--@Table pr_flow_monitoring--> - <id column="id" jdbcType="BIGINT" property="id" /> - <result column="countyId" jdbcType="BIGINT" property="countyid" /> - <result column="townId" jdbcType="BIGINT" property="townid" /> - <result column="villageId" jdbcType="BIGINT" property="villageid" /> - <result column="name" jdbcType="VARCHAR" property="name" /> - <result column="lng" jdbcType="DOUBLE" property="lng" /> - <result column="lat" jdbcType="DOUBLE" property="lat" /> - <result column="remarks" jdbcType="VARCHAR" property="remarks" /> - <result column="operator" jdbcType="BIGINT" property="operator" /> - <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" /> - <result column="deleted" jdbcType="TINYINT" property="deleted" /> - </resultMap> - <sql id="Base_Column_List"> - <!--@mbg.generated--> - id, countyId, townId, villageId, `name`, lng, lat, remarks, `operator`, operateDt, - deleted - </sql> - <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> - <!--@mbg.generated--> - select - <include refid="Base_Column_List" /> - from pr_flow_monitoring - where id = #{id,jdbcType=BIGINT} - </select> - <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> - <!--@mbg.generated--> - delete from pr_flow_monitoring - where id = #{id,jdbcType=BIGINT} - </delete> - - <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> - <!--@mbg.generated--> - insert into pr_flow_monitoring (id, countyId, townId, - villageId, `name`, lng, - lat, remarks, `operator`, - operateDt, deleted) - values (#{id,jdbcType=BIGINT}, #{countyid,jdbcType=BIGINT}, #{townid,jdbcType=BIGINT}, - #{villageid,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, - #{lat,jdbcType=DOUBLE}, #{remarks,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, - #{operatedt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT}) - </insert> - - <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> - <!--@mbg.generated--> - insert into pr_flow_monitoring - <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="id != null"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> + <!--@mbg.generated--> + <!--@Table pr_flow_monitoring--> + <id column="id" jdbcType="BIGINT" property="id"/> + <result column="countyId" jdbcType="BIGINT" property="countyid"/> + <result column="townId" jdbcType="BIGINT" property="townid"/> + <result column="villageId" jdbcType="BIGINT" property="villageid"/> + <result column="name" jdbcType="VARCHAR" property="name"/> + <result column="lng" jdbcType="DOUBLE" property="lng"/> + <result column="lat" jdbcType="DOUBLE" property="lat"/> + <result column="remarks" jdbcType="VARCHAR" property="remarks"/> + <result column="operator" jdbcType="BIGINT" property="operator"/> + <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt"/> + <result column="deleted" jdbcType="TINYINT" property="deleted"/> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> id, - </if> - <if test="countyid != null"> countyId, - </if> - <if test="townid != null"> townId, - </if> - <if test="villageid != null"> villageId, - </if> - <if test="name != null"> `name`, - </if> - <if test="lng != null"> lng, - </if> - <if test="lat != null"> lat, - </if> - <if test="remarks != null"> remarks, - </if> - <if test="operator != null"> `operator`, - </if> - <if test="operatedt != null"> operateDt, - </if> - <if test="deleted != null"> - deleted, - </if> - </trim> - <trim prefix="values (" suffix=")" suffixOverrides=","> - <if test="id != null"> - #{id,jdbcType=BIGINT}, - </if> - <if test="countyid != null"> - #{countyid,jdbcType=BIGINT}, - </if> - <if test="townid != null"> - #{townid,jdbcType=BIGINT}, - </if> - <if test="villageid != null"> - #{villageid,jdbcType=BIGINT}, - </if> - <if test="name != null"> - #{name,jdbcType=VARCHAR}, - </if> - <if test="lng != null"> - #{lng,jdbcType=DOUBLE}, - </if> - <if test="lat != null"> - #{lat,jdbcType=DOUBLE}, - </if> - <if test="remarks != null"> - #{remarks,jdbcType=VARCHAR}, - </if> - <if test="operator != null"> - #{operator,jdbcType=BIGINT}, - </if> - <if test="operatedt != null"> - #{operatedt,jdbcType=TIMESTAMP}, - </if> - <if test="deleted != null"> - #{deleted,jdbcType=TINYINT}, - </if> - </trim> - </insert> - <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> - <!--@mbg.generated--> - update pr_flow_monitoring - <set> - <if test="countyid != null"> - countyId = #{countyid,jdbcType=BIGINT}, - </if> - <if test="townid != null"> - townId = #{townid,jdbcType=BIGINT}, - </if> - <if test="villageid != null"> - villageId = #{villageid,jdbcType=BIGINT}, - </if> - <if test="name != null"> - `name` = #{name,jdbcType=VARCHAR}, - </if> - <if test="lng != null"> - lng = #{lng,jdbcType=DOUBLE}, - </if> - <if test="lat != null"> - lat = #{lat,jdbcType=DOUBLE}, - </if> - <if test="remarks != null"> - remarks = #{remarks,jdbcType=VARCHAR}, - </if> - <if test="operator != null"> - `operator` = #{operator,jdbcType=BIGINT}, - </if> - <if test="operatedt != null"> - operateDt = #{operatedt,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.PrFlowMonitoring"> - <!--@mbg.generated--> - update pr_flow_monitoring - set countyId = #{countyid,jdbcType=BIGINT}, - townId = #{townid,jdbcType=BIGINT}, - villageId = #{villageid,jdbcType=BIGINT}, - `name` = #{name,jdbcType=VARCHAR}, - lng = #{lng,jdbcType=DOUBLE}, - lat = #{lat,jdbcType=DOUBLE}, - remarks = #{remarks,jdbcType=VARCHAR}, - `operator` = #{operator,jdbcType=BIGINT}, - operateDt = #{operatedt,jdbcType=TIMESTAMP}, - deleted = #{deleted,jdbcType=TINYINT} - where id = #{id,jdbcType=BIGINT} - </update> + deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List"/> + from pr_flow_monitoring + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete + from pr_flow_monitoring + where id = #{id,jdbcType=BIGINT} + </delete> - <!--鏍规嵁鐩戞祴绔欑紪鍙峰垹闄ょ洃娴嬬珯--> - <update id="deleteFlowMonitoringById"> - UPDATE pr_flow_monitoring SET deleted = 1 WHERE id = ${flowMonitoringId} - </update> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> + <!--@mbg.generated--> + insert into pr_flow_monitoring (id, countyId, townId, + villageId, `name`, lng, + lat, remarks, `operator`, + operateDt, deleted) + values (#{id,jdbcType=BIGINT}, #{countyid,jdbcType=BIGINT}, #{townid,jdbcType=BIGINT}, + #{villageid,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, + #{lat,jdbcType=DOUBLE}, #{remarks,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, + #{operatedt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT}) + </insert> - <!--鏍规嵁鐩戞祴绔欑紪鍙疯幏鍙栨湭鍒犻櫎鐨勭洃娴嬬珯鏁伴噺--> - <select id="getRecordCountOfFlowMonitoring" resultType="java.lang.Integer"> - SELECT COUNT(*) AS recordCountOfFlowMonitoring FROM pr_flow_monitoring WHERE deleted = 0 AND id = ${flowMonitoringId} - </select> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> + <!--@mbg.generated--> + insert into pr_flow_monitoring + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="countyid != null"> + countyId, + </if> + <if test="townid != null"> + townId, + </if> + <if test="villageid != null"> + villageId, + </if> + <if test="name != null"> + `name`, + </if> + <if test="lng != null"> + lng, + </if> + <if test="lat != null"> + lat, + </if> + <if test="remarks != null"> + remarks, + </if> + <if test="operator != null"> + `operator`, + </if> + <if test="operatedt != null"> + operateDt, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="countyid != null"> + #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + #{villageid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + #{operatedt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> + <!--@mbg.generated--> + update pr_flow_monitoring + <set> + <if test="countyid != null"> + countyId = #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + townId = #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + villageId = #{villageid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + `name` = #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + lng = #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + lat = #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + operateDt = #{operatedt,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.PrFlowMonitoring"> + <!--@mbg.generated--> + update pr_flow_monitoring + set countyId = #{countyid,jdbcType=BIGINT}, + townId = #{townid,jdbcType=BIGINT}, + villageId = #{villageid,jdbcType=BIGINT}, + `name` = #{name,jdbcType=VARCHAR}, + lng = #{lng,jdbcType=DOUBLE}, + lat = #{lat,jdbcType=DOUBLE}, + remarks = #{remarks,jdbcType=VARCHAR}, + `operator` = #{operator,jdbcType=BIGINT}, + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + deleted = #{deleted,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + </update> + + <!--鏍规嵁鐩戞祴绔欑紪鍙峰垹闄ょ洃娴嬬珯--> + <update id="deleteFlowMonitoringById"> + UPDATE pr_flow_monitoring + SET deleted = 1 + WHERE id = ${flowMonitoringId} + </update> + + <!--鏍规嵁鐩戞祴绔欑紪鍙疯幏鍙栨湭鍒犻櫎鐨勭洃娴嬬珯鏁伴噺--> + <select id="getRecordCountOfFlowMonitoringByFlowMonitoringId" resultType="java.lang.Integer"> + SELECT COUNT(*) AS recordCountOfFlowMonitoring + FROM pr_flow_monitoring + WHERE deleted = 0 + AND id = ${flowMonitoringId} + </select> + + <!--鏌ヨ鍏ㄩ儴鐩戞祴绔欏疄浣撹褰�--> + <select id="selectAll" resultType="com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring"> + select + <include refid="Base_Column_List"/> + from pr_flow_monitoring + where deleted = 0 + </select> + + + <!--鏍规嵁鐩戞祴绔欑紪鍙疯幏鍙栨湭鍒犻櫎鐨勭洃娴嬬珯鏁伴噺--> + <select id="getRecordCountOfFlowMonitoring" resultType="java.lang.Integer"> + SELECT COUNT(*) AS recordCountOfFlowMonitoring + from pr_flow_monitoring pfm + INNER JOIN ba_district country ON pfm.countyId = country.id + INNER JOIN ba_district town ON pfm.townId = town.id + INNER JOIN ba_district village ON pfm.villageId = village.id + INNER JOIN pr_monitoring_flowmeter pmofl ON pmofl.monitoringId = pfm.id + <where> + pfm.deleted = 0 + <if test = "name != null and name !=''"> + AND pfm.`name` like CONCAT('%',#{name},'%') + </if> + <if test = "bindState != null and bindState > 0"> + AND pmofl.operateType = ${bindState} + </if> + </where> + </select> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇娴侀噺鐩戞祴绔欏疄浣撹褰�--> + <select id="getPrFlowMonitoring" parameterType="map" resultType="com.dy.pipIrrGlobal.voPr.VoFlowMonitoring"> + select (@i:=@i+1) AS id, + CONCAT(country.`name`, town.`name`, village.`name`) AS address, + pfm.`name` AS `name`, + pmofl.operateType AS bindState + from pr_flow_monitoring pfm + INNER JOIN ba_district country ON pfm.countyId = country.id + INNER JOIN ba_district town ON pfm.townId = town.id + INNER JOIN ba_district village ON pfm.villageId = village.id + INNER JOIN pr_monitoring_flowmeter pmofl ON pmofl.monitoringId = pfm.id, + (SELECT @i:=0) AS itable + <where> + pfm.deleted = 0 + <if test = "name != null and name !=''"> + AND pfm.`name` like CONCAT('%',#{name},'%') + </if> + <if test = "bindState != null and bindState > 0"> + AND pmofl.operateType = ${bindState} + </if> + </where> + ORDER BY pmofl.operateDt DESC + <if test="pageCurr != null and pageSize != null"> + LIMIT ${pageCurr}, ${pageSize} + </if> + + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowmeterMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowmeterMapper.xml index 7af9f8a..1912ac5 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowmeterMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowmeterMapper.xml @@ -168,7 +168,47 @@ </update> <!--鏍规嵁娴侀噺璁$紪鍙疯幏鍙栨湭鍒犻櫎鐨勬祦閲忚鏁伴噺--> - <select id="getRecordCountOfFlowmeter" resultType="java.lang.Integer"> + <select id="getRecordCountOfFlowmeterByCode" resultType="java.lang.Integer"> SELECT COUNT(*) AS recordCountOfFlowmeter FROM pr_flowmeter WHERE deleted = 0 AND id = ${flowmeterId} </select> + + <!--鏍规嵁娴侀噺璁$紪鍙� 鎴栬�� 鍦ㄧ嚎鐘舵�� 鑾峰彇鏈垹闄ょ殑娴侀噺璁℃暟閲� --> + <select id="getRecordCountOfFlowMeterByOthers" resultType="_integer"> + SELECT COUNT(*) AS recordCountOfFlowmeter FROM pr_flowmeter + <where> + deleted = 0 AND + <if test="code != null"> + code = #{code,jdbcType=VARCHAR}, + </if> + <if test="onlineState != null "> + onlineState = #{onlineState,jdbcType=TINYINT} + </if> + </where> + </select> + + <!--鏍规嵁娴侀噺璁$紪鍙� 鎴栬�� 鍦ㄧ嚎鐘舵�� 鑾峰彇鏈垹闄ょ殑娴侀噺璁¤褰� --> + <select id="getFlowMeters" resultType="com.dy.pipIrrGlobal.voPr.VoFlowMeter"> + select (@i:=@i+1) AS id, + pfm.code AS code, + pfm.onlineState AS onlineState, + pfmt.`name` AS `name`, + pfm.operateDt AS operateDt + from pr_flowmeter pfm + inner join pr_monitoring_flowmeter pmofl on pmofl.flowmeterId = pfm.id + inner join pr_flow_monitoring pfmt on pfmt.id = pmofl.monitoringId, + (SELECT @i:=0) AS itable + <where> + pfm.deleted = 0 AND pfmt.deleted = 0 AND pmofl.operateType = 1 + <if test="code != null"> + AND code = #{code,jdbcType=VARCHAR} + </if> + <if test="onlineState != null "> + AND onlineState = #{onlineState,jdbcType=TINYINT} + </if> + </where> + ORDER BY pfm.operateDt DESC + <if test="pageCurr != null and pageSize != null"> + LIMIT ${pageCurr}, ${pageSize} + </if> + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrMonitoringFlowmeterMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrMonitoringFlowmeterMapper.xml index 4c63f19..2c63ca8 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrMonitoringFlowmeterMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrMonitoringFlowmeterMapper.xml @@ -16,6 +16,10 @@ <!--@mbg.generated--> id, monitoringId, flowmeterId, operateType, remarks, `operator`, operateDt </sql> + <sql id="Base_Column_List_NoId"> + <!--@mbg.generated--> + monitoringId, flowmeterId, operateType, remarks, `operator`, operateDt + </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <!--@mbg.generated--> select @@ -143,4 +147,15 @@ </if> </where> </select> + + <!--鏍规嵁 娴侀噺鐩戞祴绔欑紪鍙� 鑾峰彇 缁戝畾璁板綍 鎸夋搷浣滄椂闂撮檷搴�--> + <select id="getBingRecordsByMonitoringId" parameterType="_long" resultType="java.util.Map"> + select (@i:=@i+1) AS id, + <include refid="Base_Column_List_NoId" /> + from pr_monitoring_flowmeter + ,(SELECT @i:=0) AS itable + where + monitoringId=#{monitoringId,jdbcType=BIGINT} + order by operateDt desc + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringCtrl.java index bef9203..a5399b5 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringCtrl.java @@ -3,10 +3,15 @@ import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.pojoBa.BaClient; import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring; +import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring; +import com.dy.pipIrrGlobal.voSe.VoActiveCard; import com.dy.pipIrrProject.result.ProjectResultCode; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -17,10 +22,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.*; @@ -114,4 +116,133 @@ } return BaseResponseUtils.buildSuccess(true) ; } + + /** + * 缂栬緫淇敼鐩戞祴绔� + * @param po 淇濆瓨鐩戞祴绔檉orm琛ㄥ崟瀵硅薄 + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "缂栬緫淇敼鐩戞祴绔�", description = "鎻愪氦鐩戞祴绔欐暟鎹紙form琛ㄥ崟锛夛紝杩涜淇敼") + @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 = "update", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid PrFlowMonitoring po, @Parameter(hidden = true) BindingResult bindingResult){ + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + // 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛� + Long villageId = po.getVillageid(); + /** + * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭� + */ + Map map_districts = Optional.ofNullable(flowMonitoringSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); + if(map_districts.size() <= 0) { + return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎"); + } + Long countryId = Long.parseLong(map_districts.get("countryId").toString()); + Long townId = Long.parseLong(map_districts.get("townId").toString()); + po.setCountyid(countryId); + po.setTownid(townId); + int count; + Date operateTime = new Date(); + po.setOperatedt(operateTime); + po.setDeleted((byte)0); + try { + count = this.flowMonitoringSv.update(po); + } catch (Exception e) { + log.error("淇濆瓨鐩戞祴绔欏紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildFail(ProjectResultCode.UPDATE_FLOW_MONITORING_FAIL.getMessage()) ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + + /** + * 瀹㈡埛绔姹傚緱鍒版墍鏈夌洃娴嬬珯鍚嶅瓧 + * @return 鎵�鏈夌洃娴嬬珯鍚嶅瓧 + */ + @Operation(summary = "鑾峰緱鍏ㄩ儴鐩戞祴绔�", description = "杩斿洖鍏ㄩ儴鐩戞祴绔欐暟鎹�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖鍏ㄩ儴鐩戞祴绔欐暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = PrFlowMonitoring.class))} + ) + }) + @GetMapping(path = "all") + @SsoAop() + public BaseResponse<QueryResultVo<List<PrFlowMonitoring>>> all(){ + try { + QueryResultVo<List<PrFlowMonitoring>> res = this.flowMonitoringSv.selectAll(); + if(res == null) { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_FLOW_MONITORINGS.getMessage()); + }else { + return BaseResponseUtils.buildSuccess(res); + } + } catch (Exception e) { + log.error("鏌ヨ鐩戞祴绔欏紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 寰楀埌涓�涓洃娴嬬珯鏁版嵁 + * @return 涓�涓洃娴嬬珯鏁版嵁 + */ + @Operation(summary = "涓�涓洃娴嬬珯", description = "寰楀埌涓�涓洃娴嬬珯鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�涓洃娴嬬珯鏁版嵁锛圔aseResponse.content:{}锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = PrFlowMonitoring.class))} + ) + }) + @GetMapping(path = "one/{id}") + @SsoAop() + public BaseResponse<PrFlowMonitoring> one(@PathVariable("id") Long id){ + if(this.flowMonitoringSv.selectById(id) == null) { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_FLOW_MONITORINGS.getMessage()); + }else { + return BaseResponseUtils.buildSuccess(this.flowMonitoringSv.selectById(id)); + } + } + + @Operation(summary = "鑾峰緱涓�椤电洃娴嬬珯璁板綍", description = "杩斿洖涓�椤电洃娴嬬珯鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�椤电洃娴嬬珯鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = PrFlowMonitoring.class))} + ) + }) + @GetMapping(path = "getFlowMonitoring", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<QueryResultVo<List<VoFlowMonitoring>>> getFlowMonitoring(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVo vo){ + try { + QueryResultVo<List<VoFlowMonitoring>> res = flowMonitoringSv.getPrFlowMonitorings(vo); + if(res == null) { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_FLOW_MONITORINGS.getMessage()); + } + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇鐩戞祴绔欒褰曞紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + + } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringSv.java index 08ff400..de0dd7d 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringSv.java @@ -1,12 +1,18 @@ package com.dy.pipIrrProject.flowMonitoring; +import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper; import com.dy.pipIrrGlobal.daoPr.PrFlowMonitoringMapper; import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring; +import com.dy.pipIrrGlobal.pojoPr.PrIntake; +import com.dy.pipIrrGlobal.voPr.VoDivide; +import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring; import lombok.extern.slf4j.Slf4j; +import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Map; /** @@ -57,8 +63,67 @@ * @param flowMonitoringId 娴侀噺鐩戞祴绔欑紪鍙� * @return */ - public Integer getRecordCountOfFlowMonitoring(Long flowMonitoringId) { - return prFlowMonitoringMapper.getRecordCountOfFlowMonitoring(flowMonitoringId); + public Integer getRecordCountOfFlowMonitoringByFlowMonitoringId(Long flowMonitoringId) { + return prFlowMonitoringMapper.getRecordCountOfFlowMonitoringByFlowMonitoringId(flowMonitoringId); } + /** + * 寰楀埌涓�涓祦閲忕洃娴嬬珯 + * @param id 鐩戞祴绔橧D + * @return 鐩戞祴绔欏疄浣� + */ + public PrFlowMonitoring selectById(Long id) { + return prFlowMonitoringMapper.selectByPrimaryKey(id); + } + + /** + * 寰楀埌鍏ㄩ儴娴侀噺鐩戞祴绔� + * @return 鐩戞祴绔欏疄浣撻泦鍚� + */ + public QueryResultVo<List<PrFlowMonitoring>> selectAll(){ + QueryResultVo<List<PrFlowMonitoring>> rsVo = new QueryResultVo<>() ; + rsVo.obj = this.prFlowMonitoringMapper.selectAll() ; + return rsVo ; + } + + + /** + * 鏍规嵁鎸囧畾鏉′欢寰楀埌娴侀噺鐩戞祴绔欏疄浣撹褰� + * @param queryVo 缁欑殑鏉′欢 + * @return 鐩戞祴绔欏疄浣撻泦鍚� + */ + public QueryResultVo<List<VoFlowMonitoring>> getPrFlowMonitorings(QueryVo queryVo){ + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo) ; + + QueryResultVo<List<VoFlowMonitoring>> rsVo = new QueryResultVo<>() ; + + Integer pageCurr = 0; + Integer pageSize = 10000; + rsVo.pageCurr = 1; + rsVo.pageSize = 10000; + if(queryVo.pageSize != null && queryVo.pageCurr != null) { + rsVo.pageSize = queryVo.pageSize ; + rsVo.pageCurr = queryVo.pageCurr; + pageSize = queryVo.pageSize ; + pageCurr = (Integer.parseInt(params.get("pageCurr").toString()) - 1) * Integer.parseInt(params.get("pageSize").toString()); + } + params.put("pageCurr", pageCurr); + params.put("pageSize", pageSize); + + // 璁$畻绗﹀悎鏉′欢鐨勮褰曟暟 + Integer itemTotal = prFlowMonitoringMapper.getRecordCountOfFlowMonitoring(params); + rsVo.calculateAndSet(itemTotal.longValue(), params); + rsVo.obj = prFlowMonitoringMapper.getPrFlowMonitoring(params); + + return rsVo ; + } + + /** + * 淇濆瓨淇敼涓�涓祦閲忕洃娴嬬珯瀹炰綋 + * @param po 淇敼鐨勫唴瀹癸紙id涓嶄负绌�) + * @return + */ + public int update (PrFlowMonitoring po){ + return prFlowMonitoringMapper.updateByPrimaryKeySelective(po); + } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java index 322df4d..96513c4 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterCtrl.java @@ -3,10 +3,15 @@ import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring; import com.dy.pipIrrGlobal.pojoPr.PrFlowmeter; +import com.dy.pipIrrGlobal.voPr.VoFlowMeter; +import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring; import com.dy.pipIrrProject.result.ProjectResultCode; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -17,15 +22,9 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; -import java.util.Date; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; /** * @author ZhuBaoMin @@ -37,7 +36,7 @@ @Slf4j @Tag(name = "娴侀噺鐩戞祴绔欑鐞�", description = "娴侀噺鐩戞祴绔欐搷浣�") @RestController -@RequestMapping(path="flowmeter") +@RequestMapping(path = "flowmeter") @RequiredArgsConstructor public class FlowmeterCtrl { private final FlowmeterSv flowmeterSv; @@ -53,25 +52,26 @@ }) @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() - public BaseResponse<Boolean> add(@RequestBody @Valid DtoFlowmeter po, BindingResult bindingResult){ - if(bindingResult != null && bindingResult.hasErrors()){ + public BaseResponse<Boolean> add(@RequestBody @Valid DtoFlowmeter po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } PrFlowmeter prFlowmeter = DtoToFlowmeterPojo.INSTANCT.po2vo(po); Date operateTime = new Date(); prFlowmeter.setOperatedt(operateTime); - prFlowmeter.setDeleted((byte)0); + prFlowmeter.setDeleted((byte) 0); prFlowmeter.setReporttime(operateTime); Integer rec = Optional.ofNullable(flowmeterSv.addFlowmeter(prFlowmeter)).orElse(0); - if(rec == 0) { + if (rec == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.ADD_FLOWMETER_FAIL.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + return BaseResponseUtils.buildSuccess(true); } /** * 鍒犻櫎娴侀噺璁� + * * @param map * @return */ @@ -86,16 +86,40 @@ }) @PostMapping(path = "delete") @SsoAop() - public BaseResponse<Boolean> delete(@RequestBody Map map){ - if(map == null || map.size() <=0) { + public BaseResponse<Boolean> delete(@RequestBody Map map) { + if (map == null || map.size() <= 0) { return BaseResponseUtils.buildFail(ProjectResultCode.PLEASE_INPUT_FLOW_MONITORING_ID.getMessage()); } Long flowmeterId = Long.parseLong(map.get("flowmeterId").toString()); Integer recordCount = Optional.ofNullable(flowmeterSv.deleteFlowmeter(flowmeterId)).orElse(0); - if(recordCount == 0) { + if (recordCount == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_FLOWMETER_FAIL.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + return BaseResponseUtils.buildSuccess(true); + } + + @Operation(summary = "鑾峰緱涓�椤垫祦閲忚璁板綍", description = "杩斿洖涓�椤垫祦閲忚鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�椤垫祦閲忚鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = PrFlowmeter.class))} + ) + }) + @GetMapping(path = "getFlowMeters", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<QueryResultVo<List<VoFlowMeter>>> getFlowMeters(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVoFlowMeter vo) { + try { + QueryResultVo<List<VoFlowMeter>> res = flowmeterSv.getFlowMeters(vo); + if (res == null) { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_FLOWMETERS.getMessage()); + } + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇娴侀噺璁¤褰曞紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterSv.java index 84b38f9..92cab8d 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowmeterSv.java @@ -1,10 +1,17 @@ package com.dy.pipIrrProject.flowMonitoring; +import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoPr.PrFlowmeterMapper; import com.dy.pipIrrGlobal.pojoPr.PrFlowmeter; +import com.dy.pipIrrGlobal.voPr.VoFlowMeter; +import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring; import lombok.extern.slf4j.Slf4j; +import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; /** * @author ZhuBaoMin @@ -42,7 +49,39 @@ * @param flowmeterId * @return */ - public Integer getRecordCountOfFlowmeter(Long flowmeterId) { - return prFlowmeterMapper.getRecordCountOfFlowmeter(flowmeterId); + public Integer getRecordCountOfFlowmeterByCode(Long flowmeterId) { + return prFlowmeterMapper.getRecordCountOfFlowmeterByCode(flowmeterId); + } + + + /** + * 鏍规嵁鎸囧畾鏉′欢寰楀埌娴侀噺璁″疄浣撹褰� + * @param queryVo 缁欑殑鏉′欢 + * @return 娴侀噺璁″疄浣撻泦鍚� + */ + public QueryResultVo<List<VoFlowMeter>> getFlowMeters(QueryVoFlowMeter queryVo){ + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo) ; + + QueryResultVo<List<VoFlowMeter>> rsVo = new QueryResultVo<>() ; + + Integer pageCurr = 0; + Integer pageSize = 10000; + rsVo.pageCurr = 1; + rsVo.pageSize = 10000; + if(queryVo.pageSize != null && queryVo.pageCurr != null) { + rsVo.pageSize = queryVo.pageSize ; + rsVo.pageCurr = queryVo.pageCurr; + pageSize = queryVo.pageSize ; + pageCurr = (Integer.parseInt(params.get("pageCurr").toString()) - 1) * Integer.parseInt(params.get("pageSize").toString()); + } + params.put("pageCurr", pageCurr); + params.put("pageSize", pageSize); + + // 璁$畻绗﹀悎鏉′欢鐨勮褰曟暟 + Integer itemTotal = prFlowmeterMapper.getRecordCountOfFlowMeterByOthers(params); + rsVo.calculateAndSet(itemTotal.longValue(), params); + rsVo.obj = prFlowmeterMapper.getFlowMeters(params); + + return rsVo ; } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowCtrl.java index 1748b64..a2c12df 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowCtrl.java @@ -4,6 +4,7 @@ import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring; import com.dy.pipIrrGlobal.pojoPr.PrMonitoringFlowmeter; import com.dy.pipIrrProject.result.ProjectResultCode; import io.swagger.v3.oas.annotations.Operation; @@ -18,14 +19,9 @@ 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.Date; -import java.util.Objects; -import java.util.Optional; +import java.util.*; /** * @author ZhuBaoMin @@ -37,7 +33,7 @@ @Slf4j @Tag(name = "娴侀噺鐩戞祴绔欍�佹祦閲忚鍏宠仈绠$悊", description = "娴侀噺鐩戞祴绔欍�佹祦閲忚鍏宠仈鎿嶄綔") @RestController -@RequestMapping(path="moni_flow") +@RequestMapping(path = "moni_flow") @RequiredArgsConstructor public class MoniFlowCtrl { private final MoniFlowSv moniFlowSv; @@ -47,9 +43,10 @@ /** * 娴侀噺鐩戞祴绔欑粦瀹氭祦閲忚 - * 鑻ユ祦閲忕洃娴嬬珯鎴栨祦閲忚涓嶅瓨鍦ㄩ渶鎻愮ず鐢ㄦ埛 - * 鑻ユ祦閲忕洃娴嬬珯宸茬粡涓庢祦閲忚缁戝畾闇�鎻愮ず鐢ㄦ埛 - * @param po 缁戝畾鍏崇郴瀵硅薄 + * 鑻ユ祦閲忕洃娴嬬珯鎴栨祦閲忚涓嶅瓨鍦ㄩ渶鎻愮ず鐢ㄦ埛 + * 鑻ユ祦閲忕洃娴嬬珯宸茬粡涓庢祦閲忚缁戝畾闇�鎻愮ず鐢ㄦ埛 + * + * @param po 缁戝畾鍏崇郴瀵硅薄 * @param bindingResult * @return */ @@ -65,34 +62,34 @@ @PostMapping(path = "bind", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> bind(@RequestBody @Valid DtoMoniFlow po, BindingResult bindingResult){ - if(bindingResult != null && bindingResult.hasErrors()){ + public BaseResponse<Boolean> bind(@RequestBody @Valid DtoMoniFlow po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 鏍规嵁缂栧彿鍒嗗埆鑾峰彇娴侀噺鐩戞祴绔欍�佹祦閲忚鏈垹闄よ褰曟暟 - Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoring(po.getMonitoringId())).orElse(0); - Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeter(po.getFlowmeterId())).orElse(0); - if(recFlowMonitoring == 0 || recFlowmeter == 0) { + Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoringByFlowMonitoringId(po.getMonitoringId())).orElse(0); + Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeterByCode(po.getFlowmeterId())).orElse(0); + if (recFlowMonitoring == 0 || recFlowmeter == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.STATION_OR_FLOWMETER_NO_EXIST.getMessage()); } // 鏍规嵁缂栧彿鑾峰彇宸茬粦瀹氭暟閲� - Integer recordCount = Optional.ofNullable(moniFlowSv.getBindRecordCount(po.getMonitoringId(), po.getFlowmeterId(), (byte)1)).orElse(0); - if(recordCount > 0) { + Integer recordCount = Optional.ofNullable(moniFlowSv.getBindRecordCount(po.getMonitoringId(), po.getFlowmeterId(), (byte) 1)).orElse(0); + if (recordCount > 0) { return BaseResponseUtils.buildFail(ProjectResultCode.MONITORING_HAS_BINDED_FLOWMETER.getMessage()); } PrMonitoringFlowmeter prMonitoringFlowmeter = DtoToMoniFlowPojo.INSTANCT.po2vo(po); Date operateTime = new Date(); - prMonitoringFlowmeter .setOperatedt(operateTime); - prMonitoringFlowmeter.setOperatetype((byte)1); + prMonitoringFlowmeter.setOperatedt(operateTime); + prMonitoringFlowmeter.setOperatetype((byte) 1); Integer rec = Optional.ofNullable(moniFlowSv.addRecord(prMonitoringFlowmeter)).orElse(0); - if(rec == 0) { + if (rec == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.MONITORING_FLOWMETER_BIND_FAIL.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + return BaseResponseUtils.buildSuccess(true); } @Operation(summary = "娣诲姞瑙g粦璁板綍", description = "娣诲姞瑙g粦璁板綍") @@ -107,33 +104,63 @@ @PostMapping(path = "unbind", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> unbind(@RequestBody @Valid DtoMoniFlow po, BindingResult bindingResult){ - if(bindingResult != null && bindingResult.hasErrors()){ + public BaseResponse<Boolean> unbind(@RequestBody @Valid DtoMoniFlow po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 鏍规嵁缂栧彿鍒嗗埆鑾峰彇娴侀噺鐩戞祴绔欍�佹祦閲忚鏈垹闄よ褰曟暟 - Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoring(po.getMonitoringId())).orElse(0); - Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeter(po.getFlowmeterId())).orElse(0); - if(recFlowMonitoring == 0 || recFlowmeter == 0) { + Integer recFlowMonitoring = Optional.ofNullable(flowMonitoringSv.getRecordCountOfFlowMonitoringByFlowMonitoringId(po.getMonitoringId())).orElse(0); + Integer recFlowmeter = Optional.ofNullable(flowmeterSv.getRecordCountOfFlowmeterByCode(po.getFlowmeterId())).orElse(0); + if (recFlowMonitoring == 0 || recFlowmeter == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.STATION_OR_FLOWMETER_NO_EXIST.getMessage()); } // 鏍规嵁缂栧彿鑾峰彇宸茬粦瀹氭暟閲� - Integer recordCount = Optional.ofNullable(moniFlowSv.getBindRecordCount(po.getMonitoringId(), po.getFlowmeterId(), (byte)2)).orElse(0); - if(recordCount > 0) { + Integer recordCount = Optional.ofNullable(moniFlowSv.getBindRecordCount(po.getMonitoringId(), po.getFlowmeterId(), (byte) 2)).orElse(0); + if (recordCount > 0) { return BaseResponseUtils.buildFail(ProjectResultCode.STATION_FLOWMETER_HAS_UNBOUND.getMessage()); } PrMonitoringFlowmeter prMonitoringFlowmeter = DtoToMoniFlowPojo.INSTANCT.po2vo(po); Date operateTime = new Date(); - prMonitoringFlowmeter .setOperatedt(operateTime); - prMonitoringFlowmeter.setOperatetype((byte)1); + prMonitoringFlowmeter.setOperatedt(operateTime); + prMonitoringFlowmeter.setOperatetype((byte) 1); Integer rec = Optional.ofNullable(moniFlowSv.addRecord(prMonitoringFlowmeter)).orElse(0); - if(rec == 0) { + if (rec == 0) { return BaseResponseUtils.buildFail(ProjectResultCode.MONITORING_FLOWMETER_BIND_FAIL.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + return BaseResponseUtils.buildSuccess(true); + } + + /** + * 鏍规嵁鐩戞祴绔欑紪鍙疯幏鍙栫粦瀹氳褰� 鎸夋搷浣滄椂闂撮檷搴� + * + * @param monitoringId 鐩戞祴绔欑紪鍙� + * @return 缁戝畾璁板綍 + */ + @Operation(summary = "鑾峰彇缁戝畾璁板綍", description = "杩斿洖鑾峰彇缁戝畾璁板綍") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖缁戝畾璁板綍锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = PrMonitoringFlowmeter.class))} + ) + }) + @GetMapping(path = "bingRecords/{monitoringId}") + @SsoAop() + public BaseResponse<List<Map<String, Object>>> getBingRecordsByMonitoringId(@PathVariable("monitoringId") Long monitoringId) { + try { + List<Map<String, Object>> list = Optional.ofNullable(moniFlowSv.getBingRecordsByMonitoringId(monitoringId)).orElse(new ArrayList<>()); + if (list.size() <= 0) { + return BaseResponseUtils.buildFail(ProjectResultCode.NO_MONITORING_FLOWMETERS.getMessage()); + } + return BaseResponseUtils.buildSuccess(list); + } catch (Exception e) { + log.error("鏌ヨ缁戝畾璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowSv.java index 2577ae9..2c74c88 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/MoniFlowSv.java @@ -6,6 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Map; + /** * @author ZhuBaoMin * @date 2024-01-05 10:25 @@ -39,4 +42,12 @@ return prMonitoringFlowmeterMapper.getBindRecordCount(monitoringId, flowmeterId, operateType); } + /** + * 鏍规嵁 娴侀噺鐩戞祴绔欑紪鍙� 鑾峰彇 缁戝畾璁板綍 鎸夋搷浣滄椂闂撮檷搴� + * @param monitoringId + * @return PrMonitoringFlowmeter + * */ + public List<Map<String, Object>> getBingRecordsByMonitoringId(Long monitoringId){ + return prMonitoringFlowmeterMapper.getBingRecordsByMonitoringId(monitoringId); + } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/QueryVoFlowMeter.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/QueryVoFlowMeter.java new file mode 100644 index 0000000..5f131cf --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/QueryVoFlowMeter.java @@ -0,0 +1,27 @@ +package com.dy.pipIrrProject.flowMonitoring; + +import com.dy.common.webUtil.QueryConditionVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +/** + * @author :WuZeYu + * @Date :2024/1/15 11:12 + * @LastEditTime :2024/1/15 11:12 + * @Description + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ToString(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Schema(name = "绠$綉娴侀噺璁℃煡璇㈡潯浠�") +public class QueryVoFlowMeter extends QueryConditionVo { + + @Schema(description = "娴侀噺璁$紪鍙�") + public String code; + + @Schema(title = "鍦ㄧ嚎鐘舵��") + private Integer onlineState; +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java index d56066c..6b781f3 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java @@ -51,12 +51,14 @@ FLOW_MONITORING_FAIL(50001, "娴侀噺鐩戞祴绔欐坊鍔犲け璐�"), PLEASE_INPUT_FLOW_MONITORING_ID(50002, "璇疯緭鍏ユ祦閲忕洃娴嬬珯缂栧彿"), DELETE_FLOW_MONITORING_FAIL(50003, "娴侀噺鐩戞祴绔欏垹闄ゅけ璐�"), - + UPDATE_FLOW_MONITORING_FAIL(50004, "淇敼鐩戞祴绔欐暟鎹け璐�"), + NO_FLOW_MONITORINGS(50005, "娌℃湁绗﹀悎鏉′欢鐩戞祴绔欐暟鎹�"), /** * 娴侀噺璁� */ ADD_FLOWMETER_FAIL(60001, "娴侀噺璁℃坊鍔犲け璐�"), DELETE_FLOWMETER_FAIL(60002, "娴侀噺璁″垹闄ゅけ璐�"), + NO_FLOWMETERS(60003, "娌℃湁绗﹀悎鏉′欢娴侀噺璁℃暟鎹�"), /** * 娴侀噺鐩戞祴绔欍�佹祦閲忚鍏宠仈 @@ -64,7 +66,8 @@ MONITORING_HAS_BINDED_FLOWMETER(70001, "娴侀噺鐩戞祴绔欎笌娴侀噺璁″凡缁戝畾"), MONITORING_FLOWMETER_BIND_FAIL(70002, "娴侀噺鐩戞祴绔欎笌娴侀噺璁$粦瀹氬け璐�"), STATION_OR_FLOWMETER_NO_EXIST(70003, "娴侀噺鐩戞祴绔欐垨娴侀噺璁′笉瀛樺湪"), - STATION_FLOWMETER_HAS_UNBOUND(70004, "娴侀噺鐩戞祴绔欎笌娴侀噺璁″凡瑙g粦"); + STATION_FLOWMETER_HAS_UNBOUND(70004, "娴侀噺鐩戞祴绔欎笌娴侀噺璁″凡瑙g粦"), + NO_MONITORING_FLOWMETERS(70005, "娌℃湁绗﹀悎鏉′欢鐨勭粦瀹氳褰曟暟鎹�"); private final Integer code; private final String message; -- Gitblit v1.8.0