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.

240 lines
11 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.EquRepairOrderMapper">
<resultMap type="EquRepairOrder" id="EquRepairOrderResult">
<result property="orderId" column="order_id" />
<result property="orderCode" column="order_code" />
<result property="equipmentCode" column="equipment_code" />
<result property="orderDesc" column="order_desc" />
<result property="orderBreakdownTime" column="order_breakdown_time" />
<result property="orderSource" column="order_source" />
<result property="orderTime" column="order_time" />
<result property="orderHandle" column="order_handle" />
<result property="orderRepairman" column="order_repairman" />
<result property="orderConnection" column="order_connection" />
<result property="orderStatus" column="order_status" />
<result property="orderRelevance" column="order_relevance" />
<result property="orderPicture" column="order_picture" />
<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="factoryCode" column="factory_code" />
<result property="repairDestination" column="repair_destination" />
<!-- 设备 -->
<result property="equipmentTypeName" column="equipment_type_name" />
<result property="equipmentName" column="equipment_name" />
<result property="equipmentLocation" column="equipment_location" />
<result property="department" column="department" />
<result property="equipmentSpec" column="equipment_spec" />
<!-- 计划 -->
<result property="workPlanTime" column="work_plan_time" />
<result property="workDownMachine" column="work_down_machine" />
<result property="workPlanDownTime" column="work_plan_down_time" />
<result property="workTeam" column="work_team" />
<!-- 委外 -->
<result property="outSourcePerson" column="work_person" />
<result property="workOutsourcingUnit" column="work_outsourcing_unit" />
<result property="workConnection" column="work_connection" />
<result property="outSourceReason" column="work_reason" />
</resultMap>
<sql id="selectEquRepairOrderVo">
select order_id, order_code, equipment_code, order_desc, order_breakdown_time, order_source, order_time, order_handle, order_repairman, order_connection, order_status, order_relevance, order_picture, attr1, attr2, attr3, del_flag, create_by, create_time, update_by, update_time,factory_code,repair_destination from equ_repair_order
</sql>
<select id="selectEquRepairOrderList" parameterType="EquRepairOrder" resultMap="EquRepairOrderResult">
<include refid="selectEquRepairOrderVo"/>
<where>
<if test="orderCode != null and orderCode != ''"> and order_code like concat('%', #{orderCode}, '%')</if>
<if test="equipmentCode != null and equipmentCode != ''"> and equipment_code like concat('%', #{equipmentCode}, '%')</if>
<if test="orderDesc != null and orderDesc != ''"> and order_desc like concat('%', #{orderDesc}, '%')</if>
<if test="orderBreakdownTime != null "> and order_breakdown_time = #{orderBreakdownTime}</if>
<if test="orderSource != null and orderSource != ''"> and order_source like concat('%', #{orderSource}, '%')</if>
<if test="orderTime != null "> and order_time = #{orderTime}</if>
<if test="orderHandle != null and orderHandle != ''"> and order_handle = #{orderHandle}</if>
<if test="orderRepairman != null and orderRepairman != ''"> and order_repairman like concat('%', #{orderRepairman}, '%')</if>
<if test="orderConnection != null and orderConnection != ''"> and order_connection like concat('%', #{orderConnection}, '%')</if>
<if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if>
<if test="orderRelevance != null and orderRelevance != ''"> and order_relevance = #{orderRelevance}</if>
<if test="orderPicture != null and orderPicture != ''"> and order_picture = #{orderPicture}</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="createTime != null and createTime != ''"> and create_time = #{createTime}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="repairDestination != null and repairDestination != ''"> and repair_destination = #{repairDestination}</if>
and del_flag = '0'
ORDER BY create_time DESC
</where>
</select>
<select id="selectEquRepairOrderByOrderId" parameterType="String" resultMap="EquRepairOrderResult">
select
ero.order_id,
ero.order_code,
ero.equipment_code,
ero.order_desc,
ero.order_breakdown_time,
ero.order_source,
ero.order_time,
ero.order_handle,
ero.order_repairman,
ero.order_connection,
ero.order_status,
ero.order_relevance,
ero.order_picture,
ero.create_by,
ero.create_time,
ero.update_by,
ero.update_time,
ero.factory_code,
ero.repair_destination,
be.equipment_name,
be.equipment_type_name,
be.equipment_spec,
be.department,
be.equipment_location,
rwo.work_down_machine,
rwo.work_plan_down_time,
rwo.work_plan_time,
rwo.work_team,
eow.work_person,
eow.work_outsourcing_unit,
eow.work_connection,
eow.work_reason
from equ_repair_order ero
left join base_equipment be on ero.equipment_code = be.equipment_code
left join equ_repair_work_order rwo on ero.order_code = rwo.order_code
left join equ_outsource_work eow on ero.order_code = eow.work_code
where ero.order_id = #{orderId}
and ero.del_flag = '0'
ORDER BY create_time DESC
</select>
<insert id="insertEquRepairOrder" parameterType="EquRepairOrder">
insert into equ_repair_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if>
<if test="orderCode != null">order_code,</if>
<if test="equipmentCode != null">equipment_code,</if>
<if test="orderDesc != null">order_desc,</if>
<if test="orderBreakdownTime != null">order_breakdown_time,</if>
<if test="orderSource != null">order_source,</if>
<if test="orderTime != null">order_time,</if>
<if test="orderHandle != null">order_handle,</if>
<if test="orderRepairman != null">order_repairman,</if>
<if test="orderConnection != null">order_connection,</if>
<if test="orderStatus != null">order_status,</if>
<if test="orderRelevance != null">order_relevance,</if>
<if test="orderPicture != null">order_picture,</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="factoryCode != null">factory_code,</if>
<if test="repairDestination != null">repair_destination,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
<if test="orderCode != null">#{orderCode},</if>
<if test="equipmentCode != null">#{equipmentCode},</if>
<if test="orderDesc != null">#{orderDesc},</if>
<if test="orderBreakdownTime != null">#{orderBreakdownTime},</if>
<if test="orderSource != null">#{orderSource},</if>
<if test="orderTime != null">#{orderTime},</if>
<if test="orderHandle != null">#{orderHandle},</if>
<if test="orderRepairman != null">#{orderRepairman},</if>
<if test="orderConnection != null">#{orderConnection},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="orderRelevance != null">#{orderRelevance},</if>
<if test="orderPicture != null">#{orderPicture},</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="factoryCode != null">#{factoryCode},</if>
<if test="repairDestination != null">#{repairDestination},</if>
</trim>
</insert>
<update id="updateEquRepairOrder" parameterType="EquRepairOrder">
update equ_repair_order
<trim prefix="SET" suffixOverrides=",">
<if test="orderCode != null">order_code = #{orderCode},</if>
<if test="equipmentCode != null">equipment_code = #{equipmentCode},</if>
<if test="orderDesc != null">order_desc = #{orderDesc},</if>
<if test="orderBreakdownTime != null">order_breakdown_time = #{orderBreakdownTime},</if>
<if test="orderSource != null">order_source = #{orderSource},</if>
<if test="orderTime != null">order_time = #{orderTime},</if>
<if test="orderHandle != null">order_handle = #{orderHandle},</if>
<if test="orderRepairman != null">order_repairman = #{orderRepairman},</if>
<if test="orderConnection != null">order_connection = #{orderConnection},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="orderRelevance != null">order_relevance = #{orderRelevance},</if>
<if test="orderPicture != null">order_picture = #{orderPicture},</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="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="repairDestination != null">repair_destination = #{repairDestination},</if>
</trim>
where order_id = #{orderId}
</update>
<!--物理删除改为逻辑删除-->
<delete id="deleteEquRepairOrderByOrderId" parameterType="String">
update equ_repair_order
set del_flag = '1'
where order_id = #{orderId}
</delete>
<!--物理删除改为逻辑删除-->
<delete id="deleteEquRepairOrderByOrderIds" parameterType="String">
update equ_repair_order
set del_flag = '1'
where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</delete>
<select id="selectOrderCodeSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(order_id)+1 AS serialNum
FROM equ_repair_order
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time)
and del_flag = '0'
</select>
<select id="getRepairPersonList" parameterType="EquTeamUser" resultType="com.op.device.domain.EquTeamUser">
select
user_id AS userId,
user_name AS userName,
nick_name AS nickName,
CONCAT(nick_name,user_name) AS teamUserName
from sys_user
where del_flag = '0'
</select>
</mapper>