You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3087 lines
133 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
3 years ago
  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.xujie.sys.modules.pms.mapper.EamMapper">
  4. <select id="eamAdminSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminData" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  5. SELECT distinct
  6. ea.Site,
  7. ea.AdminID,
  8. ea.AdminName,
  9. ea.Phone,
  10. ea.Email,
  11. ea.Tel,
  12. ea.LevelID,
  13. eal.AdminLevelDesc,
  14. ea.MesUser,
  15. ea.Active,
  16. ea.CreatedDate,
  17. ea.created_by,
  18. ea.update_date,
  19. ea.update_by
  20. FROM eam_admin as ea
  21. LEFT JOIN eam_adminLevel as eal ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  22. left join eam_admin_dept as ead on ea.site = ead.site and ea.AdminID = ead.admin_id
  23. LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id
  24. <where>
  25. <if test="query.site != null and query.site != ''">
  26. AND ea.site = #{query.site}
  27. </if>
  28. <if test="query.adminID != null and query.adminID != ''">
  29. AND ea.adminID like '%' + #{query.adminID} +'%'
  30. </if>
  31. <if test="query.adminName != null and query.adminName != ''">
  32. AND ea.adminName like '%' + #{query.adminName}+'%'
  33. </if>
  34. <if test="query.departmentName != null and query.departmentName != ''">
  35. AND ved.department_name like '%' + #{query.departmentName}+'%'
  36. </if>
  37. <if test="query.active != null and query.active != ''">
  38. AND ea.active = #{query.active}
  39. </if>
  40. </where>
  41. </select>
  42. <select id="eamAdminSearch2" parameterType="com.xujie.sys.modules.pms.data.EamAdminData" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  43. SELECT distinct
  44. ea.Site,
  45. ea.bu_no,
  46. dbo.get_bu_desc(ea.Site, ea.bu_no) as buDesc,
  47. ea.AdminID,
  48. ea.AdminName,
  49. ea.Phone,
  50. ea.Email,
  51. ea.Tel,
  52. ea.LevelID,
  53. eal.AdminLevelDesc,
  54. ea.MesUser,
  55. ea.Active,
  56. ea.CreatedDate,
  57. ea.created_by,
  58. ea.update_date,
  59. ea.update_by
  60. FROM eam_admin as ea
  61. LEFT JOIN eam_adminLevel as eal ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site and ea.bu_no = eal.bu_no
  62. left join eam_admin_dept as ead on ea.site = ead.site and ea.AdminID = ead.admin_id and ea.bu_no = ead.bu_no
  63. LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id and ead.bu_no = ved.bu_no
  64. <where>
  65. ea.site in (select site from eam_access_site where username = #{userName})
  66. and (ea.site + '-' + ea.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  67. <if test="adminID != null and adminID != ''">
  68. AND ea.adminID like '%' + #{adminID} +'%'
  69. </if>
  70. <if test="adminName != null and adminName != ''">
  71. AND ea.adminName like '%' + #{adminName}+'%'
  72. </if>
  73. <if test="departmentName != null and departmentName != ''">
  74. AND ved.department_name like '%' + #{departmentName}+'%'
  75. </if>
  76. <if test="active != null and active != ''">
  77. AND ea.active = #{active}
  78. </if>
  79. </where>
  80. </select>
  81. <select id="eamFamilySearch" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData" resultType="com.xujie.sys.modules.pms.data.EamFamilyData">
  82. SELECT
  83. Site,
  84. bu_no,
  85. dbo.get_bu_desc(site, bu_no) as buDesc,
  86. FamilyID,
  87. FamilyDesc,
  88. Active,
  89. create_date,
  90. create_by,
  91. update_date,
  92. update_by
  93. FROM eam_family
  94. <where>
  95. site in (select site from eam_access_site where username = #{query.userName})
  96. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  97. <if test="query.buDesc != null and query.buDesc != ''">
  98. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  99. </if>
  100. <if test="query.familyID != null and query.familyID != ''">
  101. AND familyID like '%' + #{query.familyID} +'%'
  102. </if>
  103. <if test="query.familyDesc != null and query.familyDesc != ''">
  104. AND familyDesc like '%' + #{query.familyDesc} +'%'
  105. </if>
  106. <if test="query.active != null and query.active != ''">
  107. AND active = #{query.active}
  108. </if>
  109. </where>
  110. </select>
  111. <select id="eamGroupSearch" parameterType="com.xujie.sys.modules.pms.data.EamGroupData" resultType="com.xujie.sys.modules.pms.data.EamGroupData">
  112. SELECT
  113. Site,
  114. bu_no,
  115. dbo.get_bu_desc(site, bu_no) as buDesc,
  116. GroupID,
  117. GroupDesc,
  118. Active,
  119. create_date,
  120. create_by,
  121. update_date,
  122. update_by
  123. FROM eam_group
  124. <where>
  125. site in (select site from eam_access_site where username = #{query.userName})
  126. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  127. <if test="query.buDesc != null and query.buDesc != ''">
  128. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  129. </if>
  130. <if test="query.groupID != null and query.groupID != ''">
  131. AND groupID like '%' + #{query.groupID} + '%'
  132. </if>
  133. <if test="query.groupDesc != null and query.groupDesc != ''">
  134. AND groupDesc like '%' + #{query.groupDesc} + '%'
  135. </if>
  136. <if test="query.active != null and query.active != ''">
  137. AND active = #{query.active}
  138. </if>
  139. </where>
  140. </select>
  141. <select id="eamLocationSearch" parameterType="com.xujie.sys.modules.pms.data.EamLocationData" resultType="com.xujie.sys.modules.pms.data.EamLocationData">
  142. SELECT
  143. Site,
  144. bu_no,
  145. dbo.get_bu_desc(site, bu_no) as buDesc,
  146. LocationID,
  147. LocationName,
  148. Active,
  149. create_date,
  150. create_by,
  151. update_date,
  152. update_by
  153. FROM eam_location
  154. <where>
  155. site in (select site from eam_access_site where username = #{query.userName})
  156. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  157. <if test="query.buDesc != null and query.buDesc != ''">
  158. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  159. </if>
  160. <if test="query.locationID != null and query.locationID != ''">
  161. AND locationID like '%' + #{query.locationID} +'%'
  162. </if>
  163. <if test="query.locationName != null and query.locationName != ''">
  164. AND locationName like '%' + #{query.locationName} +'%'
  165. </if>
  166. <if test="query.active != null and query.active != ''">
  167. AND active = #{query.active}
  168. </if>
  169. </where>
  170. </select>
  171. <select id="eamManufacturerSearch" parameterType="com.xujie.sys.modules.pms.data.EamManufacturerData" resultType="com.xujie.sys.modules.pms.data.EamManufacturerData">
  172. SELECT
  173. Site,
  174. bu_no,
  175. dbo.get_bu_desc(site, bu_no) as buDesc,
  176. ManufacturerID,
  177. ManufacturerName,
  178. Active,
  179. Contact,
  180. Phone,
  181. Address,
  182. Email,
  183. Remark,
  184. create_date,
  185. create_by,
  186. update_date,
  187. update_by
  188. FROM eam_manufacturer
  189. <where>
  190. site in (select site from eam_access_site where username = #{query.userName})
  191. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  192. <if test="query.buDesc != null and query.buDesc != ''">
  193. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  194. </if>
  195. <if test="query.manufacturerID != null and query.manufacturerID != ''">
  196. AND manufacturerID like '%' + #{query.manufacturerID} +'%'
  197. </if>
  198. <if test="query.manufacturerName != null and query.manufacturerName != ''">
  199. AND manufacturerName like '%' + #{query.manufacturerName} +'%'
  200. </if>
  201. <if test="query.active != null and query.active != ''">
  202. AND active = #{query.active}
  203. </if>
  204. </where>
  205. </select>
  206. <select id="eamAdminLevelSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminLevelData" resultType="com.xujie.sys.modules.pms.data.EamAdminLevelData">
  207. SELECT
  208. Site,
  209. bu_no,
  210. dbo.get_bu_desc(site, bu_no) as buDesc,
  211. AdminLevelID,
  212. AdminLevelDesc,
  213. Active,
  214. create_date,
  215. create_by,
  216. update_date,
  217. update_by
  218. FROM eam_adminLevel
  219. <where>
  220. site in (select site from eam_access_site where username = #{query.userName})
  221. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  222. <if test="query.buDesc != null and query.buDesc != ''">
  223. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  224. </if>
  225. <if test="query.adminLevelID != null and query.adminLevelID != ''">
  226. AND adminLevelID like '%' + #{query.adminLevelID} +'%'
  227. </if>
  228. <if test="query.adminLevelDesc != null and query.adminLevelDesc != ''">
  229. AND adminLevelDesc like '%' + #{query.adminLevelDesc}+'%'
  230. </if>
  231. <if test="query.active != null and query.active != ''">
  232. AND active = #{query.active}
  233. </if>
  234. </where>
  235. </select>
  236. <select id="eamSupplierSearch" parameterType="com.xujie.sys.modules.pms.data.EamSupplierData" resultType="com.xujie.sys.modules.pms.data.EamSupplierData">
  237. SELECT
  238. Site,
  239. bu_no,
  240. dbo.get_bu_desc(site, bu_no) as buDesc,
  241. SupplierID,
  242. SupplierName,
  243. [Group],
  244. Active,
  245. Contact,
  246. Phone,
  247. Address,
  248. Email,
  249. Remark,
  250. create_date,
  251. create_by,
  252. update_date,
  253. update_by
  254. FROM eam_supplier
  255. <where>
  256. site in (select site from eam_access_site where username = #{query.userName})
  257. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  258. <if test="query.buDesc != null and query.buDesc != ''">
  259. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  260. </if>
  261. <if test="query.supplierID != null and query.supplierID != ''">
  262. AND supplierID like '%' + #{query.supplierID} +'%'
  263. </if>
  264. <if test="query.supplierName != null and query.supplierName != ''">
  265. AND supplierName like '%' + #{query.supplierName} +'%'
  266. </if>
  267. <if test="query.active != null and query.active != ''">
  268. AND active = #{query.active}
  269. </if>
  270. </where>
  271. </select>
  272. <select id="searchItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemAvailableData">
  273. SELECT
  274. site,
  275. bu_no,
  276. ItemNo,
  277. ValueNo,
  278. AvailableValue,
  279. CreatedDate,
  280. CreatedBy,
  281. ItemType
  282. from eam_properties_item_available
  283. where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  284. </select>
  285. <select id="getItemValueNo" resultType="Double">
  286. SELECT isnull( max(valueNo),0)+1 from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  287. </select>
  288. <select id="getItemValueNoForPlan" resultType="Double">
  289. SELECT isnull( max(valueNo),0)+1 from eam_workPlan_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and PlanID = #{planID} and bu_no = #{buNo}
  290. </select>
  291. <insert id="saveItemAvailable">
  292. insert into eam_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, site, bu_no)
  293. values(#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site}, #{buNo})
  294. </insert>
  295. <update id="updateItemAvailable">
  296. update eam_properties_item_available
  297. set AvailableValue = #{availableValue}
  298. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  299. </update>
  300. <delete id="deleteItemAvailable">
  301. delete from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  302. </delete>
  303. <select id="eamPropertiesModelSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  304. SELECT
  305. site,
  306. bu_no,
  307. dbo.get_bu_desc(site, bu_no) as buDesc,
  308. function_type,
  309. code_no,
  310. code_desc,
  311. active,
  312. created_date,
  313. created_by,
  314. update_date,
  315. update_by,
  316. delflag,
  317. version,
  318. CASE WHEN dbo.eam_model_is_use(site, function_type, code_no) > 0 THEN 'Y'
  319. else 'N'
  320. END as isUse
  321. FROM eam_properties_model_header
  322. <where>
  323. site in (select site from eam_access_site where username = #{query.userName})
  324. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  325. <if test="query.buDesc != null and query.buDesc != ''">
  326. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  327. </if>
  328. <if test="query.codeNo != null and query.codeNo != ''">
  329. AND code_no like '%' + #{query.codeNo} +'%'
  330. </if>
  331. <if test="query.codeDesc != null and query.codeDesc != ''">
  332. AND code_desc like '%' + #{query.codeDesc} +'%'
  333. </if>
  334. <if test="query.active != null and query.active != ''">
  335. AND active = #{query.active}
  336. </if>
  337. <if test='query.isUse != null and query.isUse != "" and query.isUse == "Y"'>
  338. AND dbo.eam_model_is_use(site, function_type, code_no) > 0
  339. </if>
  340. <if test='query.isUse != null and query.isUse != "" and query.isUse == "N"'>
  341. AND dbo.eam_model_is_use(site, function_type, code_no) = 0
  342. </if>
  343. and function_type = #{query.functionType}
  344. </where>
  345. </select>
  346. <insert id="eamPropertiesModelSave" >
  347. insert into eam_properties_model_header
  348. (function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by, site, bu_no)
  349. values (#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy}, #{site}, #{buNo})
  350. </insert>
  351. <update id="eamPropertiesModelEdit">
  352. update eam_properties_model_header
  353. set version = version + 1,
  354. code_desc = #{codeDesc},
  355. active = #{active},
  356. update_by = #{updateBy},
  357. update_date = GetDate()
  358. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  359. </update>
  360. <select id="checkPropertiesModel" resultType="EamPropertiesModelHeaderData">
  361. SELECT
  362. function_type,
  363. code_no,
  364. code_desc,
  365. active,
  366. created_date,
  367. created_by,
  368. update_date,
  369. update_by,
  370. delflag,
  371. version
  372. FROM eam_properties_model_header
  373. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  374. </select>
  375. <delete id="deleteModelDetail">
  376. delete from eam_properties_model_detail
  377. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  378. </delete>
  379. <delete id="eamPropertiesModelDelete" >
  380. delete from eam_properties_model_header where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  381. </delete>
  382. <select id="searchModalDetails" resultType="EamPropertiesModelDetailData">
  383. SELECT
  384. a.site,
  385. a.bu_no,
  386. a.function_type,
  387. a.code_no,
  388. a.properties_item_no itemNo,
  389. a.seq_no,
  390. b.ItemDesc,
  391. b.DefaultValue,
  392. b.ValueType,
  393. b.ValueType_DB,
  394. b.ValueChooseFlag,
  395. b.MaxValue,
  396. b.MinValue,
  397. b.ItemRemark,
  398. b.ItemType
  399. FROM eam_properties_model_detail a
  400. left join eam_properties_item b on a.function_type = b.itemType and a.properties_item_no = b.itemNo and a.site = b.site and a.bu_no = b.bu_no
  401. where a.function_type = #{functionType} and a.code_no = #{codeNo} and a.site = #{site} and a.bu_no = #{buNo}
  402. </select>
  403. <select id="checkItem" resultType="EamPropertiesModelDetailData">
  404. SELECT
  405. ItemDesc
  406. FROM eam_properties_item
  407. where itemType = #{functionType} and itemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  408. </select>
  409. <select id="checkModalDetails" resultType="EamPropertiesModelDetailData">
  410. SELECT
  411. site,
  412. bu_no,
  413. function_type,
  414. code_no,
  415. properties_item_no itemNo,
  416. seq_no
  417. FROM eam_properties_model_detail
  418. where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  419. </select>
  420. <select id="getModalDetailSeqNo" resultType="Integer">
  421. SELECT
  422. isnull(max(seq_no),0) + 1
  423. from eam_properties_model_detail
  424. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  425. </select>
  426. <insert id="saveModalDetails">
  427. insert into eam_properties_model_detail
  428. (function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, bu_no)
  429. values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{buNo})
  430. </insert>
  431. <delete id="deleteModalDetails">
  432. delete from eam_properties_model_detail
  433. where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  434. </delete>
  435. <select id="eamWorkPlanOverviewSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  436. SELECT
  437. a.site,
  438. a.bu_no,
  439. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  440. a.plan_id,
  441. a.plan_desc,
  442. a.status,
  443. a.plan_start_date,
  444. a.plan_end_date,
  445. a.created_date,
  446. a.created_by,
  447. a.update_date,
  448. a.update_by,
  449. a.remark,
  450. a.next_work_date,
  451. a.delete_flag,
  452. a.operator,
  453. a.operator_name,
  454. a.checker,
  455. a.checker_name,
  456. a.function_type,
  457. a.properties_code,
  458. a.plan_period,
  459. d.code_desc,
  460. a.work_order_rule,
  461. a.plan_cycle,
  462. a.task_start_date,
  463. a.plan_halt_date,
  464. a.auto_renewal
  465. FROM eam_workPlan_overview as a
  466. LEFT JOIN eam_properties_model_header as d ON a.site = d.site and a.function_type = d.function_type and a.properties_code = d.code_no and a.bu_no = d.bu_no
  467. <where>
  468. a.site in (select site from eam_access_site where username = #{query.userName})
  469. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  470. and a.delete_flag = 'N' AND a.function_type = #{query.functionType}
  471. <if test="query.buDesc != null and query.buDesc != ''">
  472. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  473. </if>
  474. <if test="query.planID != null and query.planID != ''">
  475. AND a.plan_id like '%' + #{query.planID} +'%'
  476. </if>
  477. <if test="query.planDesc != null and query.planDesc != ''">
  478. AND a.plan_desc like '%' + #{query.planDesc}+'%'
  479. </if>
  480. <if test="query.status != null and query.status != ''">
  481. AND a.status = #{query.status}
  482. </if>
  483. <if test="query.startDate != null ">
  484. AND a.plan_start_date >= #{query.startDate}
  485. </if>
  486. <if test="query.endDate != null ">
  487. AND #{query.endDate} >= a.plan_start_date
  488. </if>
  489. </where>
  490. ORDER BY a.created_date DESC
  491. </select>
  492. <select id="eamWorkPlanSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  493. SELECT
  494. a.Site,
  495. a.PlanID,
  496. a.PlanDesc,
  497. a.ObjectID,
  498. a.FunctionType,
  499. a.PropertiesCode,
  500. a.Operator,
  501. a.checker,
  502. a.PlanPeriod,
  503. a.Status,
  504. a.PlanStartDate,
  505. a.PlanEndDate,
  506. a.CreatedDate,
  507. a.CreatedBy,
  508. a.UpdateDate,
  509. a.UpdateBy,
  510. a.Version,
  511. a.Remark,
  512. a.NextWorkDate,
  513. b.ObjectDesc,
  514. d.code_desc
  515. FROM eam_workPlan a
  516. left join eam_object b on a.Site = b.Site and a.ObjectID = b.ObjectID
  517. left join eam_properties_model_header d on a.FunctionType = d.function_type and a.PropertiesCode = d.code_no
  518. <where>
  519. AND a.DeleteFlag = 'N'
  520. AND a.FunctionType = #{query.functionType}
  521. <if test="query.planID != null and query.planID != ''">
  522. AND a.PlanID like '%' + #{query.planID} +'%'
  523. </if>
  524. <if test="query.planDesc != null and query.planDesc != ''">
  525. AND a.PlanDesc like '%' + #{query.planDesc}+'%'
  526. </if>
  527. <if test="query.status != null and query.status != ''">
  528. AND a.status = #{query.status}
  529. </if>
  530. <if test="query.startDate != null ">
  531. AND a.PlanStartDate >= #{query.startDate}
  532. </if>
  533. <if test="query.endDate != null ">
  534. AND #{query.endDate} >= a.PlanStartDate
  535. </if>
  536. </where>
  537. </select>
  538. <select id="selectNameById" resultType="string" parameterType="string">
  539. SELECT
  540. AdminName
  541. FROM eam_admin
  542. WHERE AdminID = #{s}
  543. </select>
  544. <select id="searchPlanItems" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData">
  545. SELECT
  546. a.Site,
  547. a.bu_no,
  548. a.PlanID,
  549. a.ItemNo,
  550. a.ItemDesc,
  551. a.DefaultValue,
  552. a.ValueType,
  553. a.ValueType_DB,
  554. a.ValueChooseFlag,
  555. a.UpdateDate,
  556. a.UpdateBy,
  557. a.MaxValue,
  558. a.MinValue,
  559. a.ItemRemark,
  560. a.ItemType,
  561. a.CreatedDate,
  562. a.CreatedBy,
  563. a.ObjectID
  564. FROM eam_workPlan_item a
  565. <where>
  566. a.PlanID = #{planID} and a.Site = #{site} and a.ItemType = #{functionType} and bu_no = #{buNo}
  567. <if test = "objectID != null and objectID != ''">
  568. AND a.ObjectID = #{objectID}
  569. </if>
  570. </where>
  571. </select>
  572. <select id="searchPlanItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemAvailableData">
  573. SELECT
  574. Site,
  575. bu_no,
  576. PlanID,
  577. ItemNo,
  578. ItemType,
  579. ValueNo,
  580. AvailableValue,
  581. CreatedDate,
  582. CreatedBy,
  583. UpdateDate,
  584. UpdateBy,
  585. ObjectID
  586. from eam_workPlan_item_available
  587. where PlanID = #{planID} and itemNo = #{itemNo} and site = #{site} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  588. </select>
  589. <update id="updatePlanItems">
  590. update eam_workPlan_item
  591. set DefaultValue = #{defaultValue},
  592. ValueType = #{valueType},
  593. ValueType_DB = #{valueTypeDb},
  594. ValueChooseFlag = #{valueChooseFlag},
  595. UpdateDate = GetDate(),
  596. UpdateBy = #{createdBy},
  597. MaxValue = #{maxValue,jdbcType=FLOAT},
  598. MinValue = #{minValue,jdbcType=FLOAT},
  599. ItemRemark = #{itemRemark}
  600. where site = #{site} and planID = #{planID} and ItemType = #{itemType} and ItemNo = #{itemNo} and ObjectID = #{objectID} and bu_no = #{buNo}
  601. </update>
  602. <update id="updatePlanItemsForNull">
  603. update eam_workPlan_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  604. ,ValueChooseFlag=#{valueChooseFlag},UpdateDate=GetDate(),UpdateBy=#{createdBy},MaxValue=null,MinValue=null,
  605. ItemRemark=#{itemRemark}
  606. where site=#{site} and planID=#{planID} and ItemType=#{itemType}
  607. and ItemNo=#{itemNo}
  608. </update>
  609. <insert id="saveItemAvailableForPlan">
  610. insert into eam_workPlan_item_available
  611. (Site, PlanID, ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, ObjectID, bu_no)
  612. values(#{site}, #{planID}, #{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{objectID}, #{buNo})
  613. </insert>
  614. <update id="updateItemAvailableForPlan">
  615. update eam_workPlan_item_available
  616. set AvailableValue = #{availableValue},
  617. updateBy = #{createdBy},
  618. updateDate = GetDate()
  619. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
  620. </update>
  621. <delete id="deletePlanItemAvailable">
  622. delete from eam_workPlan_item_available
  623. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
  624. </delete>
  625. <select id="objectIDBlur" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  626. select
  627. objectID,
  628. ObjectDesc
  629. from eam_object
  630. where active = 'Y'
  631. and Site = #{site}
  632. and ObjectID=#{objectID}
  633. </select>
  634. <select id="modalCodeBlur" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  635. select code_no,code_desc from eam_properties_model_header where active = 'Y' and function_type = #{functionType} and code_no = #{codeNo}
  636. </select>
  637. <select id="eamWorkOrderSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  638. SELECT
  639. a.Site,
  640. a.bu_no,
  641. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  642. a.OrderNo,
  643. a.PlanID,
  644. a.PlanDesc,
  645. a.PropertiesCode,
  646. a.ObjectID,
  647. a.Status,
  648. a.PlanOperator,
  649. a.checker,
  650. a.ActualOperator,
  651. a.PlanDate,
  652. a.ActualDate,
  653. a.FunctionType,
  654. a.CreateDate,
  655. d.operator_name as createBy,
  656. a.Remark,
  657. a.StartTime,
  658. a.EndTime,
  659. a.WorkTime,
  660. a.PlanOperatorName,
  661. a.checkerName,
  662. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) ActualOperatorName,
  663. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) objectDesc,
  664. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) codeDesc,
  665. a.result,
  666. b.urgency,
  667. a.checkResult,
  668. b.DefectID,
  669. c.DefectDesc,
  670. a.disposal_measures,
  671. a.check_work_plan_id,
  672. a.check_item_no,
  673. a.reach_date,
  674. a.reach_operator,
  675. a.reach_operator_name,
  676. b.FeedBackDesc,
  677. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  678. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  679. a.check_remark,
  680. a.document_source,
  681. a.last_execution_date
  682. FROM eam_workOrder a
  683. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  684. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  685. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id
  686. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  687. left join sys_department as sd ON eo.site = sd.site and eo.dept_id = sd.department_id and eo.bu_no = sd.bu_no
  688. left join Access_dept as ead ON ead.site = sd.site and ead.department_id = sd.department_id and ead.bu_no = sd.bu_no
  689. left join sys_user as ea on ead.username = ea.username
  690. left join eam_workPlan_overview as ewo on a.site = ewo.site and a.PlanID = ewo.plan_id and a.bu_no = ewo.bu_no
  691. <where>
  692. a.site in (select site from eam_access_site where username = #{query.userName})
  693. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  694. and ea.username = #{query.userName}
  695. <if test="query.buDesc != null and query.buDesc != ''">
  696. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  697. </if>
  698. <if test="query.orderNo != null and query.orderNo != ''">
  699. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  700. </if>
  701. <if test="query.planID != null and query.planID != ''">
  702. AND a.PlanID like '%' + #{query.planID} +'%'
  703. </if>
  704. <if test="query.planDesc != null and query.planDesc != ''">
  705. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  706. </if>
  707. <if test="query.objectID != null and query.objectID != ''">
  708. AND a.ObjectID like '%' + #{query.objectID} +'%'
  709. </if>
  710. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  711. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  712. </if>
  713. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  714. AND a.status != '已取消'
  715. </if>
  716. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  717. AND a.status = #{query.status}
  718. </if>
  719. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  720. AND a.status = '未开工'
  721. </if>
  722. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  723. AND a.status != '已取消'
  724. </if>
  725. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  726. AND a.status = #{query.status}
  727. </if>
  728. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  729. AND (a.status = '未开工' or a.status = '已到达')
  730. </if>
  731. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  732. AND (a.status = '未开工' or a.status = '已到达')
  733. </if>
  734. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  735. AND a.status = #{query.status}
  736. </if>
  737. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  738. AND a.document_source = #{query.documentSource}
  739. </if>
  740. <if test="query.planDate != null">
  741. AND a.PlanDate = #{query.planDate}
  742. </if>
  743. <if test="query.startDate != null ">
  744. AND a.PlanDate >= #{query.startDate}
  745. </if>
  746. <if test="query.endDate != null ">
  747. AND #{query.endDate} >= a.PlanDate
  748. </if>
  749. <if test="query.endDate == null ">
  750. AND getDate() >= a.PlanDate
  751. </if>
  752. <if test='query.functionType == "A" and query.searchType == "reportCheck"'>
  753. and getDate() >= dbo.compare_date(ewo.task_start_date)
  754. </if>
  755. <if test="query.urgency != null and query.urgency != ''">
  756. AND b.urgency = #{query.urgency}
  757. </if>
  758. AND a.FunctionType = #{query.functionType}
  759. </where>
  760. ORDER BY a.CreateDate,
  761. CASE WHEN b.urgency = '特急' THEN 1
  762. WHEN b.urgency = '紧急' THEN 2
  763. WHEN b.urgency = '一般' THEN 3
  764. END
  765. </select>
  766. <select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  767. SELECT
  768. a.Site,
  769. a.bu_no,
  770. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  771. a.OrderNo,
  772. a.PlanID,
  773. a.ObjectID,
  774. a.Status,
  775. a.PlanOperator,
  776. a.ActualOperator,
  777. a.PlanDate,
  778. a.ActualDate,
  779. a.FunctionType,
  780. a.CreateDate,
  781. d.operator_name as createBy,
  782. a.Remark,
  783. a.StartTime,
  784. a.EndTime,
  785. a.WorkTime,
  786. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  787. b.DefectID,
  788. c.DefectDesc,
  789. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  790. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  791. a.result,
  792. b.urgency,
  793. a.disposal_measures,
  794. a.difficulty_level,
  795. a.difficulty_remark,
  796. f.department_name,
  797. a.reach_date,
  798. b.CreatedDate,
  799. a.handling_method,
  800. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  801. CASE
  802. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  803. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  804. END AS responseTime,
  805. b.FeedBackDesc,
  806. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  807. a.fault_reason,
  808. a.preventive_measure,
  809. a.document_source
  810. FROM eam_workOrder a
  811. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  812. left join eam_defect c on b.DefectID = c.DefectID
  813. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id
  814. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and a.bu_no = e.bu_no
  815. left join sys_department as f on e.site = f.site and e.dept_id = f.department_id and e.bu_no = f.bu_no
  816. left join Access_dept as ead ON ead.site = f.site and ead.department_id = f.department_id and ead.bu_no = f.bu_no
  817. left join sys_user as ea on ead.username = ea.username
  818. <where>
  819. a.site in (select site from eam_access_site where username = #{query.userName})
  820. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  821. and ea.username = #{query.userName}
  822. <if test="query.buDesc != null and query.buDesc != ''">
  823. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  824. </if>
  825. <if test="query.deptArr != null">
  826. AND
  827. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  828. f.department_name like '%' + #{item} + '%'
  829. </foreach>
  830. </if>
  831. <if test="query.orderNo != null and query.orderNo != ''">
  832. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  833. </if>
  834. <if test="query.planID != null and query.planID != ''">
  835. AND a.PlanID like '%' + #{query.planID} +'%'
  836. </if>
  837. <if test="query.objectID != null and query.objectID != ''">
  838. AND a.ObjectID like '%' + #{query.objectID} +'%'
  839. </if>
  840. <if test="query.planOperator != null and query.planOperator != ''">
  841. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  842. </if>
  843. <if test="query.status != null and query.status != ''">
  844. AND a.status = #{query.status}
  845. </if>
  846. <if test="query.documentSource != null and query.documentSource != ''">
  847. AND a.document_source = #{query.documentSource}
  848. </if>
  849. <if test="query.startDate != null ">
  850. AND a.PlanDate >= #{query.startDate}
  851. </if>
  852. <if test="query.endDate != null ">
  853. AND #{query.endDate} >= a.PlanDate
  854. </if>
  855. <if test="query.urgency != null and query.urgency != ''">
  856. AND b.urgency = #{query.urgency}
  857. </if>
  858. <if test="query.result != null and query.result != ''">
  859. AND a.result = #{query.result}
  860. </if>
  861. and a.FunctionType =#{query.functionType}
  862. </where>
  863. ORDER BY a.PlanDate,
  864. CASE WHEN b.urgency = '特急' THEN 1
  865. WHEN b.urgency = '紧急' THEN 2
  866. WHEN b.urgency = '一般' THEN 3
  867. END
  868. </select>
  869. <select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData">
  870. SELECT
  871. DefectID,
  872. DefectDesc,
  873. Active,
  874. create_date,
  875. create_by,
  876. update_date,
  877. update_by,
  878. fault_type
  879. FROM eam_defect
  880. <where>
  881. <if test="query.defectID != null and query.defectID != ''">
  882. AND defectID like '%' + #{query.defectID} + '%'
  883. </if>
  884. <if test="query.defectDesc != null and query.defectDesc != ''">
  885. AND defectDesc like '%' + #{query.defectDesc} + '%'
  886. </if>
  887. <if test="query.active != null and query.active != ''">
  888. AND active = #{query.active}
  889. </if>
  890. </where>
  891. order by id
  892. </select>
  893. <select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  894. SELECT
  895. a.site,
  896. a.ObjectID,
  897. a.DefectID,
  898. a.Active,
  899. a.id,
  900. b.ObjectDesc,
  901. c.DefectDesc,
  902. a.create_date,
  903. a.create_by,
  904. a.update_date,
  905. a.update_by
  906. FROM eam_object_defect a
  907. left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID
  908. left join eam_defect c on a.DefectID=c.DefectID
  909. <where>
  910. <if test="query.objectID != null and query.objectID != ''">
  911. AND a.ObjectID like '%' + #{query.objectID} + '%'
  912. </if>
  913. <if test="query.objectDesc != null and query.objectDesc != ''">
  914. AND b.ObjectDesc like '%' + #{query.objectDesc} + '%'
  915. </if>
  916. <if test="query.defectID != null and query.defectID != ''">
  917. AND a.defectID like '%' + #{query.defectID} + '%'
  918. </if>
  919. <if test="query.defectDesc != null and query.defectDesc != ''">
  920. AND c.defectDesc like '%' + #{query.defectDesc} + '%'
  921. </if>
  922. <if test="query.active != null and query.active != ''">
  923. AND a.active = #{query.active}
  924. </if>
  925. </where>
  926. order by a.id
  927. </select>
  928. <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  929. SELECT
  930. a.Site,
  931. a.bu_no,
  932. a.ObjectID,
  933. a.ObjectDesc,
  934. a.LocationID,
  935. a.FamilyID,
  936. a.GroupID,
  937. b.FamilyDesc,
  938. c.LocationName
  939. FROM eam_object a
  940. LEFT JOIN eam_family b ON a.site = b.site and a.FamilyID = b.FamilyID and a.bu_no = b.bu_no
  941. LEFT JOIN eam_location as c ON a.LocationID = c.LocationID and a.site = c.site and a.bu_no = c.bu_no
  942. <where>
  943. <if test="objectID != null and objectID != ''">
  944. AND a.ObjectID like '%' + #{objectID} + '%'
  945. </if>
  946. <if test="objectDesc != null and objectDesc != ''">
  947. AND a.ObjectDesc like '%' + #{objectDesc} + '%'
  948. </if>
  949. AND a.site = #{site} AND a.active = 'Y' and a.bu_no = #{buNo}
  950. </where>
  951. </select>
  952. <select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  953. SELECT
  954. a.site,
  955. a.objectID
  956. from eam_object as a
  957. left join eam_family as b on a.site = b.site and a.FamilyID = b.FamilyID
  958. where a.site = '2' and (b.son_id like #{sonId} + '%' or a.FamilyID = #{familyID})
  959. </select>
  960. <select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  961. SELECT
  962. site,
  963. objectID
  964. from eam_object
  965. where site = #{site} and GroupID = #{groupID}
  966. </select>
  967. <select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  968. SELECT
  969. site,
  970. objectID
  971. from eam_object
  972. where site = #{site} and LocationID = #{locationID}
  973. </select>
  974. <select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  975. SELECT
  976. a.Site,
  977. a.bu_no,
  978. c.OrderNo,
  979. a.ItemNo,
  980. a.ItemDesc,
  981. a.DefaultValue,
  982. a.ValueType,
  983. a.ValueType_DB,
  984. a.ValueChooseFlag,
  985. a.MaxValue,
  986. a.MinValue,
  987. a.ItemRemark,
  988. a.ItemType,
  989. a.image_flag,
  990. a.produce_control_flag,
  991. CASE WHEN b.id is null THEN 'N'
  992. ELSE 'Y'
  993. END as uploadFlag,
  994. a.item_notes
  995. from eam_workPlan_item as a
  996. left join eam_workOrder as c on a.site = c.site and a.PlanID = c.PlanID and a.bu_no = c.bu_no
  997. left join (SELECT MAX (id) as id, order_ref1, order_ref2, order_ref3, order_ref4 FROM sys_oss GROUP BY order_ref1, order_ref2, order_ref3, order_ref4) as b
  998. on b.order_ref1 = a.site and b.order_ref2 = c.OrderNo and b.order_ref3 = a.ItemNo and order_ref4 = a.bu_no
  999. where a.site = #{site} and c.orderNo = #{orderNo} and a.ObjectID = #{objectID} and a.bu_no = #{buNo}
  1000. </select>
  1001. <select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1002. SELECT
  1003. Site,
  1004. status,
  1005. OrderNo
  1006. from eam_workOrder
  1007. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1008. </select>
  1009. <select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  1010. SELECT username as adminID
  1011. from sys_user
  1012. where username = #{mesUser}
  1013. </select>
  1014. <update id="updateDefectResult" >
  1015. update eam_defect_feedBack
  1016. set Status = #{result},
  1017. FinishDate = GetDate(),
  1018. DefectID = #{defectID}
  1019. where Site = #{site} and FeedBackID = #{planID} and bu_no = #{buNo}
  1020. </update>
  1021. <update id="reportWorkOrder" parameterType="EamWorkOrderInData">
  1022. update eam_workOrder
  1023. set Status = '待审核',
  1024. ActualOperator = #{actualOperator},
  1025. ActualDate = #{actualDate},
  1026. Remark = #{remark},
  1027. disposal_measures = #{disposalMeasures},
  1028. WorkTime = CASE
  1029. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1030. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
  1031. END,
  1032. result = #{result,jdbcType=VARCHAR},
  1033. checkResult = #{checkResult},
  1034. handling_method = #{handlingMethod},
  1035. fault_reason = #{faultReason},
  1036. preventive_measure = #{preventiveMeasure}
  1037. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1038. </update>
  1039. <update id="reportWorkOrder2" parameterType="EamWorkOrderInData">
  1040. update eam_workOrder
  1041. set Status = '待审核',
  1042. ActualOperator = #{actualOperator},
  1043. reach_date = #{reachDate},
  1044. ActualDate = #{actualDate},
  1045. Remark = #{remark},
  1046. disposal_measures = #{disposalMeasures},
  1047. WorkTime = #{workTime},
  1048. result = #{result,jdbcType=VARCHAR},
  1049. checkResult = #{checkResult},
  1050. handling_method = #{handlingMethod},
  1051. check_remark = #{checkRemark}
  1052. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1053. </update>
  1054. <update id="defectReportWorkOrder" >
  1055. update eam_workOrder
  1056. set Status = '已完工',
  1057. ActualOperator = #{actualOperator},
  1058. ActualDate = GetDate(),
  1059. Remark = #{remark},
  1060. disposal_measures = #{disposalMeasures},
  1061. WorkTime = #{workTime},
  1062. result = #{result,jdbcType=VARCHAR},
  1063. checkResult = #{checkResult}
  1064. where site = #{site}
  1065. and orderNo = #{orderNo}
  1066. </update>
  1067. <insert id="saveWorkOrderItem">
  1068. INSERT into eam_workOrder_item
  1069. (Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
  1070. values (#{site}, #{buNo}, #{orderNo}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag}, #{maxValue,jdbcType=DOUBLE}, #{minValue,jdbcType=DOUBLE}, #{itemRemark,jdbcType=VARCHAR}, #{itemType}, #{textValue,jdbcType=VARCHAR}, #{numberValue,jdbcType=DOUBLE}, GetDate(), #{createdBy}, #{finishFlag}, #{itemResult}, #{itemNotes})
  1071. </insert>
  1072. <!-- 修改 eam_workPlan 状态为已结束 -->
  1073. <update id="closePlanWithCheck">
  1074. update eam_workPlan
  1075. set status = '已结束'
  1076. where site = #{site}
  1077. and PlanID = #{planID}
  1078. and ObjectID = #{objectID}
  1079. and GetDate() > PlanEndDate
  1080. </update>
  1081. <!-- 报工后更新下一个工作日期 -->
  1082. <update id="updatePlanNextDate">
  1083. update eam_workPlan_overview
  1084. set next_work_date = (select top 1 PlanDate from eam_workOrder where site = #{site} and bu_no = #{buNo} and PlanID = #{planID} and PlanDate > GetDate() and status = '未开工' order by PlanDate)
  1085. where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
  1086. </update>
  1087. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1088. SELECT
  1089. Site,
  1090. bu_no,
  1091. OrderNo,
  1092. ItemNo,
  1093. ItemDesc,
  1094. DefaultValue,
  1095. ValueType,
  1096. ValueType_DB,
  1097. ValueChooseFlag,
  1098. MaxValue,
  1099. MinValue,
  1100. ItemRemark,
  1101. ItemType,
  1102. TextValue,
  1103. NumberValue,
  1104. CreatedDate,
  1105. CreatedBy,
  1106. FinishFlag,
  1107. itemResult,
  1108. item_notes
  1109. from eam_workOrder_item
  1110. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1111. </select>
  1112. <update id="cancelOrder" parameterType="EamWorkOrderInData">
  1113. update eam_workOrder
  1114. set Status = '已取消'
  1115. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1116. </update>
  1117. <update id="cancelOrderAll" parameterType="EamWorkOrderInData">
  1118. update eam_workOrder
  1119. set Status = '已取消'
  1120. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
  1121. </update>
  1122. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1123. SELECT
  1124. site,
  1125. bu_no,
  1126. status
  1127. from eam_workPlan_overview
  1128. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1129. </select>
  1130. <update id="planOrder">
  1131. update eam_workPlan
  1132. set Status = '已计划',
  1133. NextWorkDate = null
  1134. where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1135. </update>
  1136. <update id="cancelPlan">
  1137. update eam_workPlan_overview
  1138. set status = '已取消',
  1139. next_work_date = null
  1140. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1141. </update>
  1142. <update id="updateWorkPlanStatus">
  1143. update eam_workPlan
  1144. set Status = '已取消',
  1145. NextWorkDate = null
  1146. where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1147. </update>
  1148. <update id="cancelOrderWithPlanID">
  1149. update eam_workOrder
  1150. set Status = '已取消'
  1151. where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
  1152. </update>
  1153. <update id="deleteOrderDetailWithPlanID">
  1154. delete from eam_workOrder_item
  1155. where site = #{site} and bu_no = #{buNo}
  1156. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  1157. </update>
  1158. <update id="deleteOrderWithPlanID">
  1159. delete from eam_workOrder
  1160. where site = #{site} and bu_no = #{buNo}
  1161. and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
  1162. </update>
  1163. <update id="updateOrderPlanOperator">
  1164. update eam_workOrder
  1165. set PlanOperator = #{planOperator}
  1166. where site = #{site} and orderNo = #{orderNo}
  1167. </update>
  1168. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1169. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  1170. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  1171. <where>
  1172. <if test="partNo != null and partNo != ''">
  1173. AND a.part_no like '%' + #{partNo} + '%'
  1174. </if>
  1175. <if test="partDescription != null and partDescription != ''">
  1176. AND a.part_description like '%' + #{partDescription} + '%'
  1177. </if>
  1178. and a.site=#{site} and a.active='Y'
  1179. </where>
  1180. </select>
  1181. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1182. select part_no
  1183. from resource_spare
  1184. where site = #{site}
  1185. and resource_id = #{objectID}
  1186. and part_no = #{partNo}
  1187. </select>
  1188. <insert id="savePartSpare" >
  1189. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1190. values(#{objectID},#{partNo},'',0,#{site})
  1191. </insert>
  1192. <delete id="deletePartSpare">
  1193. <foreach collection="list" item="item" separator=";">
  1194. delete from resource_spare where site = #{item.site} and resource_id = #{item.objectID}
  1195. </foreach>
  1196. </delete>
  1197. <insert id="copyPartSpare" >
  1198. INSERT INTO resource_spare
  1199. (resource_id, part_no, delflag, version, site)
  1200. <foreach item="item" index="index" collection="list" separator=",">
  1201. select #{item.objectID}, part_no, delflag, 0, site from resource_spare where resource_id = #{item.oldObjectID} and site = #{item.site}
  1202. </foreach>
  1203. </insert>
  1204. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1205. SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status,
  1206. a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark
  1207. ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
  1208. FROM eam_workPlan a
  1209. left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID
  1210. left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID
  1211. left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no
  1212. where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N'
  1213. and status in ('已计划','进行中')
  1214. </select>
  1215. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1216. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  1217. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  1218. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  1219. where a.site=#{site} and a.ObjectID=#{objectID}
  1220. and a.ItemType=#{itemType}
  1221. </select>
  1222. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1223. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  1224. from eam_object_defect a left join eam_defect b
  1225. on a.DefectID=b.DefectID
  1226. where a.site=#{site} and a.ObjectID=#{objectID}
  1227. </select>
  1228. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1229. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1230. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1231. </select>
  1232. <insert id="saveNewEamObjectItem" >
  1233. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1234. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  1235. </insert>
  1236. <update id="editEamObjectItem">
  1237. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  1238. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  1239. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1240. and ItemNo=#{itemNo}
  1241. </update>
  1242. <delete id="deleteObjectItem">
  1243. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1244. and ItemNo=#{itemNo}
  1245. </delete>
  1246. <insert id="saveNewEamObjectItemAvailable">
  1247. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1248. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1249. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1250. </insert>
  1251. <delete id="deleteEamObjectItemAvailable">
  1252. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1253. and ItemNo=#{itemNo}
  1254. </delete>
  1255. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1256. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1257. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1258. </select>
  1259. <select id="getItemValueNoForObject" resultType="Double">
  1260. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1261. </select>
  1262. <insert id="saveObjectItemAvailable">
  1263. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1264. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1265. </insert>
  1266. <update id="updateObjectItemAvailable">
  1267. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1268. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1269. </update>
  1270. <delete id="deleteObjectItemAvailable">
  1271. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1272. </delete>
  1273. <delete id="deleteObjectItemForCopy">
  1274. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1275. </delete>
  1276. <delete id="deleteObjectItemAvailableForCopy">
  1277. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1278. </delete>
  1279. <insert id="copyObjectItem" >
  1280. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1281. ItemType)
  1282. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1283. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1284. </insert>
  1285. <insert id="copyObjectItemAvailable">
  1286. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1287. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1288. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1289. </insert>
  1290. <delete id="deleteObjectDefectForCopy">
  1291. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1292. </delete>
  1293. <insert id="copyObjectDefect">
  1294. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1295. select #{site},#{objectID},DefectID,Active
  1296. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1297. </insert>
  1298. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1299. select
  1300. a.Site,
  1301. a.bu_no,
  1302. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1303. a.FeedBackID,
  1304. a.FeedBackDesc,
  1305. a.ObjectID,
  1306. a.DefectID,
  1307. a.FunctionType,
  1308. a.PlanOperator,
  1309. a.ActualOperator,
  1310. a.Status,
  1311. a.PlanDate,
  1312. a.Remark,
  1313. a.urgency,
  1314. a.deleteFlag,
  1315. a.CreatedDate,
  1316. a.CreatedBy,
  1317. c.operator_name as feedbackBy,
  1318. a.UpdateDate,
  1319. a.UpdateBy,
  1320. a.Version,
  1321. a.DefectDate,
  1322. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
  1323. b.defectDesc,
  1324. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) ObjectDesc,
  1325. FinishDate,
  1326. dbo.joint_name(a.Site, a.bu_no, (select OrderNo from eam_workOrder where PlanID = a.FeedBackID and site = a.site and Result = '维修完成' and bu_no = a.bu_no),a.FunctionType) as actualOperatorName
  1327. from eam_defect_feedBack a
  1328. left join eam_defect b on a.DefectID = b.DefectID
  1329. left join operator as c on a.site = c.site and a.CreatedBy = c.operator_id
  1330. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and e.Active = 'Y' and a.bu_no = e.bu_no
  1331. left join sys_department as f on e.site = f.site and e.dept_id = f.department_id and e.bu_no = f.bu_no
  1332. left join Access_dept as ead ON ead.site = f.site and ead.department_id = f.department_id and ead.bu_no = f.bu_no
  1333. left join sys_user as ea on ead.username = ea.username
  1334. <where>
  1335. a.site in (select site from eam_access_site where username = #{query.userName})
  1336. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1337. and ea.username = #{query.userName}
  1338. <if test="query.buDesc != null and query.buDesc != ''">
  1339. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  1340. </if>
  1341. <if test="query.feedBackID != null and query.feedBackID != ''">
  1342. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1343. </if>
  1344. <if test="query.defectDesc != null and query.defectDesc != ''">
  1345. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1346. </if>
  1347. <if test="query.objectID != null and query.objectID != ''">
  1348. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1349. </if>
  1350. <if test="query.planOperator != null and query.planOperator != ''">
  1351. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1352. </if>
  1353. <if test="query.status != null and query.status != ''">
  1354. AND a.status = #{query.status}
  1355. </if>
  1356. <if test="query.startDate != null ">
  1357. AND a.defectDate >= #{query.startDate}
  1358. </if>
  1359. <if test="query.endDate != null ">
  1360. AND #{query.endDate} >= a.defectDate
  1361. </if>
  1362. <if test="query.urgency != null and query.urgency != ''">
  1363. AND a.urgency = #{query.urgency}
  1364. </if>
  1365. and a.FunctionType = #{query.functionType}
  1366. </where>
  1367. ORDER BY a.DefectDate,
  1368. CASE WHEN a.urgency = '特急' THEN 1
  1369. WHEN a.urgency = '紧急' THEN 2
  1370. WHEN a.urgency = '一般' THEN 3
  1371. END
  1372. </select>
  1373. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1374. select Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, Status from eam_defect_feedBack where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1375. </select>
  1376. <update id="cancelFeedBack" >
  1377. update eam_defect_feedBack
  1378. set status = '已取消'
  1379. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1380. </update>
  1381. <update id="updateFeedBack">
  1382. update eam_defect_feedBack
  1383. set status = '已下达',
  1384. PlanOperator = #{planOperator},
  1385. UpdateDate = GetDate(),
  1386. UpdateBy = #{updateBy}
  1387. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1388. </update>
  1389. <insert id="saveDefectOrder">
  1390. INSERT INTO eam_workOrder
  1391. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1392. values(#{site}, #{buNo}, (select 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) from eam_workOrder where site = #{site} and FunctionType='C' and bu_no = #{buNo}), #{feedBackID}, '', #{objectID}, '未开工', #{planOperator}, #{planDate}, 'C', GetDate(), #{userId})
  1393. </insert>
  1394. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1395. SELECT
  1396. a.site,
  1397. a.bu_no,
  1398. a.itemNo,
  1399. a.ItemDesc,
  1400. a.ItemRemark
  1401. FROM eam_properties_item a
  1402. LEFT JOIN eam_properties_model_detail b on b.function_type = #{functionType} and b.code_no = #{codeNo} and b.properties_item_no = a.ItemNo and a.site = b.site and a.bu_no = b.bu_no
  1403. <where>
  1404. a.ItemType = #{functionType}
  1405. and a.site = #{site} and a.bu_no = #{buNo}
  1406. AND b.code_no is null
  1407. <if test = "itemNo != null and itemNo != ''">
  1408. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1409. </if>
  1410. <if test = "itemDesc != null and itemDesc != ''">
  1411. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1412. </if>
  1413. </where>
  1414. </select>
  1415. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1416. select
  1417. a.site,
  1418. a.bu_no,
  1419. a.properties_item_no itemNo,
  1420. b.ItemDesc,
  1421. b.ItemRemark
  1422. from eam_properties_model_detail a
  1423. left join eam_properties_item b on a.properties_item_no = b.ItemNo and a.function_type = b.ItemType and a.site = b.site and a.bu_no = b.bu_no
  1424. where a.site = #{site} and a.bu_no = #{buNo} and a.code_no = #{codeNo}
  1425. and a.function_type = #{functionType}
  1426. </select>
  1427. <delete id="deleteObjectFile">
  1428. delete from sys_oss where id = #{id}
  1429. </delete>
  1430. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1431. SELECT id, url, create_date, file_name, new_file_name, created_by,
  1432. order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1433. FROM sys_oss
  1434. WHERE order_ref2 = #{orderNo}
  1435. AND order_ref1 = #{site}
  1436. AND order_ref3 = 'reportSparPart'
  1437. </select>
  1438. <!-- 获取机修人员列表 -->
  1439. <select id="getOperatorList" resultType="EamAdminData" parameterType="EamAdminData">
  1440. SELECT
  1441. ea.AdminID,
  1442. ea.AdminName,
  1443. ea.Phone,
  1444. dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName,
  1445. ea.Email,
  1446. ea.Tel,
  1447. ea.LevelID,
  1448. eal.AdminLevelDesc,
  1449. ea.MesUser,
  1450. ea.Active,
  1451. ea.CreatedDate
  1452. FROM eam_admin as ea
  1453. LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1454. <where>
  1455. ea.Active = 'Y'
  1456. AND ea.Site = #{site}
  1457. <if test = "adminID != null and adminID != ''">
  1458. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1459. </if>
  1460. <if test = "adminName != null and adminName != ''">
  1461. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1462. </if>
  1463. </where>
  1464. </select>
  1465. <!-- 获取审核人员列表 -->
  1466. <select id="getCheckerList" resultType="EamAdminData" parameterType="EamAdminData">
  1467. SELECT
  1468. a.user_id,
  1469. a.username as adminID,
  1470. a.email,
  1471. a.mobile as phone,
  1472. a.user_display as adminName,
  1473. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  1474. d.role_id,
  1475. e.role_name
  1476. FROM sys_user as a
  1477. LEFT JOIN eam_access_site as b on a.username = b.username
  1478. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  1479. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  1480. LEFT JOIN sys_role as e on d.role_id = e.role_id
  1481. <where>
  1482. b.site = #{site} and c.bu_no = #{buNo}
  1483. <if test = "adminID != null and adminID != ''">
  1484. AND a.username LIKE '%' + #{adminID}+'%'
  1485. </if>
  1486. <if test = "adminName != null and adminName != ''">
  1487. AND a.user_display LIKE '%' + #{adminName}+'%'
  1488. </if>
  1489. <if test = "buDesc != null and buDesc != ''">
  1490. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  1491. </if>
  1492. <if test = "roleId != null and roleId != ''">
  1493. AND d.role_id = #{roleId}
  1494. </if>
  1495. </where>
  1496. </select>
  1497. <!-- 点检工单审核 -->
  1498. <update id="checkWorkOrder" parameterType="EamWorkOrderInData">
  1499. UPDATE eam_workOrder
  1500. SET Status = '已完工'
  1501. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1502. </update>
  1503. <update id="cancelCheckWorkOrder" parameterType="EamWorkOrderInData">
  1504. UPDATE eam_workOrder
  1505. SET Status = '待审核'
  1506. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1507. </update>
  1508. <!-- 查看点检工单状态 -->
  1509. <select id="checkWorkOrderStatus" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1510. SELECT
  1511. OrderNo
  1512. FROM eam_workOrder
  1513. WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' and bu_no = #{buNo}
  1514. </select>
  1515. <!-- 点检工单审核 -->
  1516. <update id="updateWorkPlanOverviewStatus" parameterType="EamWorkOrderInData">
  1517. UPDATE eam_workPlan_overview
  1518. SET status = '已结束'
  1519. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1520. </update>
  1521. <!-- 新增点检计划 -->
  1522. <insert id="saveWorkPlan" parameterType="EamWorkPlanInData">
  1523. INSERT INTO eam_workPlan_overview
  1524. (site, plan_id, plan_desc, status, plan_start_date, plan_end_date, created_date, created_by, update_date, update_by, remark, delete_flag, operator, operator_name, checker, checker_name, function_type, properties_code, plan_period, work_order_rule, plan_cycle, task_start_date, plan_halt_date, auto_renewal, bu_no)
  1525. VALUES (#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy}, #{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod}, #{workOrderRule}, #{planCycle}, #{taskStartDate}, #{planHaltDate}, #{autoRenewal}, #{buNo})
  1526. </insert>
  1527. <!-- 生成工单ID -->
  1528. <select id="selectOrderId" resultType="string" parameterType="EamWorkPlanInData">
  1529. SELECT
  1530. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1531. FROM eam_workPlan
  1532. WHERE site = #{site} AND FunctionType = #{functionType} and bu_no = #{buNo}
  1533. </select>
  1534. <!-- 查询计划中的设备列表 -->
  1535. <select id="getPlanDetailList" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1536. SELECT
  1537. ewp.PlanID,
  1538. ewp.PlanDesc,
  1539. ewp.ObjectID,
  1540. eo.ObjectDesc,
  1541. eo.FamilyID,
  1542. ef.FamilyDesc,
  1543. eo.LocationID,
  1544. el.LocationName
  1545. FROM eam_workPlan as ewP
  1546. LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site and ewP.bu_no = eo.bu_no
  1547. LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site and ewP.bu_no = ef.bu_no
  1548. LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site and ewP.bu_no = el.bu_no
  1549. <where>
  1550. ewP.site = #{site} and ewP.bu_no = #{buNo}
  1551. AND ewp.PlanID = #{planID}
  1552. <if test = "objectID != null and objectID != ''">
  1553. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  1554. </if>
  1555. <if test = "objectDesc != null and objectDesc != ''">
  1556. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  1557. </if>
  1558. </where>
  1559. </select>
  1560. <!-- 删除计划中的设备 -->
  1561. <delete id="delPlanDetail" parameterType="WorkPlanDetailData">
  1562. DELETE FROM eam_workPlan
  1563. WHERE Site = #{site}
  1564. AND PlanID = #{planID}
  1565. AND ObjectID = #{objectID}
  1566. </delete>
  1567. <!-- 获取当前计划不包含的设备 -->
  1568. <select id="getObjList1" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1569. SELECT
  1570. a.ObjectID,
  1571. a.ObjectDesc,
  1572. a.FamilyID,
  1573. ef.FamilyDesc,
  1574. a.LocationID,
  1575. el.LocationName
  1576. FROM eam_object a
  1577. LEFT JOIN eam_workPlan b ON b.PlanID = #{planID} and b.ObjectID = a.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1578. LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1579. LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1580. WHERE a.site = #{site} and a.bu_no = #{buNo} and b.PlanID is null
  1581. </select>
  1582. <!-- 获取当前计划包含的设备 -->
  1583. <select id="getObjList2" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1584. SELECT
  1585. a.ObjectID,
  1586. b.ObjectDesc,
  1587. b.FamilyID,
  1588. ef.FamilyDesc,
  1589. b.LocationID,
  1590. el.LocationName
  1591. FROM eam_workPlan a
  1592. LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1593. LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1594. LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1595. WHERE a.PlanID = #{planID} and a.site = #{site} and a.bu_no = #{buNo}
  1596. </select>
  1597. <!-- 添加计划设备 -->
  1598. <insert id="addObject" parameterType="EamWorkPlanInData">
  1599. INSERT INTO eam_workPlan
  1600. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  1601. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  1602. </insert>
  1603. <!-- 修改工单计划 -->
  1604. <update id="updateWorkPlan" parameterType="EamWorkPlanInData">
  1605. UPDATE eam_workPlan_overview
  1606. SET plan_desc = #{planDesc},
  1607. properties_code = #{propertiesCode},
  1608. plan_start_date = #{planStartDate},
  1609. plan_end_date = #{planEndDate},
  1610. plan_period = #{planPeriod},
  1611. remark = #{remark},
  1612. operator = #{operator},
  1613. operator_name = #{operatorName},
  1614. checker = #{checker},
  1615. checker_name = #{checkerName},
  1616. work_order_rule = #{workOrderRule},
  1617. task_start_date = #{taskStartDate},
  1618. plan_cycle = #{planCycle},
  1619. plan_halt_date = #{planHaltDate},
  1620. auto_renewal = #{autoRenewal}
  1621. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1622. </update>
  1623. <!-- 删除该计划的旧设备 -->
  1624. <delete id="delWorkPlanObject" parameterType="EamWorkPlanInData">
  1625. DELETE FROM eam_workPlan
  1626. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1627. </delete>
  1628. <!-- 删除该计划的旧设备item -->
  1629. <delete id="delWorkPlanItem" parameterType="EamWorkPlanInData">
  1630. DELETE FROM eam_workPlan_item
  1631. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1632. </delete>
  1633. <!-- 删除该计划的旧设备itemAvailable-->
  1634. <delete id="delWorkPlanItemAvailable">
  1635. DELETE FROM eam_workPlan_item_available
  1636. WHERE Site = #{site}
  1637. AND PlanID = #{planID}
  1638. AND ObjectID = #{objectID}
  1639. </delete>
  1640. <!-- 查询该计划的设备 -->
  1641. <select id="planObjectSearch" resultType="EamWorkPlanItemData" parameterType="EamWorkPlanItemData">
  1642. SELECT DISTINCT
  1643. a.ObjectID,
  1644. b.ObjectDesc
  1645. FROM eam_workPlan_item as a
  1646. LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1647. WHERE a.Site = #{site} AND a.PlanID = #{planID} and a.bu_no = #{buNo}
  1648. </select>
  1649. <!-- 修改该计划状态 -->
  1650. <update id="updateOverviewStatus" parameterType="EamWorkPlanInData">
  1651. UPDATE eam_workPlan_overview
  1652. SET status = '进行中',
  1653. next_work_date = plan_start_date
  1654. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1655. </update>
  1656. <!-- 查询文件路径 -->
  1657. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1658. SELECT
  1659. id,
  1660. url,
  1661. file_name
  1662. FROM sys_oss WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} and order_ref4 = #{buNo}
  1663. </select>
  1664. <!-- 新增子明细信息 -->
  1665. <insert id="saveOperator" parameterType="EamWorkOrderInData">
  1666. INSERT INTO eam_actual_operator
  1667. (site, order_no, function_type, operator, bu_no)
  1668. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
  1669. </insert>
  1670. <!-- AND Status = '已完工' AND PlanOperator is not null-->
  1671. <!-- 查询实际维修人员 -->
  1672. <select id="getActualOperatorList2" resultType="EamAdminData">
  1673. SELECT
  1674. ea.AdminID,
  1675. ea.AdminName
  1676. FROM eam_actual_operator as eao
  1677. LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site
  1678. LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo
  1679. WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID}
  1680. </select>
  1681. <!-- 查询实际维修人员 -->
  1682. <select id="getActualOperatorList" resultType="EamAdminData">
  1683. SELECT
  1684. ea.username as adminID,
  1685. ea.user_display as AdminName
  1686. FROM eam_actual_operator as eao
  1687. LEFT JOIN sys_user as ea ON eao.operator = ea.username
  1688. WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} and eao.bu_no = #{buNo}
  1689. </select>
  1690. <!-- 查询设备所属部门 -->
  1691. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  1692. SELECT ved.department_name
  1693. FROM eam_object as eo
  1694. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  1695. WHERE eo.site = #{site}
  1696. AND eo.ObjectID = #{objectID}
  1697. </select>
  1698. <!-- 查询用户所属部门 -->
  1699. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  1700. SELECT AdminID
  1701. FROM eam_admin
  1702. WHERE site = #{site}
  1703. AND MesUser = #{username}
  1704. </select>
  1705. <!-- &lt;!&ndash; 查询部门列表 &ndash;&gt;-->
  1706. <!-- <select id="getDeptList" resultType="string" parameterType="string">-->
  1707. <!-- SELECT-->
  1708. <!-- ved.department_name-->
  1709. <!-- FROM eam_admin_dept as ead-->
  1710. <!-- LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id-->
  1711. <!-- LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID-->
  1712. <!-- WHERE ead.site = #{site} AND ea.MesUser = #{username}-->
  1713. <!-- </select>-->
  1714. <!-- 查询部门列表 -->
  1715. <select id="getDeptList" resultType="string" parameterType="string">
  1716. SELECT
  1717. distinct c.department_name
  1718. from sys_user as a
  1719. left join Access_dept as b on a.username = b.username
  1720. left join sys_department as c on c.site in (select site from eam_access_site where username = #{username})
  1721. and (c.site + '-' + c.bu_no) in (select * from dbo.query_bu(#{username}))
  1722. and b.department_id = c.department_id
  1723. where a.username = #{username}
  1724. </select>
  1725. <!-- 生成新的维修工单 -->
  1726. <insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData">
  1727. INSERT INTO eam_workOrder
  1728. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no, document_source)
  1729. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource})
  1730. </insert>
  1731. <!-- 获取旧工单的基础信息 -->
  1732. <select id="queryOldWorkOrderMessage" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1733. select
  1734. PlanOperator,
  1735. PlanOperatorName,
  1736. checker,
  1737. checkerName
  1738. from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1739. </select>
  1740. <!-- 生成新的维保工单 -->
  1741. <insert id="saveMaintenanceWorkOrder" parameterType="EamWorkOrderInData">
  1742. INSERT INTO eam_workOrder
  1743. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1744. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  1745. </insert>
  1746. <!-- 检查系统操作人和审核人员是否一致 -->
  1747. <select id="selectNameByMes" resultType="EamAdminData" parameterType="EamAdminData">
  1748. SELECT AdminName
  1749. FROM eam_admin
  1750. WHERE site = #{site}
  1751. AND MesUser = #{mesUser}
  1752. </select>
  1753. <!-- 维修审核确认 -->
  1754. <update id="submitDefect" parameterType="EamWorkOrderInData">
  1755. UPDATE eam_workOrder
  1756. SET Status = #{status},
  1757. difficulty_level = #{difficultyLevel},
  1758. difficulty_remark = #{difficultyRemark}
  1759. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1760. </update>
  1761. <!-- 查询设备的点检和维保历史记录 -->
  1762. <select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1763. SELECT
  1764. top 10
  1765. ewo.OrderNo,
  1766. ewo.PlanID,
  1767. ewo.PlanDesc,
  1768. ewo.ActualDate,
  1769. ewo.ObjectID,
  1770. eo.ObjectDesc,
  1771. ewo.Remark,
  1772. dbo.eam_Get_eamAdminName(ewo.site,ewo.ActualOperator) ActualOperatorName,
  1773. ewo.checkResult
  1774. FROM eam_workOrder as ewo
  1775. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1776. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND (ewo.Status = '已完工' or ewo.Status = '待审核')and ewo.bu_no = #{buNo}
  1777. ORDER BY ewo.ActualDate desc
  1778. </select>
  1779. <!-- 查询设备的维修历史记录 -->
  1780. <select id="queryDefectHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1781. SELECT
  1782. top 10
  1783. ewo.OrderNo,
  1784. ewo.PlanID,
  1785. ewo.PlanDesc,
  1786. ewo.ActualDate,
  1787. ewo.Remark,
  1788. ewo.Result,
  1789. ewo.disposal_measures,
  1790. ed.DefectDesc,
  1791. ewo.WorkTime
  1792. FROM eam_workOrder as ewo
  1793. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1794. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID and ewo.bu_no = edf.bu_no
  1795. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  1796. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND (ewo.Status = '已完工' or ewo.Status = '待审核') and ewo.bu_no = #{buNo} ORDER BY ewo.ActualDate desc
  1797. </select>
  1798. <!-- 查询部门列表 -->
  1799. <select id="getEmpyDeptList" resultType="EmpyDept" parameterType="EmpyDept">
  1800. SELECT
  1801. site,
  1802. department_id as deptId,
  1803. department_name as deptName
  1804. FROM sys_department
  1805. <where>
  1806. site in (select site from eam_access_site where username = #{userName})
  1807. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  1808. <if test = "deptId != null and deptId != ''">
  1809. AND department_id LIKE '%' + #{deptId}+'%'
  1810. </if>
  1811. <if test = "deptName != null and deptName != ''">
  1812. AND department_name LIKE '%' + #{deptName}+'%'
  1813. </if>
  1814. </where>
  1815. </select>
  1816. <!-- 生成新的维修工单 -->
  1817. <insert id="saveAdminDepartment">
  1818. INSERT INTO eam_admin_dept
  1819. (Site, admin_id, dept_id)
  1820. VALUES (#{site}, #{adminID}, #{deptId})
  1821. </insert>
  1822. <!-- 查询部门详情 -->
  1823. <select id="getDeptDetail" resultType="EamAdminData" parameterType="string">
  1824. SELECT
  1825. ved.department_id as department,
  1826. ved.department_name as departmentName
  1827. FROM eam_admin_dept as ead
  1828. LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id and ead.bu_no = ved.bu_no
  1829. WHERE ead.site in (select site from eam_access_site where username = #{userName})
  1830. and (ead.site + '-' + ead.bu_no) in (select * from dbo.query_bu(#{userName}))
  1831. AND ead.admin_id = #{adminID}
  1832. </select>
  1833. <!-- 删除旧数据-->
  1834. <delete id="deleteAdminDepartment">
  1835. DELETE FROM eam_admin_dept
  1836. WHERE site = #{site}
  1837. AND admin_id = #{adminID}
  1838. </delete>
  1839. <!-- 获取可用的MES账号 -->
  1840. <select id="getMesList" resultType="SysUserEntity" parameterType="SysUserEntity">
  1841. SELECT
  1842. a.username,
  1843. a.user_display
  1844. FROM sys_user a
  1845. LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site
  1846. WHERE a.site = #{site}
  1847. AND b.MesUser is null
  1848. </select>
  1849. <!-- 查询点检项目 -->
  1850. <select id="eamPropertiesItemSearch" parameterType="EamPropertiesItemData" resultType="EamPropertiesItemData">
  1851. SELECT
  1852. site,
  1853. bu_no,
  1854. dbo.get_bu_desc(site, bu_no) as buDesc,
  1855. ItemNo,
  1856. ItemDesc,
  1857. DefaultValue,
  1858. ValueType,
  1859. ValueType_DB as valueTypeDb,
  1860. ValueChooseFlag,
  1861. CreatedDate,
  1862. CreatedBy,
  1863. update_date,
  1864. update_by,
  1865. MaxValue,
  1866. MinValue,
  1867. ItemRemark,
  1868. ItemType,
  1869. image_flag,
  1870. produce_control_flag
  1871. FROM eam_properties_item
  1872. <where>
  1873. site in (select site from eam_access_site where username = #{query.userName})
  1874. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1875. and ItemType = #{query.itemType}
  1876. <if test="query.buDesc != null and query.buDesc != ''">
  1877. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  1878. </if>
  1879. <if test="query.itemNo != null and query.itemNo != ''">
  1880. AND ItemNo LIKE '%' + #{query.itemNo}+'%'
  1881. </if>
  1882. <if test="query.itemDesc != null and query.itemDesc != ''">
  1883. AND ItemDesc LIKE '%' + #{query.itemDesc}+'%'
  1884. </if>
  1885. </where>
  1886. </select>
  1887. <!-- 删除图片-->
  1888. <delete id="imageDelete" parameterType="SysOssEntity">
  1889. DELETE FROM sys_oss
  1890. WHERE id = #{id}
  1891. </delete>
  1892. <!-- 检查该日期内是否已有该设备的计划 -->
  1893. <select id="checkObjectPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1894. SELECT
  1895. a.PlanID,
  1896. a.ObjectID
  1897. FROM eam_workPlan a
  1898. LEFT JOIN eam_workOrder b ON a.site = b.site AND a.PlanID = b.PlanID and a.FunctionType = b.FunctionType and a.ObjectID = b.ObjectID and a.bu_no = b.bu_no
  1899. WHERE a.site = #{site} and a.bu_no = #{buNo}
  1900. AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N'
  1901. AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  1902. or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  1903. or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0)
  1904. )
  1905. and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod}
  1906. and b.Status not in ('已取消','已完成','待审核')
  1907. </select>
  1908. <!-- 查询当前计划 -->
  1909. <select id="queryWorkPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1910. SELECT
  1911. site,
  1912. bu_no,
  1913. plan_id,
  1914. plan_desc,
  1915. properties_code,
  1916. #{objectID} as objectID,
  1917. status,
  1918. operator,
  1919. delete_flag,
  1920. plan_start_date,
  1921. plan_end_date,
  1922. plan_period,
  1923. function_type,
  1924. checker,
  1925. checker_name,
  1926. operator_name,
  1927. work_order_rule,
  1928. plan_cycle
  1929. FROM eam_workPlan_overview
  1930. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1931. </select>
  1932. <!-- 获得工单号 -->
  1933. <select id="queryPlanOrderNo" resultType="string" parameterType="EamWorkPlanInData">
  1934. SELECT
  1935. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  1936. FROM eam_workOrder
  1937. WHERE site = #{site} and bu_no = #{buNo} AND FunctionType = #{functionType}
  1938. </select>
  1939. <!-- 新增工单 -->
  1940. <insert id="insertWorkOrder" parameterType="EamWorkPlanInData">
  1941. INSERT INTO eam_workOrder
  1942. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1943. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1944. </insert>
  1945. <!-- 循环新增工单 -->
  1946. <insert id="forInsertWorkOrder" parameterType="EamWorkPlanInData">
  1947. INSERT INTO eam_workOrder
  1948. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, last_execution_date)
  1949. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{lastExecutionDate})
  1950. </insert>
  1951. <!-- 更改plan表的状态为进行中 -->
  1952. <update id="updatePlanStatus" parameterType="EamWorkPlanInData">
  1953. update eam_workPlan
  1954. set status = '进行中',
  1955. NextWorkDate = PlanStartDate
  1956. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1957. </update>
  1958. <!-- 获得工单号 -->
  1959. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="EamWorkOrderItemInData">
  1960. SELECT
  1961. id,
  1962. file_name
  1963. FROM sys_oss
  1964. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  1965. </select>
  1966. <!-- 删除原来工单项目-->
  1967. <delete id="deleteWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1968. DELETE FROM eam_workPlan_item
  1969. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1970. </delete>
  1971. <!-- 删除原来的可选值-->
  1972. <delete id="deleteWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1973. DELETE FROM eam_workPlan_item_available
  1974. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1975. </delete>
  1976. <!-- 添加新项目 -->
  1977. <insert id="saveWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1978. INSERT INTO eam_workPlan_item (Site, bu_no, PlanID, ObjectID, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, CreatedDate, CreatedBy, image_flag, produce_control_flag)
  1979. select
  1980. #{site},
  1981. #{buNo},
  1982. #{planID},
  1983. #{objectID},
  1984. a.ItemNo,
  1985. a.ItemDesc,
  1986. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  1987. case when c.site is not null then c.ValueType else a.ValueType end,
  1988. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  1989. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  1990. case when c.site is not null then c.MaxValue else a.MaxValue end,
  1991. case when c.site is not null then c.MinValue else a.MinValue end,
  1992. a.ItemRemark,
  1993. a.ItemType,
  1994. GetDate(),
  1995. #{userId},
  1996. a.image_flag,
  1997. a.produce_control_flag
  1998. from eam_properties_item a
  1999. left join eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no and a.site = b.site and a.bu_no = b.bu_no
  2000. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  2001. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2002. </insert>
  2003. <!-- 添加新项目可选值 -->
  2004. <insert id="saveWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  2005. INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  2006. SELECT DISTINCT
  2007. #{site},
  2008. #{buNo},
  2009. #{planID},
  2010. #{objectID},
  2011. a.ItemNo,
  2012. a.ItemType,
  2013. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  2014. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  2015. GetDate(),
  2016. #{userId}
  2017. FROM eam_properties_item_available a
  2018. LEFT JOIN eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no and a.site = b.site and a.bu_no = b.bu_no
  2019. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  2020. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2021. </insert>
  2022. <!-- 检查维修任务号是否已存在 -->
  2023. <select id="getEamGzData" resultType="EamDefectFeedBackData" parameterType="EamDefectFeedBackData">
  2024. select
  2025. a.Site,
  2026. a.bu_no,
  2027. a.FeedBackID,
  2028. a.FeedBackDesc,
  2029. a.ObjectID,
  2030. a.Status
  2031. from eam_defect_feedBack a
  2032. left join eam_defect b on a.DefectID = b.DefectID
  2033. <where>
  2034. a.site = #{site} and a.deleteFlag = 'N' and a.bu_no = #{buNo}
  2035. <if test="feedBackID != null and feedBackID != ''">
  2036. AND a.FeedBackID LIKE '%' + #{feedBackID}+'%'
  2037. </if>
  2038. <if test="feedBackDesc != null and feedBackDesc != ''">
  2039. AND a.FeedBackDesc LIKE '%' + #{feedBackDesc}+'%'
  2040. </if>
  2041. <if test="objectInfo != null and objectInfo != ''">
  2042. AND (a.ObjectID like '%' + #{objectInfo} + '%' or dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) like '%' + #{objectInfo} + '%')
  2043. </if>
  2044. <if test="defectInfo != null and defectInfo != ''">
  2045. AND (a.DefectID like '%' + #{defectInfo} + '%' or b.defectDesc like '%' + #{defectInfo} + '%')
  2046. </if>
  2047. </where>
  2048. </select>
  2049. <!-- 保存故障信息 -->
  2050. <insert id="saveEamGzBbData" parameterType="EamDefectFeedBackData">
  2051. INSERT INTO eam_defect_feedBack
  2052. (Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate, Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency)
  2053. VALUES (#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate}, #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency})
  2054. </insert>
  2055. <!-- 查看现场动控是否开启 -->
  2056. <select id="selectControlBaseData" resultType="SysSceneDynamicControlModelEntity" parameterType="string">
  2057. SELECT
  2058. type,
  2059. base_data,
  2060. base_desc,
  2061. status,
  2062. remark,
  2063. third_type,
  2064. second_type,
  2065. page_control,
  2066. control_style
  2067. FROM sys_scene_dynamic_control_model
  2068. where site = #{site} and control_no = #{controlNo}
  2069. </select>
  2070. <!-- 修改反馈状态为已下达 -->
  2071. <update id="updateDefectFeedBackStatus" parameterType="EamDefectFeedBackData">
  2072. UPDATE eam_defect_feedBack
  2073. SET Status = '已下达'
  2074. WHERE Site = #{site} AND FeedBackID = #{feedBackID} and bu_no = #{buNo}
  2075. </update>
  2076. <!-- 查询工单号 -->
  2077. <select id="getOrderNo" resultType="string" parameterType="EamWorkOrderInData">
  2078. select
  2079. 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2080. from eam_workOrder
  2081. where site = #{site} and FunctionType = 'C' and bu_no = #{buNo}
  2082. </select>
  2083. <!-- 创建维修工单 -->
  2084. <insert id="saveWorkOrder" parameterType="EamDefectFeedBackData">
  2085. INSERT INTO eam_workOrder
  2086. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source)
  2087. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource})
  2088. </insert>
  2089. <!-- 修改工单 -->
  2090. <update id="updateWorkOrder" parameterType="EamWorkOrderInData">
  2091. update eam_workOrder
  2092. set update_by = #{mesUser},
  2093. update_date = GetDate(),
  2094. Remark = #{remark},
  2095. reach_date = #{reachDate},
  2096. ActualDate = #{actualDate},
  2097. WorkTime = #{workTime},
  2098. <if test='functionType == "B" and checkResult == "合格"'>
  2099. disposal_measures = '',
  2100. </if>
  2101. <if test='functionType == "B" and checkResult == "异常"'>
  2102. disposal_measures = #{disposalMeasures},
  2103. </if>
  2104. checkResult = #{checkResult},
  2105. check_remark = #{checkRemark},
  2106. fault_reason = #{faultReason},
  2107. preventive_measure = #{preventiveMeasure}
  2108. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  2109. </update>
  2110. <!-- 修改工单项目 -->
  2111. <update id="updateWorkOrderItem" parameterType="EamWorkOrderItemInData">
  2112. update eam_workOrder_item
  2113. set update_by = #{updateBy},
  2114. update_date = GetDate(),
  2115. <if test='valueTypeDb == "T"'>
  2116. TextValue = #{textValue},
  2117. </if>
  2118. <if test='valueTypeDb == "N"'>
  2119. NumberValue = #{numberValue},
  2120. </if>
  2121. itemResult = #{itemResult}
  2122. where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
  2123. </update>
  2124. <!-- 删除之前的协同人员-->
  2125. <delete id="delOperator" parameterType="EamWorkOrderInData">
  2126. DELETE FROM eam_actual_operator
  2127. WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
  2128. </delete>
  2129. <!-- 到达 -->
  2130. <update id="reach" parameterType="EamWorkOrderInData">
  2131. update eam_workOrder
  2132. set Status = #{status},
  2133. reach_date = GetDate(),
  2134. reach_operator = #{reachOperator},
  2135. reach_operator_name = #{reachOperatorName}
  2136. where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_No = #{buNo}
  2137. </update>
  2138. <!-- 查询是否已经上传图片 -->
  2139. <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2140. SELECT
  2141. id
  2142. FROM sys_oss
  2143. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo}
  2144. </select>
  2145. <!-- 查询文件路径 -->
  2146. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2147. SELECT
  2148. id,
  2149. url,
  2150. file_name
  2151. FROM sys_oss
  2152. WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2153. </select>
  2154. <!-- 根据工单号查询知识库记录 -->
  2155. <select id="selectKnowledgeRecordByOrderNo" resultType="EamKnowledgeBaseData" parameterType="EamWorkOrderInData">
  2156. SELECT
  2157. site,
  2158. bu_no,
  2159. num
  2160. FROM eam_knowledge_base
  2161. WHERE site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2162. </select>
  2163. <!-- 根据工单号修改知识库记录 -->
  2164. <update id="updateKnowledgeRecordByOrderNo" parameterType="EamWorkOrderInData">
  2165. update eam_knowledge_base
  2166. set update_date = getDate(),
  2167. update_by = #{updateBy}
  2168. where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2169. </update>
  2170. <!-- 新增设备知识库记录 -->
  2171. <insert id="saveKnowledgeRecord" parameterType="EamWorkOrderInData">
  2172. INSERT INTO eam_knowledge_base
  2173. (site, bu_no, num, file_type, defect_describe, disposal_measures, create_date, create_by, object_id, defect_id, order_no)
  2174. VALUES (#{site}, #{buNo}, (select 'ZS'+ Right('0000000000' + convert(VARCHAR(10), isnull(max(convert(INT, SUBSTRING(num, 3, 10))), 0) + 1), 8) from eam_knowledge_base where site = #{site}), '维修', #{planDesc}, #{disposalMeasures}, getDate(), #{createBy}, #{objectID}, #{defectID}, #{orderNo})
  2175. </insert>
  2176. <!-- 修改反馈状态为已取消 -->
  2177. <update id="updateFeedBackStatus" parameterType="EamWorkOrderInData">
  2178. UPDATE eam_defect_feedBack
  2179. SET Status = '已取消'
  2180. WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
  2181. </update>
  2182. <!-- 获取所有分类 -->
  2183. <select id="getFamilyTree" resultType="EamFamilyData" parameterType="EamFamilyData">
  2184. SELECT
  2185. site,
  2186. bu_no,
  2187. FamilyID,
  2188. FamilyDesc,
  2189. parent_id,
  2190. son_id,
  2191. Active
  2192. FROM eam_family
  2193. WHERE site in (select site from eam_access_site where username = #{userName})
  2194. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2195. and Active = 'Y'
  2196. </select>
  2197. <!-- 获得sonId -->
  2198. <select id="getSonId" resultType="string" parameterType="EamFamilyData">
  2199. SELECT
  2200. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2)
  2201. FROM eam_family
  2202. WHERE site = #{site} and bu_no = #{buNo} and son_id like #{parentId} + '%'
  2203. </select>
  2204. <!-- 删除该分类以及其子类-->
  2205. <delete id="eamFamilyDelete" parameterType="EamFamilyData">
  2206. DELETE FROM eam_family
  2207. WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID}
  2208. <if test="sonId != null and sonId != ''">
  2209. and son_id like #{sonId} + '%'
  2210. </if>
  2211. </delete>
  2212. <select id="getEamWorkOrder" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  2213. EXEC EAM_WORK_ORDER #{site}, #{username}, #{orderNo}, #{planID}, #{objectID}, #{status}, #{startDate}, #{endDate}, #{functionType}, '*'
  2214. </select>
  2215. <!-- 修改执行结果 -->
  2216. <update id="updateReportResult" parameterType="EamWorkOrderInData">
  2217. update eam_workOrder
  2218. set ActualDate = #{actualDate},
  2219. reach_date = #{reachDate},
  2220. fault_reason = #{faultReason},
  2221. handling_method = #{handlingMethod},
  2222. preventive_measure = #{preventiveMeasure},
  2223. Remark = #{remark},
  2224. WorkTime = #{workTime}
  2225. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2226. </update>
  2227. <!-- 根据设备查所属部门 -->
  2228. <select id="queryDepartmentByObjectId" resultType="EamObjectAdminData" parameterType="EamDefectFeedBackData">
  2229. SELECT
  2230. eo.site,
  2231. eo.bu_no,
  2232. eo.ObjectDesc,
  2233. eo.dept_id,
  2234. el.LocationName
  2235. FROM eam_object as eo
  2236. LEFT JOIN eam_location as el on eo.site = el.site and eo.LocationID = el.LocationID and eo.bu_no = el.bu_no
  2237. WHERE eo.site = #{site} and eo.ObjectID = #{objectID} and eo.bu_no = #{buNo}
  2238. </select>
  2239. <!-- 根据部门ID查机修人员电话 -->
  2240. <select id="queryPhoneByDepartmentId" resultType="EamObjectAdminData" parameterType="EamObjectAdminData">
  2241. SELECT
  2242. ed.user_display as adminName,
  2243. ed.mobile as phone
  2244. FROM Access_dept as edd
  2245. LEFT JOIN sys_user ed on edd.username = ed.username and edd.site in (select site from eam_access_site where username = ed.username)
  2246. and (edd.site + '-' + edd.bu_no) in (select * from dbo.query_bu(ed.username))
  2247. WHERE edd.site = #{site} and edd.department_id = #{deptId} and edd.bu_no = #{buNo} and ed.mobile is not null
  2248. </select>
  2249. <!-- 保存短信记录 -->
  2250. <insert id="saveMessageRecord" parameterType="MessageRecordData">
  2251. INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
  2252. VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
  2253. </insert>
  2254. <!-- 查出计划结束日期为今天并且自动续期标识为Y的计划 -->
  2255. <select id="selectPlanToday" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  2256. SELECT
  2257. site,
  2258. (site + '_' + bu_no) as bu,
  2259. plan_id,
  2260. plan_desc,
  2261. status,
  2262. plan_start_date,
  2263. plan_end_date,
  2264. created_date,
  2265. created_by,
  2266. update_date,
  2267. update_by,
  2268. remark,
  2269. next_work_date,
  2270. delete_flag,
  2271. operator,
  2272. operator_name,
  2273. checker,
  2274. checker_name,
  2275. function_type,
  2276. properties_code,
  2277. plan_period,
  2278. work_order_rule,
  2279. plan_cycle,
  2280. task_start_date,
  2281. plan_halt_date,
  2282. auto_renewal
  2283. FROM eam_workPlan_overview
  2284. WHERE site = #{site} and status != #{status} and delete_flag = #{deleteFlag} and DATEDIFF(day, plan_end_date, getdate()) = 0 and auto_renewal = #{autoRenewal}
  2285. </select>
  2286. <!-- 查出老计划的设备 -->
  2287. <select id="selectObjectByPlanID" resultType="EamObjectInData" parameterType="EamWorkPlanInData">
  2288. SELECT
  2289. Site,
  2290. PlanID,
  2291. PlanDesc,
  2292. ObjectID,
  2293. FunctionType,
  2294. PropertiesCode,
  2295. Status
  2296. FROM eam_workPlan
  2297. WHERE site = #{site} and PlanID = #{planID} and FunctionType = #{functionType}
  2298. </select>
  2299. <!-- 获取用户 bu -->
  2300. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  2301. SELECT
  2302. b.id,
  2303. a.site,
  2304. c.sitename,
  2305. (a.site + '_' + a.bu_no) as buNo,
  2306. b.bu_desc
  2307. FROM AccessBu as a
  2308. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2309. left join site as c on a.site = c.siteid
  2310. WHERE a.username = #{username}
  2311. </select>
  2312. <!-- 获取用户 bu -->
  2313. <select id="getSiteAndBuByUserName2" resultType="BuData" parameterType="BuData">
  2314. SELECT
  2315. a.site,
  2316. c.sitename,
  2317. a.bu_no,
  2318. b.bu_desc
  2319. FROM AccessBu as a
  2320. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2321. left join site as c on a.site = c.siteid
  2322. WHERE a.username = #{username}
  2323. </select>
  2324. <!-- 获取用户 bu -->
  2325. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  2326. SELECT
  2327. a.site,
  2328. a.bu_no,
  2329. b.bu_desc
  2330. FROM AccessBu as a
  2331. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2332. WHERE a.username = #{username} and a.site=#{site}
  2333. </select>
  2334. <select id="eamCheckRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2335. SELECT
  2336. a.Site,
  2337. a.bu_no,
  2338. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2339. a.OrderNo,
  2340. a.PlanID,
  2341. a.PlanDesc,
  2342. a.PropertiesCode,
  2343. a.ObjectID,
  2344. a.Status,
  2345. a.PlanOperator,
  2346. a.checker,
  2347. a.ActualOperator,
  2348. a.PlanDate,
  2349. a.ActualDate,
  2350. a.FunctionType,
  2351. a.CreateDate,
  2352. d.operator_name as createBy,
  2353. a.Remark,
  2354. a.StartTime,
  2355. a.EndTime,
  2356. a.WorkTime,
  2357. a.PlanOperatorName,
  2358. a.checkerName,
  2359. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) ActualOperatorName,
  2360. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) objectDesc,
  2361. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) codeDesc,
  2362. a.result,
  2363. b.urgency,
  2364. a.checkResult,
  2365. b.DefectID,
  2366. c.DefectDesc,
  2367. a.disposal_measures,
  2368. a.check_work_plan_id,
  2369. a.check_item_no,
  2370. a.reach_date,
  2371. a.reach_operator,
  2372. a.reach_operator_name,
  2373. b.FeedBackDesc,
  2374. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  2375. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  2376. a.check_remark,
  2377. a.document_source,
  2378. ewi.ItemNo,
  2379. ewi.ItemDesc,
  2380. ewi.DefaultValue,
  2381. ewi.ValueType,
  2382. ewi.ValueType_DB,
  2383. ewi.ValueChooseFlag,
  2384. ewi.MaxValue,
  2385. ewi.MinValue,
  2386. ewi.ItemRemark,
  2387. ewi.ItemType,
  2388. ewi.TextValue,
  2389. ewi.NumberValue,
  2390. ewi.CreatedDate,
  2391. ewi.CreatedBy,
  2392. ewi.FinishFlag,
  2393. ewi.itemResult,
  2394. ewi.item_notes
  2395. FROM eam_workOrder a
  2396. left join eam_workOrder_item ewi on a.site = ewi.site and a.OrderNo = ewi.OrderNo and a.bu_no = ewi.bu_no
  2397. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  2398. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  2399. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  2400. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  2401. left join sys_department as sd ON eo.site = sd.site and eo.dept_id = sd.department_id and eo.bu_no = sd.bu_no
  2402. left join Access_dept as ead ON ead.site = sd.site and ead.department_id = sd.department_id and ead.bu_no = sd.bu_no
  2403. left join sys_user as ea on ead.username = ea.username
  2404. left join eam_workPlan_overview as ewo on a.site = ewo.site and a.PlanID = ewo.plan_id and a.bu_no = ewo.bu_no
  2405. <where>
  2406. a.site in (select site from eam_access_site where username = #{query.userName})
  2407. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2408. and ea.username = #{query.userName}
  2409. <if test="query.buDesc != null and query.buDesc != ''">
  2410. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2411. </if>
  2412. <if test="query.orderNo != null and query.orderNo != ''">
  2413. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  2414. </if>
  2415. <if test="query.planID != null and query.planID != ''">
  2416. AND a.PlanID like '%' + #{query.planID} +'%'
  2417. </if>
  2418. <if test="query.planDesc != null and query.planDesc != ''">
  2419. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  2420. </if>
  2421. <if test="query.objectID != null and query.objectID != ''">
  2422. AND a.ObjectID like '%' + #{query.objectID} +'%'
  2423. </if>
  2424. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  2425. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  2426. </if>
  2427. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  2428. AND a.status != '已取消'
  2429. </if>
  2430. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  2431. AND a.status = #{query.status}
  2432. </if>
  2433. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  2434. AND a.status = '未开工'
  2435. </if>
  2436. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2437. AND a.status != '已取消'
  2438. </if>
  2439. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2440. AND a.status = #{query.status}
  2441. </if>
  2442. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  2443. AND (a.status = '未开工' or a.status = '已到达')
  2444. </if>
  2445. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  2446. AND (a.status = '未开工' or a.status = '已到达')
  2447. </if>
  2448. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2449. AND a.status = #{query.status}
  2450. </if>
  2451. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2452. AND a.document_source = #{query.documentSource}
  2453. </if>
  2454. <if test="query.planDate != null">
  2455. AND a.PlanDate = #{query.planDate}
  2456. </if>
  2457. <if test="query.startDate != null ">
  2458. AND a.PlanDate >= #{query.startDate}
  2459. </if>
  2460. <if test="query.endDate != null ">
  2461. AND #{query.endDate} >= a.PlanDate
  2462. </if>
  2463. <if test="query.endDate == null ">
  2464. AND getDate() >= a.PlanDate
  2465. </if>
  2466. <if test='query.functionType == "A"'>
  2467. and getDate() >= dbo.compare_date(ewo.task_start_date)
  2468. </if>
  2469. <if test="query.reachDate != null ">
  2470. AND a.reach_date >= #{query.reachDate}
  2471. </if>
  2472. <if test="query.actualDate != null ">
  2473. AND #{query.actualDate} >= a.ActualDate
  2474. </if>
  2475. <if test="query.itemNo != null and query.itemNo != ''">
  2476. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  2477. </if>
  2478. <if test="query.itemDesc != null and query.itemDesc != ''">
  2479. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  2480. </if>
  2481. AND a.FunctionType = #{query.functionType}
  2482. </where>
  2483. </select>
  2484. <select id="eamDefectRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2485. SELECT
  2486. a.Site,
  2487. a.bu_no,
  2488. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2489. a.OrderNo,
  2490. a.PlanID,
  2491. a.ObjectID,
  2492. a.Status,
  2493. a.PlanOperator,
  2494. a.ActualOperator,
  2495. a.PlanDate,
  2496. a.ActualDate,
  2497. a.FunctionType,
  2498. a.CreateDate,
  2499. d.operator_name as createBy,
  2500. a.Remark,
  2501. a.StartTime,
  2502. a.EndTime,
  2503. a.WorkTime,
  2504. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  2505. b.DefectID,
  2506. c.DefectDesc,
  2507. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  2508. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  2509. a.result,
  2510. b.urgency,
  2511. a.disposal_measures,
  2512. a.difficulty_level,
  2513. a.difficulty_remark,
  2514. f.department_name,
  2515. a.reach_date,
  2516. b.CreatedDate,
  2517. a.handling_method,
  2518. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  2519. CASE
  2520. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  2521. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  2522. END AS responseTime,
  2523. b.FeedBackDesc,
  2524. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  2525. a.fault_reason,
  2526. a.preventive_measure,
  2527. a.document_source,
  2528. ewi.ItemNo,
  2529. ewi.ItemDesc,
  2530. ewi.DefaultValue,
  2531. ewi.ValueType,
  2532. ewi.ValueType_DB,
  2533. ewi.ValueChooseFlag,
  2534. ewi.MaxValue,
  2535. ewi.MinValue,
  2536. ewi.ItemRemark,
  2537. ewi.ItemType,
  2538. ewi.TextValue,
  2539. ewi.NumberValue,
  2540. ewi.FinishFlag,
  2541. ewi.itemResult,
  2542. ewi.item_notes
  2543. FROM eam_workOrder a
  2544. left join eam_workOrder_item ewi on a.site = ewi.site and a.OrderNo = ewi.OrderNo and a.bu_no = ewi.bu_no
  2545. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  2546. left join eam_defect c on b.DefectID = c.DefectID
  2547. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  2548. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and e.Active = 'Y' and a.bu_no = e.bu_no
  2549. left join sys_department as f on e.site = f.site and e.dept_id = f.department_id and e.bu_no = f.bu_no
  2550. left join Access_dept as ead ON ead.site = f.site and ead.department_id = f.department_id and ead.bu_no = f.bu_no
  2551. left join sys_user as ea on ead.username = ea.username
  2552. <where>
  2553. a.site in (select site from eam_access_site where username = #{query.userName})
  2554. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2555. and ea.username = #{query.userName}
  2556. <if test="query.buDesc != null and query.buDesc != ''">
  2557. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2558. </if>
  2559. <if test="query.deptArr != null">
  2560. AND
  2561. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  2562. f.department_name like '%' + #{item} + '%'
  2563. </foreach>
  2564. </if>
  2565. <if test="query.orderNo != null and query.orderNo != ''">
  2566. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  2567. </if>
  2568. <if test="query.planID != null and query.planID != ''">
  2569. AND a.PlanID like '%' + #{query.planID} +'%'
  2570. </if>
  2571. <if test="query.objectID != null and query.objectID != ''">
  2572. AND a.ObjectID like '%' + #{query.objectID} +'%'
  2573. </if>
  2574. <if test="query.planOperator != null and query.planOperator != ''">
  2575. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  2576. </if>
  2577. <if test="query.status != null and query.status != ''">
  2578. AND a.status = #{query.status}
  2579. </if>
  2580. <if test="query.documentSource != null and query.documentSource != ''">
  2581. AND a.document_source = #{query.documentSource}
  2582. </if>
  2583. <if test="query.startDate != null ">
  2584. AND a.PlanDate >= #{query.startDate}
  2585. </if>
  2586. <if test="query.endDate != null ">
  2587. AND #{query.endDate} >= a.PlanDate
  2588. </if>
  2589. <if test="query.reachDate != null ">
  2590. AND a.reach_date >= #{query.reachDate}
  2591. </if>
  2592. <if test="query.actualDate != null ">
  2593. AND #{query.actualDate} >= a.ActualDate
  2594. </if>
  2595. <if test="query.itemNo != null and query.itemNo != ''">
  2596. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  2597. </if>
  2598. <if test="query.itemDesc != null and query.itemDesc != ''">
  2599. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  2600. </if>
  2601. and a.FunctionType =#{query.functionType}
  2602. </where>
  2603. </select>
  2604. <!-- 获取用户角色列表 -->
  2605. <select id="getUserRoleList" resultType="SysRoleEntity">
  2606. SELECT
  2607. role_id,
  2608. role_name
  2609. FROM sys_role
  2610. </select>
  2611. <!-- 获取故障图片 -->
  2612. <select id="getFeedBackImages" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  2613. SELECT
  2614. id,
  2615. url,
  2616. create_date,
  2617. file_name,
  2618. new_file_name,
  2619. created_by,
  2620. order_ref1,
  2621. order_ref2,
  2622. order_ref3,
  2623. order_ref4,
  2624. file_type,
  2625. file_suffix,
  2626. file_type_code,
  2627. case when order_ref3 = 'feedBack' then '报修' when order_ref3 = 'reportFault' then '维修' end as typeFlag
  2628. FROM sys_oss
  2629. where order_ref1 = #{site} and (order_ref2 = #{orderNo} or order_ref2 = #{planID}) and order_ref3 in ('feedBack', 'reportFault') and order_ref4 = #{buNo}
  2630. </select>
  2631. <!-- 获取领用出库信息 -->
  2632. <select id="getInventoryStockList" resultType="InventoryStockData" parameterType="InventoryStockData">
  2633. SELECT
  2634. A.site,
  2635. A.part_no,
  2636. A.batch_no,
  2637. isnull(A.qty_on_hand ,0) as qtyOnHand,
  2638. isnull(A.in_qty,0) inQty,
  2639. isnull(A.out_qty,0) as outQty,
  2640. A.warehouse_id,
  2641. A.location_id,
  2642. (B.part_description + '/' + B.spec) as partDescription,
  2643. B.S_code_control_flag,
  2644. B.supplier_id,
  2645. dbo.qc_get_supplier_name(A.site, B.supplier_id) as supplierDesc
  2646. FROM inventory_stock as A
  2647. left join part_spare as B on A.site = B.site and A.part_no = B.part_no
  2648. <where>
  2649. A.site = #{site}
  2650. <if test="partNo != null and partNo != ''">
  2651. AND A.part_no = #{partNo}
  2652. </if>
  2653. <if test="batchNo != null and batchNo != ''">
  2654. AND A.batch_no = #{batchNo}
  2655. </if>
  2656. <if test="active != null and active != ''">
  2657. AND B.active = #{active}
  2658. </if>
  2659. </where>
  2660. </select>
  2661. <!-- 查询设备 -->
  2662. <select id="getResourceCount" resultType="ResourceData" parameterType="PartSpareData">
  2663. SELECT
  2664. id,
  2665. site,
  2666. resource_id,
  2667. resource_desc
  2668. FROM resource
  2669. where site = #{site} and resource_id = #{resourceId}
  2670. </select>
  2671. <!-- 获取编码信息 -->
  2672. <select id="getTransNo" resultType="TransNoData" parameterType="PartSpareData">
  2673. SELECT
  2674. #{site} as site,
  2675. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  2676. </select>
  2677. <!-- 修改编码信息 -->
  2678. <select id="updateTransNo" parameterType="PartSpareData">
  2679. EXEC UpdateTransNo #{site}, #{transTypeDB}
  2680. </select>
  2681. <select id="getInventoryStockCount" parameterType="InventoryStockData" resultType="int">
  2682. select
  2683. count(1)
  2684. from inventory_stock
  2685. where site = #{site} and part_no = #{partNo}
  2686. </select>
  2687. <select id="eamDocumentTypeSearch" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  2688. SELECT
  2689. a.site,
  2690. a.document_type_id,
  2691. a.document_type,
  2692. a.responsible_department,
  2693. a.estimated_completion_days,
  2694. a.create_date,
  2695. a.create_by,
  2696. a.update_date,
  2697. a.update_by,
  2698. b.role_desc
  2699. FROM document_type_definition as a
  2700. LEFT JOIN business_role as b on a.site = b.site and a.responsible_department = b.role_no
  2701. WHERE
  2702. a.site in (select eas.site from eam_access_site as eas where eas.username = #{params.userName})
  2703. <if test="params.sql != null and params.sql != ''">
  2704. ${params.sql}
  2705. </if>
  2706. </select>
  2707. <select id="checkEamDocumentType" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  2708. SELECT
  2709. Site,
  2710. document_type_id,
  2711. document_type,
  2712. responsible_department,
  2713. estimated_completion_days
  2714. FROM document_type_definition
  2715. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  2716. </select>
  2717. <insert id="saveNewEamDocumentType">
  2718. INSERT INTO document_type_definition
  2719. (Site, document_type_id, document_type, responsible_department, estimated_completion_days,create_date, create_by)
  2720. VALUES
  2721. (#{site}, #{documentTypeId}, #{documentType}, #{responsibleDepartment}, #{estimatedCompletionDays}, getDate(), #{createBy})
  2722. </insert>
  2723. <update id="eamDocumentTypeEdit">
  2724. UPDATE document_type_definition
  2725. SET document_type = #{documentType},
  2726. responsible_department = #{responsibleDepartment},
  2727. estimated_completion_days = #{estimatedCompletionDays},
  2728. update_date = getDate(),
  2729. update_by = #{updateBy}
  2730. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  2731. </update>
  2732. <delete id="eamDocumentTypeDelete">
  2733. DELETE FROM document_type_definition
  2734. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  2735. </delete>
  2736. <select id="eamBuDocumentSearch" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  2737. SELECT
  2738. a.id,
  2739. a.site,
  2740. a.bu_no,
  2741. dbo.get_bu_desc ( a.site, a.bu_no ) as buDesc,
  2742. a.project_category,
  2743. a.document_type_id,
  2744. a.project_phase,
  2745. c.document_type,
  2746. c.responsible_department,
  2747. c.estimated_completion_days,
  2748. a.create_date,
  2749. a.create_by,
  2750. a.update_date,
  2751. a.update_by,
  2752. b.bu_desc,
  2753. d.role_desc
  2754. FROM bu_document_list_definition as a
  2755. LEFT JOIN bu as b on a.site = b.site and a.bu_no = b.bu_no
  2756. LEFT JOIN document_type_definition as c on a.document_type_id = c.document_type_id
  2757. LEFT JOIN business_role as d on a.site = d.site and c.responsible_department = d.role_no
  2758. WHERE
  2759. a.site in (select site from eam_access_site where username = #{params.userName})
  2760. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{params.userName}))
  2761. <if test="params.sql != null and params.sql != ''">
  2762. ${params.sql}
  2763. </if>
  2764. ORDER BY
  2765. b.bu_no,
  2766. a.project_phase,
  2767. a.project_category,
  2768. a.document_type_id
  2769. </select>
  2770. <select id="checkEamBuDocument" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  2771. SELECT
  2772. Site,
  2773. bu_no,
  2774. project_category,
  2775. document_type_id,
  2776. project_phase
  2777. FROM bu_document_list_definition
  2778. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  2779. </select>
  2780. <select id="checkEamDocumentTypeDelete" resultType="Integer">
  2781. SELECT COUNT(*) FROM bu_document_list_definition t1
  2782. WHERE t1.document_type_id = #{documentTypeId}
  2783. UNION ALL
  2784. SELECT COUNT(*) FROM plm_document_list_definition t2
  2785. WHERE t2.document_type_id = #{documentTypeId}
  2786. </select>
  2787. <insert id="saveNewEamBuDocument">
  2788. INSERT INTO bu_document_list_definition
  2789. (Site, bu_no, project_category, document_type_id, project_phase,create_date, create_by)
  2790. VALUES
  2791. (#{site}, #{buNo}, #{projectCategory}, #{documentTypeId}, #{projectPhase},getDate(), #{createBy})
  2792. </insert>
  2793. <update id="eamBuDocumentEdit">
  2794. UPDATE bu_document_list_definition
  2795. SET project_phase = #{projectPhase},
  2796. project_category = #{projectCategory},
  2797. update_date = getDate(),
  2798. update_by = #{updateBy}
  2799. WHERE Site = #{site} and bu_no = #{buNo} and document_type_id = #{documentTypeId} and id = #{id}
  2800. </update>
  2801. <delete id="eamBuDocumentDelete">
  2802. DELETE FROM bu_document_list_definition
  2803. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  2804. </delete>
  2805. <update id="updateInventoryStock" parameterType="InventoryStockData">
  2806. update inventory_stock
  2807. set in_qty = #{inQty},
  2808. out_qty = #{outQty},
  2809. qty_on_hand = #{qtyOnHand},
  2810. latest_out_date = getDate(),
  2811. latest_count_date = getDate()
  2812. <where>
  2813. site = #{site}
  2814. <if test="partNo != null and partNo != ''">
  2815. AND part_no = #{partNo}
  2816. </if>
  2817. <if test="batchNo != null and batchNo != ''">
  2818. AND batch_no = #{batchNo}
  2819. </if>
  2820. </where>
  2821. </update>
  2822. <insert id="saveRepairTransDetailSub" parameterType="RepairTransDetailSubData">
  2823. insert into repair_TransDetailsub
  2824. (TransNo, SeqNo, Site, itemNo, LocationID, BatchNo, RollQty, RollNo, orderRef2, orderRef4)
  2825. values
  2826. (#{transNo}, #{seqNo}, #{site}, #{itemNo}, #{locationId}, #{batchNo}, #{rollQty}, #{rollNo}, #{orderRef2}, #{orderRef4})
  2827. </insert>
  2828. <insert id="saveInventoryStockData" parameterType="InventoryStockData">
  2829. insert into inventory_stock
  2830. (site, warehouse_id, part_no, first_in_date, latest_out_date, latest_in_date, active_date, in_qty, out_qty, qty_on_hand, citem_code, partner_id, latest_count_date, location_id, batch_no)
  2831. values
  2832. (#{site}, #{warehouseId}, #{partNo}, #{firstInDate}, getDate(), getDate(),getDate(), #{inQty}, #{outQty}, #{qtyOnHand}, #{citemCode}, #{partnerId}, #{latestCountDate}, #{locationId}, #{batchNo})
  2833. </insert>
  2834. <insert id="saveRepairTransDetail" parameterType="RepairTransDetailData">
  2835. insert into repair_TransDetail
  2836. (TransNo, Site, ItemNo, PartNo, LocationID, TransQty, Direction, BatchNo, OrderRef1, OrderRef2, OrderRef3, citem_code)
  2837. values
  2838. (#{transNo}, #{site}, #{itemNo}, #{partNo}, #{locationId}, #{transQty}, #{direction}, #{batchNo}, #{orderRef1}, #{orderRef2}, #{orderRef3}, #{citemCode})
  2839. </insert>
  2840. <insert id="saveRepairTransHeader" parameterType="RepairTransHeaderData">
  2841. insert into repair_TransHeader
  2842. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, TransferFlag, EnterDate, UseLocation, LinkOrderFlag, Status, Remark, orderRef1)
  2843. values
  2844. (#{transNo}, #{site}, #{warehouseId}, #{transDate}, #{transTypeDb}, #{transType}, #{userName}, #{receiver}, #{transYear}, #{transMonth}, #{partnerId}, #{partnerType}, #{authorizeFlag}, #{transferFlag}, getDate(), #{useLocation}, #{linkOrderFlag}, #{status}, #{remark}, #{orderRef1})
  2845. </insert>
  2846. <update id="updatePartSpareLocation" parameterType="PartSpareData">
  2847. update part_spare
  2848. set last_update_by =#{userName},
  2849. location_id = #{locationId},
  2850. warehouse_id = #{warehouseId}
  2851. where site = #{site} and part_no = #{partNo}
  2852. </update>
  2853. <select id="getFeedBackInfo" resultType="EamDefectFeedBackInData" parameterType="EamDefectFeedBackInData">
  2854. select
  2855. Site,
  2856. bu_no,
  2857. FeedBackID,
  2858. FeedBackDesc,
  2859. Status
  2860. from eam_defect_feedBack
  2861. <where>
  2862. Site = #{site} and bu_no = #{buNo} and FeedBackID = #{feedBackID}
  2863. </where>
  2864. </select>
  2865. <select id="getObjectInfo" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  2866. select
  2867. site,
  2868. bu_no,
  2869. objectID,
  2870. ObjectDesc,
  2871. standard_maintenance_duration
  2872. from eam_object
  2873. where Site = #{site} and bu_no = #{buNo} and ObjectID = #{objectID}
  2874. </select>
  2875. <select id="getResourceByObject" resultType="string">
  2876. select
  2877. ResourceID
  2878. from eam_object
  2879. where Site = #{site} and ObjectID = #{objectID}
  2880. </select>
  2881. </mapper>