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.

4689 lines
210 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
9 months ago
2 years ago
9 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 months ago
2 years ago
2 years ago
3 months ago
3 months ago
2 weeks ago
3 months ago
3 months ago
1 year ago
1 year ago
1 year ago
8 months ago
8 months ago
6 months ago
6 months ago
6 months ago
6 months ago
3 years ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xujie.sys.modules.pms.mapper.EamMapper">
  4. <select id="eamAdminSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminData" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  5. SELECT distinct
  6. ea.Site,
  7. ea.AdminID,
  8. ea.AdminName,
  9. ea.Phone,
  10. ea.Email,
  11. ea.Tel,
  12. ea.LevelID,
  13. eal.AdminLevelDesc,
  14. ea.MesUser,
  15. ea.Active,
  16. ea.CreatedDate,
  17. ea.created_by,
  18. ea.update_date,
  19. ea.update_by
  20. FROM eam_admin as ea
  21. LEFT JOIN eam_adminLevel as eal ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  22. left join eam_admin_dept as ead on ea.site = ead.site and ea.AdminID = ead.admin_id
  23. LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id
  24. <where>
  25. <if test="query.site != null and query.site != ''">
  26. AND ea.site = #{query.site}
  27. </if>
  28. <if test="query.adminID != null and query.adminID != ''">
  29. AND ea.adminID like '%' + #{query.adminID} +'%'
  30. </if>
  31. <if test="query.adminName != null and query.adminName != ''">
  32. AND ea.adminName like '%' + #{query.adminName}+'%'
  33. </if>
  34. <if test="query.departmentName != null and query.departmentName != ''">
  35. AND ved.department_name like '%' + #{query.departmentName}+'%'
  36. </if>
  37. <if test="query.active != null and query.active != ''">
  38. AND ea.active = #{query.active}
  39. </if>
  40. </where>
  41. </select>
  42. <select id="eamAdminSearch2" parameterType="com.xujie.sys.modules.pms.data.EamAdminData" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  43. SELECT distinct
  44. ea.Site,
  45. ea.bu_no,
  46. dbo.get_bu_desc(ea.Site, ea.bu_no) as buDesc,
  47. ea.AdminID,
  48. ea.AdminName,
  49. ea.Phone,
  50. ea.Email,
  51. ea.Tel,
  52. ea.LevelID,
  53. eal.AdminLevelDesc,
  54. ea.MesUser,
  55. ea.Active,
  56. ea.CreatedDate,
  57. ea.created_by,
  58. ea.update_date,
  59. ea.update_by
  60. FROM eam_admin as ea
  61. LEFT JOIN eam_adminLevel as eal ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site and ea.bu_no = eal.bu_no
  62. left join eam_admin_dept as ead on ea.site = ead.site and ea.AdminID = ead.admin_id and ea.bu_no = ead.bu_no
  63. LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id and ead.bu_no = ved.bu_no
  64. <where>
  65. ea.site in (select site from eam_access_site where username = #{userName})
  66. and (ea.site + '-' + ea.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  67. <if test="adminID != null and adminID != ''">
  68. AND ea.adminID like '%' + #{adminID} +'%'
  69. </if>
  70. <if test="adminName != null and adminName != ''">
  71. AND ea.adminName like '%' + #{adminName}+'%'
  72. </if>
  73. <if test="departmentName != null and departmentName != ''">
  74. AND ved.department_name like '%' + #{departmentName}+'%'
  75. </if>
  76. <if test="active != null and active != ''">
  77. AND ea.active = #{active}
  78. </if>
  79. </where>
  80. </select>
  81. <select id="eamFamilySearch" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData" resultType="com.xujie.sys.modules.pms.data.EamFamilyData">
  82. SELECT
  83. Site,
  84. bu_no,
  85. dbo.get_bu_desc(site, bu_no) as buDesc,
  86. FamilyID,
  87. FamilyDesc,
  88. Active,
  89. case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
  90. create_date,
  91. create_by,
  92. dbo.getOperatorDesc(site, create_by) as createByDesc,
  93. update_date,
  94. update_by,
  95. dbo.getOperatorDesc(site, update_by) as updateByDesc
  96. FROM eam_family
  97. <where>
  98. site in (select site from eam_access_site where username = #{query.userName})
  99. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  100. <if test="query.buDesc != null and query.buDesc != ''">
  101. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  102. </if>
  103. <if test="query.familyID != null and query.familyID != ''">
  104. AND familyID like '%' + #{query.familyID} +'%'
  105. </if>
  106. <if test="query.familyDesc != null and query.familyDesc != ''">
  107. AND familyDesc like '%' + #{query.familyDesc} +'%'
  108. </if>
  109. <if test="query.active != null and query.active != ''">
  110. AND active = #{query.active}
  111. </if>
  112. </where>
  113. </select>
  114. <select id="eamGroupSearch" parameterType="com.xujie.sys.modules.pms.data.EamGroupData" resultType="com.xujie.sys.modules.pms.data.EamGroupData">
  115. SELECT
  116. Site,
  117. bu_no,
  118. dbo.get_bu_desc(site, bu_no) as buDesc,
  119. GroupID,
  120. GroupDesc,
  121. Active,
  122. case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
  123. create_date,
  124. create_by,
  125. dbo.getOperatorDesc(site, create_by) as createByDesc,
  126. update_date,
  127. update_by,
  128. dbo.getOperatorDesc(site, update_by) as updateByDesc
  129. FROM eam_group
  130. <where>
  131. site in (select site from eam_access_site where username = #{query.userName})
  132. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  133. <if test="query.buDesc != null and query.buDesc != ''">
  134. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  135. </if>
  136. <if test="query.groupID != null and query.groupID != ''">
  137. AND groupID like '%' + #{query.groupID} + '%'
  138. </if>
  139. <if test="query.groupDesc != null and query.groupDesc != ''">
  140. AND groupDesc like '%' + #{query.groupDesc} + '%'
  141. </if>
  142. <if test="query.active != null and query.active != ''">
  143. AND active = #{query.active}
  144. </if>
  145. </where>
  146. </select>
  147. <select id="eamLocationSearch" parameterType="com.xujie.sys.modules.pms.data.EamLocationData" resultType="com.xujie.sys.modules.pms.data.EamLocationData">
  148. SELECT
  149. Site,
  150. bu_no,
  151. dbo.get_bu_desc(site, bu_no) as buDesc,
  152. LocationID,
  153. LocationName,
  154. Active,
  155. case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
  156. create_date,
  157. create_by,
  158. dbo.getOperatorDesc(site, create_by) as createByDesc,
  159. update_date,
  160. update_by,
  161. dbo.getOperatorDesc(site, update_by) as updateByDesc
  162. FROM eam_location
  163. <where>
  164. site in (select site from eam_access_site where username = #{query.userName})
  165. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  166. <if test="query.buDesc != null and query.buDesc != ''">
  167. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  168. </if>
  169. <if test="query.locationID != null and query.locationID != ''">
  170. AND locationID like '%' + #{query.locationID} +'%'
  171. </if>
  172. <if test="query.locationName != null and query.locationName != ''">
  173. AND locationName like '%' + #{query.locationName} +'%'
  174. </if>
  175. <if test="query.active != null and query.active != ''">
  176. AND active = #{query.active}
  177. </if>
  178. </where>
  179. </select>
  180. <select id="eamManufacturerSearch" parameterType="com.xujie.sys.modules.pms.data.EamManufacturerData" resultType="com.xujie.sys.modules.pms.data.EamManufacturerData">
  181. SELECT
  182. Site,
  183. bu_no,
  184. dbo.get_bu_desc(site, bu_no) as buDesc,
  185. ManufacturerID,
  186. ManufacturerName,
  187. Active,
  188. case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
  189. Contact,
  190. Phone,
  191. Address,
  192. Email,
  193. Remark,
  194. create_date,
  195. create_by,
  196. dbo.getOperatorDesc(site, create_by) as createByDesc,
  197. update_date,
  198. update_by,
  199. dbo.getOperatorDesc(site, update_by) as updateByDesc
  200. FROM eam_manufacturer
  201. <where>
  202. site in (select site from eam_access_site where username = #{query.userName})
  203. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  204. <if test="query.buDesc != null and query.buDesc != ''">
  205. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  206. </if>
  207. <if test="query.manufacturerID != null and query.manufacturerID != ''">
  208. AND manufacturerID like '%' + #{query.manufacturerID} +'%'
  209. </if>
  210. <if test="query.manufacturerName != null and query.manufacturerName != ''">
  211. AND manufacturerName like '%' + #{query.manufacturerName} +'%'
  212. </if>
  213. <if test="query.active != null and query.active != ''">
  214. AND active = #{query.active}
  215. </if>
  216. </where>
  217. </select>
  218. <select id="eamAdminLevelSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminLevelData" resultType="com.xujie.sys.modules.pms.data.EamAdminLevelData">
  219. SELECT
  220. Site,
  221. bu_no,
  222. dbo.get_bu_desc(site, bu_no) as buDesc,
  223. AdminLevelID,
  224. AdminLevelDesc,
  225. Active,
  226. case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
  227. create_date,
  228. create_by,
  229. dbo.getOperatorDesc(site, create_by) as createByDesc,
  230. update_date,
  231. update_by,
  232. dbo.getOperatorDesc(site, update_by) as updateByDesc
  233. FROM eam_adminLevel
  234. <where>
  235. site in (select site from eam_access_site where username = #{query.userName})
  236. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  237. <if test="query.buDesc != null and query.buDesc != ''">
  238. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  239. </if>
  240. <if test="query.adminLevelID != null and query.adminLevelID != ''">
  241. AND adminLevelID like '%' + #{query.adminLevelID} +'%'
  242. </if>
  243. <if test="query.adminLevelDesc != null and query.adminLevelDesc != ''">
  244. AND adminLevelDesc like '%' + #{query.adminLevelDesc}+'%'
  245. </if>
  246. <if test="query.active != null and query.active != ''">
  247. AND active = #{query.active}
  248. </if>
  249. </where>
  250. </select>
  251. <select id="eamSupplierSearch" parameterType="com.xujie.sys.modules.pms.data.EamSupplierData" resultType="com.xujie.sys.modules.pms.data.EamSupplierData">
  252. SELECT
  253. Site,
  254. bu_no,
  255. dbo.get_bu_desc(site, bu_no) as buDesc,
  256. SupplierID,
  257. SupplierName,
  258. [Group],
  259. Active,
  260. case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
  261. Contact,
  262. Phone,
  263. Address,
  264. Email,
  265. Remark,
  266. create_date,
  267. dbo.getOperatorDesc(site, create_by) as createByDesc,
  268. update_date,
  269. update_by,
  270. dbo.getOperatorDesc(site, update_by) as updateByDesc
  271. FROM eam_supplier
  272. <where>
  273. site in (select site from eam_access_site where username = #{query.userName})
  274. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  275. <if test="query.buDesc != null and query.buDesc != ''">
  276. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  277. </if>
  278. <if test="query.supplierID != null and query.supplierID != ''">
  279. AND supplierID like '%' + #{query.supplierID} +'%'
  280. </if>
  281. <if test="query.supplierName != null and query.supplierName != ''">
  282. AND supplierName like '%' + #{query.supplierName} +'%'
  283. </if>
  284. <if test="query.active != null and query.active != ''">
  285. AND active = #{query.active}
  286. </if>
  287. </where>
  288. </select>
  289. <select id="searchItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemAvailableData">
  290. SELECT
  291. site,
  292. bu_no,
  293. ItemNo,
  294. ValueNo,
  295. AvailableValue,
  296. CreatedDate,
  297. CreatedBy,
  298. ItemType
  299. from eam_properties_item_available
  300. where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  301. </select>
  302. <select id="getItemValueNo" resultType="Double">
  303. SELECT isnull( max(valueNo),0)+1 from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  304. </select>
  305. <select id="getItemValueNoForPlan" resultType="Double">
  306. SELECT isnull( max(valueNo),0)+1 from eam_workPlan_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and PlanID = #{planID} and bu_no = #{buNo}
  307. </select>
  308. <insert id="saveItemAvailable">
  309. insert into eam_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, site, bu_no)
  310. values(#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site}, #{buNo})
  311. </insert>
  312. <update id="updateItemAvailable">
  313. update eam_properties_item_available
  314. set AvailableValue = #{availableValue}
  315. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  316. </update>
  317. <delete id="deleteItemAvailable">
  318. delete from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  319. </delete>
  320. <select id="eamPropertiesModelSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  321. SELECT
  322. site,
  323. bu_no,
  324. dbo.get_bu_desc(site, bu_no) as buDesc,
  325. function_type,
  326. code_no,
  327. code_desc,
  328. active,
  329. case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
  330. created_date,
  331. created_by,
  332. dbo.getOperatorDesc(site, created_by) as createdByDesc,
  333. update_date,
  334. update_by,
  335. dbo.getOperatorDesc(site, update_by) as updateByDesc,
  336. delflag,
  337. version,
  338. CASE WHEN dbo.eam_model_is_use(site, function_type, code_no) > 0 THEN 'Y' else 'N' END as isUse,
  339. check_type
  340. FROM eam_properties_model_header
  341. <where>
  342. site in (select site from eam_access_site where username = #{query.userName})
  343. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  344. and check_type in (select role_no from access_role where username = #{query.userName})
  345. and function_type = #{query.functionType}
  346. <if test="query.buDesc != null and query.buDesc != ''">
  347. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  348. </if>
  349. <if test="query.codeNo != null and query.codeNo != ''">
  350. AND code_no like '%' + #{query.codeNo} +'%'
  351. </if>
  352. <if test="query.codeDesc != null and query.codeDesc != ''">
  353. AND code_desc like '%' + #{query.codeDesc} +'%'
  354. </if>
  355. <if test="query.active != null and query.active != ''">
  356. AND active = #{query.active}
  357. </if>
  358. <if test='query.isUse != null and query.isUse != "" and query.isUse == "Y"'>
  359. AND dbo.eam_model_is_use(site, function_type, code_no) > 0
  360. </if>
  361. <if test='query.isUse != null and query.isUse != "" and query.isUse == "N"'>
  362. AND dbo.eam_model_is_use(site, function_type, code_no) = 0
  363. </if>
  364. <if test="query.checkType != null and query.checkType != ''">
  365. AND check_type = #{query.checkType}
  366. </if>
  367. </where>
  368. </select>
  369. <insert id="eamPropertiesModelSave">
  370. insert into eam_properties_model_header
  371. (function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by, site, bu_no, check_type)
  372. values
  373. (#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy}, #{site}, #{buNo}, #{checkType})
  374. </insert>
  375. <update id="eamPropertiesModelEdit">
  376. update eam_properties_model_header
  377. set version = version + 1,
  378. code_desc = #{codeDesc},
  379. active = #{active},
  380. update_by = #{updateBy},
  381. update_date = GetDate()
  382. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  383. </update>
  384. <select id="checkPropertiesModel" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  385. SELECT
  386. function_type,
  387. code_no,
  388. code_desc,
  389. active,
  390. created_date,
  391. created_by,
  392. update_date,
  393. update_by,
  394. delflag,
  395. version
  396. FROM eam_properties_model_header
  397. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  398. </select>
  399. <delete id="deleteModelDetail">
  400. delete from eam_properties_model_detail
  401. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  402. </delete>
  403. <delete id="eamPropertiesModelDelete" >
  404. delete from eam_properties_model_header where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  405. </delete>
  406. <select id="searchModalDetails" resultType="EamPropertiesModelDetailData">
  407. SELECT
  408. a.site,
  409. a.bu_no,
  410. a.function_type,
  411. a.code_no,
  412. a.properties_item_no itemNo,
  413. a.seq_no,
  414. b.ItemDesc,
  415. b.DefaultValue,
  416. b.ValueType,
  417. b.ValueType_DB,
  418. b.ValueChooseFlag,
  419. b.MaxValue,
  420. b.MinValue,
  421. b.ItemRemark,
  422. b.ItemType,
  423. a.check_type,a.order_id
  424. FROM eam_properties_model_detail a
  425. left join eam_properties_item b on a.function_type = b.itemType and a.properties_item_no = b.itemNo and a.site = b.site and a.bu_no = b.bu_no and a.check_type = b.check_type
  426. where a.function_type = #{functionType} and a.code_no = #{codeNo} and a.site = #{site} and a.bu_no = #{buNo} and a.check_type = #{checkType}
  427. order by a.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_TPM(a.Site, a.ActualOperator) as actualOperatorName,
  703. eo.ObjectDesc as objectDesc,
  704. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  705. a.result,
  706. a.checkResult,
  707. a.disposal_measures,
  708. a.check_work_plan_id,
  709. a.check_item_no,
  710. a.reach_date,
  711. a.reach_operator,
  712. a.reach_operator_name,
  713. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  714. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  715. a.check_remark,
  716. a.document_source,
  717. a.last_execution_date,
  718. a.handling_method,
  719. a.fault_reason,
  720. a.preventive_measure,
  721. a.repair_reporting_type,
  722. a.repair_type,
  723. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  724. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  725. END AS responseTime,
  726. a.check_type,
  727. a.is_return,
  728. ewo.plan_period,
  729. ewo.plan_cycle,
  730. CASE
  731. when ewo.plan_cycle = '时' then a.PlanDate
  732. else ewo.task_start_date
  733. end as taskStartDate
  734. FROM eam_workOrder a
  735. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  736. 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
  737. 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
  738. left join sys_user as ea on ead.username = ea.username
  739. 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
  740. <where>
  741. a.site in (select site from eam_access_site where username = #{query.userName})
  742. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  743. and a.check_type in (select role_no from access_role where username = #{query.userName})
  744. and ea.username = #{query.userName}
  745. AND a.FunctionType = #{query.functionType}
  746. <if test="query.buDesc != null and query.buDesc != ''">
  747. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  748. </if>
  749. <if test="query.isReturn != null and query.isReturn != ''">
  750. AND a.is_return = #{query.isReturn}
  751. </if>
  752. <if test="query.orderNo != null and query.orderNo != ''">
  753. AND a.OrderNo like '%' + #{query.orderNo} + '%'
  754. </if>
  755. <if test="query.planID != null and query.planID != ''">
  756. AND a.PlanID like '%' + #{query.planID} + '%'
  757. </if>
  758. <if test="query.planDesc != null and query.planDesc != ''">
  759. AND a.PlanDesc like '%' + #{query.planDesc} + '%'
  760. </if>
  761. <if test="query.objectID != null and query.objectID != ''">
  762. AND a.ObjectID like '%' + #{query.objectID} + '%'
  763. </if>
  764. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  765. AND a.PlanOperatorName like '%' + #{query.planOperatorName} + '%'
  766. </if>
  767. <if test="query.actualOperatorName != null and query.actualOperatorName != ''">
  768. AND dbo.eam_Get_eamAdminName_TPM(a.Site, a.ActualOperator) like '%' + #{query.actualOperatorName} + '%'
  769. </if>
  770. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  771. AND a.status != '已取消'
  772. </if>
  773. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  774. AND a.status = #{query.status}
  775. </if>
  776. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  777. AND a.status = '未开工'
  778. </if>
  779. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  780. AND a.status != '已取消'
  781. </if>
  782. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  783. AND a.status = #{query.status}
  784. </if>
  785. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  786. AND (a.status = '未开工' or a.status = '已到达')
  787. </if>
  788. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  789. AND (a.status = '未开工' or a.status = '已到达')
  790. </if>
  791. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  792. AND a.status = #{query.status}
  793. </if>
  794. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  795. AND a.document_source = #{query.documentSource}
  796. </if>
  797. <if test="query.planDate != null">
  798. AND a.PlanDate = #{query.planDate}
  799. </if>
  800. <if test="query.startDate != null ">
  801. AND a.PlanDate >= #{query.startDate}
  802. </if>
  803. <if test="query.endDate != null ">
  804. AND #{query.endDate} >= a.PlanDate
  805. </if>
  806. <if test="query.endDate == null ">
  807. AND getDate() >= a.PlanDate
  808. </if>
  809. <if test='query.functionType == "A" and query.searchType == "reportCheck"'>
  810. and getDate() >= dbo.compare_date(ewo.task_start_date)
  811. </if>
  812. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  813. AND a.repair_reporting_type = #{query.repairReportingType}
  814. </if>
  815. <if test="query.repairType != null and query.repairType != ''">
  816. AND a.repair_type = #{query.repairType}
  817. </if>
  818. <if test="query.checkType != null and query.checkType != ''">
  819. AND a.check_type = #{query.checkType}
  820. </if>
  821. </where>
  822. ORDER BY a.CreateDate
  823. </select>
  824. <select id="eamWorkOrderSearch2" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  825. SELECT
  826. a.Site,
  827. a.bu_no,
  828. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  829. a.OrderNo,
  830. a.PlanID,
  831. a.PlanDesc,
  832. a.PropertiesCode,
  833. a.ObjectID,
  834. a.Status,
  835. a.PlanOperator,
  836. a.checker,
  837. a.ActualOperator,
  838. a.PlanDate,
  839. a.ActualDate,
  840. a.FunctionType,
  841. a.CreateDate,
  842. dbo.eam_Get_eamAdminName_TPM(a.Site,b.CreatedBy) as createBy,
  843. a.Remark,
  844. a.StartTime,
  845. a.EndTime,
  846. a.WorkTime,
  847. dbo.eam_Get_eamAdminName_TPM(a.Site,a.PlanOperator) as PlanOperatorName,
  848. a.checkerName,
  849. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) as actualOperatorName,
  850. eo.ObjectDesc as objectDesc,
  851. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  852. a.result,
  853. b.urgency,
  854. a.checkResult,
  855. b.DefectID,
  856. c.DefectDesc,
  857. a.disposal_measures,
  858. a.check_work_plan_id,
  859. a.check_item_no,
  860. a.reach_date,
  861. a.reach_operator,
  862. a.reach_operator_name,
  863. b.FeedBackID as feedBackId,
  864. b.FeedBackDesc,
  865. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  866. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  867. a.check_remark,
  868. a.document_source,
  869. a.last_execution_date,
  870. a.handling_method,
  871. a.fault_reason,
  872. a.preventive_measure,
  873. a.repair_reporting_type,
  874. a.repair_type,
  875. b.CreatedDate,
  876. a.is_return as isReturn,
  877. a.difficulty_remark,
  878. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  879. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  880. END AS responseTime
  881. FROM eam_workOrder a
  882. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  883. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  884. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id
  885. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  886. 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
  887. 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
  888. left join sys_user as ea on ead.username = ea.username
  889. 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
  890. <where>
  891. a.site in (select site from eam_access_site where username = #{query.userName})
  892. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  893. and ea.username = #{query.userName}
  894. <if test="query.buDesc != null and query.buDesc != ''">
  895. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  896. </if>
  897. <if test="query.orderNo != null and query.orderNo != ''">
  898. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  899. </if>
  900. <if test="query.planID != null and query.planID != ''">
  901. AND a.PlanID like '%' + #{query.planID} +'%'
  902. </if>
  903. <if test="query.planDesc != null and query.planDesc != ''">
  904. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  905. </if>
  906. <if test="query.objectID != null and query.objectID != ''">
  907. AND a.ObjectID like '%' + #{query.objectID} +'%'
  908. </if>
  909. <if test="query.isReturn != null and query.isReturn != ''">
  910. AND a.is_return = #{query.isReturn}
  911. </if>
  912. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  913. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  914. </if>
  915. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  916. AND a.status != '已取消'
  917. </if>
  918. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  919. AND a.status = #{query.status}
  920. </if>
  921. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  922. AND a.status = '未开工'
  923. </if>
  924. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  925. AND a.status != '已取消'
  926. </if>
  927. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  928. AND a.status = #{query.status}
  929. </if>
  930. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  931. AND (a.status = '未开工' or a.status = '已到达')
  932. </if>
  933. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  934. AND (a.status = '未开工' or a.status = '已到达')
  935. </if>
  936. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  937. AND a.status = #{query.status}
  938. </if>
  939. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  940. AND a.document_source = #{query.documentSource}
  941. </if>
  942. <if test="query.planDate != null">
  943. AND a.PlanDate = #{query.planDate}
  944. </if>
  945. <if test="query.startDate != null ">
  946. AND a.PlanDate >= #{query.startDate}
  947. </if>
  948. <if test="query.endDate != null ">
  949. AND #{query.endDate} >= a.PlanDate
  950. </if>
  951. <if test="query.endDate == null ">
  952. AND getDate() >= a.PlanDate
  953. </if>
  954. <if test='query.functionType == "A" and query.searchType == "reportCheck"'>
  955. and getDate() >= dbo.compare_date(ewo.task_start_date)
  956. </if>
  957. <if test="query.urgency != null and query.urgency != ''">
  958. AND b.urgency = #{query.urgency}
  959. </if>
  960. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  961. AND a.repair_reporting_type = #{query.repairReportingType}
  962. </if>
  963. <if test="query.repairType != null and query.repairType != ''">
  964. AND a.repair_type = #{query.repairType}
  965. </if>
  966. AND a.FunctionType = #{query.functionType}
  967. </where>
  968. ORDER BY a.CreateDate,
  969. CASE WHEN b.urgency = '特急' THEN 1
  970. WHEN b.urgency = '紧急' THEN 2
  971. WHEN b.urgency = '一般' THEN 3
  972. END
  973. </select>
  974. <select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  975. SELECT
  976. a.Site,
  977. a.bu_no,
  978. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  979. a.OrderNo,
  980. a.PlanID,
  981. a.ObjectID,
  982. a.Status,
  983. a.PlanOperator,
  984. a.ActualOperator,
  985. a.PlanDate,
  986. a.ActualDate,
  987. a.FunctionType,
  988. a.CreateDate,
  989. dbo.eam_Get_eamAdminName_TPM(a.Site,b.CreatedBy) as createBy,
  990. a.Remark,
  991. a.StartTime,
  992. a.EndTime,
  993. a.WorkTime,
  994. dbo.eam_Get_eamAdminName_TPM(a.Site,a.PlanOperator) as planOperatorName,
  995. b.DefectID,
  996. c.DefectDesc,
  997. e.ObjectDesc as objectDesc,
  998. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  999. a.result,
  1000. b.urgency,
  1001. a.disposal_measures,
  1002. a.difficulty_level,
  1003. a.difficulty_remark,
  1004. f.department_name,
  1005. a.reach_date,
  1006. a.reach_operator,
  1007. a.reach_operator_name,
  1008. case when a.status = '已废弃' then null else b.CreatedDate end as CreatedDate,
  1009. a.handling_method,
  1010. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  1011. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  1012. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  1013. END AS responseTime,
  1014. b.FeedBackDesc,
  1015. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  1016. a.fault_reason,
  1017. a.preventive_measure,
  1018. a.document_source,
  1019. a.repair_reporting_type,
  1020. a.repair_type,
  1021. a.confirm_assessment,
  1022. a.confirm_remark,
  1023. a.check_assessment,
  1024. a.check_notes
  1025. FROM eam_workOrder a
  1026. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  1027. left join eam_defect c on b.DefectID = c.DefectID
  1028. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id
  1029. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and a.bu_no = e.bu_no
  1030. 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
  1031. 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
  1032. left join sys_user as ea on ead.username = ea.username
  1033. <where>
  1034. a.site in (select site from eam_access_site where username = #{query.userName})
  1035. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1036. and ea.username = #{query.userName}
  1037. <if test="query.buDesc != null and query.buDesc != ''">
  1038. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  1039. </if>
  1040. <if test="query.deptArr != null">
  1041. AND
  1042. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  1043. f.department_name like '%' + #{item} + '%'
  1044. </foreach>
  1045. </if>
  1046. <if test="query.orderNo != null and query.orderNo != ''">
  1047. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  1048. </if>
  1049. <if test="query.planID != null and query.planID != ''">
  1050. AND a.PlanID like '%' + #{query.planID} +'%'
  1051. </if>
  1052. <if test="query.objectID != null and query.objectID != ''">
  1053. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1054. </if>
  1055. <if test="query.planOperator != null and query.planOperator != ''">
  1056. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1057. </if>
  1058. <if test="query.status != null and query.status != ''">
  1059. AND a.status = #{query.status}
  1060. </if>
  1061. <if test="query.documentSource != null and query.documentSource != ''">
  1062. AND a.document_source = #{query.documentSource}
  1063. </if>
  1064. <if test="query.startDate != null ">
  1065. AND a.PlanDate >= #{query.startDate}
  1066. </if>
  1067. <if test="query.endDate != null ">
  1068. AND #{query.endDate} >= a.PlanDate
  1069. </if>
  1070. <if test="query.actualStartDate != null ">
  1071. AND a.ActualDate >= #{query.actualStartDate}
  1072. </if>
  1073. <if test="query.actualEndDate != null ">
  1074. AND DATEADD(DAY, 1, CONVERT(DATE, #{query.actualEndDate})) > a.ActualDate
  1075. </if>
  1076. <if test="query.urgency != null and query.urgency != ''">
  1077. AND b.urgency = #{query.urgency}
  1078. </if>
  1079. <if test="query.result != null and query.result != ''">
  1080. AND a.result = #{query.result}
  1081. </if>
  1082. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  1083. AND a.repair_reporting_type = #{query.repairReportingType}
  1084. </if>
  1085. <if test="query.repairType != null and query.repairType != ''">
  1086. AND a.repair_type = #{query.repairType}
  1087. </if>
  1088. <if test="query.feedBackDesc != null and query.feedBackDesc != ''">
  1089. AND b.FeedBackDesc like '%' +#{query.feedBackDesc}+'%'
  1090. </if>
  1091. <if test="query.createdStartDate != null ">
  1092. AND b.CreatedDate >= #{query.createdStartDate}
  1093. </if>
  1094. <if test="query.createdEndDate != null ">
  1095. AND #{query.createdEndDate} >= b.CreatedDate
  1096. </if>
  1097. and a.FunctionType =#{query.functionType}
  1098. </where>
  1099. ORDER BY a.PlanDate,
  1100. CASE WHEN b.urgency = '特急' THEN 1
  1101. WHEN b.urgency = '紧急' THEN 2
  1102. WHEN b.urgency = '一般' THEN 3
  1103. END
  1104. </select>
  1105. <select id="eamWorkOrderSearchForDefect2" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderExportData">
  1106. SELECT
  1107. a.Site,
  1108. a.bu_no,
  1109. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1110. a.OrderNo,
  1111. a.PlanID,
  1112. a.ObjectID,
  1113. a.Status,
  1114. a.PlanOperator,
  1115. a.ActualOperator,
  1116. a.PlanDate,
  1117. a.ActualDate,
  1118. a.FunctionType,
  1119. a.CreateDate,
  1120. dbo.eam_Get_eamAdminName_TPM(a.Site,b.CreatedBy) as createBy,
  1121. a.Remark,
  1122. a.StartTime,
  1123. a.EndTime,
  1124. a.WorkTime,
  1125. dbo.eam_Get_eamAdminName_TPM(a.Site,a.PlanOperator) as planOperatorName,
  1126. b.DefectID,
  1127. c.DefectDesc,
  1128. e.ObjectDesc as objectDesc,
  1129. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  1130. a.result,
  1131. b.urgency,
  1132. a.disposal_measures,
  1133. a.difficulty_level,
  1134. a.difficulty_remark,
  1135. f.department_name,
  1136. a.reach_date,
  1137. a.reach_operator,
  1138. a.reach_operator_name,
  1139. b.CreatedDate,
  1140. a.handling_method,
  1141. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  1142. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  1143. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  1144. END AS responseTime,
  1145. b.FeedBackDesc,
  1146. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  1147. a.fault_reason,
  1148. a.preventive_measure,
  1149. a.document_source,
  1150. a.repair_reporting_type,
  1151. a.repair_type,
  1152. a.confirm_assessment,
  1153. a.confirm_remark,
  1154. a.check_assessment,
  1155. a.check_notes
  1156. FROM eam_workOrder a
  1157. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  1158. left join eam_defect c on b.DefectID = c.DefectID
  1159. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id
  1160. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and a.bu_no = e.bu_no
  1161. 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
  1162. 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
  1163. left join sys_user as ea on ead.username = ea.username
  1164. <where>
  1165. a.site in (select site from eam_access_site where username = #{query.userName})
  1166. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1167. and ea.username = #{query.userName}
  1168. <if test="query.buDesc != null and query.buDesc != ''">
  1169. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  1170. </if>
  1171. <if test="query.deptArr != null">
  1172. AND
  1173. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  1174. f.department_name like '%' + #{item} + '%'
  1175. </foreach>
  1176. </if>
  1177. <if test="query.orderNo != null and query.orderNo != ''">
  1178. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  1179. </if>
  1180. <if test="query.planID != null and query.planID != ''">
  1181. AND a.PlanID like '%' + #{query.planID} +'%'
  1182. </if>
  1183. <if test="query.objectID != null and query.objectID != ''">
  1184. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1185. </if>
  1186. <if test="query.planOperator != null and query.planOperator != ''">
  1187. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1188. </if>
  1189. <if test="query.status != null and query.status != ''">
  1190. AND a.status = #{query.status}
  1191. </if>
  1192. <if test="query.documentSource != null and query.documentSource != ''">
  1193. AND a.document_source = #{query.documentSource}
  1194. </if>
  1195. <if test="query.startDate != null ">
  1196. AND a.PlanDate >= #{query.startDate}
  1197. </if>
  1198. <if test="query.endDate != null ">
  1199. AND #{query.endDate} >= a.PlanDate
  1200. </if>
  1201. <if test="query.actualStartDate != null ">
  1202. AND a.ActualDate >= #{query.actualStartDate}
  1203. </if>
  1204. <if test="query.actualEndDate != null ">
  1205. AND DATEADD(DAY, 1, CONVERT(DATE, #{query.actualEndDate})) > a.ActualDate
  1206. </if>
  1207. <if test="query.urgency != null and query.urgency != ''">
  1208. AND b.urgency = #{query.urgency}
  1209. </if>
  1210. <if test="query.result != null and query.result != ''">
  1211. AND a.result = #{query.result}
  1212. </if>
  1213. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  1214. AND a.repair_reporting_type = #{query.repairReportingType}
  1215. </if>
  1216. <if test="query.repairType != null and query.repairType != ''">
  1217. AND a.repair_type = #{query.repairType}
  1218. </if>
  1219. and a.FunctionType =#{query.functionType}
  1220. </where>
  1221. ORDER BY a.PlanDate,
  1222. CASE WHEN b.urgency = '特急' THEN 1
  1223. WHEN b.urgency = '紧急' THEN 2
  1224. WHEN b.urgency = '一般' THEN 3
  1225. END
  1226. </select>
  1227. <select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData">
  1228. SELECT
  1229. DefectID,
  1230. DefectDesc,
  1231. Active,
  1232. create_date,
  1233. create_by,
  1234. update_date,
  1235. update_by,
  1236. fault_type
  1237. FROM eam_defect
  1238. <where>
  1239. <if test="query.defectID != null and query.defectID != ''">
  1240. AND defectID like '%' + #{query.defectID} + '%'
  1241. </if>
  1242. <if test="query.defectDesc != null and query.defectDesc != ''">
  1243. AND defectDesc like '%' + #{query.defectDesc} + '%'
  1244. </if>
  1245. <if test="query.active != null and query.active != ''">
  1246. AND active = #{query.active}
  1247. </if>
  1248. </where>
  1249. order by id
  1250. </select>
  1251. <select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1252. SELECT
  1253. a.site,
  1254. a.ObjectID,
  1255. a.DefectID,
  1256. a.Active,
  1257. a.id,
  1258. b.ObjectDesc,
  1259. c.DefectDesc,
  1260. a.create_date,
  1261. a.create_by,
  1262. a.update_date,
  1263. a.update_by
  1264. FROM eam_object_defect a
  1265. left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID
  1266. left join eam_defect c on a.DefectID=c.DefectID
  1267. <where>
  1268. <if test="query.objectID != null and query.objectID != ''">
  1269. AND a.ObjectID like '%' + #{query.objectID} + '%'
  1270. </if>
  1271. <if test="query.objectDesc != null and query.objectDesc != ''">
  1272. AND b.ObjectDesc like '%' + #{query.objectDesc} + '%'
  1273. </if>
  1274. <if test="query.defectID != null and query.defectID != ''">
  1275. AND a.defectID like '%' + #{query.defectID} + '%'
  1276. </if>
  1277. <if test="query.defectDesc != null and query.defectDesc != ''">
  1278. AND c.defectDesc like '%' + #{query.defectDesc} + '%'
  1279. </if>
  1280. <if test="query.active != null and query.active != ''">
  1281. AND a.active = #{query.active}
  1282. </if>
  1283. </where>
  1284. order by a.id
  1285. </select>
  1286. <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  1287. SELECT
  1288. a.Site,
  1289. a.bu_no,
  1290. a.ObjectID,
  1291. a.ObjectDesc,
  1292. a.LocationID,
  1293. a.FamilyID,
  1294. a.GroupID,
  1295. b.FamilyDesc,
  1296. c.LocationName
  1297. FROM eam_object a
  1298. LEFT JOIN eam_family b ON a.site = b.site and a.FamilyID = b.FamilyID and a.bu_no = b.bu_no
  1299. LEFT JOIN eam_location as c ON a.LocationID = c.LocationID and a.site = c.site and a.bu_no = c.bu_no
  1300. <where>
  1301. <if test="objectID != null and objectID != ''">
  1302. AND a.ObjectID like '%' + #{objectID} + '%'
  1303. </if>
  1304. <if test="objectDesc != null and objectDesc != ''">
  1305. AND a.ObjectDesc like '%' + #{objectDesc} + '%'
  1306. </if>
  1307. AND a.site = #{site} AND a.active = 'Y' and a.bu_no = #{buNo}
  1308. </where>
  1309. </select>
  1310. <select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  1311. SELECT
  1312. a.site,
  1313. a.objectID
  1314. from eam_object as a
  1315. left join eam_family as b on a.site = b.site and a.FamilyID = b.FamilyID
  1316. where a.site = '2' and (b.son_id like #{sonId} + '%' or a.FamilyID = #{familyID})
  1317. </select>
  1318. <select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  1319. SELECT
  1320. site,
  1321. objectID
  1322. from eam_object
  1323. where site = #{site} and GroupID = #{groupID}
  1324. </select>
  1325. <select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  1326. SELECT
  1327. site,
  1328. objectID
  1329. from eam_object
  1330. where site = #{site} and LocationID = #{locationID}
  1331. </select>
  1332. <select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1333. SELECT
  1334. a.Site,
  1335. a.bu_no,
  1336. c.OrderNo,
  1337. a.ItemNo,
  1338. a.ItemDesc,
  1339. a.DefaultValue,
  1340. a.ValueType,
  1341. a.ValueType_DB,
  1342. a.ValueChooseFlag,
  1343. a.MaxValue,
  1344. a.MinValue,
  1345. a.ItemRemark,
  1346. a.ItemType,
  1347. a.image_flag,
  1348. a.produce_control_flag,
  1349. CASE WHEN d.id is null THEN 'N'
  1350. ELSE 'Y'
  1351. END as uploadFlag,
  1352. a.item_notes
  1353. from eam_workPlan_item as a
  1354. left join eam_workOrder as c on a.site = c.site and a.PlanID = c.PlanID and a.bu_no = c.bu_no
  1355. left join eam_properties_model_detail pmd on a.Site = pmd.site and a.ItemType = pmd.function_type and a.ItemNo = pmd.properties_item_no and a.bu_no = pmd.bu_no and pmd.code_no = c.PropertiesCode
  1356. 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 d
  1357. on d.order_ref1 = a.site and d.order_ref2 = c.OrderNo and d.order_ref3 = a.ItemNo and d.order_ref4 = a.bu_no
  1358. where a.site = #{site} and c.orderNo = #{orderNo} and a.ObjectID = #{objectID} and a.bu_no = #{buNo}
  1359. order by pmd.order_id
  1360. </select>
  1361. <select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1362. SELECT
  1363. Site,
  1364. status,
  1365. OrderNo
  1366. from eam_workOrder
  1367. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1368. </select>
  1369. <select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  1370. SELECT username as adminID
  1371. from sys_user
  1372. where username = #{mesUser}
  1373. </select>
  1374. <update id="updateDefectResult" >
  1375. update eam_defect_feedBack
  1376. set Status = #{result},
  1377. FinishDate = GetDate(),
  1378. DefectID = #{defectID}
  1379. where Site = #{site} and FeedBackID = #{planID} and bu_no = #{buNo}
  1380. </update>
  1381. <update id="reportWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1382. update eam_workOrder
  1383. set Status = '待确认',
  1384. ActualOperator = #{actualOperator},
  1385. ActualDate = #{actualDate},
  1386. Remark = #{remark},
  1387. disposal_measures = #{disposalMeasures},
  1388. WorkTime = CASE
  1389. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1390. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
  1391. END,
  1392. result = #{result,jdbcType=VARCHAR},
  1393. checkResult = #{checkResult},
  1394. handling_method = #{handlingMethod},
  1395. fault_reason = #{faultReason},
  1396. preventive_measure = #{preventiveMeasure}
  1397. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1398. </update>
  1399. <update id="reportWorkOrder2" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1400. update eam_workOrder
  1401. set Status = '待审核',
  1402. ActualOperator = #{actualOperator},
  1403. reach_date = #{reachDate},
  1404. ActualDate = #{actualDate},
  1405. Remark = #{remark},
  1406. disposal_measures = #{disposalMeasures},
  1407. WorkTime = #{workTime},
  1408. result = #{result,jdbcType=VARCHAR},
  1409. checkResult = #{checkResult},
  1410. handling_method = #{handlingMethod},
  1411. check_remark = #{checkRemark}
  1412. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1413. </update>
  1414. <update id="reportWorkOrder3" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1415. update eam_workOrder
  1416. set Status = '待审核',
  1417. ActualOperator = #{actualOperator},
  1418. ActualDate = #{actualDate},
  1419. Remark = #{remark},
  1420. disposal_measures = #{disposalMeasures},
  1421. WorkTime = CASE
  1422. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1423. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
  1424. END,
  1425. result = #{result,jdbcType=VARCHAR},
  1426. checkResult = #{checkResult},
  1427. handling_method = #{handlingMethod},
  1428. fault_reason = #{faultReason},
  1429. preventive_measure = #{preventiveMeasure}
  1430. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1431. </update>
  1432. <update id="defectReportWorkOrder" >
  1433. update eam_workOrder
  1434. set Status = '已完工',
  1435. ActualOperator = #{actualOperator},
  1436. ActualDate = GetDate(),
  1437. Remark = #{remark},
  1438. disposal_measures = #{disposalMeasures},
  1439. WorkTime = #{workTime},
  1440. result = #{result,jdbcType=VARCHAR},
  1441. checkResult = #{checkResult}
  1442. where site = #{site}
  1443. and orderNo = #{orderNo}
  1444. </update>
  1445. <insert id="saveWorkOrderItem">
  1446. INSERT into eam_workOrder_item
  1447. (Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
  1448. 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})
  1449. </insert>
  1450. <!-- 修改 eam_workPlan 状态为已结束 -->
  1451. <update id="closePlanWithCheck">
  1452. update eam_workPlan
  1453. set status = '已结束'
  1454. where site = #{site}
  1455. and PlanID = #{planID}
  1456. and ObjectID = #{objectID}
  1457. and GetDate() > PlanEndDate
  1458. </update>
  1459. <!-- 报工后更新下一个工作日期 -->
  1460. <update id="updatePlanNextDate">
  1461. update eam_workPlan_overview
  1462. 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)
  1463. where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
  1464. </update>
  1465. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1466. SELECT
  1467. a.Site,
  1468. a.bu_no,
  1469. a.OrderNo,
  1470. a.ItemNo,
  1471. a.ItemDesc,
  1472. a.DefaultValue,
  1473. a.ValueType,
  1474. a.ValueType_DB,
  1475. a.ValueChooseFlag,
  1476. a.MaxValue,
  1477. a.MinValue,
  1478. a.ItemRemark,
  1479. a.ItemType,
  1480. a.TextValue,
  1481. a.NumberValue,
  1482. a.CreatedDate,
  1483. a.CreatedBy,
  1484. a.FinishFlag,
  1485. a.itemResult,
  1486. a.item_notes
  1487. from eam_workOrder_item a
  1488. left join eam_workOrder c on a.site = c.site and a.orderNo = c.orderNo and a.bu_no = c.bu_no
  1489. left join eam_properties_model_detail pmd on a.site = pmd.site and a.ItemType = pmd.function_type and a.ItemNo = pmd.properties_item_no and a.bu_no = pmd.bu_no and pmd.code_no = c.PropertiesCode
  1490. where a.site = #{site} and a.orderNo = #{orderNo} and a.bu_no = #{buNo}
  1491. order by pmd.order_id
  1492. </select>
  1493. <update id="cancelOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1494. update eam_workOrder
  1495. set Status = '已取消',
  1496. cancel_date = getDate(),
  1497. cancel_by = #{userId}
  1498. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1499. </update>
  1500. <update id="cancelOrderAll" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1501. update eam_workOrder
  1502. set Status = '已取消',
  1503. cancel_date = getDate(),
  1504. cancel_by = #{userId}
  1505. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
  1506. </update>
  1507. <update id="updateWorkPlanStatus2" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1508. update eam_workPlan
  1509. set Status = '已取消',
  1510. cancel_date = getDate(),
  1511. cancel_by = #{userId}
  1512. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1513. </update>
  1514. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1515. SELECT
  1516. site,
  1517. bu_no,
  1518. status
  1519. from eam_workPlan_overview
  1520. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1521. </select>
  1522. <update id="planOrder">
  1523. update eam_workPlan
  1524. set Status = '已计划',
  1525. NextWorkDate = null
  1526. where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1527. </update>
  1528. <update id="cancelPlan">
  1529. update eam_workPlan_overview
  1530. set status = '已取消',
  1531. next_work_date = null,
  1532. cancel_date = getDate(),
  1533. cancel_by = #{userId}
  1534. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1535. </update>
  1536. <update id="updateWorkPlanStatus">
  1537. update eam_workPlan
  1538. set Status = '已取消',
  1539. NextWorkDate = null,
  1540. cancel_date = getDate(),
  1541. cancel_by = #{userId}
  1542. where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1543. </update>
  1544. <update id="cancelOrderWithPlanID">
  1545. update eam_workOrder
  1546. set Status = '已取消',
  1547. cancel_date = getDate(),
  1548. cancel_by = #{userId}
  1549. where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
  1550. </update>
  1551. <update id="deleteOrderDetailWithPlanID">
  1552. delete from eam_workOrder_item
  1553. where site = #{site} and bu_no = #{buNo}
  1554. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  1555. </update>
  1556. <update id="deleteOrderWithPlanID">
  1557. delete from eam_workOrder
  1558. where site = #{site} and bu_no = #{buNo}
  1559. and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
  1560. </update>
  1561. <update id="updateOrderPlanOperator">
  1562. update eam_workOrder
  1563. set PlanOperator = #{planOperator}
  1564. where site = #{site} and orderNo = #{orderNo}
  1565. </update>
  1566. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1567. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  1568. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  1569. <where>
  1570. <if test="partNo != null and partNo != ''">
  1571. AND a.part_no like '%' + #{partNo} + '%'
  1572. </if>
  1573. <if test="partDescription != null and partDescription != ''">
  1574. AND a.part_description like '%' + #{partDescription} + '%'
  1575. </if>
  1576. and a.site=#{site} and a.active='Y'
  1577. </where>
  1578. </select>
  1579. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1580. select part_no
  1581. from resource_spare
  1582. where site = #{site}
  1583. and resource_id = #{objectID}
  1584. and part_no = #{partNo}
  1585. </select>
  1586. <insert id="savePartSpare" >
  1587. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1588. values(#{objectID},#{partNo},'',0,#{site})
  1589. </insert>
  1590. <delete id="deletePartSpare">
  1591. <foreach collection="list" item="item" separator=";">
  1592. delete from resource_spare where site = #{item.site} and resource_id = #{item.objectID}
  1593. </foreach>
  1594. </delete>
  1595. <insert id="copyPartSpare" >
  1596. INSERT INTO resource_spare
  1597. (resource_id, part_no, delflag, version, site)
  1598. <foreach item="item" index="index" collection="list" separator=",">
  1599. select #{item.objectID}, part_no, delflag, 0, site from resource_spare where resource_id = #{item.oldObjectID} and site = #{item.site}
  1600. </foreach>
  1601. </insert>
  1602. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1603. SELECT DISTINCT
  1604. a.site AS site,
  1605. a.plan_id AS planID,
  1606. a.plan_desc AS planDesc,
  1607. wp.ObjectID AS objectID,
  1608. a.function_type AS functionType,
  1609. a.properties_code AS propertiesCode,
  1610. a.operator AS operator,
  1611. a.plan_period AS planPeriod,
  1612. a.status AS status,
  1613. a.plan_start_date AS planStartDate,
  1614. a.plan_end_date AS planEndDate,
  1615. a.created_date AS createdDate,
  1616. a.created_by AS createdBy,
  1617. a.update_date AS updateDate,
  1618. a.update_by AS updateBy,
  1619. a.remark AS remark,
  1620. a.next_work_date AS nextWorkDate,
  1621. b.ObjectDesc AS objectDesc,
  1622. a.operator_name AS adminName,
  1623. d.code_desc AS codeDesc
  1624. FROM eam_workPlan_overview a
  1625. LEFT JOIN eam_workPlan wp
  1626. ON a.site = wp.Site
  1627. AND a.bu_no = wp.bu_no
  1628. AND a.plan_id = wp.PlanID
  1629. AND wp.deleteFlag = 'N'
  1630. LEFT JOIN eam_object b
  1631. ON wp.Site = b.Site
  1632. AND wp.ObjectID = b.ObjectID
  1633. LEFT JOIN eam_properties_model_header d
  1634. ON a.function_type = d.function_type
  1635. AND a.properties_code = d.code_no
  1636. WHERE a.site = #{site}
  1637. AND wp.ObjectID = #{objectID}
  1638. AND a.function_type = #{functionType}
  1639. AND a.delete_flag = 'N'
  1640. AND a.status IN ('已计划','进行中')
  1641. </select>
  1642. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1643. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  1644. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  1645. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  1646. where a.site=#{site} and a.ObjectID=#{objectID}
  1647. and a.ItemType=#{itemType}
  1648. </select>
  1649. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1650. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  1651. from eam_object_defect a left join eam_defect b
  1652. on a.DefectID=b.DefectID
  1653. where a.site=#{site} and a.ObjectID=#{objectID}
  1654. </select>
  1655. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1656. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1657. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1658. </select>
  1659. <insert id="saveNewEamObjectItem" >
  1660. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1661. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  1662. </insert>
  1663. <update id="editEamObjectItem">
  1664. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  1665. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  1666. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1667. and ItemNo=#{itemNo}
  1668. </update>
  1669. <delete id="deleteObjectItem">
  1670. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1671. and ItemNo=#{itemNo}
  1672. </delete>
  1673. <insert id="saveNewEamObjectItemAvailable">
  1674. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1675. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1676. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1677. </insert>
  1678. <delete id="deleteEamObjectItemAvailable">
  1679. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1680. and ItemNo=#{itemNo}
  1681. </delete>
  1682. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1683. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1684. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1685. </select>
  1686. <select id="getItemValueNoForObject" resultType="Double">
  1687. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1688. </select>
  1689. <insert id="saveObjectItemAvailable">
  1690. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1691. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1692. </insert>
  1693. <update id="updateObjectItemAvailable">
  1694. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1695. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1696. </update>
  1697. <delete id="deleteObjectItemAvailable">
  1698. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1699. </delete>
  1700. <delete id="deleteObjectItemForCopy">
  1701. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1702. </delete>
  1703. <delete id="deleteObjectItemAvailableForCopy">
  1704. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1705. </delete>
  1706. <insert id="copyObjectItem" >
  1707. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1708. ItemType)
  1709. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1710. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1711. </insert>
  1712. <insert id="copyObjectItemAvailable">
  1713. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1714. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1715. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1716. </insert>
  1717. <delete id="deleteObjectDefectForCopy">
  1718. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1719. </delete>
  1720. <insert id="copyObjectDefect">
  1721. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1722. select #{site},#{objectID},DefectID,Active
  1723. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1724. </insert>
  1725. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1726. select
  1727. a.Site,
  1728. a.bu_no,
  1729. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1730. a.FeedBackID,
  1731. a.FeedBackDesc,
  1732. a.ObjectID,
  1733. a.DefectID,
  1734. a.FunctionType,
  1735. a.PlanOperator,
  1736. a.ActualOperator,
  1737. DBO.GET_EAM_Status (A.site,a.bu_no,a.FeedBackID) AS status,
  1738. a.PlanDate,
  1739. a.Remark,
  1740. a.urgency,
  1741. a.deleteFlag,
  1742. a.CreatedDate,
  1743. a.CreatedBy,
  1744. dbo.eam_Get_eamAdminName_TPM(a.site,a.CreatedBy) as feedbackBy,
  1745. a.UpdateDate,
  1746. a.UpdateBy,
  1747. a.Version,
  1748. a.DefectDate,
  1749. dbo.eam_Get_eamAdminName_TPM(a.Site,a.PlanOperator) as PlanOperatorName,
  1750. b.defectDesc,
  1751. e.ObjectDesc as ObjectDesc,
  1752. FinishDate,
  1753. 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,
  1754. a.repair_reporting_type,
  1755. a.repair_type,
  1756. f.department_name as department,
  1757. g.LocationName,
  1758. a.matter_tracking_flag
  1759. from eam_defect_feedBack a
  1760. left join eam_defect b on a.DefectID = b.DefectID
  1761. left join operator as c on a.CreatedBy = c.operator_id
  1762. 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
  1763. 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
  1764. 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
  1765. left join sys_user as ea on ead.username = ea.username
  1766. left join eam_location as g on e.site = g.site and e.LocationID = g.LocationID and e.bu_no = g.bu_no
  1767. <where>
  1768. a.site in (select site from eam_access_site where username = #{query.userName})
  1769. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1770. and ea.username = #{query.userName}
  1771. <if test="query.buDesc != null and query.buDesc != ''">
  1772. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  1773. </if>
  1774. <if test="query.feedBackID != null and query.feedBackID != ''">
  1775. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1776. </if>
  1777. <if test="query.defectDesc != null and query.defectDesc != ''">
  1778. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1779. </if>
  1780. <if test="query.objectID != null and query.objectID != ''">
  1781. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1782. </if>
  1783. <if test="query.planOperator != null and query.planOperator != ''">
  1784. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1785. </if>
  1786. <if test="query.status != null and query.status != ''">
  1787. AND a.status = #{query.status}
  1788. </if>
  1789. <if test="query.startDate != null ">
  1790. AND a.defectDate >= #{query.startDate}
  1791. </if>
  1792. <if test="query.endDate != null ">
  1793. AND #{query.endDate} >= a.defectDate
  1794. </if>
  1795. <if test="query.urgency != null and query.urgency != ''">
  1796. AND a.urgency = #{query.urgency}
  1797. </if>
  1798. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  1799. AND a.repair_reporting_type = #{query.repairReportingType}
  1800. </if>
  1801. <if test="query.repairType != null and query.repairType != ''">
  1802. AND a.repair_type = #{query.repairType}
  1803. </if>
  1804. <if test="query.department != null and query.department != ''">
  1805. AND f.department_name like '%' + #{query.department} + '%'
  1806. </if>
  1807. <if test="query.locationName != null and query.locationName != ''">
  1808. AND g.LocationName like '%' + #{query.locationName} + '%'
  1809. </if>
  1810. <if test="query.matterTrackingFlag != null and query.matterTrackingFlag != ''">
  1811. AND a.matter_tracking_flag = #{query.matterTrackingFlag}
  1812. </if>
  1813. and a.FunctionType = #{query.functionType}
  1814. </where>
  1815. ORDER BY a.DefectDate,
  1816. CASE WHEN a.urgency = '特急' THEN 1
  1817. WHEN a.urgency = '紧急' THEN 2
  1818. WHEN a.urgency = '一般' THEN 3
  1819. END
  1820. </select>
  1821. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1822. select Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, Status from eam_defect_feedBack where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1823. </select>
  1824. <update id="cancelFeedBack" >
  1825. update eam_defect_feedBack
  1826. set status = '已取消'
  1827. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1828. </update>
  1829. <update id="updateFeedBack">
  1830. update eam_defect_feedBack
  1831. set status = '已下达',
  1832. PlanOperator = #{planOperator},
  1833. UpdateDate = GetDate(),
  1834. UpdateBy = #{updateBy}
  1835. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1836. </update>
  1837. <insert id="saveDefectOrder">
  1838. INSERT INTO eam_workOrder
  1839. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1840. 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})
  1841. </insert>
  1842. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1843. SELECT
  1844. a.site,
  1845. a.bu_no,
  1846. a.itemNo,
  1847. a.ItemDesc,
  1848. a.ItemRemark
  1849. FROM eam_properties_item a
  1850. 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
  1851. <where>
  1852. a.site = #{site} and a.bu_no = #{buNo} and a.ItemType = #{functionType} and a.check_type = #{checkType} AND b.code_no is null
  1853. <if test = "itemNo != null and itemNo != ''">
  1854. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1855. </if>
  1856. <if test = "itemDesc != null and itemDesc != ''">
  1857. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1858. </if>
  1859. </where>
  1860. </select>
  1861. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1862. select
  1863. a.site,
  1864. a.bu_no,
  1865. a.properties_item_no itemNo,
  1866. b.ItemDesc,
  1867. b.ItemRemark
  1868. from eam_properties_model_detail a
  1869. 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
  1870. where a.site = #{site} and a.bu_no = #{buNo} and a.code_no = #{codeNo} and a.function_type = #{functionType} and a.check_type = #{checkType}
  1871. </select>
  1872. <delete id="deleteObjectFile">
  1873. delete from sys_oss where id = #{id}
  1874. </delete>
  1875. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1876. SELECT
  1877. id,
  1878. url,
  1879. create_date,
  1880. file_name,
  1881. new_file_name,
  1882. created_by,
  1883. order_ref1,
  1884. order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1885. FROM sys_oss
  1886. WHERE order_ref2 = #{orderNo}
  1887. AND order_ref1 = #{site}
  1888. AND order_ref3 = 'reportSparPart'
  1889. </select>
  1890. <!-- 获取机修人员列表 -->
  1891. <select id="getOperatorList" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  1892. SELECT
  1893. ea.AdminID,
  1894. ea.AdminName,
  1895. ea.Phone,
  1896. dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName,
  1897. ea.Email,
  1898. ea.Tel,
  1899. ea.LevelID,
  1900. eal.AdminLevelDesc,
  1901. ea.MesUser,
  1902. ea.Active,
  1903. ea.CreatedDate
  1904. FROM eam_admin as ea
  1905. LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1906. <where>
  1907. ea.Active = 'Y'
  1908. AND ea.Site = #{site}
  1909. <if test = "adminID != null and adminID != ''">
  1910. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1911. </if>
  1912. <if test = "adminName != null and adminName != ''">
  1913. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1914. </if>
  1915. </where>
  1916. </select>
  1917. <!-- 获取审核人员列表 -->
  1918. <select id="getCheckerList" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  1919. SELECT
  1920. a.user_id,
  1921. a.username as adminID,
  1922. a.email,
  1923. a.mobile as phone,
  1924. a.user_display as adminName,
  1925. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  1926. d.role_id,
  1927. e.role_name
  1928. FROM sys_user as a
  1929. LEFT JOIN eam_access_site as b on a.username = b.username
  1930. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  1931. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  1932. LEFT JOIN sys_role as e on d.role_id = e.role_id
  1933. <where>
  1934. b.site = #{site} and c.bu_no = #{buNo}
  1935. <if test = "adminID != null and adminID != ''">
  1936. AND a.username LIKE '%' + #{adminID}+'%'
  1937. </if>
  1938. <if test = "adminName != null and adminName != ''">
  1939. AND a.user_display LIKE '%' + #{adminName}+'%'
  1940. </if>
  1941. <if test = "buDesc != null and buDesc != ''">
  1942. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  1943. </if>
  1944. <if test = "roleId != null and roleId != ''">
  1945. AND d.role_id = #{roleId}
  1946. </if>
  1947. </where>
  1948. </select>
  1949. <!-- 点检工单审核 -->
  1950. <update id="checkWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1951. UPDATE eam_workOrder
  1952. SET Status = '已完工'
  1953. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1954. </update>
  1955. <update id="cancelCheckWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1956. UPDATE eam_workOrder
  1957. SET Status = '待审核'
  1958. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1959. </update>
  1960. <!-- 查看点检工单状态 -->
  1961. <select id="checkWorkOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1962. SELECT
  1963. OrderNo
  1964. FROM eam_workOrder
  1965. WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' and bu_no = #{buNo}
  1966. </select>
  1967. <!-- 点检工单审核 -->
  1968. <update id="updateWorkPlanOverviewStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1969. UPDATE eam_workPlan_overview
  1970. SET status = '已结束'
  1971. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1972. </update>
  1973. <!-- 新增点检计划 -->
  1974. <insert id="saveWorkPlan" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1975. INSERT INTO eam_workPlan_overview
  1976. (site, plan_id, plan_desc, status, plan_start_date, plan_end_date, created_date, created_by, update_date, update_by,
  1977. remark, delete_flag, operator, operator_name, checker, checker_name, function_type, properties_code, plan_period,
  1978. work_order_rule, plan_cycle, task_start_date, plan_halt_date, auto_renewal, bu_no, check_type)
  1979. VALUES
  1980. (#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy},
  1981. #{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod},
  1982. #{workOrderRule}, #{planCycle}, #{taskStartDate}, #{planHaltDate}, #{autoRenewal}, #{buNo}, #{checkType})
  1983. </insert>
  1984. <!-- 生成工单ID -->
  1985. <select id="selectOrderId" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1986. SELECT
  1987. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1988. FROM eam_workPlan
  1989. WHERE site = #{site} AND FunctionType = #{functionType} and bu_no = #{buNo}
  1990. </select>
  1991. <!-- 查询计划中的设备列表 -->
  1992. <select id="getPlanDetailList" resultType="com.xujie.sys.modules.pms.data.WorkPlanDetailData" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  1993. SELECT
  1994. ewp.PlanID,
  1995. ewp.PlanDesc,
  1996. ewp.ObjectID,
  1997. eo.ObjectDesc,
  1998. eo.FamilyID,
  1999. ef.FamilyDesc,
  2000. eo.LocationID,
  2001. el.LocationName
  2002. FROM eam_workPlan as ewP
  2003. LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site and ewP.bu_no = eo.bu_no
  2004. LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site and ewP.bu_no = ef.bu_no
  2005. LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site and ewP.bu_no = el.bu_no
  2006. <where>
  2007. ewP.site = #{site} and ewP.bu_no = #{buNo}
  2008. AND ewp.PlanID = #{planID}
  2009. <if test = "objectID != null and objectID != ''">
  2010. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  2011. </if>
  2012. <if test = "objectDesc != null and objectDesc != ''">
  2013. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  2014. </if>
  2015. </where>
  2016. </select>
  2017. <!-- 删除计划中的设备 -->
  2018. <delete id="delPlanDetail" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  2019. DELETE FROM eam_workPlan
  2020. WHERE Site = #{site}
  2021. AND PlanID = #{planID}
  2022. AND ObjectID = #{objectID}
  2023. </delete>
  2024. <!-- 获取当前计划不包含的设备 -->
  2025. <select id="getObjList1" resultType="com.xujie.sys.modules.pms.data.WorkPlanDetailData" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  2026. SELECT
  2027. a.ObjectID,
  2028. a.ObjectDesc,
  2029. a.FamilyID,
  2030. ef.FamilyDesc,
  2031. a.LocationID,
  2032. el.LocationName
  2033. FROM eam_object a
  2034. 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
  2035. LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  2036. LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  2037. WHERE a.site = #{site} and a.bu_no = #{buNo} and b.PlanID is null
  2038. </select>
  2039. <!-- 获取当前计划包含的设备 -->
  2040. <select id="getObjList2" resultType="com.xujie.sys.modules.pms.data.WorkPlanDetailData" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  2041. SELECT
  2042. a.ObjectID,
  2043. b.ObjectDesc,
  2044. b.FamilyID,
  2045. ef.FamilyDesc,
  2046. b.LocationID,
  2047. el.LocationName
  2048. FROM eam_workPlan a
  2049. LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  2050. LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  2051. LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  2052. WHERE a.PlanID = #{planID} and a.site = #{site} and a.bu_no = #{buNo}
  2053. </select>
  2054. <!-- 添加计划设备 -->
  2055. <insert id="addObject" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2056. INSERT INTO eam_workPlan
  2057. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  2058. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  2059. </insert>
  2060. <!-- 修改工单计划 -->
  2061. <update id="updateWorkPlan" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2062. UPDATE eam_workPlan_overview
  2063. SET plan_desc = #{planDesc},
  2064. properties_code = #{propertiesCode},
  2065. plan_start_date = #{planStartDate},
  2066. plan_end_date = #{planEndDate},
  2067. plan_period = #{planPeriod},
  2068. remark = #{remark},
  2069. operator = #{operator},
  2070. operator_name = #{operatorName},
  2071. checker = #{checker},
  2072. checker_name = #{checkerName},
  2073. work_order_rule = #{workOrderRule},
  2074. task_start_date = #{taskStartDate},
  2075. plan_cycle = #{planCycle},
  2076. plan_halt_date = #{planHaltDate},
  2077. auto_renewal = #{autoRenewal}
  2078. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  2079. </update>
  2080. <!-- 删除该计划的旧设备 -->
  2081. <delete id="delWorkPlanObject" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2082. DELETE FROM eam_workPlan
  2083. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  2084. </delete>
  2085. <!-- 删除该计划的旧设备item -->
  2086. <delete id="delWorkPlanItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2087. DELETE FROM eam_workPlan_item
  2088. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  2089. </delete>
  2090. <!-- 删除该计划的旧设备itemAvailable-->
  2091. <delete id="delWorkPlanItemAvailable">
  2092. DELETE FROM eam_workPlan_item_available
  2093. WHERE Site = #{site}
  2094. AND PlanID = #{planID}
  2095. AND ObjectID = #{objectID}
  2096. </delete>
  2097. <!-- 查询该计划的设备 -->
  2098. <select id="planObjectSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData">
  2099. SELECT DISTINCT
  2100. a.ObjectID,
  2101. b.ObjectDesc
  2102. FROM eam_workPlan_item as a
  2103. LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  2104. WHERE a.Site = #{site} AND a.PlanID = #{planID} and a.bu_no = #{buNo}
  2105. </select>
  2106. <!-- 修改该计划状态 -->
  2107. <update id="updateOverviewStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2108. UPDATE eam_workPlan_overview
  2109. SET status = '进行中',
  2110. next_work_date = plan_start_date
  2111. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  2112. </update>
  2113. <!-- 查询文件路径 -->
  2114. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2115. SELECT
  2116. id,
  2117. url,
  2118. file_name,
  2119. create_date,
  2120. new_file_name,
  2121. created_by,
  2122. order_ref1,
  2123. order_ref2,
  2124. order_ref3,
  2125. order_ref4,
  2126. file_type,
  2127. file_suffix,
  2128. file_type_code
  2129. FROM sys_oss
  2130. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} and order_ref4 = #{buNo}
  2131. </select>
  2132. <!-- 新增子明细信息 -->
  2133. <insert id="saveOperator" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2134. INSERT INTO eam_actual_operator
  2135. (site, order_no, function_type, operator, bu_no)
  2136. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
  2137. </insert>
  2138. <!-- AND Status = '已完工' AND PlanOperator is not null-->
  2139. <!-- 查询实际维修人员 -->
  2140. <select id="getActualOperatorList2" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  2141. SELECT
  2142. ea.AdminID,
  2143. ea.AdminName
  2144. FROM eam_actual_operator as eao
  2145. LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site
  2146. LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo
  2147. WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID}
  2148. </select>
  2149. <!-- 查询实际维修人员 -->
  2150. <select id="getActualOperatorList" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  2151. SELECT
  2152. ea.username as adminID,
  2153. ea.user_display as AdminName
  2154. FROM eam_actual_operator as eao
  2155. LEFT JOIN sys_user as ea ON eao.operator = ea.username
  2156. WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} and eao.bu_no = #{buNo}
  2157. </select>
  2158. <!-- 查询设备所属部门 -->
  2159. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  2160. SELECT ved.department_name
  2161. FROM eam_object as eo
  2162. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  2163. WHERE eo.site = #{site}
  2164. AND eo.ObjectID = #{objectID}
  2165. </select>
  2166. <!-- 查询用户所属部门 -->
  2167. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  2168. SELECT AdminID
  2169. FROM eam_admin
  2170. WHERE site = #{site}
  2171. AND MesUser = #{username}
  2172. </select>
  2173. <!-- &lt;!&ndash; 查询部门列表 &ndash;&gt;-->
  2174. <!-- <select id="getDeptList" resultType="string" parameterType="string">-->
  2175. <!-- SELECT-->
  2176. <!-- ved.department_name-->
  2177. <!-- FROM eam_admin_dept as ead-->
  2178. <!-- LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id-->
  2179. <!-- LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID-->
  2180. <!-- WHERE ead.site = #{site} AND ea.MesUser = #{username}-->
  2181. <!-- </select>-->
  2182. <!-- 查询部门列表 -->
  2183. <select id="getDeptList" resultType="string" parameterType="string">
  2184. SELECT
  2185. distinct c.department_name
  2186. from sys_user as a
  2187. left join Access_dept as b on a.username = b.username
  2188. left join sys_department as c on c.site in (select site from eam_access_site where username = #{username})
  2189. and (c.site + '-' + c.bu_no) in (select * from dbo.query_bu(#{username}))
  2190. and b.department_id = c.department_id
  2191. where a.username = #{username}
  2192. </select>
  2193. <!-- 生成新的维修工单 -->
  2194. <insert id="saveDefectWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2195. INSERT INTO eam_workOrder
  2196. (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)
  2197. VALUES
  2198. (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource}, #{repairReportingType}, #{repairType}, #{planOperator})
  2199. </insert>
  2200. <!-- 获取旧工单的基础信息 -->
  2201. <select id="queryOldWorkOrderMessage" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2202. select
  2203. PlanOperator,
  2204. PlanOperatorName,
  2205. checker,
  2206. checkerName
  2207. from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2208. </select>
  2209. <!-- 生成新的维保工单 -->
  2210. <insert id="saveMaintenanceWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2211. INSERT INTO eam_workOrder
  2212. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  2213. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  2214. </insert>
  2215. <!-- 检查系统操作人和审核人员是否一致 -->
  2216. <select id="selectNameByMes" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  2217. SELECT AdminName
  2218. FROM eam_admin
  2219. WHERE site = #{site}
  2220. AND MesUser = #{mesUser}
  2221. </select>
  2222. <!-- 维修审核确认 -->
  2223. <update id="submitDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2224. UPDATE eam_workOrder
  2225. SET Status = #{status},
  2226. difficulty_level = #{difficultyLevel},
  2227. difficulty_remark = #{difficultyRemark}
  2228. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  2229. </update>
  2230. <!-- 查询设备的点检和维保历史记录 -->
  2231. <select id="queryHistoryRecord" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2232. SELECT
  2233. ewo.OrderNo,
  2234. ewo.PlanID,
  2235. ewo.PlanDesc,
  2236. ewo.ActualDate,
  2237. ewo.ObjectID,
  2238. eo.ObjectDesc,
  2239. ewo.Remark,
  2240. dbo.eam_Get_eamAdminName(ewo.site, ewo.ActualOperator) ActualOperatorName,
  2241. ewo.checkResult,
  2242. FROM eam_workOrder as ewo
  2243. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  2244. 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 = '待审核')
  2245. ORDER BY ewo.ActualDate desc
  2246. </select>
  2247. <!-- 查询设备的维修历史记录 -->
  2248. <select id="queryDefectHistoryRecord" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2249. SELECT DISTINCT
  2250. ewo.OrderNo,
  2251. ewo.PlanID,
  2252. ewo.PlanDesc,
  2253. ewo.ActualDate,
  2254. ewo.Remark,
  2255. ewo.Result,
  2256. ewo.disposal_measures,
  2257. ed.DefectDesc,
  2258. ewo.WorkTime,
  2259. dbo.eam_Get_eamAdminName(ewo.Site, ewo.ActualOperator) actualOperatorName,
  2260. case when so.id is not null then 'Y' else 'N' end as reportFaultFlag,
  2261. case when so1.id is not null then 'Y' else 'N' end as reportSparPartFlag
  2262. FROM eam_workOrder as ewo
  2263. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  2264. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID and ewo.bu_no = edf.bu_no
  2265. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  2266. 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
  2267. LEFT JOIN sys_oss as so1 on so1.order_ref1 = ewo.Site AND so1.order_ref2 = ewo.OrderNo AND so1.order_ref3 =
  2268. 'reportSparPart' and so1.order_ref4 = ewo.bu_no
  2269. <where>ewo.site = #{query.site} and ewo.bu_no = #{query.buNo} and ewo.ObjectID = #{query.objectID} and
  2270. ewo.FunctionType = #{query.functionType} AND (ewo.Status = '已完工' or ewo.Status = '待审核')
  2271. <if test="query.startDate != null ">
  2272. AND ewo.ActualDate >= #{query.startDate}
  2273. </if>
  2274. <if test="query.endDate != null ">
  2275. AND #{query.endDate} >= ewo.ActualDate
  2276. </if>
  2277. </where> ORDER BY ewo.ActualDate desc
  2278. </select>
  2279. <!-- 查询部门列表 -->
  2280. <select id="getEmpyDeptList" resultType="com.xujie.sys.modules.pms.data.EmpyDept" parameterType="com.xujie.sys.modules.pms.data.EmpyDept">
  2281. SELECT
  2282. site,
  2283. department_id as deptId,
  2284. department_name as deptName
  2285. FROM sys_department
  2286. <where>
  2287. site in (select site from eam_access_site where username = #{userName})
  2288. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2289. <if test = "deptId != null and deptId != ''">
  2290. AND department_id LIKE '%' + #{deptId}+'%'
  2291. </if>
  2292. <if test = "deptName != null and deptName != ''">
  2293. AND department_name LIKE '%' + #{deptName}+'%'
  2294. </if>
  2295. </where>
  2296. </select>
  2297. <!-- 生成新的维修工单 -->
  2298. <insert id="saveAdminDepartment">
  2299. INSERT INTO eam_admin_dept
  2300. (Site, admin_id, dept_id)
  2301. VALUES (#{site}, #{adminID}, #{deptId})
  2302. </insert>
  2303. <!-- 查询部门详情 -->
  2304. <select id="getDeptDetail" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="string">
  2305. SELECT
  2306. ved.department_id as department,
  2307. ved.department_name as departmentName
  2308. FROM eam_admin_dept as ead
  2309. 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
  2310. WHERE ead.site in (select site from eam_access_site where username = #{userName})
  2311. and (ead.site + '-' + ead.bu_no) in (select * from dbo.query_bu(#{userName}))
  2312. AND ead.admin_id = #{adminID}
  2313. </select>
  2314. <!-- 删除旧数据-->
  2315. <delete id="deleteAdminDepartment">
  2316. DELETE FROM eam_admin_dept
  2317. WHERE site = #{site}
  2318. AND admin_id = #{adminID}
  2319. </delete>
  2320. <!-- 获取可用的MES账号 -->
  2321. <select id="getMesList" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity" parameterType="com.xujie.sys.modules.sys.entity.SysUserEntity">
  2322. SELECT
  2323. a.username,
  2324. a.user_display
  2325. FROM sys_user a
  2326. LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site
  2327. WHERE a.site = #{site}
  2328. AND b.MesUser is null
  2329. </select>
  2330. <!-- 查询点检项目 -->
  2331. <select id="eamPropertiesItemSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesItemData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  2332. SELECT
  2333. site,
  2334. bu_no,
  2335. dbo.get_bu_desc(site, bu_no) as buDesc,
  2336. ItemNo,
  2337. ItemDesc,
  2338. DefaultValue,
  2339. ValueType,
  2340. ValueType_DB as valueTypeDb,
  2341. ValueChooseFlag,
  2342. case when ValueChooseFlag = 'Y' then '是' when ValueChooseFlag = 'N' then '否' else '' end as valueChooseFlagDesc,
  2343. CreatedDate,
  2344. CreatedBy,
  2345. dbo.getOperatorDesc(site, CreatedBy) as createdByDesc,
  2346. update_date,
  2347. update_by,
  2348. dbo.getOperatorDesc(site, update_by) as updateByDesc,
  2349. MaxValue,
  2350. MinValue,
  2351. ItemRemark,
  2352. ItemType,
  2353. image_flag,
  2354. produce_control_flag,
  2355. check_type
  2356. FROM eam_properties_item
  2357. <where>
  2358. site in (select site from eam_access_site where username = #{query.userName})
  2359. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2360. and check_type in (select role_no from access_role where username = #{query.userName})
  2361. and ItemType = #{query.itemType}
  2362. <if test="query.buDesc != null and query.buDesc != ''">
  2363. AND dbo.get_bu_desc(site, bu_no) = #{query.buDesc}
  2364. </if>
  2365. <if test="query.itemNo != null and query.itemNo != ''">
  2366. AND ItemNo LIKE '%' + #{query.itemNo} + '%'
  2367. </if>
  2368. <if test="query.itemDesc != null and query.itemDesc != ''">
  2369. AND ItemDesc LIKE '%' + #{query.itemDesc} + '%'
  2370. </if>
  2371. <if test="query.checkType != null and query.checkType != ''">
  2372. AND check_type = #{query.checkType}
  2373. </if>
  2374. </where>
  2375. </select>
  2376. <!-- 删除图片-->
  2377. <delete id="imageDelete" parameterType="SysOssEntity">
  2378. DELETE FROM sys_oss
  2379. WHERE id = #{id}
  2380. </delete>
  2381. <!-- 检查该日期内是否已有该设备的计划 -->
  2382. <select id="checkObjectPlan" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2383. SELECT
  2384. a.PlanID,
  2385. a.ObjectID
  2386. FROM eam_workPlan a
  2387. 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
  2388. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.check_type = #{checkType}
  2389. AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N'
  2390. AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  2391. or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  2392. or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0))
  2393. and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod}
  2394. and b.Status not in ('已取消','已完工','待审核')
  2395. </select>
  2396. <!-- 查询当前计划 -->
  2397. <select id="queryWorkPlan" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2398. SELECT
  2399. site,
  2400. bu_no,
  2401. plan_id,
  2402. plan_desc,
  2403. properties_code,
  2404. #{objectID} as objectID,
  2405. status,
  2406. operator,
  2407. delete_flag,
  2408. plan_start_date,
  2409. plan_end_date,
  2410. plan_period,
  2411. function_type,
  2412. checker,
  2413. checker_name,
  2414. operator_name,
  2415. work_order_rule,
  2416. plan_cycle,
  2417. check_type
  2418. FROM eam_workPlan_overview
  2419. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  2420. </select>
  2421. <!-- 获得工单号 -->
  2422. <select id="queryPlanOrderNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2423. SELECT
  2424. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2425. FROM eam_workOrder
  2426. WHERE site = #{site} and bu_no = #{buNo} AND FunctionType = #{functionType}
  2427. </select>
  2428. <!-- 新增工单 -->
  2429. <insert id="insertWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2430. INSERT INTO eam_workOrder
  2431. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, check_type)
  2432. VALUES
  2433. (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{checkType})
  2434. </insert>
  2435. <!-- 循环新增工单 -->
  2436. <insert id="forInsertWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2437. INSERT INTO eam_workOrder
  2438. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, last_execution_date, check_type)
  2439. VALUES
  2440. (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{lastExecutionDate}, #{checkType})
  2441. </insert>
  2442. <!-- 更改plan表的状态为进行中 -->
  2443. <update id="updatePlanStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2444. update eam_workPlan
  2445. set status = '进行中',
  2446. NextWorkDate = PlanStartDate
  2447. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2448. </update>
  2449. <!-- 获得工单号 -->
  2450. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2451. SELECT
  2452. id,
  2453. file_name
  2454. FROM sys_oss
  2455. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2456. </select>
  2457. <!-- 删除原来工单项目-->
  2458. <delete id="deleteWorkPlanItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2459. DELETE FROM eam_workPlan_item
  2460. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2461. </delete>
  2462. <!-- 删除原来的可选值-->
  2463. <delete id="deleteWorkPlanItemAvailable" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2464. DELETE FROM eam_workPlan_item_available
  2465. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2466. </delete>
  2467. <!-- 添加新项目 -->
  2468. <insert id="saveWorkPlanItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2469. 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)
  2470. select
  2471. #{site},
  2472. #{buNo},
  2473. #{planID},
  2474. #{objectID},
  2475. a.ItemNo,
  2476. a.ItemDesc,
  2477. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  2478. case when c.site is not null then c.ValueType else a.ValueType end,
  2479. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  2480. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  2481. case when c.site is not null then c.MaxValue else a.MaxValue end,
  2482. case when c.site is not null then c.MinValue else a.MinValue end,
  2483. a.ItemRemark,
  2484. a.ItemType,
  2485. GetDate(),
  2486. #{userId},
  2487. a.image_flag,
  2488. a.produce_control_flag
  2489. from eam_properties_item a
  2490. 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
  2491. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  2492. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2493. order by b.order_id
  2494. </insert>
  2495. <!-- 添加新项目可选值 -->
  2496. <insert id="saveWorkPlanItemAvailable" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2497. INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  2498. SELECT DISTINCT
  2499. #{site},
  2500. #{buNo},
  2501. #{planID},
  2502. #{objectID},
  2503. a.ItemNo,
  2504. a.ItemType,
  2505. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  2506. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  2507. GetDate(),
  2508. #{userId}
  2509. FROM eam_properties_item_available a
  2510. 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
  2511. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  2512. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2513. </insert>
  2514. <!-- 检查维修任务号是否已存在 -->
  2515. <select id="getEamGzData" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2516. select
  2517. a.Site,
  2518. a.bu_no,
  2519. a.FeedBackID,
  2520. a.FeedBackDesc,
  2521. a.ObjectID,
  2522. a.Status,
  2523. ISNULL(c.public_facilities_flag,'N') AS public_facilities_flag
  2524. from eam_defect_feedBack a
  2525. left join eam_defect b on a.DefectID = b.DefectID
  2526. left join eam_object c on a.ObjectID = c.ObjectID and a.site = c.site and a.bu_no = c.bu_no
  2527. <where>
  2528. a.site = #{site} and a.deleteFlag = 'N' and a.bu_no = #{buNo} and a.repair_type = #{repairType}
  2529. <if test="feedBackID != null and feedBackID != ''">
  2530. AND a.FeedBackID LIKE '%' + #{feedBackID}+'%'
  2531. </if>
  2532. <if test="feedBackDesc != null and feedBackDesc != ''">
  2533. AND a.FeedBackDesc LIKE '%' + #{feedBackDesc}+'%'
  2534. </if>
  2535. <if test="objectInfo != null and objectInfo != ''">
  2536. AND (a.ObjectID like '%' + #{objectInfo} + '%' or dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) like '%' + #{objectInfo} + '%')
  2537. </if>
  2538. <if test="defectInfo != null and defectInfo != ''">
  2539. AND (a.DefectID like '%' + #{defectInfo} + '%' or b.defectDesc like '%' + #{defectInfo} + '%')
  2540. </if>
  2541. </where>
  2542. ORDER BY a.CreatedDate desc
  2543. </select>
  2544. <!-- 保存故障信息 -->
  2545. <insert id="saveEamGzBbData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2546. INSERT INTO eam_defect_feedBack
  2547. (Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate,
  2548. Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency, repair_reporting_type, repair_type)
  2549. VALUES
  2550. (#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate},
  2551. #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency}, #{repairReportingType}, #{repairType})
  2552. </insert>
  2553. <!-- 查看现场动控是否开启 -->
  2554. <select id="selectControlBaseData" resultType="com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity" parameterType="string">
  2555. SELECT
  2556. type,
  2557. base_data,
  2558. base_desc,
  2559. status,
  2560. remark,
  2561. third_type,
  2562. second_type,
  2563. page_control,
  2564. control_style
  2565. FROM sys_scene_dynamic_control_model
  2566. where site = #{site} and control_no = #{controlNo}
  2567. </select>
  2568. <!-- 修改反馈状态为已下达 -->
  2569. <update id="updateDefectFeedBackStatus" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2570. UPDATE eam_defect_feedBack
  2571. SET Status = '已下达'
  2572. WHERE Site = #{site} and bu_no = #{buNo} and FeedBackID = #{feedBackID}
  2573. </update>
  2574. <!-- 查询工单号 -->
  2575. <select id="getOrderNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2576. select
  2577. 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2578. from eam_workOrder
  2579. where site = #{site} and FunctionType = 'C' and bu_no = #{buNo}
  2580. </select>
  2581. <!-- 创建维修工单 -->
  2582. <insert id="saveWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2583. INSERT INTO eam_workOrder
  2584. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source, repair_reporting_type, repair_type, PlanOperator)
  2585. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource}, #{repairReportingType}, #{repairType}, #{planOperator})
  2586. </insert>
  2587. <!-- 修改工单 -->
  2588. <update id="updateWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2589. update eam_workOrder
  2590. set update_by = #{mesUser},
  2591. update_date = GetDate(),
  2592. Remark = #{remark},
  2593. reach_date = #{reachDate},
  2594. ActualDate = #{actualDate},
  2595. WorkTime = #{workTime},
  2596. <if test='functionType == "B" and checkResult == "合格"'>
  2597. disposal_measures = '',
  2598. </if>
  2599. <if test='functionType == "B" and checkResult == "异常"'>
  2600. disposal_measures = #{disposalMeasures},
  2601. </if>
  2602. checkResult = #{checkResult},
  2603. check_remark = #{checkRemark},
  2604. fault_reason = #{faultReason},
  2605. preventive_measure = #{preventiveMeasure}
  2606. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  2607. </update>
  2608. <!-- 修改工单项目 -->
  2609. <update id="updateWorkOrderItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2610. update eam_workOrder_item
  2611. set update_by = #{updateBy},
  2612. update_date = GetDate(),
  2613. <if test='valueTypeDb == "T"'>
  2614. TextValue = #{textValue},
  2615. </if>
  2616. <if test='valueTypeDb == "N"'>
  2617. NumberValue = #{numberValue},
  2618. </if>
  2619. itemResult = #{itemResult}
  2620. where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
  2621. </update>
  2622. <!-- 删除之前的协同人员-->
  2623. <delete id="delOperator" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2624. DELETE FROM eam_actual_operator
  2625. WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
  2626. </delete>
  2627. <!-- 到达 -->
  2628. <update id="reach" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2629. update eam_workOrder
  2630. set Status = #{status},
  2631. reach_date = GetDate(),
  2632. reach_operator = #{reachOperator},
  2633. reach_operator_name = #{reachOperatorName}
  2634. where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_No = #{buNo}
  2635. </update>
  2636. <!-- 查询是否已经上传图片 -->
  2637. <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemData">
  2638. SELECT
  2639. id
  2640. FROM sys_oss
  2641. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo}
  2642. </select>
  2643. <!-- 查询文件路径 -->
  2644. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemData">
  2645. SELECT
  2646. id,
  2647. url,
  2648. file_name
  2649. FROM sys_oss
  2650. WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2651. </select>
  2652. <!-- 根据工单号查询知识库记录 -->
  2653. <select id="selectKnowledgeRecordByOrderNo" resultType="com.xujie.sys.modules.pms.data.EamKnowledgeBaseData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2654. SELECT
  2655. site,
  2656. bu_no,
  2657. num
  2658. FROM eam_knowledge_base
  2659. WHERE site = #{site} and bu_no = #{buNo} and order_no = #{orderNo}
  2660. </select>
  2661. <!-- 根据工单号修改知识库记录 -->
  2662. <update id="updateKnowledgeRecordByOrderNo" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2663. update eam_knowledge_base
  2664. SET defect_id = #{defectID},
  2665. defect_desc = #{defectDesc},
  2666. defect_describe = #{planDesc},
  2667. remark = #{remark},
  2668. fault_reason = #{faultReason},
  2669. handling_method = #{handlingMethod},
  2670. preventive_measure = #{preventiveMeasure},
  2671. feedback_by = #{feedbackBy},
  2672. actual_operator_name = #{actualOperatorName},
  2673. update_date = getDate(),
  2674. update_by = #{updateBy}
  2675. where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2676. </update>
  2677. <!-- 新增设备知识库记录 -->
  2678. <insert id="saveKnowledgeRecord" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2679. INSERT INTO eam_knowledge_base
  2680. (site, bu_no, num, defect_describe, remark, object_id, defect_id, defect_desc, order_no,
  2681. fault_reason, handling_method, preventive_measure, feedback_by, actual_operator_name, create_date, create_by)
  2682. VALUES
  2683. (#{site}, #{buNo}, #{num}, #{planDesc}, #{remark}, #{objectID}, #{defectID}, #{defectDesc}, #{orderNo},
  2684. #{faultReason}, #{handlingMethod}, #{preventiveMeasure}, #{feedbackBy}, #{actualOperatorName}, getDate(), #{updateBy})
  2685. </insert>
  2686. <!-- 修改反馈状态为已取消 -->
  2687. <update id="updateFeedBackStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2688. UPDATE eam_defect_feedBack
  2689. SET Status = '已取消'
  2690. WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
  2691. </update>
  2692. <!-- 获取所有分类 -->
  2693. <select id="getFamilyTree" resultType="com.xujie.sys.modules.pms.data.EamFamilyData" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData">
  2694. SELECT
  2695. site,
  2696. bu_no,
  2697. FamilyID,
  2698. FamilyDesc,
  2699. parent_id,
  2700. son_id,
  2701. Active
  2702. FROM eam_family
  2703. WHERE site in (select site from eam_access_site where username = #{userName})
  2704. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2705. and Active = 'Y'
  2706. </select>
  2707. <!-- 获得sonId -->
  2708. <select id="getSonId" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData">
  2709. SELECT
  2710. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2)
  2711. FROM eam_family
  2712. WHERE site = #{site} and bu_no = #{buNo} and son_id like #{parentId} + '%'
  2713. </select>
  2714. <!-- 删除该分类以及其子类-->
  2715. <delete id="eamFamilyDelete" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData">
  2716. DELETE FROM eam_family
  2717. WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID}
  2718. <if test="sonId != null and sonId != ''">
  2719. and son_id like #{sonId} + '%'
  2720. </if>
  2721. </delete>
  2722. <select id="getEamWorkOrder" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2723. EXEC EAM_WORK_ORDER #{site}, #{username}, #{orderNo}, #{planID}, #{objectID}, #{status}, #{startDate}, #{endDate}, #{functionType}, '*'
  2724. </select>
  2725. <!-- 修改执行结果 -->
  2726. <update id="updateReportResult" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2727. update eam_workOrder
  2728. set ActualDate = #{actualDate},
  2729. reach_date = #{reachDate},
  2730. fault_reason = #{faultReason},
  2731. handling_method = #{handlingMethod},
  2732. preventive_measure = #{preventiveMeasure},
  2733. Remark = #{remark},
  2734. WorkTime = #{workTime},
  2735. check_assessment = #{checkAssessment},
  2736. check_notes = #{checkNotes}
  2737. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2738. </update>
  2739. <!-- 根据设备查所属部门 -->
  2740. <select id="queryDepartmentByObjectId" resultType="com.xujie.sys.modules.pms.data.EamObjectAdminData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2741. SELECT
  2742. eo.site,
  2743. eo.bu_no,
  2744. eo.ObjectDesc,
  2745. eo.dept_id,
  2746. el.LocationName
  2747. FROM eam_object as eo
  2748. LEFT JOIN eam_location as el on eo.site = el.site and eo.LocationID = el.LocationID and eo.bu_no = el.bu_no
  2749. WHERE eo.site = #{site} and eo.ObjectID = #{objectID} and eo.bu_no = #{buNo}
  2750. </select>
  2751. <!-- 根据部门ID查机修人员电话 -->
  2752. <select id="queryPhoneByDepartmentId" resultType="com.xujie.sys.modules.pms.data.EamObjectAdminData" parameterType="com.xujie.sys.modules.pms.data.EamObjectAdminData">
  2753. SELECT
  2754. ed.user_display as adminName,
  2755. ed.mobile as phone
  2756. FROM Access_dept as edd
  2757. LEFT JOIN sys_user ed on edd.username = ed.username and edd.site in (select site from eam_access_site where username = ed.username)
  2758. and (edd.site + '-' + edd.bu_no) in (select * from dbo.query_bu(ed.username))
  2759. 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)
  2760. 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
  2761. </select>
  2762. <!-- 保存短信记录 -->
  2763. <insert id="saveMessageRecord" parameterType="com.xujie.sys.modules.pms.data.MessageRecordData">
  2764. INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
  2765. VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
  2766. </insert>
  2767. <!-- 查出计划结束日期为今天并且自动续期标识为Y的计划 -->
  2768. <select id="selectPlanToday" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2769. SELECT
  2770. site,
  2771. (site + '_' + bu_no) as bu,
  2772. plan_id,
  2773. plan_desc,
  2774. status,
  2775. plan_start_date,
  2776. plan_end_date,
  2777. created_date,
  2778. created_by,
  2779. update_date,
  2780. update_by,
  2781. remark,
  2782. next_work_date,
  2783. delete_flag,
  2784. operator,
  2785. operator_name,
  2786. checker,
  2787. checker_name,
  2788. function_type,
  2789. properties_code,
  2790. plan_period,
  2791. work_order_rule,
  2792. plan_cycle,
  2793. task_start_date,
  2794. plan_halt_date,
  2795. auto_renewal,
  2796. check_type
  2797. FROM eam_workPlan_overview
  2798. WHERE site = #{site} and status != #{status} and delete_flag = #{deleteFlag} and DATEDIFF(day, plan_end_date, getdate()) = 0 and auto_renewal = #{autoRenewal}
  2799. </select>
  2800. <!-- 查出老计划的设备 -->
  2801. <select id="selectObjectByPlanID" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2802. SELECT
  2803. Site,
  2804. PlanID,
  2805. PlanDesc,
  2806. ObjectID,
  2807. FunctionType,
  2808. PropertiesCode,
  2809. Status
  2810. FROM eam_workPlan
  2811. WHERE site = #{site} and PlanID = #{planID} and FunctionType = #{functionType}
  2812. </select>
  2813. <!-- 获取用户 bu -->
  2814. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  2815. SELECT
  2816. b.id,
  2817. a.site,
  2818. c.sitename,
  2819. (a.site + '_' + a.bu_no) as buNo,
  2820. b.bu_desc
  2821. FROM AccessBu as a
  2822. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2823. left join site as c on a.site = c.siteid
  2824. WHERE a.username = #{username}
  2825. </select>
  2826. <select id="getProjectCategoryByBu" resultType="com.xujie.sys.modules.pms.data.EamProjectInfoData">
  2827. SELECT DISTINCT
  2828. a.project_category as projectCategory
  2829. FROM plm_bu_project_category as a
  2830. WHERE ISNULL(a.active, 'Y') = 'Y'
  2831. <if test="buNo != null and buNo != ''">
  2832. AND a.bu_no = #{buNo}
  2833. </if>
  2834. AND a.project_category IS NOT NULL
  2835. AND a.project_category != ''
  2836. ORDER BY a.project_category
  2837. </select>
  2838. <!-- 获取用户 bu -->
  2839. <select id="getSiteAndBuByUserName2" resultType="BuData" parameterType="BuData">
  2840. SELECT
  2841. a.site,
  2842. c.sitename,
  2843. a.bu_no,
  2844. b.bu_desc
  2845. FROM AccessBu as a
  2846. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2847. left join site as c on a.site = c.siteid
  2848. WHERE a.username = #{username}
  2849. </select>
  2850. <!-- 获取用户 bu -->
  2851. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  2852. SELECT
  2853. a.site,
  2854. a.bu_no,
  2855. b.bu_desc
  2856. FROM AccessBu as a
  2857. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2858. WHERE a.username = #{username} and a.site = #{site}
  2859. </select>
  2860. <select id="eamCheckRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2861. SELECT
  2862. a.Site,
  2863. a.bu_no,
  2864. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2865. a.OrderNo,
  2866. a.PlanID,
  2867. a.PlanDesc,
  2868. a.PropertiesCode,
  2869. a.ObjectID,
  2870. a.Status,
  2871. a.PlanOperator,
  2872. a.checker,
  2873. a.ActualOperator,
  2874. a.PlanDate,
  2875. a.ActualDate,
  2876. a.FunctionType,
  2877. a.CreateDate,
  2878. d.operator_name as createBy,
  2879. a.Remark,
  2880. a.StartTime,
  2881. a.EndTime,
  2882. a.WorkTime,
  2883. a.PlanOperatorName,
  2884. a.checkerName,
  2885. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) as ActualOperatorName,
  2886. eo.ObjectDesc as objectDesc,
  2887. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  2888. a.result,
  2889. b.urgency,
  2890. a.checkResult,
  2891. b.DefectID,
  2892. c.DefectDesc,
  2893. a.disposal_measures,
  2894. a.check_work_plan_id,
  2895. a.check_item_no,
  2896. a.reach_date,
  2897. a.reach_operator,
  2898. a.reach_operator_name,
  2899. b.FeedBackDesc,
  2900. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  2901. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  2902. a.check_remark,
  2903. a.document_source,
  2904. ewi.ItemNo,
  2905. ewi.ItemDesc,
  2906. ewi.DefaultValue,
  2907. ewi.ValueType,
  2908. ewi.ValueType_DB,
  2909. ewi.ValueChooseFlag,
  2910. ewi.MaxValue,
  2911. ewi.MinValue,
  2912. ewi.ItemRemark,
  2913. ewi.ItemType,
  2914. ewi.TextValue,
  2915. ewi.NumberValue,
  2916. ewi.CreatedDate,
  2917. ewi.CreatedBy,
  2918. ewi.FinishFlag,
  2919. ewi.itemResult,
  2920. ewi.item_notes
  2921. FROM eam_workOrder a
  2922. left join eam_workOrder_item ewi on a.site = ewi.site and a.OrderNo = ewi.OrderNo and a.bu_no = ewi.bu_no
  2923. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  2924. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  2925. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  2926. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  2927. 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
  2928. 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
  2929. left join sys_user as ea on ead.username = ea.username
  2930. 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
  2931. <where>
  2932. a.site in (select site from eam_access_site where username = #{query.userName})
  2933. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2934. and a.check_type in (select role_no from access_role where username = #{query.userName})
  2935. and ea.username = #{query.userName}
  2936. <if test="query.buDesc != null and query.buDesc != ''">
  2937. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2938. </if>
  2939. <if test="query.orderNo != null and query.orderNo != ''">
  2940. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  2941. </if>
  2942. <if test="query.planID != null and query.planID != ''">
  2943. AND a.PlanID like '%' + #{query.planID} +'%'
  2944. </if>
  2945. <if test="query.planDesc != null and query.planDesc != ''">
  2946. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  2947. </if>
  2948. <if test="query.objectID != null and query.objectID != ''">
  2949. AND a.ObjectID like '%' + #{query.objectID} +'%'
  2950. </if>
  2951. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  2952. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  2953. </if>
  2954. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  2955. AND a.status != '已取消'
  2956. </if>
  2957. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  2958. AND a.status = #{query.status}
  2959. </if>
  2960. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  2961. AND a.status = '未开工'
  2962. </if>
  2963. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2964. AND a.status != '已取消'
  2965. </if>
  2966. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2967. AND a.status = #{query.status}
  2968. </if>
  2969. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  2970. AND (a.status = '未开工' or a.status = '已到达')
  2971. </if>
  2972. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  2973. AND (a.status = '未开工' or a.status = '已到达')
  2974. </if>
  2975. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2976. AND a.status = #{query.status}
  2977. </if>
  2978. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2979. AND a.document_source = #{query.documentSource}
  2980. </if>
  2981. <if test="query.planDate != null">
  2982. AND a.PlanDate = #{query.planDate}
  2983. </if>
  2984. <if test="query.startDate != null ">
  2985. AND a.PlanDate >= #{query.startDate}
  2986. </if>
  2987. <if test="query.endDate != null ">
  2988. AND #{query.endDate} >= a.PlanDate
  2989. </if>
  2990. <if test="query.endDate == null ">
  2991. AND getDate() >= a.PlanDate
  2992. </if>
  2993. <if test='query.functionType == "A"'>
  2994. and getDate() >= dbo.compare_date(ewo.task_start_date)
  2995. </if>
  2996. <if test="query.reachDate != null ">
  2997. AND a.reach_date >= #{query.reachDate}
  2998. </if>
  2999. <if test="query.actualDate != null ">
  3000. AND #{query.actualDate} >= a.ActualDate
  3001. </if>
  3002. <if test="query.itemNo != null and query.itemNo != ''">
  3003. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  3004. </if>
  3005. <if test="query.itemDesc != null and query.itemDesc != ''">
  3006. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  3007. </if>
  3008. AND a.FunctionType = #{query.functionType}
  3009. </where>
  3010. </select>
  3011. <select id="eamCheckRecordSearch2" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3012. SELECT
  3013. B.ObjectDesc,
  3014. a.Site,
  3015. a.bu_no,
  3016. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  3017. a.OrderNo,
  3018. a.PlanID,
  3019. a.PlanDesc,
  3020. a.PropertiesCode,
  3021. a.ObjectID,
  3022. a.Status,
  3023. a.PlanOperator,
  3024. a.checker,
  3025. a.ActualOperator,
  3026. a.PlanDate,
  3027. a.ActualDate,
  3028. a.FunctionType,
  3029. a.CreateDate,
  3030. a.Remark,
  3031. a.StartTime,
  3032. a.EndTime,
  3033. a.WorkTime,
  3034. a.PlanOperatorName,
  3035. a.checkerName,
  3036. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) as ActualOperatorName,
  3037. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  3038. a.result,
  3039. a.checkResult,
  3040. a.disposal_measures,
  3041. a.check_work_plan_id,
  3042. a.check_item_no,
  3043. a.reach_date,
  3044. a.reach_operator,
  3045. a.reach_operator_name,
  3046. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  3047. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  3048. a.check_remark,
  3049. a.document_source
  3050. FROM eam_workOrder a
  3051. INNER JOIN eam_object B ON A.SITE = B.SITE AND A.bu_no = B.bu_no AND A.ObjectID = B.ObjectID
  3052. <where>
  3053. A.site = #{query.site} AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc} and a.PlanOperatorName like '%网格员%'
  3054. <if test="query.orderNo != null and query.orderNo != ''">
  3055. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  3056. </if>
  3057. <if test="query.planID != null and query.planID != ''">
  3058. AND a.PlanID like '%' + #{query.planID} +'%'
  3059. </if>
  3060. <if test="query.planDesc != null and query.planDesc != ''">
  3061. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  3062. </if>
  3063. <if test="query.objectID != null and query.objectID != ''">
  3064. AND a.ObjectID like '%' + #{query.objectID} +'%'
  3065. </if>
  3066. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  3067. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  3068. </if>
  3069. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  3070. AND a.document_source = #{query.documentSource}
  3071. </if>
  3072. <if test="query.planDate != null">
  3073. AND a.PlanDate = #{query.planDate}
  3074. </if>
  3075. <if test="query.startDate != null ">
  3076. AND a.PlanDate >= #{query.startDate}
  3077. </if>
  3078. <if test="query.endDate != null ">
  3079. AND #{query.endDate} >= a.PlanDate
  3080. </if>
  3081. <if test="query.endDate == null ">
  3082. AND getDate() >= a.PlanDate
  3083. </if>
  3084. <if test="query.reachDate != null ">
  3085. AND a.reach_date >= #{query.reachDate}
  3086. </if>
  3087. <if test="query.actualDate != null ">
  3088. AND #{query.actualDate} >= a.ActualDate
  3089. </if>
  3090. <if test="query.status != null and query.status != ''">
  3091. AND a.status = #{query.status}
  3092. </if>
  3093. AND a.FunctionType = #{query.functionType}
  3094. </where>
  3095. </select>
  3096. <select id="eamDefectRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3097. SELECT
  3098. a.Site,
  3099. a.bu_no,
  3100. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  3101. a.OrderNo,
  3102. a.PlanID,
  3103. a.ObjectID,
  3104. a.Status,
  3105. a.PlanOperator,
  3106. a.ActualOperator,
  3107. a.PlanDate,
  3108. a.ActualDate,
  3109. a.FunctionType,
  3110. a.CreateDate,
  3111. d.operator_name as createBy,
  3112. a.Remark,
  3113. a.StartTime,
  3114. a.EndTime,
  3115. a.WorkTime,
  3116. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  3117. b.DefectID,
  3118. c.DefectDesc,
  3119. e.ObjectDesc as objectDesc,
  3120. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  3121. a.result,
  3122. b.urgency,
  3123. a.disposal_measures,
  3124. a.difficulty_level,
  3125. a.difficulty_remark,
  3126. f.department_name,
  3127. a.reach_date,
  3128. b.CreatedDate,
  3129. a.handling_method,
  3130. a.repair_reporting_type as repairReportingType,
  3131. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  3132. CASE
  3133. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  3134. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  3135. END AS responseTime,
  3136. b.FeedBackDesc,
  3137. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  3138. a.fault_reason,
  3139. a.preventive_measure,
  3140. a.document_source,
  3141. ewi.ItemNo,
  3142. ewi.ItemDesc,
  3143. ewi.DefaultValue,
  3144. ewi.ValueType,
  3145. ewi.ValueType_DB,
  3146. ewi.ValueChooseFlag,
  3147. ewi.MaxValue,
  3148. ewi.MinValue,
  3149. ewi.ItemRemark,
  3150. ewi.ItemType,
  3151. ewi.TextValue,
  3152. ewi.NumberValue,
  3153. ewi.FinishFlag,
  3154. ewi.itemResult,
  3155. ewi.item_notes
  3156. FROM eam_workOrder a
  3157. left join eam_workOrder_item ewi on a.site = ewi.site and a.bu_no = ewi.bu_no and a.OrderNo = ewi.OrderNo
  3158. left join eam_defect_feedBack b on a.site = b.site and a.bu_no = b.bu_no and a.PlanID = b.feedBackID
  3159. left join eam_defect c on b.DefectID = c.DefectID
  3160. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  3161. 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'
  3162. 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
  3163. 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
  3164. left join sys_user as ea on ead.username = ea.username
  3165. <where>
  3166. a.site in (select site from eam_access_site where username = #{query.userName})
  3167. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  3168. and ea.username = #{query.userName}
  3169. <if test="query.buDesc != null and query.buDesc != ''">
  3170. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  3171. </if>
  3172. <if test="query.deptArr != null">
  3173. AND
  3174. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  3175. f.department_name like '%' + #{item} + '%'
  3176. </foreach>
  3177. </if>
  3178. <if test="query.orderNo != null and query.orderNo != ''">
  3179. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  3180. </if>
  3181. <if test="query.planID != null and query.planID != ''">
  3182. AND a.PlanID like '%' + #{query.planID} +'%'
  3183. </if>
  3184. <if test="query.objectID != null and query.objectID != ''">
  3185. AND a.ObjectID like '%' + #{query.objectID} +'%'
  3186. </if>
  3187. <if test="query.planOperator != null and query.planOperator != ''">
  3188. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  3189. </if>
  3190. <if test="query.status != null and query.status != ''">
  3191. AND a.status = #{query.status}
  3192. </if>
  3193. <if test="query.documentSource != null and query.documentSource != ''">
  3194. AND a.document_source = #{query.documentSource}
  3195. </if>
  3196. <if test="query.createdDate != null ">
  3197. And a.CreatedDate >= #{query.createdDate}
  3198. </if>
  3199. <if test="query.startDate != null ">
  3200. AND a.PlanDate >= #{query.startDate}
  3201. </if>
  3202. <if test="query.endDate != null ">
  3203. AND #{query.endDate} >= a.PlanDate
  3204. </if>
  3205. <if test="query.reachDate != null ">
  3206. AND a.reach_date >= #{query.reachDate}
  3207. </if>
  3208. <if test="query.actualDate != null ">
  3209. AND #{query.actualDate} >= a.ActualDate
  3210. </if>
  3211. <if test="query.itemNo != null and query.itemNo != ''">
  3212. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  3213. </if>
  3214. <if test="query.itemDesc != null and query.itemDesc != ''">
  3215. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  3216. </if>
  3217. <if test="query.createdStartDate != null ">
  3218. AND b.CreatedDate >= #{query.createdStartDate}
  3219. </if>
  3220. <if test="query.createdEndDate != null ">
  3221. AND #{query.createdEndDate} >= b.CreatedDate
  3222. </if>
  3223. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  3224. AND a.repair_reporting_type like '%' + #{query.repairReportingType} + '%'
  3225. </if>
  3226. and a.FunctionType =#{query.functionType}
  3227. </where>
  3228. </select>
  3229. <select id="eamDefectRecordExport" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamDefectRecordExportData">
  3230. SELECT
  3231. b.urgency as urgency,
  3232. a.result as result,
  3233. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  3234. a.disposal_measures as disposalMeasures,
  3235. a.OrderNo as orderNo,
  3236. a.PlanID as planID,
  3237. b.FeedBackDesc as feedBackDesc,
  3238. b.DefectID as defectID,
  3239. c.DefectDesc as defectDesc,
  3240. a.ObjectID as objectID,
  3241. e.ObjectDesc as objectDesc,
  3242. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  3243. f.department_name as departmentName,
  3244. d.operator_name as createBy,
  3245. a.repair_reporting_type as repairReportingType,
  3246. a.Status as status,
  3247. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  3248. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  3249. a.PlanDate as planDate,
  3250. b.CreatedDate as createdDate,
  3251. a.reach_date as reachDate,
  3252. a.ActualDate as actualDate,
  3253. CASE
  3254. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  3255. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  3256. END AS responseTime,
  3257. a.WorkTime as workTime,
  3258. a.Remark as remark,
  3259. a.difficulty_level as difficultyLevel,
  3260. a.difficulty_remark as difficultyRemark,
  3261. a.document_source as documentSource,
  3262. ewi.ItemNo as itemNo,
  3263. ewi.ItemDesc as itemDesc,
  3264. ewi.ItemRemark as itemRemark,
  3265. ewi.ValueType as valueType,
  3266. ewi.DefaultValue as defaultValue,
  3267. ewi.MaxValue as maxValue,
  3268. ewi.MinValue as minValue
  3269. FROM eam_workOrder a
  3270. left join eam_workOrder_item ewi on a.site = ewi.site and a.bu_no = ewi.bu_no and a.OrderNo = ewi.OrderNo
  3271. left join eam_defect_feedBack b on a.site = b.site and a.bu_no = b.bu_no and a.PlanID = b.feedBackID
  3272. left join eam_defect c on b.DefectID = c.DefectID
  3273. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  3274. 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'
  3275. 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
  3276. <where>
  3277. a.site in (select site from eam_access_site where username = #{query.userName})
  3278. and a.site_bu_key in (select * from dbo.query_bu(#{query.userName}))
  3279. and exists (
  3280. select 1
  3281. from Access_dept as ead
  3282. where ead.site = f.site
  3283. and ead.bu_no = f.bu_no
  3284. and ead.department_id = f.department_id
  3285. and ead.username = #{query.userName}
  3286. )
  3287. <if test="query.buDesc != null and query.buDesc != ''">
  3288. AND exists (select 1 from BU bu where bu.site = a.site and bu.bu_no = a.bu_no and bu.bu_desc = #{query.buDesc})
  3289. </if>
  3290. <if test="query.deptArr != null">
  3291. AND
  3292. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  3293. f.department_name like '%' + #{item} + '%'
  3294. </foreach>
  3295. </if>
  3296. <if test="query.orderNo != null and query.orderNo != ''">
  3297. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  3298. </if>
  3299. <if test="query.planID != null and query.planID != ''">
  3300. AND a.PlanID like '%' + #{query.planID} +'%'
  3301. </if>
  3302. <if test="query.objectID != null and query.objectID != ''">
  3303. AND a.ObjectID like '%' + #{query.objectID} +'%'
  3304. </if>
  3305. <if test="query.planOperator != null and query.planOperator != ''">
  3306. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  3307. </if>
  3308. <if test="query.status != null and query.status != ''">
  3309. AND a.status = #{query.status}
  3310. </if>
  3311. <if test="query.documentSource != null and query.documentSource != ''">
  3312. AND a.document_source = #{query.documentSource}
  3313. </if>
  3314. <if test="query.createdDate != null ">
  3315. And a.CreatedDate >= #{query.createdDate}
  3316. </if>
  3317. <if test="query.startDate != null ">
  3318. AND a.PlanDate >= #{query.startDate}
  3319. </if>
  3320. <if test="query.endDate != null ">
  3321. AND #{query.endDate} >= a.PlanDate
  3322. </if>
  3323. <if test="query.reachDate != null ">
  3324. AND a.reach_date >= #{query.reachDate}
  3325. </if>
  3326. <if test="query.actualDate != null ">
  3327. AND #{query.actualDate} >= a.ActualDate
  3328. </if>
  3329. <if test="query.itemNo != null and query.itemNo != ''">
  3330. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  3331. </if>
  3332. <if test="query.itemDesc != null and query.itemDesc != ''">
  3333. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  3334. </if>
  3335. <if test="query.createdStartDate != null ">
  3336. AND b.CreatedDate >= #{query.createdStartDate}
  3337. </if>
  3338. <if test="query.createdEndDate != null ">
  3339. AND #{query.createdEndDate} >= b.CreatedDate
  3340. </if>
  3341. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  3342. AND a.repair_reporting_type = #{query.repairReportingType}
  3343. </if>
  3344. and a.FunctionType =#{query.functionType}
  3345. </where>
  3346. </select>
  3347. <!-- 获取用户角色列表 -->
  3348. <select id="getUserRoleList" resultType="com.xujie.sys.modules.sys.entity.SysRoleEntity">
  3349. SELECT
  3350. role_id,
  3351. role_name
  3352. FROM sys_role
  3353. </select>
  3354. <!-- 获取故障图片 -->
  3355. <select id="getFeedBackImages" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3356. SELECT
  3357. id,
  3358. url,
  3359. create_date,
  3360. file_name,
  3361. new_file_name,
  3362. created_by,
  3363. order_ref1,
  3364. order_ref2,
  3365. order_ref3,
  3366. order_ref4,
  3367. file_type,
  3368. file_suffix,
  3369. file_type_code,
  3370. case when order_ref3 = 'feedBack' then '报修' when order_ref3 = 'reportFault' then '维修' end as typeFlag
  3371. FROM sys_oss
  3372. where order_ref1 = #{site} and (order_ref2 = #{orderNo} or order_ref2 = #{planID}) and order_ref3 in ('feedBack', 'reportFault') and order_ref4 = #{buNo}
  3373. </select>
  3374. <!-- 获取故障图片 -->
  3375. <select id="getFeedBackImages2" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3376. SELECT
  3377. id,
  3378. url,
  3379. create_date,
  3380. file_name,
  3381. new_file_name,
  3382. created_by,
  3383. order_ref1,
  3384. order_ref2,
  3385. order_ref3,
  3386. order_ref4,
  3387. file_type,
  3388. file_suffix,
  3389. file_type_code
  3390. FROM sys_oss
  3391. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = 'reportSparPart' and order_ref4 = #{buNo}
  3392. </select>
  3393. <insert id="saveCoreComponent">
  3394. insert into eam_workOrder_coreComponents
  3395. (site, bu_no, OrderNo, ItemNo, partNo, oldSerialNo, newSerialNo, created_by, created_date)
  3396. values
  3397. (#{site}, #{buNo}, #{orderNo}, #{itemNo}, #{partNo}, #{oldSerialNo}, #{newSerialNo}, #{createdBy}, GetDate())
  3398. </insert>
  3399. <update id="updateCoreComponent">
  3400. UPDATE eam_workOrder_coreComponents
  3401. SET oldSerialNo = #{oldSerialNo},
  3402. newSerialNo = #{newSerialNo}
  3403. WHERE site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
  3404. </update>
  3405. <!-- 获取领用出库信息 -->
  3406. <select id="getInventoryStockList" resultType="com.xujie.sys.modules.pms.data.InventoryStockData" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData">
  3407. SELECT
  3408. A.site,
  3409. A.part_no,
  3410. A.batch_no,
  3411. isnull(A.qty_on_hand ,0) as qtyOnHand,
  3412. isnull(A.in_qty,0) inQty,
  3413. isnull(A.out_qty,0) as outQty,
  3414. A.warehouse_id,
  3415. A.location_id,
  3416. (B.part_description + '/' + B.spec) as partDescription,
  3417. B.S_code_control_flag,
  3418. B.supplier_id,
  3419. dbo.qc_get_supplier_name(A.site, B.supplier_id) as supplierDesc
  3420. FROM inventory_stock as A
  3421. left join part_spare as B on A.site = B.site and A.part_no = B.part_no
  3422. <where>
  3423. A.site = #{site}
  3424. <if test="partNo != null and partNo != ''">
  3425. AND A.part_no = #{partNo}
  3426. </if>
  3427. <if test="batchNo != null and batchNo != ''">
  3428. AND A.batch_no = #{batchNo}
  3429. </if>
  3430. <if test="active != null and active != ''">
  3431. AND B.active = #{active}
  3432. </if>
  3433. </where>
  3434. </select>
  3435. <!-- 查询设备 -->
  3436. <select id="getResourceCount" resultType="com.xujie.sys.modules.pms.data.ResourceData" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3437. SELECT
  3438. id,
  3439. site,
  3440. resource_id,
  3441. resource_desc
  3442. FROM resource
  3443. where site = #{site} and resource_id = #{resourceId}
  3444. </select>
  3445. <!-- 获取编码信息 -->
  3446. <select id="getTransNo" resultType="com.xujie.sys.modules.pms.data.TransNoData" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3447. SELECT
  3448. #{site} as site,
  3449. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  3450. </select>
  3451. <!-- 修改编码信息 -->
  3452. <select id="updateTransNo" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3453. EXEC UpdateTransNo #{site}, #{transTypeDB}
  3454. </select>
  3455. <select id="getInventoryStockCount" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData" resultType="int">
  3456. select
  3457. count(1)
  3458. from inventory_stock
  3459. where site = #{site} and part_no = #{partNo}
  3460. </select>
  3461. <select id="queryEamDocumentType" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  3462. SELECT
  3463. a.site,
  3464. a.document_type_id,
  3465. a.document_type,
  3466. a.responsible_department,
  3467. a.estimated_completion_days,
  3468. a.create_date,
  3469. a.create_by,
  3470. a.update_date,
  3471. a.update_by,
  3472. b.role_desc
  3473. FROM document_type_definition as a
  3474. LEFT JOIN business_role as b on a.site = b.site and a.responsible_department = b.role_no
  3475. WHERE
  3476. a.site in (select eas.site from eam_access_site as eas where eas.username = #{params.userName})
  3477. <if test="params.sql != null and params.sql != ''">
  3478. ${params.sql}
  3479. </if>
  3480. </select>
  3481. <select id="eamDocumentTypeSearch" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  3482. SELECT
  3483. a.site,
  3484. a.document_type_id,
  3485. a.document_type,
  3486. a.responsible_department,
  3487. a.estimated_completion_days,
  3488. a.create_date,
  3489. a.create_by,
  3490. a.update_date,
  3491. a.update_by,
  3492. b.role_desc
  3493. FROM document_type_definition as a
  3494. LEFT JOIN business_role as b on a.site = b.site and a.responsible_department = b.role_no
  3495. WHERE
  3496. a.site in (select eas.site from eam_access_site as eas where eas.username = #{query.userName})
  3497. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  3498. AND UPPER(a.document_type_id) LIKE '%' + UPPER(#{query.documentTypeId}) + '%'
  3499. </if>
  3500. <if test="query.documentType != null and query.documentType != ''">
  3501. AND UPPER(a.document_type) LIKE '%' + UPPER(#{query.documentType}) + '%'
  3502. </if>
  3503. <if test="query.responsibleDepartment != null and query.responsibleDepartment != ''">
  3504. AND UPPER(a.responsible_department) LIKE '%' + UPPER(#{query.responsibleDepartment}) + '%'
  3505. </if>
  3506. </select>
  3507. <select id="checkEamDocumentType" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  3508. SELECT
  3509. Site,
  3510. document_type_id,
  3511. document_type,
  3512. responsible_department,
  3513. estimated_completion_days
  3514. FROM document_type_definition
  3515. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  3516. </select>
  3517. <insert id="saveNewEamDocumentType">
  3518. INSERT INTO document_type_definition
  3519. (Site, document_type_id, document_type, responsible_department, estimated_completion_days,create_date, create_by)
  3520. VALUES
  3521. (#{site}, #{documentTypeId}, #{documentType}, #{responsibleDepartment}, #{estimatedCompletionDays}, getDate(), #{createBy})
  3522. </insert>
  3523. <update id="eamDocumentTypeEdit">
  3524. UPDATE document_type_definition
  3525. SET document_type = #{documentType},
  3526. responsible_department = #{responsibleDepartment},
  3527. estimated_completion_days = #{estimatedCompletionDays},
  3528. update_date = getDate(),
  3529. update_by = #{updateBy}
  3530. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  3531. </update>
  3532. <delete id="eamDocumentTypeDelete">
  3533. DELETE FROM document_type_definition
  3534. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  3535. </delete>
  3536. <select id="queryBuDocument" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  3537. SELECT
  3538. a.id,
  3539. a.site,
  3540. a.bu_no,
  3541. dbo.get_bu_desc ( a.site, a.bu_no ) as buDesc,
  3542. a.project_category,
  3543. a.document_type_id,
  3544. a.project_phase,
  3545. c.document_type,
  3546. c.responsible_department,
  3547. c.estimated_completion_days,
  3548. a.create_date,
  3549. a.create_by,
  3550. a.update_date,
  3551. a.update_by,
  3552. b.bu_desc,
  3553. d.role_desc
  3554. FROM bu_document_list_definition as a
  3555. LEFT JOIN bu as b on a.site = b.site and a.bu_no = b.bu_no
  3556. LEFT JOIN document_type_definition as c on a.document_type_id = c.document_type_id
  3557. LEFT JOIN business_role as d on a.site = d.site and c.responsible_department = d.role_no
  3558. WHERE
  3559. a.site in (select site from eam_access_site where username = #{params.userName})
  3560. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{params.userName}))
  3561. <if test="params.sql != null and params.sql != ''">
  3562. ${params.sql}
  3563. </if>
  3564. ORDER BY
  3565. b.bu_no,
  3566. a.project_phase,
  3567. a.project_category,
  3568. a.document_type_id
  3569. </select>
  3570. <select id="eamBuDocumentSearch" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  3571. SELECT
  3572. a.id,
  3573. a.site,
  3574. a.bu_no,
  3575. a.project_category,
  3576. a.document_type_id,
  3577. a.project_phase,
  3578. c.document_type,
  3579. c.responsible_department,
  3580. c.estimated_completion_days,
  3581. a.create_date,
  3582. a.create_by,
  3583. a.update_date,
  3584. a.update_by,
  3585. b.bu_desc,
  3586. d.role_desc
  3587. FROM bu_document_list_definition as a
  3588. LEFT JOIN bu as b on a.site = b.site and a.bu_no = b.bu_no
  3589. LEFT JOIN document_type_definition as c on a.document_type_id = c.document_type_id
  3590. LEFT JOIN business_role as d on a.site = d.site and c.responsible_department = d.role_no
  3591. WHERE
  3592. a.site in (select site from eam_access_site where username = #{query.userName})
  3593. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  3594. <if test="query.buDesc != null and query.buDesc != ''">
  3595. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  3596. </if>
  3597. <if test="query.projectPhase != null and query.projectPhase != ''">
  3598. AND a.project_phase = #{query.projectPhase}
  3599. </if>
  3600. <if test="query.projectCategory != null and query.projectCategory != ''">
  3601. AND a.project_category = #{query.projectCategory}
  3602. </if>
  3603. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  3604. AND UPPER(a.document_type_id) LIKE '%' + UPPER(#{query.documentTypeId}) + '%'
  3605. </if>
  3606. <if test="query.documentType != null and query.documentType != ''">
  3607. AND UPPER(c.document_type) LIKE '%' + UPPER(#{query.documentType}) + '%'
  3608. </if>
  3609. ORDER BY
  3610. b.bu_no,
  3611. a.project_phase,
  3612. a.project_category,
  3613. a.document_type_id
  3614. </select>
  3615. <select id="checkEamBuDocument" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  3616. SELECT
  3617. Site,
  3618. bu_no,
  3619. project_category,
  3620. document_type_id,
  3621. project_phase
  3622. FROM bu_document_list_definition
  3623. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  3624. </select>
  3625. <select id="checkEamDocumentTypeDelete" resultType="Integer">
  3626. SELECT COUNT(*) FROM bu_document_list_definition t1
  3627. WHERE t1.document_type_id = #{documentTypeId}
  3628. UNION ALL
  3629. SELECT COUNT(*) FROM plm_document_list_definition t2
  3630. WHERE t2.document_type_id = #{documentTypeId}
  3631. </select>
  3632. <insert id="saveNewEamBuDocument">
  3633. INSERT INTO bu_document_list_definition
  3634. (Site, bu_no, project_category, document_type_id, project_phase,create_date, create_by)
  3635. VALUES
  3636. (#{site}, #{buNo}, #{projectCategory}, #{documentTypeId}, #{projectPhase},getDate(), #{createBy})
  3637. </insert>
  3638. <update id="eamBuDocumentEdit">
  3639. UPDATE bu_document_list_definition
  3640. SET project_phase = #{projectPhase},
  3641. project_category = #{projectCategory},
  3642. update_date = getDate(),
  3643. update_by = #{updateBy}
  3644. WHERE Site = #{site} and bu_no = #{buNo} and document_type_id = #{documentTypeId} and id = #{id}
  3645. </update>
  3646. <delete id="eamBuDocumentDelete">
  3647. DELETE FROM bu_document_list_definition
  3648. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  3649. </delete>
  3650. <delete id="deleteCoreComponents">
  3651. delete from eam_workOrder_coreComponents
  3652. WHERE site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
  3653. </delete>
  3654. <update id="cancelDefectOrder">
  3655. update eam_workOrder
  3656. set Status = '已取消'
  3657. where site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo} and FunctionType = #{functionType}
  3658. </update>
  3659. <update id="updateInventoryStock" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData">
  3660. update inventory_stock
  3661. set in_qty = #{inQty},
  3662. out_qty = #{outQty},
  3663. qty_on_hand = #{qtyOnHand},
  3664. latest_out_date = getDate(),
  3665. latest_count_date = getDate()
  3666. <where>
  3667. site = #{site}
  3668. <if test="partNo != null and partNo != ''">
  3669. AND part_no = #{partNo}
  3670. </if>
  3671. <if test="batchNo != null and batchNo != ''">
  3672. AND batch_no = #{batchNo}
  3673. </if>
  3674. </where>
  3675. </update>
  3676. <insert id="saveRepairTransDetailSub" parameterType="com.xujie.sys.modules.pms.data.RepairTransDetailSubData">
  3677. insert into repair_TransDetailsub
  3678. (TransNo, SeqNo, Site, itemNo, LocationID, BatchNo, RollQty, RollNo, orderRef2, orderRef4)
  3679. values
  3680. (#{transNo}, #{seqNo}, #{site}, #{itemNo}, #{locationId}, #{batchNo}, #{rollQty}, #{rollNo}, #{orderRef2}, #{orderRef4})
  3681. </insert>
  3682. <insert id="saveInventoryStockData" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData">
  3683. insert into inventory_stock
  3684. (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)
  3685. values
  3686. (#{site}, #{warehouseId}, #{partNo}, #{firstInDate}, getDate(), getDate(),getDate(), #{inQty}, #{outQty}, #{qtyOnHand}, #{citemCode}, #{partnerId}, #{latestCountDate}, #{locationId}, #{batchNo})
  3687. </insert>
  3688. <insert id="saveRepairTransDetail" parameterType="com.xujie.sys.modules.pms.data.RepairTransDetailData">
  3689. insert into repair_TransDetail
  3690. (TransNo, Site, ItemNo, PartNo, LocationID, TransQty, Direction, BatchNo, OrderRef1, OrderRef2, OrderRef3, citem_code)
  3691. values
  3692. (#{transNo}, #{site}, #{itemNo}, #{partNo}, #{locationId}, #{transQty}, #{direction}, #{batchNo}, #{orderRef1}, #{orderRef2}, #{orderRef3}, #{citemCode})
  3693. </insert>
  3694. <insert id="saveRepairTransHeader" parameterType="com.xujie.sys.modules.pms.data.RepairTransHeaderData">
  3695. insert into repair_TransHeader
  3696. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, TransferFlag, EnterDate, UseLocation, LinkOrderFlag, Status, Remark, orderRef1)
  3697. values
  3698. (#{transNo}, #{site}, #{warehouseId}, #{transDate}, #{transTypeDb}, #{transType}, #{userName}, #{receiver}, #{transYear}, #{transMonth}, #{partnerId}, #{partnerType}, #{authorizeFlag}, #{transferFlag}, getDate(), #{useLocation}, #{linkOrderFlag}, #{status}, #{remark}, #{orderRef1})
  3699. </insert>
  3700. <update id="updatePartSpareLocation" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3701. update part_spare
  3702. set last_update_by =#{userName},
  3703. location_id = #{locationId},
  3704. warehouse_id = #{warehouseId}
  3705. where site = #{site} and part_no = #{partNo}
  3706. </update>
  3707. <select id="getFeedBackInfo" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  3708. select
  3709. a.Site,
  3710. a.bu_no,
  3711. a.FeedBackID,
  3712. a.FeedBackDesc,
  3713. a.Status,
  3714. a.ObjectID,
  3715. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  3716. b.reach_date as createdDate,
  3717. b.reach_operator_name as createdBy,
  3718. '' as feedbackBy
  3719. from eam_defect_feedBack as a
  3720. left join eam_workOrder as b on a.site = b.site and a.bu_no = b.bu_no and b.PlanID = a.feedBackID
  3721. <where>
  3722. a.Site = #{site} and a.bu_no = #{buNo} and a.FeedBackID = #{feedBackID} and b.status in ('未开始', '已到达')
  3723. </where>
  3724. </select>
  3725. <select id="getObjectInfo" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  3726. select
  3727. site,
  3728. bu_no,
  3729. objectID,
  3730. ObjectDesc,
  3731. standard_maintenance_duration,
  3732. time_out_maintenance_duration,
  3733. standard_response_duration,
  3734. time_out_response_duration
  3735. from eam_object
  3736. where Site = #{site} and bu_no = #{buNo} and ObjectID = #{objectID}
  3737. </select>
  3738. <select id="getResourceByObject" resultType="string">
  3739. select
  3740. ResourceID
  3741. from eam_object
  3742. where Site = #{site} and bu_no = #{buNo} and ObjectID = #{objectID}
  3743. </select>
  3744. <select id="selectRecordByOrderNo" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3745. SELECT
  3746. a.Site,
  3747. a.bu_no,
  3748. a.OrderNo,
  3749. a.PlanID,
  3750. b.FeedBackDesc,
  3751. a.ObjectID,
  3752. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  3753. a.Status,
  3754. a.PlanDate,
  3755. a.ActualDate,
  3756. a.FunctionType,
  3757. a.CreateDate,
  3758. a.Remark,
  3759. a.StartTime,
  3760. a.EndTime,
  3761. a.WorkTime,
  3762. a.result,
  3763. a.reach_date,
  3764. a.confirm_date,
  3765. a.confirm_by,
  3766. a.confirm_result,
  3767. a.confirm_count,
  3768. a.confirm_assessment,
  3769. a.confirm_remark,
  3770. b.CreatedDate,
  3771. dbo.getOperatorDesc(b.site, b.CreatedBy) as createdBy
  3772. FROM eam_workOrder as a
  3773. left join eam_defect_feedBack as b on a.site = b.site and a.bu_no = b.bu_no and a.PlanID = b.feedBackID
  3774. where a.Site = #{site} and a.bu_no = #{buNo} and a.OrderNo = #{orderNo} and a.FunctionType = #{functionType}
  3775. </select>
  3776. <update id="confirmDefectOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3777. update eam_workOrder
  3778. set Status = #{status},
  3779. confirm_by = #{confirmBy},
  3780. confirm_date = getDate(),
  3781. confirm_result = #{confirmResult},
  3782. confirm_count = #{confirmCount},
  3783. confirm_assessment = #{confirmAssessment},
  3784. confirm_remark = #{confirmRemark}
  3785. where site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo} and FunctionType = #{functionType}
  3786. </update>
  3787. <update id="confirmDefectPlan" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3788. update eam_defect_feedBack
  3789. set Status = #{status}
  3790. where site = #{site} AND bu_no = #{buNo} AND FeedBackID = #{planID} and FunctionType = #{functionType}
  3791. </update>
  3792. <select id="getCoreComponentByNo" resultType="com.xujie.sys.modules.pms.entity.EamWorkOrderCoreComponentsData">
  3793. select
  3794. site,
  3795. bu_no,
  3796. OrderNo,
  3797. partNo
  3798. from eam_workOrder_coreComponents
  3799. where site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
  3800. </select>
  3801. <select id="getCoreSerialLatestAction" resultType="java.lang.String" parameterType="com.xujie.sys.modules.pms.entity.EamWorkOrderCoreComponentsData">
  3802. SELECT TOP 1 tempData.action
  3803. FROM (
  3804. SELECT
  3805. created_date,
  3806. '下机' AS action
  3807. FROM eam_workOrder_coreComponents
  3808. WHERE site = #{site} and bu_no = #{buNo} and partNo = #{partNo} and oldSerialNo = #{serialNo}
  3809. <if test="orderNo != null and orderNo != ''">
  3810. and OrderNo != #{orderNo}
  3811. </if>
  3812. UNION ALL
  3813. SELECT
  3814. created_date,
  3815. '上机' AS action
  3816. FROM eam_workOrder_coreComponents
  3817. WHERE site = #{site} and bu_no = #{buNo} and partNo = #{partNo} and newSerialNo = #{serialNo}
  3818. <if test="orderNo != null and orderNo != ''">
  3819. and OrderNo != #{orderNo}
  3820. </if>
  3821. ) tempData
  3822. ORDER BY tempData.created_date DESC,
  3823. CASE WHEN tempData.action = '上机' THEN 0 ELSE 1 END
  3824. </select>
  3825. <select id="getRoleByUserName" resultType="com.xujie.sys.modules.factory.entity.vo.BusinessRoleVo" parameterType="com.xujie.sys.modules.factory.entity.vo.BusinessRoleVo">
  3826. SELECT
  3827. a.site,
  3828. b.role_no,
  3829. b.role_desc
  3830. FROM access_role as a
  3831. left join business_role as b on a.site = b.site and a.role_no = b.role_no
  3832. WHERE a.username = #{username} and b.role_no in ('R022', 'R023', 'R024')
  3833. </select>
  3834. <select id="checkItemByUse" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  3835. SELECT
  3836. site,
  3837. bu_no,
  3838. function_type,
  3839. code_no,
  3840. properties_item_no itemNo,
  3841. seq_no
  3842. FROM eam_properties_model_detail
  3843. where site = #{site} and bu_no = #{buNo} and function_type = #{itemType} and properties_item_no = #{itemNo}
  3844. </select>
  3845. <select id="getOperatorListByOrder" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  3846. SELECT
  3847. a.user_id, a.username AS adminID, a.email, a.mobile AS phone, a.user_display AS adminName,
  3848. d.role_id, e.role_name, c.site, c.bu_no,
  3849. -- 获取计划工单数
  3850. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) AS planOrderCount,
  3851. -- 获取实际工单数
  3852. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) AS actualOrderCount,
  3853. -- 负荷率(%)
  3854. CASE
  3855. WHEN dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) = 0 THEN 0
  3856. ELSE
  3857. CAST(
  3858. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) * 100.0 /
  3859. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username)
  3860. AS DECIMAL(5,2))
  3861. END AS load_rate
  3862. FROM
  3863. sys_user AS a
  3864. LEFT JOIN eam_access_site AS b ON a.username = b.username
  3865. LEFT JOIN AccessBu AS c ON b.username = c.username AND b.site = c.site
  3866. LEFT JOIN sys_user_role AS d ON a.user_id = d.user_id
  3867. LEFT JOIN sys_role AS e ON d.role_id = e.role_id
  3868. <where>
  3869. b.site = #{site} and c.bu_no = #{buNo}
  3870. <if test = "adminID != null and adminID != ''">
  3871. AND a.username LIKE '%' + #{adminID} + '%'
  3872. </if>
  3873. <if test = "adminName != null and adminName != ''">
  3874. AND a.user_display LIKE '%' + #{adminName} + '%'
  3875. </if>
  3876. <if test = "roleId != null and roleId != ''">
  3877. AND d.role_id = #{roleId}
  3878. </if>
  3879. <if test = "date != null and classesCode != null and classesCode != ''">
  3880. AND a.username IN (
  3881. SELECT tpm_scheduling_record.admin_id
  3882. FROM tpm_scheduling
  3883. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3884. 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'
  3885. )
  3886. </if>
  3887. <if test = "date != null and (classesCode == null or classesCode == '')">
  3888. AND a.username IN (
  3889. SELECT tpm_scheduling_record.admin_id
  3890. FROM tpm_scheduling
  3891. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3892. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling_record.isHoliday = 'N'
  3893. )
  3894. </if>
  3895. <if test = "classesCode != null and classesCode != '' and date == null">
  3896. AND a.username IN (
  3897. SELECT tpm_scheduling_record.admin_id
  3898. FROM tpm_scheduling
  3899. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3900. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  3901. )
  3902. </if>
  3903. </where>
  3904. order by load_rate desc
  3905. </select>
  3906. <select id="getOrderId" resultType="java.lang.Integer">
  3907. SELECT isnull(max(order_id), 0) + 1
  3908. from eam_properties_model_detail
  3909. where site = #{site}
  3910. and bu_no= #{buNo}
  3911. and function_type = #{functionType}
  3912. and code_no = #{codeNo}
  3913. </select>
  3914. <update id="updateOrderStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3915. update eam_workOrder
  3916. set Status = '已完工'
  3917. where site = #{site} and bu_no = #{buNo} and orderNo = #{orderNo} and FunctionType = #{functionType}
  3918. </update>
  3919. <update id="updateMessageNotification" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3920. update TPM_Message_Notification
  3921. set send_flag = 'N'
  3922. WHERE SITE = #{site} AND bu_no = #{buNo} AND plan_no = #{feedBackId} AND order_no = #{orderNo}
  3923. </update>
  3924. <update id="updateRepairTypes">
  3925. UPDATE eam_workOrder
  3926. SET repair_type = #{repairType}
  3927. WHERE site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo}
  3928. </update>
  3929. <update id="updateEamItemOrder">
  3930. update eam_properties_model_detail
  3931. set order_id=#{orderId}
  3932. where site = #{site}
  3933. and bu_no= #{buNo}
  3934. and properties_item_no = #{itemNo}
  3935. and code_no = #{codeNo}
  3936. and function_type = #{functionType}
  3937. </update>
  3938. <update id="updateMessageNotificationByParameter">
  3939. update TPM_Message_Notification
  3940. set send_flag = 'N'
  3941. WHERE SITE = #{site} AND bu_no = #{buNo} AND plan_no = #{planID} AND order_no = #{orderNo}
  3942. </update>
  3943. <update id="updateIsReturn">
  3944. UPDATE eam_workOrder
  3945. SET is_return = 'Y'
  3946. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  3947. </update>
  3948. <update id="updateIsReturn2">
  3949. UPDATE eam_workOrder
  3950. SET is_return = 'N'
  3951. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  3952. </update>
  3953. <update id="reportWorkOrderForIsReturn">
  3954. update eam_workOrder
  3955. set Remark = #{remark},
  3956. handling_method = #{handlingMethod},
  3957. fault_reason = #{faultReason},
  3958. preventive_measure = #{preventiveMeasure},
  3959. is_return = 'N',
  3960. status = '待审核'
  3961. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  3962. </update>
  3963. <update id="updateEamDefectFeedBackPlanOperator">
  3964. update eam_defect_feedBack
  3965. set PlanOperator = #{planOperator}
  3966. where site = #{site} and bu_no = #{buNo} and feedBackID = #{feedBackID}
  3967. </update>
  3968. <update id="returnWorkOrder">
  3969. UPDATE eam_workOrder
  3970. SET Status = '已到达',
  3971. is_return = 'Y'
  3972. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  3973. </update>
  3974. <update id="abandonedEamWorkOrder">
  3975. update eam_workOrder
  3976. set Status = '已废弃' , abandoned_reason = #{abandonedReason} , update_by = #{updateBy} , update_date = getDate()
  3977. where Site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo}
  3978. </update>
  3979. <update id="updateTpmMessageNotificationSendFlag">
  3980. update TPM_Message_Notification
  3981. set send_flag = 'N'
  3982. WHERE SITE = #{site} AND bu_no = #{buNo} AND plan_no = #{planID} AND order_no = #{orderNo} and IP = #{ip} and mes_typ_desc = '三色灯'
  3983. </update>
  3984. <select id="getUpItemdataEam" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelDetailData">
  3985. select
  3986. top 1
  3987. site,
  3988. bu_no,
  3989. properties_item_no as itemNo,
  3990. code_no,
  3991. function_type,
  3992. order_id
  3993. from eam_properties_model_detail
  3994. where #{orderId} > order_id
  3995. and site = #{site}
  3996. and bu_no= #{buNo}
  3997. and code_no = #{codeNo}
  3998. and function_type = #{functionType}
  3999. order by order_id desc
  4000. </select>
  4001. <select id="getDownItemdataEam" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelDetailData">
  4002. select
  4003. top 1
  4004. site,
  4005. bu_no,
  4006. properties_item_no as itemNo,
  4007. code_no,
  4008. function_type,
  4009. order_id
  4010. from eam_properties_model_detail
  4011. where order_id > #{orderId}
  4012. and site = #{site}
  4013. and bu_no= #{buNo}
  4014. and code_no = #{codeNo}
  4015. and function_type = #{functionType}
  4016. order by order_id
  4017. </select>
  4018. <select id="getResourceSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  4019. SELECT
  4020. rs.part_no,
  4021. ps.part_description
  4022. FROM resource_spare rs
  4023. LEFT JOIN part_spare ps ON rs.site = ps.site AND rs.bu_no = ps.bu_no AND rs.part_no = ps.part_no
  4024. WHERE
  4025. rs.site = #{site} and rs.bu_no = #{buNo}
  4026. and rs.resource_id = #{objectID} and rs.part_no = #{partNo} and ps.coreFlag = 'Y'
  4027. </select>
  4028. <select id="getConfirmButtonOperator" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  4029. select sys_user.username as adminID,
  4030. sys_user.user_display as adminName
  4031. from sys_user
  4032. LEFT JOIN sys_user_role on sys_user.user_id = sys_user_role.user_id
  4033. LEFT JOIN sys_role ON sys_user_role.role_id = sys_role.role_id
  4034. WHERE sys_role.role_name = '维修工单确认按钮权限'
  4035. </select>
  4036. <select id="queryItemNo" resultType="java.lang.String">
  4037. SELECT DBO.get_next_code (#{site},#{buNo},#{itemNo},#{itemType})
  4038. </select>
  4039. <select id="getAllCoreComponents" resultType="com.xujie.sys.modules.pms.data.ExportCoreComponentsData">
  4040. SELECT
  4041. D.OrderNo,
  4042. ewc.site,
  4043. ewc.bu_no,
  4044. ewc.partno,
  4045. ps.part_description,
  4046. ewc.oldSerialNo,
  4047. ewc.newSerialNo,
  4048. ewc.created_date,
  4049. ps.spec,
  4050. ps.umid,
  4051. ps.remark,
  4052. ewc.created_by,
  4053. d.fault_reason,
  4054. b.resource_id,
  4055. dbo.eam_Get_eamResourceDesc(d.Site, d.ObjectID) as resourceDesc
  4056. FROM eam_workOrder_coreComponents ewc
  4057. LEFT JOIN part_spare ps ON ewc.site = ps.site AND ewc.bu_no = ps.bu_no AND ewc.partNo = ps.part_no
  4058. LEFT JOIN eam_workOrder d ON ewc.site = d.Site AND ewc.bu_no = d.bu_no AND ewc.OrderNo = d.OrderNo
  4059. left join resource B ON ewc.site = b.site and d.objectid = b.resource_id
  4060. <where>
  4061. ewc.site = #{site} and ewc.bu_no = #{buNo} and ps.coreFlag = 'Y'
  4062. <if test="startDate != null ">
  4063. AND ewc.created_date >= #{startDate}
  4064. </if>
  4065. <if test="endDate != null ">
  4066. AND #{endDate} >= CAST(ewc.created_date AS DATE)
  4067. </if>
  4068. </where>
  4069. </select>
  4070. <select id="exportEamPropertiesTemplateAndItem"
  4071. resultType="com.xujie.sys.modules.pms.data.ExportEamPropertiesModelData">
  4072. SELECT
  4073. epmh.site,
  4074. epmh.bu_no,
  4075. dbo.get_bu_desc(epmh.site, epmh.bu_no) as buDesc,
  4076. epmh.code_no,
  4077. epmh.code_desc,
  4078. epmh.active,
  4079. case when epmh.active = 'Y' then '是' when epmh.active = 'N' then '否' else '' end as activeDesc,
  4080. epmh.created_date,
  4081. epmh.created_by,
  4082. dbo.getOperatorDesc(epmh.site, epmh.created_by) as createdByDesc,
  4083. epmh.update_date,
  4084. epmh.update_by,
  4085. dbo.getOperatorDesc(epmh.site, epmh.update_by) as updateByDesc,
  4086. CASE WHEN dbo.eam_model_is_use(epmh.site, epmh.function_type, epmh.code_no) > 0 THEN 'Y' else 'N' END as isUse,
  4087. a.properties_item_no itemNo,
  4088. b.ItemDesc,
  4089. b.ItemRemark,
  4090. b.ValueType,
  4091. b.DefaultValue,
  4092. b.MaxValue,
  4093. b.MinValue,
  4094. b.ValueChooseFlag
  4095. FROM eam_properties_model_header epmh
  4096. left join eam_properties_model_detail a on a.function_type = epmh.function_type and a.code_no = epmh.code_no and a.site = epmh.site and a.bu_no = epmh.bu_no and a.check_type = epmh.check_type
  4097. 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
  4098. <where>
  4099. epmh.site in (select site from eam_access_site where username = #{query.userName})
  4100. and (epmh.site + '-' + epmh.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  4101. and epmh.check_type in (select role_no from access_role where username = #{query.userName})
  4102. and epmh.function_type = #{query.functionType}
  4103. <if test="query.buDesc != null and query.buDesc != ''">
  4104. AND dbo.get_bu_desc ( epmh.site, epmh.bu_no ) = #{query.buDesc}
  4105. </if>
  4106. <if test="query.codeNo != null and query.codeNo != ''">
  4107. AND epmh.code_no like '%' + #{query.codeNo} +'%'
  4108. </if>
  4109. <if test="query.codeDesc != null and query.codeDesc != ''">
  4110. AND epmh.code_desc like '%' + #{query.codeDesc} +'%'
  4111. </if>
  4112. <if test="query.active != null and query.active != ''">
  4113. AND epmh.active = #{query.active}
  4114. </if>
  4115. <if test='query.isUse != null and query.isUse != "" and query.isUse == "Y"'>
  4116. AND dbo.eam_model_is_use(epmh.site, epmh.function_type, epmh.code_no) > 0
  4117. </if>
  4118. <if test='query.isUse != null and query.isUse != "" and query.isUse == "N"'>
  4119. AND dbo.eam_model_is_use(epmh.site, epmh.function_type, epmh.code_no) = 0
  4120. </if>
  4121. <if test="query.checkType != null and query.checkType != ''">
  4122. AND epmh.check_type = #{query.checkType}
  4123. </if>
  4124. </where>
  4125. order by epmh.code_no,a.order_id
  4126. </select>
  4127. <select id="getEquipmentFolderLocationIp" resultType="java.lang.String">
  4128. select IP from Equipment_folder_location where site = #{site} and bu_no = #{buNo} and repair_type = '换线专家组'
  4129. </select>
  4130. <select id="getIusseRoleUserList" resultType="com.xujie.sys.modules.base.entity.IusseRoleUserData">
  4131. select DISTINCT a.user_id,b.username,b.user_display,b.WorkShopId,b.email,c.role_id,c.role_name
  4132. from sys_role c
  4133. left join sys_user_role a on a.role_id = c.role_id
  4134. left join sys_user b on a.user_id=b.user_id
  4135. <where>
  4136. and c.role_name = '领料主管'
  4137. and b.username is not null
  4138. and b.email is not null
  4139. </where>
  4140. </select>
  4141. <select id="getSoundBoxEmailLogList" resultType="com.xujie.sys.modules.pms.entity.SoundBoxEmailLog">
  4142. select site, component_part_no as componentPartNo, notify_no as notifyNo
  4143. from sound_box_email_log
  4144. </select>
  4145. <select id="getEamPropertiesItemByItemNo" resultType="com.xujie.sys.modules.pms.data.QcItemData">
  4146. SELECT
  4147. epi.site,
  4148. epi.bu_no,
  4149. dbo.get_bu_desc(epi.site, epi.bu_no) as buDesc,
  4150. epi.ItemNo,
  4151. epi.ItemDesc,
  4152. epi.DefaultValue,
  4153. epi.ValueType,
  4154. epi.ValueType_DB as valueTypeDb,
  4155. epi.ValueChooseFlag,
  4156. epi.CreatedDate,
  4157. epi.CreatedBy,
  4158. dbo.getOperatorDesc(epi.site, epi.CreatedBy) as createdByDesc,
  4159. epi.MaxValue,
  4160. epi.MinValue,
  4161. epi.ItemRemark,
  4162. epi.ItemType,
  4163. epi.update_date,
  4164. epi.update_by,
  4165. dbo.getOperatorDesc(epi.site, epi.update_by) as updateByDesc,
  4166. qm.method_no,
  4167. qm.method_name,
  4168. qm.method_remark,
  4169. epi.inspection_type_no,
  4170. epi.item_sampling_quantity,
  4171. epi.sampling_programme_no,
  4172. epi.sampling_level_no,
  4173. epi.default_sampling_proportion,
  4174. epi.collection_flag,
  4175. epi.collection_source,
  4176. epi.collection_method,
  4177. CASE WHEN epi.collection_method = 'plc' THEN 'PLC'
  4178. WHEN epi.collection_method = 'file' THEN '文件'
  4179. WHEN epi.collection_method = 'image' THEN '图片'
  4180. else '' end as collectionMethodDesc,
  4181. epi.collection_condition,
  4182. epi.collection_data_content
  4183. FROM eam_properties_item as epi
  4184. LEFT JOIN qc_method_item as qmi on epi.ItemNo = qmi.ItemNo and epi.site = qmi.site and epi.bu_no = qmi.bu_no
  4185. LEFT JOIN qc_method as qm on qmi.method_no = qm.method_no and qmi.site = qm.site and qmi.bu_no = qm.bu_no
  4186. <where>
  4187. epi.site = #{data.site} and epi.ItemNo = #{data.itemNo} and epi.bu_no = #{data.buNo}
  4188. </where>
  4189. </select>
  4190. <select id="eamWorkOrderSearchList" resultType="com.xujie.sys.modules.pms.data.EamMaintainOrderExportData">
  4191. SELECT
  4192. a.Site,
  4193. a.bu_no,
  4194. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  4195. a.OrderNo,
  4196. a.PlanID,
  4197. a.PlanDesc,
  4198. a.PropertiesCode,
  4199. a.ObjectID,
  4200. a.Status,
  4201. a.PlanOperator,
  4202. a.checker,
  4203. a.ActualOperator,
  4204. a.PlanDate,
  4205. a.ActualDate,
  4206. a.FunctionType,
  4207. a.CreateDate,
  4208. a.Remark,
  4209. a.StartTime,
  4210. a.EndTime,
  4211. a.WorkTime,
  4212. a.PlanOperatorName,
  4213. a.checkerName,
  4214. dbo.eam_Get_eamAdminName_TPM(a.Site, a.ActualOperator) as actualOperatorName,
  4215. eo.ObjectDesc as objectDesc,
  4216. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  4217. a.result,
  4218. a.checkResult,
  4219. a.disposal_measures,
  4220. a.check_work_plan_id,
  4221. a.check_item_no,
  4222. a.reach_date,
  4223. a.reach_operator,
  4224. a.reach_operator_name,
  4225. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  4226. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  4227. a.check_remark,
  4228. a.document_source,
  4229. a.last_execution_date,
  4230. a.handling_method,
  4231. a.fault_reason,
  4232. a.preventive_measure,
  4233. a.repair_reporting_type,
  4234. a.repair_type,
  4235. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  4236. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  4237. END AS responseTime,
  4238. a.check_type,
  4239. a.is_return,
  4240. ewo.plan_period,
  4241. ewo.plan_cycle,
  4242. CASE
  4243. when ewo.plan_cycle = '时' then a.PlanDate
  4244. else ewo.task_start_date
  4245. end as taskStartDate
  4246. FROM eam_workOrder a
  4247. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  4248. 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
  4249. 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
  4250. left join sys_user as ea on ead.username = ea.username
  4251. 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
  4252. <where>
  4253. a.site in (select site from eam_access_site where username = #{query.userName})
  4254. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  4255. and a.check_type in (select role_no from access_role where username = #{query.userName})
  4256. and ea.username = #{query.userName}
  4257. AND a.FunctionType = #{query.functionType}
  4258. <if test="query.buDesc != null and query.buDesc != ''">
  4259. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  4260. </if>
  4261. <if test="query.isReturn != null and query.isReturn != ''">
  4262. AND a.is_return = #{query.isReturn}
  4263. </if>
  4264. <if test="query.orderNo != null and query.orderNo != ''">
  4265. AND a.OrderNo like '%' + #{query.orderNo} + '%'
  4266. </if>
  4267. <if test="query.planID != null and query.planID != ''">
  4268. AND a.PlanID like '%' + #{query.planID} + '%'
  4269. </if>
  4270. <if test="query.planDesc != null and query.planDesc != ''">
  4271. AND a.PlanDesc like '%' + #{query.planDesc} + '%'
  4272. </if>
  4273. <if test="query.objectID != null and query.objectID != ''">
  4274. AND a.ObjectID like '%' + #{query.objectID} + '%'
  4275. </if>
  4276. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  4277. AND a.PlanOperatorName like '%' + #{query.planOperatorName} + '%'
  4278. </if>
  4279. <if test="query.actualOperatorName != null and query.actualOperatorName != ''">
  4280. AND dbo.eam_Get_eamAdminName_TPM(a.Site, a.ActualOperator) like '%' + #{query.actualOperatorName} + '%'
  4281. </if>
  4282. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  4283. AND a.status != '已取消'
  4284. </if>
  4285. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  4286. AND a.status = #{query.status}
  4287. </if>
  4288. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  4289. AND a.status = '未开工'
  4290. </if>
  4291. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  4292. AND a.status != '已取消'
  4293. </if>
  4294. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  4295. AND a.status = #{query.status}
  4296. </if>
  4297. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  4298. AND (a.status = '未开工' or a.status = '已到达')
  4299. </if>
  4300. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  4301. AND (a.status = '未开工' or a.status = '已到达')
  4302. </if>
  4303. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  4304. AND a.status = #{query.status}
  4305. </if>
  4306. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  4307. AND a.document_source = #{query.documentSource}
  4308. </if>
  4309. <if test="query.planDate != null">
  4310. AND a.PlanDate = #{query.planDate}
  4311. </if>
  4312. <if test="query.startDate != null ">
  4313. AND a.PlanDate >= #{query.startDate}
  4314. </if>
  4315. <if test="query.endDate != null ">
  4316. AND #{query.endDate} >= a.PlanDate
  4317. </if>
  4318. <if test="query.endDate == null ">
  4319. AND getDate() >= a.PlanDate
  4320. </if>
  4321. <if test='query.functionType == "A" and query.searchType == "reportCheck"'>
  4322. and getDate() >= dbo.compare_date(ewo.task_start_date)
  4323. </if>
  4324. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  4325. AND a.repair_reporting_type = #{query.repairReportingType}
  4326. </if>
  4327. <if test="query.repairType != null and query.repairType != ''">
  4328. AND a.repair_type = #{query.repairType}
  4329. </if>
  4330. <if test="query.checkType != null and query.checkType != ''">
  4331. AND a.check_type = #{query.checkType}
  4332. </if>
  4333. </where>
  4334. ORDER BY a.CreateDate
  4335. </select>
  4336. <select id="eamWorkOrderSearchForDefectExport"
  4337. resultType="com.xujie.sys.modules.pms.data.EamWorkOrderExportData">
  4338. SELECT
  4339. a.Site,
  4340. a.bu_no,
  4341. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  4342. a.OrderNo,
  4343. a.PlanID,
  4344. a.ObjectID,
  4345. a.Status,
  4346. a.PlanOperator,
  4347. a.ActualOperator,
  4348. a.PlanDate,
  4349. a.ActualDate,
  4350. a.FunctionType,
  4351. a.CreateDate,
  4352. dbo.eam_Get_eamAdminName_TPM(a.Site,b.CreatedBy) as createBy,
  4353. a.Remark,
  4354. a.StartTime,
  4355. a.EndTime,
  4356. a.WorkTime,
  4357. dbo.eam_Get_eamAdminName_TPM(a.Site,a.PlanOperator) as planOperatorName,
  4358. b.DefectID,
  4359. c.DefectDesc,
  4360. e.ObjectDesc as objectDesc,
  4361. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  4362. a.result,
  4363. b.urgency,
  4364. a.disposal_measures,
  4365. a.difficulty_level,
  4366. a.difficulty_remark,
  4367. f.department_name,
  4368. a.reach_date,
  4369. a.reach_operator,
  4370. a.reach_operator_name,
  4371. case when a.status = '已废弃' then null else b.CreatedDate end as CreatedDate,
  4372. a.handling_method,
  4373. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  4374. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  4375. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  4376. END AS responseTime,
  4377. b.FeedBackDesc,
  4378. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  4379. a.fault_reason,
  4380. a.preventive_measure,
  4381. a.document_source,
  4382. a.repair_reporting_type,
  4383. a.repair_type,
  4384. a.confirm_assessment,
  4385. a.confirm_remark,
  4386. a.check_assessment,
  4387. a.check_notes
  4388. FROM eam_workOrder a
  4389. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  4390. left join eam_defect c on b.DefectID = c.DefectID
  4391. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id
  4392. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and a.bu_no = e.bu_no
  4393. 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
  4394. 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
  4395. left join sys_user as ea on ead.username = ea.username
  4396. <where>
  4397. a.site in (select site from eam_access_site where username = #{query.userName})
  4398. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  4399. and ea.username = #{query.userName}
  4400. <if test="query.buDesc != null and query.buDesc != ''">
  4401. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  4402. </if>
  4403. <if test="query.deptArr != null">
  4404. AND
  4405. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  4406. f.department_name like '%' + #{item} + '%'
  4407. </foreach>
  4408. </if>
  4409. <if test="query.orderNo != null and query.orderNo != ''">
  4410. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  4411. </if>
  4412. <if test="query.planID != null and query.planID != ''">
  4413. AND a.PlanID like '%' + #{query.planID} +'%'
  4414. </if>
  4415. <if test="query.objectID != null and query.objectID != ''">
  4416. AND a.ObjectID like '%' + #{query.objectID} +'%'
  4417. </if>
  4418. <if test="query.planOperator != null and query.planOperator != ''">
  4419. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  4420. </if>
  4421. <if test="query.status != null and query.status != ''">
  4422. AND a.status = #{query.status}
  4423. </if>
  4424. <if test="query.documentSource != null and query.documentSource != ''">
  4425. AND a.document_source = #{query.documentSource}
  4426. </if>
  4427. <if test="query.startDate != null ">
  4428. AND a.PlanDate >= #{query.startDate}
  4429. </if>
  4430. <if test="query.endDate != null ">
  4431. AND #{query.endDate} >= a.PlanDate
  4432. </if>
  4433. <if test="query.actualStartDate != null ">
  4434. AND a.ActualDate >= #{query.actualStartDate}
  4435. </if>
  4436. <if test="query.actualEndDate != null ">
  4437. AND DATEADD(DAY, 1, CONVERT(DATE, #{query.actualEndDate})) > a.ActualDate
  4438. </if>
  4439. <if test="query.urgency != null and query.urgency != ''">
  4440. AND b.urgency = #{query.urgency}
  4441. </if>
  4442. <if test="query.result != null and query.result != ''">
  4443. AND a.result = #{query.result}
  4444. </if>
  4445. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  4446. AND a.repair_reporting_type = #{query.repairReportingType}
  4447. </if>
  4448. <if test="query.repairType != null and query.repairType != ''">
  4449. AND a.repair_type = #{query.repairType}
  4450. </if>
  4451. <if test="query.feedBackDesc != null and query.feedBackDesc != ''">
  4452. AND b.FeedBackDesc like '%' +#{query.feedBackDesc}+'%'
  4453. </if>
  4454. and a.FunctionType =#{query.functionType}
  4455. </where>
  4456. ORDER BY a.PlanDate,
  4457. CASE WHEN b.urgency = '特急' THEN 1
  4458. WHEN b.urgency = '紧急' THEN 2
  4459. WHEN b.urgency = '一般' THEN 3
  4460. END
  4461. </select>
  4462. <insert id="saveSoundBoxEmailLog" parameterType="com.xujie.sys.modules.pms.entity.SoundBoxEmailLog">
  4463. insert into sound_box_email_log (site, component_part_no, notify_no, request_data, response_data, email, created_at, user_id, username)
  4464. values (#{site}, #{componentPartNo}, #{notifyNo}, #{requestData}, #{responseData}, #{email}, #{createdAt}, #{userId}, #{username})
  4465. </insert>
  4466. </mapper>