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.

2429 lines
106 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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.familyID != null and query.familyID != ''">
  98. AND familyID like '%' + #{query.familyID} +'%'
  99. </if>
  100. <if test="query.familyDesc != null and query.familyDesc != ''">
  101. AND familyDesc like '%' + #{query.familyDesc} +'%'
  102. </if>
  103. <if test="query.active != null and query.active != ''">
  104. AND active = #{query.active}
  105. </if>
  106. </where>
  107. </select>
  108. <select id="eamGroupSearch" parameterType="com.xujie.sys.modules.pms.data.EamGroupData" resultType="com.xujie.sys.modules.pms.data.EamGroupData">
  109. SELECT
  110. Site,
  111. bu_no,
  112. dbo.get_bu_desc(site, bu_no) as buDesc,
  113. GroupID,
  114. GroupDesc,
  115. Active,
  116. create_date,
  117. create_by,
  118. update_date,
  119. update_by
  120. FROM eam_group
  121. <where>
  122. site in (select site from eam_access_site where username = #{query.userName})
  123. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  124. <if test="query.groupID != null and query.groupID != ''">
  125. AND groupID like '%' + #{query.groupID} + '%'
  126. </if>
  127. <if test="query.groupDesc != null and query.groupDesc != ''">
  128. AND groupDesc like '%' + #{query.groupDesc} + '%'
  129. </if>
  130. <if test="query.active != null and query.active != ''">
  131. AND active = #{query.active}
  132. </if>
  133. </where>
  134. </select>
  135. <select id="eamLocationSearch" parameterType="com.xujie.sys.modules.pms.data.EamLocationData" resultType="com.xujie.sys.modules.pms.data.EamLocationData">
  136. SELECT
  137. Site,
  138. bu_no,
  139. dbo.get_bu_desc(site, bu_no) as buDesc,
  140. LocationID,
  141. LocationName,
  142. Active,
  143. create_date,
  144. create_by,
  145. update_date,
  146. update_by
  147. FROM eam_location
  148. <where>
  149. site in (select site from eam_access_site where username = #{query.userName})
  150. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  151. <if test="query.locationID != null and query.locationID != ''">
  152. AND locationID like '%' + #{query.locationID} +'%'
  153. </if>
  154. <if test="query.locationName != null and query.locationName != ''">
  155. AND locationName like '%' + #{query.locationName} +'%'
  156. </if>
  157. <if test="query.active != null and query.active != ''">
  158. AND active = #{query.active}
  159. </if>
  160. </where>
  161. </select>
  162. <select id="eamManufacturerSearch" parameterType="com.xujie.sys.modules.pms.data.EamManufacturerData" resultType="com.xujie.sys.modules.pms.data.EamManufacturerData">
  163. SELECT
  164. Site,
  165. bu_no,
  166. dbo.get_bu_desc(site, bu_no) as buDesc,
  167. ManufacturerID,
  168. ManufacturerName,
  169. Active,
  170. Contact,
  171. Phone,
  172. Address,
  173. Email,
  174. Remark,
  175. create_date,
  176. create_by,
  177. update_date,
  178. update_by
  179. FROM eam_manufacturer
  180. <where>
  181. site in (select site from eam_access_site where username = #{query.userName})
  182. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  183. <if test="query.manufacturerID != null and query.manufacturerID != ''">
  184. AND manufacturerID like '%' + #{query.manufacturerID} +'%'
  185. </if>
  186. <if test="query.manufacturerName != null and query.manufacturerName != ''">
  187. AND manufacturerName like '%' + #{query.manufacturerName} +'%'
  188. </if>
  189. <if test="query.active != null and query.active != ''">
  190. AND active = #{query.active}
  191. </if>
  192. </where>
  193. </select>
  194. <select id="eamAdminLevelSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminLevelData" resultType="com.xujie.sys.modules.pms.data.EamAdminLevelData">
  195. SELECT
  196. Site,
  197. bu_no,
  198. dbo.get_bu_desc(site, bu_no) as buDesc,
  199. AdminLevelID,
  200. AdminLevelDesc,
  201. Active,
  202. create_date,
  203. create_by,
  204. update_date,
  205. update_by
  206. FROM eam_adminLevel
  207. <where>
  208. site in (select site from eam_access_site where username = #{query.userName})
  209. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  210. <if test="query.adminLevelID != null and query.adminLevelID != ''">
  211. AND adminLevelID like '%' + #{query.adminLevelID} +'%'
  212. </if>
  213. <if test="query.adminLevelDesc != null and query.adminLevelDesc != ''">
  214. AND adminLevelDesc like '%' + #{query.adminLevelDesc}+'%'
  215. </if>
  216. <if test="query.active != null and query.active != ''">
  217. AND active = #{query.active}
  218. </if>
  219. </where>
  220. </select>
  221. <select id="eamSupplierSearch" parameterType="com.xujie.sys.modules.pms.data.EamSupplierData" resultType="com.xujie.sys.modules.pms.data.EamSupplierData">
  222. SELECT
  223. Site,
  224. bu_no,
  225. dbo.get_bu_desc(site, bu_no) as buDesc,
  226. SupplierID,
  227. SupplierName,
  228. [Group],
  229. Active,
  230. Contact,
  231. Phone,
  232. Address,
  233. Email,
  234. Remark,
  235. create_date,
  236. create_by,
  237. update_date,
  238. update_by
  239. FROM eam_supplier
  240. <where>
  241. site in (select site from eam_access_site where username = #{query.userName})
  242. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  243. <if test="query.supplierID != null and query.supplierID != ''">
  244. AND supplierID like '%' + #{query.supplierID} +'%'
  245. </if>
  246. <if test="query.supplierName != null and query.supplierName != ''">
  247. AND supplierName like '%' + #{query.supplierName} +'%'
  248. </if>
  249. <if test="query.active != null and query.active != ''">
  250. AND active = #{query.active}
  251. </if>
  252. </where>
  253. </select>
  254. <select id="searchItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemAvailableData">
  255. SELECT
  256. site,
  257. bu_no,
  258. ItemNo,
  259. ValueNo,
  260. AvailableValue,
  261. CreatedDate,
  262. CreatedBy,
  263. ItemType
  264. from eam_properties_item_available
  265. where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  266. </select>
  267. <select id="getItemValueNo" resultType="Double">
  268. SELECT isnull( max(valueNo),0)+1 from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  269. </select>
  270. <select id="getItemValueNoForPlan" resultType="Double">
  271. 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}
  272. </select>
  273. <insert id="saveItemAvailable">
  274. insert into eam_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, site, bu_no)
  275. values(#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site}, #{buNo})
  276. </insert>
  277. <update id="updateItemAvailable">
  278. update eam_properties_item_available
  279. set AvailableValue = #{availableValue}
  280. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  281. </update>
  282. <delete id="deleteItemAvailable">
  283. delete from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  284. </delete>
  285. <select id="eamPropertiesModelSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  286. SELECT
  287. site,
  288. bu_no,
  289. dbo.get_bu_desc(site, bu_no) as buDesc,
  290. function_type,
  291. code_no,
  292. code_desc,
  293. active,
  294. created_date,
  295. created_by,
  296. update_date,
  297. update_by,
  298. delflag,
  299. version,
  300. CASE WHEN dbo.eam_model_is_use(site, function_type, code_no) > 0 THEN 'Y'
  301. else 'N'
  302. END as isUse
  303. FROM eam_properties_model_header
  304. <where>
  305. site in (select site from eam_access_site where username = #{query.userName})
  306. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  307. <if test="query.codeNo != null and query.codeNo != ''">
  308. AND code_no like '%' + #{query.codeNo} +'%'
  309. </if>
  310. <if test="query.codeDesc != null and query.codeDesc != ''">
  311. AND code_desc like '%' + #{query.codeDesc} +'%'
  312. </if>
  313. <if test="query.active != null and query.active != ''">
  314. AND active = #{query.active}
  315. </if>
  316. <if test='query.isUse != null and query.isUse != "" and query.isUse == "Y"'>
  317. AND dbo.eam_model_is_use(site, function_type, code_no) > 0
  318. </if>
  319. <if test='query.isUse != null and query.isUse != "" and query.isUse == "N"'>
  320. AND dbo.eam_model_is_use(site, function_type, code_no) = 0
  321. </if>
  322. and function_type = #{query.functionType}
  323. </where>
  324. </select>
  325. <insert id="eamPropertiesModelSave" >
  326. insert into eam_properties_model_header
  327. (function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by, site, bu_no)
  328. values (#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy}, #{site}, #{buNo})
  329. </insert>
  330. <update id="eamPropertiesModelEdit">
  331. update eam_properties_model_header
  332. set version = version + 1,
  333. code_desc = #{codeDesc},
  334. active = #{active},
  335. update_by = #{updateBy},
  336. update_date = GetDate()
  337. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  338. </update>
  339. <select id="checkPropertiesModel" resultType="EamPropertiesModelHeaderData">
  340. SELECT
  341. function_type,
  342. code_no,
  343. code_desc,
  344. active,
  345. created_date,
  346. created_by,
  347. update_date,
  348. update_by,
  349. delflag,
  350. version
  351. FROM eam_properties_model_header
  352. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  353. </select>
  354. <delete id="deleteModelDetail">
  355. delete from eam_properties_model_detail
  356. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  357. </delete>
  358. <delete id="eamPropertiesModelDelete" >
  359. delete from eam_properties_model_header where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  360. </delete>
  361. <select id="searchModalDetails" resultType="EamPropertiesModelDetailData">
  362. SELECT
  363. a.site,
  364. a.bu_no,
  365. a.function_type,
  366. a.code_no,
  367. a.properties_item_no itemNo,
  368. a.seq_no,
  369. b.ItemDesc,
  370. b.DefaultValue,
  371. b.ValueType,
  372. b.ValueType_DB,
  373. b.ValueChooseFlag,
  374. b.MaxValue,
  375. b.MinValue,
  376. b.ItemRemark,
  377. b.ItemType
  378. FROM eam_properties_model_detail a
  379. 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
  380. where a.function_type = #{functionType} and a.code_no = #{codeNo} and a.site = #{site} and a.bu_no = #{buNo}
  381. </select>
  382. <select id="checkItem" resultType="EamPropertiesModelDetailData">
  383. SELECT
  384. ItemDesc
  385. FROM eam_properties_item
  386. where itemType = #{functionType} and itemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  387. </select>
  388. <select id="checkModalDetails" resultType="EamPropertiesModelDetailData">
  389. SELECT
  390. site,
  391. bu_no,
  392. function_type,
  393. code_no,
  394. properties_item_no itemNo,
  395. seq_no
  396. FROM eam_properties_model_detail
  397. where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  398. </select>
  399. <select id="getModalDetailSeqNo" resultType="Integer">
  400. SELECT
  401. isnull(max(seq_no),0) + 1
  402. from eam_properties_model_detail
  403. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  404. </select>
  405. <insert id="saveModalDetails">
  406. insert into eam_properties_model_detail
  407. (function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, bu_no)
  408. values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{buNo})
  409. </insert>
  410. <delete id="deleteModalDetails">
  411. delete from eam_properties_model_detail
  412. where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  413. </delete>
  414. <select id="eamWorkPlanOverviewSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  415. SELECT
  416. a.site,
  417. a.bu_no,
  418. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  419. a.plan_id,
  420. a.plan_desc,
  421. a.status,
  422. a.plan_start_date,
  423. a.plan_end_date,
  424. a.created_date,
  425. a.created_by,
  426. a.update_date,
  427. a.update_by,
  428. a.remark,
  429. a.next_work_date,
  430. a.delete_flag,
  431. a.operator,
  432. a.operator_name,
  433. a.checker,
  434. a.checker_name,
  435. a.function_type,
  436. a.properties_code,
  437. a.plan_period,
  438. d.code_desc,
  439. a.work_order_rule,
  440. a.plan_cycle,
  441. a.task_start_date,
  442. a.plan_halt_date,
  443. a.auto_renewal
  444. FROM eam_workPlan_overview as a
  445. 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
  446. <where>
  447. a.site in (select site from eam_access_site where username = #{query.userName})
  448. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  449. and a.delete_flag = 'N' AND a.function_type = #{query.functionType}
  450. <if test="query.planID != null and query.planID != ''">
  451. AND a.plan_id like '%' + #{query.planID} +'%'
  452. </if>
  453. <if test="query.planDesc != null and query.planDesc != ''">
  454. AND a.plan_desc like '%' + #{query.planDesc}+'%'
  455. </if>
  456. <if test="query.status != null and query.status != ''">
  457. AND a.status = #{query.status}
  458. </if>
  459. <if test="query.startDate != null ">
  460. AND a.plan_start_date >= #{query.startDate}
  461. </if>
  462. <if test="query.endDate != null ">
  463. AND #{query.endDate} >= a.plan_start_date
  464. </if>
  465. </where>
  466. ORDER BY a.created_date DESC
  467. </select>
  468. <select id="eamWorkPlanSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  469. SELECT
  470. a.Site,
  471. a.PlanID,
  472. a.PlanDesc,
  473. a.ObjectID,
  474. a.FunctionType,
  475. a.PropertiesCode,
  476. a.Operator,
  477. a.checker,
  478. a.PlanPeriod,
  479. a.Status,
  480. a.PlanStartDate,
  481. a.PlanEndDate,
  482. a.CreatedDate,
  483. a.CreatedBy,
  484. a.UpdateDate,
  485. a.UpdateBy,
  486. a.Version,
  487. a.Remark,
  488. a.NextWorkDate,
  489. b.ObjectDesc,
  490. d.code_desc
  491. FROM eam_workPlan a
  492. left join eam_object b on a.Site = b.Site and a.ObjectID = b.ObjectID
  493. left join eam_properties_model_header d on a.FunctionType = d.function_type and a.PropertiesCode = d.code_no
  494. <where>
  495. AND a.DeleteFlag = 'N'
  496. AND a.FunctionType = #{query.functionType}
  497. <if test="query.planID != null and query.planID != ''">
  498. AND a.PlanID like '%' + #{query.planID} +'%'
  499. </if>
  500. <if test="query.planDesc != null and query.planDesc != ''">
  501. AND a.PlanDesc like '%' + #{query.planDesc}+'%'
  502. </if>
  503. <if test="query.status != null and query.status != ''">
  504. AND a.status = #{query.status}
  505. </if>
  506. <if test="query.startDate != null ">
  507. AND a.PlanStartDate >= #{query.startDate}
  508. </if>
  509. <if test="query.endDate != null ">
  510. AND #{query.endDate} >= a.PlanStartDate
  511. </if>
  512. </where>
  513. </select>
  514. <select id="selectNameById" resultType="string" parameterType="string">
  515. SELECT
  516. AdminName
  517. FROM eam_admin
  518. WHERE AdminID = #{s}
  519. </select>
  520. <select id="searchPlanItems" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData">
  521. SELECT
  522. a.Site,
  523. a.bu_no,
  524. a.PlanID,
  525. a.ItemNo,
  526. a.ItemDesc,
  527. a.DefaultValue,
  528. a.ValueType,
  529. a.ValueType_DB,
  530. a.ValueChooseFlag,
  531. a.UpdateDate,
  532. a.UpdateBy,
  533. a.MaxValue,
  534. a.MinValue,
  535. a.ItemRemark,
  536. a.ItemType,
  537. a.CreatedDate,
  538. a.CreatedBy,
  539. a.ObjectID
  540. FROM eam_workPlan_item a
  541. <where>
  542. a.PlanID = #{planID} and a.Site = #{site} and a.ItemType = #{functionType} and bu_no = #{buNo}
  543. <if test = "objectID != null and objectID != ''">
  544. AND a.ObjectID = #{objectID}
  545. </if>
  546. </where>
  547. </select>
  548. <select id="searchPlanItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemAvailableData">
  549. SELECT
  550. Site,
  551. bu_no,
  552. PlanID,
  553. ItemNo,
  554. ItemType,
  555. ValueNo,
  556. AvailableValue,
  557. CreatedDate,
  558. CreatedBy,
  559. UpdateDate,
  560. UpdateBy,
  561. ObjectID
  562. from eam_workPlan_item_available
  563. where PlanID = #{planID} and itemNo = #{itemNo} and site = #{site} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  564. </select>
  565. <update id="updatePlanItems">
  566. update eam_workPlan_item
  567. set DefaultValue = #{defaultValue},
  568. ValueType = #{valueType},
  569. ValueType_DB = #{valueTypeDb},
  570. ValueChooseFlag = #{valueChooseFlag},
  571. UpdateDate = GetDate(),
  572. UpdateBy = #{createdBy},
  573. MaxValue = #{maxValue,jdbcType=FLOAT},
  574. MinValue = #{minValue,jdbcType=FLOAT},
  575. ItemRemark = #{itemRemark}
  576. where site = #{site} and planID = #{planID} and ItemType = #{itemType} and ItemNo = #{itemNo} and ObjectID = #{objectID} and bu_no = #{buNo}
  577. </update>
  578. <update id="updatePlanItemsForNull">
  579. update eam_workPlan_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  580. ,ValueChooseFlag=#{valueChooseFlag},UpdateDate=GetDate(),UpdateBy=#{createdBy},MaxValue=null,MinValue=null,
  581. ItemRemark=#{itemRemark}
  582. where site=#{site} and planID=#{planID} and ItemType=#{itemType}
  583. and ItemNo=#{itemNo}
  584. </update>
  585. <insert id="saveItemAvailableForPlan">
  586. insert into eam_workPlan_item_available
  587. (Site, PlanID, ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, ObjectID, bu_no)
  588. values(#{site}, #{planID}, #{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{objectID}, #{buNo})
  589. </insert>
  590. <update id="updateItemAvailableForPlan">
  591. update eam_workPlan_item_available
  592. set AvailableValue = #{availableValue},
  593. updateBy = #{createdBy},
  594. updateDate = GetDate()
  595. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
  596. </update>
  597. <delete id="deletePlanItemAvailable">
  598. delete from eam_workPlan_item_available
  599. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
  600. </delete>
  601. <select id="objectIDBlur" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  602. select objectID,ObjectDesc from eam_object where active='Y' and Site=#{site} and ObjectID=#{objectID}
  603. </select>
  604. <select id="modalCodeBlur" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  605. select code_no,code_desc from eam_properties_model_header where active = 'Y' and function_type = #{functionType} and code_no = #{codeNo}
  606. </select>
  607. <select id="eamWorkOrderSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  608. SELECT
  609. a.Site,
  610. a.bu_no,
  611. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  612. a.OrderNo,
  613. a.PlanID,
  614. a.PlanDesc,
  615. a.PropertiesCode,
  616. a.ObjectID,
  617. a.Status,
  618. a.PlanOperator,
  619. a.checker,
  620. a.ActualOperator,
  621. a.PlanDate,
  622. a.ActualDate,
  623. a.FunctionType,
  624. a.CreateDate,
  625. d.operator_name as createBy,
  626. a.Remark,
  627. a.StartTime,
  628. a.EndTime,
  629. a.WorkTime,
  630. a.PlanOperatorName,
  631. a.checkerName,
  632. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) ActualOperatorName,
  633. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) objectDesc,
  634. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) codeDesc,
  635. a.result,
  636. b.urgency,
  637. a.checkResult,
  638. b.DefectID,
  639. c.DefectDesc,
  640. a.disposal_measures,
  641. a.check_work_plan_id,
  642. a.check_item_no,
  643. a.reach_date,
  644. a.reach_operator,
  645. a.reach_operator_name,
  646. b.FeedBackDesc,
  647. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  648. dbo.joint_name(a.Site, a.OrderNo, a.FunctionType) as operator,
  649. a.check_remark,
  650. a.document_source
  651. FROM eam_workOrder a
  652. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  653. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  654. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  655. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  656. 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
  657. 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
  658. left join sys_user as ea on ead.username = ea.username
  659. 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
  660. <where>
  661. a.site in (select site from eam_access_site where username = #{query.userName})
  662. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  663. and ea.username = #{query.userName}
  664. <if test="query.orderNo != null and query.orderNo != ''">
  665. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  666. </if>
  667. <if test="query.planID != null and query.planID != ''">
  668. AND a.PlanID like '%' + #{query.planID} +'%'
  669. </if>
  670. <if test="query.planDesc != null and query.planDesc != ''">
  671. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  672. </if>
  673. <if test="query.objectID != null and query.objectID != ''">
  674. AND a.ObjectID like '%' + #{query.objectID} +'%'
  675. </if>
  676. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  677. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  678. </if>
  679. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  680. AND a.status != '已取消'
  681. </if>
  682. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  683. AND a.status = #{query.status}
  684. </if>
  685. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  686. AND a.status = '未开工'
  687. </if>
  688. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  689. AND a.status != '已取消'
  690. </if>
  691. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  692. AND a.status = #{query.status}
  693. </if>
  694. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  695. AND (a.status = '未开工' or a.status = '已到达')
  696. </if>
  697. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  698. AND (a.status = '未开工' or a.status = '已到达')
  699. </if>
  700. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  701. AND a.status = #{query.status}
  702. </if>
  703. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  704. AND a.document_source = #{query.documentSource}
  705. </if>
  706. <if test="query.planDate != null">
  707. AND a.PlanDate = #{query.planDate}
  708. </if>
  709. <if test="query.startDate != null ">
  710. AND a.PlanDate >= #{query.startDate}
  711. </if>
  712. <if test="query.endDate != null ">
  713. AND #{query.endDate} >= a.PlanDate
  714. </if>
  715. <if test="query.endDate == null ">
  716. AND getDate() >= a.PlanDate
  717. </if>
  718. <if test='query.functionType == "A"'>
  719. and getDate() >= dbo.compare_date(ewo.task_start_date)
  720. </if>
  721. AND a.FunctionType = #{query.functionType}
  722. </where>
  723. ORDER BY a.CreateDate,
  724. CASE WHEN b.urgency = '特急' THEN 1
  725. WHEN b.urgency = '紧急' THEN 2
  726. WHEN b.urgency = '一般' THEN 3
  727. END
  728. </select>
  729. <select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  730. SELECT
  731. a.Site,
  732. a.bu_no,
  733. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  734. a.OrderNo,
  735. a.PlanID,
  736. a.ObjectID,
  737. a.Status,
  738. a.PlanOperator,
  739. a.ActualOperator,
  740. a.PlanDate,
  741. a.ActualDate,
  742. a.FunctionType,
  743. a.CreateDate,
  744. d.operator_name as createBy,
  745. a.Remark,
  746. a.StartTime,
  747. a.EndTime,
  748. a.WorkTime,
  749. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  750. b.DefectID,
  751. c.DefectDesc,
  752. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  753. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  754. a.result,
  755. b.urgency,
  756. a.disposal_measures,
  757. a.difficulty_level,
  758. a.difficulty_remark,
  759. f.department_name,
  760. a.reach_date,
  761. b.CreatedDate,
  762. a.handling_method,
  763. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  764. CASE
  765. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  766. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  767. END AS responseTime,
  768. b.FeedBackDesc,
  769. dbo.joint_name(a.Site,a.OrderNo,a.FunctionType) as actualOperatorName,
  770. a.fault_reason,
  771. a.preventive_measure,
  772. a.document_source
  773. FROM eam_workOrder a
  774. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  775. left join eam_defect c on b.DefectID = c.DefectID
  776. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  777. 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
  778. 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
  779. <where>
  780. a.site in (select site from eam_access_site where username = #{query.userName})
  781. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  782. <if test="query.deptArr != null">
  783. AND
  784. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  785. f.department_name like '%' + #{item} + '%'
  786. </foreach>
  787. </if>
  788. <if test="query.orderNo != null and query.orderNo != ''">
  789. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  790. </if>
  791. <if test="query.planID != null and query.planID != ''">
  792. AND a.PlanID like '%' + #{query.planID} +'%'
  793. </if>
  794. <if test="query.objectID != null and query.objectID != ''">
  795. AND a.ObjectID like '%' + #{query.objectID} +'%'
  796. </if>
  797. <if test="query.planOperator != null and query.planOperator != ''">
  798. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  799. </if>
  800. <if test="query.status != null and query.status != ''">
  801. AND a.status = #{query.status}
  802. </if>
  803. <if test="query.documentSource != null and query.documentSource != ''">
  804. AND a.document_source = #{query.documentSource}
  805. </if>
  806. <if test="query.startDate != null ">
  807. AND a.PlanDate >= #{query.startDate}
  808. </if>
  809. <if test="query.endDate != null ">
  810. AND #{query.endDate} >= a.PlanDate
  811. </if>
  812. and a.FunctionType =#{query.functionType}
  813. </where>
  814. ORDER BY a.PlanDate,
  815. CASE WHEN b.urgency = '特急' THEN 1
  816. WHEN b.urgency = '紧急' THEN 2
  817. WHEN b.urgency = '一般' THEN 3
  818. END
  819. </select>
  820. <select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData">
  821. SELECT
  822. DefectID,
  823. DefectDesc,
  824. Active,
  825. create_date,
  826. create_by,
  827. update_date,
  828. update_by,
  829. fault_type
  830. FROM eam_defect
  831. <where>
  832. <if test="query.defectID != null and query.defectID != ''">
  833. AND defectID like '%' + #{query.defectID} + '%'
  834. </if>
  835. <if test="query.defectDesc != null and query.defectDesc != ''">
  836. AND defectDesc like '%' + #{query.defectDesc} + '%'
  837. </if>
  838. <if test="query.active != null and query.active != ''">
  839. AND active = #{query.active}
  840. </if>
  841. </where>
  842. order by id
  843. </select>
  844. <select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  845. SELECT
  846. a.site,
  847. a.ObjectID,
  848. a.DefectID,
  849. a.Active,
  850. a.id,
  851. b.ObjectDesc,
  852. c.DefectDesc,
  853. a.create_date,
  854. a.create_by,
  855. a.update_date,
  856. a.update_by
  857. FROM eam_object_defect a
  858. left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID
  859. left join eam_defect c on a.DefectID=c.DefectID
  860. <where>
  861. <if test="query.objectID != null and query.objectID != ''">
  862. AND a.ObjectID like '%' + #{query.objectID} + '%'
  863. </if>
  864. <if test="query.objectDesc != null and query.objectDesc != ''">
  865. AND b.ObjectDesc like '%' + #{query.objectDesc} + '%'
  866. </if>
  867. <if test="query.defectID != null and query.defectID != ''">
  868. AND a.defectID like '%' + #{query.defectID} + '%'
  869. </if>
  870. <if test="query.defectDesc != null and query.defectDesc != ''">
  871. AND c.defectDesc like '%' + #{query.defectDesc} + '%'
  872. </if>
  873. <if test="query.active != null and query.active != ''">
  874. AND a.active = #{query.active}
  875. </if>
  876. </where>
  877. order by a.id
  878. </select>
  879. <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  880. SELECT
  881. a.Site,
  882. a.ObjectID,
  883. a.ObjectDesc,
  884. a.LocationID,
  885. a.FamilyID,
  886. a.GroupID,
  887. b.FamilyDesc,
  888. c.LocationName
  889. FROM eam_object a
  890. LEFT JOIN eam_family b ON a.site = b.site and a.FamilyID = b.FamilyID and a.bu_no = b.bu_no
  891. LEFT JOIN eam_location as c ON a.LocationID = c.LocationID and a.site = c.site and a.bu_no = c.bu_no
  892. <where>
  893. <if test="objectID != null and objectID != ''">
  894. AND a.ObjectID like '%' + #{objectID} + '%'
  895. </if>
  896. <if test="objectDesc != null and objectDesc != ''">
  897. AND a.ObjectDesc like '%' + #{objectDesc} + '%'
  898. </if>
  899. AND a.site = #{site} AND a.active = 'Y' and a.bu_no = #{buNo}
  900. </where>
  901. </select>
  902. <select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  903. SELECT
  904. a.site,
  905. a.objectID
  906. from eam_object as a
  907. left join eam_family as b on a.site = b.site and a.FamilyID = b.FamilyID
  908. where a.site = '2' and (b.son_id like #{sonId} + '%' or a.FamilyID = #{familyID})
  909. </select>
  910. <select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  911. SELECT site, objectID from eam_object where site = #{site} and GroupID = #{groupID}
  912. </select>
  913. <select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  914. SELECT site ,objectID from eam_object where site=#{site} and LocationID=#{locationID}
  915. </select>
  916. <select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  917. SELECT
  918. a.Site,
  919. a.bu_no,
  920. c.OrderNo,
  921. a.ItemNo,
  922. a.ItemDesc,
  923. a.DefaultValue,
  924. a.ValueType,
  925. a.ValueType_DB,
  926. a.ValueChooseFlag,
  927. a.MaxValue,
  928. a.MinValue,
  929. a.ItemRemark,
  930. a.ItemType,
  931. a.image_flag,
  932. a.produce_control_flag,
  933. CASE WHEN b.id is null THEN 'N'
  934. ELSE 'Y'
  935. END as uploadFlag,
  936. a.item_notes
  937. from eam_workPlan_item as a
  938. left join eam_workOrder as c on a.site = c.site and a.PlanID = c.PlanID and a.bu_no = c.bu_no
  939. 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
  940. on b.order_ref1 = a.site and b.order_ref2 = c.OrderNo and b.order_ref3 = a.ItemNo and order_ref4 = a.bu_no
  941. where a.site = #{site} and c.orderNo = #{orderNo} and a.ObjectID = #{objectID} and a.bu_no = #{buNo}
  942. </select>
  943. <select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  944. SELECT
  945. Site,
  946. status,
  947. OrderNo
  948. from eam_workOrder
  949. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  950. </select>
  951. <select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  952. SELECT username as adminID
  953. from sys_user
  954. where username = #{mesUser}
  955. </select>
  956. <update id="updateDefectResult" >
  957. update eam_defect_feedBack
  958. set Status = #{result},
  959. FinishDate = GetDate(),
  960. DefectID = #{defectID}
  961. where Site = #{site} and FeedBackID = #{planID}
  962. </update>
  963. <update id="reportWorkOrder" parameterType="EamWorkOrderInData">
  964. update eam_workOrder
  965. set Status = '待审核',
  966. ActualOperator = #{actualOperator},
  967. ActualDate = #{actualDate},
  968. Remark = #{remark},
  969. disposal_measures = #{disposalMeasures},
  970. WorkTime = CASE
  971. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  972. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) / 30) / 2)
  973. END,
  974. result = #{result,jdbcType=VARCHAR},
  975. checkResult = #{checkResult},
  976. handling_method = #{handlingMethod},
  977. fault_reason = #{faultReason},
  978. preventive_measure = #{preventiveMeasure}
  979. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  980. </update>
  981. <update id="reportWorkOrder2" parameterType="EamWorkOrderInData">
  982. update eam_workOrder
  983. set Status = '待审核',
  984. ActualOperator = #{actualOperator},
  985. ActualDate = #{actualDate},
  986. Remark = #{remark},
  987. disposal_measures = #{disposalMeasures},
  988. WorkTime = #{workTime},
  989. result = #{result,jdbcType=VARCHAR},
  990. checkResult = #{checkResult},
  991. handling_method = #{handlingMethod},
  992. check_remark = #{checkRemark}
  993. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  994. </update>
  995. <update id="defectReportWorkOrder" >
  996. update eam_workOrder
  997. set Status = '已完工',
  998. ActualOperator = #{actualOperator},
  999. ActualDate = GetDate(),
  1000. Remark = #{remark},
  1001. disposal_measures = #{disposalMeasures},
  1002. WorkTime = #{workTime},
  1003. result = #{result,jdbcType=VARCHAR},
  1004. checkResult = #{checkResult}
  1005. where site = #{site}
  1006. and orderNo = #{orderNo}
  1007. </update>
  1008. <insert id="saveWorkOrderItem">
  1009. INSERT into eam_workOrder_item
  1010. (Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
  1011. 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})
  1012. </insert>
  1013. <!-- 修改 eam_workPlan 状态为已结束 -->
  1014. <update id="closePlanWithCheck">
  1015. update eam_workPlan
  1016. set status = '已结束'
  1017. where site = #{site}
  1018. and PlanID = #{planID}
  1019. and ObjectID = #{objectID}
  1020. and GetDate() > PlanEndDate
  1021. </update>
  1022. <!-- 报工后更新下一个工作日期 -->
  1023. <update id="updatePlanNextDate">
  1024. update eam_workPlan_overview
  1025. 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)
  1026. where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
  1027. </update>
  1028. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1029. SELECT
  1030. Site,
  1031. bu_no,
  1032. OrderNo,
  1033. ItemNo,
  1034. ItemDesc,
  1035. DefaultValue,
  1036. ValueType,
  1037. ValueType_DB,
  1038. ValueChooseFlag,
  1039. MaxValue,
  1040. MinValue,
  1041. ItemRemark,
  1042. ItemType,
  1043. TextValue,
  1044. NumberValue,
  1045. CreatedDate,
  1046. CreatedBy,
  1047. FinishFlag,
  1048. itemResult,
  1049. item_notes
  1050. from eam_workOrder_item
  1051. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1052. </select>
  1053. <update id="cancelOrder" parameterType="EamWorkOrderInData">
  1054. update eam_workOrder
  1055. set Status = '已取消'
  1056. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1057. </update>
  1058. <update id="cancelOrderAll" parameterType="EamWorkOrderInData">
  1059. update eam_workOrder
  1060. set Status = '已取消'
  1061. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
  1062. </update>
  1063. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1064. SELECT
  1065. site,
  1066. bu_no,
  1067. status
  1068. from eam_workPlan_overview
  1069. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1070. </select>
  1071. <update id="planOrder">
  1072. update eam_workPlan
  1073. set Status = '已计划',
  1074. NextWorkDate = null
  1075. where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1076. </update>
  1077. <update id="cancelPlan">
  1078. update eam_workPlan_overview
  1079. set status = '已取消',
  1080. next_work_date = null
  1081. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1082. </update>
  1083. <update id="updateWorkPlanStatus">
  1084. update eam_workPlan
  1085. set Status = '已取消',
  1086. NextWorkDate = null
  1087. where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1088. </update>
  1089. <update id="cancelOrderWithPlanID">
  1090. update eam_workOrder
  1091. set Status = '已取消'
  1092. where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
  1093. </update>
  1094. <update id="deleteOrderDetailWithPlanID">
  1095. delete from eam_workOrder_item
  1096. where site = #{site} and bu_no = #{buNo}
  1097. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  1098. </update>
  1099. <update id="deleteOrderWithPlanID">
  1100. delete from eam_workOrder
  1101. where site = #{site} and bu_no = #{buNo}
  1102. and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
  1103. </update>
  1104. <update id="updateOrderPlanOperator">
  1105. update eam_workOrder
  1106. set PlanOperator = #{planOperator}
  1107. where site = #{site} and orderNo = #{orderNo}
  1108. </update>
  1109. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1110. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  1111. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  1112. <where>
  1113. <if test="partNo != null and partNo != ''">
  1114. AND a.part_no like '%' + #{partNo} + '%'
  1115. </if>
  1116. <if test="partDescription != null and partDescription != ''">
  1117. AND a.part_description like '%' + #{partDescription} + '%'
  1118. </if>
  1119. and a.site=#{site} and a.active='Y'
  1120. </where>
  1121. </select>
  1122. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1123. select part_no
  1124. from resource_spare
  1125. where site = #{site}
  1126. and resource_id = #{objectID}
  1127. and part_no = #{partNo}
  1128. </select>
  1129. <insert id="savePartSpare" >
  1130. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1131. values(#{objectID},#{partNo},'',0,#{site})
  1132. </insert>
  1133. <delete id="deletePartSpare">
  1134. delete from resource_spare
  1135. where resource_id = #{objectID}
  1136. and site = #{site}
  1137. </delete>
  1138. <insert id="copyPartSpare" >
  1139. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1140. select #{objectID},part_no,delflag,0,site from resource_spare where resource_id=#{oldObjectID} and site=#{site}
  1141. </insert>
  1142. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1143. SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status,
  1144. a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark
  1145. ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
  1146. FROM eam_workPlan a
  1147. left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID
  1148. left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID
  1149. left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no
  1150. where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N'
  1151. and status in ('已计划','进行中')
  1152. </select>
  1153. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1154. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  1155. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  1156. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  1157. where a.site=#{site} and a.ObjectID=#{objectID}
  1158. and a.ItemType=#{itemType}
  1159. </select>
  1160. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1161. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  1162. from eam_object_defect a left join eam_defect b
  1163. on a.DefectID=b.DefectID
  1164. where a.site=#{site} and a.ObjectID=#{objectID}
  1165. </select>
  1166. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1167. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1168. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1169. </select>
  1170. <insert id="saveNewEamObjectItem" >
  1171. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1172. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  1173. </insert>
  1174. <update id="editEamObjectItem">
  1175. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  1176. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  1177. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1178. and ItemNo=#{itemNo}
  1179. </update>
  1180. <delete id="deleteObjectItem">
  1181. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1182. and ItemNo=#{itemNo}
  1183. </delete>
  1184. <insert id="saveNewEamObjectItemAvailable">
  1185. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1186. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1187. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1188. </insert>
  1189. <delete id="deleteEamObjectItemAvailable">
  1190. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1191. and ItemNo=#{itemNo}
  1192. </delete>
  1193. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1194. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1195. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1196. </select>
  1197. <select id="getItemValueNoForObject" resultType="Double">
  1198. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1199. </select>
  1200. <insert id="saveObjectItemAvailable">
  1201. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1202. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1203. </insert>
  1204. <update id="updateObjectItemAvailable">
  1205. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1206. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1207. </update>
  1208. <delete id="deleteObjectItemAvailable">
  1209. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1210. </delete>
  1211. <delete id="deleteObjectItemForCopy">
  1212. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1213. </delete>
  1214. <delete id="deleteObjectItemAvailableForCopy">
  1215. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1216. </delete>
  1217. <insert id="copyObjectItem" >
  1218. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1219. ItemType)
  1220. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1221. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1222. </insert>
  1223. <insert id="copyObjectItemAvailable">
  1224. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1225. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1226. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1227. </insert>
  1228. <delete id="deleteObjectDefectForCopy">
  1229. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1230. </delete>
  1231. <insert id="copyObjectDefect">
  1232. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1233. select #{site},#{objectID},DefectID,Active
  1234. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1235. </insert>
  1236. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1237. select
  1238. a.Site,
  1239. a.bu_no,
  1240. a.FeedBackID,
  1241. a.FeedBackDesc,
  1242. a.ObjectID,
  1243. a.DefectID,
  1244. a.FunctionType,
  1245. a.PlanOperator,
  1246. a.ActualOperator,
  1247. a.Status,
  1248. a.PlanDate,
  1249. a.Remark,
  1250. a.urgency,
  1251. a.deleteFlag,
  1252. a.CreatedDate,
  1253. a.CreatedBy,
  1254. c.operator_name as feedbackBy,
  1255. a.UpdateDate,
  1256. a.UpdateBy,
  1257. a.Version,
  1258. a.DefectDate,
  1259. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
  1260. b.defectDesc,
  1261. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) ObjectDesc,
  1262. FinishDate,
  1263. dbo.joint_name(a.Site,(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
  1264. from eam_defect_feedBack a
  1265. left join eam_defect b on a.DefectID = b.DefectID
  1266. left join operator as c on a.site = c.site and a.CreatedBy = c.operator_id
  1267. <where>
  1268. a.site in (select site from eam_access_site where username = #{query.userName})
  1269. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1270. <if test="query.feedBackID != null and query.feedBackID != ''">
  1271. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1272. </if>
  1273. <if test="query.defectDesc != null and query.defectDesc != ''">
  1274. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1275. </if>
  1276. <if test="query.objectID != null and query.objectID != ''">
  1277. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1278. </if>
  1279. <if test="query.planOperator != null and query.planOperator != ''">
  1280. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1281. </if>
  1282. <if test="query.status != null and query.status != ''">
  1283. AND a.status = #{query.status}
  1284. </if>
  1285. <if test="query.startDate != null ">
  1286. AND a.defectDate >= #{query.startDate}
  1287. </if>
  1288. <if test="query.endDate != null ">
  1289. AND #{query.endDate} >= a.defectDate
  1290. </if>
  1291. and a.FunctionType = #{query.functionType}
  1292. </where>
  1293. ORDER BY a.DefectDate,
  1294. CASE WHEN a.urgency = '特急' THEN 1
  1295. WHEN a.urgency = '紧急' THEN 2
  1296. WHEN a.urgency = '一般' THEN 3
  1297. END
  1298. </select>
  1299. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1300. select Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, Status from eam_defect_feedBack where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1301. </select>
  1302. <update id="cancelFeedBack" >
  1303. update eam_defect_feedBack
  1304. set status = '已取消'
  1305. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1306. </update>
  1307. <update id="updateFeedBack">
  1308. update eam_defect_feedBack
  1309. set status = '已下达',
  1310. PlanOperator = #{planOperator},
  1311. UpdateDate = GetDate(),
  1312. UpdateBy = #{updateBy}
  1313. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1314. </update>
  1315. <insert id="saveDefectOrder">
  1316. INSERT INTO eam_workOrder
  1317. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1318. 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})
  1319. </insert>
  1320. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1321. SELECT
  1322. a.site,
  1323. a.bu_no,
  1324. a.itemNo,
  1325. a.ItemDesc,
  1326. a.ItemRemark
  1327. FROM eam_properties_item a
  1328. 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
  1329. <where>
  1330. a.ItemType = #{functionType}
  1331. and a.site = #{site} and a.bu_no = #{buNo}
  1332. AND b.code_no is null
  1333. <if test = "itemNo != null and itemNo != ''">
  1334. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1335. </if>
  1336. <if test = "itemDesc != null and itemDesc != ''">
  1337. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1338. </if>
  1339. </where>
  1340. </select>
  1341. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1342. select
  1343. a.site,
  1344. a.bu_no,
  1345. a.properties_item_no itemNo,
  1346. b.ItemDesc,
  1347. b.ItemRemark
  1348. from eam_properties_model_detail a
  1349. 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
  1350. where a.site = #{site} and a.bu_no = #{buNo} and a.code_no = #{codeNo}
  1351. and a.function_type = #{functionType}
  1352. </select>
  1353. <delete id="deleteObjectFile">
  1354. delete from sys_oss where id = #{id}
  1355. </delete>
  1356. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1357. SELECT id, url, create_date, file_name, new_file_name, created_by,
  1358. order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1359. FROM sys_oss
  1360. WHERE order_ref2 = #{orderNo}
  1361. AND order_ref1 = #{site}
  1362. AND order_ref3 = 'reportSparPart'
  1363. </select>
  1364. <!-- 获取机修人员列表 -->
  1365. <select id="getOperatorList" resultType="EamAdminData" parameterType="EamAdminData">
  1366. SELECT
  1367. ea.AdminID,
  1368. ea.AdminName,
  1369. ea.Phone,
  1370. dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName,
  1371. ea.Email,
  1372. ea.Tel,
  1373. ea.LevelID,
  1374. eal.AdminLevelDesc,
  1375. ea.MesUser,
  1376. ea.Active,
  1377. ea.CreatedDate
  1378. FROM eam_admin as ea
  1379. LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1380. <where>
  1381. ea.Active = 'Y'
  1382. AND ea.Site = #{site}
  1383. <if test = "adminID != null and adminID != ''">
  1384. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1385. </if>
  1386. <if test = "adminName != null and adminName != ''">
  1387. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1388. </if>
  1389. </where>
  1390. </select>
  1391. <!-- 获取审核人员列表 -->
  1392. <select id="getCheckerList" resultType="EamAdminData" parameterType="EamAdminData">
  1393. SELECT
  1394. a.user_id,
  1395. a.username as adminID,
  1396. a.email,
  1397. a.mobile as phone,
  1398. a.user_display as adminName
  1399. FROM sys_user as a
  1400. LEFT JOIN eam_access_site as b on a.username = b.username
  1401. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  1402. <where>
  1403. b.site = #{site} and c.bu_no = #{buNo}
  1404. <if test = "adminID != null and adminID != ''">
  1405. AND a.username LIKE '%' + #{adminID}+'%'
  1406. </if>
  1407. <if test = "adminName != null and adminName != ''">
  1408. AND a.user_display LIKE '%' + #{adminName}+'%'
  1409. </if>
  1410. </where>
  1411. </select>
  1412. <!-- 点检工单审核 -->
  1413. <update id="checkWorkOrder" parameterType="EamWorkOrderInData">
  1414. UPDATE eam_workOrder
  1415. SET Status = '已完工'
  1416. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1417. </update>
  1418. <update id="cancelCheckWorkOrder" parameterType="EamWorkOrderInData">
  1419. UPDATE eam_workOrder
  1420. SET Status = '待审核'
  1421. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1422. </update>
  1423. <!-- 查看点检工单状态 -->
  1424. <select id="checkWorkOrderStatus" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1425. SELECT
  1426. OrderNo
  1427. FROM eam_workOrder
  1428. WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' and bu_no = #{buNo}
  1429. </select>
  1430. <!-- 点检工单审核 -->
  1431. <update id="updateWorkPlanOverviewStatus" parameterType="EamWorkOrderInData">
  1432. UPDATE eam_workPlan_overview
  1433. SET status = '已结束'
  1434. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1435. </update>
  1436. <!-- 新增点检计划 -->
  1437. <insert id="saveWorkPlan" parameterType="EamWorkPlanInData">
  1438. INSERT INTO eam_workPlan_overview
  1439. (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)
  1440. 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})
  1441. </insert>
  1442. <!-- 生成工单ID -->
  1443. <select id="selectOrderId" resultType="string" parameterType="EamWorkPlanInData">
  1444. SELECT
  1445. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1446. FROM eam_workPlan
  1447. WHERE site = #{site} AND FunctionType = #{functionType} and bu_no = #{buNo}
  1448. </select>
  1449. <!-- 查询计划中的设备列表 -->
  1450. <select id="getPlanDetailList" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1451. SELECT
  1452. ewp.PlanID,
  1453. ewp.PlanDesc,
  1454. ewp.ObjectID,
  1455. eo.ObjectDesc,
  1456. eo.FamilyID,
  1457. ef.FamilyDesc,
  1458. eo.LocationID,
  1459. el.LocationName
  1460. FROM eam_workPlan as ewP
  1461. LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site and ewP.bu_no = eo.bu_no
  1462. LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site and ewP.bu_no = ef.bu_no
  1463. LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site and ewP.bu_no = el.bu_no
  1464. <where>
  1465. ewP.site = #{site} and ewP.bu_no = #{buNo}
  1466. AND ewp.PlanID = #{planID}
  1467. <if test = "objectID != null and objectID != ''">
  1468. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  1469. </if>
  1470. <if test = "objectDesc != null and objectDesc != ''">
  1471. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  1472. </if>
  1473. </where>
  1474. </select>
  1475. <!-- 删除计划中的设备 -->
  1476. <delete id="delPlanDetail" parameterType="WorkPlanDetailData">
  1477. DELETE FROM eam_workPlan
  1478. WHERE Site = #{site}
  1479. AND PlanID = #{planID}
  1480. AND ObjectID = #{objectID}
  1481. </delete>
  1482. <!-- 获取当前计划不包含的设备 -->
  1483. <select id="getObjList1" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1484. SELECT
  1485. a.ObjectID,
  1486. a.ObjectDesc,
  1487. a.FamilyID,
  1488. ef.FamilyDesc,
  1489. a.LocationID,
  1490. el.LocationName
  1491. FROM eam_object a
  1492. 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
  1493. LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1494. LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1495. WHERE a.site = #{site} and a.bu_no = #{buNo} and b.PlanID is null
  1496. </select>
  1497. <!-- 获取当前计划包含的设备 -->
  1498. <select id="getObjList2" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1499. SELECT
  1500. a.ObjectID,
  1501. b.ObjectDesc,
  1502. b.FamilyID,
  1503. ef.FamilyDesc,
  1504. b.LocationID,
  1505. el.LocationName
  1506. FROM eam_workPlan a
  1507. LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1508. LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1509. LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1510. WHERE a.PlanID = #{planID} and a.site = #{site} and a.bu_no = #{buNo}
  1511. </select>
  1512. <!-- 添加计划设备 -->
  1513. <insert id="addObject" parameterType="EamWorkPlanInData">
  1514. INSERT INTO eam_workPlan
  1515. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  1516. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  1517. </insert>
  1518. <!-- 修改工单计划 -->
  1519. <update id="updateWorkPlan" parameterType="EamWorkPlanInData">
  1520. UPDATE eam_workPlan_overview
  1521. SET plan_desc = #{planDesc},
  1522. properties_code = #{propertiesCode},
  1523. plan_start_date = #{planStartDate},
  1524. plan_end_date = #{planEndDate},
  1525. plan_period = #{planPeriod},
  1526. remark = #{remark},
  1527. operator = #{operator},
  1528. operator_name = #{operatorName},
  1529. checker = #{checker},
  1530. checker_name = #{checkerName},
  1531. work_order_rule = #{workOrderRule},
  1532. task_start_date = #{taskStartDate},
  1533. plan_cycle = #{planCycle},
  1534. plan_halt_date = #{planHaltDate},
  1535. auto_renewal = #{autoRenewal}
  1536. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1537. </update>
  1538. <!-- 删除该计划的旧设备 -->
  1539. <delete id="delWorkPlanObject" parameterType="EamWorkPlanInData">
  1540. DELETE FROM eam_workPlan
  1541. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1542. </delete>
  1543. <!-- 删除该计划的旧设备item -->
  1544. <delete id="delWorkPlanItem" parameterType="EamWorkPlanInData">
  1545. DELETE FROM eam_workPlan_item
  1546. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1547. </delete>
  1548. <!-- 删除该计划的旧设备itemAvailable-->
  1549. <delete id="delWorkPlanItemAvailable">
  1550. DELETE FROM eam_workPlan_item_available
  1551. WHERE Site = #{site}
  1552. AND PlanID = #{planID}
  1553. AND ObjectID = #{objectID}
  1554. </delete>
  1555. <!-- 查询该计划的设备 -->
  1556. <select id="planObjectSearch" resultType="EamWorkPlanItemData" parameterType="EamWorkPlanItemData">
  1557. SELECT DISTINCT
  1558. a.ObjectID,
  1559. b.ObjectDesc
  1560. FROM eam_workPlan_item as a
  1561. LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1562. WHERE a.Site = #{site} AND a.PlanID = #{planID} and a.bu_no = #{buNo}
  1563. </select>
  1564. <!-- 修改该计划状态 -->
  1565. <update id="updateOverviewStatus" parameterType="EamWorkPlanInData">
  1566. UPDATE eam_workPlan_overview
  1567. SET status = '进行中',
  1568. next_work_date = plan_start_date
  1569. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1570. </update>
  1571. <!-- 查询文件路径 -->
  1572. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1573. SELECT
  1574. id,
  1575. url,
  1576. file_name
  1577. FROM sys_oss WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} and order_ref4 = #{buNo}
  1578. </select>
  1579. <!-- 新增子明细信息 -->
  1580. <insert id="saveOperator" parameterType="EamWorkOrderInData">
  1581. INSERT INTO eam_actual_operator
  1582. (site, order_no, function_type, operator, bu_no)
  1583. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
  1584. </insert>
  1585. <!-- AND Status = '已完工' AND PlanOperator is not null-->
  1586. <!-- 查询实际维修人员 -->
  1587. <select id="getActualOperatorList2" resultType="EamAdminData">
  1588. SELECT
  1589. ea.AdminID,
  1590. ea.AdminName
  1591. FROM eam_actual_operator as eao
  1592. LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site
  1593. LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo
  1594. WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID}
  1595. </select>
  1596. <!-- 查询实际维修人员 -->
  1597. <select id="getActualOperatorList" resultType="EamAdminData">
  1598. SELECT
  1599. ea.username as adminID,
  1600. ea.user_display as AdminName
  1601. FROM eam_actual_operator as eao
  1602. LEFT JOIN sys_user as ea ON eao.operator = ea.username
  1603. WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} and eao.bu_no = #{buNo}
  1604. </select>
  1605. <!-- 查询设备所属部门 -->
  1606. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  1607. SELECT ved.department_name
  1608. FROM eam_object as eo
  1609. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  1610. WHERE eo.site = #{site}
  1611. AND eo.ObjectID = #{objectID}
  1612. </select>
  1613. <!-- 查询用户所属部门 -->
  1614. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  1615. SELECT AdminID
  1616. FROM eam_admin
  1617. WHERE site = #{site}
  1618. AND MesUser = #{username}
  1619. </select>
  1620. <!-- &lt;!&ndash; 查询部门列表 &ndash;&gt;-->
  1621. <!-- <select id="getDeptList" resultType="string" parameterType="string">-->
  1622. <!-- SELECT-->
  1623. <!-- ved.department_name-->
  1624. <!-- FROM eam_admin_dept as ead-->
  1625. <!-- LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id-->
  1626. <!-- LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID-->
  1627. <!-- WHERE ead.site = #{site} AND ea.MesUser = #{username}-->
  1628. <!-- </select>-->
  1629. <!-- 查询部门列表 -->
  1630. <select id="getDeptList" resultType="string" parameterType="string">
  1631. SELECT
  1632. distinct c.department_name
  1633. from sys_user as a
  1634. left join Access_dept as b on a.username = b.username
  1635. left join sys_department as c on c.site in (select site from eam_access_site where username = #{username})
  1636. and (c.site + '-' + c.bu_no) in (select * from dbo.query_bu(#{userName}))
  1637. and b.department_id = c.department_id
  1638. where a.username = #{username}
  1639. </select>
  1640. <!-- 生成新的维修工单 -->
  1641. <insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData">
  1642. INSERT INTO eam_workOrder
  1643. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no, document_source)
  1644. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource})
  1645. </insert>
  1646. <!-- 创建count表 -->
  1647. <insert id="saveDefectRecordCount2" parameterType="EamWorkOrderInData">
  1648. INSERT INTO eam_workOrder_count
  1649. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no)
  1650. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo})
  1651. </insert>
  1652. <!-- 获取旧工单的基础信息 -->
  1653. <select id="queryOldWorkOrderMessage" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1654. select
  1655. PlanOperator,
  1656. PlanOperatorName,
  1657. checker,
  1658. checkerName
  1659. from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1660. </select>
  1661. <!-- 生成新的维保工单 -->
  1662. <insert id="saveMaintenanceWorkOrder" parameterType="EamWorkOrderInData">
  1663. INSERT INTO eam_workOrder
  1664. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1665. VALUES (#{site}, #{buNo}, (select 'W' + Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) from eam_workOrder where site = #{site} and FunctionType = 'B' and bu_no = #{buNo}),
  1666. #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  1667. </insert>
  1668. <!-- 检查系统操作人和审核人员是否一致 -->
  1669. <select id="selectNameByMes" resultType="EamAdminData" parameterType="EamAdminData">
  1670. SELECT AdminName
  1671. FROM eam_admin
  1672. WHERE site = #{site}
  1673. AND MesUser = #{mesUser}
  1674. </select>
  1675. <!-- 维修审核确认 -->
  1676. <update id="submitDefect" parameterType="EamWorkOrderInData">
  1677. UPDATE eam_workOrder
  1678. SET Status = #{status},
  1679. difficulty_level = #{difficultyLevel},
  1680. difficulty_remark = #{difficultyRemark}
  1681. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1682. </update>
  1683. <!-- 查询设备的点检和维保历史记录 -->
  1684. <select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1685. SELECT
  1686. top 10
  1687. ewo.OrderNo,
  1688. ewo.PlanID,
  1689. ewo.PlanDesc,
  1690. ewo.ActualDate,
  1691. ewo.ObjectID,
  1692. eo.ObjectDesc,
  1693. ewo.Remark,
  1694. dbo.eam_Get_eamAdminName(ewo.site,ewo.ActualOperator) ActualOperatorName,
  1695. ewo.checkResult
  1696. FROM eam_workOrder as ewo
  1697. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1698. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND ewo.Status = '已完工' and ewo.bu_no = #{buNo}
  1699. ORDER BY ewo.ActualDate desc
  1700. </select>
  1701. <!-- 查询设备的维修历史记录 -->
  1702. <select id="queryDefectHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1703. SELECT
  1704. top 10
  1705. ewo.OrderNo,
  1706. ewo.PlanID,
  1707. ewo.PlanDesc,
  1708. ewo.ActualDate,
  1709. ewo.Remark,
  1710. ewo.Result,
  1711. ewo.disposal_measures,
  1712. ed.DefectDesc,
  1713. ewo.WorkTime
  1714. FROM eam_workOrder as ewo
  1715. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1716. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID and ewo.bu_no = edf.bu_no
  1717. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  1718. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND ewo.Status = '已完工' and ewo.bu_no = #{buNo} ORDER BY ewo.ActualDate desc
  1719. </select>
  1720. <!-- 查询部门列表 -->
  1721. <select id="getEmpyDeptList" resultType="EmpyDept" parameterType="EmpyDept">
  1722. SELECT
  1723. site,
  1724. department_id as deptId,
  1725. department_name as deptName
  1726. FROM sys_department
  1727. <where>
  1728. site in (select site from eam_access_site where username = #{userName})
  1729. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  1730. <if test = "deptId != null and deptId != ''">
  1731. AND department_id LIKE '%' + #{deptId}+'%'
  1732. </if>
  1733. <if test = "deptName != null and deptName != ''">
  1734. AND department_name LIKE '%' + #{deptName}+'%'
  1735. </if>
  1736. </where>
  1737. </select>
  1738. <!-- 生成新的维修工单 -->
  1739. <insert id="saveAdminDepartment">
  1740. INSERT INTO eam_admin_dept
  1741. (Site, admin_id, dept_id)
  1742. VALUES (#{site}, #{adminID}, #{deptId})
  1743. </insert>
  1744. <!-- 查询部门详情 -->
  1745. <select id="getDeptDetail" resultType="EamAdminData" parameterType="string">
  1746. SELECT
  1747. ved.department_id as department,
  1748. ved.department_name as departmentName
  1749. FROM eam_admin_dept as ead
  1750. 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
  1751. WHERE ead.site in (select site from eam_access_site where username = #{userName})
  1752. and (ead.site + '-' + ead.bu_no) in (select * from dbo.query_bu(#{userName}))
  1753. AND ead.admin_id = #{adminID}
  1754. </select>
  1755. <!-- 删除旧数据-->
  1756. <delete id="deleteAdminDepartment">
  1757. DELETE FROM eam_admin_dept
  1758. WHERE site = #{site}
  1759. AND admin_id = #{adminID}
  1760. </delete>
  1761. <!-- 获取可用的MES账号 -->
  1762. <select id="getMesList" resultType="SysUserEntity" parameterType="SysUserEntity">
  1763. SELECT
  1764. a.username,
  1765. a.user_display
  1766. FROM sys_user a
  1767. LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site
  1768. WHERE a.site = #{site}
  1769. AND b.MesUser is null
  1770. </select>
  1771. <!-- 查询点检项目 -->
  1772. <select id="eamPropertiesItemSearch" parameterType="EamPropertiesItemData" resultType="EamPropertiesItemData">
  1773. SELECT
  1774. site,
  1775. bu_no,
  1776. dbo.get_bu_desc(site, bu_no) as buDesc,
  1777. ItemNo,
  1778. ItemDesc,
  1779. DefaultValue,
  1780. ValueType,
  1781. ValueType_DB as valueTypeDb,
  1782. ValueChooseFlag,
  1783. CreatedDate,
  1784. CreatedBy,
  1785. update_date,
  1786. update_by,
  1787. MaxValue,
  1788. MinValue,
  1789. ItemRemark,
  1790. ItemType,
  1791. image_flag,
  1792. produce_control_flag
  1793. FROM eam_properties_item
  1794. <where>
  1795. site in (select site from eam_access_site where username = #{query.userName})
  1796. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1797. and ItemType = #{query.itemType}
  1798. <if test="query.itemNo != null and query.itemNo != ''">
  1799. AND ItemNo LIKE '%' + #{query.itemNo}+'%'
  1800. </if>
  1801. <if test="query.itemDesc != null and query.itemDesc != ''">
  1802. AND ItemDesc LIKE '%' + #{query.itemDesc}+'%'
  1803. </if>
  1804. </where>
  1805. </select>
  1806. <!-- 删除图片-->
  1807. <delete id="imageDelete" parameterType="SysOssEntity">
  1808. DELETE FROM sys_oss
  1809. WHERE id = #{id}
  1810. </delete>
  1811. <!-- 检查该日期内是否已有该设备的计划 -->
  1812. <select id="checkObjectPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1813. SELECT
  1814. a.PlanID,
  1815. a.ObjectID
  1816. FROM eam_workPlan a
  1817. 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
  1818. WHERE a.site = #{site} and a.bu_no = #{buNo}
  1819. AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N'
  1820. AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  1821. or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  1822. or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0)
  1823. )
  1824. and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod}
  1825. and b.Status not in ('已取消','已完成','待审核')
  1826. </select>
  1827. <!-- 查询当前计划 -->
  1828. <select id="queryWorkPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1829. SELECT
  1830. site,
  1831. bu_no,
  1832. plan_id,
  1833. plan_desc,
  1834. properties_code,
  1835. #{objectID} as objectID,
  1836. status,
  1837. operator,
  1838. delete_flag,
  1839. plan_start_date,
  1840. plan_end_date,
  1841. plan_period,
  1842. function_type,
  1843. checker,
  1844. checker_name,
  1845. operator_name,
  1846. work_order_rule,
  1847. plan_cycle
  1848. FROM eam_workPlan_overview
  1849. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1850. </select>
  1851. <!-- 获得工单号 -->
  1852. <select id="queryPlanOrderNo" resultType="string" parameterType="EamWorkPlanInData">
  1853. SELECT
  1854. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  1855. FROM eam_workOrder
  1856. WHERE site = #{site} and bu_no = #{buNo} AND FunctionType = #{functionType}
  1857. </select>
  1858. <!-- 新增工单 -->
  1859. <insert id="insertWorkOrder" parameterType="EamWorkPlanInData">
  1860. INSERT INTO eam_workOrder
  1861. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1862. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1863. </insert>
  1864. <!-- 循环新增工单 -->
  1865. <insert id="forInsertWorkOrder" parameterType="EamWorkPlanInData">
  1866. INSERT INTO eam_workOrder
  1867. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1868. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1869. </insert>
  1870. <!-- 更改plan表的状态为进行中 -->
  1871. <update id="updatePlanStatus" parameterType="EamWorkPlanInData">
  1872. update eam_workPlan
  1873. set status = '进行中',
  1874. NextWorkDate = PlanStartDate
  1875. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1876. </update>
  1877. <!-- 获得工单号 -->
  1878. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="EamWorkOrderItemInData">
  1879. SELECT
  1880. id,
  1881. file_name
  1882. FROM sys_oss
  1883. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  1884. </select>
  1885. <!-- 删除原来工单项目-->
  1886. <delete id="deleteWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1887. DELETE FROM eam_workPlan_item
  1888. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1889. </delete>
  1890. <!-- 删除原来的可选值-->
  1891. <delete id="deleteWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1892. DELETE FROM eam_workPlan_item_available
  1893. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1894. </delete>
  1895. <!-- 添加新项目 -->
  1896. <insert id="saveWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1897. 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)
  1898. select
  1899. #{site},
  1900. #{buNo},
  1901. #{planID},
  1902. #{objectID},
  1903. a.ItemNo,
  1904. a.ItemDesc,
  1905. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  1906. case when c.site is not null then c.ValueType else a.ValueType end,
  1907. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  1908. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  1909. case when c.site is not null then c.MaxValue else a.MaxValue end,
  1910. case when c.site is not null then c.MinValue else a.MinValue end,
  1911. a.ItemRemark,
  1912. a.ItemType,
  1913. GetDate(),
  1914. #{userId},
  1915. a.image_flag,
  1916. a.produce_control_flag
  1917. from eam_properties_item a
  1918. 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
  1919. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  1920. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  1921. </insert>
  1922. <!-- 添加新项目可选值 -->
  1923. <insert id="saveWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1924. INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  1925. SELECT DISTINCT
  1926. #{site},
  1927. #{buNo},
  1928. #{planID},
  1929. #{objectID},
  1930. a.ItemNo,
  1931. a.ItemType,
  1932. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  1933. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  1934. GetDate(),
  1935. #{userId}
  1936. FROM eam_properties_item_available a
  1937. 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
  1938. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  1939. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  1940. </insert>
  1941. <!-- 检查维修任务号是否已存在 -->
  1942. <select id="getEamGzData" resultType="EamDefectFeedBackData" parameterType="EamDefectFeedBackData">
  1943. select
  1944. a.Site,
  1945. a.bu_no,
  1946. a.FeedBackID,
  1947. a.FeedBackDesc,
  1948. a.ObjectID,
  1949. a.Status
  1950. from eam_defect_feedBack a
  1951. left join eam_defect b on a.DefectID = b.DefectID
  1952. <where>
  1953. a.site = #{site} and a.deleteFlag = 'N' and a.bu_no = #{buNo}
  1954. <if test="feedBackID != null and feedBackID != ''">
  1955. AND a.FeedBackID LIKE '%' + #{feedBackID}+'%'
  1956. </if>
  1957. <if test="feedBackDesc != null and feedBackDesc != ''">
  1958. AND a.FeedBackDesc LIKE '%' + #{feedBackDesc}+'%'
  1959. </if>
  1960. <if test="objectInfo != null and objectInfo != ''">
  1961. AND (a.ObjectID like '%' + #{objectInfo} + '%' or dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) like '%' + #{objectInfo} + '%')
  1962. </if>
  1963. <if test="defectInfo != null and defectInfo != ''">
  1964. AND (a.DefectID like '%' + #{defectInfo} + '%' or b.defectDesc like '%' + #{defectInfo} + '%')
  1965. </if>
  1966. </where>
  1967. </select>
  1968. <!-- 保存故障信息 -->
  1969. <insert id="saveEamGzBbData" parameterType="EamDefectFeedBackData">
  1970. INSERT INTO eam_defect_feedBack
  1971. (Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate, Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency)
  1972. VALUES (#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate}, #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency})
  1973. </insert>
  1974. <!-- 查看现场动控是否开启 -->
  1975. <select id="selectControlBaseData" resultType="SysSceneDynamicControlModelEntity" parameterType="string">
  1976. SELECT
  1977. type,
  1978. base_data,
  1979. base_desc,
  1980. status,
  1981. remark,
  1982. third_type,
  1983. second_type,
  1984. page_control,
  1985. control_style
  1986. FROM sys_scene_dynamic_control_model
  1987. where site = #{site} and control_no = #{controlNo}
  1988. </select>
  1989. <!-- 修改反馈状态为已下达 -->
  1990. <update id="updateDefectFeedBackStatus" parameterType="EamDefectFeedBackData">
  1991. UPDATE eam_defect_feedBack
  1992. SET Status = '已下达'
  1993. WHERE Site = #{site} AND FeedBackID = #{feedBackID} and bu_no = #{buNo}
  1994. </update>
  1995. <!-- 查询工单号 -->
  1996. <select id="getOrderNo" resultType="string" parameterType="EamWorkOrderInData">
  1997. select
  1998. 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  1999. from eam_workOrder
  2000. where site = #{site} and FunctionType = 'C' and bu_no = #{buNo}
  2001. </select>
  2002. <!-- 创建维修工单 -->
  2003. <insert id="saveWorkOrder" parameterType="EamDefectFeedBackData">
  2004. INSERT INTO eam_workOrder
  2005. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source)
  2006. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource})
  2007. </insert>
  2008. <!-- 创建维修count表数据 -->
  2009. <insert id="saveDefectRecordCount" parameterType="EamDefectFeedBackData">
  2010. INSERT INTO eam_workOrder_count
  2011. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc)
  2012. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc})
  2013. </insert>
  2014. <!-- 修改工单 -->
  2015. <update id="updateWorkOrder" parameterType="EamWorkOrderInData">
  2016. update eam_workOrder
  2017. set update_by = #{mesUser},
  2018. update_date = GetDate(),
  2019. Remark = #{remark},
  2020. <if test='functionType == "B"'>
  2021. reach_date = #{reachDate},
  2022. ActualDate = #{actualDate},
  2023. WorkTime = CASE WHEN (DATEDIFF(SECOND, #{reachDate}, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 60.0
  2024. ELSE ceiling(floor(DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 30) / 2)
  2025. END,
  2026. </if>
  2027. <if test='functionType == "A"'>
  2028. WorkTime = #{workTime},
  2029. </if>
  2030. <if test='functionType == "B" and checkResult == "合格"'>
  2031. disposal_measures = '',
  2032. </if>
  2033. <if test='functionType == "B" and checkResult == "异常"'>
  2034. disposal_measures = #{disposalMeasures},
  2035. </if>
  2036. checkResult = #{checkResult},
  2037. check_remark = #{checkRemark},
  2038. fault_reason = #{faultReason},
  2039. preventive_measure = #{preventiveMeasure}
  2040. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  2041. </update>
  2042. <!-- 修改工单项目 -->
  2043. <update id="updateWorkOrderItem" parameterType="EamWorkOrderItemInData">
  2044. update eam_workOrder_item
  2045. set update_by = #{updateBy},
  2046. update_date = GetDate(),
  2047. <if test='valueTypeDb == "T"'>
  2048. TextValue = #{textValue},
  2049. </if>
  2050. <if test='valueTypeDb == "N"'>
  2051. NumberValue = #{numberValue},
  2052. </if>
  2053. itemResult = #{itemResult}
  2054. where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
  2055. </update>
  2056. <!-- 删除之前的协同人员-->
  2057. <delete id="delOperator" parameterType="EamWorkOrderInData">
  2058. DELETE FROM eam_actual_operator
  2059. WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
  2060. </delete>
  2061. <!-- 到达 -->
  2062. <update id="reach" parameterType="EamWorkOrderInData">
  2063. update eam_workOrder
  2064. set Status = #{status},
  2065. reach_date = GetDate(),
  2066. reach_operator = #{reachOperator},
  2067. reach_operator_name = #{reachOperatorName}
  2068. where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType}
  2069. </update>
  2070. <!-- 查询是否已经上传图片 -->
  2071. <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2072. SELECT
  2073. id
  2074. FROM sys_oss
  2075. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo}
  2076. </select>
  2077. <!-- 查询文件路径 -->
  2078. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2079. SELECT
  2080. id,
  2081. url,
  2082. file_name
  2083. FROM sys_oss
  2084. WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2085. </select>
  2086. <!-- 根据工单号查询知识库记录 -->
  2087. <select id="selectKnowledgeRecordByOrderNo" resultType="EamKnowledgeBaseData" parameterType="EamWorkOrderInData">
  2088. SELECT
  2089. site,
  2090. bu_no,
  2091. num
  2092. FROM eam_knowledge_base
  2093. WHERE site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2094. </select>
  2095. <!-- 根据工单号修改知识库记录 -->
  2096. <update id="updateKnowledgeRecordByOrderNo" parameterType="EamWorkOrderInData">
  2097. update eam_knowledge_base
  2098. set update_date = getDate(),
  2099. update_by = #{updateBy}
  2100. where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2101. </update>
  2102. <!-- 新增设备知识库记录 -->
  2103. <insert id="saveKnowledgeRecord" parameterType="EamWorkOrderInData">
  2104. INSERT INTO eam_knowledge_base
  2105. (site, bu_no, num, file_type, defect_describe, disposal_measures, create_date, create_by, object_id, defect_id, order_no)
  2106. 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})
  2107. </insert>
  2108. <!-- 修改反馈状态为已取消 -->
  2109. <update id="updateFeedBackStatus" parameterType="EamWorkOrderInData">
  2110. UPDATE eam_defect_feedBack
  2111. SET Status = '已取消'
  2112. WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
  2113. </update>
  2114. <!-- 获取所有分类 -->
  2115. <select id="getFamilyTree" resultType="EamFamilyData" parameterType="EamFamilyData">
  2116. SELECT
  2117. site,
  2118. bu_no,
  2119. FamilyID,
  2120. FamilyDesc,
  2121. parent_id,
  2122. son_id,
  2123. Active
  2124. FROM eam_family
  2125. WHERE site in (select site from eam_access_site where username = #{userName})
  2126. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2127. and Active = 'Y'
  2128. </select>
  2129. <!-- 获得sonId -->
  2130. <select id="getSonId" resultType="string" parameterType="EamFamilyData">
  2131. SELECT
  2132. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2)
  2133. FROM eam_family
  2134. WHERE site = #{site} and bu_no = #{buNo} and son_id like #{parentId} + '%'
  2135. </select>
  2136. <!-- 删除该分类以及其子类-->
  2137. <delete id="eamFamilyDelete" parameterType="EamFamilyData">
  2138. DELETE FROM eam_family
  2139. WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID} and son_id like #{sonId} + '%'
  2140. </delete>
  2141. <select id="getEamWorkOrder" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  2142. EXEC EAM_WORK_ORDER #{site}, #{username}, #{orderNo}, #{planID}, #{objectID}, #{status}, #{startDate}, #{endDate}, #{functionType}, '*'
  2143. </select>
  2144. <!-- 修改执行结果 -->
  2145. <update id="updateReportResult" parameterType="EamWorkOrderInData">
  2146. update eam_workOrder
  2147. set ActualDate = #{actualDate},
  2148. reach_date = #{reachDate},
  2149. fault_reason = #{faultReason},
  2150. handling_method = #{handlingMethod},
  2151. preventive_measure = #{preventiveMeasure},
  2152. Remark = #{remark},
  2153. WorkTime = CASE
  2154. WHEN (DATEDIFF(SECOND, #{reachDate}, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 60.0
  2155. ELSE ceiling(floor(DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 30) / 2)
  2156. END
  2157. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2158. </update>
  2159. <!-- 根据设备查所属部门 -->
  2160. <select id="queryDepartmentByObjectId" resultType="EamObjectAdminData" parameterType="EamDefectFeedBackData">
  2161. SELECT
  2162. eo.site,
  2163. eo.bu_no,
  2164. eo.ObjectDesc,
  2165. eo.dept_id,
  2166. el.LocationName
  2167. FROM eam_object as eo
  2168. LEFT JOIN eam_location as el on eo.site = el.site and eo.LocationID = el.LocationID and eo.bu_no = el.bu_no
  2169. WHERE eo.site = #{site} and eo.ObjectID = #{objectID} and eo.bu_no = #{buNo}
  2170. </select>
  2171. <!-- 根据部门ID查机修人员电话 -->
  2172. <select id="queryPhoneByDepartmentId" resultType="EamObjectAdminData" parameterType="EamObjectAdminData">
  2173. SELECT
  2174. ed.user_display as adminName,
  2175. ed.mobile as phone
  2176. FROM Access_dept as edd
  2177. LEFT JOIN sys_user ed on edd.username = ed.username and edd.site in (select site from eam_access_site where username = ed.username)
  2178. and (edd.site + '-' + edd.bu_no) in (select * from dbo.query_bu(ed.username))
  2179. WHERE edd.site = #{site} and edd.department_id = #{deptId} and edd.bu_no = #{buNo}
  2180. </select>
  2181. <!-- 保存短信记录 -->
  2182. <insert id="saveMessageRecord" parameterType="MessageRecordData">
  2183. INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
  2184. VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
  2185. </insert>
  2186. <!-- 查出计划结束日期为今天并且自动续期标识为Y的计划 -->
  2187. <select id="selectPlanToday" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  2188. SELECT
  2189. site,
  2190. plan_id,
  2191. plan_desc,
  2192. status,
  2193. plan_start_date,
  2194. plan_end_date,
  2195. created_date,
  2196. created_by,
  2197. update_date,
  2198. update_by,
  2199. remark,
  2200. next_work_date,
  2201. delete_flag,
  2202. operator,
  2203. operator_name,
  2204. checker,
  2205. checker_name,
  2206. function_type,
  2207. properties_code,
  2208. plan_period,
  2209. work_order_rule,
  2210. plan_cycle,
  2211. task_start_date,
  2212. plan_halt_date,
  2213. auto_renewal
  2214. FROM eam_workPlan_overview
  2215. WHERE site = #{site} and status != #{status} and delete_flag = #{deleteFlag} and DATEDIFF(day, plan_end_date, getdate()) = 0 and auto_renewal = #{autoRenewal}
  2216. </select>
  2217. <!-- 查出老计划的设备 -->
  2218. <select id="selectObjectByPlanID" resultType="EamObjectInData" parameterType="EamWorkPlanInData">
  2219. SELECT
  2220. Site,
  2221. PlanID,
  2222. PlanDesc,
  2223. ObjectID,
  2224. FunctionType,
  2225. PropertiesCode,
  2226. Status
  2227. FROM eam_workPlan
  2228. WHERE site = #{site} and PlanID = #{planID} and FunctionType = #{functionType}
  2229. </select>
  2230. <!-- 获取用户 bu -->
  2231. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  2232. SELECT
  2233. a.site,
  2234. c.sitename,
  2235. (a.site + '_' + a.bu_no) as buNo,
  2236. b.bu_desc
  2237. FROM AccessBu as a
  2238. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2239. left join site as c on a.site = c.siteid
  2240. WHERE a.username = #{username}
  2241. </select>
  2242. </mapper>