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.

407 lines
19 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.plan.mapper.ProOrderMapper">
<resultMap type="ProOrder" id="ProOrderResult">
<result property="id" column="id"/>
<result property="planFactoryCode" column="plan_factory_code"/>
<result property="factoryCode" column="factory_code"/>
<result property="orderType" column="order_type"/>
<result property="orderCode" column="order_code"/>
<result property="prodCode" column="prod_code"/>
<result property="prodDesc" column="prod_desc"/>
<result property="quantity" column="quantity"/>
<result property="quantitySplit" column="quantity_split"/>
<result property="unit" column="unit"/>
<result property="workerOrder" column="worker_order"/>
<result property="planProDate" column="plan_pro_date"/>
<result property="planComplete" column="plan_complete"/>
<result property="atrr1" column="atrr1"/>
<result property="atrr2" column="atrr2"/>
<result property="atrr3" column="atrr3"/>
<result property="status" column="status"/>
<result property="parentOrder" column="parent_order"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="prodType" column="prod_type"/>
<result property="prodSpc" column="prod_spc"/>
<result property="carNum" column="car_num"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<sql id="selectProOrderVo">
select id, plan_factory_code, order_type, order_code, prod_code, prod_desc, quantity, quantity_split,
unit, worker_order, plan_pro_date, plan_complete, atrr1, atrr2, atrr3,
status, parent_order, create_by, create_time, update_by, update_time, prod_type,
factory_code, prod_spc ,car_num,del_flag
from pro_order
</sql>
<select id="selectProOrderList" parameterType="ProOrder" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
<where>
<if test="planFactoryCode != null and planFactoryCode != ''">and plan_factory_code = #{planFactoryCode}
</if>
<if test="factoryCode != null and factoryCode != ''">and factory_code = #{factoryCode}</if>
<if test="orderType != null and orderType != ''">and order_type = #{orderType}</if>
<if test="orderCode != null and orderCode != ''">and order_code like concat('%', #{orderCode}, '%')</if>
<if test="prodCode != null and prodCode != ''">and prod_code like concat('%', #{prodCode}, '%')</if>
<if test="prodDesc != null and prodDesc != ''">and prod_desc like concat('%', #{prodDesc}, '%')</if>
<if test="quantity != null ">and quantity = #{quantity}</if>
<if test="unit != null and unit != ''">and unit = #{unit}</if>
<if test="workerOrder != null and workerOrder != ''">and worker_order like concat('%', #{workerOrder},
'%')
</if>
<if test="planProDate != null ">and plan_pro_date = #{planProDate}</if>
<if test="planComplete != null ">and plan_complete = #{planComplete}</if>
<if test="atrr1 != null and atrr1 != ''">and atrr1 = #{atrr1}</if>
<if test="atrr2 != null and atrr2 != ''">and atrr2 = #{atrr2}</if>
<if test="atrr3 != null and atrr3 != ''">and atrr3 = #{atrr3}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="parentOrder != null and parentOrder != ''">and parent_order = #{parentOrder}</if>
<if test="prodType != null and prodType != ''">and prod_type = #{prodType}</if>
<if test="prodSpc != null and prodSpc != ''">and prod_spc = #{prodSpc}</if>
<if test="planDateStart != null ">and CONVERT(varchar(10),plan_pro_date, 120) >= '${planDateStart}'</if>
<if test="planDateEnd != null ">and '${planDateEnd}%' >= CONVERT(varchar(10),plan_pro_date, 120)</if>
and prod_type != 'white'
<if test="delFlag != null and delFlag != ''">and del_flag = #{delFlag}</if>
</where>
ORDER BY plan_pro_date DESC
</select>
<select id="selectProOrderById" parameterType="String" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
where id = #{id}
</select>
<select id="selectConvert" resultType="com.op.plan.domain.Convert">
SELECT dict_code dictCode , dict_label dictLabel , dict_value dictValue ,
dict_sort dictSort FROM sys_dict_data
WHERE dict_type = 'convert_type'
</select>
<select id="selectChildProOrderByCode" parameterType="String" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
where parent_order = #{orderCode} and del_flag = '0'
</select>
<select id="selectParentProOrderByCode" parameterType="String" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
where order_code = #{parentOrder} and del_flag = '0'
</select>
<select id="selectProShift" resultType="com.op.plan.domain.ProShift">
SELECT bst.Shift_Id shiftId,bst.Shift_Desc shiftDesc
FROM base_shifts_t bst
</select>
<select id="selectProdLineName" resultType="java.lang.String">
SELECT equipment_name AS 'prodLineName'
FROM base_equipment
WHERE equipment_code = #{prodLineCode}
</select>
<select id="selectBatchCodes" resultType="java.lang.String">
SELECT batch_code
FROM pro_order_workorder_batch
WHERE status = '1'
and del_flag = '0'
GROUP BY batch_code
</select>
<select id="selectBatchNameByCode" resultType="java.lang.String">
SELECT sf.factory_name
FROM sys_factory sf
WHERE sf.f_code = #{prodLineCode}
</select>
<select id="selectBatchCodesById" resultType="com.op.plan.domain.ProOrderWorkorderBatch">
SELECT powb.batch_code batchCode,
powb.batch_quantity batchQuantity
FROM pro_order_workorder_batch powb
LEFT JOIN pro_order_workorder pow
ON powb.workorder_id = pow.workorder_id
WHERE pow.workorder_id = #{workorderId} and powb.del_flag = '0'
order by powb.batch_code
</select>
<select id="selectPackageLine" resultType="com.op.plan.domain.ProLine">
SELECT equipment_id AS 'key', equipment_name AS 'label'
FROM base_equipment
WHERE equipment_type_code = 'equ_type_bzx'
</select>
<select id="selectShiftNameById" resultType="java.lang.String">
SELECT bst.Shift_Desc_Global shiftDesc
FROM base_shifts_t bst
WHERE bst.Shift_Id = #{shiftId}
</select>
<select id="getMaxCreatetime" resultType="com.op.system.api.model.SapProOrder">
select CONVERT(varchar(112),max(create_time), 112) createTimeStr
from pro_order
where order_type != 'white'
and del_flag = '0'
</select>
<select id="selectProOrderByOrderCode" parameterType="String" resultMap="ProOrderResult">
<include refid="selectProOrderVo"/>
where order_code = #{orderCode} and del_flag = '0'
</select>
<select id="selectChildProOrderCodeByCode" resultType="java.lang.String">
select order_code from pro_order
where parent_order = #{orderCode}
and del_flag = '0'
</select>
<select id="selectEquipmentListByRouteCode" resultType="java.lang.String">
select pps.equipment
from pro_route_process pp
INNER JOIN pro_process pps on pp.process_code = pps.process_code
INNER JOIN pro_route pr on pr.route_id = pp.route_id
where pr.route_code = #{routeCode} and pp.order_num = '1'
</select>
<select id="selectEquipment" resultType="com.op.plan.domain.ProLine" parameterType="String">
SELECT equipment_code AS 'key', equipment_name AS 'label'
FROM base_equipment
where equipment_code in
<foreach item="code" collection="array" open="(" separator="," close=")">
#{code}
</foreach>
</select>
<select id="getRouteProcess" resultType="com.op.plan.domain.vo.CascaderDTO">
select process_code value,
process_name label
from pro_route_process where route_id in(
select route_id from pro_route where route_code = #{routeCode}
)
order by order_num
</select>
<select id="getRouteProcessEquips" resultType="com.op.plan.domain.vo.CascaderDTO">
select equipment value,process_code label from pro_process where process_code in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.value}
</foreach>
</select>
<select id="getEquipInfoByCodes" resultType="com.op.plan.domain.vo.CascaderDTO">
select equipment_code value,equipment_name label from base_equipment where equipment_code in
('${equipCodes}')
</select>
<select id="getMaxPlanDate" resultType="com.op.plan.domain.ProOrder">
select max(plan_pro_date) planProDate
from pro_order where prod_type != 'white' and del_flag = '0'
</select>
<select id="selectOrderIdByParentOrder" resultType="java.lang.String">
select id from pro_order where parent_order = ( select order_code from pro_order where id = #{id} ) and del_flag = '0'
</select>
<insert id="insertProOrder" parameterType="ProOrder">
insert into pro_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="planFactoryCode != null">plan_factory_code,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="orderType != null">order_type,</if>
<if test="orderCode != null">order_code,</if>
<if test="prodCode != null">prod_code,</if>
<if test="prodDesc != null">prod_desc,</if>
<if test="quantity != null">quantity,</if>
<if test="quantitySplit != null">quantity_split,</if>
<if test="unit != null">unit,</if>
<if test="workerOrder != null">worker_order,</if>
<if test="planProDate != null">plan_pro_date,</if>
<if test="planComplete != null">plan_complete,</if>
<if test="atrr1 != null">atrr1,</if>
<if test="atrr2 != null">atrr2,</if>
<if test="atrr3 != null">atrr3,</if>
<if test="status != null">status,</if>
<if test="parentOrder != null">parent_order,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="prodType != null">prod_type,</if>
<if test="prodSpc != null">prod_spc,</if>
<if test="carNum != null">car_num,</if>
<if test="syncUser != null">sync_user,</if>
from_sap_time,
cegci,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="planFactoryCode != null">#{planFactoryCode},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="orderType != null">#{orderType},</if>
<if test="orderCode != null">#{orderCode},</if>
<if test="prodCode != null">#{prodCode},</if>
<if test="prodDesc != null">#{prodDesc},</if>
<if test="quantity != null">#{quantity},</if>
<if test="quantitySplit != null">#{quantitySplit},</if>
<if test="unit != null">#{unit},</if>
<if test="workerOrder != null">#{workerOrder},</if>
<if test="planProDate != null">#{planProDate},</if>
<if test="planComplete != null">#{planComplete},</if>
<if test="atrr1 != null">#{atrr1},</if>
<if test="atrr2 != null">#{atrr2},</if>
<if test="atrr3 != null">#{atrr3},</if>
<if test="status != null">#{status},</if>
<if test="parentOrder != null">#{parentOrder},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="prodType != null">#{prodType},</if>
<if test="prodSpc != null">#{prodSpc},</if>
<if test="carNum != null">#{carNum},</if>
<if test="syncUser != null">#{syncUser},</if>
GETDATE(),
#{cegci},
</trim>
</insert>
<insert id="addSapLog">
insert into sys_sap_log
(id,messsge,create_time,reqcode,method,remark,status)
values(
#{id},#{messsge}, #{createTime}, #{reqcode},#{method},#{remark},#{status})
</insert>
<update id="updateProOrder" parameterType="ProOrder">
update pro_order
<trim prefix="SET" suffixOverrides=",">
<if test="planFactoryCode != null">plan_factory_code = #{planFactoryCode},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="orderCode != null">order_code = #{orderCode},</if>
<if test="prodCode != null">prod_code = #{prodCode},</if>
<if test="prodDesc != null">prod_desc = #{prodDesc},</if>
<if test="quantity != null">quantity = #{quantity},</if>
<if test="quantitySplit != null">quantity_split = #{quantitySplit},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="workerOrder != null">worker_order = #{workerOrder},</if>
<if test="planProDate != null">plan_pro_date = #{planProDate},</if>
<if test="planComplete != null">plan_complete = #{planComplete},</if>
<if test="atrr1 != null">atrr1 = #{atrr1},</if>
<if test="atrr2 != null">atrr2 = #{atrr2},</if>
<if test="atrr3 != null">atrr3 = #{atrr3},</if>
<if test="status != null">status = #{status},</if>
<if test="parentOrder != null">parent_order = #{parentOrder},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="prodType != null">prod_type = #{prodType},</if>
<if test="prodSpc != null">prod_spc = #{prodSpc},</if>
from_sap_time = GETDATE(),
<if test="cegci != null">cegci = #{cegci},</if>
<if test="syncUser != null">sync_user = #{syncUser},</if>
</trim>
where id = #{id}
</update>
<update id="updateOrder">
update pro_order
<trim prefix="SET" suffixOverrides=",">
<if test="quantitySplit != null">quantity_split = #{quantitySplit},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="status != null">status = #{status},</if>
<if test="carNum != null">car_num = #{carNum},</if>
</trim>
where id = #{id}
</update>
<update id="updateOrderBatch">
<foreach collection="workers" item="worker" index="index" separator=";">
update pro_order set quantity_split = quantity_split-#{worker.quantitySplit},
update_time = GETDATE(),
status = 'o1'
where id = #{worker.orderId}
</foreach>
</update>
<update id="updateCloseOrderBatch">
<foreach collection="workers" item="worker" index="index" separator=";">
update pro_order set del_flag = '1',
update_time = GETDATE()
where id = #{worker.orderId}
</foreach>
</update>
<update id="updateProOrderByOrderCode" parameterType="ProOrder">
update pro_order
<trim prefix="SET" suffixOverrides=",">
<if test="planFactoryCode != null">plan_factory_code = #{planFactoryCode},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="orderCode != null">order_code = #{orderCode},</if>
<if test="prodCode != null">prod_code = #{prodCode},</if>
<if test="prodDesc != null">prod_desc = #{prodDesc},</if>
<if test="quantity != null">quantity = #{quantity},</if>
<if test="quantitySplit != null">quantity_split = #{quantitySplit},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="workerOrder != null">worker_order = #{workerOrder},</if>
<if test="planProDate != null">plan_pro_date = #{planProDate},</if>
<if test="planComplete != null">plan_complete = #{planComplete},</if>
<if test="atrr1 != null">atrr1 = #{atrr1},</if>
<if test="atrr2 != null">atrr2 = #{atrr2},</if>
<if test="atrr3 != null">atrr3 = #{atrr3},</if>
<if test="status != null">status = #{status},</if>
<if test="parentOrder != null">parent_order = #{parentOrder},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="prodType != null">prod_type = #{prodType},</if>
<if test="prodSpc != null">prod_spc = #{prodSpc},</if>
</trim>
where order_code = #{orderCode} and del_flag = '0'
</update>
<update id="updateOrderStatusByOrderCode">
update pro_order set status = 'o1' where parent_order = #{orderCode} and del_flag = '0'
</update>
<update id="updateWhiteOrder">
update pro_order
<trim prefix="SET" suffixOverrides=",">
<if test="quantity != null ">quantity += #{quantity},</if>
<if test="quantitySplit != null ">quantity_split += #{quantitySplit},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="status != null">status = #{status},</if>
<if test="carNum != null">car_num = #{carNum},</if>
</trim>
where id = #{id}
</update>
<update id="updateOrderStatusCompleteByOrderCode">
update pro_order set status = 'o2' where parent_order = #{orderCode} and del_flag = '0'
</update>
<update id="updateCloseOrderBatchById">
update pro_order
set del_flag = '1'
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<delete id="deleteProOrderById" parameterType="String">
update pro_order
set del_flag = '1'
where id = #{id}
</delete>
<delete id="deleteProOrderByIds" parameterType="String">
update pro_order
set del_flag = '1'
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>