<?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.qianwen.smartman.modules.andon.mapper.AndonTypeMapper">
|
|
<select id="andonTypeList" resultType="com.qianwen.smartman.modules.andon.vo.AndonTypeVO">
|
select bat.id,
|
bat.code,
|
bat.name,
|
bat.remark,
|
count(bdat.id) as bindingCount
|
from blade_andon_type bat
|
left join blade_device_andon_type bdat on bat.id = bdat.andon_type_id and bdat.is_deleted = 0
|
where bat.is_deleted = 0
|
<if test="keyword != null and keyword != ''">
|
and (bat.code like CONCAT(#{keyword}, '%')
|
or bat.name like CONCAT(#{keyword}, '%'))
|
</if>
|
group by bat.id, bat.code, bat.name, bat.remark, bat.create_time
|
order by bat.create_time desc, bat.code desc
|
</select>
|
|
<select id="allDeviceTypes" resultType="com.qianwen.smartman.modules.andon.vo.BindingDeviceTypeVO">
|
select bdt.code,
|
bdt.name
|
from blade_device_type bdt
|
left join blade_device_andon_type bdat on bdt.id = bdat.device_type_id and bdat.is_deleted = 0
|
where bdat.andon_type_id = #{typeId}
|
order by bdt.name asc
|
</select>
|
|
<select id="workBanding" resultType="com.qianwen.smartman.modules.andon.vo.AndonTypeVO">
|
select bat.id,
|
bat.code,
|
bat.name,
|
bat.remark
|
from blade_andon_type bat
|
left join blade_device_andon_type bdat on bdat.andon_type_id = bat.id and bdat.is_deleted = 0
|
left join blade_device_type bdt on bdat.device_type_id = bdt.id and bdt.is_deleted = 0
|
left join blade_machine bm on bdt.id = bm.machine_type_id and bm.is_deleted = 0
|
left join blade_workstation_of_machine bwom on bm.id = bwom.machine_id
|
where bat.is_deleted = 0
|
and bwom.workstation_id = #{workstationId}
|
</select>
|
|
<select id="detail" resultType="com.qianwen.smartman.modules.andon.vo.AndonTypeDetailVO">
|
select bat.id,
|
bat.code,
|
bat.name,
|
bat.remark,
|
<if test="_databaseId=='mysql'">
|
group_concat(bdt.id) deviceIds,
|
group_concat(bdt.code) deviceCodes,
|
group_concat(bdt.name) deviceNames
|
</if>
|
<if test="_databaseId=='dm'">
|
WM_CONCAT(bdt.id) deviceIds,
|
WM_CONCAT(bdt.code) deviceCodes,
|
WM_CONCAT(bdt.name) deviceNames
|
</if>
|
<if test="_databaseId=='oracle'">
|
LISTAGG ( DISTINCT (bdt.id), ',' ) WITHIN GROUP ( ORDER BY bdt.id ) AS deviceIds,
|
LISTAGG ( DISTINCT (bdt.code), ',' ) WITHIN GROUP ( ORDER BY bdt.code ) AS deviceCodes,
|
LISTAGG ( DISTINCT (bdt.name), ',' ) WITHIN GROUP ( ORDER BY bdt.name ) AS deviceNames
|
</if>
|
from blade_andon_type bat
|
left join blade_device_andon_type bdat on bat.id = bdat.andon_type_id and bdat.is_deleted = 0
|
left join blade_device_type bdt on bdat.device_type_id = bdt.id and bdt.is_deleted = 0
|
where bat.is_deleted = 0
|
and bat.id = #{typeId}
|
group by bat.id, bat.code, bat.name, bat.remark
|
</select>
|
</mapper>
|