TQtdevinfoValueMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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.chinaitop.depot.intelligent.grainsituation.mapper.TQtdevinfoValueMapper" >
  4. <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.grainsituation.model.TQtdevinfoValue" >
  5. <result column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="org_id" property="orgId" jdbcType="VARCHAR" />
  7. <result column="v_cf_code" property="vCfCode" jdbcType="VARCHAR" />
  8. <result column="v_dev_code" property="vDevCode" jdbcType="VARCHAR" />
  9. <result column="v_value_time" property="vValueTime" jdbcType="TIMESTAMP" />
  10. <result column="cpo_avg" property="cpoAvg" jdbcType="DECIMAL" />
  11. <result column="v_dev_kind_code" property="vDevKindCode" jdbcType="VARCHAR" />
  12. <result column="data_source" property="dataSource" jdbcType="VARCHAR" />
  13. </resultMap>
  14. <sql id="Example_Where_Clause" >
  15. <where >
  16. <foreach collection="oredCriteria" item="criteria" separator="or" >
  17. <if test="criteria.valid" >
  18. <trim prefix="(" suffix=")" prefixOverrides="and" >
  19. <foreach collection="criteria.criteria" item="criterion" >
  20. <choose >
  21. <when test="criterion.noValue" >
  22. and ${criterion.condition}
  23. </when>
  24. <when test="criterion.singleValue" >
  25. and ${criterion.condition} #{criterion.value}
  26. </when>
  27. <when test="criterion.betweenValue" >
  28. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  29. </when>
  30. <when test="criterion.listValue" >
  31. and ${criterion.condition}
  32. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  33. #{listItem}
  34. </foreach>
  35. </when>
  36. </choose>
  37. </foreach>
  38. </trim>
  39. </if>
  40. </foreach>
  41. </where>
  42. </sql>
  43. <sql id="Update_By_Example_Where_Clause" >
  44. <where >
  45. <foreach collection="example.oredCriteria" item="criteria" separator="or" >
  46. <if test="criteria.valid" >
  47. <trim prefix="(" suffix=")" prefixOverrides="and" >
  48. <foreach collection="criteria.criteria" item="criterion" >
  49. <choose >
  50. <when test="criterion.noValue" >
  51. and ${criterion.condition}
  52. </when>
  53. <when test="criterion.singleValue" >
  54. and ${criterion.condition} #{criterion.value}
  55. </when>
  56. <when test="criterion.betweenValue" >
  57. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  58. </when>
  59. <when test="criterion.listValue" >
  60. and ${criterion.condition}
  61. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  62. #{listItem}
  63. </foreach>
  64. </when>
  65. </choose>
  66. </foreach>
  67. </trim>
  68. </if>
  69. </foreach>
  70. </where>
  71. </sql>
  72. <sql id="Base_Column_List" >
  73. id, org_id, v_cf_code, v_dev_code, v_value_time, cpo_avg, v_dev_kind_code, data_source
  74. </sql>
  75. <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TQtdevinfoValueExample" >
  76. select
  77. <if test="distinct" >
  78. distinct
  79. </if>
  80. <include refid="Base_Column_List" />
  81. from t_qtdevinfo_value
  82. <if test="_parameter != null" >
  83. <include refid="Example_Where_Clause" />
  84. </if>
  85. <if test="orderByClause != null" >
  86. order by ${orderByClause}
  87. </if>
  88. </select>
  89. <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TQtdevinfoValueExample" >
  90. delete from t_qtdevinfo_value
  91. <if test="_parameter != null" >
  92. <include refid="Example_Where_Clause" />
  93. </if>
  94. </delete>
  95. <insert id="insert" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TQtdevinfoValue" >
  96. insert into t_qtdevinfo_value (id, org_id, v_cf_code,
  97. v_dev_code, v_value_time, cpo_avg,
  98. v_dev_kind_code, data_source)
  99. values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, #{vCfCode,jdbcType=VARCHAR},
  100. #{vDevCode,jdbcType=VARCHAR}, #{vValueTime,jdbcType=TIMESTAMP}, #{cpoAvg,jdbcType=DECIMAL},
  101. #{vDevKindCode,jdbcType=VARCHAR}, #{dataSource,jdbcType=VARCHAR})
  102. </insert>
  103. <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TQtdevinfoValue" >
  104. insert into t_qtdevinfo_value
  105. <trim prefix="(" suffix=")" suffixOverrides="," >
  106. <if test="id != null" >
  107. id,
  108. </if>
  109. <if test="orgId != null" >
  110. org_id,
  111. </if>
  112. <if test="vCfCode != null" >
  113. v_cf_code,
  114. </if>
  115. <if test="vDevCode != null" >
  116. v_dev_code,
  117. </if>
  118. <if test="vValueTime != null" >
  119. v_value_time,
  120. </if>
  121. <if test="cpoAvg != null" >
  122. cpo_avg,
  123. </if>
  124. <if test="vDevKindCode != null" >
  125. v_dev_kind_code,
  126. </if>
  127. <if test="dataSource != null" >
  128. data_source,
  129. </if>
  130. </trim>
  131. <trim prefix="values (" suffix=")" suffixOverrides="," >
  132. <if test="id != null" >
  133. #{id,jdbcType=VARCHAR},
  134. </if>
  135. <if test="orgId != null" >
  136. #{orgId,jdbcType=VARCHAR},
  137. </if>
  138. <if test="vCfCode != null" >
  139. #{vCfCode,jdbcType=VARCHAR},
  140. </if>
  141. <if test="vDevCode != null" >
  142. #{vDevCode,jdbcType=VARCHAR},
  143. </if>
  144. <if test="vValueTime != null" >
  145. #{vValueTime,jdbcType=TIMESTAMP},
  146. </if>
  147. <if test="cpoAvg != null" >
  148. #{cpoAvg,jdbcType=DECIMAL},
  149. </if>
  150. <if test="vDevKindCode != null" >
  151. #{vDevKindCode,jdbcType=VARCHAR},
  152. </if>
  153. <if test="dataSource != null" >
  154. #{dataSource,jdbcType=VARCHAR},
  155. </if>
  156. </trim>
  157. </insert>
  158. <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TQtdevinfoValueExample" resultType="java.lang.Integer" >
  159. select count(*) from t_qtdevinfo_value
  160. <if test="_parameter != null" >
  161. <include refid="Example_Where_Clause" />
  162. </if>
  163. </select>
  164. <update id="updateByExampleSelective" parameterType="map" >
  165. update t_qtdevinfo_value
  166. <set >
  167. <if test="record.id != null" >
  168. id = #{record.id,jdbcType=VARCHAR},
  169. </if>
  170. <if test="record.orgId != null" >
  171. org_id = #{record.orgId,jdbcType=VARCHAR},
  172. </if>
  173. <if test="record.vCfCode != null" >
  174. v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
  175. </if>
  176. <if test="record.vDevCode != null" >
  177. v_dev_code = #{record.vDevCode,jdbcType=VARCHAR},
  178. </if>
  179. <if test="record.vValueTime != null" >
  180. v_value_time = #{record.vValueTime,jdbcType=TIMESTAMP},
  181. </if>
  182. <if test="record.cpoAvg != null" >
  183. cpo_avg = #{record.cpoAvg,jdbcType=DECIMAL},
  184. </if>
  185. <if test="record.vDevKindCode != null" >
  186. v_dev_kind_code = #{record.vDevKindCode,jdbcType=VARCHAR},
  187. </if>
  188. <if test="record.dataSource != null" >
  189. data_source = #{record.dataSource,jdbcType=VARCHAR},
  190. </if>
  191. </set>
  192. <if test="_parameter != null" >
  193. <include refid="Update_By_Example_Where_Clause" />
  194. </if>
  195. </update>
  196. <update id="updateByExample" parameterType="map" >
  197. update t_qtdevinfo_value
  198. set id = #{record.id,jdbcType=VARCHAR},
  199. org_id = #{record.orgId,jdbcType=VARCHAR},
  200. v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
  201. v_dev_code = #{record.vDevCode,jdbcType=VARCHAR},
  202. v_value_time = #{record.vValueTime,jdbcType=TIMESTAMP},
  203. cpo_avg = #{record.cpoAvg,jdbcType=DECIMAL},
  204. v_dev_kind_code = #{record.vDevKindCode,jdbcType=VARCHAR},
  205. data_source = #{record.dataSource,jdbcType=VARCHAR}
  206. <if test="_parameter != null" >
  207. <include refid="Update_By_Example_Where_Clause" />
  208. </if>
  209. </update>
  210. <insert id="insertBatch" parameterType="java.util.List">
  211. insert into t_qtdevinfo_value (id, org_id, v_cf_code,
  212. v_dev_code, v_value_time, cpo_avg,
  213. v_dev_kind_code, data_source)
  214. values
  215. <foreach collection="list" item="qt" index="index" separator=",">
  216. (#{qt.id,jdbcType=VARCHAR}, #{qt.orgId,jdbcType=VARCHAR}, #{qt.vCfCode,jdbcType=VARCHAR},
  217. #{qt.vDevCode,jdbcType=VARCHAR}, #{qt.vValueTime,jdbcType=TIMESTAMP}, #{qt.cpoAvg,jdbcType=DECIMAL},
  218. #{qt.vDevKindCode,jdbcType=VARCHAR}, #{qt.dataSource,jdbcType=VARCHAR})
  219. </foreach>
  220. </insert>
  221. <select id="getByCfCdoe" resultType="java.util.Map" parameterType="java.util.Map">
  222. SELECT
  223. id,
  224. v_cf_code AS "vCfCode",
  225. v_value_time AS "vValueTime",
  226. MAX(
  227. CASE v_dev_kind_code
  228. WHEN "6964" THEN
  229. cpo_avg
  230. ELSE
  231. 0
  232. END
  233. ) AS "co2avg",
  234. MAX(
  235. CASE v_dev_kind_code
  236. WHEN "6965" THEN
  237. cpo_avg
  238. ELSE
  239. 0
  240. END
  241. ) AS "ph3avg",
  242. MAX(
  243. CASE v_dev_kind_code
  244. WHEN "6962" THEN
  245. cpo_avg
  246. ELSE
  247. 0
  248. END
  249. ) AS "o2avg"
  250. FROM
  251. t_qtdevinfo_value
  252. <where>
  253. <if test="vCfCode != null">
  254. v_cf_code = #{vCfCode}
  255. </if>
  256. <if test="searchStartDate != null and test=searchEndDate != null">
  257. AND v_value_time BETWEEN #{searchStartDate} AND #{searchEndDate}
  258. </if>
  259. <if test="id != null">
  260. AND id IN ${id}
  261. </if>
  262. </where>
  263. GROUP BY
  264. v_cf_code,
  265. v_value_time
  266. ORDER BY v_value_time DESC
  267. </select>
  268. <select id="getByCfCdoes" parameterType="java.util.Map" resultType="java.util.Map">
  269. SELECT
  270. a.vCfCode,
  271. a.vValueTime,
  272. MAX(
  273. CASE a.v_dev_kind_code
  274. WHEN "6964" THEN
  275. a.cpo_avg
  276. ELSE
  277. 0
  278. END
  279. ) AS "co2avg",
  280. MAX(
  281. CASE a.v_dev_kind_code
  282. WHEN "6965" THEN
  283. a.cpo_avg
  284. ELSE
  285. 0
  286. END
  287. ) AS "ph3avg",
  288. MAX(
  289. CASE a.v_dev_kind_code
  290. WHEN "6962" THEN
  291. a.cpo_avg
  292. ELSE
  293. 0
  294. END
  295. ) AS "o2avg"
  296. FROM
  297. (
  298. SELECT
  299. v_cf_code AS "vCfCode",
  300. v_value_time AS "vValueTime",
  301. v_dev_kind_code,
  302. cpo_avg
  303. FROM
  304. t_qtdevinfo_value
  305. ORDER BY
  306. vValueTime DESC
  307. ) a
  308. WHERE 1=1
  309. <if test="orgId != null">
  310. AND a.orgId = #{orgId}
  311. </if>
  312. GROUP BY
  313. a.v_value_time DESC
  314. </select>
  315. <select id="getByCfCdoeGroup" parameterType="java.lang.String" resultType="java.util.Map">
  316. SELECT
  317. *
  318. FROM
  319. (
  320. SELECT
  321. id,
  322. v_cf_code AS "vCfCode",
  323. v_value_time AS "vValueTime",
  324. MAX(
  325. CASE v_dev_kind_code
  326. WHEN "6964" THEN
  327. cpo_avg
  328. ELSE
  329. 0
  330. END
  331. ) AS "co2avg",
  332. MAX(
  333. CASE v_dev_kind_code
  334. WHEN "6965" THEN
  335. cpo_avg
  336. ELSE
  337. 0
  338. END
  339. ) AS "ph3avg",
  340. MAX(
  341. CASE v_dev_kind_code
  342. WHEN "6962" THEN
  343. cpo_avg
  344. ELSE
  345. 0
  346. END
  347. ) AS "o2avg"
  348. FROM
  349. t_qtdevinfo_value
  350. GROUP BY
  351. v_cf_code,
  352. v_value_time
  353. ORDER BY
  354. v_value_time DESC
  355. ) a
  356. WHERE 1 = 1
  357. <if test="vCfCode != null and vCfCode!= ''">
  358. AND a.vCfCode = #{vCfCode}
  359. </if>
  360. GROUP BY
  361. a.vCfCode
  362. ORDER BY
  363. a.vValueTime DESC
  364. </select>
  365. </mapper>