<?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.cps.mapper.TrayMapper">
|
|
<update id="updateFixTure">
|
update blade_fixture bf
|
set bf.fixture_status = #{status}
|
where bf.id in (select btf.fix_id
|
from blade_tray_fixture btf
|
where btf.tray_id = #{id})
|
</update>
|
|
<select id="trayPage" resultType="com.qianwen.smartman.modules.cps.vo.PageTrayVO">
|
select bt.id,
|
bt.code,
|
bt.name,
|
bt.tray_status as trayStatus,
|
bt.description,
|
bt.category,
|
bt.standard_model standardModel,
|
bt.availability,
|
bt.remark,
|
bcg.id groupId,
|
bcg.name groupName
|
from blade_tray bt
|
left join blade_common_group_of_item bcgoi on bt.id = bcgoi.item_id
|
left join blade_common_group bcg on bcgoi.group_id = bcg.id
|
where bt.is_deleted = 0
|
<if test="groupId != null">
|
and group_id = #{groupId}
|
</if>
|
and bcg.is_deleted = 0
|
<if test="keyword != null and keyword != ''">
|
and (bt.code like concat(#{keyword}, '%') or bt.name like concat(#{keyword}, '%'))
|
</if>
|
order by bt.create_time desc,bt.id desc
|
</select>
|
|
<select id="trayTree" resultType="com.qianwen.smartman.modules.cps.vo.ToolingVO">
|
SELECT bcg1.id,
|
bcg1.code,
|
bcg1.name,
|
bcg1.parent_id as parentId,
|
count(bt.id) numbers,
|
bcg2.name parentName
|
FROM blade_common_group bcg1
|
LEFT JOIN blade_common_group bcg2 on bcg2.id = bcg1.parent_id and bcg2.is_deleted = 0
|
AND bcg1.group_type = bcg2.group_type and bcg1.group_category = bcg2.group_category
|
LEFT JOIN blade_common_group_of_item bcgoi on bcgoi.group_id = bcg1.id
|
LEFT JOIN blade_tray bt on bt.id = bcgoi.item_id and bt.is_deleted = 0
|
where bcg1.is_deleted = 0
|
and bcg1.group_type = #{query.groupType}
|
and bcg1.group_category = #{query.groupCategory}
|
group by bcg1.id, bcg1.code, bcg1.name, bcg1.parent_id, bcg2.name;
|
</select>
|
|
<select id="fixtureTree" resultType="com.qianwen.smartman.modules.cps.vo.ToolingVO">
|
SELECT bcg1.id,
|
bcg1.code,
|
bcg1.name,
|
bcg1.parent_id as parentId,
|
count(bf.id) numbers,
|
bcg2.name parentName
|
FROM blade_common_group bcg1
|
LEFT JOIN blade_common_group bcg2 on bcg2.id = bcg1.parent_id and bcg2.is_deleted = 0
|
AND bcg1.group_type = bcg2.group_type and bcg1.group_category = bcg2.group_category
|
LEFT JOIN blade_common_group_of_item bcgoi on bcgoi.group_id = bcg1.id
|
LEFT JOIN blade_fixture bf on bf.id = bcgoi.item_id and bf.is_deleted = 0
|
where bcg1.is_deleted = 0
|
and bcg1.group_type = #{query.groupType}
|
and bcg1.group_category = #{query.groupCategory}
|
group by bcg1.id, bcg1.code, bcg1.name, bcg1.parent_id, bcg2.name;
|
</select>
|
|
<select id="groupTray" resultType="com.qianwen.smartman.modules.cps.vo.TrayTreeVO">
|
select bt.id,
|
bt.code,
|
bt.name,
|
bcg.id parentId,
|
0 as isGroup
|
from blade_tray bt
|
LEFT JOIN blade_common_group_of_item bcgoi ON bt.id = bcgoi.item_id
|
LEFT JOIN blade_common_group bcg on bcgoi.group_id = bcg.id and bcg.is_deleted = 0
|
where bt.is_deleted = 0
|
</select>
|
|
<select id="unUsedGroupTray" resultType="com.qianwen.smartman.modules.cps.vo.TrayTreeVO">
|
select bt.id,
|
bt.code,
|
bt.name,
|
bcg.id parentId,
|
0 as isGroup
|
from blade_tray bt
|
LEFT JOIN blade_common_group_of_item bcgoi ON bt.id = bcgoi.item_id
|
LEFT JOIN blade_common_group bcg on bcgoi.group_id = bcg.id and bcg.is_deleted = 0
|
where bt.is_deleted = 0
|
and bt.in_use = 0
|
</select>
|
|
<select id="removeFaceFixture" resultType="java.lang.Integer">
|
select count(*)
|
from blade_fixture bf
|
where bf.is_deleted = 0
|
and exists(select *
|
from blade_production_craft_process_related_fixture bpcprf
|
where bpcprf.fixture_id = bf.id
|
and exists(select *
|
from blade_tray_fixture btf
|
where bpcprf.fixture_id = btf.fix_id
|
and btf.is_deleted = 0
|
and btf.tray_id in
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>)
|
)
|
</select>
|
|
<select id="getWarehouseAreaTrayList" resultType="com.qianwen.smartman.modules.fms.vo.FmsWarehouseAreaTrayVO">
|
SELECT bt.code code,
|
bt.availability availability,
|
bfrtt.current_position currentPosition,
|
bfrtt.current_station currentStation,
|
bfrtt.order_code orderCode,
|
bfrtt.process_code processCode,
|
bfrtt.components_number componentsNumber,
|
bfrtt.part_type partType,
|
bfrtt.order_id orderId,
|
fo.product_code productCode
|
FROM blade_tray bt
|
LEFT JOIN blade_tray_storage bts ON bt.id = bts.tray_id and bts.is_deleted = 0
|
LEFT JOIN blade_warehouse_station bws ON bws.id = bts.warehouse_station_id and bws.is_deleted = 0
|
LEFT JOIN blade_fms_real_time_tray bfrtt ON bfrtt.tray_code = bt.code and bfrtt.is_deleted = 0
|
LEFT JOIN blade_fms_order fo on fo.id=bfrtt.order_id and fo.is_deleted = 0
|
WHERE bt.is_deleted = 0
|
<if test="areaId != null">
|
and bws.area_id = #{areaId}
|
</if>
|
order by bt.create_time desc, bt.id desc
|
</select>
|
|
<select id="getWarehouseAreaTray" resultType="com.qianwen.smartman.modules.cps.dto.TrayWarehouseAreaDTO">
|
SELECT bt.CODE trayCode,
|
bwa.code areaCode
|
FROM blade_tray bt
|
LEFT JOIN blade_tray_storage bts ON bt.id = bts.tray_id
|
AND bts.is_deleted = 0
|
LEFT JOIN blade_warehouse_station bws ON bws.id = bts.warehouse_station_id
|
AND bws.is_deleted = 0
|
LEFT JOIN blade_fms_real_time_tray bfrtt ON bfrtt.tray_code = bt.CODE
|
AND bfrtt.is_deleted = 0
|
LEFT JOIN blade_warehouse_area bwa on bwa.id = bws.area_id
|
WHERE bt.is_deleted = 0
|
AND bfrtt.tray_code IS NOT NULL
|
and bwa.code is not null
|
</select>
|
</mapper>
|