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.

3066 lines
133 KiB

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