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.

1002 lines
53 KiB
XML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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.OdsProcureOrderMapper">
<resultMap type="OdsProcureOrder" id="OdsProcureOrderResult">
<result property="siteCode" column="Site_code"/>
<result property="ID" column="ID"/>
<result property="procureCode" column="Procure_Code"/>
<result property="materialCode" column="Material_Code"/>
<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="realityNumber" column="Reality_Number"/>
<result property="cardNum" column="cardNum"/>
<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="Remark" column="Remark"/>
<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="operationNumber" column="Operation_Number"/>
<result property="sn" column="sn"/>
<result property="palletNum" column="pallet_num"/>
<result property="returnNumber" column="returnNumber"/>
<result property="whCode" column="whCode"/>
<result property="waCode" column="waCode"/>
<result property="factoryCode" column="factoryCode"/>
<result property="SapTempInfor" column="Sap_Temp_Infor"/>
<result property="temNumber" column="tem_number"/>
</resultMap>
<sql id="selectOdsProcureOrderVo">
SELECT
opo.Site_code,
opo.ID,
opo.Procure_Code,
opo.Material_Code,
opo.Material_Desc,
opo.Plan_Date,
opo.Plan_Number,
opo.Unit,
COALESCE ( opo.Reality_Number, 0 ) Reality_Number,
opo.Order_Status,
opo.User_Defined1,
opo.User_Defined2,
opo.User_Defined3,
opo.User_Defined4,
opo.User_Defined5,
opo.User_Defined6,
opo.User_Defined7,
opo.User_Defined8,
opo.User_Defined9,
opo.User_Defined10,
opo.User_Defined11,
opo.Supplier_Code,
opo.Supplier_Name,
opo.Remark,
opo.Create_By,
opo.Create_Date,
opo.Last_Update_By,
opo.Last_Update_Date,
opo.Active,
opo.Enterprise_Id,
opo.Enterprise_Code,
COALESCE ( opo.Operation_Number, 0 ) Operation_Number,
bpa.wa_code waCode
FROM
ods_procure_order opo
LEFT JOIN base_product_attached bpa on RIGHT ( opo.Material_Code, 11 ) = bpa.product_code
</sql>
<select id="selectOdsProcureOrderList" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
<include refid="selectOdsProcureOrderVo"/>
<where>
<if test="siteCode != null and siteCode != ''">and Site_code = #{siteCode}</if>
<if test="ID != null and ID != ''">and ID = #{ID}</if>
<if test="procureCode != null and procureCode != ''">and Procure_Code = #{procureCode}</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="realityNumber != null ">and Reality_Number = #{realityNumber}</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="Remark != null and Remark != ''">and Remark = #{Remark}</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="palletNum != null and palletNum != ''">and pallet_num = #{palletNum}</if>
</where>
order by Create_Date desc
</select>
<select id="selectOdsProcureOrderListT" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
<include refid="selectOdsProcureOrderVo"/>
<where>
<if test="siteCode != null and siteCode != ''">and Site_code = #{siteCode}</if>
<if test="ID != null and ID != ''">and ID = #{ID}</if>
<if test="procureCode != null and procureCode != ''">and Procure_Code = #{procureCode}</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="realityNumber != null ">and Reality_Number = #{realityNumber}</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="Remark != null and Remark != ''">and Remark = #{Remark}</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="palletNum != null and palletNum != ''">and pallet_num = #{palletNum}</if>
<if test="operationNumber != null and operationNumber != ''">and Operation_Number is not null </if>
</where>
order by Create_Date desc
</select>
<select id="selectOdsProcureOrderByID" parameterType="String" resultMap="OdsProcureOrderResult">
<include refid="selectOdsProcureOrderVo"/>
where ID = #{ID}
</select>
<select id="selectWMSOdsProcureReturnOrderByID" parameterType="String" resultMap="OdsProcureOrderResult">
SELECT DISTINCT
wms_ods_procure_return_order.Site_code,
wms_ods_procure_return_order.ID,
wms_ods_procure_return_order.Produce_Code Procure_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,
COALESCE ( wms_ods_procure_return_order.Return_Number , 0 ) returnNumber,
wms_ods_procure_return_order.Unit,
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_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,
ods_procure_order.Supplier_Code,
wms_ods_procure_return_order.Enterprise_Code
FROM
wms_ods_procure_return_order
LEFT JOIN ods_procure_order ON wms_ods_procure_return_order.User_Defined5= ods_procure_order.User_Defined7
where wms_ods_procure_return_order.ID = #{ID}
</select>
<select id="selectOdsProcureOrderByIDAndSap" parameterType="String" resultMap="OdsProcureOrderResult">
<include refid="selectOdsProcureOrderVo"/>
where ID = #{ID}
and ( Sap_Temp_Status!='1' OR Sap_Temp_Status is NULL)
</select>
<insert id="insertOdsProcureOrder" parameterType="OdsProcureOrder">
insert into ods_procure_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="siteCode != null">Site_code,</if>
<if test="ID != null">ID,</if>
<if test="procureCode != null">Procure_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="realityNumber != null">Reality_Number,</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="Remark != null">Remark,</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="procureCode != null">#{procureCode},</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="realityNumber != null">#{realityNumber},</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="Remark != null">#{Remark},</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="updateOdsProcureOrder" parameterType="OdsProcureOrder">
update ods_procure_order
<trim prefix="SET" suffixOverrides=",">
<if test="siteCode != null">Site_code = #{siteCode},</if>
<if test="procureCode != null">Procure_Code = #{procureCode},</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="realityNumber != null">Reality_Number = #{realityNumber},</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="Remark != null">Remark = #{Remark},</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="SapTempInfor != null">Sap_Temp_Infor = #{SapTempInfor},</if>
<if test="SapTempStatus != null">Sap_Temp_Status = #{SapTempStatus},</if>
<if test="SAPstatus != null">SAP_status = #{SAPstatus},</if>
<if test="SAPmessage != null">SAP_message = #{SAPmessage},</if>
<if test="enterpriseId != null">Enterprise_Id = #{enterpriseId},</if>
<if test="enterpriseCode != null">Enterprise_Code = #{enterpriseCode},</if>
</trim>
where ID = #{ID}
</update>
<delete id="deleteOdsProcureOrderByID" parameterType="String">
delete from ods_procure_order where ID = #{ID}
</delete>
<delete id="deleteOdsProcureOrderByIDs" parameterType="String">
delete from ods_procure_order where ID in
<foreach item="ID" collection="array" open="(" separator="," close=")">
#{ID}
</foreach>
</delete>
<update id="updateRealityNuById" parameterType="OdsProcureOrder">
update ods_procure_order
SET Reality_Number = COALESCE(Reality_Number, 0) + #{planNumber},
Order_Status=#{orderStatus}
where ID = #{ID}
</update>
<select id="selectBaseSupplier" resultType="java.lang.String">
SELECT DISTINCT zh_desc FROM base_supplier WHERE supplier_code= #{supplierCode}
</select>
<select id="selectOdsProcureOrderAlreadyList" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
<include refid="selectOdsProcureOrderVo"/>
<![CDATA[ where Procure_Code = #{procureCode} and Active='1' AND Order_Status <> 0 ]]>
</select>
<update id="updateOdsProcureOrderAddOperationNumber" parameterType="OdsProcureOrder">
update ods_procure_order
SET Operation_Number = COALESCE(Operation_Number, 0) + #{czNumber},
Last_Update_By = #{lastUpdateBy},
Last_Update_Date = getdate()
where ID = #{ID}
</update>
<select id="selectOdsProcureOrderAlreadyReaderList" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
<include refid="selectOdsProcureOrderVo"/>
where Active='1'
AND Last_Update_Date IS NOT NULL
<if test="procureCode != null"> AND Procure_Code = #{procureCode}</if>
<if test="lastUpdateDateMIN != null ">AND CONVERT(date, Last_Update_Date, 23) >= #{lastUpdateDateMIN}</if>
<if test="lastUpdateDateMAX != null "> <![CDATA[ AND CONVERT(date, Last_Update_Date, 23) <= #{lastUpdateDateMAX} ]]></if>
<if test="materialCode != null and materialCode != ''">and Material_Code = #{materialCode}</if>
<if test="userDefined5 != null and userDefined5 != ''">and Material_Code = #{userDefined5}</if>
</select>
<select id="updateOdsProcureOrderByProcureCode" parameterType="OdsProcureOrder">
update ods_procure_order
SET User_Defined5 = #{userDefined5}
where Procure_Code= #{procureCode}
and Site_code= #{siteCode}
and Material_Code= #{materialCode}
and Material_Desc= #{materialDesc}
and Active= #{Active}
</select>
<select id="getIdCardList" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
SELECT
Site_code,
ID,
Procure_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Reality_Number, 0 ) Reality_Number,
card_num cardNum,
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,
Remark,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code,
COALESCE ( Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order_card
where Procure_Code=#{procureCode} and User_Defined3= #{userDefined3} and User_Defined8= #{userDefined8} and User_Defined11= #{userDefined11} and User_Defined7= #{userDefined7}
and User_Defined4=#{ID}
ORDER BY CAST(card_num AS INT)
</select>
<select id="getIdCardListTH" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
SELECT
Site_code,
ID,
Procure_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Reality_Number, 0 ) Reality_Number,
card_num cardNum,
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,
Remark,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code,
COALESCE ( Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order_card
where User_Defined4=#{ID}
ORDER BY card_num
</select>
<!-- 定义一个插入操作ID为addBatchPallet参数类型为List<OdsProcureOrder> -->
<insert id="addBatchPallet" parameterType="java.util.List">
<!-- 使用<foreach>标签遍历传入的集合item为集合中每个元素index为当前索引 -->
<foreach collection="list" item="dto" separator=";">
<!-- 插入数据到ods_procure_order_card表 -->
insert into ods_procure_order_card
<!-- 使用<trim>标签来处理列名,这样可以自动去掉最后一个逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 如果siteCode不为null则添加列名Site_code -->
<if test="dto.siteCode != null">Site_code,</if>
<!-- 如果ID不为null则添加列名ID -->
<if test="dto.ID != null">ID,</if>
<!-- 如果cardNum不为null则添加列名card_num -->
<if test="dto.cardNum != null">card_num,</if>
<!-- 如果procureCode不为null则添加列名Procure_Code -->
<if test="dto.procureCode != null">Procure_Code,</if>
<!-- 如果materialCode不为null则添加列名Material_Code -->
<if test="dto.materialCode != null">Material_Code,</if>
<!-- 如果materialDesc不为null则添加列名Material_Desc -->
<if test="dto.materialDesc != null">Material_Desc,</if>
<!-- 如果planDate不为null则添加列名Plan_Date -->
<if test="dto.planDate != null">Plan_Date,</if>
<!-- 如果planNumber不为null则添加列名Plan_Number -->
<if test="dto.planNumber != null">Plan_Number,</if>
<!-- 如果Unit不为null则添加列名Unit -->
<if test="dto.Unit != null">Unit,</if>
<!-- 如果realityNumber不为null则添加列名Reality_Number -->
<if test="dto.realityNumber != null">Reality_Number,</if>
<!-- 如果orderStatus不为null则添加列名Order_Status -->
<if test="dto.orderStatus != null">Order_Status,</if>
<!-- 如果userDefined1不为null则添加列名User_Defined1 -->
<if test="dto.userDefined1 != null">User_Defined1,</if>
<!-- 如果userDefined2不为null则添加列名User_Defined2 -->
<if test="dto.userDefined2 != null">User_Defined2,</if>
<!-- 如果userDefined3不为null则添加列名User_Defined3 -->
<if test="dto.userDefined3 != null">User_Defined3,</if>
<!-- 如果userDefined4不为null则添加列名User_Defined4 -->
<if test="dto.userDefined4 != null">User_Defined4,</if>
<!-- 如果userDefined5不为null则添加列名User_Defined5 -->
<if test="dto.userDefined5 != null">User_Defined5,</if>
<!-- 如果userDefined6不为null则添加列名User_Defined6 -->
<if test="dto.userDefined6 != null">User_Defined6,</if>
<!-- 如果userDefined7不为null则添加列名User_Defined7 -->
<if test="dto.userDefined7 != null">User_Defined7,</if>
<!-- 如果userDefined8不为null则添加列名User_Defined8 -->
<if test="dto.userDefined8 != null">User_Defined8,</if>
<!-- 如果userDefined9不为null则添加列名User_Defined9 -->
<if test="dto.userDefined9 != null">User_Defined9,</if>
<!-- 如果userDefined10不为null则添加列名User_Defined10 -->
<if test="dto.userDefined10 != null">User_Defined10,</if>
<!-- 如果userDefined11不为null则添加列名User_Defined11 -->
<if test="dto.userDefined11 != null">User_Defined11,</if>
<!-- 如果supplierCode不为null则添加列名Supplier_Code -->
<if test="dto.supplierCode != null">Supplier_Code,</if>
<!-- 如果supplierName不为null则添加列名Supplier_Name -->
<if test="dto.supplierName != null">Supplier_Name,</if>
<!-- 如果Remark不为null则添加列名Remark -->
<if test="dto.Remark != null">Remark,</if>
<!-- 如果createBy不为null则添加列名Create_By -->
<if test="dto.createBy != null">Create_By,</if>
<!-- 如果createDate不为null则添加列名Create_Date -->
<if test="dto.createDate != null">Create_Date,</if>
<!-- 如果lastUpdateBy不为null则添加列名Last_Update_By -->
<if test="dto.lastUpdateBy != null">Last_Update_By,</if>
<!-- 如果lastUpdateDate不为null则添加列名Last_Update_Date -->
<if test="dto.lastUpdateDate != null">Last_Update_Date,</if>
<!-- 如果Active不为null则添加列名Active -->
<if test="dto.Active != null">Active,</if>
<!-- 如果enterpriseId不为null则添加列名Enterprise_Id -->
<if test="dto.enterpriseId != null">Enterprise_Id,</if>
<!-- 如果enterpriseCode不为null则添加列名Enterprise_Code -->
<if test="dto.enterpriseCode != null">Enterprise_Code,</if>
<if test="dto.temNumber != null">tem_number,</if>
</trim>
<!-- 使用<trim>标签来处理值,这样可以自动去掉最后一个逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<!-- 如果siteCode不为null则添加对应的值 -->
<if test="dto.siteCode != null">#{dto.siteCode},</if>
<!-- 如果ID不为null则添加对应的值 -->
<if test="dto.ID != null">#{dto.ID},</if>
<!-- 如果cardNum不为null则添加对应的值 -->
<if test="dto.cardNum != null">#{dto.cardNum},</if>
<!-- 如果procureCode不为null则添加对应的值 -->
<if test="dto.procureCode != null">#{dto.procureCode},</if>
<!-- 如果materialCode不为null则添加对应的值 -->
<if test="dto.materialCode != null">#{dto.materialCode},</if>
<!-- 如果materialDesc不为null则添加对应的值 -->
<if test="dto.materialDesc != null">#{dto.materialDesc},</if>
<!-- 如果planDate不为null则添加对应的值 -->
<if test="dto.planDate != null">#{dto.planDate},</if>
<!-- 如果planNumber不为null则添加对应的值 -->
<if test="dto.planNumber != null">#{dto.planNumber},</if>
<!-- 如果Unit不为null则添加对应的值 -->
<if test="dto.Unit != null">#{dto.Unit},</if>
<!-- 如果realityNumber不为null则添加对应的值 -->
<if test="dto.realityNumber != null">#{dto.realityNumber},</if>
<!-- 如果orderStatus不为null则添加对应的值 -->
<if test="dto.orderStatus != null">#{dto.orderStatus},</if>
<!-- 如果userDefined1不为null则添加对应的值 -->
<if test="dto.userDefined1 != null">#{dto.userDefined1},</if>
<!-- 如果userDefined2不为null则添加对应的值 -->
<if test="dto.userDefined2 != null">#{dto.userDefined2},</if>
<!-- 如果userDefined3不为null则添加对应的值 -->
<if test="dto.userDefined3 != null">#{dto.userDefined3},</if>
<!-- 如果userDefined4不为null则添加对应的值 -->
<if test="dto.userDefined4 != null">#{dto.userDefined4},</if>
<!-- 如果userDefined5不为null则添加对应的值 -->
<if test="dto.userDefined5 != null">#{dto.userDefined5},</if>
<!-- 如果userDefined6不为null则添加对应的值 -->
<if test="dto.userDefined6 != null">#{dto.userDefined6},</if>
<!-- 如果userDefined7不为null则添加对应的值 -->
<if test="dto.userDefined7 != null">#{dto.userDefined7},</if>
<!-- 如果userDefined8不为null则添加对应的值 -->
<if test="dto.userDefined8 != null">#{dto.userDefined8},</if>
<!-- 如果userDefined9不为null则添加对应的值 -->
<if test="dto.userDefined9 != null">#{dto.userDefined9},</if>
<!-- 如果userDefined10不为null则添加对应的值 -->
<if test="dto.userDefined10 != null">#{dto.userDefined10},</if>
<!-- 如果userDefined11不为null则添加对应的值 -->
<if test="dto.userDefined11 != null">#{dto.userDefined11},</if>
<!-- 如果supplierCode不为null则添加对应的值 -->
<if test="dto.supplierCode != null">#{dto.supplierCode},</if>
<!-- 如果supplierName不为null则添加对应的值 -->
<if test="dto.supplierName != null">#{dto.supplierName},</if>
<!-- 如果Remark不为null则添加对应的值 -->
<if test="dto.Remark != null">#{dto.Remark},</if>
<!-- 如果createBy不为null则添加对应的值 -->
<if test="dto.createBy != null">#{dto.createBy},</if>
<!-- 如果createDate不为null则添加对应的值 -->
<if test="dto.createDate != null">#{dto.createDate},</if>
<!-- 如果lastUpdateBy不为null则添加对应的值 -->
<if test="dto.lastUpdateBy != null">#{dto.lastUpdateBy},</if>
<!-- 如果lastUpdateDate不为null则添加对应的值 -->
<if test="dto.lastUpdateDate != null">#{dto.lastUpdateDate},</if>
<!-- 如果Active不为null则添加对应的值 -->
<if test="dto.Active != null">#{dto.Active},</if>
<!-- 如果enterpriseId不为null则添加对应的值 -->
<if test="dto.enterpriseId != null">#{dto.enterpriseId},</if>
<!-- 如果enterpriseCode不为null则添加对应的值 -->
<if test="dto.enterpriseCode != null">#{dto.enterpriseCode},</if>
<if test="dto.temNumber != null">#{dto.temNumber},</if>
</trim>
</foreach>
</insert>
<select id="selectOdsProcureOrderCard" resultMap="OdsProcureOrderResult">
SELECT
card.Site_code,
card.Procure_Code ,
card.Material_Code ,
card.Material_Desc ,
card.User_Defined3 ,
COALESCE ( card.Reality_Number, 0 ) Reality_Number,
card.User_Defined4 ,
card.User_Defined1 sn,
card.Plan_Number ,
card.User_Defined10,
card.User_Defined9,
card.User_Defined1,
order_TME.User_Defined5
FROM
ods_procure_order_card card
LEFT JOIN ods_procure_order order_TME ON order_TME.ID= card.User_Defined4
WHERE
card.User_Defined1= #{userDefined1}
</select>
<select id="selectOdsProcureOrderCardTL" resultMap="OdsProcureOrderResult">
SELECT
card.Site_code,
card.Procure_Code ,
card.Material_Code ,
card.Material_Desc ,
card.User_Defined3 ,
card.User_Defined4 ,
card.User_Defined1 sn,
card.Plan_Number ,
card.User_Defined10,
card.User_Defined7,
card.User_Defined1
FROM
ods_procure_order_card card
WHERE
card.User_Defined1= #{userDefined1}
</select>
<select id="selectOdsProcureOrderList1" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
SELECT
o.Site_code,
o.ID,
o.Procure_Code,
o.Material_Code,
o.Material_Desc,
o.Plan_Date,
o.Plan_Number,
o.Unit,
COALESCE ( Reality_Number, 0 ) Reality_Number,
o.Order_Status,
o.User_Defined1,
o.User_Defined2,
o.User_Defined3,
o.User_Defined4,
o.User_Defined5,
o.User_Defined6,
o.User_Defined7,
o.User_Defined8,
o.User_Defined9,
o.User_Defined10,
o.User_Defined11,
o.Supplier_Code,
o.Supplier_Name,
o.Remark,
o.Create_By,
o.Create_Date,
o.Last_Update_By,
o.Last_Update_Date,
o.Active,
o.Enterprise_Id,
o.Sap_Temp_Infor,
o.Enterprise_Code,
base_product_attached.pallet_num, COALESCE ( Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order as o LEFT JOIN base_product_attached
on o.Material_Code = '0000000'+base_product_attached.product_code
<where>
<if test="siteCode != null and siteCode != ''">and o.Site_code = #{siteCode}</if>
<if test="ID != null and ID != ''">and o.ID = #{ID}</if>
<if test="procureCode != null and procureCode != ''">and o.Procure_Code = #{procureCode}</if>
<if test="materialCode != null and materialCode != ''">and o.Material_Code like concat('%', #{materialCode},
'%') </if>
<if test="materialDesc != null and materialDesc != ''">and o.Material_Desc = #{materialDesc}</if>
<if test="planDate != null "> AND CAST(o.Plan_Date AS DATE) = #{planDate}</if>
<if test="planNumber != null ">and o.Plan_Number = #{planNumber}</if>
<if test="Unit != null and Unit != ''">and o.Unit = #{Unit}</if>
<if test="realityNumber != null ">and o.Reality_Number = #{realityNumber}</if>
<if test="orderStatus != null and orderStatus != ''">and o.Order_Status = #{orderStatus}</if>
<if test="userDefined1 != null and userDefined1 != ''">and o.User_Defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''">and o.User_Defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''">and o.User_Defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''">and o.User_Defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''">and o.User_Defined5 like concat('%', #{userDefined5},
'%') </if>
<if test="userDefined6 != null and userDefined6 != ''">and o.User_Defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''">and o.User_Defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''">and o.User_Defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''">and o.User_Defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''">and o.User_Defined10 = #{userDefined10}</if>
<if test="userDefined11 != null and userDefined11 != ''">and o.User_Defined11 = #{userDefined11}</if>
<if test="supplierCode != null and supplierCode != ''">and o.Supplier_Code like concat('%', #{supplierCode}, '%')</if>
<if test="supplierName != null and supplierName != ''">and o.Supplier_Name like concat('%', #{supplierName},
'%')
</if>
<if test="Remark != null and Remark != ''">and o.Remark = #{Remark}</if>
<if test="createBy != null and createBy != ''">and o.Create_By = #{createBy}</if>
<if test="createDate != null ">and o.Create_Date = #{createDate}</if>
<if test="lastUpdateBy != null and lastUpdateBy != ''">and o.Last_Update_By = #{lastUpdateBy}</if>
<if test="lastUpdateDate != null ">and o.Last_Update_Date = #{lastUpdateDate}</if>
<if test="Active != null and Active != ''">and o.Active = #{Active}</if>
<if test="enterpriseId != null and enterpriseId != ''">and o.Enterprise_Id = #{enterpriseId}</if>
<if test="enterpriseCode != null and enterpriseCode != ''">and o.Enterprise_Code = #{enterpriseCode}</if>
<if test="palletNum != null and palletNum != ''">and pallet_num = #{palletNum}</if>
</where>
order by Create_Date desc
</select>
<update id="updateodsProcureOrderCard">
update ods_procure_order_card
SET User_Defined10 = '1'
where User_Defined1 = #{userDefined6}
</update>
<update id="updateodsProcureOrderCardByu1">
update ods_procure_order_card
SET User_Defined10 = #{orderStatus},
Reality_Number=#{realityNumber},
tem_number = #{temNumber}
where User_Defined1 = #{userDefined1}
</update>
<update id="updateodsProcureOrderCardTemNumber">
update ods_procure_order_card
SET tem_number = #{temNumber}
where User_Defined1 = #{userDefined1}
</update>
<select id="selectOdsProcureOrderCardByUserDefined1" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
SELECT
ods_procure_order.Site_code,
ods_procure_order.ID,
ods_procure_order.Procure_Code,
ods_procure_order.Material_Code,
ods_procure_order.Material_Desc,
ods_procure_order.Plan_Date,
ods_procure_order.Plan_Number,
ods_procure_order.Unit,
COALESCE ( ods_procure_order.Reality_Number, 0 ) Reality_Number,
ods_procure_order.Order_Status,
ods_procure_order.User_Defined1,
ods_procure_order.User_Defined2,
ods_procure_order.User_Defined3,
ods_procure_order.User_Defined4,
ods_procure_order.User_Defined5,
ods_procure_order.User_Defined6,
ods_procure_order.User_Defined7,
ods_procure_order.User_Defined8,
ods_procure_order.User_Defined9,
ods_procure_order.User_Defined10,
ods_procure_order.User_Defined11,
ods_procure_order.Supplier_Code,
ods_procure_order.Supplier_Name,
ods_procure_order.Remark,
ods_procure_order.Create_By,
ods_procure_order.Create_Date,
ods_procure_order.Last_Update_By,
ods_procure_order.Last_Update_Date,
ods_procure_order.Active,
ods_procure_order.Enterprise_Id,
ods_procure_order.Enterprise_Code,
COALESCE ( ods_procure_order.Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order_card
LEFT JOIN ods_procure_order ON ods_procure_order_card.User_Defined4= ods_procure_order.ID
WHERE
ods_procure_order_card.User_Defined1= #{userDefined6}
</select>
<select id="getIdCardByIdList" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
SELECT
Site_code,
ID,
Procure_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Reality_Number, 0 ) Reality_Number,
card_num cardNum,
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,
Remark,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code,
COALESCE ( Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order_card
where User_Defined4=#{storageId} and User_Defined8='2'
</select>
<delete id="deleteBatchPallet" >
delete from ods_procure_order_card where ID in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.ID}
</foreach>
</delete>
<delete id="deleteBatchPalletBycard" >
delete from ods_procure_order_card where User_Defined1=#{wlCode}
</delete>
<select id="getIdCardListByU1" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
SELECT
Site_code,
ID,
Procure_Code,
Material_Code,
Material_Desc,
Plan_Date,
Plan_Number,
Unit,
COALESCE ( Reality_Number, 0 ) Reality_Number,
card_num cardNum,
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,
Remark,
Create_By,
Create_Date,
Last_Update_By,
Last_Update_Date,
Active,
Enterprise_Id,
Enterprise_Code,
COALESCE ( Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order_card
where User_Defined1= #{userDefined1}
ORDER BY CAST(card_num AS INT)
</select>
<select id="selectOdsProcureOrderUserDefined7New" resultType="java.lang.String" >
SELECT
COALESCE(MAX(User_Defined7) + 1, #{formattedTEM} + '001') AS Next_Value
FROM
ods_procure_order
WHERE
LEFT(User_Defined7, 6) = #{formattedTEM}
</select>
<select id="selectOdsProcureOrderListSH" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
<include refid="selectOdsProcureOrderVo"/>
where User_Defined5= #{userDefined5}
AND (Plan_Number-COALESCE ( Operation_Number, 0 ))>0
order by Create_Date desc
</select>
<update id="updateOdsProcureOrderBy" >
update ods_procure_order
SET Order_Status = '1',
Reality_Number = COALESCE(Reality_Number, 0) - #{requestAmount}
where ID = #{kem}
</update>
<select id="selectCardList" resultMap="OdsProcureOrderResult">
SELECT
ods_procure_order_card.Site_code,
ods_procure_order_card.ID,
ods_procure_order_card.Procure_Code,
ods_procure_order_card.Material_Code,
ods_procure_order_card.Material_Desc,
ods_procure_order_card.Plan_Date,
ods_procure_order_card.Plan_Number,
ods_procure_order_card.Unit,
COALESCE ( ods_procure_order_card.Reality_Number, 0 ) Reality_Number,
ods_procure_order_card.card_num cardNum,
ods_procure_order_card.User_Defined1,
ods_procure_order_card.User_Defined2,
ods_procure_order_card.User_Defined3,
ods_procure_order_card.User_Defined4,
ods_procure_order_card.User_Defined5 whCode,
ods_procure_order_card.User_Defined6 waCode,
ods_procure_order_card.User_Defined7,
ods_procure_order_card.User_Defined8,
ods_procure_order_card.User_Defined9,
ods_procure_order_card.User_Defined10,
ods_procure_order_card.User_Defined11,
ods_procure_order_card.Supplier_Code,
ods_procure_order_card.Supplier_Name,
ods_procure_order_card.Remark,
ods_procure_order_card.Create_By,
ods_procure_order_card.Create_Date,
ods_procure_order_card.Last_Update_By,
ods_procure_order_card.Last_Update_Date,
ods_procure_order_card.Active,
ods_procure_order_card.Enterprise_Id,
ods_procure_order_card.Enterprise_Code,
ods_procure_order_card.tem_number,
ods_procure_order.user_defined5 User_Defined5,
COALESCE ( ods_procure_order_card.Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order_card
LEFT JOIN ods_procure_order ON ods_procure_order.ID = TRY_CAST(ods_procure_order_card.User_Defined4 AS INT)
WHERE ods_procure_order.user_defined5=#{userDefined5}
AND ods_procure_order.Operation_Number IS NOT NULL
</select>
<select id="selectCardListSH" resultMap="OdsProcureOrderResult">
SELECT
ods_procure_order_card.Site_code factoryCode,
ods_procure_order_card.Procure_Code,
ods_procure_order_card.Material_Code,
ods_procure_order_card.Material_Desc,
ods_procure_order_card.tem_number Plan_Number,
ods_procure_order_card.User_Defined1 User_Defined6,
ods_procure_order_card.User_Defined1 sn,
ods_procure_order_card.User_Defined5 whCode,
ods_procure_order_card.User_Defined6 waCode,
ods_procure_order.user_defined5 User_Defined5
FROM
ods_procure_order_card
LEFT JOIN ods_procure_order ON ods_procure_order.ID = TRY_CAST(ods_procure_order_card.User_Defined4 AS INT)
WHERE ods_procure_order.user_defined5=#{userDefined5}
AND (ods_procure_order_card.User_Defined10= '0'
OR ods_procure_order_card.User_Defined10= '2')
</select>
<select id="selectOdsProcureOrderCardByUserDefined1new" parameterType="OdsProcureOrder" resultMap="OdsProcureOrderResult">
SELECT
ods_procure_order.Site_code,
ods_procure_order.ID,
ods_procure_order.Procure_Code,
ods_procure_order.Material_Code,
ods_procure_order.Material_Desc,
ods_procure_order.Plan_Date,
ods_procure_order.Plan_Number,
ods_procure_order.Unit,
COALESCE ( ods_procure_order.Reality_Number, 0 ) Reality_Number,
ods_procure_order.Order_Status,
ods_procure_order.User_Defined1,
ods_procure_order.User_Defined2,
ods_procure_order.User_Defined3,
ods_procure_order.User_Defined4,
ods_procure_order.User_Defined5,
ods_procure_order.User_Defined6,
ods_procure_order.User_Defined7,
ods_procure_order.User_Defined8,
ods_procure_order.User_Defined9,
ods_procure_order.User_Defined10,
ods_procure_order.User_Defined11,
ods_procure_order.Supplier_Code,
ods_procure_order.Supplier_Name,
ods_procure_order.Remark,
ods_procure_order.Create_By,
ods_procure_order.Create_Date,
ods_procure_order.Last_Update_By,
ods_procure_order.Last_Update_Date,
ods_procure_order.Active,
ods_procure_order.Enterprise_Id,
ods_procure_order.Enterprise_Code,
COALESCE ( ods_procure_order.Operation_Number, 0 ) Operation_Number
FROM
ods_procure_order_card
LEFT JOIN ods_procure_order ON ods_procure_order_card.User_Defined4= ods_procure_order.ID
WHERE
ods_procure_order_card.User_Defined1= #{userDefined1}
</select>
<select id="selectBaseProductAttached" resultType="java.lang.String">
SELECT DISTINCT
wa_code
FROM
base_product_attached
WHERE
CONCAT('0000000', product_code) = #{order1MaterialCode}
AND wa_code IS NOT NULL;
</select>
</mapper>