You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
402 lines
14 KiB
402 lines
14 KiB
<?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.alteams.modules.shoporder.dao.OrderTimeHistDao">
|
|
<update id="finishOrderTimeHist">
|
|
UPDATE SFDC_TimeHist
|
|
SET TillTime = #{tilltime}
|
|
, TillEnteredTime = #{tillenteredtime}
|
|
, TillEnteredBy = #{tillenteredby}
|
|
, CompletedFlag = #{completedflag}
|
|
, TotalTime = #{totaltime}
|
|
, QtyPrd = #{qtyprd}
|
|
, TillDevicecode = #{tilldevicecode}
|
|
WHERE site = #{site}
|
|
AND OrderNo = #{orderno}
|
|
AND OrderRef1 = #{orderref1}
|
|
AND OrderRef2 = #{orderref2}
|
|
AND ItemNo = #{itemno}
|
|
AND HistSeqNo = #{histseqno}
|
|
</update>
|
|
|
|
|
|
<select id="orderTimeHistList" resultType="com.alteams.modules.shoporder.entity.OrderTimeHistEntity">
|
|
select sth.Site
|
|
,sth.OrderNo
|
|
,sth.ItemNo
|
|
,sth.SeqNo
|
|
,sth.HistSeqNo
|
|
,sth.EventTime
|
|
,sth.Enteredby
|
|
,sth.EventDesc
|
|
,sth.DowntimeCode
|
|
,sth.EventType
|
|
,sth.LinkHistSeqNo
|
|
,sth.TillTime
|
|
,sth.TillEnteredTime
|
|
,sth.TillEnteredBy
|
|
,sth.CompletedFlag
|
|
,sth.TotalTime
|
|
,sth.DowntimePhaseIn
|
|
,sth.OrderRef1
|
|
,sth.OrderRef2
|
|
,sth.WorkCenterNo
|
|
,sth.ResourceId
|
|
,sth.QtyPrd
|
|
,sth.devicecode
|
|
,sth.TillDevicecode
|
|
,sth.EventEnteredTime
|
|
,sth.PartDesc
|
|
,sth.OperationDescription
|
|
,su.user_display as user_name
|
|
,tsu.user_display as till_user_name
|
|
from SFDC_TimeHist sth
|
|
left join sys_user su on sth.site = su.site and su.username = sth.Enteredby
|
|
left join sys_user tsu on sth.site = tsu.site and sth.TillEnteredBy = tsu.username
|
|
<where>
|
|
sth.site = #{site}
|
|
<if test="orderno!=null and orderno!= ''">
|
|
and (sth.OrderNo + '-' + sth.OrderRef1+ '-'+sth.OrderRef2 ) = #{orderno}
|
|
</if>
|
|
|
|
<if test="itemno!=null and itemno!= ''">
|
|
and sth.ItemNo = #{itemno}
|
|
</if>
|
|
|
|
<if test=" completedflag != '' and completedflag != null ">
|
|
and sth.CompletedFlag = #{completedflag}
|
|
</if>
|
|
|
|
<if test=" eventtype != '' and eventtype != null ">
|
|
and sth.EventType = #{eventtype}
|
|
</if>
|
|
</where>
|
|
order by sth.EventTime desc
|
|
</select>
|
|
<select id="orderTimeHisCount" resultType="java.lang.Integer">
|
|
select isnull(sum(isNull(QtyPrd,0)),0)
|
|
from SFDC_TimeHist
|
|
<where>
|
|
site = #{site} and OrderNo = #{orderno} and OrderRef1 =#{orderref1} and OrderRef2 =#{orderref2} and ItemNo =
|
|
#{itemno}
|
|
<if test="completedflag != null and completedflag != '' ">
|
|
and CompletedFlag = #{completedflag}
|
|
</if>
|
|
<if test="eventtype != null and eventtype != '' ">
|
|
and EventType = #{eventtype}
|
|
</if>
|
|
|
|
</where>
|
|
</select>
|
|
<select id="getOrderTimeHistInfo" resultType="java.lang.Integer">
|
|
SELECT MAX(HistSeqNo)
|
|
FROM SFDC_TimeHist
|
|
WHERE site = #{site}
|
|
AND OrderNo = #{orderno}
|
|
AND OrderRef1 = #{orderref1}
|
|
AND OrderRef2 = #{orderref2}
|
|
AND ItemNo = #{itemno}
|
|
|
|
</select>
|
|
<select id="orderTimeHistReportList" resultType="com.alteams.modules.shoporder.vo.OrderTimeHistVo">
|
|
select Site
|
|
,OrderNo
|
|
,ItemNo
|
|
,SeqNo
|
|
,HistSeqNo
|
|
,EventTime
|
|
,Enteredby
|
|
,EventDesc
|
|
,DowntimeCode
|
|
,(case when EventType = 'F' then '常规生产' else '返工' end) as EventType
|
|
,(case when CompletedFlag = 'Y' then '已结束' else '未结束' end) as CompletedFlag
|
|
,LinkHistSeqNo
|
|
,TillTime
|
|
,TillEnteredTime
|
|
,TillEnteredBy
|
|
,CompletedFlag
|
|
,TotalTime
|
|
,DowntimePhaseIn
|
|
,OrderRef1
|
|
,OrderRef2
|
|
,WorkCenterNo
|
|
,ResourceId
|
|
,QtyPrd
|
|
,devicecode
|
|
,partno
|
|
,projectno
|
|
,TillDevicecode
|
|
,EventEnteredTime
|
|
,PartDesc
|
|
,OperationDescription
|
|
,WorkCenterCost
|
|
,WorkCenterDesc
|
|
from SFDC_TimeHist
|
|
<where>
|
|
site = #{site}
|
|
<if test="orderno!=null and orderno!= ''">
|
|
and (OrderNo + '-' + OrderRef1+ '-'+OrderRef2 ) like #{orderno}
|
|
</if>
|
|
<if test=" completedflag != '' and completedflag != null ">
|
|
and CompletedFlag = #{completedflag}
|
|
</if>
|
|
<if test=" eventtype != '' and eventtype != null ">
|
|
and EventType = #{eventtype}
|
|
</if>
|
|
<if test=" enteredby != '' and enteredby != null ">
|
|
and enteredby like #{enteredby}
|
|
</if>
|
|
<if test=" tillenteredby != '' and tillenteredby != null ">
|
|
and tillenteredby like #{tillenteredby}
|
|
</if>
|
|
<if test=" partno != '' and partno != null ">
|
|
and partno like #{partno}
|
|
</if>
|
|
<if test=" projectno != '' and projectno != null ">
|
|
and projectno like #{projectno}
|
|
</if>
|
|
<if test=" completedflag != '' and completedflag != null ">
|
|
and completedflag = #{completedflag}
|
|
</if>
|
|
<if test=" workcenterno != '' and workcenterno != null ">
|
|
and WorkCenterNo like #{workcenterno}
|
|
</if>
|
|
<if test=" startDate != null ">
|
|
and EventTime >= #{ startDate}
|
|
</if>
|
|
<if test=" startEndDate != null">
|
|
and EventTime <![CDATA[ <= ]]> #{ startEndDate}
|
|
</if>
|
|
<if test=" finishStartDate != null ">
|
|
and TillEnteredTime >= #{ finishStartDate}
|
|
</if>
|
|
<if test=" finishDate != null ">
|
|
and TillEnteredTime <![CDATA[ <= ]]> #{ finishDate}
|
|
</if>
|
|
</where>
|
|
order by EventTime desc
|
|
</select>
|
|
<select id="getOrderTimeHistPrevious"
|
|
resultType="com.alteams.modules.shoporder.entity.OrderTimeHistEntity">
|
|
select top 1 Site
|
|
, OrderNo
|
|
, ItemNo
|
|
, SeqNo
|
|
, HistSeqNo
|
|
, EventTime
|
|
, Enteredby
|
|
, EventDesc
|
|
, DowntimeCode
|
|
, LinkHistSeqNo
|
|
, TillTime
|
|
, TillEnteredTime
|
|
, TillEnteredBy
|
|
, CompletedFlag
|
|
, TotalTime
|
|
, DowntimePhaseIn
|
|
, OrderRef1
|
|
, OrderRef2
|
|
, WorkCenterNo
|
|
, ResourceId
|
|
, QtyPrd
|
|
, devicecode
|
|
, partno
|
|
, projectno
|
|
, TillDevicecode
|
|
, EventEnteredTime
|
|
, PartDesc
|
|
, OperationDescription
|
|
, WorkCenterCost
|
|
, WorkCenterDesc
|
|
from SFDC_TimeHist
|
|
where site = #{site}
|
|
and OrderNo = #{orderno}
|
|
and OrderRef2 = #{orderref2}
|
|
and OrderRef1 = #{orderref1}
|
|
and ItemNo = #{itemno}
|
|
and HistSeqNo <![CDATA[<]]> #{histseqno}
|
|
order by HistSeqNo desc
|
|
</select>
|
|
<select id="getOrderTimeHistNext" resultType="com.alteams.modules.shoporder.entity.OrderTimeHistEntity">
|
|
select top 1 Site
|
|
, OrderNo
|
|
, ItemNo
|
|
, SeqNo
|
|
, HistSeqNo
|
|
, EventTime
|
|
, Enteredby
|
|
, EventDesc
|
|
, DowntimeCode
|
|
, LinkHistSeqNo
|
|
, TillTime
|
|
, TillEnteredTime
|
|
, TillEnteredBy
|
|
, CompletedFlag
|
|
, TotalTime
|
|
, DowntimePhaseIn
|
|
, OrderRef1
|
|
, OrderRef2
|
|
, WorkCenterNo
|
|
, ResourceId
|
|
, QtyPrd
|
|
, devicecode
|
|
, partno
|
|
, projectno
|
|
, TillDevicecode
|
|
, EventEnteredTime
|
|
, PartDesc
|
|
, OperationDescription
|
|
, WorkCenterCost
|
|
, WorkCenterDesc
|
|
from SFDC_TimeHist
|
|
where site = #{site}
|
|
and OrderNo = #{orderno}
|
|
and OrderRef2 = #{orderref2}
|
|
and OrderRef1 = #{orderref1}
|
|
and ItemNo = #{itemno}
|
|
and HistSeqNo <![CDATA[>]]> #{histseqno}
|
|
order by HistSeqNo
|
|
</select>
|
|
<select id="getLastOrderTimeHistInfo"
|
|
resultType="com.alteams.modules.shoporder.entity.OrderTimeHistEntity">
|
|
select top 1 Site
|
|
, OrderNo
|
|
, ItemNo
|
|
, SeqNo
|
|
, HistSeqNo
|
|
, EventTime
|
|
, Enteredby
|
|
, EventDesc
|
|
, DowntimeCode
|
|
, LinkHistSeqNo
|
|
, TillTime
|
|
, TillEnteredTime
|
|
, TillEnteredBy
|
|
, CompletedFlag
|
|
, TotalTime
|
|
, DowntimePhaseIn
|
|
, OrderRef1
|
|
, OrderRef2
|
|
, WorkCenterNo
|
|
, ResourceId
|
|
, QtyPrd
|
|
, devicecode
|
|
, partno
|
|
, projectno
|
|
, TillDevicecode
|
|
, EventEnteredTime
|
|
, PartDesc
|
|
, OperationDescription
|
|
, WorkCenterCost
|
|
, WorkCenterDesc
|
|
from SFDC_TimeHist
|
|
where site = #{site}
|
|
and OrderNo = #{orderno}
|
|
and OrderRef2 = #{orderref2}
|
|
and OrderRef1 = #{orderref1}
|
|
and ItemNo = #{itemno}
|
|
and EventType = #{eventtype}
|
|
|
|
order by HistSeqNo desc
|
|
|
|
</select>
|
|
<select id="getTotalOrderTimeHist" resultType="com.alteams.modules.shoporder.entity.OrderTimeHistEntity">
|
|
|
|
SELECT site,
|
|
OrderNo,
|
|
OrderRef1,
|
|
OrderRef2,
|
|
ItemNo,
|
|
MIN(EventTime) EventTime,
|
|
MAX(TillTime) TillTime,
|
|
ISNULL(SUM(TotalTime), 0) TotalTime,
|
|
ISNULL(SUM(QtyPrd), 0) QtyPrd,
|
|
ISNULL(SUM(TotalTime / 60 * WorkCenterCost), 0) WorkCenterCost
|
|
FROM SFDC_TimeHist
|
|
WHERE site = #{site}
|
|
and OrderNo = #{orderno}
|
|
and OrderRef2 = #{orderref2}
|
|
and OrderRef1 = #{orderref1}
|
|
and ItemNo = #{itemno}
|
|
and EventType = #{eventtype}
|
|
GROUP BY site, OrderNo, OrderRef1, OrderRef2, ItemNo
|
|
|
|
</select>
|
|
<select id="getFirstOrderTimeHistInfo"
|
|
resultType="com.alteams.modules.shoporder.entity.OrderTimeHistEntity">
|
|
select top 1 Site
|
|
, OrderNo
|
|
, ItemNo
|
|
, SeqNo
|
|
, HistSeqNo
|
|
, EventTime
|
|
, Enteredby
|
|
, EventDesc
|
|
, DowntimeCode
|
|
, LinkHistSeqNo
|
|
, TillTime
|
|
, TillEnteredTime
|
|
, TillEnteredBy
|
|
, CompletedFlag
|
|
, TotalTime
|
|
, DowntimePhaseIn
|
|
, OrderRef1
|
|
, OrderRef2
|
|
, WorkCenterNo
|
|
, ResourceId
|
|
, QtyPrd
|
|
, devicecode
|
|
, partno
|
|
, projectno
|
|
, TillDevicecode
|
|
, EventEnteredTime
|
|
, PartDesc
|
|
, OperationDescription
|
|
, WorkCenterCost
|
|
, WorkCenterDesc
|
|
from SFDC_TimeHist
|
|
where site = #{site}
|
|
and OrderNo = #{orderno}
|
|
and OrderRef2 = #{orderref2}
|
|
and OrderRef1 = #{orderref1}
|
|
and EventType = #{eventtype}
|
|
order by HistSeqNo
|
|
</select>
|
|
<select id="workCenterTimeHist" resultType="com.alteams.modules.shoporder.vo.WorkCenterTimeVo">
|
|
SELECT
|
|
WorkCenterNo Work_Center_No,
|
|
EventTime Event_Time,
|
|
ISNULL( TillTime, GETDATE( ) ) Till_Time,
|
|
ROUND((CASE
|
|
WHEN TillTime IS NULL THEN DATEDIFF(MINUTE, EventTime,GETDATE( ) )
|
|
ELSE TotalTime
|
|
END)/60,1) Total_Time
|
|
FROM
|
|
SFDC_TimeHist
|
|
<where>
|
|
Site = #{contract} AND WorkCenterNo like 'C%'
|
|
<if test=" status != null and status!= '' ">
|
|
AND EventType != 'R'
|
|
</if>
|
|
<if test="workCenterNo != null and workCenterNo != ''">
|
|
AND WorkCenterNo = #{workCenterNo}
|
|
</if>
|
|
AND EventTime >= #{startDate} AND TillTime <![CDATA[ <= ]]> #{ startEndDate}
|
|
OR (ISNULL( TillTime, GETDATE( ) ) >= #{startDate} AND EventTime <![CDATA[ <= ]]> #{ startEndDate} AND
|
|
WorkCenterNo like 'C%'
|
|
<if test="workCenterNo != null and workCenterNo != ''">
|
|
AND WorkCenterNo = #{workCenterNo}
|
|
</if>
|
|
)
|
|
OR (TillTime >= #{ startEndDate} AND EventTime <![CDATA[ <= ]]> #{startDate} AND WorkCenterNo like 'C%'
|
|
<if test="workCenterNo != null and workCenterNo != ''">
|
|
AND WorkCenterNo = #{workCenterNo}
|
|
</if>
|
|
)
|
|
|
|
</where>
|
|
ORDER BY WorkCenterNo,EventTime
|
|
</select>
|
|
|
|
|
|
</mapper>
|