|
|
<?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.heai.modules.production.dao.DailyPlanMapper">
<select id="getShopOrderData" resultType="com.heai.modules.production.entity.ShopOrderData" parameterType="com.heai.modules.production.entity.DailyPlanInData"> select a.site, a.OrderNo,a.PartNo,a.Status,a.PlanStartDate,a.NeedDate,a.LotSize,a.EnterDate,a.UserName, P.PartDescription,P.Spec,ROUND(ISNULL(so.scheduling_size,0),3) as scheduling_size,dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo) as weightFactor, Round(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo)*a.LotSize,2) as weight FROM ShopOrder a LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site LEFT JOIN so_scheduled_list so ON a.site=so.Site AND a.OrderNo= so.order_no <where> <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> <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="partNo != null and partNo != ''"> AND a.PartNo LIKE #{partNo} </if> <if test="planStatus != null and planStatus != ''"> and ${planStatus} </if> AND a.E_Levels=1 </where> order by a.PlanStartDate </select>
<select id="getGenerateReportList" resultType="com.heai.modules.production.entity.GenerateReportData"> Select T.Site,T.OrderNo,T.ItemNo,T.OperationDesc,T.WorkCenterNo,W.WorkCenterDesc,T.QtyRequired,T.QtyReported ,T.QtyApprove ,T.TimeRequired,T.TimeReported,T.PlanStartTime,T.PlanFinishTime ,T.ClosedFlag,T.PartNo,P.PartDescription,P.Spec,D.NeedDate,D.PlanStartDate,D.Status ,D.LotSize,D.FinishedQty from SORouting as T,ShopOrder as D,WorkCenter as W,Part as P <where> T.Site=D.Site and T.OrderNo=D.OrderNo and T.Site=W.Site and T.WorkCenterNo=W.WorkCenterNo and D.Site=P.Site and D.PartNo=P.PartNo <if test="site != null and site != ''"> and T.site = #{site,jdbcType=VARCHAR} </if> <if test="workCenterNo != null and workCenterNo != ''"> and T.WorkCenterNo like '%' + #{workCenterNo,jdbcType=VARCHAR} + '%' </if> <if test="partNo != null and partNo != ''"> and T.PartNo like '%' + #{partNo,jdbcType=VARCHAR} + '%' </if> <if test="orderNo != null and orderNo != ''"> and T.OrderNo like '%' + #{orderNo,jdbcType=VARCHAR} + '%' </if> </where> </select>
<select id="getShopOrderForHunlian" resultType="com.heai.modules.production.entity.ShopOrderData"> select A.OrderNo ,A.Site ,A.EnterDate ,A.UserName ,A.NeedDate ,A.OriginalNeedDate ,A.PlanStartDate ,A.ReleaseDate ,A.ReleaseGuys ,A.ScheduleDate ,A.Scheduler ,A.IssueDate ,A.ReportDate ,A.ReceiveDate ,A.CloseDate ,A.Planner ,A.Status ,A.Status_Tmp ,A.Printed ,A.OrderType ,A.PartNo ,A.LotSize ,A.FinishedQty ,A.ProjectID ,A.BOMRevNo ,A.RoutingRevNo ,A.Leadtime ,A.Remark ,A.OrderRef1 ,A.OrderRef2 ,A.CostRollUpFlag ,A.ManualFlag ,A.OriSOOrderNo ,A.CustomerID ,A.TechInfo ,A.ReceiveStatus ,A.E_OriginalOrderNo ,A.E_Levels ,A.E_OriginalOrderType ,A.E_SeqNo ,A.E_LevelCode ,A.SFDCReportedFlag ,A.RepairSOFlag ,A.ConfigurationFlag ,A.MaterialSplitFlag ,A.ObjectVersion ,A.ExpandFlag ,A.CodeNo ,A.LE_SeqNo ,A.LE_ItemNo ,A.LE_Levels ,B.PartDescription,dbo.Get_PartWeightFactorForReport(A.Site ,A.PartNo,A.OrderNo) as weightFactor, Round(dbo.Get_PartWeightFactorForReport(A.Site ,A.PartNo,A.OrderNo)*A.LotSize,2) weight from ShopOrder A left join Part B on A.site = B.site and A.PartNo = B.PartNo <where> and A.E_Levels=2 <if test="site != null and site != ''"> and A.Site = #{site,jdbcType=VARCHAR} </if> <if test="orderNo != null and orderNo != ''"> and A.OrderNo = #{orderNo,jdbcType=VARCHAR} </if> </where> </select> <select id="getShopOrderList" resultType="com.heai.modules.production.entity.ShopOrderData"> select A.OrderNo ,A.Site ,A.EnterDate ,A.UserName ,A.NeedDate ,A.OriginalNeedDate ,A.PlanStartDate ,A.ReleaseDate ,A.ReleaseGuys ,A.ScheduleDate ,A.Scheduler ,A.IssueDate ,A.ReportDate ,A.ReceiveDate ,A.CloseDate ,A.Planner ,A.Status ,A.Status_Tmp ,A.Printed ,A.OrderType ,A.PartNo ,A.LotSize ,A.FinishedQty ,A.ProjectID ,A.BOMRevNo ,A.RoutingRevNo ,A.Leadtime ,A.Remark ,A.OrderRef1 ,A.OrderRef2 ,A.CostRollUpFlag ,A.ManualFlag ,A.OriSOOrderNo ,A.CustomerID ,A.TechInfo ,A.ReceiveStatus ,A.E_OriginalOrderNo ,A.E_Levels ,A.E_OriginalOrderType ,A.E_SeqNo ,A.E_LevelCode ,A.SFDCReportedFlag ,A.RepairSOFlag ,A.ConfigurationFlag ,A.MaterialSplitFlag ,A.ObjectVersion ,A.ExpandFlag ,A.CodeNo ,A.LE_SeqNo ,A.LE_ItemNo ,A.LE_Levels ,B.PartDescription from ShopOrder A left join Part B on A.site = B.site and A.PartNo = B.PartNo <where> <if test="site != null and site != ''"> and A.Site = #{site,jdbcType=VARCHAR} </if> <if test="orderNo != null and orderNo != ''"> and A.OrderNo = #{orderNo,jdbcType=VARCHAR} </if> </where> </select> <select id="getTransfer" resultType="com.heai.modules.production.entity.ShopOrderData"> select a.TransNo as transFerNo ,b.PartNo,c.PartDescription,a.Status,b.TransQty as lotSize,b.ConfirmQty as FinishedQty,a.Site, b.OrderNo,dbo.Get_PartWeightFactorForReport(A.Site ,b.PartNo,b.OrderNo) as weightFactor from SOOpsTransferHeader a left join SOOpsTransferDetail b on a.TransNo=b.TransNo and a.Site=b.Site LEFT JOIN Part c on b.partNo=c.partNo and c.site=a.site <where>
<if test="transFerNo != null and transFerNo != ''"> and a.TransNo = #{transFerNo} </if> </where> </select> <select id="getOperatorData" resultType="com.heai.modules.production.entity.OperatorData" > select Site,OperatorID,OperatorName,Active,Department,CreatedDate,Passwords,LineLeader from Operator <where> <if test="site != null and site != ''"> and Site = #{site} </if> <if test="operatorID != null and operatorID != ''"> and OperatorID like #{operatorID,jdbcType=VARCHAR} </if> <if test="operatorName != null and operatorName != ''"> and OperatorName like #{operatorName} </if> <if test="active != null and active != ''"> and Active = #{active} </if> </where> order by CreatedDate </select>
<select id="getWorkCenterData" resultType="WorkCenterData"> select a.Site,a.WorkCenterNo,a.WorkCenterDesc,a.Active FROM WorkCenter a left join operator_work_center b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo and b.OperatorID=#{operatorID} where a.site=#{site} and b.WorkCenterNo is null order by a.WorkCenterNo </select> <select id="getWorkCenterOperatorData" resultType="WorkCenterData"> select a.Site,a.WorkCenterNo,b.WorkCenterDesc,b.Active FROM operator_work_center a left join WorkCenter b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo where a.site=#{site} and a.OperatorID=#{operatorID} order by a.WorkCenterNo </select>
<insert id="addSkill"> insert into operator_work_center(OperatorID,WorkCenterNo,created_by,created_date,Site) values(#{operatorID},#{workCenterNo},#{user},GetDate(),#{site}) </insert>
<delete id="deleteSkill"> delete from operator_work_center where OperatorID=#{operatorID} and Site=#{site} and WorkCenterNo=#{workCenterNo} </delete> <insert id="addUserSkill"> insert into user_work_center(UserId,WorkCenterNo,created_by,created_date,Site) values(#{userId},#{workCenterNo},#{user},GetDate(),#{site}) </insert>
<delete id="deleteUserSkill"> delete from user_work_center where UserId=#{userId} and Site=#{site} and WorkCenterNo=#{workCenterNo} </delete> <select id="checkWorkCenterOperatorData" resultType="WorkCenterData"> select site FROM operator_work_center where OperatorID=#{operatorID} and Site=#{site} and WorkCenterNo=#{workCenterNo} </select>
<select id="checkUserOperatorData" resultType="WorkCenterData"> select site FROM user_work_center where userId=#{userId} and Site=#{site} and WorkCenterNo=#{workCenterNo} </select> <select id="getAllWorkCenterDataForUser" resultType="WorkCenterData"> select a.Site,a.WorkCenterNo,a.WorkCenterDesc,a.Active FROM WorkCenter a left join user_work_center b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo and b.userId=#{user} where b.WorkCenterNo is null order by a.WorkCenterNo ,a.site </select> <select id="getWorkCenterUserData" resultType="WorkCenterData"> select a.Site,a.WorkCenterNo,b.WorkCenterDesc,b.Active FROM user_work_center a left join WorkCenter b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo where a.userId=#{user} order by a.WorkCenterNo,a.site </select> <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.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,dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo) weightFactor, Round(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo)*a.LotSize,2) weight FROM ShopOrder a LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site LEFT JOIN 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} <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>--> <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="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="getSOTastRoutingData" resultType="ShopOrderRoutingData"> select a.site, a.OrderNo,a.PartNo,a.Status,a.OrderRef1,a.OrderDate,a.OrderQty as LotSize, P.PartDescription,P.Spec,isnull(SL.scheduledQty,0) as scheduledQty,s.workCenterNo,S.machSetupTime, S.machRunFactor,S.factorUnit,S.ItemNo,S.OperationDesc,s.Efficiency,a.qtyfinished,a.finishFlag,ROUND(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderRef1)*a.OrderQty,2) as weight, dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderRef1) as weightFactor FROM SOTaskOrderHeader a LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site LEFT JOIN SORouting S on S.site=a.site and S.OrderNo=a.OrderRef1 LEFT JOIN ScheduleList SL on S.site=SL.site and a.OrderNo=SL.orderNo and S.ItemNo=SL.ItemNo left join user_work_center uwc on a.site=uwc.site and 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 a.OrderNo LIKE #{orderNo} </if> <if test="status !=null and status != ''"> AND a.Status IN ${status} </if> <if test="startDate1 != null "> AND a.orderDate >= #{startDate1} </if> <if test="endDate1 != null "> AND #{endDate1} >= a.orderDate </if> <if test="orderRef1 != null and orderRef1 != ''"> AND a.OrderRef1 LIKE #{orderRef1} </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="finishFlag != null and finishFlag != ''"> AND a.FinishFlag=#{finishFlag} </if> </where> order by a.OrderDate desc,s.itemNo </select>
<select id="getWorkCenterOperatorList" resultType="OperatorData"> Select a.OperatorID,a.OperatorName from Operator a left join operator_work_center b on a.site=b.site and a.OperatorID=b.OperatorID where a.site=#{site} and b.WorkCenterNo=#{workCenterNo} 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="checkScheduleQtyForSoTask" resultType="ScheduleCheckData"> Select a.OrderQty as Qty,isnull(b.scheduledQty,0) scheduledQty from SOTaskOrderHeader 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> <insert id="saveScheduleListForSOTask"> insert into ScheduleList(Site,OrderNo,ItemNo,Type,Type_db,Qty,scheduledQty) values (#{site},#{orderNo},#{itemNo},'日计划派工单','D',#{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) values(#{site},#{orderNo},#{itemNo},#{seqNo},#{scheduleQty},0,0,dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderNo},#{itemNo},#{scheduleQty}),0,#{scheduleDate},#{scheduleDate} ,'*','',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}) </insert> <insert id="saveScheduleForSOTask"> 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) values(#{site},#{orderRef1},#{itemNo},#{seqNo},#{scheduleQty},0,0,dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderRef1},#{itemNo},#{scheduleQty}),0,#{scheduleDate},#{scheduleDate} ,'*','',1,'N',0,'Y',#{scheduleDate},#{resourceId},#{shiftNo},#{workCenterNo} ,'N','N','N',dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderRef1},#{itemNo},#{scheduleQty}),#{scheduleQty} ,'N','N',#{efficiency},GETDATE(),'日计划派工单',#{operatorId},#{partNo},#{orderNo}) </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="searchReportedQty" resultType="SORoutingData"> select top 1 isnull(a.QtyReported,0) QtyReported,isnull(SOP.TotalFinishedQty,0) lastApproveQty ,dbo.Get_PartWeightFactorForReport(#{site},#{partNo},#{orderNo}) as weightFactor,dbo.Get_sfdcReportedSetupTime(#{site},#{seqNo}) as timeReported, [dbo].[Get_Part_Cavity](#{site},#{partNo},#{orderNo}) as cavity from 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="searchLastApproveQty" resultType="SORoutingData"> select top 1 isnull(TotalFinishedQty,0) lastApproveQty from SORoutingOutput 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_PartDesc(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_DescSpec(a.Site,partNo) as partSpec,circulation_seqNo,circulation_qty ,dbo.Get_PartWeightFactorForReport(a.site,PartNo,OrderNo) as weightFactor,dbo.Get_Part_UMID(a.Site,PartNo) umid, Round(dbo.Get_PartWeightFactorForReport(a.site,PartNo,OrderNo)*QtyRequired,2) as weight 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="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="checkUserSeqNo" resultType="SOScheduledRoutingOutData"> select seqNo 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 seqNo=#{seqNo} and uwc.WorkCenterNo is not null </select> <select id="getStockPrint" resultType="com.heai.modules.production.entity.StockPrintData"> select TransNo,Site,WareHouseId,BatchNo,LocationId,PartNo,OrderNo,TransDate,Qty,PrintFlag,dbo.Get_PartDesc(Site,PartNo) as partDesc ,dbo.Get_WareHouseDesc(Site,WareHouseId) as wareHouseDesc,dbo.Get_Part_UMID(Site,PartNo) umid from StockPrint <where> <if test="startDate != null "> and TransDate >= #{startDate} </if> <if test="endDate != null "> and #{endDate} >= TransDate -1 </if> <if test="site != null and site != ''"> AND site = #{site} </if> <if test="orderNo != null and orderNo != ''"> AND orderNo LIKE #{orderNo} </if> <if test="seqNo != null and seqNo != ''"> AND seqNo = #{seqNo} </if> <if test="printFlag != null and printFlag != ''"> AND printFlag = #{printFlag} </if>
<if test="partNo != null and partNo != ''"> AND PartNo LIKE #{partNo} </if> </where> order by TransDate desc </select>
<update id="updatePrintStock"> update StockPrint set PrintFlag='Y' where Site=#{site} and TransNo=#{transNo} </update> <update id="updatePrintInfo"> update print_info set status='Y' where Site=#{site} and orderref1=#{transNo} </update>
<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_DescSpec(Site,partNo) as partSpec,closedFlag,outWorkFlag from SOScheduledRouting where site=#{site} and SeqNo=#{seqNo} </select>
<select id="checkELevels" resultType="Integer"> select isnull(E_Levels,-1) E_Levels from shoporder where site=#{site} and orderNo=#{orderNo} </select> <select id="getSOScheduledRoutingOutData" resultType="SOScheduledRoutingOutData"> select Site,OrderNo,seqNo from SOScheduledRouting where seqNo=#{seqNo} </select>
<select id="getsfdcTimeHistData" resultType="com.heai.modules.production.entity.SfdcTimeHistData"> select top 1 site,OrderNo,ItemNo,SeqNo,#{username} as Enteredby ,ClosedFlag,OutWorkFlag from SOScheduledRouting where site=#{site} and SeqNo=#{seqNo} and ClosedFlag='N' </select> <select id="getSeqNoSite" resultType="String"> select site from SOScheduledRouting where SeqNo=#{seqNo} </select>
<select id="checkSfdcTimeHistData" resultType="com.heai.modules.production.entity.SfdcTimeHistData"> select site,OrderNo,ItemNo,SeqNo from SFDC_TimeHist where site=#{site} and seqNo=#{seqNo} and EventDesc='开始生产' and CompletedFlag='N' </select>
<select id="getHistSeqNo" resultType="Integer"> select isnull(max(HistSeqNo),0)+1 from SFDC_TimeHist where site=#{site} and seqNo=#{seqNo} </select> <update id="updateSfdcTimeHistDataContinue" > Update SFDC_TimeHist set CompletedFlag='Y' ,TillTime=GETDATE(),TillEnteredTime=GETDATE(),TillEnteredBy=#{enteredby},TotalTime=Round(datediff(mi,EventTime,GETDATE())/60.0,2) where SeqNo=#{seqNo,jdbcType=INTEGER} and Site=#{site} and CompletedFlag='N' and EventDesc='暂停生产'
</update> <update id="updateStopWork" > update SOScheduledRouting set OutWorkFlag=#{flag} where Site=#{site} and seqNo=#{seqNo} </update> <insert id="saveSfdcTimeHistDataStart"> insert into SFDC_TimeHist (Site,OrderNo,ItemNo,SeqNo,HistSeqNo,EventTime,Enteredby,EventDesc,DowntimeCode,EventType,LinkHistSeqNo,TillTime,TillEnteredTime, TillEnteredBy,CompletedFlag,TotalTime,DowntimePhaseIn,RollNo) values (#{site},#{orderNo},#{itemNo},#{seqNo},#{histSeqNo},GetDate(),#{enteredby},'开始生产','','P',null,null,null,null,'N',0,'','*') </insert> <insert id="saveSfdcTimeHistDataStop"> insert into SFDC_TimeHist (Site,OrderNo,ItemNo,SeqNo,HistSeqNo,EventTime,Enteredby,EventDesc,DowntimeCode,EventType,LinkHistSeqNo,TillTime,TillEnteredTime, TillEnteredBy,CompletedFlag,TotalTime,DowntimePhaseIn,RollNo) values (#{site},#{orderNo},#{itemNo},#{seqNo},#{histSeqNo},GetDate(),#{enteredby},'暂停生产','','D',null,null,null,null,'N',0,'','*') </insert>
<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,'N','N','N',#{scheduleType},#{operatorId},#{partNo},#{orderRef1} ) </insert>
<update id="closeSchedule"> update SOScheduledRouting set ClosedFlag='Y' where site=#{site} and seqNo=#{seqNo} </update>
<select id="getTransData" resultType="com.heai.modules.production.entity.SOOpsTransferData"> select top 1 a.TransNo,a.Site,b.FromWorkCenterNo WorkCenterNo ,b.OrderNo,b.TransQty,a.TransDate,b.PartNo,b.seqNo,dbo.Get_Part_DescSpec(a.Site,b.PartNo) partDesc ,dbo.Get_Part_UMID(a.Site,b.PartNo) umid FROM SOOpsTransferHeader a left join SOOpsTransferDetail b on a.site=b.site and a.TransNo=b.TransNo where a.TransNo=#{transNo} and a.Site=#{site} </select>
<select id="searchTaskTransNo" resultType="String"> select top 1 TransNo from SOOpsTransferDetail where OrderNo=#{taskNo} and site=#{site} </select>
<select id="transFerSearch" resultType="com.heai.modules.production.entity.SOOpsTransferData"> SELECT a.transNo ,a.site,b.seqNo,a.TransDate,b.TransQty ,b.OrderNo ,b.PartNo,c.PartDescription as partDesc FROM SOOpsTransferHeader a LEFT JOIN SOOpsTransferDetail b on a.TransNo=b.TransNo and a.site=b.Site LEFT JOIN Part c on b.PartNo=c.PartNo and b.site=c.site
<where> and a.Status='已录入' <if test="startDate != null "> and TransDate >= #{startDate} </if> <if test="endDate != null "> and #{endDate} >= TransDate -1 </if> <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 != ''"> AND seqNo = #{seqNo} </if>
<if test="partNo != null and partNo != ''"> AND b.PartNo LIKE #{partNo} </if> </where> ORDER BY a.TransDate </select>
<select id="getPartCardPrintData" resultType="com.heai.modules.production.entity.PartCardPrintData"> select top 1 a.orderNo,a.partNo,c.partDescription+'/'+C.Spec as partDesc,a.QtyRequired,a.S_ScheduledDate, dbo.Get_OperatorDesc(a.site,a.operatorId) OperatorName ,c.ToExpireDays,b.TechInfo,c.remark,Round(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo)*a.QtyRequired,2) as weight
from SOScheduledRouting a left join ShopOrder b on a.site=b.site and a.OrderNo=b.OrderNo left join part c on a.partNo=c.PartNo and a.site=c.site where a.site=#{site} and a.seqNo=#{seqNo} </select>
<select id="checkTool" resultType="com.heai.modules.production.entity.SOToolData"> select ToolID from SOTool where site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo} </select>
<select id="getHunlianTaskNo" resultType="String"> select 'HL'+CONVERT(varchar(100), GETDATE(), 112)+ Right( '00000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(TaskNo, 11,4))),0)+1) ,4) from Hunlian_TaskHeader where TaskNo like 'HL'+CONVERT(varchar(100), GETDATE(), 112)+'%' </select>
<insert id="saveHunlianTaskDetailData" > insert into Hunlian_TaskDetail (Site,TaskNo,OrderNo,OrderRef1,OrderRef2,OrderQty,HunlianQty,OrderDate,PartNo,HunlianPartNo)
select top 1 #{site},#{taskNo},#{orderNo},#{orderRef1},SO.OrderNo, SOT.OrderQty,#{hunlianQty},#{orderDate},SOT.partNo,#{hunlianPartNo}
from SOTaskOrderHeader SOT left join ShopOrder t on t.site=#{site} and t.orderNo=#{orderRef1} left join ShopOrder SO on SOT.site=SO.Site and t.E_OriginalOrderNo=SO.E_OriginalOrderNo and t.E_OriginalOrderType=SO.E_OriginalOrderType and SO.E_Levels=2 where SOT.site=#{site} and SOT.orderNo=#{orderNo} </insert>
<select id="checkTask" resultType="com.heai.modules.production.entity.HunlianTaskDetailData"> select OrderNo as orderRef1 ,orderNo_hunlian as orderNo FROM view_KANBAN_SO_Hunlian_Plan where site=#{site} and (erpStatus='已取消' or FinishedFlag in ('2','3') or dispatched_hunlian='Y' ) and orderNo_hunlian in (select orderNo from Hunlian_TaskDetail where site=#{site} and TaskNo=#{taskNo} ) </select>
<update id="updateSOTaskDispatchedFlag" > update SOTaskOrderHeader set dispatched_hunlian =#{flag} where site=#{site} and orderNo in (select orderNo from Hunlian_TaskDetail where site=#{site} and TaskNo=#{taskNo} ) </update>
<update id="updateTaskReportFlag" > update Hunlian_TaskHeader set ReportFlag=#{flag} ,ReportQty=#{reportQty} where site=#{site} and TaskNo=#{taskNo} </update>
<insert id="saveHunlianTaskHeaderData" > insert into Hunlian_TaskHeader (Site,TaskNo,TaskQty,PartNo,CreateDate,CreateBy,ReportFlag,ReportQty,DeleteFlag,WareHouseFlag,WareHouseQty) values(#{site},#{taskNo},#{taskQty},#{partNo},GetDate(),#{createBy},'N',0,'N','N',0) </insert>
<select id="getHunlianTaskData" resultType="com.heai.modules.production.entity.HunlianData"> select a.Site,a.TaskNo,a.TaskQty,a.PartNo,a.CreateDate,a.CreateBy,a.ReportFlag,a.ReportQty,dbo.Get_Part_DescSpec(a.Site,a.PartNo) as partDesc ,b.toExpireDays,a.WareHouseFlag from Hunlian_TaskHeader a left join part b on a.site=b.site and a.PartNo=b.partNo <where> and a.deleteFlag='N' <if test="startDate != null "> and a.CreateDate >= #{startDate} </if> <if test="endDate != null "> and #{endDate} >= a.CreateDate -1 </if>
<if test="reportFlag != null and reportFlag != ''"> AND a.reportFlag = #{reportFlag} </if> <if test="partNo != null and partNo != ''"> AND a.partNo like #{partNo} </if>
<if test="taskNo != null and taskNo != ''"> AND a.taskNo LIKE #{taskNo} </if> </where> ORDER BY a.CreateDate </select>
<select id="getHunlianTaskDetailData" resultType="com.heai.modules.production.entity.HunlianTaskDetailData"> select a.Site,a.TaskNo,a.OrderNo,a.OrderRef1,a.OrderRef2,a.OrderQty,a.HunlianQty,a.OrderDate,a.PartNo,a.HunlianPartNo, dbo.Get_Part_DescSpec(a.Site,a.HunlianPartNo) as partDesc from Hunlian_TaskDetail a
where site=#{site} and TaskNo=#{taskNo} </select>
<select id="getHunlianTaskDetailDataSum" resultType="com.heai.modules.production.entity.HunlianTaskDetailData"> select a.Site,a.TaskNo,a.OrderRef2,SUM(a.HunlianQty) HunlianQty,a.HunlianPartNo
from Hunlian_TaskDetail a
where site=#{site} and TaskNo=#{taskNo} GROUP BY a.Site,a.TaskNo,a.OrderRef2,a.HunlianPartNo </select>
<select id="checkTaskHeader" resultType="com.heai.modules.production.entity.HunlianData"> select Site,TaskNo,TaskQty,PartNo,CreateDate,CreateBy,ReportFlag,ReportQty,DeleteFlag,DeleteBy,DeleteDate,WareHouseFlag from Hunlian_TaskHeader where site=#{site} and DeleteFlag='N' and TaskNo=#{taskNo} </select>
<select id="checkTaskOrder" resultType="com.heai.modules.production.entity.HunlianData"> select orderNo from shopOrder where status in ('已取消','已关闭') and site=#{site} and orderNo in (select orderRef1 from Hunlian_TaskDetail where site=#{site} and taskNo=#{taskNo} )
</select>
<update id="deleteTask"> update Hunlian_TaskHeader set DeleteFlag='Y' where site=#{site} and TaskNo=#{taskNo} </update>
<update id="updateSOTaskReport" parameterType="com.heai.modules.production.entity.DailyReportInData"> update SOTaskOrderHeader SET Qtyfinished=Round(#{reportQty}*#{orderQty}/#{taskQty},1),ReportTime=GetDate(),FinishFlag='Y',ReportBy=#{userId} ,InputQty=Round(#{reportQty}*#{hunlianQty}/#{taskQty},1) where OrderNo=#{orderNo} and site =#{site} </update>
<update id="cancelReportSOTask" parameterType="com.heai.modules.production.entity.HunlianData"> update SOTaskOrderHeader SET Qtyfinished=0,ReportTime=null,FinishFlag='N',ReportBy=null ,InputQty=0 where site =#{site} and orderNo in (select orderNo from Hunlian_TaskDetail where site =#{site} and taskNo=#{taskNo}) </update>
<insert id="saveSOOpsTransferHeader"> INSERT INTO SOOpsTransferHeader (TransNo,Site,FromProLineNo,ToProLineNo,ToWarehouseID,FromEnteredby,FromEnteredDate,TransDate,ToReceiver,FromReceiver, FromRemark,ToRemark,ConfirmedFlag,ToConfirmedBy,ToEnteredby,LatestUpdatedBy,LatestUpdatedDate,RecordVersion, Status,ToTypeFlag_DB,ToTypeFlag,ConfirmedTransNo,need_inspect_flag) VALUES (#{transNo},#{site},'*','*','*',#{userId},GETDATE(),GETDATE(),'',#{userId}, '','','N','N','',#{userId},GETDATE(),'0', '已录入','W','混炼胶入库','','N') </insert> <insert id="saveSOOpsTransferDetail"> INSERT INTO SOOpsTransferDetail (TransNo,Site,ItemNo,FromOpsID,FromWorkCenterNo,ToWorkCenterNo,ToOpsID,OrderNo,PartNo,TransQty,ConfirmQty,TaskNo,InsStatus, ToConfirmQty) VALUES ( #{transNo},#{site},1,1,'*','',0,#{taskNo},#{partNo},#{reportQty},0,#{taskNo},'合格',0) </insert>
<select id="getTransNo" resultType="String"> select 'OT'+CONVERT(varchar(100), GETDATE(), 112)+ Right( '00000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(TransNo, 11,4))),0)+1) ,4) from SOOpsTransferHeader where TransNo like 'OT'+CONVERT(varchar(100), GETDATE(), 112)+'%' </select> <select id="checkLocationId" resultType="com.heai.modules.production.entity.LocationData"> select LocationID,Site,LocationName,WareHouseID,Keeper,Active from Location where site=#{site} and LocationID=#{locationId} </select> <delete id="deleteSOOpsTransferHeader"> update SOOpsTransferHeader set Status='已取消' where site=#{site} and transNo=#{transNo} </delete>
<delete id="deleteSOOpsTransferDetail"> delete from SOOpsTransferDetail where site=#{site} and transNo=#{transNo} </delete></mapper>
|