liurunyu
2024-10-28 302b525c1bd459b2fc6e27d3b4073aee6e8b3f2b
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
6个文件已修改
3个文件已添加
337 ■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrCommonIntakesMapper.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrCommonIntakes.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrCommonIntakesMapper.xml 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java
@@ -11,9 +11,11 @@
import com.dy.pipIrrGlobal.command.enums.LastOperateENUM;
import com.dy.pipIrrGlobal.command.result.CommandResultCode;
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.daoPr.PrCommonIntakesMapper;
import com.dy.pipIrrGlobal.daoPr.PrControllerMapper;
import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes;
import com.dy.pipIrrGlobal.pojoPr.PrController;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard;
@@ -78,6 +80,9 @@
    @Autowired
    private SeVirtualCardMapper seVirtualCardMapper;
    @Autowired
    private PrCommonIntakesMapper prCommonIntakesMapper;
    public static ComSupport comSupport;
@@ -279,6 +284,9 @@
        rmCommandHistoryMapper.insert(rmCommandHistory);
        comId = rmCommandHistory.getComId();
        // 添加常用取水口或更新使用信息
        addCommonIntake(operator, intakeId);
        /**
         * 处理回调
         * feature准备就绪后发送命令
@@ -357,4 +365,25 @@
        return response_CallBack;
    }
    /**
     * 添加常用取水口或更新使用信息
     * @param intakeId
     * @return
     */
    public Integer addCommonIntake(Long operatorId, Long intakeId) {
        PrCommonIntakes commonIntake = prCommonIntakesMapper.selectByOperatorAndIntake(operatorId, intakeId);
        if(commonIntake == null) {
            commonIntake = new PrCommonIntakes();
            commonIntake.setOperatorId(operatorId);
            commonIntake.setIntakeId(intakeId);
            commonIntake.setLastUsedTime(new Date());
            commonIntake.setUsageCount(1);
            return prCommonIntakesMapper.insert(commonIntake);
        }
        commonIntake.setLastUsedTime(new Date());
        commonIntake.setUsageCount(commonIntake.getUsageCount() + 1);
        return prCommonIntakesMapper.updateByPrimaryKeySelective(commonIntake);
    }
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrCommonIntakesMapper.java
New file
@@ -0,0 +1,36 @@
package com.dy.pipIrrGlobal.daoPr;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * @author ZhuBaoMin
 * @date 2024-10-28 14:11
 * @LastEditTime 2024-10-28 14:11
 * @Description
 */
