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.

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