feiyu02
2025-03-28 7d74f3fd087d4a8192ed556a6c2e3a2ea3c81cff
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?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="cn.flightfeather.supervision.domain.ds1.mapper.InspectionMapper" >
  <resultMap id="BaseResultMap" type="cn.flightfeather.supervision.domain.ds1.entity.Inspection" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="I_GUID" property="guid" jdbcType="VARCHAR" />
    <result column="ST_GUID" property="stguid" jdbcType="VARCHAR" />
    <result column="S_GUID" property="sguid" jdbcType="VARCHAR" />
    <result column="I_ScenseName" property="scensename" jdbcType="VARCHAR" />
    <result column="I_ScenseAddress" property="scenseaddress" jdbcType="VARCHAR" />
    <result column="I_IsTogether" property="istogether" jdbcType="BIT" />
    <result column="I_EntourageT" property="entouraget" jdbcType="VARCHAR" />
    <result column="I_EntourageWX" property="entouragewx" jdbcType="VARCHAR" />
    <result column="I_Entourage" property="entourage" jdbcType="VARCHAR" />
    <result column="I_ExecutionStartTime" property="executionstarttime" jdbcType="TIMESTAMP" />
    <result column="I_ExecutionEndTime" property="executionendtime" jdbcType="TIMESTAMP" />
    <result column="I_ProblemCount" property="problemcount" jdbcType="INTEGER" />
    <result column="I_IsRechecked" property="isrechecked" jdbcType="BIT" />
    <result column="I_RecheckCount" property="recheckcount" jdbcType="INTEGER" />
    <result column="I_PromissedNum" property="promissednum" jdbcType="INTEGER" />
    <result column="I_ChangedNum" property="changednum" jdbcType="INTEGER" />
    <result column="I_IsChanged" property="ischanged" jdbcType="BIT" />
    <result column="I_IsRvaluated" property="isrvaluated" jdbcType="BIT" />
    <result column="I_isPromissed" property="ispromissed" jdbcType="BIT" />
    <result column="I_PromissedTime" property="promissedtime" jdbcType="TIMESTAMP" />
    <result column="I_PromissedUserGUID" property="promisseduserguid" jdbcType="VARCHAR" />
    <result column="I_PromissedUserName" property="promissedusername" jdbcType="VARCHAR" />
    <result column="I_PromissedUserRealName" property="promisseduserrealname" jdbcType="VARCHAR" />
    <result column="I_PromissedWay" property="promissedway" jdbcType="VARCHAR" />
    <result column="I_PromissedDeadline" property="promisseddeadline" jdbcType="TIMESTAMP" />
    <result column="I_PromissBookPath" property="promissbookpath" jdbcType="VARCHAR" />
    <result column="I_SignPath" property="signpath" jdbcType="VARCHAR" />
    <result column="I_Extension1" property="extension1" jdbcType="VARCHAR" />
    <result column="I_Extension2" property="extension2" jdbcType="VARCHAR" />
    <result column="I_Extension3" property="extension3" jdbcType="VARCHAR" />
    <result column="I_Remark" property="remark" jdbcType="VARCHAR" />
  </resultMap>
 
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbg.generated
    -->
    I_GUID, ST_GUID, S_GUID, I_ScenseName, I_ScenseAddress, I_IsTogether, I_EntourageT, 
    I_EntourageWX, I_Entourage, I_ExecutionStartTime, I_ExecutionEndTime, I_ProblemCount, 
    I_IsRechecked, I_RecheckCount, I_PromissedNum, I_ChangedNum, I_IsChanged, I_IsRvaluated, 
    I_isPromissed, I_PromissedTime, I_PromissedUserGUID, I_PromissedUserName, I_PromissedUserRealName, 
    I_PromissedWay, I_PromissedDeadline, I_PromissBookPath, I_SignPath, I_Extension1, 
    I_Extension2, I_Extension3, I_Remark
  </sql>
 
    <resultMap id="InspectionStatisticVo" type="cn.flightfeather.supervision.lightshare.vo.InspectionStatisticVo" >
        <id column="MOV_DisplayID" property="index" jdbcType="INTEGER" />
        <result column="S_GUID" property="sceneId" jdbcType="VARCHAR" />
        <result column="ST_GUID" property="subTaskId" jdbcType="VARCHAR" />
        <result column="S_Name" property="sceneName" jdbcType="VARCHAR" />
        <result column="projectType" property="projectType" jdbcType="VARCHAR" />
        <result column="S_Location" property="location" jdbcType="VARCHAR" />
        <result column="status" property="status" jdbcType="VARCHAR" />
        <result column="S_TownName" property="town" jdbcType="VARCHAR" />
        <result column="E_ResultScoreBef" property="score" jdbcType="VARCHAR" />
        <result column="rate" property="rate" jdbcType="VARCHAR" />
        <result column="problems" property="problem" jdbcType="VARCHAR" />
    </resultMap>
 
    <resultMap id="InspectionInfoVo" type="cn.flightfeather.supervision.lightshare.vo.InspectionInfoVo" >
        <id column="inspectionId" property="inspectionId" />
        <result column="topTaskid" property="topTaskid"/>
        <result column="topTaskName" property="topTaskName"/>
        <result column="sceneId" property="sceneId"/>
        <result column="sceneName" property="sceneName"/>
        <result column="subtaskId" property="subtaskId"/>
        <result column="inspected" property="inspected"/>
        <result column="inspectionTime" property="inspectionTime"/>
        <result column="inspectionTimes" property="inspectionTimes"/>
        <result column="promised" property="promised"/>
        <result column="changed" property="changed"/>
        <result column="unChangedCount" property="unChangedCount"/>
        <result column="changedCount" property="changedCount"/>
        <result column="inspectionTimes" property="inspectionTimes"/>
        <result column="promisedTime" property="promisedTime"/>
    </resultMap>
 
  <select id="getInspectionInfoByScene" resultMap="InspectionInfoVo">
    SELECT
        a.T_GUID AS topTaskId,
        a.T_Name AS topTaskName,
        b.ST_ScenseID AS sceneId,
        b.ST_ScenseName AS sceneName,
        c.I_GUID AS inspectionId,
        b.ST_GUID AS subtaskId,
        (CASE WHEN COUNT(DISTINCT c.I_GUID) > 0 THEN TRUE ELSE FALSE END) AS inspected,
        c.I_ExecutionStartTime AS inspectionTime,
        COUNT(DISTINCT c.I_GUID) AS inspectionTimes,
        (CASE WHEN (SUM(CASE WHEN d.PL_Extension1 IS NULL THEN 0 ELSE 1 END)) > 0 THEN TRUE ELSE FALSE END) AS promised,
        CASE WHEN SUM(d.PL_IsChanged) = COUNT(d.PL_IsChanged) THEN TRUE ELSE FALSE END AS changed,
      COUNT(CASE WHEN d.PL_IsChanged = 0 AND d.PL_Extension3 = 'pass' THEN 1 ELSE NULL END) AS unChangedCount,
      COUNT(CASE WHEN d.PL_IsChanged = 1 THEN 1 ELSE NULL END) AS changedCount,
      d.PL_Extension1 AS promisedTime
    FROM
        tm_t_task AS a
    LEFT JOIN tm_t_subtask AS b ON a.T_GUID = b.T_GUID
    LEFT JOIN im_t_inspection AS c ON b.ST_GUID = c.ST_GUID
    LEFT JOIN im_t_problemlist AS d ON c.I_GUID = d.I_GUID
    WHERE
        b.ST_ScenseID = #{param1}
    AND a.T_GUID = #{param2}
    GROUP BY
        c.I_GUID
    ORDER BY
        c.I_ExecutionStartTime DESC
  </select>
 
  <select id="getStatistic" resultMap="InspectionStatisticVo">
      SELECT e.S_GUID,
      b.ST_GUID,
      e.MOV_DisplayID,
      a.S_Name,
      a.S_Location,
      <choose>
          <when test="param2 == 1">
             f.CS_Project_Type as projectType,
             f.CS_Status as status,
          </when>
          <when test="param2 == 2">
             f.W_Project_Type as projectType,
             f.W_Status as status,
          </when>
          <when test="param2 == 3">
             f.MP_Status as status,
          </when>
          <when test="param2 == 14">
             f.SY_Project_Type as projectType,
             f.SY_Status as status,
          </when>
      </choose>
      a.S_TownName,
      c.E_ResultScoreBef,
      GROUP_CONCAT(CONCAT(d.PL_ProblemName, (IF(d.PL_IsChanged = TRUE, '(已整改)', ''))) SEPARATOR '\n') as problems
      FROM sm_t_monitorobjectversion as e
      LEFT JOIN sm_t_scense AS a on e.S_GUID = a.S_GUID
      LEFT JOIN tm_t_subtask AS b ON a.S_GUID = b.ST_ScenseID
      LEFT JOIN ea_t_evaluation AS c ON b.ST_GUID = c.ST_GUID
      LEFT JOIN im_t_problemlist AS d ON b.ST_GUID = d.ST_GUID
      <choose>
          <when test="param2 == 1">
              LEFT JOIN sm_t_scene_construction_site f on a.S_GUID = f.S_GUID
          </when>
          <when test="param2 == 2">
              LEFT JOIN sm_t_scene_wharf f on a.S_GUID = f.S_GUID
          </when>
          <when test="param2 == 3">
              LEFT JOIN sm_t_scene_mixing_plant f on a.S_GUID = f.S_GUID
          </when>
          <when test="param2 == 14">
              LEFT JOIN sm_t_scene_storage_yard f on a.S_GUID = f.S_GUID
          </when>
      </choose>
 
      WHERE e.T_ID = #{param1}
      and a.S_TypeID = #{param2}
      AND b.T_GUID = #{param1}
      GROUP BY e.S_GUID
      ORDER BY e.MOV_DisplayID;
 
 
  </select>
</mapper>