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

4060 lines
180 KiB

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