cuijian
2023-08-19 bdd0875d4b13a3f1ef472f64d4b6a95e0ef64b22
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
79
80
81
82
83
<?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.jeecg.modules.eam.mapper.InspectionCycleMapper">
 
    <select id="page" resultType="Map">
        select
        t1.id id,
        t1.code code,
        concat(t1.cycle,t2.item_text) name,
        t1.version version,
        t1.create_by createBy,
        t1.create_time createTime,
        t1.update_by updateBy,
        t1.update_time updateTime,
        t1.version_status versionStatus,
        t1.cycle cycle,
        t1.cycle_unit cycleUnit,
        t1.unit unit,
        t1.start_condition startCondition,
        t1.arrange_way arrangeWay,
        t1.audit_status auditStatus,
        t1.first_inspection_time as firstInspectionTime,
        DATE_FORMAT(t1.first_inspection_time, '%Y-%m-%d') firstInspectionTime1,
        DATE_FORMAT(t1.first_inspection_time, '%h:%i:%s') firstInspectionTime2,
        t1.lead_time leadTime,
        t1.effective_time effectiveTime,
        t2.item_text cycleUnitName,
        t3.item_text unitName,
        t4.item_text startConditionName,
        t5.item_text arrangeWayName,
        t6.item_text versionStatusName,
        t1.overdue_dispose_mode as overdueDisposeMode,
        t1.according_calendar as accordingCalendar,
        t8.item_text overdueDisposeModeName,
        t9.item_text accordingCalendarName
        from mom_eam_inspection_cycle t1
        left join (select * from v_sys_dict where dict_code = 'cycle_unit') t2 on t1.cycle_unit=t2.item_value
        left join (select * from v_sys_dict where dict_code = 'cycle_time_unit') t3 on t1.unit=t3.item_value
        left join (select * from v_sys_dict where dict_code = 'start_condition') t4 on t1.start_condition=t4.item_value
        left join (select * from v_sys_dict where dict_code = 'arrange_way') t5 on t1.arrange_way=t5.item_value
        left join (select * from v_sys_dict where dict_code = 'version_status') t6 on t1.version_status=t6.item_value
        left join (select * from v_sys_dict where dict_code = 'overdue_dispose_mode') t8 on t1.overdue_dispose_mode=t8.item_value
        left join (select * from v_sys_dict where dict_code = 'according_calendar') t9 on t1.according_calendar=t9.item_value
        where 1=1
        <if test="inspectionCycle.version!=null and inspectionCycle.version!= ''">
            and t1.version=#{inspectionCycle.version}
        </if>
        <if test="inspectionCycle.versionStatus!=null and inspectionCycle.versionStatus!= ''">
            and t1.version_status=#{inspectionCycle.versionStatus}
        </if>
        <if test="inspectionCycle.versionStatus == null ">
            and t1.version_status='2'
        </if>
        <if test="inspectionCycle.enterpriseId!=null and inspectionCycle.enterpriseId!= ''">
            and t1.enterprise_id=#{inspectionCycle.enterpriseId}
        </if>
        <if test="inspectionCycle.code!=null and inspectionCycle.code!= ''">
            and t1.code like concat('%',#{inspectionCycle.code},'%')
        </if>
        <if test="inspectionCycle.name!=null and inspectionCycle.name!= ''">
            and t1.name like concat('%',#{inspectionCycle.name},'%')
        </if>
        order by t1.create_time desc
    </select>
 
    <select id="getAllVersion" resultType="Integer">
        select
        version
        from mom_eam_inspection_cycle
        where del_flag = 0
    </select>
 
    <select id="getUsableVersion" resultType="Integer">
        select
        t1.version version
        from mom_eam_inspection_cycle t1
        left join
        (select * from mom_sys_data_version where business_type='点检周期' and del_flag=0) t2
        on t1.id = t2.business_id
        where t2.version_status='2'
        and t1.del_flag=0
    </select>
</mapper>