TDepotStyleMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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.supervise.mapper.TDepotStyleMapper">
  4. <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.supervise.model.TDepotStyle">
  5. <id column="id" property="id" jdbcType="INTEGER"/>
  6. <result column="org_id" property="orgId" jdbcType="INTEGER"/>
  7. <result column="type" property="type" jdbcType="VARCHAR"/>
  8. <result column="indexid" property="indexid" jdbcType="INTEGER"/>
  9. <result column="styles" property="styles" jdbcType="VARCHAR"/>
  10. </resultMap>
  11. <resultMap id="ResultMapWithBLOBs" type="com.chinaitop.depot.intelligent.supervise.model.TDepotStyle"
  12. extends="BaseResultMap">
  13. <result column="imgdata" property="imgdata" jdbcType="LONGVARBINARY"/>
  14. </resultMap>
  15. <sql id="Example_Where_Clause">
  16. <where>
  17. <foreach collection="oredCriteria" item="criteria" separator="or">
  18. <if test="criteria.valid">
  19. <trim prefix="(" suffix=")" prefixOverrides="and">
  20. <foreach collection="criteria.criteria" item="criterion">
  21. <choose>
  22. <when test="criterion.noValue">
  23. and ${criterion.condition}
  24. </when>
  25. <when test="criterion.singleValue">
  26. and ${criterion.condition} #{criterion.value}
  27. </when>
  28. <when test="criterion.betweenValue">
  29. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  30. </when>
  31. <when test="criterion.listValue">
  32. and ${criterion.condition}
  33. <foreach collection="criterion.value" item="listItem" open="(" close=")"
  34. separator=",">
  35. #{listItem}
  36. </foreach>
  37. </when>
  38. </choose>
  39. </foreach>
  40. </trim>
  41. </if>
  42. </foreach>
  43. </where>
  44. </sql>
  45. <sql id="Update_By_Example_Where_Clause">
  46. <where>
  47. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  48. <if test="criteria.valid">
  49. <trim prefix="(" suffix=")" prefixOverrides="and">
  50. <foreach collection="criteria.criteria" item="criterion">
  51. <choose>
  52. <when test="criterion.noValue">
  53. and ${criterion.condition}
  54. </when>
  55. <when test="criterion.singleValue">
  56. and ${criterion.condition} #{criterion.value}
  57. </when>
  58. <when test="criterion.betweenValue">
  59. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  60. </when>
  61. <when test="criterion.listValue">
  62. and ${criterion.condition}
  63. <foreach collection="criterion.value" item="listItem" open="(" close=")"
  64. separator=",">
  65. #{listItem}
  66. </foreach>
  67. </when>
  68. </choose>
  69. </foreach>
  70. </trim>
  71. </if>
  72. </foreach>
  73. </where>
  74. </sql>
  75. <sql id="Base_Column_List">
  76. id, org_id, type, indexid, styles
  77. </sql>
  78. <sql id="Blob_Column_List">
  79. imgdata
  80. </sql>
  81. <select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs"
  82. parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyleExample">
  83. select
  84. <if test="distinct">
  85. distinct
  86. </if>
  87. <include refid="Base_Column_List"/>
  88. ,
  89. <include refid="Blob_Column_List"/>
  90. from t_depot_style
  91. <if test="_parameter != null">
  92. <include refid="Example_Where_Clause"/>
  93. </if>
  94. <if test="orderByClause != null">
  95. order by ${orderByClause}
  96. </if>
  97. </select>
  98. <select id="selectByExample" resultMap="BaseResultMap"
  99. parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyleExample">
  100. select
  101. <if test="distinct">
  102. distinct
  103. </if>
  104. <include refid="Base_Column_List"/>
  105. from t_depot_style
  106. <if test="_parameter != null">
  107. <include refid="Example_Where_Clause"/>
  108. </if>
  109. <if test="orderByClause != null">
  110. order by ${orderByClause}
  111. </if>
  112. </select>
  113. <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer">
  114. select
  115. <include refid="Base_Column_List"/>
  116. ,
  117. <include refid="Blob_Column_List"/>
  118. from t_depot_style
  119. where id = #{id,jdbcType=INTEGER}
  120. </select>
  121. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  122. delete from t_depot_style
  123. where id = #{id,jdbcType=INTEGER}
  124. </delete>
  125. <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyleExample">
  126. delete from t_depot_style
  127. <if test="_parameter != null">
  128. <include refid="Example_Where_Clause"/>
  129. </if>
  130. </delete>
  131. <insert id="insert" parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyle">
  132. insert into t_depot_style (id, org_id, type,
  133. indexid, styles, imgdata
  134. )
  135. values (#{id,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR},
  136. #{indexid,jdbcType=INTEGER}, #{styles,jdbcType=VARCHAR}, #{imgdata,jdbcType=LONGVARBINARY}
  137. )
  138. </insert>
  139. <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyle">
  140. insert into t_depot_style
  141. <trim prefix="(" suffix=")" suffixOverrides=",">
  142. <if test="id != null">
  143. id,
  144. </if>
  145. <if test="orgId != null">
  146. org_id,
  147. </if>
  148. <if test="type != null">
  149. type,
  150. </if>
  151. <if test="indexid != null">
  152. indexid,
  153. </if>
  154. <if test="styles != null">
  155. styles,
  156. </if>
  157. <if test="imgdata != null">
  158. imgdata,
  159. </if>
  160. </trim>
  161. <trim prefix="values (" suffix=")" suffixOverrides=",">
  162. <if test="id != null">
  163. #{id,jdbcType=INTEGER},
  164. </if>
  165. <if test="orgId != null">
  166. #{orgId,jdbcType=INTEGER},
  167. </if>
  168. <if test="type != null">
  169. #{type,jdbcType=VARCHAR},
  170. </if>
  171. <if test="indexid != null">
  172. #{indexid,jdbcType=INTEGER},
  173. </if>
  174. <if test="styles != null">
  175. #{styles,jdbcType=VARCHAR},
  176. </if>
  177. <if test="imgdata != null">
  178. #{imgdata,jdbcType=LONGVARBINARY},
  179. </if>
  180. </trim>
  181. </insert>
  182. <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyleExample"
  183. resultType="java.lang.Integer">
  184. select count(*) from t_depot_style
  185. <if test="_parameter != null">
  186. <include refid="Example_Where_Clause"/>
  187. </if>
  188. </select>
  189. <update id="updateByExampleSelective" parameterType="map">
  190. update t_depot_style
  191. <set>
  192. <if test="record.id != null">
  193. id = #{record.id,jdbcType=INTEGER},
  194. </if>
  195. <if test="record.orgId != null">
  196. org_id = #{record.orgId,jdbcType=INTEGER},
  197. </if>
  198. <if test="record.type != null">
  199. type = #{record.type,jdbcType=VARCHAR},
  200. </if>
  201. <if test="record.indexid != null">
  202. indexid = #{record.indexid,jdbcType=INTEGER},
  203. </if>
  204. <if test="record.styles != null">
  205. styles = #{record.styles,jdbcType=VARCHAR},
  206. </if>
  207. <if test="record.imgdata != null">
  208. imgdata = #{record.imgdata,jdbcType=LONGVARBINARY},
  209. </if>
  210. </set>
  211. <if test="_parameter != null">
  212. <include refid="Update_By_Example_Where_Clause"/>
  213. </if>
  214. </update>
  215. <update id="updateByExampleWithBLOBs" parameterType="map">
  216. update t_depot_style
  217. set id = #{record.id,jdbcType=INTEGER},
  218. org_id = #{record.orgId,jdbcType=INTEGER},
  219. type = #{record.type,jdbcType=VARCHAR},
  220. indexid = #{record.indexid,jdbcType=INTEGER},
  221. styles = #{record.styles,jdbcType=VARCHAR},
  222. imgdata = #{record.imgdata,jdbcType=LONGVARBINARY}
  223. <if test="_parameter != null">
  224. <include refid="Update_By_Example_Where_Clause"/>
  225. </if>
  226. </update>
  227. <update id="updateByExample" parameterType="map">
  228. update t_depot_style
  229. set id = #{record.id,jdbcType=INTEGER},
  230. org_id = #{record.orgId,jdbcType=INTEGER},
  231. type = #{record.type,jdbcType=VARCHAR},
  232. indexid = #{record.indexid,jdbcType=INTEGER},
  233. styles = #{record.styles,jdbcType=VARCHAR}
  234. <if test="_parameter != null">
  235. <include refid="Update_By_Example_Where_Clause"/>
  236. </if>
  237. </update>
  238. <update id="updateByPrimaryKeySelective"
  239. parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyle">
  240. update t_depot_style
  241. <set>
  242. <if test="orgId != null">
  243. org_id = #{orgId,jdbcType=INTEGER},
  244. </if>
  245. <if test="type != null">
  246. type = #{type,jdbcType=VARCHAR},
  247. </if>
  248. <if test="indexid != null">
  249. indexid = #{indexid,jdbcType=INTEGER},
  250. </if>
  251. <if test="styles != null">
  252. styles = #{styles,jdbcType=VARCHAR},
  253. </if>
  254. <if test="imgdata != null">
  255. imgdata = #{imgdata,jdbcType=LONGVARBINARY},
  256. </if>
  257. </set>
  258. where id = #{id,jdbcType=INTEGER}
  259. </update>
  260. <update id="updateByPrimaryKeyWithBLOBs"
  261. parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyle">
  262. update t_depot_style
  263. set org_id = #{orgId,jdbcType=INTEGER},
  264. type = #{type,jdbcType=VARCHAR},
  265. indexid = #{indexid,jdbcType=INTEGER},
  266. styles = #{styles,jdbcType=VARCHAR},
  267. imgdata = #{imgdata,jdbcType=LONGVARBINARY}
  268. where id = #{id,jdbcType=INTEGER}
  269. </update>
  270. <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.intelligent.supervise.model.TDepotStyle">
  271. update t_depot_style
  272. set org_id = #{orgId,jdbcType=INTEGER},
  273. type = #{type,jdbcType=VARCHAR},
  274. indexid = #{indexid,jdbcType=INTEGER},
  275. styles = #{styles,jdbcType=VARCHAR}
  276. where id = #{id,jdbcType=INTEGER}
  277. </update>
  278. <select id="selectByGrainSituaiton" parameterType="java.util.Map" resultType="java.util.HashMap">
  279. SELECT DISTINCT
  280. style.styles,
  281. style.imgdata,
  282. hw.input_year TestDate,
  283. house.storehouse_name barnName,
  284. house.storehouse_code vCf,
  285. t3.inTemp _InT,
  286. t3.outTemp OutT,
  287. t3.inH InH,
  288. t3.outH OutH,
  289. t3.avg AvgT,
  290. t3.min MinT,
  291. t3.max MaxT,
  292. t3.storehouse vCfCode,
  293. t3.time time,
  294. house.storehouse_id house_id,
  295. house.storehouse_name,
  296. house.storehouse_type,
  297. hw.sub_type
  298. FROM
  299. basic_storehouse house
  300. LEFT JOIN t_depot_style style ON style.indexid = house.storehouse_id
  301. LEFT JOIN storage_foodbasicinfo hw ON house.storehouse_id = hw.house_id
  302. LEFT JOIN (
  303. SELECT
  304. *
  305. FROM
  306. (
  307. SELECT
  308. *
  309. FROM
  310. t_testdata
  311. WHERE iLq_yq = 0
  312. AND org_id =#{orgId}
  313. ORDER BY
  314. time DESC
  315. limit 10000000000
  316. ) a
  317. GROUP BY
  318. a.storehouse
  319. ) t3 ON house.storehouse_code = t3.storehouse
  320. WHERE
  321. 1 = 1
  322. AND style.type = 2
  323. GROUP BY
  324. house.storehouse_id
  325. </select>
  326. <select id="selectByQT" parameterType="java.util.Map" resultType="java.util.HashMap">
  327. SELECT DISTINCT
  328. style.styles,
  329. style.imgdata,
  330. hw.input_year TestDate,
  331. house.storehouse_name barnName,
  332. house.storehouse_code vCf,
  333. t3.co2avg co2avg,
  334. t3.ph3avg ph3avg,
  335. t3.o2avg o2avg,
  336. t3.vValueTime time,
  337. t3.vCfCode vCfCode,
  338. house.storehouse_id house_id,
  339. house.storehouse_name,
  340. house.storehouse_type,
  341. hw.sub_type
  342. FROM
  343. basic_storehouse house
  344. LEFT JOIN t_depot_style style ON style.indexid = house.storehouse_id
  345. LEFT JOIN storage_foodbasicinfo hw ON house.storehouse_id = hw.house_id
  346. LEFT JOIN (
  347. SELECT
  348. a.vCfCode,
  349. a.vValueTime,
  350. MAX(
  351. CASE a.v_dev_kind_code
  352. WHEN "6964" THEN
  353. a.cpo_avg
  354. ELSE
  355. 0
  356. END
  357. ) AS "co2avg",
  358. MAX(
  359. CASE a.v_dev_kind_code
  360. WHEN "6965" THEN
  361. a.cpo_avg
  362. ELSE
  363. 0
  364. END
  365. ) AS "ph3avg",
  366. MAX(
  367. CASE a.v_dev_kind_code
  368. WHEN "6962" THEN
  369. a.cpo_avg
  370. ELSE
  371. 0
  372. END
  373. ) AS "o2avg"
  374. FROM
  375. (
  376. SELECT
  377. v_cf_code AS "vCfCode",
  378. v_value_time AS "vValueTime",
  379. v_dev_kind_code,
  380. cpo_avg
  381. FROM
  382. t_qtdevinfo_value
  383. WHERE org_id =#{orgId}
  384. ORDER BY
  385. vValueTime DESC
  386. limit 10000000000
  387. ) a
  388. GROUP BY
  389. a.vCfCode
  390. ) t3 ON house.storehouse_code = t3.vCfCode
  391. WHERE
  392. 1 = 1
  393. AND style.type = 2
  394. GROUP BY
  395. house.storehouse_id
  396. </select>
  397. <select id="selectByInsect" parameterType="java.util.Map" resultType="java.util.HashMap">
  398. SELECT DISTINCT
  399. style.styles,
  400. style.imgdata,
  401. hw.input_year TestDate,
  402. house.storehouse_name barnName,
  403. house.storehouse_code vCf,
  404. t3.max max,
  405. t3.min min,
  406. t3.avg avg,
  407. t3.vUpdateTime time,
  408. t3.vCfCode vCfCode,
  409. house.storehouse_id house_id,
  410. house.storehouse_name,
  411. house.storehouse_type,
  412. hw.sub_type
  413. FROM
  414. basic_storehouse house
  415. LEFT JOIN t_depot_style style ON style.indexid = house.storehouse_id
  416. LEFT JOIN storage_foodbasicinfo hw ON house.storehouse_id = hw.house_id
  417. LEFT JOIN (
  418. SELECT
  419. a.*
  420. FROM
  421. (
  422. SELECT
  423. v_cf_code AS vCfCode,
  424. v_max AS max,
  425. v_min AS min,
  426. v_avg AS avg,
  427. v_update_time AS vUpdateTime
  428. FROM
  429. t_ccvalue
  430. WHERE org_id =#{orgId}
  431. ORDER BY
  432. vUpdateTime DESC
  433. limit 10000000000
  434. ) a
  435. GROUP BY
  436. a.vCfCode
  437. ) t3 ON house.storehouse_code = t3.vCfCode
  438. WHERE
  439. 1 = 1
  440. AND style.type = 2
  441. GROUP BY
  442. house.storehouse_id
  443. </select>
  444. <select id="selectByWarning" parameterType="java.util.Map" resultType="java.util.HashMap">
  445. SELECT DISTINCT
  446. style.styles,
  447. style.imgdata,
  448. hw.input_year TestDate,
  449. house.storehouse_name barnName,
  450. house.storehouse_code vCf,
  451. t3.wThreshold wThreshold,
  452. t3.threshold threshold,
  453. t3.wRemark wRemark,
  454. t3.time time,
  455. t3.vCfCode vCfCode,
  456. house.storehouse_id house_id,
  457. house.storehouse_name,
  458. house.storehouse_type,
  459. hw.sub_type
  460. FROM
  461. basic_storehouse house
  462. LEFT JOIN t_depot_style style ON style.indexid = house.storehouse_id
  463. LEFT JOIN storage_foodbasicinfo hw ON house.storehouse_id = hw.house_id
  464. LEFT JOIN (
  465. SELECT
  466. a.v_cf_code vCfCode,
  467. a.w_time time,
  468. a.w_threshold wThreshold,
  469. a.threshold threshold,
  470. a.w_remark wRemark
  471. FROM
  472. (
  473. SELECT
  474. *
  475. FROM
  476. t_warning_threshold_history
  477. WHERE w_warning = 0
  478. AND org_id =#{orgId}
  479. ORDER BY
  480. w_time DESC
  481. ) a
  482. WHERE 1=1
  483. <if test="times != null">
  484. AND a.w_time in
  485. <foreach item="time" index="index" collection="times" open="(" separator="," close=")">
  486. #{time}
  487. </foreach>
  488. </if>
  489. <if test="cfCodes != null">
  490. AND a.v_cf_code in
  491. <foreach item="cfCode" index="index" collection="cfCodes" open="(" separator="," close=")">
  492. #{cfCode}
  493. </foreach>
  494. </if>
  495. GROUP BY
  496. a.v_cf_code
  497. ) t3 ON house.storehouse_code = t3.vCfCode
  498. WHERE
  499. 1 = 1
  500. AND style.type = 2
  501. GROUP BY
  502. house.storehouse_id
  503. </select>
  504. </mapper>