郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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
<?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.gk.hotwork.Mapper.RiskAnaUintMapper">
  <resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.RiskAnaUnit">
    <!--          -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="hazard_code" jdbcType="VARCHAR" property="hazardCode" />
    <result column="hazard_dep" jdbcType="VARCHAR" property="hazardDep" />
    <result column="hazard_liable_person" jdbcType="VARCHAR" property="hazardLiablePerson" />
    <result column="risk_uint_name" jdbcType="VARCHAR" property="riskUnitName" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="valid_flag" jdbcType="TINYINT" property="validFlag" />
    <result column="hazard_liable_person_id" jdbcType="BIGINT" property="hazardLiablePersonId" />
    <result column="hazard_dep_id" jdbcType="BIGINT" property="hazardDepId" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--          -->
    id, hazard_code, hazard_dep, hazard_liable_person, risk_unit_name, create_time, update_time,
    create_by, update_by, valid_flag, hazard_liable_person_id, hazard_dep_id
  </sql>
  <select id="selectPages" resultType="com.gk.hotwork.Domain.RiskAnaUnit">
    select
    rau.id,
    rau.hazard_code,
    u.realname hazard_liable_person,
    rau.risk_unit_name,
    rau.create_time,
    rau.update_time,
    rau.create_by,
    rau.update_by,
    rau.valid_flag,
    rau.hazard_liable_person_id,
    rau.hazard_dep_id,
    d.department hazard_dep
    from risk_ana_unit as rau
    left join department as d on d.id = rau.hazard_dep_id and d.isdel = 0
    left join user as u on u.id = rau.hazard_liable_person_id
    where rau.valid_flag = 1
    <if test="params.riskUnitName != null and params.riskUnitName  != ''">
      and rau.risk_unit_name like concat("%",#{params.riskUnitName},"%")
    </if>
    <if test="params.hazardDep != null and params.hazardDep  != ''">
      and d.department  like concat("%",#{params.hazardDep},"%")
    </if>
    <if test="params.hazardLiablePerson != null and params.hazardLiablePerson  != ''">
      and u.realname like concat("%",#{params.hazardLiablePerson},"%")
    </if>
  </select>
  <select id="selectDepartmentAnalysis" resultType="java.util.Map">
    select count(0) count,d.department
    from  risk_ana_unit as rau
    left join department as d on d.id = rau.hazard_dep_id and d.isdel = 0
    group by d.id
  </select>
 
  <select id="getInfo" resultType="com.gk.hotwork.Domain.RiskAnaUnit">
    select
    a.hazard_code,
    u.realname hazard_liable_person,
    a.risk_unit_name,
    b.department hazard_dep
    from risk_ana_unit as a
    left join department as b on b.id = a.hazard_dep_id and b.isdel = 0
    left join user as u on u.id = a.hazard_liable_person_id
    where valid_flag = 1
  </select>
 
<!--  RiskAnaUnit getInfoByRiskUnitName(String riskUnitName);-->
  <select id="getInfoByRiskUnitName" resultType="com.gk.hotwork.Domain.RiskAnaUnit">
    select * from risk_ana_unit where valid_flag = 1 and risk_unit_name = #{riskUnitName}
  </select>
</mapper>