Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private SeVirtualCardMapper seVirtualCardMapper; |
| | | |
| | | @Autowired |
| | | private PrCommonIntakesMapper prCommonIntakesMapper; |
| | | |
| | | public static ComSupport comSupport; |
| | | |
| | |
| | | rmCommandHistoryMapper.insert(rmCommandHistory); |
| | | comId = rmCommandHistory.getComId(); |
| | | |
| | | // 添加常用取水口或更新使用信息 |
| | | addCommonIntake(operator, intakeId); |
| | | |
| | | /** |
| | | * 处理回调 |
| | | * feature准备就绪后发送命令 |
| | |
| | | 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); |
| | | } |
| | | } |
New file |
| | |
| | | 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); |
| | | } |
New file |
| | |
| | | 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; |
| | | |
| | | } |
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.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> |
| | |
| | | |
| | | <!--根据操作员获取常用取水口--> |
| | | <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,扫码开阀使用--> |
| | |
| | | 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); |
| | |
| | | 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:属性 |
| | |
| | | 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; |
| | |
| | | rsVo.obj = rmIrrigateProfileMapper.getIrrPro(type); |
| | | return rsVo ; |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | @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); |
| | |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | |
| | | 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<>(); |