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.

3675 lines
162 KiB

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