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.

271 lines
16 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="org.dromara.dms.mapper.DmsBillsFaultInstanceMapper">
<resultMap type="DmsBillsFaultInstanceVo" 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="wfDefinitionId" column="wf_definition_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="machineId" column="machine_id" />
<result property="machineCode" column="machine_code" />
<result property="machineName" column="machine_name" />
<result property="machineLocation" column="machine_location" />
<result property="machineSpec" column="machine_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="outsourcingId" column="outsourcing_id" />
<result property="processHandleResolution" column="process_handle_resolution" />
<result property="approveStatus" column="approveStatus" />
<!-- 添加缺失的字段映射 -->
<result property="checkedFault" column="checked_fault" />
<result property="repairContent" column="repair_content" />
<result property="protectedMethod" column="protected_method" />
<result property="repairer" column="repairer" />
<result property="repairConfirm" column="repair_confirm" />
<result property="confirmTime" column="confirm_time" />
<result property="componentsPartsId" column="components_parts_id" />
</resultMap>
<resultMap id="DmsBillsFaultInstanceDmsFaultInstanceActivityResult" type="DmsBillsFaultInstance" extends="DmsBillsFaultInstanceResult">
<collection property="dmsFaultInstanceActivityList" notNullColumn="sub_instance_activity_id" javaType="java.util.List" resultMap="DmsFaultInstanceActivityResult" />
</resultMap>
<!-- <select id="selectProcessActivityId" parameterType="Long" resultType="Long">-->
<!-- select min(process_activity_id) from wf_process_activity where wf_process_id = #{wfDefinitionId}-->
<!-- </select>-->
<sql id="selectDmsBillsFaultInstanceJoinVo">
select dbfi.repair_instance_id, dbfi.fault_source_type, dbfi.fault_source_id,
dbfi.wf_definition_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.machine_id as machine_id,
dbfi.approveStatus,
dbdl.machine_code,dbdl.machine_name,dbdl.machine_location,dbdl.machine_spec
from dms_bills_fault_instance dbfi
left join prod_base_machine_info dbdl on dbfi.machine_id = dbdl.machine_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="machineId != null and machineId != ''"> and machine_id = #{machineId}</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.wf_definition_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.machine_id,dbfi.approveStatus,
dbdl.machine_code,dbdl.machine_name,dbdl.machine_location,dbdl.machine_spec,
dfia.instance_activity_id,dfia.fault_type,dfia.fault_description,dfia.design_operations,dfia.repair_type,
dfia.outsourcing_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 prod_base_machine_info dbdl on dbfi.machine_id=dbdl.machine_id
left join dms_fault_instance_activity dfia on dbfi.repair_instance_id=dfia.repair_instance_id
where dbfi.repair_instance_id = #{repairInstanceId}
&lt;!&ndash; and dfia.process_step_order=1 &ndash;&gt;
and dfia.process_step_order=2
</select>-->
<select id="selectFaultInstanceJoinFirstAndDeviceById" parameterType="Long" resultMap="DmsBillsFaultInstanceResult">
select dbfi.repair_instance_id, dbfi.fault_source_type, dbfi.fault_source_id,
dbfi.wf_definition_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.machine_id,dbfi.approveStatus,
dbdl.machine_code,dbdl.machine_name,dbdl.machine_location,dbdl.machine_spec,
dfia.instance_activity_id,dfia.fault_type,dfia.fault_description,dfia.design_operations,dfia.repair_type,
dfia.outsourcing_id,
dfia.process_handle_resolution
,dfia.checked_fault checked_fault,
dfia.repair_content repair_content,
dfia.protected_method protected_method,
dfia.repairer repairer,
dbfi.repair_confirm repair_confirm,
dfia.confirm_time confirm_time,dfia.components_parts_id components_parts_id
from dms_bills_fault_instance dbfi
left join prod_base_machine_info dbdl on dbfi.machine_id=dbdl.machine_id
left join dms_fault_instance_activity dfia on (dbfi.repair_instance_id=dfia.repair_instance_id
and dfia.instance_activity_id = (
select max(instance_activity_id)
from dms_fault_instance_activity dfia2
where dfia2.repair_instance_id = dbfi.repair_instance_id
and dfia2.process_step_order = (
select max(process_step_order)
from dms_fault_instance_activity dfia3
where dfia3.repair_instance_id = dbfi.repair_instance_id
)
))
where dbfi.repair_instance_id = #{repairInstanceId}
</select>
<select id="selectFaultInstanceJoinActivityByRepairInstanceId" parameterType="Long" resultMap="DmsBillsFaultInstanceDmsFaultInstanceActivityResult">
select a.repair_instance_id, a.fault_source_type, a.fault_source_id,
a.wf_definition_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.remark, a.create_by, a.create_time, a.update_by, a.update_time,a.approveStatus,dbdl.machine_code,dbdl.machine_name,dbdl.machine_location,dbdl.machine_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.machine_id as sub_machine_id,
b.repair_type as sub_repair_type,
b.outsourcing_id as outsourcing_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 prod_base_machine_info dbdl on a.machine_id = dbdl.machine_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 prod_base_machine_info dbdl
where dbfi.machine_id=dbdl.machine_id and dbdl.machine_code=#{machineCode})
</select>
<select id="selectFaultInstanceJoinFirstById" parameterType="Long" resultMap="DmsBillsFaultInstanceResult">
select dbfi.repair_instance_id, dbfi.fault_source_type, dbfi.fault_source_id,
dbfi.wf_definition_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.machine_id,
dfia.instance_activity_id,dfia.fault_type,dfia.fault_description,dfia.design_operations,dfia.repair_type,dfia.outsourcing_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="org.dromara.dms.domain.vo.DmsFaultInstanceActivityVo"
parameterType="java.lang.Long">
select
x.fault_description ,
x.checked_fault ,
x.process_handle_resolution,
x.repair_content ,
x.protected_method ,
x.repairer ,
a.machine_name ,
a.machine_code,
a.machine_location ,
b.apply_user ,
b.apply_time ,
b.real_begin_time ,
b.real_end_time,
b.repair_confirm,
b.update_time,
b.confirm_user
from
dms_fault_instance_activity x
left join prod_base_machine_info a on x.machine_id = a.machine_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="org.dromara.dms.domain.vo.DmsFaultComponentsPartsVo"
parameterType="java.lang.Long">
SELECT x.* FROM dms_fault_components_parts x where x.repair_instance_id = #{repairInstanceId}
</select>
<select id="selectDmsBillsFaultInstanceCompletedList" resultType="org.dromara.dms.domain.vo.DmsBillsFaultInstanceVo"
parameterType="org.dromara.dms.domain.DmsBillsFaultInstance">
select repair_instance_id, fault_source_type, fault_source_id, wf_definition_id, bills_fault_code, bills_status, apply_user, apply_time, real_begin_time, real_end_time, require_end_time, instance_type, remark, create_by, create_time, update_by, update_time,machine_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="wfDefinitionId != null "> and wf_definition_id = #{wfDefinitionId}</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="machineId != null and machineId != ''"> and machine_id = #{machineId}</if>
</where>
order by create_time desc
</select>
<select id="getDmsPartsList" resultType="org.dromara.dms.domain.vo.DmsFaultComponentsPartsVo"
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>