|
|
<?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.xujie.sys.modules.orderIssure.mapper.IssureNotifyMapper"> <select id="getUserNotifyNo" resultType="SOIssueNotifyHeaderData"> select top 1 a.NotifyNo,a.Site,a.NotifyDate,a.UserName,a.EnteredDate,a.Receiver,a.DepartmentID,a.Remark,a.CreditFlag,a.IssueFlag, a.IssueResult,a.PlanIssueDate,a.RealIssueDate,a.Status,a.HaveIssueRecordFlag,a.CalcFlag,a.NeedApproveFlag,a.ApprovedFlag, a.Approver,a.ApproveDate,a.WarehouseID,a.RecordVersion,a.OutWorkOrderFlag,a.ProjectID,a.OrderType,a.AuthRuleID,a.bu from SOIssueNotifyHeader a where a.Site=#{site} and a.UserName=#{userName} and a.Status='已计划' order by a.EnteredDate desc
</select>
<insert id="createNotify"> insert into SOIssueNotifyHeader (NotifyNo,Site,NotifyDate,UserName,EnteredDate,Receiver,DepartmentID,Remark,CreditFlag,IssueFlag,IssueResult,PlanIssueDate,RealIssueDate,Status,HaveIssueRecordFlag,CalcFlag,NeedApproveFlag,ApprovedFlag,Approver,ApproveDate,WarehouseID,RecordVersion,OutWorkOrderFlag,ProjectID,OrderType,AuthRuleID,bu) values(#{notifyNo},#{site},#{notifyDate},#{userName},#{enteredDate},#{receiver},#{departmentID},#{remark},#{creditFlag},#{issueFlag},#{issueResult},#{planIssueDate}, #{realIssueDate},#{status},#{haveIssueRecordFlag},#{calcFlag},#{needApproveFlag},#{approvedFlag},#{approver},#{approveDate},#{warehouseID}, #{recordVersion},#{outWorkOrderFlag},#{projectID},#{orderType},#{authRuleID},#{bu} ) </insert> <update id="updateNotifyBu"> update SOIssueNotifyHeader set bu=#{bu} where site=#{site} and NotifyNo=#{notifyNo} </update>
<select id="getNotifyNoDetail" resultType="SOIssueNotifyOrderListData"> select a.NotifyNo,a.Site,a.ItemNo,a.FGPartNo,a.SOOrderNo,a.OpsItemNo,a.SeqNo,a.IssureQty,a.OutWorkOrderFlag,a.locationNo,a.needDate ,b.operation_desc itemDesc from SOIssueNotifyOrderList a left join so_routing b on a.site=b.site and a.SOOrderNo=b.order_no and b.item_no=a.OpsItemNo where a.site=#{site} and a.NotifyNo=#{notifyNo} </select>
<select id="getSOScheduledRoutingListForIssure" resultType="SOScheduledRoutingData"> select a.site,a.orderno,a.itemno,b.operation_desc itemDesc,a.seqno,a.qtyrequired,a.qtyreported,a.remark, a.s_scheduleddate,a.s_resourceid,dbo.getResourceDesc(a.site,a.s_resourceid) ResourceDesc,a.s_shiftno, dbo.getScheduleShiftDesc(a.site,a.s_shiftno) shiftDesc,a.s_workcenterno,a.part_no,a.operator_id, c.work_center_desc workCenterDesc,dbo.Get_PartDesc(a.site,a.part_no) partDesc, dbo.getOperatorDesc(a.site,a.operator_id) operatorDesc from soscheduledrouting a left join so_routing b on a.site=b.site and a.orderno=b.order_no and b.item_no=a.itemno left join work_center c on a.site=c.site and a.s_workcenterno=c.work_center_no left join part d on a.site=d.site and a.part_no=d.part_no <where> and a.closed_flag='N' <if test="partNo != null and partNo != ''"> and a.part_no like #{partNo} </if> <if test="seqno != null and seqno != ''"> and a.seqno like #{seqno} </if> <if test="operatorDesc != null and operatorDesc != ''"> and dbo.getOperatorDesc(a.site,a.operator_id) like #{operatorDesc} </if> <if test="orderno != null and orderno != ''"> and a.orderno like #{orderno} </if> <if test="sShiftno != null and sShiftno != ''"> and a.s_shiftno like #{sShiftno} </if> <if test="sResourceid != null and sResourceid != ''"> and a.s_resourceid like #{sResourceid} </if> <if test="sWorkcenterno != null and sWorkcenterno != ''"> and a.s_workcenterno like #{sWorkcenterno} </if> <if test="operatorId != null and operatorId != ''"> and a.operator_id like #{operatorId} </if> <if test="startDate != null "> AND a.s_scheduleddate >= #{startDate} </if> <if test="endDate != null "> AND #{endDate} >= a.s_scheduleddate </if> and a.site=#{site} and d.sourceBu=#{bu} </where> order by a.s_scheduleddate </select>
<!-- <select id="getSOSBOMForIssure" resultType="SOIssueNotifyOrderMaterialListData">--><!-- select a.site,b.ItemNo,a.item_no_mat as BOMItemNo,a.component_partno as ComponentPartNo,--><!-- round(a.qty_assembly*b.IssureQty,2) qty_required , round(a.qty_issue,2) qty_issue,c.QtyToIssue,#{notifyNo} as notifyNo--><!-- ,dbo.Get_PartDesc(a.site,a.component_partno) partDesc,Round( dbo.get_MaterialOnUse(a.site,a.order_no,a.item_no,a.component_partno),3) qtyOnHand--><!-- from so_bom a--><!-- left join SOIssueNotifyOrderList b on a.site=b.site and b.NotifyNo=#{notifyNo} and b.seqNo=#{seqno}--><!-- left join SOIssueNotifyOrderMaterialList c on a.site=c.site and a.item_no_mat=c.BOMItemNo and c.NotifyNo=#{notifyNo} and c.itemNo=b.itemNo--><!--<!– left join SOIssueNotifyOrderList d on a.site=d.site and c.NotifyNo=d.NotifyNo and c.itemNo=d.itemNo–>--><!-- where a.site=#{site} and a.order_no=#{orderno} and a.item_no=#{itemno,jdbcType=DOUBLE} and a.control_mes='Y'--><!-- order by a.item_no--><!-- </select>-->
<select id="getSOSBOMForIssure" resultType="SOIssueNotifyOrderMaterialListData"> select a.site,b.ItemNo,a.item_no_mat as BOMItemNo,a.component_partno as ComponentPartNo, round(a.qty_assembly*b.IssureQty,2) qty_required , round(a.qty_issue,2) qty_issue,c.QtyToIssue,#{notifyNo} as notifyNo ,dbo.Get_PartDesc(a.site,a.component_partno) partDesc,Round( dbo.get_MaterialOnUse(a.site,a.order_no,a.item_no,a.component_partno),3) qtyOnHand, round(sum(h.qty_on_hand),2) stockQty,c.remark from so_bom a left join SOIssueNotifyOrderList b on a.site=b.site and b.NotifyNo=#{notifyNo} and b.seqNo=#{seqno} left join SOIssueNotifyOrderMaterialList c on a.site=c.site and a.item_no_mat=c.BOMItemNo and c.NotifyNo=#{notifyNo} and c.itemNo=b.itemNo left join view_custdev_currentstock h on a.site=h.site and a.component_partno=h.part_no<!-- left join SOIssueNotifyOrderList d on a.site=d.site and c.NotifyNo=d.NotifyNo and c.itemNo=d.itemNo--> where a.site=#{site} and a.order_no=#{orderno} and a.item_no=#{itemno,jdbcType=DOUBLE} and a.control_mes='Y' group by a.site,b.ItemNo,a.item_no_mat,a.component_partno,a.qty_assembly,b.IssureQty,a.qty_issue,c.QtyToIssue,a.order_no,a.item_no,a.control_mes,c.remark<!-- UNION all--><!-- select b.site,b.ItemNo,c.BOMItemNo,c.ComponentPartNo,--><!-- null as qty_required , null qty_issue,c.QtyToIssue,#{notifyNo} as notifyNo--><!-- ,dbo.Get_PartDesc(c.site,c.ComponentPartNo) partDesc,Round( dbo.get_MaterialOnUse(b.site,b.SOOrderNo ,b.OpsItemNo,c.ComponentPartNo),3) qtyOnHand,--><!-- round(sum(h.qty_on_hand),2) stockQty,c.remark--><!-- from SOIssueNotifyOrderList b--><!-- left join SOIssueNotifyOrderMaterialList c on b.site=c.site and c.NotifyNo=#{notifyNo} and c.itemNo=b.itemNo--><!-- left join so_bom a on a.site=b.site and a.order_no=b.SOOrderNo and a.item_no=b.OpsItemNo and a.control_mes='Y'--><!-- and a.component_partno=c.ComponentPartNo--><!-- left join view_custdev_currentstock h on c.site=h.site and c.ComponentPartNo=h.part_no--><!-- WHERE b.NotifyNo=#{notifyNo} and b.seqNo=#{seqno} and b.site=#{site} and a.item_no_mat is null and c.ComponentPartNo is not null--><!-- group by b.site,b.ItemNo,c.BOMItemNo,c.ComponentPartNo,c.QtyToIssue,c.site,b.SOOrderNo ,b.OpsItemNo,c.remark-->
</select>
<select id="searchOtherPart" resultType="SOIssueNotifyOrderMaterialListData"> select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType ,dbo.Get_PartDesc(site,ComponentPartNo) partDesc,remark from SOIssueNotifyOrderMaterialList where NotifyNo=#{notifyNo} and site=#{site} and issueType=#{issueType} </select> <select id="getNextItemForSOIssueNotifyOrderList" resultType="Double"> select isnull(max(ItemNo),0)+1 from SOIssueNotifyOrderList where site=#{site} and NotifyNo=#{notifyNo} and 998>ItemNo </select>
<insert id="saveSOIssueNotifyOrderList"> insert into SOIssueNotifyOrderList(NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate) values(#{notifyNo},#{site},#{itemNo},#{fGPartNo},#{sOOrderNo},#{opsItemNo},#{seqNo},#{issureQty,jdbcType=DECIMAL},#{outWorkOrderFlag} ,#{locationNo},#{needDate}) </insert> <delete id="deleteSOIssueNotifyOrderMaterialListData"> delete from SOIssueNotifyOrderMaterialList where site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo}
</delete> <insert id="batchSaveSOIssueNotifyOrderMaterialListData"> insert into SOIssueNotifyOrderMaterialList (NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType,remark) values <foreach collection="list" separator="," item="item"> (#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue},0,#{item.issueType},#{item.remark}) </foreach> </insert>
<insert id="saveSOIssueNotifyOrderMaterialListData"> insert into SOIssueNotifyOrderMaterialList (NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType,remark) values
(#{notifyNo},#{site},#{itemNo},#{bOMItemNo},#{componentPartNo},#{qtyToIssue},0,#{issueType},#{remark})
</insert>
<delete id="deleteNotifySOS"> delete from SOIssueNotifyOrderList where site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo} </delete>
<update id="xiadaNotifyHeader"> update SOIssueNotifyHeader set PlanIssueDate=#{planIssueDate},remark=#{remark} ,status='已下达' where site=#{site} and NotifyNo=#{notifyNo} </update>
<delete id="deleteNotifyHeader"> delete from SOIssueNotifyHeader where site=#{site} and NotifyNo=#{notifyNo} </delete>
<select id="searchNotifyHeader" parameterType="SOIssueNotifyHeaderData" resultType="SOIssueNotifyHeaderData"> select a.NotifyNo,a.Site,a.NotifyDate,a.UserName,a.EnteredDate,a.Receiver,a.DepartmentID,a.Remark,a.CreditFlag,a.IssueFlag, a.IssueResult,a.PlanIssueDate,a.RealIssueDate,a.Status,a.HaveIssueRecordFlag,a.CalcFlag,a.NeedApproveFlag,a.ApprovedFlag, a.Approver,a.ApproveDate,a.WarehouseID,a.RecordVersion,a.OutWorkOrderFlag,a.ProjectID,a.OrderType,a.AuthRuleID,(CASE WHEN a.confirm_status IS NULL THEN '未确认' ELSE a.confirm_status END) as confirm_status ,dbo.plm_get_user_display(a.Site,a.UserName) userDisplay, a.confirm_user_id,a.confirm_username,a.confirm_user_display,a.confirm_date, c.workShopName,d.needDate from SOIssueNotifyHeader a left join sys_user b on a.UserName=b.username left join eam_WorkShop c on b.workShopId=c.workShopId LEFT JOIN SOIssueNotifyOrderList d on a.site=d.site and a.NotifyNo=d.NotifyNo and d.ItemNo = '1' <where>
<if test="query.notifyNo != null and query.notifyNo != ''"> AND a.NotifyNo = #{query.notifyNo} </if> <if test="query.status != null and query.status != ''"> AND a.Status = #{query.status} </if> <if test = "query.userName != null and query.userName != ''"> AND a.UserName LIKE #{query.userName} </if> <if test = "query.issueFlag != null and query.issueFlag != ''"> AND a.issueFlag LIKE #{query.issueFlag} </if> <if test = "query.issueResult != null and query.issueResult != ''"> AND a.issueResult LIKE #{query.issueResult} </if> <if test = "query.startDate != null "> AND a.NotifyDate >= #{query.startDate} </if> <if test = "query.endDate != null"> AND #{query.endDate} >=a.NotifyDate </if> <if test = "query.confirmStatus != null and query.confirmStatus != ''"> <choose> <when test="query.confirmStatus == '未确认'"> AND (a.confirm_status = #{query.confirmStatus} or a.confirm_status is null) </when> <otherwise> AND a.confirm_status = #{query.confirmStatus} </otherwise> </choose> </if> <if test = "query.sql != null and query.sql != ''"> ${query.sql} </if> <if test = "query.workShopId != null and query.workShopId != ''"> AND b.workShopId in ${query.workShopId} </if> </where> order by a.NotifyNo </select>
<select id="searchNotifyOrderList" resultType="SOIssueNotifyOrderListData"> select a.NotifyNo,a.Site,a.ItemNo,a.FGPartNo,a.SOOrderNo,a.OpsItemNo,a.SeqNo, a.IssureQty,a.OutWorkOrderFlag ,b.operation_desc itemDesc,a.locationNo,a.needDate, dbo.Get_PartDesc(a.site,a.FGPartNo) partDesc from SOIssueNotifyOrderList a left join so_routing b on a.site=b.site and a.SOOrderNo=b.order_no and a.OpsItemNo=b.item_no where a.NotifyNo=#{notifyNo} and a.site=#{site} order by a.ItemNo </select>
<select id="searchNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData"> select a.NotifyNo,a.Site,a.ItemNo,a.BOMItemNo,a.ComponentPartNo,a.QtyToIssue,a.QtyToIssue_Original ,b.FGPartNo,b.OpsItemNo,b.SOOrderNo orderNo,b.SeqNo, dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc ,b.locationNo,a.issueType,b.needDate,a.remark,a.timeout_reason from SOIssueNotifyOrderMaterialList a left join SOIssueNotifyOrderList b on a.site=b.site and a.NotifyNo=b.NotifyNo and a.ItemNo=b.ItemNo where a.NotifyNo=#{notifyNo} and a.site=#{site} order by b.needDate,a.ItemNo </select>
<select id="searchSumNotifyMaterialList" resultType="SOIssueNotifyOrderMaterialListData"> select a.ComponentPartNo,sum(a.QtyToIssue) QtyToIssue,sum(isnull(a.QtyToIssue_Original,0)) QtyToIssue_Original, dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,a.issueType from SOIssueNotifyOrderMaterialList a where a.NotifyNo=#{notifyNo} and a.site=#{site} group by a.site,a.ComponentPartNo,a.issueType order by a.issueType </select>
<select id="getPartList" resultType="PartData" > select top 1000 part_no,part_desc,umid,spec,sku,cinv_source_code from part <where> and site = #{site} and sourceBu = #{sourceBu} and control_mes='G' <if test="partNo != null and partNo != ''"> AND part_no LIKE '%'+ #{partNo} + '%' </if> <if test = "partDesc != null and partDesc != ''"> AND part_desc LIKE '%'+ #{partDesc}+ '%' </if> <if test = "spec != null and spec != ''"> AND spec LIKE '%'+ #{spec}+ '%' </if>
</where> </select> <select id="getNoControlPartList" resultType="PartData" > select top 1000 part_no,part_desc,umid,spec,sku,cinv_source_code from part <where> and site = #{site} and sourceBu = #{sourceBu} and control_mes='N' <if test="partNo != null and partNo != ''"> AND part_no LIKE '%'+ #{partNo} + '%' </if> <if test = "partDesc != null and partDesc != ''"> AND part_desc LIKE '%'+ #{partDesc}+ '%' </if> <if test = "spec != null and spec != ''"> AND spec LIKE '%'+ #{spec}+ '%' </if>
</where> </select>
<select id="checkPartStock" resultType="SOIssueNotifyOrderMaterialListData" > select g.ComponentPartNo,g.QtyToIssue ,g.partDesc,sum(h.qty_on_hand) qty_on_hand,sum(h.qty_available) qty_available from ( select a.ComponentPartNo,sum(a.QtyToIssue) QtyToIssue,sum(isnull(a.QtyToIssue_Original,0)) QtyToIssue_Original, dbo.Get_PartDesc(a.site,a.ComponentPartNo) partDesc,a.site from SOIssueNotifyOrderMaterialList a where a.NotifyNo=#{notifyNo} and a.site=#{site} group by a.site,a.ComponentPartNo ) g left join view_custdev_currentstock h on g.site=h.site and g.ComponentPartNo=h.part_no
group by g.ComponentPartNo,g.QtyToIssue ,g.partDesc </select>
<select id="checkDeleteOrderList" resultType="SOIssueNotifyOrderMaterialListData" > select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo,jdbcType=DOUBLE} </select>
<update id="updateNotifyStatus" > update SOIssueNotifyHeader set status=#{status} where Site=#{site} and NotifyNo=#{notifyNo} </update>
<select id="checkDeleteMaterial" resultType="SOIssueNotifyOrderMaterialListData"> select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo} and BOMItemNo=#{bOMItemNo} </select> <select id="deleteNotifyMaterial"> delete from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo} and BOMItemNo=#{bOMItemNo} </select> <insert id="saveIssueNotifyChangeLog"> insert into IssueNotifyChangeLog (Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType) values (#{site},#{notifyNo},#{itemNo},#{sOOrderNo},#{seqNo},#{componentPartNo},#{qtyToIssue,jdbcType=DOUBLE},#{updateType},#{updateBy},#{updateDate},#{issueType}) </insert>
<select id="getSOIssueNotifyOrderListData" resultType="com.xujie.sys.modules.orderIssure.vo.SOIssueNotifyOrderList"> select NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate from SOIssueNotifyOrderList where Site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo} </select>
<select id="checkOtherPart" resultType="SOIssueNotifyOrderMaterialListData"> select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo} and ComponentPartNo=#{componentPartNo} </select>
<select id="getNextBomItemNo" resultType="String">
SELECT #{str}+ CONVERT(VARCHAR(50),isnull( max(CONVERT(int,SUBSTRING(BOMItemNo, LEN(#{str})+1, LEN(BOMItemNo)))+1),1))
FROM SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo} and BOMItemNo like #{str}+'%'
</select>
<select id="searchIssueNotifyChangeLog" resultType="com.xujie.sys.modules.orderIssure.vo.IssueNotifyChangeLog"> select Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType from IssueNotifyChangeLog where Site=#{site} and NotifyNo=#{notifyNo} </select>
<select id="insertNotifyLogClose" > insert into SOIssueNotifyLog (Site,NotifyNo,[Action],username,ActionTime,ActionRemark) values (#{site},#{notifyNo},'关闭',#{username},GetDate(),#{closeRemark}) </select>
<select id="insertNotifyLogOpen"> insert into SOIssueNotifyLog (Site,NotifyNo,[Action],username,ActionTime,ActionRemark) values (#{site},#{notifyNo},'开启',#{username},GetDate(),'重新开启') </select>
<select id="searchNotifyLogClose" resultType="SOIssueNotifyLogData"> select id,Site,NotifyNo,[Action],username,ActionTime,ActionRemark ,dbo.plm_get_user_display(Site,username) userDisplay from SOIssueNotifyLog where site=#{site} and NotifyNo=#{notifyNo} order by id </select>
<!-- 超时未配料清单:已发数量 < 申请数量 且 当前时间 > 需求时间 --> <select id="searchOvertimeMaterialList" resultType="SOIssueNotifyOrderMaterialListData"> SELECT m.NotifyNo, m.Site, m.ItemNo, m.BOMItemNo, m.ComponentPartNo, m.QtyToIssue, m.QtyToIssue_Original, m.issueType, m.remark , dbo.Get_PartDesc(m.Site, m.ComponentPartNo) AS partDesc, o.needDate, o.locationNo, h.Status, (CASE WHEN h.confirm_status IS NULL THEN '未确认' ELSE h.confirm_status END) AS confirmStatus, h.UserName, dbo.plm_get_user_display(h.Site, h.UserName) AS userDisplay, h.NotifyDate, h.EnteredDate, w.workShopName, o.SOOrderNo as orderNo, o.OpsItemNo as opsItemNo, o.SeqNo as seqNo, m.timeout_reason, calc.overtimeMinutes
FROM SOIssueNotifyOrderMaterialList m INNER JOIN SOIssueNotifyOrderList o ON m.Site = o.Site AND m.NotifyNo = o.NotifyNo AND m.ItemNo = o.ItemNo INNER JOIN SOIssueNotifyHeader h ON m.Site = h.Site AND m.NotifyNo = h.NotifyNo LEFT JOIN sys_user u ON h.UserName = u.username LEFT JOIN eam_WorkShop w ON u.workShopId = w.workShopId CROSS APPLY ( SELECT CASE when h.confirm_status = '确认' then DATEDIFF(MINUTE, o.needDate, h.confirm_date)/ 60.0 else DATEDIFF(MINUTE, o.needDate, GETDATE())/ 60.0 end as overtimeMinutes ) AS calc <where> AND m.Site = #{query.site}
AND DATEDIFF(MINUTE, o.needDate, GETDATE()) > 0 AND calc.overtimeMinutes > 0
<if test="query.overtimeNotDistributed != null and query.overtimeNotDistributed == false"> AND ISNULL(m.QtyToIssue_Original,0) < ISNULL(m.QtyToIssue,0) </if>
<if test="query.notifyNo != null and query.notifyNo != ''"> AND m.NotifyNo = #{query.notifyNo} </if> <if test="query.componentPartNo != null and query.componentPartNo != ''"> AND m.ComponentPartNo LIKE '%' + #{query.componentPartNo} + '%' </if> <if test="query.partDesc != null and query.partDesc != ''"> AND dbo.Get_PartDesc(m.Site, m.ComponentPartNo) LIKE '%' + #{query.partDesc} + '%' </if> <if test="query.userName != null and query.userName != ''"> AND h.UserName LIKE #{query.userName} </if> <if test="query.status != null and query.status != ''"> AND h.Status = #{query.status} </if> <if test="query.confirmStatus != null and query.confirmStatus != ''"> <choose> <when test="query.confirmStatus == '未确认'"> AND (h.confirm_status = #{query.confirmStatus} OR h.confirm_status IS NULL) </when> <otherwise> AND h.confirm_status = #{query.confirmStatus} </otherwise> </choose> </if> <!-- 配料状态 = 超时原因--> <if test="query.timeoutReason != null and query.timeoutReason != ''"> <choose> <when test="query.timeoutReason == 'isemtpy'"> AND (LTRIM(RTRIM(m.timeout_reason)) = '' OR m.timeout_reason IS NULL) </when> <otherwise> AND m.timeout_reason = #{query.timeoutReason} </otherwise> </choose> </if> <if test="query.startDate != null"> AND h.NotifyDate <![CDATA[>=]]> #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} <![CDATA[>=]]> h.NotifyDate </if> <choose> <when test="query.workShopList != null and query.workShopList.size >0"> AND w.WorkShopId IN ( <foreach collection="query.workShopList" item="item" separator=","> #{item} </foreach> ) </when> <otherwise> AND w.WorkShopId in ('WS005','WS006') </otherwise> </choose> <if test="query.timeoutReasons != null and query.timeoutReasons.size > 0"> AND ( m.timeout_reason IN ( <foreach collection="query.timeoutReasons" item="item" separator=","> #{item} </foreach> ) <if test="'isemtpy' in query.timeoutReasons"> OR LTRIM(RTRIM(m.timeout_reason)) = '' OR m.timeout_reason IS NULL </if> <if test="'isall' in query.timeoutReasons"> OR LTRIM(RTRIM(m.timeout_reason)) != '' OR m.timeout_reason IS NOT NULL </if> ) </if> </where> ORDER BY m.NotifyNo, o.needDate, m.ItemNo </select> <update id="updateTimeoutReason"> update SOIssueNotifyOrderMaterialList set timeout_reason = #{data.timeoutReason} where Site = #{data.site} and NotifyNo = #{data.notifyNo} and ItemNo = #{data.itemNo} and BOMItemNo = #{data.bOMItemNo} </update> <select id="searchTimeMaterialList" resultType="com.xujie.sys.modules.orderIssure.entity.SOIssueNotifyOrderMaterialListData"> SELECT m.NotifyNo, m.Site, m.ItemNo, m.BOMItemNo, m.ComponentPartNo, m.QtyToIssue, m.QtyToIssue_Original, m.issueType, m.remark AS timeoutReason, dbo.Get_PartDesc(m.Site, m.ComponentPartNo) AS partDesc, o.needDate, o.locationNo, h.Status, (CASE WHEN h.confirm_status IS NULL THEN '未确认' ELSE h.confirm_status END) AS confirmStatus, h.UserName, dbo.plm_get_user_display(h.Site, h.UserName) AS userDisplay, h.NotifyDate, w.workShopName, o.SOOrderNo as orderNo, o.OpsItemNo as opsItemNo, o.SeqNo as seqNo, DATEDIFF(MINUTE, o.needDate, GETDATE())/ 60.0 AS overtimeMinutes FROM SOIssueNotifyOrderMaterialList m INNER JOIN SOIssueNotifyOrderList o ON m.Site = o.Site AND m.NotifyNo = o.NotifyNo AND m.ItemNo = o.ItemNo INNER JOIN SOIssueNotifyHeader h ON m.Site = h.Site AND m.NotifyNo = h.NotifyNo LEFT JOIN sys_user u ON h.UserName = u.username LEFT JOIN eam_WorkShop w ON u.workShopId = w.workShopId <where> AND m.Site = '2' AND ISNULL(m.QtyToIssue_Original,0) < ISNULL(m.QtyToIssue,0) AND DATEDIFF(MINUTE, o.needDate, GETDATE()) > 0 AND m.timeout_reason is null AND h.Status = '已下达' AND (h.confirm_status = '未确认' OR h.confirm_status IS NULL) AND w.WorkShopId in ('WS005','WS006')
</where> ORDER BY m.NotifyNo, o.needDate, m.ItemNo </select></mapper>
|