TSpecdevDzsbMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.project.sems.mapper.TSpecdevDzsbMapper">
  6. <resultMap type="TSpecdevDzsb" id="TSpecdevDzsbResult">
  7. <result property="id" column="id" />
  8. <result property="plantCode" column="plant_code" />
  9. <result property="unit" column="unit" />
  10. <result property="devname" column="devname" />
  11. <result property="devno" column="devno" />
  12. <result property="submitdate" column="submitdate" />
  13. <result property="status" column="status" />
  14. <result property="delFlag" column="del_flag" />
  15. <result property="createrCode" column="creater_code" />
  16. <result property="createdate" column="createdate" />
  17. <result property="updaterCode" column="updater_code" />
  18. <result property="updatedate" column="updatedate" />
  19. <result property="deptId" column="dept_id" />
  20. <result property="remarks" column="remarks" />
  21. <result property="approveStatus" column="approve_status" />
  22. <result property="regno" column="regno" />
  23. <result property="useno" column="useno" />
  24. <result property="warnDate" column="warn_date" />
  25. <result property="warnCycle" column="warn_cycle" />
  26. <result property="nextWarnDate" column="next_warn_date" />
  27. <result property="warnFlag" column="warn_flag" />
  28. <result property="plantMaint" column="plant_maint" />
  29. <result property="docno" column="docno" />
  30. <result property="model" column="model" />
  31. <result property="capacity" column="capacity" />
  32. <result property="location" column="location" />
  33. <result property="createUnit" column="create_unit" />
  34. <result property="checkStrategy" column="check_strategy" />
  35. <result property="yearMaint" column="year_maint" />
  36. <result property="reportNo" column="report_no" />
  37. <result property="approveTime" column="approve_time" />
  38. <result property="changeTime" column="change_time" />
  39. <result property="checkUnit" column="check_unit" />
  40. <result property="engineer" column="engineer" />
  41. <result property="isEx" column="is_ex" />
  42. <result property="hiFlag" column="hiFlag" />
  43. <result property="perTestConclusion" column="per_test_conclusion" />
  44. <result property="isRepeat" column="is_repeat"/>
  45. <result property="factoryNo" column="factory_no"/>
  46. <result property="devCode" column="dev_code"/>
  47. </resultMap>
  48. <sql id="selectTSpecdevDzsbVo">
  49. select d.id, d.plant_code, d.unit, d.devname,d.dev_code,d.factory_no, d.devno, d.submitdate, d.status, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks, d.approve_status, d.regno, d.useno, d.warn_date, d.warn_cycle, d.next_warn_date, d.warn_flag, d.plant_maint, d.docno, d.model, d.capacity, d.location, d.create_unit, d.check_strategy, d.year_maint, d.report_no, d.approve_time, d.change_time, d.check_unit, d.engineer, d.is_ex ,s.dept_name,
  50. (SELECT COUNT(1) from T_SPECHI_DZSB h where h.DEV_ID = d.id and HI_TYPE = 0 ) as hiFlag, per_test_conclusion
  51. ,d.is_repeat
  52. from t_specdev_dzsb d
  53. left join sys_dept s on s.dept_id = d.dept_id
  54. </sql>
  55. <select id="selectTSpecdevDzsbList" parameterType="TSpecdevDzsb" resultMap="TSpecdevDzsbResult">
  56. <include refid="selectTSpecdevDzsbVo"/>
  57. <where>
  58. <if test="plantCode != null and plantCode != ''"> and plant_code like concat(concat('%', #{plantCode}), '%')</if>
  59. <if test="unit != null and unit != ''"> and unit like concat(concat('%', #{unit}), '%') </if>
  60. <if test="devname != null and devname != ''"> and devname like concat(concat('%', #{devname}), '%')</if>
  61. <if test="devno != null and devno != ''"> and devno like concat(concat('%', #{devno}), '%') </if>
  62. <if test="submitdate != null "> and submitdate = #{submitdate}</if>
  63. <if test="status != null "> and d.status = #{status}</if>
  64. <if test="approveStatus != null ">and approve_status = #{approveStatus}</if>
  65. <if test="warnFlag != null ">and warn_Flag = #{warnFlag}</if>
  66. <if test="searchValue != null and searchValue != ''">
  67. and
  68. (plant_code like concat(concat('%', #{searchValue}), '%')
  69. or unit like concat(concat('%', #{searchValue}), '%')
  70. or devname like concat(concat('%', #{searchValue}), '%')
  71. or devno like concat(concat('%', #{searchValue}), '%')
  72. )
  73. </if>
  74. <if test="isRepeat != null and isRepeat != ''">
  75. <if test="isRepeat == 2 ">
  76. and (d.DEVNO,d.DOCNO, d.PLANT_CODE, d.DEL_FLAG, d.APPROVE_STATUS) IN (
  77. SELECT DEVNO,DOCNO, PLANT_CODE, DEL_FLAG, APPROVE_STATUS
  78. FROM T_SPECDEV_DZSB
  79. WHERE DEL_FLAG = 0 AND APPROVE_STATUS = 0
  80. GROUP BY DEVNO,DOCNO, PLANT_CODE, DEL_FLAG, APPROVE_STATUS
  81. HAVING COUNT(*) > 1
  82. )
  83. </if>
  84. </if>
  85. and d.del_flag = 0
  86. </where>
  87. <!-- 数据范围过滤 -->
  88. ${params.dataScopePlant}
  89. order by d.is_repeat desc, d.plant_code, d.unit, d.id
  90. </select>
  91. <select id="selectExpiredDzsb" parameterType="TSpecdevDzsb" resultMap="TSpecdevDzsbResult">
  92. select d.id, d.plant_code, d.unit, d.devname,d.dev_code,d.factory_no, d.devno, d.submitdate, d.status, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks, d.approve_status, d.regno, d.useno, d.warn_date, d.warn_cycle, d.next_warn_date, d.warn_flag, d.plant_maint, d.docno, d.model, d.capacity, d.location, d.create_unit, d.check_strategy, d.year_maint, d.report_no, d.approve_time, d.change_time, d.check_unit, d.engineer, d.is_ex
  93. from t_specdev_dzsb d
  94. where SYSDATE > NEXT_WARN_DATE
  95. and DEL_FLAG = 0
  96. and STATUS = 1
  97. order by d.plant_code asc
  98. </select>
  99. <select id="selectTSpecdevDzsbListByYear" parameterType="TSpecdevDzsb" resultMap="TSpecdevDzsbResult">
  100. <include refid="selectTSpecdevDzsbVo"/>
  101. <where>
  102. <if test="checkYear != null ">and to_char(NEXT_WARN_DATE,'yyyyMM') = #{checkYear}</if>
  103. <if test="plantIds != null and plantIds != ''">
  104. and
  105. d.plant_code in
  106. <foreach collection="plantIds.split(',')" item="item" index="index"
  107. open="(" close=")" separator=",">
  108. #{item}
  109. </foreach>
  110. </if>
  111. <!--<if test="unitIds != null and unitIds != ''">
  112. and
  113. (
  114. d.unit in
  115. <foreach collection="unitIds.split(',')" item="item" index="index"
  116. open="(" close=")" separator=",">
  117. #{item}
  118. </foreach>
  119. )
  120. </if>-->
  121. and d.del_flag = 0
  122. and d.status = 1
  123. </where>
  124. </select>
  125. <select id="selectTSpecdevDzsbById" parameterType="Long" resultMap="TSpecdevDzsbResult">
  126. <include refid="selectTSpecdevDzsbVo"/>
  127. where id = #{id}
  128. </select>
  129. <insert id="insertTSpecdevDzsb" parameterType="TSpecdevDzsb">
  130. <selectKey keyProperty="id" resultType="long" order="BEFORE">
  131. SELECT seq_t_specdev_ylrq.NEXTVAL as id FROM DUAL
  132. </selectKey>
  133. insert into t_specdev_dzsb
  134. <trim prefix="(" suffix=")" suffixOverrides=",">
  135. <if test="id != null">id,</if>
  136. <if test="plantCode != null and plantCode != ''">plant_code,</if>
  137. <if test="unit != null">unit,</if>
  138. <if test="devname != null">devname,</if>
  139. <if test="devno != null">devno,</if>
  140. <if test="submitdate != null">submitdate,</if>
  141. <if test="status != null">status,</if>
  142. <if test="delFlag != null">del_flag,</if>
  143. <if test="createrCode != null">creater_code,</if>
  144. <if test="createdate != null">createdate,</if>
  145. <if test="updaterCode != null">updater_code,</if>
  146. <if test="updatedate != null">updatedate,</if>
  147. <if test="deptId != null">dept_id,</if>
  148. <if test="remarks != null">remarks,</if>
  149. <if test="approveStatus != null">approve_status,</if>
  150. <if test="regno != null">regno,</if>
  151. <if test="useno != null">useno,</if>
  152. <if test="warnDate != null">warn_date,</if>
  153. <if test="warnCycle != null">warn_cycle,</if>
  154. <if test="nextWarnDate != null">next_warn_date,</if>
  155. <if test="warnFlag != null">warn_flag,</if>
  156. <if test="plantMaint != null">plant_maint,</if>
  157. <if test="docno != null">docno,</if>
  158. <if test="model != null">model,</if>
  159. <if test="capacity != null">capacity,</if>
  160. <if test="location != null">location,</if>
  161. <if test="createUnit != null">create_unit,</if>
  162. <if test="checkStrategy != null">check_strategy,</if>
  163. <if test="yearMaint != null">year_maint,</if>
  164. <if test="reportNo != null">report_no,</if>
  165. <if test="approveTime != null">approve_time,</if>
  166. <if test="changeTime != null">change_time,</if>
  167. <if test="checkUnit != null">check_unit,</if>
  168. <if test="engineer != null">engineer,</if>
  169. <if test="isEx != null">is_ex,</if>
  170. <if test="perTestConclusion != null">per_test_conclusion,</if>
  171. <if test="factoryNo != null">factory_no,</if>
  172. <if test="devCode != null">dev_code,</if>
  173. </trim>
  174. <trim prefix="values (" suffix=")" suffixOverrides=",">
  175. <if test="id != null">#{id},</if>
  176. <if test="plantCode != null and plantCode != ''">#{plantCode},</if>
  177. <if test="unit != null">#{unit},</if>
  178. <if test="devname != null">#{devname},</if>
  179. <if test="devno != null">#{devno},</if>
  180. <if test="submitdate != null">#{submitdate},</if>
  181. <if test="status != null">#{status},</if>
  182. <if test="delFlag != null">#{delFlag},</if>
  183. <if test="createrCode != null">#{createrCode},</if>
  184. <if test="createdate != null">#{createdate},</if>
  185. <if test="updaterCode != null">#{updaterCode},</if>
  186. <if test="updatedate != null">#{updatedate},</if>
  187. <if test="deptId != null">#{deptId},</if>
  188. <if test="remarks != null">#{remarks},</if>
  189. <if test="approveStatus != null">#{approveStatus},</if>
  190. <if test="regno != null">#{regno},</if>
  191. <if test="useno != null">#{useno},</if>
  192. <if test="warnDate != null">#{warnDate},</if>
  193. <if test="warnCycle != null">#{warnCycle},</if>
  194. <if test="nextWarnDate != null">#{nextWarnDate},</if>
  195. <if test="warnFlag != null">#{warnFlag},</if>
  196. <if test="plantMaint != null">#{plantMaint},</if>
  197. <if test="docno != null">#{docno},</if>
  198. <if test="model != null">#{model},</if>
  199. <if test="capacity != null">#{capacity},</if>
  200. <if test="location != null">#{location},</if>
  201. <if test="createUnit != null">#{createUnit},</if>
  202. <if test="checkStrategy != null">#{checkStrategy},</if>
  203. <if test="yearMaint != null">#{yearMaint},</if>
  204. <if test="reportNo != null">#{reportNo},</if>
  205. <if test="approveTime != null">#{approveTime},</if>
  206. <if test="changeTime != null">#{changeTime},</if>
  207. <if test="checkUnit != null">#{checkUnit},</if>
  208. <if test="engineer != null">#{engineer},</if>
  209. <if test="isEx != null">#{isEx},</if>
  210. <if test="perTestConclusion != null">#{perTestConclusion},</if>
  211. <if test="factoryNo != null">#{factoryNo},</if>
  212. <if test="devCode != null">#{devCode},</if>
  213. </trim>
  214. </insert>
  215. <update id="updateTSpecdevDzsb" parameterType="TSpecdevDzsb">
  216. update t_specdev_dzsb
  217. <trim prefix="SET" suffixOverrides=",">
  218. <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
  219. <if test="unit != null">unit = #{unit},</if>
  220. <if test="devname != null">devname = #{devname},</if>
  221. <if test="devno != null">devno = #{devno},</if>
  222. <if test="submitdate != null">submitdate = #{submitdate},</if>
  223. <if test="status != null">status = #{status},</if>
  224. <if test="delFlag != null">del_flag = #{delFlag},</if>
  225. <if test="createrCode != null">creater_code = #{createrCode},</if>
  226. <if test="createdate != null">createdate = #{createdate},</if>
  227. <if test="updaterCode != null">updater_code = #{updaterCode},</if>
  228. <if test="updatedate != null">updatedate = #{updatedate},</if>
  229. <if test="deptId != null">dept_id = #{deptId},</if>
  230. <if test="remarks != null">remarks = #{remarks},</if>
  231. <if test="approveStatus != null">approve_status = #{approveStatus},</if>
  232. <if test="regno != null">regno = #{regno},</if>
  233. <if test="useno != null">useno = #{useno},</if>
  234. <if test="warnDate != null">warn_date = #{warnDate},</if>
  235. <if test="warnCycle != null">warn_cycle = #{warnCycle},</if>
  236. <if test="nextWarnDate != null">next_warn_date = #{nextWarnDate},</if>
  237. <if test="warnFlag != null">warn_flag = #{warnFlag},</if>
  238. <if test="plantMaint != null">plant_maint = #{plantMaint},</if>
  239. <if test="docno != null">docno = #{docno},</if>
  240. <if test="model != null">model = #{model},</if>
  241. <if test="capacity != null">capacity = #{capacity},</if>
  242. <if test="location != null">location = #{location},</if>
  243. <if test="createUnit != null">create_unit = #{createUnit},</if>
  244. <if test="checkStrategy != null">check_strategy = #{checkStrategy},</if>
  245. <if test="yearMaint != null">year_maint = #{yearMaint},</if>
  246. <if test="reportNo != null">report_no = #{reportNo},</if>
  247. <if test="approveTime != null">approve_time = #{approveTime},</if>
  248. <if test="changeTime != null">change_time = #{changeTime},</if>
  249. <if test="checkUnit != null">check_unit = #{checkUnit},</if>
  250. <if test="engineer != null">engineer = #{engineer},</if>
  251. <if test="isEx != null">is_ex = #{isEx},</if>
  252. <if test="perTestConclusion != null">per_test_conclusion = #{perTestConclusion},</if>
  253. <if test="isRepeat != null">is_repeat = #{isRepeat},</if>
  254. <if test="factoryNo != null">factory_no = #{factoryNo},</if>
  255. <if test="devCode != null">dev_code = #{devCode},</if>
  256. </trim>
  257. where id = #{id}
  258. </update>
  259. <update id="updateTSpecdevDzsbByHi" parameterType="TSpechiDzsb">
  260. update t_specdev_dzsb
  261. <trim prefix="SET" suffixOverrides=",">
  262. <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
  263. <if test="unit != null">unit = #{unit},</if>
  264. <if test="devname != null">devname = #{devname},</if>
  265. <if test="devno != null">devno = #{devno},</if>
  266. <if test="submitdate != null">submitdate = #{submitdate},</if>
  267. <if test="status != null">status = #{status},</if>
  268. <if test="delFlag != null">del_flag = #{delFlag},</if>
  269. <if test="createrCode != null">creater_code = #{createrCode},</if>
  270. <if test="createdate != null">createdate = #{createdate},</if>
  271. <if test="updaterCode != null">updater_code = #{updaterCode},</if>
  272. <if test="updatedate != null">updatedate = #{updatedate},</if>
  273. <if test="deptId != null">dept_id = #{deptId},</if>
  274. <if test="remarks != null">remarks = #{remarks},</if>
  275. <if test="approveStatus != null">approve_status = #{approveStatus},</if>
  276. <if test="regno != null">regno = #{regno},</if>
  277. <if test="useno != null">useno = #{useno},</if>
  278. <if test="warnDate != null">warn_date = #{warnDate},</if>
  279. <if test="warnCycle != null">warn_cycle = #{warnCycle},</if>
  280. <if test="nextWarnDate != null">next_warn_date = #{nextWarnDate},</if>
  281. <if test="warnFlag != null">warn_flag = #{warnFlag},</if>
  282. <if test="plantMaint != null">plant_maint = #{plantMaint},</if>
  283. <if test="docno != null">docno = #{docno},</if>
  284. <if test="model != null">model = #{model},</if>
  285. <if test="capacity != null">capacity = #{capacity},</if>
  286. <if test="location != null">location = #{location},</if>
  287. <if test="createUnit != null">create_unit = #{createUnit},</if>
  288. <if test="checkStrategy != null">check_strategy = #{checkStrategy},</if>
  289. <if test="yearMaint != null">year_maint = #{yearMaint},</if>
  290. <if test="reportNo != null">report_no = #{reportNo},</if>
  291. <if test="approveTime != null">approve_time = #{approveTime},</if>
  292. <if test="changeTime != null">change_time = #{changeTime},</if>
  293. <if test="checkUnit != null">check_unit = #{checkUnit},</if>
  294. <if test="engineer != null">engineer = #{engineer},</if>
  295. <if test="isEx != null">is_ex = #{isEx},</if>
  296. <if test="perTestConclusion != null">per_test_conclusion = #{perTestConclusion},</if>
  297. <if test="factoryNo != null">factory_no = #{factoryNo},</if>
  298. <if test="devCode != null">dev_code = #{devCode},</if>
  299. </trim>
  300. where id = #{devId}
  301. </update>
  302. <update id="deleteTSpecdevDzsbById" parameterType="Long">
  303. update t_specdev_dzsb set del_flag = 2 where id = #{id}
  304. </update>
  305. <update id="deleteTSpecdevDzsbByIds" parameterType="String">
  306. update t_specdev_dzsb set del_flag = 2 where id in
  307. <foreach item="id" collection="array" open="(" separator="," close=")">
  308. #{id}
  309. </foreach>
  310. </update>
  311. <select id="otherDevCount" resultType="com.ruoyi.project.sems.domain.DevData">
  312. SELECT COUNT(1) as num,to_char(t.NEXT_WARN_DATE,'yyyyMM') as yearM FROM "T_SPECDEV_DZSB" t
  313. where
  314. t.status = 1
  315. and del_flag = 0
  316. and t.PLANT_CODE in
  317. <foreach collection="plants" item="plant" index="index"
  318. open="(" close=")" separator=",">
  319. #{plant}
  320. </foreach>
  321. GROUP BY to_char(t.NEXT_WARN_DATE,'yyyyMM')
  322. </select>
  323. <update id="duplicateTSpecdevDzsb" >
  324. UPDATE T_SPECDEV_DZSB set DEL_FLAG = 2
  325. where rowid !=( select max(rowid)
  326. from T_SPECDEV_DZSB b
  327. where b.DEVNO = T_SPECDEV_DZSB.DEVNO and b.DOCNO = T_SPECDEV_DZSB.DOCNO and b.PLANT_CODE = T_SPECDEV_DZSB.PLANT_CODE and T_SPECDEV_DZSB.DEL_FLAG = 0 and b.DEL_FLAG = 0
  328. and T_SPECDEV_DZSB.APPROVE_STATUS = 0
  329. )
  330. </update>
  331. </mapper>