TTestdataMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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.TTestdataMapper" >
  4. <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.grainsituation.model.TTestdata" >
  5. <result column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="org_id" property="orgId" jdbcType="VARCHAR" />
  7. <result column="storehouse" property="storehouse" jdbcType="VARCHAR" />
  8. <result column="house" property="house" jdbcType="VARCHAR" />
  9. <result column="time" property="time" jdbcType="TIMESTAMP" />
  10. <result column="inTemp" property="intemp" jdbcType="DECIMAL" />
  11. <result column="inH" property="inh" jdbcType="DECIMAL" />
  12. <result column="outTemp" property="outtemp" jdbcType="DECIMAL" />
  13. <result column="outH" property="outh" jdbcType="DECIMAL" />
  14. <result column="max" property="max" jdbcType="DECIMAL" />
  15. <result column="min" property="min" jdbcType="DECIMAL" />
  16. <result column="avg" property="avg" jdbcType="DECIMAL" />
  17. <result column="data_source" property="dataSource" jdbcType="VARCHAR" />
  18. <result column="updatetime" property="updatetime" jdbcType="TIMESTAMP" />
  19. <result column="iLq_yq" property="ilqYq" jdbcType="VARCHAR" />
  20. </resultMap>
  21. <resultMap id="ResultMapWithBLOBs" type="com.chinaitop.depot.intelligent.grainsituation.model.TTestdata" extends="BaseResultMap" >
  22. <result column="t_points" property="tPoints" jdbcType="LONGVARCHAR" />
  23. </resultMap>
  24. <sql id="Example_Where_Clause" >
  25. <where >
  26. <foreach collection="oredCriteria" item="criteria" separator="or" >
  27. <if test="criteria.valid" >
  28. <trim prefix="(" suffix=")" prefixOverrides="and" >
  29. <foreach collection="criteria.criteria" item="criterion" >
  30. <choose >
  31. <when test="criterion.noValue" >
  32. and ${criterion.condition}
  33. </when>
  34. <when test="criterion.singleValue" >
  35. and ${criterion.condition} #{criterion.value}
  36. </when>
  37. <when test="criterion.betweenValue" >
  38. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  39. </when>
  40. <when test="criterion.listValue" >
  41. and ${criterion.condition}
  42. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  43. #{listItem}
  44. </foreach>
  45. </when>
  46. </choose>
  47. </foreach>
  48. </trim>
  49. </if>
  50. </foreach>
  51. </where>
  52. </sql>
  53. <sql id="Update_By_Example_Where_Clause" >
  54. <where >
  55. <foreach collection="example.oredCriteria" item="criteria" separator="or" >
  56. <if test="criteria.valid" >
  57. <trim prefix="(" suffix=")" prefixOverrides="and" >
  58. <foreach collection="criteria.criteria" item="criterion" >
  59. <choose >
  60. <when test="criterion.noValue" >
  61. and ${criterion.condition}
  62. </when>
  63. <when test="criterion.singleValue" >
  64. and ${criterion.condition} #{criterion.value}
  65. </when>
  66. <when test="criterion.betweenValue" >
  67. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  68. </when>
  69. <when test="criterion.listValue" >
  70. and ${criterion.condition}
  71. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  72. #{listItem}
  73. </foreach>
  74. </when>
  75. </choose>
  76. </foreach>
  77. </trim>
  78. </if>
  79. </foreach>
  80. </where>
  81. </sql>
  82. <sql id="Base_Column_List" >
  83. id, org_id, storehouse, house, time, inTemp, inH, outTemp, outH, max, min, avg, data_source,
  84. updatetime, iLq_yq
  85. </sql>
  86. <sql id="Blob_Column_List" >
  87. t_points
  88. </sql>
  89. <select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataExample" >
  90. select
  91. <if test="distinct" >
  92. distinct
  93. </if>
  94. <include refid="Base_Column_List" />
  95. ,
  96. <include refid="Blob_Column_List" />
  97. from t_testdata
  98. <if test="_parameter != null" >
  99. <include refid="Example_Where_Clause" />
  100. </if>
  101. <if test="orderByClause != null" >
  102. order by ${orderByClause}
  103. </if>
  104. </select>
  105. <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataExample" >
  106. select
  107. <if test="distinct" >
  108. distinct
  109. </if>
  110. <include refid="Base_Column_List" />
  111. from t_testdata
  112. <if test="_parameter != null" >
  113. <include refid="Example_Where_Clause" />
  114. </if>
  115. <if test="orderByClause != null" >
  116. order by ${orderByClause}
  117. </if>
  118. </select>
  119. <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataExample" >
  120. delete from t_testdata
  121. <if test="_parameter != null" >
  122. <include refid="Example_Where_Clause" />
  123. </if>
  124. </delete>
  125. <insert id="insert" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdata" >
  126. insert into t_testdata (id, org_id, storehouse,
  127. house, time, inTemp,
  128. inH, outTemp, outH,
  129. max, min, avg, data_source,
  130. updatetime, iLq_yq, t_points
  131. )
  132. values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, #{storehouse,jdbcType=VARCHAR},
  133. #{house,jdbcType=VARCHAR}, #{time,jdbcType=TIMESTAMP}, #{intemp,jdbcType=DECIMAL},
  134. #{inh,jdbcType=DECIMAL}, #{outtemp,jdbcType=DECIMAL}, #{outh,jdbcType=DECIMAL},
  135. #{max,jdbcType=DECIMAL}, #{min,jdbcType=DECIMAL}, #{avg,jdbcType=DECIMAL}, #{dataSource,jdbcType=VARCHAR},
  136. #{updatetime,jdbcType=TIMESTAMP}, #{ilqYq,jdbcType=VARCHAR}, #{tPoints,jdbcType=LONGVARCHAR}
  137. )
  138. </insert>
  139. <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdata" >
  140. insert into t_testdata
  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="storehouse != null" >
  149. storehouse,
  150. </if>
  151. <if test="house != null" >
  152. house,
  153. </if>
  154. <if test="time != null" >
  155. time,
  156. </if>
  157. <if test="intemp != null" >
  158. inTemp,
  159. </if>
  160. <if test="inh != null" >
  161. inH,
  162. </if>
  163. <if test="outtemp != null" >
  164. outTemp,
  165. </if>
  166. <if test="outh != null" >
  167. outH,
  168. </if>
  169. <if test="max != null" >
  170. max,
  171. </if>
  172. <if test="min != null" >
  173. min,
  174. </if>
  175. <if test="avg != null" >
  176. avg,
  177. </if>
  178. <if test="dataSource != null" >
  179. data_source,
  180. </if>
  181. <if test="updatetime != null" >
  182. updatetime,
  183. </if>
  184. <if test="ilqYq != null" >
  185. iLq_yq,
  186. </if>
  187. <if test="tPoints != null" >
  188. t_points,
  189. </if>
  190. </trim>
  191. <trim prefix="values (" suffix=")" suffixOverrides="," >
  192. <if test="id != null" >
  193. #{id,jdbcType=VARCHAR},
  194. </if>
  195. <if test="orgId != null" >
  196. #{orgId,jdbcType=VARCHAR},
  197. </if>
  198. <if test="storehouse != null" >
  199. #{storehouse,jdbcType=VARCHAR},
  200. </if>
  201. <if test="house != null" >
  202. #{house,jdbcType=VARCHAR},
  203. </if>
  204. <if test="time != null" >
  205. #{time,jdbcType=TIMESTAMP},
  206. </if>
  207. <if test="intemp != null" >
  208. #{intemp,jdbcType=DECIMAL},
  209. </if>
  210. <if test="inh != null" >
  211. #{inh,jdbcType=DECIMAL},
  212. </if>
  213. <if test="outtemp != null" >
  214. #{outtemp,jdbcType=DECIMAL},
  215. </if>
  216. <if test="outh != null" >
  217. #{outh,jdbcType=DECIMAL},
  218. </if>
  219. <if test="max != null" >
  220. #{max,jdbcType=DECIMAL},
  221. </if>
  222. <if test="min != null" >
  223. #{min,jdbcType=DECIMAL},
  224. </if>
  225. <if test="avg != null" >
  226. #{avg,jdbcType=DECIMAL},
  227. </if>
  228. <if test="dataSource != null" >
  229. #{dataSource,jdbcType=VARCHAR},
  230. </if>
  231. <if test="updatetime != null" >
  232. #{updatetime,jdbcType=TIMESTAMP},
  233. </if>
  234. <if test="ilqYq != null" >
  235. #{ilqYq,jdbcType=VARCHAR},
  236. </if>
  237. <if test="tPoints != null" >
  238. #{tPoints,jdbcType=LONGVARCHAR},
  239. </if>
  240. </trim>
  241. </insert>
  242. <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.grainsituation.model.TTestdataExample" resultType="java.lang.Integer" >
  243. select count(*) from t_testdata
  244. <if test="_parameter != null" >
  245. <include refid="Example_Where_Clause" />
  246. </if>
  247. </select>
  248. <update id="updateByExampleSelective" parameterType="map" >
  249. update t_testdata
  250. <set >
  251. <if test="record.id != null" >
  252. id = #{record.id,jdbcType=VARCHAR},
  253. </if>
  254. <if test="record.orgId != null" >
  255. org_id = #{record.orgId,jdbcType=VARCHAR},
  256. </if>
  257. <if test="record.storehouse != null" >
  258. storehouse = #{record.storehouse,jdbcType=VARCHAR},
  259. </if>
  260. <if test="record.house != null" >
  261. house = #{record.house,jdbcType=VARCHAR},
  262. </if>
  263. <if test="record.time != null" >
  264. time = #{record.time,jdbcType=TIMESTAMP},
  265. </if>
  266. <if test="record.intemp != null" >
  267. inTemp = #{record.intemp,jdbcType=DECIMAL},
  268. </if>
  269. <if test="record.inh != null" >
  270. inH = #{record.inh,jdbcType=DECIMAL},
  271. </if>
  272. <if test="record.outtemp != null" >
  273. outTemp = #{record.outtemp,jdbcType=DECIMAL},
  274. </if>
  275. <if test="record.outh != null" >
  276. outH = #{record.outh,jdbcType=DECIMAL},
  277. </if>
  278. <if test="record.max != null" >
  279. max = #{record.max,jdbcType=DECIMAL},
  280. </if>
  281. <if test="record.min != null" >
  282. min = #{record.min,jdbcType=DECIMAL},
  283. </if>
  284. <if test="record.avg != null" >
  285. avg = #{record.avg,jdbcType=DECIMAL},
  286. </if>
  287. <if test="record.dataSource != null" >
  288. data_source = #{record.dataSource,jdbcType=VARCHAR},
  289. </if>
  290. <if test="record.updatetime != null" >
  291. updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
  292. </if>
  293. <if test="record.ilqYq != null" >
  294. iLq_yq = #{record.ilqYq,jdbcType=VARCHAR},
  295. </if>
  296. <if test="record.tPoints != null" >
  297. t_points = #{record.tPoints,jdbcType=LONGVARCHAR},
  298. </if>
  299. </set>
  300. <if test="_parameter != null" >
  301. <include refid="Update_By_Example_Where_Clause" />
  302. </if>
  303. </update>
  304. <update id="updateByExampleWithBLOBs" parameterType="map" >
  305. update t_testdata
  306. set id = #{record.id,jdbcType=VARCHAR},
  307. org_id = #{record.orgId,jdbcType=VARCHAR},
  308. storehouse = #{record.storehouse,jdbcType=VARCHAR},
  309. house = #{record.house,jdbcType=VARCHAR},
  310. time = #{record.time,jdbcType=TIMESTAMP},
  311. inTemp = #{record.intemp,jdbcType=DECIMAL},
  312. inH = #{record.inh,jdbcType=DECIMAL},
  313. outTemp = #{record.outtemp,jdbcType=DECIMAL},
  314. outH = #{record.outh,jdbcType=DECIMAL},
  315. max = #{record.max,jdbcType=DECIMAL},
  316. min = #{record.min,jdbcType=DECIMAL},
  317. avg = #{record.avg,jdbcType=DECIMAL},
  318. data_source = #{record.dataSource,jdbcType=VARCHAR},
  319. updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
  320. iLq_yq = #{record.ilqYq,jdbcType=VARCHAR},
  321. t_points = #{record.tPoints,jdbcType=LONGVARCHAR}
  322. <if test="_parameter != null" >
  323. <include refid="Update_By_Example_Where_Clause" />
  324. </if>
  325. </update>
  326. <update id="updateByExample" parameterType="map" >
  327. update t_testdata
  328. set id = #{record.id,jdbcType=VARCHAR},
  329. org_id = #{record.orgId,jdbcType=VARCHAR},
  330. storehouse = #{record.storehouse,jdbcType=VARCHAR},
  331. house = #{record.house,jdbcType=VARCHAR},
  332. time = #{record.time,jdbcType=TIMESTAMP},
  333. inTemp = #{record.intemp,jdbcType=DECIMAL},
  334. inH = #{record.inh,jdbcType=DECIMAL},
  335. outTemp = #{record.outtemp,jdbcType=DECIMAL},
  336. outH = #{record.outh,jdbcType=DECIMAL},
  337. max = #{record.max,jdbcType=DECIMAL},
  338. min = #{record.min,jdbcType=DECIMAL},
  339. avg = #{record.avg,jdbcType=DECIMAL},
  340. data_source = #{record.dataSource,jdbcType=VARCHAR},
  341. updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
  342. iLq_yq = #{record.ilqYq,jdbcType=VARCHAR}
  343. <if test="_parameter != null" >
  344. <include refid="Update_By_Example_Where_Clause" />
  345. </if>
  346. </update>
  347. <insert id="insertBatch" parameterType="java.util.List">
  348. insert into t_testdata (id, org_id, storehouse,
  349. house, time, inTemp,
  350. inH, outTemp, outH,
  351. max, min, avg, data_source,
  352. updatetime, iLq_yq, t_points
  353. )
  354. values
  355. <foreach collection="list" item="testData" index="index" separator=",">
  356. (#{testData.id,jdbcType=VARCHAR}, #{testData.orgId,jdbcType=VARCHAR}, #{testData.storehouse,jdbcType=VARCHAR},
  357. #{testData.house,jdbcType=VARCHAR}, #{testData.time,jdbcType=TIMESTAMP}, #{testData.intemp,jdbcType=DECIMAL},
  358. #{testData.inh,jdbcType=DECIMAL}, #{testData.outtemp,jdbcType=DECIMAL}, #{testData.outh,jdbcType=DECIMAL},
  359. #{testData.max,jdbcType=DECIMAL}, #{testData.min,jdbcType=DECIMAL}, #{testData.avg,jdbcType=DECIMAL}, #{testData.dataSource,jdbcType=VARCHAR},
  360. #{testData.updatetime,jdbcType=TIMESTAMP}, #{testData.ilqYq,jdbcType=VARCHAR}, #{testData.tPoints,jdbcType=LONGVARCHAR}
  361. )
  362. </foreach>
  363. </insert>
  364. <select id="getList" parameterType="Map" resultMap="BaseResultMap">
  365. select
  366. <include refid="Base_Column_List"/>
  367. from t_testdata
  368. <where>
  369. <if test="vDatatime != null and vDatatime != ''">
  370. time like #{vDatatime}
  371. </if>
  372. <if test="vCfCode != null and vCfCode != ''">
  373. and house = #{vCfCode}
  374. </if>
  375. </where>
  376. order by time desc
  377. </select>
  378. <select id="getByCfCdoes" parameterType="Map" resultMap="BaseResultMap">
  379. SELECT
  380. a.*
  381. FROM
  382. (
  383. SELECT
  384. <include refid="Base_Column_List"/>
  385. FROM
  386. t_testdata
  387. ORDER BY
  388. time DESC
  389. ) a
  390. WHERE 1=1
  391. <if test="orgId != null">
  392. AND a.orgId = #{orgId}
  393. </if>
  394. GROUP BY
  395. a.storehouse
  396. </select>
  397. <select id="getNewest" resultMap="BaseResultMap" parameterType="java.util.Map">
  398. SELECT
  399. t2.id,
  400. t2.org_id,
  401. t2.storehouse,
  402. t2.house,
  403. t2.time,
  404. t2.inTemp,
  405. t2.inH,
  406. t2.outTemp,
  407. t2.outH,
  408. t2.max,
  409. t2.min,
  410. t2.avg,
  411. t2.data_source,
  412. t2.updatetime,
  413. t2.iLq_yq
  414. FROM
  415. (
  416. SELECT
  417. MAX(time) time,
  418. org_id
  419. FROM
  420. t_testdata
  421. WHERE
  422. org_id = #{orgId}
  423. GROUP BY
  424. storehouse
  425. ) t1
  426. LEFT JOIN t_testdata t2 ON t1.time = t2.time
  427. AND t1.org_id = t2.org_id
  428. </select>
  429. <select id="getById" resultMap="ResultMapWithBLOBs" parameterType="java.lang.String">
  430. SELECT * FROM t_testdata WHERE id = #{id}
  431. </select>
  432. <select id="getOrgId" resultType="java.lang.String" parameterType="java.lang.String">
  433. SELECT
  434. org_id
  435. FROM
  436. basic_storehouse
  437. <if test="cfCode != null">
  438. WHERE storehouse_code = #{cfCode}
  439. </if>
  440. LIMIT 0,1
  441. </select>
  442. <select id="getGrainPointAll" resultType="java.util.Map" parameterType="java.util.Map">
  443. SELECT
  444. *
  445. FROM
  446. t_testdata
  447. <where>
  448. <if test="tHouse != null">
  449. storehouse = #{tHouse}
  450. </if>
  451. <if test="startTime != null and endTime != null">
  452. AND time BETWEEN #{startTime} AND #{endTime}
  453. </if>
  454. <if test="lqIds != null">
  455. AND id IN
  456. <foreach item="lqId" index="index" collection="lqIds" open="(" separator="," close=")">
  457. #{lqId}
  458. </foreach>
  459. </if>
  460. </where>
  461. </select>
  462. </mapper>