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

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