|
|
<?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.dao.ScheduleMapper"> <!--查询加工中心机台的信息--> <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, 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="workCenterNo != null and workCenterNo != ''"> AND T.WorkCenterNo like '%' + #{workCenterNo} + '%' </if> <if test="scheduledFlag != null and scheduledFlag != ''"> AND Isnull(S1.ScheduledFlag, 'Y') = #{scheduledFlag} </if> <if test="resourceId != null and resourceId != ''"> AND dbo.Get_SOOpsScheduleAvailResource(T.Site,T.OrderNo,T.WorkCenterNo,T.ItemNo) like '%' + #{resourceId} + '(%' </if> </where> Order by D.NeedDate </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 lotSize, T.QtyReported qtyReported, 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, D.CostRollUpFlag costRollUpFlag 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> <if test="workCenterNo != null and workCenterNo != ''"> AND T.S_WorkCenterNo like '%' + #{workCenterNo} + '%' </if> <if test="resourceId != null and resourceId != ''"> AND E.ResourceID like '%' + #{resourceId} + '%' </if> </where> Order by E.S_ScheduledSeqNo </select>
<!--查询-待生产工单--> <select id="getProduceScheduleData" parameterType="SearchScheduleData" 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 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, 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 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 like '%' + #{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 T.PlanFinishTime desc </select>
<!--查询操作员信息列表--> <select id="getOperatorList" 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 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="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 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, 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 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 sro.Site site, sro.OrderNo orderNo, sro.RollNo rollNo, sro.ItemNo itemNo, sro.SeqNo seqNo, sro.ScanedBy scanBy, sro.ScanedDate scanDate, 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, sth.TotalTime 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, smh.TransQty transQty, smh.NetIssueQty 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="getSfdcRollOpsByCon" parameterType="SearchScheduleData" resultType="SfdcRollOpsData"> SELECT sro.Site site, sro.OrderNo orderNo, sro.RollNo rollNo, sro.ItemNo itemNo, sro.SeqNo seqNo, sro.ScanedBy scanBy, sro.ScanedDate scanDate, 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(T.VirtualRollFlag='N' AND T.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 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) totalSetupTime ,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) totalDowntimeTime_Setup ,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) totalProdTime ,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) totalDowntimeTime_Prod ,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, SUM(TotalTime) 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>
</mapper>
|