AnalysisResultMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.energy.manage.service.mappers.analysis.AnalysisResultMapper">
  4. <resultMap id="BaseResultMap" type="com.energy.manage.common.po.analysis.AnalysisResultPo">
  5. <id column="id" property="id" jdbcType="BIGINT"/>
  6. <result column="batch_code" property="batchCode" jdbcType="VARCHAR"/>
  7. <result column="analysis_state" property="analysisState" jdbcType="INTEGER"/>
  8. <result column="err_state" property="errState" jdbcType="INTEGER"/>
  9. <result column="err_code" property="errCode" jdbcType="VARCHAR"/>
  10. <result column="err_info" property="errInfo" jdbcType="VARCHAR"/>
  11. <result column="create_by" property="createBy" jdbcType="INTEGER"/>
  12. <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
  13. <result column="update_by" property="updateBy" jdbcType="INTEGER"/>
  14. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  15. <result column="analysis_progress" property="analysisProgress" jdbcType="DECIMAL"/>
  16. <result column="call_status" property="callStatus" jdbcType="INTEGER"/>
  17. <result column="on_off_call" property="onOffCall" jdbcType="INTEGER"/>
  18. <result column="field_code" property="fieldCode" jdbcType="VARCHAR"/>
  19. <result column="analysis_name" property="analysisName" jdbcType="VARCHAR"/>
  20. <result column="data_start_time" property="dataStartTime" jdbcType="DATE"/>
  21. <result column="data_end_time" property="dataEndTime" jdbcType="DATE"/>
  22. <result column="sketch" property="sketch" jdbcType="VARCHAR"/>
  23. <result column="data_type_code" property="dataTypeCode" jdbcType="VARCHAR"/>
  24. <result column="analysis_start_time" property="analysisStartTime" jdbcType="DATE"/>
  25. <result column="analysis_finish_time" property="analysisFinishTime" jdbcType="DATE"/>
  26. </resultMap>
  27. <select id="selectByCondition" parameterType="com.energy.manage.service.domain.dto.analysis.AnalysisResultDto" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisResultVo">
  28. select
  29. result.*,
  30. field.field_name
  31. from analysis_result result
  32. left join sys_organization_auth auth
  33. on result.field_code = auth.code_number
  34. left join wind_field field
  35. on result.field_code = field.field_code
  36. where auth.role_id = #{roleId,jdbcType=INTEGER}
  37. <if test="fieldName != null and fieldName != ''">
  38. and field.field_name like concat('%', #{fieldName,jdbcType=VARCHAR}, '%')
  39. </if>
  40. <if test="analysisName != null and analysisName != ''">
  41. and result.analysis_name like concat('%', #{analysisName,jdbcType=VARCHAR}, '%')
  42. </if>
  43. <if test="analysisState != null">
  44. and result.analysis_state = #{analysisState}
  45. </if>
  46. <if test="errState != null">
  47. and result.err_state = #{errState}
  48. </if>
  49. order by result.update_time desc
  50. </select>
  51. <select id="selectByFieldCode" parameterType="java.lang.String" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisResultVo">
  52. select
  53. field.field_name,
  54. result.field_code,
  55. result.batch_code,
  56. result.analysis_state,
  57. result.err_state,
  58. result.err_info,
  59. result.create_time,
  60. result.analysis_progress,
  61. result.on_off_call,
  62. result.analysis_name,
  63. result.data_start_time,
  64. result.data_end_time,
  65. result.sketch,
  66. result.data_type_code,
  67. result.analysis_start_time,
  68. result.analysis_finish_time,
  69. type.transfer_type_name as data_type_name
  70. from analysis_result result
  71. left join wind_field field
  72. on result.field_code = field.field_code
  73. left join data_transfer_type type
  74. on result.data_type_code = type.transfer_type
  75. where result.field_code = #{fieldCode}
  76. order by result.update_time desc
  77. </select>
  78. <select id="selectAlasisingCount" resultType="int">
  79. select count(*)
  80. from analysis_result
  81. where analysis_state in (10,20)
  82. </select>
  83. <select id="selectShortInfoByFieldCode" parameterType="java.lang.String" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisInfoVo">
  84. select batch_code, analysis_name from analysis_result where field_code = #{fieldCode}
  85. </select>
  86. <select id="selectByBatchCode" parameterType="java.lang.String" resultMap="BaseResultMap">
  87. select *
  88. from analysis_result
  89. where batch_code = #{batchCode,jdbcType=VARCHAR}
  90. </select>
  91. <select id="selectLastBatchResultByFieldCode" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisResultVo">
  92. select *
  93. from analysis_result
  94. where id in (
  95. select max( id )
  96. from analysis_result
  97. group by field_code
  98. having field_code in
  99. <foreach collection="fieldCodes" item="item" separator="," open="(" close=")">
  100. #{item,jdbcType=VARCHAR}
  101. </foreach>
  102. )
  103. <if test="startTime != null and endTime != null">
  104. and analysis_start_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  105. </if>
  106. </select>
  107. <select id="selectAnalysisingCount" resultType="int">
  108. select count(*) from analysis_result where analysis_state = 10 or analysis_state = 20
  109. </select>
  110. <select id="selectAnalysisProcessingCount" resultType="int">
  111. select count(*) from analysis_result where analysis_state = 20
  112. </select>
  113. <select id="selectFieldCode" parameterType="com.energy.manage.service.domain.dto.analysis.AnalysisResultDto" resultType="com.energy.manage.common.po.windfield.WindFieldPO">
  114. select
  115. result.field_code,
  116. field.field_name
  117. from analysis_result result
  118. left join wind_field field
  119. on result.field_code = field.field_code
  120. left join sys_organization_auth auth
  121. on result.field_code = auth.code_number
  122. where auth.role_id = #{roleId}
  123. <if test="analysisName != null and analysisName != ''">
  124. and result.analysis_name like concat('%',#{analysisName},'%')
  125. </if>
  126. <if test="batchCode != null">
  127. and result.batch_code = #{batchCode};
  128. </if>
  129. <if test="fieldName != null and fieldName != ''">
  130. and field.field_name like concat('%',#{fieldName},'%')
  131. </if>
  132. group by result.field_code, field.field_name
  133. order by result.update_time desc
  134. </select>
  135. <update id="updateOnOffCall">
  136. update analysis_result
  137. set on_off_call = #{onOffCall,jdbcType=INTEGER}
  138. where batch_code = #{batchCode,jdbcType=VARCHAR}
  139. </update>
  140. <update id="updateCallStatus" parameterType="java.lang.String">
  141. update analysis_result
  142. set call_status = 1
  143. where batch_code = #{batchCode,jdbcType=VARCHAR}
  144. </update>
  145. <update id="updateAnalysisState" parameterType="java.lang.String">
  146. update analysis_result
  147. set analysis_state = 10,
  148. err_state = 0,
  149. err_code = '',
  150. err_info = '',
  151. analysis_progress = 0.00,
  152. data_start_time = null,
  153. data_end_time = null,
  154. data_type_code = '',
  155. analysis_start_time = null,
  156. analysis_finish_time = null
  157. where analysis_state = -1 or analysis_state = 30
  158. and batch_code = #{batchCode,jdbcType=VARCHAR}
  159. </update>
  160. <update id="updateByBatchCode" parameterType="com.energy.manage.service.domain.dto.analysis.AnalysisDto">
  161. update analysis_result
  162. set
  163. err_state = 0,
  164. err_code = '',
  165. err_info = '',
  166. data_start_time = #{beginTime,jdbcType=INTEGER},
  167. data_end_time = #{endTime,jdbcType=VARCHAR},
  168. data_type_code = #{scada,jdbcType=VARCHAR},
  169. analysis_start_time = now(),
  170. update_time = now(),
  171. update_by = #{updateBy,jdbcType=INTEGER}
  172. where batch_code = #{dataBatchNum,jdbcType=VARCHAR}
  173. </update>
  174. </mapper>