You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2130 lines
93 KiB
XML

<?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.op.wms.mapper.OdsProcureOutOrderMapper">
<resultMap type="OdsProcureOutOrder" id="OdsProcureOutOrderResult">
<result property="siteCode" column="Site_code"/>
<result property="ID" column="ID"/>
<result property="produceCode" column="Produce_Code"/>
<result property="materialCode" column="Material_Code"/>
<result property="materialCodeKEN" column="materialCodeKEN"/>
<result property="materialDesc" column="Material_Desc"/>
<result property="planDate" column="Plan_Date"/>
<result property="planNumber" column="Plan_Number"/>
<result property="Unit" column="Unit"/>
<result property="outNumber" column="Out_Number"/>
<result property="locCode" column="Loc_Code"/>
<result property="locDesc" column="Loc_Desc"/>
<result property="productionLineDesc" column="Production_Line_Desc"/>
<result property="productionLineCode" column="Production_Line_Code"/>
<result property="orderStatus" column="Order_Status"/>
<result property="userDefined1" column="User_Defined1"/>
<result property="userDefined2" column="User_Defined2"/>
<result property="userDefined3" column="User_Defined3"/>
<result property="userDefined4" column="User_Defined4"/>
<result property="userDefined5" column="User_Defined5"/>
<result property="userDefined6" column="User_Defined6"/>
<result property="userDefined7" column="User_Defined7"/>
<result property="userDefined8" column="User_Defined8"/>
<result property="userDefined9" column="User_Defined9"/>
<result property="userDefined10" column="User_Defined10"/>
<result property="userDefined11" column="User_Defined11"/>
<result property="supplierCode" column="Supplier_Code"/>
<result property="supplierName" column="Supplier_Name"/>
<result property="createBy" column="Create_By"/>
<result property="createDate" column="Create_Date"/>
<result property="lastUpdateBy" column="Last_Update_By"/>
<result property="lastUpdateDate" column="Last_Update_Date"/>
<result property="Active" column="Active"/>
<result property="enterpriseId" column="Enterprise_Id"/>
<result property="enterpriseCode" column="Enterprise_Code"/>
<result property="workorderCode" column="workorderCode"/>
<result property="needDate" column="needDate"/>
<result property="returnNumber" column="Return_Number"/>
<result property="sapNumber" column="Sap_Number"/>
</resultMap>
<sql id="pagination_tail">
limit #{page.pageOffset} , #{page.rows}
</sql>
<sql id="selectOdsProcureOutOrderVo">
select Site_code, ID, Produce_Code, Material_Code, Material_Desc, Plan_Date, Plan_Number, Unit, COALESCE(Out_Number, 0) as Out_Number , Loc_Code, Loc_Desc, Production_Line_Desc, Production_Line_Code, Order_Status, User_Defined1, User_Defined2, User_Defined3, User_Defined4, User_Defined5, User_Defined6, User_Defined7, User_Defined8, User_Defined9, User_Defined10, User_Defined11, Supplier_Code, Supplier_Name, Create_By, Create_Date, Last_Update_By, Last_Update_Date, Active, Enterprise_Id, Enterprise_Code from ods_procure_out_order
</sql>
<select id="selectOdsProcureOutOrderListZU" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Produce_Code,
User_Defined1,
MAX(Create_Date) AS Create_Date
FROM
ods_procure_out_order
where
Active='1'
<if test="produceCode != null and produceCode != ''"> and Produce_Code like concat('%', #{produceCode}, '%')
</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
GROUP BY Produce_Code,User_Defined1
ORDER BY
Create_Date DESC;
</select>
<select id="selectOdsProcureOutOrderListZUfcsy" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Material_Code,
User_Defined5,
sum(Plan_Number) AS Out_Number
FROM
ods_procure_out_order_fc
where
Active='1'
and Material_Code like concat('%', #{materialCode}, '%')
and User_Defined5 = #{userDefined5}
GROUP BY User_Defined5,Material_Code
</select>
<select id="selectOdsProcureOutOrderListZUKEN" resultType="java.lang.String">
SELECT DISTINCT
User_Defined11
FROM
ods_procure_out_order
WHERE
Active = '1'
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
AND User_Defined3 !='x'
</select>
<select id="selectOdsProcureOutOrderListZUKENX" resultType="java.lang.String">
SELECT DISTINCT
User_Defined11
FROM
ods_procure_out_order
WHERE
Active = '1'
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
AND User_Defined3 ='x'
</select>
<select id="selectOdsProcureOutOrderListZUT" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
<include refid="selectOdsProcureOutOrderVo"/>
<where>
<if test="produceCode != null and produceCode != ''"> and Produce_Code like concat('%', #{produceCode}, '%')</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
</where>
</select>
<select id="selectOdsProcureOutOrderList" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
<include refid="selectOdsProcureOutOrderVo"/>
<where>
<if test="siteCode != null and siteCode != ''"> and Site_code = #{siteCode}</if>
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''"> and Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> and Plan_Date = #{planDate}</if>
<if test="planNumber != null "> and Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and Unit = #{Unit}</if>
<if test="outNumber != null "> and Out_Number = #{outNumber}</if>
<if test="locCode != null and locCode != ''"> and Loc_Code = #{locCode}</if>
<if test="locDesc != null and locDesc != ''"> and Loc_Desc = #{locDesc}</if>
<if test="productionLineDesc != null and productionLineDesc != ''"> and Production_Line_Desc = #{productionLineDesc}</if>
<if test="productionLineCode != null and productionLineCode != ''"> and Production_Line_Code = #{productionLineCode}</if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and User_Defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''"> and User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''"> and Supplier_Code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and Supplier_Name like concat('%', #{supplierName}, '%')</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createDate != null "> and Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
</where>
</select>
<select id="selectOdsProcureOutOrderByID" parameterType="String" resultMap="OdsProcureOutOrderResult">
<include refid="selectOdsProcureOutOrderVo"/>
where ID = #{ID}
</select>
<insert id="insertOdsProcureOutOrder" parameterType="OdsProcureOutOrder">
insert into ods_procure_out_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="siteCode != null">Site_code,</if>
<if test="ID != null">ID,</if>
<if test="produceCode != null">Produce_Code,</if>
<if test="materialCode != null">Material_Code,</if>
<if test="materialDesc != null">Material_Desc,</if>
<if test="planDate != null">Plan_Date,</if>
<if test="planNumber != null">Plan_Number,</if>
<if test="Unit != null">Unit,</if>
<if test="outNumber != null">Out_Number,</if>
<if test="locCode != null">Loc_Code,</if>
<if test="locDesc != null">Loc_Desc,</if>
<if test="productionLineDesc != null">Production_Line_Desc,</if>
<if test="productionLineCode != null">Production_Line_Code,</if>
<if test="orderStatus != null">Order_Status,</if>
<if test="userDefined1 != null">User_Defined1,</if>
<if test="userDefined2 != null">User_Defined2,</if>
<if test="userDefined3 != null">User_Defined3,</if>
<if test="userDefined4 != null">User_Defined4,</if>
<if test="userDefined5 != null">User_Defined5,</if>
<if test="userDefined6 != null">User_Defined6,</if>
<if test="userDefined7 != null">User_Defined7,</if>
<if test="userDefined8 != null">User_Defined8,</if>
<if test="userDefined9 != null">User_Defined9,</if>
<if test="userDefined10 != null">User_Defined10,</if>
<if test="userDefined11 != null">User_Defined11,</if>
<if test="supplierCode != null">Supplier_Code,</if>
<if test="supplierName != null">Supplier_Name,</if>
<if test="createBy != null">Create_By,</if>
<if test="createDate != null">Create_Date,</if>
<if test="lastUpdateBy != null">Last_Update_By,</if>
<if test="lastUpdateDate != null">Last_Update_Date,</if>
<if test="Active != null">Active,</if>
<if test="enterpriseId != null">Enterprise_Id,</if>
<if test="enterpriseCode != null">Enterprise_Code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="siteCode != null">#{siteCode},</if>
<if test="ID != null">#{ID},</if>
<if test="produceCode != null">#{produceCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="planDate != null">#{planDate},</if>
<if test="planNumber != null">#{planNumber},</if>
<if test="Unit != null">#{Unit},</if>
<if test="outNumber != null">#{outNumber},</if>
<if test="locCode != null">#{locCode},</if>
<if test="locDesc != null">#{locDesc},</if>
<if test="productionLineDesc != null">#{productionLineDesc},</if>
<if test="productionLineCode != null">#{productionLineCode},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="userDefined1 != null">#{userDefined1},</if>
<if test="userDefined2 != null">#{userDefined2},</if>
<if test="userDefined3 != null">#{userDefined3},</if>
<if test="userDefined4 != null">#{userDefined4},</if>
<if test="userDefined5 != null">#{userDefined5},</if>
<if test="userDefined6 != null">#{userDefined6},</if>
<if test="userDefined7 != null">#{userDefined7},</if>
<if test="userDefined8 != null">#{userDefined8},</if>
<if test="userDefined9 != null">#{userDefined9},</if>
<if test="userDefined10 != null">#{userDefined10},</if>
<if test="userDefined11 != null">#{userDefined11},</if>
<if test="supplierCode != null">#{supplierCode},</if>
<if test="supplierName != null">#{supplierName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="lastUpdateBy != null">#{lastUpdateBy},</if>
<if test="lastUpdateDate != null">#{lastUpdateDate},</if>
<if test="Active != null">#{Active},</if>
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="enterpriseCode != null">#{enterpriseCode},</if>
</trim>
</insert>
<insert id="insertOdsProcureOutOrderfc" parameterType="OdsProcureOutOrder">
insert into ods_procure_out_order_fc
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="siteCode != null">Site_code,</if>
<if test="ID != null">ID,</if>
<if test="produceCode != null">Produce_Code,</if>
<if test="materialCode != null">Material_Code,</if>
<if test="materialDesc != null">Material_Desc,</if>
<if test="planDate != null">Plan_Date,</if>
<if test="planNumber != null">Plan_Number,</if>
<if test="Unit != null">Unit,</if>
<if test="outNumber != null">Out_Number,</if>
<if test="locCode != null">Loc_Code,</if>
<if test="locDesc != null">Loc_Desc,</if>
<if test="productionLineDesc != null">Production_Line_Desc,</if>
<if test="productionLineCode != null">Production_Line_Code,</if>
<if test="orderStatus != null">Order_Status,</if>
<if test="userDefined1 != null">User_Defined1,</if>
<if test="userDefined2 != null">User_Defined2,</if>
<if test="userDefined3 != null">User_Defined3,</if>
<if test="userDefined4 != null">User_Defined4,</if>
<if test="userDefined5 != null">User_Defined5,</if>
<if test="userDefined6 != null">User_Defined6,</if>
<if test="userDefined7 != null">User_Defined7,</if>
<if test="userDefined8 != null">User_Defined8,</if>
<if test="userDefined9 != null">User_Defined9,</if>
<if test="userDefined10 != null">User_Defined10,</if>
<if test="userDefined11 != null">User_Defined11,</if>
<if test="supplierCode != null">Supplier_Code,</if>
<if test="supplierName != null">Supplier_Name,</if>
<if test="createBy != null">Create_By,</if>
<if test="createDate != null">Create_Date,</if>
<if test="lastUpdateBy != null">Last_Update_By,</if>
<if test="lastUpdateDate != null">Last_Update_Date,</if>
<if test="Active != null">Active,</if>
<if test="enterpriseId != null">Enterprise_Id,</if>
<if test="enterpriseCode != null">Enterprise_Code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="siteCode != null">#{siteCode},</if>
<if test="ID != null">#{ID},</if>
<if test="produceCode != null">#{produceCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="planDate != null">#{planDate},</if>
<if test="planNumber != null">#{planNumber},</if>
<if test="Unit != null">#{Unit},</if>
<if test="outNumber != null">#{outNumber},</if>
<if test="locCode != null">#{locCode},</if>
<if test="locDesc != null">#{locDesc},</if>
<if test="productionLineDesc != null">#{productionLineDesc},</if>
<if test="productionLineCode != null">#{productionLineCode},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="userDefined1 != null">#{userDefined1},</if>
<if test="userDefined2 != null">#{userDefined2},</if>
<if test="userDefined3 != null">#{userDefined3},</if>
<if test="userDefined4 != null">#{userDefined4},</if>
<if test="userDefined5 != null">#{userDefined5},</if>
<if test="userDefined6 != null">#{userDefined6},</if>
<if test="userDefined7 != null">#{userDefined7},</if>
<if test="userDefined8 != null">#{userDefined8},</if>
<if test="userDefined9 != null">#{userDefined9},</if>
<if test="userDefined10 != null">#{userDefined10},</if>
<if test="userDefined11 != null">#{userDefined11},</if>
<if test="supplierCode != null">#{supplierCode},</if>
<if test="supplierName != null">#{supplierName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="lastUpdateBy != null">#{lastUpdateBy},</if>
<if test="lastUpdateDate != null">#{lastUpdateDate},</if>
<if test="Active != null">#{Active},</if>
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="enterpriseCode != null">#{enterpriseCode},</if>
</trim>
</insert>
<update id="updateOdsProcureOutOrder" parameterType="OdsProcureOutOrder">
update ods_procure_out_order
<trim prefix="SET" suffixOverrides=",">
<if test="siteCode != null">Site_code = #{siteCode},</if>
<if test="produceCode != null">Produce_Code = #{produceCode},</if>
<if test="materialCode != null">Material_Code = #{materialCode},</if>
<if test="materialDesc != null">Material_Desc = #{materialDesc},</if>
<if test="planDate != null">Plan_Date = #{planDate},</if>
<if test="planNumber != null">Plan_Number = #{planNumber},</if>
<if test="Unit != null">Unit = #{Unit},</if>
<if test="outNumber != null">Out_Number = #{outNumber},</if>
<if test="locCode != null">Loc_Code = #{locCode},</if>
<if test="locDesc != null">Loc_Desc = #{locDesc},</if>
<if test="productionLineDesc != null">Production_Line_Desc = #{productionLineDesc},</if>
<if test="productionLineCode != null">Production_Line_Code = #{productionLineCode},</if>
<if test="orderStatus != null">Order_Status = #{orderStatus},</if>
<if test="userDefined1 != null">User_Defined1 = #{userDefined1},</if>
<if test="userDefined2 != null">User_Defined2 = #{userDefined2},</if>
<if test="userDefined3 != null">User_Defined3 = #{userDefined3},</if>
<if test="userDefined4 != null">User_Defined4 = #{userDefined4},</if>
<if test="userDefined5 != null">User_Defined5 = #{userDefined5},</if>
<if test="userDefined6 != null">User_Defined6 = #{userDefined6},</if>
<if test="userDefined7 != null">User_Defined7 = #{userDefined7},</if>
<if test="userDefined8 != null">User_Defined8 = #{userDefined8},</if>
<if test="userDefined9 != null">User_Defined9 = #{userDefined9},</if>
<if test="userDefined10 != null">User_Defined10 = #{userDefined10},</if>
<if test="userDefined11 != null">User_Defined11 = #{userDefined11},</if>
<if test="supplierCode != null">Supplier_Code = #{supplierCode},</if>
<if test="supplierName != null">Supplier_Name = #{supplierName},</if>
<if test="createBy != null">Create_By = #{createBy},</if>
<if test="createDate != null">Create_Date = #{createDate},</if>
<if test="lastUpdateBy != null">Last_Update_By = #{lastUpdateBy},</if>
<if test="lastUpdateDate != null">Last_Update_Date = #{lastUpdateDate},</if>
<if test="Active != null">Active = #{Active},</if>
<if test="enterpriseId != null">Enterprise_Id = #{enterpriseId},</if>
<if test="enterpriseCode != null">Enterprise_Code = #{enterpriseCode},</if>
</trim>
where ID = #{ID}
</update>
<update id="updateOdsProcureOutOrderByPcAndMc" parameterType="OdsProcureOutOrder">
update wms_ods_procure_out_order
set Return_Number = COALESCE(Return_Number, 0) + #{qty}
where Produce_Code = #{produceCode} and Material_Code=#{materialCode}
</update>
<delete id="deleteOdsProcureOutOrderByID" parameterType="String">
delete from ods_procure_out_order where ID = #{ID}
</delete>
<delete id="deleteOdsProcureOutOrderByIDs" parameterType="String">
delete from ods_procure_out_order where ID in
<foreach item="ID" collection="array" open="(" separator="," close=")">
#{ID}
</foreach>
</delete>
<select id="selectmesPrepare" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
prepare_id id,
workorder_name Produce_Code,
workorder_code workorderCode,
product_code Material_Code,
product_name Material_Desc,
unit Unit,
product_date Plan_Date,
prod_type User_Defined1
FROM mes_prepare WHERE
workorder_name =#{produceCode}
</select>
<select id="selectmesPrepareDetail" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
mes_prepare_detail.record_id ID,
mes_prepare.workorder_name,
mes_prepare_detail.prepare_id User_Defined2,
mes_prepare_detail.material_code Material_Code,
SUBSTRING(mes_prepare_detail.material_code, 8, LEN(mes_prepare_detail.material_code)) AS materialCodeKEN,
mes_prepare_detail.material_name Material_Desc,
mes_prepare_detail.prod_type User_Defined1,
mes_prepare_detail.unit Unit,
mes_prepare_detail.quantity Plan_Number,
COALESCE(out_order.Plan_Number, 0) Out_Number,
mes_prepare_detail.recoil User_Defined3,
mes_prepare_detail.factory_code Site_code
FROM
mes_prepare_detail
LEFT JOIN mes_prepare ON mes_prepare.prepare_id= mes_prepare_detail.prepare_id
LEFT JOIN (SELECT Produce_Code,Material_Code,SUM(Plan_Number) Plan_Number FROM ods_procure_out_order GROUP BY Produce_Code,Material_Code)AS out_order ON out_order.Produce_Code= mes_prepare.workorder_name AND out_order.Material_Code=mes_prepare_detail.material_code
WHERE
mes_prepare_detail.prepare_id= #{ID}
ORDER BY mes_prepare_detail.recoil
</select>
<insert id="insertWmsRawMissionOut" >
insert into wms_raw_mission_out(id,
prd_order,
material_code,
material_desc,
unit,
user_defined1,
user_defined2,
user_defined3,
user_defined4,
user_defined5,
sn,
amount,
origin_location,
factory_code,
active_flag,
create_by,
gmt_create
)values (
#{ID},
#{produceCode},
#{materialCode},
#{materialDesc},
#{Unit},
#{userDefined1},
#{userDefined2},
#{userDefined3},
#{userDefined4},
'1',
#{sn},
#{planNumber},
#{locCode},
#{factoryCode},
#{Active},
#{createBy},
#{createDate} )
</insert>
<update id="updateOdsProcureOutOrderByid">
update ods_procure_out_order
set User_Defined10 = #{userDefined10},
User_Defined9 = #{userDefined9},
User_Defined11 = #{userDefined11}
where ID = #{ID}
</update>
<update id="updateOdsProcureOutOrderByids">
update ods_procure_out_order
set User_Defined10 = #{order.userDefined10},
User_Defined9 = #{order.userDefined9},
User_Defined11 = #{order.userDefined11}
where ID in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.ID}
</foreach>
</update>
<update id="updateWMSOdsProcureOutOrderByids">
update wms_ods_procure_out_order
set User_Defined10 = #{order.userDefined10},
User_Defined9 = CASE
WHEN User_Defined9 IS NULL OR User_Defined9 = '' THEN #{order.userDefined9}
ELSE CONCAT(User_Defined9, ',', #{order.userDefined9})
END,
User_Defined11 = #{order.userDefined11}
where ID in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.ID}
</foreach>
</update>
<update id="updateWMSOdsProcureReturnOrderByids">
update wms_ods_procure_return_order
set User_Defined10 = #{order.userDefined10},
User_Defined9 = #{order.userDefined9},
User_Defined11 = #{order.userDefined11}
where ID in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.ID}
</foreach>
</update>
<update id="updateOdsProcureOutOrderByidsfc">
update ods_procure_out_order_fc
set User_Defined10 = #{order.userDefined10},
User_Defined9 = #{order.userDefined9},
User_Defined11 = #{order.userDefined11}
where ID in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.ID}
</foreach>
</update>
<select id="selectOdsProcureOutOrderListByIds" resultMap="OdsProcureOutOrderResult">
<include refid="selectOdsProcureOutOrderVo"/>
WHERE
<![CDATA[ Order_Status = '3' and (User_Defined10 <> '2' OR User_Defined10 is NULL ) ]]>
and ID in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.ID}
</foreach>
</select>
<select id="selectOdsProcureOutOrderListByu1fc" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Plan_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
from ods_procure_out_order_fc
WHERE
<![CDATA[ (User_Defined10 <> '2' OR User_Defined10 is NULL ) ]]>
and Produce_Code in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.produceCode}
</foreach>
and User_Defined1 in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.userDefined1}
</foreach>
</select>
<select id="selectOdsProcureOutOrderListByu1" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Plan_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
from ods_procure_out_order
WHERE
<![CDATA[ (User_Defined10 <> '2' OR User_Defined10 is NULL ) ]]>
and Produce_Code in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.produceCode}
</foreach>
and User_Defined1 in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.userDefined1}
</foreach>
</select>
<select id="selectMachineCode" resultType="java.lang.String">
SELECT DISTINCT
machine_code
FROM mes_report_work
WHERE workorder_code=#{order.workorderCode}
</select>
<select id="selectmesPrepareDetailWhite" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
mes_prepare_detail.record_id ID,
mes_prepare.workorder_name,
mes_prepare_detail.prepare_id User_Defined2,
mes_prepare_detail.material_code Material_Code,
mes_prepare_detail.material_name Material_Desc,
mes_prepare_detail.prod_type User_Defined1,
mes_prepare_detail.unit Unit,
mes_prepare_detail.quantity Plan_Number,
COALESCE ( ods_white_embryo.Reality_Number, 0 ) Out_Number,
mes_prepare_detail.recoil User_Defined3,
mes_prepare_detail.factory_code Site_code
FROM
mes_prepare_detail
LEFT JOIN mes_prepare ON mes_prepare.prepare_id= mes_prepare_detail.prepare_id
LEFT JOIN ods_white_embryo ON ods_white_embryo.Order_Code= mes_prepare.workorder_name
AND ods_white_embryo.Material_Code= mes_prepare_detail.material_code
WHERE
mes_prepare_detail.prepare_id= #{ ID}
</select>
<select id="selectmesPreparelike" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
prepare_id id,
workorder_name Produce_Code,
workorder_code workorderCode,
product_code Material_Code,
product_name Material_Desc,
unit Unit,
product_date Plan_Date,
prod_type User_Defined1
FROM mes_prepare
WHERE workorder_name LIKE CONCAT('%', #{produceCode}, '%')
and del_flag='0'
</select>
<select id="selectOdsProcureOutOrderListZUfc" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
ods_procure_out_order_fc
<where>
<if test="siteCode != null and siteCode != ''"> and Site_code = #{siteCode}</if>
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code like concat('%', #{materialCode},
'%')</if>
<if test="materialDesc != null and materialDesc != ''"> and Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> and Plan_Date = #{planDate}</if>
<if test="planNumber != null "> and Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and Unit = #{Unit}</if>
<if test="outNumber != null "> and Out_Number = #{outNumber}</if>
<if test="locCode != null and locCode != ''"> and Loc_Code = #{locCode}</if>
<if test="locDesc != null and locDesc != ''"> and Loc_Desc = #{locDesc}</if>
<if test="productionLineDesc != null and productionLineDesc != ''"> and Production_Line_Desc = #{productionLineDesc}</if>
<if test="productionLineCode != null and productionLineCode != ''"> and Production_Line_Code = #{productionLineCode}</if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and User_Defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''"> and User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''"> and Supplier_Code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and Supplier_Name like concat('%', #{supplierName}, '%')</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createDate != null "> and Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
</where>
ORDER BY User_Defined5 DESC, Produce_Code DESC
</select>
<select id="PurchaseOrderOutboundPdafc" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
need_date User_Defined5,
material_code Material_Code,
material_name Material_Desc,
unit Unit,
factory_code Site_code,
SUM ( quantity ) AS Plan_Number
FROM
[dbo].[mes_prepare_detail] -- 筛选出 recoil 列为 'x' 的行
WHERE
recoil = 'x'
<![CDATA[ AND need_date <= #{planDateMax} ]]>
AND need_date >= #{planDateMin}
AND material_code LIKE concat('%', #{materialCode}, '%') -- 在子查询中按 need_date 列进行分组
GROUP BY
need_date,
material_code,
material_name,
factory_code,
unit
</select>
<select id="selectMesPrepareBC" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
prepare_id ID,
workorder_name Produce_Code,
workorder_code workorderCode
FROM mes_prepare WHERE
workorder_code =#{userDefined4}
and del_flag='0'
</select>
<select id="selectMesPrepareDetailBC" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
mp.workorder_name workorderCode,
mpd.material_code Material_Code,
mpd.material_name Material_Desc,
mpd.quantity Plan_Number,
mpd.unit Unit,
mpd.fund_quanlity fundQuanlity,
mpd.factory_code Site_code,
mpd.recoil User_Defined3,
ow.product_date needDate
FROM
pro_order_workorder ow
LEFT JOIN mes_prepare mp ON ow.workorder_code = mp.workorder_code
LEFT JOIN mes_prepare_detail mpd ON mp.prepare_id = mpd.prepare_id
WHERE
ow.belong_work_order =#{workorderCode}
AND ow.del_flag = '0'
AND mpd.recoil =''
AND mp.del_flag = '0'
AND mpd.del_flag = '0'
ORDER BY
mpd.recoil
</select>
<select id="selectWmsOdsProcureOutOrderByID" parameterType="String" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order
where ID = #{ID}
</select>
<select id="selectWmsOdsProcureOutOrderByIDs" resultMap="OdsProcureOutOrderResult">
SELECT DISTINCT
wms_ods_procure_out_order.Site_code,
wms_ods_procure_out_order.ID,
wms_ods_procure_out_order.Produce_Code,
wms_ods_procure_out_order.Material_Code,
wms_ods_procure_out_order.Material_Desc,
wms_ods_procure_out_order.Plan_Date,
wms_ods_procure_out_order.Plan_Number,
wms_ods_procure_out_order.Unit,
COALESCE ( wms_ods_procure_out_order.Out_Number, 0 ) - COALESCE ( wms_ods_procure_out_order.Sap_Number, 0 ) AS Out_Number ,
wms_raw_mission_out.user_defined2 Loc_Code,
wms_ods_procure_out_order.Loc_Desc,
wms_ods_procure_out_order.Production_Line_Desc,
wms_ods_procure_out_order.Production_Line_Code,
wms_ods_procure_out_order.Order_Status,
wms_ods_procure_out_order.User_Defined1,
wms_ods_procure_out_order.User_Defined2,
wms_ods_procure_out_order.User_Defined3,
wms_ods_procure_out_order.User_Defined4,
wms_ods_procure_out_order.User_Defined5,
wms_ods_procure_out_order.User_Defined6,
wms_ods_procure_out_order.User_Defined7,
wms_ods_procure_out_order.User_Defined8,
wms_ods_procure_out_order.User_Defined9,
wms_ods_procure_out_order.User_Defined10,
wms_ods_procure_out_order.User_Defined11,
wms_ods_procure_out_order.Supplier_Code,
wms_ods_procure_out_order.Supplier_Name,
wms_ods_procure_out_order.Create_By,
wms_ods_procure_out_order.Create_Date,
wms_ods_procure_out_order.Last_Update_By,
wms_ods_procure_out_order.Last_Update_Date,
wms_ods_procure_out_order.Active,
wms_ods_procure_out_order.Enterprise_Id,
COALESCE ( wms_ods_procure_out_order.Sap_Number, 0 ) AS Sap_Number,
wms_ods_procure_out_order.Enterprise_Code
FROM
wms_ods_procure_out_order
LEFT JOIN wms_raw_mission_out ON wms_raw_mission_out.prd_order = wms_ods_procure_out_order.Produce_Code
AND wms_raw_mission_out.material_code = wms_ods_procure_out_order.Material_Code
where wms_ods_procure_out_order.ID IN
<foreach item="odsProcureOutOrder" collection="list" open="(" separator="," close=")">
#{odsProcureOutOrder.ID}
</foreach>
AND (COALESCE ( wms_ods_procure_out_order.Out_Number, 0 ) - COALESCE ( wms_ods_procure_out_order.Sap_Number, 0 ))>0
</select>
<select id="selectWmsOdsProcureOutOrderByIDsTS" resultMap="OdsProcureOutOrderResult">
SELECT DISTINCT
wms_ods_procure_out_order_special.Site_code,
wms_ods_procure_out_order_special.ID,
wms_ods_procure_out_order_special.Produce_Code,
wms_ods_procure_out_order_special.Material_Code,
wms_ods_procure_out_order_special.Material_Desc,
wms_ods_procure_out_order_special.Plan_Date,
wms_ods_procure_out_order_special.Plan_Number,
wms_ods_procure_out_order_special.Unit,
COALESCE ( wms_ods_procure_out_order_special.Out_Number, 0 ) - COALESCE ( wms_ods_procure_out_order_special.Sap_Number, 0 ) AS Out_Number,
wms_raw_mission_out.user_defined2 Loc_Code,
wms_ods_procure_out_order_special.Loc_Desc,
wms_ods_procure_out_order_special.Production_Line_Desc,
wms_ods_procure_out_order_special.Production_Line_Code,
wms_ods_procure_out_order_special.Order_Status,
wms_ods_procure_out_order_special.User_Defined1,
wms_ods_procure_out_order_special.User_Defined2,
wms_ods_procure_out_order_special.User_Defined3,
wms_ods_procure_out_order_special.User_Defined4,
wms_ods_procure_out_order_special.User_Defined5,
wms_ods_procure_out_order_special.User_Defined6,
wms_ods_procure_out_order_special.User_Defined7,
wms_ods_procure_out_order_special.User_Defined8,
wms_ods_procure_out_order_special.User_Defined9,
wms_ods_procure_out_order_special.User_Defined10,
wms_ods_procure_out_order_special.User_Defined11,
wms_ods_procure_out_order_special.Supplier_Code,
wms_ods_procure_out_order_special.Supplier_Name,
wms_ods_procure_out_order_special.Create_By,
wms_ods_procure_out_order_special.Create_Date,
wms_ods_procure_out_order_special.Last_Update_By,
wms_ods_procure_out_order_special.Last_Update_Date,
wms_ods_procure_out_order_special.Active,
wms_ods_procure_out_order_special.Enterprise_Id,
COALESCE ( wms_ods_procure_out_order_special.Sap_Number, 0 ) AS Sap_Number,
wms_ods_procure_out_order_special.Enterprise_Code
FROM
wms_ods_procure_out_order_special
LEFT JOIN wms_raw_mission_out ON wms_raw_mission_out.prd_order = wms_ods_procure_out_order_special.Produce_Code
AND wms_raw_mission_out.material_code = wms_ods_procure_out_order_special.Material_Code
WHERE wms_ods_procure_out_order_special.ID IN
<foreach item="odsProcureOutOrder" collection="list" open="(" separator="," close=")">
#{odsProcureOutOrder.ID}
</foreach>
AND (COALESCE ( wms_ods_procure_out_order_special.Out_Number, 0 ) - COALESCE ( wms_ods_procure_out_order_special.Sap_Number, 0 ))>0
</select>
<select id="selectWmsOdsProcureReturnOrderByID" resultMap="OdsProcureOutOrderResult">
SELECT DISTINCT
wms_ods_procure_return_order.Site_code,
wms_ods_procure_return_order.ID,
wms_ods_procure_return_order.Produce_Code,
wms_ods_procure_return_order.Material_Code,
wms_ods_procure_return_order.Material_Desc,
wms_ods_procure_return_order.Plan_Date,
wms_ods_procure_return_order.Plan_Number,
wms_ods_procure_return_order.Unit,
COALESCE ( wms_ods_procure_return_order.Return_Number, 0 ) AS Return_Number,
wms_raw_order_in_sn.wh_code Loc_Code,
wms_ods_procure_return_order.Loc_Desc,
wms_ods_procure_return_order.Production_Line_Desc,
wms_ods_procure_return_order.Production_Line_Code,
wms_ods_procure_return_order.Order_Status,
wms_ods_procure_return_order.User_Defined1,
wms_ods_procure_return_order.User_Defined2,
wms_ods_procure_return_order.User_Defined3,
wms_ods_procure_return_order.User_Defined4,
wms_ods_procure_return_order.User_Defined5,
wms_ods_procure_return_order.User_Defined6,
wms_ods_procure_return_order.User_Defined7,
wms_ods_procure_return_order.User_Defined8,
wms_ods_procure_return_order.User_Defined9,
wms_ods_procure_return_order.User_Defined10,
wms_ods_procure_return_order.User_Defined11,
wms_ods_procure_return_order.Supplier_Code,
wms_ods_procure_return_order.Supplier_Name,
wms_ods_procure_return_order.Create_By,
wms_ods_procure_return_order.Create_Date,
wms_ods_procure_return_order.Last_Update_By,
wms_ods_procure_return_order.Last_Update_Date,
wms_ods_procure_return_order.Active,
wms_ods_procure_return_order.Enterprise_Id,
wms_ods_procure_return_order.Enterprise_Code
FROM
wms_ods_procure_return_order
LEFT JOIN wms_raw_order_in_sn ON wms_raw_order_in_sn.user_defined5 = wms_ods_procure_return_order.Produce_Code
AND wms_raw_order_in_sn.material_code = wms_ods_procure_return_order.Material_Code
where wms_ods_procure_return_order.ID IN
<foreach item="odsProcureOutOrder" collection="list" open="(" separator="," close=")">
#{odsProcureOutOrder.ID}
</foreach>
and wms_ods_procure_return_order.User_Defined10!='2'
and Order_Status='3'
</select>
<select id="selectWmsOdsProcureOutOrder" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
COALESCE ( Sap_Number, 0 ) AS Sap_Number,
Enterprise_Code
FROM
wms_ods_procure_out_order
<where>
<if test="siteCode != null and siteCode != ''"> and Site_code = #{siteCode}</if>
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''"> and Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> and Plan_Date = #{planDate}</if>
<if test="planNumber != null "> and Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and Unit = #{Unit}</if>
<if test="outNumber != null "> and Out_Number = #{outNumber}</if>
<if test="locCode != null and locCode != ''"> and Loc_Code = #{locCode}</if>
<if test="locDesc != null and locDesc != ''"> and Loc_Desc = #{locDesc}</if>
<if test="productionLineDesc != null and productionLineDesc != ''"> and Production_Line_Desc = #{productionLineDesc}</if>
<if test="productionLineCode != null and productionLineCode != ''"> and Production_Line_Code = #{productionLineCode}</if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<!-- <if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3}</if>-->
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and User_Defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''"> and User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''"> and Supplier_Code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and Supplier_Name like concat('%', #{supplierName}, '%')</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createDate != null "> and Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
</where>
</select>
<insert id="insertWmsOdsProcureOutOrder" parameterType="OdsProcureOutOrder">
insert into wms_ods_procure_out_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="siteCode != null">Site_code,</if>
<if test="ID != null">ID,</if>
<if test="produceCode != null">Produce_Code,</if>
<if test="materialCode != null">Material_Code,</if>
<if test="materialDesc != null">Material_Desc,</if>
<if test="planDate != null">Plan_Date,</if>
<if test="planNumber != null">Plan_Number,</if>
<if test="Unit != null">Unit,</if>
<if test="outNumber != null">Out_Number,</if>
<if test="locCode != null">Loc_Code,</if>
<if test="locDesc != null">Loc_Desc,</if>
<if test="productionLineDesc != null">Production_Line_Desc,</if>
<if test="productionLineCode != null">Production_Line_Code,</if>
<if test="orderStatus != null">Order_Status,</if>
<if test="userDefined1 != null">User_Defined1,</if>
<if test="userDefined2 != null">User_Defined2,</if>
<if test="userDefined3 != null">User_Defined3,</if>
<if test="userDefined4 != null">User_Defined4,</if>
<if test="userDefined5 != null">User_Defined5,</if>
<if test="userDefined6 != null">User_Defined6,</if>
<if test="userDefined7 != null">User_Defined7,</if>
<if test="userDefined8 != null">User_Defined8,</if>
<if test="userDefined9 != null">User_Defined9,</if>
<if test="userDefined10 != null">User_Defined10,</if>
<if test="userDefined11 != null">User_Defined11,</if>
<if test="supplierCode != null">Supplier_Code,</if>
<if test="supplierName != null">Supplier_Name,</if>
<if test="createBy != null">Create_By,</if>
<if test="createDate != null">Create_Date,</if>
<if test="lastUpdateBy != null">Last_Update_By,</if>
<if test="lastUpdateDate != null">Last_Update_Date,</if>
<if test="Active != null">Active,</if>
<if test="enterpriseId != null">Enterprise_Id,</if>
<if test="enterpriseCode != null">Enterprise_Code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="siteCode != null">#{siteCode},</if>
<if test="ID != null">#{ID},</if>
<if test="produceCode != null">#{produceCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="planDate != null">#{planDate},</if>
<if test="planNumber != null">#{planNumber},</if>
<if test="Unit != null">#{Unit},</if>
<if test="outNumber != null">#{outNumber},</if>
<if test="locCode != null">#{locCode},</if>
<if test="locDesc != null">#{locDesc},</if>
<if test="productionLineDesc != null">#{productionLineDesc},</if>
<if test="productionLineCode != null">#{productionLineCode},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="userDefined1 != null">#{userDefined1},</if>
<if test="userDefined2 != null">#{userDefined2},</if>
<if test="userDefined3 != null">#{userDefined3},</if>
<if test="userDefined4 != null">#{userDefined4},</if>
<if test="userDefined5 != null">#{userDefined5},</if>
<if test="userDefined6 != null">#{userDefined6},</if>
<if test="userDefined7 != null">#{userDefined7},</if>
<if test="userDefined8 != null">#{userDefined8},</if>
<if test="userDefined9 != null">#{userDefined9},</if>
<if test="userDefined10 != null">#{userDefined10},</if>
<if test="userDefined11 != null">#{userDefined11},</if>
<if test="supplierCode != null">#{supplierCode},</if>
<if test="supplierName != null">#{supplierName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="lastUpdateBy != null">#{lastUpdateBy},</if>
<if test="lastUpdateDate != null">#{lastUpdateDate},</if>
<if test="Active != null">#{Active},</if>
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="enterpriseCode != null">#{enterpriseCode},</if>
</trim>
</insert>
<update id="updateWmsOdsProcureOutOrder" parameterType="OdsProcureOutOrder">
update wms_ods_procure_out_order
<trim prefix="SET" suffixOverrides=",">
<if test="siteCode != null">Site_code = #{siteCode},</if>
<if test="produceCode != null">Produce_Code = #{produceCode},</if>
<if test="materialCode != null">Material_Code = #{materialCode},</if>
<if test="materialDesc != null">Material_Desc = #{materialDesc},</if>
<if test="planDate != null">Plan_Date = #{planDate},</if>
<if test="planNumber != null">Plan_Number = #{planNumber},</if>
<if test="Unit != null">Unit = #{Unit},</if>
<if test="outNumber != null">Out_Number = #{outNumber},</if>
<if test="locCode != null">Loc_Code = #{locCode},</if>
<if test="locDesc != null">Loc_Desc = #{locDesc},</if>
<if test="productionLineDesc != null">Production_Line_Desc = #{productionLineDesc},</if>
<if test="productionLineCode != null">Production_Line_Code = #{productionLineCode},</if>
<if test="orderStatus != null">Order_Status = #{orderStatus},</if>
<if test="userDefined1 != null">User_Defined1 = #{userDefined1},</if>
<if test="userDefined2 != null">User_Defined2 = #{userDefined2},</if>
<if test="userDefined3 != null">User_Defined3 = #{userDefined3},</if>
<if test="userDefined4 != null">User_Defined4 = #{userDefined4},</if>
<if test="userDefined5 != null">User_Defined5 = #{userDefined5},</if>
<if test="userDefined6 != null">User_Defined6 = #{userDefined6},</if>
<if test="userDefined7 != null">User_Defined7 = #{userDefined7},</if>
<if test="userDefined8 != null">User_Defined8 = #{userDefined8},</if>
<if test="userDefined9 != null">User_Defined9 = #{userDefined9},</if>
<if test="userDefined10 != null">User_Defined10 = #{userDefined10},</if>
<if test="userDefined11 != null">User_Defined11 = #{userDefined11},</if>
<if test="supplierCode != null">Supplier_Code = #{supplierCode},</if>
<if test="supplierName != null">Supplier_Name = #{supplierName},</if>
<if test="createBy != null">Create_By = #{createBy},</if>
<if test="createDate != null">Create_Date = #{createDate},</if>
<if test="lastUpdateBy != null">Last_Update_By = #{lastUpdateBy},</if>
<if test="lastUpdateDate != null">Last_Update_Date = #{lastUpdateDate},</if>
<if test="Active != null">Active = #{Active},</if>
<if test="enterpriseId != null">Enterprise_Id = #{enterpriseId},</if>
<if test="enterpriseCode != null">Enterprise_Code = #{enterpriseCode},</if>
<if test="sapNumber != null">Sap_Number = #{sapNumber},</if>
</trim>
where ID = #{ID}
</update>
<update id="updateWmsOdsProcureReturnOrderByID" parameterType="OdsProcureOrder">
update wms_ods_procure_return_order
<trim prefix="SET" suffixOverrides=",">
<if test="returnNumber != null">Return_Number = #{returnNumber},</if>
<if test="orderStatus != null">Order_Status = #{orderStatus},</if>
</trim>
where ID = #{ID}
</update>
<select id="selectOdsProcureOutOrderListZC" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order
<where>
<if test="produceCode != null and produceCode != ''"> and Produce_Code like concat('%', #{produceCode}, '%')</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code like concat('%', #{materialCode}, '%')</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 like concat('%', #{userDefined4}, '%') </if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
</where>
ORDER BY Create_Date DESC
</select>
<select id="selectOdsProcureOutOrderListZCTW" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order
<where>
<if test="produceCode != null and produceCode != ''"> and Produce_Code like concat('%', #{produceCode}, '%')</if>
<if test="userDefined3 != null and userDefined3 != ''"> <![CDATA[ and User_Defined3 <> #{userDefined3} ]]> </if>
<if test="materialCode != null and materialCode != ''"> and Material_Code like concat('%', #{materialCode}, '%')</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 like concat('%', #{userDefined4}, '%') </if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
</where>
ORDER BY Create_Date DESC
</select>
<select id="selectWmsRawMissionOutByPrdAndMa" resultType="com.op.wms.domain.WmsOdsMateStorageNews">
SELECT
id storageId,
material_code materialCode,
origin_location waCode,
amount amount,
sn,
user_defined1 userDefined1,
user_defined2 userDefined2,
user_defined3 userDefined3
FROM
wms_raw_mission_out
WHERE
prd_order=#{produceCode} AND
material_code like concat('%', #{materialCode},'%') AND
user_defined5='1'
</select>
<select id="selectWmsRawMissionOutByPrdAndMaQC" resultType="java.lang.String">
SELECT
DISTINCT
user_defined1 userDefined1
FROM
wms_raw_mission_out
WHERE
prd_order=#{produceCode} AND
material_code=#{materialCode}
</select>
<select id="selectPreDetailHzList" resultMap="OdsProcureOutOrderResult">
SELECT
mpd.material_code Material_Code,
mpd.material_name Material_Desc,
SUM ( mpd.quantity ) Plan_Number,
mpd.unit Unit,
-- SUM ( CONVERT ( DECIMAL ( 10, 3 ), mpd.fund_quanlity ) ) fundQuanlity,
mpd.factory_code Site_code,
mpd.recoil User_Defined3
FROM
pro_order_workorder ow
LEFT JOIN mes_prepare mp ON ow.workorder_code = mp.workorder_code
LEFT JOIN mes_prepare_detail mpd ON mp.prepare_id = mpd.prepare_id
WHERE
ow.product_date = #{userDefined4}
AND mpd.recoil = 'X'
AND mp.del_flag = '0'
AND mpd.del_flag = '0'
AND mpd.material_name NOT LIKE '%白坯%'
AND mpd.material_name NOT LIKE '%药液%'
AND mpd.material_code NOT LIKE '0000000208%'
GROUP BY
mpd.material_code,
mpd.material_name,
mpd.unit,
mpd.factory_code,
mpd.recoil
ORDER BY
mpd.material_code
</select>
<select id="selectWmsOdsProcureOutOrderByOrderStatus" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order
where Order_Status='3' and Active='1'
and User_Defined10='1'
</select>
<select id="selectWmsOdsProcureReturnOrderStatus" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order
where Order_Status='3' and Active='1'
and User_Defined10='1' and Produce_Code=#{produceCode}
</select>
<select id="selectMesReportWorkConsume" resultType="java.lang.String">
SELECT
quantity
FROM
mes_report_work_consume
WHERE
workorder_code =#{userDefined4}
AND material_code = #{materialCode}
</select>
<select id="selectMesReportWorkConsumeFC" resultMap="OdsProcureOutOrderResult">
select
ISNULL(sum(mco.quantity), 0) AS Plan_Number
from pro_order_workorder ow
left join mes_prepare mp on ow.workorder_code = mp.workorder_code
left join mes_prepare_detail mpd on mp.prepare_id = mpd.prepare_id
left join mes_report_work_consume mco ON mpd.parent_work_order=mco.parent_order AND mpd.material_code=mco.material_code
where ow.product_date =#{userDefined4} AND mpd.material_code=#{materialCode}
and mpd.recoil = 'X' and mp.del_flag = '0' and mpd.del_flag = '0'
GROUP BY mpd.material_code,
mpd.unit,
mpd.factory_code,mpd.recoil
order by mpd.material_code
</select>
<select id="selectOdsProcureReturnOrderListZC" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Return_Number, 0 ) AS Return_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_return_order
<where>
<if test="siteCode != null and siteCode != ''"> and Site_code = #{siteCode}</if>
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''"> and Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> and Plan_Date = #{planDate}</if>
<if test="planNumber != null "> and Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and Unit = #{Unit}</if>
<if test="outNumber != null "> and Out_Number = #{outNumber}</if>
<if test="locCode != null and locCode != ''"> and Loc_Code = #{locCode}</if>
<if test="locDesc != null and locDesc != ''"> and Loc_Desc = #{locDesc}</if>
<if test="productionLineDesc != null and productionLineDesc != ''"> and Production_Line_Desc = #{productionLineDesc}</if>
<if test="productionLineCode != null and productionLineCode != ''"> and Production_Line_Code = #{productionLineCode}</if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and User_Defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''"> and User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''"> and Supplier_Code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and Supplier_Name like concat('%', #{supplierName}, '%')</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createDate != null "> and Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
<if test="ID != null and ID != ''"> and ID = #{ID}</if>
</where>
ORDER BY Produce_Code DESC
</select>
<select id="insertWmsOdsProcureReturnOrder" parameterType="OdsProcureOutOrder">
insert into wms_ods_procure_return_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="siteCode != null">Site_code,</if>
<if test="ID != null">ID,</if>
<if test="produceCode != null">Produce_Code,</if>
<if test="materialCode != null">Material_Code,</if>
<if test="materialDesc != null">Material_Desc,</if>
<if test="planDate != null">Plan_Date,</if>
<if test="planNumber != null">Plan_Number,</if>
<if test="Unit != null">Unit,</if>
<if test="returnNumber != null">Return_Number,</if>
<if test="locCode != null">Loc_Code,</if>
<if test="locDesc != null">Loc_Desc,</if>
<if test="productionLineDesc != null">Production_Line_Desc,</if>
<if test="productionLineCode != null">Production_Line_Code,</if>
<if test="orderStatus != null">Order_Status,</if>
<if test="userDefined1 != null">User_Defined1,</if>
<if test="userDefined2 != null">User_Defined2,</if>
<if test="userDefined3 != null">User_Defined3,</if>
<if test="userDefined4 != null">User_Defined4,</if>
<if test="userDefined5 != null">User_Defined5,</if>
<if test="userDefined6 != null">User_Defined6,</if>
<if test="userDefined7 != null">User_Defined7,</if>
<if test="userDefined8 != null">User_Defined8,</if>
<if test="userDefined9 != null">User_Defined9,</if>
<if test="userDefined10 != null">User_Defined10,</if>
<if test="userDefined11 != null">User_Defined11,</if>
<if test="supplierCode != null">Supplier_Code,</if>
<if test="supplierName != null">Supplier_Name,</if>
<if test="createBy != null">Create_By,</if>
<if test="createDate != null">Create_Date,</if>
<if test="lastUpdateBy != null">Last_Update_By,</if>
<if test="lastUpdateDate != null">Last_Update_Date,</if>
<if test="Active != null">Active,</if>
<if test="enterpriseId != null">Enterprise_Id,</if>
<if test="enterpriseCode != null">Enterprise_Code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="siteCode != null">#{siteCode},</if>
<if test="ID != null">#{ID},</if>
<if test="produceCode != null">#{produceCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="planDate != null">#{planDate},</if>
<if test="planNumber != null">#{planNumber},</if>
<if test="Unit != null">#{Unit},</if>
<if test="returnNumber != null">#{returnNumber},</if>
<if test="locCode != null">#{locCode},</if>
<if test="locDesc != null">#{locDesc},</if>
<if test="productionLineDesc != null">#{productionLineDesc},</if>
<if test="productionLineCode != null">#{productionLineCode},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="userDefined1 != null">#{userDefined1},</if>
<if test="userDefined2 != null">#{userDefined2},</if>
<if test="userDefined3 != null">#{userDefined3},</if>
<if test="userDefined4 != null">#{userDefined4},</if>
<if test="userDefined5 != null">#{userDefined5},</if>
<if test="userDefined6 != null">#{userDefined6},</if>
<if test="userDefined7 != null">#{userDefined7},</if>
<if test="userDefined8 != null">#{userDefined8},</if>
<if test="userDefined9 != null">#{userDefined9},</if>
<if test="userDefined10 != null">#{userDefined10},</if>
<if test="userDefined11 != null">#{userDefined11},</if>
<if test="supplierCode != null">#{supplierCode},</if>
<if test="supplierName != null">#{supplierName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="lastUpdateBy != null">#{lastUpdateBy},</if>
<if test="lastUpdateDate != null">#{lastUpdateDate},</if>
<if test="Active != null">#{Active},</if>
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="enterpriseCode != null">#{enterpriseCode},</if>
</trim>
</select>
<select id="CKlist" resultType="com.op.wms.domain.OdsProcureOutOrder">
SELECT
id ID,
factory_code factoryCode,
prd_order produceCode,
material_code materialCode,
material_desc materialDesc,
unit Unit,
origin_location locCode,
amount planNumber,
sn sn,
user_defined1 userDefined1,
user_defined2 userDefined2,
create_by createBy,
gmt_create createDate,
user_defined4 userDefined4,
user_defined3 userDefined3
FROM
wms_raw_mission_out
<where>
<if test="ID != null">and id= #{ID},</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="produceCode != null and produceCode != ''"> and prd_order like concat('%', #{produceCode}, '%')</if>
<if test="materialCode != null and materialCode != ''"> and material_code like concat('%', #{materialCode}, '%')</if>
<if test="materialDesc != null and materialDesc != ''"> and material_desc like concat('%',#{materialDesc}, '%')</if>
<if test="planNumber != null "> and amount = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and unit = #{Unit}</if>
<if test="locCode != null and locCode != ''"> and origin_location = #{locCode}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 like concat('%', #{userDefined1}, '%')</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 like concat('%', #{userDefined3}, '%')</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 like concat('%', #{userDefined4}, '%')</if>
<if test="sn != null and sn != ''"> and sn = #{sn}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="createDate != null "> and gmt_create = #{createDate}</if>
</where>
ORDER BY gmt_create DESC
</select>
<update id="updateWMSOdsProcureOutOrdersapById" >
update wms_ods_procure_out_order
set Sap_Number = #{sapNumber}
where ID = #{ID}
</update>
<update id="updateWMSOdsProcureOutOrdersapSpecialById" >
update wms_ods_procure_out_order_special
set Sap_Number = #{sapNumber},
User_Defined9 = #{userDefined9},
User_Defined10 = #{userDefined10},
User_Defined11 = #{userDefined11}
where ID = #{ID}
</update>
<update id="updateWMSOdsProcureOutOrdersapSpecialTWById" >
update wms_ods_procure_out_order_special
set User_Defined10 = #{userDefined10},
User_Defined11 = #{userDefined11}
where ID = #{ID}
</update>
<select id="listckTS" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order_special
<where>
<if test="siteCode != null and siteCode != ''"> and Site_code = #{siteCode}</if>
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''"> and Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> and Plan_Date = #{planDate}</if>
<if test="planNumber != null "> and Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and Unit = #{Unit}</if>
<if test="outNumber != null "> and Out_Number = #{outNumber}</if>
<if test="locCode != null and locCode != ''"> and Loc_Code = #{locCode}</if>
<if test="locDesc != null and locDesc != ''"> and Loc_Desc = #{locDesc}</if>
<if test="productionLineDesc != null and productionLineDesc != ''"> and Production_Line_Desc = #{productionLineDesc}</if>
<if test="productionLineCode != null and productionLineCode != ''"> and Production_Line_Code = #{productionLineCode}</if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and User_Defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''"> and User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''"> and Supplier_Code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and Supplier_Name like concat('%', #{supplierName}, '%')</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createDate != null "> and Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
</where>
</select>
<insert id="addOdsProcureOutOrderTS" parameterType="OdsProcureOutOrder">
insert into wms_ods_procure_out_order_special
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="siteCode != null">Site_code,</if>
<if test="ID != null">ID,</if>
<if test="produceCode != null">Produce_Code,</if>
<if test="materialCode != null">Material_Code,</if>
<if test="materialDesc != null">Material_Desc,</if>
<if test="planDate != null">Plan_Date,</if>
<if test="planNumber != null">Plan_Number,</if>
<if test="Unit != null">Unit,</if>
<if test="outNumber != null">Out_Number,</if>
<if test="locCode != null">Loc_Code,</if>
<if test="locDesc != null">Loc_Desc,</if>
<if test="productionLineDesc != null">Production_Line_Desc,</if>
<if test="productionLineCode != null">Production_Line_Code,</if>
<if test="orderStatus != null">Order_Status,</if>
<if test="userDefined1 != null">User_Defined1,</if>
<if test="userDefined2 != null">User_Defined2,</if>
<if test="userDefined3 != null">User_Defined3,</if>
<if test="userDefined4 != null">User_Defined4,</if>
<if test="userDefined5 != null">User_Defined5,</if>
<if test="userDefined6 != null">User_Defined6,</if>
<if test="userDefined7 != null">User_Defined7,</if>
<if test="userDefined8 != null">User_Defined8,</if>
<if test="userDefined9 != null">User_Defined9,</if>
<if test="userDefined10 != null">User_Defined10,</if>
<if test="userDefined11 != null">User_Defined11,</if>
<if test="supplierCode != null">Supplier_Code,</if>
<if test="supplierName != null">Supplier_Name,</if>
<if test="createBy != null">Create_By,</if>
<if test="createDate != null">Create_Date,</if>
<if test="lastUpdateBy != null">Last_Update_By,</if>
<if test="lastUpdateDate != null">Last_Update_Date,</if>
<if test="Active != null">Active,</if>
<if test="enterpriseId != null">Enterprise_Id,</if>
<if test="enterpriseCode != null">Enterprise_Code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="siteCode != null">#{siteCode},</if>
<if test="ID != null">#{ID},</if>
<if test="produceCode != null">#{produceCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="planDate != null">#{planDate},</if>
<if test="planNumber != null">#{planNumber},</if>
<if test="Unit != null">#{Unit},</if>
<if test="outNumber != null">#{outNumber},</if>
<if test="locCode != null">#{locCode},</if>
<if test="locDesc != null">#{locDesc},</if>
<if test="productionLineDesc != null">#{productionLineDesc},</if>
<if test="productionLineCode != null">#{productionLineCode},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="userDefined1 != null">#{userDefined1},</if>
<if test="userDefined2 != null">#{userDefined2},</if>
<if test="userDefined3 != null">#{userDefined3},</if>
<if test="userDefined4 != null">#{userDefined4},</if>
<if test="userDefined5 != null">#{userDefined5},</if>
<if test="userDefined6 != null">#{userDefined6},</if>
<if test="userDefined7 != null">#{userDefined7},</if>
<if test="userDefined8 != null">#{userDefined8},</if>
<if test="userDefined9 != null">#{userDefined9},</if>
<if test="userDefined10 != null">#{userDefined10},</if>
<if test="userDefined11 != null">#{userDefined11},</if>
<if test="supplierCode != null">#{supplierCode},</if>
<if test="supplierName != null">#{supplierName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="lastUpdateBy != null">#{lastUpdateBy},</if>
<if test="lastUpdateDate != null">#{lastUpdateDate},</if>
<if test="Active != null">#{Active},</if>
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="enterpriseCode != null">#{enterpriseCode},</if>
</trim>
</insert>
<select id="listOdsProcureOutOrderTS" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order_special
<where>
<if test="siteCode != null and siteCode != ''"> and Site_code = #{siteCode}</if>
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''"> and Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> and Plan_Date = #{planDate}</if>
<if test="planNumber != null "> and Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and Unit = #{Unit}</if>
<if test="outNumber != null "> and Out_Number = #{outNumber}</if>
<if test="locCode != null and locCode != ''"> and Loc_Code = #{locCode}</if>
<if test="locDesc != null and locDesc != ''"> and Loc_Desc = #{locDesc}</if>
<if test="productionLineDesc != null and productionLineDesc != ''"> and Production_Line_Desc = #{productionLineDesc}</if>
<if test="productionLineCode != null and productionLineCode != ''"> and Production_Line_Code = #{productionLineCode}</if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and User_Defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''"> and User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''"> and Supplier_Code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and Supplier_Name like concat('%', #{supplierName}, '%')</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createDate != null "> and Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
</where>
</select>
<select id="selectOdsProcureOutOrderTS" resultType="java.lang.String">
SELECT
COALESCE(
MAX(TRY_CAST(User_Defined1 AS BIGINT)) + 1, -- 使用 BIGINT 以避免溢出
CAST(CONCAT(#{formattedDate}, '0001') AS BIGINT) -- 同样使用 BIGINT
) AS Result_Value
FROM
wms_ods_procure_out_order_special
WHERE
User_Defined1 LIKE CONCAT('%', #{formattedDate}, '%');
</select>
<select id="selectwmsFpStorageNewsTS" resultType="java.lang.String">
SELECT
COALESCE(
MAX(TRY_CAST(lot_number AS BIGINT)) + 1, -- 使用 BIGINT 以避免溢出
CAST(CONCAT(#{formattedDate}, '0001') AS BIGINT) -- 同样使用 BIGINT
) AS Result_Value
FROM
wms_sell_out_embryo_special
WHERE
lot_number LIKE CONCAT('%', #{formattedDate}, '%');
</select>
<select id="selectWmsOdsProcureOutOrderSpecial" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
COALESCE ( Sap_Number, 0 ) AS Sap_Number,
Enterprise_Code
FROM
wms_ods_procure_out_order_special
<where>
<if test="siteCode != null and siteCode != ''"> and Site_code = #{siteCode}</if>
<if test="produceCode != null and produceCode != ''"> and Produce_Code = #{produceCode}</if>
<if test="materialCode != null and materialCode != ''"> and Material_Code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''"> and Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> and Plan_Date = #{planDate}</if>
<if test="planNumber != null "> and Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''"> and Unit = #{Unit}</if>
<if test="outNumber != null "> and Out_Number = #{outNumber}</if>
<if test="locCode != null and locCode != ''"> and Loc_Code = #{locCode}</if>
<if test="locDesc != null and locDesc != ''"> and Loc_Desc = #{locDesc}</if>
<if test="productionLineDesc != null and productionLineDesc != ''"> and Production_Line_Desc = #{productionLineDesc}</if>
<if test="productionLineCode != null and productionLineCode != ''"> and Production_Line_Code = #{productionLineCode}</if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and User_Defined2 = #{userDefined2}</if>
<!-- <if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3}</if>-->
<if test="userDefined4 != null and userDefined4 != ''"> and User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and User_Defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''"> and User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''"> and Supplier_Code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and Supplier_Name like concat('%', #{supplierName}, '%')</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createDate != null "> and Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''"> and Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
</where>
</select>
<select id="selectWmsOdsProcureOutOrderByOrderStatusSpecial" parameterType="OdsProcureOutOrder" resultMap="OdsProcureOutOrderResult">
SELECT
Site_code,
ID,
Produce_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Out_Number, 0 ) AS Out_Number,
Loc_Code,
Loc_Desc,
Production_Line_Desc,
Production_Line_Code,
Order_Status,
User_Defined1,
User_Defined2,
User_Defined3,
User_Defined4,
User_Defined5,
User_Defined6,
User_Defined7,
User_Defined8,
User_Defined9,
User_Defined10,
User_Defined11,
Supplier_Code,
Supplier_Name,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code
FROM
wms_ods_procure_out_order_special
where Order_Status='3' and Active='1'
and User_Defined10='1'
and ID=#{ID}
</select>
<update id="updateWmsOdsProcureOutOrderSpecial" parameterType="OdsProcureOutOrder">
update wms_ods_procure_out_order_special
<trim prefix="SET" suffixOverrides=",">
<if test="siteCode != null">Site_code = #{siteCode},</if>
<if test="produceCode != null">Produce_Code = #{produceCode},</if>
<if test="materialCode != null">Material_Code = #{materialCode},</if>
<if test="materialDesc != null">Material_Desc = #{materialDesc},</if>
<if test="planDate != null">Plan_Date = #{planDate},</if>
<if test="planNumber != null">Plan_Number = #{planNumber},</if>
<if test="Unit != null">Unit = #{Unit},</if>
<if test="outNumber != null">Out_Number = #{outNumber},</if>
<if test="locCode != null">Loc_Code = #{locCode},</if>
<if test="locDesc != null">Loc_Desc = #{locDesc},</if>
<if test="productionLineDesc != null">Production_Line_Desc = #{productionLineDesc},</if>
<if test="productionLineCode != null">Production_Line_Code = #{productionLineCode},</if>
<if test="orderStatus != null">Order_Status = #{orderStatus},</if>
<if test="userDefined1 != null">User_Defined1 = #{userDefined1},</if>
<if test="userDefined2 != null">User_Defined2 = #{userDefined2},</if>
<if test="userDefined3 != null">User_Defined3 = #{userDefined3},</if>
<if test="userDefined4 != null">User_Defined4 = #{userDefined4},</if>
<if test="userDefined5 != null">User_Defined5 = #{userDefined5},</if>
<if test="userDefined6 != null">User_Defined6 = #{userDefined6},</if>
<if test="userDefined7 != null">User_Defined7 = #{userDefined7},</if>
<if test="userDefined8 != null">User_Defined8 = #{userDefined8},</if>
<if test="userDefined9 != null">User_Defined9 = #{userDefined9},</if>
<if test="userDefined10 != null">User_Defined10 = #{userDefined10},</if>
<if test="userDefined11 != null">User_Defined11 = #{userDefined11},</if>
<if test="supplierCode != null">Supplier_Code = #{supplierCode},</if>
<if test="supplierName != null">Supplier_Name = #{supplierName},</if>
<if test="createBy != null">Create_By = #{createBy},</if>
<if test="createDate != null">Create_Date = #{createDate},</if>
<if test="lastUpdateBy != null">Last_Update_By = #{lastUpdateBy},</if>
<if test="lastUpdateDate != null">Last_Update_Date = #{lastUpdateDate},</if>
<if test="Active != null">Active = #{Active},</if>
<if test="enterpriseId != null">Enterprise_Id = #{enterpriseId},</if>
<if test="enterpriseCode != null">Enterprise_Code = #{enterpriseCode},</if>
<if test="sapNumber != null">Sap_Number = #{sapNumber},</if>
</trim>
where ID = #{ID}
</update>
<select id="selectWmsOdsProcureOutOrderSpecialByIDs" resultMap="OdsProcureOutOrderResult">
SELECT DISTINCT
wms_ods_procure_out_order_special.Site_code,
wms_ods_procure_out_order_special.ID,
wms_ods_procure_out_order_special.Produce_Code,
wms_ods_procure_out_order_special.Material_Code,
wms_ods_procure_out_order_special.Material_Desc,
wms_ods_procure_out_order_special.Plan_Date,
wms_ods_procure_out_order_special.Plan_Number,
-- wms_ods_procure_out_order_special.Unit,
COALESCE ( wms_ods_procure_out_order_special.Out_Number, 0 ) - COALESCE ( wms_ods_procure_out_order_special.Sap_Number, 0 ) AS Out_Number ,
wms_raw_mission_out.user_defined2 Loc_Code,
wms_raw_mission_out.unit Unit,
wms_ods_procure_out_order_special.Loc_Desc,
wms_ods_procure_out_order_special.Production_Line_Desc,
wms_ods_procure_out_order_special.Production_Line_Code,
wms_ods_procure_out_order_special.Order_Status,
wms_ods_procure_out_order_special.User_Defined1,
wms_ods_procure_out_order_special.User_Defined2,
wms_ods_procure_out_order_special.User_Defined3,
wms_ods_procure_out_order_special.User_Defined4,
wms_ods_procure_out_order_special.User_Defined5,
wms_ods_procure_out_order_special.User_Defined6,
wms_ods_procure_out_order_special.User_Defined7,
wms_ods_procure_out_order_special.User_Defined8,
wms_ods_procure_out_order_special.User_Defined9,
wms_ods_procure_out_order_special.User_Defined10,
wms_ods_procure_out_order_special.User_Defined11,
wms_ods_procure_out_order_special.Supplier_Code,
wms_ods_procure_out_order_special.Supplier_Name,
wms_ods_procure_out_order_special.Create_By,
wms_ods_procure_out_order_special.Create_Date,
wms_ods_procure_out_order_special.Last_Update_By,
wms_ods_procure_out_order_special.Last_Update_Date,
wms_ods_procure_out_order_special.Active,
wms_ods_procure_out_order_special.Enterprise_Id,
COALESCE ( wms_ods_procure_out_order_special.Sap_Number, 0 ) AS Sap_Number,
wms_ods_procure_out_order_special.Enterprise_Code
FROM
wms_ods_procure_out_order_special
LEFT JOIN wms_raw_mission_out ON wms_raw_mission_out.prd_order = wms_ods_procure_out_order_special.Produce_Code
AND wms_raw_mission_out.material_code = wms_ods_procure_out_order_special.Material_Code
where wms_ods_procure_out_order_special.ID IN
<foreach item="odsProcureOutOrder" collection="list" open="(" separator="," close=")">
#{odsProcureOutOrder.ID}
</foreach>
AND (COALESCE ( wms_ods_procure_out_order_special.Out_Number, 0 ) - COALESCE ( wms_ods_procure_out_order_special.Sap_Number, 0 ))>0
</select>
<update id="updateWmsRawMissionOutById" parameterType="com.op.wms.domain.WmsOdsMateStorageNews">
update wms_raw_mission_out
set user_defined5 = '2'
where id=#{storageId}
</update>
<select id="selectWmsOdsProcureReturnOrderByproduceCode" resultMap="OdsProcureOutOrderResult">
SELECT DISTINCT
wms_ods_procure_return_order.Site_code,
wms_ods_procure_return_order.ID,
wms_ods_procure_return_order.Produce_Code,
wms_ods_procure_return_order.Material_Code,
wms_ods_procure_return_order.Material_Desc,
wms_ods_procure_return_order.Plan_Date,
wms_ods_procure_return_order.Plan_Number,
wms_ods_procure_return_order.Unit,
COALESCE ( wms_ods_procure_return_order.Return_Number, 0 ) AS Return_Number,
wms_raw_mission_out.user_defined2 Loc_Code,
wms_ods_procure_return_order.Loc_Desc,
wms_ods_procure_return_order.Production_Line_Desc,
wms_ods_procure_return_order.Production_Line_Code,
wms_ods_procure_return_order.Order_Status,
wms_ods_procure_return_order.User_Defined1,
wms_ods_procure_return_order.User_Defined2,
wms_ods_procure_return_order.User_Defined3,
wms_ods_procure_return_order.User_Defined4,
wms_ods_procure_return_order.User_Defined5,
wms_ods_procure_return_order.User_Defined6,
wms_ods_procure_return_order.User_Defined7,
wms_ods_procure_return_order.User_Defined8,
wms_ods_procure_return_order.User_Defined9,
wms_ods_procure_return_order.User_Defined10,
wms_ods_procure_return_order.User_Defined11,
wms_ods_procure_return_order.Supplier_Code,
wms_ods_procure_return_order.Supplier_Name,
wms_ods_procure_return_order.Create_By,
wms_ods_procure_return_order.Create_Date,
wms_ods_procure_return_order.Last_Update_By,
wms_ods_procure_return_order.Last_Update_Date,
wms_ods_procure_return_order.Active,
wms_ods_procure_return_order.Enterprise_Id,
wms_ods_procure_return_order.Enterprise_Code
FROM
wms_ods_procure_return_order
LEFT JOIN wms_raw_mission_out ON wms_raw_mission_out.prd_order = wms_ods_procure_return_order.Produce_Code
AND wms_raw_mission_out.material_code = wms_ods_procure_return_order.Material_Code
where wms_ods_procure_return_order.Produce_Code=#{order.produceCode}
and wms_ods_procure_return_order.User_Defined10!='2'
</select>
<select id="getWmsOdsProcureOutOrder" resultType="java.lang.String">
SELECT DISTINCT
User_Defined5
FROM
wms_ods_procure_out_order
WHERE
Produce_Code = #{userDefined4}
</select>
<delete id="removeReturn" parameterType="String">
delete from wms_ods_procure_return_order where ID in
<foreach item="ID" collection="array" open="(" separator="," close=")">
#{ID}
</foreach>
</delete>
</mapper>