@Mapper
public interface PrCommonIntakesMapper extends BaseMapper<PrCommonIntakes> {
    int deleteByPrimaryKey(Long id);
    int insert(PrCommonIntakes record);
    int insertSelective(PrCommonIntakes record);
    PrCommonIntakes selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(PrCommonIntakes record);
    int updateByPrimaryKey(PrCommonIntakes record);
    /**
     * 根据操作员ID、取水口ID获取常用取水口对象
     * @param operatorId
     * @param intakeId
     * @return
     */
    PrCommonIntakes selectByOperatorAndIntake(@Param("operatorId") Long operatorId, @Param("intakeId")Long intakeId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrCommonIntakes.java
New file
@@ -0,0 +1,62 @@
package com.dy.pipIrrGlobal.pojoPr;
/**
 * @author ZhuBaoMin
 * @date 2024-10-28 14:11
 * @LastEditTime 2024-10-28 14:11
 * @Description 常用取水口实体类
 */
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.util.Date;
@TableName(value="pr_common_intakes", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class PrCommonIntakes implements BaseEntity {
    public static final long serialVersionUID = 202410281133001L;
    /**
     * 主键
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
     * 操作人ID
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @NotNull(message = "取水口编号不能为空")
    private Long operatorId;
    /**
     * 取水口ID
     */
    @NotNull(message = "取水口编号不能为空")
    private Long intakeId;
    /**
     * 最后一次使用时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastUsedTime;
    /**
     * 使用次数
     */
    private Integer usageCount;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrCommonIntakesMapper.xml
New file
@@ -0,0 +1,110 @@
<?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.PrCommonIntakesMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes">
    <!--@mbg.generated-->
    <!--@Table pr_common_intakes-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="operator_id" jdbcType="BIGINT" property="operatorId" />
    <result column="intake_id" jdbcType="BIGINT" property="intakeId" />
    <result column="last_used_time" jdbcType="TIMESTAMP" property="lastUsedTime" />
    <result column="usage_count" jdbcType="INTEGER" property="usageCount" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, operator_id, intake_id, last_used_time, usage_count
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from pr_common_intakes
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from pr_common_intakes
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes">
    <!--@mbg.generated-->
    insert into pr_common_intakes (id, operator_id, intake_id,
      last_used_time, usage_count)
    values (#{id,jdbcType=BIGINT}, #{operatorId,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT},
      #{lastUsedTime,jdbcType=TIMESTAMP}, #{usageCount,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes">
    <!--@mbg.generated-->
    insert into pr_common_intakes
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="operatorId != null">
        operator_id,
      </if>
      <if test="intakeId != null">
        intake_id,
      </if>
      <if test="lastUsedTime != null">
        last_used_time,
      </if>
      <if test="usageCount != null">
        usage_count,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="operatorId != null">
        #{operatorId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="lastUsedTime != null">
        #{lastUsedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="usageCount != null">
        #{usageCount,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes">
    <!--@mbg.generated-->
    update pr_common_intakes
    <set>
      <if test="operatorId != null">
        operator_id = #{operatorId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        intake_id = #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="lastUsedTime != null">
        last_used_time = #{lastUsedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="usageCount != null">
        usage_count = #{usageCount,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes">
    <!--@mbg.generated-->
    update pr_common_intakes
    set operator_id = #{operatorId,jdbcType=BIGINT},
      intake_id = #{intakeId,jdbcType=BIGINT},
      last_used_time = #{lastUsedTime,jdbcType=TIMESTAMP},
      usage_count = #{usageCount,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据操作员ID、取水口ID获取常用取水口对象-->
  <select id="selectByOperatorAndIntake" resultType="com.dy.pipIrrGlobal.pojoPr.PrCommonIntakes">
    SELECT *
    FROM pr_common_intakes
    WHERE operator_id = #{operatorId} AND intake_id = #{intakeId}
    LIMIT 1
  </select>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -637,26 +637,28 @@
    <!--根据操作员获取常用取水口-->
    <select id="getUsedIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake">
        SELECT DISTINCT con.intakeId,
        con.rtuAddr,
        inta.name AS intakeNum,
        rtus.isOnLine
        FROM pr_controller con
        INNER JOIN pr_intake inta ON con.intakeId = inta.id
        INNER JOIN rm_command_history com ON con.rtuAddr = com.rtu_addr
        INNER JOIN JSON_TABLE(
        <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',-->
        #{onLineMap},
        '$[*]' COLUMNS (
        rtuAddr VARCHAR(20) PATH '$.rtuAddr',
        isOnLine BOOLEAN PATH '$.isOnLine'
        )
        ) rtus ON con.rtuAddr = rtus.rtuAddr
        SELECT
            com.intake_id AS intakeId,
            con.rtuAddr,
            inta.name AS intakeNum,
            rtus.isOnLine
        FROM pr_common_intakes com
            INNER JOIN pr_intake inta ON inta.id = com.intake_id
            INNER JOIN pr_controller con ON con.intakeId = com.intake_id
            INNER JOIN JSON_TABLE(
                <!--'[{"rtuAddr":"620201000030","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',-->
                #{onLineMap},
                '$[*]' COLUMNS (
                    rtuAddr VARCHAR(20) PATH '$.rtuAddr',
                    isOnLine BOOLEAN PATH '$.isOnLine'
                )
            ) rtus ON con.rtuAddr = rtus.rtuAddr
        <where>
            <if test="operator != null">
                com.operator = #{operator}
                com.operator_id = #{operator}
            </if>
        </where>
        ORDER BY com.last_used_time DESC,com.usage_count DESC
    </select>
    <!--取水口名称换取水口ID,扫码开阀使用-->
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java
@@ -124,14 +124,16 @@
        JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
        if(response != null && response.getString("code").equals("0001")) {
            JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
            HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
            JSONArray jsonArray = new JSONArray();
            for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("rtuAddr", entry.getKey());
                jsonObject.put("isOnLine", entry.getValue());
                jsonArray.add(jsonObject);
            if(attachment != null) {
                HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
                for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("rtuAddr", entry.getKey());
                    jsonObject.put("isOnLine", entry.getValue());
                    jsonArray.add(jsonObject);
                }
            }
            System.out.println(jsonArray);
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
@@ -50,7 +50,8 @@
    private final PrIntakeVcMapper prIntakeVcMapper;
    private final SeClientCardMapper seClientCardMapper;
    private final RmIrrigateProfileMapper rmIrrigateProfileMapper;
    private RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper;
    private final RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper;
    //private final PrCommonIntakesMapper prCommonIntakesMapper;
    /**
     * pro_mw:属性
@@ -64,6 +65,7 @@
    public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper,RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, RmIrrigateProfileMapper rmIrrigateProfileMapper, Environment env) {
        this.rmCommandHistoryMapper = rmCommandHistoryMapper;
        this.rmOpenCloseValveLastMapper = rmOpenCloseValveLastMapper;
        //this.prCommonIntakesMapper = prCommonIntakesMapper;
        this.seVirtualCardMapper = seVirtualCardMapper;
        this.prIntakeMapper = prIntakeMapper;
        this.prWaterPriceMapper = prWaterPriceMapper;
@@ -195,5 +197,4 @@
        rsVo.obj = rmIrrigateProfileMapper.getIrrPro(type);
        return rsVo ;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java
@@ -69,6 +69,10 @@
     */
    @GetMapping(path = "used_intakes")
    public BaseResponse<List<VoOnLineIntake>> getUsedIntakes(Long operator) {
        if(operator == null || operator <= 0) {
            return BaseResponseUtils.buildErrorMsg("操作员不能为空");
        }
        try {
            List<VoOnLineIntake> res = intakeSv.getUsedIntakes(operator);
            return BaseResponseUtils.buildSuccess(res);
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java
@@ -78,14 +78,16 @@
        JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
        if(response != null && response.getString("code").equals("0001")) {
            JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
            HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
            JSONArray jsonArray = new JSONArray();
            for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("rtuAddr", entry.getKey());
                jsonObject.put("isOnLine", entry.getValue());
                jsonArray.add(jsonObject);
            if(attachment != null) {
                HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
                for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("rtuAddr", entry.getKey());
                    jsonObject.put("isOnLine", entry.getValue());
                    jsonArray.add(jsonObject);
                }
            }
            qo.setOnLineMap(jsonArray.toJSONString());
@@ -116,14 +118,16 @@
        JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
        if(response != null && response.getString("code").equals("0001")) {
            JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
            HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
            JSONArray jsonArray = new JSONArray();
            for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("rtuAddr", entry.getKey());
                jsonObject.put("isOnLine", entry.getValue());
                jsonArray.add(jsonObject);
            if(attachment != null) {
                HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
                for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("rtuAddr", entry.getKey());
                    jsonObject.put("isOnLine", entry.getValue());
                    jsonArray.add(jsonObject);
                }
            }
            qo.setOnLineMap(jsonArray.toJSONString());
@@ -163,15 +167,18 @@
        if(response != null && response.getString("code").equals("0001")) {
            JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
            HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
            JSONArray jsonArray = new JSONArray();
            for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("rtuAddr", entry.getKey());
                jsonObject.put("isOnLine", entry.getValue());
                jsonArray.add(jsonObject);
            if(attachment != null) {
                HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
                for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("rtuAddr", entry.getKey());
                    jsonObject.put("isOnLine", entry.getValue());
                    jsonArray.add(jsonObject);
                }
            }
            return prIntakeMapper.getUsedIntakes(jsonArray.toJSONString(), operator);
        } else {
            return new ArrayList<>();