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.

4897 lines
218 KiB

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