2024-01-02 朱宝民 控制器查询,绑定记录查询
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrController; |
| | | import com.dy.pipIrrGlobal.voPr.VoController; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023-12-29 9:59 |
| | | * @LastEditTime 2023-12-29 9:59 |
| | | * @LastEditTime 2024-01-02 16:22 |
| | | * @Description |
| | | */ |
| | | |
| | |
| | | int updateByPrimaryKeySelective(PrController record); |
| | | |
| | | int updateByPrimaryKey(PrController record); |
| | | |
| | | /** |
| | | * 根据指定获取控制器记录数 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Long getRecordCount(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据指定获取控制器记录 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<VoController> getControllers(Map<?, ?> params); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.daoPr; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrIntakeController; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-01-02 9:16 |
| | | * @LastEditTime 2024-01-02 9:16 |
| | | * @Description |
| | | */ |
| | | |
| | | @Mapper |
| | | public interface PrIntakeControllerMapper extends BaseMapper<PrIntakeController> { |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PrIntakeController record); |
| | | |
| | | int insertSelective(PrIntakeController record); |
| | | |
| | | PrIntakeController selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(PrIntakeController record); |
| | | |
| | | int updateByPrimaryKey(PrIntakeController record); |
| | | |
| | | /** |
| | | * 根据取水口编号、控制器编号、操作类别获取记录数量 |
| | | * 重复绑定、重复解绑都用该方法判断 |
| | | * @param intakeId 取水口ID |
| | | * @param controllerId 控制器ID |
| | | * @param operateType 操作类型 1-捆绑,2-解绑 |
| | | * @return 如何条件记录数 |
| | | */ |
| | | Integer getBindRecordCount(@Param("intakeId") Long intakeId, @Param("controllerId") Long controllerId, @Param("operateType") Byte operateType); |
| | | |
| | | /** |
| | | * 根据取水口编号获取绑定记录列表 |
| | | * @param intakeId 取水口编号 |
| | | * @return 取水口与控制器绑定列表 |
| | | */ |
| | | List<Map<String, Object>> getBindsByIntakeId(@Param("intakeId") Long intakeId); |
| | | |
| | | /** |
| | | * 根据控制器编号获取绑定记录列表 |
| | | * @param controllerId 控制器编号 |
| | | * @return 取水口与控制器绑定列表 |
| | | */ |
| | | List<Map<String, Object>> getBindsByControllerId(@Param("controllerId") Long controllerId); |
| | | } |
| | |
| | | public static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | * 主键 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @TableId(type = IdType.INPUT) |
| | | @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | * 编号 |
| | | */ |
| | | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "控制器编号不能为空") |
| | | @Length(message = "控制器编号不大于{max}字",max = 25) |
| | | private String code; |
| | | |
| | | /** |
| | | * 通讯协议 |
| | | */ |
| | | * 通讯协议 |
| | | */ |
| | | @Schema(description = "通讯协议", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "通讯协议不能为空") |
| | | @Length(message = "通讯协议不大于{max}字",max = 25) |
| | | private String protocol; |
| | | |
| | | /** |
| | | * 添加方式;1-系统自动,2-手动 |
| | | */ |
| | | * 在线状态;1-在线,2-离线 |
| | | */ |
| | | @Schema(description = "在线状态", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Byte onlinestate; |
| | | |
| | | /** |
| | | * 最近上报时间 |
| | | */ |
| | | @Schema(description = "最近上报时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Date reporttime; |
| | | |
| | | /** |
| | | * 添加方式;1-系统自动,2-手动 |
| | | */ |
| | | @Schema(description = "添加方式", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Byte addways; |
| | | |
| | | /** |
| | | * 操作人编号 |
| | | */ |
| | | * 操作人编号 |
| | | */ |
| | | @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long operator; |
| | | |
| | | /** |
| | | * 操作时间 |
| | | */ |
| | | * 操作时间 |
| | | */ |
| | | @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Date operatedt; |
| | | |
| | | /** |
| | | * 逻辑删除标识;0-未删除,1-删除 |
| | | */ |
| | | * 逻辑删除标识;0-未删除,1-删除 |
| | | */ |
| | | @Schema(description = "删除标识", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Byte deleted; |
| | | } |
New file |
| | |
| | | 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.Max; |
| | | import jakarta.validation.constraints.Min; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Positive; |
| | | import lombok.*; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-01-02 9:16 |
| | | * @LastEditTime 2024-01-02 9:16 |
| | | * @Description |
| | | */ |
| | | |
| | | /** |
| | | * 取水口捆绑表 |
| | | */ |
| | | |
| | | @TableName(value="pr_intake_controller", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Schema(name = "取水口捆绑实体") |
| | | public class PrIntakeController implements BaseEntity { |
| | | public static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @TableId(type = IdType.INPUT) |
| | | @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 取水口编号 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "取水口ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "取水口ID不能为空") |
| | | private Long intakeid; |
| | | |
| | | /** |
| | | * 控制器编号 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "控制器ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "控制器ID不能为空") |
| | | private Long controllerid; |
| | | |
| | | /** |
| | | * 操作类型;1-捆绑,2-解绑 |
| | | */ |
| | | @Schema(description = "操作类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Max(message = "操作类型只能1或2", value = 2) |
| | | @Min(message = "操作类型只能1或2",value = 1) |
| | | private Byte operatetype; |
| | | |
| | | /** |
| | | * 备注信息 |
| | | */ |
| | | @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Length(message = "备注长度小于{max}字", min = 1, max = 200) |
| | | private String remarks; |
| | | |
| | | /** |
| | | * 操作人编号 |
| | | */ |
| | | @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Positive(message = "操作人编号必须为大于0的整数") |
| | | private Long operator; |
| | | |
| | | /** |
| | | * 操作时间 |
| | | */ |
| | | @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Date operatedt; |
| | | |
| | | } |
| | |
| | | @Schema(title = "控制器编号") |
| | | @ExcelProperty("控制器编号") |
| | | @ColumnWidth(15) |
| | | private String code; |
| | | private String controllerCode; |
| | | |
| | | @Schema(title = "在线状态") |
| | | @ExcelProperty("在线状态") |
| | | @ColumnWidth(15) |
| | | private String state; |
| | | private String onlineState; |
| | | |
| | | @Schema(title = "绑定取水口") |
| | | @ExcelProperty("绑定取水口") |
| | |
| | | @Schema(title = "绑定次数") |
| | | @ExcelProperty("绑定次数") |
| | | @ColumnWidth(10) |
| | | private Integer bindings; |
| | | private Integer bindNumber; |
| | | |
| | | @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; |
| | | private Date reportTime; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.voSe; |
| | | |
| | | 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 ZhuBaoMin |
| | | * @date 2024-01-02 15:56 |
| | | * @LastEditTime 2024-01-02 15:56 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @Schema(title = "控制器视图对象") |
| | | public class VoController implements BaseEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(title = "ID") |
| | | private Long id; |
| | | |
| | | @Schema(title = "控制器编号") |
| | | private Long controllerCode; |
| | | |
| | | @Schema(title = "在线状态") |
| | | private String onlineState; |
| | | |
| | | @Schema(title = "绑定取水口") |
| | | private String intakeName; |
| | | |
| | | @Schema(title = "绑定次数") |
| | | private Integer bindNumber; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @Schema(title = "最近上报时间") |
| | | private Date reportTime; |
| | | } |
| | |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="code" jdbcType="VARCHAR" property="code" /> |
| | | <result column="protocol" jdbcType="VARCHAR" property="protocol" /> |
| | | <result column="onlineState" jdbcType="TINYINT" property="onlinestate" /> |
| | | <result column="reportTime" jdbcType="TIMESTAMP" property="reporttime" /> |
| | | <result column="addWays" jdbcType="TINYINT" property="addways" /> |
| | | <result column="operator" jdbcType="BIGINT" property="operator" /> |
| | | <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" /> |
| | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, code, protocol, addWays, `operator`, operateDt, deleted |
| | | id, code, protocol, onlineState, reportTime, addWays, `operator`, operateDt, deleted |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrController"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_controller (id, code, protocol, |
| | | addWays, `operator`, operateDt, |
| | | deleted) |
| | | onlineState, reportTime, addWays, |
| | | `operator`, operateDt, deleted |
| | | ) |
| | | values (#{id,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, |
| | | #{addways,jdbcType=TINYINT}, #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP}, |
| | | #{deleted,jdbcType=TINYINT}) |
| | | #{onlinestate,jdbcType=TINYINT}, #{reporttime,jdbcType=TIMESTAMP}, #{addways,jdbcType=TINYINT}, |
| | | #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT} |
| | | ) |
| | | </insert> |
| | | |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrController"> |
| | |
| | | </if> |
| | | <if test="protocol != null"> |
| | | protocol, |
| | | </if> |
| | | <if test="onlinestate != null"> |
| | | onlineState, |
| | | </if> |
| | | <if test="reporttime != null"> |
| | | reportTime, |
| | | </if> |
| | | <if test="addways != null"> |
| | | addWays, |
| | |
| | | </if> |
| | | <if test="protocol != null"> |
| | | #{protocol,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="onlinestate != null"> |
| | | #{onlinestate,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="reporttime != null"> |
| | | #{reporttime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="addways != null"> |
| | | #{addways,jdbcType=TINYINT}, |
| | |
| | | <if test="protocol != null"> |
| | | protocol = #{protocol,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="onlinestate != null"> |
| | | onlineState = #{onlinestate,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="reporttime != null"> |
| | | reportTime = #{reporttime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="addways != null"> |
| | | addWays = #{addways,jdbcType=TINYINT}, |
| | | </if> |
| | |
| | | update pr_controller |
| | | set code = #{code,jdbcType=VARCHAR}, |
| | | protocol = #{protocol,jdbcType=VARCHAR}, |
| | | onlineState = #{onlinestate,jdbcType=TINYINT}, |
| | | reportTime = #{reporttime,jdbcType=TIMESTAMP}, |
| | | addWays = #{addways,jdbcType=TINYINT}, |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | operateDt = #{operatedt,jdbcType=TIMESTAMP}, |
| | | deleted = #{deleted,jdbcType=TINYINT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <!--根据指定获取控制器记录数--> |
| | | <select id="getRecordCount" resultType="java.lang.Long"> |
| | | SELECT |
| | | COUNT(*) AS recordCount |
| | | FROM pr_controller con |
| | | INNER JOIN pr_intake_controller ic ON ic.controllerId = con.id |
| | | INNER JOIN pr_intake inta ON ic.intakeId = inta.id |
| | | , (SELECT @i:=0) AS itable |
| | | <where> |
| | | AND ic.operateType = 1 |
| | | <if test = "controllerCode != null and controllerCode !=''"> |
| | | AND con.code like CONCAT('%',#{controllerCode},'%') |
| | | </if> |
| | | |
| | | <if test = "onlineState != null and onlineState > 0"> |
| | | AND con.onlineState = ${onlineState} |
| | | </if> |
| | | |
| | | <if test = "bindNumber != null and bindNumber > 0"> |
| | | AND (SELECT COUNT(*) FROM pr_intake_controller WHERE controllerId = con.id AND intakeId = inta.id AND operateType = 1) = ${bindNumber} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <!--根据指定获取控制器记录--> |
| | | <select id="getControllers" resultType="com.dy.pipIrrGlobal.voPr.VoController"> |
| | | SELECT |
| | | (@i:=@i+1) AS id, |
| | | con.code AS controllerCode, |
| | | (CASE |
| | | WHEN con.onlineState = 1 THEN "在线" |
| | | WHEN con.onlineState = 2 THEN "离线" |
| | | END) AS onlineState, |
| | | inta.name AS intakeName, |
| | | (SELECT COUNT(*) FROM pr_intake_controller WHERE controllerId = con.id AND intakeId = inta.id AND operateType = 1) AS bindNumber, |
| | | con.reportTime |
| | | FROM pr_controller con |
| | | INNER JOIN pr_intake_controller ic ON ic.controllerId = con.id |
| | | INNER JOIN pr_intake inta ON ic.intakeId = inta.id |
| | | , (SELECT @i:=0) AS itable |
| | | <where> |
| | | AND ic.operateType = 1 |
| | | <if test = "controllerCode != null and controllerCode !=''"> |
| | | AND con.code like CONCAT('%',#{controllerCode},'%') |
| | | </if> |
| | | |
| | | <if test = "onlineState != null and onlineState > 0"> |
| | | AND con.onlineState = ${onlineState} |
| | | </if> |
| | | |
| | | <if test = "bindNumber != null and bindNumber > 0"> |
| | | AND (SELECT COUNT(*) FROM pr_intake_controller WHERE controllerId = con.id AND intakeId = inta.id AND operateType = 1) = ${bindNumber} |
| | | </if> |
| | | </where> |
| | | ORDER BY con.operateDt DESC |
| | | <if test="pageCurr != null and pageSize != null"> |
| | | LIMIT ${pageCurr}, ${pageSize} |
| | | </if> |
| | | |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrIntakeController"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table pr_intake_controller--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="intakeId" jdbcType="BIGINT" property="intakeid" /> |
| | | <result column="controllerId" jdbcType="BIGINT" property="controllerid" /> |
| | | <result column="operateType" jdbcType="TINYINT" property="operatetype" /> |
| | | <result column="remarks" jdbcType="VARCHAR" property="remarks" /> |
| | | <result column="operator" jdbcType="BIGINT" property="operator" /> |
| | | <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, intakeId, controllerId, operateType, remarks, `operator`, operateDt |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from pr_intake_controller |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from pr_intake_controller |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntakeController"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_intake_controller (id, intakeId, controllerId, |
| | | operateType, remarks, `operator`, |
| | | operateDt) |
| | | values (#{id,jdbcType=BIGINT}, #{intakeid,jdbcType=BIGINT}, #{controllerid,jdbcType=BIGINT}, |
| | | #{operatetype,jdbcType=TINYINT}, #{remarks,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, |
| | | #{operatedt,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntakeController"> |
| | | <!--@mbg.generated--> |
| | | insert into pr_intake_controller |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="intakeid != null"> |
| | | intakeId, |
| | | </if> |
| | | <if test="controllerid != null"> |
| | | controllerId, |
| | | </if> |
| | | <if test="operatetype != null"> |
| | | operateType, |
| | | </if> |
| | | <if test="remarks != null"> |
| | | remarks, |
| | | </if> |
| | | <if test="operator != null"> |
| | | `operator`, |
| | | </if> |
| | | <if test="operatedt != null"> |
| | | operateDt, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="intakeid != null"> |
| | | #{intakeid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="controllerid != null"> |
| | | #{controllerid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operatetype != null"> |
| | | #{operatetype,jdbcType=TINYINT}, |
| | | </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> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntakeController"> |
| | | <!--@mbg.generated--> |
| | | update pr_intake_controller |
| | | <set> |
| | | <if test="intakeid != null"> |
| | | intakeId = #{intakeid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="controllerid != null"> |
| | | controllerId = #{controllerid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operatetype != null"> |
| | | operateType = #{operatetype,jdbcType=TINYINT}, |
| | | </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> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntakeController"> |
| | | <!--@mbg.generated--> |
| | | update pr_intake_controller |
| | | set intakeId = #{intakeid,jdbcType=BIGINT}, |
| | | controllerId = #{controllerid,jdbcType=BIGINT}, |
| | | operateType = #{operatetype,jdbcType=TINYINT}, |
| | | remarks = #{remarks,jdbcType=VARCHAR}, |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | operateDt = #{operatedt,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <!--根据取水口编号、控制器编号、操作类别获取记录数量--> |
| | | <select id="getBindRecordCount" resultType="java.lang.Integer"> |
| | | SELECT |
| | | COUNT(*) AS recordCount |
| | | FROM pr_intake_controller |
| | | <where> |
| | | <if test = "intakeId != null and intakeId > 0"> |
| | | AND intakeId = ${intakeId} |
| | | </if> |
| | | |
| | | <if test = "controllerId != null and controllerId > 0"> |
| | | AND controllerId = ${controllerId} |
| | | </if> |
| | | |
| | | <if test = "operateType != null and operateType > 0"> |
| | | AND operateType = ${operateType} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <!--根据取水口编号获取绑定记录列表--> |
| | | <select id="getBindsByIntakeId" resultType="java.util.Map"> |
| | | SELECT |
| | | user.name AS userName, |
| | | con.code AS controllerCode, |
| | | (CASE |
| | | WHEN ic.operateType = 1 THEN "绑定" |
| | | WHEN ic.operateType = 2 THEN "解绑" |
| | | END) AS operateType, |
| | | ic.operateDt |
| | | FROM pr_intake inta |
| | | INNER JOIN pr_intake_controller ic ON inta.id= ic.intakeId |
| | | INNER JOIN ba_user user ON ic.operator = user.id |
| | | INNER JOIN pr_controller con ON ic.controllerId = con.id |
| | | <if test = "intakeId != null and intakeId > 0"> |
| | | AND inta.id = ${intakeId} |
| | | </if> |
| | | ORDER BY ic.operateDt DESC |
| | | </select> |
| | | |
| | | <!--根据控制器编号获取绑定记录列表--> |
| | | <select id="getBindsByControllerId" resultType="java.util.Map"> |
| | | SELECT |
| | | (CASE |
| | | WHEN ic.operateType = 1 THEN "绑定" |
| | | WHEN ic.operateType = 2 THEN "解绑" |
| | | END) AS operateType, |
| | | inta.name AS intakeName, |
| | | user.name AS userName, |
| | | ic.operateDt |
| | | FROM pr_controller con |
| | | INNER JOIN pr_intake_controller ic ON ic.controllerId = con.id |
| | | INNER JOIN pr_intake inta ON ic.intakeId = inta.id |
| | | INNER JOIN ba_user user ON ic.operator = user.id |
| | | <if test = "controllerId != null and controllerId > 0"> |
| | | AND con.id = ${controllerId} |
| | | </if> |
| | | ORDER BY ic.operateDt DESC |
| | | </select> |
| | | </mapper> |
| | |
| | | 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.PrController; |
| | | import com.dy.pipIrrGlobal.voPr.VoController; |
| | | 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.media.Content; |
| | |
| | | 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.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | |
| | |
| | | public class ControllerCtrl { |
| | | private final ControllerSv controllerSv; |
| | | |
| | | @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 = VoActiveCard.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "/getControllers") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoController>>> getControllers(QueryVo vo){ |
| | | try { |
| | | QueryResultVo<List<VoController>> res = controllerSv.getControllers(vo); |
| | | if(res.itemTotal != null && res.itemTotal > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | }else { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.NO_RECORDS.getMessage()); |
| | | } |
| | | //return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取开卡记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加控制器 |
| | | * @param po 控制器实体对象 |
| | | * @param bindingResult |
| | | * @return 添加是否成功 |
| | | */ |
| | | @Operation(summary = "添加控制器记录", description = "添加控制器记录") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | |
| | | @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> add(@RequestBody @Valid PrController po, BindingResult bindingResult){ |
| | | public BaseResponse<Boolean> add(@RequestBody @Valid DtoController po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | PrController prController = DtoToPojo.INSTANCT.po2vo(po); |
| | | Date operateTime = new Date(); |
| | | po.setOperatedt(operateTime); |
| | | po.setDeleted((byte)0); |
| | | Integer rec = Optional.ofNullable(controllerSv.addController(po)).orElse(0); |
| | | prController.setOperatedt(operateTime); |
| | | prController.setDeleted((byte)0); |
| | | prController.setOnlinestate((byte)2); |
| | | prController.setReporttime(operateTime); |
| | | Integer rec = Optional.ofNullable(controllerSv.addController(prController)).orElse(0); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.CONTROLLER_FAIL.getMessage()); |
| | | } |
| | |
| | | package com.dy.pipIrrProject.controller; |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoPr.PrControllerMapper; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrController; |
| | | import com.dy.pipIrrGlobal.voPr.VoController; |
| | | 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 |
| | |
| | | private PrControllerMapper prControllerMapper; |
| | | |
| | | /** |
| | | * 根据指定获取控制器记录 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoController>> getControllers(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | Long itemTotal = prControllerMapper.getRecordCount(params); |
| | | |
| | | QueryResultVo<List<VoController>> 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); |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = prControllerMapper.getControllers(params); |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 添加控制器 |
| | | * @param po |
| | | * @return |
New file |
| | |
| | | package com.dy.pipIrrProject.controller; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-01-02 16:36 |
| | | * @LastEditTime 2024-01-02 16:36 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @Schema(name = "控制器传入对象") |
| | | public class DtoController { |
| | | public static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "控制器编号不能为空") |
| | | @Length(message = "控制器编号不大于{max}字",max = 25) |
| | | private String code; |
| | | |
| | | /** |
| | | * 通讯协议 |
| | | */ |
| | | @Schema(description = "通讯协议", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "通讯协议不能为空") |
| | | @Length(message = "通讯协议不大于{max}字",max = 25) |
| | | private String protocol; |
| | | |
| | | /** |
| | | * 添加方式;1-系统自动,2-手动 |
| | | */ |
| | | @Schema(description = "添加方式", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Byte addWays; |
| | | |
| | | /** |
| | | * 操作人编号 |
| | | */ |
| | | @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long operator; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrProject.controller; |
| | | |
| | | import com.dy.pipIrrGlobal.pojoPr.PrController; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mapping; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-01-02 16:39 |
| | | * @LastEditTime 2024-01-02 16:39 |
| | | * @Description |
| | | */ |
| | | |
| | | @Mapper |
| | | public interface DtoToPojo { |
| | | DtoToPojo INSTANCT = Mappers.getMapper(DtoToPojo.class); |
| | | @Mapping(target = "code", source = "code") |
| | | @Mapping(target = "protocol", source = "protocol") |
| | | @Mapping(target = "addways", source = "addWays") |
| | | @Mapping(target = "operator", source = "operator") |
| | | PrController po2vo(DtoController po); |
| | | } |
| | |
| | | package com.dy.pipIrrProject.controller; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.*; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023-12-29 10:07 |
| | | * @LastEditTime 2023-12-29 10:07 |
| | | * @Description |
| | | */ |
| | | public class QueryVo { |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | @Schema(name = "控制器查询条件") |
| | | public class QueryVo extends QueryConditionVo { |
| | | |
| | | @Schema(description = "控制器编号") |
| | | private String controllerCode; |
| | | |
| | | @Schema(description = "在线状态") |
| | | public Integer onlineState; |
| | | |
| | | @Schema(description = "绑定数量") |
| | | public Integer bindNumber; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrProject.intakeController; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Positive; |
| | | import lombok.Data; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-01-02 10:53 |
| | | * @LastEditTime 2024-01-02 10:53 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @Schema(name = "取水口、控制器绑定关系传入对象") |
| | | public class DtoIntakeController { |
| | | public static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 取水口编号 |
| | | */ |
| | | @Schema(description = "取水口ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "取水口ID不能为空") |
| | | private Long intakeId; |
| | | |
| | | /** |
| | | * 控制器编号 |
| | | */ |
| | | @Schema(description = "控制器ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "控制器ID不能为空") |
| | | private Long controllerId; |
| | | |
| | | /** |
| | | * 备注信息 |
| | | */ |
| | | @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Length(message = "备注长度小于{max}字", min = 1, max = 200) |
| | | private String remarks; |
| | | |
| | | /** |
| | | * 操作人编号 |
| | | */ |
| | | @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Positive(message = "操作人编号必须为大于0的整数") |
| | | private Long operator; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrProject.intakeController; |
| | | |
| | | import com.dy.pipIrrGlobal.pojoPr.PrIntakeController; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mapping; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-01-02 10:59 |
| | | * @LastEditTime 2024-01-02 10:59 |
| | | * @Description DtoToPojo 转 PrIntakeController |
| | | */ |
| | | |
| | | @Mapper |
| | | public interface DtoToPojo { |
| | | DtoToPojo INSTANCT = Mappers.getMapper(DtoToPojo.class); |
| | | @Mapping(target = "intakeid", source = "intakeId") |
| | | @Mapping(target = "controllerid", source = "controllerId") |
| | | @Mapping(target = "remarks", source = "remarks") |
| | | @Mapping(target = "operator", source = "operator") |
| | | PrIntakeController po2vo(DtoIntakeController po); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrProject.intakeController; |
| | | |
| | | 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.PrIntakeController; |
| | | import com.dy.pipIrrProject.result.ProjectResultCode; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| | | import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-01-02 9:18 |
| | | * @LastEditTime 2024-01-02 9:18 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "取水口/控制器关联管理", description = "取水口/控制器关联操作") |
| | | @RestController |
| | | @RequestMapping(path="intake_controller") |
| | | @RequiredArgsConstructor |
| | | public class IntakeControllerCtrl { |
| | | private final IntakeControllerSv intakeControllerSv; |
| | | |
| | | /** |
| | | * 添加取水口/控制器捆绑记录 |
| | | * 1. 判断取水口是否存在 |
| | | * 2. 判断控制器是否存在 |
| | | * 3. 判断取水口、控制器绑定关系是否已存在 |
| | | */ |
| | | @Operation(summary = "添加绑定记录", description = "添加绑定记录") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "操作结果:true:成功,false:失败(BaseResponse.content)", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = Boolean.class))} |
| | | ) |
| | | }) |
| | | @PostMapping(path = "bind", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> bind(@RequestBody @Valid DtoIntakeController po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Integer recordCount = Optional.ofNullable(intakeControllerSv.getBindRecordCount(po.getIntakeId(), po.getControllerId(), (byte)1)).orElse(0); |
| | | if(recordCount > 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_HAS_BINDED_CONTROLLER.getMessage()); |
| | | } |
| | | |
| | | PrIntakeController prIntakeController = DtoToPojo.INSTANCT.po2vo(po); |
| | | Date operateTime = new Date(); |
| | | prIntakeController.setOperatedt(operateTime); |
| | | prIntakeController.setOperatetype((byte)1); |
| | | |
| | | Integer rec = Optional.ofNullable(intakeControllerSv.addRecord(prIntakeController)).orElse(0); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | |
| | | /** |
| | | * 添加取水口/控制器解绑记录 |
| | | * 1. 判断取水口是否存在 |
| | | * 2. 判断控制器是否存在 |
| | | * 3. 判断取水口、控制器解绑关系是否已存在 |
| | | */ |
| | | @Operation(summary = "添加解绑记录", description = "添加解绑记录") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "操作结果:true:成功,false:失败(BaseResponse.content)", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = Boolean.class))} |
| | | ) |
| | | }) |
| | | @PostMapping(path = "unbind", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> unbind(@RequestBody @Valid DtoIntakeController po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Integer recordCount = Optional.ofNullable(intakeControllerSv.getBindRecordCount(po.getIntakeId(), po.getControllerId(), (byte)2)).orElse(0); |
| | | if(recordCount > 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_CONTROLLER_HAS_UNBOUND.getMessage()); |
| | | } |
| | | |
| | | PrIntakeController prIntakeController = DtoToPojo.INSTANCT.po2vo(po); |
| | | Date operateTime = new Date(); |
| | | prIntakeController.setOperatedt(operateTime); |
| | | prIntakeController.setOperatetype((byte)2); |
| | | |
| | | Integer rec = Optional.ofNullable(intakeControllerSv.addRecord(prIntakeController)).orElse(0); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | |
| | | /** |
| | | * 根据取水口编号获取绑定记录列表 |
| | | * @param intakeId 取水口编号 |
| | | * @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 = BaClient.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "intake_binds") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getBindsByIntakeId(Long intakeId){ |
| | | try { |
| | | List<Map<String, Object>> list = Optional.ofNullable(intakeControllerSv.getBindsByIntakeId(intakeId)).orElse(new ArrayList<>()); |
| | | if(list.size() <= 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_NO_RECORDS.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } catch (Exception e) { |
| | | log.error("查询农户异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据控制器编号获取绑定记录列表 |
| | | * @param controllerId 控制器编号 |
| | | * @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 = BaClient.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "controller_binds") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getBindsByControllerId(Long controllerId){ |
| | | try { |
| | | List<Map<String, Object>> list = Optional.ofNullable(intakeControllerSv.getBindsByControllerId(controllerId)).orElse(new ArrayList<>()); |
| | | if(list.size() <= 0) { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.CONTROLLER_NO_RECORDS.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } catch (Exception e) { |
| | | log.error("查询农户异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrProject.intakeController; |
| | | |
| | | import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper; |
| | | import com.dy.pipIrrGlobal.pojoPr.PrIntakeController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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-02 9:19 |
| | | * @LastEditTime 2024-01-02 9:19 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class IntakeControllerSv { |
| | | @Autowired |
| | | private PrIntakeControllerMapper prIntakeControllerMapper; |
| | | |
| | | /** |
| | | * 根据取水口编号、控制器编号、操作类别获取记录数量 |
| | | * 重复绑定、重复解绑都用该方法判断 |
| | | * @param intakeId 取水口ID |
| | | * @param controllerId 控制器ID |
| | | * @param operateType 操作类型 1-捆绑,2-解绑 |
| | | * @return 如何条件记录数 |
| | | */ |
| | | Integer getBindRecordCount(Long intakeId, Long controllerId, Byte operateType) { |
| | | return prIntakeControllerMapper.getBindRecordCount(intakeId, controllerId, operateType); |
| | | } |
| | | /** |
| | | * 添加取水口、控制器捆绑记录,1-捆绑,2-解绑 |
| | | * @param po 取水口/控制器实体对象 |
| | | * @return |
| | | */ |
| | | Integer addRecord(PrIntakeController po) { |
| | | return prIntakeControllerMapper.insert(po); |
| | | } |
| | | |
| | | /** |
| | | * 根据取水口编号获取绑定记录列表 |
| | | * @param intakeId 取水口编号 |
| | | * @return 取水口与控制器绑定列表 |
| | | */ |
| | | List<Map<String, Object>> getBindsByIntakeId(Long intakeId) { |
| | | return prIntakeControllerMapper.getBindsByIntakeId(intakeId); |
| | | } |
| | | |
| | | /** |
| | | * 根据控制器编号获取绑定记录列表 |
| | | * @param controllerId 控制器编号 |
| | | * @return 取水口与控制器绑定列表 |
| | | */ |
| | | List<Map<String, Object>> getBindsByControllerId(Long controllerId) { |
| | | return prIntakeControllerMapper.getBindsByControllerId(controllerId); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 控制器 |
| | | */ |
| | | CONTROLLER_FAIL(30001, "控制器添加失败"); |
| | | CONTROLLER_FAIL(30001, "控制器添加失败"), |
| | | NO_RECORDS(30001, "没有符合条件的控制器数据"), |
| | | |
| | | /** |
| | | * 取水口、控制器关联 |
| | | */ |
| | | INTAKE_HAS_BINDED_CONTROLLER(40001, "取水口与控制器已绑定"), |
| | | BIND_FAIL(40002, "取水口与控制器绑定失败"), |
| | | INTAKE_CONTROLLER_HAS_UNBOUND(40003, "取水口与控制器已解绑"), |
| | | INTAKE_NO_RECORDS(40004, "该取水口无绑定记录"), |
| | | CONTROLLER_NO_RECORDS(40005, "该控制器无绑定记录"); |
| | | private final Integer code; |
| | | private final String message; |
| | | } |