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.

315 lines
17 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.aucma.base.mapper.BaseOrderInfoMapper">
<resultMap type="BaseOrderInfo" id="BaseOrderInfoResult">
<result property="objId" column="obj_id"/>
<result property="orderCode" column="order_code"/>
<result property="saleOrderCode" column="saleorder_code"/>
<result property="saleOrderLineNumber" column="saleorder_linenumber"/>
<result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name"/>
<result property="matkl" column="matkl"/>
<result property="orderAmount" column="order_amount"/>
<result property="completeAmount" column="complete_amount"/>
<result property="orderType" column="order_type"/>
<result property="orderStatus" column="order_status"/>
<result property="beginDate" column="begin_date"/>
<result property="endDate" column="end_date"/>
<result property="factoryCode" column="factory_code"/>
<result property="isFlag" column="is_flag"/>
<result property="createdBy" column="created_by"/>
<result property="createdTime" column="created_time"/>
<result property="updatedBy" column="updated_by"/>
<result property="updatedTime" column="updated_time"/>
<result property="completeDate" column="complete_date"/>
<result property="isRelease" column="is_release"/>
<result property="workCenterCode" column="work_center_code"/>
<result property="routingCode" column="routing_code"/>
<result property="manualUpdateFlag" column="manual_update_flag"/>
<result property="executionStatus" column="execution_status"/>
<result property="startTime" column="start_time"/>
<result property="finishTime" column="end_time"/>
<result property="executionOperator" column="execution_operator"/>
<result property="actualCompleteQty" column="actual_complete_qty"/>
<result property="actualDefectQty" column="actual_defect_qty"/>
</resultMap>
<sql id="selectBaseOrderInfoVo">
select oi.obj_id,
oi.order_code,
oi.saleorder_code,
oi.saleorder_linenumber,
oi.material_code,
oi.material_name,
oi.matkl,
oi.order_amount,
oi.complete_amount,
oi.order_type,
oi.order_status,
oi.begin_date,
oi.end_date,
oi.factory_code,
oi.is_flag,
oi.is_release,
oi.work_center_code,
oi.routing_code,
oi.manual_update_flag,
oi.execution_status,
oi.start_time,
oi.end_time,
oi.execution_operator,
oi.actual_complete_qty,
oi.actual_defect_qty,
oi.created_by,
oi.created_time,
oi.updated_by,
oi.updated_time,
oi.complete_date
from base_orderinfo oi
</sql>
<select id="selectBaseOrderInfoList" parameterType="BaseOrderInfo" resultMap="BaseOrderInfoResult">
<include refid="selectBaseOrderInfoVo"/>
LEFT JOIN BASE_MATERIALINFO bm
ON bm.MATERIAL_CODE = oi.material_code
AND bm.DISPO IN ('100')
<where>
<if test="orderCode != null and orderCode != ''">and oi.order_code = #{orderCode}</if>
<if test="saleOrderCode != null and saleOrderCode != ''">and oi.saleorder_code = #{saleOrderCode}</if>
<if test="saleOrderLineNumber != null and saleOrderLineNumber != ''">and oi.saleorder_linenumber =
#{saleOrderLineNumber}
</if>
<if test="materialCode != null and materialCode != ''">and oi.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and oi.material_name like concat(concat('%',
#{materialName}), '%')
</if>
<if test="matkl != null and matkl != ''">and oi.matkl = #{matkl}</if>
<if test="orderAmount != null ">and oi.order_amount = #{orderAmount}</if>
<if test="completeAmount != null ">and oi.complete_amount = #{completeAmount}</if>
<if test="orderType != null and orderType != ''">and oi.order_type = #{orderType}</if>
<if test="orderStatus != null and orderStatus != '' and orderStatus != 'RELCRTD'">and oi.order_status LIKE #{orderStatus} || '%'</if>
<if test="orderStatus != null and orderStatus != '' and orderStatus == 'RELCRTD'">and (oi.order_status LIKE 'REL%' OR oi.order_status LIKE 'CRTD%')</if>
<if test="manualUpdateFlag != null and manualUpdateFlag != ''">and oi.manual_update_flag = #{manualUpdateFlag}</if>
<if test="executionStatus != null and executionStatus != ''">and nvl(oi.execution_status, 'PENDING') = #{executionStatus}</if>
<if test="beginDate != null ">and oi.begin_date = #{beginDate}</if>
<if test="endDate != null ">and oi.end_date = #{endDate}</if>
<if test="beginTime != null and endTime != null">
and oi.begin_date between to_date(#{beginTime}, 'yyyy-mm-dd') and to_date(#{endTime}, 'yyyy-mm-dd')
</if>
<if test="factoryCode != null and factoryCode != ''">and oi.factory_code = #{factoryCode}</if>
<if test="isFlag != null ">and is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''">and oi.created_by = #{createdBy}</if>
<if test="createdTime != null ">and oi.created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and oi.updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and oi.updated_time = #{updatedTime}</if>
<if test="completeDate != null ">and oi.complete_date = #{completeDate}</if>
<if test="isRelease != null ">and oi.is_release = #{isRelease}</if>
<if test="workCenterCode != null ">and oi.work_center_code = #{workCenterCode}</if>
<if test="params != null and params.beginTime != null and params.endTime != null">
and oi.begin_date between to_date(#{params.beginTime}, 'yyyy-mm-dd') and to_date(#{params.endTime}, 'yyyy-mm-dd')
</if>
<if test="params.beginEndTime != null and params.beginEndTime != '' and params.endEndTime != null and params.endEndTime != ''">
and oi.begin_date between to_date(#{params.beginEndTime}, 'yyyy-mm-dd') and
to_date(#{params.endEndTime}, 'yyyy-mm-dd')
</if>
</where>
order by oi.material_name, order_code desc
</select>
<select id="selectBaseOrderInfoByObjId" parameterType="Long" resultMap="BaseOrderInfoResult">
<include refid="selectBaseOrderInfoVo"/>
where obj_id = #{objId}
</select>
<select id="selectAllOrderInfoList" parameterType="BaseOrderInfo" resultMap="BaseOrderInfoResult">
<include refid="selectBaseOrderInfoVo"/>
<where>
<if test="orderCode != null and orderCode != ''">and oi.order_code = #{orderCode}</if>
<if test="materialCode != null and materialCode != ''">and oi.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and oi.material_name like concat(concat('%',
#{materialName}), '%')
</if>
<if test="workCenterCode != null ">and oi.work_center_code = #{workCenterCode}</if>
</where>
order by oi.material_name, order_code desc
</select>
<select id="selectPdaOrderListByMaterialCodes" resultMap="BaseOrderInfoResult">
<include refid="selectBaseOrderInfoVo"/>
<where>
<!-- PDA只维护有效工单避免停用/脏数据进入下拉框 -->
AND NVL(oi.is_flag, 0) = 0
<if test="materialCodes != null and materialCodes.size() > 0">
<!-- 这里按物料编码精确匹配,模糊搜索已在物料主数据层完成 -->
AND oi.material_code IN
<foreach collection="materialCodes" item="materialCode" open="(" separator="," close=")">
#{materialCode}
</foreach>
</if>
</where>
<!-- 先按物料名称再按工单倒序便于PDA下拉框更快定位最近工单 -->
order by oi.material_name, oi.order_code desc
</select>
<insert id="insertBaseOrderInfo" parameterType="BaseOrderInfo">
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_base_orderinfo.NEXTVAL as objId FROM DUAL
</selectKey>
insert into base_orderinfo
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="objId != null">obj_id,</if>
<if test="orderCode != null">order_code,</if>
<if test="saleOrderCode != null">saleorder_code,</if>
<if test="saleOrderLineNumber != null">saleorder_linenumber,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="matkl != null">matkl,</if>
<if test="orderAmount != null">order_amount,</if>
<if test="completeAmount != null">complete_amount,</if>
<if test="orderType != null">order_type,</if>
<if test="orderStatus != null">order_status,</if>
<if test="beginDate != null">begin_date,</if>
<if test="endDate != null">end_date,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="isFlag != null">is_flag,</if>
<if test="isRelease != null">is_release,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="completeDate != null">complete_date,</if>
<if test="workCenterCode != null">work_center_code,</if>
<if test="routingCode != null">routing_code,</if>
<if test="manualUpdateFlag != null">manual_update_flag,</if>
<if test="executionStatus != null">execution_status,</if>
<if test="startTime != null">start_time,</if>
<if test="finishTime != null">end_time,</if>
<if test="executionOperator != null">execution_operator,</if>
<if test="actualCompleteQty != null">actual_complete_qty,</if>
<if test="actualDefectQty != null">actual_defect_qty,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if>
<if test="orderCode != null">#{orderCode},</if>
<if test="saleOrderCode != null">#{saleOrderCode},</if>
<if test="saleOrderLineNumber != null">#{saleOrderLineNumber},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName,jdbcType=NVARCHAR},</if>
<if test="matkl != null">#{matkl},</if>
<if test="orderAmount != null">#{orderAmount},</if>
<if test="completeAmount != null">#{completeAmount},</if>
<if test="orderType != null">#{orderType},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="beginDate != null">#{beginDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="isRelease != null">#{isRelease},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="completeDate != null">#{completeDate},</if>
<if test="workCenterCode != null">#{workCenterCode},</if>
<if test="routingCode != null">#{routingCode},</if>
<if test="manualUpdateFlag != null">#{manualUpdateFlag},</if>
<if test="executionStatus != null">#{executionStatus},</if>
<if test="startTime != null">#{startTime},</if>
<if test="finishTime != null">#{finishTime},</if>
<if test="executionOperator != null">#{executionOperator},</if>
<if test="actualCompleteQty != null">#{actualCompleteQty},</if>
<if test="actualDefectQty != null">#{actualDefectQty},</if>
</trim>
</insert>
<update id="updateBaseOrderInfo" parameterType="BaseOrderInfo">
update base_orderinfo
<trim prefix="SET" suffixOverrides=",">
<if test="orderCode != null">order_code = #{orderCode},</if>
<if test="saleOrderCode != null">saleorder_code = #{saleOrderCode},</if>
<if test="saleOrderLineNumber != null">saleorder_linenumber = #{saleOrderLineNumber},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName,jdbcType=NVARCHAR},</if>
<if test="matkl != null">matkl = #{matkl},</if>
<if test="orderAmount != null">order_amount = #{orderAmount},</if>
<if test="completeAmount != null">complete_amount = #{completeAmount},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="beginDate != null">begin_date = #{beginDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="isRelease != null">is_release = #{isRelease},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="completeDate != null">complete_date = #{completeDate},</if>
<if test="workCenterCode != null">work_center_code = #{workCenterCode},</if>
<if test="routingCode != null">routing_code = #{routingCode},</if>
<if test="manualUpdateFlag != null">manual_update_flag = #{manualUpdateFlag},</if>
<if test="executionStatus != null">execution_status = #{executionStatus},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="finishTime != null">end_time = #{finishTime},</if>
<if test="executionOperator != null">execution_operator = #{executionOperator},</if>
<if test="actualCompleteQty != null">actual_complete_qty = #{actualCompleteQty},</if>
<if test="actualDefectQty != null">actual_defect_qty = #{actualDefectQty},</if>
</trim>
where obj_id = #{objId}
</update>
<delete id="deleteBaseOrderInfoByObjId" parameterType="Long">
delete
from base_orderinfo
where obj_id = #{objId}
</delete>
<delete id="deleteBaseOrderInfoByObjIds" parameterType="String">
delete from base_orderinfo where obj_id in
<foreach item="objId" collection="array" open="(" separator="," close=")">
#{objId}
</foreach>
</delete>
<update id="batchStartProduction">
update base_orderinfo
set execution_status = 'RUNNING',
start_time = #{startTime},
execution_operator = #{operator},
updated_time = #{startTime}
where obj_id in
<foreach collection="objIds" item="objId" open="(" separator="," close=")">
#{objId}
</foreach>
and (execution_status is null or execution_status = 'PENDING')
</update>
<update id="batchUpdateQuantity">
update base_orderinfo
set actual_complete_qty = #{completeQty},
actual_defect_qty = #{defectQty},
updated_time = #{updateTime}
where obj_id in
<foreach collection="objIds" item="objId" open="(" separator="," close=")">
#{objId}
</foreach>
</update>
<update id="batchCompleteProduction">
update base_orderinfo
set execution_status = 'COMPLETED',
actual_complete_qty = #{completeQty},
actual_defect_qty = #{defectQty},
finish_time = #{finishTime},
updated_time = #{finishTime}
where obj_id in
<foreach collection="objIds" item="objId" open="(" separator="," close=")">
#{objId}
</foreach>
and execution_status = 'RUNNING'
</update>
</mapper>