O
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.

3255 lines
140 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
1 year ago
3 years ago
1 year ago
3 years ago
3 years ago
1 year 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
1 year ago
1 year ago
1 year 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
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
2 years ago
2 years ago
2 years 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. a.handling_method,
  683. a.fault_reason,
  684. a.preventive_measure,
  685. isnull(ewc.partNo,'') core_partNo,
  686. isnull(ps.part_description,'') core_part_description,
  687. isnull(ewc.oldSerialNo,'') oldSerialNo,
  688. isnull(ewc.newSerialNo,'') newSerialNo
  689. FROM eam_workOrder a
  690. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  691. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  692. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id
  693. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  694. 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
  695. 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
  696. left join sys_user as ea on ead.username = ea.username
  697. 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
  698. left join eam_workOrder_coreComponents as ewc on a.site=ewc.site and a.orderNo=ewc.orderNo and a.bu_no = ewc.bu_no
  699. left join part_spare as ps on ewc.site=ps.site and ewc.partNo=ps.part_no and ewc.bu_no=ps.bu_no
  700. <where>
  701. a.site in (select site from eam_access_site where username = #{query.userName})
  702. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  703. and ea.username = #{query.userName}
  704. <if test="query.buDesc != null and query.buDesc != ''">
  705. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  706. </if>
  707. <if test="query.orderNo != null and query.orderNo != ''">
  708. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  709. </if>
  710. <if test="query.corePartNo != null and query.corePartNo != ''">
  711. AND ewc.partNo like '%' + #{query.corePartNo} +'%'
  712. </if>
  713. <if test="query.planID != null and query.planID != ''">
  714. AND a.PlanID like '%' + #{query.planID} +'%'
  715. </if>
  716. <if test="query.planDesc != null and query.planDesc != ''">
  717. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  718. </if>
  719. <if test="query.objectID != null and query.objectID != ''">
  720. AND a.ObjectID like '%' + #{query.objectID} +'%'
  721. </if>
  722. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  723. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  724. </if>
  725. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  726. AND a.status != '已取消'
  727. </if>
  728. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  729. AND a.status = #{query.status}
  730. </if>
  731. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  732. AND a.status = '未开工'
  733. </if>
  734. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  735. AND a.status != '已取消'
  736. </if>
  737. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  738. AND a.status = #{query.status}
  739. </if>
  740. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  741. AND (a.status = '未开工' or a.status = '已到达')
  742. </if>
  743. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  744. AND (a.status = '未开工' or a.status = '已到达')
  745. </if>
  746. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  747. AND a.status = #{query.status}
  748. </if>
  749. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  750. AND a.document_source = #{query.documentSource}
  751. </if>
  752. <if test="query.planDate != null">
  753. AND a.PlanDate = #{query.planDate}
  754. </if>
  755. <if test="query.startDate != null ">
  756. AND a.PlanDate >= #{query.startDate}
  757. </if>
  758. <if test="query.endDate != null ">
  759. AND #{query.endDate} >= a.PlanDate
  760. </if>
  761. <if test="query.endDate == null ">
  762. AND getDate() >= a.PlanDate
  763. </if>
  764. <if test='query.functionType == "A" and query.searchType == "reportCheck"'>
  765. and getDate() >= dbo.compare_date(ewo.task_start_date)
  766. </if>
  767. <if test="query.urgency != null and query.urgency != ''">
  768. AND b.urgency = #{query.urgency}
  769. </if>
  770. AND a.FunctionType = #{query.functionType}
  771. </where>
  772. ORDER BY a.CreateDate,
  773. CASE WHEN b.urgency = '特急' THEN 1
  774. WHEN b.urgency = '紧急' THEN 2
  775. WHEN b.urgency = '一般' THEN 3
  776. END
  777. </select>
  778. <select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  779. SELECT
  780. a.Site,
  781. a.bu_no,
  782. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  783. a.OrderNo,
  784. a.PlanID,
  785. a.ObjectID,
  786. a.Status,
  787. a.PlanOperator,
  788. a.ActualOperator,
  789. a.PlanDate,
  790. a.ActualDate,
  791. a.FunctionType,
  792. a.CreateDate,
  793. d.operator_name as createBy,
  794. a.Remark,
  795. a.StartTime,
  796. a.EndTime,
  797. a.WorkTime,
  798. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  799. b.DefectID,
  800. c.DefectDesc,
  801. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  802. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  803. a.result,
  804. b.urgency,
  805. a.disposal_measures,
  806. a.difficulty_level,
  807. a.difficulty_remark,
  808. f.department_name,
  809. a.reach_date,
  810. b.CreatedDate,
  811. a.handling_method,
  812. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  813. CASE
  814. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  815. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  816. END AS responseTime,
  817. b.FeedBackDesc,
  818. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  819. a.fault_reason,
  820. a.preventive_measure,
  821. a.document_source,
  822. isnull(ewc.partNo,'') core_partNo,
  823. isnull(ps.part_description,'') core_part_description,
  824. isnull(ewc.oldSerialNo,'') oldSerialNo,
  825. isnull(ewc.newSerialNo,'') newSerialNo
  826. FROM eam_workOrder a
  827. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  828. left join eam_defect c on b.DefectID = c.DefectID
  829. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id
  830. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and a.bu_no = e.bu_no
  831. 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
  832. 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
  833. left join sys_user as ea on ead.username = ea.username
  834. left join eam_workOrder_coreComponents as ewc on a.site=ewc.site and a.orderNo=ewc.orderNo and a.bu_no = ewc.bu_no
  835. left join part_spare as ps on ewc.site=ps.site and ewc.partNo=ps.part_no and ewc.bu_no=ps.bu_no
  836. <where>
  837. a.site in (select site from eam_access_site where username = #{query.userName})
  838. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  839. and ea.username = #{query.userName}
  840. <if test="query.buDesc != null and query.buDesc != ''">
  841. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  842. </if>
  843. <if test="query.deptArr != null">
  844. AND
  845. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  846. f.department_name like '%' + #{item} + '%'
  847. </foreach>
  848. </if>
  849. <if test="query.orderNo != null and query.orderNo != ''">
  850. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  851. </if>
  852. <if test="query.planID != null and query.planID != ''">
  853. AND a.PlanID like '%' + #{query.planID} +'%'
  854. </if>
  855. <if test="query.corePartNo != null and query.corePartNo != ''">
  856. AND ewc.partNo like '%' + #{query.corePartNo} +'%'
  857. </if>
  858. <if test="query.objectID != null and query.objectID != ''">
  859. AND a.ObjectID like '%' + #{query.objectID} +'%'
  860. </if>
  861. <if test="query.planOperator != null and query.planOperator != ''">
  862. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  863. </if>
  864. <if test="query.status != null and query.status != ''">
  865. AND a.status = #{query.status}
  866. </if>
  867. <if test="query.documentSource != null and query.documentSource != ''">
  868. AND a.document_source = #{query.documentSource}
  869. </if>
  870. <if test="query.startDate != null ">
  871. AND a.PlanDate >= #{query.startDate}
  872. </if>
  873. <if test="query.endDate != null ">
  874. AND #{query.endDate} >= a.PlanDate
  875. </if>
  876. <if test="query.urgency != null and query.urgency != ''">
  877. AND b.urgency = #{query.urgency}
  878. </if>
  879. <if test="query.result != null and query.result != ''">
  880. AND a.result = #{query.result}
  881. </if>
  882. and a.FunctionType =#{query.functionType}
  883. </where>
  884. ORDER BY a.PlanDate,
  885. CASE WHEN b.urgency = '特急' THEN 1
  886. WHEN b.urgency = '紧急' THEN 2
  887. WHEN b.urgency = '一般' THEN 3
  888. END
  889. </select>
  890. <select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData">
  891. SELECT
  892. DefectID,
  893. DefectDesc,
  894. Active,
  895. create_date,
  896. create_by,
  897. update_date,
  898. update_by,
  899. fault_type
  900. FROM eam_defect
  901. <where>
  902. <if test="query.defectID != null and query.defectID != ''">
  903. AND defectID like '%' + #{query.defectID} + '%'
  904. </if>
  905. <if test="query.defectDesc != null and query.defectDesc != ''">
  906. AND defectDesc like '%' + #{query.defectDesc} + '%'
  907. </if>
  908. <if test="query.active != null and query.active != ''">
  909. AND active = #{query.active}
  910. </if>
  911. </where>
  912. order by id
  913. </select>
  914. <select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  915. SELECT
  916. a.site,
  917. a.ObjectID,
  918. a.DefectID,
  919. a.Active,
  920. a.id,
  921. b.ObjectDesc,
  922. c.DefectDesc,
  923. a.create_date,
  924. a.create_by,
  925. a.update_date,
  926. a.update_by
  927. FROM eam_object_defect a
  928. left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID
  929. left join eam_defect c on a.DefectID=c.DefectID
  930. <where>
  931. <if test="query.objectID != null and query.objectID != ''">
  932. AND a.ObjectID like '%' + #{query.objectID} + '%'
  933. </if>
  934. <if test="query.objectDesc != null and query.objectDesc != ''">
  935. AND b.ObjectDesc like '%' + #{query.objectDesc} + '%'
  936. </if>
  937. <if test="query.defectID != null and query.defectID != ''">
  938. AND a.defectID like '%' + #{query.defectID} + '%'
  939. </if>
  940. <if test="query.defectDesc != null and query.defectDesc != ''">
  941. AND c.defectDesc like '%' + #{query.defectDesc} + '%'
  942. </if>
  943. <if test="query.active != null and query.active != ''">
  944. AND a.active = #{query.active}
  945. </if>
  946. </where>
  947. order by a.id
  948. </select>
  949. <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  950. SELECT
  951. a.Site,
  952. a.bu_no,
  953. a.ObjectID,
  954. a.ObjectDesc,
  955. a.LocationID,
  956. a.FamilyID,
  957. a.GroupID,
  958. b.FamilyDesc,
  959. c.LocationName
  960. FROM eam_object a
  961. LEFT JOIN eam_family b ON a.site = b.site and a.FamilyID = b.FamilyID and a.bu_no = b.bu_no
  962. LEFT JOIN eam_location as c ON a.LocationID = c.LocationID and a.site = c.site and a.bu_no = c.bu_no
  963. <where>
  964. <if test="objectID != null and objectID != ''">
  965. AND a.ObjectID like '%' + #{objectID} + '%'
  966. </if>
  967. <if test="objectDesc != null and objectDesc != ''">
  968. AND a.ObjectDesc like '%' + #{objectDesc} + '%'
  969. </if>
  970. AND a.site = #{site} AND a.active = 'Y' and a.bu_no = #{buNo}
  971. </where>
  972. </select>
  973. <select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  974. SELECT
  975. a.site,
  976. a.objectID
  977. from eam_object as a
  978. left join eam_family as b on a.site = b.site and a.FamilyID = b.FamilyID
  979. where a.site = '2' and (b.son_id like #{sonId} + '%' or a.FamilyID = #{familyID})
  980. </select>
  981. <select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  982. SELECT
  983. site,
  984. objectID
  985. from eam_object
  986. where site = #{site} and GroupID = #{groupID}
  987. </select>
  988. <select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  989. SELECT
  990. site,
  991. objectID
  992. from eam_object
  993. where site = #{site} and LocationID = #{locationID}
  994. </select>
  995. <select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  996. SELECT
  997. a.Site,
  998. a.bu_no,
  999. c.OrderNo,
  1000. a.ItemNo,
  1001. a.ItemDesc,
  1002. a.DefaultValue,
  1003. a.ValueType,
  1004. a.ValueType_DB,
  1005. a.ValueChooseFlag,
  1006. a.MaxValue,
  1007. a.MinValue,
  1008. a.ItemRemark,
  1009. a.ItemType,
  1010. a.image_flag,
  1011. a.produce_control_flag,
  1012. CASE WHEN b.id is null THEN 'N'
  1013. ELSE 'Y'
  1014. END as uploadFlag,
  1015. a.item_notes
  1016. from eam_workPlan_item as a
  1017. left join eam_workOrder as c on a.site = c.site and a.PlanID = c.PlanID and a.bu_no = c.bu_no
  1018. 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
  1019. on b.order_ref1 = a.site and b.order_ref2 = c.OrderNo and b.order_ref3 = a.ItemNo and order_ref4 = a.bu_no
  1020. where a.site = #{site} and c.orderNo = #{orderNo} and a.ObjectID = #{objectID} and a.bu_no = #{buNo}
  1021. </select>
  1022. <select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1023. SELECT
  1024. Site,
  1025. status,
  1026. OrderNo
  1027. from eam_workOrder
  1028. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1029. </select>
  1030. <select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  1031. SELECT username as adminID
  1032. from sys_user
  1033. where username = #{mesUser}
  1034. </select>
  1035. <update id="updateDefectResult" >
  1036. update eam_defect_feedBack
  1037. set Status = #{result},
  1038. FinishDate = GetDate(),
  1039. DefectID = #{defectID}
  1040. where Site = #{site} and FeedBackID = #{planID} and bu_no = #{buNo}
  1041. </update>
  1042. <update id="reportWorkOrder" parameterType="EamWorkOrderInData">
  1043. update eam_workOrder
  1044. set Status = '待确认',
  1045. ActualOperator = #{actualOperator},
  1046. ActualDate = #{actualDate},
  1047. Remark = #{remark},
  1048. disposal_measures = #{disposalMeasures},
  1049. WorkTime = CASE
  1050. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1051. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
  1052. END,
  1053. result = #{result,jdbcType=VARCHAR},
  1054. checkResult = #{checkResult},
  1055. handling_method = #{handlingMethod},
  1056. fault_reason = #{faultReason},
  1057. preventive_measure = #{preventiveMeasure}
  1058. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1059. </update>
  1060. <update id="reportWorkOrder2" parameterType="EamWorkOrderInData">
  1061. update eam_workOrder
  1062. set Status = '待审核',
  1063. ActualOperator = #{actualOperator},
  1064. reach_date = #{reachDate},
  1065. ActualDate = #{actualDate},
  1066. Remark = #{remark},
  1067. disposal_measures = #{disposalMeasures},
  1068. WorkTime = #{workTime},
  1069. result = #{result,jdbcType=VARCHAR},
  1070. checkResult = #{checkResult},
  1071. handling_method = #{handlingMethod},
  1072. check_remark = #{checkRemark}
  1073. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1074. </update>
  1075. <update id="reportWorkOrder3" parameterType="EamWorkOrderInData">
  1076. update eam_workOrder
  1077. set Status = '待审核',
  1078. ActualOperator = #{actualOperator},
  1079. ActualDate = #{actualDate},
  1080. Remark = #{remark},
  1081. disposal_measures = #{disposalMeasures},
  1082. WorkTime = CASE
  1083. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1084. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
  1085. END,
  1086. result = #{result,jdbcType=VARCHAR},
  1087. checkResult = #{checkResult},
  1088. handling_method = #{handlingMethod},
  1089. fault_reason = #{faultReason},
  1090. preventive_measure = #{preventiveMeasure}
  1091. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1092. </update>
  1093. <update id="defectReportWorkOrder" >
  1094. update eam_workOrder
  1095. set Status = '已完工',
  1096. ActualOperator = #{actualOperator},
  1097. ActualDate = GetDate(),
  1098. Remark = #{remark},
  1099. disposal_measures = #{disposalMeasures},
  1100. WorkTime = #{workTime},
  1101. result = #{result,jdbcType=VARCHAR},
  1102. checkResult = #{checkResult}
  1103. where site = #{site}
  1104. and orderNo = #{orderNo}
  1105. </update>
  1106. <insert id="saveWorkOrderItem">
  1107. INSERT into eam_workOrder_item
  1108. (Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
  1109. 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})
  1110. </insert>
  1111. <!-- 修改 eam_workPlan 状态为已结束 -->
  1112. <update id="closePlanWithCheck">
  1113. update eam_workPlan
  1114. set status = '已结束'
  1115. where site = #{site}
  1116. and PlanID = #{planID}
  1117. and ObjectID = #{objectID}
  1118. and GetDate() > PlanEndDate
  1119. </update>
  1120. <!-- 报工后更新下一个工作日期 -->
  1121. <update id="updatePlanNextDate">
  1122. update eam_workPlan_overview
  1123. 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)
  1124. where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
  1125. </update>
  1126. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1127. SELECT
  1128. Site,
  1129. bu_no,
  1130. OrderNo,
  1131. ItemNo,
  1132. ItemDesc,
  1133. DefaultValue,
  1134. ValueType,
  1135. ValueType_DB,
  1136. ValueChooseFlag,
  1137. MaxValue,
  1138. MinValue,
  1139. ItemRemark,
  1140. ItemType,
  1141. TextValue,
  1142. NumberValue,
  1143. CreatedDate,
  1144. CreatedBy,
  1145. FinishFlag,
  1146. itemResult,
  1147. item_notes
  1148. from eam_workOrder_item
  1149. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1150. </select>
  1151. <update id="cancelOrder" parameterType="EamWorkOrderInData">
  1152. update eam_workOrder
  1153. set Status = '已取消'
  1154. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1155. </update>
  1156. <update id="cancelOrderAll" parameterType="EamWorkOrderInData">
  1157. update eam_workOrder
  1158. set Status = '已取消'
  1159. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
  1160. </update>
  1161. <update id="updateWorkPlanStatus2" parameterType="EamWorkOrderInData">
  1162. update eam_workPlan
  1163. set Status = '已取消'
  1164. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1165. </update>
  1166. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1167. SELECT
  1168. site,
  1169. bu_no,
  1170. status
  1171. from eam_workPlan_overview
  1172. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1173. </select>
  1174. <update id="planOrder">
  1175. update eam_workPlan
  1176. set Status = '已计划',
  1177. NextWorkDate = null
  1178. where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1179. </update>
  1180. <update id="cancelPlan">
  1181. update eam_workPlan_overview
  1182. set status = '已取消',
  1183. next_work_date = null
  1184. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1185. </update>
  1186. <update id="updateWorkPlanStatus">
  1187. update eam_workPlan
  1188. set Status = '已取消',
  1189. NextWorkDate = null
  1190. where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1191. </update>
  1192. <update id="cancelOrderWithPlanID">
  1193. update eam_workOrder
  1194. set Status = '已取消'
  1195. where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
  1196. </update>
  1197. <update id="deleteOrderDetailWithPlanID">
  1198. delete from eam_workOrder_item
  1199. where site = #{site} and bu_no = #{buNo}
  1200. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  1201. </update>
  1202. <update id="deleteOrderWithPlanID">
  1203. delete from eam_workOrder
  1204. where site = #{site} and bu_no = #{buNo}
  1205. and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
  1206. </update>
  1207. <update id="updateOrderPlanOperator">
  1208. update eam_workOrder
  1209. set PlanOperator = #{planOperator}
  1210. where site = #{site} and orderNo = #{orderNo}
  1211. </update>
  1212. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1213. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  1214. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  1215. <where>
  1216. <if test="partNo != null and partNo != ''">
  1217. AND a.part_no like '%' + #{partNo} + '%'
  1218. </if>
  1219. <if test="partDescription != null and partDescription != ''">
  1220. AND a.part_description like '%' + #{partDescription} + '%'
  1221. </if>
  1222. and a.site=#{site} and a.active='Y'
  1223. </where>
  1224. </select>
  1225. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1226. select part_no
  1227. from resource_spare
  1228. where site = #{site}
  1229. and resource_id = #{objectID}
  1230. and part_no = #{partNo}
  1231. </select>
  1232. <insert id="savePartSpare" >
  1233. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1234. values(#{objectID},#{partNo},'',0,#{site})
  1235. </insert>
  1236. <delete id="deletePartSpare">
  1237. <foreach collection="list" item="item" separator=";">
  1238. delete from resource_spare where site = #{item.site} and resource_id = #{item.objectID}
  1239. </foreach>
  1240. </delete>
  1241. <insert id="copyPartSpare" >
  1242. INSERT INTO resource_spare
  1243. (resource_id, part_no, delflag, version, site)
  1244. <foreach item="item" index="index" collection="list" separator=",">
  1245. select #{item.objectID}, part_no, delflag, 0, site from resource_spare where resource_id = #{item.oldObjectID} and site = #{item.site}
  1246. </foreach>
  1247. </insert>
  1248. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1249. SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status,
  1250. a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark
  1251. ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
  1252. FROM eam_workPlan a
  1253. left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID
  1254. left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID
  1255. left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no
  1256. where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N'
  1257. and status in ('已计划','进行中')
  1258. </select>
  1259. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1260. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  1261. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  1262. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  1263. where a.site=#{site} and a.ObjectID=#{objectID}
  1264. and a.ItemType=#{itemType}
  1265. </select>
  1266. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1267. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  1268. from eam_object_defect a left join eam_defect b
  1269. on a.DefectID=b.DefectID
  1270. where a.site=#{site} and a.ObjectID=#{objectID}
  1271. </select>
  1272. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1273. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1274. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1275. </select>
  1276. <insert id="saveNewEamObjectItem" >
  1277. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1278. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  1279. </insert>
  1280. <update id="editEamObjectItem">
  1281. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  1282. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  1283. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1284. and ItemNo=#{itemNo}
  1285. </update>
  1286. <delete id="deleteObjectItem">
  1287. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1288. and ItemNo=#{itemNo}
  1289. </delete>
  1290. <insert id="saveNewEamObjectItemAvailable">
  1291. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1292. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1293. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1294. </insert>
  1295. <delete id="deleteEamObjectItemAvailable">
  1296. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1297. and ItemNo=#{itemNo}
  1298. </delete>
  1299. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1300. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1301. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1302. </select>
  1303. <select id="getItemValueNoForObject" resultType="Double">
  1304. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1305. </select>
  1306. <insert id="saveObjectItemAvailable">
  1307. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1308. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1309. </insert>
  1310. <update id="updateObjectItemAvailable">
  1311. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1312. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1313. </update>
  1314. <delete id="deleteObjectItemAvailable">
  1315. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1316. </delete>
  1317. <delete id="deleteObjectItemForCopy">
  1318. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1319. </delete>
  1320. <delete id="deleteObjectItemAvailableForCopy">
  1321. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1322. </delete>
  1323. <insert id="copyObjectItem" >
  1324. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1325. ItemType)
  1326. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1327. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1328. </insert>
  1329. <insert id="copyObjectItemAvailable">
  1330. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1331. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1332. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1333. </insert>
  1334. <delete id="deleteObjectDefectForCopy">
  1335. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1336. </delete>
  1337. <insert id="copyObjectDefect">
  1338. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1339. select #{site},#{objectID},DefectID,Active
  1340. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1341. </insert>
  1342. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1343. select
  1344. a.Site,
  1345. a.bu_no,
  1346. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1347. a.FeedBackID,
  1348. a.FeedBackDesc,
  1349. a.ObjectID,
  1350. a.DefectID,
  1351. a.FunctionType,
  1352. a.PlanOperator,
  1353. a.ActualOperator,
  1354. a.Status,
  1355. a.PlanDate,
  1356. a.Remark,
  1357. a.urgency,
  1358. a.deleteFlag,
  1359. a.CreatedDate,
  1360. a.CreatedBy,
  1361. c.operator_name as feedbackBy,
  1362. a.UpdateDate,
  1363. a.UpdateBy,
  1364. a.Version,
  1365. a.DefectDate,
  1366. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
  1367. b.defectDesc,
  1368. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) ObjectDesc,
  1369. FinishDate,
  1370. 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
  1371. from eam_defect_feedBack a
  1372. left join eam_defect b on a.DefectID = b.DefectID
  1373. left join operator as c on a.site = c.site and a.CreatedBy = c.operator_id
  1374. 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
  1375. 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
  1376. 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
  1377. left join sys_user as ea on ead.username = ea.username
  1378. <where>
  1379. a.site in (select site from eam_access_site where username = #{query.userName})
  1380. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1381. and ea.username = #{query.userName}
  1382. <if test="query.buDesc != null and query.buDesc != ''">
  1383. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  1384. </if>
  1385. <if test="query.feedBackID != null and query.feedBackID != ''">
  1386. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1387. </if>
  1388. <if test="query.defectDesc != null and query.defectDesc != ''">
  1389. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1390. </if>
  1391. <if test="query.objectID != null and query.objectID != ''">
  1392. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1393. </if>
  1394. <if test="query.planOperator != null and query.planOperator != ''">
  1395. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1396. </if>
  1397. <if test="query.status != null and query.status != ''">
  1398. AND a.status = #{query.status}
  1399. </if>
  1400. <if test="query.startDate != null ">
  1401. AND a.defectDate >= #{query.startDate}
  1402. </if>
  1403. <if test="query.endDate != null ">
  1404. AND #{query.endDate} >= a.defectDate
  1405. </if>
  1406. <if test="query.urgency != null and query.urgency != ''">
  1407. AND a.urgency = #{query.urgency}
  1408. </if>
  1409. and a.FunctionType = #{query.functionType}
  1410. </where>
  1411. ORDER BY a.DefectDate,
  1412. CASE WHEN a.urgency = '特急' THEN 1
  1413. WHEN a.urgency = '紧急' THEN 2
  1414. WHEN a.urgency = '一般' THEN 3
  1415. END
  1416. </select>
  1417. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1418. select Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, Status from eam_defect_feedBack where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1419. </select>
  1420. <update id="cancelFeedBack" >
  1421. update eam_defect_feedBack
  1422. set status = '已取消'
  1423. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1424. </update>
  1425. <update id="updateFeedBack">
  1426. update eam_defect_feedBack
  1427. set status = '已下达',
  1428. PlanOperator = #{planOperator},
  1429. UpdateDate = GetDate(),
  1430. UpdateBy = #{updateBy}
  1431. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1432. </update>
  1433. <insert id="saveDefectOrder">
  1434. INSERT INTO eam_workOrder
  1435. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1436. 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})
  1437. </insert>
  1438. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1439. SELECT
  1440. a.site,
  1441. a.bu_no,
  1442. a.itemNo,
  1443. a.ItemDesc,
  1444. a.ItemRemark
  1445. FROM eam_properties_item a
  1446. 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
  1447. <where>
  1448. a.ItemType = #{functionType}
  1449. and a.site = #{site} and a.bu_no = #{buNo}
  1450. AND b.code_no is null
  1451. <if test = "itemNo != null and itemNo != ''">
  1452. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1453. </if>
  1454. <if test = "itemDesc != null and itemDesc != ''">
  1455. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1456. </if>
  1457. </where>
  1458. </select>
  1459. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1460. select
  1461. a.site,
  1462. a.bu_no,
  1463. a.properties_item_no itemNo,
  1464. b.ItemDesc,
  1465. b.ItemRemark
  1466. from eam_properties_model_detail a
  1467. 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
  1468. where a.site = #{site} and a.bu_no = #{buNo} and a.code_no = #{codeNo}
  1469. and a.function_type = #{functionType}
  1470. </select>
  1471. <delete id="deleteObjectFile">
  1472. delete from sys_oss where id = #{id}
  1473. </delete>
  1474. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1475. SELECT id, url, create_date, file_name, new_file_name, created_by,
  1476. order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1477. FROM sys_oss
  1478. WHERE order_ref2 = #{orderNo}
  1479. AND order_ref1 = #{site}
  1480. AND order_ref3 = 'reportSparPart'
  1481. </select>
  1482. <!-- 获取机修人员列表 -->
  1483. <select id="getOperatorList" resultType="EamAdminData" parameterType="EamAdminData">
  1484. SELECT
  1485. ea.AdminID,
  1486. ea.AdminName,
  1487. ea.Phone,
  1488. dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName,
  1489. ea.Email,
  1490. ea.Tel,
  1491. ea.LevelID,
  1492. eal.AdminLevelDesc,
  1493. ea.MesUser,
  1494. ea.Active,
  1495. ea.CreatedDate
  1496. FROM eam_admin as ea
  1497. LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1498. <where>
  1499. ea.Active = 'Y'
  1500. AND ea.Site = #{site}
  1501. <if test = "adminID != null and adminID != ''">
  1502. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1503. </if>
  1504. <if test = "adminName != null and adminName != ''">
  1505. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1506. </if>
  1507. </where>
  1508. </select>
  1509. <!-- 获取审核人员列表 -->
  1510. <select id="getCheckerList" resultType="EamAdminData" parameterType="EamAdminData">
  1511. SELECT
  1512. a.user_id,
  1513. a.username as adminID,
  1514. a.email,
  1515. a.mobile as phone,
  1516. a.user_display as adminName,
  1517. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  1518. d.role_id,
  1519. e.role_name
  1520. FROM sys_user as a
  1521. LEFT JOIN eam_access_site as b on a.username = b.username
  1522. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  1523. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  1524. LEFT JOIN sys_role as e on d.role_id = e.role_id
  1525. <where>
  1526. b.site = #{site} and c.bu_no = #{buNo}
  1527. <if test = "adminID != null and adminID != ''">
  1528. AND a.username LIKE '%' + #{adminID}+'%'
  1529. </if>
  1530. <if test = "adminName != null and adminName != ''">
  1531. AND a.user_display LIKE '%' + #{adminName}+'%'
  1532. </if>
  1533. <if test = "buDesc != null and buDesc != ''">
  1534. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  1535. </if>
  1536. <if test = "roleId != null and roleId != ''">
  1537. AND d.role_id = #{roleId}
  1538. </if>
  1539. </where>
  1540. </select>
  1541. <!-- 点检工单审核 -->
  1542. <update id="checkWorkOrder" parameterType="EamWorkOrderInData">
  1543. UPDATE eam_workOrder
  1544. SET Status = '已完工'
  1545. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1546. </update>
  1547. <update id="cancelCheckWorkOrder" parameterType="EamWorkOrderInData">
  1548. UPDATE eam_workOrder
  1549. SET Status = '待审核'
  1550. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1551. </update>
  1552. <!-- 查看点检工单状态 -->
  1553. <select id="checkWorkOrderStatus" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1554. SELECT
  1555. OrderNo
  1556. FROM eam_workOrder
  1557. WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' and bu_no = #{buNo}
  1558. </select>
  1559. <!-- 点检工单审核 -->
  1560. <update id="updateWorkPlanOverviewStatus" parameterType="EamWorkOrderInData">
  1561. UPDATE eam_workPlan_overview
  1562. SET status = '已结束'
  1563. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1564. </update>
  1565. <!-- 新增点检计划 -->
  1566. <insert id="saveWorkPlan" parameterType="EamWorkPlanInData">
  1567. INSERT INTO eam_workPlan_overview
  1568. (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)
  1569. 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})
  1570. </insert>
  1571. <!-- 生成工单ID -->
  1572. <select id="selectOrderId" resultType="string" parameterType="EamWorkPlanInData">
  1573. SELECT
  1574. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1575. FROM eam_workPlan
  1576. WHERE site = #{site} AND FunctionType = #{functionType} and bu_no = #{buNo}
  1577. </select>
  1578. <!-- 查询计划中的设备列表 -->
  1579. <select id="getPlanDetailList" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1580. SELECT
  1581. ewp.PlanID,
  1582. ewp.PlanDesc,
  1583. ewp.ObjectID,
  1584. eo.ObjectDesc,
  1585. eo.FamilyID,
  1586. ef.FamilyDesc,
  1587. eo.LocationID,
  1588. el.LocationName
  1589. FROM eam_workPlan as ewP
  1590. LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site and ewP.bu_no = eo.bu_no
  1591. LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site and ewP.bu_no = ef.bu_no
  1592. LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site and ewP.bu_no = el.bu_no
  1593. <where>
  1594. ewP.site = #{site} and ewP.bu_no = #{buNo}
  1595. AND ewp.PlanID = #{planID}
  1596. <if test = "objectID != null and objectID != ''">
  1597. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  1598. </if>
  1599. <if test = "objectDesc != null and objectDesc != ''">
  1600. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  1601. </if>
  1602. </where>
  1603. </select>
  1604. <!-- 删除计划中的设备 -->
  1605. <delete id="delPlanDetail" parameterType="WorkPlanDetailData">
  1606. DELETE FROM eam_workPlan
  1607. WHERE Site = #{site}
  1608. AND PlanID = #{planID}
  1609. AND ObjectID = #{objectID}
  1610. </delete>
  1611. <!-- 获取当前计划不包含的设备 -->
  1612. <select id="getObjList1" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1613. SELECT
  1614. a.ObjectID,
  1615. a.ObjectDesc,
  1616. a.FamilyID,
  1617. ef.FamilyDesc,
  1618. a.LocationID,
  1619. el.LocationName
  1620. FROM eam_object a
  1621. 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
  1622. LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1623. LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1624. WHERE a.site = #{site} and a.bu_no = #{buNo} and b.PlanID is null
  1625. </select>
  1626. <!-- 获取当前计划包含的设备 -->
  1627. <select id="getObjList2" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1628. SELECT
  1629. a.ObjectID,
  1630. b.ObjectDesc,
  1631. b.FamilyID,
  1632. ef.FamilyDesc,
  1633. b.LocationID,
  1634. el.LocationName
  1635. FROM eam_workPlan a
  1636. LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1637. LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1638. LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1639. WHERE a.PlanID = #{planID} and a.site = #{site} and a.bu_no = #{buNo}
  1640. </select>
  1641. <!-- 添加计划设备 -->
  1642. <insert id="addObject" parameterType="EamWorkPlanInData">
  1643. INSERT INTO eam_workPlan
  1644. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  1645. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  1646. </insert>
  1647. <!-- 修改工单计划 -->
  1648. <update id="updateWorkPlan" parameterType="EamWorkPlanInData">
  1649. UPDATE eam_workPlan_overview
  1650. SET plan_desc = #{planDesc},
  1651. properties_code = #{propertiesCode},
  1652. plan_start_date = #{planStartDate},
  1653. plan_end_date = #{planEndDate},
  1654. plan_period = #{planPeriod},
  1655. remark = #{remark},
  1656. operator = #{operator},
  1657. operator_name = #{operatorName},
  1658. checker = #{checker},
  1659. checker_name = #{checkerName},
  1660. work_order_rule = #{workOrderRule},
  1661. task_start_date = #{taskStartDate},
  1662. plan_cycle = #{planCycle},
  1663. plan_halt_date = #{planHaltDate},
  1664. auto_renewal = #{autoRenewal}
  1665. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1666. </update>
  1667. <!-- 删除该计划的旧设备 -->
  1668. <delete id="delWorkPlanObject" parameterType="EamWorkPlanInData">
  1669. DELETE FROM eam_workPlan
  1670. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1671. </delete>
  1672. <!-- 删除该计划的旧设备item -->
  1673. <delete id="delWorkPlanItem" parameterType="EamWorkPlanInData">
  1674. DELETE FROM eam_workPlan_item
  1675. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1676. </delete>
  1677. <!-- 删除该计划的旧设备itemAvailable-->
  1678. <delete id="delWorkPlanItemAvailable">
  1679. DELETE FROM eam_workPlan_item_available
  1680. WHERE Site = #{site}
  1681. AND PlanID = #{planID}
  1682. AND ObjectID = #{objectID}
  1683. </delete>
  1684. <!-- 查询该计划的设备 -->
  1685. <select id="planObjectSearch" resultType="EamWorkPlanItemData" parameterType="EamWorkPlanItemData">
  1686. SELECT DISTINCT
  1687. a.ObjectID,
  1688. b.ObjectDesc
  1689. FROM eam_workPlan_item as a
  1690. LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1691. WHERE a.Site = #{site} AND a.PlanID = #{planID} and a.bu_no = #{buNo}
  1692. </select>
  1693. <!-- 修改该计划状态 -->
  1694. <update id="updateOverviewStatus" parameterType="EamWorkPlanInData">
  1695. UPDATE eam_workPlan_overview
  1696. SET status = '进行中',
  1697. next_work_date = plan_start_date
  1698. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1699. </update>
  1700. <!-- 查询文件路径 -->
  1701. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1702. SELECT
  1703. id,
  1704. url,
  1705. file_name
  1706. FROM sys_oss WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} and order_ref4 = #{buNo}
  1707. </select>
  1708. <!-- 新增子明细信息 -->
  1709. <insert id="saveOperator" parameterType="EamWorkOrderInData">
  1710. INSERT INTO eam_actual_operator
  1711. (site, order_no, function_type, operator, bu_no)
  1712. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
  1713. </insert>
  1714. <!-- AND Status = '已完工' AND PlanOperator is not null-->
  1715. <!-- 查询实际维修人员 -->
  1716. <select id="getActualOperatorList2" resultType="EamAdminData">
  1717. SELECT
  1718. ea.AdminID,
  1719. ea.AdminName
  1720. FROM eam_actual_operator as eao
  1721. LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site
  1722. LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo
  1723. WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID}
  1724. </select>
  1725. <!-- 查询实际维修人员 -->
  1726. <select id="getActualOperatorList" resultType="EamAdminData">
  1727. SELECT
  1728. ea.username as adminID,
  1729. ea.user_display as AdminName
  1730. FROM eam_actual_operator as eao
  1731. LEFT JOIN sys_user as ea ON eao.operator = ea.username
  1732. WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} and eao.bu_no = #{buNo}
  1733. </select>
  1734. <!-- 查询设备所属部门 -->
  1735. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  1736. SELECT ved.department_name
  1737. FROM eam_object as eo
  1738. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  1739. WHERE eo.site = #{site}
  1740. AND eo.ObjectID = #{objectID}
  1741. </select>
  1742. <!-- 查询用户所属部门 -->
  1743. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  1744. SELECT AdminID
  1745. FROM eam_admin
  1746. WHERE site = #{site}
  1747. AND MesUser = #{username}
  1748. </select>
  1749. <!-- &lt;!&ndash; 查询部门列表 &ndash;&gt;-->
  1750. <!-- <select id="getDeptList" resultType="string" parameterType="string">-->
  1751. <!-- SELECT-->
  1752. <!-- ved.department_name-->
  1753. <!-- FROM eam_admin_dept as ead-->
  1754. <!-- LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id-->
  1755. <!-- LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID-->
  1756. <!-- WHERE ead.site = #{site} AND ea.MesUser = #{username}-->
  1757. <!-- </select>-->
  1758. <!-- 查询部门列表 -->
  1759. <select id="getDeptList" resultType="string" parameterType="string">
  1760. SELECT
  1761. distinct c.department_name
  1762. from sys_user as a
  1763. left join Access_dept as b on a.username = b.username
  1764. left join sys_department as c on c.site in (select site from eam_access_site where username = #{username})
  1765. and (c.site + '-' + c.bu_no) in (select * from dbo.query_bu(#{username}))
  1766. and b.department_id = c.department_id
  1767. where a.username = #{username}
  1768. </select>
  1769. <!-- 生成新的维修工单 -->
  1770. <insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData">
  1771. INSERT INTO eam_workOrder
  1772. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no, document_source)
  1773. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource})
  1774. </insert>
  1775. <!-- 获取旧工单的基础信息 -->
  1776. <select id="queryOldWorkOrderMessage" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1777. select
  1778. PlanOperator,
  1779. PlanOperatorName,
  1780. checker,
  1781. checkerName
  1782. from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1783. </select>
  1784. <!-- 生成新的维保工单 -->
  1785. <insert id="saveMaintenanceWorkOrder" parameterType="EamWorkOrderInData">
  1786. INSERT INTO eam_workOrder
  1787. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1788. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  1789. </insert>
  1790. <!-- 检查系统操作人和审核人员是否一致 -->
  1791. <select id="selectNameByMes" resultType="EamAdminData" parameterType="EamAdminData">
  1792. SELECT AdminName
  1793. FROM eam_admin
  1794. WHERE site = #{site}
  1795. AND MesUser = #{mesUser}
  1796. </select>
  1797. <!-- 维修审核确认 -->
  1798. <update id="submitDefect" parameterType="EamWorkOrderInData">
  1799. UPDATE eam_workOrder
  1800. SET Status = #{status},
  1801. difficulty_level = #{difficultyLevel},
  1802. difficulty_remark = #{difficultyRemark}
  1803. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1804. </update>
  1805. <!-- 查询设备的点检和维保历史记录 -->
  1806. <select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1807. SELECT
  1808. top 10
  1809. ewo.OrderNo,
  1810. ewo.PlanID,
  1811. ewo.PlanDesc,
  1812. ewo.ActualDate,
  1813. ewo.ObjectID,
  1814. eo.ObjectDesc,
  1815. ewo.Remark,
  1816. dbo.eam_Get_eamAdminName(ewo.site,ewo.ActualOperator) ActualOperatorName,
  1817. ewo.checkResult
  1818. FROM eam_workOrder as ewo
  1819. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1820. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND (ewo.Status = '已完工' or ewo.Status = '待审核')and ewo.bu_no = #{buNo}
  1821. ORDER BY ewo.ActualDate desc
  1822. </select>
  1823. <!-- 查询设备的维修历史记录 -->
  1824. <select id="queryDefectHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1825. SELECT
  1826. top 10
  1827. ewo.OrderNo,
  1828. ewo.PlanID,
  1829. ewo.PlanDesc,
  1830. ewo.ActualDate,
  1831. ewo.Remark,
  1832. ewo.Result,
  1833. ewo.disposal_measures,
  1834. ed.DefectDesc,
  1835. ewo.WorkTime
  1836. FROM eam_workOrder as ewo
  1837. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1838. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID and ewo.bu_no = edf.bu_no
  1839. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  1840. 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
  1841. </select>
  1842. <!-- 查询部门列表 -->
  1843. <select id="getEmpyDeptList" resultType="EmpyDept" parameterType="EmpyDept">
  1844. SELECT
  1845. site,
  1846. department_id as deptId,
  1847. department_name as deptName
  1848. FROM sys_department
  1849. <where>
  1850. site in (select site from eam_access_site where username = #{userName})
  1851. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  1852. <if test = "deptId != null and deptId != ''">
  1853. AND department_id LIKE '%' + #{deptId}+'%'
  1854. </if>
  1855. <if test = "deptName != null and deptName != ''">
  1856. AND department_name LIKE '%' + #{deptName}+'%'
  1857. </if>
  1858. </where>
  1859. </select>
  1860. <!-- 生成新的维修工单 -->
  1861. <insert id="saveAdminDepartment">
  1862. INSERT INTO eam_admin_dept
  1863. (Site, admin_id, dept_id)
  1864. VALUES (#{site}, #{adminID}, #{deptId})
  1865. </insert>
  1866. <!-- 查询部门详情 -->
  1867. <select id="getDeptDetail" resultType="EamAdminData" parameterType="string">
  1868. SELECT
  1869. ved.department_id as department,
  1870. ved.department_name as departmentName
  1871. FROM eam_admin_dept as ead
  1872. 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
  1873. WHERE ead.site in (select site from eam_access_site where username = #{userName})
  1874. and (ead.site + '-' + ead.bu_no) in (select * from dbo.query_bu(#{userName}))
  1875. AND ead.admin_id = #{adminID}
  1876. </select>
  1877. <!-- 删除旧数据-->
  1878. <delete id="deleteAdminDepartment">
  1879. DELETE FROM eam_admin_dept
  1880. WHERE site = #{site}
  1881. AND admin_id = #{adminID}
  1882. </delete>
  1883. <!-- 获取可用的MES账号 -->
  1884. <select id="getMesList" resultType="SysUserEntity" parameterType="SysUserEntity">
  1885. SELECT
  1886. a.username,
  1887. a.user_display
  1888. FROM sys_user a
  1889. LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site
  1890. WHERE a.site = #{site}
  1891. AND b.MesUser is null
  1892. </select>
  1893. <!-- 查询点检项目 -->
  1894. <select id="eamPropertiesItemSearch" parameterType="EamPropertiesItemData" resultType="EamPropertiesItemData">
  1895. SELECT
  1896. site,
  1897. bu_no,
  1898. dbo.get_bu_desc(site, bu_no) as buDesc,
  1899. ItemNo,
  1900. ItemDesc,
  1901. DefaultValue,
  1902. ValueType,
  1903. ValueType_DB as valueTypeDb,
  1904. ValueChooseFlag,
  1905. CreatedDate,
  1906. CreatedBy,
  1907. update_date,
  1908. update_by,
  1909. MaxValue,
  1910. MinValue,
  1911. ItemRemark,
  1912. ItemType,
  1913. image_flag,
  1914. produce_control_flag
  1915. FROM eam_properties_item
  1916. <where>
  1917. site in (select site from eam_access_site where username = #{query.userName})
  1918. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1919. and ItemType = #{query.itemType}
  1920. <if test="query.buDesc != null and query.buDesc != ''">
  1921. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  1922. </if>
  1923. <if test="query.itemNo != null and query.itemNo != ''">
  1924. AND ItemNo LIKE '%' + #{query.itemNo}+'%'
  1925. </if>
  1926. <if test="query.itemDesc != null and query.itemDesc != ''">
  1927. AND ItemDesc LIKE '%' + #{query.itemDesc}+'%'
  1928. </if>
  1929. </where>
  1930. </select>
  1931. <!-- 删除图片-->
  1932. <delete id="imageDelete" parameterType="SysOssEntity">
  1933. DELETE FROM sys_oss
  1934. WHERE id = #{id}
  1935. </delete>
  1936. <!-- 检查该日期内是否已有该设备的计划 -->
  1937. <select id="checkObjectPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1938. SELECT
  1939. a.PlanID,
  1940. a.ObjectID
  1941. FROM eam_workPlan a
  1942. 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
  1943. WHERE a.site = #{site} and a.bu_no = #{buNo}
  1944. AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N'
  1945. AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  1946. or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  1947. or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0)
  1948. )
  1949. and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod}
  1950. and b.Status not in ('已取消','已完成','待审核')
  1951. </select>
  1952. <!-- 查询当前计划 -->
  1953. <select id="queryWorkPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1954. SELECT
  1955. site,
  1956. bu_no,
  1957. plan_id,
  1958. plan_desc,
  1959. properties_code,
  1960. #{objectID} as objectID,
  1961. status,
  1962. operator,
  1963. delete_flag,
  1964. plan_start_date,
  1965. plan_end_date,
  1966. plan_period,
  1967. function_type,
  1968. checker,
  1969. checker_name,
  1970. operator_name,
  1971. work_order_rule,
  1972. plan_cycle
  1973. FROM eam_workPlan_overview
  1974. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1975. </select>
  1976. <!-- 获得工单号 -->
  1977. <select id="queryPlanOrderNo" resultType="string" parameterType="EamWorkPlanInData">
  1978. SELECT
  1979. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  1980. FROM eam_workOrder
  1981. WHERE site = #{site} and bu_no = #{buNo} AND FunctionType = #{functionType}
  1982. </select>
  1983. <!-- 新增工单 -->
  1984. <insert id="insertWorkOrder" parameterType="EamWorkPlanInData">
  1985. INSERT INTO eam_workOrder
  1986. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1987. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1988. </insert>
  1989. <!-- 循环新增工单 -->
  1990. <insert id="forInsertWorkOrder" parameterType="EamWorkPlanInData">
  1991. INSERT INTO eam_workOrder
  1992. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, last_execution_date)
  1993. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{lastExecutionDate})
  1994. </insert>
  1995. <!-- 更改plan表的状态为进行中 -->
  1996. <update id="updatePlanStatus" parameterType="EamWorkPlanInData">
  1997. update eam_workPlan
  1998. set status = '进行中',
  1999. NextWorkDate = PlanStartDate
  2000. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2001. </update>
  2002. <!-- 获得工单号 -->
  2003. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="EamWorkOrderItemInData">
  2004. SELECT
  2005. id,
  2006. file_name
  2007. FROM sys_oss
  2008. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2009. </select>
  2010. <!-- 删除原来工单项目-->
  2011. <delete id="deleteWorkPlanItem" parameterType="EamWorkOrderItemInData">
  2012. DELETE FROM eam_workPlan_item
  2013. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2014. </delete>
  2015. <!-- 删除原来的可选值-->
  2016. <delete id="deleteWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  2017. DELETE FROM eam_workPlan_item_available
  2018. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2019. </delete>
  2020. <!-- 添加新项目 -->
  2021. <insert id="saveWorkPlanItem" parameterType="EamWorkOrderItemInData">
  2022. 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)
  2023. select
  2024. #{site},
  2025. #{buNo},
  2026. #{planID},
  2027. #{objectID},
  2028. a.ItemNo,
  2029. a.ItemDesc,
  2030. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  2031. case when c.site is not null then c.ValueType else a.ValueType end,
  2032. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  2033. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  2034. case when c.site is not null then c.MaxValue else a.MaxValue end,
  2035. case when c.site is not null then c.MinValue else a.MinValue end,
  2036. a.ItemRemark,
  2037. a.ItemType,
  2038. GetDate(),
  2039. #{userId},
  2040. a.image_flag,
  2041. a.produce_control_flag
  2042. from eam_properties_item a
  2043. 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
  2044. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  2045. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2046. </insert>
  2047. <!-- 添加新项目可选值 -->
  2048. <insert id="saveWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  2049. INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  2050. SELECT DISTINCT
  2051. #{site},
  2052. #{buNo},
  2053. #{planID},
  2054. #{objectID},
  2055. a.ItemNo,
  2056. a.ItemType,
  2057. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  2058. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  2059. GetDate(),
  2060. #{userId}
  2061. FROM eam_properties_item_available a
  2062. 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
  2063. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  2064. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2065. </insert>
  2066. <!-- 检查维修任务号是否已存在 -->
  2067. <select id="getEamGzData" resultType="EamDefectFeedBackData" parameterType="EamDefectFeedBackData">
  2068. select
  2069. a.Site,
  2070. a.bu_no,
  2071. a.FeedBackID,
  2072. a.FeedBackDesc,
  2073. a.ObjectID,
  2074. a.Status
  2075. from eam_defect_feedBack a
  2076. left join eam_defect b on a.DefectID = b.DefectID
  2077. <where>
  2078. a.site = #{site} and a.deleteFlag = 'N' and a.bu_no = #{buNo}
  2079. <if test="feedBackID != null and feedBackID != ''">
  2080. AND a.FeedBackID LIKE '%' + #{feedBackID}+'%'
  2081. </if>
  2082. <if test="feedBackDesc != null and feedBackDesc != ''">
  2083. AND a.FeedBackDesc LIKE '%' + #{feedBackDesc}+'%'
  2084. </if>
  2085. <if test="objectInfo != null and objectInfo != ''">
  2086. AND (a.ObjectID like '%' + #{objectInfo} + '%' or dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) like '%' + #{objectInfo} + '%')
  2087. </if>
  2088. <if test="defectInfo != null and defectInfo != ''">
  2089. AND (a.DefectID like '%' + #{defectInfo} + '%' or b.defectDesc like '%' + #{defectInfo} + '%')
  2090. </if>
  2091. </where>
  2092. </select>
  2093. <!-- 保存故障信息 -->
  2094. <insert id="saveEamGzBbData" parameterType="EamDefectFeedBackData">
  2095. INSERT INTO eam_defect_feedBack
  2096. (Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate, Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency)
  2097. VALUES (#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate}, #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency})
  2098. </insert>
  2099. <!-- 查看现场动控是否开启 -->
  2100. <select id="selectControlBaseData" resultType="SysSceneDynamicControlModelEntity" parameterType="string">
  2101. SELECT
  2102. type,
  2103. base_data,
  2104. base_desc,
  2105. status,
  2106. remark,
  2107. third_type,
  2108. second_type,
  2109. page_control,
  2110. control_style
  2111. FROM sys_scene_dynamic_control_model
  2112. where site = #{site} and control_no = #{controlNo}
  2113. </select>
  2114. <!-- 修改反馈状态为已下达 -->
  2115. <update id="updateDefectFeedBackStatus" parameterType="EamDefectFeedBackData">
  2116. UPDATE eam_defect_feedBack
  2117. SET Status = '已下达'
  2118. WHERE Site = #{site} AND FeedBackID = #{feedBackID} and bu_no = #{buNo}
  2119. </update>
  2120. <!-- 查询工单号 -->
  2121. <select id="getOrderNo" resultType="string" parameterType="EamWorkOrderInData">
  2122. select
  2123. 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2124. from eam_workOrder
  2125. where site = #{site} and FunctionType = 'C' and bu_no = #{buNo}
  2126. </select>
  2127. <!-- 创建维修工单 -->
  2128. <insert id="saveWorkOrder" parameterType="EamDefectFeedBackData">
  2129. INSERT INTO eam_workOrder
  2130. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source)
  2131. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource})
  2132. </insert>
  2133. <!-- 修改工单 -->
  2134. <update id="updateWorkOrder" parameterType="EamWorkOrderInData">
  2135. update eam_workOrder
  2136. set update_by = #{mesUser},
  2137. update_date = GetDate(),
  2138. Remark = #{remark},
  2139. reach_date = #{reachDate},
  2140. ActualDate = #{actualDate},
  2141. WorkTime = #{workTime},
  2142. <if test='functionType == "B" and checkResult == "合格"'>
  2143. disposal_measures = '',
  2144. </if>
  2145. <if test='functionType == "B" and checkResult == "异常"'>
  2146. disposal_measures = #{disposalMeasures},
  2147. </if>
  2148. checkResult = #{checkResult},
  2149. check_remark = #{checkRemark},
  2150. fault_reason = #{faultReason},
  2151. preventive_measure = #{preventiveMeasure}
  2152. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  2153. </update>
  2154. <!-- 修改工单项目 -->
  2155. <update id="updateWorkOrderItem" parameterType="EamWorkOrderItemInData">
  2156. update eam_workOrder_item
  2157. set update_by = #{updateBy},
  2158. update_date = GetDate(),
  2159. <if test='valueTypeDb == "T"'>
  2160. TextValue = #{textValue},
  2161. </if>
  2162. <if test='valueTypeDb == "N"'>
  2163. NumberValue = #{numberValue},
  2164. </if>
  2165. itemResult = #{itemResult}
  2166. where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
  2167. </update>
  2168. <!-- 删除之前的协同人员-->
  2169. <delete id="delOperator" parameterType="EamWorkOrderInData">
  2170. DELETE FROM eam_actual_operator
  2171. WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
  2172. </delete>
  2173. <!-- 到达 -->
  2174. <update id="reach" parameterType="EamWorkOrderInData">
  2175. update eam_workOrder
  2176. set Status = #{status},
  2177. reach_date = GetDate(),
  2178. reach_operator = #{reachOperator},
  2179. reach_operator_name = #{reachOperatorName}
  2180. where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_No = #{buNo}
  2181. </update>
  2182. <!-- 查询是否已经上传图片 -->
  2183. <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2184. SELECT
  2185. id
  2186. FROM sys_oss
  2187. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo}
  2188. </select>
  2189. <!-- 查询文件路径 -->
  2190. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2191. SELECT
  2192. id,
  2193. url,
  2194. file_name
  2195. FROM sys_oss
  2196. WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2197. </select>
  2198. <!-- 根据工单号查询知识库记录 -->
  2199. <select id="selectKnowledgeRecordByOrderNo" resultType="EamKnowledgeBaseData" parameterType="EamWorkOrderInData">
  2200. SELECT
  2201. site,
  2202. bu_no,
  2203. num
  2204. FROM eam_knowledge_base
  2205. WHERE site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2206. </select>
  2207. <!-- 根据工单号修改知识库记录 -->
  2208. <update id="updateKnowledgeRecordByOrderNo" parameterType="EamWorkOrderInData">
  2209. update eam_knowledge_base
  2210. set update_date = getDate(),
  2211. update_by = #{updateBy}
  2212. where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2213. </update>
  2214. <!-- 新增设备知识库记录 -->
  2215. <insert id="saveKnowledgeRecord" parameterType="EamWorkOrderInData">
  2216. INSERT INTO eam_knowledge_base
  2217. (site, bu_no, num, file_type, defect_describe, disposal_measures, create_date, create_by, object_id, defect_id, order_no)
  2218. 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})
  2219. </insert>
  2220. <!-- 修改反馈状态为已取消 -->
  2221. <update id="updateFeedBackStatus" parameterType="EamWorkOrderInData">
  2222. UPDATE eam_defect_feedBack
  2223. SET Status = '已取消'
  2224. WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
  2225. </update>
  2226. <!-- 获取所有分类 -->
  2227. <select id="getFamilyTree" resultType="EamFamilyData" parameterType="EamFamilyData">
  2228. SELECT
  2229. site,
  2230. bu_no,
  2231. FamilyID,
  2232. FamilyDesc,
  2233. parent_id,
  2234. son_id,
  2235. Active
  2236. FROM eam_family
  2237. WHERE site in (select site from eam_access_site where username = #{userName})
  2238. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2239. and Active = 'Y'
  2240. </select>
  2241. <!-- 获得sonId -->
  2242. <select id="getSonId" resultType="string" parameterType="EamFamilyData">
  2243. SELECT
  2244. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2)
  2245. FROM eam_family
  2246. WHERE site = #{site} and bu_no = #{buNo} and son_id like #{parentId} + '%'
  2247. </select>
  2248. <!-- 删除该分类以及其子类-->
  2249. <delete id="eamFamilyDelete" parameterType="EamFamilyData">
  2250. DELETE FROM eam_family
  2251. WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID}
  2252. <if test="sonId != null and sonId != ''">
  2253. and son_id like #{sonId} + '%'
  2254. </if>
  2255. </delete>
  2256. <select id="getEamWorkOrder" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  2257. EXEC EAM_WORK_ORDER #{site}, #{username}, #{orderNo}, #{planID}, #{objectID}, #{status}, #{startDate}, #{endDate}, #{functionType}, '*'
  2258. </select>
  2259. <!-- 修改执行结果 -->
  2260. <update id="updateReportResult" parameterType="EamWorkOrderInData">
  2261. update eam_workOrder
  2262. set ActualDate = #{actualDate},
  2263. reach_date = #{reachDate},
  2264. fault_reason = #{faultReason},
  2265. handling_method = #{handlingMethod},
  2266. preventive_measure = #{preventiveMeasure},
  2267. Remark = #{remark},
  2268. WorkTime = #{workTime}
  2269. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2270. </update>
  2271. <!-- 根据设备查所属部门 -->
  2272. <select id="queryDepartmentByObjectId" resultType="EamObjectAdminData" parameterType="EamDefectFeedBackData">
  2273. SELECT
  2274. eo.site,
  2275. eo.bu_no,
  2276. eo.ObjectDesc,
  2277. eo.dept_id,
  2278. el.LocationName
  2279. FROM eam_object as eo
  2280. LEFT JOIN eam_location as el on eo.site = el.site and eo.LocationID = el.LocationID and eo.bu_no = el.bu_no
  2281. WHERE eo.site = #{site} and eo.ObjectID = #{objectID} and eo.bu_no = #{buNo}
  2282. </select>
  2283. <!-- 根据部门ID查机修人员电话 -->
  2284. <select id="queryPhoneByDepartmentId" resultType="EamObjectAdminData" parameterType="EamObjectAdminData">
  2285. SELECT
  2286. ed.user_display as adminName,
  2287. ed.mobile as phone
  2288. FROM Access_dept as edd
  2289. LEFT JOIN sys_user ed on edd.username = ed.username and edd.site in (select site from eam_access_site where username = ed.username)
  2290. and (edd.site + '-' + edd.bu_no) in (select * from dbo.query_bu(ed.username))
  2291. WHERE edd.site = #{site} and edd.department_id = #{deptId} and edd.bu_no = #{buNo} and ed.mobile is not null
  2292. </select>
  2293. <!-- 保存短信记录 -->
  2294. <insert id="saveMessageRecord" parameterType="MessageRecordData">
  2295. INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
  2296. VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
  2297. </insert>
  2298. <!-- 查出计划结束日期为今天并且自动续期标识为Y的计划 -->
  2299. <select id="selectPlanToday" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  2300. SELECT
  2301. site,
  2302. (site + '_' + bu_no) as bu,
  2303. plan_id,
  2304. plan_desc,
  2305. status,
  2306. plan_start_date,
  2307. plan_end_date,
  2308. created_date,
  2309. created_by,
  2310. update_date,
  2311. update_by,
  2312. remark,
  2313. next_work_date,
  2314. delete_flag,
  2315. operator,
  2316. operator_name,
  2317. checker,
  2318. checker_name,
  2319. function_type,
  2320. properties_code,
  2321. plan_period,
  2322. work_order_rule,
  2323. plan_cycle,
  2324. task_start_date,
  2325. plan_halt_date,
  2326. auto_renewal
  2327. FROM eam_workPlan_overview
  2328. WHERE site = #{site} and status != #{status} and delete_flag = #{deleteFlag} and DATEDIFF(day, plan_end_date, getdate()) = 0 and auto_renewal = #{autoRenewal}
  2329. </select>
  2330. <!-- 查出老计划的设备 -->
  2331. <select id="selectObjectByPlanID" resultType="EamObjectInData" parameterType="EamWorkPlanInData">
  2332. SELECT
  2333. Site,
  2334. PlanID,
  2335. PlanDesc,
  2336. ObjectID,
  2337. FunctionType,
  2338. PropertiesCode,
  2339. Status
  2340. FROM eam_workPlan
  2341. WHERE site = #{site} and PlanID = #{planID} and FunctionType = #{functionType}
  2342. </select>
  2343. <!-- 获取用户 bu -->
  2344. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  2345. SELECT
  2346. b.id,
  2347. a.site,
  2348. c.sitename,
  2349. (a.site + '_' + a.bu_no) as buNo,
  2350. b.bu_desc
  2351. FROM AccessBu as a
  2352. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2353. left join site as c on a.site = c.siteid
  2354. WHERE a.username = #{username}
  2355. </select>
  2356. <!-- 获取用户 bu -->
  2357. <select id="getSiteAndBuByUserName2" resultType="BuData" parameterType="BuData">
  2358. SELECT
  2359. a.site,
  2360. c.sitename,
  2361. a.bu_no,
  2362. b.bu_desc
  2363. FROM AccessBu as a
  2364. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2365. left join site as c on a.site = c.siteid
  2366. WHERE a.username = #{username}
  2367. </select>
  2368. <!-- 获取用户 bu -->
  2369. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  2370. SELECT
  2371. a.site,
  2372. a.bu_no,
  2373. b.bu_desc
  2374. FROM AccessBu as a
  2375. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2376. WHERE a.username = #{username} and a.site=#{site}
  2377. </select>
  2378. <select id="eamCheckRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2379. SELECT
  2380. a.Site,
  2381. a.bu_no,
  2382. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2383. a.OrderNo,
  2384. a.PlanID,
  2385. a.PlanDesc,
  2386. a.PropertiesCode,
  2387. a.ObjectID,
  2388. a.Status,
  2389. a.PlanOperator,
  2390. a.checker,
  2391. a.ActualOperator,
  2392. a.PlanDate,
  2393. a.ActualDate,
  2394. a.FunctionType,
  2395. a.CreateDate,
  2396. d.operator_name as createBy,
  2397. a.Remark,
  2398. a.StartTime,
  2399. a.EndTime,
  2400. a.WorkTime,
  2401. a.PlanOperatorName,
  2402. a.checkerName,
  2403. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) ActualOperatorName,
  2404. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) objectDesc,
  2405. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) codeDesc,
  2406. a.result,
  2407. b.urgency,
  2408. a.checkResult,
  2409. b.DefectID,
  2410. c.DefectDesc,
  2411. a.disposal_measures,
  2412. a.check_work_plan_id,
  2413. a.check_item_no,
  2414. a.reach_date,
  2415. a.reach_operator,
  2416. a.reach_operator_name,
  2417. b.FeedBackDesc,
  2418. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  2419. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  2420. a.check_remark,
  2421. a.document_source,
  2422. ewi.ItemNo,
  2423. ewi.ItemDesc,
  2424. ewi.DefaultValue,
  2425. ewi.ValueType,
  2426. ewi.ValueType_DB,
  2427. ewi.ValueChooseFlag,
  2428. ewi.MaxValue,
  2429. ewi.MinValue,
  2430. ewi.ItemRemark,
  2431. ewi.ItemType,
  2432. ewi.TextValue,
  2433. ewi.NumberValue,
  2434. ewi.CreatedDate,
  2435. ewi.CreatedBy,
  2436. ewi.FinishFlag,
  2437. ewi.itemResult,
  2438. ewi.item_notes
  2439. FROM eam_workOrder a
  2440. left join eam_workOrder_item ewi on a.site = ewi.site and a.OrderNo = ewi.OrderNo and a.bu_no = ewi.bu_no
  2441. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  2442. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  2443. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  2444. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  2445. 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
  2446. 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
  2447. left join sys_user as ea on ead.username = ea.username
  2448. 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
  2449. <where>
  2450. a.site in (select site from eam_access_site where username = #{query.userName})
  2451. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2452. and ea.username = #{query.userName}
  2453. <if test="query.buDesc != null and query.buDesc != ''">
  2454. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2455. </if>
  2456. <if test="query.orderNo != null and query.orderNo != ''">
  2457. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  2458. </if>
  2459. <if test="query.planID != null and query.planID != ''">
  2460. AND a.PlanID like '%' + #{query.planID} +'%'
  2461. </if>
  2462. <if test="query.planDesc != null and query.planDesc != ''">
  2463. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  2464. </if>
  2465. <if test="query.objectID != null and query.objectID != ''">
  2466. AND a.ObjectID like '%' + #{query.objectID} +'%'
  2467. </if>
  2468. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  2469. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  2470. </if>
  2471. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  2472. AND a.status != '已取消'
  2473. </if>
  2474. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  2475. AND a.status = #{query.status}
  2476. </if>
  2477. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  2478. AND a.status = '未开工'
  2479. </if>
  2480. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2481. AND a.status != '已取消'
  2482. </if>
  2483. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2484. AND a.status = #{query.status}
  2485. </if>
  2486. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  2487. AND (a.status = '未开工' or a.status = '已到达')
  2488. </if>
  2489. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  2490. AND (a.status = '未开工' or a.status = '已到达')
  2491. </if>
  2492. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2493. AND a.status = #{query.status}
  2494. </if>
  2495. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2496. AND a.document_source = #{query.documentSource}
  2497. </if>
  2498. <if test="query.planDate != null">
  2499. AND a.PlanDate = #{query.planDate}
  2500. </if>
  2501. <if test="query.startDate != null ">
  2502. AND a.PlanDate >= #{query.startDate}
  2503. </if>
  2504. <if test="query.endDate != null ">
  2505. AND #{query.endDate} >= a.PlanDate
  2506. </if>
  2507. <if test="query.endDate == null ">
  2508. AND getDate() >= a.PlanDate
  2509. </if>
  2510. <if test='query.functionType == "A"'>
  2511. and getDate() >= dbo.compare_date(ewo.task_start_date)
  2512. </if>
  2513. <if test="query.reachDate != null ">
  2514. AND a.reach_date >= #{query.reachDate}
  2515. </if>
  2516. <if test="query.actualDate != null ">
  2517. AND #{query.actualDate} >= a.ActualDate
  2518. </if>
  2519. <if test="query.itemNo != null and query.itemNo != ''">
  2520. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  2521. </if>
  2522. <if test="query.itemDesc != null and query.itemDesc != ''">
  2523. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  2524. </if>
  2525. AND a.FunctionType = #{query.functionType}
  2526. </where>
  2527. </select>
  2528. <select id="eamDefectRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2529. SELECT
  2530. a.Site,
  2531. a.bu_no,
  2532. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2533. a.OrderNo,
  2534. a.PlanID,
  2535. a.ObjectID,
  2536. a.Status,
  2537. a.PlanOperator,
  2538. a.ActualOperator,
  2539. a.PlanDate,
  2540. a.ActualDate,
  2541. a.FunctionType,
  2542. a.CreateDate,
  2543. d.operator_name as createBy,
  2544. a.Remark,
  2545. a.StartTime,
  2546. a.EndTime,
  2547. a.WorkTime,
  2548. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  2549. b.DefectID,
  2550. c.DefectDesc,
  2551. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  2552. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  2553. a.result,
  2554. b.urgency,
  2555. a.disposal_measures,
  2556. a.difficulty_level,
  2557. a.difficulty_remark,
  2558. f.department_name,
  2559. a.reach_date,
  2560. b.CreatedDate,
  2561. a.handling_method,
  2562. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  2563. CASE
  2564. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  2565. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  2566. END AS responseTime,
  2567. b.FeedBackDesc,
  2568. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  2569. a.fault_reason,
  2570. a.preventive_measure,
  2571. a.document_source,
  2572. ewi.ItemNo,
  2573. ewi.ItemDesc,
  2574. ewi.DefaultValue,
  2575. ewi.ValueType,
  2576. ewi.ValueType_DB,
  2577. ewi.ValueChooseFlag,
  2578. ewi.MaxValue,
  2579. ewi.MinValue,
  2580. ewi.ItemRemark,
  2581. ewi.ItemType,
  2582. ewi.TextValue,
  2583. ewi.NumberValue,
  2584. ewi.FinishFlag,
  2585. ewi.itemResult,
  2586. ewi.item_notes
  2587. FROM eam_workOrder a
  2588. left join eam_workOrder_item ewi on a.site = ewi.site and a.OrderNo = ewi.OrderNo and a.bu_no = ewi.bu_no
  2589. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  2590. left join eam_defect c on b.DefectID = c.DefectID
  2591. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  2592. 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
  2593. 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
  2594. 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
  2595. left join sys_user as ea on ead.username = ea.username
  2596. <where>
  2597. a.site in (select site from eam_access_site where username = #{query.userName})
  2598. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2599. and ea.username = #{query.userName}
  2600. <if test="query.buDesc != null and query.buDesc != ''">
  2601. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2602. </if>
  2603. <if test="query.deptArr != null">
  2604. AND
  2605. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  2606. f.department_name like '%' + #{item} + '%'
  2607. </foreach>
  2608. </if>
  2609. <if test="query.orderNo != null and query.orderNo != ''">
  2610. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  2611. </if>
  2612. <if test="query.planID != null and query.planID != ''">
  2613. AND a.PlanID like '%' + #{query.planID} +'%'
  2614. </if>
  2615. <if test="query.objectID != null and query.objectID != ''">
  2616. AND a.ObjectID like '%' + #{query.objectID} +'%'
  2617. </if>
  2618. <if test="query.planOperator != null and query.planOperator != ''">
  2619. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  2620. </if>
  2621. <if test="query.status != null and query.status != ''">
  2622. AND a.status = #{query.status}
  2623. </if>
  2624. <if test="query.documentSource != null and query.documentSource != ''">
  2625. AND a.document_source = #{query.documentSource}
  2626. </if>
  2627. <if test="query.startDate != null ">
  2628. AND a.PlanDate >= #{query.startDate}
  2629. </if>
  2630. <if test="query.endDate != null ">
  2631. AND #{query.endDate} >= a.PlanDate
  2632. </if>
  2633. <if test="query.reachDate != null ">
  2634. AND a.reach_date >= #{query.reachDate}
  2635. </if>
  2636. <if test="query.actualDate != null ">
  2637. AND #{query.actualDate} >= a.ActualDate
  2638. </if>
  2639. <if test="query.itemNo != null and query.itemNo != ''">
  2640. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  2641. </if>
  2642. <if test="query.itemDesc != null and query.itemDesc != ''">
  2643. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  2644. </if>
  2645. and a.FunctionType =#{query.functionType}
  2646. </where>
  2647. </select>
  2648. <!-- 获取用户角色列表 -->
  2649. <select id="getUserRoleList" resultType="SysRoleEntity">
  2650. SELECT
  2651. role_id,
  2652. role_name
  2653. FROM sys_role
  2654. </select>
  2655. <!-- 获取故障图片 -->
  2656. <select id="getFeedBackImages" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  2657. SELECT
  2658. id,
  2659. url,
  2660. create_date,
  2661. file_name,
  2662. new_file_name,
  2663. created_by,
  2664. order_ref1,
  2665. order_ref2,
  2666. order_ref3,
  2667. order_ref4,
  2668. file_type,
  2669. file_suffix,
  2670. file_type_code,
  2671. case when order_ref3 = 'feedBack' then '报修' when order_ref3 = 'reportFault' then '维修' end as typeFlag
  2672. FROM sys_oss
  2673. where order_ref1 = #{site} and (order_ref2 = #{orderNo} or order_ref2 = #{planID}) and order_ref3 in ('feedBack', 'reportFault') and order_ref4 = #{buNo}
  2674. </select>
  2675. <delete id="deleteCoreComponent">
  2676. delete from eam_workOrder_coreComponents where site=#{site} and bu_no=#{buNo} and OrderNo=#{orderNo} and ItemNo=#{itemNo}
  2677. </delete>
  2678. <insert id="saveCoreComponent">
  2679. insert into eam_workOrder_coreComponents (site,bu_no,OrderNo,ItemNo,partNo,oldSerialNo,newSerialNo,created_by,created_date)
  2680. values (#{site},#{buNo},#{orderNo},#{itemNo},#{partNo},#{oldSerialNo},#{newSerialNo},#{createdBy},GetDate())
  2681. </insert>
  2682. <!-- 获取领用出库信息 -->
  2683. <select id="getInventoryStockList" resultType="InventoryStockData" parameterType="InventoryStockData">
  2684. SELECT
  2685. A.site,
  2686. A.part_no,
  2687. A.batch_no,
  2688. isnull(A.qty_on_hand ,0) as qtyOnHand,
  2689. isnull(A.in_qty,0) inQty,
  2690. isnull(A.out_qty,0) as outQty,
  2691. A.warehouse_id,
  2692. A.location_id,
  2693. (B.part_description + '/' + B.spec) as partDescription,
  2694. B.S_code_control_flag,
  2695. B.supplier_id,
  2696. dbo.qc_get_supplier_name(A.site, B.supplier_id) as supplierDesc
  2697. FROM inventory_stock as A
  2698. left join part_spare as B on A.site = B.site and A.part_no = B.part_no
  2699. <where>
  2700. A.site = #{site}
  2701. <if test="partNo != null and partNo != ''">
  2702. AND A.part_no = #{partNo}
  2703. </if>
  2704. <if test="batchNo != null and batchNo != ''">
  2705. AND A.batch_no = #{batchNo}
  2706. </if>
  2707. <if test="active != null and active != ''">
  2708. AND B.active = #{active}
  2709. </if>
  2710. </where>
  2711. </select>
  2712. <!-- 查询设备 -->
  2713. <select id="getResourceCount" resultType="ResourceData" parameterType="PartSpareData">
  2714. SELECT
  2715. id,
  2716. site,
  2717. resource_id,
  2718. resource_desc
  2719. FROM resource
  2720. where site = #{site} and resource_id = #{resourceId}
  2721. </select>
  2722. <!-- 获取编码信息 -->
  2723. <select id="getTransNo" resultType="TransNoData" parameterType="PartSpareData">
  2724. SELECT
  2725. #{site} as site,
  2726. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  2727. </select>
  2728. <!-- 修改编码信息 -->
  2729. <select id="updateTransNo" parameterType="PartSpareData">
  2730. EXEC UpdateTransNo #{site}, #{transTypeDB}
  2731. </select>
  2732. <select id="getInventoryStockCount" parameterType="InventoryStockData" resultType="int">
  2733. select
  2734. count(1)
  2735. from inventory_stock
  2736. where site = #{site} and part_no = #{partNo}
  2737. </select>
  2738. <select id="queryEamDocumentType" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  2739. SELECT
  2740. a.site,
  2741. a.document_type_id,
  2742. a.document_type,
  2743. a.responsible_department,
  2744. a.estimated_completion_days,
  2745. a.create_date,
  2746. a.create_by,
  2747. a.update_date,
  2748. a.update_by,
  2749. b.role_desc
  2750. FROM document_type_definition as a
  2751. LEFT JOIN business_role as b on a.site = b.site and a.responsible_department = b.role_no
  2752. WHERE
  2753. a.site in (select eas.site from eam_access_site as eas where eas.username = #{params.userName})
  2754. <if test="params.sql != null and params.sql != ''">
  2755. ${params.sql}
  2756. </if>
  2757. </select>
  2758. <select id="eamDocumentTypeSearch" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  2759. SELECT
  2760. a.site,
  2761. a.document_type_id,
  2762. a.document_type,
  2763. a.responsible_department,
  2764. a.estimated_completion_days,
  2765. a.create_date,
  2766. a.create_by,
  2767. a.update_date,
  2768. a.update_by,
  2769. b.role_desc
  2770. FROM document_type_definition as a
  2771. LEFT JOIN business_role as b on a.site = b.site and a.responsible_department = b.role_no
  2772. WHERE
  2773. a.site in (select eas.site from eam_access_site as eas where eas.username = #{query.userName})
  2774. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  2775. AND a.document_type_id LIKE #{query.documentTypeId}
  2776. </if>
  2777. <if test="query.documentType != null and query.documentType != ''">
  2778. AND a.document_type LIKE #{query.documentType}
  2779. </if>
  2780. </select>
  2781. <select id="checkEamDocumentType" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  2782. SELECT
  2783. Site,
  2784. document_type_id,
  2785. document_type,
  2786. responsible_department,
  2787. estimated_completion_days
  2788. FROM document_type_definition
  2789. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  2790. </select>
  2791. <insert id="saveNewEamDocumentType">
  2792. INSERT INTO document_type_definition
  2793. (Site, document_type_id, document_type, responsible_department, estimated_completion_days,create_date, create_by)
  2794. VALUES
  2795. (#{site}, #{documentTypeId}, #{documentType}, #{responsibleDepartment}, #{estimatedCompletionDays}, getDate(), #{createBy})
  2796. </insert>
  2797. <update id="eamDocumentTypeEdit">
  2798. UPDATE document_type_definition
  2799. SET document_type = #{documentType},
  2800. responsible_department = #{responsibleDepartment},
  2801. estimated_completion_days = #{estimatedCompletionDays},
  2802. update_date = getDate(),
  2803. update_by = #{updateBy}
  2804. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  2805. </update>
  2806. <delete id="eamDocumentTypeDelete">
  2807. DELETE FROM document_type_definition
  2808. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  2809. </delete>
  2810. <select id="queryBuDocument" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  2811. SELECT
  2812. a.id,
  2813. a.site,
  2814. a.bu_no,
  2815. dbo.get_bu_desc ( a.site, a.bu_no ) as buDesc,
  2816. a.project_category,
  2817. a.document_type_id,
  2818. a.project_phase,
  2819. c.document_type,
  2820. c.responsible_department,
  2821. c.estimated_completion_days,
  2822. a.create_date,
  2823. a.create_by,
  2824. a.update_date,
  2825. a.update_by,
  2826. b.bu_desc,
  2827. d.role_desc
  2828. FROM bu_document_list_definition as a
  2829. LEFT JOIN bu as b on a.site = b.site and a.bu_no = b.bu_no
  2830. LEFT JOIN document_type_definition as c on a.document_type_id = c.document_type_id
  2831. LEFT JOIN business_role as d on a.site = d.site and c.responsible_department = d.role_no
  2832. WHERE
  2833. a.site in (select site from eam_access_site where username = #{params.userName})
  2834. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{params.userName}))
  2835. <if test="params.sql != null and params.sql != ''">
  2836. ${params.sql}
  2837. </if>
  2838. ORDER BY
  2839. b.bu_no,
  2840. a.project_phase,
  2841. a.project_category,
  2842. a.document_type_id
  2843. </select>
  2844. <select id="eamBuDocumentSearch" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  2845. SELECT
  2846. a.id,
  2847. a.site,
  2848. a.bu_no,
  2849. a.project_category,
  2850. a.document_type_id,
  2851. a.project_phase,
  2852. c.document_type,
  2853. c.responsible_department,
  2854. c.estimated_completion_days,
  2855. a.create_date,
  2856. a.create_by,
  2857. a.update_date,
  2858. a.update_by,
  2859. b.bu_desc,
  2860. d.role_desc
  2861. FROM bu_document_list_definition as a
  2862. LEFT JOIN bu as b on a.site = b.site and a.bu_no = b.bu_no
  2863. LEFT JOIN document_type_definition as c on a.document_type_id = c.document_type_id
  2864. LEFT JOIN business_role as d on a.site = d.site and c.responsible_department = d.role_no
  2865. WHERE
  2866. a.site in (select site from eam_access_site where username = #{query.userName})
  2867. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2868. <if test="query.buDesc != null and query.buDesc != ''">
  2869. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2870. </if>
  2871. <if test="query.projectPhase != null and query.projectPhase != ''">
  2872. AND a.project_phase = #{query.projectPhase}
  2873. </if>
  2874. <if test="query.projectCategory != null and query.projectCategory != ''">
  2875. AND a.project_category = #{query.projectCategory}
  2876. </if>
  2877. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  2878. AND a.document_type_id like #{query.documentTypeId}
  2879. </if>
  2880. <if test="query.documentType != null and query.documentType != ''">
  2881. AND c.document_type like #{query.documentType}
  2882. </if>
  2883. ORDER BY
  2884. b.bu_no,
  2885. a.project_phase,
  2886. a.project_category,
  2887. a.document_type_id
  2888. </select>
  2889. <select id="checkEamBuDocument" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  2890. SELECT
  2891. Site,
  2892. bu_no,
  2893. project_category,
  2894. document_type_id,
  2895. project_phase
  2896. FROM bu_document_list_definition
  2897. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  2898. </select>
  2899. <select id="checkEamDocumentTypeDelete" resultType="Integer">
  2900. SELECT COUNT(*) FROM bu_document_list_definition t1
  2901. WHERE t1.document_type_id = #{documentTypeId}
  2902. UNION ALL
  2903. SELECT COUNT(*) FROM plm_document_list_definition t2
  2904. WHERE t2.document_type_id = #{documentTypeId}
  2905. </select>
  2906. <insert id="saveNewEamBuDocument">
  2907. INSERT INTO bu_document_list_definition
  2908. (Site, bu_no, project_category, document_type_id, project_phase,create_date, create_by)
  2909. VALUES
  2910. (#{site}, #{buNo}, #{projectCategory}, #{documentTypeId}, #{projectPhase},getDate(), #{createBy})
  2911. </insert>
  2912. <update id="eamBuDocumentEdit">
  2913. UPDATE bu_document_list_definition
  2914. SET project_phase = #{projectPhase},
  2915. project_category = #{projectCategory},
  2916. update_date = getDate(),
  2917. update_by = #{updateBy}
  2918. WHERE Site = #{site} and bu_no = #{buNo} and document_type_id = #{documentTypeId} and id = #{id}
  2919. </update>
  2920. <delete id="eamBuDocumentDelete">
  2921. DELETE FROM bu_document_list_definition
  2922. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  2923. </delete>
  2924. <update id="updateInventoryStock" parameterType="InventoryStockData">
  2925. update inventory_stock
  2926. set in_qty = #{inQty},
  2927. out_qty = #{outQty},
  2928. qty_on_hand = #{qtyOnHand},
  2929. latest_out_date = getDate(),
  2930. latest_count_date = getDate()
  2931. <where>
  2932. site = #{site}
  2933. <if test="partNo != null and partNo != ''">
  2934. AND part_no = #{partNo}
  2935. </if>
  2936. <if test="batchNo != null and batchNo != ''">
  2937. AND batch_no = #{batchNo}
  2938. </if>
  2939. </where>
  2940. </update>
  2941. <insert id="saveRepairTransDetailSub" parameterType="RepairTransDetailSubData">
  2942. insert into repair_TransDetailsub
  2943. (TransNo, SeqNo, Site, itemNo, LocationID, BatchNo, RollQty, RollNo, orderRef2, orderRef4)
  2944. values
  2945. (#{transNo}, #{seqNo}, #{site}, #{itemNo}, #{locationId}, #{batchNo}, #{rollQty}, #{rollNo}, #{orderRef2}, #{orderRef4})
  2946. </insert>
  2947. <insert id="saveInventoryStockData" parameterType="InventoryStockData">
  2948. insert into inventory_stock
  2949. (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)
  2950. values
  2951. (#{site}, #{warehouseId}, #{partNo}, #{firstInDate}, getDate(), getDate(),getDate(), #{inQty}, #{outQty}, #{qtyOnHand}, #{citemCode}, #{partnerId}, #{latestCountDate}, #{locationId}, #{batchNo})
  2952. </insert>
  2953. <insert id="saveRepairTransDetail" parameterType="RepairTransDetailData">
  2954. insert into repair_TransDetail
  2955. (TransNo, Site, ItemNo, PartNo, LocationID, TransQty, Direction, BatchNo, OrderRef1, OrderRef2, OrderRef3, citem_code)
  2956. values
  2957. (#{transNo}, #{site}, #{itemNo}, #{partNo}, #{locationId}, #{transQty}, #{direction}, #{batchNo}, #{orderRef1}, #{orderRef2}, #{orderRef3}, #{citemCode})
  2958. </insert>
  2959. <insert id="saveRepairTransHeader" parameterType="RepairTransHeaderData">
  2960. insert into repair_TransHeader
  2961. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, TransferFlag, EnterDate, UseLocation, LinkOrderFlag, Status, Remark, orderRef1)
  2962. values
  2963. (#{transNo}, #{site}, #{warehouseId}, #{transDate}, #{transTypeDb}, #{transType}, #{userName}, #{receiver}, #{transYear}, #{transMonth}, #{partnerId}, #{partnerType}, #{authorizeFlag}, #{transferFlag}, getDate(), #{useLocation}, #{linkOrderFlag}, #{status}, #{remark}, #{orderRef1})
  2964. </insert>
  2965. <update id="updatePartSpareLocation" parameterType="PartSpareData">
  2966. update part_spare
  2967. set last_update_by =#{userName},
  2968. location_id = #{locationId},
  2969. warehouse_id = #{warehouseId}
  2970. where site = #{site} and part_no = #{partNo}
  2971. </update>
  2972. <select id="getFeedBackInfo" resultType="EamDefectFeedBackInData" parameterType="EamDefectFeedBackInData">
  2973. select
  2974. Site,
  2975. bu_no,
  2976. FeedBackID,
  2977. FeedBackDesc,
  2978. Status
  2979. from eam_defect_feedBack
  2980. <where>
  2981. Site = #{site} and bu_no = #{buNo} and FeedBackID = #{feedBackID}
  2982. </where>
  2983. </select>
  2984. <select id="getObjectInfo" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  2985. select
  2986. site,
  2987. bu_no,
  2988. objectID,
  2989. ObjectDesc,
  2990. standard_maintenance_duration
  2991. from eam_object
  2992. where Site = #{site} and bu_no = #{buNo} and ObjectID = #{objectID}
  2993. </select>
  2994. <select id="getResourceByObject" resultType="string">
  2995. select
  2996. ResourceID
  2997. from eam_object
  2998. where Site = #{site} and ObjectID = #{objectID}
  2999. </select>
  3000. <select id="selectRecordByOrderNo" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  3001. SELECT
  3002. a.Site,
  3003. a.bu_no,
  3004. a.OrderNo,
  3005. a.PlanID,
  3006. a.ObjectID,
  3007. a.Status,
  3008. a.PlanDate,
  3009. a.ActualDate,
  3010. a.FunctionType,
  3011. a.CreateDate,
  3012. a.Remark,
  3013. a.StartTime,
  3014. a.EndTime,
  3015. a.WorkTime,
  3016. a.result,
  3017. a.reach_date,
  3018. a.confirm_date,
  3019. a.confirm_by,
  3020. a.confirm_result,
  3021. a.confirm_count,
  3022. a.confirm_assessment,
  3023. a.confirm_remark
  3024. FROM eam_workOrder as a
  3025. where a.Site = #{site} and a.bu_no = #{buNo} and a.OrderNo = #{orderNo} and a.FunctionType = #{functionType}
  3026. </select>
  3027. <update id="confirmDefectOrder" parameterType="EamWorkOrderInData">
  3028. update eam_workOrder
  3029. set Status = #{status},
  3030. confirm_by = #{confirmBy},
  3031. confirm_date = getDate(),
  3032. confirm_result = #{confirmResult},
  3033. confirm_count = #{confirmCount},
  3034. confirm_assessment = #{confirmAssessment},
  3035. confirm_remark = #{confirmRemark}
  3036. where site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo} and FunctionType = #{functionType}
  3037. </update>
  3038. <update id="confirmDefectPlan" parameterType="EamWorkOrderInData">
  3039. update eam_defect_feedBack
  3040. set Status = #{status}
  3041. where site = #{site} AND bu_no = #{buNo} AND FeedBackID = #{planID} and FunctionType = #{functionType}
  3042. </update>
  3043. </mapper>