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
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}
)
update SOIssueNotifyHeader set bu=#{bu} where site=#{site} and NotifyNo=#{notifyNo}
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 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
and a.closed_flag='N'
and a.part_no like #{partNo}
and a.seqno like #{seqno}
and dbo.getOperatorDesc(a.site,a.operator_id) like #{operatorDesc}
and a.orderno like #{orderno}
and a.s_shiftno like #{sShiftno}
and a.s_resourceid like #{sResourceid}
and a.s_workcenterno like #{sWorkcenterno}
and a.operator_id like #{operatorId}
AND a.s_scheduleddate >= #{startDate}
AND #{endDate} >= a.s_scheduleddate
and a.site=#{site}
and d.sourceBu=#{bu}
order by a.s_scheduleddate
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
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
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 isnull(max(ItemNo),0)+1 from SOIssueNotifyOrderList where site=#{site} and NotifyNo=#{notifyNo} and 998>ItemNo
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})
delete from SOIssueNotifyOrderMaterialList where site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo}
insert into SOIssueNotifyOrderMaterialList (NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType,remark)
values
(#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue},0,#{item.issueType},#{item.remark})
insert into SOIssueNotifyOrderMaterialList (NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original,issueType,remark)
values
(#{notifyNo},#{site},#{itemNo},#{bOMItemNo},#{componentPartNo},#{qtyToIssue},0,#{issueType},#{remark})
delete from SOIssueNotifyOrderList where site=#{site} and NotifyNo=#{notifyNo} and ItemNo=#{itemNo}
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 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 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 top 1000 part_no,part_desc,umid,spec,sku,cinv_source_code
from part
and site = #{site} and sourceBu = #{sourceBu} and control_mes='G'
AND part_no LIKE '%'+ #{partNo} + '%'
AND part_desc LIKE '%'+ #{partDesc}+ '%'
AND spec LIKE '%'+ #{spec}+ '%'
select top 1000 part_no,part_desc,umid,spec,sku,cinv_source_code
from part
and site = #{site} and sourceBu = #{sourceBu} and control_mes='N'
AND part_no LIKE '%'+ #{partNo} + '%'
AND part_desc LIKE '%'+ #{partDesc}+ '%'
AND spec LIKE '%'+ #{spec}+ '%'
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 NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
and ItemNo=#{itemNo,jdbcType=DOUBLE}
update SOIssueNotifyHeader set status=#{status}
where Site=#{site} and NotifyNo=#{notifyNo}
select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
and ItemNo=#{itemNo} and BOMItemNo=#{bOMItemNo}
delete from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
and ItemNo=#{itemNo} and BOMItemNo=#{bOMItemNo}
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})
select NotifyNo,Site,ItemNo,FGPartNo,SOOrderNo,OpsItemNo,SeqNo,IssureQty,OutWorkOrderFlag,LocationNo,needDate
from SOIssueNotifyOrderList where Site=#{site} and NotifyNo=#{notifyNo}
and ItemNo=#{itemNo}
select NotifyNo,Site,ItemNo,BOMItemNo,ComponentPartNo,QtyToIssue,QtyToIssue_Original
from SOIssueNotifyOrderMaterialList where Site=#{site} and NotifyNo=#{notifyNo}
and ComponentPartNo=#{componentPartNo}
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 Site,NotifyNo,ItemNo,SOOrderNo,SeqNo,ComponentPartNo,QtyToIssue,updateType,updateBy,updateDate,issueType
from IssueNotifyChangeLog where Site=#{site} and NotifyNo=#{notifyNo}
insert into SOIssueNotifyLog (Site,NotifyNo,[Action],username,ActionTime,ActionRemark)
values (#{site},#{notifyNo},'关闭',#{username},GetDate(),#{closeRemark})
insert into SOIssueNotifyLog (Site,NotifyNo,[Action],username,ActionTime,ActionRemark)
values (#{site},#{notifyNo},'开启',#{username},GetDate(),'重新开启')
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
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
AND m.Site = #{query.site}
AND DATEDIFF(MINUTE, o.needDate, GETDATE()) > 0
AND calc.overtimeMinutes > 0
AND ISNULL(m.QtyToIssue_Original,0) < ISNULL(m.QtyToIssue,0)
AND m.NotifyNo = #{query.notifyNo}
AND m.ComponentPartNo LIKE '%' + #{query.componentPartNo} + '%'
AND dbo.Get_PartDesc(m.Site, m.ComponentPartNo) LIKE '%' + #{query.partDesc} + '%'
AND h.UserName LIKE #{query.userName}
AND h.Status = #{query.status}
AND (h.confirm_status = #{query.confirmStatus} OR h.confirm_status IS NULL)
AND h.confirm_status = #{query.confirmStatus}
AND (LTRIM(RTRIM(m.timeout_reason)) = '' OR m.timeout_reason IS NULL)
AND m.timeout_reason = #{query.timeoutReason}
AND h.NotifyDate =]]> #{query.startDate}
AND #{query.endDate} =]]> h.NotifyDate
AND w.WorkShopId IN (
#{item}
)
AND w.WorkShopId in ('WS005','WS006')
AND (
m.timeout_reason IN (
#{item}
)
OR LTRIM(RTRIM(m.timeout_reason)) = ''
OR m.timeout_reason IS NULL
OR LTRIM(RTRIM(m.timeout_reason)) != ''
OR m.timeout_reason IS NOT NULL
)
ORDER BY m.NotifyNo, o.needDate, m.ItemNo
update SOIssueNotifyOrderMaterialList
set timeout_reason = #{data.timeoutReason}
where Site = #{data.site}
and NotifyNo = #{data.notifyNo}
and ItemNo = #{data.itemNo}
and BOMItemNo = #{data.bOMItemNo}
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
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')
ORDER BY m.NotifyNo, o.needDate, m.ItemNo