yangys
2024-01-29 3ef1c88e46ba88f46e70377b158062096dd286e0
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
84
85
86
87
88
89
90
<?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.qianwen.mdc.mapper.MachineMaintainMapper">
  <resultMap id="BaseResultMap" type="com.qianwen.mdc.domain.maintain.MachineMaintain">
 
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="machine_id" jdbcType="INTEGER" property="machineId" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="machine_account_id" jdbcType="INTEGER" property="machineAccountId" />
    <result column="style" jdbcType="INTEGER" property="style" />
    <result column="period" jdbcType="VARCHAR" property="period" />
    <result column="start_date_from" jdbcType="TIMESTAMP" property="startDateFrom" />
    <result column="start_date_to" jdbcType="TIMESTAMP" property="startDateTo" />
    <result column="complete_date_from" jdbcType="TIMESTAMP" property="completeDateFrom" />
    <result column="complete_date_to" jdbcType="TIMESTAMP" property="completeDateTo" />
    <result column="is_qualified" jdbcType="BIT" property="isQualified" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="detail" jdbcType="VARCHAR" property="detail" />
    <result column="department" jdbcType="INTEGER" property="department" />
  </resultMap>
  
  <resultMap id="FullResultMap" type="com.qianwen.mdc.dto.MachineMaintainFullDTO">
 
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="machine_id" jdbcType="INTEGER" property="machineId" />
    <result column="machine_name" jdbcType="VARCHAR" property="machineName" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
    <result column="machine_account_id" jdbcType="INTEGER" property="machineAccountId" />
    <result column="style" jdbcType="INTEGER" property="style" />
    <result column="uuid" jdbcType="VARCHAR" property="uuid" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="period" jdbcType="VARCHAR" property="period" />
    <result column="start_date_from" jdbcType="TIMESTAMP" property="startDateFrom" />
    <result column="start_date_to" jdbcType="TIMESTAMP" property="startDateTo" />
    <result column="complete_date_from" jdbcType="TIMESTAMP" property="completeDateFrom" />
    <result column="complete_date_to" jdbcType="TIMESTAMP" property="completeDateTo" />
    <result column="is_qualified" jdbcType="BIT" property="isQualified" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="detail" jdbcType="VARCHAR" property="detail" />
    <result column="department" jdbcType="VARCHAR" property="department" />
    <result column="department_name" jdbcType="VARCHAR" property="departmentName" />
    <result column="specification" jdbcType="VARCHAR" property="specification" />
   
  </resultMap>
  
  <select id="queryPage" resultMap="FullResultMap">
      SELECT mm.id,mm.machine_id,ma.machine_name,mm.user_id,u.name user_name,style,mm.department,ud.name department_name,ma.uuid,ma.type,
      ma.specification,
      start_date_from,start_date_to,complete_date_from,complete_date_to,is_qualified,mm.status,mm.detail
      FROM machine_maintain mm left join machine m on mm.machine_id=m.id left join sys_account u on mm.user_id=u.id
      left join machine_account ma on m.id=ma.machine_id
      left join use_department ud on mm.department=ud.id
      <where>
            <if test="dto.uuid != null and dto.uuid != ''">
               <bind name="uuid" value="'%' + dto.uuid + '%'" />
           and ma.uuid like #{uuid}
         </if>
         <if test="dto.type != null and dto.type != ''">
             <bind name="type" value="'%' + dto.type + '%'" />
           and ma.type like #{type}
         </if>
         <if test="dto.style != null">
           and mm.style=#{dto.style}
         </if>
         <if test="dto.department != null">
           and mm.department=#{dto.department}
         </if>
         <if test="dto.machineId != null">
           and mm.machine_id=#{dto.machineId}
         </if>
         <if test="dto.isQualified != null">
           and mm.is_qualified=#{dto.isQualified}
         </if>
         
         <if test="dto.startDateFrom != null">
           and (mm.start_date_from&gt;=#{dto.startDateFrom} or mm.start_date_to &lt;=#{dto.startDateFrom})
         </if>
         <if test="dto.startDateTo != null">
           and mm.start_date_to&lt;=#{dto.startDateTo}
         </if>
         <if test="dto.completeDateFrom != null">
           and (mm.complete_date_from&gt;=#{dto.completeDateFrom} or mm.complete_date_to &lt;=#{dto.completeDateFrom})
         </if>
         <if test="dto.completeDateTo != null">
           and mm.complete_date_to&lt;=#{dto.completeDateTo}
         </if>
      </where>
  </select>
</mapper>