TEnergyInfoMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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.energyMonitor.mapper.TEnergyInfoMapper" >
  4. <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfo" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="v_nh_code" property="vNhCode" jdbcType="VARCHAR" />
  7. <result column="v_nh_name" property="vNhName" jdbcType="VARCHAR" />
  8. <result column="v_hhtype" property="vHhtype" jdbcType="VARCHAR" />
  9. <result column="v_cf_code" property="vCfCode" jdbcType="VARCHAR" />
  10. <result column="f_total_nh" property="fTotalNh" jdbcType="DECIMAL" />
  11. <result column="f_voltage" property="fVoltage" jdbcType="DECIMAL" />
  12. <result column="f_electric" property="fElectric" jdbcType="DECIMAL" />
  13. <result column="v_update_person" property="vUpdatePerson" jdbcType="VARCHAR" />
  14. <result column="v_update_time" property="vUpdateTime" jdbcType="TIMESTAMP" />
  15. <result column="i_tdh" property="iTdh" jdbcType="INTEGER" />
  16. <result column="v_zd_code" property="vZdCode" jdbcType="VARCHAR" />
  17. <result column="v_remark" property="vRemark" jdbcType="VARCHAR" />
  18. <result column="org_id" property="orgId" jdbcType="INTEGER" />
  19. <result column="del_flag" property="delFlag" jdbcType="INTEGER" />
  20. </resultMap>
  21. <sql id="Example_Where_Clause" >
  22. <where >
  23. <foreach collection="oredCriteria" item="criteria" separator="or" >
  24. <if test="criteria.valid" >
  25. <trim prefix="(" suffix=")" prefixOverrides="and" >
  26. <foreach collection="criteria.criteria" item="criterion" >
  27. <choose >
  28. <when test="criterion.noValue" >
  29. and ${criterion.condition}
  30. </when>
  31. <when test="criterion.singleValue" >
  32. and ${criterion.condition} #{criterion.value}
  33. </when>
  34. <when test="criterion.betweenValue" >
  35. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  36. </when>
  37. <when test="criterion.listValue" >
  38. and ${criterion.condition}
  39. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  40. #{listItem}
  41. </foreach>
  42. </when>
  43. </choose>
  44. </foreach>
  45. </trim>
  46. </if>
  47. </foreach>
  48. </where>
  49. </sql>
  50. <sql id="Update_By_Example_Where_Clause" >
  51. <where >
  52. <foreach collection="example.oredCriteria" item="criteria" separator="or" >
  53. <if test="criteria.valid" >
  54. <trim prefix="(" suffix=")" prefixOverrides="and" >
  55. <foreach collection="criteria.criteria" item="criterion" >
  56. <choose >
  57. <when test="criterion.noValue" >
  58. and ${criterion.condition}
  59. </when>
  60. <when test="criterion.singleValue" >
  61. and ${criterion.condition} #{criterion.value}
  62. </when>
  63. <when test="criterion.betweenValue" >
  64. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  65. </when>
  66. <when test="criterion.listValue" >
  67. and ${criterion.condition}
  68. <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
  69. #{listItem}
  70. </foreach>
  71. </when>
  72. </choose>
  73. </foreach>
  74. </trim>
  75. </if>
  76. </foreach>
  77. </where>
  78. </sql>
  79. <sql id="Base_Column_List" >
  80. id, v_nh_code, v_nh_name, v_hhtype, v_cf_code, f_total_nh, f_voltage, f_electric,
  81. v_update_person, v_update_time, i_tdh, v_zd_code, v_remark, org_id, del_flag
  82. </sql>
  83. <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfoExample" >
  84. select
  85. <if test="distinct" >
  86. distinct
  87. </if>
  88. <include refid="Base_Column_List" />
  89. from t_energy_info
  90. <if test="_parameter != null" >
  91. <include refid="Example_Where_Clause" />
  92. </if>
  93. <if test="orderByClause != null" >
  94. order by ${orderByClause}
  95. </if>
  96. </select>
  97. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  98. select
  99. <include refid="Base_Column_List" />
  100. from t_energy_info
  101. where id = #{id,jdbcType=VARCHAR}
  102. </select>
  103. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  104. delete from t_energy_info
  105. where id = #{id,jdbcType=VARCHAR}
  106. </delete>
  107. <delete id="deleteByExample" parameterType="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfoExample" >
  108. delete from t_energy_info
  109. <if test="_parameter != null" >
  110. <include refid="Example_Where_Clause" />
  111. </if>
  112. </delete>
  113. <insert id="insert" parameterType="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfo" >
  114. insert into t_energy_info (id, v_nh_code, v_nh_name,
  115. v_hhtype, v_cf_code, f_total_nh,
  116. f_voltage, f_electric, v_update_person,
  117. v_update_time, i_tdh, v_zd_code,
  118. v_remark, org_id, del_flag
  119. )
  120. values (#{id,jdbcType=VARCHAR}, #{vNhCode,jdbcType=VARCHAR}, #{vNhName,jdbcType=VARCHAR},
  121. #{vHhtype,jdbcType=VARCHAR}, #{vCfCode,jdbcType=VARCHAR}, #{fTotalNh,jdbcType=DECIMAL},
  122. #{fVoltage,jdbcType=DECIMAL}, #{fElectric,jdbcType=DECIMAL}, #{vUpdatePerson,jdbcType=VARCHAR},
  123. #{vUpdateTime,jdbcType=TIMESTAMP}, #{iTdh,jdbcType=INTEGER}, #{vZdCode,jdbcType=VARCHAR},
  124. #{vRemark,jdbcType=VARCHAR}, #{orgId,jdbcType=INTEGER}, #{delFlag,jdbcType=INTEGER}
  125. )
  126. </insert>
  127. <insert id="insertSelective" parameterType="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfo" >
  128. insert into t_energy_info
  129. <trim prefix="(" suffix=")" suffixOverrides="," >
  130. <if test="id != null" >
  131. id,
  132. </if>
  133. <if test="vNhCode != null" >
  134. v_nh_code,
  135. </if>
  136. <if test="vNhName != null" >
  137. v_nh_name,
  138. </if>
  139. <if test="vHhtype != null" >
  140. v_hhtype,
  141. </if>
  142. <if test="vCfCode != null" >
  143. v_cf_code,
  144. </if>
  145. <if test="fTotalNh != null" >
  146. f_total_nh,
  147. </if>
  148. <if test="fVoltage != null" >
  149. f_voltage,
  150. </if>
  151. <if test="fElectric != null" >
  152. f_electric,
  153. </if>
  154. <if test="vUpdatePerson != null" >
  155. v_update_person,
  156. </if>
  157. <if test="vUpdateTime != null" >
  158. v_update_time,
  159. </if>
  160. <if test="iTdh != null" >
  161. i_tdh,
  162. </if>
  163. <if test="vZdCode != null" >
  164. v_zd_code,
  165. </if>
  166. <if test="vRemark != null" >
  167. v_remark,
  168. </if>
  169. <if test="orgId != null" >
  170. org_id,
  171. </if>
  172. <if test="delFlag != null" >
  173. del_flag,
  174. </if>
  175. </trim>
  176. <trim prefix="values (" suffix=")" suffixOverrides="," >
  177. <if test="id != null" >
  178. #{id,jdbcType=VARCHAR},
  179. </if>
  180. <if test="vNhCode != null" >
  181. #{vNhCode,jdbcType=VARCHAR},
  182. </if>
  183. <if test="vNhName != null" >
  184. #{vNhName,jdbcType=VARCHAR},
  185. </if>
  186. <if test="vHhtype != null" >
  187. #{vHhtype,jdbcType=VARCHAR},
  188. </if>
  189. <if test="vCfCode != null" >
  190. #{vCfCode,jdbcType=VARCHAR},
  191. </if>
  192. <if test="fTotalNh != null" >
  193. #{fTotalNh,jdbcType=DECIMAL},
  194. </if>
  195. <if test="fVoltage != null" >
  196. #{fVoltage,jdbcType=DECIMAL},
  197. </if>
  198. <if test="fElectric != null" >
  199. #{fElectric,jdbcType=DECIMAL},
  200. </if>
  201. <if test="vUpdatePerson != null" >
  202. #{vUpdatePerson,jdbcType=VARCHAR},
  203. </if>
  204. <if test="vUpdateTime != null" >
  205. #{vUpdateTime,jdbcType=TIMESTAMP},
  206. </if>
  207. <if test="iTdh != null" >
  208. #{iTdh,jdbcType=INTEGER},
  209. </if>
  210. <if test="vZdCode != null" >
  211. #{vZdCode,jdbcType=VARCHAR},
  212. </if>
  213. <if test="vRemark != null" >
  214. #{vRemark,jdbcType=VARCHAR},
  215. </if>
  216. <if test="orgId != null" >
  217. #{orgId,jdbcType=INTEGER},
  218. </if>
  219. <if test="delFlag != null" >
  220. #{delFlag,jdbcType=INTEGER},
  221. </if>
  222. </trim>
  223. </insert>
  224. <select id="countByExample" parameterType="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfoExample" resultType="java.lang.Integer" >
  225. select count(*) from t_energy_info
  226. <if test="_parameter != null" >
  227. <include refid="Example_Where_Clause" />
  228. </if>
  229. </select>
  230. <update id="updateByExampleSelective" parameterType="map" >
  231. update t_energy_info
  232. <set >
  233. <if test="record.id != null" >
  234. id = #{record.id,jdbcType=VARCHAR},
  235. </if>
  236. <if test="record.vNhCode != null" >
  237. v_nh_code = #{record.vNhCode,jdbcType=VARCHAR},
  238. </if>
  239. <if test="record.vNhName != null" >
  240. v_nh_name = #{record.vNhName,jdbcType=VARCHAR},
  241. </if>
  242. <if test="record.vHhtype != null" >
  243. v_hhtype = #{record.vHhtype,jdbcType=VARCHAR},
  244. </if>
  245. <if test="record.vCfCode != null" >
  246. v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
  247. </if>
  248. <if test="record.fTotalNh != null" >
  249. f_total_nh = #{record.fTotalNh,jdbcType=DECIMAL},
  250. </if>
  251. <if test="record.fVoltage != null" >
  252. f_voltage = #{record.fVoltage,jdbcType=DECIMAL},
  253. </if>
  254. <if test="record.fElectric != null" >
  255. f_electric = #{record.fElectric,jdbcType=DECIMAL},
  256. </if>
  257. <if test="record.vUpdatePerson != null" >
  258. v_update_person = #{record.vUpdatePerson,jdbcType=VARCHAR},
  259. </if>
  260. <if test="record.vUpdateTime != null" >
  261. v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
  262. </if>
  263. <if test="record.iTdh != null" >
  264. i_tdh = #{record.iTdh,jdbcType=INTEGER},
  265. </if>
  266. <if test="record.vZdCode != null" >
  267. v_zd_code = #{record.vZdCode,jdbcType=VARCHAR},
  268. </if>
  269. <if test="record.vRemark != null" >
  270. v_remark = #{record.vRemark,jdbcType=VARCHAR},
  271. </if>
  272. <if test="record.orgId != null" >
  273. org_id = #{record.orgId,jdbcType=INTEGER},
  274. </if>
  275. <if test="record.delFlag != null" >
  276. del_flag = #{record.delFlag,jdbcType=INTEGER},
  277. </if>
  278. </set>
  279. <if test="_parameter != null" >
  280. <include refid="Update_By_Example_Where_Clause" />
  281. </if>
  282. </update>
  283. <update id="updateByExample" parameterType="map" >
  284. update t_energy_info
  285. set id = #{record.id,jdbcType=VARCHAR},
  286. v_nh_code = #{record.vNhCode,jdbcType=VARCHAR},
  287. v_nh_name = #{record.vNhName,jdbcType=VARCHAR},
  288. v_hhtype = #{record.vHhtype,jdbcType=VARCHAR},
  289. v_cf_code = #{record.vCfCode,jdbcType=VARCHAR},
  290. f_total_nh = #{record.fTotalNh,jdbcType=DECIMAL},
  291. f_voltage = #{record.fVoltage,jdbcType=DECIMAL},
  292. f_electric = #{record.fElectric,jdbcType=DECIMAL},
  293. v_update_person = #{record.vUpdatePerson,jdbcType=VARCHAR},
  294. v_update_time = #{record.vUpdateTime,jdbcType=TIMESTAMP},
  295. i_tdh = #{record.iTdh,jdbcType=INTEGER},
  296. v_zd_code = #{record.vZdCode,jdbcType=VARCHAR},
  297. v_remark = #{record.vRemark,jdbcType=VARCHAR},
  298. org_id = #{record.orgId,jdbcType=INTEGER},
  299. del_flag = #{record.delFlag,jdbcType=INTEGER}
  300. <if test="_parameter != null" >
  301. <include refid="Update_By_Example_Where_Clause" />
  302. </if>
  303. </update>
  304. <update id="updateByPrimaryKeySelective" parameterType="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfo" >
  305. update t_energy_info
  306. <set >
  307. <if test="vNhCode != null" >
  308. v_nh_code = #{vNhCode,jdbcType=VARCHAR},
  309. </if>
  310. <if test="vNhName != null" >
  311. v_nh_name = #{vNhName,jdbcType=VARCHAR},
  312. </if>
  313. <if test="vHhtype != null" >
  314. v_hhtype = #{vHhtype,jdbcType=VARCHAR},
  315. </if>
  316. <if test="vCfCode != null" >
  317. v_cf_code = #{vCfCode,jdbcType=VARCHAR},
  318. </if>
  319. <if test="fTotalNh != null" >
  320. f_total_nh = #{fTotalNh,jdbcType=DECIMAL},
  321. </if>
  322. <if test="fVoltage != null" >
  323. f_voltage = #{fVoltage,jdbcType=DECIMAL},
  324. </if>
  325. <if test="fElectric != null" >
  326. f_electric = #{fElectric,jdbcType=DECIMAL},
  327. </if>
  328. <if test="vUpdatePerson != null" >
  329. v_update_person = #{vUpdatePerson,jdbcType=VARCHAR},
  330. </if>
  331. <if test="vUpdateTime != null" >
  332. v_update_time = #{vUpdateTime,jdbcType=TIMESTAMP},
  333. </if>
  334. <if test="iTdh != null" >
  335. i_tdh = #{iTdh,jdbcType=INTEGER},
  336. </if>
  337. <if test="vZdCode != null" >
  338. v_zd_code = #{vZdCode,jdbcType=VARCHAR},
  339. </if>
  340. <if test="vRemark != null" >
  341. v_remark = #{vRemark,jdbcType=VARCHAR},
  342. </if>
  343. <if test="orgId != null" >
  344. org_id = #{orgId,jdbcType=INTEGER},
  345. </if>
  346. <if test="delFlag != null" >
  347. del_flag = #{delFlag,jdbcType=INTEGER},
  348. </if>
  349. </set>
  350. where id = #{id,jdbcType=VARCHAR}
  351. </update>
  352. <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.intelligent.energyMonitor.model.TEnergyInfo" >
  353. update t_energy_info
  354. set v_nh_code = #{vNhCode,jdbcType=VARCHAR},
  355. v_nh_name = #{vNhName,jdbcType=VARCHAR},
  356. v_hhtype = #{vHhtype,jdbcType=VARCHAR},
  357. v_cf_code = #{vCfCode,jdbcType=VARCHAR},
  358. f_total_nh = #{fTotalNh,jdbcType=DECIMAL},
  359. f_voltage = #{fVoltage,jdbcType=DECIMAL},
  360. f_electric = #{fElectric,jdbcType=DECIMAL},
  361. v_update_person = #{vUpdatePerson,jdbcType=VARCHAR},
  362. v_update_time = #{vUpdateTime,jdbcType=TIMESTAMP},
  363. i_tdh = #{iTdh,jdbcType=INTEGER},
  364. v_zd_code = #{vZdCode,jdbcType=VARCHAR},
  365. v_remark = #{vRemark,jdbcType=VARCHAR},
  366. org_id = #{orgId,jdbcType=INTEGER},
  367. del_flag = #{delFlag,jdbcType=INTEGER}
  368. where id = #{id,jdbcType=VARCHAR}
  369. </update>
  370. <select id="queryMeter" resultMap="BaseResultMap" parameterType="map" >
  371. select
  372. ei.id, ei.v_nh_code, ei.v_nh_name, ei.v_hhtype, ei.v_cf_code, ei.f_total_nh, ei.f_voltage, ei.f_electric,
  373. ei.v_update_person, ei.v_update_time, ei.i_tdh, ei.v_zd_code, ei.v_remark, ei.org_id
  374. from t_energy_info ei
  375. inner join basic_storehouse bs on bs.storehouse_code = ei.v_cf_code and ei.org_id = bs.org_id
  376. <where>
  377. ei.del_flag = 1 and bs.del_flag = 1
  378. <if test="deviceNumber!=null">
  379. and ei.v_nh_code = '${deviceNumber}'
  380. </if>
  381. <if test="orgId!=null">
  382. and ei.org_id = ${orgId}
  383. </if>
  384. </where>
  385. </select>
  386. <select id="queryDeviceList" resultMap="BaseResultMap" parameterType="map" >
  387. select distinct v_nh_code
  388. from t_energy_info ei
  389. inner join basic_storehouse bs on bs.storehouse_code = ei.v_cf_code AND ei.org_id = bs.org_id
  390. <where>
  391. bs.del_flag = 1 AND ei.del_flag = 1
  392. <if test="orgId!=null">
  393. and ei.org_id = ${orgId}
  394. </if>
  395. </where>
  396. </select>
  397. <select id="getTrendThreePage" resultType="java.util.Map" parameterType="map" >
  398. SELECT
  399. DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') vUpdateTime,
  400. IFNULL(FJ.f_total_nh,'0') fj,IFNULL(ZM.f_total_nh,'0') zm,IFNULL(CZ.f_total_nh,'0') cz
  401. from t_energy_info ei
  402. inner join basic_storehouse bs on bs.storehouse_code = ei.v_cf_code
  403. LEFT JOIN (
  404. SELECT DATE_FORMAT(v_update_time, '%Y-%m-%d') vUpdateTime,MAX(f_total_nh) f_total_nh from t_energy_info
  405. WHERE v_hhtype = '6947'
  406. GROUP BY DATE_FORMAT(v_update_time, '%Y-%m-%d')
  407. ) FJ ON FJ.vUpdateTime = DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  408. LEFT JOIN (
  409. SELECT DATE_FORMAT(v_update_time, '%Y-%m-%d') vUpdateTime,MAX(f_total_nh) f_total_nh from t_energy_info
  410. WHERE v_hhtype = '6948'
  411. GROUP BY DATE_FORMAT(v_update_time, '%Y-%m-%d')
  412. ) ZM ON ZM.vUpdateTime = DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  413. LEFT JOIN (
  414. SELECT DATE_FORMAT(v_update_time, '%Y-%m-%d') vUpdateTime,MAX(f_total_nh) f_total_nh from t_energy_info
  415. WHERE v_hhtype = '6949'
  416. GROUP BY DATE_FORMAT(v_update_time, '%Y-%m-%d')
  417. ) CZ ON CZ.vUpdateTime = DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  418. <where>
  419. <if test="deviceNumber!=null">
  420. and ei.v_nh_code = '${deviceNumber}'
  421. </if>
  422. <if test="orgId!=null">
  423. and bs.depot_id = ${orgId}
  424. </if>
  425. <if test="startDate != null and startDate != ''">
  426. and ei.v_update_time >= #{startDate,jdbcType=TIMESTAMP}
  427. </if>
  428. <if test="endDate != null and endDate != ''">
  429. and #{endDate,jdbcType=TIMESTAMP} >= ei.v_update_time
  430. </if>
  431. </where>
  432. GROUP BY DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  433. </select>
  434. <select id="getTimePointThreePage" resultType="java.util.Map" parameterType="map" >
  435. SELECT
  436. DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') vUpdateTime,
  437. IFNULL(FJ.f_total_nh,'0') fj,IFNULL(ZM.f_total_nh,'0') zm,IFNULL(CZ.f_total_nh,'0') cz
  438. from t_energy_info ei
  439. inner join basic_storehouse bs on bs.storehouse_code = ei.v_cf_code
  440. LEFT JOIN (
  441. SELECT DATE_FORMAT(v_update_time, '%Y-%m-%d') vUpdateTime,MAX(f_total_nh) f_total_nh from t_energy_info
  442. WHERE v_hhtype = '6947'
  443. GROUP BY DATE_FORMAT(v_update_time, '%Y-%m-%d')
  444. ) FJ ON FJ.vUpdateTime = DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  445. LEFT JOIN (
  446. SELECT DATE_FORMAT(v_update_time, '%Y-%m-%d') vUpdateTime,MAX(f_total_nh) f_total_nh from t_energy_info
  447. WHERE v_hhtype = '6948'
  448. GROUP BY DATE_FORMAT(v_update_time, '%Y-%m-%d')
  449. ) ZM ON ZM.vUpdateTime = DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  450. LEFT JOIN (
  451. SELECT DATE_FORMAT(v_update_time, '%Y-%m-%d') vUpdateTime,MAX(f_total_nh) f_total_nh from t_energy_info
  452. WHERE v_hhtype = '6949'
  453. GROUP BY DATE_FORMAT(v_update_time, '%Y-%m-%d')
  454. ) CZ ON CZ.vUpdateTime = DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  455. <where>
  456. <if test="deviceNumber!=null">
  457. and ei.v_nh_code = '${deviceNumber}'
  458. </if>
  459. <if test="orgId!=null">
  460. and bs.depot_id = ${orgId}
  461. </if>
  462. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  463. and (DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') = #{startDate,jdbcType=TIMESTAMP}
  464. or DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') = #{endDate,jdbcType=TIMESTAMP} )
  465. </if>
  466. <if test="startDate != null and startDate != '' and (endDate == null or endDate == '')">
  467. and (DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') = #{startDate,jdbcType=TIMESTAMP})
  468. </if>
  469. <if test="(startDate == null or startDate == '') and endDate != null and endDate != ''">
  470. and (DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') = #{endDate,jdbcType=TIMESTAMP} )
  471. </if>
  472. </where>
  473. GROUP BY DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  474. </select>
  475. <select id="getTimeThreePage" resultType="java.util.Map" parameterType="map" >
  476. SELECT
  477. DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') vUpdateTime,
  478. IFNULL(MAX(ei.f_total_nh),'0') fTotalNh
  479. from t_energy_info ei
  480. inner join basic_storehouse bs on bs.storehouse_code = ei.v_cf_code
  481. <where>
  482. <if test="deviceNumber!=null">
  483. and ei.v_nh_code = '${deviceNumber}'
  484. </if>
  485. <if test="orgId!=null">
  486. and bs.depot_id = ${orgId}
  487. </if>
  488. <if test="type!=null">
  489. and ei.v_hhtype = '${type}'
  490. </if>
  491. <if test="startDate != null and startDate != ''">
  492. and ei.v_update_time >= #{startDate,jdbcType=TIMESTAMP}
  493. </if>
  494. <if test="endDate != null and endDate != ''">
  495. and #{endDate,jdbcType=TIMESTAMP} >= ei.v_update_time
  496. </if>
  497. </where>
  498. GROUP BY DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  499. </select>
  500. <select id="getDailyConsumptionList" resultMap="BaseResultMap" parameterType="map" >
  501. select
  502. group_concat(distinct bs.storehouse_name) v_cf_code,ei.v_nh_code,IFNULL(SUM(ei.f_total_nh),'0') f_total_nh,
  503. ei.v_hhtype,ei.v_update_time
  504. from t_energy_info ei
  505. inner join basic_storehouse bs on bs.storehouse_code = ei.v_cf_code
  506. <where>
  507. <if test="vnhcode!=null">
  508. and ei.v_nh_code = '${vnhcode}'
  509. </if>
  510. <if test="vhhtype!=null">
  511. and ei.v_hhtype = '${vhhtype}'
  512. </if>
  513. <if test="orgId!=null">
  514. and bs.depot_id = ${orgId}
  515. </if>
  516. </where>
  517. GROUP BY DATE_FORMAT(ei.v_update_time, '%Y-%m-%d')
  518. ORDER BY DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') DESC
  519. </select>
  520. <select id="getAmmeterPageInfo" resultMap="BaseResultMap" parameterType="map" >
  521. select DISTINCT
  522. ei.id, ei.v_nh_code, ei.v_nh_name, ei.v_hhtype, ei.v_cf_code, ei.f_total_nh, ei.f_voltage, ei.f_electric,
  523. ei.v_update_person, ei.v_update_time, ei.i_tdh, ei.v_zd_code, ei.v_remark, ei.org_id, ei.del_flag
  524. from t_energy_info ei
  525. inner join basic_storehouse bs on bs.storehouse_code = ei.v_cf_code
  526. <where>
  527. <if test="vcfcode!=null and vcfcode!=''">
  528. and ei.v_cf_code = '${vcfcode}'
  529. </if>
  530. <if test="vhhtype!=null and vhhtype!=''">
  531. and ei.v_hhtype = '${vhhtype}'
  532. </if>
  533. <if test="orgId!=null">
  534. and bs.depot_id = ${orgId}
  535. </if>
  536. <if test="delFlag!=null">
  537. and ei.del_flag =${delFlag}
  538. </if>
  539. </where>
  540. ORDER BY DATE_FORMAT(ei.v_update_time, '%Y-%m-%d') DESC
  541. </select>
  542. <select id="validCode" parameterType="map" resultMap="BaseResultMap">
  543. select
  544. <include refid="Base_Column_List" />
  545. from t_energy_info
  546. <where>
  547. <if test="id!=null">
  548. and id != '${id}'
  549. </if>
  550. <if test="vNhCode!=null">
  551. and v_nh_code = '${vNhCode}'
  552. </if>
  553. </where>
  554. </select>
  555. <insert id="insertBatch" parameterType="java.util.List">
  556. insert into t_energy_info (id, v_nh_code, v_nh_name,
  557. v_hhtype, v_cf_code, f_total_nh,
  558. f_voltage, f_electric, v_update_person,
  559. v_update_time, i_tdh, v_zd_code,
  560. v_remark, org_id)
  561. values
  562. <foreach collection="list" item="energy" index="index" separator=",">
  563. (#{energy.id,jdbcType=VARCHAR}, #{energy.vNhCode,jdbcType=VARCHAR}, #{energy.vNhName,jdbcType=VARCHAR},
  564. #{energy.vHhtype,jdbcType=VARCHAR}, #{energy.vCfCode,jdbcType=VARCHAR}, #{energy.fTotalNh,jdbcType=DECIMAL},
  565. #{energy.fVoltage,jdbcType=DECIMAL}, #{energy.fElectric,jdbcType=DECIMAL}, #{energy.vUpdatePerson,jdbcType=VARCHAR},
  566. #{energy.vUpdateTime,jdbcType=TIMESTAMP}, #{energy.iTdh,jdbcType=INTEGER}, #{energy.vZdCode,jdbcType=VARCHAR},
  567. #{energy.vRemark,jdbcType=VARCHAR}, #{energy.orgId,jdbcType=INTEGER})
  568. </foreach>
  569. </insert>
  570. <select id="getTEnergyInfo" parameterType="map" resultMap="BaseResultMap">
  571. select
  572. <include refid="Base_Column_List" />
  573. from t_energy_info
  574. <where>
  575. <if test="vNhCode!=null">
  576. and v_nh_code = '${vNhCode}'
  577. </if>
  578. <if test="siteCode!=null">
  579. and v_zd_code = '${siteCode}'
  580. </if>
  581. </where>
  582. </select>
  583. </mapper>