You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
908 lines
36 KiB
908 lines
36 KiB
<?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.shopOrder.dao.ShopOrderMapper">
|
|
<!-- =============生产订单类型===================-->
|
|
|
|
<select id="getShopOrderFamily" resultType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
|
|
Select OrderType, TypeDesc, Site, Active
|
|
from SOOrderType as T
|
|
where T.Site in (Select Site from AccessSite where upper(UserID) = #{user})
|
|
|
|
</select>
|
|
|
|
<insert id="saveShopOrderFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
|
|
INSERT INTO SOOrderType (OrderType, TypeDesc, Site, Active)
|
|
values (#{orderType}, #{typeDesc}, #{site}, #{active})
|
|
</insert>
|
|
<update id="editShopOrderFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
|
|
UPDATE SOOrderType
|
|
SET TypeDesc=#{typeDesc},
|
|
Active=#{active},
|
|
Site=#{site}
|
|
where OrderType = #{orderType}
|
|
and Site = #{site}
|
|
</update>
|
|
|
|
<delete id="deleteShopOrderFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
|
|
delete
|
|
from SOOrderType
|
|
where OrderType = #{orderType}
|
|
and Site = #{site}
|
|
</delete>
|
|
<select id="checkOrderType" resultType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
|
|
select OrderType, TypeDesc
|
|
from SOOrderType
|
|
where OrderType = #{orderType}
|
|
and Site = #{site}
|
|
</select>
|
|
|
|
<!-- =============生产计划===================-->
|
|
|
|
<select id="getPlanFamily" resultType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
|
|
Select PlannerType, TypeDesc, Site, Active
|
|
from SOPlanner as T
|
|
where T.Site in (Select Site from AccessSite where upper(UserID) = #{user})
|
|
</select>
|
|
|
|
<insert id="savePlanFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
|
|
INSERT INTO SOPlanner (PlannerType, TypeDesc, Site, Active)
|
|
values (#{plannerType}, #{typeDesc}, #{site}, #{active})
|
|
</insert>
|
|
|
|
<update id="editPlanFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
|
|
UPDATE SOPlanner
|
|
SET TypeDesc=#{typeDesc},
|
|
Active=#{active},
|
|
Site=#{site}
|
|
where PlannerType = #{plannerType}
|
|
and Site = #{site}
|
|
</update>
|
|
|
|
<delete id="deletePlanFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
|
|
delete
|
|
from SOPlanner
|
|
where PlannerType = #{plannerType}
|
|
and Site = #{site}
|
|
</delete>
|
|
<select id="checkPlannerType" resultType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
|
|
select PlannerType, TypeDesc
|
|
from SOPlanner
|
|
where PlannerType = #{plannerType}
|
|
and Site = #{site}
|
|
</select>
|
|
|
|
<!-- 查询-生产订单无工艺路线 -->
|
|
<select id="searchShopOrderWithNoProcessRoute"
|
|
resultType="com.gaotao.modules.shopOrder.entity.ShopOrderWithNoProcessRouteData">
|
|
Select * from view_SOrouting_check as T
|
|
<where>
|
|
AND T.site in (Select Site from AccessSite where upper(UserID)=#{user})
|
|
<if test=" site != null and site != ''">
|
|
AND Site like '%' + #{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=" date1 != null ">
|
|
AND EnterDate >= #{date1}
|
|
</if>
|
|
<if test=" date2 != null ">
|
|
AND dateadd( DAY, 1, #{date2} ) > EnterDate
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="searchProductionDispatchList" resultType="com.gaotao.modules.shopOrder.entity.SearchProductionDispatchListData">
|
|
SELECT
|
|
<if test="page != null and limit != null">
|
|
COUNT(*) OVER() AS totalCount,
|
|
</if>
|
|
T.Site,
|
|
T.OrderNo,
|
|
T.ItemNo,
|
|
S.OperationDesc,
|
|
S.PartNo,
|
|
P.PartDescription,
|
|
P.Spec,
|
|
T.QtyRequired AS LotSize,
|
|
T.QtyReported,
|
|
(T.QtyRequired - T.QtyReported) as qtyToReport,
|
|
D.NeedDate,
|
|
S.PreItemNo,
|
|
S1.OperationDesc AS PreOperationDesc,
|
|
S1.ScheduledFlag AS PreScheduledFlag,
|
|
S.NextItemNo,
|
|
S2.OperationDesc AS NextOperationDesc,
|
|
S2.ScheduledFlag AS NextScheduledFlag,
|
|
D.CustomerID,
|
|
C.CustomerName AS CustomerName,
|
|
D.EnterDate,
|
|
dbo.Get_SOOpsScheduleAvailResource (
|
|
T.Site,
|
|
T.OrderNo,
|
|
T.S_WorkCenterNo,
|
|
T.ItemNo
|
|
) AS AvailResource,
|
|
T.S_WorkCenterNo AS WorkCenterNo,
|
|
S.MachRunFactor,
|
|
S.MachSetupTime,
|
|
S.FactorUnit,
|
|
T.ClosedFlag,
|
|
isnull(E.S_ScheduledSeqNo ,- 1) AS S_ScheduledSeqNo,
|
|
T.PlanStartTime,
|
|
T.PlanFinishTime,
|
|
T.S_ResourceID,
|
|
ROUND(T.TimeRequired,2),
|
|
T.SeqNo,
|
|
T.SelectedFlag,
|
|
T.SourceFlag,
|
|
S1.QtyScheduled AS QtyScheduled_PreOps,
|
|
T.ParkFlag,
|
|
ROUND(T.TimeRequired_Original,2),
|
|
T.QtyRequired_Original,
|
|
S1.PlanStartTime AS PreOpsPlanStartTime,
|
|
S1.PlanFinishTime AS PreOpsPlanFinishTime,
|
|
T.EnteredDate,
|
|
(
|
|
CASE
|
|
WHEN S1.PlanStartTime > T.PlanStartTime THEN
|
|
'Y'
|
|
ELSE
|
|
'N'
|
|
END
|
|
) AS InAdvancedFlag,
|
|
P.Remark AS CustPartNo,
|
|
T.ClosedDate,
|
|
T.closedby,
|
|
T.serial_number AS serialNumber,
|
|
d.total_roll,
|
|
ISNULL(R.RollCount, 0) AS rollCount,
|
|
D.LotSize AS OrderQty
|
|
FROM
|
|
SOScheduledRouting AS T
|
|
INNER JOIN SORouting AS S WITH(NOLOCK) ON T.Site = S.Site AND T.OrderNo = S.OrderNo AND T.ItemNo = S.ItemNo
|
|
LEFT JOIN ShopOrder AS D WITH(NOLOCK) ON T.Site = D.Site AND T.OrderNo = D.OrderNo
|
|
LEFT JOIN SOScheduledList AS E WITH(NOLOCK) ON E.Site = T.Site AND E.LinkedSeqNo = T.SeqNo and T.S_ResourceID = E.ResourceID
|
|
LEFT JOIN Part AS P WITH(NOLOCK) ON S.Site = P.Site AND S.PartNo = P.PartNo
|
|
LEFT JOIN SORouting AS S1 WITH(NOLOCK) ON S.Site = S1.Site AND S.OrderNo = S1.OrderNo AND S.PreItemNo = S1.ItemNo
|
|
LEFT JOIN SORouting AS S2 WITH(NOLOCK) ON S.Site = S2.Site AND S.OrderNo = S2.OrderNo AND S.NextItemNo = S2.ItemNo
|
|
LEFT JOIN (SELECT Site, CreatedOpsSeqNo, COUNT(1) AS RollCount FROM SFDC_Rolls WITH(NOLOCK) WHERE RollType = '下道流转' GROUP BY Site, CreatedOpsSeqNo) AS R ON R.Site = T.Site AND R.CreatedOpsSeqNo = T.SeqNo
|
|
LEFT JOIN Customer C WITH(NOLOCK) ON D.Site = C.Site AND D.CustomerID = C.CustomerID
|
|
<where>
|
|
AND T.Site = S.Site
|
|
AND T.OrderNo = S.OrderNo
|
|
AND T.ItemNo = S.ItemNo
|
|
<if test="site != null and site != ''">
|
|
AND T.Site like '%' + #{site} + '%'
|
|
</if>
|
|
<if test="orderNo != null and orderNo != ''">
|
|
AND T.OrderNo like '%' + #{orderNo} + '%'
|
|
</if>
|
|
<if test="seqNo != null">
|
|
AND T.SeqNo like '%' + CAST(CAST(#{seqNo} AS BIGINT) AS VARCHAR) + '%'
|
|
</if>
|
|
<if test="partNo != null and partNo != ''">
|
|
AND S.PartNo like '%' + #{partNo} + '%'
|
|
</if>
|
|
<if test="sResourceID != null and sResourceID != ''">
|
|
AND T.S_ResourceID like '%' + #{sResourceID} + '%'
|
|
</if>
|
|
<if test="workCenterNo != null and workCenterNo != ''">
|
|
AND T.S_WorkCenterNo like '%' + #{workCenterNo} + '%'
|
|
</if>
|
|
<if test="date1 != null ">
|
|
AND D.EnterDate >= #{date1}
|
|
</if>
|
|
<if test="date2 != null ">
|
|
AND dateadd( DAY, 1, #{date2} ) > D.EnterDate
|
|
</if>
|
|
<if test="date3 != null ">
|
|
AND T.PlanStartTime >= #{date3}
|
|
</if>
|
|
<if test="date4 != null ">
|
|
AND dateadd( DAY, 1, #{date4} ) > T.PlanStartTime
|
|
</if>
|
|
<if test="date5 != null ">
|
|
AND T.PlanFinishTime>= #{date5}
|
|
</if>
|
|
<if test="date6 != null ">
|
|
AND dateadd( DAY, 1, #{date6} ) > T.PlanFinishTime
|
|
</if>
|
|
<if test="closedFlag != null and closedFlag != ''">
|
|
AND T.ClosedFlag = #{closedFlag}
|
|
</if>
|
|
<if test="parkFlag != null and parkFlag != ''">
|
|
AND T.ParkFlag = #{parkFlag}
|
|
</if>
|
|
${sql}
|
|
</where>
|
|
ORDER BY d.bu_no, T.S_ResourceID, ISNULL(T.serial_number, 999999)
|
|
<if test="page != null and limit != null">
|
|
OFFSET #{page} ROWS FETCH NEXT #{limit} ROWS ONLY
|
|
</if>
|
|
</select>
|
|
<select id="searchShopOrder" resultType="com.gaotao.modules.shopOrder.entity.SearchShopOrder">
|
|
Select T.OrderNo,T.NeedDate,T.OrderType,T.PartNo,p.PartDescription+' / '+isnull(p.Spec,'') as PartDescription,
|
|
T.LotSize,T.Planner,T.Status,T.CustomerID,P.ConfigurationTemplateID as CustomerName,T.PlanStartDate,T.Leadtime,
|
|
T.EnterDate,T.Username,T.FinishedQty,T.ReleaseDate,T.ReleaseGuys,T.ScheduleDate,T.Scheduler,T.IssueDate,
|
|
T.ReportDate,T.ReceiveDate,T.Printed,T.ProjectID,pr.ProjectName,T.BOMRevNo,T.RoutingRevNo,T.OriginalNeedDate,
|
|
T.OrderRef1,T.OrderRef2,T.Site,T.Remark,CostRollUpFlag,T.ManualFlag,T.OriSOOrderNo,P.FamilyID,
|
|
dbo.Get_PartFamilyDesc(P.Site,P.FamilyID) as FamilyName,P.GroupID,dbo.Get_PartGroupDesc(P.Site,P.GroupID) as
|
|
GroupName,
|
|
T.ReceiveStatus,T.RepairSOFlag,T.E_OriginalOrderType,T.E_OriginalOrderNo,T.E_Levels,P.PartType,P.Remark as
|
|
CustPartNo,
|
|
T.NeedDate as COPlanShipDate
|
|
from Part as p,ShopOrder as T
|
|
left join Project as pr on pr.Site=T.Site and pr.Projectid=T.ProjectID
|
|
<where>
|
|
AND T.Site=p.Site and T.PartNo=p.PartNo
|
|
and T.site in (Select Site from AccessSite where upper(UserID)=#{user})
|
|
<if test=" orderType != null and orderType != ''">
|
|
AND T.OrderType like '%' + #{orderType} + '%'
|
|
</if>
|
|
<if test=" planner != null and planner != ''">
|
|
AND T.Planner like '%' + #{planner} + '%'
|
|
</if>
|
|
<if test=" site != null and site != ''">
|
|
AND T.Site like '%' + #{site} + '%'
|
|
</if>
|
|
<if test=" buNo != null and buNo != ''">
|
|
AND T.bu_no like '%' + #{buNo} + '%'
|
|
</if>
|
|
<if test=" partType != null and partType != ''">
|
|
AND P.PartType like '%' + #{partType} + '%'
|
|
</if>
|
|
<if test=" partNo != null and partNo != ''">
|
|
AND T.PartNo like '%' + #{partNo} + '%'
|
|
</if>
|
|
<if test=" partDescription != null and partDescription != ''">
|
|
AND p.PartDescription like '%' + #{partDescription} + '%'
|
|
</if>
|
|
<if test=" projectID != null and projectID != ''">
|
|
AND T.ProjectID like '%' + #{projectID} + '%'
|
|
</if>
|
|
<if test=" remark != null and remark != ''">
|
|
AND T.Remark like '%' + #{remark} + '%'
|
|
</if>
|
|
<if test=" orderNo != null and orderNo != ''">
|
|
AND T.OrderNo like '%' + #{orderNo} + '%'
|
|
</if>
|
|
<if test=" orderRef1 != null and orderRef1 != ''">
|
|
AND T.OrderRef1 like '%' + #{orderRef1} + '%'
|
|
</if>
|
|
<if test=" costRollUpFlag != null and costRollUpFlag != ''">
|
|
AND CostRollUpFlag like '%' + #{costRollUpFlag} + '%'
|
|
</if>
|
|
<if test=" statusList != null and statusList.size > 0 ">
|
|
AND T.Status in
|
|
<foreach item="item" collection="statusList" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test=" date1 != null ">
|
|
AND T.EnterDate >= #{date1}
|
|
</if>
|
|
<if test=" date2 != null ">
|
|
AND dateadd( DAY, 1, #{date2} ) > T.EnterDate
|
|
</if>
|
|
<if test=" date3 != null ">
|
|
AND T.PlanStartDate >= #{date3}
|
|
</if>
|
|
<if test=" date4 != null ">
|
|
AND dateadd( DAY, 1, #{date4} ) > T.PlanStartDate
|
|
</if>
|
|
|
|
</where>
|
|
</select>
|
|
<select id="searchShopOrderByPaging" parameterType="com.gaotao.modules.shopOrder.entity.SearchShopOrder" resultType="com.gaotao.modules.shopOrder.entity.SearchShopOrder">
|
|
Select
|
|
T.OrderNo,
|
|
T.NeedDate,
|
|
T.OrderType,
|
|
T.PartNo,
|
|
p.PartDescription + ' / ' + isnull(p.Spec, '') AS PartDescription,
|
|
T.LotSize,
|
|
T.Planner,
|
|
T.Status,
|
|
T.CustomerID,
|
|
P.ConfigurationTemplateID AS CustomerName,
|
|
T.PlanStartDate,
|
|
T.Leadtime,
|
|
T.EnterDate,
|
|
T.Username,
|
|
T.FinishedQty,
|
|
T.ReleaseDate,
|
|
T.ReleaseGuys,
|
|
T.ScheduleDate,
|
|
T.Scheduler,
|
|
T.IssueDate,
|
|
T.ReportDate,
|
|
T.ReceiveDate,
|
|
T.Printed,
|
|
T.ProjectID,
|
|
pr.ProjectName,
|
|
T.BOMRevNo,
|
|
T.RoutingRevNo,
|
|
T.OriginalNeedDate,
|
|
T.OrderRef1,
|
|
T.OrderRef2,
|
|
T.Site,
|
|
T.Remark,
|
|
CostRollUpFlag,
|
|
T.ManualFlag,
|
|
T.OriSOOrderNo,
|
|
P.FamilyID,
|
|
dbo.Get_PartFamilyDesc (P.Site, P.FamilyID) AS FamilyName,
|
|
P.GroupID,
|
|
dbo.Get_PartGroupDesc (P.Site, P.GroupID) AS GroupName,
|
|
T.ReceiveStatus,
|
|
T.RepairSOFlag,
|
|
T.E_OriginalOrderType,
|
|
T.E_OriginalOrderNo,
|
|
T.E_Levels,
|
|
P.PartType,
|
|
P.Remark AS CustPartNo,
|
|
T.NeedDate AS COPlanShipDate,
|
|
T.batch_no batchNo,
|
|
(SELECT COUNT(1) FROM SOScheduledRouting where Site = T.site and OrderNo = T.OrderNo ) AS apsResourceTotal,
|
|
(SELECT COUNT(1) FROM SOScheduledRouting where Site = T.site and OrderNo = T.OrderNo AND QtyReported <![CDATA[<=]]> 0 AND TimeReported <![CDATA[<=]]> 0 ) AS notYetStartedResourceTotal,
|
|
<!--(SELECT ROUND(SUM(issureQty),3) FROM SOIssueNotifyOrderList where Site = T.site and sOOrderNo = T.OrderNo)--> 0 alreadyApplyTotal
|
|
from Part as p,ShopOrder as T
|
|
left join Project as pr on pr.Site=T.Site and pr.Projectid=T.ProjectID
|
|
<where>
|
|
AND T.Site = p.Site and T.PartNo = p.PartNo
|
|
and T.site in (Select Site from AccessSite where upper(UserID)=#{query.user})
|
|
<if test=" query.orderType != null and query.orderType != ''">
|
|
AND T.OrderType like '%' + #{query.orderType} + '%'
|
|
</if>
|
|
<if test=" query.planner != null and query.planner != ''">
|
|
AND T.Planner like '%' + #{query.planner} + '%'
|
|
</if>
|
|
<if test=" query.site != null and query.site != ''">
|
|
AND T.Site like '%' + #{query.site} + '%'
|
|
</if>
|
|
<if test=" query.buNo != null and query.buNo != ''">
|
|
AND T.bu_no like '%' + #{query.buNo} + '%'
|
|
</if>
|
|
<if test=" query.partType != null and query.partType != ''">
|
|
AND P.PartType like '%' + #{query.partType} + '%'
|
|
</if>
|
|
<if test=" query.partNo != null and query.partNo != ''">
|
|
AND T.PartNo like '%' + #{query.partNo} + '%'
|
|
</if>
|
|
<if test=" query.statusList != null and query.statusList.size > 0 ">
|
|
AND T.Status in
|
|
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test=" query.partDescription != null and query.partDescription != ''">
|
|
AND p.PartDescription like '%' + #{query.partDescription} + '%'
|
|
</if>
|
|
<if test=" query.projectID != null and query.projectID != ''">
|
|
AND T.ProjectID like '%' + #{query.projectID} + '%'
|
|
</if>
|
|
<if test=" query.remark != null and query.remark != ''">
|
|
AND T.Remark like '%' + #{query.remark} + '%'
|
|
</if>
|
|
<if test=" query.orderNo != null and query.orderNo != ''">
|
|
AND T.OrderNo like '%' + #{query.orderNo} + '%'
|
|
</if>
|
|
<if test=" query.orderRef1 != null and query.orderRef1 != ''">
|
|
AND T.OrderRef1 like '%' + #{query.orderRef1} + '%'
|
|
</if>
|
|
<if test=" query.costRollUpFlag != null and query.costRollUpFlag != ''">
|
|
AND CostRollUpFlag like '%' + #{query.costRollUpFlag} + '%'
|
|
</if>
|
|
<if test=" query.statusList != null and query.statusList.size > 0 ">
|
|
AND T.Status in
|
|
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test=" query.date1 != null ">
|
|
AND T.EnterDate >= #{query.date1}
|
|
</if>
|
|
<if test=" query.date2 != null ">
|
|
AND dateadd( DAY, 1, #{query.date2} ) > T.EnterDate
|
|
</if>
|
|
<if test=" query.date3 != null ">
|
|
AND T.PlanStartDate >= #{query.date3}
|
|
</if>
|
|
<if test=" query.date4 != null ">
|
|
AND dateadd( DAY, 1, #{query.date4} ) > T.PlanStartDate
|
|
</if>
|
|
|
|
</where>
|
|
</select>
|
|
<select id="getShopOrderData" resultType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
|
|
SELECT
|
|
T.*,
|
|
dbo.Get_ProjectDesc(T.Site,T.ProjectID) as ProjectIDName,
|
|
P.Remark as PartRemark,
|
|
P.ConfigurationTemplateID,
|
|
P.UMID,
|
|
p.PartDescription + ' / ' + isnull(p.Spec,'') as PartDesc,
|
|
t.total_roll
|
|
FROM
|
|
ShopOrder AS T
|
|
LEFT JOIN
|
|
Part as P ON P.Site=T.Site and P.PartNo=T.PartNo
|
|
<where>
|
|
AND MaterialSplitFlag = 'N'
|
|
and T.Site IN (
|
|
SELECT
|
|
Site
|
|
FROM
|
|
AccessSite
|
|
WHERE
|
|
UPPER (UserID) = #{user}
|
|
)
|
|
<if test=" orderNo != null and orderNo != ''">
|
|
AND T.OrderNo like '%' + #{orderNo} + '%'
|
|
</if>
|
|
|
|
<if test=" site != null and site != ''">
|
|
AND T.Site like '%' + #{site} + '%'
|
|
</if>
|
|
<if test=" partNo != null and partNo != ''">
|
|
AND T.PartNo like '%' + #{partNo} + '%'
|
|
</if>
|
|
<if test=" status != null and status != ''">
|
|
AND T.Status = #{status}
|
|
</if>
|
|
<if test=" date1 != null ">
|
|
AND T.NeedDate >= #{date1}
|
|
</if>
|
|
<if test=" date2 != null ">
|
|
AND dateadd( DAY, 1, #{date2} ) > T.NeedDate
|
|
</if>
|
|
<if test=" date3 != null ">
|
|
AND T.PlanStartDate >= #{date3}
|
|
</if>
|
|
<if test=" date4 != null ">
|
|
AND dateadd( DAY, 1, #{date4} ) > T.PlanStartDate
|
|
</if>
|
|
|
|
</where>
|
|
</select>
|
|
|
|
<delete id="deleteShopOrderData">
|
|
delete
|
|
from ShopOrder
|
|
where site = #{site}
|
|
and orderNo = #{orderNo}
|
|
</delete>
|
|
<delete id="deleteRouteInShopOrder">
|
|
delete
|
|
from SORouting
|
|
where site = #{site}
|
|
and orderNo = #{orderNo}
|
|
and itemNo = #{itemNo}
|
|
|
|
</delete>
|
|
|
|
<insert id="insertRouteInShopOrder">
|
|
insert into SORouting (Site, OrderNo, ItemNo, OperationDesc,
|
|
WorkCenterNo, MachSetupTime, MachRunFactor,
|
|
FactorUnit_DB, FactorUnit, QtyRequired,
|
|
QtyReported, QtyApprove, TimeRequired,
|
|
TimeReported, Efficiency, PlanStartTime,
|
|
PlanFinishTime, BarcodeID, Remark,
|
|
PartNo, Crewsize, ClosedFlag,
|
|
ActionNotes, QtyScheduled)
|
|
values (#{site}, #{orderNo}, #{itemNo}, #{operationDesc}, #{workCenterNo}, #{machSetupTime}, #{machRunFactor},
|
|
#{factorUnit_DB},
|
|
#{factorUnit}, #{qtyRequired}, #{qtyReported}, #{qtyApprove}, #{timeRequired}, #{timeReported},
|
|
#{efficiency},
|
|
#{planStartTime}, #{planFinishTime}, #{barcodeID}, #{remark}, #{partNo}, #{crewsize}, #{closedFlag},
|
|
#{actionNotes}, 0)
|
|
|
|
</insert>
|
|
<delete id="deleteAvailResourceInShopOrder">
|
|
delete from SORouting_AvailableResource where site=#{site} and orderNo=#{orderNo} and ItemNo=#{itemNo}
|
|
</delete>
|
|
|
|
<update id="updateRouteInShopOrder">
|
|
update SORouting
|
|
set OperationDesc = #{operationDesc}
|
|
, WorkCenterNo = #{workCenterNo}
|
|
, MachSetupTime = #{machSetupTime}
|
|
, MachRunFactor = #{machRunFactor}
|
|
, FactorUnit = #{factorUnit}
|
|
, Efficiency =#{efficiency}
|
|
, TimeReported =#{timeRequired}
|
|
, PlanFinishTime = #{planFinishTime}
|
|
, PlanStartTime = #{planStartTime}
|
|
, Crewsize = #{crewsize}
|
|
, Remark= #{remark}
|
|
where site = #{site}
|
|
and OrderNo = #{orderNo}
|
|
and ItemNo = #{itemNo}
|
|
|
|
</update>
|
|
|
|
<select id="getRoutingTimeRequired" resultType="java.math.BigDecimal">
|
|
select dbo.Get_Routing_TimeRequired(#{site}, #{lotSize}, #{machSetupTime}, #{machRunFactor}, #{factorUnit},
|
|
#{efficiency})
|
|
</select>
|
|
|
|
<select id="getWorkCenterInfo" resultType="com.gaotao.modules.shopOrder.entity.vo.WorkCenterVo">
|
|
Select WorkCenterNo Work_Center_No,
|
|
WorkCenterDesc Work_Center_Desc,
|
|
WorkCenterType Work_Center_Type,
|
|
Active,
|
|
Site
|
|
from WorkCenter
|
|
where WorkCenterNo = #{workCenterNo}
|
|
and Site = #{site}
|
|
</select>
|
|
|
|
|
|
<select id="getOrderNoRouteInMaxItemNo" resultType="java.lang.String">
|
|
select max(itemno)
|
|
from SORouting
|
|
where site = #{site}
|
|
and orderNo = #{orderNo}
|
|
</select>
|
|
|
|
<select id="getOrderNoItemNoCenter" resultType="java.lang.String">
|
|
select dbo.Get_SORoutingAvailResource(#{site}, #{orderNo}, #{workCenterNo}, #{itemNo})
|
|
</select>
|
|
<update id="saveShopOrderData" parameterType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
|
|
update ShopOrder
|
|
set NeedDate=#{needDate},
|
|
PlanStartDate=#{planStartDate},
|
|
OriginalNeedDate=#{originalNeedDate},
|
|
OrderType=#{orderType},
|
|
Planner=#{planner},
|
|
OriSOOrderNo=#{oriSOOrderNo},
|
|
ProjectID=#{projectID},
|
|
Leadtime=#{leadtime,jdbcType=FLOAT},
|
|
RepairSOFlag=#{repairSOFlag},
|
|
TechInfo=#{techInfo},
|
|
Remark=#{remark},
|
|
batch_no=#{batchNo},
|
|
total_roll=#{totalRoll,jdbcType=INTEGER}
|
|
where Site = #{site}
|
|
and OrderNo = #{orderNo}
|
|
</update>
|
|
|
|
|
|
<select id="getRouteInShopOrderData" resultType="com.gaotao.modules.shopOrder.entity.RouteInShopOrderData">
|
|
Select R.Site
|
|
, R.OrderNo
|
|
, R.ItemNo
|
|
, R.OperationDesc
|
|
, R.WorkCenterNo
|
|
, W.WorkCenterDesc
|
|
, R.MachSetupTime
|
|
, R.MachRunFactor
|
|
, R.FactorUnit_DB
|
|
, R.FactorUnit
|
|
, R.QtyRequired
|
|
, R.production_qty as productionQty
|
|
, R.total_roll_qty as totalRollQty
|
|
, R.total_per_volume as totalPerVolume
|
|
, R.QtyReported
|
|
, R.QtyApprove
|
|
, R.TimeRequired
|
|
, R.TimeReported
|
|
, R.Efficiency
|
|
, R.PlanStartTime
|
|
, R.PlanFinishTime
|
|
, R.BarcodeID
|
|
, R.Remark
|
|
, R.PartNo
|
|
, R.Crewsize
|
|
, R.ClosedFlag
|
|
, R.ActionNotes
|
|
, W.WorkCenterType
|
|
, dbo.Get_SORoutingAvailResource(R.Site, R.OrderNo, R.WorkCenterNo, R.ItemNo) as AvailResource
|
|
from SORouting as R,
|
|
WorkCenter as W
|
|
<where>
|
|
R.Site = W.Site
|
|
and R.WorkCenterNo = W.WorkCenterNo
|
|
and R.Site = #{site}
|
|
and R.OrderNo = #{orderNo}
|
|
<if test="itemNo!= null and itemNo != '' ">
|
|
and R.itemNo = #{itemNo}
|
|
</if>
|
|
<if test=" itemDesc != null and itemDesc != ''">
|
|
AND R.OperationDesc like '%' + #{itemDesc} + '%'
|
|
</if>
|
|
</where>
|
|
order by R.ItemNo
|
|
</select>
|
|
|
|
<select id="getToolInShopOrder" resultType="com.gaotao.modules.shopOrder.entity.ToolInShopOrder">
|
|
|
|
Select T.Site
|
|
, T.OrderNo
|
|
, ItemNo
|
|
, T.ToolID
|
|
, P.ToolDescription
|
|
, P.Spec
|
|
, T.ToolQty
|
|
, P.UMID
|
|
, P.FamilyID
|
|
, dbo.Get_PartFamilyDesc(T.Site, P.FamilyID) as FamilyName
|
|
, P.Active
|
|
, T.Remark
|
|
, T.CreateDate
|
|
, T.CreatedBy
|
|
from SOTool as T,
|
|
ToolHeader as P
|
|
Where T.Site = P.Site
|
|
and T.ToolID = P.ToolID
|
|
and T.Site = #{site}
|
|
and T.OrderNo = #{orderNo}
|
|
Order by ItemNo, T.ToolID
|
|
</select>
|
|
|
|
<select id="getProductMixInShopOrder" resultType="com.gaotao.modules.shopOrder.entity.ProductMixInShopOrder">
|
|
SELECT
|
|
B.Site,
|
|
B.OrderNo,
|
|
B.ItemNo,
|
|
B.ComponentPartNo,
|
|
P.PartDescription AS PartDesc,
|
|
P.Spec AS PartSpec,
|
|
P.UMid AS PartUm,
|
|
B.QtyAssembly,
|
|
B.QtyFixedScrapt,
|
|
B.ScraptFactor,
|
|
B.Remark,
|
|
B.QtyRequired,
|
|
B.QtyIssue,
|
|
B.IssueDate,
|
|
B.QtyReserved,
|
|
B.RMType_DB,
|
|
p.issue_method
|
|
FROM dbo.view_SAP_SOBOM AS B
|
|
left join Part as P on B.Site = P.Site and B.ComponentPartNo = P.PartNo
|
|
Where B.Site = #{site} and B.OrderNo = #{orderNo}
|
|
Order by B.ItemNo
|
|
</select>
|
|
<select id="getShopOrderSapSOBOM" resultType="com.gaotao.modules.shopOrder.entity.ProductMixInShopOrder">
|
|
Select T.ItemNo as item_no,
|
|
T.ComponentPartNo as component_part_no,
|
|
P.PartDescription as part_desc,
|
|
P.Spec as part_spec,
|
|
P.UMID,
|
|
T.QtyRequired as qty_required
|
|
,
|
|
P.DefaultLocationID as default_location_ID
|
|
from dbo.view_SAP_SOBOM as T,
|
|
Part as P
|
|
Where T.Site = P.Site
|
|
and T.ComponentPartNo = P.PartNo
|
|
and T.Site = #{site}
|
|
and T.OrderNo = #{orderNo}
|
|
|
|
</select>
|
|
<select id="getOrderInfo" resultType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
|
|
Select T.OrderNo as order_no
|
|
, T.PartNo as part_no
|
|
, T.LotSize as lot_size
|
|
, P.PartDescription as part_desc
|
|
, isnull(P.Spec, '') as spec
|
|
, T.Remark as remark
|
|
, dbo.get_ShopOrderPrintInfo(T.Site, T.OrderNo) as first_item_no
|
|
from ShopOrder as T,
|
|
Part as P
|
|
Where T.Site = P.Site
|
|
and T.PartNo = P.PartNo
|
|
and T.Site = #{site}
|
|
and T.OrderNo = #{orderNo}
|
|
</select>
|
|
|
|
<!--获取工单的工具信息-->
|
|
<select id="getShopOrderToolDatas" resultType="ShopOrderToolData">
|
|
Select T.Site site,
|
|
T.OrderNo orderNo,
|
|
ItemNo itemNo,
|
|
T.ToolID toolId,
|
|
P.ToolDescription toolDesc,
|
|
P.Spec toolSpec,
|
|
T.ToolQty toolQty,
|
|
P.UMID umid,
|
|
P.FamilyID familyId,
|
|
dbo.Get_SOOpsDescription(T.Site, T.OrderNo, ItemNo) itemDesc,
|
|
dbo.Get_PartFamilyDesc(T.Site, P.FamilyID) familyName,
|
|
P.Active active,
|
|
T.Remark remark,
|
|
T.CreateDate createdDate,
|
|
T.CreatedBy createdBy
|
|
FROM SOTool as T,
|
|
ToolHeader as P
|
|
Where T.Site = P.Site
|
|
and T.ToolID = P.ToolID
|
|
and T.Site = #{site}
|
|
and T.OrderNo = #{orderNo}
|
|
Order by ItemNo, T.ToolID
|
|
</select>
|
|
<select id="getOrderQtyRequired" resultType="java.lang.Double">
|
|
Select LotSize
|
|
from ShopOrder
|
|
Where Site = #{site}
|
|
and OrderNo = #{orderNo}
|
|
</select>
|
|
<select id="getSORoute" resultType="com.gaotao.modules.shopOrder.entity.RouteInShopOrderData">
|
|
Select R.Site
|
|
, R.OrderNo
|
|
, R.ItemNo
|
|
, ISNULL(R.NextItemNo, 0) next_item_no
|
|
, ISNULL(R.PreItemNo, 0) pre_item_no
|
|
|
|
from SORouting as R
|
|
where R.site = #{site}
|
|
and R.OrderNo = #{orderNo}
|
|
and R.ItemNo = #{itemNo}
|
|
</select>
|
|
|
|
|
|
<update id="updateRouteByItemNo">
|
|
update SORouting
|
|
<set>
|
|
<if test="nextItemNo != null">
|
|
NextItemNo = #{nextItemNo},
|
|
</if>
|
|
<if test="preItemNo != null">
|
|
PreItemNo = #{preItemNo},
|
|
</if>
|
|
</set>
|
|
where site = #{site}
|
|
and OrderNo = #{orderNo}
|
|
and ItemNo = #{itemNo}
|
|
|
|
</update>
|
|
|
|
<select id="getSORouteItemNoOrderBy" resultType="com.gaotao.modules.shopOrder.entity.RouteInShopOrderData">
|
|
select top 1 Site
|
|
, OrderNo
|
|
, ItemNo
|
|
from SORouting
|
|
<where>
|
|
site = #{route.site}
|
|
and OrderNo = #{route.orderNo}
|
|
<if test="orderBy == 'desc'">
|
|
and ItemNo <![CDATA[ < ]]> #{route.itemNo}
|
|
</if>
|
|
<if test="orderBy == 'asc'">
|
|
and ItemNo > #{route.itemNo}
|
|
</if>
|
|
</where>
|
|
|
|
order by ItemNo ${orderBy}
|
|
</select>
|
|
<select id="getShopOrderByPart" resultType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
|
|
|
|
SELECT
|
|
*
|
|
FROM
|
|
ShopOrder AS T
|
|
WHERE
|
|
Site = #{site}
|
|
AND PartNo = #{partNo}
|
|
AND ( Status = '已计划' OR Status = '已下达' )
|
|
AND NOT EXISTS ( SELECT 1 FROM SOScheduledRouting AS D WHERE T.Site = D.Site AND T.OrderNo = D.OrderNo )
|
|
AND T.OrderType != 'P'
|
|
</select>
|
|
|
|
<select id="getRouteInShopOrderResource"
|
|
resultType="com.gaotao.modules.shopOrder.entity.SoroutingAvailableresourceEntity">
|
|
SELECT s.Site,s.OrderNo,s.ItemNo,s.WorkCenterNo,w.ResourceID FROM
|
|
SORouting s,RoutingDetail e
|
|
LEFT JOIN RoutingDetail_AvailableResource w ON
|
|
e.Site = w.Site AND
|
|
e.PartNo = w.PartNo AND
|
|
e.RevNo = w.RevNo AND
|
|
e.itemNo=w.itemNo
|
|
WHERE s.Site = #{site} AND s.OrderNo = #{orderNo} AND
|
|
e.Site = s.Site AND
|
|
e.PartNo = s.PartNo AND
|
|
e.RevNo=#{bOMRevNo}
|
|
and s.ItemNo=e.ItemNo
|
|
and s.itemNo in (select h.itemNo from RoutingDetail_AvailableResource h
|
|
where h.site = e.site
|
|
and h.partno = e.partno
|
|
and h.revno = e.revno )
|
|
Union all
|
|
SELECT s.Site,s.OrderNo,s.ItemNo,s.WorkCenterNo,w.ResourceID FROM
|
|
SORouting s
|
|
LEFT JOIN WorkCenterResource w ON
|
|
s.Site = w.Site AND
|
|
s.WorkCenterNo = w.WorkCenterNo
|
|
WHERE w.Active = 'Y' AND s.Site = #{site} AND s.OrderNo = #{orderNo}
|
|
and s.itemNo not in (select h.itemNo from RoutingDetail_AvailableResource h
|
|
where h.site = s.site
|
|
and h.partno = s.partno
|
|
and h.revno = #{bOMRevNo} )
|
|
</select>
|
|
<select id="getOrderSopFileInfo" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
|
|
SELECT
|
|
*
|
|
FROM
|
|
(--如果工序有设置了可用机台的话,那么和可用机台关联
|
|
SELECT
|
|
t.Site,
|
|
t.WorkCenterNo,
|
|
d.ResourceID ,
|
|
w.ResourceDesc
|
|
FROM
|
|
SORouting AS t,
|
|
SORouting_AvailableResource AS d ,
|
|
WorkCenterResource AS w
|
|
WHERE
|
|
t.site= d.site
|
|
AND t.site= w.site
|
|
AND t.WorkCenterNo= w.WorkCenterNo
|
|
AND d.ResourceID = w.ResourceID
|
|
AND t.OrderNo= d.OrderNo
|
|
AND t.ItemNo= d.ItemNo
|
|
AND t.Site=#{site}
|
|
AND t.OrderNo=#{orderNo}
|
|
|
|
UNION ALL--如果工序没有设置可用机台的话,那么和和该加工中心下的所有机台对应
|
|
|
|
SELECT
|
|
t.Site,
|
|
t.WorkCenterNo,
|
|
d.ResourceID ,
|
|
w.ResourceDesc
|
|
FROM
|
|
SORouting AS t
|
|
LEFT JOIN SORouting_AvailableResource AS d ON t.site= d.site
|
|
AND t.OrderNo= d.OrderNo
|
|
AND t.ItemNo= d.ItemNo
|
|
,
|
|
WorkCenterResource AS w
|
|
WHERE
|
|
d.Site IS NULL
|
|
AND t.site= w.site
|
|
AND t.WorkCenterNo= w.WorkCenterNo
|
|
AND d.ResourceID = w.ResourceID
|
|
AND t.Site=#{site}
|
|
AND t.OrderNo=#{orderNo}
|
|
) AS x,
|
|
sys_oss AS y
|
|
WHERE
|
|
x.Site= y.order_ref1
|
|
AND x.WorkCenterNo= y.order_ref2
|
|
AND x.ResourceID= y.order_ref3
|
|
ORDER BY ResourceID,order_ref4
|
|
</select>
|
|
<select id="getShopOrderSopSOBOM" resultType="com.gaotao.modules.shopOrder.entity.ProductMixInShopOrder">
|
|
Select
|
|
T.ItemNo as item_no,
|
|
T.WOR1_ItemCode as component_part_no,
|
|
T.WOR1_ItemName as part_desc,
|
|
T.WOR1_PlannedQty as qty_required,
|
|
T.U_SNUM AS qty_on_hand
|
|
from dbo.sop_sobom as T
|
|
Where
|
|
T.Site = #{site}
|
|
and T.DocEntry = #{orderNo}
|
|
</select>
|
|
<select id="getOrderSopInfo" resultType="com.gaotao.modules.shopOrder.entity.SopViewData">
|
|
select * from sop
|
|
where DocEntry = #{orderNo}
|
|
</select>
|
|
<select id="getFileData" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
|
|
select url,file_name,new_file_name from sys_oss where id = #{id}
|
|
</select>
|
|
|
|
<insert id="saveShopOrderData2">
|
|
insert into ShopOrder
|
|
(Site, bu_no, OrderNo, Status, Status_Tmp, EnterDate, NeedDate, PlanStartDate,
|
|
OrderType, PartNo, LotSize, BOMRevNo, RoutingRevNo, ProjectID, CustomerID, batch_no, OrderRef1, OrderRef2)
|
|
values
|
|
(#{site}, #{buNo}, #{orderNo}, #{status}, #{statusTmp}, #{enterDate}, #{needDate}, #{planStartDate},
|
|
#{orderType}, #{partNo}, #{lotSize,jdbcType=FLOAT}, #{bOMRevNo}, #{routingRevNo}, #{projectID}, #{customerID}, #{batchNo}, #{orderRef1}, #{orderRef2})
|
|
</insert>
|
|
</mapper>
|