zhubaomin
2024-08-23 2fec1051da5d9f3e5dbef812aa06b5db76792151
2024-08-23 朱宝民 常用用水时长及用水量自动配置、获取接口
4个文件已添加
5个文件已修改
391 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmIrrigateProfileMapper.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmIrrigateProfile.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoIrrigaterProfile.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmIrrigateProfileMapper.xml 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/PipIrrBaseApplication.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmIrrigateProfileMapper.java
New file
@@ -0,0 +1,37 @@
package com.dy.pipIrrGlobal.daoRm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile;
import com.dy.pipIrrGlobal.voRm.VoIrrigaterProfile;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * @author ZhuBaoMin
 * @date 2024-08-23 15:17
 * @LastEditTime 2024-08-23 15:17
 * @Description
 */
@Mapper
public interface RmIrrigateProfileMapper extends BaseMapper<RmIrrigateProfile> {
    int deleteByPrimaryKey(Long id);
    int insert(RmIrrigateProfile record);
    int insertSelective(RmIrrigateProfile record);
    RmIrrigateProfile selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(RmIrrigateProfile record);
    int updateByPrimaryKey(RmIrrigateProfile record);
    /**
     * 根据配置类型获取配置值
     * @param type
     * @return
     */
    List<VoIrrigaterProfile> getIrrPro(Integer type);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmIrrigateProfile.java
New file
@@ -0,0 +1,69 @@
package com.dy.pipIrrGlobal.pojoRm;
/**
 * @author ZhuBaoMin
 * @date 2024-08-23 15:17
 * @LastEditTime 2024-08-23 15:17
 * @Description
 */
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import jakarta.validation.constraints.NotNull;
import lombok.*;
/**
 * 灌溉配置表
 */
@TableName(value = "rm_irrigate_profile", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class RmIrrigateProfile implements BaseEntity {
    public static final long serialVersionUID = 202408230823001L;
    /**
     * 主键
     */
    @JSONField(serializeUsing = ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
     * 默认值
     */
    @NotNull(message = "配置默认值不能为空")
    private Integer defaultValue;
    /**
     * 计量单位;1-时(h),2-分(min),3-立方米(cbm)
     */
    private Byte unit;
    /**
     * 排序
     */
    private Integer sort;
    /**
     * 类型;1-用时,2-用水量
     */
    private Byte type;
    /**
     * 备注信息
     */
    private String remarks;
    /**
     * 是否删除标识
     */
    private Long deleted;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoIrrigaterProfile.java
New file
@@ -0,0 +1,35 @@
package com.dy.pipIrrGlobal.voRm;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Data;
/**
 * @author ZhuBaoMin
 * @date 2024-08-23 8:43
 * @LastEditTime 2024-08-23 8:43
 * @Description 灌溉配置视图对象
 */
@Data
@JsonPropertyOrder({ "irrProId", "defaultValue", "unit"})
public class VoIrrigaterProfile {
    private static final long serialVersionUID = 202408230844001L;
    /**
     * 灌溉配置ID
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private Long irrProId;
    /**
     * 配置默认值
     */
    private Integer defaultValue;
    /**
     * 计量单位
     */
    private String unit;
}
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
@@ -28,6 +28,16 @@
                <item4 typeName="养殖用水"/>
                <item5 typeName="绿化用水"/>
            </waterTypes>
            <irrigateProfile>
                <item1 default_value = "10" unit = "2" sort = "1" type = "1"/>
                <item2 default_value = "20" unit = "2" sort = "2" type = "1" />
                <item3 default_value = "1" unit = "1" sort = "3" type = "1"/>
                <item4 default_value = "2" unit = "1" sort = "4" type = "1"/>
                <item5 default_value = "20" unit = "3" sort = "1" type = "2"/>
                <item6 default_value = "30" unit = "3" sort = "2" type = "2"/>
                <item7 default_value = "50" unit = "3" sort = "3" type = "2"/>
                <item8 default_value = "80" unit = "3" sort = "4" type = "2"/>
            </irrigateProfile>
        </org1>
        <org2 tag="pj" name="片角" enable="false">
            <districts>
@@ -55,6 +65,16 @@
                <item4 typeName="养殖用水"/>
                <item5 typeName="绿化用水"/>
            </waterTypes>
            <irrigateProfile>
                <item1 default_value = "10" unit = "2" sort = "1" type = "1"/>
                <item2 default_value = "20" unit = "2" sort = "2" type = "1" />
                <item3 default_value = "1" unit = "1" sort = "3" type = "1"/>
                <item4 default_value = "2" unit = "1" sort = "4" type = "1"/>
                <item5 default_value = "20" unit = "3" sort = "1" type = "2"/>
                <item6 default_value = "30" unit = "3" sort = "2" type = "2"/>
                <item7 default_value = "50" unit = "3" sort = "3" type = "2"/>
                <item8 default_value = "80" unit = "3" sort = "4" type = "2"/>
            </irrigateProfile>
        </org2>
    </orgs>
</config>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmIrrigateProfileMapper.xml
New file
@@ -0,0 +1,143 @@
<?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.daoRm.RmIrrigateProfileMapper">
    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile">
        <!--@mbg.generated-->
        <!--@Table rm_irrigate_profile-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="default_value" jdbcType="INTEGER" property="defaultValue"/>
        <result column="unit" jdbcType="TINYINT" property="unit"/>
        <result column="sort" jdbcType="INTEGER" property="sort"/>
        <result column="type" jdbcType="TINYINT" property="type"/>
        <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
        <result column="deleted" jdbcType="BIGINT" property="deleted"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id,
        default_value,
        unit,
        sort,
        `type`,
        remarks,
        deleted
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from rm_irrigate_profile
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        delete
        from rm_irrigate_profile
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile">
        <!--@mbg.generated-->
        insert into rm_irrigate_profile (id, default_value, unit,
                                         sort, `type`, remarks,
                                         deleted)
        values (#{id,jdbcType=BIGINT}, #{defaultValue,jdbcType=INTEGER}, #{unit,jdbcType=TINYINT},
                #{sort,jdbcType=INTEGER}, #{type,jdbcType=TINYINT}, #{remarks,jdbcType=VARCHAR},
                #{deleted,jdbcType=BIGINT})
    </insert>
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile">
        <!--@mbg.generated-->
        insert into rm_irrigate_profile
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="defaultValue != null">
                default_value,
            </if>
            <if test="unit != null">
                unit,
            </if>
            <if test="sort != null">
                sort,
            </if>
            <if test="type != null">
                `type`,
            </if>
            <if test="remarks != null">
                remarks,
            </if>
            <if test="deleted != null">
                deleted,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="defaultValue != null">
                #{defaultValue,jdbcType=INTEGER},
            </if>
            <if test="unit != null">
                #{unit,jdbcType=TINYINT},
            </if>
            <if test="sort != null">
                #{sort,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=TINYINT},
            </if>
            <if test="remarks != null">
                #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                #{deleted,jdbcType=BIGINT},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile">
        <!--@mbg.generated-->
        update rm_irrigate_profile
        <set>
            <if test="defaultValue != null">
                default_value = #{defaultValue,jdbcType=INTEGER},
            </if>
            <if test="unit != null">
                unit = #{unit,jdbcType=TINYINT},
            </if>
            <if test="sort != null">
                sort = #{sort,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                `type` = #{type,jdbcType=TINYINT},
            </if>
            <if test="remarks != null">
                remarks = #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,jdbcType=BIGINT},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile">
        <!--@mbg.generated-->
        update rm_irrigate_profile
        set default_value = #{defaultValue,jdbcType=INTEGER},
            unit          = #{unit,jdbcType=TINYINT},
            sort          = #{sort,jdbcType=INTEGER},
            `type`        = #{type,jdbcType=TINYINT},
            remarks       = #{remarks,jdbcType=VARCHAR},
            deleted       = #{deleted,jdbcType=BIGINT}
        where id = #{id,jdbcType=BIGINT}
    </update>
    <!--根据配置类型获取配置值-->
    <select id="getIrrPro" resultType="com.dy.pipIrrGlobal.voRm.VoIrrigaterProfile">
        SELECT id            AS irrProId,
               default_value AS defaultValue,
               unit
        FROM rm_irrigate_profile
        WHERE type = #{type}
        ORDER BY sort
    </select>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/PipIrrBaseApplication.java
@@ -18,7 +18,7 @@
                })
        }
)
@MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa","com.dy.pipIrrGlobal.daoSe"})
@MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa","com.dy.pipIrrGlobal.daoSe","com.dy.pipIrrGlobal.daoRm"})
public class PipIrrBaseApplication {
    public static void main(String[] args) {
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
@@ -8,11 +8,13 @@
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.daoBa.BaUserMapper;
import com.dy.pipIrrGlobal.daoRm.RmIrrigateProfileMapper;
import com.dy.pipIrrGlobal.daoSe.SePaymentMethodMapper;
import com.dy.pipIrrGlobal.daoSe.SeWaterTypeMapper;
import com.dy.pipIrrGlobal.pojoBa.BaDistrict;
import com.dy.pipIrrGlobal.pojoBa.BaSettings;
import com.dy.pipIrrGlobal.pojoBa.BaUser;
import com.dy.pipIrrGlobal.pojoRm.RmIrrigateProfile;
import com.dy.pipIrrGlobal.pojoSe.SePaymentMethod;
import com.dy.pipIrrGlobal.pojoSe.SeWaterType;
import com.dy.pipIrrGlobal.util.DistrictLevel;
@@ -40,6 +42,7 @@
    private SePaymentMethodMapper paymentMethodDao ;
    private BaSettingsMapper settingsDao ;
    private SeWaterTypeMapper waterTypeDao ;
    private RmIrrigateProfileMapper rmIrrigateProfileDao;
    @Autowired
    public void setResourceLoader(ResourceLoader resourceLoader){
@@ -71,6 +74,10 @@
        this.waterTypeDao = waterTypeDao ;
    }
    @Autowired
    public void setRmIrrigateProfileDao(RmIrrigateProfileMapper rmIrrigateProfileDao) {
        this.rmIrrigateProfileDao = rmIrrigateProfileDao;
    }
    /**
     * SpringBoot容器已经准备好了
@@ -167,12 +174,15 @@
                                }
                            }
                        }
                        if(!this.existWaterTypes()){
                            if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes")){
                        if(!this.existIrrigateProfile()){
                            if(configXml.existElement(doc, "config.orgs.org" + num + ".irrigateProfile")){
                                for(int i = 1 ; i < 10000; i++){
                                    if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes.item" + i)){
                                        String typeName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".waterTypes.item" + i,"typeName", null, false, null) ;
                                        this.saveWaterType(orgTag, typeName);
                                    if(configXml.existElement(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i)){
                                        String default_value = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"default_value", null, false, null) ;
                                        String unit = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"unit", null, false, null) ;
                                        String sort = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"sort", null, false, null) ;
                                        String type = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".irrigateProfile.item" + i,"type", null, false, null) ;
                                        this.saveIrrigateProfile(orgTag, default_value, unit,sort,type);
                                    }else{
                                        break ;
                                    }
@@ -229,6 +239,15 @@
     */
    private boolean existWaterTypes(){
        Long total = this.waterTypeDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
    /**
     * 数据库中是否存在灌溉配置
     * @return
     */
    private boolean existIrrigateProfile(){
        Long total = this.rmIrrigateProfileDao.selectCount(null) ;
        return (total != null && total > 0) ;
    }
@@ -328,4 +347,27 @@
        }
    }
    /**
     * 保存灌溉配置
     * @param orgTag
     * @param default_value
     * @param unit
     * @param sort
     * @param type
     * @throws Exception
     */
    private void saveIrrigateProfile(String orgTag, String default_value, String unit, String sort, String type) throws Exception{
        if((default_value != null && !default_value.trim().equals("")) &&
                (unit != null && !unit.trim().equals("")) &&
                (sort != null && !sort.trim().equals("")) &&
                (type != null && !type.trim().equals(""))){
            RmIrrigateProfile po = new RmIrrigateProfile();
            po.setDefaultValue(Integer.parseInt(default_value));
            po.setUnit(Byte.valueOf(unit));
            po.setSort(Integer.parseInt(sort));
            po.setType(Byte.valueOf(type));
            this.rmIrrigateProfileDao.insert(po);
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java
@@ -11,11 +11,13 @@
import com.dy.pipIrrGlobal.daoPr.PrIntakeVcMapper;
import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper;
import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
import com.dy.pipIrrGlobal.daoRm.RmIrrigateProfileMapper;
import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrGlobal.voRm.VoIrrigaterProfile;
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
import lombok.RequiredArgsConstructor;
@@ -46,6 +48,7 @@
    private final PrWaterPriceMapper prWaterPriceMapper;
    private final PrIntakeVcMapper prIntakeVcMapper;
    private final SeClientCardMapper seClientCardMapper;
    private final RmIrrigateProfileMapper rmIrrigateProfileMapper;
    /**
     * pro_mw:属性
@@ -56,13 +59,14 @@
    private String pro_mw = "mw";
    private String key_mw = "comSendUrl";
    @Autowired
    public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, Environment env) {
    public CommandSv(RmCommandHistoryMapper rmCommandHistoryMapper, SeVirtualCardMapper seVirtualCardMapper, PrIntakeMapper prIntakeMapper, PrWaterPriceMapper prWaterPriceMapper, PrIntakeVcMapper prIntakeVcMapper, SeClientCardMapper seClientCardMapper, RmIrrigateProfileMapper rmIrrigateProfileMapper, Environment env) {
        this.rmCommandHistoryMapper = rmCommandHistoryMapper;
        this.seVirtualCardMapper = seVirtualCardMapper;
        this.prIntakeMapper = prIntakeMapper;
        this.prWaterPriceMapper = prWaterPriceMapper;
        this.prIntakeVcMapper = prIntakeVcMapper;
        this.seClientCardMapper = seClientCardMapper;
        this.rmIrrigateProfileMapper = rmIrrigateProfileMapper;
        this.env = env;
    }
    /**
@@ -166,4 +170,15 @@
        return prIntakeMapper.getIntakeIdByName(intakeName);
    }
    /**
     * 根据配置类型获取配置值
     * @param type
     * @return
     */
    QueryResultVo<List<VoIrrigaterProfile>> getIrrPro(Integer type) {
        QueryResultVo<List<VoIrrigaterProfile>> rsVo = new QueryResultVo<>() ;
        rsVo.obj = rmIrrigateProfileMapper.getIrrPro(type);
        return rsVo ;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
@@ -10,10 +10,12 @@
import com.dy.common.util.IDLongGenerator;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.command.ComSupport;
import com.dy.pipIrrGlobal.command.dto.Param;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClientCard;
import com.dy.pipIrrGlobal.voRm.VoIrrigaterProfile;
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
import com.dy.pipIrrWechat.command.dto.AutomaticClose;
@@ -794,4 +796,18 @@
            return BaseResponseUtils.buildFail("系统暂不支持该协议");
        }
    }
    /**
     * 根据配置类型获取配置值
     * @param type
     * @return
     */
    @GetMapping(path = "/irrigate_profile")
    public BaseResponse<QueryResultVo<List<VoIrrigaterProfile>>> getIrrPro(Integer type){
        try {
            return BaseResponseUtils.buildSuccess(commandSv.getIrrPro(type));
        } catch (Exception e) {
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
}