286 lines
10 KiB
XML
Raw Normal View History

2022-01-10 15:20:33 +08:00
<?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.xhpc.activity.mapper.XhpcWorkOrderMapper">
<resultMap id="BaseResultMap" type="com.xhpc.activity.domain.XhpcWorkOrderDomain">
2022-01-11 10:21:53 +08:00
<id column="work_order_id" jdbcType="BIGINT" property="workOrderId" />
<result column="type" jdbcType="SMALLINT" property="type" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="content" jdbcType="VARCHAR" property="content" />
2022-01-11 18:11:20 +08:00
<result column="fault_time" jdbcType="TIMESTAMP" property="faultTime" />
2022-01-11 10:21:53 +08:00
<result column="device_type" jdbcType="VARCHAR" property="deviceType" />
<result column="serial_number" jdbcType="VARCHAR" property="serialNumber" />
2022-09-12 10:26:13 +08:00
<result column="station_id" jdbcType="BIGINT" property="stationId" />
2022-01-11 10:21:53 +08:00
<result column="reason" jdbcType="VARCHAR" property="reason" />
<result column="disposal_method" jdbcType="VARCHAR" property="disposalMethod" />
<result column="status" jdbcType="SMALLINT" property="status" />
<result column="del_flag" jdbcType="SMALLINT" property="delFlag" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
2022-02-21 09:35:37 +08:00
<result column="remark" jdbcType="VARCHAR" property="remark" />
2022-01-11 10:21:53 +08:00
</resultMap>
<sql id="Base_Column_List">
2022-08-24 11:30:31 +08:00
o.work_order_id, o.`type`, o.title, o.content, o.fault_time, o.device_type, o.serial_number, o.station_id,
2022-02-21 09:35:37 +08:00
o.reason, o.disposal_method, o.`status`, o.del_flag, o.tenant_id, o.create_time, o.create_by, o.update_time,
o.update_by, o.remark
2022-01-11 10:21:53 +08:00
</sql>
2022-01-11 18:11:20 +08:00
2022-02-21 09:35:37 +08:00
<insert id="insertOrderUser">
insert into xhpc_work_order_user (order_id, user_id)
values
<foreach collection="domainList" item="domain" separator=",">
(#{domain.orderId}, #{domain.userId})
</foreach>
</insert>
<select id="selectByTypeAndTitle" resultType="com.xhpc.activity.domain.XhpcWorkOrderDomain">
2022-01-11 18:11:20 +08:00
select
<include refid="Base_Column_List" />
2022-02-21 09:35:37 +08:00
from xhpc_work_order o
where o.del_flag=0
and o.type =#{type}
and o.title=#{title}
and o.status=1
2022-01-14 13:56:20 +08:00
order by create_time desc limit 1
2022-01-11 18:11:20 +08:00
</select>
2022-02-21 09:35:37 +08:00
2022-01-11 18:11:20 +08:00
<select id="findOrderListByParams" resultType="java.util.Map">
SELECT
2022-02-21 09:35:37 +08:00
o.work_order_id as 'workOrderId',
o.title as 'title',
2022-03-04 17:36:10 +08:00
o.type as 'typeId',
td.name as 'typeName',
GROUP_CONCAT(u.dept_id) as 'deptId',
GROUP_CONCAT(d.dept_name) as 'deptName',
GROUP_CONCAT(u.work_user_id) as 'userId',
GROUP_CONCAT(u.user_name, '(', d.dept_name, ')') as 'userName',
o.`status` as 'status',
o.create_time as createTime
2022-01-11 18:11:20 +08:00
from xhpc_work_order o
2022-03-04 17:36:10 +08:00
left join xhpc_work_type_dict td on td.work_type_id=o.type
2022-02-21 09:35:37 +08:00
LEFT JOIN xhpc_work_order_user ou on o.work_order_id=ou.order_id
LEFT JOIN xhpc_work_user u on ou.user_id=u.work_user_id
LEFT JOIN xhpc_work_dept d on d.work_dept_id=u.dept_id
2022-01-11 18:11:20 +08:00
where o.del_flag=0
<if test="params.orderType != null and params.orderType != ''">
2022-01-26 15:39:12 +08:00
and o.type=#{params.orderType}
2022-01-11 18:11:20 +08:00
</if>
<if test="params.userName!=null and params.userName!=''">
2022-01-26 15:39:12 +08:00
and u.user_name like concat ('%', #{params.userName}, '%')
2022-01-11 18:11:20 +08:00
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
2022-01-26 15:39:12 +08:00
and o.tenant_id = #{params.tenantId}
2022-01-11 18:11:20 +08:00
</if>
2022-02-21 09:35:37 +08:00
GROUP BY o.work_order_id
ORDER BY o.status ASC,o.create_time desc
2022-01-11 18:11:20 +08:00
</select>
<select id="selectByPrimaryKey" resultType="com.xhpc.activity.domain.XhpcWorkOrderDomain">
select
2022-02-21 09:35:37 +08:00
<include refid="Base_Column_List" />,
d.device_name, s.name, co.start_time, co.source, td.name as 'type_name'
2022-02-21 09:35:37 +08:00
from xhpc_work_order o
LEFT JOIN xhpc_station_device d on o.serial_number=d.serial_number
LEFT JOIN xhpc_work_station s on d.station_id=s.work_station_id
2022-02-22 10:43:20 +08:00
left join xhpc_charge_order co on co.serial_number=o.serial_number
left join xhpc_work_type_dict td on td.work_type_id=o.type
2022-02-21 09:35:37 +08:00
where o.work_order_id = #{workOrderId,jdbcType=BIGINT}
2022-01-11 10:21:53 +08:00
</select>
<update id="deleteByPrimaryKey" parameterType="java.lang.Long">
update xhpc_work_order set del_flag=2
where work_order_id = #{workOrderId,jdbcType=BIGINT}
</update>
<insert id="insert" keyColumn="work_order_id" keyProperty="workOrderId" parameterType="com.xhpc.activity.domain.XhpcWorkOrderDomain" useGeneratedKeys="true">
2022-01-11 18:11:20 +08:00
insert into xhpc_work_order (`type`, title, content, fault_time
2022-02-21 09:35:37 +08:00
device_type, serial_number, reason, disposal_method,
`status`, del_flag, tenant_id,
create_time, create_by, update_time,
2022-02-21 09:35:37 +08:00
update_by, remark)
2022-01-14 10:11:27 +08:00
values (#{type,jdbcType=SMALLINT}, #{title,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{faultTime, jdbcType=TIMESTAMP}
2022-02-21 09:35:37 +08:00
#{deviceType,jdbcType=VARCHAR}, #{serialNumber,jdbcType=VARCHAR},
#{reason,jdbcType=VARCHAR}, #{disposalMethod,jdbcType=VARCHAR},
1, 0, #{tenantId,jdbcType=VARCHAR},
2022-01-11 10:21:53 +08:00
sysdate(), #{createBy,jdbcType=VARCHAR},sysdate(),
2022-02-21 09:35:37 +08:00
#{updateBy,jdbcType=VARCHAR}, #{remark})
2022-01-11 10:21:53 +08:00
</insert>
<insert id="insertSelective" keyColumn="work_order_id" keyProperty="workOrderId" parameterType="com.xhpc.activity.domain.XhpcWorkOrderDomain" useGeneratedKeys="true">
2022-01-11 10:21:53 +08:00
insert into xhpc_work_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="type != null">
`type`,
</if>
<if test="title != null">
title,
</if>
<if test="content != null">
content,
</if>
2022-01-11 18:11:20 +08:00
<if test="faultTime != null">
fault_time,
</if>
2022-01-11 10:21:53 +08:00
<if test="deviceType != null">
device_type,
</if>
<if test="serialNumber != null">
serial_number,
</if>
2022-08-24 11:30:31 +08:00
<if test="stationId != null">
station_id,
</if>
2022-01-11 10:21:53 +08:00
<if test="reason != null">
reason,
</if>
<if test="disposalMethod != null">
disposal_method,
</if>
`status`,
del_flag,
<if test="tenantId != null">
tenant_id,
</if>
create_time,
<if test="createBy != null">
create_by,
</if>
update_time,
<if test="updateBy != null">
update_by,
</if>
2022-02-21 09:35:37 +08:00
<if test="remark != null">
remark,
</if>
2022-01-11 10:21:53 +08:00
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null">
#{type,jdbcType=SMALLINT},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=VARCHAR},
</if>
2022-01-14 13:56:20 +08:00
<if test="faultTime!=null">
2022-01-14 10:11:27 +08:00
#{faultTime, jdbcType=TIMESTAMP},
2022-01-11 18:11:20 +08:00
</if>
2022-01-11 10:21:53 +08:00
<if test="deviceType != null">
#{deviceType,jdbcType=VARCHAR},
</if>
<if test="serialNumber != null">
#{serialNumber,jdbcType=VARCHAR},
</if>
2022-08-24 11:30:31 +08:00
<if test="stationId != null">
#{stationId},
</if>
2022-01-11 10:21:53 +08:00
<if test="reason != null">
#{reason,jdbcType=VARCHAR},
</if>
<if test="disposalMethod != null">
#{disposalMethod,jdbcType=VARCHAR},
</if>
<choose>
<when test="status == null">
1,
</when>
<otherwise>
#{status},
</otherwise>
</choose>
2022-01-14 13:56:20 +08:00
0,
2022-01-11 10:21:53 +08:00
<if test="tenantId != null">
#{tenantId,jdbcType=VARCHAR},
</if>
sysdate(),
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
sysdate(),
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
2022-02-21 09:35:37 +08:00
<if test="remark != null">
#{remark},
</if>
2022-01-11 10:21:53 +08:00
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.activity.domain.XhpcWorkOrderDomain">
2022-01-11 10:21:53 +08:00
update xhpc_work_order
<set>
<if test="type != null">
`type` = #{type,jdbcType=SMALLINT},
</if>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=VARCHAR},
</if>
2022-01-11 18:11:20 +08:00
<if test="faultTime!=null">
2022-01-14 10:11:27 +08:00
fault_time = #{faultTime, jdbcType=TIMESTAMP},
2022-01-11 18:11:20 +08:00
</if>
2022-01-11 10:21:53 +08:00
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
<if test="serialNumber != null">
serial_number = #{serialNumber,jdbcType=VARCHAR},
</if>
2022-08-24 11:30:31 +08:00
<if test="stationId != null">
station_id = #{stationId},
</if>
2022-01-11 10:21:53 +08:00
<if test="reason != null">
reason = #{reason,jdbcType=VARCHAR},
</if>
<if test="disposalMethod != null">
disposal_method = #{disposalMethod,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=SMALLINT},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=VARCHAR},
</if>
update_time = sysdate(),
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
2022-02-21 09:35:37 +08:00
<if test="remark != null">
remark=#{remark},
</if>
2022-01-11 10:21:53 +08:00
</set>
where work_order_id = #{workOrderId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.activity.domain.XhpcWorkOrderDomain">
2022-01-11 10:21:53 +08:00
update xhpc_work_order
set `type` = #{type,jdbcType=SMALLINT},
title = #{title,jdbcType=VARCHAR},
content = #{content,jdbcType=VARCHAR},
2022-01-14 10:11:27 +08:00
fault_time = #{faultTime, jdbcType=TIMESTAMP},
2022-01-11 10:21:53 +08:00
device_type = #{deviceType,jdbcType=VARCHAR},
serial_number = #{serialNumber,jdbcType=VARCHAR},
2022-08-24 11:30:31 +08:00
station_id=#{stationId},
2022-01-11 10:21:53 +08:00
reason = #{reason,jdbcType=VARCHAR},
disposal_method = #{disposalMethod,jdbcType=VARCHAR},
`status` = #{status,jdbcType=SMALLINT},
tenant_id = #{tenantId,jdbcType=VARCHAR},
update_time = sysdate(),
2022-02-21 09:35:37 +08:00
update_by = #{updateBy,jdbcType=VARCHAR},
remark=#{remark}
2022-01-11 10:21:53 +08:00
where work_order_id = #{workOrderId,jdbcType=BIGINT}
</update>
2022-02-21 09:35:37 +08:00
<delete id="deleteOrderUserByOrderId">
delete from xhpc_work_order_user where order_id=#{orderId}
</delete>
<select id="workOrderMessage" resultType="int">
select count(work_order_id) from xhpc_work_order where type=#{type} and create_time like concat('%', #{time}, '%') and status !=2
</select>
2022-01-10 15:20:33 +08:00
</mapper>