<?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.ycl.platform.mapper.YwUnitMapper">
|
|
<resultMap type="YwUnitVo" id="YwUnitResult">
|
<result property="id" column="id" />
|
<result property="unitCode" column="unit_code" />
|
<result property="unitName" column="unit_name" />
|
<result property="unitContact" column="unit_contact" />
|
<result property="unitContactPhone" column="unit_contact_phone" />
|
<result property="unitAdminAccount" column="unit_admin_account" />
|
<result property="remark" column="remark" />
|
<result property="createTime" column="create_time" />
|
</resultMap>
|
|
<sql id="selectYwUnitVo">
|
select id, unit_code, unit_name, unit_contact, unit_contact_phone, unit_admin_account, remark, create_time, update_time, deleted from t_yw_unit
|
</sql>
|
|
<select id="selectYwUnitList" parameterType="YwUnit" resultMap="YwUnitResult">
|
<include refid="selectYwUnitVo"/>
|
<where>
|
<if test="unitCode != null and unitCode != ''"> and unit_code = #{unitCode}</if>
|
<if test="unitName != null and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
|
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
</where>
|
</select>
|
|
<select id="selectYwUnitById" parameterType="Long" resultMap="YwUnitResult">
|
<include refid="selectYwUnitVo"/>
|
where id = #{id}
|
</select>
|
|
<select id="workList" resultType="integer">
|
SELECT
|
count(*)
|
FROM
|
t_work_order wo
|
INNER JOIN t_monitor tm ON wo.serial_number = tm.serial_number AND #{query.unitId}
|
INNER JOIN t_yw_point yp ON yp.serial_number = wo.serial_number AND yp.deleted = 0
|
INNER JOIN t_work_order_error_type et ON wo.work_order_no = et.work_order_no
|
INNER JOIN sys_dict_data da ON da.dict_value = et.error_name AND da.dict_type = 'error_type'
|
<if test="query.errorTypeList != null and query.errorTypeList.size() > 0">AND da.dict_value in <foreach
|
collection="query.errorTypeList" open="(" separator="," close=")" item="errorType">#{errorType}</foreach>
|
</if>
|
WHERE
|
wo.deleted = 0
|
<if test="query.status != null and query.status != ''">
|
AND wo.status = #{query.status}
|
</if>
|
<if test="query.keyword != null and query.keyword != ''">
|
AND (tm.name like concat('%', #{query.keyword}, '%') or tm.serial_number like concat('%', #{query.keyword}, '%'))
|
</if>
|
</select>
|
|
<insert id="insertYwUnit" parameterType="YwUnit" useGeneratedKeys="true" keyProperty="id">
|
insert into t_yw_unit
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="unitCode != null and unitCode != ''">unit_code,</if>
|
<if test="unitName != null and unitName != ''">unit_name,</if>
|
<if test="unitContact != null and unitContact != ''">unit_contact,</if>
|
<if test="unitContactPhone != null and unitContactPhone != ''">unit_contact_phone,</if>
|
<if test="unitAdminAccount != null and unitAdminAccount != ''">unit_admin_account,</if>
|
<if test="remark != null">remark,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
<if test="deleted != null">deleted,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="unitCode != null and unitCode != ''">#{unitCode},</if>
|
<if test="unitName != null and unitName != ''">#{unitName},</if>
|
<if test="unitContact != null and unitContact != ''">#{unitContact},</if>
|
<if test="unitContactPhone != null and unitContactPhone != ''">#{unitContactPhone},</if>
|
<if test="unitAdminAccount != null and unitAdminAccount != ''">#{unitAdminAccount},</if>
|
<if test="remark != null">#{remark},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
<if test="deleted != null">#{deleted},</if>
|
</trim>
|
</insert>
|
|
<update id="updateYwUnit" parameterType="YwUnit">
|
update t_yw_unit
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="unitCode != null and unitCode != ''">unit_code = #{unitCode},</if>
|
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
|
<if test="unitContact != null and unitContact != ''">unit_contact = #{unitContact},</if>
|
<if test="unitContactPhone != null and unitContactPhone != ''">unit_contact_phone = #{unitContactPhone},</if>
|
<if test="unitAdminAccount != null and unitAdminAccount != ''">unit_admin_account = #{unitAdminAccount},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="deleted != null">deleted = #{deleted},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteYwUnitById" parameterType="Long">
|
delete from t_yw_unit where id = #{id}
|
</delete>
|
|
<delete id="deleteYwUnitByIds" parameterType="String">
|
delete from t_yw_unit where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<select id="getByUserId" resultMap="YwUnitResult">
|
SELECT
|
tyw.*
|
FROM
|
t_yw_unit tyw
|
INNER JOIN t_unit_people tup ON tup.unit_id = tyw.id and tyw.deleted = 0
|
INNER JOIN t_yw_people typ ON tup.yw_people_id = typ.id AND typ.user_id = #{userId} AND typ.deleted = 0
|
</select>
|
|
<select id="ywUnitCount" resultType="java.util.Map">
|
SELECT
|
u.unit_name AS name,
|
COUNT(tcs.id) AS num,
|
100 - SUM(score) AS score
|
FROM
|
t_contract_score tcs
|
LEFT JOIN t_yw_unit u ON tcs.unit_id = u.id
|
WHERE tcs.deleted = 0
|
GROUP BY tcs.unit_id
|
ORDER BY score DESC
|
</select>
|
</mapper>
|