初次提交

This commit is contained in:
2025-06-30 10:11:32 +08:00
commit f059c64d0e
1785 changed files with 258159 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?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.ho.business.mapper.AutoDeviceCurveMapper">
<select id="getSrcIdByStationId" resultType="Integer">
select src_id from device where device_type = #{deviceType} and station_id = #{stationId}
limit 1
</select>
</mapper>

View File

@ -0,0 +1,36 @@
<?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.ho.business.mapper.BusiIdControlMapper">
<sql id="Base_Column_List">
id
,id_type,current_value
</sql>
<select id="selectByType" resultType="com.ho.business.entity.BusiIdControl">
select
<include refid="Base_Column_List"/>
from busi_id_control
<where>
<if test="idType != null">
and id_type = #{idType}
</if>
</where>
</select>
<insert id="insert" keyColumn="id" keyProperty="id"
useGeneratedKeys="true">
insert into busi_id_control
(id_type, current_value)
values (#{idType}, #{currentValue})
</insert>
<update id="update">
update busi_id_control
set current_value = #{currentValue}
where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,113 @@
<?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.ho.business.mapper.ColCountMapper">
<sql id="Base_Column_List">
id
,station_id,device_type,col,col_name,`offset`,count_method,count_flag,create_time,update_time,identify_num
</sql>
<insert id="insertColCount" parameterType="com.ho.business.entity.ColCount">
insert into col_count
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="deviceType != null">device_type,</if>
<if test="col != null">col,</if>
<if test="colName != null">col_name,</if>
<if test="offset != null">`offset`,</if>
<if test="countMethod != null">count_method,</if>
<if test="countFlag != null">count_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="identifyNum != null">identify_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="col != null">#{col},</if>
<if test="colName != null">#{colName},</if>
<if test="offset != null">#{offset},</if>
<if test="countMethod != null">#{countMethod},</if>
<if test="countFlag != null">#{countFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="identifyNum != null">#{identifyNum},</if>
</trim>
</insert>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into col_count (station_id,device_type,col,col_name,`offset`,count_method,count_flag,create_time)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.stationId},#{item.deviceType},#{item.col},
#{item.colName},#{item.offset},#{item.countMethod},#{item.countFlag},now()
)
</foreach>
</insert>
<update id="updateById" parameterType="com.ho.business.entity.ColCount">
update col_count
<set>
<if test="deviceType != null">device_type = #{deviceType},</if>
<if test="col != null">col = #{col},</if>
<if test="colName != null">col_name = #{colName},</if>
<if test="offset != null">`offset` = #{offset},</if>
<if test="countMethod != null">count_method = #{countMethod},</if>
<if test="countFlag != null">count_flag = #{countFlag},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="identifyNum != null">identify_num = #{identifyNum},</if>
</set>
where id = #{id}
</update>
<select id="selectByParam" resultType="com.ho.business.vo.resp.colCount.ColCountResp">
SELECT
<include refid="Base_Column_List"/>
FROM col_count
<where>
<if test="stationId != null">and station_id = #{stationId}</if>
<if test="deviceType != null">and device_type = #{deviceType}</if>
<if test="col != null">and col = #{col}</if>
<if test="colName != null">and col_name = #{colName}</if>
<if test="name !=null ">and (col_name like concat('%',#{name},'%') or col like concat('%',#{name},'%')) </if>
<if test="offset != null">and `offset` = #{offset}</if>
<if test="countMethod != null">and count_method = #{countMethod}</if>
<if test="countFlag != null">and count_flag = #{countFlag}</if>
<if test="ids != null and ids.size() != 0">
and station_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="cols != null and cols.size() != 0">
and col in
<foreach collection="cols" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<delete id="deleteByList">
delete
from col_count
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteStationId">
delete
from col_count
where station_id = #{stationId}
</delete>
</mapper>

View File

@ -0,0 +1,92 @@
<?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.ho.business.mapper.ConvertMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.Convert">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="srcId" column="src_id" jdbcType="INTEGER"/>
<result property="col" column="col" jdbcType="VARCHAR"/>
<result property="colName" column="col_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
,station_id,src_id,
col,col_name
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Convert"
useGeneratedKeys="true">
insert into `convert`
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="srcId != null">src_id,</if>
<if test="stationId != null">station_id,</if>
<if test="col != null">col,</if>
<if test="colName != null">col_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="col != null">#{col},</if>
<if test="colName != null">#{colName},</if>
</trim>
</insert>
<delete id="delete">
delete
from `convert`
where id = #{id,jdbcType=INTEGER}
</delete>
<select id="selectByStationIdAndCol" resultType="com.ho.business.entity.Convert">
SELECT
<include refid="Base_Column_List"/>
from `convert`
<where>
<if test="stationId != null ">
station_id = #{stationId}
</if>
<if test="col != null">
and col = #{col}
</if>
</where>
</select>
<select id="selectByParam" resultType="com.ho.business.entity.Convert">
SELECT
<include refid="Base_Column_List"/>
from `convert`
<where>
<if test="stationId != null ">
station_id = #{stationId}
</if>
<if test="name != null">
and col_name LIKE concat('%',#{name},'%')
</if>
</where>
</select>
<select id="selectByCols" resultType="java.lang.String">
SELECT
col
from `convert`
<where>
<if test="stationId != null ">
station_id = #{stationId}
</if>
<if test="srcId != null ">
and src_id = #{srcId}
</if>
<if test="cols != null and cols.size != 0 ">
and col in
<foreach collection="cols" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,91 @@
<?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.ho.business.mapper.CurveConfigMapper">
<sql id="Base_Column_List">
id,curve_type,curve_name,auxiliary_value,is_hide,station_id,permission_id,page_location,device_id
</sql>
<insert id="insertOne" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into curve_config (curve_type,curve_name,auxiliary_value,is_hide,station_id,permission_id,page_location,device_id,sort)
values(#{curveType},#{curveName},#{auxiliaryValue},#{isHide},#{stationId},#{permissionId},#{pageLocation},#{deviceId},#{sort})
</insert>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into curve_config (curve_type,curve_name,curve_name_en,auxiliary_value,is_hide,station_id,permission_id,page_location,device_id,sort)
values
<foreach item="item" collection="list" index="index" separator=",">
(#{item.curveType},#{item.curveName},#{item.curveNameEn},#{item.auxiliaryValue},#{item.isHide},#{item.stationId},#{item.permissionId},#{item.pageLocation},#{item.deviceId},#{item.sort})
</foreach>
</insert>
<update id="updateById" parameterType="com.ho.business.entity.CurveConfig">
update curve_config
<set>
<if test="curveType != null">curve_type = #{curveType},</if>
<if test="curveName != null">curve_name = #{curveName},</if>
<if test="auxiliaryValue != null">auxiliary_value = #{auxiliaryValue},</if>
<if test="isHide != null">is_hide = #{isHide},</if>
</set>
where id = #{id}
</update>
<select id="selectByParam" resultType="com.ho.business.vo.resp.dynamicConfig.CurveConfigResp">
SELECT
c.id,
c.curve_name,
c.curve_name as curve_name_zh,
c.curve_name_en,
c.curve_type,
c.auxiliary_value,
c.station_id,
c.permission_id,
c.page_location,
c.device_id,
c.is_hide,
d.src_id,
d.device_type,
d.col,
d.col_name,
d.col_name as col_name_zh,
d.col_name_en,
d.sens_type,
d.sort
FROM
curve_config c
LEFT JOIN curve_config_relation r ON r.curve_id = c.id
LEFT JOIN `dynamic_config` d ON r.dynamic_config_id = d.id
<where>
<if test="stationId != null"> and c.station_id = #{stationId}</if>
<if test="permissionId != null"> and c.permission_id = #{permissionId}</if>
<if test="pageLocation != null"> and c.page_location = #{pageLocation}</if>
<if test="deviceId != null"> and c.device_id = #{deviceId}</if>
<if test="isHide != null"> and c.is_hide = #{isHide}</if>
</where>
order by c.sort asc,c.id asc
</select>
<delete id="deleteByIds">
delete
from curve_config
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<insert id="updateList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into curve_config (id,curve_type,curve_name,auxiliary_value,is_hide,station_id,permission_id,page_location,device_id,sort)
values
<foreach item="item" collection="list" index="index" separator=",">
(#{item.id},#{item.curveType},#{item.curveName},#{item.auxiliaryValue},#{item.isHide},#{item.stationId},#{item.permissionId},#{item.pageLocation},#{item.deviceId},#{item.sort})
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,45 @@
<?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.ho.business.mapper.CurveConfigRelationMapper">
<sql id="Base_Column_List">
id,curve_id,dynamic_config_id
</sql>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into curve_config_relation (curve_id,dynamic_config_id)
values
<foreach item="item" collection="list" index="index" separator=",">
( #{item.curveId},#{item.dynamicConfigId} )
</foreach>
</insert>
<delete id="deleteByCurveIds">
delete
from curve_config_relation
<where>
<if test="ids != null and ids.size() != 0">
and curve_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByIds">
delete
from curve_config_relation
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,361 @@
<?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.ho.business.mapper.DeviceCallMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.DeviceCall">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="src_id" property="srcId" jdbcType="INTEGER"/>
<result column="group_id" property="groupId" jdbcType="INTEGER"/>
<result column="dept_id" property="deptId" jdbcType="INTEGER"/>
<result column="station_id" property="stationId" jdbcType="INTEGER"/>
<result column="device_name" property="deviceName" jdbcType="VARCHAR"/>
<result column="device_type" property="deviceType" jdbcType="VARCHAR"/>
<result column="producer" property="producer" jdbcType="VARCHAR"/>
<result column="serial_no" property="serialNo" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!--将json类型的device_json字段修改为如下形式-->
<result column="device_json" property="deviceJson"
typeHandler="com.ho.business.handler.JsonHandler"/>
</resultMap>
<sql id="Base_Column_List">
id
,group_id,dept_id,src_id,pid,category,
station_id,device_name,device_type,
producer,serial_no,status,device_json
</sql>
<select id="selectByInfo" resultType="com.ho.business.vo.resp.DeviceRespVO">
select
<include refid="Base_Column_List"/>
from device_call
<where>
<if test="deviceReqVO.groupId != null">
and group_id = #{deviceReqVO.groupId}
</if>
<if test="deviceReqVO.srcId != null">
and src_id = #{deviceReqVO.srcId}
</if>
<if test="deviceReqVO.deptId != null">
and dept_id = #{deviceReqVO.deptId}
</if>
<if test="deviceReqVO.stationId != null ">
and station_id = #{deviceReqVO.stationId}
</if>
<if test="stationIds != null and stationIds.size() !=0">
and station_id in
<foreach collection="stationIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deviceTypeList != null and deviceTypeList.size() !=0">
and device_type in
<foreach collection="deviceTypeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deviceReqVO.deviceType != null">
and device_type LIKE concat(#{deviceReqVO.deviceType},'%')
</if>
<if test="deviceReqVO.deviceName != null">
and device_name LIKE concat('%',#{deviceReqVO.deviceName},'%')
</if>
<if test="deviceReqVO.producer != null">
and producer = #{deviceReqVO.producer}
</if>
<if test="deviceReqVO.serialNo != null">
and serial_no LIKE concat('%',#{deviceReqVO.serialNo},'%')
</if>
<if test="deviceReqVO.status != null">
and status = #{deviceReqVO.status}
</if>
<if test="deviceReqVO.needFilter != null">
and category > 2
</if>
</where>
</select>
<select id="selectByCondition" resultType="com.ho.business.vo.resp.DeviceRespVO">
select
<include refid="Base_Column_List"/>
from device_call
<where>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="srcId != null">
and src_id = #{srcId}
</if>
<if test="deviceType != null">
and device_type = #{deviceType}
</if>
<if test="deviceTypePrefix != null">
and device_type LIKE concat(#{deviceTypePrefix},'%')
</if>
<if test="pId != null">
and pid = #{pId}
</if>
<if test="category != null">
and category = #{category}
</if>
<if test="deviceIds != null and deviceIds.size != 0 ">
and id in
<foreach collection="deviceIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="stationIds != null and stationIds.size != 0 ">
and station_id in
<foreach collection="stationIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="statusList != null and statusList.size() !=0">
and status in
<foreach collection="statusList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deviceTypeList != null and deviceTypeList.size() !=0">
and device_type in
<foreach collection="deviceTypeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="needFilter != null">
and category > 2
</if>
</where>
</select>
<select id="selectBySId" resultType="com.ho.business.entity.DeviceCall">
select
<include refid="Base_Column_List"/>
from device_call
where src_id = #{id,jdbcType=INTEGER}
</select>
<select id="selectBySrcIds" resultType="com.ho.business.vo.resp.chargepile.ChargePileRespVO">
select
<include refid="Base_Column_List"/>
from device_call
<where>
<if test="stationId != null ">
and station_id = #{stationId}
</if>
<if test="srcIds != null and srcIds.size != 0 ">
and src_id in
<foreach collection="srcIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByPrimaryKey" resultType="com.ho.business.entity.DeviceCall">
select
<include refid="Base_Column_List"/>
from device_call
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByStationIdAndSrcId" resultType="com.ho.business.entity.DeviceCall">
select
<include refid="Base_Column_List"/>
from device_call
<where>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER}
</if>
<if test="stationId != null">
and station_id = #{stationId,jdbcType=INTEGER}
</if>
</where>
</select>
<select id="selectDistinctDeviceTypeByStationId" resultType="java.lang.String">
SELECT DISTINCT device_type
FROM `device_call`
WHERE station_id = #{stationId}
AND device_type IS NOT NULL
</select>
<select id="selectDevicesByStationId" resultType="com.ho.business.entity.DeviceCall">
SELECT
<include refid="Base_Column_List"/>
FROM `device_call`
WHERE station_id = #{stationId}
AND device_type IS NOT NULL
</select>
<select id="selectDevicesByStationIds" resultType="com.ho.business.entity.DeviceCall">
SELECT
<include refid="Base_Column_List"/>
FROM `device_call`
<where>
<if test="stationIds != null and stationIds.size != 0 ">
and station_id in
<foreach collection="stationIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByIds" resultType="com.ho.business.entity.Device">
SELECT
<include refid="Base_Column_List"/>
FROM `device_call`
<where>
<if test="deviceIds != null and deviceIds.size != 0 ">
and id in
<foreach collection="deviceIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByIdAndSrcIdNotZero" resultType="com.ho.business.vo.resp.DeviceRespVO">
SELECT
<include refid="Base_Column_List"/>
FROM `device_call`
where
hide = 0
<if test="needAccessPoint == null">
and src_id != 0
</if>
<if test="stationId != null">
and station_id = #{stationId,jdbcType=INTEGER}
</if>
</select>
<select id="selectByStationIdAndSrcIds" resultType="com.ho.business.vo.resp.DeviceRespVO">
SELECT
<include refid="Base_Column_List"/>
FROM `device_call`
<where>
<if test="stationId != null">
and station_id = #{stationId,jdbcType=INTEGER}
</if>
<if test="srcIds != null and srcIds.size != 0 ">
and src_id in
<foreach collection="srcIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from device_call
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Device"
useGeneratedKeys="true">
insert into device_call
(id, group_id, dept_id, bay_id
, station, device_name, device_name,
producer, serial_no, status)
values ( #{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}
, #{bayId,jdbcType=INTEGER},
, #{station,jdbcType=INTEGER}, #{deviceName,jdbcType=VARCHAR}, #{producer,jdbcType=VARCHAR}
, #{serialNo,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Device"
useGeneratedKeys="true">
insert into device_call
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="groupId != null">group_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="srcId != null">src_id,</if>
<if test="pid != null">pid,</if>
<if test="category != null">category,</if>
<if test="stationId != null">station_id,</if>
<if test="deviceName != null">device_name,</if>
<if test="deviceType != null">device_type,</if>
<if test="producer != null">producer,</if>
<if test="serialNo != null">serial_no,</if>
<if test="createTime != null">create_time,</if>
<if test="status != null">status,</if>
<if test="deviceJson != null">device_json,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="pid != null">#{pid,jdbcType=INTEGER},</if>
<if test="category != null">#{category,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="deviceName != null">#{deviceName,jdbcType=VARCHAR},</if>
<if test="deviceType != null">#{deviceType,jdbcType=VARCHAR},</if>
<if test="producer != null">#{producer,jdbcType=VARCHAR},</if>
<if test="serialNo != null">#{serialNo,jdbcType=VARCHAR},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="status != null">#{status,jdbcType=INTEGER},</if>
<if test="deviceJson != null">
#{deviceJson,jdbcType=OTHER,typeHandler=com.ho.business.handler.JsonHandler},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.Device">
update device_call
<set>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=INTEGER},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="category != null">
category = #{category},
</if>
<if test="deviceName != null">
device_name = #{deviceName,jdbcType=VARCHAR},
</if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
<if test="producer != null">
producer = #{producer,jdbcType=VARCHAR},
</if>
<if test="serialNo != null">
serial_no = #{serialNo,jdbcType=VARCHAR},
</if>
<if test="status!= null">
status= #{status,jdbcType=INTEGER}
</if>
<if test="deviceJson != null">
device_json = #{deviceJson,jdbcType=OTHER,typeHandler=com.ho.business.handler.JsonHandler}
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.Device">
update device_call
set group_id = #{groupId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
bay_id = #{bayId,jdbcType=INTEGER},
station = #{station,jdbcType=INTEGER},
device_name = #{deviceName,jdbcType=VARCHAR},
producer = #{producer,jdbcType=VARCHAR},
serial_no = #{serialNo,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,494 @@
<?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.ho.business.mapper.DeviceMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.Device">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="src_id" property="srcId" jdbcType="INTEGER"/>
<result column="group_id" property="groupId" jdbcType="INTEGER"/>
<result column="dept_id" property="deptId" jdbcType="INTEGER"/>
<result column="station_id" property="stationId" jdbcType="INTEGER"/>
<result column="device_name" property="deviceName" jdbcType="VARCHAR"/>
<result column="device_type" property="deviceType" jdbcType="VARCHAR"/>
<result column="producer" property="producer" jdbcType="VARCHAR"/>
<result column="serial_no" property="serialNo" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!--将json类型的device_json字段修改为如下形式-->
<result column="device_json" property="deviceJson"
typeHandler="com.ho.business.handler.JsonHandler"/>
</resultMap>
<sql id="Base_Column_List">
id,group_id,dept_id,src_id,pid,category,
station_id,device_name,device_name_en,device_type,
producer,serial_no,status,device_json,`virtual`,from_id,hide,flow_direction,producer_type,unit_type
</sql>
<select id="selectByInfo" resultType="com.ho.business.vo.resp.DeviceRespVO">
select
<include refid="Base_Column_List"/>
from device
<where>
<if test="deviceReqVO.groupId != null">
and group_id = #{deviceReqVO.groupId}
</if>
<if test="deviceReqVO.srcId != null">
and src_id = #{deviceReqVO.srcId}
</if>
<if test="deviceReqVO.deptId != null">
and dept_id = #{deviceReqVO.deptId}
</if>
<if test="deviceReqVO.stationId != null ">
and station_id = #{deviceReqVO.stationId}
</if>
<if test="stationIds != null and stationIds.size() !=0">
and station_id in
<foreach collection="stationIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deviceTypeList != null and deviceTypeList.size() !=0">
and device_type in
<foreach collection="deviceTypeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deviceReqVO.deviceType != null">
and device_type LIKE concat(#{deviceReqVO.deviceType},'%')
</if>
<if test="deviceReqVO.deviceName != null and deviceReqVO.deviceName != ''">
and device_name LIKE concat('%',#{deviceReqVO.deviceName},'%')
</if>
<if test="deviceReqVO.producer != null">
and producer = #{deviceReqVO.producer}
</if>
<if test="deviceReqVO.serialNo != null and deviceReqVO.serialNo != ''">
and serial_no LIKE concat('%',#{deviceReqVO.serialNo},'%')
</if>
<if test="deviceReqVO.status != null">
and status = #{deviceReqVO.status}
</if>
<if test="deviceReqVO.needFilter != null">
and category > 2
</if>
<if test="deviceReqVO.hide != null">
and hide = #{deviceReqVO.hide}
</if>
</where>
</select>
<select id="selectByCondition" resultType="com.ho.business.vo.resp.DeviceRespVO">
select
<include refid="Base_Column_List"/>
from device
<where>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="srcId != null">
and src_id = #{srcId}
</if>
<if test="srcIdList != null and srcIdList.size != 0 ">
and src_id in
<foreach collection="srcIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="noNeedFromId !=null and formIdList != null and formIdList.size != 0 ">
and from_id not in
<foreach collection="formIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="deviceType != null">
and device_type = #{deviceType}
</if>
<if test="deviceTypePrefix != null">
and device_type LIKE concat('%',#{deviceTypePrefix},'%')
</if>
<if test="pId != null">
and pid = #{pId}
</if>
<if test="category != null">
and category = #{category}
</if>
<if test="deviceIds != null and deviceIds.size != 0 ">
and id in
<foreach collection="deviceIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="stationIds != null and stationIds.size != 0 ">
and station_id in
<foreach collection="stationIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="statusList != null and statusList.size() !=0">
and status in
<foreach collection="statusList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deviceTypeList != null and deviceTypeList.size() !=0">
and device_type in
<foreach collection="deviceTypeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="needFilter != null">
and category > 2
</if>
<if test="hide != null">
and hide =0
</if>
<if test="fuzzyDeviceType != null">
and device_type LIKE concat('%',#{fuzzyDeviceType},'%')
</if>
<if test="needDeviceTypeNotNull != null">
and device_type is not null
</if>
</where>
</select>
<select id="selectBySId" resultType="com.ho.business.entity.Device">
select
<include refid="Base_Column_List"/>
from device
where src_id = #{id,jdbcType=INTEGER}
</select>
<select id="selectBySrcIds" resultType="com.ho.business.vo.resp.chargepile.ChargePileRespVO">
select
<include refid="Base_Column_List"/>
from device
<where>
<if test="stationId != null ">
and station_id = #{stationId}
</if>
<if test="srcIds != null and srcIds.size != 0 ">
and src_id in
<foreach collection="srcIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByPrimaryKey" resultType="com.ho.business.entity.Device">
select
<include refid="Base_Column_List"/>
from device
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByStationIdAndSrcId" resultType="com.ho.business.entity.Device">
select
<include refid="Base_Column_List"/>
from device
<where>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER}
</if>
<if test="stationId != null">
and station_id = #{stationId,jdbcType=INTEGER}
</if>
</where>
</select>
<select id="selectDistinctDeviceTypeByStationId" resultType="java.lang.String">
SELECT DISTINCT device_type
FROM `device`
WHERE station_id = #{stationId}
AND device_type IS NOT NULL
</select>
<select id="selectDevicesByStationId" resultType="com.ho.business.entity.Device">
SELECT
<include refid="Base_Column_List"/>
FROM `device`
WHERE station_id = #{stationId}
AND device_type IS NOT NULL
</select>
<select id="selectDevicesByStationIds" resultType="com.ho.business.entity.Device">
SELECT
<include refid="Base_Column_List"/>
FROM `device`
<where>
<if test="stationIds != null and stationIds.size != 0 ">
and station_id in
<foreach collection="stationIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByIds" resultType="com.ho.business.entity.Device">
SELECT
<include refid="Base_Column_List"/>
FROM `device`
<where>
<if test="deviceIds != null and deviceIds.size != 0 ">
and id in
<foreach collection="deviceIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByStationIdAndSrcIds" resultType="com.ho.business.vo.resp.DeviceRespVO">
SELECT
<include refid="Base_Column_List"/>
FROM `device`
<where>
<if test="stationId != null">
and station_id = #{stationId,jdbcType=INTEGER}
</if>
<if test="srcIds != null and srcIds.size != 0 ">
and src_id in
<foreach collection="srcIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByIdAndSrcIdNotZero" resultType="com.ho.business.vo.resp.DeviceRespVO">
SELECT
<include refid="Base_Column_List"/>
FROM `device`
<where>
<if test="needHide == null">
and hide=0
</if>
<if test="needAccessPoint == null">
and src_id != 0
</if>
<if test="stationId != null">
and station_id = #{stationId,jdbcType=INTEGER}
</if>
</where>
</select>
<select id="selectRealDevice" resultType="com.ho.business.entity.Device">
SELECT
<include refid="Base_Column_List"/>
FROM `device`
<where>
<if test="stationId != null">
station_id= #{stationId,jdbcType=INTEGER}
</if>
<if test="virtual != null">
and `virtual`= #{virtual,jdbcType=INTEGER}
</if>
<if test="category != null">
and category= #{category}
</if>
<if test="fromId != null">
and from_id = #{fromId}
</if>
<if test="pid != null">
and pid = #{pid}
</if>
<if test="deviceType != null">
and device_type LIKE concat('%',#{deviceType},'%')
</if>
<if test="deviceName != null and deviceName != ''">
and device_name LIKE concat('%',#{deviceName},'%')
</if>
<if test="isFilterUnitType != null">
and unit_type > 1
</if>
</where>
</select>
<delete id="deleteByPrimaryKey">
delete
from device
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Device"
useGeneratedKeys="true">
insert into device
(id, group_id, dept_id, bay_id
, station, device_name, device_name,
producer, serial_no, status)
values ( #{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}
, #{bayId,jdbcType=INTEGER},
, #{station,jdbcType=INTEGER}, #{deviceName,jdbcType=VARCHAR}, #{producer,jdbcType=VARCHAR}
, #{serialNo,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Device"
useGeneratedKeys="true">
insert into device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="groupId != null">group_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="srcId != null">src_id,</if>
<if test="pid != null">pid,</if>
<if test="category != null">category,</if>
<if test="stationId != null">station_id,</if>
<if test="deviceName != null">device_name,</if>
<if test="deviceType != null">device_type,</if>
<if test="producer != null">producer,</if>
<if test="serialNo != null">serial_no,</if>
<if test="createTime != null">create_time,</if>
<if test="status != null">status,</if>
<if test="deviceJson != null">device_json,</if>
<if test="virtual != null">`virtual`,</if>
<if test="fromId != null">from_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="pid != null">#{pid,jdbcType=INTEGER},</if>
<if test="category != null">#{category,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="deviceName != null">#{deviceName,jdbcType=VARCHAR},</if>
<if test="deviceType != null">#{deviceType,jdbcType=VARCHAR},</if>
<if test="producer != null">#{producer,jdbcType=VARCHAR},</if>
<if test="serialNo != null">#{serialNo,jdbcType=VARCHAR},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="status != null">#{status,jdbcType=INTEGER},</if>
<if test="deviceJson != null">
#{deviceJson,jdbcType=OTHER,typeHandler=com.ho.business.handler.JsonHandler},
</if>
<if test="virtual != null">#{virtual,jdbcType=INTEGER},</if>
<if test="fromId != null">#{fromId,jdbcType=INTEGER},</if>
</trim>
</insert>
<insert id="insertBatch">
INSERT INTO device
(group_id,dept_id,src_id,pid,category,
station_id,device_name,device_type,
serial_no,status,`virtual`,from_id,create_time)
VALUES
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.groupId},#{item.deptId},#{item.srcId},#{item.pid}
,#{item.category} ,#{item.stationId},#{item.deviceName},#{item.deviceType}
,#{item.serialNo},#{item.status},#{item.virtual},#{item.fromId},#{item.createTime}
)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.Device">
update device
<set>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=INTEGER},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="category != null">
category = #{category},
</if>
<if test="deviceName != null">
device_name = #{deviceName,jdbcType=VARCHAR},
</if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
<if test="producer != null">
producer = #{producer,jdbcType=VARCHAR},
</if>
<if test="serialNo != null">
serial_no = #{serialNo,jdbcType=VARCHAR},
</if>
<if test="status!= null">
status= #{status,jdbcType=INTEGER},
</if>
<if test="deviceJson != null">
device_json = #{deviceJson,jdbcType=OTHER,typeHandler=com.ho.business.handler.JsonHandler},
</if>
<if test="createTime!= null">
create_time = #{createTime},
</if>
<if test="updateTime!= null">
update_time = #{updateTime},
</if>
<if test="address!= null">
address = #{address},
</if>
<if test="virtual!= null">
`virtual` = #{virtual},
</if>
<if test="fromId!= null">
from_id = #{fromId},
</if>
<if test="hide!= null">
hide = #{hide},
</if>
<if test="flowDirection!= null">
flow_direction = #{flowDirection},
</if>
<if test="unitType!= null">
unit_type = #{unitType,jdbcType=INTEGER},
</if>
<if test="producerType!= null">
producer_type = #{producerType},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.Device">
update device
set group_id = #{groupId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
bay_id = #{bayId,jdbcType=INTEGER},
station = #{station,jdbcType=INTEGER},
device_name = #{deviceName,jdbcType=VARCHAR},
producer = #{producer,jdbcType=VARCHAR},
serial_no = #{serialNo,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByStationId">
update device
<set>
<if test="serialNo != null">
serial_no = #{serialNo,jdbcType=VARCHAR},
</if>
</set>
where station_id = #{stationId,jdbcType=INTEGER}
</update>
<delete id="deleteByList">
delete
from device
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<update id="updateDeviceList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
<foreach collection="list" item="item" index="index" separator=";">
update device set device_name = #{item.deviceName},device_name_en = #{item.deviceNameEn} where id = #{item.id}
</foreach>
</update>
</mapper>

View File

@ -0,0 +1,460 @@
<?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.ho.business.mapper.DeviceTypeColMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.DeviceTypeCol">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="deviceTypeId" column="device_type_id" jdbcType="INTEGER"/>
<result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
<result property="deviceTypeName" column="device_type_name" jdbcType="VARCHAR"/>
<result property="col" column="col" jdbcType="VARCHAR"/>
<result property="colName" column="col_name" jdbcType="VARCHAR"/>
<result property="sensType" column="sens_type" jdbcType="INTEGER"/>
<result property="isShow" column="is_show" jdbcType="INTEGER"/>
<result property="isSave" column="is_save" jdbcType="INTEGER"/>
<result property="maxValue" column="max_value"/>
<result property="minValue" column="min_value"/>
<result property="specifiedValue" column="specified_value"/>
<result property="offsetValue" column="offset_value"/>
<result property="factor" column="factor"/>
<result property="unit" column="unit"/>
<result property="dataType" column="data_type" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
,device_type_id,device_type,
device_type_name,col,col_name,col_en,sens_type,is_show,is_save,
max_value,min_value,specified_value,offset_value,factor,unit,
data_type,filter_type
</sql>
<sql id="Base_List">
id
,device_type_id,device_type,
device_type_name,col,col_name,sens_type,is_show,is_save,
max_value,min_value,specified_value,offset_value,factor,unit
</sql>
<delete id="deleteByPrimaryKey">
delete
from device_type_col
where id = #{id}
</delete>
<delete id="deleteBatchDevice">
delete
from device_type_col
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteBatchModel">
delete
from model_type_col
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<select id="selectByDeviceType" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="deviceType != null">
and device_type=#{deviceType}
</if>
</where>
ORDER BY id asc
</select>
<select id="selectByParam" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="deviceTypeCol.deviceType != null">
and device_type=#{deviceTypeCol.deviceType}
</if>
<if test="deviceTypeCol.col != null">
and col LIKE concat('%',#{deviceTypeCol.col},'%')
</if>
<if test="deviceTypeCol.colName != null">
and col_name LIKE concat('%',#{deviceTypeCol.colName},'%')
</if>
</where>
ORDER BY id asc
</select>
<select id="selectByDeviceTypeList" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="deviceTypeColReqVO.deviceTypeList != null and deviceTypeColReqVO.deviceTypeList.size !=0">
and device_type in
<foreach collection="deviceTypeColReqVO.deviceTypeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="deviceTypeColReqVO.isSave != null">
and is_save = #{deviceTypeColReqVO.isSave}
</if>
<if test="deviceTypeColReqVO.name != null">
and (col_name LIKE concat('%',#{deviceTypeColReqVO.name},'%') or col LIKE
concat('%',#{deviceTypeColReqVO.name},'%'))
</if>
<if test="deviceTypeColReqVO.sensType != null">
and sens_type = #{deviceTypeColReqVO.sensType}
</if>
</where>
</select>
<select id="selectByDeviceTypeAndIsShow" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="deviceType != null">
and device_type = #{deviceType}
</if>
<if test="isShow != null">
and is_show = #{isShow}
</if>
</where>
</select>
<select id="selectByIds" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<!--查模型设备关联列表 联合查询 -->
<select id="getCompListByType" resultType="com.ho.business.entity.ModelDeviceColComp">
select r.id, r.device_col_id,r.device_type, d.col as device_col, d.col_name as device_col_name,
r.model_col_id ,r.model_type, m.col as model_col, m.col_name as model_col_name,d.unit,d.sens_type
from model_device_col r
left join
device_type_col d
on r.device_col_id = d.id
left join
model_type_col m
on r.model_col_id = m.id
<where>
<if test="modelCol !=null">
and m.col = #{modelCol}
</if>
<choose>
<when test="type =='device'">
and r.device_type = #{typeName}
</when>
<when test="type =='model'">
and r.model_type = #{typeName}
</when>
</choose>
</where>
</select>
<select id="selectSameCol" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="deviceType != null">
and device_type=#{deviceType}
</if>
<if test="list != null and list.size !=0">
and col in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectTypeAndCol" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="deviceType != null">
and device_type = #{deviceType}
</if>
<if test="col != null">
and col = #{col}
</if>
</where>
</select>
<select id="selectCountByDeviceType" resultType="java.lang.Integer">
select count(1)
from device_type_col
<where>
<if test="deviceTypeCol.deviceType != null">
and device_type = #{deviceTypeCol.deviceType}
</if>
</where>
</select>
<select id="selectDimType" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="deviceType != null">
and device_type LIKE concat('%',#{deviceType},'%')
</if>
</where>
</select>
<select id="selectType" resultType="java.lang.String">
SELECT device_type
FROM `device_type_col`
where
<if test="collect != null and collect.size != 0 ">
device_type in
<foreach collection="collect" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
group by device_type
</select>
<select id="selectById" resultType="com.ho.business.entity.DeviceTypeCol">
SELECT
<include refid="Base_Column_List"/>
FROM `device_type_col`
where id = #{id}
</select>
<select id="selectAllData" resultType="com.ho.business.entity.DeviceTypeCol">
SELECT
<include refid="Base_Column_List"/>
from device_type_col
where id >= #{colBeginId} limit #{allNum}
</select>
<select id="selectByBatchId" resultType="com.ho.business.entity.DeviceTypeCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.DeviceTypeCol"
useGeneratedKeys="true">
insert into device_type_col
(id, device_type_id, device_type,
device_type_name, col, col_name, sens_type, is_show, is_save,
max_value, min_value, specified_value, offset_value, factor, unit
data_type)
values ( #{id}, #{device_type_id}, #{device_type}
, #{device_type_name},
, #{col}, #{col_name}, #{sens_type}, #{is_show}, #{is_save}
, #{max_value}, #{min_value}, #{specified_value}, #{offset_value}, #{factor}, #{unit}, #{data_type})
</insert>
<insert id="insertList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
insert into device_type_col
(device_type_id,device_type,device_type_name,col,col_name,col_en,sens_type,is_show,is_save,max_value,min_value,offset_value,factor,unit)
values
<foreach collection="deviceTypeColList" item="item" index="index" separator=",">
(#{item.deviceTypeId},#{item.deviceType},#{item.deviceTypeName},#{item.col},#{item.colName},#{item.colEn},#{item.sensType},#{item.isShow},#{item.isSave},#{item.maxValue},#{item.minValue},#{item.offsetValue},#{item.factor},#{item.unit})
</foreach>
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.DeviceTypeCol"
useGeneratedKeys="true">
insert into device_type_col
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="deviceTypeId != null">device_type_id,</if>
<if test="deviceType != null">device_type,</if>
<if test="deviceTypeName != null">device_type_name,</if>
<if test="col != null">col,</if>
<if test="colName != null">col_name,</if>
<if test="colEn != null">col_en,</if>
<if test="sensType != null">sens_type,</if>
<if test="isShow != null">is_show,</if>
<if test="isSave != null">is_save,</if>
<if test="maxValue != null">max_value,</if>
<if test="minValue != null">min_value,</if>
<if test="specifiedValue != null">specified_value,</if>
<if test="offsetValue != null">offset_value,</if>
<if test="factor != null">factor,</if>
<if test="unit != null">unit,</if>
<if test="dataType != null">data_type</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="deviceTypeId != null">#{deviceTypeId},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="deviceTypeName != null">#{deviceTypeName},</if>
<if test="col != null">#{col},</if>
<if test="colName != null">#{colName},</if>
<if test="colEn != null">#{colEn},</if>
<if test="sensType != null">#{sensType},</if>
<if test="isShow != null">#{isShow},</if>
<if test="isSave != null">#{isSave},</if>
<if test="maxValue != null">#{maxValue},</if>
<if test="minValue != null">#{minValue},</if>
<if test="specifiedValue != null">#{specifiedValue},</if>
<if test="offsetValue != null">#{offsetValue},</if>
<if test="factor != null">#{factor},</if>
<if test="unit != null">#{unit},</if>
<if test="dataType != null">#{dataType},</if>
</trim>
</insert>
<insert id="addBatchDevice" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into device_type_col (<include refid="Base_List"/>)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.id},
#{item.deviceTypeId},#{item.deviceType},
#{item.deviceTypeName},#{item.col},#{item.colName},#{item.sensType}, #{item.isShow}, #{item.isSave},
#{item.maxValue}, #{item.minValue}, #{item.specifiedValue}, #{item.offsetValue}, #{item.factor},
#{item.unit}
)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.DeviceTypeCol">
update device_type_col
<set>
<if test="deviceTypeId != null">
device_type_id= #{deviceTypeId},
</if>
<if test="deviceType != null">
device_type=#{deviceType},
</if>
<if test="deviceTypeName != null">
device_type_name = #{deviceTypeName},
</if>
<if test="col != null">
col = #{col},
</if>
<if test="colName != null">
col_name = #{colName},
</if>
<if test="sensType != null">
sens_type = #{sensType},
</if>
<if test="isShow != null">
is_show = #{isShow},
</if>
<if test="isSave != null">
is_save = #{isSave},
</if>
<if test="maxValue != null">
max_value = #{maxValue},
</if>
<if test="minValue != null">
min_value = #{minValue},
</if>
<if test="specifiedValue != null">
specified_value = #{specifiedValue},
</if>
<if test="offsetValue != null">
offset_value = #{offsetValue},
</if>
<if test="offsetValue != null">
offset_value = #{offsetValue},
</if>
<if test="factor != null">
factor = #{factor},
</if>
<if test="unit != null">
unit = #{unit},
</if>
<if test="dataType != null">
data_type = #{dataType},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey">
update device_type_col
set device_type_id= #{deviceTypeId},
device_type=#{deviceType},
device_type_name = #{deviceTypeName},
col = #{col},
col_name = #{colName},
sens_type = #{sensType},
is_show = #{isShow},
is_save = #{isSave},
max_value = #{maxValue},
min_value = #{minValue},
specified_value = #{specifiedValue},
offset_value = #{offsetValue},
offset_value = #{offsetValue},
factor = #{factor},
unit = #{unit},
data_type = #{dataType}
where id = #{id}
</update>
<update id="updateList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
<foreach collection="deviceTypeColList" item="item" index="index" separator=";">
update device_type_col set device_type_id = #{item.deviceTypeId},device_type = #{item.deviceType},
device_type_name = #{item.deviceTypeName},
col = #{item.col},col_name = #{item.colName},col_en = #{item.colEn},sens_type = #{item.sensType}, is_show =
#{item.isShow}, is_save = #{item.isSave},
max_value = #{item.maxValue}, min_value = #{item.minValue}, unit = #{item.unit}
where id = #{item.id}
</foreach>
</update>
<select id="countByDeviceType" resultType="com.ho.business.vo.resp.deviceTypeCol.DeviceTypeColCountResp">
select count(1) as num,device_type
from device_type_col
<where>
<if test="typeList != null and typeList.size !=0">
and device_type in
<foreach collection="typeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
GROUP BY device_type
</select>
</mapper>

View File

@ -0,0 +1,182 @@
<?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.ho.business.mapper.DeviceTypeConfigMapper">
<sql id="Base_Column_List">
id
,group_id, station_id, scope,device_type,`name`, name_en,model_name,deleted,creator,create_time, update_time
</sql>
<select id="selectById" resultType="com.ho.business.entity.DeviceTypeConfig">
select
<include refid="Base_Column_List"/>
from device_type_config
where id = #{id}
</select>
<select id="selectByDeviceType" resultType="com.ho.business.entity.DeviceTypeConfig">
select
<include refid="Base_Column_List"/>
from device_type_config
<where>
<if test="deviceType != null">
and device_type = #{deviceType}
</if>
<if test="groupId != null">
and group_id = #{groupId}
</if>
and deleted = 1
</where>
limit 1
</select>
<select id="selectListByCondition" resultType="com.ho.business.entity.DeviceTypeConfig">
select
<include refid="Base_Column_List"/>
from device_type_config
<where>
<if test="id!=null">
and id =#{id}
</if>
<if test="groupId!=null">
and group_id = #{groupId}
</if>
<if test="type == null">
<if test="stationId!=null">
and station_id = #{stationId}
</if>
</if>
<if test="deviceTypePrefix!=null">
and device_type like concat(#{deviceType},'%')
</if>
<!--用于查询集团和具体电站对应的配置数据-->
<if test="type != null and stationId != null">
and (scope = 1 or (scope = 2 and station_id = #{stationId}))
</if>
<if test="deviceTypeList != null and deviceTypeList.size() != 0">
and device_type in
<foreach collection="deviceTypeList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="deviceType!=null">
and device_type =#{deviceType}
</if>
<if test="scope != null">
and `scope` = #{scope}
</if>
<!--设备类型名称-->
<if test="name != null">
and `name` = #{name}
</if>
<if test="stationIds != null and stationIds.size() != 0">
and station_id in
<foreach collection="stationIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
and deleted =1
</where>
order by create_time desc
</select>
<select id="selectByType" resultType="com.ho.business.entity.DeviceTypeConfig">
select
<include refid="Base_Column_List"/>
from device_type_config
<where>
<if test="deviceType!=null">
and device_type =#{deviceType}
</if>
<if test="stationId!=null">
and station_id = #{stationId}
</if>
and deleted =1
</where>
</select>
<insert id="add">
insert into device_type_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="groupId != null">group_id,</if>
<if test="stationId != null">station_id,</if>
<if test="scope!= null">scope,</if>
<if test="deviceType!= null">device_type,</if>
<if test="name!= null">`name`,</if>
<if test="modelName!= null">model_name,</if>
<if test="deleted!= null">deleted,</if>
<if test="creator!= null">creator,</if>
<if test="createTime!= null">create_time,</if>
<if test="updateTime!= null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="groupId != null">#{groupId},</if>
<if test="stationId != null">#{stationId},</if>
<if test="scope != null">#{scope},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="name != null">#{name},</if>
<if test="modelName != null">#{modelName},</if>
<if test="deleted != null">#{deleted},</if>
<if test="creator != null">#{creator},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<insert id="addBatchDeviceTypeConfig" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into device_type_config (group_id, station_id,`scope`,device_type,`name`,model_name,deleted,creator,create_time) values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.groupId},#{item.stationId},#{item.scope},#{item.deviceType},
#{item.name},#{item.modelName},#{item.deleted}, #{item.creator}, #{item.createTime}
)
</foreach>
</insert>
<update id="update">
update device_type_config
<set>
<if test="name != null">
`name` = #{name},
</if>
<if test="modelName != null">
`model_name` = #{modelName},
</if>
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="creator != null">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{id}
</update>
<!---->
<delete id="deletedById">
from device_type_config
where id =
#{id}
</delete>
<delete id="deleteByStationId">
delete from device_type_config where station_id = #{stationId}
</delete>
<update id="updateDeviceTypeConfigList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
<foreach collection="list" item="item" index="index" separator=";">
update device_type_config set name = #{item.name},name_en = #{item.nameEn} where id = #{item.id}
</foreach>
</update>
</mapper>

View File

@ -0,0 +1,154 @@
<?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.ho.business.mapper.DeviceTypeMapper">
<sql id="Base_Column_List">
id
,type_id,pid,
name,device_type
</sql>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from device_type
where id = #{id}
</delete>
<select id="selectByPrimaryKey" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
where id = #{id}
</select>
<select id="selectAll" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
</select>
<select id="selectByPid" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
where id=#{pid}
</select>
<select id="selectByIds" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
<where>
<if test="typeIds != null and typeIds.size() != 0">
id in
<foreach collection="typeIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByPids" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
<where>
<if test="pIds != null and pIds.size() != 0">
id in
<foreach collection="pIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="getDeviceType" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
where id = #{deviceTypeId}
</select>
<select id="selectByDeviceType" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
where device_type = #{deviceType,jdbcType=VARCHAR}
</select>
<select id="selectName" resultType="com.ho.business.entity.DeviceType">
select
<include refid="Base_Column_List"/>
from device_type
<where>
<if test="deviceTypeList != null and deviceTypeList.size() != 0">
device_type in
<foreach collection="deviceTypeList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<insert id="insert">
insert into device_type
( id, type_id, pid
, name)
values ( #{id,jdbcType=INTEGER}, #{typeId,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}
, #{name,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective">
insert into device_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="typeId != null">type_id,</if>
<if test="pid != null">pid,</if>
<if test="name != null">name,</if>
<if test="deviceType != null">device_type</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="typeId != null">#{typeId,jdbcType=INTEGER},</if>
<if test="pid != null">#{pid,jdbcType=INTEGER},</if>
<if test="name != null">#{name,jdbcType=VARCHAR},</if>
<if test="deviceType != null">#{deviceType,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.DeviceType">
update device_type
<set>
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
<if test="typeId != null">
type_id = #{typeId,jdbcType=INTEGER},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR}
</if>
</set>
where
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.DeviceType">
update device_type
set id = #{id,jdbcType=INTEGER},
type_id = #{typeId,jdbcType=INTEGER},
pid = #{pid,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR} device_type = #{deviceType,jdbcType=VARCHAR}
where
</update>
</mapper>

View File

@ -0,0 +1,109 @@
<?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.ho.business.mapper.DynamicConfigMapper">
<sql id="Base_Column_List">
id,station_id,src_id,device_type,col,col_name,sens_type,permission_id,page_location,div_location,sort,device_id
</sql>
<resultMap id="baseMap" type="com.ho.business.entity.DynamicConfig">
<result property="srcId" column="src_id" jdbcType="BIGINT"/>
<result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
<result property="col" column="col" jdbcType="VARCHAR"/>
<result property="colName" column="col_name" jdbcType="VARCHAR"/>
<result property="colNameZh" column="col_name_zh" jdbcType="VARCHAR"/>
<result property="colNameEn" column="col_name_en" jdbcType="VARCHAR"/>
<result property="sensType" column="sens_type" jdbcType="BIGINT"/>
</resultMap>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into dynamic_config (station_id,src_id,device_type,col,col_name,col_name_en,sens_type,permission_id,page_location,div_location,sort,device_id)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.stationId},#{item.srcId},#{item.deviceType},#{item.col},
#{item.colName},#{item.colNameEn},#{item.sensType},#{item.permissionId},#{item.pageLocation},#{item.divLocation},#{item.sort},#{item.deviceId}
)
</foreach>
</insert>
<update id="updateList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
<foreach collection="list" item="item" index="index" separator=";">
update dynamic_config set src_id = #{item.srcId},device_type = #{item.deviceType},
col = #{item.col},col_name = #{item.colName},sens_type = #{item.sensType}, sort = #{item.sort}
where id = #{item.id}
</foreach>
</update>
<select id="selectByParam" resultType="com.ho.business.entity.DynamicConfig">
SELECT
<include refid="Base_Column_List"/>
FROM dynamic_config
<where>
<if test="stationId != null">and station_id = #{stationId}</if>
<if test="srcId != null">and src_id = #{srcId}</if>
<if test="deviceType != null">and device_type = #{deviceType}</if>
<if test="col != null">and col = #{col}</if>
<if test="colName != null">and col_name = #{colName}</if>
<if test="name !=null ">and (col_name like concat('%',#{name},'%') or col like concat('%',#{name},'%')) </if>
<if test="sensType != null">and sens_type = #{sensType}</if>
<if test="permissionId != null">and permission_id = #{permissionId}</if>
<if test="pageLocation != null">and page_location = #{pageLocation}</if>
<if test="divLocation != null">and div_location = #{divLocation}</if>
<if test="deviceId != null">and device_id = #{deviceId}</if>
</where>
order by sort asc
</select>
<delete id="deleteByIds">
delete
from dynamic_config
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByCurveIds">
delete
from dynamic_config where
id in (SELECT dynamic_config_id FROM `curve_config_relation`
<where>
<if test="ids != null and ids.size() != 0">
and curve_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
)
</delete>
<delete id="deleteByPointIds">
delete
from dynamic_config where
id in (SELECT dynamic_config_id FROM `point_config_relation`
<where>
<if test="ids != null and ids.size() != 0">
and point_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
)
</delete>
<delete id="deleteByStationId">
delete
from dynamic_config
where station_id = #{stationId}
</delete>
</mapper>

View File

@ -0,0 +1,77 @@
<?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.ho.business.mapper.DynamicConfigTitleMapper">
<sql id="Base_Column_List">
id,name,station_id,permission_id,page_location,div_location,device_id
</sql>
<insert id="insertOne" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into dynamic_config_title (name,name_en,station_id,permission_id,page_location,div_location,device_id)
values (#{name},#{nameEn},#{stationId},#{permissionId},#{pageLocation},#{divLocation},#{deviceId})
</insert>
<update id="updateById">
update dynamic_config_title
<set>
<if test="name != null">
name = #{name},
</if>
<if test="nameEn != null">
name_en = #{nameEn},
</if>
<if test="stationId != null">
station_id = #{stationId},
</if>
<if test="permissionId != null">
permission_id = #{permissionId},
</if>
<if test="pageLocation != null">
page_location = #{pageLocation},
</if>
<if test="divLocation != null">
div_location = #{divLocation},
</if>
<if test="deviceId != null">
device_id = #{deviceId},
</if>
</set>
where id = #{id}
</update>
<select id="selectByParam" resultType="com.ho.business.entity.DynamicConfigTitle">
SELECT
<include refid="Base_Column_List"/>
FROM dynamic_config_title
<where>
<if test="name != null">and name like concat('%',#{name},'%')</if>
<if test="stationId != null">and station_id = #{stationId}</if>
<if test="permissionId != null">and permission_id = #{permissionId}</if>
<if test="pageLocation != null">and page_location = #{pageLocation}</if>
<if test="divLocation != null">and div_location = #{divLocation}</if>
<if test="deviceId != null">and device_id = #{deviceId}</if>
</where>
</select>
<delete id="deleteById">
delete
from dynamic_config_title where
id = #{id}
</delete>
<delete id="deleteByIds">
delete
from dynamic_config_title
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,336 @@
<?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.ho.business.mapper.EarningsCalculateMapper">
<sql id="Base_Column_List">
id
,group_id,pid,
station_id,src_id,dept_id,
create_time,day,type,
digital,elec,rate_type,price,total
</sql>
<select id="selectList" resultType="com.ho.business.entity.EarningsCalculate">
SELECT
<include refid="Base_Column_List"/>
from earnings_calculate
<where>
and station_id = #{ec.stationId}
<if test="ec.typeList!=null and ec.typeList.size() !=0">
and type in
<foreach collection="ec.typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and day BETWEEN #{ec.beginTime}
AND #{ec.endTime}
</where>
order by `day`
</select>
<select id="totalList" resultType="com.ho.business.entity.EarningsCalculate">
SELECT ifnull(sum(digital),0) digital,ifnull(sum(elec),0) elec,ifnull(sum(total),0) total,type,rate_type
from earnings_calculate
<where>
and station_id = #{ec.stationId}
<if test="ec.beginTime!=null and ec.endTime != null">
and day BETWEEN #{ec.beginTime} AND #{ec.endTime}
</if>
group by `type`,rate_type
</where>
</select>
<select id="totalListByDay" resultType="com.ho.business.entity.EarningsCalculate">
SELECT sum(digital) digital,sum(elec) elec,sum(total) total,day,type,rate_type
from earnings_calculate
<where>
and station_id = #{ec.stationId}
<if test="ec.beginTime!=null and ec.endTime != null">
and day BETWEEN #{ec.beginTime} AND #{ec.endTime}
</if>
group by day,`type`,rate_type
</where>
</select>
<insert id="insertSelective" keyColumn="id" keyProperty="id"
parameterType="com.ho.business.entity.EarningsCalculate"
useGeneratedKeys="true">
insert into earnings_calculate
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="groupId != null">group_id,</if>
<if test="pid != null">pid,</if>
<if test="stationId != null">station_id,</if>
<if test="srcId != null">src_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="createTime != null">create_time,</if>
<if test="day != null">day,</if>
<if test="type != null">type,</if>
<if test="digital != null">digital,</if>
<if test="elec != null">elec,</if>
<if test="rateType != null">rate_type,</if>
<if test="price != null">price,</if>
<if test="total != null">total,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="pid != null">#{pid,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="day != null">#{day,jdbcType=VARCHAR},</if>
<if test="type != null">#{type,jdbcType=VARCHAR},</if>
<if test="digital != null">#{digital,jdbcType=VARCHAR},</if>
<if test="elec != null">#{elec},</if>
<if test="rateType != null">#{rateType},</if>
<if test="price != null">#{price},</if>
<if test="total != null">#{total},</if>
</trim>
</insert>
<delete id="deleteByDay">
delete
from earnings_calculate
<where>
and day = #{day}
<if test="typeList !=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByStationAndDay">
delete
from earnings_calculate
<where>
and day = #{day}
<if test="typeList !=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and station_id=#{stationId}
</where>
</delete>
<insert id="insertBatch">
INSERT INTO earnings_calculate
(group_id, pid, station_id, src_id, dept_id, create_time, day, type,
digital,elec,rate_type,price,total,discount)
VALUES
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.groupId},#{item.pid},#{item.stationId},#{item.srcId},#{item.deptId}, now(),
#{item.day},#{item.type},#{item.digital},#{item.elec},#{item.rateType},#{item.price},#{item.total},#{item.discount}
)
</foreach>
</insert>
<select id="queryElecTemplateSubByStationId" resultType="com.ho.business.entity.EarningsCalculateSub">
select sub.id,sub.begin_time,sub.end_time,sub.type,sub.price,tem.discount from elec_template_sub sub
right join elec_template tem on tem.id = sub.pid
where station_id = #{stationId} and tem.is_enable = 1
<if test="date == null">
and date_format(date_sub(now(),interval 1 day),'%Y-%m-%d') >= tem.validity_start_time and
date_format(date_sub(now(),interval 1 day),'%Y-%m-%d') &lt;= tem.validity_end_time
</if>
<if test="date != null">
and date_format(#{date},'%Y-%m-%d') >= tem.validity_start_time and date_format(#{date},'%Y-%m-%d') &lt;=
tem.validity_end_time
</if>
<!-- <if test="templateType != null">-->
<!-- and template_type = #{templateType}-->
<!-- </if>-->
order by begin_time
</select>
<select id="queryElecRateTemplateSubByStationId" resultType="com.ho.business.entity.EarningsCalculateSub">
select distinct sub.type,sub.price from elec_template_sub sub
right join elec_template tem on tem.id = sub.pid
where station_id = #{stationId} and tem.is_enable = 1
<if test="date == null">
and date_format(date_sub(now(),interval 1 day),'%Y-%m-%d') >= tem.validity_start_time and
date_format(date_sub(now(),interval 1 day),'%Y-%m-%d') &lt;= tem.validity_end_time
</if>
<if test="date != null">
and date_format(#{date},'%Y-%m-%d') >= tem.validity_start_time and date_format(#{date},'%Y-%m-%d') &lt;=
tem.validity_end_time
</if>
order by sub.type
</select>
<select id="getSrcIdByStationId" resultType="java.lang.Integer">
select src_id
from device
where device_type = #{deviceType}
and station_id = #{stationId} limit 1
</select>
<select id="getColCount" resultType="java.lang.Double">
select ifnull(offset, 0) as data
from col_count
where station_id = #{stationId}
and col = #{col}
and count_flag = 2
</select>
<select id="queryData" resultType="com.ho.business.entity.MonFreezeTotal">
select total_charge, total_discharge, month
from mon_freeze_total
where station_id = #{stationId}
and month = #{month}
</select>
<insert id="batchInsertData" parameterType="com.ho.business.entity.MonFreezeTotal">
insert into mon_freeze_total (station_id,total_charge,total_discharge,month)
values
<foreach collection="list" item="item" separator=",">
(#{item.stationId},#{item.totalCharge},#{item.totalDischarge},#{item.month})
</foreach>
</insert>
<select id="selectSumIncomeByStationId" resultType="java.math.BigDecimal">
select
sum(digital)
from earnings_calculate
where type = #{type}
<if test="stationId != null">
and station_id = #{stationId}
</if>
and day BETWEEN #{beginTime}
AND #{endTime}
</select>
<select id="queryRegionDataByDistrict" resultType="com.ho.business.vo.RegionData">
select p.name province_name,
p.region_id province_region_id,
c.name city_name,
c.region_id city_region_id,
d.name district_name,
d.region_id district_region_id
from dict_province p
left join dict_city c on p.id = c.p_id
left join dict_district d on c.id = d.p_id
where
(p.name = #{district} and c.name = #{city}) or c.name = #{city} or d.name = #{province}
limit 1
</select>
<select id="getGroupProfit" resultType="com.ho.business.vo.resp.profit.GroupProfitType">
select
sum(digital) as digital,type
from earnings_calculate
<where>
digital > 0
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and day BETWEEN #{beginTime}
AND #{endTime}
</if>
</where>
group by type
</select>
<select id="getStationProfit" resultType="com.ho.business.vo.resp.profit.StationProfitType">
select
station_id,type,sum(digital) as digital
from earnings_calculate
<where>
digital > 0
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and day BETWEEN #{beginTime}
AND #{endTime}
</if>
</where>
group by station_id,type
</select>
<select id="getDayProfit" resultType="com.ho.business.vo.resp.profit.DayProfitType">
select
day,type,sum(digital) as digital
from earnings_calculate
<where>
digital > 0
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and day BETWEEN #{beginTime}
AND #{endTime}
</if>
</where>
group by day,type
</select>
<select id="getFirstTime" resultType="java.lang.String">
SELECT min(day) day
FROM earnings_calculate;
</select>
<select id="getProfit" resultType="com.ho.business.vo.resp.profit.DayProfitType">
select
station_id,day,type,sum(digital) as digital
from earnings_calculate
<where>
digital > 0
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and day BETWEEN #{beginTime}
AND #{endTime}
</if>
</where>
group by station_id, day,type
</select>
<select id="getEarningsByParam" resultType="com.ho.business.vo.resp.profit.DayProfitType">
select
station_id,day,type,sum(digital) as digital
from earnings_calculate
<where>
digital > 0
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and day BETWEEN #{beginTime}
AND #{endTime}
</if>
<if test="stationIds != null and stationIds.size() != 0">
and station_id in
<foreach collection="stationIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
group by station_id, day,type
</select>
<delete id="deleteByStationId">
delete
from earnings_calculate
<where>
and day = #{day}
and station_id = #{stationId}
<if test="typeList !=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,59 @@
<?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.ho.business.mapper.ElecMeterConfigMapper">
<sql id="Base_Column_List">
id,station_id,user_id,begin_time,end_time,create_time,update_time
</sql>
<insert id="insertElecMeterConfig" parameterType="com.ho.business.entity.ElecMeterConfig">
insert into elec_meter_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="userId != null">user_id,</if>
<if test="beginTime != null">begin_time,</if>
<if test="endTime != null">end_time,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId},</if>
<if test="userId != null">#{userId},</if>
<if test="beginTime != null">#{beginTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateById" parameterType="com.ho.business.entity.ElecMeterConfig">
update elec_meter_config
<set>
<if test="beginTime != null">
begin_time = #{beginTime},
</if>
<if test="endTime != null">
end_time = #{endTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{id}
</update>
<select id="selectByParam" resultType="com.ho.business.entity.ElecMeterConfig">
SELECT <include refid="Base_Column_List"/>
FROM elec_meter_config
<where>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
</where>
limit 1
</select>
</mapper>

View File

@ -0,0 +1,348 @@
<?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.ho.business.mapper.ElecMeterValueMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ElecMeterValue">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="groupId" column="group_id" jdbcType="INTEGER"/>
<result property="pid" column="pid" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="srcId" column="src_id" jdbcType="INTEGER"/>
<result property="deptId" column="dept_id" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="day" column="day" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="digital" column="digital" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id
,group_id,pid,
station_id,src_id,dept_id,
create_time,day,type,
digital,status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from elec_meter_value
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectSumByType" resultType="java.math.BigDecimal">
SELECT sum(digital) as sum
from elec_meter_value
WHERE station_id = #{stationId}
and type = #{type}
<if test="srcId!=null">
and src_id = #{srcId}
</if>
<if test="beginTime != null">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
and status !=0
</select>
<select id="selectSumValue" resultType="java.math.BigDecimal">
SELECT sum(digital) as sum
from elec_meter_value
WHERE station_id = #{stationId}
and type = #{type}
<if test="srcId!=null">
and src_id = #{srcId}
</if>
and status !=0
</select>
<select id="selectListByStationAndSrcId" resultType="com.ho.business.entity.ElecMeterValue">
SELECT
<include refid="Base_Column_List"/>
from elec_meter_value
<where>
<if test="stationId!=null">
and station_id = #{stationId}
</if>
<if test="srcId!=null">
and src_id = #{srcId}
</if>
<if test="type!=null">
and `type` = #{type}
</if>
<if test="typeList!=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and day BETWEEN #{beginTime}
AND #{endTime}
</where>
</select>
<select id="selectList" resultType="com.ho.business.entity.ElecMeterValue">
SELECT
<include refid="Base_Column_List"/>
from elec_meter_value
<where>
and station_id = #{stationId}
<if test="typeList!=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and day BETWEEN #{beginTime}
AND #{endTime}
</where>
</select>
<select id="selectAllList" resultType="com.ho.business.entity.ElecMeterValue">
SELECT
<include refid="Base_Column_List"/>
from elec_meter_value
<where>
and station_id = #{stationId}
<if test="typeList!=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="deviceTypeList!=null and deviceTypeList.size() !=0">
and src_id in
<foreach collection="deviceTypeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and day BETWEEN #{beginTime}
AND #{endTime}
</where>
</select>
<select id="selectListByStationIds" resultType="com.ho.business.entity.ElecMeterValue">
SELECT
<include refid="Base_Column_List"/>
from elec_meter_value
<where>
<if test="stationIds!=null and stationIds.size() !=0">
and station_id in
<foreach collection="stationIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and type = #{type}
<if test="beginTime != null">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
and status !=0
</where>
</select>
<select id="selectByStationIdsAndTime" resultType="com.ho.business.entity.ElecMeterValue">
SELECT sum(digital) as digital,type,station_id
from elec_meter_value
<where>
<if test="stationIds!=null and stationIds.size() !=0">
and station_id in
<foreach collection="stationIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="beginTime != null">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="srcId!=null">
and src_id = #{srcId}
</if>
and status !=0
group by type,station_id
</where>
</select>
<select id="selectGroupByDay" resultType="com.ho.business.entity.ElecMeterValue">
SELECT sum(digital) as digital,type,station_id,day
from elec_meter_value
<where>
<if test="stationIds!=null and stationIds.size() !=0">
and station_id in
<foreach collection="stationIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="beginTime != null">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="srcId != null">
and src_id = #{srcId}
</if>
<if test="srcIds!=null and srcIds.size() !=0 ">
and src_id in
<foreach collection="srcIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and status !=0
group by type,station_id,day
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from elec_meter_value
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecMeterValue"
useGeneratedKeys="true">
insert into elec_meter_value
( id, group_id, pid
, station_id, src_id, dept_id
, create_time, day, type
, digital, status)
values ( #{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}
, #{stationId,jdbcType=INTEGER}, #{srcId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}
, #{createTime,jdbcType=TIMESTAMP}, #{day,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}
, #{digital,jdbcType=VARCHAR}, #{status})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecMeterValue"
useGeneratedKeys="true">
insert into elec_meter_value
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="groupId != null">group_id,</if>
<if test="pid != null">pid,</if>
<if test="stationId != null">station_id,</if>
<if test="srcId != null">src_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="createTime != null">create_time,</if>
<if test="day != null">day,</if>
<if test="type != null">type,</if>
<if test="digital != null">digital,</if>
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="pid != null">#{pid,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="day != null">#{day,jdbcType=VARCHAR},</if>
<if test="type != null">#{type,jdbcType=VARCHAR},</if>
<if test="digital != null">#{digital,jdbcType=VARCHAR},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.ElecMeterValue">
update elec_meter_value
<set>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=INTEGER},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="day != null">
day = #{day,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="digital != null">
digital = #{digital,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.ElecMeterValue">
update elec_meter_value
set group_id = #{groupId,jdbcType=INTEGER},
pid = #{pid,jdbcType=INTEGER},
station_id = #{stationId,jdbcType=INTEGER},
src_id = #{srcId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
day = #{day,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
digital = #{digital,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByDay">
delete
from elec_meter_value
<where>
and day = #{day}
<if test="typeList !=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByStationAndDay">
delete
from elec_meter_value
<where>
and day = #{day}
<if test="typeList !=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and station_id=#{stationId}
</where>
</delete>
<insert id="insertBatch">
INSERT INTO elec_meter_value
(group_id, pid, station_id, src_id, dept_id, create_time, day, type, digital,status)
VALUES
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.groupId},#{item.pid},#{item.stationId},#{item.srcId},#{item.deptId}, now(),
#{item.day},#{item.type},#{item.digital},#{item.status}
)
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,132 @@
<?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.ho.business.mapper.ElecPriceMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ElecPrice">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="groupId" column="group_id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="price" column="prices" jdbcType="DECIMAL"/>
<result property="priceType" column="prices_type" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
,start_time,price,group_id,station_id,
price_type
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from elec_price
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultType="com.ho.business.entity.ElecPrice">
select
<include refid="Base_Column_List"/>
from elec_price
</select>
<select id="selectByStationIdAndTime" resultType="com.ho.business.entity.ElecPrice">
SELECT
<include refid="Base_Column_List"/>
FROM `elec_price`
<where>
<if test="groupId!=null">
and group_id=#{groupId}
</if>
<if test="stationId!=null">
and station_id=#{stationId}
</if>
<if test="startTime!=null and startTime!=''">
and start_time between #{startTime} and #{endTime}
</if>
</where>
ORDER BY start_time
</select>
<select id="selectStartTime" resultType="java.lang.String">
SELECT start_time AS startTime
FROM `elec_price`
<where>
<if test="groupId!=null">
and group_id = #{groupId}
</if>
</where>
ORDER BY start_time DESC
LIMIT 1
</select>
<select id="selectDayTimes" resultType="java.lang.String">
SELECT start_time
FROM `elec_price`
WHERE start_time between #{stime} and now()
and station_id = #{id}
ORDER BY start_time
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from elec_price
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecPrice"
useGeneratedKeys="true">
insert into elec_price
( id, start_time, price, station_id
, price_type)
values (#{id,jdbcType=INTEGER},
#{startTime,jdbcType=TIMESTAMP},
#{stationId,jdbcType=INTEGER},
#{price,jdbcType=DECIMAL},
#{priceType,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecPrice"
useGeneratedKeys="true">
insert into elec_price
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="stationId != null">station_id,</if>
<if test="startTime != null">start_time,</if>
<if test="price != null">price,</if>
<if test="priceType != null">price_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="startTime != null">#{startTime,jdbcType=DATE},</if>
<if test="price != null">#{price,jdbcType=DECIMAL},</if>
<if test="priceType != null">#{priceType,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.ElecPrice">
update elec_price
<set>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER}
</if>
<if test="prices != null">
price = #{price,jdbcType=DECIMAL},
</if>
<if test="pricerType != null">
price_type = #{priceType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.ElecPrice">
update elec_price
set start_time = #{startTime,jdbcType=TIMESTAMP},
station_id = #{stationId,jdbcType=INTEGER},
price = #{price,jdbcType=DECIMAL},
price_type = #{priceType,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,194 @@
<?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.ho.business.mapper.ElecStationValueMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ElecStationValue">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="groupId" column="group_id" jdbcType="INTEGER"/>
<result property="deptId" column="dept_id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="digital" column="digital" jdbcType="DECIMAL"/>
<result property="day" column="day" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,group_id,dept_id,src_id,pid,
station_id,create_time,type,
digital,day
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from elec_station_value
where id = #{id,jdbcType=INTEGER}
</select>
<select id="underElectricityCollection" resultType="com.ho.business.vo.resp.StatisticsRespVO">
select day as date,digital
from elec_station_value
<where>
<if test="beginTime != null ">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="groupId !=null">
and group_id = #{groupId}
</if>
<if test="deptId != null">
and dept_id = #{deptId}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="type !=null">
and type = #{type}
</if>
</where>
order by day
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from elec_station_value
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecStationValue" useGeneratedKeys="true">
insert into elec_station_value
( id,group_id,dept_id,pid,src_id
,station_id,create_time,type
,digital,day)
values (#{id,jdbcType=INTEGER},#{groupId,jdbcType=INTEGER},#{deptId,jdbcType=INTEGER}
,#{stationId,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{type,jdbcType=INTEGER}
,#{digital,jdbcType=DECIMAL},#{day,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecStationValue" useGeneratedKeys="true">
insert into elec_station_value
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="groupId != null">group_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="stationId != null">station_id,</if>
<if test="createTime != null">create_time,</if>
<if test="type != null">type,</if>
<if test="digital != null">digital,</if>
<if test="day != null">day,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="type != null">#{type,jdbcType=INTEGER},</if>
<if test="digital != null">#{digital,jdbcType=DECIMAL},</if>
<if test="day != null">#{day,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.ElecStationValue">
update elec_station_value
<set>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="digital != null">
digital = #{digital,jdbcType=DECIMAL},
</if>
<if test="day != null">
day = #{day,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.ElecStationValue">
update elec_station_value
set
group_id = #{groupId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
station_id = #{stationId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
type = #{type,jdbcType=INTEGER},
digital = #{digital,jdbcType=DECIMAL},
day = #{day,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<!-- <insert id="insertBatch">-->
<!-- INSERT INTO elec_station_value (-->
<!-- <if test="groupId != null">group_id,</if>-->
<!-- <if test="deptId != null">dept_id,</if>-->
<!-- <if test="stationId != null">station_id,</if>-->
<!-- <if test="createTime != null">create_time,</if>-->
<!-- <if test="type != null">type,</if>-->
<!-- <if test="digital != null">digital,</if>-->
<!-- <if test="day != null">day,</if>-->
<!-- <if test="srcId != null">src_id,</if>-->
<!-- <if test="pid != null">pid,</if>-->
<!-- )-->
<!-- VALUES-->
<!-- <foreach item="item" collection="list" index="index" separator=",">-->
<!-- values (-->
<!-- <if test="groupId != null">#{item.groupId,jdbcType=INTEGER},</if>-->
<!-- <if test="deptId != null">#{item.deptId,jdbcType=INTEGER},</if>-->
<!-- <if test="stationId != null">#{item.stationId,jdbcType=INTEGER},</if>-->
<!-- <if test="createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</if>-->
<!-- <if test="type != null">#{item.type,jdbcType=INTEGER},</if>-->
<!-- <if test="digital != null">#{item.digital,jdbcType=DECIMAL},</if>-->
<!-- <if test="day != null">#{item.day,jdbcType=VARCHAR},</if>-->
<!-- <if test="srcId != null">#{item.src_id},</if>-->
<!-- <if test="pid != null">#{item.pid},</if>-->
<!-- )-->
<!-- </foreach>-->
<!-- </insert>-->
<insert id="insertBatch">
INSERT INTO elec_station_value (
group_id,dept_id,pid,src_id
,station_id,create_time,type,digital,day
)
VALUES
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.groupId,jdbcType=INTEGER},#{item.deptId,jdbcType=INTEGER},
#{item.stationId,jdbcType=INTEGER},now(),#{item.type,jdbcType=INTEGER},
#{item.digital,jdbcType=DECIMAL},#{item.day,jdbcType=VARCHAR},
#{item.pid,jdbcType=INTEGER},#{item.srcId,jdbcType=INTEGER}
)
</foreach>
</insert>
<delete id="deleteByDay">
delete
from elec_station_value
<where>
and day = #{day}
<if test="typeList !=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item = "item" open="(" close=")" separator="," >
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,213 @@
<?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.ho.business.mapper.ElecTemplateMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ElecTemplate">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="groupId" column="group_id" jdbcType="INTEGER"/>
<result property="templateNo" column="template_no" jdbcType="VARCHAR"/>
<result property="templateName" column="template_name" jdbcType="VARCHAR"/>
<result property="isEnable" column="is_enable" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="templateType" column="template_type"/>
<result property="elecType" column="elec_type"/>
<result property="validityStartTime" column="validity_start_time" jdbcType="TIMESTAMP"/>
<result property="validityEndTime" column="validity_end_time" jdbcType="TIMESTAMP"/>
<result property="discount" column="discount" />
</resultMap>
<sql id="Base_Column_List">
id,station_id,group_id,
template_no,template_name,is_enable,
create_time,update_time,template_type,elec_type,validity_start_time,validity_end_time,discount
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from elec_template
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByTemplateName" resultType="com.ho.business.entity.ElecTemplate">
select
<include refid="Base_Column_List"/>
from elec_template
where template_name = #{templateName}
and station_id = #{stationId}
limit 1
</select>
<select id="selectByInfo" resultType="com.ho.business.entity.ElecTemplate">
select
<include refid="Base_Column_List"/>
from elec_template
<where>
<if test="templateName != null and templateName != ''">
and template_name LIKE concat('%',#{templateName},'%')
</if>
<if test="isEnable != null">
and is_enable = #{isEnable,jdbcType=INTEGER}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="elecType != null">
and elec_type = #{elecType}
</if>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="validityStartTime != null and validityEndTime!= null">
and (
(
(validity_start_time between str_to_date(#{validityStartTime},'%Y-%m-%d %H:%i:%s') and str_to_date(#{validityEndTime},'%Y-%m-%d %H:%i:%s'))
or
(validity_end_time between str_to_date(#{validityStartTime},'%Y-%m-%d %H:%i:%s') and str_to_date(#{validityEndTime},'%Y-%m-%d %H:%i:%s'))
)
or
(
(str_to_date(#{validityStartTime},'%Y-%m-%d %H:%i:%s') between validity_start_time and validity_end_time)
or
(str_to_date(#{validityEndTime},'%Y-%m-%d %H:%i:%s') between validity_start_time and validity_end_time)
)
)
</if>
</where>
order by is_enable desc, update_time desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete
from elec_template
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByIds">
delete
from elec_template
<where>
<if test="ids != null and ids.size() !=0">
and id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and is_enable = 0
</where>
</delete>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecTemplate"
useGeneratedKeys="true">
insert into elec_template
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="groupId != null">group_id,</if>
<if test="templateNo != null">template_no,</if>
<if test="templateName != null">template_name,</if>
<if test="isEnable != null">is_enable,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="templateType != null">template_type,</if>
<if test="elecType != null">elec_type,</if>
<if test="validityStartTime != null">validity_start_time,</if>
<if test="validityEndTime != null">validity_end_time,</if>
<if test="discount != null">discount,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="templateNo != null">#{templateNo,jdbcType=VARCHAR},</if>
<if test="templateName != null">#{templateName,jdbcType=VARCHAR},</if>
<if test="isEnable != null">#{isEnable,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="templateType != null">#{templateType},</if>
<if test="elecType != null">#{elecType},</if>
<if test="validityStartTime != null">#{validityStartTime},</if>
<if test="validityEndTime != null">#{validityEndTime},</if>
<if test="discount != null">#{discount},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.ElecTemplate">
update elec_template
<set>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="templateNo != null">
template_no = #{templateNo,jdbcType=VARCHAR},
</if>
<if test="templateName != null">
template_name = #{templateName,jdbcType=VARCHAR},
</if>
<if test="isEnable != null">
is_enable = #{isEnable,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="templateType != null">
template_type = #{templateType,jdbcType=INTEGER},
</if>
<if test="elecType != null">
elec_type = #{elecType},
</if>
<if test="validityStartTime != null">
validity_start_time = #{validityStartTime},
</if>
<if test="validityEndTime != null">
validity_end_time = #{validityEndTime},
</if>
discount = #{discount},
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="checkTemplate" resultType="Integer">
select count(1) from elec_template where id = #{id} and is_enable = 1
</select>
<update id="updateIsEnabled" parameterType="com.ho.business.entity.ElecTemplate">
update elec_template set is_enable = 0 where station_id = #{stationId}
</update>
<select id="queryTemplatesByStationId" resultType="com.ho.business.entity.ElecTemplate">
select
<include refid="Base_Column_List"/>
from elec_template
where station_id = #{stationId} and is_enable = 1
and
(
(
(validity_start_time between str_to_date(#{validityStartTime},'%Y-%m-%d %H:%i:%s') and str_to_date(#{validityEndTime},'%Y-%m-%d %H:%i:%s'))
or
(validity_end_time between str_to_date(#{validityStartTime},'%Y-%m-%d %H:%i:%s') and str_to_date(#{validityEndTime},'%Y-%m-%d %H:%i:%s'))
)
or
(
(str_to_date(#{validityStartTime},'%Y-%m-%d %H:%i:%s') between validity_start_time and validity_end_time)
or
(str_to_date(#{validityEndTime},'%Y-%m-%d %H:%i:%s') between validity_start_time and validity_end_time)
)
)
<if test="id != null">
and id &lt;> #{id}
</if>
</select>
<select id="checkTemplateName" resultType="java.lang.Integer">
select count(1) from elec_template where template_name = #{templateName} and station_id = #{stationId}
and id &lt;> #{id}
</select>
</mapper>

View File

@ -0,0 +1,221 @@
<?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.ho.business.mapper.ElecTemplateSubMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ElecTemplateSub">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="pid" column="pid" jdbcType="INTEGER"/>
<result property="beginTime" column="begin_time" jdbcType="VARCHAR"/>
<result property="endTime" column="end_time" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="price" column="price" jdbcType="DECIMAL"/>
</resultMap>
<sql id="Base_Column_List">
id,pid,begin_time,
end_time,type,price
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from elec_template_sub
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByPid" resultType="com.ho.business.entity.ElecTemplateSub">
select
<include refid="Base_Column_List" />
from elec_template_sub
where pid = #{pid}
</select>
<select id="selectByPids" resultType="com.ho.business.entity.ElecTemplateSub">
select
<include refid="Base_Column_List" />
from elec_template_sub
<where>
<if test="pIds != null and pIds.size() !=0">
and pid in
<foreach collection="pIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from elec_template_sub
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deletedByPid">
delete from elec_template_sub
where pid = #{pid}
</delete>
<delete id="deletedByPids">
delete
from elec_template_sub
<where>
<if test="pIds != null and pIds.size() !=0">
and pid in
<foreach collection="pIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecTemplateSub" useGeneratedKeys="true">
insert into elec_template_sub
( id,pid,begin_time
,end_time,type,price
)
values (#{id,jdbcType=INTEGER},#{pid,jdbcType=INTEGER},#{beginTime,jdbcType=VARCHAR}
,#{endTime,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{price,jdbcType=DECIMAL}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ElecTemplateSub" useGeneratedKeys="true">
insert into elec_template_sub
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="pid != null">pid,</if>
<if test="beginTime != null">begin_time,</if>
<if test="endTime != null">end_time,</if>
<if test="type != null">type,</if>
<if test="price != null">price,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="pid != null">#{pid,jdbcType=INTEGER},</if>
<if test="beginTime != null">#{beginTime,jdbcType=VARCHAR},</if>
<if test="endTime != null">#{endTime,jdbcType=VARCHAR},</if>
<if test="type != null">#{type,jdbcType=VARCHAR},</if>
<if test="price != null">#{price,jdbcType=DECIMAL},</if>
</trim>
</insert>
<insert id="insertList">
insert into elec_template_sub
(pid,begin_time,end_time,type,price)
values
<foreach separator="," collection="list" item="item">
(#{item.pid},#{item.beginTime},#{item.endTime},#{item.type},#{item.price})
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.ElecTemplateSub">
update elec_template_sub
<set>
<if test="pid != null">
pid = #{pid,jdbcType=INTEGER},
</if>
<if test="beginTime != null">
begin_time = #{beginTime,jdbcType=VARCHAR},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="price != null">
price = #{price,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.ElecTemplateSub">
update elec_template_sub
set
pid = #{pid,jdbcType=INTEGER},
begin_time = #{beginTime,jdbcType=VARCHAR},
end_time = #{endTime,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByStationId" resultType="com.ho.business.entity.ElecTemplateSub">
select sub.id,sub.begin_time,sub.end_time,sub.price,sub.type
from elec_template tem
left join elec_template_sub sub on sub.pid = tem.id
where tem.station_id = #{stationId} and tem.is_enable = 1
order by sub.begin_time
</select>
<insert id="insertRateMeterValue" parameterType="com.ho.business.entity.ElecRateMeterValue">
insert into elec_rate_meter_value ( station_id,create_time,day,type,digital,rate_type ) values
<foreach collection="values" item="item" index="index" separator=",">
( #{item.stationId},sysdate(),#{item.day},#{item.type},#{item.digital},#{item.rateType} )
</foreach>
</insert>
<select id="getPcsIncomeData" resultType="HashMap">
<if test="req.type == 'day' or req.type == 'month'">
SELECT a.selected_date day,ifnull(b.data,'') data FROM
(
SELECT adddate('1970-01-01',t4.i * 10000 + t3.i * 1000 + t2.i * 100 + t1.i * 10 + t0.i) selected_date
FROM
( SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 ) t0,
( SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 ) t1,
( SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 ) t2,
( SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 ) t3,
( SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 ) t4
) a
left join (
select a.day,(b.data-a.data) data from (
(select day,sum(digital) data from elec_rate_meter_value value where station_id = #{req.stationId} and type = 1 and day between DATE_FORMAT(#{beginTime},'%Y-%m-%d') and DATE_FORMAT(#{endTime},'%Y-%m-%d') group by day) a,
(select day,sum(digital) data from elec_rate_meter_value value where station_id = #{req.stationId} and type = 2 and day between DATE_FORMAT(#{beginTime},'%Y-%m-%d') and DATE_FORMAT(#{endTime},'%Y-%m-%d') group by day) b
) where a.day=b.day
) b on b.day = a.selected_date
WHERE a.selected_date BETWEEN #{beginTime} AND #{endTime}
order by a.selected_date
</if>
<if test="req.type == 'year'">
select a.yearAndMonth day,ifnull(sum(b.data),'') data from (
select date_format(`date`, '%Y-%m') yearAndMonth from (select adddate('1970-01-01', interval t2.i * 100 + t1.i * 10 + t0.i month) `date`
from (select 0 i union select 1 union
select 2 union select 3 union
select 4 union select 5 union
select 6 union select 7 union
select 8 union select 9) t0,
(select 0 i union select 1 union
select 2 union select 3 union
select 4 union select 5 union
select 6 union select 7 union
select 8 union select 9) t1,
(select 0 i union select 1 union
select 2 union select 3 union
select 4 union select 5 union
select 6 union select 7 union
select 8 union select 9) t2) a
where date between date_format(#{beginTime},'%Y-%m-%d') and #{endTime}
) a
left join (
select date_format(a.day,'%Y-%m') date,(b.data-a.data) data from (
(select day,sum(digital) data from elec_rate_meter_value value where station_id = #{req.stationId} and type = 1 and day between DATE_FORMAT(#{beginTime},'%Y-%m-%d') and DATE_FORMAT(#{endTime},'%Y-%m-%d') group by day) a,
(select day,sum(digital) data from elec_rate_meter_value value where station_id = #{req.stationId} and type = 2 and day between DATE_FORMAT(#{beginTime},'%Y-%m-%d') and DATE_FORMAT(#{endTime},'%Y-%m-%d') group by day) b
) where a.day=b.day
) b on b.date = a.yearAndMonth
group by a.yearAndMonth
order by a.yearAndMonth
</if>
</select>
<delete id="deleteRateMeterValue">
delete from elec_rate_meter_value where day between DATE_FORMAT(#{beginTime},'%Y-%m-%d') and DATE_FORMAT(#{endTime},'%Y-%m-%d')
and type = #{type}
</delete>
<select id="queryRealTimePcsIncomeData" resultType="com.ho.business.entity.ElecRateMeterValue">
select id,type,digital,rate_type from elec_rate_meter_value
where station_id = #{stationId} and day = DATE_FORMAT(#{dateTime},'%Y-%m-%d')
order by id
</select>
</mapper>

View File

@ -0,0 +1,32 @@
<?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.ho.business.mapper.EmsMetricMapper">
<insert id="insert" parameterType="com.ho.business.entity.EmsMetric">
insert into ems_metrics
(station_id, cpu_ratio, memory_ratio, disk_ratio, day, create_time, sn)
values
(#{stationId},#{cpuRatio},#{memoryRatio},#{diskRatio},#{day},#{createTime},#{sn})
</insert>
<update id="updateByStationIdAndDay" parameterType="com.ho.business.entity.EmsMetric">
update ems_metrics set cpu_ratio=#{cpuRatio}, memory_ratio=#{memoryRatio}, disk_ratio=#{diskRatio}, create_time=#{createTime}, sn=#{sn}
where station_id=#{stationId} and day=#{day}
</update>
<select id="selectByStationIdAndDay" resultType="com.ho.business.entity.EmsMetric">
select id, station_id, cpu_ratio, memory_ratio, disk_ratio, day, create_time, sn from ems_metrics
where station_id = #{stationId} and day = #{day}
</select>
<select id="listByStationId" resultType="com.ho.business.entity.EmsMetric"
parameterType="java.lang.Integer">
select id, station_id, cpu_ratio, memory_ratio, disk_ratio, day, create_time, sn from ems_metrics
where
station_id = #{id}
order by day desc limit 1
</select>
</mapper>

View File

@ -0,0 +1,118 @@
<?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.ho.business.mapper.ForwardColTemplateMapper">
<resultMap id="baseResult" type="com.ho.business.vo.resp.ForwardColTemplateResp">
<id property="tempId" column="id" />
<result property="templateName" column="template_name"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<collection property="forwardCols" ofType="com.ho.business.entity.ForwardCol">
<id property="id" column="id"/>
<result property="templateId" column="template_id"/>
<result property="modelColId" column="model_col_id"/>
<result property="colName" column="col_name"/>
</collection>
</resultMap>
<!-- 新增模板 -->
<insert id="addForwardColTemplate" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.ho.business.vo.req.ForwardColTemplateReq">
insert into forward_col_template (template_name,create_time)
values(#{templateName},now())
</insert>
<!-- 新增测点 -->
<insert id="addForwardCol" parameterType="com.ho.business.entity.ForwardCol">
insert into forward_col ( template_id,model_col_id,col_name) values
<foreach collection="list" item="item" index="index" separator=",">
( #{planningTemplateId},#{item.modelColId},#{item.colName})
</foreach>
</insert>
<!-- 编辑模板 -->
<update id="modifyForwardColTemplate" parameterType="com.ho.business.vo.req.ForwardColTemplateReq">
update forward_col_template set
<if test="templateName != null and templateName != ''">
template_name = #{templateName},
</if>
update_time = sysdate()
where id = #{id}
</update>
<!-- 删除测点数据 -->
<delete id="deleteForwardCol">
delete from forward_col where template_id = #{id}
</delete>
<delete id="deleteForwardColTemplates">
delete from forward_col_template
where id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<delete id="deleteForwardCols">
delete from forward_col
where template_id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<select id="checkName" resultType="java.lang.Integer">
select count(1) from forward_col_template where template_name = #{templateName}
<if test="temId != null">
and id = #{temId}
</if>
</select>
<!-- 查询模板列表接口 -->
<select id="getForwardColTemplateDetail" resultMap="baseResult">
select tem.id temp_id,tem.template_name template_name,tem.create_time create_time, tem.update_time update_time,
cur.id id,cur.template_id,cur.model_col_id,cur.col_name
from (
select id,template_name,create_time,update_time
from forward_col_template
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
<if test="templateName != null and templateName != ''">
and template_name like concat('%',#{templateName},'%')
</if>
</where>
) tem left join forward_col cur on cur.template_id = tem.id
order by tem.create_time,tem.update_time desc
</select>
<select id="getForwardCol" resultType="com.ho.business.entity.DeviceTypeCol">
SELECT
device_type,
col,
col_name
FROM
device_type_col
WHERE
id IN (
SELECT
m.device_col_id
FROM
forward_col f
LEFT JOIN model_device_col m ON f.model_col_id = m.model_col_id
<where>
<if test="tempId != null">
and template_id = #{tempId}
</if>
<if test="typeList != null and typeList.size >0 ">
and m.device_type in
<foreach collection="typeList" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
)
</select>
</mapper>

View File

@ -0,0 +1,125 @@
<?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.ho.business.mapper.GateValueMapper">
<sql id="Base_Column_List">
id
,group_id,dept_id,
station_id,create_time,type,
digital,day
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from gate_value
where id = #{id,jdbcType=INTEGER}
</select>
<select id="getStatisticsList" resultType="com.ho.business.vo.resp.StatisticsRespVO">
select day as date , digital
from gate_value
<where>
<if test="beginTime != null ">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="deptId != null">
and dept_id = #{deptId}
</if>
<if test="type !=null">
and type = #{type}
</if>
</where>
order by day
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from gate_value
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.GateValue"
useGeneratedKeys="true">
insert into gate_value
( id, group_id, dept_id
, station_id, create_time, type
, digital, day)
values ( #{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}
, #{stationId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER}
, #{digital,jdbcType=DECIMAL}, #{day,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.GateValue"
useGeneratedKeys="true">
insert into gate_value
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="groupId != null">group_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="stationId != null">station_id,</if>
<if test="createTime != null">create_time,</if>
<if test="type != null">type,</if>
<if test="digital != null">digital,</if>
<if test="day != null">day,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="type != null">#{type,jdbcType=INTEGER},</if>
<if test="digital != null">#{digital,jdbcType=DECIMAL},</if>
<if test="day != null">#{day,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.GateValue">
update gate_value
<set>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="digital != null">
digital = #{digital,jdbcType=DECIMAL},
</if>
<if test="day != null">
day = #{day,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.GateValue">
update gate_value
set group_id = #{groupId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
station_id = #{stationId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
type = #{type,jdbcType=INTEGER},
digital = #{digital,jdbcType=DECIMAL},
day = #{day,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,64 @@
<?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.ho.business.mapper.HisCurveRelateMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.HisCurveRelate">
<id property="id" column="id" jdbcType="INTEGER"/>
<id property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="modelId" column="model_id" jdbcType="VARCHAR"/>
<result property="modelName" column="model_name" jdbcType="VARCHAR"/>
<result property="srcId" column="src_id" jdbcType="INTEGER"/>
<result property="col" column="col" jdbcType="VARCHAR"/>
<result property="colName" column="col_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
,user_id,model_id,
model_name,src_id,col,station_id,device_type,
col_name
</sql>
<insert id="insertBatch">
INSERT INTO his_curve_relate
(user_id,model_id,
model_name,src_id,col,station_id,device_type,
col_name)
VALUES
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.userId},#{item.modelId},#{item.modelName},#{item.srcId}
,#{item.col} ,#{item.stationId},#{item.deviceType}
,#{item.colName}
)
</foreach>
</insert>
<select id="selectAll" resultType="com.ho.business.entity.HisCurveRelate">
select
<include refid="Base_Column_List"/>
from his_curve_relate
<where>
<if test="hisCurveRelate.stationId!=null">
and station_id = #{hisCurveRelate.stationId}
</if>
<if test="hisCurveRelate.userId!=null">
and user_id = #{hisCurveRelate.userId}
</if>
<if test="hisCurveRelate.modelName!=null">
and model_name like concat('%',#{hisCurveRelate.modelName},'%')
</if>
</where>
</select>
<delete id="delete">
delete
from his_curve_relate
where model_id = #{modelId}
</delete>
</mapper>

View File

@ -0,0 +1,67 @@
<?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.ho.business.mapper.HomeConfigMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.HomeConfig">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="topLeft" column="topLeft" jdbcType="VARCHAR"/>
<result property="leftBottom" column="leftBottom" jdbcType="VARCHAR"/>
<result property="topCenter" column="topCenter" jdbcType="VARCHAR"/>
<result property="rightCenter" column="rightCenter" jdbcType="VARCHAR"/>
<result property="bottom" column="bottom" jdbcType="VARCHAR"/>
<result property="rightTop" column="rightTop" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
,station_id,topLeft,leftBottom,topCenter,rightCenter,bottom,rightTop
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.vo.req.HomeConfigAddReqVO"
useGeneratedKeys="true">
insert into `home_config`
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="topLeft != null">topLeft,</if>
<if test="leftBottom != null">leftBottom,</if>
<if test="topCenter != null">topCenter,</if>
<if test="rightCenter != null">rightCenter,</if>
<if test="bottom != null">bottom,</if>
<if test="rightTop != null">rightTop,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId},</if>
<if test="topLeft != null">#{topLeft},</if>
<if test="leftBottom != null">#{leftBottom},</if>
<if test="topCenter != null">#{topCenter},</if>
<if test="rightCenter != null">#{rightCenter},</if>
<if test="bottom != null">#{bottom},</if>
<if test="rightTop != null">#{rightTop},</if>
</trim>
</insert>
<delete id="delete">
delete
from `home_config`
where station_id = #{id,jdbcType=INTEGER}
</delete>
<select id="selectByStationId" resultType="com.ho.business.entity.HomeConfig">
SELECT
<include refid="Base_Column_List"/>
from `home_config`
<where>
<if test="stationId != null ">
station_id = #{stationId}
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,109 @@
<?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.ho.business.mapper.IncomeMappingMapper">
<resultMap type="com.ho.business.entity.RateTemplate" id="rateTemplateResultMap">
<id property="id" column="id"/>
<result property="templateType" column="template_type"/>
<result property="templateTypeName" column="template_type_name"/>
<result property="templateName" column="template_name"/>
<result property="rateNum" column="rate_num"/>
<result property="context" column="context"/>
<result property="operatorName" column="operator_name"/>
<result property="createTime" column="create_time"/>
<result property="modifyName" column="modify_name"/>
<result property="modifyTime" column="modify_time"/>
<result property="stationId" column="station_id"/>
<result property="open" column="open"/>
<collection property="rateMappings" ofType="com.ho.business.entity.IncomeRateMapping">
<id property="rateId" column="rate_id"/>
<result property="rateName" column="rate_name"/>
<result property="price" column="price"/>
<result property="templateId" column="template_id"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="discount" column="discount"/>
</collection >
</resultMap>
<select id="selectRateTemplates" resultMap="rateTemplateResultMap">
select t1.id,t1.template_type,t3.type_name template_type_name,t1.template_name,t1.rate_num,t1.context,t1.operator_id,date_format(t1.create_time,'%Y-%m-%d') create_time,t1.modify_id,
date_format(t1.modify_time,'%Y-%m-%d') modify_time,t1.station_id, t2.rate_id,t2.rate_name,t2.price,t2.template_id,t2.discount,t2.start_time,t2.end_time,t1.open
from
income_rate_template t1
left join income_rate_mapping t2 on t1.id = t2.template_id
left join income_template_type t3 on t1.template_type = t3.type
where t1.station_id = #{stationId}
<if test=" templateName != null and templateName != '' ">
and t1.template_name like concat('%',#{templateName},'%')
</if>
order by t1.id,t2.rate_id
</select>
<insert id="insertRateTemplate" parameterType="com.ho.business.entity.RateTemplate">
insert into income_rate_template ( id,template_type,template_name,rate_num,context,operator_id,create_time,station_id,open )
values ( #{id},#{templateType},#{templateName},#{rateNum},#{context},#{operatorId},#{createTime},#{stationId},0 )
</insert>
<update id="modifyRateTemplate" parameterType="com.ho.business.entity.IncomeRateMapping">
update income_rate_template set template_type = #{templateType},template_name = #{templateName},rate_num = #{rateNum},context =#{context},modify_id = #{modifyId},modify_time = #{createTime}
where id = #{id}
</update>
<delete id="deleteRateTemplate">
delete from income_rate_template where id = #{id}
</delete>
<resultMap id="templateTypeMap" type="com.ho.business.entity.IncomeTemplateType">
<id property="id" column="id"/>
<result property="type" column="type"/>
<result property="typeName" column="type_name"/>
</resultMap>
<select id="getIncomeTemplateTypes" resultMap="templateTypeMap" >
select id ,type ,type_name from income_template_type
</select>
<insert id="insertRateMapping" parameterType="com.ho.business.entity.IncomeRateMapping">
insert into income_rate_mapping ( rate_id,start_time,end_time,rate_name,price,template_id,discount )
values
<foreach item="data" collection="incomeRateMappings" separator=",">
(
#{data.rateId},#{data.startTime},#{data.endTime},#{data.rateName},#{data.price},#{templateId},#{data.discount}
)
</foreach>
</insert>
<delete id="deleteRateMapping">
delete from income_rate_mapping where template_id = #{templateId}
</delete>
<select id="checkTemplateName" resultType="java.lang.Integer">
select count(1) from income_rate_template where template_name = #{templateName} and station_id = #{stationId}
</select>
<select id="checkTemplateOpen" resultType="java.lang.Integer" parameterType="com.ho.business.entity.RateTemplate">
select count(1) from income_rate_template where station_id = #{stationId} and template_type = #{templateType} and open = 1
</select>
<update id="changeSwitch" parameterType="com.ho.business.entity.RateTemplate">
update income_rate_template set open = #{open} where id = #{id}
</update>
<select id="checkTemplateRate" resultType="java.lang.Integer">
select count(1) from income_rate_template t1
join income_rate t2 on t1.id = t2.template_id where t1.id = #{id}
</select>
<select id="checkTemplateQRate" resultType="java.lang.Integer">
select count(1) from income_rate_template t1
join income_q_rate t2 on t1.id = t2.template_id where t1.id = #{id}
</select>
<select id="checkTotalTemplate" resultType="java.lang.Integer">
select count(1) from income_rate_template t1
join income_total t2 on (t1.id = t2.template_id or t1.id = t2.surf_template_id)
where t1.id = #{id} and t2.type = '1' and t2.flag = '0'
</select>
</mapper>

View File

@ -0,0 +1,442 @@
<?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.ho.business.mapper.IncomeMeasurementMapper">
<!-- 根据电站id查询费率模板下拉列表数据 -->
<select id="getRateTemplateList" resultType="com.ho.business.entity.RateTemplate">
select id,
template_name
from income_rate_template
where station_id = #{stationId}
and open = 1
</select>
<!-- 根据模板id查询费率下拉列表数据 -->
<select id="getRateList" resultType="com.ho.business.entity.IncomeRateMapping">
select rate_id,
rate_name,
start_time,
end_time
from income_rate_mapping
where template_id = #{templateId}
</select>
<!-- 根据模板id和费率id查询费率详情 -->
<select id="getRateDetails" resultType="com.ho.business.entity.IncomeRateMapping">
select price,
start_time,
end_time,
discount
from income_rate_mapping
where rate_id = #{rateId}
and template_id = #{templateId}
</select>
<!-- 根据电站id查询企业用电费率 -->
<select id="selectIncomeRates" resultType="com.ho.business.entity.IncomeRate">
select q.id,
q.start_time,
q.end_time,
q.rate_name,
q.q,
q.price,
q.discount,
q.template_id,
q.rate_id,
q.data_date,
1 type,
q.template_id old_template_id,
q.rate_id old_rate_id
from income_rate q
left join income_rate_template tem on q.template_id = tem.id
where tem.station_id = #{stationId}
and date_format(q.data_date, '%Y-%m') = #{dataDate}
</select>
<!-- 查询上网用电数据 -->
<select id="selectQRate" resultType="com.ho.business.entity.IncomeQRate">
select q.id,
q.surf_q,
q.price,
q.template_id,
q.rate_id,
q.data_date,
q.discount,
q.start_time,
q.end_time,
q.template_id old_template_id,
q.rate_id old_rate_id
from income_q_rate q
left join income_rate_template tem on q.template_id = tem.id
where tem.station_id = #{stationId}
and date_format(q.data_date, '%Y-%m') = #{dataDate}
</select>
<!-- 删除(可批量) -->
<delete id="deleteIncomeRates" parameterType="com.ho.business.entity.IncomeRate">
delete
from income_rate
where station_id = #{stationId}
and date_format(data_date, '%Y-%m') = #{dataDate}
</delete>
<!-- 批量插入企业用电费率 -->
<insert id="batchIncomeRates" parameterType="com.ho.business.entity.IncomeRate">
insert into income_rate
(
data_date,
rate_id,
template_id,
q,
start_time,
end_time,
rate_name,
price,
discount,
station_id
)
values
<foreach item="data" collection="incomeRates" separator=",">
(
concat(#{dataDate},'-01'),
<if test="data.rateId != null and data.rateId != 0">
#{data.rateId},
</if>
<if test="data.rateId == null or data.rateId == 0">
(
select rate_id from income_rate_mapping where rate_name = #{data.rateName} and template_id
=#{data.templateId}
),
</if>
#{data.templateId},
#{data.q},
#{data.startTime},
#{data.endTime},
#{data.rateName},
#{data.price},
#{data.discount},
#{data.stationId}
)
</foreach>
</insert>
<insert id="insertSurfQRate" parameterType="com.ho.business.entity.IncomeQRate">
insert into income_q_rate (data_date, surf_q, rate_id, template_id, start_time, end_time, rate_name, price,
discount)
values (date_format(concat(#{surfQRate.dataDate}, '-01'), '%Y-%m-%d'), #{surfQRate.surfQ}, #{surfQRate.rateId},
#{surfQRate.templateId}, #{surfQRate.startTime}, #{surfQRate.endTime}, #{surfQRate.rateName},
#{surfQRate.price}, #{surfQRate.discount})
</insert>
<!-- 修改上网用电数据 -->
<update id="modifySurfRate" parameterType="com.ho.business.entity.IncomeQRate">
update income_q_rate
set surf_q = #{surfQ},
template_id = #{templateId},
rate_id = #{rateId},
rate_name = #{rateName},
start_time = #{startTime},
end_time = #{endTime},
price = #{price},
discount = #{discount}
where id = #{id}
</update>
<!-- 确认按钮 type = 2 -->
<update id="confirmTwo" parameterType="com.ho.business.entity.IncomeTotal">
update income_total
set flag = 1
where station_id = #{stationId}
and date_format(date, '%Y-%m') = #{dataDate}
and type = 2
</update>
<!-- 确认按钮 type = 1 -->
<update id="confirmOne">
update income_total
set flag = 1
where station_id = #{stationId}
and date_format(data_date, '%Y-%m') = #{dataDate}
and type = 1
</update>
<!-- 查询费率号(下拉框数据) -->
<select id="selectRates" resultType="com.ho.business.entity.IncomeRateMapping">
select rate_id,
rate_name,
station_id
from income_rate_mapping
</select>
<!-- 查询累计收益 -->
<select id="selectTotal" resultType="com.ho.business.entity.IncomeTotal">
select
ele_total_fee,
income_fee,
total_fee,
flag,
date,
station_id
from income_total
where station_id = #{incomeTotal.stationId} and date_format(data_date, '%Y-%m') = #{incomeTotal.dataDate}
and type = 1 limit 1
</select>
<!-- 查询累计收益 -->
<select id="selectTotalReal" resultType="com.ho.business.entity.IncomeTotal">
select
sum(ele_total_fee) ele_total_fee,
sum(income_fee) income_fee,
sum(total_fee) total_fee,
flag,
station_id
from income_total
where type = 2
<if test="incomeTotal.stationId != null">
and station_id = #{incomeTotal.stationId}
</if>
<if test="incomeTotal.startTime != null and incomeTotal.endTime != null ">
and date BETWEEN #{incomeTotal.startTime} and #{incomeTotal.endTime}
</if>
group by station_id,flag
</select>
<!-- 根据模板id和当前系统时间查询费率 -->
<select id="selectRate" resultType="com.ho.business.entity.IncomeRateMapping">
select rate_id, price, discount
from income_rate_mapping
where template_id = #{templateId}
and start_time &lt;= current_time
and end_time >= current_time
</select>
<!-- 在累计收益表中插入一条数据 -->
<insert id="insertTotalFee" parameterType="com.ho.business.entity.IncomeTotal">
insert into income_total (ele_total_fee, income_fee, total_fee, flag, date, station_id, data_date, group_id,
type, template_id, rate_id)
values (#{incomeTotal.eleTotalFee}, #{incomeTotal.incomeFee}, #{incomeTotal.totalFee}, 0,
current_date, #{incomeTotal.stationId}, str_to_date(concat(#{incomeTotal.dataDate}, '-01'), '%Y-%m-%d'),
#{incomeTotal.groupId}, 1, #{incomeTotal.templateId}, #{incomeTotal.rateId})
</insert>
<!-- 修改企业用电收益 -->
<update id="modifyEleTotalFee" parameterType="com.ho.business.entity.IncomeTotal">
update income_total set
<if test="eleTotalFee != 0">
ele_total_fee = #{eleTotalFee},
</if>
<if test="incomeFee != 0">
income_fee = #{incomeFee},
</if>
<if test="templateId != 0 and templateId != null">
template_id = #{templateId},
</if>
<if test="surfTemplateId != 0 and surfTemplateId != null">
surf_template_id = #{surfTemplateId},
</if>
rate_id = #{rateId},
total_fee = (#{eleTotalFee} + #{incomeFee})
where date_format(data_date, '%Y-%m') = #{dataDate} and station_id = #{stationId} and flag = 0 and type = 1
</update>
<select id="getIncomeFee" resultType="java.lang.String">
select ifnull(income_fee, 0) income_fee
from income_total
where date_format(data_date, '%Y-%m') = #{dataDate}
and station_id = #{stationId}
and type = 1
</select>
<select id="getEleTotalFee" resultType="java.lang.String">
select ifnull(ele_total_fee, 0) ele_total_fee
from income_total
where date_format(data_date, '%Y-%m') = #{dataDate}
and station_id = #{stationId}
and type = 1
</select>
<!-- 根据date(时间)和templateId(模板id)查询是否已经有一条数据 -->
<select id="selectTotalFee" resultType="com.ho.business.entity.IncomeTotal">
select sum(ele_total_fee) ele_total_fee, sum(income_fee) income_fee, sum(total_fee) total_fee
from income_total
where date_format(data_date, '%Y-%m') = #{dataDate}
and station_id = #{stationId}
and type = 1
group by template_id, date
</select>
<select id="selectIncomeDetails" resultType="com.ho.business.entity.IncomeRate">
select rate.start_time,
rate.end_time,
rate.rate_name,
q.q,
rate.price,
concat(rate.discount * 100, '%') discount,
tem.id template_id,
rate.rate_id,
q.data_date
from income_rate q
left join income_rate_template tem on q.template_id = tem.id
left join income_rate_mapping rate on rate.rate_id = q.rate_id and q.template_id = rate.template_id
where tem.station_id = #{stationId}
and date_format(q.data_date, '%Y-%m') = #{dataDate}
and q.template_id = #{templateId}
and q.rate_id = #{rate}
</select>
<!-- excel模板导入 -->
<insert id="excelInput" parameterType="com.ho.business.entity.IncomeRate">
insert into income_rate
(
data_date,
rate_id,
template_id,
q,
start_time,
end_time,
rate_name,
price,
discount,
station_id
)
values
(
concat(#{dataDate},'-01'),
<if test="incomeRate.rateId != null and incomeRate.rateId != 0">
#{incomeRate.rateId},
</if>
<if test="incomeRate.rateId == null or incomeRate.rateId == 0">
(
select rate_id from income_rate_mapping where rate_name = #{incomeRate.rateName} and template_id
=#{templateId}
),
</if>
#{templateId},
#{incomeRate.q},
#{incomeRate.startTime},
#{incomeRate.endTime},
#{incomeRate.rateName},
#{incomeRate.price},
#{incomeRate.discount},
#{incomeRate.stationId}
)
</insert>
<select id="getTemplateByName" resultType="com.ho.business.entity.RateTemplate">
select id
from income_rate_template
where station_id = #{stationId}
and template_name = #{templateName}
</select>
<select id="getRateByName" resultType="com.ho.business.entity.IncomeRateMapping">
select rate_id,
rate_name,
price,
discount,
start_time,
end_time
from income_rate_mapping
where template_id = #{templateId}
and rate_name = #{rateName}
</select>
<select id="ischeck" resultType="java.lang.Integer">
select count(1)
from income_rate q
left join income_rate_template tem on q.template_id = tem.id
left join income_rate_mapping rate on rate.rate_id = q.rate_id and q.template_id = rate.template_id
where tem.station_id = #{stationId}
and date_format(q.data_date, '%Y-%m') = #{dataDate}
and q.template_id = #{templateId}
and rate.rate_id = #{rateId}
and q.id &lt;> #{id}
</select>
<update id="modifyIncomeRate">
update income_rate
set q = #{incomeRate.q},
rate_id = #{incomeRate.rateId},
template_id=#{incomeRate.templateId},
rate_name = #{incomeRate.rateName},
start_time = #{incomeRate.startTime},
end_time = #{incomeRate.endTime},
price = #{incomeRate.price},
discount = #{incomeRate.discount}
where id = #{incomeRate.id}
</update>
<select id="queryRateTotal" resultType="java.lang.String">
select sum(q.q * rate.price * rate.discount) data
from income_rate q
left join income_rate_template tem on tem.id = q.template_id
left join income_rate_mapping rate on rate.rate_id = q.rate_id and rate.template_id = q.template_id
where q.template_id = #{templateId}
and date_format(q.data_date, '%Y-%m') = #{dataDate}
and q.rate_id &lt;> #{rateId}
</select>
<select id="queryPriceBystationId" resultType="com.ho.business.entity.IncomeQRate">
select tem.id templateId,
rate.rate_id,
rate.price,
rate.discount,
rate.rate_name,
rate.start_time,
rate.end_time,
tem.station_id,
rate.discount
from income_rate_mapping rate
left join income_rate_template tem on tem.id = rate.template_id
where tem.template_type = 1
and rate.start_time &lt;= #{time}
and rate.end_time > #{time}
and open = 1
and tem.station_id = #{stationId}
limit 1
</select>
<insert id="insertRealData">
insert into income_total (template_id, rate_name, rate_id, price, ele, ele_total_fee, total_fee, flag, date,
src_id, station_id, data_date, group_id, type, discount, start_time, end_time)
values (#{templateId}, #{rateName}, #{rateId}, #{price}, #{ele}, #{eleTotalFee}, #{totalFee}, 0, current_date,
#{srcId}, #{stationId}, #{dataDate}, #{groupId}, 2, #{discount}, #{startTime}, #{endTime})
</insert>
<select id="selectRealRates" resultType="com.ho.business.entity.IncomeRate">
select rate_name,price,sum(ele) q,discount,start_time,end_time from income_total
where type = 2
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="startTime != null and endTime != null ">
and date BETWEEN #{startTime} and #{endTime}
</if>
group by template_id,rate_name,price,discount,start_time,end_time
</select>
<!-- 判断企业用电是否选择了别的模板 -->
<select id="checkTemplate" resultType="java.lang.Integer">
select count(1) from income_rate q
left join income_rate_template tem on q.template_id = tem.id
left join income_rate_mapping rate on rate.rate_id = q.rate_id and q.template_id = rate.template_id
where tem.station_id = #{stationId} and date_format(q.data_date, '%Y-%m') = #{dataDate} and q.template_id &lt;>
#{templateId}
<if test="id != 0 and id != null">
and q.id &lt;> #{id}
</if>
</select>
<select id="checkTemplateOpen" resultType="java.lang.Integer">
select count(1)
from income_rate_template
where id = #{templateId} and open = '1'
</select>
</mapper>

View 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.ho.business.mapper.IncomeTotalMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.IncomeTotal">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="templateId" column="template_id" jdbcType="VARCHAR"/>
<result property="rateId" column="rate_id" jdbcType="INTEGER"/>
<result property="ele" column="ele" jdbcType="DECIMAL"/>
<result property="eleTotalFee" column="ele_total_fee" jdbcType="DECIMAL"/>
<result property="incomeFee" column="income_fee" jdbcType="DECIMAL"/>
<result property="totalFee" column="total_fee" jdbcType="DECIMAL"/>
<result property="flag" column="flag" jdbcType="INTEGER"/>
<result property="date" column="date" jdbcType="DATE"/>
<result property="srcId" column="src_id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="dataDate" column="data_date" jdbcType="TIMESTAMP"/>
<result property="groupId" column="group_id" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id
,template_id,rate_id,
ele,ele_total_fee,income_fee,
total_fee,flag,date,
src_id,station_id,data_date,
group_id,type
</sql>
<select id="selectByDate" resultType="com.ho.business.entity.IncomeTotal">
select
<include refid="Base_Column_List"/>
from income_total
<where>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="list !=null and list.size() !=0">
and src_id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="startDayTime != null ">
and data_date > #{startDayTime}
</if>
<if test="endDayTime != null">
and data_date &lt;= #{endDayTime}
</if>
and type = 2
</where>
</select>
<select id="selectByStations" resultType="com.ho.business.entity.IncomeTotal">
select
<include refid="Base_Column_List"/>
from income_total
<where>
<if test="list !=null and list.size() !=0">
and station_id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="startDayTime != null and endDayTime != null">
and date between #{startDayTime} and #{endDayTime}
</if>
and type = 2
</where>
</select>
<select id="selectDailySumByStationId"
resultType="com.ho.business.vo.resp.report.CurrentMonthReportRespVO">
select sum(ele) ele,
sum(ele) powerGeneration,
date
from income_total
where station_id = #{stationId}
<if test="beginTime != null and endTime != null">
and date BETWEEN #{beginTime} and #{endTime}
</if>
and type = 2
GROUP BY date
</select>
<select id="selectFeeByStationId" resultType="com.ho.business.vo.resp.report.HistoryReportRespVO">
select sum(ele_total_fee) eleTotalFee,
sum(income_fee) incomeFee,
sum(total_fee) totalFee,
sum(ele) powerGeneration,
date
from income_total
where type = 2
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="beginTime != null and endTime != null ">
and date BETWEEN #{beginTime} and #{endTime}
</if>
GROUP BY date
order by date asc
</select>
<select id="selectSumIncomeByStationId" resultType="java.math.BigDecimal">
select
sum(total_fee) totalFee
from income_total
where type = 2
<if test="stationId != null">
and station_id = #{stationId}
</if>
</select>
<select id="selectSumIncomeByGroupId" resultType="java.math.BigDecimal">
select
sum(total_fee) totalFee
from income_total
where type = 2
<if test="groupId != null">
and group_id = #{groupId}
</if>
</select>
<insert id="insertRealDataBatch">
insert into income_total ( template_id,rate_name,rate_id,price,ele,ele_total_fee,total_fee,flag,date,src_id,
station_id,data_date,group_id,type,discount,start_time,end_time )
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.templateId}, #{item.rateName}, #{item.rateId},#{item.price},#{item.ele},
#{item.eleTotalFee}, #{item.totalFee}, 0, #{item.date},#{item.srcId},
#{item.stationId},#{item.dataDate},#{item.groupId}, 2, #{item.discount},
#{item.startTime},#{item.endTime}
)
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,11 @@
<?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.ho.business.mapper.InspectionFaultMapper">
<update id="updateInspectionFault">
update business_db.inspection_fault set status = #{status} where order_id = #{orderId}
</update>
</mapper>

View File

@ -0,0 +1,99 @@
<?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.ho.business.mapper.MaintenanceDataMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.MaintenanceData">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="alarmStatus" column="alarm_status" jdbcType="INTEGER"/>
<result property="alarmNum" column="alarm_num" jdbcType="VARCHAR"/>
<result property="alarmUnresolvedNum" column="alarm_unresolved_num" jdbcType="VARCHAR"/>
<result property="pcsConversion" column="pcs_conversion" jdbcType="VARCHAR"/>
<result property="time" column="time" jdbcType="VARCHAR"/>
<result property="totalCharge" column="total_charge" jdbcType="DECIMAL"/>
<result property="totalDischarge" column="total_discharge" jdbcType="DECIMAL"/>
<result property="minTemperature" column="min_temperature" jdbcType="DECIMAL"/>
<result property="maxTemperature" column="max_temperature" jdbcType="DECIMAL"/>
<result property="pcsMaxTemperature" column="pcs_max_temperature" jdbcType="VARCHAR"/>
<result property="cpuUseProportion" column="cpu_use_proportion" jdbcType="DECIMAL"/>
<result property="memUseProportion" column="mem_use_proportion" jdbcType="DECIMAL"/>
<result property="hardUseProportion" column="hard_use_proportion" jdbcType="DECIMAL"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
,station_id,alarm_status,
alarm_num,alarm_unresolved_num,pcs_conversion,
`time`,total_charge,total_discharge,
min_temperature,max_temperature,pcs_max_temperature,
cpu_use_proportion,mem_use_proportion,hard_use_proportion,
create_time
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.MaintenanceData"
useGeneratedKeys="true">
insert into maintenance_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="stationId != null">station_id,</if>
<if test="alarmStatus != null">alarm_status,</if>
<if test="alarmNum != null">alarm_num,</if>
<if test="alarmUnresolvedNum != null">alarm_unresolved_num,</if>
<if test="pcsConversion != null">pcs_conversion,</if>
<if test="time != null">`time`,</if>
<if test="totalCharge != null">total_charge,</if>
<if test="totalDischarge != null">total_discharge,</if>
<if test="minTemperature != null">min_temperature,</if>
<if test="maxTemperature != null">max_temperature,</if>
<if test="pcsMaxTemperature != null">pcs_max_temperature,</if>
<if test="cpuUseProportion != null">cpu_use_proportion,</if>
<if test="memUseProportion != null">mem_use_proportion,</if>
<if test="hardUseProportion != null">hard_use_proportion,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="stationId != null">#{stationId},</if>
<if test="alarmStatus != null">#{alarmStatus},</if>
<if test="alarmNum != null">#{alarmNum},</if>
<if test="alarmUnresolvedNum != null">#{alarmUnresolvedNum},</if>
<if test="pcsConversion != null">#{pcsConversion},</if>
<if test="time != null">#{time},</if>
<if test="totalCharge != null">#{totalCharge},</if>
<if test="totalDischarge != null">#{totalDischarge},</if>
<if test="minTemperature != null">#{minTemperature},</if>
<if test="maxTemperature != null">#{maxTemperature},</if>
<if test="pcsMaxTemperature != null">#{pcsMaxTemperature},</if>
<if test="cpuUseProportion != null">#{cpuUseProportion},</if>
<if test="memUseProportion != null">#{memUseProportion},</if>
<if test="hardUseProportion != null">#{hardUseProportion},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<select id="selectByParam" resultType="com.ho.business.entity.MaintenanceData">
SELECT
<include refid="Base_Column_List"/>
FROM maintenance_data
<where>
<if test="stationId != null">and station_id = #{stationId}</if>
<if test="alarmStatus != null">and alarm_status = #{alarmStatus}</if>
</where>
</select>
<delete id="deleteByList">
delete
from maintenance_data
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,168 @@
<?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.ho.business.mapper.MessageInfoMapper">
<insert id="addMessageInfo" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.MessageInfoVo">
insert into message_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="messageDetail.messageId != null">message_id,</if>
<if test="messageDetail.messageName != null">message_name,</if>
<if test="messageDetail.messageContent != null">message_content,</if>
<if test="messageDetail.messageType != null">message_type,</if>
<if test="messageDetail.messageFrequency != null">message_frequency,</if>
<if test="messageDetail.frequencyUnit != null">frequency_unit,</if>
<if test="messageDetail.startTime != null">start_time,</if>
<if test="messageDetail.endTime != null">end_time,</if>
<if test="messageDetail.createTime != null">create_time,</if>
<if test="messageDetail.createUser != null">create_user,</if>
<if test="messageDetail.createStatus != null">create_status,</if>
<if test="messageDetail.readTime != null">read_time,</if>
<if test="messageDetail.sendType != null">send_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="messageDetail.messageId != null">#{messageDetail.messageId},</if>
<if test="messageDetail.messageName != null">#{messageDetail.messageName},</if>
<if test="messageDetail.messageContent != null">#{messageDetail.messageContent},</if>
<if test="messageDetail.messageType != null">#{messageDetail.messageType},</if>
<if test="messageDetail.messageFrequency != null">#{messageDetail.messageFrequency},</if>
<if test="messageDetail.frequencyUnit != null">#{messageDetail.frequencyUnit},</if>
<if test="messageDetail.startTime != null">#{messageDetail.startTime},</if>
<if test="messageDetail.endTime != null">#{messageDetail.endTime},</if>
<if test="messageDetail.createTime != null">#{messageDetail.createTime},</if>
<if test="messageDetail.createUser != null">#{messageDetail.createUser},</if>
<if test="messageDetail.createStatus != null">#{messageDetail.createStatus},</if>
<if test="messageDetail.readTime != null">#{messageDetail.readTime},</if>
<if test="messageDetail.sendType != null">#{messageDetail.sendType},</if>
</trim>
</insert>
<insert id="addMessageReceiver" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.MessageReceiverVo">
insert into message_receiver(message_id,receiving_type,receiving_user,read_status,receiving_time) values
<foreach collection="messageReceiver" item="item" separator=",">
( #{item.messageId},#{item.receivingType},#{item.receivingUser},#{item.readStatus},#{item.receivingTime})
</foreach>
</insert>
<update id="updateMessageReadStatus">
update message_receiver set read_status = 1
where
message_id = #{condition.messageId}
and ((receiving_user = #{condition.stationId} and receiving_type = '1')
or (receiving_user = #{condition.receivingUser} and receiving_type = '2'))
</update>
<delete id="deleteMessageInfo">
delete from message_info where message_id in
<foreach collection="messageIds" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</delete>
<delete id="deleteMessageReceivers">
delete from message_receiver where message_id in
<foreach collection="messageIds" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</delete>
<select id="selectMessageInfo" resultType="com.ho.business.entity.MessageInfoVo">
select * from message_info where 1=1
<if test ="condition.messageId != null">
and message_id = #{condition.messageId}
</if>
<if test ="condition.startTime != null">
and create_time &gt;= #{condition.startTime }
</if>
<if test ="condition.endTime != null">
and create_time &lt;= #{condition.endTime}
</if>
<if test ="condition.beginTime != null">
and start_time &lt;= #{condition.beginTime}
</if>
<if test ="condition.finishTime != null">
and end_time &gt;= #{condition.finishTime}
</if>
<if test ="condition.messageName != null">
and message_name like concat('%',#{condition.messageName},'%')
</if>
<if test ="condition.messageType != null">
and message_type = #{condition.messageType}
</if>
<if test ="condition.createUser != null">
and create_user = #{condition.createUser}
</if>
<if test ="condition.createStatus != null">
and create_status = #{condition.createStatus}
</if>
</select>
<select id="selectMessageReceivers" resultType="com.ho.business.entity.MessageReceiverVo">
SELECT *,
(
CASE
WHEN receiving_type &lt;= 1 THEN
(SELECT NAME
FROM
station q
WHERE
q.id = receiving_user) ELSE (SELECT
real_name
FROM
user_center_db.sys_user a
WHERE
a.id = receiving_user )
END
) receivingUserName
FROM
message_receiver where
message_id = #{condition.messageId}
<if test="condition.receivingUser != null and condition.receivingType != null">
and receiving_type = #{condition.receivingType} and receiving_user in
<foreach collection="condition.receivingUser" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</if>
<if test="condition.receivingUser != null and condition.stationId != null">
and ((receiving_user = #{condition.stationId} and receiving_type = '1')
or (receiving_user = #{condition.receivingUser} and receiving_type = '2'))
</if>
<if test="condition.receivingTime != null">
and receiving_time = #{condition.receivingTime}
</if>
<if test="condition.readStatus != null">
and read_status = #{condition.readStatus}
</if>
</select>
<update id="updateCreateStatus">
update message_info set create_status = 3
where message_id in
<foreach collection="messageId" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</update>
<update id="updateReceivingTime">
update message_receiver set receiving_time = now()
where message_id in
<foreach collection="messageId" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</update>
<update id="refreshMessageReadStatus">
update message_receiver set read_status = 0,receiving_time = now()
where message_id = #{message.messageId}
and date_add(receiving_time,INTERVAL ${message.messageFrequency} ${message.frequencyUnit}) &lt;= now()
</update>
</mapper>

View File

@ -0,0 +1,279 @@
<?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.ho.business.mapper.ModelDeviceColMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ModelDeviceCol">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
<result property="deviceColId" column="device_col_id" jdbcType="INTEGER"/>
<result property="modelType" column="model_type" jdbcType="VARCHAR"/>
<result property="modelColId" column="model_col_id" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id
,device_type,device_col_id,
model_type,model_col_id
</sql>
<insert id="insert">
insert into model_device_col
(id, device_type, device_col_id,
model_type, model_col_id)
values ( #{id}, #{device_type}, #{device_col_id}
, #{model_type}, #{model_col_id})
</insert>
<insert id="insertSelective">
insert into model_device_col
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="deviceType != null">device_type,</if>
<if test="deviceColId != null">device_col_id,</if>
<if test="modelType != null">model_type,</if>
<if test="modelColId != null">model_col_id</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="deviceColId != null">#{deviceColId},</if>
<if test="modelType != null">#{modelType},</if>
<if test="modelColId != null">#{modelColId}</if>
</trim>
</insert>
<insert id="addBatch" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into model_device_col (<include refid="Base_Column_List"/>)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.id},
#{item.deviceType},#{item.deviceColId},
#{item.modelType},#{item.modelColId}
)
</foreach>
</insert>
<insert id="insertList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
insert into model_device_col (device_type,device_col_id,model_type,model_col_id) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.deviceType},#{item.deviceColId},#{item.modelType},#{item.modelColId})
</foreach>
</insert>
<update id="updateByPrimaryKeySelective">
update model_device_col
<set>
<if test="deviceType != null">
device_type=#{deviceType}
</if>
<if test="deviceTypeId != null">
device_col_id= #{deviceColId}
</if>
<if test="modelType != null">
model_type = #{modelType}
</if>
<if test="modelColId != null">
model_col_id = #{modelColId}
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByPrimaryKey">
delete
from model_device_col
where id = #{id}
</delete>
<delete id="deleteBatchDevice">
delete
from model_device_col
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByDeviceType">
delete
from model_device_col
where device_type like concat('%',#{deviceType})
</delete>
<select id="selectByDeviceType" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from model_device_col
where device_type=#{deviceType}
ORDER BY id desc
</select>
<select id="selectByIds" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from device_type_col
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByDeviceIds" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from model_device_col
<where>
<if test="deviceType != null">
and device_type=#{deviceType}
</if>
<if test="ids != null and ids.size !=0">
and device_col_id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByModelIds" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from model_device_col
<where>
<if test="deviceType != null">
and device_type=#{deviceType}
</if>
<if test="ids != null and ids.size !=0">
and model_col_id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByDeviceTypeList" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from model_device_col
<where>
<if test="list != null and list.size !=0">
and device_type in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByModelType" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from model_device_col
<where>
<if test="type != null">
and model_type=#{type}
</if>
<if test="ids != null and ids.size !=0">
and model_col_id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByType" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from model_device_col
<where>
<if test="deviceType != null">
and device_type=#{deviceType}
</if>
<if test="modelType != null">
and model_type =#{modelType}
</if>
<if test="deviceColId != null">
and device_col_id= #{deviceColId}
</if>
<if test="modelColId != null">
and model_col_id = #{modelColId}
</if>
</where>
</select>
<select id="selectByModelTypes" resultType="com.ho.business.entity.ModelDevice">
select * from model_device
<where>
<if test="modelType != null">
and model_type =#{modelType}
</if>
</where>
</select>
<select id="selectByModelId" resultType="com.ho.business.entity.ModelDeviceCol">
select *
from model_device_col
where
device_type = #{deviceType}
and model_col_id = #{modelColId}
</select>
<select id="selectByParam" resultType="com.ho.business.vo.resp.deviceModel.ModelDeviceColRespVo">
select m.id,m.device_type,m.device_col_id,m.model_type,m.model_col_id,d.col as deviceCol,d.col_name as deviceColIdName
from model_device_col m left join device_type_col d on m.device_col_id = d.id
where m.device_type like concat('%',#{deviceType})
</select>
<select id="selectDeviceColsByIds" resultType="com.ho.business.entity.ModelDeviceCol">
select
<include refid="Base_Column_List"/>
from model_device_col
<where>
<if test="ids != null and ids.size !=0">
and model_col_id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="deviceTypeList != null and deviceTypeList.size !=0">
and device_type in
<foreach collection="deviceTypeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectModelData" resultType="com.ho.business.vo.resp.modelType.ModelColData">
SELECT d.id,d.device_type,t.col FROM `model_device_col` d left join model_type_col t on d.model_col_id = t.id
<where>
<if test="ids != null and ids.size !=0">
and d.id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="getStationModelColCount" resultType="java.lang.Integer">
select count(0) from model_device_col t1,device t2
where t1.device_type = t2.device_type
and t2.station_id = #{stationId} and t1.model_col_id = #{modelId}
</select>
</mapper>

View File

@ -0,0 +1,203 @@
<?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.ho.business.mapper.ModelTypeColMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ModelTypeCol">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="modelTypeId" column="model_type_id" jdbcType="INTEGER"/>
<result property="modelType" column="model_type" jdbcType="VARCHAR"/>
<result property="modelTypeName" column="model_type_name" jdbcType="VARCHAR"/>
<result property="col" column="col" jdbcType="VARCHAR"/>
<result property="colName" column="col_name" jdbcType="VARCHAR"/>
<result property="dataType" column="data_type" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id
,model_type_id,model_type,
model_type_name,col,col_name,
data_type
</sql>
<sql id="Base_List">
id
,model_type_id,model_type,
model_type_name,col,col_name
</sql>
<insert id="insert">
insert into model_type_col
(id, model_type_id, model_type,
model_type_name, col, col_name,
data_type)
values ( #{id}, #{model_type_id}, #{model_type}
, #{model_type_name}, #{col}, #{col_name}, #{data_type})
</insert>
<insert id="insertSelective">
insert into model_type_col
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="modelTypeId != null">model_type_id,</if>
<if test="modelType != null">model_type,</if>
<if test="modelTypeName != null">model_type_name,</if>
<if test="col != null">col</if>
<if test="colName != null">col_name</if>
<if test="dataType != null">data_type</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="modelTypeId != null">#{modelTypeId},</if>
<if test="modelType != null">#{modelType},</if>
<if test="modelTypeName != null">#{modelTypeName},</if>
<if test="col != null">#{col},</if>
<if test="colName != null">#{colName},</if>
<if test="dataType != null">#{dataType},</if>
</trim>
</insert>
<insert id="addBatchModel" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into model_type_col (<include refid="Base_List"/>)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.id}, #{item.modelTypeId}, #{item.modelType}
, #{item.modelTypeName}, #{item.col}, #{item.colName}
)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective">
update model_type_col
<set>
<if test="modelTypeId != null">
model_type_id=#{modelTypeId},
</if>
<if test="modelType != null">
model_type=#{modelType},
</if>
<if test="modelTypeName != null">
model_type_name=#{modelTypeName},
</if>
<if test="col != null">
col=#{col},
</if>
<if test="colName != null">
col_name=#{colName},
</if>
<if test="dataType != null">
data_type=#{dataType},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByPrimaryKey">
delete
from model_type_col
where id = #{id}
</delete>
<select id="selectByTypeId" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
where model_type_id=#{modelTypeId}
</select>
<select id="selectByModelType" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
<where>
<if test="type!=null">
and model_type = #{type}
</if>
<if test="name!=null">
and (col_name LIKE concat('%',#{name},'%') or col LIKE concat('%',#{name},'%'))
</if>
</where>
ORDER BY id desc
</select>
<select id="selectSameModelCol" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
<where>
<if test="deviceType != null">
and model_type=#{deviceType}
</if>
<if test="list != null and list.size !=0">
and col in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByIds" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByCol" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
<where>
<if test="col != null">
and col=#{col}
</if>
</where>
</select>
<select id="selectByColList" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
<where>
<if test="list != null and list.size !=0">
and col in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectById" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
where id = #{modelColId}
</select>
<select id="selectByColValue" resultType="com.ho.business.entity.ModelTypeCol">
select
<include refid="Base_Column_List"/>
from model_type_col
<where>
<if test="col != null">
and col=#{col}
</if>
<if test="modelType != null">
and model_type=#{modelType}
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,137 @@
<?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.ho.business.mapper.ModelTypeMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.ModelType">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="modelType" column="model_type" jdbcType="VARCHAR"/>
<result property="modelName" column="model_name" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id
,model_type,model_name
</sql>
<insert id="insertModelType" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ModelType"
useGeneratedKeys="true">
insert into model_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="modelType != null">model_type,</if>
<if test="modelName != null">model_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="modelType != null">#{modelType,jdbcType=VARCHAR},</if>
<if test="modelName != null">#{modelName,jdbcType=VARCHAR},</if>
</trim>
</insert>
<select id="getModelTypeList" resultType="com.ho.business.entity.ModelType">
select
<include refid="Base_Column_List"/>
from model_type
<where>
<if test="modelType.modelType != null">
model_type = #{modelType.modelType}
</if>
<if test="modelType.modelName != null">
model_name LIKE concat('%',#{modelType.modelName},'%')
</if>
</where>
</select>
<select id="selectByModelType" resultType="com.ho.business.entity.ModelType">
select
<include refid="Base_Column_List"/>
from model_type
where model_type=#{model_type}
</select>
<select id="getModelType" resultType="com.ho.business.entity.ModelType">
select
<include refid="Base_Column_List"/>
from model_type
<where>
<if test="modelType != null">
model_type = #{modelType}
</if>
</where>
</select>
<select id="getDeviceType" resultType="com.ho.business.entity.ModelDevice">
select *
from model_device
where model_type = #{model_type}
</select>
<select id="selectByDict" resultType="com.ho.business.entity.ModelDevice">
select *
from model_device
where model_type = #{modelType}
and device_type = #{deviceType}
</select>
<select id="selectByDeviceType" resultType="com.ho.business.entity.ModelDevice">
select * from model_device where `device_type` like concat('%',#{deviceType})
</select>
<insert id="insertModelDevice" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.ModelDevice"
useGeneratedKeys="true">
insert into model_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="modelType != null">model_type,</if>
<if test="deviceType != null">device_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="modelType != null">#{modelType,jdbcType=VARCHAR},</if>
<if test="deviceType != null">#{deviceType,jdbcType=VARCHAR},</if>
</trim>
</insert>
<insert id="insertModelDeviceList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into model_device (`model_type`,`device_type`)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.modelType},#{item.deviceType}
)
</foreach>
</insert>
<update id="updateModelDevice" parameterType="com.ho.business.entity.ModelDevice">
update `model_device`
<set>
<if test="modelType != null">
model_type = #{modelType},
</if>
<if test="deviceType != null">
device_type = #{deviceType},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteModelDevice">
delete from `model_device`
<where>
<if test="ids != null and ids.size !=0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteModelDeviceByDeviceType">
delete from `model_device` where `device_type` like concat('%',#{deviceType})
</delete>
</mapper>

View File

@ -0,0 +1,86 @@
<?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.ho.business.mapper.OneClickSequentialControlMapper">
<sql id="Base_Column_List">
id,col,col_name,max_value,min_value,station_id,src_id,set_value,sort,control_name,flag_id
</sql>
<select id="getListByParam" resultType="com.ho.business.entity.OneClickSequentialControl">
select
<include refid="Base_Column_List"/>
from one_click_sequential_control
<where>
<if test="vo.controlName != null">
and control_name = #{vo.controlName}
</if>
<if test="vo.stationId != null">
and station_id = #{vo.stationId}
</if>
<if test="vo.srcId != null">
and src_id = #{vo.srcId}
</if>
order by sort
</where>
</select>
<select id="getListLikeParam" resultType="com.ho.business.entity.OneClickSequentialControl">
select
<include refid="Base_Column_List"/>
from one_click_sequential_control
<where>
<if test="vo.controlName != null">
and control_name LIKE concat('%',#{vo.controlName},'%')
</if>
<if test="vo.stationId != null">
and station_id = #{vo.stationId}
</if>
<if test="vo.srcId != null">
and src_id = #{vo.srcId}
</if>
order by sort
</where>
</select>
<insert id="insertBatch">
INSERT INTO one_click_sequential_control
(col,col_name,max_value,min_value,station_id,src_id,set_value,sort,control_name,flag_id)
VALUES
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.col},#{item.colName},#{item.maxValue},#{item.minValue},#{item.stationId},#{item.srcId}
,#{item.setValue} ,#{item.sort},#{item.controlName},#{item.flagId}
)
</foreach>
</insert>
<update id="updateBatch" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
<foreach collection="list" item="item" index="index" separator=";">
update one_click_sequential_control set
col = #{item.col},col_name = #{item.colName},max_value = #{item.maxValue}, min_value = #{item.minValue}, station_id = #{item.stationId},
src_id = #{item.srcId},set_value = #{item.setValue},sort = #{item.sort},control_name = #{item.controlName},flag_id = #{item.flagId}
where id = #{item.id}
</foreach>
</update>
<delete id="deleteByIds">
delete
from one_click_sequential_control
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByControlName" >
delete from one_click_sequential_control where control_name = #{controlName} and station_id = #{stationId}
</delete>
</mapper>

View File

@ -0,0 +1,69 @@
<?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.ho.business.mapper.PageConfigMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.PageConfig">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
<result property="deviceCol" column="device_col" jdbcType="VARCHAR"/>
<result property="deviceColId" column="device_col_id" jdbcType="INTEGER"/>
<result property="deviceColIdName" column="device_col_id_name" jdbcType="VARCHAR"/>
<result property="modelCol" column="model_col" jdbcType="VARCHAR"/>
<result property="modelColId" column="model_col_id" jdbcType="INTEGER"/>
<result property="modelColIdName" column="model_col_id_name" jdbcType="VARCHAR"/>
<result property="modelType" column="model_type" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,station_id,device_type,
device_col,device_col_id,device_col_id_name,
model_col,model_col_id,model_col_id_name,
model_type
</sql>
<insert id="addBatch">
insert into page_config (<include refid="Base_Column_List"/>)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.id},
#{item.stationId},#{item.deviceType},
#{item.deviceCol},#{item.deviceColId},#{item.deviceColIdName},
#{item.modelCol}, #{item.modelColId}, #{item.modelColIdName},
#{item.modelType}
)
</foreach>
</insert>
<delete id="deleteBatch">
delete from page_config
where id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<select id="selectPage" resultType="com.ho.business.entity.PageConfig">
select
<include refid="Base_Column_List"/>
from page_config
<where>
<if test="pageConfig.stationId!=null">
and station_id = #{pageConfig.stationId}
</if>
<if test="pageConfig.deviceType!=null">
and device_type = #{pageConfig.deviceType}
</if>
<if test="pageConfig.modelType!=null">
and model_type = #{pageConfig.modelType}
</if>
</where>
</select>
<delete id="deleteStationId">
delete
from page_config
where station_id = #{stationId}
</delete>
</mapper>

View File

@ -0,0 +1,444 @@
<?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.ho.business.mapper.PeakShavingMapper">
<resultMap id="baseResult" type="com.ho.business.entity.PlanningCurveTemplate">
<id property="temId" column="tem_id" />
<result property="templateNo" column="template_no"/>
<result property="templateName" column="template_name"/>
<result property="stationId" column="station_id"/>
<result property="income" column="income"/>
<result property="groupId" column="group_id"/>
<!-- <result property="elecTemplateId" column="elec_template_id"/> -->
<result property="status" column="status"/>
<result property="updateTime" column="update_time"/>
<result property="temP" column="tem_p"/>
<result property="capacity" column="capacity"/>
<result property="socUpper" column="soc_upper"/>
<result property="socLower" column="soc_lower"/>
<result property="modelType" column="model_type"/>
<collection property="planningCurves" ofType="com.ho.business.entity.PlanningCurve">
<id property="id" column="id"/>
<result property="planningTemplateId" column="planning_template_id"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="p" column="p"/>
<result property="q" column="q"/>
<result property="soc" column="soc"/>
</collection>
</resultMap>
<select id="getSeq" resultType="java.lang.Integer">
select ifnull(max(id),0)+1 from planning_curve_template
</select>
<select id="checkNo" resultType="java.lang.Integer">
select count(1) from planning_curve_template where template_no = #{templateNo} and id &lt;> #{temId} and station_id = #{stationId}
</select>
<select id="checkName" resultType="java.lang.Integer">
select count(1) from planning_curve_template where template_name = #{templateName} and id &lt;> #{temId} and ( station_id = #{stationId} or station_id is null )
</select>
<insert id="addPlanningCurveTemplate" parameterType="com.ho.business.entity.PlanningCurveTemplate" keyColumn="id" keyProperty="temId" useGeneratedKeys="true">
insert into planning_curve_template (
id,template_no,template_name,
<if test="stationId != null">
station_id,
</if>
<if test="groupId != null">
group_id,
</if>
<if test="income != null" > income, </if>
<if test="status != null"> `status`, </if>
<if test="temP != null"> p, </if>
<if test="capacity != null"> capacity, </if>
<if test="socUpper != null"> soc_upper, </if>
<if test="socLower != null"> soc_lower, </if>
create_time
)
values(
#{temId},
#{templateNo},
#{templateName},
<if test="stationId != null">
#{stationId},
</if>
<if test="groupId != null">
#{groupId},
</if>
<if test="income != null">
#{income},
</if>
<if test="status != null">#{status},</if>
<if test="temP != null">#{temP},</if>
<if test="capacity != null">#{capacity},</if>
<if test="socUpper != null">#{socUpper},</if>
<if test="socLower != null">#{socLower},</if>
sysdate() )
</insert>
<!-- 新增曲线 -->
<insert id="addPlanningCurve" parameterType="com.ho.business.entity.PlanningCurve">
insert into planning_curve ( planning_template_id,start_time,end_time,p,q) values
<foreach collection="curves" item="item" index="index" separator=",">
( #{planningTemplateId},#{item.startTime},#{item.endTime},#{item.p},#{item.q})
</foreach>
</insert>
<!-- 编辑计划曲线模板 -->
<update id="modifyPlanningCurveTemplate" parameterType="com.ho.business.entity.PlanningCurveTemplate">
update planning_curve_template set
<if test="templateNo != null and templateNo != ''">
template_no = #{templateNo},
</if>
<if test="templateName != null and templateName != ''">
template_name = #{templateName},
</if>
<!--
<if test="elecTemplateId != null and elecTemplateId != ''">
elec_template_id = #{elecTemplateId},
</if>
-->
<if test="stationId != null ">
station_id = #{stationId},
</if>
<if test="groupId != null and groupId != ''">
group_id = #{groupId},
</if>
<if test="income != null and income != ''">
income = #{income},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="temP != null and temP != ''">
p = #{temP},
</if>
<if test="capacity != null and capacity != ''">
capacity = #{capacity},
</if>
<if test="socUpper != null and socUpper != ''">
soc_upper = #{socUpper},
</if>
<if test="socLower != null and socLower != ''">
soc_lower = #{socLower},
</if>
update_time = sysdate()
where id = #{temId}
</update>
<delete id="deleteTemplateById">
delete from planning_curve_template where id = #{temId}
</delete>
<delete id="deleteCurves">
delete from planning_curve where planning_template_id = #{temId}
</delete>
<select id="getPeakSeq" resultType="java.lang.Integer">
select ifnull(max(id),0)+1 from peak_policy_config
</select>
<insert id="addPolicyConfig" parameterType="com.ho.business.entity.PolicyConfig">
insert into peak_policy_config (id,station_id,plan_id,tem_id,`month`)
values(#{id},#{stationId},#{planId},#{temId},#{month})
</insert>
<insert id="addPolicyConfigData" parameterType="com.ho.business.vo.req.PolicyConfigData">
insert into peak_policy_config_data (`day`,tem_id,plan_id)
values
<foreach item="item" collection="datas" index="index" separator=",">
(#{item.day},#{item.temId},#{item.planId})
</foreach>
</insert>
<select id="queryPolicyConifg" parameterType="com.ho.business.entity.PolicyConfig" resultType="com.ho.business.vo.req.PolicyConfigData">
select ppcd.id,ppcd.day,ppcd.plan_id,ppcd.tem_id
from peak_policy_config ppc
left join peak_policy_config_data ppcd on ppc.plan_id = ppcd.plan_id
where month = #{month} and station_id = #{stationId}
order by ppcd.`day`
</select>
<select id="queryPolicyConifgMonth" resultType="com.ho.business.entity.PolicyConfig">
select id,station_id,plan_id,tem_id,`month`,case when tem_id is null then concat(plan_id,'_',1) else concat(tem_id,'_',0) end as `key` from peak_policy_config
where station_id = #{stationId}
</select>
<!-- 查询模板列表接口 -->
<select id="getPlanningCurveTemplates" resultMap="baseResult">
select tem.id tem_id, tem.template_no template_no, tem.template_name template_name, tem.station_id, tem.income, tem.group_id,
tem.elec_template_id elec_template_id, tem.status status, date_format(tem.update_time,'%Y-%m-%d %H:%i:%s') update_time, tem.p tem_p, tem.capacity, tem.soc_upper,
tem.soc_lower, cur.id id, cur.start_time start_time, cur.end_time end_time, cur.p p, cur.q q, cur.soc soc,cur.planning_template_id
from (
select id,template_no,template_name,elec_template_id,station_id,group_id,income,status,p,capacity,soc_upper,soc_lower,create_time,update_time
from planning_curve_template
<where>
<if test="temId != null and temId != ''">
id = #{temId}
</if>
<if test="templateName != null and templateName != ''">
and template_name like concat('%',#{templateName},'%')
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="stationId != null and stationId != ''">
and ( station_id = #{stationId} or station_id is null )
</if>
<if test="groupId != null and groupId != ''">
and ( group_id = #{groupId} or group_id is null )
</if>
</where>
<if test="pageNum != null and pageSize != null" >
limit ${pageNum},${pageSize}
</if>
)tem left join planning_curve cur on cur.planning_template_id = tem.id
order by tem.create_time,tem.update_time desc, cur.start_time
</select>
<resultMap id="tableQuery" type="com.ho.business.entity.PlanningCurveTableTemplate">
<id property="temId" column="tem_id" />
<result property="templateNo" column="template_no"/>
<result property="templateName" column="template_name"/>
<result property="stationId" column="station_id"/>
<result property="income" column="income"/>
<result property="groupId" column="group_id"/>
<!-- <result property="elecTemplateId" column="elec_template_id"/> -->
<result property="status" column="status"/>
<result property="updateTime" column="update_time"/>
<result property="temP" column="tem_p"/>
<result property="capacity" column="capacity"/>
<result property="socUpper" column="soc_upper"/>
<result property="socLower" column="soc_lower"/>
<result property="planningTemplateId" column="planning_template_id"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="p" column="p"/>
<result property="q" column="q"/>
<result property="soc" column="soc"/>
</resultMap>
<select id="getPlanningCurveTableTemplates" resultMap="tableQuery">
select tem.id tem_id, tem.template_no template_no, tem.template_name template_name, tem.station_id, tem.income, tem.group_id,
tem.elec_template_id elec_template_id, tem.status status, date_format(tem.update_time,'%Y-%m-%d %H:%i:%s') update_time, tem.p tem_p, tem.capacity, tem.soc_upper,
tem.soc_lower, cur.id id, cur.start_time start_time, cur.end_time end_time, cur.p p, cur.q q, cur.soc soc,cur.planning_template_id
from (
select id,template_no,template_name,elec_template_id,station_id,group_id,income,status,p,capacity,soc_upper,soc_lower,create_time,update_time
from planning_curve_template
<where>
<if test="temId != null and temId != ''">
id = #{temId}
</if>
<if test="templateName != null and templateName != ''">
and template_name like concat('%',#{templateName},'%')
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="stationId != null and stationId != ''">
and station_id = #{stationId} or station_id is null
</if>
<if test="groupId != null and groupId != ''">
and group_id = #{groupId} or group_id is null
</if>
</where>
<if test="pageNum != null and pageSize != null" >
limit ${pageNum},${pageSize}
</if>
)tem left join planning_curve cur on cur.planning_template_id = tem.id
order by tem.create_time,tem.update_time desc, cur.start_time
</select>
<select id="getPlanningCurveTemplate" resultMap="baseResult">
select tem.id tem_id, tem.template_no template_no, tem.template_name template_name, tem.station_id, tem.income, tem.group_id,
tem.elec_template_id elec_template_id, tem.status status, tem.update_time update_time, tem.p tem_p, tem.capacity, tem.soc_upper,
tem.soc_lower, cur.id id, cur.start_time start_time, cur.end_time end_time, ifnull(cur.p,0) p, ifnull(cur.q,0) q, cur.soc soc,cur.planning_template_id,
case when tem.station_id is null then 0 else 1 end as model_type
from (
select id,template_no,template_name,elec_template_id,station_id,group_id,income,status,p,capacity,soc_upper,soc_lower,create_time,update_time
from planning_curve_template
<where>
<if test="temId != null and temId != ''">
id = #{temId}
</if>
<if test="templateName != null and templateName != ''">
and template_name like concat('%',#{templateName},'%')
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="stationId != null and stationId != ''">
and station_id = #{stationId} or station_id is null
</if>
<if test="groupId != null and groupId != ''">
and group_id = #{groupId} or group_id is null
</if>
</where>
limit 1
) tem left join planning_curve cur on cur.planning_template_id = tem.id
order by tem.create_time,tem.update_time desc, cur.start_time
</select>
<select id="getTemplateIds" resultType="java.lang.Integer">
select id from planning_curve_template where station_id = #{stationId} or station_id is null
</select>
<select id="queryTemplateCurves" resultType="com.ho.business.entity.PlanningCurve">
select c.p,c.q,c.soc,c.planning_template_id,c.start_time,c.id,t.template_name from planning_curve c
join planning_curve_template t on t.id = c.planning_template_id
where c.planning_template_id = #{temId}
</select>
<delete id="deletePolicyConfig" parameterType="com.ho.business.entity.PolicyConfig">
delete c,d from peak_policy_config c
join peak_policy_config_data d on c.plan_id = d.plan_id
where station_id = #{stationId} and c.month = #{month}
</delete>
<select id="getIssueDevice" resultType="com.ho.business.vo.resp.planningCurve.PlanningIssueVo">
SELECT d.src_id,d.station_id,d.device_type,sn.sn from device d
join station_sn sn on sn.station_id = d.station_id
where device_type like '%plan%' order by station_id
</select>
<!--
<select id="queryPolicyConfigByParam" resultType="com.ho.business.vo.PolicyConfigVo">
select d.tem_id from peak_policy_config c
join peak_policy_config_data d on c.plan_id = d.plan_id
where c.station_id = #{stationId} and c.month = #{month}
and d.tem_id is not null
limit 1
</select>
-->
<!-- 此查询方法排除了后台生成的方案 -->
<select id="checkUse" resultType="java.lang.Integer">
select count(1) from peak_policy_config_data d
join peak_policy_config_plan p on d.plan_id = p.id
where d.tem_id = #{temId} and p.type = 0
</select>
<select id="checkUse2" resultType="java.lang.Integer">
select count(1) from peak_policy_config c
join peak_policy_config_plan p on c.plan_id = p.id
where c.tem_id = #{temId}
</select>
<select id="queryIssueDevice" resultType="java.lang.Integer">
select src_id
from device where (device_type like 'agc%' or device_type like 'planCurve%' ) and station_id = #{stationId}
limit 1
</select>
<select id="getSnByStationId" resultType="java.lang.String">
select sn from station_sn where station_id = #{stationId}
</select>
<select id="queryPeakPolicyConfigData" resultType="com.ho.business.vo.req.PolicyConfigData">
select d.day,c.month,d.tem_id from peak_policy_config c
join peak_policy_config_data d on c.plan_id = d.plan_id
where c.station_id = #{stationId}
order by month,day
</select>
<resultMap id="peakResult" type="com.ho.business.entity.PolicyConfigPlan">
<id property="id" column="id" />
<result property="planName" column="plan_name"/>
<result property="createTime" column="create_time"/>
<result property="stationId" column="station_id"/>
<result property="month" column="month"/>
<result property="type" column="type"/>
<collection property="childs" ofType="com.ho.business.vo.req.PolicyConfigData">
<id property="id" column="data_id"/>
<result property="day" column="day"/>
<result property="month" column="month"/>
<result property="temId" column="tem_id"/>
<result property="planId" column="plan_id"/>
<result property="templateName" column="template_name"/>
</collection>
</resultMap>
<select id="queryPlanList" resultMap="peakResult">
select plan.id,plan.plan_name,plan.create_time,plan.station_id,plan.month,plan.type,
d.id as data_id,d.day,d.tem_id,d.plan_id,
t.template_name from peak_policy_config_plan plan
join peak_policy_config_data d on d.plan_id = plan.id
join planning_curve_template t on t.id = d.tem_id
where plan.station_id = #{stationId} and plan.type = 0
<if test="month != null" >
and month = #{month}
</if>
order by plan.month
</select>
<select id="queryPeakPolicyList" resultType="com.ho.business.entity.PeakShavingBean">
select t.id,t.template_name name,0 type,concat(t.id,'_',0) as `key` from planning_curve_template t
where ( t.station_id = #{stationId} or t.station_id is null ) and t.status = 1
order by t.template_name
</select>
<delete id="deletePlan" parameterType="com.ho.business.entity.PeakShavingBean">
delete c,d from peak_policy_config_plan c
join peak_policy_config_data d on c.id = d.plan_id
where c.id = #{id}
</delete>
<select id="checkPlanUse" resultType="java.lang.Integer">
select count(1) from peak_policy_config where plan_id = #{id}
</select>
<select id="getPlanSeq" resultType="java.lang.Integer">
select ifnull(max(id),0)+1 from peak_policy_config_plan
</select>
<insert id="addPlan" parameterType="com.ho.business.entity.PolicyConfigPlan">
insert into peak_policy_config_plan( id,plan_name,station_id,`month`,create_time,type)
values ( #{id},#{planName},#{stationId},#{month},now(),#{type} )
</insert>
<select id="queryPolicyConifgDetail" resultType="com.ho.business.vo.req.PolicyConfigData">
select ppcd.day,pct.template_name from peak_policy_config_plan ppcp
join peak_policy_config_data ppcd on ppcp.id = ppcd.plan_id
join planning_curve_template pct on pct.id = ppcd.tem_id
where ppcp.id = #{planId}
order by ppcd.day
</select>
<delete id="deletePolicyConfigByMonth">
delete from peak_policy_config where month = #{month} and station_id = #{stationId}
</delete>
<select id="queryHolidayList" resultType="com.ho.business.vo.Holiday">
select id,date,type,name,week,DATE_FORMAT(date,'%Y') year,DATE_FORMAT(date,'%d') day from dict_holiday where DATE_FORMAT(date,'%m') = #{month} order by date
</select>
<select id="queryTemplateStatus" resultType="java.lang.Integer">
select `status` from planning_curve_template where id = #{temId}
</select>
<select id="checkPlanName" resultType="java.lang.Integer">
select count(1) from peak_policy_config_plan where station_id = #{stationId} and plan_name = #{planName} and type = 0 and month = #{month}
</select>
<select id="getPCT" resultType="com.ho.business.entity.PlanningCurveTemplate">
select tem.id tem_id, tem.template_no template_no, tem.template_name template_name,
tem.station_id, tem.income, tem.group_id, tem.status status, tem.p tem_p, tem.capacity, tem.soc_upper,tem.soc_lower
from planning_curve_template tem
where template_no = #{templateNo} and template_name = #{templateName} and station_id = #{stationId} limit 1
</select>
<insert id="insertPlanningCurve" parameterType="com.ho.business.entity.PlanningCurve">
insert into planning_curve ( planning_template_id,start_time,end_time,p,q) values
( #{planningTemplateId},#{startTime},#{endTime},#{p},#{q})
</insert>
<delete id="deletePlanningCurve" >
delete from planning_curve
where planning_template_id = #{templateId} and start_time = #{startTime}
</delete>
</mapper>

View File

@ -0,0 +1,247 @@
<?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.ho.business.mapper.PictureMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.Picture">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="srcId" column="src_id" jdbcType="INTEGER"/>
<result property="url" column="url" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
,src_id,file_name,file_path,url,
type,create_time,version,owner_user,owner_org,update_log,bucket
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from picture
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectBySrcIdAndType" resultType="com.ho.business.entity.Picture">
select
<include refid="Base_Column_List"/>
from picture
<where>
<if test=" srcId != null ">
and src_id = #{srcId}
</if>
<if test=" type != null ">
and `type` = #{type}
</if>
</where>
</select>
<select id="selectByParam" resultType="com.ho.business.entity.Picture">
select
<include refid="Base_Column_List"/>
from picture
<where>
<if test=" stationId != null ">
and src_id = #{stationId}
</if>
<if test=" beginTime != null ">
and create_time >= #{beginTime}
</if>
<if test=" endTime != null ">
and create_time &lt;= #{endTime}
</if>
<if test=" type != null ">
and `type` = #{type}
</if>
<if test=" fileName != null">
and file_name like concat('%',#{fileName},'%')
</if>
<if test="url != null">
and url = #{url}
</if>
<if test="ownerUser != null">
and owner_user = #{ownerUser}
</if>
</where>
order by create_time desc
</select>
<select id="selectByParams" resultType="com.ho.business.entity.Picture">
select
<include refid="Base_Column_List"/>
from picture
<where>
<if test=" stationId != null ">
and src_id = #{stationId}
</if>
<if test=" beginTime != null ">
and create_time >= #{beginTime}
</if>
<if test=" endTime != null ">
and create_time &lt;= #{endTime}
</if>
<if test=" type != null ">
and `type` = #{type}
</if>
<if test=" fileName != null">
and file_name like concat('%',#{fileName},'%')
</if>
<if test="url != null">
and url = #{url}
</if>
<if test="ownerUser != null">
and owner_user = " "
</if>
</where>
order by create_time desc
</select>
<select id="selectLastOne" resultType="com.ho.business.entity.Picture">
select
<include refid="Base_Column_List"/>
from picture
<where>
<if test=" type != null ">
and `type` = #{type}
</if>
</where>
order by create_time DESC limit 1
</select>
<select id="selectByStationAndType" resultType="com.ho.business.entity.Picture">
select
<include refid="Base_Column_List"/>
from picture
<where>
src_id = #{id}
<if test=" type != null ">
and `type` = #{type}
</if>
</where>
</select>
<select id="selectAll" resultType="com.ho.business.entity.Picture">
select
<include refid="Base_Column_List"/>
from picture
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete
from picture
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deletedBySrcIdsAndType">
delete from picture
<where>
<if test="srcIds != null and srcIds.size() != 0">
and src_id in
<foreach collection="srcIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="type != null">
and type = #{type}
</if>
</where>
</delete>
<delete id="deletedByIds">
delete from picture
<where>
<if test="picturesIds != null and picturesIds.size() != 0">
and id in
<foreach collection="picturesIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Picture"
useGeneratedKeys="true">
insert into picture
( id, src_id, file_name, url
, type, create_time)
values ( #{id,jdbcType=INTEGER}, #{srcId,jdbcType=INTEGER}, #{fileName,jdbcType=VARCHAR}
, #{url,jdbcType=VARCHAR}
, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Picture"
useGeneratedKeys="true">
insert into picture
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="srcId != null">src_id,</if>
<if test="fileName != null">file_name,</if>
<if test="filePath != null">file_path,</if>
<if test="url != null">url,</if>
<if test="type != null">type,</if>
<if test="createTime != null">create_time,</if>
<if test="version != null">version,</if>
<if test="ownerUser != null">owner_user,</if>
<if test="ownerOrg != null">owner_org,</if>
<if test="updateLog != null">update_log,</if>
<if test="bucket != null">bucket,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="fileName != null">#{fileName,jdbcType=VARCHAR},</if>
<if test="filePath != null">#{filePath,jdbcType=VARCHAR},</if>
<if test="url != null">#{url,jdbcType=VARCHAR},</if>
<if test="type != null">#{type,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="version != null">#{version},</if>
<if test="ownerUser != null">#{ownerUser},</if>
<if test="ownerOrg != null">#{ownerOrg},</if>
<if test="updateLog != null">#{updateLog},</if>
<if test="bucket != null">#{bucket},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.Picture">
update picture
<set>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER},
</if>
<if test="fileName != null">
file_name = #{fileName,jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.Picture">
update picture
set src_id = #{srcId,jdbcType=INTEGER},
file_name = #{fileName,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
type = #{type,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="setUpSrcIdNUll">
update picture
set src_id = null
<where>
<if test="pictureIds != null and pictureIds.size() != 0">
and id in
<foreach collection="pictureIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</update>
</mapper>

View File

@ -0,0 +1,137 @@
<?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.ho.business.mapper.PlanningCurveIssueMapper">
<select id="getIssueDevices" resultType="HashMap">
select
src_id as value, device_name as label
from device where (device_type like 'agc%' or device_type like 'planCurve%' ) and station_id = #{stationId}
</select>
<select id="getTemplate" resultType="HashMap">
select id as value,template_name as label from planning_curve_template
where ( station_id = #{stationId} or station_id is null ) and status = 1
</select>
<select id="getIssueComms" resultType="com.ho.business.entity.PlanningIssueComm">
select model.col model_col,type.col type_col,type.max_value,type.min_value,model.col_name
from model_device_col device
join device_type_col type on type.id = device.device_col_id
join model_type_col model on model.id = device.model_col_id
where model.col like 'plan%' and device.device_type=#{deviceType}
</select>
<select id="getDeviceById" resultType="com.ho.business.entity.Device">
select src_id,device_name,device_type,serial_no from device where src_id = #{srcId} and station_id = #{stationId}
</select>
<select id="getCurveDetail" resultType="com.ho.business.entity.PlanningCurve">
select id,start_time,end_time,p,q,soc from planning_curve where planning_template_id = #{temId}
</select>
<insert id="insertIssueStatus">
insert into planning_curve_device ( station_id,plan_tem_id,device_id,issue,operation,operation_date )
values( #{stationId},#{planTemId},#{deviceId},0,#{operation},sysdate() )
</insert>
<select id="queryIssueStatus" resultType="com.ho.business.entity.PlanningIssueDevice">
select id,station_id,plan_tem_id,device_id,issue,operation ,operation_date
from planning_curve_device
<where>
<if test="stationId != null">
station_id = #{stationId}
</if>
<if test="deviceId != null">
and device_id = #{deviceId}
</if>
<if test="planTemId != null">
and plan_tem_id = #{planTemId}
</if>
</where>
</select>
<delete id="deleteIssueStatus">
delete from planning_curve_device where station_id = #{stationId}
</delete>
<resultMap id="baseResult" type="com.ho.business.entity.PlanningIssueCommDetail">
<id property="temId" column="tem_id" />
<result property="templateNo" column="template_no"/>
<result property="templateName" column="template_name"/>
<result property="stationId" column="station_id"/>
<result property="income" column="income"/>
<result property="groupId" column="group_id"/>
<result property="status" column="status"/>
<result property="updateTime" column="update_time"/>
<result property="temP" column="tem_p"/>
<result property="capacity" column="capacity"/>
<result property="socUpper" column="soc_upper"/>
<result property="socLower" column="soc_lower"/>
<result property="deviceId" column="device_id"/>
<result property="issue" column="issue"/>
<result property="operation" column="operation"/>
<collection property="planningCurves" ofType="com.ho.business.entity.PlanningCurve">
<id property="id" column="id"/>
<result property="planningTemplateId" column="planning_template_id"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="p" column="p"/>
<result property="q" column="q"/>
<result property="soc" column="soc"/>
</collection>
</resultMap>
<select id="queryCurrentIssue" resultMap="baseResult">
select tem.id tem_id, tem.template_no template_no, tem.template_name template_name, tem.station_id, tem.income, tem.group_id,
tem.elec_template_id elec_template_id, tem.status status, tem.update_time update_time, tem.p tem_p, tem.capacity, tem.soc_upper,
tem.soc_lower,cur.id id, cur.start_time start_time, cur.end_time end_time, cur.p p, cur.q q, cur.soc soc,cur.planning_template_id
from (
select id,template_no,template_name,elec_template_id,station_id,group_id,income,status,p,capacity,soc_upper,soc_lower,create_time,update_time
from planning_curve_template
<where>
<if test="stationId != null and stationId != ''">
and station_id = #{stationId}
</if>
<if test="planTemId != null" >
and id = #{planTemId}
</if>
</where>
) tem
left join planning_curve cur on cur.planning_template_id = tem.id
order by tem.create_time,tem.update_time desc, cur.start_time
</select>
<select id="chechTemplateExists" resultType="java.lang.Integer">
select count(1) from planning_curve_template where id = #{temId}
</select>
<insert id="planCurveOperationRecord" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.ho.business.vo.resp.planningCurve.PlanningIssueVo">
insert into planning_curve_operation_record
(user_id,user_name,operate_time,operate_content,operate_result,effective_time,status,previous_planning_curve,latest_planning_curve,station_id)
values (
#{condition.userId},#{condition.userName},#{condition.operateTime},#{condition.operateContent},#{condition.operateResult},
#{condition.effectiveTime},#{condition.status},#{condition.previousPlanningCurve},#{condition.latestPlanningCurve},#{condition.stationId}
)
</insert>
<insert id="addPlanningCurveHistory" parameterType="com.ho.business.entity.PlanningCurveHistory">
insert into planning_curve_history ( temp_no,operate_no,start_time,end_time,p,soc_upper,soc_lower,effective_time) values
<foreach collection="condition" item="item" index="index" separator=",">
(#{item.tempNo},#{item.operateNo},#{item.startTime},#{item.endTime},#{item.p},#{item.socUpper},#{item.socLower},#{item.effectiveTime})
</foreach>
</insert>
<select id="getPlanCurveOperationList" resultType="com.ho.business.entity.PlanCurveOperationRecordReq">
select user_id,user_name,operate_time,operate_content,operate_result,effective_time,status,previous_planning_curve,latest_planning_curve,station_id from
planning_curve_operation_record where station_id = #{stationId} order by operate_time desc
</select>
<select id="getPlanningCurveHistory" resultType="com.ho.business.entity.PlanningCurveHistory">
select temp_no,operate_no,start_time,end_time,p,soc_upper,soc_lower,effective_time from planning_curve_history
where operate_no = #{planningCurveId} order by start_time
</select>
</mapper>

View File

@ -0,0 +1,196 @@
<?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.ho.business.mapper.PlanningCurveMapper">
<resultMap id="baseResult" type="com.ho.business.entity.PlanningCurveTemplate">
<id property="temId" column="tem_id" />
<result property="templateNo" column="template_no"/>
<result property="templateName" column="template_name"/>
<result property="stationId" column="station_id"/>
<result property="income" column="income"/>
<result property="groupId" column="group_id"/>
<!-- <result property="elecTemplateId" column="elec_template_id"/> -->
<result property="status" column="status"/>
<result property="updateTime" column="update_time"/>
<result property="temP" column="tem_p"/>
<result property="capacity" column="capacity"/>
<result property="socUpper" column="soc_upper"/>
<result property="socLower" column="soc_lower"/>
<collection property="planningCurves" ofType="com.ho.business.entity.PlanningCurve">
<id property="id" column="id"/>
<result property="planningTemplateId" column="planning_template_id"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="p" column="p"/>
<result property="q" column="q"/>
<result property="soc" column="soc"/>
</collection>
</resultMap>
<!-- 查询模板列表接口 -->
<select id="getPlanningCurveTemplates" resultType="java.util.HashMap">
select tem.id tem_id, tem.template_no template_no, tem.template_name template_name, tem.station_id, tem.income, tem.group_id,
tem.elec_template_id elec_template_id, tem.status status, date_format(tem.update_time,'%Y-%m-%d %H:%i:%s') update_time, tem.p tem_p, tem.capacity, tem.soc_upper,
tem.soc_lower, cur.id id, cur.start_time start_time, cur.end_time end_time, cur.p p, cur.q q, cur.soc soc,cur.planning_template_id
from (
select id,template_no,template_name,elec_template_id,station_id,group_id,income,status,p,capacity,soc_upper,soc_lower,create_time,update_time
from planning_curve_template
<where>
<if test="temId != null and temId != ''">
id = #{temId}
</if>
<if test="templateName != null and templateName != ''">
and template_name like concat('%',#{templateName},'%')
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="stationId != null and stationId != ''">
and station_id = #{stationId} or station_id is null
</if>
<if test="groupId != null and groupId != ''">
and group_id = #{groupId} or group_id is null
</if>
</where>
<if test="pageNum != null and pageSize != null" >
limit ${pageNum},${pageSize}
</if>
)tem left join planning_curve cur on cur.planning_template_id = tem.id
order by tem.create_time,tem.update_time desc, cur.start_time
</select>
<select id="getSeq" resultType="java.lang.Integer">
select ifnull(max(id),0)+1 from planning_curve_template
</select>
<!-- 新增模板 -->
<insert id="addPlanningCurveTemplate" parameterType="com.ho.business.entity.PlanningCurveTemplate">
insert into planning_curve_template ( id,template_no,template_name,<!-- elec_template_id, -->
<if test="stationId != null and stationId != ''">
station_id,
</if>
<if test="groupId != null and groupId != ''">
group_id,
</if>
income,status,p,capacity,soc_upper,soc_lower,create_time )
values( #{temId},#{templateNo},#{templateName},<!-- #{elecTemplateId}, -->
<if test="stationId != null and stationId != ''">
#{stationId},
</if>
<if test="groupId != null and groupId != ''">
#{groupId},
</if>
#{income},#{status},#{temP},#{capacity},#{socUpper},#{socLower},sysdate() )
</insert>
<!-- 新增曲线 -->
<insert id="addPlanningCurve" parameterType="com.ho.business.entity.PlanningCurve">
insert into planning_curve ( planning_template_id,start_time,end_time,p) values
<foreach collection="curves" item="item" index="index" separator=",">
( #{planningTemplateId},#{item.startTime},#{item.endTime},#{item.p})
</foreach>
</insert>
<!-- 编辑计划曲线模板 -->
<update id="modifyPlanningCurveTemplate" parameterType="com.ho.business.entity.PlanningCurveTemplate">
update planning_curve_template set
<if test="templateNo != null and templateNo != ''">
template_no = #{templateNo},
</if>
<if test="templateName != null and templateName != ''">
template_name = #{templateName},
</if>
<!--
<if test="elecTemplateId != null and elecTemplateId != ''">
elec_template_id = #{elecTemplateId},
</if>
-->
<if test="stationId != null and stationId != ''">
station_id = #{stationId},
</if>
<if test="groupId != null and groupId != ''">
group_id = #{groupId},
</if>
<if test="income != null and income != ''">
income = #{income},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="temP != null and temP != ''">
p = #{temP},
</if>
<if test="capacity != null and capacity != ''">
capacity = #{capacity},
</if>
<if test="socUpper != null and socUpper != ''">
soc_upper = #{socUpper},
</if>
<if test="socLower != null and socLower != ''">
soc_lower = #{socLower},
</if>
update_time = sysdate()
where id = #{temId}
</update>
<!-- 删除计划曲线数据 -->
<delete id="deleteCurves">
delete from planning_curve where planning_template_id = #{id}
</delete>
<delete id="deletePlanningCurveTemplates">
delete from planning_curve_template
where id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<delete id="batchDeleteCurves">
delete from planning_curve
where planning_template_id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<select id="checkNo" resultType="java.lang.Integer">
select count(1) from planning_curve_template where template_no = #{templateNo} and id &lt;> #{temId} and station_id = #{stationId}
</select>
<select id="checkName" resultType="java.lang.Integer">
select count(1) from planning_curve_template where template_name = #{templateName} and id &lt;> #{temId} and station_id = #{stationId}
</select>
<!-- 查询模板列表接口 -->
<select id="getPlanningCurveTemplate" resultMap="baseResult">
select tem.id tem_id, tem.template_no template_no, tem.template_name template_name, tem.station_id, tem.income, tem.group_id,
tem.elec_template_id elec_template_id, tem.status status, tem.update_time update_time, tem.p tem_p, tem.capacity, tem.soc_upper,
tem.soc_lower, cur.id id, cur.start_time start_time, cur.end_time end_time, ifnull(cur.p,0) p, ifnull(cur.q,0) q, cur.soc soc,cur.planning_template_id
from (
select id,template_no,template_name,elec_template_id,station_id,group_id,income,status,p,capacity,soc_upper,soc_lower,create_time,update_time
from planning_curve_template
<where>
<if test="temId != null and temId != ''">
id = #{temId}
</if>
<if test="templateName != null and templateName != ''">
and template_name like concat('%',#{templateName},'%')
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="stationId != null and stationId != ''">
and station_id = #{stationId} or station_id is null
</if>
<if test="groupId != null and groupId != ''">
and group_id = #{groupId} or group_id is null
</if>
</where>
) tem left join planning_curve cur on cur.planning_template_id = tem.id
order by tem.create_time,tem.update_time desc, cur.start_time
</select>
</mapper>

View File

@ -0,0 +1,100 @@
<?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.ho.business.mapper.PlanningCurveTacticsMapper">
<resultMap id="baseResult" type="com.ho.business.entity.PlanningCurveTactics">
<id property="id" column="id" />
<result property="temId" column="tem_id" />
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="type" column="type"/>
<result property="createTime" column="create_time"/>
<result property="creator" column="creator"/>
<result property="updateTime" column="update_time"/>
<result property="modifier" column="modifier"/>
<collection property="planningCurves" ofType="com.ho.business.entity.PlanningCurve">
<id property="id" column="id"/>
<result property="planningTemplateId" column="planning_template_id"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="p" column="p"/>
<result property="q" column="q"/>
<result property="soc" column="soc"/>
</collection>
</resultMap>
<select id="getTacticsList" resultType="com.ho.business.entity.PlanningCurveTactics">
select ct.id,ct.tem_id,ct.start_date,ct.end_date,ct.type,ct.create_time,ct.creator,
t.template_name as tem_name
from planning_curve_tactics ct
left join planning_curve_template t on ct.tem_id = t.id
where station_id = #{stationId}
<if test="temName != null and temName != ''" >
and t.template_name like concat('%',#{temName},'%')
</if>
<if test="type != null">
and ct.type = #{type}
</if>
<if test="startDate != null and endDate != null">
and (
ct.start_date between #{startDate} and #{endDate}
or
ct.end_date between #{startDate} and #{endDate}
)
</if>
<if test="pageNum != null and pageSize != null" >
limit ${pageNum},${pageSize}
</if>
</select>
<select id="getTacticsDetails" resultType="com.ho.business.entity.PlanningCurveTactics">
select ct.tem_id,ct.start_date,ct.end_date,ct.type,ct.create_time,ct.creator
from planning_curve_tactics ct
where ct.id = #{id}
</select>
<select id="getPlanningCurves" resultType="com.ho.business.entity.PlanningCurve">
select cur.id id,cur.start_time start_time, cur.end_time end_time, cur.p p, cur.q q,
cur.soc soc,cur.planning_template_id
from planning_curve cur
where cur.planning_template_id = #{temId}
</select>
<insert id="add" parameterType="com.ho.business.entity.PlanningCurveTactics">
INSERT INTO `business_db`.`planning_curve_tactics`
( `tem_id`, `start_date`, `end_date`, `type`, `create_time`, `creator`)
VALUES ( #{temId}, #{startDate}, #{endDate}, #{type}, now(), #{creator})
</insert>
<update id="modify" parameterType="com.ho.business.entity.PlanningCurveTactics">
UPDATE `planning_curve_tactics`
SET
`tem_id` = #{temId},
`start_date` = date_format(#{startDate},'%Y-%m-%d'),
`end_date` = date_format(#{endDate},'%Y-%m-%d'),
`type` = #{type},
`update_time` = now(),
`modifier` = #{modifier}
WHERE `id` = #{id}
</update>
<delete id="delete" parameterType="java.lang.Integer">
delete from planning_curve_tactics where `id` = #{id}
</delete>
<select id="getPlanningCurveTemplates" resultType="com.ho.business.entity.PlanningCurveTactics">
select t.id as value,t.template_name title from planning_curve_template t
where t.station_id = #{stationId}
</select>
<select id="getTacticsByStationId" resultType="com.ho.business.entity.PlanningCurveTactics">
select ct.tem_id,ct.start_date,ct.end_date,ct.type,ct.create_time,ct.creator,
t.template_name as tem_name
from planning_curve_tactics ct
left join planning_curve_template t on ct.tem_id = t.id
where station_id = #{stationId}
</select>
</mapper>

View File

@ -0,0 +1,314 @@
<?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.ho.business.mapper.PlanningPolicyMapper">
<insert id="addPlanningPolicy">
insert into planning_policy
(
<if test="stationId != null">
station_id,
</if>
<if test="policyTypeId != null">
policy_type_id,
</if>
<if test="policyName != null and policyName != ''">
policy_name,
</if>
<if test="customPolicyName != null and customPolicyName != ''">
custom_policy_name,
</if>
<if test="customPolicyStartDate != null">
custom_policy_start_date,
</if>
<if test="customPolicyEndDate != null">
custom_policy_end_date,
</if>
<if test="temId != null">
tem_id,
</if>
<if test="policyPriorityId != null">
policy_priority_id,
</if>
<if test="effectiveType != null">
effective_type,
</if>
<if test="effectiveStartDate != null">
effective_start_date,
</if>
<if test="effectiveEndDate != null">
effective_end_date,
</if>
<if test="status != null">
status,
</if>
<if test="context != null and context != ''">
context,
</if>
create_time
)
values
(
<if test="stationId != null">
#{stationId},
</if>
<if test="policyTypeId != null">
#{policyTypeId},
</if>
<if test="policyName != null and policyName != ''">
#{policyName},
</if>
<if test="customPolicyName != null and customPolicyName != ''">
#{customPolicyName},
</if>
<if test="customPolicyStartDate != null">
#{customPolicyStartDate,jdbcType=DATE},
</if>
<if test="customPolicyEndDate != null">
#{customPolicyEndDate,jdbcType=DATE},
</if>
<if test="temId != null">
#{temId},
</if>
<if test="policyPriorityId != null">
#{policyPriorityId},
</if>
<if test="effectiveType != null">
#{effectiveType},
</if>
<if test="effectiveStartDate != null">
#{effectiveStartDate,jdbcType=DATE},
</if>
<if test="effectiveEndDate != null">
#{effectiveEndDate,jdbcType=DATE},
</if>
<if test="status != null">
#{status},
</if>
<if test="context != null and context != ''">
#{context},
</if>
now()
)
</insert>
<resultMap id="baseResult" type="com.ho.business.entity.PlanningPolicy">
<id property="policyId" column="policy_id" />
<result property="stationId" column="station_id"/>
<result property="policyTypeId" column="policy_type_id"/>
<result property="policyTypeName" column="policy_type_name"/>
<result property="policyName" column="policy_name"/>
<result property="customPolicyName" column="custom_policy_name"/>
<result property="customPolicyStartDate" column="custom_policy_start_date"/>
<result property="customPolicyEndDate" column="custom_policy_end_date"/>
<result property="temId" column="tem_id"/>
<result property="planningTemplateName" column="planning_template_name"/>
<result property="policyPriorityId" column="policy_priority_id"/>
<result property="policyPriorityName" column="policy_priority_name"/>
<result property="effectiveType" column="effective_type"/>
<result property="effectiveStartDate" column="effective_start_date"/>
<result property="effectiveEndDate" column="effective_end_date"/>
<result property="status" column="status"/>
<result property="context" column="context"/>
<result property="createTime" column="create_time"/>
<result property="modifyTime" column="modify_time"/>
</resultMap>
<select id="getPlanningPolicys" resultMap="baseResult">
select policy.policy_id,policy.station_id,policy.policy_type_id,type.policy_type_name,policy.policy_name,policy.custom_policy_name,policy.custom_policy_start_date,policy.custom_policy_end_date,
policy.tem_id,tem.template_name planning_template_name,policy.policy_priority_id,priority.priority_name policy_priority_name,policy.effective_type,
policy.effective_start_date,policy.effective_end_date,policy.status,policy.context
from planning_policy policy
left join planning_policy_priority priority on priority.id = policy.policy_priority_id
left join planning_policy_type type on type.id = policy.policy_type_id
left join planning_curve_template tem on tem.id = policy.tem_id
<where>
<if test="customPolicyName != null and customPolicyName != ''">
and policy.custom_policy_name like concat('%',#{customPolicyName},'%')
</if>
<if test="policyName != null and policyName != ''">
and policy.policy_name like concat('%',#{policyName},'%')
</if>
<if test="policyTypeId != null">
and policy.policy_type_id = #{policyTypeId}
</if>
<if test="status != null">
and policy.status = #{status}
</if>
</where>
order by policy.policy_priority_id
</select>
<resultMap id="curveResult" type="com.ho.business.entity.PlanningPolicy">
<id property="policyId" column="policy_id" />
<result property="stationId" column="station_id"/>
<result property="policyTypeId" column="policy_type_id"/>
<result property="policyTypeName" column="policy_type_name"/>
<result property="policyName" column="policy_name"/>
<result property="customPolicyName" column="custom_policy_name"/>
<result property="customPolicyStartDate" column="custom_policy_start_date"/>
<result property="customPolicyEndDate" column="custom_policy_end_date"/>
<result property="temId" column="tem_id"/>
<result property="planningTemplateName" column="planning_template_name"/>
<result property="policyPriorityId" column="policy_priority_id"/>
<result property="policyPriorityName" column="policy_priority_name"/>
<result property="effectiveType" column="effective_type"/>
<result property="effectiveStartDate" column="effective_start_date"/>
<result property="effectiveEndDate" column="effective_end_date"/>
<result property="status" column="status"/>
<result property="context" column="context"/>
<result property="createTime" column="create_time"/>
<result property="modifyTime" column="modify_time"/>
<collection property="curves" ofType="com.ho.business.entity.PlanningCurve">
<id property="id" column="id"/>
<result property="planningTemplateId" column="planning_template_id"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="p" column="p"/>
<result property="q" column="q"/>
<result property="soc" column="soc"/>
</collection>
</resultMap>
<select id="getPlanningPolicyDetail4Modify" resultMap="curveResult">
select policy.policy_id,policy.station_id,policy.policy_type_id,policy.policy_name,policy.custom_policy_name,policy.custom_policy_start_date,policy.custom_policy_end_date,
policy.tem_id,policy.policy_priority_id,policy.effective_type,policy.effective_start_date,policy.effective_end_date,policy.context,policy.status,
cur.start_time start_time, cur.end_time end_time, cur.p p, cur.q q, cur.soc soc
from (
select policy_id,station_id,policy_type_id,policy_name,custom_policy_name,custom_policy_start_date,custom_policy_end_date,
tem_id,policy_priority_id,effective_type,effective_start_date,effective_end_date,context,create_time,modify_time,status
from planning_policy
<where>
<if test="policyId != null">
and policy_id = #{policyId}
</if>
</where>
) policy left join planning_curve cur on cur.planning_template_id = policy.tem_id
order by policy.policy_priority_id,policy.modify_time desc, cur.start_time
</select>
<update id="modifyPlanningPolicy">
update planning_policy set
<if test="policyTypeId != null">
policy_type_id = #{policyTypeId},
</if>
<if test="policyName != null and policyName != ''">
policy_name = #{policyName},
</if>
<if test="customPolicyName != null and customPolicyName != ''">
custom_policy_name = #{customPolicyName},
</if>
<if test="customPolicyStartDate != null">
custom_policy_start_date = #{customPolicyStartDate,jdbcType=DATE},
</if>
<if test=" customPolicyEndDate != null">
custom_policy_end_date = #{customPolicyEndDate,jdbcType=DATE},
</if>
<if test=" temId != null ">
tem_id = #{temId},
</if>
<if test=" policyPriorityId != null ">
policy_priority_id = #{policyPriorityId},
</if>
<if test=" effectiveType != null ">
effective_type = #{effectiveType},
</if>
<if test=" effectiveStartDate != null">
effective_start_date = #{effectiveStartDate,jdbcType=DATE},
</if>
<if test=" effectiveEndDate != null">
effective_end_date = #{effectiveEndDate,jdbcType=DATE},
</if>
<if test="status != null">
status = #{status},
</if>
<if test=" context != null and context != ''">
context = #{context},
</if>
modify_time = now()
where policy_id = #{policyId}
</update>
<delete id="deletePlanningPolicy">
delete from planning_policy
where policy_id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<resultMap id="dorpDownResult" type="com.ho.business.entity.DropDownVo">
<id property="id" column="id" />
<result property="name" column="name"/>
</resultMap>
<select id="queryPolicyTypes" resultMap="dorpDownResult">
select id,policy_type_name name from planning_policy_type order by id
</select>
<select id="queryPolicyPriority" resultMap="dorpDownResult">
select id,priority_name name from planning_policy_priority order by id
</select>
<insert id="batchPlanningPolicy">
insert into planning_policy
(
station_id,
policy_type_id,
policy_name,
custom_policy_name,
custom_policy_start_date,
custom_policy_end_date,
tem_id,
policy_priority_id,
effective_type,
effective_start_date,
effective_end_date,
status,
context,
create_time
)
values
(
<foreach collection="policys" item="policy" index="index">
#{policy.stationId},
#{policy.policyTypeId},
#{policy.policyName},
#{policy.customPolicyName},
#{policy.customPolicyStartDate,jdbcType=DATE},
#{policy.customPolicyEndDate,jdbcType=DATE},
#{policy.temId},
#{policy.policyPriorityId},
#{policy.effectiveType},
#{policy.effectiveStartDate,jdbcType=DATE},
#{policy.effectiveEndDate,jdbcType=DATE},
#{policy.status},
#{policy.context},
now()
</foreach>
)
</insert>
<select id="getPlanningCurveTemplates" resultType="com.ho.business.entity.PlanningCurveTemplate">
select id temId,template_name from planning_curve_template where station_id = #{stationId}
</select>
<select id="checkName" resultType="java.lang.Integer">
<if test="type == 1">
select count(1) from planning_policy
where policy_name = #{name}
<if test="policyId != null">
and policy_id &lt;> #{policyId}
</if>
</if>
<if test="type == 2">
select count(1) from planning_policy
where custom_policy_name = #{name}
<if test="policyId != null">
and policy_id &lt;> #{policyId}
</if>
</if>
</select>
</mapper>

View File

@ -0,0 +1,151 @@
<?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.ho.business.mapper.PointConfigMapper">
<sql id="Base_Column_List">
id,name,default_value,point_type,station_id,permission_id,page_location,div_location,sort,device_id
</sql>
<resultMap id="baseMap" type="com.ho.business.vo.resp.dynamicConfig.PointConfigResultResp">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="defaultValue" column="default_value" jdbcType="VARCHAR"/>
<result property="pointType" column="point_type" jdbcType="BIGINT"/>
<result property="stationId" column="station_id" jdbcType="BIGINT"/>
<result property="permissionId" column="permission_id" jdbcType="BIGINT"/>
<result property="pageLocation" column="page_location" jdbcType="VARCHAR"/>
<result property="divLocation" column="div_location" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="BIGINT"/>
<result property="deviceId" column="device_id" jdbcType="BIGINT"/>
<result property="offsetValue" column="offset_value" jdbcType="DECIMAL"/>
<result property="factor" column="factor" jdbcType="DECIMAL"/>
<result property="nameZh" column="name_zh" jdbcType="VARCHAR"/>
<result property="nameEn" column="name_en" jdbcType="VARCHAR"/>
<association property="list" resultMap="com.ho.business.mapper.DynamicConfigMapper.baseMap"/>
</resultMap>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_config (name,name_en,default_value,point_type,station_id,permission_id,page_location,div_location,sort,device_id,offset_value,factor)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.name},#{item.nameEn},#{item.defaultValue},#{item.pointType},
#{item.stationId},#{item.permissionId},#{item.pageLocation},#{item.divLocation},#{item.sort},#{item.deviceId},#{item.offsetValue},#{item.factor}
)
</foreach>
</insert>
<insert id="insertOne" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_config (name,default_value,point_type,station_id,permission_id,page_location,div_location,sort,device_id,offset_value,factor)
values(#{name},#{defaultValue},#{pointType},#{stationId},#{permissionId},#{pageLocation},#{divLocation},#{sort},#{deviceId},#{offsetValue},#{factor})
</insert>
<update id="updateById" parameterType="com.ho.business.entity.CurveConfig">
update point_config
<set>
<if test="colName != null">col_name = #{colName},</if>
<if test="defaultValue != null">default_value = #{defaultValue},</if>
<if test="pointType != null">point_type = #{pointType},</if>
<if test="sort != null">sort = #{sort},</if>
</set>
where id = #{id}
</update>
<select id="selectByParam" resultType="com.ho.business.vo.resp.dynamicConfig.PointConfigResp">
SELECT
p.id,
p.name,
p.default_value,
p.point_type,
p.station_id,
p.permission_id,
p.page_location,
p.div_location,
p.sort,
p.device_id,
p.offset_value,
p.factor,
d.src_id,
d.device_type,
d.col,
d.col_name,
d.sens_type
FROM
point_config p
LEFT JOIN point_config_relation r ON r.point_id = p.id
LEFT JOIN `dynamic_config` d ON r.dynamic_config_id = d.id
<where>
<if test="stationId != null"> and p.station_id = #{stationId}</if>
<if test="permissionId != null"> and p.permission_id = #{permissionId}</if>
<if test="pageLocation != null"> and p.page_location = #{pageLocation}</if>
<if test="divLocation != null"> and p.div_location = #{divLocation}</if>
<if test="deviceId != null"> and p.device_id = #{deviceId}</if>
</where>
order by p.sort asc,p.id asc,r.id asc
</select>
<select id="selectByParamNew" resultMap="baseMap">
SELECT
p.id,
p.name,
p.name as name_zh,
p.name_en,
p.default_value,
p.point_type,
p.station_id,
p.permission_id,
p.page_location,
p.div_location,
p.sort,
p.device_id,
p.offset_value,
p.factor,
d.src_id,
d.device_type,
d.col,
d.col_name,
d.col_name as col_name_zh,
d.col_name_en,
d.sens_type
FROM
point_config p
LEFT JOIN point_config_relation r ON r.point_id = p.id
LEFT JOIN `dynamic_config` d ON r.dynamic_config_id = d.id
<where>
<if test="stationId != null"> and p.station_id = #{stationId}</if>
<if test="permissionId != null"> and p.permission_id = #{permissionId}</if>
<if test="pageLocation != null"> and p.page_location = #{pageLocation}</if>
<if test="divLocation != null"> and p.div_location = #{divLocation}</if>
<if test="deviceId != null"> and p.device_id = #{deviceId}</if>
</where>
order by p.sort asc,p.id asc,r.id asc
</select>
<delete id="deleteByIds">
delete
from point_config
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<insert id="updateList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_config (id,name,name_en,default_value,point_type,station_id,permission_id,page_location,div_location,sort,device_id,offset_value,factor)
values
<foreach item="item" collection="list" index="index" separator=",">
(#{item.id},#{item.name},#{item.nameEn},#{item.defaultValue},#{item.pointType},
#{item.stationId},#{item.permissionId},#{item.pageLocation},#{item.divLocation},#{item.sort},#{item.deviceId},#{item.offsetValue},#{item.factor}
)
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,45 @@
<?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.ho.business.mapper.PointConfigRelationMapper">
<sql id="Base_Column_List">
id,point_id,dynamic_config_id
</sql>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_config_relation (point_id,dynamic_config_id)
values
<foreach item="item" collection="list" index="index" separator=",">
( #{item.pointId},#{item.dynamicConfigId} )
</foreach>
</insert>
<delete id="deleteByIds">
delete
from point_config_relation
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByPointIds">
delete
from point_config_relation
<where>
<if test="ids != null and ids.size() != 0">
and point_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,74 @@
<?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.ho.business.mapper.PointDisassembleConfigMapper">
<sql id="Base_Column_List">
id,point_id,value
</sql>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_disassemble_config (point_id,value)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.pointId},#{item.value}
)
</foreach>
</insert>
<insert id="insertOne" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_disassemble_config (point_id,value)
values(#{pointId},#{value})
</insert>
<update id="updateById" parameterType="com.ho.business.entity.PointDisassembleConfig">
update point_disassemble_config
<set>
<if test="value != null">value = #{value},</if>
</set>
where id = #{id}
</update>
<select id="selectByPointIds" resultType="com.ho.business.entity.PointDisassembleConfig">
select <include refid="Base_Column_List"/>
from point_disassemble_config
<where>
<if test="ids != null and ids.size() != 0">
and point_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<delete id="deleteByIds">
delete
from point_disassemble_config
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByPointIds">
delete
from point_disassemble_config
<where>
<if test="ids != null and ids.size() != 0">
and point_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,76 @@
<?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.ho.business.mapper.PointPolysemyConfigMapper">
<sql id="Base_Column_List">
id,point_id,value,name,name as name_zh,name_en,symbol
</sql>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_polysemy_config (point_id,value,name,name_en,symbol)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.pointId},#{item.value},#{item.name},#{item.nameEn},#{item.symbol}
)
</foreach>
</insert>
<insert id="insertOne" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into point_polysemy_config (point_id,value,name,symbol)
values(#{pointId},#{value},#{name},#{symbol}
</insert>
<update id="updateById" parameterType="com.ho.business.entity.PointPolysemyConfig">
update point_polysemy_config
<set>
<if test="value != null">value = #{value},</if>
<if test="name != null">name = #{name},</if>
<if test="symbol != null">symbol = #{symbol},</if>
</set>
where id = #{id}
</update>
<select id="selectByPointIds" resultType="com.ho.business.entity.PointPolysemyConfig">
select <include refid="Base_Column_List"/>
from point_polysemy_config
<where>
<if test="ids != null and ids.size() != 0">
and point_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<delete id="deleteByIds">
delete
from point_polysemy_config
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteByPointIds">
delete
from point_polysemy_config
<where>
<if test="ids != null and ids.size() != 0">
and point_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,456 @@
<?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.ho.business.mapper.StationMapper">
<sql id="Base_Column_List">
id
,pid,group_id,dept_id,
`name`,name_en,address,address_en,longitude,
latitude,capacity,rate_power,
status,type,create_time,
contact,contact_details,grid_time,
update_time,deleted,is_enable,cabin_num,district,ad_code,is_daily_count,topology_type,cupboard_type,plan_version,inverter_flag,icc_id,province,city,
electricity_type,customer_type,voltage_level,batch_number,nation
</sql>
<select id="selectByName" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where name = #{name,jdbcType=VARCHAR}
and deleted = 1
</select>
<select id="getByName" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where name LIKE concat('%',#{name},'%')
</select>
<select id="selectByDimName" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where name LIKE concat('%',#{name},'%')
and group_id = #{groupId}
and deleted = 1
</select>
<select id="selectByPrimaryKey" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByIds" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByNameAndId" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where id != #{id,jdbcType=INTEGER}
and name = #{name,jdbcType=VARCHAR}
and dept_id = #{deptId}
and deleted = 1
</select>
<select id="selectAll" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where deleted = 1
</select>
<select id="selectByInverterFlag" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where inverter_flag = #{inverterFlag}
and deleted = 1
</select>
<select id="selectByCondition" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
from station
where deleted = 1
<if test="record.name != null and record.name != ''">
and name LIKE concat('%',#{record.name},'%')
</if>
<if test="record.startTime != null">
and grid_time &gt;= #{record.startTime}
</if>
<if test="record.endTime != null">
and grid_time &lt;= #{record.endTime}
</if>
<if test="depts != null and depts.size != 0">
and dept_id in
<foreach collection="depts" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</select>
<select id="selectByDeptId" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
FROM station
where dept_id= #{deptId}
and deleted = 1
</select>
<select id="selectByGroupIdNotExclude" resultType="com.ho.business.entity.Station">
select <include refid="Base_Column_List"/>
FROM station
<where>
<if test="record.name != null and record.name != ''">
and `name` LIKE concat('%',#{record.name},'%')
</if>
<if test="record.batchNumber != null and record.batchNumber != ''">
and batch_number LIKE concat('%',#{record.batchNumber},'%')
</if>
<if test="record.startTime != null">
and grid_time &gt;= #{record.startTime}
</if>
<if test="record.endTime != null">
and grid_time &lt;= #{record.endTime}
</if>
<if test="record.groupId != null">
and group_id = #{record.groupId}
</if>
<if test="record.ids != null and record.ids.size() != 0">
and id in
<foreach collection="record.ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
and deleted = 1
</where>
</select>
<select id="selectStatistics" resultType="com.ho.business.entity.Station">
select
<include refid="Base_Column_List"/>
FROM station
where
deleted = #{deleted}
and is_daily_count = #{dailyCount}
</select>
<delete id="deleteByPrimaryKey">
delete
from station
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Station"
useGeneratedKeys="true">
insert into station
( id, pid, group_id, dept_id
, name, address, longitude
, latitude, capacity, rate_power
, contact, contact_details, grid_time
, status, type, create_time
, update_time, deleted, is_enable,batch_number)
values ( #{record.id,jdbcType=INTEGER}, #{record.pId,jdbcType=INTEGER}, #{record.groupId,jdbcType=INTEGER}
, #{record.deptId,jdbcType=INTEGER}
, #{record.name,jdbcType=VARCHAR}, #{record.address,jdbcType=VARCHAR}
, #{record.longitude,jdbcType=DECIMAL}
, #{record.latitude,jdbcType=DECIMAL}, #{record.capacity,jdbcType=DECIMAL}
, #{record.ratePower,jdbcType=DECIMAL}
, #{record.contact,jdbcType=VARCHAR}, #{record.contactDetails,jdbcType=VARCHAR}
, #{record.gridTime,jdbcType=TIMESTAMP}
, #{record.status,jdbcType=VARCHAR}, #{record.type,jdbcType=VARCHAR}
, #{record.createTime,jdbcType=TIMESTAMP}
, #{record.updateTime,jdbcType=TIMESTAMP}, #{record.deleted,jdbcType=TINYINT}
, #{record.isEnable}
, #{record.cabinNum}
,#{record.batchNumber})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Station"
useGeneratedKeys="true">
insert into station
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.id != null">id,</if>
<if test="record.pId != null">pid,</if>
<if test="record.groupId != null">group_id,</if>
<if test="record.deptId != null">dept_id,</if>
<if test="record.name != null">name,</if>
<if test="record.address != null">address,</if>
<if test="record.longitude != null">longitude,</if>
<if test="record.latitude != null">latitude,</if>
<if test="record.capacity != null">capacity,</if>
<if test="record.ratePower != null">rate_power,</if>
<if test="record.contact != null">contact,</if>
<if test="record.contactDetails != null">contact_details,</if>
<if test="record.gridTime != null">grid_time,</if>
<if test="record.status != null">status,</if>
<if test="record.type != null">type,</if>
<if test="record.createTime != null">create_time,</if>
<if test="record.updateTime != null">update_time,</if>
<if test="record.deleted != null">deleted,</if>
<if test="record.isEnable != null">is_enable,</if>
<if test="record.cabinNum != null">cabin_num,</if>
<if test="record.district != null">district,</if>
<if test="record.adCode != null">ad_code,</if>
<if test="record.isDailyCount != null">is_daily_count,</if>
<if test="record.topologyType != null">topology_type,</if>
<if test="record.cupboardType != null">cupboard_type,</if>
<if test="record.planVersion != null">plan_version,</if>
<if test="record.inverterFlag != null">inverter_flag,</if>
<if test="record.iccId != null">icc_id,</if>
<if test="record.province != null">province,</if>
<if test="record.city != null">city,</if>
<if test="record.electricityType != null">electricity_type,</if>
<if test="record.customerType != null">customer_type,</if>
<if test="record.voltageLevel != null">voltage_level,</if>
<if test="record.batchNumber != null">batch_number,</if>
<if test="record.nation != null">nation,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.id != null">#{record.id,jdbcType=INTEGER},</if>
<if test="record.pId != null">#{record.pId,jdbcType=INTEGER},</if>
<if test="record.groupId != null">#{record.groupId,jdbcType=INTEGER},</if>
<if test="record.deptId != null">#{record.deptId,jdbcType=INTEGER},</if>
<if test="record.name != null">#{record.name,jdbcType=VARCHAR},</if>
<if test="record.address != null">#{record.address,jdbcType=VARCHAR},</if>
<if test="record.longitude != null">#{record.longitude,jdbcType=DECIMAL},</if>
<if test="record.latitude != null">#{record.latitude,jdbcType=DECIMAL},</if>
<if test="record.capacity != null">#{record.capacity,jdbcType=DECIMAL},</if>
<if test="record.ratePower != null">#{record.ratePower,jdbcType=DECIMAL},</if>
<if test="record.contact != null">#{record.contact,jdbcType=VARCHAR},</if>
<if test="record.contactDetails != null">#{record.contactDetails,jdbcType=VARCHAR},</if>
<if test="record.gridTime != null">#{record.gridTime,jdbcType=TIMESTAMP},</if>
<if test="record.status != null">#{record.status,jdbcType=VARCHAR},</if>
<if test="record.type != null">#{record.type,jdbcType=VARCHAR},</if>
<if test="record.createTime != null">#{record.createTime,jdbcType=TIMESTAMP},</if>
<if test="record.updateTime != null">#{record.updateTime,jdbcType=TIMESTAMP},</if>
<if test="record.deleted != null">#{record.deleted,jdbcType=TINYINT},</if>
<if test="record.isEnable != null">#{record.isEnable},</if>
<if test="record.cabinNum != null">#{record.cabinNum},</if>
<if test="record.district != null">#{record.district},</if>
<if test="record.adCode != null">#{record.adCode},</if>
<if test="record.isDailyCount != null">#{record.isDailyCount},</if>
<if test="record.topologyType != null">#{record.topologyType},</if>
<if test="record.cupboardType != null">#{record.cupboardType},</if>
<if test="record.planVersion != null">#{record.planVersion},</if>
<if test="record.inverterFlag != null">#{record.inverterFlag},</if>
<if test="record.iccId != null">#{record.iccId},</if>
<if test="record.province != null">#{record.province},</if>
<if test="record.city != null">#{record.city},</if>
<if test="record.electricityType != null">#{record.electricityType},</if>
<if test="record.customerType != null">#{record.customerType},</if>
<if test="record.voltageLevel != null">#{record.voltageLevel},</if>
<if test="record.batchNumber != null">#{record.batchNumber},</if>
<if test="record.nation != null">#{record.nation},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.Station">
update station
<set>
<if test="record.groupId != null">
group_id = #{record.groupId,jdbcType=INTEGER},
</if>
<if test="record.deptId != null">
dept_id = #{record.deptId,jdbcType=INTEGER},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.address != null">
address = #{record.address,jdbcType=VARCHAR},
</if>
<if test="record.longitude != null">
longitude = #{record.longitude,jdbcType=DECIMAL},
</if>
<if test="record.latitude != null">
latitude = #{record.latitude,jdbcType=DECIMAL},
</if>
<if test="record.capacity != null">
capacity = #{record.capacity,jdbcType=DECIMAL},
</if>
<if test="record.ratePower != null">
rate_power = #{record.ratePower,jdbcType=DECIMAL},
</if>
<if test="record.contact != null">
contact = #{record.contact,jdbcType=VARCHAR},
</if>
<if test="record.contactDetails != null">
contact_details = #{record.contactDetails,jdbcType=VARCHAR},
</if>
<if test="record.gridTime != null">
grid_time = #{record.gridTime,jdbcType=TIMESTAMP},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
type = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=TINYINT},
</if>
<if test="record.isEnable != null">
is_enable = #{record.isEnable,jdbcType=TINYINT},
</if>
<if test="record.cabinNum != null">
cabin_num = #{record.cabinNum},
</if>
<if test="record.district != null">
district = #{record.district},
</if>
<if test="record.adCode != null">
ad_code = #{record.adCode},
</if>
<if test="record.isDailyCount != null">
is_daily_count = #{record.isDailyCount},
</if>
<if test="record.topologyType != null">
topology_type = #{record.topologyType},
</if>
<if test="record.cupboardType != null">
cupboard_type = #{record.cupboardType},
</if>
<if test="record.planVersion != null">
plan_version = #{record.planVersion},
</if>
<if test="record.inverterFlag != null">
inverter_flag = #{record.inverterFlag},
</if>
<if test="record.iccId != null">
icc_id = #{record.iccId},
</if>
<if test="record.iccId == null">
icc_id = null,
</if>
<if test="record.province != null">
province = #{record.province},
</if>
<if test="record.city != null">
city = #{record.city},
</if>
<if test="record.electricityType != null">
electricity_type = #{record.electricityType},
</if>
<if test="record.customerType != null">
customer_type = #{record.customerType},
</if>
<if test="record.voltageLevel != null">
voltage_level = #{record.voltageLevel},
</if>
<if test="record.batchNumber != null">
batch_number = #{record.batchNumber},
</if>
<if test="record.nation != null">
nation = #{record.nation},
</if>
</set>
where id = #{record.id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.Station">
update station
set group_id = #{groupId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR},
longitude = #{longitude,jdbcType=DECIMAL},
latitude = #{latitude,jdbcType=DECIMAL},
capacity = #{capacity,jdbcType=DECIMAL},
rate_power = #{ratePower,jdbcType=DECIMAL},
contact = #{contact,jdbcType=VARCHAR},
contact_details = #{contactDetails,jdbcType=VARCHAR},
grid_time = #{gridTime,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
deleted = #{deleted,jdbcType=TINYINT},
is_enable = #{isEnable,jdbcType=TINYINT},
cabin_num = #{cabinNum},
batch_number = #{batchNumber},
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByParam" resultType="com.ho.business.vo.resp.StationInfoResp">
select s.id,s.pid,s.group_id,s.dept_id,s.name,s.address,s.capacity,s.rate_power,s.status,s.type,s.grid_time,
s.cupboard_type,s.plan_version,d.device_name,d.producer,d.producer_type from
(
<if test="record.list != null and record.list.size != 0">
<foreach collection="record.list" open="(" close=")" separator=" union all " item="item">
select * from device
<where>
<if test="item.deviceType != null">
and device_type like concat('%',#{item.deviceType},'%')
</if>
<if test="item.producer != null">
and producer like concat('%',#{item.producer},'%')
</if>
<if test="item.producerType != null">
and producer_type like concat('%',#{item.producerType},'%')
</if>
and `virtual` = 0 and category > 2 and device_type is not null
</where>
</foreach>
</if>
<if test="record.list == null">
select * from device where `virtual` = 0 and category > 2 and device_type is not null
</if>
) d,
( select * from station
<where>
<if test="record.name != null">
and name like concat('%',#{record.name},'%')
</if>
<if test="record.cupboardType != null">
and cupboard_type = #{record.cupboardType}
</if>
<if test="record.planVersion != null">
and plan_version like concat('%',#{record.planVersion},'%')
</if>
</where>
) s
where d.station_id = s.id order by s.id asc
</select>
<select id="getTermDictionary" parameterType="java.lang.String" resultType="java.util.Map">
select * from term_dictionary
<where>
<if test="language!= null and language !=''">
and language = #{language}
</if>
</where>
</select>
<update id="updateStationList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
<foreach collection="list" item="item" index="index" separator=";">
update station set name = #{item.name},name_en = #{item.nameEn},address = #{item.address},address_en = #{item.addressEn} where id = #{item.id}
</foreach>
</update>
</mapper>

View File

@ -0,0 +1,89 @@
<?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.ho.business.mapper.StationNoteAndRepairMapper">
<insert id="addStationNote" keyProperty="id" keyColumn="id" useGeneratedKeys="true" parameterType="com.ho.business.entity.StationNotepad">
insert into station_notepad (title,content,create_user,create_user_name,create_time,station)
values (#{record.title},#{record.content},#{record.createUser},#{record.createUserName},#{record.createTime},#{record.station})
</insert>
<delete id="deleteStationNote">
delete from station_notepad where id = #{id}
</delete>
<update id="updateStationNote" parameterType="com.ho.business.entity.StationNotepad">
update station_notepad set title = #{record.title},content = #{record.content},update_user = #{record.updateUser},update_user_name=#{record.updateUserName},
update_time = #{record.updateTime} where id = #{record.id}
</update>
<select id="selectStationNote" resultType="com.ho.business.entity.StationNotepad">
select * from station_notepad where station = #{record.station}
<if test="record.title != null and record.title !=''">
and title like concat('%',#{record.title},'%')
</if>
<if test="record.startTime != null and record.startTime != ''">
and create_time &gt;= #{record.startTime}
</if>
<if test="record.endTime != null and record.endTime != ''">
and create_time &lt;= #{record.endTime}
</if>
order by create_time desc
</select>
<insert id="addStationRepair" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.ho.business.entity.StationRepair">
insert into station_repair (repair_user,repair_user_name,repair_content,repair_position,create_time,repair_time,remark,station
) values(#{record.repairUser},#{record.repairUserName},#{record.repairContent},#{record.repairPosition},
#{record.createTime},#{record.repairTime},#{record.remark},#{record.station})
</insert>
<update id="updateRepairFile" >
update repair_file set repair_id = #{repairId} where id in (
<foreach collection="repairFileList" separator="," item="item">
#{item.id}
</foreach>
)
</update>
<update id="updateFileRepairNull">
update repair_file set repair_id = null where repair_id =#{repairId}
</update>
<insert id="addRepairFile" parameterType="com.ho.business.entity.RepairFile" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
insert into repair_file (repair_id,file_name,url) values
(#{record.repairId},#{record.fileName},#{record.url})
</insert>
<delete id="deleteStationRepair">
delete from station_repair where id = #{id}
</delete>
<delete id="deleteRepairInfo">
delete from repair_file where repair_id =#{id}
</delete>
<update id="updateStationRepair" parameterType="com.ho.business.vo.req.StationRepairReqVo">
update station_repair set repair_content = #{record.repairContent},repair_position =#{record.repairPosition},
remark = #{record.remark},repair_time =#{record.repairTime} where id =#{record.id}
</update>
<select id="selectStationRepair" resultType="com.ho.business.entity.StationRepair">
select * from station_repair where station = #{record.station}
<if test="record.repairUserName != null and record.repairUserName !=''">
and repair_user_name like concat('%',#{record.repairUserName},'%')
</if>
<if test="record.repairPosition != null and record.repairPosition !=''">
and repair_position like concat('%',#{record.repairPosition},'%')
</if>
<if test="record.startTime != null and record.startTime != ''">
and repair_time &gt;= #{record.startTime}
</if>
<if test="record.endTime != null and record.endTime != ''">
and repair_time &lt;= #{record.endTime}
</if>
</select>
<select id="selectRepairFile" resultType="com.ho.business.entity.RepairFile">
select * from repair_file where repair_id = #{id}
</select>
</mapper>

View File

@ -0,0 +1,125 @@
<?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.ho.business.mapper.StationSnMapper">
<sql id="Base_Column_List">
id
,station_id,sn
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from station_sn
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByStationId" resultType="com.ho.business.entity.StationSn">
select
<include refid="Base_Column_List"/>
from station_sn
where station_id = #{stationId}
</select>
<select id="selectBySn" resultType="com.ho.business.entity.StationSn">
select
<include refid="Base_Column_List"/>
from station_sn
where sn = #{sn}
</select>
<select id="selectBySnList" resultType="com.ho.business.entity.StationSn">
select
<include refid="Base_Column_List"/>
from station_sn
<where>
sn in
<foreach separator="," collection="snList" item="item" open="(" close=")">
#{item}
</foreach>
</where>
</select>
<select id="selectByStationIds" resultType="com.ho.business.entity.StationSn">
select
<include refid="Base_Column_List"/>
from station_sn
<where>
station_id in
<foreach separator="," collection="stationIds" item="item" open="(" close=")">
#{item}
</foreach>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from station_sn
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByStationIds">
delete
from station_sn
<where>
station_id in
<foreach collection="ids" open="(" close=")" separator="," item="stationId">
#{stationId}
</foreach>
</where>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.StationSn"
useGeneratedKeys="true">
insert into station_sn
(id, stationId, sn)
values (#{id,jdbcType=INTEGER}, #{stationid,jdbcType=INTEGER}, #{sn,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.StationSn"
useGeneratedKeys="true">
insert into station_sn
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="station_id != null">stationId,</if>
<if test="sn != null">sn,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="station_id != null">#{stationid,jdbcType=INTEGER},</if>
<if test="sn != null">#{sn,jdbcType=VARCHAR},</if>
</trim>
</insert>
<insert id="insertSNList">
insert into station_sn
(station_id, sn)
values
<foreach separator="," collection="stationSnList" item="item">
(#{item.stationId},#{item.sn})
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.StationSn">
update station_sn
<set>
<if test="stationId != null">
station_id = #{stationid,jdbcType=INTEGER},
</if>
<if test="sn != null">
sn = #{sn,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.StationSn">
update station_sn
set station_id = #{stationid,jdbcType=INTEGER},
sn = #{sn,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,51 @@
<?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.ho.business.mapper.StationStatusMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.StationStatus">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="stationId" column="station_id" jdbcType="INTEGER"/>
<result property="stationStatus" column="station_status" jdbcType="VARCHAR"/>
<result property="time" column="time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
,station_id,station_status,
`time`
</sql>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.StationStatus"
useGeneratedKeys="true">
insert into station_status
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="stationId != null">station_id,</if>
<if test="stationStatus != null">station_status,</if>
<if test="time != null">`time`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="stationId != null">#{stationId},</if>
<if test="stationStatus != null">#{stationStatus},</if>
<if test="time != null">#{time},</if>
</trim>
</insert>
<select id="selectByStationId" resultType="com.ho.business.entity.StationStatus">
select
<include refid="Base_Column_List"/>
from station_status
<where>
station_id in
<foreach separator="," collection="stationIds" item="item" open="(" close=")">
#{item}
</foreach>
</where>
and time BETWEEN #{beginTime}
AND #{endTime}
</select>
</mapper>

View File

@ -0,0 +1,45 @@
<?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.ho.business.mapper.StrategyOverviewUserSetMapper">
<sql id="Base_Column_List">
id,user_id,is_original,permission_id
</sql>
<insert id="insertUserHabit" parameterType="com.ho.business.entity.StrategyOverviewUserSet">
insert into strategy_overview_user_set
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="isOriginal != null">is_original,</if>
<if test="permissionId != null">permission_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null"> #{userId},</if>
<if test="isOriginal != null">#{isOriginal},</if>
<if test="permissionId != null">#{permissionId},</if>
</trim>
</insert>
<update id="updateById" parameterType="com.ho.business.entity.StrategyOverviewUserSet">
update strategy_overview_user_set
<set>
<if test="isOriginal != null">
is_original = #{isOriginal},
</if>
<if test="permissionId != null">
permissionId = #{permissionId},
</if>
</set>
where id = #{id}
</update>
<select id="selectByUserId" resultType="com.ho.business.entity.StrategyOverviewUserSet">
SELECT <include refid="Base_Column_List"/>
FROM strategy_overview_user_set
WHERE user_id = #{userId}
limit 1
</select>
</mapper>

View File

@ -0,0 +1,86 @@
<?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.ho.business.mapper.TabSortMapper">
<resultMap id="baseResult" type="com.ho.business.entity.TabSort">
<id property="tabId" column="tab_id" />
<result property="tabName" column="tab_name"/>
<result property="tabOrder" column="tab_order"/>
<result property="tabStatus" column="tab_status"/>
<result property="stationId" column="station_id"/>
<result property="commissioning" column="commissioning"/>
<result property="versionNo" column="version_no"/>
<result property="status" column="status"/>
<result property="tabFlag" column="tab_flag"/>
<result property="sn" column="sn"/>
<collection property="childs" column="tag_id" ofType="com.ho.business.entity.TabTag">
<id property="tagId" column="tag_id"/>
<result property="tagName" column="tag_name"/>
<result property="tagNameEn" column="tag_name_en"/>
<result property="tagType" column="tag_type"/>
<result property="srcId" column="src_id"/>
<result property="tabId" column="tab_id"/>
<result property="col" column="col"/>
<result property="maxValue" column="max_value"/>
<result property="minValue" column="min_value"/>
<result property="frame" column="frame"/>
<result property="tagFlag" column="tag_flag"/>
<collection property="values" column="val_id" ofType="com.ho.business.entity.TabTagDefaultValue">
<id property="valId" column="val_id"/>
<result property="defVal" column="def_val"/>
<result property="tagId" column="tag_id"/>
<result property="valFlag" column="val_flag"/>
</collection>
</collection>
</resultMap>
<select id="queryIssueDatas" resultMap="baseResult" parameterType="com.ho.business.entity.TabSort">
select ts.tab_id,ts.tab_name,ts.tab_order,ts.tab_status,ts.station_id,ts.commissioning,ts.version_no,ts.status,s.sn,0 tab_flag,
tt.tag_id,tt.tag_name,tt.tag_name_en,tt.tag_type,tt.src_id,tt.tab_id,tt.col,tt.max_value,tt.min_value,tt.frame,0 tag_flag,
dv.val_id,def_val,dv.tag_id,0 val_flag
from tab_sort ts
left join tab_tag tt on ts.tab_id = tt.tab_id
left join tab_tag_default_value dv on dv.tag_id = tt.tag_id
left join station_sn s on s.station_id = ts.station_id
where ts.station_id = #{stationId} and ts.status = 1
<if test="tabId != null">
and ts.tab_id = #{tabId}
</if>
<if test="tagId != null">
and tt.tag_id = #{tagId}
</if>
</select>
<select id="queryPlanControlIssueData" resultType="com.ho.business.entity.PlanningIssueComm">
select model.col model_col,type.col type_col,type.max_value,type.min_value,model.col_name,d.src_id,d.station_id,d.device_type
from model_device_col device
join device_type_col type on type.id = device.device_col_id
join model_type_col model on model.id = device.model_col_id
join device d on d.device_type = device.device_type
where model.col like 'planControl%' and ( device.device_type=#{deviceType} or device.device_type like 'agc%' )
</select>
<select id="getStationSn" resultType="java.lang.String">
select sn from station_sn where station_id = #{stationId} limit 1
</select>
<select id="queryTabSortById" resultType="com.ho.business.entity.TabSort">
select tab_id,tab_name,tab_order,tab_status,station_id,commissioning,version_no,status from tab_sort where tab_id = #{id}
</select>
<select id="queryExcelDatas" resultType="com.ho.business.vo.resp.tabSort.TabSortExcel">
select ts.tab_name,tt.tag_name,tt.tag_name_en,tt.tag_type,tt.src_id,tt.device_type,tt.col,tt.max_value,tt.min_value,tt.frame,
case when dv.def_val is not null then concat(dv.def_level,':',dv.def_val) else dv.def_level end as def_val
from tab_sort ts
left join tab_tag tt on tt.tab_id = ts.tab_id
left join tab_tag_default_value dv on dv.tag_id = tt.tag_id
where ts.station_id = #{stationId} and ts.status = 1
</select>
<select id="getColNameByCol" resultType="java.lang.String">
select col_name from device_type_col where col = #{col} and device_type = #{deviceType}
</select>
</mapper>

View File

@ -0,0 +1,75 @@
<?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.ho.business.mapper.TopologyJumpConfigMapper">
<sql id="Base_Column_List">
id,station_id,src_id,topology_id
</sql>
<insert id="insertOne" parameterType="com.ho.business.entity.TopologyJumpConfig">
insert into topology_jump_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="srcId != null">src_id,</if>
<if test="topologyId != null">topology_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId},</if>
<if test="srcId != null">#{srcId},</if>
<if test="topologyId != null">#{topologyId},</if>
</trim>
</insert>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into topology_jump_config (station_id,src_id,topology_id)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.stationId},#{item.srcId},#{item.topologyId}
)
</foreach>
</insert>
<update id="updateById" parameterType="com.ho.business.entity.TopologyJumpConfig">
update topology_jump_config
<set>
<if test="stationId != null">station_id = #{stationId},</if>
<if test="srcId != null">src_id = #{srcId},</if>
<if test="topologyId != null">topology_id = #{topologyId},</if>
</set>
where id = #{id}
</update>
<select id="selectByParam" resultType="com.ho.business.entity.TopologyJumpConfig">
SELECT
<include refid="Base_Column_List"/>
FROM topology_jump_config
<where>
<if test="stationId != null">station_id = #{stationId}</if>
<if test="ids != null and ids.size() != 0">
and topology_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<delete id="deleteByList">
delete
from topology_jump_config
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,368 @@
<?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.ho.business.mapper.TopologyMapper">
<sql id="Base_Column_List">
id
,src_id,pid,
group_id,dept_id,station_id,
name,category,type,
sub_type,link1,link2,
link3,link4
</sql>
<select id="selectByPrimaryKey" resultType="com.ho.business.entity.Topology">
select
<include refid="Base_Column_List"/>
from topology
where id = #{id}
</select>
<select id="selectOne" resultType="com.ho.business.entity.Topology">
select
<include refid="Base_Column_List"/>
from topology
<where>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="srcId != null">
and src_id =#{srcId}
</if>
<if test="pid!=null">
and pid = #{pid}
</if>
</where>
</select>
<select id="selectByStationId" resultType="com.ho.business.entity.Topology">
SELECT t1.t1.id,
t1.src_id,
t1.pid,
t1.group_id,
t1.dept_id,
t1.station_id,
t1.NAME,
t1.category,
t1.TYPE,
t1.sub_type,
t1.link1,
t1.link2,
t1.link3,
t1.link4
FROM (SELECT id,
src_id,
pid,
group_id,
dept_id,
station_id,
NAME,
category,
TYPE,
sub_type,
link1,
link2,
link3,
link4
FROM topology
WHERE station_id = #{id jdbcType=INTEGER}) t1
WHERE t1.id NOT IN
(
SELECT id
FROM topology
WHERE station_id = 1
AND category = 11
AND TYPE = 4
AND sub_type = 8
)
</select>
<select id="selectAll" resultType="com.ho.business.entity.Topology">
select
<include refid="Base_Column_List"/>
from topology
</select>
<select id="selectBysev" resultType="com.ho.business.entity.Topology">
select
<include refid="Base_Column_List"/>
from topology
<where>
<if test="groupId != null">
and group_id=#{groupId}
</if>
<if test="deptId != null">
and dept_id=#{deptId}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="srcId != null">
and src_id =#{srcId}
</if>
</where>
</select>
<select id="selectList" resultType="com.ho.business.entity.Topology">
select
<include refid="Base_Column_List"/>
from topology
<where>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="srcId != null">
and src_id =#{srcId}
</if>
<if test="pid!=null">
and pid = #{pid}
</if>
<if test="category!=null">
and category = #{category}
</if>
<if test="type!=null">
and `type` = #{type}
</if>
<if test="subType != null">
and sub_type = #{subType}
</if>
<if test="pids != null and pids.size() != 0">
and pid in
<foreach collection="pids" open="(" close=")" separator="," item="pid">
#{pid}
</foreach>
</if>
<if test="stationIds != null and stationIds.size() != 0">
and station_id in
<foreach collection="stationIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectListByPid" resultType="com.ho.business.entity.Topology">
select
<include refid="Base_Column_List"/>
from topology
<where>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="list != null and list.size !=0">
and src_id in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectByWarehouse" resultType="com.ho.business.entity.Topology">
SELECT
<include refid="Base_Column_List"/>
from topology
WHERE pid=#{srcId}
AND category=2 AND TYPE=9 AND sub_type=1
</select>
<select id="selectByStack" resultType="com.ho.business.entity.Topology">
SELECT
<include refid="Base_Column_List"/>
from topology
WHERE pid=#{srcId}
AND category=11 AND TYPE=4 AND sub_type=5
</select>
<select id="selectByStation" resultType="com.ho.business.entity.Topology">
SELECT
<include refid="Base_Column_List"/>
from topology
<where>
<if test="groupId != null">
and group_id=#{groupId}
</if>
<if test="deptId != null">
and dept_id=#{deptId}
</if>
<if test="stationId != null">
and station_id=#{stationId}
</if>
</where>
AND category=1 AND TYPE=1 AND sub_type=3
</select>
<select id="getAllTopology" resultType="com.ho.business.entity.Topology">
select
<include refid="Base_Column_List"/>
from topology
where station_id = #{stationId,jdbcType=INTEGER}
</select>
<select id="getStationTopology" resultType="com.ho.business.entity.Topology">
SELECT
<include refid="Base_Column_List"/>
from topology
WHERE station_id = #{stationId,jdbcType=INTEGER}
AND category= 1 AND TYPE= 1 AND sub_type= 3
</select>
<select id="getCategoryTopology" resultType="com.ho.business.entity.Topology">
SELECT
<include refid="Base_Column_List"/>
from topology
<where>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="category!=null">
and category = #{category}
</if>
<if test="type!=null">
and `type` = #{type}
</if>
<if test="subType != null">
and sub_type = #{subType}
</if>
<if test="subTypeList != null and subTypeList.size !=0">
and sub_type in
<foreach collection="subTypeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="srcId != null">
src_id = #{srcId}
</if>
</where>
</select>
<delete id="deleteBytopologyId" parameterType="java.lang.Integer">
delete
from topology
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insertTopology" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.Topology"
useGeneratedKeys="true">
insert into topology
( id, src_id, pid
, group_id, dept_id, station_id
, name, category, type
, sub_type, link1, link2
, link3, link4)
values ( #{id,jdbcType=INTEGER}, #{srcId,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}
, #{groupId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}, #{stationId,jdbcType=INTEGER}
, #{name,jdbcType=VARCHAR}, #{category,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}
, #{subType,jdbcType=INTEGER}, #{link1,jdbcType=INTEGER}, #{link2,jdbcType=INTEGER}
, #{link3,jdbcType=INTEGER}, #{link4,jdbcType=INTEGER})
</insert>
<insert id="insertSelective">
insert into topology
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="srcId != null">src_id,</if>
<if test="pid != null">pid,</if>
<if test="groupId != null">group_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="stationId != null">station_id,</if>
<if test="name != null">name,</if>
<if test="category != null">category,</if>
<if test="type != null">type,</if>
<if test="subType != null">sub_type,</if>
<if test="link1 != null">link1,</if>
<if test="link2 != null">link2,</if>
<if test="link3 != null">link3,</if>
<if test="link4 != null">link4,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="pid != null">#{pid,jdbcType=INTEGER},</if>
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="name != null">#{name,jdbcType=VARCHAR},</if>
<if test="category != null">#{category,jdbcType=INTEGER},</if>
<if test="type != null">#{type,jdbcType=INTEGER},</if>
<if test="subType != null">#{subType,jdbcType=INTEGER},</if>
<if test="link1 != null">#{link1,jdbcType=INTEGER},</if>
<if test="link2 != null">#{link2,jdbcType=INTEGER},</if>
<if test="link3 != null">#{link3,jdbcType=INTEGER},</if>
<if test="link4 != null">#{link4,jdbcType=INTEGER},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.Topology">
update topology
<set>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=INTEGER},
</if>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="category != null">
category = #{category,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="subType != null">
sub_type = #{subType,jdbcType=INTEGER},
</if>
<if test="link1 != null">
link1 = #{link1,jdbcType=INTEGER},
</if>
<if test="link2 != null">
link2 = #{link2,jdbcType=INTEGER},
</if>
<if test="link3 != null">
link3 = #{link3,jdbcType=INTEGER},
</if>
<if test="link4 != null">
link4 = #{link4,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.Topology">
update topology
set src_id = #{srcId,jdbcType=INTEGER},
pid = #{pid,jdbcType=INTEGER},
group_id = #{groupId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
station_id = #{stationId,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR},
category = #{category,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER},
sub_type = #{subType,jdbcType=INTEGER},
link1 = #{link1,jdbcType=INTEGER},
link2 = #{link2,jdbcType=INTEGER},
link3 = #{link3,jdbcType=INTEGER},
link4 = #{link4,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,15 @@
<?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.ho.business.mapper.TranslateNationMapper">
<sql id="Base_Column_List">
id,`name`,name_en
</sql>
<select id="getDictNation" resultType="com.ho.business.entity.TranslateNation">
select <include refid="Base_Column_List"/> from translate_nation
</select>
</mapper>

View File

@ -0,0 +1,15 @@
<?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.ho.business.mapper.TranslateProvinceMapper">
<sql id="Base_Column_List">
id,`name`,name_en
</sql>
<select id="getDictProvince" resultType="com.ho.business.entity.TranslateProvince">
select <include refid="Base_Column_List"/> from translate_province
</select>
</mapper>

View File

@ -0,0 +1,105 @@
<?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.ho.business.mapper.TypeContrastMapper">
<resultMap id="BaseResultMap" type="com.ho.business.entity.TypeContrast">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="deviceTypeId" column="device_type_id" jdbcType="INTEGER"/>
<result property="category" column="category" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="subType" column="sub_type" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,device_type_id,category,
type,sub_type,name
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from type_contrast
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCategory" resultType="com.ho.business.entity.TypeContrast">
select
<include refid="Base_Column_List" />
from type_contrast
where category = #{id}
</select>
<select id="getDeviceTypeId" resultType="com.ho.business.entity.TypeContrast">
select
<include refid="Base_Column_List"/>
from type_contrast
where category = #{record.category}
and type = #{record.type}
and sub_type = #{record.subType}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from type_contrast
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.TypeContrast" useGeneratedKeys="true">
insert into type_contrast
( id,device_type_id,category
,type,sub_type,name
)
values (#{id,jdbcType=INTEGER},#{deviceTypeId,jdbcType=INTEGER},#{category,jdbcType=INTEGER}
,#{type,jdbcType=INTEGER},#{subType,jdbcType=INTEGER},#{name,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.TypeContrast" useGeneratedKeys="true">
insert into type_contrast
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="deviceTypeId != null">device_type_id,</if>
<if test="category != null">category,</if>
<if test="type != null">type,</if>
<if test="subType != null">sub_type,</if>
<if test="name != null">name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="deviceTypeId != null">#{deviceTypeId,jdbcType=INTEGER},</if>
<if test="category != null">#{category,jdbcType=INTEGER},</if>
<if test="type != null">#{type,jdbcType=INTEGER},</if>
<if test="subType != null">#{subType,jdbcType=INTEGER},</if>
<if test="name != null">#{name,jdbcType=VARCHAR},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.TypeContrast">
update type_contrast
<set>
<if test="deviceTypeId != null">
device_type_id = #{deviceTypeId,jdbcType=INTEGER},
</if>
<if test="category != null">
category = #{category,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="subType != null">
sub_type = #{subType,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.TypeContrast">
update type_contrast
set
device_type_id = #{deviceTypeId,jdbcType=INTEGER},
category = #{category,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER},
sub_type = #{subType,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,41 @@
<?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.ho.business.mapper.UserHabitMapper">
<sql id="Base_Column_List">
id,user_id,user_data
</sql>
<insert id="insertUserHabit" parameterType="com.ho.business.entity.UserHabit">
insert into user_habit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="userData != null">user_data,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null"> #{userId},</if>
<if test="userData != null">#{userData},</if>
</trim>
</insert>
<update id="updateById" parameterType="com.ho.business.entity.UserHabit">
update user_habit
<set>
<if test="userData != null">
user_data = #{userData},
</if>
</set>
where id = #{id}
</update>
<select id="selectByUserId" resultType="com.ho.business.entity.UserHabit">
SELECT <include refid="Base_Column_List"/>
FROM user_habit
WHERE user_id = #{userId}
limit 1
</select>
</mapper>

View File

@ -0,0 +1,179 @@
<?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.ho.business.mapper.VirtualDeviceColMapper">
<sql id="Base_Column_List">
id
,station_id,src_id,device_col_id,col,col_name,`type`
</sql>
<select id="selectVirtualDeviceCol" resultType="com.ho.business.vo.resp.VirtualDeviceColResp">
select
<include refid="Base_Column_List"/>,factor,offset_value
FROM (select a.*,b.factor,b.offset_value from virtual_device_col a left join device_type_col b on
a.device_col_id = b.id ) col
<where>
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="stationId != null">
and station_id = #{stationId,jdbcType=INTEGER}
</if>
<if test="srcId != null">
and src_id = #{srcId,jdbcType=INTEGER}
</if>
<if test="srcIdList != null and srcIdList.size != 0">
and src_id in
<foreach collection="srcIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="typeList != null and typeList.size != 0">
and `type` in
<foreach collection="typeList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="deviceColId != null">
and device_col_id = #{deviceColId,jdbcType=INTEGER}
</if>
<if test="name != null">
and (col_name LIKE concat('%',#{name},'%') or col LIKE concat('%',#{name},'%'))
</if>
</where>
</select>
<select id="selectByColId" resultType="com.ho.business.entity.VirtualDeviceCol">
select
<include refid="Base_Column_List"/>
FROM virtual_device_col
where
station_id = #{stationId,jdbcType=INTEGER}
and device_col_id = #{deviceColId,jdbcType=INTEGER}
</select>
<select id="selectBySrcId" resultType="com.ho.business.entity.VirtualDeviceCol">
select
<include refid="Base_Column_List"/>
FROM virtual_device_col
<where>
station_id = #{stationId}
<if test="collect != null and collect.size() != 0">
and src_id in
<foreach collection="collect" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="type != null">
and (type LIKE concat('%',#{type},'%'))
</if>
</where>
</select>
<insert id="insertVirtualDeviceCol" keyColumn="id" keyProperty="id"
parameterType="com.ho.business.entity.VirtualDeviceCol" useGeneratedKeys="true">
insert into virtual_device_col
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="stationId != null">station_id,</if>
<if test="srcId != null">src_id,</if>
<if test="deviceColId != null">device_col_id,</if>
<if test="col != null">col,</if>
<if test="colName != null">col_name,</if>
<if test="type != null">`type`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
<if test="deviceColId != null">#{deviceColId,jdbcType=INTEGER},</if>
<if test="col != null">#{col,jdbcType=VARCHAR},</if>
<if test="colName != null">#{colName,jdbcType=VARCHAR},</if>
<if test="type != null">#{type,jdbcType=VARCHAR},</if>
</trim>
</insert>
<insert id="insertList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
insert into virtual_device_col (station_id,src_id,device_col_id,col,col_name,`type`) values
<foreach collection="virtualDeviceColList" item="item" index="index" separator=",">
(#{item.stationId},#{item.srcId},#{item.deviceColId},#{item.col},#{item.colName},#{item.type})
</foreach>
</insert>
<update id="updateVirtualDeviceCol" parameterType="com.ho.business.entity.VirtualDeviceCol">
update virtual_device_col
<set>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER},
</if>
<if test="deviceColId != null">
device_col_id = #{deviceColId,jdbcType=INTEGER},
</if>
<if test="col != null">
col = #{col,jdbcType=VARCHAR},
</if>
<if test="colName != null">
col_name = #{colName,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateList" keyColumn="id" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
<foreach collection="virtualDeviceColList" item="item" index="index" separator=";">
update virtual_device_col
<set>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="srcId != null">
src_id = #{srcId,jdbcType=INTEGER},
</if>
<if test="deviceColId != null">
device_col_id = #{deviceColId,jdbcType=INTEGER},
</if>
<if test="col != null">
col = #{col,jdbcType=VARCHAR},
</if>
<if test="colName != null">
col_name = #{colName,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</foreach>
</update>
<delete id="deleteByPrimaryKey">
delete
from virtual_device_col
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByList">
delete
from virtual_device_col
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
</mapper>

View File

@ -0,0 +1,87 @@
<?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.ho.business.mapper.VirtualDeviceRelationMapper">
<sql id="Base_Column_List">
id,station_id,device_id,col,relation_device_id,relation_col,count_method
</sql>
<insert id="insertOne" parameterType="com.ho.business.entity.VirtualDeviceRelation">
insert into virtual_device_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationId != null">station_id,</if>
<if test="deviceType != null">device_id,</if>
<if test="col != null">col,</if>
<if test="colName != null">relation_device_id,</if>
<if test="offset != null">relation_col,</if>
<if test="countMethod != null">count_method,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationId != null">#{stationId},</if>
<if test="deviceType != null">#{deviceId},</if>
<if test="col != null">#{col},</if>
<if test="colName != null">#{relationDeviceId},</if>
<if test="offset != null">#{relationCol},</if>
<if test="countMethod != null">#{countMethod},</if>
</trim>
</insert>
<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into virtual_device_relation (station_id,device_id,col,relation_device_id,relation_col,count_method)
values
<foreach item="item" collection="list" index="index" separator=",">
(
#{item.stationId},#{item.deviceId},#{item.col},
#{item.relationDeviceId},#{item.relationCol},#{item.countMethod}
)
</foreach>
</insert>
<update id="updateById" parameterType="com.ho.business.entity.VirtualDeviceRelation">
update virtual_device_relation
<set>
<if test="stationId != null">station_id = #{stationId},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="col != null">col = #{col},</if>
<if test="relationDeviceId != null">relation_device_id = #{relationDeviceId},</if>
<if test="relationCol != null">relation_col = #{relationCol},</if>
<if test="countMethod != null">count_method = #{countMethod},</if>
</set>
where id = #{id}
</update>
<select id="selectByParam" resultType="com.ho.business.vo.resp.virtualDeviceRelation.VirtualDeviceRelationResp">
SELECT vr.id,vr.station_id,vr.device_id,vr.col,vr.relation_device_id,vr.relation_col,vr.count_method,d.device_type as relation_device_type
FROM virtual_device_relation vr left join device d on vr.relation_device_id = d.src_id
<where>
<if test="stationId != null">and vr.station_id = #{stationId}</if>
<if test="deviceId != null">and vr.device_id = #{deviceId}</if>
<if test="col != null">and vr.col = #{col}</if>
<if test="relationDeviceId != null">and vr.relation_device_id = #{relationDeviceId}</if>
<if test="relationCol != null">and vr.relation_col = #{relationCol}</if>
<if test="countMethod != null">and vr.count_method = #{countMethod}</if>
</where>
</select>
<delete id="deleteByList">
delete
from virtual_device_relation
<where>
<if test="ids != null and ids.size() != 0">
and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
</delete>
<delete id="deleteStationId">
delete
from virtual_device_relation
where station_id = #{stationId}
</delete>
</mapper>

View File

@ -0,0 +1,233 @@
<?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.ho.business.mapper.YcValueMapper">
<sql id="Base_Column_List">
id
,group_id,dept_id,
station_id,create_time,`type`,
digital,`day`
</sql>
<select id="selectByPrimaryKey" resultType="com.ho.business.entity.YcValue">
select
<include refid="Base_Column_List"/>
from yc_value
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByStationAndCreateTime" resultType="com.ho.business.entity.YcValue">
select
<include refid="Base_Column_List"/>
from yc_value
where station_id = #{stationId}
and `day` BETWEEN #{first} and #{current}
</select>
<select id="selectByStationAndDay" resultType="com.ho.business.entity.YcValue">
select
<include refid="Base_Column_List"/>
from yc_value
<where>
and station_id = #{stationId}
and day BETWEEN #{beginDay} and #{endDay}
<if test="typeList!=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectYearChargeE" resultType="java.math.BigDecimal">
SELECT sum(digital) as sum
from yc_value
WHERE station_id = #{stationId}
and type = #{type}
and create_time BETWEEN #{beginTime}
AND #{endTime}
</select>
<select id="getStatisticsList" resultType="com.ho.business.vo.resp.StatisticsRespVO">
select day as date , digital
from yc_value
<where>
<if test="beginTime != null ">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="deptId != null">
and dept_id = #{deptId}
</if>
<if test="type !=null">
and type = #{type}
</if>
</where>
order by day
</select>
<select id="getListByCondition" resultType="com.ho.business.entity.YcValue">
select <include refid="Base_Column_List"/>
from yc_value
<where>
<if test="beginTime != null ">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="stationIds != null and stationIds.size() !=0">
and station_id in
<foreach collection="stationIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="typeList !=null and typeList.size() !=0">
and type in
<foreach collection="typeList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
order by day
</select>
<select id="getHoursCounted" resultType="java.math.BigDecimal">
select sum(digital)
from yc_value
where type in (5,6,7,8)
<if test="beginTime != null ">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="deptId != null">
and dept_id = #{deptId}
</if>
</select>
<select id="selectCommandsNum" resultType="java.math.BigDecimal">
select sum(digital) as digital
from yc_value
<where>
<if test="beginTime != null ">
and day &gt;= #{beginTime}
</if>
<if test="endTime != null">
and day &lt;= #{endTime}
</if>
<if test="stationId != null">
and station_id = #{stationId}
</if>
<if test="groupId != null">
and group_id = #{groupId}
</if>
<if test="deptId != null">
and dept_id = #{deptId}
</if>
<if test="type !=null">
and type = #{type}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete
from yc_value
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.YcValue"
useGeneratedKeys="true">
insert into yc_value
( id, group_id, dept_id
, station_id, create_time, type
, digital)
values ( #{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}
, #{stationId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER}
, #{digital,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.YcValue"
useGeneratedKeys="true">
insert into yc_value
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="groupId != null">group_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="stationId != null">station_id,</if>
<if test="createTime != null">create_time,</if>
<if test="type != null">type,</if>
<if test="digital != null">digital,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="groupId != null">#{groupId,jdbcType=INTEGER},</if>
<if test="deptId != null">#{deptId,jdbcType=INTEGER},</if>
<if test="stationId != null">#{stationId,jdbcType=INTEGER},</if>
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
<if test="type != null">#{type,jdbcType=INTEGER},</if>
<if test="digital != null">#{digital,jdbcType=DECIMAL},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.YcValue">
update yc_value
<set>
<if test="groupId != null">
group_id = #{groupId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="stationId != null">
station_id = #{stationId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="digital != null">
digital = #{digital,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ho.business.entity.YcValue">
update yc_value
set group_id = #{groupId,jdbcType=INTEGER},
dept_id = #{deptId,jdbcType=INTEGER},
station_id = #{stationId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
type = #{type,jdbcType=INTEGER},
digital = #{digital,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>