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.

3898 lines
173 KiB

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