zss
2025-03-07 12291480d592402398c3ba76e8de6006da5c2612
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?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.ruoyi.personnel.mapper.PersonSupervisionRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.personnel.pojo.PersonSupervisionRecord">
        <id column="id" property="id" />
        <result column="tester_id" property="testerId" />
        <result column="supervisor_id" property="supervisorId" />
        <result column="test_item" property="testItem" />
        <result column="sample_number" property="sampleNumber" />
        <result column="detection_date" property="detectionDate" />
        <result column="personnel" property="personnel" />
        <result column="instrument_equipment" property="instrumentEquipment" />
        <result column="working_environment" property="workingEnvironment" />
        <result column="sample_collection" property="sampleCollection" />
        <result column="sample_preparation" property="samplePreparation" />
        <result column="test_method" property="testMethod" />
        <result column="test_report" property="testReport" />
        <result column="evaluation_supervision_situation" property="evaluationSupervisionSituation" />
        <result column="do_not_meet_the_handling_opinions" property="doNotMeetTheHandlingOpinions" />
        <result column="technical_director" property="technicalDirector" />
        <result column="technical_director_date" property="technicalDirectorDate" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_user" property="createUser" />
        <result column="update_user" property="updateUser" />
    </resultMap>
 
    <select id="personSupervisionRecordPage" resultType="com.ruoyi.personnel.dto.PersonSupervisionRecordDto">
        select cpsr.*, u1.name tester_name, u2.name supervisor_name, u3.name technical_director_name,
        cp.personnel_name, cpscs.current_state current_state_control, cpscs.corrective_measure, cpsps.current_state current_state_processing,u2.depart_lims_id
        from cnas_person_supervision_record cpsr
        left join user u1 on cpsr.tester_id = u1.id
        left join user u2 on cpsr.supervisor_id = u2.id
        left join user u3 on cpsr.technical_director = u3.id
        left join (
        select GROUP_CONCAT(u.name) personnel_name, cp.id
        from cnas_person_supervision_record cp
        left join user u on FIND_IN_SET(u.id, cp.personnel)
        GROUP BY cp.id
        ) cp on cp.id = cpsr.id
        left join cnas_person_supervision_control_sheet cpscs on cpscs.supervision_record_id = cpsr.id
        left join cnas_person_supervision_processing_sheet cpsps on cpsps.supervision_record_id = cpsr.id
        <where>
            <if test="userId != null and userId != ''">
                and cpsr.supervisor_id = #{userId}
            </if>
            <if test="departLimsId != null and departLimsId != ''">
                <!--and FIND_IN_SET(#{departLimsId}, u2.depart_lims_id)-->
                and cpsr.depart_lims_id = #{departLimsId}
            </if>
            <if test="userName != null and userName != ''">
                and u2.name like concat('%', #{userName}, '%')
            </if>
        </where>
        order by cpsr.id desc
    </select>
 
    <!-- 查询监督记录详情 -->
    <select id="selectPersonSupervisionRecord" resultType="com.ruoyi.personnel.dto.PersonSupervisionRecordDto">
        select cpsr.*, u1.name tester_name, u2.name supervisor_name, u3.name technical_director_name,
               cp.personnel_name, cpscs.current_state current_state_control, cpsps.current_state current_state_processing
        from cnas_person_supervision_record cpsr
                 left join user u1 on cpsr.tester_id = u1.id
                 left join user u2 on cpsr.supervisor_id = u2.id
                 left join user u3 on cpsr.technical_director = u3.id
                 left join (
            select GROUP_CONCAT(u.name) personnel_name, cp.id
            from cnas_person_supervision_record cp
                     left join user u on FIND_IN_SET(u.id, cp.personnel)
            GROUP BY cp.id
        ) cp on cp.id = cpsr.id
                 left join cnas_person_supervision_control_sheet cpscs on cpscs.supervision_record_id = cpsr.id
                 left join cnas_person_supervision_processing_sheet cpsps on cpsps.supervision_record_id = cpsr.id
        where cpsr.id = #{id}
    </select>
</mapper>