<?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.CalendarMapper">
|
<!-- 与mysql mapper相同,改动需同步 -->
|
<resultMap id="calendarMapCopy" type="com.qianwen.smartman.modules.smis.vo.CalendarVO">
|
<id column="id" property="id"/>
|
<result column="code" property="code"/>
|
<result column="name" property="name"/>
|
<result column="year" property="year"/>
|
<result column="status" property="status"/>
|
<collection property="calendarDayVOList" ofType="com.qianwen.smartman.modules.smis.vo.CalendarDayVO">
|
<id column="calendarDayId" property="id"/>
|
<result column="calendar_date" property="calendarDate"/>
|
<result column="model_id" property="modelId"/>
|
<result column="is_high_priority" property="isHighPriority"/>
|
<result column="isOffDay" property="isOffDay"/>
|
<result column="modelName" property="modelName"/>
|
<result column="offDayRemark" property="offDayRemark"/>
|
</collection>
|
</resultMap>
|
|
<!--查询班次模型详情-->
|
<select id="getCalendarDetail" resultMap="calendarMapCopy">
|
select
|
t1.id,
|
t1.code,
|
t1.name,
|
t1.year,
|
t1.status,
|
t2.id as calendarDayId,
|
t2.calendar_date,
|
t2.model_id,
|
t2.is_high_priority,
|
t3.name as modelName,
|
nvl(t2.is_off_day, 0) isOffDay,
|
t4.remark offDayRemark
|
from blade_production_calendar t1
|
left join blade_production_calendar_day t2 on t1.id = t2.calendar_id
|
left join blade_shift_model t3 on t2.model_id = t3.id
|
left join blade_shift_off_day t4 on t2.is_off_day = 1 and t2.off_id = t4.id
|
<where>
|
t1.id = #{calendarId}
|
</where>
|
order by t2.calendar_date
|
</select>
|
|
<select id="getShiftIndexNameByCodeAndYear" resultType="java.lang.String">
|
SELECT distinct sd.index_name
|
FROM blade_production_calendar pc
|
LEFT JOIN blade_production_calendar_day pdc ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0
|
LEFT JOIN blade_shift_detail sd on pdc.model_id = sd.model_id
|
WHERE pc.code = #{calendarCode}
|
AND pc.year = #{year}
|
AND pdc.calendar_date = TO_DATE(#{factoryDate}, 'yyyy-mm-dd')
|
AND pc.tenant_id = #{tenantId}
|
AND sd.shift_index = #{shiftIndex}
|
AND pc.is_deleted = 0
|
</select>
|
|
|
<select id="queryShiftIndexName" resultType="com.qianwen.smartman.modules.mdc.dto.ShiftIndexNameDTO">
|
SELECT sd.shift_index as shiftIndex,
|
sd.index_name as shiftIndexName,
|
NVL(sd.index_name,'班次' || sd.shift_index) as indexName
|
FROM blade_production_calendar pc
|
INNER JOIN blade_production_calendar_day pdc
|
ON pc.id = pdc.calendar_id AND pdc.is_deleted = 0 AND
|
pdc.calendar_date = TO_DATE(#{day}, 'yyyy-mm-dd')
|
LEFT JOIN blade_shift_detail sd on pdc.model_id = sd.model_id
|
WHERE pc.code = #{calendarCode}
|
AND pc.year = #{year}
|
AND pc.is_deleted = 0
|
</select>
|
|
<select id="listShiftInfo" resultType="com.qianwen.smartman.modules.smis.dto.ShiftInfoDTO">
|
SELECT
|
to_char(b.calendar_date,'yyyy-mm-dd') calendarDate,
|
c.shift_index shiftIndex,
|
c.index_name indexName,
|
c.shift_start_time startTime,
|
c.shift_end_time endTime,
|
d.id workstationId,
|
b.model_id modelId
|
FROM
|
blade_production_calendar a
|
LEFT JOIN blade_production_calendar_day b ON a.id = b.calendar_id
|
LEFT JOIN blade_shift_detail c on b.model_id = c.model_id
|
LEFT JOIN blade_workstation d ON d.calendar_code = a.code
|
WHERE b.calendar_date BETWEEN #{startDay} AND #{endDay}
|
and a.is_deleted = 0
|
and b.is_deleted = 0
|
and a.code IN (
|
SELECT DISTINCT( d.calendar_code )
|
FROM blade_workstation d
|
WHERE d.id IN
|
<foreach collection="workstationIdList" item="workstationId" index="index" open="(" close=")" separator=",">
|
#{workstationId}
|
</foreach>
|
)
|
AND d.id IN
|
<foreach collection="workstationIdList" item="workstationId" index="index" open="(" close=")" separator=",">
|
#{workstationId}
|
</foreach>
|
</select>
|
|
<select id="getShiftDetailDates" resultType="com.qianwen.smartman.modules.smis.vo.ShiftTimeDetailVO">
|
select bpcd.calendar_date as calendarDate,
|
bsd.id as id,
|
bsd.model_id as modelId,
|
shift_index as shiftIndex,
|
shift_start_time as shiftStartTime,
|
shift_end_time as shiftEndTime,
|
rest_number as restNumber,
|
index_name as indexName,
|
bsm.colour as colour
|
from blade_production_calendar bpc
|
INNER JOIN blade_production_calendar_day bpcd on bpc.id = bpcd.calendar_id
|
INNER JOIN blade_shift_detail bsd on bpcd.model_id = bsd.model_id
|
LEFT JOIN blade_shift_model bsm on bsd.model_id = bsm.id and bsm.is_deleted = 0
|
where ${ew.sqlSegment}
|
</select>
|
|
<select id="getTimeShiftAll" resultType="com.qianwen.smartman.modules.smis.dto.CalendarShiftDTO">
|
select bpcd.calendar_date, bsd.shift_start_time, bsd.shift_end_time, bsd.shift_index, bsd.index_name
|
from blade_production_calendar bpc
|
inner join blade_production_calendar_day bpcd on bpc.id = bpcd.calendar_id
|
inner join blade_shift_detail bsd on bpcd.model_id = bsd.model_id
|
where ${ew.sqlSegment}
|
</select>
|
|
<select id="getWorkstationShiftIndexListByDate"
|
resultType="com.qianwen.smartman.modules.smis.dto.ShiftDetailInfoDTO">
|
SELECT pdc.calendar_date,sd.shift_index as shiftIndex,
|
NVL(sd.index_name,'班次' || sd.shift_index) as indexName,
|
sd.shift_start_time,
|
sd.shift_end_time
|
FROM blade_production_calendar pc
|
LEFT JOIN blade_production_calendar_day pdc ON pc.id = pdc.calendar_id
|
LEFT JOIN blade_shift_detail sd ON pdc.model_id = sd.model_id
|
WHERE pc.code = #{calendarCode}
|
AND pc.year = #{year}
|
AND pc.is_deleted = 0
|
AND pdc.is_deleted = 0
|
AND (to_char(pdc.start_time,'yyyy-mm-dd') = #{date} or to_char(pdc.end_time,'yyyy-mm-dd') = #{date})
|
ORDER BY pdc.calendar_date,sd.shift_index
|
</select>
|
|
</mapper>
|