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.

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