<?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.dms.mapper.DmsBillsFaultInstanceMapper" >
<resultMap type= "DmsBillsFaultInstance" id= "DmsBillsFaultInstanceResult" >
<result property= "repairInstanceId" column= "repair_instance_id" />
<result property= "faultSourceType" column= "fault_source_type" />
<result property= "faultSourceId" column= "fault_source_id" />
<result property= "billsFaultCode" column= "bills_fault_code" />
<result property= "billsStatus" column= "bills_status" />
<result property= "applyUser" column= "apply_user" />
<result property= "applyTime" column= "apply_time" />
<result property= "realBeginTime" column= "real_begin_time" />
<result property= "realEndTime" column= "real_end_time" />
<result property= "requireEndTime" column= "require_end_time" />
<result property= "instanceType" column= "instance_type" />
<result property= "isFlag" column= "is_flag" />
<result property= "remark" column= "remark" />
<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="wfProcessId" column="wf_process_id" /> -->
<result property= "deviceId" column= "device_id" />
<result property= "approveStatus" column= "approveStatus" />
<result property= "deviceCode" column= "device_code" />
<result property= "deviceName" column= "device_name" />
<result property= "deviceLocation" column= "device_location" />
<result property= "deviceSpec" column= "device_spec" />
<result property= "instanceActivityId" column= "instance_activity_id" />
<result property= "faultType" column= "fault_type" />
<result property= "faultDescription" column= "fault_description" />
<result property= "designOperations" column= "design_operations" />
<result property= "repairType" column= "repair_type" />
<result property= "outsrcId" column= "outsrc_id" />
<result property= "processHandleResolution" column= "process_handle_resolution" />
</resultMap>
<resultMap id= "DmsBillsFaultInstanceDmsFaultInstanceActivityResult" type= "DmsBillsFaultInstance" extends= "DmsBillsFaultInstanceResult" >
<collection property= "dmsFaultInstanceActivityList" notNullColumn= "sub_instance_activity_id" javaType= "java.util.List" resultMap= "DmsFaultInstanceActivityResult" />
</resultMap>
<resultMap type= "DmsFaultInstanceActivity" id= "DmsFaultInstanceActivityResult" >
<result property= "instanceActivityId" column= "sub_instance_activity_id" />
<result property= "repairInstanceId" column= "sub_repair_instance_id" />
<result property= "processActivityId" column= "sub_process_activity_id" />
<result property= "faultType" column= "sub_fault_type" />
<result property= "faultDescription" column= "sub_fault_description" />
<result property= "designOperations" column= "sub_design_operations" />
<result property= "deviceId" column= "sub_device_id" />
<result property= "repairType" column= "sub_repair_type" />
<result property= "outsrcId" column= "sub_outsrc_id" />
<result property= "processHandleResolution" column= "sub_process_handle_resolution" />
<result property= "remark" column= "sub_remark" />
<result property= "processHandleStatus" column= "sub_process_handle_status" />
<result property= "processStepOrder" column= "sub_process_step_order" />
<result property= "startTime" column= "sub_start_time" />
<result property= "endTime" column= "sub_end_time" />
<result property= "handleUserId" column= "sub_handle_user_id" />
<result property= "handleBy" column= "sub_handle_by" />
<result property= "handleTime" column= "sub_handle_time" />
<result property= "createBy" column= "sub_create_by" />
<result property= "createTime" column= "sub_create_time" />
<result property= "transferUserId" column= "sub_transfer_user_id" />
<result property= "attr1" column= "sub_attr1" />
</resultMap>
<sql id= "selectDmsBillsFaultInstanceVo" >
select repair_instance_id, fault_source_type, fault_source_id, bills_fault_code, bills_status, apply_user, apply_time, real_begin_time, real_end_time, require_end_time, instance_type, is_flag, remark, create_by, create_time, update_by, update_time,device_id,approveStatus from dms_bills_fault_instance
</sql>
<select id= "selectDmsBillsFaultInstanceList" parameterType= "DmsBillsFaultInstance" resultMap= "DmsBillsFaultInstanceResult" >
<include refid= "selectDmsBillsFaultInstanceVo" />
<where >
approveStatus != '4'
<if test= "faultSourceType != null and faultSourceType != ''" > and fault_source_type = #{faultSourceType}</if>
<if test= "faultSourceId != null " > and fault_source_id = #{faultSourceId}</if>
<if test= "repairInstanceId != null " > and repair_instance_id = #{repairInstanceId}</if>
<!-- 已废弃审批流 -->
<!-- <if test="wfProcessId != null "> and wf_process_id = #{wfProcessId}</if> -->
<if test= "billsFaultCode != null and billsFaultCode != ''" > and bills_fault_code = #{billsFaultCode}</if>
<if test= "billsStatus != null and billsStatus != ''" > and bills_status = #{billsStatus}</if>
<if test= "applyUser != null and applyUser != ''" > and apply_user = #{applyUser}</if>
<if test= "applyTime != null " > and apply_time = #{applyTime}</if>
<if test= "realBeginTime != null " > and real_begin_time = #{realBeginTime}</if>
<if test= "realEndTime != null " > and real_end_time = #{realEndTime}</if>
<if test= "requireEndTime != null " > and require_end_time = #{requireEndTime}</if>
<if test= "instanceType != null and instanceType != ''" > and instance_type = #{instanceType}</if>
<if test= "isFlag != null and isFlag != ''" > and is_flag = #{isFlag}</if>
<if test= "deviceId != null and deviceId != ''" > and device_id = #{deviceId}</if>
</where>
order by create_time desc
</select>
<select id= "selectDmsBillsFaultInstanceByRepairInstanceId" parameterType= "Long" resultMap= "DmsBillsFaultInstanceResult" >
<include refid= "selectDmsBillsFaultInstanceVo" />
where repair_instance_id = #{repairInstanceId}
</select>
<insert id= "insertDmsBillsFaultInstance" parameterType= "DmsBillsFaultInstance" >
<selectKey keyProperty= "repairInstanceId" resultType= "long" order= "BEFORE" >
SELECT seq_dms_bills_fault_instance.NEXTVAL FROM DUAL
</selectKey>
insert into dms_bills_fault_instance
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
repair_instance_id,
<if test= "faultSourceType != null" > fault_source_type,</if>
<if test= "faultSourceId != null" > fault_source_id,</if>
<if test= "billsFaultCode != null and billsFaultCode != ''" > bills_fault_code,</if>
<if test= "billsStatus != null and billsStatus != ''" > bills_status,</if>
<if test= "applyUser != null" > apply_user,</if>
<if test= "applyTime != null" > apply_time,</if>
<if test= "realBeginTime != null" > real_begin_time,</if>
<if test= "realEndTime != null" > real_end_time,</if>
<if test= "requireEndTime != null" > require_end_time,</if>
<if test= "instanceType != null and instanceType != ''" > instance_type,</if>
<if test= "isFlag != null and isFlag != ''" > is_flag,</if>
<if test= "remark != null" > remark,</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= "deviceId != null" > device_id,</if>
<!-- 已废弃审批流 -->
<!-- <if test="wfProcessId != null">wf_process_id,</if> -->
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
#{repairInstanceId},
<if test= "faultSourceType != null" > #{faultSourceType},</if>
<if test= "faultSourceId != null" > #{faultSourceId},</if>
<if test= "billsFaultCode != null and billsFaultCode != ''" > #{billsFaultCode},</if>
<if test= "billsStatus != null and billsStatus != ''" > #{billsStatus},</if>
<if test= "applyUser != null" > #{applyUser},</if>
<if test= "applyTime != null" > #{applyTime},</if>
<if test= "realBeginTime != null" > #{realBeginTime},</if>
<if test= "realEndTime != null" > #{realEndTime},</if>
<if test= "requireEndTime != null" > #{requireEndTime},</if>
<if test= "instanceType != null and instanceType != ''" > #{instanceType},</if>
<if test= "isFlag != null and isFlag != ''" > #{isFlag},</if>
<if test= "remark != null" > #{remark},</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= "deviceId != null" > #{deviceId},</if>
<!-- 已废弃审批流 -->
<!-- <if test="wfProcessId != null">#{wfProcessId},</if> -->
</trim>
</insert>
<update id= "updateDmsBillsFaultInstance" parameterType= "DmsBillsFaultInstance" >
update dms_bills_fault_instance
<trim prefix= "SET" suffixOverrides= "," >
<if test= "faultSourceType != null" > fault_source_type = #{faultSourceType},</if>
<if test= "faultSourceId != null" > fault_source_id = #{faultSourceId},</if>
<if test= "billsFaultCode != null and billsFaultCode != ''" > bills_fault_code = #{billsFaultCode},</if>
<if test= "billsStatus != null and billsStatus != ''" > bills_status = #{billsStatus},</if>
<if test= "applyUser != null" > apply_user = #{applyUser},</if>
<if test= "applyTime != null" > apply_time = #{applyTime},</if>
<if test= "realBeginTime != null" > real_begin_time = #{realBeginTime},</if>
<if test= "realEndTime != null" > real_end_time = #{realEndTime},</if>
<if test= "requireEndTime != null" > require_end_time = #{requireEndTime},</if>
<if test= "instanceType != null and instanceType != ''" > instance_type = #{instanceType},</if>
<if test= "isFlag != null and isFlag != ''" > is_flag = #{isFlag},</if>
<if test= "remark != null" > remark = #{remark},</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= "deviceId != null" > device_id = #{deviceId},</if>
<if test= "approveStatus != null" > approveStatus = #{approveStatus},</if>
<if test= "repairConfirm != null" > repair_confirm = #{repairConfirm},</if>
<if test= "confirmer != null" > confirmer = #{confirmer},</if>
</trim>
where repair_instance_id = #{repairInstanceId}
</update>
<delete id= "deleteDmsBillsFaultInstanceByRepairInstanceId" parameterType= "Long" >
delete from dms_bills_fault_instance where repair_instance_id = #{repairInstanceId}
</delete>
<delete id= "deleteDmsBillsFaultInstanceByRepairInstanceIds" parameterType= "java.lang.Long" >
delete from dms_bills_fault_instance where repair_instance_id in
<foreach item= "repairInstanceId" collection= "array" open= "(" separator= "," close= ")" >
#{repairInstanceId}
</foreach>
</delete>
<sql id= "selectDmsBillsFaultInstanceJoinVo" >
select dbfi.repair_instance_id, dbfi.fault_source_type, dbfi.fault_source_id, dbfi.bills_fault_code, dbfi.bills_status,
dbfi.apply_user, dbfi.apply_time, dbfi.real_begin_time, dbfi.real_end_time, dbfi.require_end_time, dbfi.device_id,dbfi.approveStatus,
dbdl.device_code,
dbdl.device_name,
dbdl.device_address as device_location,
dbdl.device_model as device_spec
from dms_bills_fault_instance dbfi left join base_deviceledger dbdl on dbfi.device_id=dbdl.OBJ_ID
</sql>
<select id= "selectDmsBillsFaultInstanceJoinList" parameterType= "DmsBillsFaultInstance" resultMap= "DmsBillsFaultInstanceResult" >
<include refid= "selectDmsBillsFaultInstanceJoinVo" />
<where >
<if test= "faultSourceType != null and faultSourceType != ''" > and fault_source_type = #{faultSourceType}</if>
<if test= "faultSourceId != null " > and fault_source_id = #{faultSourceId}</if>
<if test= "repairInstanceId != null " > and repair_instance_id = #{repairInstanceId}</if>
<!-- 已废弃审批流 -->
<!-- <if test="wfProcessId != null "> and wf_process_id = #{wfProcessId}</if> -->
<if test= "billsFaultCode != null and billsFaultCode != ''" > and bills_fault_code = #{billsFaultCode}</if>
<if test= "billsStatus != null and billsStatus != ''" > and bills_status = #{billsStatus}</if>
<if test= "applyUser != null and applyUser != ''" > and apply_user = #{applyUser}</if>
<if test= "applyTime != null " > and apply_time = #{applyTime}</if>
<if test= "instanceType != null and instanceType != ''" > and instance_type = #{instanceType}</if>
<if test= "isFlag != null and isFlag != ''" > and is_flag = #{isFlag}</if>
<if test= "deviceId != null and deviceId != ''" > and device_id = #{deviceId}</if>
</where>
order by dbfi.repair_instance_id desc
</select>
<select id= "selectFaultInstanceJoinFirstAndDeviceById" parameterType= "Long" resultMap= "DmsBillsFaultInstanceResult" >
select dbfi.repair_instance_id, dbfi.fault_source_type, dbfi.fault_source_id, dbfi.bills_fault_code, dbfi.bills_status,
dbfi.apply_user, dbfi.apply_time, dbfi.real_begin_time, dbfi.real_end_time, dbfi.require_end_time, dbfi.device_id,dbfi.approveStatus,
dbdl.device_code,
dbdl.device_name,
dbdl.device_address as device_location,
dbdl.device_model as device_spec,
dfia.instance_activity_id,dfia.fault_type,dfia.fault_description,dfia.design_operations,dfia.repair_type,dfia.outsrc_id,dfia.process_handle_resolution
,dfia.checked_fault checked_fault,
dfia.repair_content repair_content,
dfia.protected_method protected_method,
dfia.repairer repairer,
dfia.repair_confirm repair_confirm,
dfia.confirm_time confirm_time,dfia.components_parts_id components_parts_id
from dms_bills_fault_instance dbfi left join base_deviceledger dbdl on dbfi.device_id=dbdl.OBJ_ID
left join dms_fault_instance_activity dfia on dbfi.repair_instance_id=dfia.repair_instance_id
where dbfi.repair_instance_id = #{repairInstanceId} and dfia.process_step_order=1
</select>
<select id= "selectFaultInstanceJoinActivityByRepairInstanceId" parameterType= "Long" resultMap= "DmsBillsFaultInstanceDmsFaultInstanceActivityResult" >
select a.repair_instance_id, a.fault_source_type, a.fault_source_id, a.bills_fault_code, a.bills_status, a.apply_user, a.apply_time, a.real_begin_time, a.real_end_time, a.require_end_time, a.instance_type, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time,a.approveStatus,
dbdl.device_code,
dbdl.device_name,
dbdl.device_address as device_location,
dbdl.device_model as device_spec,
b.instance_activity_id as sub_instance_activity_id, b.repair_instance_id as sub_repair_instance_id, b.process_activity_id as sub_process_activity_id, b.fault_type as sub_fault_type, b.fault_description as sub_fault_description, b.design_operations as sub_design_operations, b.device_id as sub_device_id, b.repair_type as sub_repair_type, b.outsrc_id as sub_outsrc_id, b.process_handle_resolution as sub_process_handle_resolution, b.remark as sub_remark, b.process_handle_status as sub_process_handle_status, b.process_step_order as sub_process_step_order, b.start_time as sub_start_time, b.end_time as sub_end_time, b.handle_user_id as sub_handle_user_id, b.handle_by as sub_handle_by, b.handle_time as sub_handle_time,
a.approveStatus
from dms_bills_fault_instance a
left join base_deviceledger dbdl on a.device_id=dbdl.OBJ_ID
left join dms_fault_instance_activity b on b.repair_instance_id = a.repair_instance_id
where a.repair_instance_id = #{repairInstanceId} order by b.process_step_order
</select>
<select id= "selectCountByRepairInstanceIdAndDeviceCode" resultType= "Long" >
select count(1) from dms_bills_fault_instance dbfi where dbfi.repair_instance_id=#{repairInstanceId}
and exists (select 1 from base_deviceledger dbdl where dbfi.device_id=dbdl.OBJ_ID and dbdl.device_code=#{deviceCode})
</select>
<select id= "selectFaultInstanceJoinFirstById" parameterType= "Long" resultMap= "DmsBillsFaultInstanceResult" >
select dbfi.repair_instance_id, dbfi.fault_source_type, dbfi.fault_source_id, dbfi.bills_fault_code, dbfi.bills_status,
dbfi.apply_user, dbfi.apply_time, dbfi.real_begin_time, dbfi.real_end_time, dbfi.require_end_time, dbfi.device_id,
dfia.instance_activity_id,dfia.fault_type,dfia.fault_description,dfia.design_operations,dfia.repair_type,dfia.outsrc_id,dfia.process_handle_resolution
from dms_bills_fault_instance dbfi
left join dms_fault_instance_activity dfia on dbfi.repair_instance_id=dfia.repair_instance_id
where dbfi.repair_instance_id = #{repairInstanceId} and dfia.process_step_order=1
</select>
<select id= "selectFaults" resultType= "com.aucma.dms.domain.DmsFaultInstanceActivity"
parameterType="java.lang.Long">
select
x.fault_description ,
x.checked_fault ,
-- dri.wf_process_id, -- 已废弃审批流handle_resolution,
x.repair_content ,
x.protected_method ,
x.repairer ,
a.device_name ,
a.device_code,
a.device_address as device_location ,
b.apply_user ,
b.apply_time ,
b.real_begin_time ,
b.real_end_time,
b.repair_confirm,
b.update_time,
b.confirmer
from
dms_fault_instance_activity x left join base_deviceledger a on x.device_id = a.OBJ_ID
left join dms_bills_fault_instance b on x.repair_instance_id = b.repair_instance_id where x.repair_instance_id = #{repairInstanceId}
</select>
<select id= "selectParts" resultType= "com.aucma.dms.domain.DmsFaultCompentsParts"
parameterType="java.lang.Long">
SELECT x.* FROM dms_fault_compents_parts x where x.fault_id = #{repairInstanceId}
</select>
<select id= "selectDmsBillsFaultInstanceCompletedList" resultType= "com.aucma.dms.domain.DmsBillsFaultInstance"
parameterType="com.aucma.dms.domain.DmsBillsFaultInstance">
select repair_instance_id, fault_source_type, fault_source_id, bills_fault_code, bills_status, apply_user, apply_time, real_begin_time, real_end_time, require_end_time, instance_type, is_flag, remark, create_by, create_time, update_by, update_time,device_id,approveStatus,repair_confirm from dms_bills_fault_instance
<where >
bills_status = 2
<if test= "faultSourceType != null and faultSourceType != ''" > and fault_source_type = #{faultSourceType}</if>
<if test= "faultSourceId != null " > and fault_source_id = #{faultSourceId}</if>
<if test= "repairInstanceId != null " > and repair_instance_id = #{repairInstanceId}</if>
<if test= "wfProcessId != null " > and wf_process_id = #{wfProcessId}</if>
<if test= "billsFaultCode != null and billsFaultCode != ''" > and bills_fault_code = #{billsFaultCode}</if>
<if test= "billsStatus != null and billsStatus != ''" > and bills_status = #{billsStatus}</if>
<if test= "applyUser != null and applyUser != ''" > and apply_user = #{applyUser}</if>
<if test= "applyTime != null " > and apply_time = #{applyTime}</if>
<if test= "realBeginTime != null " > and real_begin_time = #{realBeginTime}</if>
<if test= "realEndTime != null " > and real_end_time = #{realEndTime}</if>
<if test= "requireEndTime != null " > and require_end_time = #{requireEndTime}</if>
<if test= "instanceType != null and instanceType != ''" > and instance_type = #{instanceType}</if>
<if test= "isFlag != null and isFlag != ''" > and is_flag = #{isFlag}</if>
<if test= "deviceId != null and deviceId != ''" > and device_id = #{deviceId}</if>
</where>
order by create_time desc
</select>
<select id= "getDmsPartsList" resultType= "com.aucma.dms.domain.DmsFaultCompentsParts"
parameterType="java.lang.Long">
select
x.*,a.bills_fault_code
from
dms_fault_compents_parts x
left join dms_bills_fault_instance a on
x.fault_id = a.repair_instance_id where x.fault_id = #{repairInstanceId}
</select>
</mapper>