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.
361 lines
16 KiB
361 lines
16 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
|
|
T.Site,
|
|
T.OrderNo,
|
|
T.ItemNo,
|
|
S.OperationDesc,
|
|
S.PartNo,
|
|
P.PartDescription,
|
|
P.Spec,
|
|
T.QtyRequired AS LotSize,
|
|
T.QtyReported,
|
|
D.NeedDate,
|
|
S.PreItemNo,
|
|
S1.OperationDesc AS PreOperationDesc,
|
|
S1.ScheduledFlag AS PreScheduledFlag,
|
|
S.NextItemNo,
|
|
S2.OperationDesc AS NextOperationDesc,
|
|
S2.ScheduledFlag AS NextScheduledFlag,
|
|
D.CustomerID,
|
|
P.ConfigurationTemplateID 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
|
|
FROM
|
|
SOScheduledRouting AS T
|
|
LEFT JOIN ShopOrder AS D ON T.Site = D.Site
|
|
AND T.OrderNo = D.OrderNo
|
|
LEFT JOIN SOScheduledList AS E ON E.Site = T.Site
|
|
AND E.LinkedSeqNo = T.SeqNo,
|
|
SORouting AS S
|
|
LEFT JOIN Part AS P ON S.Site = P.Site
|
|
AND S.PartNo = P.PartNo
|
|
LEFT JOIN SORouting AS S1 ON S.Site = S1.Site
|
|
AND S.OrderNo = S1.OrderNo
|
|
AND S.PreItemNo = S1.ItemNo
|
|
LEFT JOIN SORouting AS S2 ON S.Site = S2.Site
|
|
AND S.OrderNo = S2.OrderNo
|
|
AND S.NextItemNo = S2.ItemNo
|
|
|
|
<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=" 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>
|
|
${sql}
|
|
</where>
|
|
</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=" 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=" status != null and status != ''">
|
|
AND T.Status in ${status}
|
|
</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.PlanStartTime >= #{date3}
|
|
</if>
|
|
<if test=" date4 != null ">
|
|
AND dateadd( DAY, 1, #{date4} ) > T.PlanStartTime
|
|
</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
|
|
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" parameterType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
|
|
delete from ShopOrder where site=#{site} and orderNo=#{orderNo}
|
|
</delete>
|
|
|
|
<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},
|
|
RepairSOFlag=#{repairSOFlag},TechInfo=#{techInfo},Remark=#{remark} 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.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}
|
|
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
|
|
From dbo.view_SAP_SOBOM as B
|
|
left join ReferencePartInfo as E On B.Site=E.Site and B.ComponentPartNo=E.PartNo
|
|
and E.CustomerID=#{customerID} and (E.FGPartNo=#{partNo} or E.FGPartNo='全部')
|
|
,Part as P Where B.Site=P.Site and B.ComponentPartNo=P.PartNo
|
|
and 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.getOrderFirstItemNoFun(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>
|
|
</mapper>
|