package com.mh.user.mapper; import com.mh.user.dto.HotWaterControlListVO; import com.mh.user.entity.CollectionParamsManageEntity; import com.mh.user.entity.DeviceInstallEntity; import org.apache.ibatis.annotations.*; import tk.mybatis.mapper.common.BaseMapper; import java.math.BigDecimal; import java.util.List; /** * @author LJF * @version 1.0 * @project CHWS * @description 采集参数设备mapper类 * @date 2025-12-10 11:31:42 */ @Mapper public interface CollectionParamsManageMapper extends BaseMapper { @Select("") @Results({ @Result(column = "id", property = "id"), @Result(column = "create_time", property = "createTime"), @Result(column = "update_time", property = "updateTime"), @Result(column = "device_install_id", property = "deviceInstallId"), @Result(column = "register_addr", property = "registerAddr"), @Result(column = "func_code", property = "funcCode"), @Result(column = "mt_ratio", property = "mtRatio"), @Result(column = "mt_init_value", property = "mtInitValue"), @Result(column = "digits", property = "digits"), @Result(column = "data_type", property = "dataType"), @Result(column = "cur_value", property = "curValue"), @Result(column = "cur_time", property = "curTime"), @Result(column = "mt_is_sum", property = "mtIsSum"), @Result(column = "unit", property = "unit"), @Result(column = "order_num", property = "orderNum"), @Result(column = "remark", property = "remark"), @Result(column = "register_size", property = "registerSize"), @Result(column = "is_use", property = "isUse"), @Result(column = "other_name", property = "otherName"), @Result(column = "grade", property = "grade"), @Result(column = "param_type_id", property = "paramTypeId"), @Result(column = "collection_type", property = "collectionType"), @Result(column = "quality", property = "quality") }) List selectCPMList(String buildingId,String deviceInstallId, String otherName, Integer pageNum, Integer pageSize); @Select("") int selectCPMListCount(String buildingId, String deviceInstallId, String otherName, Integer pageNum, Integer pageSize); @Select("select count(1) from collection_params_manage where other_name = #{otherName} ") int selectCountByOtherName(String otherName); @Update("update collection_params_manage set cur_value = #{value}, cur_time = #{time}, quality = #{quality} where other_name = #{name} and building_id = #{buildingId}") void updateCPMByOtherName(String name, BigDecimal value, String time, String quality, String buildingId); @Select("select top 1 * from collection_params_manage where other_name = #{name} and building_id = #{buildingId} ") @Results({ @Result(column = "id", property = "id"), @Result(column = "create_time", property = "createTime"), @Result(column = "update_time", property = "updateTime"), @Result(column = "device_install_id", property = "deviceInstallId"), @Result(column = "register_addr", property = "registerAddr"), @Result(column = "func_code", property = "funcCode"), @Result(column = "mt_ratio", property = "mtRatio"), @Result(column = "mt_init_value", property = "mtInitValue"), @Result(column = "digits", property = "digits"), @Result(column = "data_type", property = "dataType"), @Result(column = "cur_value", property = "curValue"), @Result(column = "cur_time", property = "curTime"), @Result(column = "mt_is_sum", property = "mtIsSum"), @Result(column = "unit", property = "unit"), @Result(column = "order_num", property = "orderNum"), @Result(column = "remark", property = "remark"), @Result(column = "register_size", property = "registerSize"), @Result(column = "is_use", property = "isUse"), @Result(column = "other_name", property = "otherName"), @Result(column = "grade", property = "grade"), @Result(column = "param_type_id", property = "paramTypeId"), @Result(column = "collection_type", property = "collectionType"), @Result(column = "quality", property = "quality") }) CollectionParamsManageEntity selectDeviceInstallByOtherName(String name, String buildingId); @Insert("insert into collection_params_manage(" + "device_install_id, register_addr, func_code, mt_ratio, mt_init_value, digits, data_type, " + "mt_is_sum, unit, order_num, remark, register_size, is_use, " + "other_name, grade, param_type_id, collection_type, quality, create_time, building_id, cur_value, cur_time) " + "values(#{deviceInstallId}, #{registerAddr}, #{funcCode}, #{mtRatio}, #{mtInitValue}, " + "#{digits}, #{dataType}, #{mtIsSum}, #{unit}, #{orderNum}, " + "#{remark}, #{registerSize}, #{isUse}, #{otherName}, #{grade}, #{paramTypeId}, " + "#{collectionType}, #{quality}, getdate(), #{buildingId}, #{curValue}, #{curTime})") void insertCPM(CollectionParamsManageEntity cpmEntity); @Update("") void updateById(CollectionParamsManageEntity cpmEntity); @Delete("delete from collection_params_manage where id = #{msId}") void deleteById(String msId); @Select("SELECT " + " cpm.id as cpm_id, " + " di.building_id, " + " di.building_name, " + " di.device_type, " + " di.id as device_id, " + " di.device_name, " + " cpm.other_name, " + " cpm.cur_value, " + " cpm.cur_time, " + " cpm.param_type_id, " + " ct.order_num AS ct_order_num, " + " di.order_num AS dl_order_num " + "FROM " + " device_install di " + " JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + " JOIN code_table ct ON ct.des = di.device_type " + " AND di.building_id = #{buildingId} " + " AND ct.name = 'deviceType' " + "ORDER BY " + " ct.order_num, " + " di.order_num ") @Results({ @Result(column = "cpm_id", property = "cpmId"), @Result(column = "building_id", property = "buildingId"), @Result(column = "building_name", property = "buildingName"), @Result(column = "device_type", property = "deviceType"), @Result(column = "device_id", property = "deviceId"), @Result(column = "device_name", property = "deviceName"), @Result(column = "other_name", property = "otherName"), @Result(column = "cur_value", property = "curValue"), @Result(column = "cur_time", property = "curTime"), @Result(column = "param_type_id", property = "paramTypeId"), @Result(column = "ct_order_num", property = "ctOrderNum"), @Result(column = "dl_order_num", property = "dlOrderNum") }) List selectHotWaterByBuildingId(String buildingId); @Select("SELECT " + " top 1 gm.community_type " + "FROM " + " device_install di " + " JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + " JOIN gateway_manage gm ON di.data_com = gm.data_com " + " AND cpm.id = #{cpmId} ") String selectCommunicationType(String cpmId); @Select("SELECT " + " top 1 gm.sn " + "FROM " + " device_install di " + " JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + " JOIN gateway_manage gm ON di.data_com = gm.data_com " + " AND cpm.id = #{cpmId} ") String selectSn(String cpmId); @Select("SELECT " + " top 1 gm.gateway_name " + "FROM " + " device_install di " + " JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + " JOIN gateway_manage gm ON di.data_com = gm.data_com " + " AND cpm.id = #{cpmId} ") String selectPlcName(String cpmId); @Select("select top 1 * from collection_params_manage where id = #{id}") @Results({ @Result(column = "id", property = "id"), @Result(column = "create_time", property = "createTime"), @Result(column = "update_time", property = "updateTime"), @Result(column = "device_install_id", property = "deviceInstallId"), @Result(column = "register_addr", property = "registerAddr"), @Result(column = "func_code", property = "funcCode"), @Result(column = "mt_ratio", property = "mtRatio"), @Result(column = "mt_init_value", property = "mtInitValue"), @Result(column = "digits", property = "digits"), @Result(column = "data_type", property = "dataType"), @Result(column = "cur_value", property = "curValue"), @Result(column = "cur_time", property = "curTime"), @Result(column = "mt_is_sum", property = "mtIsSum"), @Result(column = "unit", property = "unit"), @Result(column = "order_num", property = "orderNum"), @Result(column = "remark", property = "remark"), @Result(column = "register_size", property = "registerSize"), @Result(column = "is_use", property = "isUse"), @Result(column = "other_name", property = "otherName"), @Result(column = "grade", property = "grade"), @Result(column = "param_type_id", property = "paramTypeId"), @Result(column = "collection_type", property = "collectionType"), @Result(column = "quality", property = "quality") }) CollectionParamsManageEntity selectById(String id); @Select("select top 1 * from collection_params_manage where device_install_id = #{deviceInstallId} and param_type_id = #{paramTypeId}") @Results({ @Result(column = "id", property = "id"), @Result(column = "create_time", property = "createTime"), @Result(column = "update_time", property = "updateTime"), @Result(column = "device_install_id", property = "deviceInstallId"), @Result(column = "register_addr", property = "registerAddr"), @Result(column = "func_code", property = "funcCode"), @Result(column = "mt_ratio", property = "mtRatio"), @Result(column = "mt_init_value", property = "mtInitValue"), @Result(column = "digits", property = "digits"), @Result(column = "data_type", property = "dataType"), @Result(column = "cur_value", property = "curValue"), @Result(column = "cur_time", property = "curTime"), @Result(column = "mt_is_sum", property = "mtIsSum"), @Result(column = "unit", property = "unit"), @Result(column = "order_num", property = "orderNum"), @Result(column = "remark", property = "remark"), @Result(column = "register_size", property = "registerSize"), @Result(column = "is_use", property = "isUse"), @Result(column = "other_name", property = "otherName"), @Result(column = "grade", property = "grade"), @Result(column = "param_type_id", property = "paramTypeId"), @Result(column = "collection_type", property = "collectionType"), @Result(column = "quality", property = "quality") }) CollectionParamsManageEntity selectByDeviceIdAndParamTypeId(Long deviceInstallId, String paramTypeId); }