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.
 
 
 
 
 
 

1960 lines
86 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.gaotao.modules.schedule.mapper.ScheduleMapper">
<update id="closeOrOpenProduceOrder">
Update SOScheduledRouting
Set ClosedFlag=#{closedFlag}
, Closedby=#{username}
, ClosedDate=#{closedDate}
Where Site = #{site}
and OrderNo = #{orderNo}
and ItemNo = #{itemNo}
and SeqNo = #{seqNo}
</update>
<update id="pauseOrReopenProduceOrder">
Update SOScheduledRouting
Set ParkFlag=#{parkFlag}
Where Site = #{site}
and OrderNo = #{orderNo}
and ItemNo = #{itemNo}
and SeqNo = #{seqNo}
</update>
<update id="costRollUpProduceOrder">
Update ShopOrder
Set CostRollUpFlag= #{costRollUpFlag}
Where Site = #{site}
and OrderNo = #{orderNo}
</update>
<update id="manualProduceOrder">
Update ShopOrder
Set ManualFlag=#{manualFlag}
Where Site = #{site}
and OrderNo = #{orderNo}
</update>
<update id="repairSOFlagProduceOrder">
Update ShopOrder
Set RepairSOFlag=#{repairSOFlag}
Where Site = #{site}
and OrderNo = #{orderNo}
</update>
<!--查询加工中心机台的信息-->
<select id="getResourceLIst" parameterType="SearchScheduleData" resultType="ResourceOutData">
SELECT wcr.Site site, wcr.WorkCenterNo workCenterNo, wcr.ResourceID resourceId, wcr.ResourceDesc resourceDEsc,
wcr.Efficiency efficiency,
wcr.Utilization utilization, wcr.Active active, wcr.Remark Remark, wcr.CreatedDate createdDate, wcr.CalendarID
calendarId, wcr.VirturlFlag virturlFlag
FROM WorkCenterResource wcr
<where>
wcr.Site = site
<if test="workCenterNo != null and workCenterNo != ''">
AND wcr.WorkCenterNo= #{workCenterNo}
</if>
<if test="resourceId != null and resourceId != ''">
AND wcr.ResourceID = #{resourceId}
</if>
</where>
</select>
<!--查询机台+排产日期的休息信息-->
<select id="getResourceRestList" parameterType="SearchScheduleData" resultType="ShiftInfoData">
Select top 10 ScheduleDate shiftDate, CONVERT(Varchar(200), (Case when ExceptDuration1<![CDATA[ <> ]]>0 then
CONVERT(Varchar(10),Convert(float,ExceptTime1)) + '/' + CONVERT(Varchar(10),Convert(float,ExceptDuration1)) else
'' end)
+' ; '+
(Case when ExceptDuration2<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime2)) + '/' +
CONVERT(Varchar(10),Convert(float,ExceptDuration2)) else '' end)
+' ; '+
(Case when ExceptDuration3<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime3)) + '/' +
CONVERT(Varchar(10),Convert(float,ExceptDuration3)) else '' end)
+' ; '+
(Case when ExceptDuration4<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime4)) + '/' +
CONVERT(Varchar(10),Convert(float,ExceptDuration4)) else '' end)
+' ; '+
(Case when ExceptDuration5<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime5)) + '/' +
CONVERT(Varchar(10),Convert(float,ExceptDuration5)) else '' end)
+' ; '+
(Case when ExceptDuration6<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime6)) + '/' +
CONVERT(Varchar(10),Convert(float,ExceptDuration6)) else '' end)
) as shiftInfo from Calendar_Exception cde
<where>
AND cde.Site = #{site}
AND cde.CalendarID = #{calendarId}
AND cde.ScheduleDate <![CDATA[ >= ]]> #{scheduleDate}
</where>
</select>
<!--按照条件查询工单的数据-->
<select id="getShopOrderList" parameterType="SearchScheduleData" resultType="ShopOrderOutData">
Select T.Site site, T.OrderNo orderNo, T.ItemNo itemNo, T.OperationDesc itemDesc, T.PartNo partNo,
P.PartDescription partDesc, P.Spec spec,
D.LotSize lotSize, T.QtyReported qtyReported, D.NeedDate needDate, T.PreItemNo PreItemNo, S1.OperationDesc
PreItemDesc, S1.ScheduledFlag preScheduledFlag,
T.NextItemNo nextItemNo, S2.OperationDesc nextItemDesc, S2.ScheduledFlag nextScheduledFlag, D.CustomerID
customerId, P.ConfigurationTemplateID customerName,
D.EnterDate enterDate, dbo.Get_SOOpsScheduleAvailResource(T.Site,T.OrderNo,T.WorkCenterNo,T.ItemNo)
availResource, T.WorkCenterNo workCenterNo,
T.MachRunFactor machRunFactor, T.MachSetupTime machSetupTime, T.FactorUnit factorUnit, T.ScheduledFlag
scheduledFlag, D.RoutingRevNo routingRevNo,
T.QtyScheduled qtyScheduled,(round(T.QtyRequired,3) - Round(T.QtyScheduled,3)) qtyToSchedule,
Isnull(S1.QtyScheduled,0.0) qtyScheduledPreOps,
dbo.getScheduleToPlanTime(D.LotSize, T.MachSetupTime, T.MachRunFactor, T.FactorUnit, t.Efficiency)
scheduleToPlanTime,
D.OriSOOrderNo oriSOOrderNo, P.Remark custPartNo, 1*t.Efficiency efficiency, D.CostRollUpFlag costRollUpFlag,
isnull(S1.QtyApprove,0.0) qtyApprovedPreOps,
d.ManualFlag manualFlag, d.RepairSOFlag repairSOFlag
from SORouting as T
Left Join ShopOrder as D On T.Site=D.Site and T.OrderNo=D.OrderNo
Left Join Part as P On T.Site=P.Site and T.PartNo=P.PartNo
Left Join SORouting as S1 On T.Site=S1.Site and T.OrderNo=S1.OrderNo and T.PreItemNo=S1.ItemNo
Left Join SORouting as S2 On T.Site=S2.Site and T.OrderNo=S2.OrderNo and T.NextItemNo=S2.ItemNo
<where>
Round(T.QtyScheduled,3) <![CDATA[ < ]]> round(T.QtyRequired,3) and T.ClosedFlag = 'N'
<if test="username != null and username != ''">
and T.site in (Select Site from AccessSite where upper(UserID)=#{username})
</if>
and T.OrderNo<![CDATA[ <> ]]>'9999' and isnull(D.Status,'')<![CDATA[ <> ]]>'已取消' and isnull(D.Status,'')
<![CDATA[ <> ]]>'已计划'
and isnull(D.Status,'')<![CDATA[ <> ]]>'已关闭'
<if test="enterTime1 != null">
and D.EnterDate<![CDATA[ >= ]]> #{enterTime1}
</if>
<if test="enterTime2 != null">
and D.EnterDate-1<![CDATA[<]]> #{enterTime2}
</if>
<if test="needTime1 != null">
and D.NeedDate<![CDATA[ >= ]]>#{needTime1}
</if>
<if test="needTime2 != null">
and D.NeedDate<![CDATA[ <= ]]>#{needTime2}
</if>
<if test="site != null and site != ''">
AND T.Site like '%' + #{site} + '%'
</if>
<if test="partNo != null and partNo != ''">
AND T.PartNo like '%' + #{partNo} + '%'
</if>
AND Rtrim(T.WorkCenterNo) like '%' + #{workCenterNo} + '%'
<if test="scheduledFlag != null and scheduledFlag != ''">
AND Isnull(S1.ScheduledFlag, 'Y') = #{scheduledFlag}
</if>
<if test='preScheduledFlag != null and preScheduledFlag == "Y"'>
and Isnull(S1.ScheduledFlag,'Y') = 'Y'
</if>
AND dbo.Get_SOOpsScheduleAvailResource(T.Site,T.OrderNo,T.WorkCenterNo,T.ItemNo) like '%' + #{resourceId} +
'(%'
</where>
/*设置排序规则*/
<if test="sortField == null || sortField == ''">
Order by D.NeedDate
</if>
<if test="sortField != null and sortField == 'needDate'">
Order by D.NeedDate
</if>
<if test="sortField != null and sortField == 'orderNo'">
Order by T.OrderNo
</if>
<if test="sortField != null and sortField == 'partNo'">
Order by T.PartNo
</if>
</select>
<!--按照条件查询工单的数据-->
<select id="getOrderScheduleList" parameterType="SearchScheduleData" resultType="ScheduleData">
select
T.Site site,
T.OrderNo orderNo,
T.ItemNo itemNo,
S.OperationDesc itemDesc,
S.PartNo partNo,
P.PartDescription partDesc,
P.Spec spec,
T.QtyRequired qtyRequired,
T.QtyReported qtyReported,
(T.QtyRequired - T.QtyReported) as qtyToReport,
D.NeedDate needDate,
S.PreItemNo preItemNo,
S1.OperationDesc preItemDesc,
S1.ScheduledFlag preScheduledFlag,
S.NextItemNo nextItemNo,
S2.OperationDesc nextItemDesc,
S2.ScheduledFlag nextScheduledFlag,
D.CustomerID customerId,
dbo.Get_CustomerDesc (D.Site, D.CustomerID) customerName,
D.EnterDate enterDate,
dbo.Get_SOOpsScheduleAvailResource (
T.Site,
S.OrderNo,
T.S_WorkCenterNo,
T.ItemNo
) availResource,
T.S_WorkCenterNo workCenterNo,
S.MachRunFactor machRunFactor,
S.MachSetupTime machSetupTime,
S.FactorUnit factorUnit,
T.ClosedFlag closedFlag,
E.S_ScheduledSeqNo scheduledSeqNo,
T.PlanStartTime planStartTime,
T.PlanFinishTime planFinishTime,
T.S_ResourceID resourceId,
T.TimeRequired timeRequired,
T.SeqNo seqNo,
T.SelectedFlag selectedFlag,
T.SourceFlag sourceFlag,
S1.QtyScheduled qtyScheduledPreOps,
T.ParkFlag parkFlag,
T.TimeRequired_Original timeRequiredOriginal,
T.QtyRequired_Original qtyRequiredOriginal,
S1.PlanStartTime preOpsPlanStartTime,
S1.PlanFinishTime preOpsPlanFinishTime,
T.Remark remark,
D.OriSOOrderNo oriSOOrderNo,
P.Remark custPartNo,
T.Efficiency eficiency,
(Case when dbo.Get_SOOpsJobEstFinishDate(T.Site,T.OrderNo,T.ItemNo,T.SeqNo)<![CDATA[ <= ]]>T.PlanFinishTime then
0.0
else round((convert(float,dbo.Get_SOOpsJobEstFinishDate(T.Site,T.OrderNo,T.ItemNo,T.SeqNo)) -
convert(float,T.PlanFinishTime)) * 24,2) end) delayHours,
dbo.Get_SOSchedule_RecordIdentity(T.Site,T.PlanStartTime,T.PlanFinishTime,D.NeedDate,S1.PlanStartTime,S1.PlanFinishTime) mergeStatusCon,
T.mat_issueflag costRollUpFlag,
dbo.getCurrentScheduleColorStyle(T.QtyReported, T.QtyRequired, T.PlanFinishTime, T.ClosedFlag) colorStyle
from SOScheduledList as E,SOScheduledRouting as T
Left Join ShopOrder as D On T.Site=D.Site and T.OrderNo=D.OrderNo
,SORouting as S
Left Join Part as P On S.Site=P.Site and S.PartNo=P.PartNo
Left Join SORouting as S1 On S.Site=S1.Site and S.OrderNo=S1.OrderNo and S.PreItemNo=S1.ItemNo
Left Join SORouting as S2 On S.Site=S2.Site and S.OrderNo=S2.OrderNo and S.NextItemNo=S2.ItemNo
<where>
T.Site=S.Site and T.OrderNo=S.OrderNo and T.ItemNo=S.ItemNo and E.Site=T.Site and E.LinkedSeqNo=T.SeqNo
<if test="site != null and site != ''">
AND E.Site like '%' + #{site} + '%'
</if>
AND RTrim(T.S_WorkCenterNo) like #{workCenterNo} AND T.S_WorkCenterNo <![CDATA[<>]]> 'FQC'
AND RTrim(E.ResourceID) like '%' + #{resourceId} + '%'
</where>
Order by E.S_ScheduledSeqNo
</select>
<!--查询-待生产工单-->
<select id="getProduceScheduleData" parameterType="SearchScheduleData" resultType="ScheduleData">
<if test='exportFlag != null and exportFlag == "N"'>
Select TOP 200 T.Site site, T.OrderNo orderNo, T.ItemNo itemNo, D.OperationDesc itemDesc, D.PartNo partNo,
</if>
<if test='exportFlag != null and exportFlag == "Y"'>
Select T.Site site, T.OrderNo orderNo, T.ItemNo itemNo, D.OperationDesc itemDesc, D.PartNo partNo,
</if>
P.PartDescription partDesc,
P.Spec spec,
T.SeqNo seqNo,
T.QtyRequired qtyRequired,
T.QtyReported qtyReported,
(T.QtyRequired - T.QtyReported) as qtyToReport,
T.QtyApprove qtyApprove,
ROUND(T.TimeRequired, 3) timeRequired,
T.TimeReported timeReported,
T.PlanStartTime planStartTime,
T.PlanFinishTime planFinishTime,
T.BarcodeID barcodeId,
T.Remark remark,
T.Crewsize crewSize,
T.ClosedFlag closedFlag,
T.QtyScrapt qtyScrapt,
T.OutWorkFlag outWorkFlag,
T.S_ScheduledDate scheduledDate,
T.S_ResourceID resourceId,
dbo.getWorkCenterResourceDesc(T.Site, t.S_WorkCenterNo, T.S_ResourceID) resourceDesc,
T.serial_number serialNumber,
T.S_ShiftNo shiftNo,
D.MachSetupTime machSetupTime,
D.MachRunFactor machRunFactor,
D.FactorUnit factorUnit,
D.Efficiency efficiency,
D.NextItemNo nextItemNo,
dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.NextItemNo) nextItemDesc,
D.PreItemNo preItemNo,
dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.PreItemNo) preItemDesc,
SO.NeedDate needDate,
T.ParkFlag parkFlag,
dbo.Get_SOOpsPreResourceInfo(T.Site, T.OrderNo, T.ItemNo) preResourceInfo,
dbo.Get_SOOpsPreQtyFinished(T.Site, T.OrderNo, T.ItemNo) preQtyFinished,
P.ConfigurationTemplateID customerName,
P.Remark custPartNo,
t.S_WorkCenterNo workCenterNo,
dbo.Get_WorkCenterDesc(T.Site, T.S_WorkCenterNo) workCenterDesc,
T.QtyRequired_Original qtyRequiredOriginal,
SO.orderType,
T.ClosedBy closedBy,
T.ClosedDate closedDate,
T.mat_issueflag matIssueFlag,
T.plate_issueflag plateIssueFlag,
T.tool_issueflag toolIssueFlag
from SOScheduledRouting as T
Left Join SOScheduledList as E on E.Site=T.Site and E.LinkedSeqNo=T.SeqNo,
SORouting as D,Part as P,ShopOrder as SO
<where>
T.Site=D.Site and T.OrderNo=D.OrderNo and T.ItemNo=D.ItemNo and D.Site=P.Site and D.PartNo=P.PartNo
and T.site in (Select Site from AccessSite where upper(UserID)=#{username})
and T.Site=SO.Site and T.OrderNo=SO.OrderNo and T.OrderNo<![CDATA[ <> ]]>'9999'
<if test="site != null and site != ''">
AND T.Site like '%' + #{site} + '%'
</if>
<if test="planStartTime1 != null">
and T.PlanStartTime<![CDATA[ >= ]]> #{planStartTime1}
</if>
<if test="planStartTime2 != null">
and T.PlanStartTime<![CDATA[ <= ]]> #{planStartTime2}
</if>
<if test="resourceId != null and resourceId != ''">
AND T.S_ResourceID = #{resourceId}
</if>
<if test="orderNo != null and orderNo != ''">
AND T.OrderNo like '%' + #{orderNo} + '%'
</if>
<if test="seqNo != null and seqNo != ''">
AND T.SeqNo like '%' + #{seqNo} + '%'
</if>
<if test='closedFlag != null and closedFlag == "N"'>
and T.ClosedFlag = #{closedFlag}
</if>
</where>
Order by SO.bu_no, T.S_ResourceID, ISNULL(T.serial_number, 999999) asc
</select>
<!--查询操作员信息列表-->
<select id="getOperatorList" parameterType="OperatorOutData" resultType="com.gaotao.modules.shopOrder.entity.OperatorData">
SELECT
op.Site site,
op.OperatorID operatorId,
op.OperatorName operatorName,
op.Active status
FROM Operator op
<where>
op.Site IN (SELECT Site FROM AccessSite WHERE UPPER(UserID) = #{username})
<if test="site != null and site != ''">
AND op.Site = #{site}
</if>
<if test="operatorId != null and operatorId != ''">
AND op.OperatorID like '%' + #{operatorId} + '%'
</if>
<if test="operatorName != null and operatorName != ''">
AND op.OperatorName like '%' + #{operatorName} + '%'
</if>
<if test="status != null and status != ''">
AND op.Active = #{status}
</if>
</where>
</select>
<!--查询操作员信息-->
<select id="getOperatorData" parameterType="OperatorOutData" resultType="OperatorOutData">
SELECT op.Site site, op.OperatorID operatorId, op.OperatorName operatorName, op.Active status
FROM Operator op
<where>
op.Site IN (SELECT Site FROM AccessSite WHERE UPPER(UserID) = #{username})
<if test="site != null and site != ''">
AND op.Site = #{site}
</if>
<if test="operatorId != null and operatorId != ''">
AND op.OperatorID = #{operatorId}
</if>
<if test="operatorName != null and operatorName != ''">
AND op.OperatorName = #{operatorName}
</if>
</where>
</select>
<!--获取操作员列表-->
<select id="getOperatorList2" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
id,
site,
order_no AS orderNo,
item_no AS itemNo,
seq_no AS seqNo,
roll_no AS rollNo,
created_by AS createdBy,
created_date AS createdDate,
operator,
(SELECT OperatorName FROM Operator WHERE OperatorID = sol.operator AND Site = sol.site) AS operatorName,
is_on_duty AS isOnDuty,
on_duty_time AS onDutyTime,
off_duty_time AS offDutyTime,
batch_no AS batchNo,
remark
FROM sfdc_operator_list sol
<where>
<if test="site != null and site != ''">
AND site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND order_no = #{orderNo}
</if>
<if test="itemNo != null">
AND item_no = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND seq_no = #{seqNo}
</if>
<if test="isOnDuty != null and isOnDuty != ''">
AND is_on_duty = #{isOnDuty}
</if>
</where>
ORDER BY on_duty_time DESC
</select>
<!--添加操作员上岗-->
<insert id="addOperatorOnDuty" parameterType="java.util.Map">
INSERT INTO sfdc_operator_list (
site,
order_no,
item_no,
seq_no,
roll_no,
created_by,
created_date,
operator,
is_on_duty,
on_duty_time,
batch_no,
remark
) VALUES (
#{site},
#{orderNo},
#{itemNo},
#{seqNo},
#{rollNo},
#{createdBy},
#{createdDate},
#{operator},
#{isOnDuty},
#{onDutyTime},
#{batchNo},
#{remark}
)
</insert>
<!--操作员下岗-->
<update id="removeOperatorOnDuty" parameterType="java.util.Map">
UPDATE sfdc_operator_list
SET is_on_duty = #{isOnDuty},
off_duty_time = #{offDutyTime}
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="site != null and site != ''">
AND site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND order_no = #{orderNo}
</if>
<if test="itemNo != null">
AND item_no = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND seq_no = #{seqNo}
</if>
<if test="operator != null and operator != ''">
AND operator = #{operator}
</if>
</where>
</update>
<!--删除操作员数据-->
<delete id="deleteOperatorData" parameterType="java.util.Map">
DELETE FROM sfdc_operator_list
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="site != null and site != ''">
AND site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND order_no = #{orderNo}
</if>
<if test="itemNo != null">
AND item_no = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND seq_no = #{seqNo}
</if>
<if test="operator != null and operator != ''">
AND operator = #{operator}
</if>
</where>
</delete>
<!--更新操作员时间-->
<update id="updateOperatorTime" parameterType="java.util.Map">
UPDATE sfdc_operator_list
SET
on_duty_time = #{onDutyTime},
off_duty_time = #{offDutyTime}
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="site != null and site != ''">
AND site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND order_no = #{orderNo}
</if>
<if test="itemNo != null">
AND item_no = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND seq_no = #{seqNo}
</if>
<if test="operator != null and operator != ''">
AND operator = #{operator}
</if>
</where>
</update>
<!--更新派工单MRB信息-->
<update id="updateScheduleMrbInfo" parameterType="java.util.Map">
UPDATE SOScheduledRouting
SET
mrb = #{mrb},
mrb_inspection_report = #{mrbInspectionReport},
mrb_remark = #{mrbRemark}
WHERE
Site = #{site}
AND OrderNo = #{orderNo}
AND ItemNo = #{itemNo}
AND SeqNo = #{seqNo}
</update>
<!--查询派工单MRB信息-->
<select id="getScheduleMrbInfo" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
mrb,
mrb_inspection_report AS mrbInspectionReport,
mrb_remark AS mrbRemark
FROM SOScheduledRouting
WHERE
Site = #{site}
AND OrderNo = #{orderNo}
AND ItemNo = #{itemNo}
AND SeqNo = #{seqNo}
</select>
<!--只更新操作员上岗时间-->
<update id="updateOnDutyTime" parameterType="java.util.Map">
UPDATE sfdc_operator_list
SET on_duty_time = #{onDutyTime}
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="site != null and site != ''">
AND site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND order_no = #{orderNo}
</if>
<if test="itemNo != null">
AND item_no = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND seq_no = #{seqNo}
</if>
<if test="operator != null and operator != ''">
AND operator = #{operator}
</if>
</where>
</update>
<!--按照派工单号查询派工单的数据-->
<select id="getScheduleDataBySeqNo" parameterType="java.lang.String" resultType="ScheduleData">
Select
T.Site site,
T.OrderNo orderNo,
T.ItemNo itemNo,
D.OperationDesc itemDesc,
D.PartNo partNo,
P.PartDescription partDesc,
P.Spec spec,
T.SeqNo seqNo,
T.QtyRequired qtyRequired,
T.QtyReported qtyReported,
T.QtyApprove qtyApprove,
ROUND(T.TimeRequired, 3) timeRequired,
T.TimeReported timeReported,
T.PlanStartTime planStartTime,
T.PlanFinishTime planFinishTime,
T.BarcodeID as barcodeId,
T.Remark remark,
T.Crewsize crewSize,
T.ClosedFlag closedFlag,
T.QtyScrapt qtyScrapt,
T.OutWorkFlag outWorkFlag,
T.S_ScheduledDate scheduledDate,
t.S_WorkCenterNo workCenterNo,
T.S_ResourceID resourceId,
dbo.getWorkCenterResourceDesc(T.Site, t.S_WorkCenterNo, T.S_ResourceID) resourceDesc,
E.S_ScheduledSeqNo scheduledSeqNo,
T.S_ShiftNo shiftNo,
D.MachSetupTime machSetupTime,
D.MachRunFactor machRunFactor,
D.FactorUnit factorUnit,
D.Efficiency efficiency,
D.NextItemNo nextItemNo,
dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.NextItemNo) nextItemDesc,
D.PreItemNo preItemNo,
dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.PreItemNo) preItemDesc,
SO.NeedDate needDate,
T.ParkFlag parkFlag,
P.ConfigurationTemplateID customerName,
P.Remark custPartNo,
t.S_WorkCenterNo workCenterNo,
dbo.Get_WorkCenterDesc(T.Site, T.S_WorkCenterNo) workCenterDesc,
T.QtyRequired_Original qtyRequiredOriginal,
T.ClosedBy closedBy,
T.ClosedDate closedDate,
SO.CostRollUpFlag costRollUpFlag,
SO.RepairSOFlag repairSOFlag,
SO.ManualFlag manualFlag,
T.row_count,
T.roll_count,
T.carrier_no
from SOScheduledRouting as T
Left Join SOScheduledList as E on E.Site = T.Site and E.LinkedSeqNo = T.SeqNo,
SORouting as D, Part as P, ShopOrder as SO
<where>
T.Site=D.Site and T.OrderNo=D.OrderNo and T.ItemNo=D.ItemNo and D.Site=P.Site and D.PartNo=P.PartNo
and T.Site=SO.Site and T.OrderNo=SO.OrderNo and T.OrderNo<![CDATA[ <> ]]>'9999'
AND T.SeqNo = #{seqNo}
</where>
</select>
<!--获取当前的上机卷信息-->
<select id="getCurrentRollOpsBySeqNo" parameterType="BaseRollData" resultType="SfdcRollOpsData">
SELECT TOP 1 sro.Site site, sro.OrderNo orderNo, sro.RollNo rollNo, sro.ItemNo itemNo, sro.SeqNo seqNo,
sro.ScanedBy scanedBy, sro.ScanedDate scanedDate,
sro.StartProdFlag startProdFlag, sro.FirstSetupBy firstSetupBy, sro.FirstSetupDate firstSetupDate,
sro.LatestSetupBy latestSetupBy,
sro.LatestSetupDate latestSetupDate, sro.FirstEndSetupBy firstEndSetupBy, sro.FirstEndSetupDate
firstEndSetupDate, sro.LatestEndSetupBy latestEndSetupBy,
sro.LatestEndSetupDate latestEndSetupDate, sro.FirstProdBy firstProdBy, sro.FirstProdDate firstProdDate,
sro.LatestProdBy latestProdBy,
sro.LatestProdDate latestProdDate, sro.FirstEndProdBy firstEndProdBy, sro.FirstEndProdDate firstEndProdDate,
sro.LatestEndProdBy latestEndProdBy,
sro.LatestEndProdDate latestEndProdDate, sro.FinishedDate finishedDate, sro.FinishedBy finishedBy,
sro.FinishedFlag finishedFlag, sro.PauseFlag pauseFlag,
sro.Remark remark, sro.QtyReported qtyReported, sro.QtyDefected qtyDefected, sro.ReportedFlag reportedFlag
FROM SFDC_RollOps sro
<where>
sro.Site = #{site} AND sro.SeqNo = #{seqNo}
AND sro.FinishedFlag <![CDATA[<>]]> 'Y' AND sro.PauseFlag <![CDATA[<>]]> 'Y'
</where>
</select>
<!--查询派工单的时间记录信息-->
<select id="getSfdcTimeByCon" parameterType="SearchScheduleData" resultType="SfdcTimeData">
SELECT sth.Site site, sth.OrderNo orderNo,sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
sth.RollNo rollNo,
sth.EventTime eventTime, sth.Enteredby enteredby, sth.EventDesc eventDesc, sth.DowntimeCode downtimeCode,
sth.TillTime tillTime,
sth.TillEnteredTime tillEnteredTime, sth.TillEnteredBy tillEnteredBy, sth.CompletedFlag completedFlag,
ROUND(sth.TotalTime, 3) totalTime,
sth.DowntimePhaseIn downtimePhaseIn
FROM SFDC_TimeHist sth
<where>
<if test="site != null and site != ''">
AND sth.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sth.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sth.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sth.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sth.RollNo = #{rollNo}
</if>
</where>
ORDER BY sth.HistSeqNo DESC
</select>
<!--查询工单工序的刀具信息-->
<select id="getOrderToolByCon" parameterType="SearchScheduleData" resultType="ToolInstanceData">
SELECT st.Site site, st.OrderNo orderNo, st.ItemNo itemNo, st.ToolID toolId, th.ToolDescription toolDesc,
th.Spec spec,
st.ToolQty toolQty, th.UMID umid, th.FamilyID familyId, dbo.Get_PartFamilyDesc (st.Site, th.FamilyID)
familyName,
th.Active active, st.Remark remark, st.CreateDate createdDate, st.CreatedBy createdBy
FROM SOTool st
LEFT JOIN ToolHeader th ON st.Site = th.Site AND st.ToolID = th.ToolID
<where>
st.Site = th.Site AND st.ToolID = th.ToolID
<if test="site != null and site != ''">
AND st.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND st.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND st.ItemNo = #{itemNo}
</if>
</where>
ORDER BY st.ItemNo
</select>
<!--查询派工单的工具记录信息-->
<select id="getSfdcToolByCon" parameterType="SearchScheduleData" resultType="SfdcToolData">
SELECT sth.Site site, sth.OrderNo orderNo, sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
sth.RollNo rollNo,
sth.ReportDate reportedDate, sth.Reportedby reportedby, sth.ToolInstanceID toolInstanceID, sth.StartDate
startDate,
sth.FinishDate finishedDate, sth.FinishFlag finishedFlag, sth.Remark remark, sth.StartFromRollNo
startFromRollNo, sth.FinishQty finishQty
FROM SFDC_ToolingHist sth
<where>
<if test="site != null and site != ''">
AND sth.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sth.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sth.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sth.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sth.RollNo = #{rollNo}
</if>
</where>
ORDER BY sth.HistSeqNo DESC
</select>
<!--获取关联的客户ID-->
<select id="getReferenceCustomerId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT ISNULL(ReferenceCustomerID, '') referenceCustomerID
FROM Site
WHERE SiteID = #{site}
</select>
<!--查询工单的bom信息-->
<select id="getOrderBomByCon" parameterType="SearchScheduleData" resultType="OrderBomData">
SELECT vss.Site site, vss.OrderNo orderNo, vss.ItemNo itemNo, vss.ComponentPartNo componentPartNo,
/*动态sql语句*/
<!-- <if test="referenceCustomerId != null and referenceCustomerId != ''">-->
<!-- <choose>-->
<!-- <when test="referenceCustomerId != null and referenceCustomerId != ''">-->
<!-- ISNULL(rpi.ReferencePartDesc, P.PartDescription) partDesc, '' partSpec,-->
<!-- </when>-->
<!-- <otherwise>-->
P.PartDescription partDesc, P.Spec partSpec,
<!-- </otherwise>-->
<!-- </choose>-->
<!-- </if>-->
P.UMid partUm, vss.QtyAssembly qtyAssembly, vss.QtyFixedScrapt qtyFixedScrapt, vss.ScraptFactor scraptFactor,
vss.Remark remark,
vss.QtyRequired qtyRequired, vss.QtyIssue qtyIssue, vss.IssueDate issueDate, vss.QtyReserved qtyReserved,
vss.MatGroup matGroup, vss.RMType_DB rmTypeDb
FROM dbo.view_SAP_SOBOM vss
/*动态sql语句*/
<!-- <if test="referenceCustomerId != null and referenceCustomerId != ''">-->
<!-- LEFT JOIN ReferencePartInfo rpi ON vss.Site = rpi.Site AND vss.ComponentPartNo = rpi.PartNo AND-->
<!-- rpi.CustomerID = #{referenceCustomerId}-->
<!-- AND (rpi.FGPartNo = #{partNo} OR rpi.FGPartNo = '全部')-->
<!-- </if>-->
LEFT JOIN Part P ON vss.Site = P.Site AND vss.ComponentPartNo = P.PartNo
<where>
vss.Site = P.Site AND vss.ComponentPartNo = P.PartNo
<if test="site != null and site != ''">
AND vss.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND vss.OrderNo = #{orderNo}
</if>
</where>
ORDER BY vss.ItemNo ASC
</select>
<!--查询派工单时的材料记录信息-->
<select id="getSfdcMaterialByCon" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
SELECT
smh.Site site,
smh.OrderNo orderNo,
smh.ItemNo itemNo,
smh.SeqNo seqNo,
smh.HistSeqNo histSeqNo,
smh.RollNo rollNo,
smh.ReportDate reportDate,
smh.Reportedby reportedby,
smh.RMRollNo rmRollNo,
smh.PartNo partNo,
smh.Remark remark,
smh.StartDate startDate,
smh.FinishDate finishedDate,
smh.FinishFlag finishedFlag,
smh.HistType histType,
smh.TransGeneratedFlag transGeneratedFlag,
smh.OriginalRMRollNo originalRMRollNo,
smh.UnissueFlag unissueFlag,
ROUND(smh.TransQty, 3) transQty,
ROUND(smh.NetIssueQty, 3) netIssueQty,
smh.OriginalHistSeqNo originalHistSeqNo,
smh.StartFromRollNo startFromRollNo,
smh.KeyRMFlag keyRMFlag,
smh.SAPBOMItemNo sAPBOMItemNo,
smh.Setupflag setupflag
FROM SFDC_MaterialHist smh
<where>
<if test="site != null and site != ''">
AND smh.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND smh.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND smh.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND smh.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND smh.RollNo = #{rollNo}
</if>
<if test="finishedFlag != null and finishedFlag != ''">
AND smh.FinishFlag = #{finishedFlag}
</if>
<if test="keyRMFlag != null and keyRMFlag != ''">
AND smh.KeyRMFlag = #{keyRMFlag}
</if>
<if test="histType != null and histType != ''">
AND smh.HistType = #{histType}
</if>
<if test="bomItemNo != null and bomItemNo > -1">
AND smh.SAPBOMItemNo = #{bomItemNo}
</if>
<if test="histSeqNo != null and histSeqNo > 0">
AND smh.HistSeqNo = #{histSeqNo}
</if>
</where>
ORDER BY smh.HistSeqNo DESC
</select>
<!--按照条件查询上机卷记录-->
<select id="getSfdcRollOpsByCon" parameterType="SearchScheduleData" resultType="SfdcRollOpsData">
SELECT sro.Site site, sro.OrderNo orderNo, sro.RollNo rollNo, sro.ItemNo itemNo, sro.SeqNo seqNo, sro.ScanedBy
scanedBy, sro.ScanedDate scanedDate,
sro.StartProdFlag startProdFlag, sro.FirstSetupBy firstSetupBy, sro.FirstSetupDate firstSetupDate,
sro.LatestSetupBy latestSetupBy,
sro.LatestSetupDate latestSetupDate, sro.FirstEndSetupBy firstEndSetupBy, sro.FirstEndSetupDate
firstEndSetupDate, sro.LatestEndSetupBy latestEndSetupBy,
sro.LatestEndSetupDate latestEndSetupDate, sro.FirstProdBy firstProdBy, sro.FirstProdDate firstProdDate,
sro.LatestProdBy latestProdBy,
sro.LatestProdDate latestProdDate, sro.FirstEndProdBy firstEndProdBy, sro.FirstEndProdDate firstEndProdDate,
sro.LatestEndProdBy latestEndProdBy,
sro.LatestEndProdDate latestEndProdDate, sro.FinishedDate finishedDate, sro.FinishedBy finishedBy,
sro.FinishedFlag finishedFlag, sro.PauseFlag pauseFlag,
sro.Remark remark, sro.QtyReported qtyReported, sro.QtyDefected qtyDefected, sro.ReportedFlag reportedFlag
FROM SFDC_RollOps sro
<where>
<if test="site != null and site != ''">
AND sro.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sro.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sro.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sro.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sro.RollNo = #{rollNo}
</if>
</where>
ORDER BY sro.RollNo DESC
</select>
<!--查询派工单的不良信息记录-->
<select id="getSfdcDefectByCon" parameterType="SearchScheduleData" resultType="SfdcDefectData">
SELECT sdh.Site site, sdh.OrderNo orderNo, sdh.ItemNo itemNo, sdh.SeqNo seqNo, sdh.HistSeqNo histSeqNo,
sdh.RollNo rollNo,
sdh.ReportDate reportedDate, sdh.Reportedby reportedBy, sdh.DefectCode defectCode, sdh.DefectQty defectQty,
sdh.Remark remark,
(SELECT idc.DefectDesc FROM InspectionDefectCode idc WHERE idc.Site = sdh.Site AND idc.DefectCode =
sdh.DefectCode) defectDesc
FROM SFDC_DefectHist sdh
<where>
<if test="site != null and site != ''">
AND sdh.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sdh.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sdh.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sdh.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sdh.RollNo = #{rollNo}
</if>
</where>
ORDER BY sdh.HistSeqNo DESC
</select>
<!--查询派工单的下机卷信息-->
<select id="getSfdcRollByCon" parameterType="SearchScheduleData" resultType="SfdcRollData">
SELECT sfr.Site site, sfr.OrderNo orderNo, sfr.RollNo rollNo, sfr.CreatedDate createdDate, sfr.Createdby
createdby, sfr.CurrentOpsItemNo currentOpsItemNo,
sfr.LastFinishedOpsItemNo lastFinishedOpsItemNo, sfr.FinishedDate finishedDate, sfr.FinishedFlag finishedFlag,
sfr.OnLineFlag onLineFlag,
sfr.PauseFlag pauseFlag, sfr.OriRollNo oriRollNo, sfr.StartOpsItemNo startOpsItemNo, sfr.RollType rollType,
sfr.CreatedOpsItemNo createdOpsItemNo,
sfr.CreatedOpsSeqNo createdOpsSeqNo, sfr.RollQty rollQty, sfr.FirstLevelRollNo firstLevelRollNo,
sfr.VirtualRollFlag virtualRollFlag
FROM SFDC_Rolls sfr
<where>
<if test="site != null and site != ''">
AND sfr.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfr.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfr.CreatedOpsItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfr.CreatedOpsSeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfr.RollNo = #{rollNo}
</if>
</where>
ORDER BY sfr.RollNo
</select>
<!--查询报工数据-->
<select id="getSfdcDataByCon" parameterType="SearchScheduleData" resultType="SfdcData">
SELECT SUM (ApproveQty) approveQty, SUM (ReportQty - ApproveQty) defectQty, SUM (ReportedManfTime)
reportedManfTime,
SUM (Downtime) downtime
FROM SFDC
<where>
<if test="site != null and site != ''">
AND Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND AssJobSeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND RollNo = #{rollNo}
</if>
</where>
</select>
<!--查询sfdc_roll表的数据-->
<select id="getSfdcRollReportedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
SELECT SUM(RollQty) reportedQty FROM SFDC_Rolls sfr
<where>
<if test="site != null and site != ''">
AND sfr.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfr.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfr.CreatedOpsItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfr.CreatedOpsSeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfr.OriRollNo = #{rollNo}
</if>
<choose>
<when test='switchKey != null and switchKey == "V"'>
AND sfr.VirtualRollFlag<![CDATA[<>]]>'Y'
</when>
<when test='switchKey != null and switchKey == "VC"'>
AND NOT(sfr.VirtualRollFlag='N' AND sfr.CombineFlag='Y')
</when>
</choose>
AND sfr.RollType_DB<![CDATA[<>]]>'C'
</where>
</select>
<!--统计是否报工过-->
<select id="countSfdcRollByRollNo" parameterType="SearchScheduleData" resultType="java.lang.Integer">
SELECT COUNT(1) FROM SFDC_Rolls sfr
<where>
<if test="site != null and site != ''">
AND sfr.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfr.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfr.CreatedOpsItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfr.CreatedOpsSeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfr.OriRollNo = #{rollNo}
</if>
AND sfr.RollType_DB<![CDATA[<>]]>'C'
</where>
</select>
<!--查询sfdcdefect的数据-->
<select id="getSfdcDefectDefectedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
SELECT SUM(sfd.DefectQty) defectQty FROM SFDC_DefectHist sfd
<where>
<if test="site != null and site != ''">
AND sfd.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfd.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfd.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfd.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfd.RollNo = #{rollNo}
</if>
</where>
</select>
<!--查询sfdc_time_hist的数据-->
<select id="countSfdcTimeQty" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT Round(SUM(CASE WHEN EventType='P' AND sfd.EventDesc='开始调机'
THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
ELSE 0.0 END), 2) totalSetupTime
, Round(SUM(CASE WHEN EventType='D' AND sfd.DowntimePhaseIn='调机'
THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
ELSE 0.0 END), 2) totalDowntimeTimeSetup
, Round(SUM(CASE WHEN EventType='P' AND sfd.EventDesc='开始生产'
THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
ELSE 0.0 END), 2) totalProdTime
, Round(SUM(CASE WHEN EventType='D' AND sfd.DowntimePhaseIn='生产'
THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
ELSE 0.0 END), 2) totalDowntimeTimeProd
,SUM(CASE WHEN CompletedFlag='N' THEN 1.0 ELSE 0.0 END) unCloseLeft
FROM SFDC_TimeHist sfd
<where>
<if test="site != null and site != ''">
AND sfd.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfd.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfd.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfd.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfd.RollNo = #{rollNo}
</if>
</where>
</select>
<!--查询sfdc_time_hist的数据-->
<select id="getSfdcTimeMaxAndMinTime" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT MIN(sfd.EventTime) eventTime, COUNT(1) sl, ROUND(SUM(TotalTime), 2) totalTime,
MAX((CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()END)) tillTime
FROM SFDC_TimeHist sfd
<where>
<if test="site != null and site != ''">
AND sfd.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfd.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfd.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfd.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfd.RollNo = #{rollNo}
</if>
AND sfd.EventType='P'
</where>
</select>
<!--查询sfdc_rollops表的数据-->
<select id="getSfdcRollOpsReportedQty" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT sfo.QtyReported approvedQty, ISNULL((SELECT SUM(DefectQty) FROM SFDC_DefectHist sfd
WHERE sfo.Site = sfd.Site AND sfo.OrderNo = sfd.OrderNo AND sfo.ItemNo = sfd.ItemNo AND sfo.SeqNo = sfd.SeqNo
AND sfo.RollNo = sfd.RollNo), 0) defectedQty
FROM SFDC_RollOps sfo
<where>
<if test="site != null and site != ''">
AND sfo.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfo.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfo.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfo.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfo.RollNo = #{rollNo}
</if>
</where>
</select>
<!--查询派工单的班次信息数据-->
<select id="getScheduleShiftData" parameterType="SearchScheduleData" resultType="java.util.HashMap">
Select WR.ResourceID resourceId,
CE.ScheduleDate scheduledDate,
CES.ShiftNo shiftNo,
CES.ShiftDesc shiftDesc,
(CONVERT(Decimal(20, 6), CE.ScheduleDate) + CONVERT(Decimal(20, 6), CES.StartTime / 24.0)) startTime,
(CONVERT(Decimal(20, 6), CE.ScheduleDate) + CONVERT(Decimal(20, 6), CES.EndTime / 24.0) +
(case when CES.EndTime <![CDATA[<]]> CES.StartTime then 1.0 else 0.0 end)) endTime,
(CONVERT(Decimal(20, 6), Convert(datetime, #{currentTime}))) curTime
from WorkCenterResource as WR
, Calendar_Exception as CE
, Calendar_Exception_Shift CES
where WR.Site = CE.Site
and WR.CalendarID = CE.CalendarID
and CE.Site = CES.Site
and CE.CalendarID = CES.CalendarID
and CE.ScheduleDate = CES.ScheduleDate
and WR.Site = '1'
and WR.ResourceID = #{resourceId}
and CONVERT(Decimal(20, 6), CE.ScheduleDate)<![CDATA[ >=]]>
Convert(Decimal(20, 6), Convert(datetime, #{currentDate})) - 1
and CONVERT(Decimal(20, 6), CE.ScheduleDate)<![CDATA[ <=]]>
Convert(Decimal(20, 6), Convert(datetime, #{currentDate})) + 1
Order by CE.ScheduleDate, CES.StartTime
</select>
<!--查询sfdc的时间数据-->
<select id="getSfdcTimeData" parameterType="SearchScheduleData" resultType="java.util.Map">
SELECT MAX(finishtime) finishTime, SUM(ReportedSetupTime) reportedSetupTime, SUM(ReportedManfTime)
reportedManfTime,
SUM(Downtime) downTime, SUM(ReportedSetupDowntime) reportedSetupDowntime, SUM(ReportedManfDowntime)
reportedManfDowntime
FROM SFDC
<where>
<if test="site != null and site != ''">
AND Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND ItemNo = #{itemNo}
</if>
AND AssJobSeqNo = #{seqNo} AND RollNo = #{rollNo} AND InAdvanceflag='Y'
</where>
</select>
<select id="getSfdcMaterialByRollNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
SELECT smh.Site site, smh.OrderNo orderNo, smh.ItemNo itemNo, smh.SeqNo seqNo, smh.HistSeqNo histSeqNo,
smh.RollNo rollNo, smh.ReportDate reportDate,
smh.Reportedby reportedby, smh.RMRollNo rmRollNo, smh.PartNo partNo, smh.Remark remark, smh.StartDate startDate,
smh.FinishDate finishedDate,
smh.FinishFlag finishedFlag, smh.HistType histType, smh.TransGeneratedFlag transGeneratedFlag,
smh.OriginalRMRollNo originalRMRollNo,
smh.UnissueFlag unissueFlag, ROUND(smh.TransQty, 3) transQty, ROUND(smh.NetIssueQty, 3) netIssueQty,
smh.OriginalHistSeqNo originalHistSeqNo,
smh.StartFromRollNo startFromRollNo, smh.KeyRMFlag keyRMFlag, smh.SAPBOMItemNo sAPBOMItemNo, smh.Setupflag
setupflag
FROM SFDC_MaterialHist smh
<where>
<if test="site != null and site != ''">
AND smh.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND smh.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND smh.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND smh.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND smh.RollNo = #{rollNo}
</if>
<if test="finishedFlag != null and finishedFlag != ''">
AND smh.FinishFlag = #{finishedFlag}
</if>
<if test="keyRMFlag != null and keyRMFlag != ''">
AND smh.KeyRMFlag = #{keyRMFlag}
</if>
<if test="histType != null and histType != ''">
AND smh.HistType = #{histType}
</if>
</where>
ORDER BY smh.HistSeqNo DESC
</select>
<!--检查派工单是否关闭-->
<select id="checkScheduleStatus" parameterType="SearchScheduleData" resultType="java.lang.Integer">
SELECT COUNT(1) FROM SOScheduledRouting ssr
<where>
<if test="site != null and site != ''">
AND ssr.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND ssr.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND ssr.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND ssr.SeqNo = #{seqNo}
</if>
<if test="closedFlag != null and closedFlag != ''">
AND ssr.ClosedFlag = #{closedFlag}
</if>
</where>
</select>
<!--获取rollId和normalRollId-->
<select id="getRollIdAndNormalRollIdByCon" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT MAX(RollID) rollId, MAX(NormalRollID) normalRollId FROM SFDC_Rolls ssr
<where>
<if test="site != null and site != ''">
AND ssr.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND ssr.OrderNo = #{orderNo}
</if>
</where>
</select>
<!--插入sfdcRolls的数据-->
<insert id="insertSfdcRolls" parameterType="SfdcRollData">
INSERT INTO SFDC_Rolls(Site, OrderNo, RollID, RollNo, CreatedDate, Createdby, CreatedOpsItemNo, CreatedOpsSeqNo,
CurrentOpsItemNo, LastFinishedOpsItemNo, FinishedDate,
FinishedFlag, OnLineFlag, PauseFlag, OriRollNo, Remark, StartOpsItemNo, RollType,
RollType_DB, RollQty, FirstLevelRollNo, FGRollFlag, FGRollID,
NormalRollID, CombineFlag, VirtualRollFlag, VirtualLinkRollNo, CQCPassFlag,
CQCInspectedFlag, CQCNeedInspectFlag)
VALUES (#{site}, #{orderNo}, #{rollId}, #{rollNo}, #{createdDate}, #{createdBy}, #{createdOpsItemNo},
#{createdOpsSeqNo}, #{currentOpsItemNo}, #{lastFinishedOpsItemNo}, #{finishedDate},
#{finishedFlag}, #{onLineFlag}, #{pauseFlag}, #{oriRollNo}, #{remark}, #{startOpsItemNo}, #{rollType},
#{rollTypeDb}, #{rollQty}, #{firstLevelRollNo}, #{fgRollFlag}, #{fgRollId},
#{normalRollId}, #{combineFlag}, #{virtualRollFlag}, #{virtualLinkRollNo}, #{cqcPassFlag},
#{cqcInspectedFlag}, #{cqcNeedInspectFlag})
</insert>
<!--插入sfdcRollOps的数据-->
<insert id="insertSfdcRollOps" parameterType="SfdcRollData">
INSERT INTO SFDC_RollOps(Site, OrderNo, RollNo, ItemNo, SeqNo, StartProdFlag, FinishedFlag, PauseFlag,
ScanedBy, ScanedDate, Remark, QtyReported, QtyDefected, ReportedFlag)
VALUES (#{site}, #{orderNo}, #{rollNo}, #{itemNo}, #{seqNo}, #{startProdFlag}, #{finishedFlag}, #{pauseFlag},
#{scanedBy}, #{scanedDate}, #{remark}, #{qtyReported}, #{qtyDefected}, #{reportedFlag})
</insert>
<!--根据条件或者材料卷数据-->
<select id="getCRollInfoByRollNo" parameterType="SearchScheduleData" resultType="CRollInfoOutData">
SELECT cri.rollno rollNo,
cri.partno partNo,
part.PartDescription partDesc,
cri.rolltype rollType,
cri.rolltype_db rollTypeDb,
status status,
cri.status_db statusDb,
cri.rollqty rollQty,
cri.site,
cri.SourceType orderRefType,
cri.orderref1 orderRef1,
cri.orderref2 orderRef2,
cri.orderref3 orderRef3,
cri.frozenflag frozenFlag
FROM C_RollInfo cri
LEFT JOIN Part part ON part.Site = cri.site AND part.PartNo = cri.partno
WHERE cri.site = #{site}
AND cri.rollno = #{rmRollNo}
</select>
<!--根据条件或者材料卷数据-->
<select id="getInventoryStockByRollNo" parameterType="SearchScheduleData" resultType="CRollInfoOutData">
SELECT cri.roll_no rollNo,
cri.part_no partNo,
part.PartDescription partDesc,
'合格卷' rollType,
'0' rollTypeDb,
status status,
cri.status_tb statusDb,
cri.qty_on_hand rollQty,
cri.site,
cri.orderref0 orderRefType,
cri.orderref1 orderRef1,
cri.orderref2 orderRef2,
cri.orderref3 orderRef3,
case when cri.status='冻结' then 'Y' else 'N' end frozenFlag
FROM inventory_stock cri
LEFT JOIN Part part ON part.Site = cri.site AND part.PartNo = cri.part_no
WHERE cri.site = #{site}
AND cri.roll_no = #{rmRollNo}
</select>
<!--根据工单和物料自动获取bom行数据-->
<select id="getBomItemNosByPartNo" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT Site site,
OrderNo orderNo,
CONVERT(INT, ItemNo) itemNo,
ComponentPartNo partNo,
QtyAssembly qtyAssembly,
QtyFixedScrapt qtyFixedScrapt,
ScraptFactor scraptFactor,
Remark remark,
QtyRequired qtyRequired,
QtyIssue qtyIssue,
CONVERT(VARCHAR(20), IssueDate, 120) issueDate,
QtyReserved qtyReserved,
MatGroup matGroup,
QtyNotified qtyNotified,
RMType_DB rmTypeDb,
IssueType issueType
FROM dbo.view_SAP_SOBOM vss
WHERE vss.Site = #{site}
AND vss.OrderNo = #{orderNo}
AND vss.ComponentPartNo = #{rmPartNo}
</select>
<!--查询材料的上机卷记录数据-->
<select id="getBomItemNosByPartNo" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT OrderNo + '/' + CONVERT(VARCHAR(20), ItemNo) + '/' + CONVERT(VARCHAR(20), SeqNo) orderInfo
FROM SFDC_MaterialHist
WHERE Site = #{site}
AND RMRollNo = #{rmPartNo}
</select>
<!--查询派工单时的材料记录信息-->
<select id="getSfdcMaterialByBomItemNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
SELECT smh.Site site, smh.OrderNo orderNo, smh.ItemNo itemNo, smh.SeqNo seqNo, smh.HistSeqNo histSeqNo,
smh.RollNo rollNo, smh.ReportDate reportDate,
smh.Reportedby reportedby, smh.RMRollNo rmRollNo, smh.PartNo partNo, smh.Remark remark, smh.StartDate startDate,
smh.FinishDate finishedDate,
smh.FinishFlag finishedFlag, smh.HistType histType, smh.TransGeneratedFlag transGeneratedFlag,
smh.OriginalRMRollNo originalRMRollNo,
smh.UnissueFlag unissueFlag, ROUND(smh.TransQty, 3) transQty, ROUND(smh.NetIssueQty, 3) netIssueQty,
smh.OriginalHistSeqNo originalHistSeqNo,
smh.StartFromRollNo startFromRollNo, smh.KeyRMFlag keyRMFlag, smh.SAPBOMItemNo sAPBOMItemNo, smh.Setupflag
setupflag
FROM SFDC_MaterialHist smh
<where>
<if test="site != null and site != ''">
AND smh.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND smh.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo > 0">
AND smh.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND smh.SeqNo = #{seqNo}
</if>
<if test="bomItemNo != null and bomItemNo > -1">
AND smh.SAPBOMItemNo = #{bomItemNo}
</if>
</where>
ORDER BY smh.HistSeqNo DESC
</select>
<!--查询派工单时的材料记录信息-->
<select id="getSfdcMaterialByBomItemNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
SELECT COUNT(1) FROM SFDC_MaterialHist smh
<where>
<if test="site != null and site != ''">
AND smh.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND smh.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo > 0">
AND smh.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND smh.SeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND smh.RollNo = #{rollNo}
</if>
<if test="rmPartNo != null and rmPartNo != ''">
AND smh.PartNo = #{rmPartNo}
</if>
<if test="finishedFlag != null and finishedFlag != ''">
AND smh.FinishFlag = #{finishedFlag}
</if>
<if test="histType != null and histType != ''">
AND smh.HistType = #{histType}
</if>
</where>
ORDER BY smh.HistSeqNo DESC
</select>
<!--查询派工单的不良记录-->
<select id="getScheduleDefectHist" parameterType="SearchScheduleData" resultType="SfdcDefectData">
SELECT sdh.Site site, sdh.OrderNo orderNo, sdh.ItemNo itemNo, sdh.SeqNo seqNo, sdh.HistSeqNo histSeqNo,
sdh.RollNo rollNo,
sdh.ReportDate reportedDate, sdh.Reportedby reportedBy, sdh.DefectCode defectCode, sdh.DefectQty defectQty,
sdh.Remark remark,
(SELECT idc.DefectDesc FROM InspectionDefectCode idc WHERE idc.Site = sdh.Site AND idc.DefectCode =
sdh.DefectCode) defectDesc
FROM SFDC_DefectHist sdh
<where>
<if test="site != null and site != ''">
AND sdh.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sdh.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sdh.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sdh.SeqNo = #{seqNo}
</if>
</where>
ORDER BY sdh.HistSeqNo DESC
</select>
<!--查询派工单的不良记录-->
<select id="countToolUsedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
SELECT SUM(FinishQty)
FROM SFDC_ToolingHist sth
WHERE sth.Site = #{site}
AND sth.OrderNo = #{orderNo}
AND sth.ItemNo = #{itemNo}
AND sth.SeqNo = #{seqNo}
AND sth.RollNo <![CDATA[<>]]> #{rollNo}
AND sth.ToolInstanceID = #{oriToolInstanceId}
</select>
<!--查询派工单的时间记录信息-->
<select id="getSfdcTimeHistBySeqNo" parameterType="SearchScheduleData" resultType="SfdcTimeData">
SELECT sth.Site site, sth.OrderNo orderNo,sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
sth.RollNo rollNo,
sth.EventTime eventTime, sth.Enteredby enteredby, sth.EventDesc eventDesc, sth.DowntimeCode downtimeCode,
sth.TillTime tillTime,
sth.TillEnteredTime tillEnteredTime, sth.TillEnteredBy tillEnteredBy, sth.CompletedFlag completedFlag,
ROUND(sth.TotalTime, 3) totalTime,
sth.DowntimePhaseIn downtimePhaseIn
FROM SFDC_TimeHist sth
<where>
<if test="site != null and site != ''">
AND sth.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sth.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sth.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sth.SeqNo = #{seqNo}
</if>
<if test='showNoFinishedTimeFlag != null and showNoFinishedTimeFlag != "" and showNoFinishedTimeFlag == "Y"'>
AND sth.CompletedFlag = 'N'
</if>
</where>
ORDER BY sth.HistSeqNo DESC
</select>
<!--查询派工单的工具记录信息-->
<select id="getSfdcToolHistBySeqNo" parameterType="SearchScheduleData" resultType="SfdcToolData">
SELECT sth.Site site, sth.OrderNo orderNo, sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
sth.RollNo rollNo,
sth.ReportDate reportedDate, sth.Reportedby reportedby, sth.ToolInstanceID toolInstanceID, sth.StartDate
startDate,
sth.FinishDate finishedDate, sth.FinishFlag finishedFlag, sth.Remark remark, sth.StartFromRollNo
startFromRollNo, sth.FinishQty finishQty
FROM SFDC_ToolingHist sth
<where>
<if test="site != null and site != ''">
AND sth.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sth.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sth.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sth.SeqNo = #{seqNo}
</if>
<if test='showNoFinishedToolFlag != null and showNoFinishedToolFlag != "" and showNoFinishedToolFlag == "Y"'>
AND sth.FinishFlag = 'N'
</if>
</where>
ORDER BY sth.HistSeqNo DESC
</select>
<!--查询派工单时的材料记录信息-->
<select id="getSfdcMaterialHistBySeqNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
SELECT smh.Site site, smh.OrderNo orderNo, smh.ItemNo itemNo, smh.SeqNo seqNo, smh.HistSeqNo histSeqNo,
smh.RollNo rollNo, smh.ReportDate reportDate,
smh.Reportedby reportedby, smh.RMRollNo rmRollNo, smh.PartNo partNo, smh.Remark remark, smh.StartDate startDate,
smh.FinishDate finishedDate,
smh.FinishFlag finishedFlag, smh.HistType histType, smh.TransGeneratedFlag transGeneratedFlag,
smh.OriginalRMRollNo originalRMRollNo,
smh.UnissueFlag unissueFlag, ROUND(smh.TransQty, 3) transQty, ROUND(smh.NetIssueQty, 3) netIssueQty,
smh.OriginalHistSeqNo originalHistSeqNo,
smh.StartFromRollNo startFromRollNo, smh.KeyRMFlag keyRMFlag, smh.SAPBOMItemNo sAPBOMItemNo, smh.Setupflag
setupflag
FROM SFDC_MaterialHist smh
<where>
<if test="site != null and site != ''">
AND smh.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND smh.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND smh.ItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND smh.SeqNo = #{seqNo}
</if>
<if test='showNoFinishedMaterialFlag != null and showNoFinishedMaterialFlag != "" and showNoFinishedMaterialFlag == "Y"'>
AND smh.FinishFlag = 'N'
</if>
</where>
ORDER BY smh.HistSeqNo DESC
</select>
<!--获取当前加工中心机台对应的calendarId-->
<select id="getCalendarId" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT wcr.CalendarID calendarId,
(SELECT cd.CalendarDesc
FROM Calendar cd
WHERE wcr.Site = cd.Site
AND wcr.CalendarID = cd.CalendarID) calendarDesc,
Efficiency efficiency
FROM WorkCenterResource wcr
WHERE wcr.Site = #{site}
AND wcr.WorkCenterNo = #{workCenterNo}
AND wcr.ResourceID = #{resourceId}
</select>
<!--获取班次选择的数据-->
<select id="getScheduleShiftWithSelect" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT WR.ResourceID resourceId,
CONVERT(VARCHAR(10), CE.ScheduleDate, 120) scheduleDate,
CES.ShiftNo shiftNo,
CES.ShiftDesc shiftDesc,
CONVERT(VARCHAR(5), CES.StartExactTime, 108) startTime,
CONVERT(VARCHAR(5), CES.EndExactTime, 108) endTime,
(CASE WHEN CES.EndTime <![CDATA[<]]> CES.StartTime THEN 'Y' ELSE 'N' END) nextDayFlag
FROM WorkCenterResource WR,
Calendar_Exception CE,
Calendar_Exception_Shift CES
WHERE WR.Site = CE.Site
and WR.CalendarID = CE.CalendarID
AND CE.Site = CES.Site
and CE.CalendarID = CES.CalendarID
and CE.ScheduleDate = CES.ScheduleDate
AND WR.Site = #{site}
AND WR.ResourceID = #{resourceId}
AND CONVERT(DECIMAL(20, 6), CE.ScheduleDate)<![CDATA[ >=]]>
CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{scheduledDate})) - 1
AND CONVERT(DECIMAL(20, 6), CE.ScheduleDate)<![CDATA[ <=]]>
CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{scheduledDate})) + 1
AND (CONVERT(DECIMAL(20, 6), CE.ScheduleDate) + CONVERT(DECIMAL(20, 6), CES.StartTime / 24.0)) <![CDATA[<=]]>
(CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{scheduledDate})) +
(CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{reportedTime})) -
floor(CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{reportedTime})))))
ORDER BY CE.ScheduleDate, CES.Starttime
</select>
<select id="searchFqcSfdcRolls" resultType="com.gaotao.modules.schedule.data.SfdcRollData">
SELECT sfr.Site site, sfr.OrderNo orderNo, sfr.RollNo rollNo, sfr.CreatedDate createdDate, sfr.Createdby
createdby, sfr.CurrentOpsItemNo currentOpsItemNo,
sfr.LastFinishedOpsItemNo lastFinishedOpsItemNo, sfr.FinishedDate finishedDate, sfr.FinishedFlag finishedFlag,
sfr.OnLineFlag onLineFlag,
sfr.PauseFlag pauseFlag, sfr.OriRollNo oriRollNo, sfr.StartOpsItemNo startOpsItemNo, sfr.RollType rollType,
sfr.CreatedOpsItemNo createdOpsItemNo,
sfr.CreatedOpsSeqNo createdOpsSeqNo, sfr.RollQty rollQty, sfr.FirstLevelRollNo firstLevelRollNo,
sfr.VirtualRollFlag virtualRollFlag
FROM SFDC_Rolls sfr
<where>
sfr.Site= #{site}
and sfr.OrderNo=#{orderNo}
and sfr.StartOpsItemNo <![CDATA[ <= ]]> #{itemNo}
and sfr.CQCPassFlag='N'
and sfr.FinishedFlag='N'
and sfr.CQCInspectedFlag='Y'
<if test=" rollNo != null and rollNo != ''">
and sfr.RollNo like '%' + #{rollNo} + '%'
</if>
</where>
</select>
<select id="getReworkSfdcRollByCon" resultType="com.gaotao.modules.schedule.data.SfdcRollData">
SELECT sfr.Site site, sfr.OrderNo orderNo, sfr.RollNo rollNo, sfr.CreatedDate createdDate, sfr.Createdby
createdby, sfr.CurrentOpsItemNo currentOpsItemNo,
sfr.LastFinishedOpsItemNo lastFinishedOpsItemNo, sfr.FinishedDate finishedDate, sfr.FinishedFlag finishedFlag,
sfr.OnLineFlag onLineFlag,
sfr.PauseFlag pauseFlag, sfr.OriRollNo oriRollNo, sfr.StartOpsItemNo startOpsItemNo, sfr.RollType rollType,
sfr.CreatedOpsItemNo createdOpsItemNo,
sfr.CreatedOpsSeqNo createdOpsSeqNo, sfr.RollQty rollQty, sfr.FirstLevelRollNo firstLevelRollNo,
sfr.VirtualRollFlag virtualRollFlag,
sfr.CombineFlag combineFlag
FROM SFDC_Rolls sfr
<where>
<if test="site != null and site != ''">
AND sfr.Site = #{site}
</if>
<if test="orderNo != null and orderNo != ''">
AND sfr.OrderNo = #{orderNo}
</if>
<if test="itemNo != null and itemNo != ''">
AND sfr.CreatedOpsItemNo = #{itemNo}
</if>
<if test="seqNo != null and seqNo != ''">
AND sfr.CreatedOpsSeqNo = #{seqNo}
</if>
<if test="rollNo != null and rollNo != ''">
AND sfr.RollNo = #{rollNo}
</if>
</where>
Union all
Select
T.Site,T.OrderNo,D.RollNo,D.CreatedDate,D.Createdby,D.CurrentOpsItemNo,D.LastFinishedOpsItemNo,D.FinishedDate,D.FinishedFlag
,D.OnLineFlag,D.PauseFlag,D.OriRollNo,D.StartOpsItemNo,D.RollType,D.CreatedOpsItemNo,D.CreatedOpsSeqNo,D.RollQty,D.FirstLevelRollNo
,D.FGRollFlag,D.CombineFlag
from SFDC_RollOps as T,SFDC_Rolls as D
Where T.Site=D.Site and T.OrderNo=D.OrderNo and T.RollNo=D.RollNo
and T.Site=#{site}
and T.OrderNo=#{orderNo}
and T.ItemNo=#{itemNo}
and T.SeqNo=#{seqNo}
and T.Remark='直接送检'
ORDER BY sfr.RollNo
</select>
<select id="reportCheck" resultType="java.lang.Integer">
Select count(1)
from SOScheduledRouting as T
Where Site = #{site}
and S_ResourceID = #{resourceId}
and S_WorkCenterNo = #{workCenterNo}
and SeqNo != #{seqNo}
and ClosedFlag = 'N'
and StartProdFlag = 'Y'
and (
(case
when exists(select 1
from SFDC_MaterialHist as T1
where T1.Site = T.Site
and T1.OrderNo = T.OrderNo
and T1.ItemNo = T.ItemNo
and T1.SeqNo = T.SeqNo
and T1.FinishFlag = 'N'
)
then 1
else 0 end
)
+
(case
when exists(select 1
from SFDC_ToolingHist as T2
where T2.Site = T.Site
and T2.OrderNo = T.OrderNo
and T2.ItemNo = T.ItemNo
and T2.SeqNo = T.SeqNo
and T2.FinishFlag = 'N'
)
then 1
else 0 end
)
+
(case
when exists(select 1
from SFDC_TimeHist as T3
where T3.Site = T.Site
and T3.OrderNo = T.OrderNo
and T3.ItemNo = T.ItemNo
and T3.SeqNo = T.SeqNo
and T3.CompletedFlag = 'N'
)
then 1
else 0 end
)
+
(case
when exists(select 1
from SFDC_RollOps as T4
where T4.Site = T.Site
and T4.OrderNo = T.OrderNo
and T4.ItemNo = T.ItemNo
and T4.SeqNo = T.SeqNo
and T4.FinishedFlag = 'N'
)
then 1
else 0 end
)
) > 0
</select>
<select id="getUserSpecialSecurity" resultType="java.lang.String">
select dbo.Get_User_Special_Security(#{username}, #{sNo})
</select>
<insert id="saveSfdcDefect" parameterType="SfdcDefectData">
INSERT INTO SFDC_DefectHist(Site, OrderNo, ItemNo, SeqNo, HistSeqNo, ReportDate, Reportedby, DefectCode,
DefectQty, RollNo)
VALUES (#{site}, #{orderNo}, #{itemNo}, #{seqNo}, #{histSeqNo}, #{reportedDate}, #{reportedBy}, #{defectCode},
#{defectQty}, #{rollNo})
</insert>
<insert id="saveSfdcDefectList">
INSERT INTO
SFDC_DefectHist(Site,OrderNo,ItemNo,SeqNo,HistSeqNo,ReportDate,Reportedby,DefectCode,DefectQty,RollNo)
VALUES
<foreach collection="list" separator="," item="item">
( #{item.site},#{item.orderNo},#{item.itemNo},#{item.seqNo},#{item.histSeqNo}
,#{item.reportedDate},#{item.reportedBy},#{item.defectCode},#{item.defectQty},#{item.rollNo} )
</foreach>
</insert>
<insert id="insertShopOrderChangeHist">
Insert into ShopOrderChangeHist(Site, OrderNo, CreateDate, Fieldname, FieldCaption, OldValue, NewValue, UserID,
RecordType, Remark)
Values (#{site}, #{orderNo}, getdate(), '*', '*', '*', '*', #{username}, '更改', #{orderChangeStatus})
</insert>
<select id="getSORoutingPreviousOperationItemNo" resultType="java.lang.Integer">
select dbo.Get_SORouting_PreviousOperationItemNo(#{site}, #{orderNo}, #{itemNo})
</select>
<select id="getShopOrderType" resultType="java.lang.String">
Select OrderType as order_type
from ShopOrder
where Site = #{site}
and OrderNo = #{orderNo}
</select>
<!--查询分切工单的物料信息-->
<select id="getSplitOrderParts" parameterType="SearchScheduleData" resultType="java.util.HashMap">
SELECT vss.Site site,
vss.SAPOrderNo sapOrderNo,
vss.OrderNo orderNo,
vss.OrderItemNo bomItemNo,
vss.PartNo partNo,
vss.PartDescription partDesc,
vss.Quantity orderQty
FROM view_sap_slitting_partlist vss
WHERE vss.Site = #{site}
AND vss.OrderNo = #{orderNo}
</select>
<!--统计C_RollInfo是否报工过-->
<select id="countCRollByRollNo" parameterType="SearchScheduleData" resultType="java.lang.Integer">
SELECT COUNT(1) FROM C_RollInfo cri
<where>
cri.Site = #{site} AND cri.OrderRef1 = #{orderNo} AND cri.OriginalRollNo = #{rollNo}
</where>
</select>
<!--统计C_RollInfo表的报工数据-->
<select id="getCRollReportedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
SELECT SUM(ISNULL(cri.RollQty, 0)) FROM C_RollInfo cri
<where>
cri.Site = #{site} AND cri.OrderRef1 = #{orderNo} AND cri.OriginalRollNo = #{rollNo}
</where>
</select>
<!--修改派工单的排料标记-->
<update id="updateSoScheduledRoutingMatIssueFlag" parameterType="SearchScheduleData">
UPDATE SOScheduledRouting
SET mat_issueflag = #{matIssueFlag}
WHERE Site = #{site}
AND OrderNo = #{orderNo}
AND SeqNo = #{seqNo}
</update>
<!--修改派工单的网版标记-->
<update id="updateSoScheduledRoutingPlateIssueFlag" parameterType="SearchScheduleData">
UPDATE SOScheduledRouting
SET plate_issueflag = #{plateIssueFlag}
WHERE Site = #{site}
AND OrderNo = #{orderNo}
AND SeqNo = #{seqNo}
</update>
<!--修改派工单的刀模标记-->
<update id="updateSoScheduledRoutingToolIssueFlag" parameterType="SearchScheduleData">
UPDATE SOScheduledRouting
SET tool_issueflag = #{toolIssueFlag}
WHERE Site = #{site}
AND OrderNo = #{orderNo}
AND SeqNo = #{seqNo}
</update>
<update id="updateSOScheduledRouting">
Update SOScheduledRouting
Set ClosedFlag='Y'
, Closedby=#{userId}
, ClosedDate=getdate()
Where Site = #{site}
and OrderNo = #{orderNo}
and ItemNo = #{itemNo}
and SeqNo = #{seqNo}
</update>
<!-- 更新派工单的备注 -->
<update id="updateSOScheduledRoutingRemark">
UPDATE SOScheduledRouting
SET Remark = #{remark}
WHERE Site = #{site}
AND OrderNo = #{orderNo}
AND ItemNo = #{itemNo}
AND SeqNo = #{seqNo}
</update>
<select id="checkKeyMart" resultType="java.lang.String">
Select Isnull(RMType_DB, '') as RMType_DB
From dbo.view_SAP_SOBOM as B
Where B.Site = #{site}
and B.OrderNo = #{orderNo}
and B.ItemNo = #{bomItemNo}
</select>
<select id="sumProductionCapacity" resultType="java.lang.Double">
SELECT
sum (dbo.getScheduleToPlanTime ( D.LotSize, T.MachSetupTime, T.MachRunFactor, T.FactorUnit, t.Efficiency ))
scheduleToPlanTime
FROM
SORouting AS T
LEFT JOIN ShopOrder AS D ON T.Site= D.Site
AND T.OrderNo= D.OrderNo
<where>
Round(T.QtyScheduled,3) <![CDATA[ < ]]> round(T.QtyRequired,3) and T.ClosedFlag = 'N' AND T.WorkCenterNo
<![CDATA[<>]]> 'FQC'
<if test="username != null and username != ''">
and T.site in (Select Site from AccessSite where upper(UserID)=#{username})
</if>
and T.OrderNo<![CDATA[ <> ]]>'9999' and isnull(D.Status,'')<![CDATA[ <> ]]>'已取消' and isnull(D.Status,'')
<![CDATA[ <> ]]>'已计划'
and isnull(D.Status,'')<![CDATA[ <> ]]>'已关闭'
<if test="enterTime1 != null">
and D.EnterDate<![CDATA[ >= ]]> #{enterTime1}
</if>
<if test="enterTime2 != null">
and D.EnterDate-1 <![CDATA[<]]> #{enterTime2}
</if>
<if test="needTime1 != null">
and D.NeedDate<![CDATA[ >= ]]>#{needTime1}
</if>
<if test="needTime2 != null">
and D.NeedDate<![CDATA[ <= ]]>#{needTime2}
</if>
<if test="site != null and site != ''">
AND T.Site like '%' + #{site} + '%'
</if>
<if test="partNo != null and partNo != ''">
AND T.PartNo like '%' + #{partNo} + '%'
</if>
AND T.WorkCenterNo = #{workCenterNo}
<if test="scheduledFlag != null and scheduledFlag != ''">
AND Isnull(S1.ScheduledFlag, 'Y') = #{scheduledFlag}
</if>
</where>
</select>
<select id="getBomItemNosByKeyPartNo" resultType="java.util.Map">
SELECT Site site,
OrderNo orderNo,
CONVERT(INT, ItemNo) itemNo,
ComponentPartNo partNo,
QtyAssembly qtyAssembly,
QtyFixedScrapt qtyFixedScrapt,
ScraptFactor scraptFactor,
Remark remark,
QtyRequired qtyRequired,
QtyIssue qtyIssue,
CONVERT(VARCHAR(20), IssueDate, 120) issueDate,
QtyReserved qtyReserved,
MatGroup matGroup,
QtyNotified qtyNotified,
RMType_DB rmTypeDb,
IssueType issueType
FROM dbo.view_SAP_SOBOM vss
WHERE vss.Site = #{site}
AND vss.RMType_DB = 'key Mart'
AND vss.OrderNo = #{orderNo}
AND vss.ComponentPartNo = #{rmPartNo}
</select>
<select id="deleteSfdcDefect" resultType="java.util.Map">
exec dbo.RemoveSfdcDefect #{site},#{orderNo},#{itemNo},#{seqNo},#{rollNo},#{histSeqNo}
</select>
<select id="deleteSfdcTimeHist" resultType="java.util.Map">
exec dbo.RemoveSfdcTimeHist #{site},#{orderNo},#{itemNo},#{seqNo},#{rollNo},#{histSeqNo}
</select>
<select id="deleteSfdcMaterialHist" resultType="java.util.Map">
exec dbo.RemoveSfdcMaterialHist #{site},#{orderNo},#{itemNo},#{seqNo},#{rollNo},#{histSeqNo},#{histType}
</select>
<!-- 获取固定载具列表 -->
<select id="getFixedCarrierList" resultType="map">
SELECT
site,
bu_no AS buNo,
carrier_no AS carrierNo,
carrier_type_code AS carrierTypeCode,
carrier_type_name AS carrierTypeName,
specification,
asset_no AS assetNo,
dimensions,
max_weight AS maxWeight,
expected_life_cycles AS expectedLifeCycles,
expected_life_days AS expectedLifeDays,
status,
current_location AS currentLocation,
last_used_time AS lastUsedTime,
total_usage_count AS totalUsageCount,
purchase_date AS purchaseDate,
create_by AS createBy,
create_date AS createDate,
remark
FROM fixed_carrier
WHERE site = #{site}
<if test="carrierNo != null and carrierNo != ''">
AND carrier_no LIKE '%' + #{carrierNo} + '%'
</if>
<if test="carrierTypeName != null and carrierTypeName != ''">
AND carrier_type_name LIKE '%' + #{carrierTypeName} + '%'
</if>
<if test="specification != null and specification != ''">
AND specification LIKE '%' + #{specification} + '%'
</if>
ORDER BY carrier_no
</select>
</mapper>