<?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.smis.mapper.MachineMapper">
|
|
<update id="changeCollectSwitch">
|
UPDATE blade_machine m,
|
blade_workstation w,
|
blade_workstation_of_machine wm
|
SET m.collect_switch = #{collectSwitch}
|
WHERE w.id = wm.workstation_id
|
AND m.id = wm.machine_id
|
AND w.tenant_id = #{tenantId}
|
AND w.id = #{workstationId};
|
</update>
|
|
<select id="typeAndonRecord" resultType="int">
|
select count(*)
|
from blade_andon_record bar
|
left join blade_device_andon_type bdat on bar.type_id = bdat.andon_type_id and bdat.is_deleted = 0
|
left join blade_machine bm on bm.machine_type_id = bdat.device_type_id and bm.is_deleted = 0
|
where bar.is_deleted = 0
|
and bar.cur_status in (1, 2)
|
and bm.id in
|
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="selectMachineDetail" resultType="com.qianwen.smartman.modules.smis.vo.MachineDetailVO">
|
select bm.id,
|
bm.tenant_id tenantId,
|
bm.extend_id extendId,
|
machine_code machineCode,
|
machine_name machineName,
|
machine_model machineModel,
|
machine_life_status machineLifeStatus,
|
machine_use_status machineUseStatus,
|
factory_no factoryNo,
|
assets_code assetsCode,
|
brand,
|
nameplate,
|
bm.avatar,
|
serial_no serialNo,
|
factory_file factoryFile,
|
manufacturer,
|
country_of_manufacture countryOfManufacture,
|
system_name systemName,
|
software_version softwareVersion,
|
net_weight netWeight,
|
power,
|
voltage,
|
dimensions,
|
production_time productionTime,
|
delivery_time deliveryTime,
|
depreciation_year depreciationYear,
|
turn_to_fixed_assets_time turnToFixedAssetsTime,
|
invoice_value invoiceValue,
|
ovfa,
|
net_asset_value netAssetValue,
|
bm.organization_id organizationId,
|
bcg2.name organizationName,
|
production_line productionLine,
|
management_class managementClass,
|
elaborate_equipment elaborateEquipment,
|
bm.pin_code pinCode,
|
short_code shortCode,
|
installation_location installationLocation,
|
bm.remark,
|
machine_type_id machineTypeId,
|
bdt.name machineTypeName,
|
bdt.code machineTypeCode,
|
bm.group_id groupId,
|
bcg1.name groupName,
|
bm.employee_id employeeId,
|
be.name employeeName,
|
bm.status status
|
from blade_machine bm
|
LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
|
LEFT JOIN blade_common_group bcg1 on bm.group_id = bcg1.id and bcg1.is_deleted = 0
|
LEFT JOIN blade_common_group bcg2 on bm.organization_id = bcg2.id and bcg2.is_deleted = 0
|
LEFT JOIN blade_employee be on bm.employee_id = be.id and be.is_deleted = 0
|
where bm.id = #{id}
|
</select>
|
|
<select id="pageMachine" resultType="com.qianwen.smartman.modules.smis.vo.MachineListVO">
|
select bm.id,
|
bm.machine_code machineCode,
|
bm.machine_name machineName,
|
bdt.id machineTypeId,
|
bdt.name machineTypeName,
|
bm.machine_model machineModel,
|
bcg.name groupName,
|
bm.machine_type_id,
|
bm.serial_no serialNo,
|
bm.short_code shortCode,
|
bm.machine_use_status machineUseStatus,
|
bm.status status
|
from blade_machine bm
|
LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
|
LEFT JOIN blade_common_group bcg on bm.group_id = bcg.id and bcg.is_deleted = 0
|
WHERE bm.is_deleted = 0
|
<if test="machineName != null and machineName != ''">
|
and machine_name like CONCAT(#{machineName}, '%')
|
</if>
|
<if test="machineCode != null and machineCode != ''">
|
and machine_code like CONCAT( #{machineCode}, '%')
|
</if>
|
<if test="machineTypeId != null">
|
and machine_type_id = #{machineTypeId}
|
</if>
|
<if test="groupId != null and groupId != allMachineId">
|
and group_id = #{groupId}
|
</if>
|
<if test="status != null">
|
and bm.status = #{status}
|
</if>
|
ORDER BY bm.create_time DESC,bm.id DESC
|
</select>
|
<select id="deviceListByDeviceTypeId" resultType="com.qianwen.smartman.modules.smis.dto.DeviceSimpleDTO">
|
SELECT t1.machine_type_id AS deviceTypeId,
|
t2.name AS deviceTypeName,
|
t1.id AS deviceId,
|
t1.machine_code AS code,
|
t1.machine_name AS name,
|
t1.machine_model AS machineModel
|
FROM blade_machine t1
|
LEFT JOIN blade_device_type t2
|
ON t1.machine_type_id = t2.id and t2.is_deleted = 0
|
WHERE t1.machine_type_id = #{deviceTypeId}
|
and t1.is_deleted = 0
|
</select>
|
|
<select id="deviceListByDeviceIdList" resultType="com.qianwen.smartman.modules.smis.dto.DeviceSimpleDTO">
|
SELECT t1.machine_type_id AS deviceTypeId,
|
t2.name AS deviceTypeName,
|
t1.id AS deviceId,
|
t1.machine_code AS code,
|
t1.machine_name AS name,
|
t1.machine_model AS machineModel
|
FROM blade_machine t1
|
LEFT JOIN blade_device_type t2
|
ON t1.machine_type_id = t2.id and t2.is_deleted = 0
|
WHERE t1.is_deleted = 0
|
<if test="deviceIdList!= null and deviceIdList.size > 0 ">
|
AND t1.id IN
|
<foreach collection="deviceIdList" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="listMachineDetail" resultType="com.qianwen.smartman.modules.smis.vo.MachineDetailVO">
|
select bm.id,
|
bm.tenant_id tenantId,
|
bm.extend_id extendId,
|
machine_code machineCode,
|
machine_name machineName,
|
machine_model machineModel,
|
machine_life_status machineLifeStatus,
|
machine_use_status machineUseStatus,
|
factory_no factoryNo,
|
assets_code assetsCode,
|
brand,
|
nameplate,
|
bm.avatar,
|
serial_no serialNo,
|
factory_file factoryFile,
|
manufacturer,
|
country_of_manufacture countryOfManufacture,
|
system_name systemName,
|
software_version softwareVersion,
|
net_weight netWeight,
|
power,
|
voltage,
|
dimensions,
|
production_time productionTime,
|
delivery_time deliveryTime,
|
depreciation_year depreciationYear,
|
turn_to_fixed_assets_time turnToFixedAssetsTime,
|
invoice_value invoiceValue,
|
ovfa,
|
net_asset_value netAssetValue,
|
bm.organization_id organizationId,
|
bcg2.name organizationName,
|
production_line productionLine,
|
management_class managementClas,
|
elaborate_equipment elaborateEquipment,
|
bm.pin_code pinCode,
|
short_code shortCode,
|
installation_location installationLocation,
|
bm.remark,
|
machine_type_id machineTypeId,
|
bdt.name machineTypeName,
|
bdt.code machineTypeCode,
|
bcg1.name groupName,
|
be.name employeeName
|
from blade_machine bm
|
LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
|
LEFT JOIN blade_common_group bcg1 on bm.group_id = bcg1.id and bcg1.is_deleted = 0
|
LEFT JOIN blade_common_group bcg2 on bm.organization_id = bcg2.id and bcg2.is_deleted = 0
|
LEFT JOIN blade_employee be on bm.employee_id = be.id and be.is_deleted = 0
|
WHERE bm.is_deleted = 0
|
<if test="machineName != null and machineName != ''">
|
and machine_name like CONCAT( #{machineName}, '%')
|
</if>
|
<if test="machineCode != null and machineCode != ''">
|
and machine_code like CONCAT( #{machineCode}, '%')
|
</if>
|
<if test="machineTypeId != null">
|
and machine_type_id = #{machineTypeId}
|
</if>
|
<if test="groupId != null and groupId != allMachineId">
|
and group_id = #{groupId}
|
</if>
|
<if test="status != null">
|
and bm.status = #{status}
|
</if>
|
ORDER BY bm.create_time DESC,bm.id DESC
|
</select>
|
|
<select id="getMachineByWorkStation" resultType="com.qianwen.smartman.modules.smis.dto.MachineExtDTO">
|
select distinct bm.extend_id, bwom.workstation_id
|
from blade_machine bm
|
INNER JOIN blade_workstation_of_machine bwom on bm.id = bwom.machine_id
|
where bm.is_deleted = 0
|
and bwom.workstation_id in
|
<foreach collection="workstationIds" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="queryDateTypeState" resultType="java.lang.String">
|
select bdv.dmp_id
|
from blade_workstation_wcs bww
|
left join blade_dmp_variables bdv on bww.dmp_variables_id = bdv.id
|
where workstation_id = #{workstationId}
|
and bww.data_type = #{code}
|
and bww.is_deleted = 0
|
</select>
|
|
<select id="selectMachineDetailByCode" resultType="com.qianwen.smartman.modules.smis.vo.MachineDetailVO">
|
select bm.id,
|
bm.tenant_id tenantId,
|
bm.extend_id extendId,
|
machine_code machineCode,
|
machine_name machineName,
|
machine_model machineModel,
|
machine_life_status machineLifeStatus,
|
machine_use_status machineUseStatus,
|
factory_no factoryNo,
|
assets_code assetsCode,
|
brand,
|
nameplate,
|
bm.avatar,
|
serial_no serialNo,
|
factory_file factoryFile,
|
manufacturer,
|
country_of_manufacture countryOfManufacture,
|
system_name systemName,
|
software_version softwareVersion,
|
net_weight netWeight,
|
power,
|
voltage,
|
dimensions,
|
production_time productionTime,
|
delivery_time deliveryTime,
|
depreciation_year depreciationYear,
|
turn_to_fixed_assets_time turnToFixedAssetsTime,
|
invoice_value invoiceValue,
|
ovfa,
|
net_asset_value netAssetValue,
|
bm.organization_id organizationId,
|
bcg2.name organizationName,
|
production_line productionLine,
|
management_class managementClass,
|
elaborate_equipment elaborateEquipment,
|
bm.pin_code pinCode,
|
short_code shortCode,
|
installation_location installationLocation,
|
bm.remark,
|
machine_type_id machineTypeId,
|
bdt.name machineTypeName,
|
bdt.code machineTypeCode,
|
bm.group_id groupId,
|
bcg1.name groupName,
|
bm.employee_id employeeId,
|
be.name employeeName,
|
bm.status status
|
from blade_machine bm
|
LEFT JOIN blade_device_type bdt
|
on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
|
LEFT JOIN blade_common_group bcg1 on bm.group_id = bcg1.id and bcg1.is_deleted = 0
|
LEFT JOIN blade_common_group bcg2 on bm.organization_id = bcg2.id and bcg2.is_deleted = 0
|
LEFT JOIN blade_employee be on bm.employee_id = be.id and be.is_deleted = 0
|
where bm.machine_code = #{machineCode}
|
</select>
|
|
<select id="pageMachineByParam" resultType="com.qianwen.smartman.modules.smis.vo.MachineListVO">
|
select bm.id,
|
bm.machine_code machineCode,
|
bm.machine_name machineName,
|
bdt.id machineTypeId,
|
bdt.name machineTypeName,
|
bm.machine_model machineModel,
|
bcg.name groupName,
|
bm.machine_type_id,
|
bm.serial_no serialNo,
|
bm.short_code shortCode,
|
bm.machine_use_status machineUseStatus,
|
bm.status status
|
from blade_machine bm
|
LEFT JOIN blade_device_type bdt on bm.machine_type_id = bdt.id and bdt.is_deleted = 0
|
LEFT JOIN blade_common_group bcg on bm.group_id = bcg.id and bcg.is_deleted = 0
|
WHERE bm.is_deleted = 0
|
<if test="machineSelectVO.keyword != null and machineSelectVO.keyword != ''">
|
and (bm.machine_name like CONCAT(#{machineSelectVO.keyword}, '%')
|
or bm.machine_code like CONCAT(#{machineSelectVO.keyword}, '%'))
|
</if>
|
ORDER BY bm.create_time DESC,bm.id DESC
|
</select>
|
<!-- 查询未绑定的机器-->
|
<select id="listNoBand" resultType="com.qianwen.smartman.modules.smis.vo.MachineVO">
|
select bm.*
|
from blade_machine bm
|
where bm.is_deleted = 0
|
AND bm.id not in (select bwom.machine_id
|
from blade_workstation_of_machine bwom)
|
</select>
|
<select id="listHaveBand" resultType="com.qianwen.smartman.modules.smis.vo.MachineVO">
|
select bm.*
|
from blade_machine bm
|
where bm.is_deleted = 0
|
AND bm.id in (select bwom.machine_id
|
from blade_workstation_of_machine bwom)
|
</select>
|
</mapper>
|