<?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.WorkstationMapper">
|
|
<select id="listWorkStationOnShiftIndex" resultType="com.qianwen.smartman.modules.smis.entity.Workstation">
|
SELECT w.*
|
FROM blade_workstation w
|
INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
|
INNER JOIN blade_production_calendar_day pdc
|
ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date = TO_DATE(#{queryDate}, 'yyyy-mm-dd')
|
INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index = #{shift}
|
WHERE w.is_deleted = 0
|
AND pc.is_deleted = 0
|
AND pdc.is_deleted = 0
|
AND w.type = #{type}
|
<if test="ids != null and ids.size() > 0">
|
AND w.id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
order by w.code asc;
|
</select>
|
<select id="countWorkStationOnShiftIndex" resultType="java.lang.Integer">
|
SELECT count(*)
|
FROM blade_workstation w
|
INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
|
INNER JOIN blade_production_calendar_day pdc
|
ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date =TO_DATE(#{queryDate}, 'yyyy-mm-dd')
|
INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index = #{shift}
|
WHERE w.is_deleted = 0
|
AND pc.is_deleted = 0
|
AND pdc.is_deleted = 0
|
AND w.type = #{type}
|
<if test="ids != null and ids.size() > 0">
|
AND w.id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
|
<select id="findByIndexAndDateAndTypeAndYear" resultType="java.lang.Long">
|
SELECT distinct w.id
|
FROM blade_workstation w
|
INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
|
INNER JOIN blade_production_calendar_day pdc
|
ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date =TO_DATE(#{queryDate}, 'yyyy-mm-dd')
|
INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index = #{shift}
|
WHERE w.is_deleted = 0
|
AND pc.is_deleted = 0
|
AND pdc.is_deleted = 0
|
AND w.type = #{type}
|
</select>
|
|
|
|
|
<select id="listWorkStationOnShift" resultType="com.qianwen.smartman.modules.smis.entity.Workstation">
|
SELECT distinct w.*
|
FROM blade_workstation w
|
INNER JOIN blade_production_calendar pc ON w.calendar_code = pc.code AND pc.year = #{year}
|
INNER JOIN blade_production_calendar_day pdc
|
ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND pdc.calendar_date = TO_DATE(#{queryDate}, 'yyyy-mm-dd')
|
INNER JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id AND sd.shift_index IN
|
<foreach collection="shifts" item="shift" open="(" separator="," close=")">
|
#{shift}
|
</foreach>
|
WHERE w.is_deleted = 0
|
AND pc.is_deleted = 0
|
AND pdc.is_deleted = 0
|
AND w.type = #{type}
|
<if test="ids != null and ids.size() > 0">
|
AND w.id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
order by w.code;
|
</select>
|
|
<select id="getDayShift" resultType="com.qianwen.smartman.modules.smis.entity.ProductionCalendarDay">
|
select bpcd.*
|
from blade_production_calendar_day bpcd
|
left join blade_production_calendar bpc on bpc.id = bpcd.calendar_id
|
where bpcd.calendar_date =TO_DATE(#{calendarDate}, 'yyyy-mm-dd')
|
and bpc.code = (select bw.calendar_code
|
from blade_workstation bw
|
where bw.id = #{workstationId})
|
</select>
|
|
|
</mapper>
|