FoldTheValuesMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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.steerinfo.ems.foldthevalues.mapper.FoldTheValuesMapper">
  4. <resultMap id="BaseResultMap" type="com.steerinfo.ems.foldthevalues.model.FoldTheValues">
  5. <id column="ID" jdbcType="VARCHAR" property="id" />
  6. <result column="MATERIALSOURCE" jdbcType="VARCHAR" property="materialsource" />
  7. <result column="CLOCK" jdbcType="VARCHAR" property="clock" />
  8. <result column="CODE" jdbcType="VARCHAR" property="code" />
  9. <result column="DESCRIPTION" jdbcType="VARCHAR" property="description" />
  10. <result column="ISAVAILABLE" jdbcType="VARCHAR" property="isavailable" />
  11. <result column="REVISOR" jdbcType="VARCHAR" property="revisor" />
  12. <result column="REVISETIME" jdbcType="VARCHAR" property="revisetime" />
  13. <result column="UNITID" jdbcType="VARCHAR" property="unitid" />
  14. <result column="BZ" jdbcType="VARCHAR" property="bz" />
  15. <result column="MATERIALNO" jdbcType="VARCHAR" property="materialno"/>
  16. <result column="TIMEGRANID" jdbcType="VARCHAR" property="timegranid"/>
  17. <result column="ESTIMATEDVALUE" jdbcType="VARCHAR" property="estimatedvalue"/>
  18. </resultMap>
  19. <sql id="columns">
  20. ID, MATERIALSOURCE, CLOCK, CODE, DESCRIPTION, ISAVAILABLE, REVISOR, REVISETIME,
  21. UNITID, BZ,MATERIALNO,TIMEGRANID,ESTIMATEDVALUE
  22. </sql>
  23. <sql id="columns_alias">
  24. t.ID, t.MATERIALSOURCE, t.CLOCK, t.CODE, t.DESCRIPTION, t.ISAVAILABLE, t.REVISOR,
  25. t.REVISETIME, t.UNITID, t.BZ,t.MATERIALNO
  26. </sql>
  27. <sql id="select">
  28. SELECT <include refid="columns"/> FROM FOLD_THE_VALUES
  29. </sql>
  30. <sql id="select_alias">
  31. SELECT <include refid="columns_alias"/> FROM FOLD_THE_VALUES t
  32. </sql>
  33. <sql id="where">
  34. <where>
  35. <if test="id != null and id != ''">
  36. and ID = #{id}
  37. </if>
  38. <if test="materialsource != null and materialsource != ''">
  39. and MATERIALSOURCE = #{materialsource}
  40. </if>
  41. <if test="clock != null and clock != ''">
  42. and CLOCK = #{clock}
  43. </if>
  44. <if test="code != null and code != ''">
  45. and CODE = #{code}
  46. </if>
  47. <if test="description != null and description != ''">
  48. and DESCRIPTION = #{description}
  49. </if>
  50. <if test="isavailable != null and isavailable != ''">
  51. and ISAVAILABLE = #{isavailable}
  52. </if>
  53. <if test="revisor != null and revisor != ''">
  54. and REVISOR = #{revisor}
  55. </if>
  56. <if test="revisetime != null and revisetime != ''">
  57. and REVISETIME = #{revisetime}
  58. </if>
  59. <if test="unitid != null and unitid != ''">
  60. and UNITID = #{unitid}
  61. </if>
  62. <if test="bz != null and bz != ''">
  63. and BZ = #{bz}
  64. </if>
  65. </where>
  66. </sql>
  67. <sql id="whereLike">
  68. <where>
  69. <if test="id != null and id != ''">
  70. and ID LIKE '%${id}%'
  71. </if>
  72. <if test="materialsource != null and materialsource != ''">
  73. and MATERIALSOURCE LIKE '%${materialsource}%'
  74. </if>
  75. <if test="clock != null and clock != ''">
  76. and CLOCK LIKE '%${clock}%'
  77. </if>
  78. <if test="code != null and code != ''">
  79. and CODE LIKE '%${code}%'
  80. </if>
  81. <if test="description != null and description != ''">
  82. and DESCRIPTION LIKE '%${description}%'
  83. </if>
  84. <if test="isavailable != null and isavailable != ''">
  85. and ISAVAILABLE LIKE '%${isavailable}%'
  86. </if>
  87. <if test="revisor != null and revisor != ''">
  88. and REVISOR LIKE '%${revisor}%'
  89. </if>
  90. <if test="revisetime != null and revisetime != ''">
  91. and REVISETIME LIKE '%${revisetime}%'
  92. </if>
  93. <if test="unitid != null and unitid != ''">
  94. and UNITID LIKE '%${unitid}%'
  95. </if>
  96. <if test="bz != null and bz != ''">
  97. and BZ LIKE '%${bz}%'
  98. </if>
  99. </where>
  100. </sql>
  101. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  102. delete from FOLD_THE_VALUES
  103. where ID = #{id,jdbcType=VARCHAR}
  104. </delete>
  105. <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
  106. delete from FOLD_THE_VALUES
  107. where 1!=1
  108. <if test="materialsource != null and materialsource != ''">
  109. or MATERIALSOURCE = #{materialsource}
  110. </if>
  111. <if test="clock != null and clock != ''">
  112. or CLOCK = #{clock}
  113. </if>
  114. <if test="code != null and code != ''">
  115. or CODE = #{code}
  116. </if>
  117. <if test="description != null and description != ''">
  118. or DESCRIPTION = #{description}
  119. </if>
  120. <if test="isavailable != null and isavailable != ''">
  121. or ISAVAILABLE = #{isavailable}
  122. </if>
  123. <if test="revisor != null and revisor != ''">
  124. or REVISOR = #{revisor}
  125. </if>
  126. <if test="revisetime != null and revisetime != ''">
  127. or REVISETIME = #{revisetime}
  128. </if>
  129. <if test="unitid != null and unitid != ''">
  130. or UNITID = #{unitid}
  131. </if>
  132. <if test="bz != null and bz != ''">
  133. or BZ = #{bz}
  134. </if>
  135. </delete>
  136. <insert id="insert" parameterType="com.steerinfo.ems.foldthevalues.model.FoldTheValues">
  137. insert into FOLD_THE_VALUES (ID, MATERIALSOURCE, CLOCK,
  138. CODE, DESCRIPTION, ISAVAILABLE,
  139. REVISOR, REVISETIME,MATERIALNO,
  140. UNITID, BZ,TIMEGRANID,ESTIMATEDVALUE)
  141. values (#{id,jdbcType=VARCHAR}, #{materialsource,jdbcType=VARCHAR}, #{clock,jdbcType=VARCHAR},
  142. #{code,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{isavailable,jdbcType=VARCHAR},
  143. #{revisor,jdbcType=VARCHAR}, #{revisetime,jdbcType=VARCHAR},#{materialno,jdbcType=VARCHAR},
  144. #{unitid,jdbcType=VARCHAR}, #{bz,jdbcType=VARCHAR},#{timegranid,jdbcType=VARCHAR},#{estimatedvalue,jdbcType=VARCHAR})
  145. </insert>
  146. <insert id="insertSelective" parameterType="com.steerinfo.ems.foldthevalues.model.FoldTheValues">
  147. insert into FOLD_THE_VALUES
  148. <trim prefix="(" suffix=")" suffixOverrides=",">
  149. <if test="id != null">
  150. ID,
  151. </if>
  152. <if test="materialsource != null">
  153. MATERIALSOURCE,
  154. </if>
  155. <if test="clock != null">
  156. CLOCK,
  157. </if>
  158. <if test="code != null">
  159. CODE,
  160. </if>
  161. <if test="description != null">
  162. DESCRIPTION,
  163. </if>
  164. <if test="isavailable != null">
  165. ISAVAILABLE,
  166. </if>
  167. <if test="revisor != null">
  168. REVISOR,
  169. </if>
  170. <if test="revisetime != null">
  171. REVISETIME,
  172. </if>
  173. <if test="unitid != null">
  174. UNITID,
  175. </if>
  176. <if test="bz != null">
  177. BZ,
  178. </if>
  179. </trim>
  180. <trim prefix="values (" suffix=")" suffixOverrides=",">
  181. <if test="id != null">
  182. #{id,jdbcType=VARCHAR},
  183. </if>
  184. <if test="materialsource != null">
  185. #{materialsource,jdbcType=VARCHAR},
  186. </if>
  187. <if test="clock != null">
  188. #{clock,jdbcType=VARCHAR},
  189. </if>
  190. <if test="code != null">
  191. #{code,jdbcType=VARCHAR},
  192. </if>
  193. <if test="description != null">
  194. #{description,jdbcType=VARCHAR},
  195. </if>
  196. <if test="isavailable != null">
  197. #{isavailable,jdbcType=VARCHAR},
  198. </if>
  199. <if test="revisor != null">
  200. #{revisor,jdbcType=VARCHAR},
  201. </if>
  202. <if test="revisetime != null">
  203. #{revisetime,jdbcType=VARCHAR},
  204. </if>
  205. <if test="unitid != null">
  206. #{unitid,jdbcType=VARCHAR},
  207. </if>
  208. <if test="bz != null">
  209. #{bz,jdbcType=VARCHAR},
  210. </if>
  211. </trim>
  212. </insert>
  213. <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.foldthevalues.model.FoldTheValues">
  214. update FOLD_THE_VALUES
  215. set
  216. CLOCK = #{clock,jdbcType=VARCHAR},
  217. CODE = #{code,jdbcType=VARCHAR},
  218. DESCRIPTION = #{description,jdbcType=VARCHAR},
  219. ISAVAILABLE = #{isavailable,jdbcType=VARCHAR},
  220. REVISOR = #{revisor,jdbcType=VARCHAR},
  221. REVISETIME = #{revisetime,jdbcType=VARCHAR},
  222. UNITID = #{unitid,jdbcType=VARCHAR},
  223. BZ = #{bz,jdbcType=VARCHAR},
  224. TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
  225. ESTIMATEDVALUE = #{estimatedvalue,jdbcType=VARCHAR}
  226. where ID = #{id,jdbcType=VARCHAR}
  227. </update>
  228. <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.foldthevalues.model.FoldTheValues">
  229. update FOLD_THE_VALUES
  230. <set>
  231. <if test="materialsource != null">
  232. MATERIALSOURCE = #{materialsource,jdbcType=VARCHAR},
  233. </if>
  234. <if test="clock != null">
  235. CLOCK = #{clock,jdbcType=VARCHAR},
  236. </if>
  237. <if test="code != null">
  238. CODE = #{code,jdbcType=VARCHAR},
  239. </if>
  240. <if test="description != null">
  241. DESCRIPTION = #{description,jdbcType=VARCHAR},
  242. </if>
  243. <if test="isavailable != null">
  244. ISAVAILABLE = #{isavailable,jdbcType=VARCHAR},
  245. </if>
  246. <if test="revisor != null">
  247. REVISOR = #{revisor,jdbcType=VARCHAR},
  248. </if>
  249. <if test="revisetime != null">
  250. REVISETIME = #{revisetime,jdbcType=VARCHAR},
  251. </if>
  252. <if test="unitid != null">
  253. UNITID = #{unitid,jdbcType=VARCHAR},
  254. </if>
  255. <if test="bz != null">
  256. BZ = #{bz,jdbcType=VARCHAR},
  257. </if>
  258. </set>
  259. where ID = #{id,jdbcType=VARCHAR}
  260. </update>
  261. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  262. <include refid="select"/>
  263. where ID = #{id,jdbcType=VARCHAR}
  264. </select>
  265. <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  266. <include refid="select"/>
  267. <include refid="where"/>
  268. </select>
  269. <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  270. <include refid="select"/>
  271. <include refid="whereLike"/>
  272. </select>
  273. <insert id="batchInsert" parameterType="java.util.List">
  274. insert into FOLD_THE_VALUES
  275. (ID,
  276. MATERIALSOURCE, CLOCK, CODE,
  277. DESCRIPTION, ISAVAILABLE, REVISOR,
  278. REVISETIME, UNITID,
  279. BZ)
  280. ( <foreach collection="list" item="item" separator="union all">
  281. select
  282. #{item.id,jdbcType=VARCHAR},
  283. #{item.materialsource,jdbcType=VARCHAR}, #{item.clock,jdbcType=VARCHAR}, #{item.code,jdbcType=VARCHAR},
  284. #{item.description,jdbcType=VARCHAR}, #{item.isavailable,jdbcType=VARCHAR}, #{item.revisor,jdbcType=VARCHAR},
  285. #{item.revisetime,jdbcType=VARCHAR}, #{item.unitid,jdbcType=VARCHAR},
  286. #{item.bz,jdbcType=VARCHAR} from dual
  287. </foreach> )
  288. </insert>
  289. <update id="batchUpdate" parameterType="java.util.List">
  290. update FOLD_THE_VALUES
  291. set
  292. ID=
  293. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  294. when #{item.id,jdbcType=VARCHAR} then #{item.id,jdbcType=VARCHAR}
  295. </foreach>
  296. ,MATERIALSOURCE=
  297. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  298. when #{item.id,jdbcType=VARCHAR} then #{item.materialsource,jdbcType=VARCHAR}
  299. </foreach>
  300. ,CLOCK=
  301. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  302. when #{item.id,jdbcType=VARCHAR} then #{item.clock,jdbcType=VARCHAR}
  303. </foreach>
  304. ,CODE=
  305. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  306. when #{item.id,jdbcType=VARCHAR} then #{item.code,jdbcType=VARCHAR}
  307. </foreach>
  308. ,DESCRIPTION=
  309. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  310. when #{item.id,jdbcType=VARCHAR} then #{item.description,jdbcType=VARCHAR}
  311. </foreach>
  312. ,ISAVAILABLE=
  313. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  314. when #{item.id,jdbcType=VARCHAR} then #{item.isavailable,jdbcType=VARCHAR}
  315. </foreach>
  316. ,REVISOR=
  317. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  318. when #{item.id,jdbcType=VARCHAR} then #{item.revisor,jdbcType=VARCHAR}
  319. </foreach>
  320. ,REVISETIME=
  321. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  322. when #{item.id,jdbcType=VARCHAR} then #{item.revisetime,jdbcType=VARCHAR}
  323. </foreach>
  324. ,UNITID=
  325. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  326. when #{item.id,jdbcType=VARCHAR} then #{item.unitid,jdbcType=VARCHAR}
  327. </foreach>
  328. ,BZ=
  329. <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
  330. when #{item.id,jdbcType=VARCHAR} then #{item.bz,jdbcType=VARCHAR}
  331. </foreach>
  332. where ID in
  333. <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
  334. #{item.id,jdbcType=VARCHAR}
  335. </foreach>
  336. </update>
  337. <delete id="batchDelete" parameterType="java.util.List">
  338. delete from FOLD_THE_VALUES
  339. where ID in
  340. <foreach collection="list" item="id" open="(" close=")" separator=",">
  341. #{id}
  342. </foreach>
  343. </delete>
  344. <!-- 友情提示!!!-->
  345. <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
  346. <select id="getDateForPage" parameterType="java.util.HashMap" resultType="Map">
  347. select t.*, t1.id as energyid, t1.name as energyname
  348. from Fold_the_values t
  349. left join t_rm_energy t1
  350. on t.materialno = t1.id
  351. <where>
  352. <if test = "startTime != null and startTime != '' and endTime != null and endTime != '' " >
  353. and t.clock between #{startTime} and #{endTime}
  354. </if >
  355. <if test = "energyid != null and energyid != '' " >
  356. and t.materialno in (${energyid})
  357. </if >
  358. <if test="timegranid != null and timegranid != ''">
  359. and t.timegranid = #{timegranid}
  360. </if>
  361. </where>
  362. order by t.clock desc
  363. </select>
  364. <!---->
  365. <select id="getNewData" resultMap="BaseResultMap">
  366. select t.batchno as id,
  367. '三电厂' as materialsource,
  368. to_char(to_date(t.monitordate, 'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd') as clock,
  369. t.monitoringvalue as estimatedvalue,
  370. (t.MONITORINGVALUE * 0.03412 / 100) as code,
  371. t.powersystemname as materialno
  372. from t_cm_0348 t
  373. where t.SITEM = 'BFHYD_05'
  374. and t.powersystemname in ('P00006', 'P00007', 'P00008')
  375. and t.powermonitorname in ('007', '008', '009')
  376. and t.batchno not in (select distinct ID from FOLD_THE_VALUES)
  377. </select>
  378. <!--获取最近最新的数据-->
  379. <select id="getNewOne" parameterType="java.lang.String" resultMap="BaseResultMap">
  380. select *
  381. from (select *
  382. from FOLD_THE_VALUES
  383. <where>
  384. <if test="materialno != null and materialno !=''">
  385. materialno = #{materialno}
  386. </if>
  387. </where>
  388. order by CLOCK desc)
  389. where rownum = 1
  390. </select>
  391. <!--查询出昨天没有折标值的数据-->
  392. <select id="getNozbzData" parameterType="java.lang.String" resultMap="BaseResultMap">
  393. select distinct t.materialno
  394. from FOLD_THE_VALUES t
  395. where t.materialno not in
  396. (select materialno from FOLD_THE_VALUES
  397. <where>
  398. <if test="clock != null and clock != ''">
  399. clock = #{clock}
  400. </if>
  401. </where>
  402. )
  403. </select>
  404. <update id="updateByClockAndMaterialno" parameterType="com.steerinfo.ems.foldthevalues.model.FoldTheValues">
  405. update FOLD_THE_VALUES
  406. set
  407. CLOCK = #{clock,jdbcType=VARCHAR},
  408. CODE = #{code,jdbcType=VARCHAR},
  409. ISAVAILABLE = #{isavailable,jdbcType=VARCHAR},
  410. UNITID = #{unitid,jdbcType=VARCHAR},
  411. TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
  412. MATERIALNO = #{materialno,jdbcType=VARCHAR}
  413. <where>
  414. <if test="clock != null and clock != ''">
  415. and CLOCK = #{clock,jdbcType=VARCHAR}
  416. </if>
  417. <if test="materialno != null and materialno != ''">
  418. and MATERIALNO = #{materialno,jdbcType=VARCHAR}
  419. </if>
  420. </where>
  421. </update>
  422. <select id="getByClockAndMaterialno" parameterType="com.steerinfo.ems.foldthevalues.model.FoldTheValues" resultMap="BaseResultMap">
  423. select * from FOLD_THE_VALUES
  424. <where>
  425. <if test="clock != null and clock != ''">
  426. and CLOCK = #{clock,jdbcType=VARCHAR}
  427. </if>
  428. <if test="materialno != null and materialno != ''">
  429. and MATERIALNO = #{materialno,jdbcType=VARCHAR}
  430. </if>
  431. </where>
  432. </select>
  433. <!--获取月指标数据-->
  434. <select id="getDataForMoth" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  435. select sum(t.ESTIMATEDVALUE) as estimatedvalue, t.MATERIALSOURCE,t.MATERIALNO
  436. from FOLD_THE_VALUES t
  437. <where>
  438. <if test="startTime != null and startTime != '' and endTime != null and endTime !=''">
  439. T.clock between #{startTime} AND
  440. #{endTime}
  441. </if>
  442. </where>
  443. group by t.MATERIALNO,MATERIALSOURCE
  444. </select>
  445. <!--获取物料日折标数据-->
  446. <select id="getDateForwl" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  447. select t2.*
  448. from (select to_char(t.id, 'yyyymmdd') || t.MATERIALNO as id,
  449. t.code as ESTIMATEDVALUE,
  450. to_char(ROUND(((29727 + (10 - t.code) * 334) / 29307.6), 3),
  451. '0.999') as code,
  452. t.MATERIALNO,
  453. MATERIALSOURCE,
  454. to_char(t.id, 'yyyy-mm-dd') as clock
  455. from (select Dates as id,
  456. code,
  457. MATERIALNO,
  458. '机焦厂' as MATERIALSOURCE
  459. from EMS_SCQK_JJ unpivot(code for MATERIALNO in(A as
  460. 'X010'))
  461. union all
  462. select Dates as id,
  463. code,
  464. MATERIALNO,
  465. '机焦厂' as MATERIALSOURCE
  466. from EMS_SCQK_JJ unpivot(code for MATERIALNO in(JM_HF as
  467. 'X005'))
  468. union all
  469. select Dates as id,
  470. code,
  471. MATERIALNO,
  472. '机焦厂' as MATERIALSOURCE
  473. from EMS_SCQK_JJ unpivot(code for MATERIALNO in(A as
  474. 'X018'))) t
  475. <where>
  476. <if test="clock != null and clock != ''">
  477. and t.id = to_date(#{clock}, 'yyyy-mm-dd')
  478. </if>
  479. </where>) t2
  480. where t2.id not in
  481. (select distinct t.id
  482. from FOLD_THE_VALUES t
  483. where
  484. t.materialno in ('X005', 'X018', 'X010'))
  485. </select>
  486. </mapper>