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.

362 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.op.device.mapper.EquOrderMapper">
<resultMap type="EquOrder" id="EquOrderResult">
<result property="orderId" column="order_id" />
<result property="planId" column="plan_id" />
<result property="planCode" column="plan_code" />
<result property="planType" column="plan_type" />
<result property="orderCode" column="order_code" />
<result property="planWorkshop" column="plan_workshop" />
<result property="planProdLine" column="plan_prod_line" />
<result property="planLoop" column="plan_loop" />
<result property="planLoopType" column="plan_loop_type" />
<result property="planLoopStart" column="plan_loop_start" />
<result property="planLoopEnd" column="plan_loop_end" />
<result property="orderStart" column="order_start" />
<result property="orderEnd" column="order_end" />
<result property="equipmentCode" column="equipment_code" />
<result property="orderStatus" column="order_status" />
<result property="orderCost" column="order_cost" />
<result property="planPerson" column="plan_person" />
<result property="orderCostTime" column="order_cost_time" />
<result property="orderSignPerson" column="order_sign_person" />
<result property="factoryCode" column="factory_code" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="delFlag" column="del_flag" />
<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="upkeep" column="upkeep" />
<result property="calculationRule" column="calculation_rule" />
<result property="shutDown" column="shut_down" />
<result property="orderInspect" column="order_inspect" />
<result property="repairCode" column="repair_code" />
<result property="workCode" column="work_code" />
<result property="id" column="id" />
<result property="itemName" column="item_name" />
<result property="itemMethod" column="item_method" />
<result property="itemType" column="item_type" />
<result property="itemTypeName" column="item_type_name" />
<result property="outsourceCode" column="outsource_code" />
</resultMap>
<sql id="selectEquOrderVo">
select order_id, plan_id, plan_code, plan_type, order_code, plan_workshop, plan_prod_line, plan_loop, plan_loop_type,
plan_loop_start, plan_loop_end, order_start, order_end, equipment_code, order_status,
order_cost, plan_person, order_cost_time, order_sign_person,
factory_code, attr1, attr2, attr3, del_flag, create_by, create_time,
update_by, update_time,upkeep,calculation_rule,shut_down,order_inspect,repair_code,work_code,outsource_code
from equ_order
</sql>
<select id="selectEquOrderList" parameterType="EquOrder" resultMap="EquOrderResult">
<include refid="selectEquOrderVo"/>
<where>
<if test="planId != null and planId != ''"> and plan_id = #{planId}</if>
<if test="planCode != null and planCode != ''"> and plan_code like concat('%', #{planCode}, '%')</if>
<if test="planType != null and planType != ''"> and plan_type = #{planType}</if>
<if test="orderCode != null and orderCode != ''"> and order_code like concat('%', #{orderCode}, '%')</if>
<if test="planWorkshop != null and planWorkshop != ''"> and plan_workshop = #{planWorkshop}</if>
<if test="planProdLine != null and planProdLine != ''"> and plan_prod_line = #{planProdLine}</if>
<if test="planLoop != null and planLoop != ''"> and plan_loop = #{planLoop}</if>
<if test="planLoopType != null and planLoopType != ''"> and plan_loop_type = #{planLoopType}</if>
<if test="equipmentCode != null and equipmentCode != ''"> and equipment_code like concat('%', #{equipmentCode}, '%')</if>
<if test="planLoopStart != null "> and plan_loop_start = #{planLoopStart}</if>
<if test="planLoopEnd != null "> and plan_loop_end = #{planLoopEnd}</if>
<if test="orderStart != null "> and order_start = #{orderStart}</if>
<if test="orderEnd != null "> and order_end = #{orderEnd}</if>
<if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if>
<if test="orderCost != null "> and order_cost = #{orderCost}</if>
<if test="planPerson != null and planPerson != ''"> and plan_person like concat('%', #{planPerson}, '%')</if>
<if test="orderCostTime != null and orderCostTime != ''"> and order_cost_time = #{orderCostTime}</if>
<if test="orderSignPerson != null and orderSignPerson != ''"> and order_sign_person = #{orderSignPerson}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''"> and attr3 = #{attr3}</if>
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and CONVERT(date,create_time) = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and CONVERT(date,update_time) = #{updateTime}</if>
<if test="upkeep != null "> and upkeep = #{upkeep}</if>
<if test="calculationRule != null "> and calculation_rule = #{calculationRule}</if>
<if test="shutDown != null "> and shut_down = #{shutDown}</if>
<if test="orderInspect != null "> and order_inspect = #{orderInspect}</if>
<if test="repairCode != null "> and repair_code = #{repairCode}</if>
<if test="outsourceCode != null "> and outsource_code = #{outsourceCode}</if>
<if test="workCode != null "> and work_code = #{workCode}</if>
<if test="loopStart != null "> and CONVERT(date,plan_loop_start) >= #{loopStart}</if>
<if test="loopEnd != null "> and #{loopEnd} >= CONVERT(date,plan_loop_start)</if>
<if test="loopEndArrayStart != null "> and CONVERT(date,plan_loop_end) >= #{loopEndArrayStart}</if>
<if test="getLoopEndArrayEnd != null "> and #{getLoopEndArrayEnd} >= CONVERT(date,plan_loop_end)</if>
<if test="orderStartArrayStart != null "> and CONVERT(date,order_start) >= #{orderStartArrayStart}</if>
<if test="orderStartArrayEnd != null "> and #{orderStartArrayEnd} >= CONVERT(date,order_start)</if>
<if test="orderEndArrayStart != null "> and CONVERT(date,order_end) >= #{orderEndArrayStart}</if>
<if test="orderEndArrayEnd != null "> and #{orderEndArrayEnd} >= CONVERT(date,order_end)</if>
and del_flag = '0'
</where>
</select>
<select id="selectEquOrderByOrderCode" parameterType="String" resultMap="EquOrderResult">
<include refid="selectEquOrderVo"/>
where order_code = #{orderCode} and del_flag = '0'
</select>
<select id="selectPlanNameByPlanCode" resultType="java.lang.String">
select plan_name AS 'planName' from equ_plan where del_flag = '0' and plan_code = #{orderCode}
</select>
<select id="selectCenterNameByCenterCode" resultType="java.lang.String">
select top 1 workshop_name from base_equipment where del_flag = '0' and workshop_code = #{planWorkshop}
</select>
<select id="selectEquOrderByOrderId" parameterType="String" resultMap="EquOrderResult">
<include refid="selectEquOrderVo"/>
where order_id = #{orderId} and del_flag = '0'
</select>
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(order_id)+1 AS serialNum
FROM equ_order
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time)
</select>
<select id="changeLoopType" resultType="java.lang.String">
select dict_label from sys_dict_data where dict_value = #{planLoopType}
</select>
<select id="selectTodayTask" parameterType="String" resultMap="EquOrderResult">
<include refid="selectEquOrderVo"/>
where CONVERT(date,GETDATE()) >= plan_loop_start and plan_type = #{planType} and del_flag = '0' and order_status != '1' and order_code in (
select order_code from equ_order_person where del_flag = '0' and user_id = #{userId} GROUP BY order_code
)
</select>
<select id="selectTaskRecord" parameterType="String" resultMap="EquOrderResult">
<include refid="selectEquOrderVo"/>
where del_flag = '0' and order_status = '1' and plan_type = #{planType} and order_code in (
select order_code from equ_order_person where del_flag = '0' and user_id = #{userId} GROUP BY order_code
)
</select>
<select id="selectEquipmentNameByEquCode" resultType="java.lang.String">
select equipment_name AS 'equipmentName' from base_equipment where equipment_code = #{equipmentCode} and del_flag = '0'
</select>
<insert id="insertEquOrder" parameterType="EquOrder">
insert into equ_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if>
<if test="planId != null">plan_id,</if>
<if test="planCode != null">plan_code,</if>
<if test="planType != null">plan_type,</if>
<if test="orderCode != null">order_code,</if>
<if test="planWorkshop != null">plan_workshop,</if>
<if test="planProdLine != null">plan_prod_line,</if>
<if test="planLoop != null">plan_loop,</if>
<if test="planLoopType != null">plan_loop_type,</if>
<if test="planLoopStart != null">plan_loop_start,</if>
<if test="planLoopEnd != null">plan_loop_end,</if>
<if test="orderStart != null">order_start,</if>
<if test="orderEnd != null">order_end,</if>
<if test="equipmentCode != null">equipment_code,</if>
<if test="orderStatus != null">order_status,</if>
<if test="orderCost != null">order_cost,</if>
<if test="planPerson != null">plan_person,</if>
<if test="orderCostTime != null">order_cost_time,</if>
<if test="orderSignPerson != null">order_sign_person,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="delFlag != null">del_flag,</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="upkeep != null">upkeep,</if>
<if test="calculationRule != null">calculation_rule,</if>
<if test="shutDown != null">shut_down,</if>
<if test="orderInspect != null">order_inspect,</if>
<if test="repairCode != null">repair_code,</if>
<if test="repairCode != null">repair_code,</if>
<if test="workCode != null">work_code,</if>
<if test="planRestrict != null">plan_restrict,</if>
<if test="outsourceCode != null">outsource_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
<if test="planId != null">#{planId},</if>
<if test="planCode != null">#{planCode},</if>
<if test="planType != null">#{planType},</if>
<if test="orderCode != null">#{orderCode},</if>
<if test="planWorkshop != null">#{planWorkshop},</if>
<if test="planProdLine != null">#{planProdLine},</if>
<if test="planLoop != null">#{planLoop},</if>
<if test="planLoopType != null">#{planLoopType},</if>
<if test="planLoopStart != null">#{planLoopStart},</if>
<if test="planLoopEnd != null">#{planLoopEnd},</if>
<if test="orderStart != null">#{orderStart},</if>
<if test="orderEnd != null">#{orderEnd},</if>
<if test="equipmentCode != null">#{equipmentCode},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="orderCost != null">#{orderCost},</if>
<if test="planPerson != null">#{planPerson},</if>
<if test="orderCostTime != null">#{orderCostTime},</if>
<if test="orderSignPerson != null">#{orderSignPerson},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="delFlag != null">#{delFlag},</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="upkeep != null">#{upkeep},</if>
<if test="calculationRule != null">#{calculationRule},</if>
<if test="shutDown != null">#{shutDown},</if>
<if test="orderInspect != null">#{orderInspect},</if>
<if test="repairCode != null">#{repairCode},</if>
<if test="workCode != null">#{workCode},</if>
<if test="planRestrict != null">#{planRestrict},</if>
<if test="outsourceCode != null">#{outsourceCode},</if>
</trim>
</insert>
<update id="updateEquOrder" parameterType="EquOrder">
update equ_order
<trim prefix="SET" suffixOverrides=",">
<if test="planId != null">plan_id = #{planId},</if>
<if test="planCode != null">plan_code = #{planCode},</if>
<if test="planType != null">plan_type = #{planType},</if>
<if test="orderCode != null">order_code = #{orderCode},</if>
<if test="planWorkshop != null">plan_workshop = #{planWorkshop},</if>
<if test="planProdLine != null">plan_prod_line = #{planProdLine},</if>
<if test="planLoop != null">plan_loop = #{planLoop},</if>
<if test="planLoopType != null">plan_loop_type = #{planLoopType},</if>
<if test="planLoopStart != null">plan_loop_start = #{planLoopStart},</if>
<if test="planLoopEnd != null">plan_loop_end = #{planLoopEnd},</if>
<if test="orderStart != null">order_start = #{orderStart},</if>
<if test="orderEnd != null">order_end = #{orderEnd},</if>
<if test="equipmentCode != null">equipment_code = #{equipmentCode},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="orderCost != null">order_cost = #{orderCost},</if>
<if test="planPerson != null">plan_person = #{planPerson},</if>
<if test="orderCostTime != null">order_cost_time = #{orderCostTime},</if>
<if test="orderSignPerson != null">order_sign_person = #{orderSignPerson},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="delFlag != null">del_flag = #{delFlag},</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="upkeep != null">upkeep = #{upkeep},</if>
<if test="calculationRule != null">calculation_rule = #{calculationRule},</if>
<if test="shutDown != null">shut_down = #{shutDown},</if>
<if test="orderInspect != null">order_inspect = #{orderInspect},</if>
<if test="repairCode != null">repair_code = #{repairCode},</if>
<if test="workCode != null">work_code = #{workCode},</if>
<if test="outsourceCode != null">outsource_code = #{outsourceCode},</if>
</trim>
where order_id = #{orderId}
</update>
<delete id="deleteEquOrderByOrderId" parameterType="String">
delete from equ_order where order_id = #{orderId}
</delete>
<delete id="deleteEquOrderByOrderIds" parameterType="String">
delete from equ_order where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</delete>
<delete id="delEquOrderByOrderIds">
update equ_order set del_flag = '1' where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</delete>
<!-- 手持维修查询检查项-->
<select id="selectCheckListByWorkCode" parameterType="EquOrder" resultMap="EquOrderResult">
select
eo.order_id,
eo.order_code,
eo.repair_code,
eo.work_code,
eod.id,
eod.item_name,
eod.item_method,
eod.item_type,
eod.item_type_name
from equ_order eo
left join equ_order_detail eod on eo.order_code = eod.order_code
where eo.work_code = #{workCode}
and eo.del_flag = '0'
</select>
<!-- 手持报修查询检查项-->
<select id="selectCheckListByRepairCode" parameterType="EquOrder" resultMap="EquOrderResult">
select
eo.order_id,
eo.order_code,
eo.repair_code,
eo.work_code,
eod.id,
eod.item_name,
eod.item_method,
eod.item_type,
eod.item_type_name
from equ_order eo
left join equ_order_detail eod on eo.order_code = eod.order_code
where eo.repair_code = #{repairCode}
and eo.del_flag = '0'
</select>
<!-- 查询对应检查项id-->
<select id="getIdsByOrderCode" parameterType="EquOrder" resultType="java.lang.String">
select
order_id
from equ_order
where repair_code = #{orderCode}
and del_flag = '0'
</select>
<!-- 更新维修单号 -->
<update id="updateEquOrderRepairCode" parameterType="EquOrder">
update equ_order
<trim prefix="SET" suffixOverrides=",">
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="workCode != null">work_code = #{workCode},</if>
</trim>
where order_id = #{orderId}
</update>
<update id="updateEquOrderStatusComplete" parameterType="String">
update equ_order
set
order_status = '1'
where order_code = #{repairCode}
and del_flag = '0'
</update>
</mapper>