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.
348 lines
18 KiB
348 lines
18 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.purchasingManagement.dao.MaterialSplitMapper">
|
|
<!-- 查询-卷信息 -->
|
|
<select id="searchRollInformation" resultType="com.gaotao.modules.purchasingManagement.entity.SearchRollInformationData">
|
|
select T.OrderRef2 as SAPOrderNo,T.OrderRef1 as OrderNo,isnull(T.SupplierID,'') as SupplierID,
|
|
isnull(dbo.Get_SupplierDesc(T.Site,T.SupplierID),'') as SupplierName,T.OrderRef3 as OrderItemNo,
|
|
T.PartNo,dbo.Get_Part_DescSpec(T.Site,T.PartNo) as PartDescription,T.RollNo,T.RollQty,T.consumedqty,
|
|
T.SuppDeliveryNote,T.RollDate,T.CreatedDate,T.CreatedBy,T.Status as RollStatus,T.SuppRollNoFlag,
|
|
T.SuppRollNo,T.Site,T.SourceType as Type,T.OriginalRollNo,T.OrderRef6,T.warehouseid,T.OrderRef7,
|
|
T.CustomerID,Isnull(T.frozenflag,'N') as frozenflag,T.frozendate,T.frozenby
|
|
from View_C_RollInfo as T
|
|
Left Join C_OrderSlittedList as D On D.OrderRef1 = T.OrderRef1 and D.OrderRef2 = T.OrderRef2 and D.OrderRef3 = T.OrderRef3 and D.Type = T.OrderRef4
|
|
|
|
<where>
|
|
AND T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
|
|
<if test=" site != null and site != ''">
|
|
AND T.Site = #{site}
|
|
</if>
|
|
<if test=" orderNo != null and orderNo != ''">
|
|
AND T.OrderRef1 like #{orderNo}
|
|
</if>
|
|
<if test=" type != null and type != ''">
|
|
AND T.SourceType like #{type}
|
|
</if>
|
|
<if test="rollNo != null and rollNo != ''">
|
|
AND T.RollNo like #{rollNo}
|
|
</if>
|
|
<if test=" supplierID != null and supplierID != ''">
|
|
AND T.SupplierID like #{supplierID}
|
|
</if>
|
|
<if test=" suppRollNo != null and suppRollNo != ''">
|
|
AND T.SuppRollNo like #{suppRollNo}
|
|
</if>
|
|
<if test=" rollStatus != null and rollStatus != ''">
|
|
AND T.Status like #{rollStatus}
|
|
</if>
|
|
<if test=" partNo != null and partNo != ''">
|
|
AND T.PartNo like #{partNo}
|
|
</if>
|
|
<if test=" warehouseid != null and warehouseid != ''">
|
|
AND T.warehouseid like #{warehouseid}
|
|
</if>
|
|
<if test=" orderRef6 != null and orderRef6 != ''">
|
|
AND T.OrderRef6 like #{orderRef6}
|
|
</if>
|
|
<if test=" orderRef7 != null and orderRef7 != ''">
|
|
AND T.OrderRef7 like #{orderRef7}
|
|
</if>
|
|
<if test=" frozenflag != null and frozenflag != ''">
|
|
AND T.frozenflag like #{frozenflag}
|
|
</if>
|
|
<if test=" date1 != null ">
|
|
AND T.CreatedDate >= #{date1}
|
|
</if>
|
|
<if test=" date2 != null ">
|
|
AND #{date2} >= T.CreatedDate
|
|
</if>
|
|
<if test=" date3 != null ">
|
|
AND T.RollDate >= #{date3}
|
|
</if>
|
|
<if test=" date4 != null ">
|
|
AND #{date4} >= T.RollDate
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="searchSAPPurchaseOrder" resultType="com.gaotao.modules.purchasingManagement.entity.ViewSapPoData">
|
|
Select T.SAPOrderNo,T.OrderNo,T.CancelledFlag,T.Status,T.OrderDate,T.PlanReceiptDate,T.SupplierID,T.SupplierName,T.OrderItemNo,T.PartNo,T.PartDescription,T.Quantity,T.Site,T.SlittedFlag
|
|
from view_SAP_PO as T
|
|
<where>
|
|
AND CancelledFlag!='Y' and T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
|
|
<if test=" site != null and site != ''">
|
|
AND T.Site = #{site}
|
|
</if>
|
|
<if test=" orderNo != null and orderNo != ''">
|
|
AND T.OrderNo like #{orderNo}
|
|
</if>
|
|
<if test=" date1 != null ">
|
|
AND T.OrderDate >= #{date1}
|
|
</if>
|
|
<if test=" date2 != null ">
|
|
AND #{date2} >= T.OrderDate
|
|
</if>
|
|
<if test=" slittedFlag != null and slittedFlag != ''">
|
|
AND T.SlittedFlag like #{slittedFlag}
|
|
</if>
|
|
</where>
|
|
|
|
</select>
|
|
<select id="searchSAPSlittedOrder" resultType="com.gaotao.modules.purchasingManagement.entity.ViewSapPoData">
|
|
Select T.SAPOrderNo,T.OrderNo,T.CancelledFlag ,T.Status,T.OrderDate,T.PlanReceiptDate,T.SupplierID,T.SupplierName,T.OrderItemNo,T.PartNo,T.PartDescription,T.Quantity,T.Site,T.SlittedFlag,
|
|
T.FGPartNo as SOPartNo
|
|
from view_SAP_SO as T
|
|
<where>
|
|
and T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
|
|
<if test=" site != null and site != ''">
|
|
AND T.Site = #{site}
|
|
</if>
|
|
<if test=" orderNo != null and orderNo != ''">
|
|
AND T.OrderNo like #{orderNo}
|
|
</if>
|
|
<if test=" date1 != null ">
|
|
AND T.OrderDate >= #{date1}
|
|
</if>
|
|
<if test=" date2 != null ">
|
|
AND #{date2} >= T.OrderDate
|
|
</if>
|
|
<if test=" slittedFlag != null and slittedFlag != ''">
|
|
AND T.SlittedFlag like #{slittedFlag}
|
|
</if>
|
|
</where>
|
|
|
|
</select>
|
|
<select id="searchCRollInfoDetail" resultType="com.gaotao.modules.purchasingManagement.entity.CRollInfoData">
|
|
Select Site,RollNo,RollQty,PartNo,SupplierID,OrderRef1,OrderRef2,OrderRef3,OrderRef4,SuppDeliveryNote,RollDate,CreatedDate,
|
|
CreatedBy,Status_DB,Status,SuppRollNo,RollSeqNo,SuppRollNoFlag,SourceType,OriginalRollNo,OrderRef5,rolltype,rolltype_db,
|
|
firstlevelrollno,remark,parttype_flag,warehouseid,synchronizedFlag,ConsumeOrderNo,ConsumeSeqNo,CustomerID,FGPartNo,
|
|
Ref_SupplierID,Ref_PartDesc,NeedsynchronizeFlag,OpsLog,frozenflag,frozendate,frozenby,ExpiredDate,ManufactureDate
|
|
from C_RollInfo
|
|
|
|
<where>
|
|
AND site=#{site} and OrderRef1=#{orderRef1}
|
|
<if test=" orderRef3 != null and orderRef3 != ''">
|
|
AND OrderRef3 = #{orderRef3}
|
|
</if>
|
|
<if test=" orderRef2 != null and orderRef2 != ''">
|
|
AND OrderRef2 = #{orderRef2}
|
|
</if>
|
|
<!-- <if test=" orderRef1 != null and orderRef1 != ''">-->
|
|
<!-- AND OrderRef1 = #{orderRef1}-->
|
|
<!-- </if>-->
|
|
</where>
|
|
order by RollNo
|
|
</select>
|
|
|
|
<select id="checkCOrderSlittedList" resultType="com.gaotao.modules.purchasingManagement.entity.COrderSlittedListData">
|
|
select OrderRef1,OrderRef2,OrderRef3,CreatedDate,CreatedBy,SupplierID,PartNo
|
|
from C_OrderSlittedList
|
|
WHERE OrderRef1=#{orderRef1} and OrderRef3=#{orderRef3} and site=#{site}
|
|
</select>
|
|
|
|
<insert id="saveCOrderSlittedList" parameterType="com.gaotao.modules.purchasingManagement.entity.COrderSlittedListData">
|
|
insert into C_OrderSlittedList (OrderRef1,OrderRef2,OrderRef3,CreatedDate,CreatedBy,Type,Site,SupplierID,PartNo)
|
|
values(#{orderRef1},#{orderRef2},#{orderRef3},#{createdDate},#{createdBy},'P',#{site},#{supplierID},#{partNo})
|
|
</insert>
|
|
|
|
<select id="getRollNo" resultType="Integer">
|
|
Select isnull(max(RollSeqNo),0) as SL from C_RollInfo as T
|
|
where T.OrderRef1=#{orderRef1} and T.OrderRef2=#{orderRef2} and T.OrderRef3=#{orderRef3} and T.Site=#{site}
|
|
and T.OrderRef4=#{orderRef4}
|
|
</select>
|
|
|
|
<insert id="saveCRollInfo" >
|
|
insert into C_RollInfo(Site,RollNo,RollQty,PartNo,SupplierID,OrderRef1,OrderRef2,OrderRef3,OrderRef4,
|
|
SuppDeliveryNote,RollDate,CreatedDate,CreatedBy,Status_DB,Status,SuppRollNo,RollSeqNo,SuppRollNoFlag,
|
|
SourceType,OriginalRollNo,OrderRef5,rolltype,rolltype_db,firstlevelrollno,remark,parttype_flag,
|
|
CustomerID,FGPartNo,Ref_SupplierID,Ref_PartDesc,warehouseid) values
|
|
(#{site},#{rollNo},#{rollQty},#{partNo},#{supplierID},#{orderRef1},#{orderRef2},#{orderRef3},#{orderRef4},
|
|
#{suppDeliveryNote},#{rollDate},#{createdDate},#{createdBy},#{statusDb},#{status},#{suppRollNo},#{rollSeqNo},#{suppRollNoFlag},
|
|
#{sourceType},#{originalRollNo},#{orderRef5},#{rolltype},#{rolltypeDb},#{firstlevelrollno},#{remark},#{parttypeFlag},
|
|
#{customerID},#{fGPartNo},#{refSupplierID},#{refPartDesc},#{warehouseid})
|
|
</insert>
|
|
|
|
<select id="checkRollNo" resultType="com.gaotao.modules.purchasingManagement.entity.CRollInfoData">
|
|
Select TOP 1 SuppRollNoFlag,SuppRollNo from C_RollInfo Where Site=#{site} and RollNo=#{rollNo}
|
|
</select>
|
|
|
|
<update id="doSaveSuppRollNo" >
|
|
Update C_RollInfo Set SuppRollNoFlag='Y',SuppRollNo=#{suppRollNo} Where Site=#{site} and RollNo=#{rollNo}
|
|
</update>
|
|
|
|
<select id="getTransRoll" resultType="com.gaotao.modules.purchasingManagement.entity.TransRollDetailData">
|
|
Select T.TransNo,T.TransDate,T.TransType_DB,T.UserName,D.subNo,D.subQty
|
|
,#{partNo} as PartNo
|
|
from TransHeader as T,TransDetailSub as D
|
|
Where T.Site=D.Site and T.TransNo=D.transNo
|
|
and (T.TransType_DB='SI' or T.TransType_DB='SIR')
|
|
and T.Site=#{site} and T.OrderRef1=#{orderRef1}
|
|
</select>
|
|
|
|
<select id="getNetWeight" resultType="Double">
|
|
Select Top 1 T.NetWeight from Part as T
|
|
Where T.Site= #{site} and T.PartNo=#{partNo}
|
|
</select>
|
|
|
|
<select id="checkCOrderCurrRoll" resultType="com.gaotao.modules.purchasingManagement.entity.COrderCurrRollData">
|
|
select Site,OrderNo,UserID,RollNo from C_OrderCurrRoll Where Site=#{site} and OrderNo=#{orderNo} and UserID=#{userID}
|
|
</select>
|
|
|
|
<select id="getTotalQty" resultType="Double">
|
|
Select isnull(sum(RollQty * P.NetWeight),0) as TotalQty from C_RollInfo as T,Part as P
|
|
where T.OrderRef1=#{orderRef1} and T.OriginalRollNo=#{originalRollNo} and T.Site=#{site} and T.Site=P.Site and T.PartNo=P.PartNo
|
|
</select>
|
|
|
|
<select id="getTotalQty2" resultType="Double">
|
|
Select isnull(sum((case when T.TransType_DB='SI' then 1.0 else -1.0 end) * D.subQty * P.NetWeight),0) as TotalQty
|
|
from TransHeader as T,TransDetailSub as D,TransDetail as E,Part as P
|
|
Where T.Site=D.Site and T.TransNo=D.transNo
|
|
and T.Site=E.Site and T.TransNo=E.transNo
|
|
and D.Site=E.Site and D.TransNo=E.transNo and D.ItemNo=E.ItemNo
|
|
and E.Site=P.Site and E.PartNo=P.PartNo
|
|
and (T.TransType_DB='SI' or T.TransType_DB='SIR')
|
|
and T.Site=#{site} and T.OrderRef1=#{orderRef1}
|
|
and D.SubNo= #{rollNo}
|
|
</select>
|
|
|
|
<delete id="deleteCOrderCurrRoll">
|
|
Delete from C_OrderCurrRoll Where Site=#{site} and OrderNo=#{orderNo} and UserID=#{userID}
|
|
</delete>
|
|
|
|
<select id="getWarehouseid" resultType="String">
|
|
Select warehouseid from C_RollInfo where RollNo=#{rollNo} and Site=#{site}
|
|
</select>
|
|
|
|
<select id="searchCRollInfoOld" resultType="com.gaotao.modules.purchasingManagement.entity.CRollInfoData">
|
|
Select firstlevelrollno,parttype_flag,SuppRollNo,SuppDeliveryNote,SupplierID from C_RollInfo as T
|
|
where T.RollNo=#{rollNo} and T.Site=#{site}
|
|
</select>
|
|
|
|
<insert id="saveTransHeader">
|
|
Insert into TransHeader(Site,TransNo,TransDate,TransType_DB,UserID,UserName,Remark,OrderRef1,Status,OrderRef2,OrderRef3,EnterDate)
|
|
VALUES (#{site},#{transNo},#{transDate},#{transTypeDb},#{userID},#{userName},#{remark},#{orderRef1},#{status},#{orderRef2},#{orderRef3},#{enterDate})
|
|
</insert>
|
|
|
|
<insert id="saveTransDetailSub">
|
|
Insert into TransDetailSub(site,transNo,itemNo,seqNo,subNo,subQty,direction,orderRef1,orderRef2,orderRef3,orderRef4,orderRef5,orderRef6,remark)
|
|
VALUES (#{site},#{transNo},#{itemNo},#{seqNo},#{subNo},#{subQty},#{direction},#{orderRef1},#{orderRef2},#{orderRef3},#{orderRef4},#{orderRef5},#{orderRef6},#{remark})
|
|
</insert>
|
|
|
|
<insert id="saveTransDetail">
|
|
INSERT INTO TransDetail (site,transNo,itemNo,partNo,transQty,batchNo,warehouseID,direction,orderRef1,orderRef2,orderRef3,orderRef4,orderRef5,remark)
|
|
SELECT
|
|
site,transNo,itemNo,orderRef5 AS PartNo,SUM (subQty) AS transQty,'*' AS batchNo,#{warehouseID} AS warehouseID,'-',orderRef1,orderRef2,orderRef3,orderRef4,orderRef5,remark
|
|
FROM
|
|
TransDetailSub
|
|
WHERE
|
|
Site = #{site} AND transNo = #{transNo}
|
|
GROUP BY
|
|
site,transNo,itemNo,orderRef5,orderRef1,orderRef2,orderRef3,orderRef4,orderRef5,remark
|
|
</insert>
|
|
|
|
<select id="getSysParamenter" resultType="String">
|
|
select dbo.Get_SysParamenter(#{site},#{parameterID})
|
|
</select>
|
|
|
|
<select id="getTransNo" resultType="String">
|
|
select dbo.Get_TransNo(#{site},#{type})
|
|
</select>
|
|
|
|
<update id="updateTransNo" >
|
|
EXEC UpdateTransNo #{site},#{type}
|
|
</update>
|
|
|
|
<select id="searchOrderRoll" resultType="com.gaotao.modules.purchasingManagement.entity.SearchOrderRollData">
|
|
Select D.OrderRef2 as SAPOrderNo,D.OrderRef1 as OrderNo,ISNULL(T.CancelledFlag,0) as CancelledFlag,T.Status,T.OrderDate,
|
|
T.PlanReceiptDate ,D.SupplierID,dbo.Get_SupplierDesc(D.Site,D.SupplierID) as SupplierName ,D.OrderRef3 as OrderItemNo,
|
|
D.PartNo,dbo.Get_Part_DescSpec(D.Site,D.PartNo) as PartDescription,isnull(T.Quantity,0.0) as Quantity,D.Site,
|
|
D.CreatedDate,D.CreatedBy,(Case when D.Type='P' then '采购订单' when D.Type='S' then '分卷订单' else '期初入库' end) as Type
|
|
from C_OrderSlittedList as D
|
|
Left Join view_SAP_AllOrder as T On Convert(Varchar(30),T.OrderNo)=D.OrderRef1 and Convert(Varchar(30),T.SAPOrderNo)=D.OrderRef2 and Convert(Varchar(30),T.OrderItemNo)=D.OrderRef3 and T.Type = (Case when D.Type='P' then '采购订单' when D.Type='S' then '分卷订单' else '' end)
|
|
<where>
|
|
AND D.Site in (Select Site from AccessSite where upper(UserID)=#{user})
|
|
<if test=" site != null and site != ''">
|
|
AND D.Site like #{site}
|
|
</if>
|
|
<if test=" orderNo != null and orderNo != ''">
|
|
and D.OrderRef1 like #{orderNo}
|
|
</if>
|
|
<if test=" type != null and type != ''">
|
|
and (Case when D.Type='P' then '采购订单' when D.Type='S' then '分卷订单' else '期初入库' end) = #{type}
|
|
</if>
|
|
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getCRollInfo" resultType="com.gaotao.modules.purchasingManagement.entity.CRollInfoData">
|
|
Select TOP 1 Site,RollNo,RollQty,PartNo,dbo.Get_Part_DescSpec(Site,PartNo) as spec,
|
|
Status_DB,Status,SourceType,1 as number,warehouseid,SupplierID
|
|
from C_RollInfo
|
|
|
|
<where>
|
|
AND site=#{site} and RollNo=#{rollNo}
|
|
|
|
</where>
|
|
order by RollNo
|
|
</select>
|
|
|
|
<select id="getUserSpecialSecurity" resultType="String">
|
|
SELECT dbo.Get_User_Special_Security(#{userId},#{itemNo})
|
|
</select>
|
|
|
|
<update id="updateRollInfo" >
|
|
Update C_RollInfo Set Status_DB='D' ,Status='已耗用' ,ConsumeOrderNo=#{orderRef1} ,ConsumeSeqNo=-1
|
|
,NeedsynchronizeFlag='N',synchronizedFlag='N' where RollNo=#{rollNo} and Site=#{site}
|
|
</update>
|
|
|
|
<insert id="insertCOrderCurrRoll">
|
|
Insert into C_OrderCurrRoll(Site,OrderNo,UserID,RollNo)
|
|
Values(#{site},#{orderRef1},#{user},#{rollNo})
|
|
</insert>
|
|
|
|
<select id="getSourceType" resultType="String">
|
|
SELECT top 1 isnull(SourceType,'') FROM C_RollInfo WHERE site=#{site} and RollNo=#{rollNo}
|
|
</select>
|
|
<delete id="deleteRoll">
|
|
delete from C_RollInfo WHERE site=#{site} and rollNo=#{rollNo}
|
|
</delete>
|
|
|
|
<delete id="deleteRoll2">
|
|
delete from C_OrderSlittedList WHERE OrderRef1=#{orderRef1} and OrderRef2=#{orderRef2} and OrderRef3=#{orderRef3}
|
|
</delete>
|
|
|
|
<select id="checkRollStatus" resultType="com.gaotao.modules.purchasingManagement.entity.CRollInfoData">
|
|
select 1 from C_RollInfo Where Site=#{site} and RollNo =#{rollNo} and NOT (Status_db='D' and ISNULL(synchronizedFlag,'N')='N' and ISNULL(NeedsynchronizeFlag,'Y')='Y')
|
|
</select>
|
|
|
|
<update id="sapSynchronization" >
|
|
Update C_RollInfo Set synchronizedFlag='Y' ,OpsLog=(isnull(OpsLog,'')+#{user}+#{type} +'手工更改了同步标识' )
|
|
where site=#{site} and rollNo=#{rollNo}
|
|
</update>
|
|
|
|
<select id="checkFrozenflag" resultType="com.gaotao.modules.purchasingManagement.entity.CRollInfoData">
|
|
select 1 from C_RollInfo Where Site=#{site} and RollNo =#{rollNo} and ISNULL(frozenflag,'N')='Y'
|
|
</select>
|
|
|
|
<update id="freezing">
|
|
Update C_RollInfo Set frozenflag='Y' ,frozendate= #{type},frozenby=#{user},OpsLog=(isnull(OpsLog,'')+#{user}+#{type} +'冻结' )
|
|
where site=#{site} and rollNo=#{rollNo}
|
|
</update>
|
|
|
|
<update id="notFreezing">
|
|
Update C_RollInfo Set frozenflag='N' ,frozendate= null,frozenby=null,OpsLog=(isnull(OpsLog,'')+#{user}+#{type} +'取消冻结' )
|
|
where site=#{site} and rollNo=#{rollNo}
|
|
</update>
|
|
|
|
<!--2022-04-24 获取分切材料打印分切卷的标签-->
|
|
<select id="getSplitPrintMaterialRoll" parameterType="com.gaotao.modules.purchasingManagement.entity.CRollInfoData" resultType="java.util.HashMap">
|
|
SELECT cri.RollNo rollNo, cri.PartNo partNo,
|
|
(CASE WHEN dbo.Get_ReferenceInfo_SupplierID(cri.Site, cri.PartNo, cri.CustomerID, cri.FGPartNo) = '' THEN cri.SupplierID ELSE dbo.Get_ReferenceInfo_SupplierID(cri.Site,cri.PartNo,cri.CustomerID,cri.FGPartNo) END) supplierId,
|
|
dbo.Get_SupplierDesc(cri.Site, (CASE WHEN dbo.Get_ReferenceInfo_SupplierID(cri.Site, cri.PartNo, cri.CustomerID, cri.FGPartNo) = '' THEN cri.SupplierID ELSE dbo.Get_ReferenceInfo_SupplierID(cri.Site, cri.PartNo, cri.CustomerID, cri.FGPartNo) END)) supplierDesc,
|
|
(CASE WHEN dbo.Get_ReferenceInfo_PartDesc(cri.Site, cri.PartNo, cri.CustomerID, cri.FGPartNo) = '' THEN pt.PartDescription ELSE dbo.Get_ReferenceInfo_PartDesc(cri.Site,cri.PartNo,cri.CustomerID,cri.FGPartNo) END) partDesc,
|
|
'' spec, cri.RollQty rollQty, pt.UMID umid, cri.RollDate rollDate, NULL expiredDate, cri.CreatedBy createdBy, pt.DefaultLocationID locationId
|
|
FROM C_RollInfo cri
|
|
LEFT JOIN Part pt ON cri.Site = pt.Site AND cri.PartNo = pt.PartNo
|
|
WHERE cri.Site = #{site} AND cri.RollNo = #{rollNo}
|
|
|
|
</select>
|
|
</mapper>
|