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.

4612 lines
207 KiB

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