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.

3772 lines
168 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
9 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
9 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
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
9 months ago
9 months ago
8 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. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as 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. a.is_return as isReturn,
  864. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  865. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  866. END AS responseTime
  867. FROM eam_workOrder a
  868. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  869. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  870. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id
  871. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  872. 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
  873. 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
  874. left join sys_user as ea on ead.username = ea.username
  875. 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
  876. <where>
  877. a.site in (select site from eam_access_site where username = #{query.userName})
  878. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  879. and ea.username = #{query.userName}
  880. <if test="query.buDesc != null and query.buDesc != ''">
  881. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  882. </if>
  883. <if test="query.orderNo != null and query.orderNo != ''">
  884. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  885. </if>
  886. <if test="query.planID != null and query.planID != ''">
  887. AND a.PlanID like '%' + #{query.planID} +'%'
  888. </if>
  889. <if test="query.planDesc != null and query.planDesc != ''">
  890. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  891. </if>
  892. <if test="query.objectID != null and query.objectID != ''">
  893. AND a.ObjectID like '%' + #{query.objectID} +'%'
  894. </if>
  895. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  896. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  897. </if>
  898. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  899. AND a.status != '已取消'
  900. </if>
  901. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  902. AND a.status = #{query.status}
  903. </if>
  904. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  905. AND a.status = '未开工'
  906. </if>
  907. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  908. AND a.status != '已取消'
  909. </if>
  910. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  911. AND a.status = #{query.status}
  912. </if>
  913. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  914. AND (a.status = '未开工' or a.status = '已到达')
  915. </if>
  916. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  917. AND (a.status = '未开工' or a.status = '已到达')
  918. </if>
  919. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  920. AND a.status = #{query.status}
  921. </if>
  922. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  923. AND a.document_source = #{query.documentSource}
  924. </if>
  925. <if test="query.planDate != null">
  926. AND a.PlanDate = #{query.planDate}
  927. </if>
  928. <if test="query.startDate != null ">
  929. AND a.PlanDate >= #{query.startDate}
  930. </if>
  931. <if test="query.endDate != null ">
  932. AND #{query.endDate} >= a.PlanDate
  933. </if>
  934. <if test="query.endDate == null ">
  935. AND getDate() >= a.PlanDate
  936. </if>
  937. <if test='query.functionType == "A" and query.searchType == "reportCheck"'>
  938. and getDate() >= dbo.compare_date(ewo.task_start_date)
  939. </if>
  940. <if test="query.urgency != null and query.urgency != ''">
  941. AND b.urgency = #{query.urgency}
  942. </if>
  943. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  944. AND a.repair_reporting_type = #{query.repairReportingType}
  945. </if>
  946. <if test="query.repairType != null and query.repairType != ''">
  947. AND a.repair_type = #{query.repairType}
  948. </if>
  949. AND a.FunctionType = #{query.functionType}
  950. </where>
  951. ORDER BY a.CreateDate,
  952. CASE WHEN b.urgency = '特急' THEN 1
  953. WHEN b.urgency = '紧急' THEN 2
  954. WHEN b.urgency = '一般' THEN 3
  955. END
  956. </select>
  957. <select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  958. SELECT
  959. a.Site,
  960. a.bu_no,
  961. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  962. a.OrderNo,
  963. a.PlanID,
  964. a.ObjectID,
  965. a.Status,
  966. a.PlanOperator,
  967. a.ActualOperator,
  968. a.PlanDate,
  969. a.ActualDate,
  970. a.FunctionType,
  971. a.CreateDate,
  972. d.operator_name as createBy,
  973. a.Remark,
  974. a.StartTime,
  975. a.EndTime,
  976. a.WorkTime,
  977. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  978. b.DefectID,
  979. c.DefectDesc,
  980. e.ObjectDesc as objectDesc,
  981. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  982. a.result,
  983. b.urgency,
  984. a.disposal_measures,
  985. a.difficulty_level,
  986. a.difficulty_remark,
  987. f.department_name,
  988. a.reach_date,
  989. a.reach_operator,
  990. a.reach_operator_name,
  991. b.CreatedDate,
  992. a.handling_method,
  993. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  994. CASE WHEN (DATEDIFF(SECOND, a.CreateDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, a.CreateDate, a.reach_date) / 60.0
  995. ELSE DATEDIFF(MINUTE, a.CreateDate, a.reach_date)
  996. END AS responseTime,
  997. b.FeedBackDesc,
  998. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  999. a.fault_reason,
  1000. a.preventive_measure,
  1001. a.document_source,
  1002. a.repair_reporting_type,
  1003. a.repair_type,
  1004. a.confirm_assessment,
  1005. a.confirm_remark,
  1006. a.check_assessment,
  1007. a.check_notes
  1008. FROM eam_workOrder a
  1009. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  1010. left join eam_defect c on b.DefectID = c.DefectID
  1011. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id
  1012. left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and a.bu_no = e.bu_no
  1013. 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
  1014. 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
  1015. left join sys_user as ea on ead.username = ea.username
  1016. <where>
  1017. a.site in (select site from eam_access_site where username = #{query.userName})
  1018. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1019. and ea.username = #{query.userName}
  1020. <if test="query.buDesc != null and query.buDesc != ''">
  1021. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  1022. </if>
  1023. <if test="query.deptArr != null">
  1024. AND
  1025. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  1026. f.department_name like '%' + #{item} + '%'
  1027. </foreach>
  1028. </if>
  1029. <if test="query.orderNo != null and query.orderNo != ''">
  1030. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  1031. </if>
  1032. <if test="query.planID != null and query.planID != ''">
  1033. AND a.PlanID like '%' + #{query.planID} +'%'
  1034. </if>
  1035. <if test="query.objectID != null and query.objectID != ''">
  1036. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1037. </if>
  1038. <if test="query.planOperator != null and query.planOperator != ''">
  1039. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1040. </if>
  1041. <if test="query.status != null and query.status != ''">
  1042. AND a.status = #{query.status}
  1043. </if>
  1044. <if test="query.documentSource != null and query.documentSource != ''">
  1045. AND a.document_source = #{query.documentSource}
  1046. </if>
  1047. <if test="query.startDate != null ">
  1048. AND a.PlanDate >= #{query.startDate}
  1049. </if>
  1050. <if test="query.endDate != null ">
  1051. AND #{query.endDate} >= a.PlanDate
  1052. </if>
  1053. <if test="query.urgency != null and query.urgency != ''">
  1054. AND b.urgency = #{query.urgency}
  1055. </if>
  1056. <if test="query.result != null and query.result != ''">
  1057. AND a.result = #{query.result}
  1058. </if>
  1059. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  1060. AND a.repair_reporting_type = #{query.repairReportingType}
  1061. </if>
  1062. <if test="query.repairType != null and query.repairType != ''">
  1063. AND a.repair_type = #{query.repairType}
  1064. </if>
  1065. and a.FunctionType =#{query.functionType}
  1066. </where>
  1067. ORDER BY a.PlanDate,
  1068. CASE WHEN b.urgency = '特急' THEN 1
  1069. WHEN b.urgency = '紧急' THEN 2
  1070. WHEN b.urgency = '一般' THEN 3
  1071. END
  1072. </select>
  1073. <select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData">
  1074. SELECT
  1075. DefectID,
  1076. DefectDesc,
  1077. Active,
  1078. create_date,
  1079. create_by,
  1080. update_date,
  1081. update_by,
  1082. fault_type
  1083. FROM eam_defect
  1084. <where>
  1085. <if test="query.defectID != null and query.defectID != ''">
  1086. AND defectID like '%' + #{query.defectID} + '%'
  1087. </if>
  1088. <if test="query.defectDesc != null and query.defectDesc != ''">
  1089. AND defectDesc like '%' + #{query.defectDesc} + '%'
  1090. </if>
  1091. <if test="query.active != null and query.active != ''">
  1092. AND active = #{query.active}
  1093. </if>
  1094. </where>
  1095. order by id
  1096. </select>
  1097. <select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1098. SELECT
  1099. a.site,
  1100. a.ObjectID,
  1101. a.DefectID,
  1102. a.Active,
  1103. a.id,
  1104. b.ObjectDesc,
  1105. c.DefectDesc,
  1106. a.create_date,
  1107. a.create_by,
  1108. a.update_date,
  1109. a.update_by
  1110. FROM eam_object_defect a
  1111. left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID
  1112. left join eam_defect c on a.DefectID=c.DefectID
  1113. <where>
  1114. <if test="query.objectID != null and query.objectID != ''">
  1115. AND a.ObjectID like '%' + #{query.objectID} + '%'
  1116. </if>
  1117. <if test="query.objectDesc != null and query.objectDesc != ''">
  1118. AND b.ObjectDesc like '%' + #{query.objectDesc} + '%'
  1119. </if>
  1120. <if test="query.defectID != null and query.defectID != ''">
  1121. AND a.defectID like '%' + #{query.defectID} + '%'
  1122. </if>
  1123. <if test="query.defectDesc != null and query.defectDesc != ''">
  1124. AND c.defectDesc like '%' + #{query.defectDesc} + '%'
  1125. </if>
  1126. <if test="query.active != null and query.active != ''">
  1127. AND a.active = #{query.active}
  1128. </if>
  1129. </where>
  1130. order by a.id
  1131. </select>
  1132. <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  1133. SELECT
  1134. a.Site,
  1135. a.bu_no,
  1136. a.ObjectID,
  1137. a.ObjectDesc,
  1138. a.LocationID,
  1139. a.FamilyID,
  1140. a.GroupID,
  1141. b.FamilyDesc,
  1142. c.LocationName
  1143. FROM eam_object a
  1144. LEFT JOIN eam_family b ON a.site = b.site and a.FamilyID = b.FamilyID and a.bu_no = b.bu_no
  1145. LEFT JOIN eam_location as c ON a.LocationID = c.LocationID and a.site = c.site and a.bu_no = c.bu_no
  1146. <where>
  1147. <if test="objectID != null and objectID != ''">
  1148. AND a.ObjectID like '%' + #{objectID} + '%'
  1149. </if>
  1150. <if test="objectDesc != null and objectDesc != ''">
  1151. AND a.ObjectDesc like '%' + #{objectDesc} + '%'
  1152. </if>
  1153. AND a.site = #{site} AND a.active = 'Y' and a.bu_no = #{buNo}
  1154. </where>
  1155. </select>
  1156. <select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  1157. SELECT
  1158. a.site,
  1159. a.objectID
  1160. from eam_object as a
  1161. left join eam_family as b on a.site = b.site and a.FamilyID = b.FamilyID
  1162. where a.site = '2' and (b.son_id like #{sonId} + '%' or a.FamilyID = #{familyID})
  1163. </select>
  1164. <select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  1165. SELECT
  1166. site,
  1167. objectID
  1168. from eam_object
  1169. where site = #{site} and GroupID = #{groupID}
  1170. </select>
  1171. <select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  1172. SELECT
  1173. site,
  1174. objectID
  1175. from eam_object
  1176. where site = #{site} and LocationID = #{locationID}
  1177. </select>
  1178. <select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1179. SELECT
  1180. a.Site,
  1181. a.bu_no,
  1182. c.OrderNo,
  1183. a.ItemNo,
  1184. a.ItemDesc,
  1185. a.DefaultValue,
  1186. a.ValueType,
  1187. a.ValueType_DB,
  1188. a.ValueChooseFlag,
  1189. a.MaxValue,
  1190. a.MinValue,
  1191. a.ItemRemark,
  1192. a.ItemType,
  1193. a.image_flag,
  1194. a.produce_control_flag,
  1195. CASE WHEN b.id is null THEN 'N'
  1196. ELSE 'Y'
  1197. END as uploadFlag,
  1198. a.item_notes
  1199. from eam_workPlan_item as a
  1200. left join eam_workOrder as c on a.site = c.site and a.PlanID = c.PlanID and a.bu_no = c.bu_no
  1201. 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
  1202. on b.order_ref1 = a.site and b.order_ref2 = c.OrderNo and b.order_ref3 = a.ItemNo and order_ref4 = a.bu_no
  1203. where a.site = #{site} and c.orderNo = #{orderNo} and a.ObjectID = #{objectID} and a.bu_no = #{buNo}
  1204. </select>
  1205. <select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1206. SELECT
  1207. Site,
  1208. status,
  1209. OrderNo
  1210. from eam_workOrder
  1211. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1212. </select>
  1213. <select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  1214. SELECT username as adminID
  1215. from sys_user
  1216. where username = #{mesUser}
  1217. </select>
  1218. <update id="updateDefectResult" >
  1219. update eam_defect_feedBack
  1220. set Status = #{result},
  1221. FinishDate = GetDate(),
  1222. DefectID = #{defectID}
  1223. where Site = #{site} and FeedBackID = #{planID} and bu_no = #{buNo}
  1224. </update>
  1225. <update id="reportWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1226. update eam_workOrder
  1227. set Status = '待确认',
  1228. ActualOperator = #{actualOperator},
  1229. ActualDate = #{actualDate},
  1230. Remark = #{remark},
  1231. disposal_measures = #{disposalMeasures},
  1232. WorkTime = CASE
  1233. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1234. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
  1235. END,
  1236. result = #{result,jdbcType=VARCHAR},
  1237. checkResult = #{checkResult},
  1238. handling_method = #{handlingMethod},
  1239. fault_reason = #{faultReason},
  1240. preventive_measure = #{preventiveMeasure}
  1241. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1242. </update>
  1243. <update id="reportWorkOrder2" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1244. update eam_workOrder
  1245. set Status = '待审核',
  1246. ActualOperator = #{actualOperator},
  1247. reach_date = #{reachDate},
  1248. ActualDate = #{actualDate},
  1249. Remark = #{remark},
  1250. disposal_measures = #{disposalMeasures},
  1251. WorkTime = #{workTime},
  1252. result = #{result,jdbcType=VARCHAR},
  1253. checkResult = #{checkResult},
  1254. handling_method = #{handlingMethod},
  1255. check_remark = #{checkRemark}
  1256. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1257. </update>
  1258. <update id="reportWorkOrder3" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1259. update eam_workOrder
  1260. set Status = '待审核',
  1261. ActualOperator = #{actualOperator},
  1262. ActualDate = #{actualDate},
  1263. Remark = #{remark},
  1264. disposal_measures = #{disposalMeasures},
  1265. WorkTime = CASE
  1266. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1267. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) * 1.0 / 30) / 2)
  1268. END,
  1269. result = #{result,jdbcType=VARCHAR},
  1270. checkResult = #{checkResult},
  1271. handling_method = #{handlingMethod},
  1272. fault_reason = #{faultReason},
  1273. preventive_measure = #{preventiveMeasure}
  1274. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1275. </update>
  1276. <update id="defectReportWorkOrder" >
  1277. update eam_workOrder
  1278. set Status = '已完工',
  1279. ActualOperator = #{actualOperator},
  1280. ActualDate = GetDate(),
  1281. Remark = #{remark},
  1282. disposal_measures = #{disposalMeasures},
  1283. WorkTime = #{workTime},
  1284. result = #{result,jdbcType=VARCHAR},
  1285. checkResult = #{checkResult}
  1286. where site = #{site}
  1287. and orderNo = #{orderNo}
  1288. </update>
  1289. <insert id="saveWorkOrderItem">
  1290. INSERT into eam_workOrder_item
  1291. (Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
  1292. 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})
  1293. </insert>
  1294. <!-- 修改 eam_workPlan 状态为已结束 -->
  1295. <update id="closePlanWithCheck">
  1296. update eam_workPlan
  1297. set status = '已结束'
  1298. where site = #{site}
  1299. and PlanID = #{planID}
  1300. and ObjectID = #{objectID}
  1301. and GetDate() > PlanEndDate
  1302. </update>
  1303. <!-- 报工后更新下一个工作日期 -->
  1304. <update id="updatePlanNextDate">
  1305. update eam_workPlan_overview
  1306. 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)
  1307. where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
  1308. </update>
  1309. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1310. SELECT
  1311. Site,
  1312. bu_no,
  1313. OrderNo,
  1314. ItemNo,
  1315. ItemDesc,
  1316. DefaultValue,
  1317. ValueType,
  1318. ValueType_DB,
  1319. ValueChooseFlag,
  1320. MaxValue,
  1321. MinValue,
  1322. ItemRemark,
  1323. ItemType,
  1324. TextValue,
  1325. NumberValue,
  1326. CreatedDate,
  1327. CreatedBy,
  1328. FinishFlag,
  1329. itemResult,
  1330. item_notes
  1331. from eam_workOrder_item
  1332. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1333. </select>
  1334. <update id="cancelOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1335. update eam_workOrder
  1336. set Status = '已取消',
  1337. cancel_date = getDate(),
  1338. cancel_by = #{userId}
  1339. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1340. </update>
  1341. <update id="cancelOrderAll" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1342. update eam_workOrder
  1343. set Status = '已取消',
  1344. cancel_date = getDate(),
  1345. cancel_by = #{userId}
  1346. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
  1347. </update>
  1348. <update id="updateWorkPlanStatus2" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1349. update eam_workPlan
  1350. set Status = '已取消',
  1351. cancel_date = getDate(),
  1352. cancel_by = #{userId}
  1353. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1354. </update>
  1355. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1356. SELECT
  1357. site,
  1358. bu_no,
  1359. status
  1360. from eam_workPlan_overview
  1361. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1362. </select>
  1363. <update id="planOrder">
  1364. update eam_workPlan
  1365. set Status = '已计划',
  1366. NextWorkDate = null
  1367. where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1368. </update>
  1369. <update id="cancelPlan">
  1370. update eam_workPlan_overview
  1371. set status = '已取消',
  1372. next_work_date = null,
  1373. cancel_date = getDate(),
  1374. cancel_by = #{userId}
  1375. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1376. </update>
  1377. <update id="updateWorkPlanStatus">
  1378. update eam_workPlan
  1379. set Status = '已取消',
  1380. NextWorkDate = null,
  1381. cancel_date = getDate(),
  1382. cancel_by = #{userId}
  1383. where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1384. </update>
  1385. <update id="cancelOrderWithPlanID">
  1386. update eam_workOrder
  1387. set Status = '已取消',
  1388. cancel_date = getDate(),
  1389. cancel_by = #{userId}
  1390. where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
  1391. </update>
  1392. <update id="deleteOrderDetailWithPlanID">
  1393. delete from eam_workOrder_item
  1394. where site = #{site} and bu_no = #{buNo}
  1395. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  1396. </update>
  1397. <update id="deleteOrderWithPlanID">
  1398. delete from eam_workOrder
  1399. where site = #{site} and bu_no = #{buNo}
  1400. and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
  1401. </update>
  1402. <update id="updateOrderPlanOperator">
  1403. update eam_workOrder
  1404. set PlanOperator = #{planOperator}
  1405. where site = #{site} and orderNo = #{orderNo}
  1406. </update>
  1407. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1408. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  1409. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  1410. <where>
  1411. <if test="partNo != null and partNo != ''">
  1412. AND a.part_no like '%' + #{partNo} + '%'
  1413. </if>
  1414. <if test="partDescription != null and partDescription != ''">
  1415. AND a.part_description like '%' + #{partDescription} + '%'
  1416. </if>
  1417. and a.site=#{site} and a.active='Y'
  1418. </where>
  1419. </select>
  1420. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1421. select part_no
  1422. from resource_spare
  1423. where site = #{site}
  1424. and resource_id = #{objectID}
  1425. and part_no = #{partNo}
  1426. </select>
  1427. <insert id="savePartSpare" >
  1428. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1429. values(#{objectID},#{partNo},'',0,#{site})
  1430. </insert>
  1431. <delete id="deletePartSpare">
  1432. <foreach collection="list" item="item" separator=";">
  1433. delete from resource_spare where site = #{item.site} and resource_id = #{item.objectID}
  1434. </foreach>
  1435. </delete>
  1436. <insert id="copyPartSpare" >
  1437. INSERT INTO resource_spare
  1438. (resource_id, part_no, delflag, version, site)
  1439. <foreach item="item" index="index" collection="list" separator=",">
  1440. select #{item.objectID}, part_no, delflag, 0, site from resource_spare where resource_id = #{item.oldObjectID} and site = #{item.site}
  1441. </foreach>
  1442. </insert>
  1443. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1444. SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status,
  1445. a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark
  1446. ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
  1447. FROM eam_workPlan a
  1448. left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID
  1449. left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID
  1450. left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no
  1451. where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N'
  1452. and status in ('已计划','进行中')
  1453. </select>
  1454. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1455. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  1456. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  1457. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  1458. where a.site=#{site} and a.ObjectID=#{objectID}
  1459. and a.ItemType=#{itemType}
  1460. </select>
  1461. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1462. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  1463. from eam_object_defect a left join eam_defect b
  1464. on a.DefectID=b.DefectID
  1465. where a.site=#{site} and a.ObjectID=#{objectID}
  1466. </select>
  1467. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1468. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1469. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1470. </select>
  1471. <insert id="saveNewEamObjectItem" >
  1472. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1473. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  1474. </insert>
  1475. <update id="editEamObjectItem">
  1476. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  1477. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  1478. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1479. and ItemNo=#{itemNo}
  1480. </update>
  1481. <delete id="deleteObjectItem">
  1482. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1483. and ItemNo=#{itemNo}
  1484. </delete>
  1485. <insert id="saveNewEamObjectItemAvailable">
  1486. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1487. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1488. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1489. </insert>
  1490. <delete id="deleteEamObjectItemAvailable">
  1491. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1492. and ItemNo=#{itemNo}
  1493. </delete>
  1494. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1495. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1496. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1497. </select>
  1498. <select id="getItemValueNoForObject" resultType="Double">
  1499. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1500. </select>
  1501. <insert id="saveObjectItemAvailable">
  1502. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1503. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1504. </insert>
  1505. <update id="updateObjectItemAvailable">
  1506. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1507. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1508. </update>
  1509. <delete id="deleteObjectItemAvailable">
  1510. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1511. </delete>
  1512. <delete id="deleteObjectItemForCopy">
  1513. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1514. </delete>
  1515. <delete id="deleteObjectItemAvailableForCopy">
  1516. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1517. </delete>
  1518. <insert id="copyObjectItem" >
  1519. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1520. ItemType)
  1521. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1522. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1523. </insert>
  1524. <insert id="copyObjectItemAvailable">
  1525. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1526. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1527. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1528. </insert>
  1529. <delete id="deleteObjectDefectForCopy">
  1530. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1531. </delete>
  1532. <insert id="copyObjectDefect">
  1533. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1534. select #{site},#{objectID},DefectID,Active
  1535. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1536. </insert>
  1537. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1538. select
  1539. a.Site,
  1540. a.bu_no,
  1541. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1542. a.FeedBackID,
  1543. a.FeedBackDesc,
  1544. a.ObjectID,
  1545. a.DefectID,
  1546. a.FunctionType,
  1547. a.PlanOperator,
  1548. a.ActualOperator,
  1549. DBO.GET_EAM_Status (A.site,a.bu_no,a.FeedBackID) AS status,
  1550. a.PlanDate,
  1551. a.Remark,
  1552. a.urgency,
  1553. a.deleteFlag,
  1554. a.CreatedDate,
  1555. a.CreatedBy,
  1556. c.operator_name as feedbackBy,
  1557. a.UpdateDate,
  1558. a.UpdateBy,
  1559. a.Version,
  1560. a.DefectDate,
  1561. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as PlanOperatorName,
  1562. b.defectDesc,
  1563. e.ObjectDesc as ObjectDesc,
  1564. FinishDate,
  1565. 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,
  1566. a.repair_reporting_type,
  1567. a.repair_type,
  1568. f.department_name as department,
  1569. g.LocationName,
  1570. a.matter_tracking_flag
  1571. from eam_defect_feedBack a
  1572. left join eam_defect b on a.DefectID = b.DefectID
  1573. left join operator as c on a.CreatedBy = c.operator_id
  1574. 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
  1575. 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
  1576. 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
  1577. left join sys_user as ea on ead.username = ea.username
  1578. left join eam_location as g on e.site = g.site and e.LocationID = g.LocationID and e.bu_no = g.bu_no
  1579. <where>
  1580. a.site in (select site from eam_access_site where username = #{query.userName})
  1581. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1582. and ea.username = #{query.userName}
  1583. <if test="query.buDesc != null and query.buDesc != ''">
  1584. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  1585. </if>
  1586. <if test="query.feedBackID != null and query.feedBackID != ''">
  1587. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1588. </if>
  1589. <if test="query.defectDesc != null and query.defectDesc != ''">
  1590. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1591. </if>
  1592. <if test="query.objectID != null and query.objectID != ''">
  1593. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1594. </if>
  1595. <if test="query.planOperator != null and query.planOperator != ''">
  1596. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1597. </if>
  1598. <if test="query.status != null and query.status != ''">
  1599. AND a.status = #{query.status}
  1600. </if>
  1601. <if test="query.startDate != null ">
  1602. AND a.defectDate >= #{query.startDate}
  1603. </if>
  1604. <if test="query.endDate != null ">
  1605. AND #{query.endDate} >= a.defectDate
  1606. </if>
  1607. <if test="query.urgency != null and query.urgency != ''">
  1608. AND a.urgency = #{query.urgency}
  1609. </if>
  1610. <if test="query.repairReportingType != null and query.repairReportingType != ''">
  1611. AND a.repair_reporting_type = #{query.repairReportingType}
  1612. </if>
  1613. <if test="query.repairType != null and query.repairType != ''">
  1614. AND a.repair_type = #{query.repairType}
  1615. </if>
  1616. <if test="query.department != null and query.department != ''">
  1617. AND f.department_name like '%' + #{query.department} + '%'
  1618. </if>
  1619. <if test="query.locationName != null and query.locationName != ''">
  1620. AND g.LocationName like '%' + #{query.locationName} + '%'
  1621. </if>
  1622. <if test="query.matterTrackingFlag != null and query.matterTrackingFlag != ''">
  1623. AND a.matter_tracking_flag = #{query.matterTrackingFlag}
  1624. </if>
  1625. and a.FunctionType = #{query.functionType}
  1626. </where>
  1627. ORDER BY a.DefectDate,
  1628. CASE WHEN a.urgency = '特急' THEN 1
  1629. WHEN a.urgency = '紧急' THEN 2
  1630. WHEN a.urgency = '一般' THEN 3
  1631. END
  1632. </select>
  1633. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1634. select Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, Status from eam_defect_feedBack where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1635. </select>
  1636. <update id="cancelFeedBack" >
  1637. update eam_defect_feedBack
  1638. set status = '已取消'
  1639. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1640. </update>
  1641. <update id="updateFeedBack">
  1642. update eam_defect_feedBack
  1643. set status = '已下达',
  1644. PlanOperator = #{planOperator},
  1645. UpdateDate = GetDate(),
  1646. UpdateBy = #{updateBy}
  1647. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1648. </update>
  1649. <insert id="saveDefectOrder">
  1650. INSERT INTO eam_workOrder
  1651. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1652. 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})
  1653. </insert>
  1654. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1655. SELECT
  1656. a.site,
  1657. a.bu_no,
  1658. a.itemNo,
  1659. a.ItemDesc,
  1660. a.ItemRemark
  1661. FROM eam_properties_item a
  1662. 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
  1663. <where>
  1664. a.site = #{site} and a.bu_no = #{buNo} and a.ItemType = #{functionType} and a.check_type = #{checkType} AND b.code_no is null
  1665. <if test = "itemNo != null and itemNo != ''">
  1666. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1667. </if>
  1668. <if test = "itemDesc != null and itemDesc != ''">
  1669. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1670. </if>
  1671. </where>
  1672. </select>
  1673. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1674. select
  1675. a.site,
  1676. a.bu_no,
  1677. a.properties_item_no itemNo,
  1678. b.ItemDesc,
  1679. b.ItemRemark
  1680. from eam_properties_model_detail a
  1681. 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
  1682. where a.site = #{site} and a.bu_no = #{buNo} and a.code_no = #{codeNo} and a.function_type = #{functionType} and a.check_type = #{checkType}
  1683. </select>
  1684. <delete id="deleteObjectFile">
  1685. delete from sys_oss where id = #{id}
  1686. </delete>
  1687. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1688. SELECT
  1689. id,
  1690. url,
  1691. create_date,
  1692. file_name,
  1693. new_file_name,
  1694. created_by,
  1695. order_ref1,
  1696. order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1697. FROM sys_oss
  1698. WHERE order_ref2 = #{orderNo}
  1699. AND order_ref1 = #{site}
  1700. AND order_ref3 = 'reportSparPart'
  1701. </select>
  1702. <!-- 获取机修人员列表 -->
  1703. <select id="getOperatorList" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  1704. SELECT
  1705. ea.AdminID,
  1706. ea.AdminName,
  1707. ea.Phone,
  1708. dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName,
  1709. ea.Email,
  1710. ea.Tel,
  1711. ea.LevelID,
  1712. eal.AdminLevelDesc,
  1713. ea.MesUser,
  1714. ea.Active,
  1715. ea.CreatedDate
  1716. FROM eam_admin as ea
  1717. LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1718. <where>
  1719. ea.Active = 'Y'
  1720. AND ea.Site = #{site}
  1721. <if test = "adminID != null and adminID != ''">
  1722. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1723. </if>
  1724. <if test = "adminName != null and adminName != ''">
  1725. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1726. </if>
  1727. </where>
  1728. </select>
  1729. <!-- 获取审核人员列表 -->
  1730. <select id="getCheckerList" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  1731. SELECT
  1732. a.user_id,
  1733. a.username as adminID,
  1734. a.email,
  1735. a.mobile as phone,
  1736. a.user_display as adminName,
  1737. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  1738. d.role_id,
  1739. e.role_name
  1740. FROM sys_user as a
  1741. LEFT JOIN eam_access_site as b on a.username = b.username
  1742. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  1743. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  1744. LEFT JOIN sys_role as e on d.role_id = e.role_id
  1745. <where>
  1746. b.site = #{site} and c.bu_no = #{buNo}
  1747. <if test = "adminID != null and adminID != ''">
  1748. AND a.username LIKE '%' + #{adminID}+'%'
  1749. </if>
  1750. <if test = "adminName != null and adminName != ''">
  1751. AND a.user_display LIKE '%' + #{adminName}+'%'
  1752. </if>
  1753. <if test = "buDesc != null and buDesc != ''">
  1754. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  1755. </if>
  1756. <if test = "roleId != null and roleId != ''">
  1757. AND d.role_id = #{roleId}
  1758. </if>
  1759. </where>
  1760. </select>
  1761. <!-- 点检工单审核 -->
  1762. <update id="checkWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1763. UPDATE eam_workOrder
  1764. SET Status = '已完工'
  1765. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1766. </update>
  1767. <update id="cancelCheckWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1768. UPDATE eam_workOrder
  1769. SET Status = '待审核'
  1770. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1771. </update>
  1772. <!-- 查看点检工单状态 -->
  1773. <select id="checkWorkOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1774. SELECT
  1775. OrderNo
  1776. FROM eam_workOrder
  1777. WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' and bu_no = #{buNo}
  1778. </select>
  1779. <!-- 点检工单审核 -->
  1780. <update id="updateWorkPlanOverviewStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1781. UPDATE eam_workPlan_overview
  1782. SET status = '已结束'
  1783. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1784. </update>
  1785. <!-- 新增点检计划 -->
  1786. <insert id="saveWorkPlan" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1787. INSERT INTO eam_workPlan_overview
  1788. (site, plan_id, plan_desc, status, plan_start_date, plan_end_date, created_date, created_by, update_date, update_by,
  1789. remark, delete_flag, operator, operator_name, checker, checker_name, function_type, properties_code, plan_period,
  1790. work_order_rule, plan_cycle, task_start_date, plan_halt_date, auto_renewal, bu_no, check_type)
  1791. VALUES
  1792. (#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy},
  1793. #{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod},
  1794. #{workOrderRule}, #{planCycle}, #{taskStartDate}, #{planHaltDate}, #{autoRenewal}, #{buNo}, #{checkType})
  1795. </insert>
  1796. <!-- 生成工单ID -->
  1797. <select id="selectOrderId" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1798. SELECT
  1799. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1800. FROM eam_workPlan
  1801. WHERE site = #{site} AND FunctionType = #{functionType} and bu_no = #{buNo}
  1802. </select>
  1803. <!-- 查询计划中的设备列表 -->
  1804. <select id="getPlanDetailList" resultType="com.xujie.sys.modules.pms.data.WorkPlanDetailData" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  1805. SELECT
  1806. ewp.PlanID,
  1807. ewp.PlanDesc,
  1808. ewp.ObjectID,
  1809. eo.ObjectDesc,
  1810. eo.FamilyID,
  1811. ef.FamilyDesc,
  1812. eo.LocationID,
  1813. el.LocationName
  1814. FROM eam_workPlan as ewP
  1815. LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site and ewP.bu_no = eo.bu_no
  1816. LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site and ewP.bu_no = ef.bu_no
  1817. LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site and ewP.bu_no = el.bu_no
  1818. <where>
  1819. ewP.site = #{site} and ewP.bu_no = #{buNo}
  1820. AND ewp.PlanID = #{planID}
  1821. <if test = "objectID != null and objectID != ''">
  1822. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  1823. </if>
  1824. <if test = "objectDesc != null and objectDesc != ''">
  1825. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  1826. </if>
  1827. </where>
  1828. </select>
  1829. <!-- 删除计划中的设备 -->
  1830. <delete id="delPlanDetail" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  1831. DELETE FROM eam_workPlan
  1832. WHERE Site = #{site}
  1833. AND PlanID = #{planID}
  1834. AND ObjectID = #{objectID}
  1835. </delete>
  1836. <!-- 获取当前计划不包含的设备 -->
  1837. <select id="getObjList1" resultType="com.xujie.sys.modules.pms.data.WorkPlanDetailData" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  1838. SELECT
  1839. a.ObjectID,
  1840. a.ObjectDesc,
  1841. a.FamilyID,
  1842. ef.FamilyDesc,
  1843. a.LocationID,
  1844. el.LocationName
  1845. FROM eam_object a
  1846. 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
  1847. LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1848. LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1849. WHERE a.site = #{site} and a.bu_no = #{buNo} and b.PlanID is null
  1850. </select>
  1851. <!-- 获取当前计划包含的设备 -->
  1852. <select id="getObjList2" resultType="com.xujie.sys.modules.pms.data.WorkPlanDetailData" parameterType="com.xujie.sys.modules.pms.data.WorkPlanDetailData">
  1853. SELECT
  1854. a.ObjectID,
  1855. b.ObjectDesc,
  1856. b.FamilyID,
  1857. ef.FamilyDesc,
  1858. b.LocationID,
  1859. el.LocationName
  1860. FROM eam_workPlan a
  1861. LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1862. LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1863. LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1864. WHERE a.PlanID = #{planID} and a.site = #{site} and a.bu_no = #{buNo}
  1865. </select>
  1866. <!-- 添加计划设备 -->
  1867. <insert id="addObject" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1868. INSERT INTO eam_workPlan
  1869. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  1870. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  1871. </insert>
  1872. <!-- 修改工单计划 -->
  1873. <update id="updateWorkPlan" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1874. UPDATE eam_workPlan_overview
  1875. SET plan_desc = #{planDesc},
  1876. properties_code = #{propertiesCode},
  1877. plan_start_date = #{planStartDate},
  1878. plan_end_date = #{planEndDate},
  1879. plan_period = #{planPeriod},
  1880. remark = #{remark},
  1881. operator = #{operator},
  1882. operator_name = #{operatorName},
  1883. checker = #{checker},
  1884. checker_name = #{checkerName},
  1885. work_order_rule = #{workOrderRule},
  1886. task_start_date = #{taskStartDate},
  1887. plan_cycle = #{planCycle},
  1888. plan_halt_date = #{planHaltDate},
  1889. auto_renewal = #{autoRenewal}
  1890. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1891. </update>
  1892. <!-- 删除该计划的旧设备 -->
  1893. <delete id="delWorkPlanObject" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1894. DELETE FROM eam_workPlan
  1895. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1896. </delete>
  1897. <!-- 删除该计划的旧设备item -->
  1898. <delete id="delWorkPlanItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1899. DELETE FROM eam_workPlan_item
  1900. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1901. </delete>
  1902. <!-- 删除该计划的旧设备itemAvailable-->
  1903. <delete id="delWorkPlanItemAvailable">
  1904. DELETE FROM eam_workPlan_item_available
  1905. WHERE Site = #{site}
  1906. AND PlanID = #{planID}
  1907. AND ObjectID = #{objectID}
  1908. </delete>
  1909. <!-- 查询该计划的设备 -->
  1910. <select id="planObjectSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData">
  1911. SELECT DISTINCT
  1912. a.ObjectID,
  1913. b.ObjectDesc
  1914. FROM eam_workPlan_item as a
  1915. LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1916. WHERE a.Site = #{site} AND a.PlanID = #{planID} and a.bu_no = #{buNo}
  1917. </select>
  1918. <!-- 修改该计划状态 -->
  1919. <update id="updateOverviewStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1920. UPDATE eam_workPlan_overview
  1921. SET status = '进行中',
  1922. next_work_date = plan_start_date
  1923. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1924. </update>
  1925. <!-- 查询文件路径 -->
  1926. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1927. SELECT
  1928. id,
  1929. url,
  1930. file_name,
  1931. create_date,
  1932. new_file_name,
  1933. created_by,
  1934. order_ref1,
  1935. order_ref2,
  1936. order_ref3,
  1937. order_ref4,
  1938. file_type,
  1939. file_suffix,
  1940. file_type_code
  1941. FROM sys_oss
  1942. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} and order_ref4 = #{buNo}
  1943. </select>
  1944. <!-- 新增子明细信息 -->
  1945. <insert id="saveOperator" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  1946. INSERT INTO eam_actual_operator
  1947. (site, order_no, function_type, operator, bu_no)
  1948. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
  1949. </insert>
  1950. <!-- AND Status = '已完工' AND PlanOperator is not null-->
  1951. <!-- 查询实际维修人员 -->
  1952. <select id="getActualOperatorList2" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  1953. SELECT
  1954. ea.AdminID,
  1955. ea.AdminName
  1956. FROM eam_actual_operator as eao
  1957. LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site
  1958. LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo
  1959. WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID}
  1960. </select>
  1961. <!-- 查询实际维修人员 -->
  1962. <select id="getActualOperatorList" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  1963. SELECT
  1964. ea.username as adminID,
  1965. ea.user_display as AdminName
  1966. FROM eam_actual_operator as eao
  1967. LEFT JOIN sys_user as ea ON eao.operator = ea.username
  1968. WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} and eao.bu_no = #{buNo}
  1969. </select>
  1970. <!-- 查询设备所属部门 -->
  1971. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  1972. SELECT ved.department_name
  1973. FROM eam_object as eo
  1974. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  1975. WHERE eo.site = #{site}
  1976. AND eo.ObjectID = #{objectID}
  1977. </select>
  1978. <!-- 查询用户所属部门 -->
  1979. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  1980. SELECT AdminID
  1981. FROM eam_admin
  1982. WHERE site = #{site}
  1983. AND MesUser = #{username}
  1984. </select>
  1985. <!-- &lt;!&ndash; 查询部门列表 &ndash;&gt;-->
  1986. <!-- <select id="getDeptList" resultType="string" parameterType="string">-->
  1987. <!-- SELECT-->
  1988. <!-- ved.department_name-->
  1989. <!-- FROM eam_admin_dept as ead-->
  1990. <!-- LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id-->
  1991. <!-- LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID-->
  1992. <!-- WHERE ead.site = #{site} AND ea.MesUser = #{username}-->
  1993. <!-- </select>-->
  1994. <!-- 查询部门列表 -->
  1995. <select id="getDeptList" resultType="string" parameterType="string">
  1996. SELECT
  1997. distinct c.department_name
  1998. from sys_user as a
  1999. left join Access_dept as b on a.username = b.username
  2000. left join sys_department as c on c.site in (select site from eam_access_site where username = #{username})
  2001. and (c.site + '-' + c.bu_no) in (select * from dbo.query_bu(#{username}))
  2002. and b.department_id = c.department_id
  2003. where a.username = #{username}
  2004. </select>
  2005. <!-- 生成新的维修工单 -->
  2006. <insert id="saveDefectWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2007. INSERT INTO eam_workOrder
  2008. (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)
  2009. VALUES
  2010. (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource}, #{repairReportingType}, #{repairType}, #{planOperator})
  2011. </insert>
  2012. <!-- 获取旧工单的基础信息 -->
  2013. <select id="queryOldWorkOrderMessage" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2014. select
  2015. PlanOperator,
  2016. PlanOperatorName,
  2017. checker,
  2018. checkerName
  2019. from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2020. </select>
  2021. <!-- 生成新的维保工单 -->
  2022. <insert id="saveMaintenanceWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2023. INSERT INTO eam_workOrder
  2024. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  2025. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  2026. </insert>
  2027. <!-- 检查系统操作人和审核人员是否一致 -->
  2028. <select id="selectNameByMes" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  2029. SELECT AdminName
  2030. FROM eam_admin
  2031. WHERE site = #{site}
  2032. AND MesUser = #{mesUser}
  2033. </select>
  2034. <!-- 维修审核确认 -->
  2035. <update id="submitDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2036. UPDATE eam_workOrder
  2037. SET Status = #{status},
  2038. difficulty_level = #{difficultyLevel},
  2039. difficulty_remark = #{difficultyRemark}
  2040. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  2041. </update>
  2042. <!-- 查询设备的点检和维保历史记录 -->
  2043. <select id="queryHistoryRecord" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2044. SELECT
  2045. ewo.OrderNo,
  2046. ewo.PlanID,
  2047. ewo.PlanDesc,
  2048. ewo.ActualDate,
  2049. ewo.ObjectID,
  2050. eo.ObjectDesc,
  2051. ewo.Remark,
  2052. dbo.eam_Get_eamAdminName(ewo.site, ewo.ActualOperator) ActualOperatorName,
  2053. ewo.checkResult,
  2054. FROM eam_workOrder as ewo
  2055. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  2056. 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 = '待审核')
  2057. ORDER BY ewo.ActualDate desc
  2058. </select>
  2059. <!-- 查询设备的维修历史记录 -->
  2060. <select id="queryDefectHistoryRecord" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2061. SELECT DISTINCT
  2062. ewo.OrderNo,
  2063. ewo.PlanID,
  2064. ewo.PlanDesc,
  2065. ewo.ActualDate,
  2066. ewo.Remark,
  2067. ewo.Result,
  2068. ewo.disposal_measures,
  2069. ed.DefectDesc,
  2070. ewo.WorkTime,
  2071. dbo.eam_Get_eamAdminName(ewo.Site, ewo.ActualOperator) actualOperatorName,
  2072. case when so.id is not null then 'Y' else 'N' end as reportFaultFlag,
  2073. case when so1.id is not null then 'Y' else 'N' end as reportSparPartFlag
  2074. FROM eam_workOrder as ewo
  2075. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  2076. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID and ewo.bu_no = edf.bu_no
  2077. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  2078. 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
  2079. LEFT JOIN sys_oss as so1 on so1.order_ref1 = ewo.Site AND so1.order_ref2 = ewo.OrderNo AND so1.order_ref3 =
  2080. 'reportSparPart' and so1.order_ref4 = ewo.bu_no
  2081. <where>ewo.site = #{query.site} and ewo.bu_no = #{query.buNo} and ewo.ObjectID = #{query.objectID} and
  2082. ewo.FunctionType = #{query.functionType} AND (ewo.Status = '已完工' or ewo.Status = '待审核')
  2083. <if test="query.startDate != null ">
  2084. AND ewo.ActualDate >= #{query.startDate}
  2085. </if>
  2086. <if test="query.endDate != null ">
  2087. AND #{query.endDate} >= ewo.ActualDate
  2088. </if>
  2089. </where> ORDER BY ewo.ActualDate desc
  2090. </select>
  2091. <!-- 查询部门列表 -->
  2092. <select id="getEmpyDeptList" resultType="com.xujie.sys.modules.pms.data.EmpyDept" parameterType="com.xujie.sys.modules.pms.data.EmpyDept">
  2093. SELECT
  2094. site,
  2095. department_id as deptId,
  2096. department_name as deptName
  2097. FROM sys_department
  2098. <where>
  2099. site in (select site from eam_access_site where username = #{userName})
  2100. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2101. <if test = "deptId != null and deptId != ''">
  2102. AND department_id LIKE '%' + #{deptId}+'%'
  2103. </if>
  2104. <if test = "deptName != null and deptName != ''">
  2105. AND department_name LIKE '%' + #{deptName}+'%'
  2106. </if>
  2107. </where>
  2108. </select>
  2109. <!-- 生成新的维修工单 -->
  2110. <insert id="saveAdminDepartment">
  2111. INSERT INTO eam_admin_dept
  2112. (Site, admin_id, dept_id)
  2113. VALUES (#{site}, #{adminID}, #{deptId})
  2114. </insert>
  2115. <!-- 查询部门详情 -->
  2116. <select id="getDeptDetail" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="string">
  2117. SELECT
  2118. ved.department_id as department,
  2119. ved.department_name as departmentName
  2120. FROM eam_admin_dept as ead
  2121. 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
  2122. WHERE ead.site in (select site from eam_access_site where username = #{userName})
  2123. and (ead.site + '-' + ead.bu_no) in (select * from dbo.query_bu(#{userName}))
  2124. AND ead.admin_id = #{adminID}
  2125. </select>
  2126. <!-- 删除旧数据-->
  2127. <delete id="deleteAdminDepartment">
  2128. DELETE FROM eam_admin_dept
  2129. WHERE site = #{site}
  2130. AND admin_id = #{adminID}
  2131. </delete>
  2132. <!-- 获取可用的MES账号 -->
  2133. <select id="getMesList" resultType="com.xujie.sys.modules.sys.entity.SysUserEntity" parameterType="com.xujie.sys.modules.sys.entity.SysUserEntity">
  2134. SELECT
  2135. a.username,
  2136. a.user_display
  2137. FROM sys_user a
  2138. LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site
  2139. WHERE a.site = #{site}
  2140. AND b.MesUser is null
  2141. </select>
  2142. <!-- 查询点检项目 -->
  2143. <select id="eamPropertiesItemSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesItemData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  2144. SELECT
  2145. site,
  2146. bu_no,
  2147. dbo.get_bu_desc(site, bu_no) as buDesc,
  2148. ItemNo,
  2149. ItemDesc,
  2150. DefaultValue,
  2151. ValueType,
  2152. ValueType_DB as valueTypeDb,
  2153. ValueChooseFlag,
  2154. case when ValueChooseFlag = 'Y' then '是' when ValueChooseFlag = 'N' then '否' else '' end as valueChooseFlagDesc,
  2155. CreatedDate,
  2156. CreatedBy,
  2157. dbo.getOperatorDesc(site, CreatedBy) as createdByDesc,
  2158. update_date,
  2159. update_by,
  2160. dbo.getOperatorDesc(site, update_by) as updateByDesc,
  2161. MaxValue,
  2162. MinValue,
  2163. ItemRemark,
  2164. ItemType,
  2165. image_flag,
  2166. produce_control_flag,
  2167. check_type
  2168. FROM eam_properties_item
  2169. <where>
  2170. site in (select site from eam_access_site where username = #{query.userName})
  2171. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2172. and check_type in (select role_no from access_role where username = #{query.userName})
  2173. and ItemType = #{query.itemType}
  2174. <if test="query.buDesc != null and query.buDesc != ''">
  2175. AND dbo.get_bu_desc(site, bu_no) = #{query.buDesc}
  2176. </if>
  2177. <if test="query.itemNo != null and query.itemNo != ''">
  2178. AND ItemNo LIKE '%' + #{query.itemNo} + '%'
  2179. </if>
  2180. <if test="query.itemDesc != null and query.itemDesc != ''">
  2181. AND ItemDesc LIKE '%' + #{query.itemDesc} + '%'
  2182. </if>
  2183. <if test="query.checkType != null and query.checkType != ''">
  2184. AND check_type = #{query.checkType}
  2185. </if>
  2186. </where>
  2187. </select>
  2188. <!-- 删除图片-->
  2189. <delete id="imageDelete" parameterType="SysOssEntity">
  2190. DELETE FROM sys_oss
  2191. WHERE id = #{id}
  2192. </delete>
  2193. <!-- 检查该日期内是否已有该设备的计划 -->
  2194. <select id="checkObjectPlan" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2195. SELECT
  2196. a.PlanID,
  2197. a.ObjectID
  2198. FROM eam_workPlan a
  2199. 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
  2200. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.check_type = #{checkType}
  2201. AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N'
  2202. AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  2203. or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  2204. or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0))
  2205. and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod}
  2206. and b.Status not in ('已取消','已完成','待审核')
  2207. </select>
  2208. <!-- 查询当前计划 -->
  2209. <select id="queryWorkPlan" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2210. SELECT
  2211. site,
  2212. bu_no,
  2213. plan_id,
  2214. plan_desc,
  2215. properties_code,
  2216. #{objectID} as objectID,
  2217. status,
  2218. operator,
  2219. delete_flag,
  2220. plan_start_date,
  2221. plan_end_date,
  2222. plan_period,
  2223. function_type,
  2224. checker,
  2225. checker_name,
  2226. operator_name,
  2227. work_order_rule,
  2228. plan_cycle,
  2229. check_type
  2230. FROM eam_workPlan_overview
  2231. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  2232. </select>
  2233. <!-- 获得工单号 -->
  2234. <select id="queryPlanOrderNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2235. SELECT
  2236. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2237. FROM eam_workOrder
  2238. WHERE site = #{site} and bu_no = #{buNo} AND FunctionType = #{functionType}
  2239. </select>
  2240. <!-- 新增工单 -->
  2241. <insert id="insertWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2242. INSERT INTO eam_workOrder
  2243. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, check_type)
  2244. VALUES
  2245. (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{checkType})
  2246. </insert>
  2247. <!-- 循环新增工单 -->
  2248. <insert id="forInsertWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2249. INSERT INTO eam_workOrder
  2250. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName, last_execution_date, check_type)
  2251. VALUES
  2252. (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}, #{lastExecutionDate}, #{checkType})
  2253. </insert>
  2254. <!-- 更改plan表的状态为进行中 -->
  2255. <update id="updatePlanStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2256. update eam_workPlan
  2257. set status = '进行中',
  2258. NextWorkDate = PlanStartDate
  2259. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2260. </update>
  2261. <!-- 获得工单号 -->
  2262. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2263. SELECT
  2264. id,
  2265. file_name
  2266. FROM sys_oss
  2267. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2268. </select>
  2269. <!-- 删除原来工单项目-->
  2270. <delete id="deleteWorkPlanItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2271. DELETE FROM eam_workPlan_item
  2272. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2273. </delete>
  2274. <!-- 删除原来的可选值-->
  2275. <delete id="deleteWorkPlanItemAvailable" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2276. DELETE FROM eam_workPlan_item_available
  2277. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  2278. </delete>
  2279. <!-- 添加新项目 -->
  2280. <insert id="saveWorkPlanItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2281. 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)
  2282. select
  2283. #{site},
  2284. #{buNo},
  2285. #{planID},
  2286. #{objectID},
  2287. a.ItemNo,
  2288. a.ItemDesc,
  2289. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  2290. case when c.site is not null then c.ValueType else a.ValueType end,
  2291. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  2292. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  2293. case when c.site is not null then c.MaxValue else a.MaxValue end,
  2294. case when c.site is not null then c.MinValue else a.MinValue end,
  2295. a.ItemRemark,
  2296. a.ItemType,
  2297. GetDate(),
  2298. #{userId},
  2299. a.image_flag,
  2300. a.produce_control_flag
  2301. from eam_properties_item a
  2302. 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
  2303. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  2304. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2305. </insert>
  2306. <!-- 添加新项目可选值 -->
  2307. <insert id="saveWorkPlanItemAvailable" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2308. INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  2309. SELECT DISTINCT
  2310. #{site},
  2311. #{buNo},
  2312. #{planID},
  2313. #{objectID},
  2314. a.ItemNo,
  2315. a.ItemType,
  2316. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  2317. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  2318. GetDate(),
  2319. #{userId}
  2320. FROM eam_properties_item_available a
  2321. 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
  2322. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  2323. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  2324. </insert>
  2325. <!-- 检查维修任务号是否已存在 -->
  2326. <select id="getEamGzData" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2327. select
  2328. a.Site,
  2329. a.bu_no,
  2330. a.FeedBackID,
  2331. a.FeedBackDesc,
  2332. a.ObjectID,
  2333. a.Status,
  2334. ISNULL(c.public_facilities_flag,'N') AS public_facilities_flag
  2335. from eam_defect_feedBack a
  2336. left join eam_defect b on a.DefectID = b.DefectID
  2337. left join eam_object c on a.ObjectID = c.ObjectID and a.site = c.site and a.bu_no = c.bu_no
  2338. <where>
  2339. a.site = #{site} and a.deleteFlag = 'N' and a.bu_no = #{buNo}
  2340. <if test="feedBackID != null and feedBackID != ''">
  2341. AND a.FeedBackID LIKE '%' + #{feedBackID}+'%'
  2342. </if>
  2343. <if test="feedBackDesc != null and feedBackDesc != ''">
  2344. AND a.FeedBackDesc LIKE '%' + #{feedBackDesc}+'%'
  2345. </if>
  2346. <if test="objectInfo != null and objectInfo != ''">
  2347. AND (a.ObjectID like '%' + #{objectInfo} + '%' or dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) like '%' + #{objectInfo} + '%')
  2348. </if>
  2349. <if test="defectInfo != null and defectInfo != ''">
  2350. AND (a.DefectID like '%' + #{defectInfo} + '%' or b.defectDesc like '%' + #{defectInfo} + '%')
  2351. </if>
  2352. </where>
  2353. ORDER BY a.CreatedDate desc
  2354. </select>
  2355. <!-- 保存故障信息 -->
  2356. <insert id="saveEamGzBbData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2357. INSERT INTO eam_defect_feedBack
  2358. (Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate,
  2359. Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency, repair_reporting_type, repair_type)
  2360. VALUES
  2361. (#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate},
  2362. #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency}, #{repairReportingType}, #{repairType})
  2363. </insert>
  2364. <!-- 查看现场动控是否开启 -->
  2365. <select id="selectControlBaseData" resultType="com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity" parameterType="string">
  2366. SELECT
  2367. type,
  2368. base_data,
  2369. base_desc,
  2370. status,
  2371. remark,
  2372. third_type,
  2373. second_type,
  2374. page_control,
  2375. control_style
  2376. FROM sys_scene_dynamic_control_model
  2377. where site = #{site} and control_no = #{controlNo}
  2378. </select>
  2379. <!-- 修改反馈状态为已下达 -->
  2380. <update id="updateDefectFeedBackStatus" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2381. UPDATE eam_defect_feedBack
  2382. SET Status = '已下达'
  2383. WHERE Site = #{site} and bu_no = #{buNo} and FeedBackID = #{feedBackID}
  2384. </update>
  2385. <!-- 查询工单号 -->
  2386. <select id="getOrderNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2387. select
  2388. 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2389. from eam_workOrder
  2390. where site = #{site} and FunctionType = 'C' and bu_no = #{buNo}
  2391. </select>
  2392. <!-- 创建维修工单 -->
  2393. <insert id="saveWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2394. INSERT INTO eam_workOrder
  2395. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source, repair_reporting_type, repair_type, PlanOperator)
  2396. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource}, #{repairReportingType}, #{repairType}, #{planOperator})
  2397. </insert>
  2398. <!-- 修改工单 -->
  2399. <update id="updateWorkOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2400. update eam_workOrder
  2401. set update_by = #{mesUser},
  2402. update_date = GetDate(),
  2403. Remark = #{remark},
  2404. reach_date = #{reachDate},
  2405. ActualDate = #{actualDate},
  2406. WorkTime = #{workTime},
  2407. <if test='functionType == "B" and checkResult == "合格"'>
  2408. disposal_measures = '',
  2409. </if>
  2410. <if test='functionType == "B" and checkResult == "异常"'>
  2411. disposal_measures = #{disposalMeasures},
  2412. </if>
  2413. checkResult = #{checkResult},
  2414. check_remark = #{checkRemark},
  2415. fault_reason = #{faultReason},
  2416. preventive_measure = #{preventiveMeasure}
  2417. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  2418. </update>
  2419. <!-- 修改工单项目 -->
  2420. <update id="updateWorkOrderItem" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  2421. update eam_workOrder_item
  2422. set update_by = #{updateBy},
  2423. update_date = GetDate(),
  2424. <if test='valueTypeDb == "T"'>
  2425. TextValue = #{textValue},
  2426. </if>
  2427. <if test='valueTypeDb == "N"'>
  2428. NumberValue = #{numberValue},
  2429. </if>
  2430. itemResult = #{itemResult}
  2431. where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
  2432. </update>
  2433. <!-- 删除之前的协同人员-->
  2434. <delete id="delOperator" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2435. DELETE FROM eam_actual_operator
  2436. WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
  2437. </delete>
  2438. <!-- 到达 -->
  2439. <update id="reach" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2440. update eam_workOrder
  2441. set Status = #{status},
  2442. reach_date = GetDate(),
  2443. reach_operator = #{reachOperator},
  2444. reach_operator_name = #{reachOperatorName}
  2445. where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_No = #{buNo}
  2446. </update>
  2447. <!-- 查询是否已经上传图片 -->
  2448. <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemData">
  2449. SELECT
  2450. id
  2451. FROM sys_oss
  2452. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo}
  2453. </select>
  2454. <!-- 查询文件路径 -->
  2455. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderItemData">
  2456. SELECT
  2457. id,
  2458. url,
  2459. file_name
  2460. FROM sys_oss
  2461. WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2462. </select>
  2463. <!-- 根据工单号查询知识库记录 -->
  2464. <select id="selectKnowledgeRecordByOrderNo" resultType="com.xujie.sys.modules.pms.data.EamKnowledgeBaseData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2465. SELECT
  2466. site,
  2467. bu_no,
  2468. num
  2469. FROM eam_knowledge_base
  2470. WHERE site = #{site} and bu_no = #{buNo} and order_no = #{orderNo}
  2471. </select>
  2472. <!-- 根据工单号修改知识库记录 -->
  2473. <update id="updateKnowledgeRecordByOrderNo" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2474. update eam_knowledge_base
  2475. SET defect_id = #{defectID},
  2476. defect_desc = #{defectDesc},
  2477. defect_describe = #{planDesc},
  2478. remark = #{remark},
  2479. fault_reason = #{faultReason},
  2480. handling_method = #{handlingMethod},
  2481. preventive_measure = #{preventiveMeasure},
  2482. feedback_by = #{feedbackBy},
  2483. actual_operator_name = #{actualOperatorName},
  2484. update_date = getDate(),
  2485. update_by = #{updateBy}
  2486. where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2487. </update>
  2488. <!-- 新增设备知识库记录 -->
  2489. <insert id="saveKnowledgeRecord" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2490. INSERT INTO eam_knowledge_base
  2491. (site, bu_no, num, defect_describe, remark, object_id, defect_id, defect_desc, order_no,
  2492. fault_reason, handling_method, preventive_measure, feedback_by, actual_operator_name, create_date, create_by)
  2493. VALUES
  2494. (#{site}, #{buNo}, #{num}, #{planDesc}, #{remark}, #{objectID}, #{defectID}, #{defectDesc}, #{orderNo},
  2495. #{faultReason}, #{handlingMethod}, #{preventiveMeasure}, #{feedbackBy}, #{actualOperatorName}, getDate(), #{updateBy})
  2496. </insert>
  2497. <!-- 修改反馈状态为已取消 -->
  2498. <update id="updateFeedBackStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2499. UPDATE eam_defect_feedBack
  2500. SET Status = '已取消'
  2501. WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
  2502. </update>
  2503. <!-- 获取所有分类 -->
  2504. <select id="getFamilyTree" resultType="com.xujie.sys.modules.pms.data.EamFamilyData" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData">
  2505. SELECT
  2506. site,
  2507. bu_no,
  2508. FamilyID,
  2509. FamilyDesc,
  2510. parent_id,
  2511. son_id,
  2512. Active
  2513. FROM eam_family
  2514. WHERE site in (select site from eam_access_site where username = #{userName})
  2515. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2516. and Active = 'Y'
  2517. </select>
  2518. <!-- 获得sonId -->
  2519. <select id="getSonId" resultType="string" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData">
  2520. SELECT
  2521. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2)
  2522. FROM eam_family
  2523. WHERE site = #{site} and bu_no = #{buNo} and son_id like #{parentId} + '%'
  2524. </select>
  2525. <!-- 删除该分类以及其子类-->
  2526. <delete id="eamFamilyDelete" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData">
  2527. DELETE FROM eam_family
  2528. WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID}
  2529. <if test="sonId != null and sonId != ''">
  2530. and son_id like #{sonId} + '%'
  2531. </if>
  2532. </delete>
  2533. <select id="getEamWorkOrder" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2534. EXEC EAM_WORK_ORDER #{site}, #{username}, #{orderNo}, #{planID}, #{objectID}, #{status}, #{startDate}, #{endDate}, #{functionType}, '*'
  2535. </select>
  2536. <!-- 修改执行结果 -->
  2537. <update id="updateReportResult" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2538. update eam_workOrder
  2539. set ActualDate = #{actualDate},
  2540. reach_date = #{reachDate},
  2541. fault_reason = #{faultReason},
  2542. handling_method = #{handlingMethod},
  2543. preventive_measure = #{preventiveMeasure},
  2544. Remark = #{remark},
  2545. WorkTime = #{workTime},
  2546. check_assessment = #{checkAssessment},
  2547. check_notes = #{checkNotes}
  2548. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2549. </update>
  2550. <!-- 根据设备查所属部门 -->
  2551. <select id="queryDepartmentByObjectId" resultType="com.xujie.sys.modules.pms.data.EamObjectAdminData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackData">
  2552. SELECT
  2553. eo.site,
  2554. eo.bu_no,
  2555. eo.ObjectDesc,
  2556. eo.dept_id,
  2557. el.LocationName
  2558. FROM eam_object as eo
  2559. LEFT JOIN eam_location as el on eo.site = el.site and eo.LocationID = el.LocationID and eo.bu_no = el.bu_no
  2560. WHERE eo.site = #{site} and eo.ObjectID = #{objectID} and eo.bu_no = #{buNo}
  2561. </select>
  2562. <!-- 根据部门ID查机修人员电话 -->
  2563. <select id="queryPhoneByDepartmentId" resultType="com.xujie.sys.modules.pms.data.EamObjectAdminData" parameterType="com.xujie.sys.modules.pms.data.EamObjectAdminData">
  2564. SELECT
  2565. ed.user_display as adminName,
  2566. ed.mobile as phone
  2567. FROM Access_dept as edd
  2568. LEFT JOIN sys_user ed on edd.username = ed.username and edd.site in (select site from eam_access_site where username = ed.username)
  2569. and (edd.site + '-' + edd.bu_no) in (select * from dbo.query_bu(ed.username))
  2570. 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)
  2571. 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
  2572. </select>
  2573. <!-- 保存短信记录 -->
  2574. <insert id="saveMessageRecord" parameterType="com.xujie.sys.modules.pms.data.MessageRecordData">
  2575. INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
  2576. VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
  2577. </insert>
  2578. <!-- 查出计划结束日期为今天并且自动续期标识为Y的计划 -->
  2579. <select id="selectPlanToday" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2580. SELECT
  2581. site,
  2582. (site + '_' + bu_no) as bu,
  2583. plan_id,
  2584. plan_desc,
  2585. status,
  2586. plan_start_date,
  2587. plan_end_date,
  2588. created_date,
  2589. created_by,
  2590. update_date,
  2591. update_by,
  2592. remark,
  2593. next_work_date,
  2594. delete_flag,
  2595. operator,
  2596. operator_name,
  2597. checker,
  2598. checker_name,
  2599. function_type,
  2600. properties_code,
  2601. plan_period,
  2602. work_order_rule,
  2603. plan_cycle,
  2604. task_start_date,
  2605. plan_halt_date,
  2606. auto_renewal
  2607. FROM eam_workPlan_overview
  2608. WHERE site = #{site} and status != #{status} and delete_flag = #{deleteFlag} and DATEDIFF(day, plan_end_date, getdate()) = 0 and auto_renewal = #{autoRenewal}
  2609. </select>
  2610. <!-- 查出老计划的设备 -->
  2611. <select id="selectObjectByPlanID" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  2612. SELECT
  2613. Site,
  2614. PlanID,
  2615. PlanDesc,
  2616. ObjectID,
  2617. FunctionType,
  2618. PropertiesCode,
  2619. Status
  2620. FROM eam_workPlan
  2621. WHERE site = #{site} and PlanID = #{planID} and FunctionType = #{functionType}
  2622. </select>
  2623. <!-- 获取用户 bu -->
  2624. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  2625. SELECT
  2626. b.id,
  2627. a.site,
  2628. c.sitename,
  2629. (a.site + '_' + a.bu_no) as buNo,
  2630. b.bu_desc
  2631. FROM AccessBu as a
  2632. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2633. left join site as c on a.site = c.siteid
  2634. WHERE a.username = #{username}
  2635. </select>
  2636. <!-- 获取用户 bu -->
  2637. <select id="getSiteAndBuByUserName2" resultType="BuData" parameterType="BuData">
  2638. SELECT
  2639. a.site,
  2640. c.sitename,
  2641. a.bu_no,
  2642. b.bu_desc
  2643. FROM AccessBu as a
  2644. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2645. left join site as c on a.site = c.siteid
  2646. WHERE a.username = #{username}
  2647. </select>
  2648. <!-- 获取用户 bu -->
  2649. <select id="getBuByUserNameSite" resultType="BuData" parameterType="BuData">
  2650. SELECT
  2651. a.site,
  2652. a.bu_no,
  2653. b.bu_desc
  2654. FROM AccessBu as a
  2655. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2656. WHERE a.username = #{username} and a.site = #{site}
  2657. </select>
  2658. <select id="eamCheckRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2659. SELECT
  2660. a.Site,
  2661. a.bu_no,
  2662. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2663. a.OrderNo,
  2664. a.PlanID,
  2665. a.PlanDesc,
  2666. a.PropertiesCode,
  2667. a.ObjectID,
  2668. a.Status,
  2669. a.PlanOperator,
  2670. a.checker,
  2671. a.ActualOperator,
  2672. a.PlanDate,
  2673. a.ActualDate,
  2674. a.FunctionType,
  2675. a.CreateDate,
  2676. d.operator_name as createBy,
  2677. a.Remark,
  2678. a.StartTime,
  2679. a.EndTime,
  2680. a.WorkTime,
  2681. a.PlanOperatorName,
  2682. a.checkerName,
  2683. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) as ActualOperatorName,
  2684. eo.ObjectDesc as objectDesc,
  2685. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  2686. a.result,
  2687. b.urgency,
  2688. a.checkResult,
  2689. b.DefectID,
  2690. c.DefectDesc,
  2691. a.disposal_measures,
  2692. a.check_work_plan_id,
  2693. a.check_item_no,
  2694. a.reach_date,
  2695. a.reach_operator,
  2696. a.reach_operator_name,
  2697. b.FeedBackDesc,
  2698. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  2699. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  2700. a.check_remark,
  2701. a.document_source,
  2702. ewi.ItemNo,
  2703. ewi.ItemDesc,
  2704. ewi.DefaultValue,
  2705. ewi.ValueType,
  2706. ewi.ValueType_DB,
  2707. ewi.ValueChooseFlag,
  2708. ewi.MaxValue,
  2709. ewi.MinValue,
  2710. ewi.ItemRemark,
  2711. ewi.ItemType,
  2712. ewi.TextValue,
  2713. ewi.NumberValue,
  2714. ewi.CreatedDate,
  2715. ewi.CreatedBy,
  2716. ewi.FinishFlag,
  2717. ewi.itemResult,
  2718. ewi.item_notes
  2719. FROM eam_workOrder a
  2720. left join eam_workOrder_item ewi on a.site = ewi.site and a.OrderNo = ewi.OrderNo and a.bu_no = ewi.bu_no
  2721. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  2722. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  2723. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  2724. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  2725. 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
  2726. 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
  2727. left join sys_user as ea on ead.username = ea.username
  2728. 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
  2729. <where>
  2730. a.site in (select site from eam_access_site where username = #{query.userName})
  2731. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2732. and a.check_type in (select role_no from access_role where username = #{query.userName})
  2733. and ea.username = #{query.userName}
  2734. <if test="query.buDesc != null and query.buDesc != ''">
  2735. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2736. </if>
  2737. <if test="query.orderNo != null and query.orderNo != ''">
  2738. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  2739. </if>
  2740. <if test="query.planID != null and query.planID != ''">
  2741. AND a.PlanID like '%' + #{query.planID} +'%'
  2742. </if>
  2743. <if test="query.planDesc != null and query.planDesc != ''">
  2744. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  2745. </if>
  2746. <if test="query.objectID != null and query.objectID != ''">
  2747. AND a.ObjectID like '%' + #{query.objectID} +'%'
  2748. </if>
  2749. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  2750. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  2751. </if>
  2752. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  2753. AND a.status != '已取消'
  2754. </if>
  2755. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  2756. AND a.status = #{query.status}
  2757. </if>
  2758. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  2759. AND a.status = '未开工'
  2760. </if>
  2761. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2762. AND a.status != '已取消'
  2763. </if>
  2764. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  2765. AND a.status = #{query.status}
  2766. </if>
  2767. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  2768. AND (a.status = '未开工' or a.status = '已到达')
  2769. </if>
  2770. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  2771. AND (a.status = '未开工' or a.status = '已到达')
  2772. </if>
  2773. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2774. AND a.status = #{query.status}
  2775. </if>
  2776. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  2777. AND a.document_source = #{query.documentSource}
  2778. </if>
  2779. <if test="query.planDate != null">
  2780. AND a.PlanDate = #{query.planDate}
  2781. </if>
  2782. <if test="query.startDate != null ">
  2783. AND a.PlanDate >= #{query.startDate}
  2784. </if>
  2785. <if test="query.endDate != null ">
  2786. AND #{query.endDate} >= a.PlanDate
  2787. </if>
  2788. <if test="query.endDate == null ">
  2789. AND getDate() >= a.PlanDate
  2790. </if>
  2791. <if test='query.functionType == "A"'>
  2792. and getDate() >= dbo.compare_date(ewo.task_start_date)
  2793. </if>
  2794. <if test="query.reachDate != null ">
  2795. AND a.reach_date >= #{query.reachDate}
  2796. </if>
  2797. <if test="query.actualDate != null ">
  2798. AND #{query.actualDate} >= a.ActualDate
  2799. </if>
  2800. <if test="query.itemNo != null and query.itemNo != ''">
  2801. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  2802. </if>
  2803. <if test="query.itemDesc != null and query.itemDesc != ''">
  2804. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  2805. </if>
  2806. AND a.FunctionType = #{query.functionType}
  2807. </where>
  2808. </select>
  2809. <select id="eamDefectRecordSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2810. SELECT
  2811. a.Site,
  2812. a.bu_no,
  2813. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2814. a.OrderNo,
  2815. a.PlanID,
  2816. a.ObjectID,
  2817. a.Status,
  2818. a.PlanOperator,
  2819. a.ActualOperator,
  2820. a.PlanDate,
  2821. a.ActualDate,
  2822. a.FunctionType,
  2823. a.CreateDate,
  2824. d.operator_name as createBy,
  2825. a.Remark,
  2826. a.StartTime,
  2827. a.EndTime,
  2828. a.WorkTime,
  2829. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  2830. b.DefectID,
  2831. c.DefectDesc,
  2832. e.ObjectDesc as objectDesc,
  2833. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  2834. a.result,
  2835. b.urgency,
  2836. a.disposal_measures,
  2837. a.difficulty_level,
  2838. a.difficulty_remark,
  2839. f.department_name,
  2840. a.reach_date,
  2841. b.CreatedDate,
  2842. a.handling_method,
  2843. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  2844. CASE
  2845. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  2846. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  2847. END AS responseTime,
  2848. b.FeedBackDesc,
  2849. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  2850. a.fault_reason,
  2851. a.preventive_measure,
  2852. a.document_source,
  2853. ewi.ItemNo,
  2854. ewi.ItemDesc,
  2855. ewi.DefaultValue,
  2856. ewi.ValueType,
  2857. ewi.ValueType_DB,
  2858. ewi.ValueChooseFlag,
  2859. ewi.MaxValue,
  2860. ewi.MinValue,
  2861. ewi.ItemRemark,
  2862. ewi.ItemType,
  2863. ewi.TextValue,
  2864. ewi.NumberValue,
  2865. ewi.FinishFlag,
  2866. ewi.itemResult,
  2867. ewi.item_notes
  2868. FROM eam_workOrder a
  2869. left join eam_workOrder_item ewi on a.site = ewi.site and a.bu_no = ewi.bu_no and a.OrderNo = ewi.OrderNo
  2870. left join eam_defect_feedBack b on a.site = b.site and a.bu_no = b.bu_no and a.PlanID = b.feedBackID
  2871. left join eam_defect c on b.DefectID = c.DefectID
  2872. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  2873. 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'
  2874. 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
  2875. 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
  2876. left join sys_user as ea on ead.username = ea.username
  2877. <where>
  2878. a.site in (select site from eam_access_site where username = #{query.userName})
  2879. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2880. and ea.username = #{query.userName}
  2881. <if test="query.buDesc != null and query.buDesc != ''">
  2882. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  2883. </if>
  2884. <if test="query.deptArr != null">
  2885. AND
  2886. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  2887. f.department_name like '%' + #{item} + '%'
  2888. </foreach>
  2889. </if>
  2890. <if test="query.orderNo != null and query.orderNo != ''">
  2891. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  2892. </if>
  2893. <if test="query.planID != null and query.planID != ''">
  2894. AND a.PlanID like '%' + #{query.planID} +'%'
  2895. </if>
  2896. <if test="query.objectID != null and query.objectID != ''">
  2897. AND a.ObjectID like '%' + #{query.objectID} +'%'
  2898. </if>
  2899. <if test="query.planOperator != null and query.planOperator != ''">
  2900. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  2901. </if>
  2902. <if test="query.status != null and query.status != ''">
  2903. AND a.status = #{query.status}
  2904. </if>
  2905. <if test="query.documentSource != null and query.documentSource != ''">
  2906. AND a.document_source = #{query.documentSource}
  2907. </if>
  2908. <if test="query.startDate != null ">
  2909. AND a.PlanDate >= #{query.startDate}
  2910. </if>
  2911. <if test="query.endDate != null ">
  2912. AND #{query.endDate} >= a.PlanDate
  2913. </if>
  2914. <if test="query.reachDate != null ">
  2915. AND a.reach_date >= #{query.reachDate}
  2916. </if>
  2917. <if test="query.actualDate != null ">
  2918. AND #{query.actualDate} >= a.ActualDate
  2919. </if>
  2920. <if test="query.itemNo != null and query.itemNo != ''">
  2921. AND ewi.ItemNo like '%' + #{query.itemNo} +'%'
  2922. </if>
  2923. <if test="query.itemDesc != null and query.itemDesc != ''">
  2924. AND ewi.ItemDesc like '%' + #{query.itemDesc} +'%'
  2925. </if>
  2926. and a.FunctionType =#{query.functionType}
  2927. </where>
  2928. </select>
  2929. <!-- 获取用户角色列表 -->
  2930. <select id="getUserRoleList" resultType="com.xujie.sys.modules.sys.entity.SysRoleEntity">
  2931. SELECT
  2932. role_id,
  2933. role_name
  2934. FROM sys_role
  2935. </select>
  2936. <!-- 获取故障图片 -->
  2937. <select id="getFeedBackImages" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2938. SELECT
  2939. id,
  2940. url,
  2941. create_date,
  2942. file_name,
  2943. new_file_name,
  2944. created_by,
  2945. order_ref1,
  2946. order_ref2,
  2947. order_ref3,
  2948. order_ref4,
  2949. file_type,
  2950. file_suffix,
  2951. file_type_code,
  2952. case when order_ref3 = 'feedBack' then '报修' when order_ref3 = 'reportFault' then '维修' end as typeFlag
  2953. FROM sys_oss
  2954. where order_ref1 = #{site} and (order_ref2 = #{orderNo} or order_ref2 = #{planID}) and order_ref3 in ('feedBack', 'reportFault') and order_ref4 = #{buNo}
  2955. </select>
  2956. <!-- 获取故障图片 -->
  2957. <select id="getFeedBackImages2" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  2958. SELECT
  2959. id,
  2960. url,
  2961. create_date,
  2962. file_name,
  2963. new_file_name,
  2964. created_by,
  2965. order_ref1,
  2966. order_ref2,
  2967. order_ref3,
  2968. order_ref4,
  2969. file_type,
  2970. file_suffix,
  2971. file_type_code
  2972. FROM sys_oss
  2973. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = 'reportSparPart' and order_ref4 = #{buNo}
  2974. </select>
  2975. <insert id="saveCoreComponent">
  2976. insert into eam_workOrder_coreComponents
  2977. (site, bu_no, OrderNo, ItemNo, partNo, oldSerialNo, newSerialNo, created_by, created_date)
  2978. values
  2979. (#{site}, #{buNo}, #{orderNo}, #{itemNo}, #{partNo}, #{oldSerialNo}, #{newSerialNo}, #{createdBy}, GetDate())
  2980. </insert>
  2981. <update id="updateCoreComponent">
  2982. UPDATE eam_workOrder_coreComponents
  2983. SET oldSerialNo = #{oldSerialNo},
  2984. newSerialNo = #{newSerialNo}
  2985. WHERE site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
  2986. </update>
  2987. <!-- 获取领用出库信息 -->
  2988. <select id="getInventoryStockList" resultType="com.xujie.sys.modules.pms.data.InventoryStockData" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData">
  2989. SELECT
  2990. A.site,
  2991. A.part_no,
  2992. A.batch_no,
  2993. isnull(A.qty_on_hand ,0) as qtyOnHand,
  2994. isnull(A.in_qty,0) inQty,
  2995. isnull(A.out_qty,0) as outQty,
  2996. A.warehouse_id,
  2997. A.location_id,
  2998. (B.part_description + '/' + B.spec) as partDescription,
  2999. B.S_code_control_flag,
  3000. B.supplier_id,
  3001. dbo.qc_get_supplier_name(A.site, B.supplier_id) as supplierDesc
  3002. FROM inventory_stock as A
  3003. left join part_spare as B on A.site = B.site and A.part_no = B.part_no
  3004. <where>
  3005. A.site = #{site}
  3006. <if test="partNo != null and partNo != ''">
  3007. AND A.part_no = #{partNo}
  3008. </if>
  3009. <if test="batchNo != null and batchNo != ''">
  3010. AND A.batch_no = #{batchNo}
  3011. </if>
  3012. <if test="active != null and active != ''">
  3013. AND B.active = #{active}
  3014. </if>
  3015. </where>
  3016. </select>
  3017. <!-- 查询设备 -->
  3018. <select id="getResourceCount" resultType="com.xujie.sys.modules.pms.data.ResourceData" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3019. SELECT
  3020. id,
  3021. site,
  3022. resource_id,
  3023. resource_desc
  3024. FROM resource
  3025. where site = #{site} and resource_id = #{resourceId}
  3026. </select>
  3027. <!-- 获取编码信息 -->
  3028. <select id="getTransNo" resultType="com.xujie.sys.modules.pms.data.TransNoData" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3029. SELECT
  3030. #{site} as site,
  3031. dbo.Get_TransNo(#{site},#{transTypeDB}) as transNo
  3032. </select>
  3033. <!-- 修改编码信息 -->
  3034. <select id="updateTransNo" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3035. EXEC UpdateTransNo #{site}, #{transTypeDB}
  3036. </select>
  3037. <select id="getInventoryStockCount" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData" resultType="int">
  3038. select
  3039. count(1)
  3040. from inventory_stock
  3041. where site = #{site} and part_no = #{partNo}
  3042. </select>
  3043. <select id="queryEamDocumentType" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  3044. SELECT
  3045. a.site,
  3046. a.document_type_id,
  3047. a.document_type,
  3048. a.responsible_department,
  3049. a.estimated_completion_days,
  3050. a.create_date,
  3051. a.create_by,
  3052. a.update_date,
  3053. a.update_by,
  3054. b.role_desc
  3055. FROM document_type_definition as a
  3056. LEFT JOIN business_role as b on a.site = b.site and a.responsible_department = b.role_no
  3057. WHERE
  3058. a.site in (select eas.site from eam_access_site as eas where eas.username = #{params.userName})
  3059. <if test="params.sql != null and params.sql != ''">
  3060. ${params.sql}
  3061. </if>
  3062. </select>
  3063. <select id="eamDocumentTypeSearch" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  3064. SELECT
  3065. a.site,
  3066. a.document_type_id,
  3067. a.document_type,
  3068. a.responsible_department,
  3069. a.estimated_completion_days,
  3070. a.create_date,
  3071. a.create_by,
  3072. a.update_date,
  3073. a.update_by,
  3074. b.role_desc
  3075. FROM document_type_definition as a
  3076. LEFT JOIN business_role as b on a.site = b.site and a.responsible_department = b.role_no
  3077. WHERE
  3078. a.site in (select eas.site from eam_access_site as eas where eas.username = #{query.userName})
  3079. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  3080. AND a.document_type_id LIKE #{query.documentTypeId}
  3081. </if>
  3082. <if test="query.documentType != null and query.documentType != ''">
  3083. AND a.document_type LIKE #{query.documentType}
  3084. </if>
  3085. </select>
  3086. <select id="checkEamDocumentType" resultType="com.xujie.sys.modules.pms.data.EamDocumentTypeData">
  3087. SELECT
  3088. Site,
  3089. document_type_id,
  3090. document_type,
  3091. responsible_department,
  3092. estimated_completion_days
  3093. FROM document_type_definition
  3094. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  3095. </select>
  3096. <insert id="saveNewEamDocumentType">
  3097. INSERT INTO document_type_definition
  3098. (Site, document_type_id, document_type, responsible_department, estimated_completion_days,create_date, create_by)
  3099. VALUES
  3100. (#{site}, #{documentTypeId}, #{documentType}, #{responsibleDepartment}, #{estimatedCompletionDays}, getDate(), #{createBy})
  3101. </insert>
  3102. <update id="eamDocumentTypeEdit">
  3103. UPDATE document_type_definition
  3104. SET document_type = #{documentType},
  3105. responsible_department = #{responsibleDepartment},
  3106. estimated_completion_days = #{estimatedCompletionDays},
  3107. update_date = getDate(),
  3108. update_by = #{updateBy}
  3109. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  3110. </update>
  3111. <delete id="eamDocumentTypeDelete">
  3112. DELETE FROM document_type_definition
  3113. WHERE Site = #{site} and document_type_id = #{documentTypeId}
  3114. </delete>
  3115. <select id="queryBuDocument" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  3116. SELECT
  3117. a.id,
  3118. a.site,
  3119. a.bu_no,
  3120. dbo.get_bu_desc ( a.site, a.bu_no ) as buDesc,
  3121. a.project_category,
  3122. a.document_type_id,
  3123. a.project_phase,
  3124. c.document_type,
  3125. c.responsible_department,
  3126. c.estimated_completion_days,
  3127. a.create_date,
  3128. a.create_by,
  3129. a.update_date,
  3130. a.update_by,
  3131. b.bu_desc,
  3132. d.role_desc
  3133. FROM bu_document_list_definition as a
  3134. LEFT JOIN bu as b on a.site = b.site and a.bu_no = b.bu_no
  3135. LEFT JOIN document_type_definition as c on a.document_type_id = c.document_type_id
  3136. LEFT JOIN business_role as d on a.site = d.site and c.responsible_department = d.role_no
  3137. WHERE
  3138. a.site in (select site from eam_access_site where username = #{params.userName})
  3139. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{params.userName}))
  3140. <if test="params.sql != null and params.sql != ''">
  3141. ${params.sql}
  3142. </if>
  3143. ORDER BY
  3144. b.bu_no,
  3145. a.project_phase,
  3146. a.project_category,
  3147. a.document_type_id
  3148. </select>
  3149. <select id="eamBuDocumentSearch" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  3150. SELECT
  3151. a.id,
  3152. a.site,
  3153. a.bu_no,
  3154. a.project_category,
  3155. a.document_type_id,
  3156. a.project_phase,
  3157. c.document_type,
  3158. c.responsible_department,
  3159. c.estimated_completion_days,
  3160. a.create_date,
  3161. a.create_by,
  3162. a.update_date,
  3163. a.update_by,
  3164. b.bu_desc,
  3165. d.role_desc
  3166. FROM bu_document_list_definition as a
  3167. LEFT JOIN bu as b on a.site = b.site and a.bu_no = b.bu_no
  3168. LEFT JOIN document_type_definition as c on a.document_type_id = c.document_type_id
  3169. LEFT JOIN business_role as d on a.site = d.site and c.responsible_department = d.role_no
  3170. WHERE
  3171. a.site in (select site from eam_access_site where username = #{query.userName})
  3172. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  3173. <if test="query.buDesc != null and query.buDesc != ''">
  3174. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  3175. </if>
  3176. <if test="query.projectPhase != null and query.projectPhase != ''">
  3177. AND a.project_phase = #{query.projectPhase}
  3178. </if>
  3179. <if test="query.projectCategory != null and query.projectCategory != ''">
  3180. AND a.project_category = #{query.projectCategory}
  3181. </if>
  3182. <if test="query.documentTypeId != null and query.documentTypeId != ''">
  3183. AND a.document_type_id like #{query.documentTypeId}
  3184. </if>
  3185. <if test="query.documentType != null and query.documentType != ''">
  3186. AND c.document_type like #{query.documentType}
  3187. </if>
  3188. ORDER BY
  3189. b.bu_no,
  3190. a.project_phase,
  3191. a.project_category,
  3192. a.document_type_id
  3193. </select>
  3194. <select id="checkEamBuDocument" resultType="com.xujie.sys.modules.pms.data.EamBuDocumentListDefinitionVo">
  3195. SELECT
  3196. Site,
  3197. bu_no,
  3198. project_category,
  3199. document_type_id,
  3200. project_phase
  3201. FROM bu_document_list_definition
  3202. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  3203. </select>
  3204. <select id="checkEamDocumentTypeDelete" resultType="Integer">
  3205. SELECT COUNT(*) FROM bu_document_list_definition t1
  3206. WHERE t1.document_type_id = #{documentTypeId}
  3207. UNION ALL
  3208. SELECT COUNT(*) FROM plm_document_list_definition t2
  3209. WHERE t2.document_type_id = #{documentTypeId}
  3210. </select>
  3211. <insert id="saveNewEamBuDocument">
  3212. INSERT INTO bu_document_list_definition
  3213. (Site, bu_no, project_category, document_type_id, project_phase,create_date, create_by)
  3214. VALUES
  3215. (#{site}, #{buNo}, #{projectCategory}, #{documentTypeId}, #{projectPhase},getDate(), #{createBy})
  3216. </insert>
  3217. <update id="eamBuDocumentEdit">
  3218. UPDATE bu_document_list_definition
  3219. SET project_phase = #{projectPhase},
  3220. project_category = #{projectCategory},
  3221. update_date = getDate(),
  3222. update_by = #{updateBy}
  3223. WHERE Site = #{site} and bu_no = #{buNo} and document_type_id = #{documentTypeId} and id = #{id}
  3224. </update>
  3225. <delete id="eamBuDocumentDelete">
  3226. DELETE FROM bu_document_list_definition
  3227. WHERE Site = #{site} and bu_no = #{buNo} and project_category = #{projectCategory} and document_type_id = #{documentTypeId} and project_phase = #{projectPhase}
  3228. </delete>
  3229. <delete id="deleteCoreComponents">
  3230. delete from eam_workOrder_coreComponents
  3231. WHERE site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
  3232. </delete>
  3233. <update id="updateInventoryStock" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData">
  3234. update inventory_stock
  3235. set in_qty = #{inQty},
  3236. out_qty = #{outQty},
  3237. qty_on_hand = #{qtyOnHand},
  3238. latest_out_date = getDate(),
  3239. latest_count_date = getDate()
  3240. <where>
  3241. site = #{site}
  3242. <if test="partNo != null and partNo != ''">
  3243. AND part_no = #{partNo}
  3244. </if>
  3245. <if test="batchNo != null and batchNo != ''">
  3246. AND batch_no = #{batchNo}
  3247. </if>
  3248. </where>
  3249. </update>
  3250. <insert id="saveRepairTransDetailSub" parameterType="com.xujie.sys.modules.pms.data.RepairTransDetailSubData">
  3251. insert into repair_TransDetailsub
  3252. (TransNo, SeqNo, Site, itemNo, LocationID, BatchNo, RollQty, RollNo, orderRef2, orderRef4)
  3253. values
  3254. (#{transNo}, #{seqNo}, #{site}, #{itemNo}, #{locationId}, #{batchNo}, #{rollQty}, #{rollNo}, #{orderRef2}, #{orderRef4})
  3255. </insert>
  3256. <insert id="saveInventoryStockData" parameterType="com.xujie.sys.modules.pms.data.InventoryStockData">
  3257. insert into inventory_stock
  3258. (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)
  3259. values
  3260. (#{site}, #{warehouseId}, #{partNo}, #{firstInDate}, getDate(), getDate(),getDate(), #{inQty}, #{outQty}, #{qtyOnHand}, #{citemCode}, #{partnerId}, #{latestCountDate}, #{locationId}, #{batchNo})
  3261. </insert>
  3262. <insert id="saveRepairTransDetail" parameterType="com.xujie.sys.modules.pms.data.RepairTransDetailData">
  3263. insert into repair_TransDetail
  3264. (TransNo, Site, ItemNo, PartNo, LocationID, TransQty, Direction, BatchNo, OrderRef1, OrderRef2, OrderRef3, citem_code)
  3265. values
  3266. (#{transNo}, #{site}, #{itemNo}, #{partNo}, #{locationId}, #{transQty}, #{direction}, #{batchNo}, #{orderRef1}, #{orderRef2}, #{orderRef3}, #{citemCode})
  3267. </insert>
  3268. <insert id="saveRepairTransHeader" parameterType="com.xujie.sys.modules.pms.data.RepairTransHeaderData">
  3269. insert into repair_TransHeader
  3270. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, TransferFlag, EnterDate, UseLocation, LinkOrderFlag, Status, Remark, orderRef1)
  3271. values
  3272. (#{transNo}, #{site}, #{warehouseId}, #{transDate}, #{transTypeDb}, #{transType}, #{userName}, #{receiver}, #{transYear}, #{transMonth}, #{partnerId}, #{partnerType}, #{authorizeFlag}, #{transferFlag}, getDate(), #{useLocation}, #{linkOrderFlag}, #{status}, #{remark}, #{orderRef1})
  3273. </insert>
  3274. <update id="updatePartSpareLocation" parameterType="com.xujie.sys.modules.pms.data.PartSpareData">
  3275. update part_spare
  3276. set last_update_by =#{userName},
  3277. location_id = #{locationId},
  3278. warehouse_id = #{warehouseId}
  3279. where site = #{site} and part_no = #{partNo}
  3280. </update>
  3281. <select id="getFeedBackInfo" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData" parameterType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  3282. select
  3283. a.Site,
  3284. a.bu_no,
  3285. a.FeedBackID,
  3286. a.FeedBackDesc,
  3287. a.Status,
  3288. a.ObjectID,
  3289. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  3290. b.reach_date as createdDate,
  3291. b.reach_operator_name as createdBy,
  3292. '' as feedbackBy
  3293. from eam_defect_feedBack as a
  3294. left join eam_workOrder as b on a.site = b.site and a.bu_no = b.bu_no and b.PlanID = a.feedBackID
  3295. <where>
  3296. a.Site = #{site} and a.bu_no = #{buNo} and a.FeedBackID = #{feedBackID} and b.status in ('未开始', '已到达')
  3297. </where>
  3298. </select>
  3299. <select id="getObjectInfo" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  3300. select
  3301. site,
  3302. bu_no,
  3303. objectID,
  3304. ObjectDesc,
  3305. standard_maintenance_duration,
  3306. time_out_maintenance_duration,
  3307. standard_response_duration,
  3308. time_out_response_duration
  3309. from eam_object
  3310. where Site = #{site} and bu_no = #{buNo} and ObjectID = #{objectID}
  3311. </select>
  3312. <select id="getResourceByObject" resultType="string">
  3313. select
  3314. ResourceID
  3315. from eam_object
  3316. where Site = #{site} and bu_no = #{buNo} and ObjectID = #{objectID}
  3317. </select>
  3318. <select id="selectRecordByOrderNo" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3319. SELECT
  3320. a.Site,
  3321. a.bu_no,
  3322. a.OrderNo,
  3323. a.PlanID,
  3324. b.FeedBackDesc,
  3325. a.ObjectID,
  3326. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  3327. a.Status,
  3328. a.PlanDate,
  3329. a.ActualDate,
  3330. a.FunctionType,
  3331. a.CreateDate,
  3332. a.Remark,
  3333. a.StartTime,
  3334. a.EndTime,
  3335. a.WorkTime,
  3336. a.result,
  3337. a.reach_date,
  3338. a.confirm_date,
  3339. a.confirm_by,
  3340. a.confirm_result,
  3341. a.confirm_count,
  3342. a.confirm_assessment,
  3343. a.confirm_remark,
  3344. b.CreatedDate,
  3345. dbo.getOperatorDesc(b.site, b.CreatedBy) as createdBy
  3346. FROM eam_workOrder as a
  3347. left join eam_defect_feedBack as b on a.site = b.site and a.bu_no = b.bu_no and a.PlanID = b.feedBackID
  3348. where a.Site = #{site} and a.bu_no = #{buNo} and a.OrderNo = #{orderNo} and a.FunctionType = #{functionType}
  3349. </select>
  3350. <update id="confirmDefectOrder" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3351. update eam_workOrder
  3352. set Status = #{status},
  3353. confirm_by = #{confirmBy},
  3354. confirm_date = getDate(),
  3355. confirm_result = #{confirmResult},
  3356. confirm_count = #{confirmCount},
  3357. confirm_assessment = #{confirmAssessment},
  3358. confirm_remark = #{confirmRemark}
  3359. where site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo} and FunctionType = #{functionType}
  3360. </update>
  3361. <update id="confirmDefectPlan" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3362. update eam_defect_feedBack
  3363. set Status = #{status}
  3364. where site = #{site} AND bu_no = #{buNo} AND FeedBackID = #{planID} and FunctionType = #{functionType}
  3365. </update>
  3366. <select id="getCoreComponentByNo" resultType="com.xujie.sys.modules.pms.entity.EamWorkOrderCoreComponentsData">
  3367. select
  3368. site,
  3369. bu_no,
  3370. OrderNo,
  3371. partNo
  3372. from eam_workOrder_coreComponents
  3373. where site = #{site} and bu_no = #{buNo} and OrderNo = #{orderNo} and partNo = #{partNo}
  3374. </select>
  3375. <select id="getRoleByUserName" resultType="com.xujie.sys.modules.factory.entity.vo.BusinessRoleVo" parameterType="com.xujie.sys.modules.factory.entity.vo.BusinessRoleVo">
  3376. SELECT
  3377. a.site,
  3378. b.role_no,
  3379. b.role_desc
  3380. FROM access_role as a
  3381. left join business_role as b on a.site = b.site and a.role_no = b.role_no
  3382. WHERE a.username = #{username} and b.role_no in ('R022', 'R023', 'R024')
  3383. </select>
  3384. <select id="checkItemByUse" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  3385. SELECT
  3386. site,
  3387. bu_no,
  3388. function_type,
  3389. code_no,
  3390. properties_item_no itemNo,
  3391. seq_no
  3392. FROM eam_properties_model_detail
  3393. where site = #{site} and bu_no = #{buNo} and function_type = #{itemType} and properties_item_no = #{itemNo}
  3394. </select>
  3395. <select id="getOperatorListByOrder" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  3396. SELECT
  3397. a.user_id, a.username AS adminID, a.email, a.mobile AS phone, a.user_display AS adminName,
  3398. d.role_id, e.role_name, c.site, c.bu_no,
  3399. -- 获取计划工单数
  3400. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) AS planOrderCount,
  3401. -- 获取实际工单数
  3402. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) AS actualOrderCount,
  3403. -- 负荷率(%)
  3404. CASE
  3405. WHEN dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) = 0 THEN 0
  3406. ELSE
  3407. CAST(
  3408. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) * 100.0 /
  3409. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username)
  3410. AS DECIMAL(5,2))
  3411. END AS load_rate
  3412. FROM
  3413. sys_user AS a
  3414. LEFT JOIN eam_access_site AS b ON a.username = b.username
  3415. LEFT JOIN AccessBu AS c ON b.username = c.username AND b.site = c.site
  3416. LEFT JOIN sys_user_role AS d ON a.user_id = d.user_id
  3417. LEFT JOIN sys_role AS e ON d.role_id = e.role_id
  3418. <where>
  3419. b.site = #{site} and c.bu_no = #{buNo}
  3420. <if test = "adminID != null and adminID != ''">
  3421. AND a.username LIKE '%' + #{adminID} + '%'
  3422. </if>
  3423. <if test = "adminName != null and adminName != ''">
  3424. AND a.user_display LIKE '%' + #{adminName} + '%'
  3425. </if>
  3426. <if test = "roleId != null and roleId != ''">
  3427. AND d.role_id = #{roleId}
  3428. </if>
  3429. <if test = "date != null and classesCode != null and classesCode != ''">
  3430. AND a.username IN (
  3431. SELECT tpm_scheduling_record.admin_id
  3432. FROM tpm_scheduling
  3433. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3434. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  3435. )
  3436. </if>
  3437. <if test = "date != null and (classesCode == null or classesCode == '')">
  3438. AND a.username IN (
  3439. SELECT tpm_scheduling_record.admin_id
  3440. FROM tpm_scheduling
  3441. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3442. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling_record.isHoliday = 'N'
  3443. )
  3444. </if>
  3445. <if test = "classesCode != null and classesCode != '' and date == null">
  3446. AND a.username IN (
  3447. SELECT tpm_scheduling_record.admin_id
  3448. FROM tpm_scheduling
  3449. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3450. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  3451. )
  3452. </if>
  3453. </where>
  3454. order by load_rate desc
  3455. </select>
  3456. <select id="getOrderId" resultType="java.lang.Integer">
  3457. SELECT isnull(max(order_id), 0) + 1
  3458. from eam_properties_model_detail
  3459. where site = #{site}
  3460. and bu_no= #{buNo}
  3461. and function_type = #{functionType}
  3462. and code_no = #{codeNo}
  3463. </select>
  3464. <update id="updateOrderStatus" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3465. update eam_workOrder
  3466. set Status = '已完工'
  3467. where site = #{site} and bu_no = #{buNo} and orderNo = #{orderNo} and FunctionType = #{functionType}
  3468. </update>
  3469. <update id="updateMessageNotification" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  3470. update TPM_Message_Notification
  3471. set send_flag = 'N'
  3472. WHERE SITE = #{site} AND bu_no = #{buNo} AND plan_no = #{feedBackId} AND order_no = #{orderNo}
  3473. </update>
  3474. <update id="updateRepairTypes">
  3475. UPDATE eam_workOrder
  3476. SET repair_type = #{repairType}
  3477. WHERE site = #{site} AND bu_no = #{buNo} AND OrderNo = #{orderNo}
  3478. </update>
  3479. <update id="updateEamItemOrder">
  3480. update eam_properties_model_detail
  3481. set order_id=#{orderId}
  3482. where site = #{site}
  3483. and bu_no= #{buNo}
  3484. and properties_item_no = #{itemNo}
  3485. and code_no = #{codeNo}
  3486. and function_type = #{functionType}
  3487. </update>
  3488. <update id="updateMessageNotificationByParameter">
  3489. update TPM_Message_Notification
  3490. set send_flag = 'N'
  3491. WHERE SITE = #{site} AND bu_no = #{buNo} AND plan_no = #{planID} AND order_no = #{orderNo}
  3492. </update>
  3493. <update id="updateIsReturn">
  3494. UPDATE eam_workOrder
  3495. SET is_return = 'Y'
  3496. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  3497. </update>
  3498. <update id="reportWorkOrderForIsReturn">
  3499. update eam_workOrder
  3500. set Remark = #{remark},
  3501. handling_method = #{handlingMethod},
  3502. fault_reason = #{faultReason},
  3503. preventive_measure = #{preventiveMeasure},
  3504. is_return = 'N',
  3505. status = '待审核'
  3506. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  3507. </update>
  3508. <update id="updateEamDefectFeedBackPlanOperator">
  3509. update eam_defect_feedBack
  3510. set PlanOperator = #{planOperator}
  3511. where site = #{site} and bu_no = #{buNo} and feedBackID = #{feedBackID}
  3512. </update>
  3513. <select id="getUpItemdataEam" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelDetailData">
  3514. select
  3515. top 1
  3516. site,
  3517. bu_no,
  3518. properties_item_no as itemNo,
  3519. code_no,
  3520. function_type,
  3521. order_id
  3522. from eam_properties_model_detail
  3523. where #{orderId} > order_id
  3524. and site = #{site}
  3525. and bu_no= #{buNo}
  3526. and code_no = #{codeNo}
  3527. and function_type = #{functionType}
  3528. order by order_id desc
  3529. </select>
  3530. <select id="getDownItemdataEam" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelDetailData">
  3531. select
  3532. top 1
  3533. site,
  3534. bu_no,
  3535. properties_item_no as itemNo,
  3536. code_no,
  3537. function_type,
  3538. order_id
  3539. from eam_properties_model_detail
  3540. where order_id > #{orderId}
  3541. and site = #{site}
  3542. and bu_no= #{buNo}
  3543. and code_no = #{codeNo}
  3544. and function_type = #{functionType}
  3545. order by order_id
  3546. </select>
  3547. <select id="getResourceSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  3548. SELECT
  3549. rs.part_no,
  3550. ps.part_description
  3551. FROM resource_spare rs
  3552. LEFT JOIN part_spare ps ON rs.site = ps.site AND rs.bu_no = ps.bu_no AND rs.part_no = ps.part_no
  3553. WHERE
  3554. rs.site = #{site} and rs.bu_no = #{buNo}
  3555. and rs.resource_id = #{objectID} and rs.part_no = #{partNo} and ps.coreFlag = 'Y'
  3556. </select>
  3557. </mapper>