中央热水项目
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.

440 lines
24 KiB

package com.mh.user.mapper;
import com.mh.user.dto.HotWaterControlListVO;
import com.mh.user.dto.HotWaterControlZDListVO;
import com.mh.user.entity.CollectionParamsManageEntity;
import com.mh.user.entity.DeviceInstallEntity;
import com.mh.user.model.SanShiFengDatas;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.BaseMapper;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @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} and building_id = #{buildingId}")
void updateCPMByOtherName(String name, BigDecimal value, String time, String quality, String buildingId);
@Update("<script>" +
"WITH BatchData AS (" +
"<foreach collection='batch' item='item' separator='UNION ALL'>" +
"SELECT #{item.name} AS other_name, #{item.value} AS cur_value" +
"</foreach>" +
") " +
"MERGE collection_params_manage AS target " +
"USING BatchData AS source " +
"ON (target.other_name = source.other_name AND target.building_id = #{buildingId}) " +
"WHEN MATCHED THEN " +
" UPDATE SET " +
" cur_value = source.cur_value, " +
" cur_time = #{time}, " +
" quality = #{quality};" +
"</script>")
void updateBatchCPMByOtherName(@Param("batch") List<SanShiFengDatas> batch,
@Param("time") String time,
@Param("quality") String quality,
@Param("buildingId") 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("<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, " +
" COALESCE(cpm.cur_value, 0) as cur_value, " +
" cpm.cur_time, " +
" cpm.param_type_id, " +
" cpm.digits, " +
" 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 = "digits", property = "digits"),
@Result(column = "ct_order_num", property = "ctOrderNum"),
@Result(column = "dl_order_num", property = "dlOrderNum")
})
List<HotWaterControlListVO> 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 = "param_type_group_id", property = "paramTypeGroupId"),
@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);
@Select("select * from collection_params_manage order by create_time desc")
@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 = "param_type_group_id", property = "paramTypeGroupId"),
@Result(column = "collection_type", property = "collectionType"),
@Result(column = "quality", property = "quality"),
@Result(column = "building_id", property = "buildingId")
})
List<CollectionParamsManageEntity> selectAllCPMList();
@Update("update collection_params_manage set cur_value = #{curValue}, cur_time = #{dateStr} where device_install_id = #{deviceInstallId} " +
"and register_addr = #{regAddr} and building_id = #{buildingId} ")
void updateCollectionParamsManage(Integer deviceInstallId, String regAddr, String curValue, String dateStr, String buildingId);
@Select("SELECT " +
" cpm.id as cpm_id, " +
" cpm.register_addr, " +
" di.building_id, " +
" di.building_name, " +
" ct.des as device_type, " +
" di.id as device_id, " +
" di.device_name, " +
" cpm.other_name, " +
" COALESCE(cpm.cur_value, 0) as cur_value, " +
" cpm.cur_time, " +
" cpm.param_type_id, " +
" cpm.param_type_group_id, " +
" cpm.digits, " +
" ct.order_num AS ct_order_num, " +
" di.order_num AS dl_order_num, " +
" cpm.order_num AS order_num " +
"FROM " +
" device_install di " +
" JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " +
" JOIN code_table ct ON ct.code = cpm.param_type_group_id " +
" AND di.building_id = #{buildingId} " +
" AND cpm.device_install_id = #{deviceInstallId} " +
" AND ct.name = 'paramGroupType' " +
"ORDER BY " +
" ct.order_num, " +
" di.order_num ")
@Results({
@Result(column = "cpm_id", property = "cpmId"),
@Result(column = "building_id", property = "buildingId"),
@Result(column = "register_addr", property = "registerAddr"),
@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 = "param_type_group_id", property = "paramTypeGroupId"),
@Result(column = "digits", property = "digits"),
@Result(column = "ct_order_num", property = "ctOrderNum"),
@Result(column = "dl_order_num", property = "dlOrderNum"),
@Result(column = "order_num", property = "orderNum")
})
List<HotWaterControlZDListVO> selectHotWaterByDeviceInstallId(String buildingId, Integer deviceInstallId);
/**
* 根据dataCom查询对应的采集参数列表(S7协议使用)
* @param dataCom 通讯口
* @return 采集参数列表
*/
@Select("SELECT cpm.* FROM collection_params_manage cpm " +
"JOIN device_install di ON cpm.device_install_id = di.id " +
"WHERE di.data_com = #{dataCom} AND cpm.is_use = 1 " +
"ORDER BY cpm.device_install_id, cpm.order_num")
@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 = "param_type_group_id", property = "paramTypeGroupId"),
@Result(column = "collection_type", property = "collectionType"),
@Result(column = "quality", property = "quality"),
@Result(column = "building_id", property = "buildingId")
})
List<CollectionParamsManageEntity> selectCPMByDataCom(String dataCom);
@Update("update collection_params_manage set cur_value = #{value}, cur_time = #{dateStr} where id = #{cpmId} ")
void updateCollectionParamsManageById(@Param("cpmId") Long cpmId,
@Param("value") String value,
@Param("dateStr") String dateStr);
@Select("SELECT " +
" cpm.cur_value, " +
" cpm.cur_time " +
"FROM " +
" collection_params_manage cpm " +
"JOIN device_install di ON " +
" cpm.device_install_id = di.id " +
"WHERE " +
" cpm.building_id = #{buildingId} " +
" AND cpm.param_type_id = 2 " +
" AND di.device_type IN ('单箱电磁阀', '多箱电磁阀');")
List<Map<String, Object>> selectBackWaterState(Long buildingId);
}