|
|
<?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.jtem.modules.Schedule.dao.ScheduleMapper">
<select id="getShopOrderRoutingData" resultType="ShopOrderRoutingData"> select a.site, a.OrderNo,a.PartNo,a.Status,a.PlanStartDate,a.NeedDate,a.LotSize,a.EnterDate,a.UserName, P.Spec+'/'+isnull(P.PartDescription,'') PartDescription,P.Spec,isnull(SL.scheduledQty,0) as scheduledQty,s.workCenterNo,S.qtyReported,S.qtyApprove,S.machSetupTime, S.machRunFactor,S.factorUnit,S.ItemNo,S.OperationDesc,s.Efficiency,isnull(SOP.TotalFinishedQty,0) lastApproveQty FROM ShopOrder a LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site LEFT JOIN v_SORouting S on S.site=a.site and S.OrderNo=a.orderNo LEFT JOIN ScheduleList SL on S.site=SL.site and S.OrderNo=SL.orderNo and S.ItemNo=SL.ItemNo LEFT JOIN SORoutingOutput SOP ON a.site=SOP.site and a.OrderNo=SOP.OrderNo and SOP.itemNo=dbo.Get_SORouting_PreviousOperationItemNo(a.site,a.OrderNo,S.itemNo)<!-- left join user_work_center uwc on a.site=uwc.site and s.workCenterNo =uwc.WorkCenterNo and uwc.userId=#{userId}--><!-- left join CODetail cod on a.site=cod.site and a.orderRef1=cod.OrderNo and a.orderRef2= CONVERT(VARCHAR(10),cod.ItemNo)--> <where><!-- and uwc.WorkCenterNo is not null--><!-- and a.E_Levels =0-->
<if test="site != null and site != ''"> AND a.site = #{site} </if> <if test="orderNo != null and orderNo != ''"> AND a.OrderNo LIKE '%' + #{orderNo} + '%' </if><!-- <if test="status !=null and status != ''">--><!-- AND a.Status IN ${status}--><!-- </if>--> and a.status in ('已下达','已发料','已入库','已开工','已排产') <if test="startDate1 != null "> AND a.EnterDate >= #{startDate1} </if> <if test="endDate1 != null "> AND #{endDate1} >= DATEADD(dd, -1, a.EnterDate) </if> <if test="startDate2 != null "> AND a.PlanStartDate >= #{startDate2} </if> <if test="endDate2 != null "> AND #{endDate2} >= a.PlanStartDate </if> <if test="startDate3 != null "> AND a.NeedDate >= #{startDate3} </if> <if test="endDate3 != null "> AND #{endDate3} >= a.NeedDate </if> <if test="startDate4 != null "> AND cod.PlanShipDate >= #{startDate4} </if>
<if test="partNo != null and partNo != ''"> AND a.PartNo LIKE '%' + #{partNo} + '%' </if> <if test="planStatus != null and planStatus != ''"> and ${planStatus} </if> <if test="itemNo != null and itemNo != ''"> and S.ItemNo = #{itemNo} </if><!-- <if test="eLevels != null ">--><!-- and a.E_Levels = #{eLevels}--><!-- </if>-->
</where> order by a.PlanStartDate desc,s.itemNo </select>
<select id="getOperatorList" resultType="OperatorData"> Select a.OperatorID,a.OperatorName from Operator a where a.site=#{site} and a.Active='Y' </select> <select id="checkScheduleQty" resultType="ScheduleCheckData"> Select a.lotSize as Qty,isnull(b.scheduledQty,0) scheduledQty from ShopOrder a left join ScheduleList b on a.site=b.site and a.orderNo=b.orderNo and b.itemNo=#{itemNo} where a.Site=#{site} and a.OrderNo=#{orderNo} </select>
<select id="checkScheduleList" resultType="ScheduleCheckData"> Select Qty from ScheduleList where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo} </select>
<insert id="saveScheduleList"> insert into ScheduleList(Site,OrderNo,ItemNo,Type,Type_db,Qty,scheduledQty) values (#{site},#{orderNo},#{itemNo},'生产订单派工单','S',#{qty},0) </insert> <select id="getDataSequence" resultType="integer"> select seqNo from DataSequence where SeqType= 'A' </select> <update id="updateDataSequence"> update DataSequence set seqNo=seqNo+1 where SeqType= 'A' </update> <insert id="saveSchedule"> Insert into soscheduledrouting(Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime ,BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ShiftNo,S_WorkCenterNo ,SelectedFlag,SourceFlag,ParkFlag,TimeRequired_Original,QtyRequired_Original ,StartProdFlag,CancelledProdFlag,Efficiency,EnteredDate,scheduleType,operatorId,partNo,OrderRef1,cancelReportFlag,CreateBy,WorkTime,stopTime) values(#{site},#{orderNo},#{itemNo},#{seqNo},#{scheduleQty},0,0,dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderNo},#{itemNo},#{scheduleQty}),0,#{scheduleDate},#{scheduleDate} ,'*',#{remark},1,'N',0,'Y',#{scheduleDate},#{resourceId},#{shiftNo},#{workCenterNo} ,'N','N','N',dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderNo},#{itemNo},#{scheduleQty}),#{scheduleQty} ,'N','N',#{efficiency},GETDATE(),'生产订单派工单',#{operatorId},#{partNo},#{orderNo},'N',#{createBy},0,0) </insert>
<update id="updateScheduleListQty"> update ScheduleList set scheduledQty=scheduledQty+#{sumQty} where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo} and type=#{scheduleType} </update>
<select id="searchLastApproveQty" resultType="SORoutingData"> select top 1 isnull(TotalFinishedQty,0) lastApproveQty from v_SORouting where Site=#{site} and OrderNo=#{orderNo} and itemNo=dbo.Get_SORouting_PreviousOperationItemNo(#{site},#{orderNo},#{itemNo}) </select>
<select id="getSOScheduleRoutingData" resultType="SOScheduledRoutingOutData"> select a.Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported, BarcodeID,Remark,Crewsize,ClosedFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo, S_WorkCenterNo, EnteredDate,scheduleType,operatorId,partNo,dbo.Get_Part_SpecDesc(a.Site,partNo) as partDesc, dbo.Get_OperatorDesc(a.Site,operatorId) as operatorName,dbo.Get_ItemDesc(a.Site,OrderNo,ItemNo) as itemDesc,orderRef1 , dbo.Get_WorkCenterDesc(a.Site,S_WorkCenterNo) as workCenterDesc , dbo.Get_Part_SpecDesc(a.Site,partNo) as partSpec,circulation_seqNo,circulation_qty ,dbo.Get_Part_UMID(a.Site,PartNo) umid from SOScheduledRouting a<!-- left join user_work_center uwc on a.site=uwc.site and a.S_WorkCenterNo =uwc.WorkCenterNo and uwc.userId=#{userId}--> <where><!-- and uwc.WorkCenterNo is not null-->
<if test="site != null and site != ''"> AND a.site = #{site} </if> <if test="orderNo != null and orderNo != ''"> AND OrderNo LIKE '%' + #{orderNo} + '%' </if>
<if test="seqNo != null "> AND seqNo = #{seqNo} </if> <if test="partNo != null and partNo != ''"> AND PartNo LIKE '%' + #{partNo} + '%' </if> <if test="sWorkCenterNo != null and sWorkCenterNo != ''"> AND S_WorkCenterNo LIKE '%'+#{sWorkCenterNo}+'%' </if>
<if test="itemNo != null and itemNo != ''"> and ItemNo = #{itemNo} </if> <if test="itemDesc != null and itemDesc != ''"> and dbo.Get_ItemDesc(a.Site,OrderNo,ItemNo) = #{itemDesc} </if> <if test="closedFlag != null and closedFlag != ''"> and ClosedFlag = #{closedFlag} </if> <if test="startDate != null "> and S_ScheduledDate >= #{startDate} </if> <if test="endDate != null "> and #{endDate} >= S_ScheduledDate </if> <if test="scheduleType != null and scheduleType != ''"> and scheduleType = #{scheduleType} </if> <if test="reportFlag != null and reportFlag != ''"> and ${reportFlag} </if> <if test="operatorName != null and operatorName != ''"> and dbo.Get_OperatorDesc(a.Site,operatorId) like '%'+#{operatorName}+'%' </if> <if test="sResourceID != null and sResourceID != ''"> and S_ResourceID like '%'+#{sResourceID}+'%' </if> <if test="sShiftNo != null and sShiftNo != ''"> and S_ShiftNo = #{sShiftNo} </if> </where> order by S_ScheduledDate </select>
<select id="getOldSOScheduledRoutingOutData" resultType="SOScheduledRoutingOutData"> select Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime, BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo, S_WorkCenterNo,ParkFlag,TimeRequired_Original,QtyRequired_Original,QtyReturntoSchedule,StartProdFlag,CancelledProdFlag, Efficiency,EnteredDate,SelectedFlag,SourceFlag,Closedby,ClosedDate,VirtualResourceFlag,mat_issueflag,plate_issueflag, tool_issueflag,scheduleType,operatorId,partNo,orderRef1,circulation_seqNo,circulation_qty from SOScheduledRouting where site=#{site} and seqNo=#{seqNo} </select>
<update id="closeOldSchedule"> update SOScheduledRouting set ClosedFlag='Y',circulation_seqNo=#{newSeqNo},circulation_qty=#{circulationQty} where site=#{site} and seqNo=#{oldSeqNo} </update>
<insert id="saveCirculationSchedule" > INSERT into SOScheduledRouting (Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime, BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo, S_WorkCenterNo,ParkFlag,TimeRequired_Original,QtyRequired_Original,QtyReturntoSchedule,StartProdFlag,CancelledProdFlag, Efficiency,EnteredDate,SelectedFlag,SourceFlag,Closedby,ClosedDate,VirtualResourceFlag,mat_issueflag,plate_issueflag, tool_issueflag,scheduleType,operatorId,partNo,orderRef1) values (#{site},#{orderNo},#{itemNo},#{seqNo},#{qtyRequired},0,0,0,0,#{planStartTime},#{planFinishTime}, #{barcodeID},#{remark},#{crewsize},'N',0,'Y',#{sScheduledDate},#{sResourceID},#{sScheduledSeqNo},#{sShiftNo}, #{sWorkCenterNo},#{parkFlag},#{timeRequiredOriginal},#{qtyRequiredOriginal},null,'N','N', 0,GetDate(),'N','N',NULL,NULL,NULL,#{matIssueflag},'N','N',#{scheduleType},#{operatorId},#{partNo},#{orderRef1} ) </insert>
<update id="closeSchedule"> update SOScheduledRouting set ClosedFlag='Y' where site=#{site} and seqNo=#{seqNo} </update> <select id="searchReportedQty" resultType="SORoutingData"> select top 1 isnull(a.QtyReported,0) QtyReported,isnull(SOP.TotalFinishedQty,0) lastApproveQty from v_SORouting a LEFT JOIN SORoutingOutput SOP ON a.site=SOP.site and a.OrderNo=SOP.OrderNo and SOP.itemNo=dbo.Get_SORouting_PreviousOperationItemNo(a.site,a.OrderNo,a.itemNo) where a.Site=#{site} and a.OrderNo=#{orderNo} and a.itemNo=#{itemNo} </select>
<select id="getSeqNoSite" resultType="String"> select site from SOScheduledRouting where SeqNo=#{seqNo} </select>
<select id="searchSeqNo" resultType="SOScheduledRoutingOutData"> select top 1 Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported, BarcodeID,Remark,Crewsize,ClosedFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo, S_WorkCenterNo, EnteredDate,scheduleType,operatorId,partNo,dbo.Get_PartDesc(Site,partNo) as partDesc, dbo.Get_OperatorDesc(Site,operatorId) as operatorName,dbo.Get_ItemDesc(site,orderNo,ItemNo) as itemDesc,orderRef1 , dbo.Get_WorkCenterDesc(Site,S_WorkCenterNo) as workCenterDesc , dbo.Get_Part_SpecDesc(Site,partNo) as partSpec,closedFlag,outWorkFlag,ParkFlag,CancelReportFlag from SOScheduledRouting where SeqNo=#{seqNo} </select> <select id="checkFirstItem" resultType="SOScheduledRoutingOutData"> select site from v_SORouting where orderNo=#{orderNo} and site=#{site} and #{itemNo} >itemNo </select>
<update id="updateOutWorkFlag"> update SOScheduledRouting set OutWorkFlag='N' where SeqNo =#{seqNo} </update>
<select id="getSfdcList" resultType="com.jtem.modules.Schedule.entity.SfdcCancel"> select a.site,a.OrderNo,a.ItemNo ,a.SeqNo,a.WorkCenterNo,a.ReportDate,a.OperatorID,a.ReportQty,a.ApproveQty,a.ReportedManfTime,a.StatisticDate, a.AssJobSeqNo,a.Scheduled_ResourceId ResourceID,b.S_ShiftNo ShiftNo,b.partNo,dbo.Get_ItemDesc(a.site,a.OrderNo,a.ItemNo) operation_desc,c.OperatorName,b.S_ShiftNo ShiftDesc,e.ResourceDesc,Reverseflag ,dbo.Get_Part_Spec(a.site,b.partNo) partSpec,dbo.Get_PartDesc(a.site,b.partNo) PartDesc from sfdc a LEFT JOIN SOScheduledRouting b on a.Site=b.Site and a.AssJobSeqNo=b.SeqNo left join Operator c on a.site=c.site and a.OperatorID=c.OperatorID left join WorkCenterResource e on a.Site=e.Site and a.Scheduled_ResourceId =e.ResourceID and a.WorkCenterNo=e.WorkCenterNo <where>
and a.AssJobSeqNo is not null <if test="orderNo != null and orderNo != ''"> and a.OrderNo like '%'+#{orderNo}+'%' </if> <if test="workCenterNo != null and workCenterNo != ''"> and a.WorkCenterNo like '%'+#{workCenterNo}+'%' </if> <if test="partNo != null and partNo != ''"> and b.partNo like '%'+#{partNo}+'%' </if> <if test="itemNo != null and itemNo != ''"> and a.ItemNo = #{itemNo} </if> <if test="operatorName != null and operatorName != ''"> and c.OperatorName like '%'+#{operatorName}+'%' </if> <if test="resourceId != null and resourceId != ''"> and a.Scheduled_ResourceId = #{resourceId} </if> <if test="shiftNo != null and shiftNo != ''"> and b.S_ShiftNo = #{shiftNo} </if> <if test="startDate != null "> and ReportDate >= #{startDate} </if> <if test="endDate != null "> and #{endDate} >= ReportDate </if> <if test="seqNo != null and seqNo != '' "> and a.AssJobSeqNo = #{seqNo} </if> </where> order by a.ReportDate desc </select>
<select id="getStockPrint" resultType="com.jtem.modules.Schedule.entity.InventoryStockData"> select Site,WarehouseID,PartNo,BatchNo,LocationID,FirstInDate,LatestOutDate,LatestInDate,ActiveDate,InQty,OutQty,Round(QtyOnHand,4) QtyOnHand,QtyReserved,InStandardValue,InActualValue,OutStandardValue,OutActualValue,PartnerID,PartnerType,LatestCountDate,Freezeflag,QtyTmp,ManufactureDate,ExpiredDate,QtytoIssue,DemandPartnerType,DemandPartnerID,DemandPartnerName,dbo.Get_Part_DescSpec(Site,PartNo) partDesc from InventoryStock
<where> <if test="partNo != null and partNo != '' "> and PartNo >= #{partNo} </if>
<if test="batchNo != null and batchNo != '' "> and BatchNo >= #{batchNo} </if> ${zeroSql} </where> </select></mapper>
|