<?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="org.jeecg.modules.mdc.mapper.MdcEquipmentMapper">
|
|
<!--查询设备的所属部门名称信息-->
|
<select id="getDepNamesByEquipmentIds" resultType="org.jeecg.modules.mdc.vo.MdcEquipmentDepVo">
|
SELECT d.depart_name, ed.equipment_id FROM mdc_equipment_depart ed, sys_depart d WHERE d.id = ed.dep_id AND ed.equipment_id IN
|
<foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<!--查询设备的所属产线名称信息-->
|
<select id="getProNamesByEquipmentIds" resultType="org.jeecg.modules.mdc.vo.MdcEquipmentProVo">
|
SELECT p.production_name, pe.equipment_id FROM mdc_production_equipment pe, mdc_production p WHERE p.id = pe.production_id AND pe.equipment_id IN
|
<foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<!--根据部门id查询设备列表-->
|
<select id="pageListByDepId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
|
SELECT
|
me.*
|
FROM
|
mdc_equipment_depart med,
|
mdc_equipment me
|
WHERE
|
med.equipment_id = me.id
|
AND med.dep_id = #{ departId }
|
<if test="equipmentId != null and equipmentId != '' ">
|
AND me.equipment_id = #{equipmentId}
|
</if>
|
</select>
|
|
<!--根据产线id查询设备列表-->
|
<select id="pageListByProId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
|
SELECT
|
me.*
|
FROM
|
mdc_production_equipment mpe,
|
mdc_equipment me
|
WHERE
|
mpe.equipment_id = me.id
|
AND mpe.production_id = #{ productionId }
|
<if test="equipmentId != null and equipmentId != '' ">
|
AND me.equipment_id = #{equipmentId}
|
</if>
|
</select>
|
|
<!--根据部门id查询设备-->
|
<select id="queryByDepartId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
|
SELECT
|
me.*
|
FROM
|
mdc_equipment_depart med,
|
mdc_equipment me
|
WHERE
|
med.equipment_id = me.id
|
AND med.dep_id = #{ departId }
|
<if test="key != null and key != '' ">
|
AND me.device_abnormal_status = 1
|
</if>
|
ORDER BY me.equipment_id
|
</select>
|
|
<!--根据产线id查询设备-->
|
<select id="queryByProductionId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
|
SELECT
|
me.*
|
FROM
|
mdc_production_equipment mpe,
|
mdc_equipment me
|
WHERE
|
mpe.equipment_id = me.id
|
AND mpe.production_id = #{ productionId }
|
<if test="key != null and key != '' ">
|
AND me.device_abnormal_status = 1
|
</if>
|
ORDER BY me.equipment_id
|
</select>
|
|
<!--根据产线id查询设备id集合-->
|
<select id="queryIdsByProductions" resultType="java.lang.String">
|
SELECT
|
me.equipment_id
|
FROM
|
mdc_equipment me
|
LEFT JOIN mdc_production_equipment mpe ON me.id = mpe.equipment_id
|
WHERE
|
mpe.production_id IN
|
<foreach collection="allProductionIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<!--查询设备监控信息-->
|
<select id="checkStatusFromEquipmentIds" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentMonitor">
|
SELECT
|
t1.equipment_id,
|
t2.CollectTime,
|
t1.equipment_name,
|
t2.Oporation,
|
t1.id,
|
t1.equipment_status,
|
t1.equipment_type equipmentType,
|
t3.equipment_type_pictures
|
FROM
|
mdc_equipment t1
|
LEFT JOIN Equipment t2 ON t1.equipment_id = t2.EquipmentID
|
LEFT JOIN mdc_equipment_type t3 ON t1.equipment_type = t3.equipment_type_name
|
WHERE equipment_id IN
|
<foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<!--根据部门id查询设备id集合-->
|
<select id="queryIdsByDeparts" resultType="java.lang.String">
|
SELECT
|
me.equipment_id
|
FROM
|
mdc_equipment me
|
LEFT JOIN mdc_equipment_depart med ON me.id = med.equipment_id
|
WHERE
|
med.dep_id IN
|
<foreach collection="allDepartIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<!--根据设备编号查询设备信息和部门信息-->
|
<select id="findEquDepList" resultType="org.jeecg.modules.mdc.dto.MdcEquDepDto">
|
SELECT
|
sd.id,
|
sd.parent_id,
|
sd.depart_name,
|
sd.org_type,
|
me.equipment_id,
|
me.equipment_name,
|
me.equipment_type,
|
me.equipment_model
|
FROM
|
mdc_equipment_depart med
|
LEFT JOIN sys_depart sd ON med.dep_id = sd.id
|
LEFT JOIN mdc_equipment me ON me.id = med.equipment_id
|
<where>
|
me.equipment_id IN
|
<foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
AND me.device_abnormal_status = 1
|
</where>
|
ORDER BY sd.depart_order
|
</select>
|
|
<!--根据设备编号查询设备信息和产线信息-->
|
<select id="findEquProList" resultType="org.jeecg.modules.mdc.dto.MdcEquProDto">
|
SELECT
|
mp.id,
|
mp.parent_id,
|
mp.production_name,
|
mp.org_type,
|
me.equipment_id,
|
me.equipment_name,
|
me.equipment_type,
|
me.equipment_model
|
FROM
|
mdc_production_equipment mpe
|
LEFT JOIN mdc_production mp ON mpe.production_id = mp.id
|
LEFT JOIN mdc_equipment me ON me.id = mpe.equipment_id
|
<where>
|
me.equipment_id IN
|
<foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
AND me.device_abnormal_status = 1
|
</where>
|
ORDER BY mp.production_order
|
</select>
|
|
<!--根据大屏车间id查询设备列表-->
|
<select id="getEquipmentByWorkshopId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
|
SELECT
|
me.*
|
FROM
|
mdc_workshop_equipment mwe
|
LEFT JOIN mdc_equipment me ON me.equipment_id = mwe.equipment_id
|
<where>
|
AND mwe.workshop_id = #{ workshopEquipmentVo.workshopId }
|
<if test="workshopEquipmentVo.equipmentId != null and workshopEquipmentVo.equipmentId != ''">
|
AND mwe.equipment_id = #{ workshopEquipmentVo.equipmentId }
|
</if>
|
</where>
|
ORDER BY me.equipment_id
|
</select>
|
|
<!--分页列表-->
|
<select id="pageList" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
|
SELECT
|
t1.*
|
FROM
|
mdc_equipment t1
|
LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id
|
LEFT JOIN mdc_production t3 ON t2.production_id = t3.id
|
<where>
|
<if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' ">
|
AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%')
|
</if>
|
<if test="mdcEquipment.equipmentName != null and mdcEquipment.equipmentName != '' ">
|
AND t1.equipment_name LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentName}),'%')
|
</if>
|
<if test="mdcEquipment.equipmentModel != null and mdcEquipment.equipmentModel != '' ">
|
AND t1.equipment_name = #{mdcEquipment.equipmentModel}
|
</if>
|
<if test="mdcEquipment.equipmentType != null and mdcEquipment.equipmentType != '' ">
|
AND t1.equipmentType = #{mdcEquipment.equipmentType}
|
</if>
|
<if test="mdcEquipment.driveType != null and mdcEquipment.driveType != '' ">
|
AND t1.drive_type = #{mdcEquipment.driveType}
|
</if>
|
<if test="mdcEquipment.deviceLevel != null and mdcEquipment.deviceLevel != '' ">
|
AND t1.device_level = #{mdcEquipment.deviceLevel}
|
</if>
|
<if test="mdcEquipment.deviceCategory != null and mdcEquipment.deviceCategory != '' ">
|
AND t1.device_category = #{mdcEquipment.deviceCategory}
|
</if>
|
<if test="mdcEquipment.deviceAbnormalStatus != null and mdcEquipment.deviceAbnormalStatus != '' ">
|
AND t1.device_abnormal_status = #{mdcEquipment.deviceAbnormalStatus}
|
</if>
|
<if test="mdcEquipment.productionIds != null and mdcEquipment.productionIds.size() > 0 ">
|
AND t3.id IN
|
<foreach collection="mdcEquipment.productionIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
order by t1.sort_no
|
</select>
|
|
<select id="exportXlsList" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
|
SELECT
|
t1.*
|
FROM
|
mdc_equipment t1
|
LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id
|
LEFT JOIN mdc_production t3 ON t2.production_id = t3.id
|
<where>
|
<if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' ">
|
AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%')
|
</if>
|
<if test="mdcEquipment.equipmentName != null and mdcEquipment.equipmentName != '' ">
|
AND t1.equipment_name LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentName}),'%')
|
</if>
|
<if test="mdcEquipment.equipmentModel != null and mdcEquipment.equipmentModel != '' ">
|
AND t1.equipment_name = #{mdcEquipment.equipmentModel}
|
</if>
|
<if test="mdcEquipment.equipmentType != null and mdcEquipment.equipmentType != '' ">
|
AND t1.equipment_type = #{mdcEquipment.equipmentType}
|
</if>
|
<if test="mdcEquipment.driveType != null and mdcEquipment.driveType != '' ">
|
AND t1.drive_type = #{mdcEquipment.driveType}
|
</if>
|
<if test="mdcEquipment.productionIds != null and mdcEquipment.productionIds.size() > 0 ">
|
AND t3.id IN
|
<foreach collection="mdcEquipment.productionIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
order by t1.sort_no
|
</select>
|
|
<!--查询单表数据-->
|
<select id="findWorkLineLast" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentDto">
|
select top 1 spindlespeed, actualspindlespeed from [${tableName}] order by CollectTime desc
|
</select>
|
|
</mapper>
|