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.

3804 lines
170 KiB

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