中央热水项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
10 KiB

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<CollectionParamsManageEntity> {
@Select("<script>" +
"SELECT * FROM (" +
"SELECT cpm.*, ROW_NUMBER() OVER (ORDER BY cpm.device_install_id) AS row_num " +
"FROM collection_params_manage cpm join device_install di on cpm.device_install_id = di.id where 1=1" +
"<if test='deviceInstallId != null and deviceInstallId != \"\"'>" +
"AND cpm.device_install_id = #{deviceInstallId} " +
"</if>" +
"<if test='buildingId != null and buildingId != \"\"'>" +
"AND di.building_id = #{buildingId} " +
"</if>" +
"<if test='otherName != null and otherName != \"\"'>" +
"AND cpm.other_name LIKE CONCAT('%', #{otherName}, '%') " +
"</if>" +
") AS t WHERE t.row_num BETWEEN (#{pageNum}-1)*#{pageSize} AND #{pageNum}*#{pageSize}" +
"</script>")
@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<CollectionParamsManageEntity> selectCPMList(String buildingId,String deviceInstallId, String otherName, Integer pageNum, Integer pageSize);
@Select("<script>" +
"SELECT count(1) " +
"FROM collection_params_manage cpm join device_install di on cpm.device_install_id = di.id where 1=1" +
"<if test='deviceInstallId != null and deviceInstallId != \"\"'>" +
"AND cpm.device_install_id = #{deviceInstallId} " +
"</if>" +
"<if test='buildingId != null and buildingId != \"\"'>" +
"AND di.building_id = #{buildingId} " +
"</if>" +
"<if test='otherName != null and otherName != \"\"'>" +
"AND cpm.other_name LIKE CONCAT('%', #{otherName}, '%') " +
"</if>" +
"</script>")
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}")
void updateCPMByOtherName(String name, BigDecimal value, String time, String quality);
@Select("select top 1 * from collection_params_manage where other_name = #{name}")
@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);
@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("<script>" +
"update collection_params_manage " +
"<set>" +
"<if test='deviceInstallId != null'>device_install_id = #{deviceInstallId},</if>" +
"<if test='registerAddr != null'>register_addr = #{registerAddr},</if>" +
"<if test='funcCode != null'>func_code = #{funcCode},</if>" +
"<if test='mtRatio != null'>mt_ratio = #{mtRatio},</if>" +
"<if test='mtInitValue != null'>mt_init_value = #{mtInitValue},</if>" +
"<if test='digits != null'>digits = #{digits},</if>" +
"<if test='dataType != null'>data_type = #{dataType},</if>" +
"<if test='curValue != null'>cur_value = #{curValue},</if>" +
"<if test='curTime != null'>cur_time = #{curTime},</if>" +
"<if test='mtIsSum != null'>mt_is_sum = #{mtIsSum},</if>" +
"<if test='unit != null'>unit = #{unit},</if>" +
"<if test='orderNum != null'>order_num = #{orderNum},</if>" +
"<if test='remark != null'>remark = #{remark},</if>" +
"<if test='registerSize != null'>register_size = #{registerSize},</if>" +
"<if test='isUse != null'>is_use = #{isUse},</if>" +
"<if test='otherName != null'>other_name = #{otherName},</if>" +
"<if test='grade != null'>grade = #{grade},</if>" +
"<if test='paramTypeId != null'>param_type_id = #{paramTypeId},</if>" +
"<if test='collectionType != null'>collection_type = #{collectionType},</if>" +
"<if test='quality != null'>quality = #{quality},</if>" +
"<if test='buildingId != null'>building_id = #{buildingId},</if>" +
" update_time = getdate() " +
"</set>" +
"where id = #{id}" +
"</script>")
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<HotWaterControlListVO> selectHotWaterByBuildingId(String buildingId);
}