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.

2484 lines
109 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
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. create_date,
  90. create_by,
  91. update_date,
  92. update_by
  93. FROM eam_family
  94. <where>
  95. site in (select site from eam_access_site where username = #{query.userName})
  96. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  97. <if test="query.buDesc != null and query.buDesc != ''">
  98. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  99. </if>
  100. <if test="query.familyID != null and query.familyID != ''">
  101. AND familyID like '%' + #{query.familyID} +'%'
  102. </if>
  103. <if test="query.familyDesc != null and query.familyDesc != ''">
  104. AND familyDesc like '%' + #{query.familyDesc} +'%'
  105. </if>
  106. <if test="query.active != null and query.active != ''">
  107. AND active = #{query.active}
  108. </if>
  109. </where>
  110. </select>
  111. <select id="eamGroupSearch" parameterType="com.xujie.sys.modules.pms.data.EamGroupData" resultType="com.xujie.sys.modules.pms.data.EamGroupData">
  112. SELECT
  113. Site,
  114. bu_no,
  115. dbo.get_bu_desc(site, bu_no) as buDesc,
  116. GroupID,
  117. GroupDesc,
  118. Active,
  119. create_date,
  120. create_by,
  121. update_date,
  122. update_by
  123. FROM eam_group
  124. <where>
  125. site in (select site from eam_access_site where username = #{query.userName})
  126. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  127. <if test="query.buDesc != null and query.buDesc != ''">
  128. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  129. </if>
  130. <if test="query.groupID != null and query.groupID != ''">
  131. AND groupID like '%' + #{query.groupID} + '%'
  132. </if>
  133. <if test="query.groupDesc != null and query.groupDesc != ''">
  134. AND groupDesc like '%' + #{query.groupDesc} + '%'
  135. </if>
  136. <if test="query.active != null and query.active != ''">
  137. AND active = #{query.active}
  138. </if>
  139. </where>
  140. </select>
  141. <select id="eamLocationSearch" parameterType="com.xujie.sys.modules.pms.data.EamLocationData" resultType="com.xujie.sys.modules.pms.data.EamLocationData">
  142. SELECT
  143. Site,
  144. bu_no,
  145. dbo.get_bu_desc(site, bu_no) as buDesc,
  146. LocationID,
  147. LocationName,
  148. Active,
  149. create_date,
  150. create_by,
  151. update_date,
  152. update_by
  153. FROM eam_location
  154. <where>
  155. site in (select site from eam_access_site where username = #{query.userName})
  156. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  157. <if test="query.buDesc != null and query.buDesc != ''">
  158. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  159. </if>
  160. <if test="query.locationID != null and query.locationID != ''">
  161. AND locationID like '%' + #{query.locationID} +'%'
  162. </if>
  163. <if test="query.locationName != null and query.locationName != ''">
  164. AND locationName like '%' + #{query.locationName} +'%'
  165. </if>
  166. <if test="query.active != null and query.active != ''">
  167. AND active = #{query.active}
  168. </if>
  169. </where>
  170. </select>
  171. <select id="eamManufacturerSearch" parameterType="com.xujie.sys.modules.pms.data.EamManufacturerData" resultType="com.xujie.sys.modules.pms.data.EamManufacturerData">
  172. SELECT
  173. Site,
  174. bu_no,
  175. dbo.get_bu_desc(site, bu_no) as buDesc,
  176. ManufacturerID,
  177. ManufacturerName,
  178. Active,
  179. Contact,
  180. Phone,
  181. Address,
  182. Email,
  183. Remark,
  184. create_date,
  185. create_by,
  186. update_date,
  187. update_by
  188. FROM eam_manufacturer
  189. <where>
  190. site in (select site from eam_access_site where username = #{query.userName})
  191. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  192. <if test="query.buDesc != null and query.buDesc != ''">
  193. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  194. </if>
  195. <if test="query.manufacturerID != null and query.manufacturerID != ''">
  196. AND manufacturerID like '%' + #{query.manufacturerID} +'%'
  197. </if>
  198. <if test="query.manufacturerName != null and query.manufacturerName != ''">
  199. AND manufacturerName like '%' + #{query.manufacturerName} +'%'
  200. </if>
  201. <if test="query.active != null and query.active != ''">
  202. AND active = #{query.active}
  203. </if>
  204. </where>
  205. </select>
  206. <select id="eamAdminLevelSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminLevelData" resultType="com.xujie.sys.modules.pms.data.EamAdminLevelData">
  207. SELECT
  208. Site,
  209. bu_no,
  210. dbo.get_bu_desc(site, bu_no) as buDesc,
  211. AdminLevelID,
  212. AdminLevelDesc,
  213. Active,
  214. create_date,
  215. create_by,
  216. update_date,
  217. update_by
  218. FROM eam_adminLevel
  219. <where>
  220. site in (select site from eam_access_site where username = #{query.userName})
  221. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  222. <if test="query.buDesc != null and query.buDesc != ''">
  223. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  224. </if>
  225. <if test="query.adminLevelID != null and query.adminLevelID != ''">
  226. AND adminLevelID like '%' + #{query.adminLevelID} +'%'
  227. </if>
  228. <if test="query.adminLevelDesc != null and query.adminLevelDesc != ''">
  229. AND adminLevelDesc like '%' + #{query.adminLevelDesc}+'%'
  230. </if>
  231. <if test="query.active != null and query.active != ''">
  232. AND active = #{query.active}
  233. </if>
  234. </where>
  235. </select>
  236. <select id="eamSupplierSearch" parameterType="com.xujie.sys.modules.pms.data.EamSupplierData" resultType="com.xujie.sys.modules.pms.data.EamSupplierData">
  237. SELECT
  238. Site,
  239. bu_no,
  240. dbo.get_bu_desc(site, bu_no) as buDesc,
  241. SupplierID,
  242. SupplierName,
  243. [Group],
  244. Active,
  245. Contact,
  246. Phone,
  247. Address,
  248. Email,
  249. Remark,
  250. create_date,
  251. create_by,
  252. update_date,
  253. update_by
  254. FROM eam_supplier
  255. <where>
  256. site in (select site from eam_access_site where username = #{query.userName})
  257. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  258. <if test="query.buDesc != null and query.buDesc != ''">
  259. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  260. </if>
  261. <if test="query.supplierID != null and query.supplierID != ''">
  262. AND supplierID like '%' + #{query.supplierID} +'%'
  263. </if>
  264. <if test="query.supplierName != null and query.supplierName != ''">
  265. AND supplierName like '%' + #{query.supplierName} +'%'
  266. </if>
  267. <if test="query.active != null and query.active != ''">
  268. AND active = #{query.active}
  269. </if>
  270. </where>
  271. </select>
  272. <select id="searchItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemAvailableData">
  273. SELECT
  274. site,
  275. bu_no,
  276. ItemNo,
  277. ValueNo,
  278. AvailableValue,
  279. CreatedDate,
  280. CreatedBy,
  281. ItemType
  282. from eam_properties_item_available
  283. where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  284. </select>
  285. <select id="getItemValueNo" resultType="Double">
  286. SELECT isnull( max(valueNo),0)+1 from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  287. </select>
  288. <select id="getItemValueNoForPlan" resultType="Double">
  289. 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}
  290. </select>
  291. <insert id="saveItemAvailable">
  292. insert into eam_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, site, bu_no)
  293. values(#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site}, #{buNo})
  294. </insert>
  295. <update id="updateItemAvailable">
  296. update eam_properties_item_available
  297. set AvailableValue = #{availableValue}
  298. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  299. </update>
  300. <delete id="deleteItemAvailable">
  301. delete from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site} and bu_no = #{buNo}
  302. </delete>
  303. <select id="eamPropertiesModelSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  304. SELECT
  305. site,
  306. bu_no,
  307. dbo.get_bu_desc(site, bu_no) as buDesc,
  308. function_type,
  309. code_no,
  310. code_desc,
  311. active,
  312. created_date,
  313. created_by,
  314. update_date,
  315. update_by,
  316. delflag,
  317. version,
  318. CASE WHEN dbo.eam_model_is_use(site, function_type, code_no) > 0 THEN 'Y'
  319. else 'N'
  320. END as isUse
  321. FROM eam_properties_model_header
  322. <where>
  323. site in (select site from eam_access_site where username = #{query.userName})
  324. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  325. <if test="query.buDesc != null and query.buDesc != ''">
  326. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  327. </if>
  328. <if test="query.codeNo != null and query.codeNo != ''">
  329. AND code_no like '%' + #{query.codeNo} +'%'
  330. </if>
  331. <if test="query.codeDesc != null and query.codeDesc != ''">
  332. AND code_desc like '%' + #{query.codeDesc} +'%'
  333. </if>
  334. <if test="query.active != null and query.active != ''">
  335. AND active = #{query.active}
  336. </if>
  337. <if test='query.isUse != null and query.isUse != "" and query.isUse == "Y"'>
  338. AND dbo.eam_model_is_use(site, function_type, code_no) > 0
  339. </if>
  340. <if test='query.isUse != null and query.isUse != "" and query.isUse == "N"'>
  341. AND dbo.eam_model_is_use(site, function_type, code_no) = 0
  342. </if>
  343. and function_type = #{query.functionType}
  344. </where>
  345. </select>
  346. <insert id="eamPropertiesModelSave" >
  347. insert into eam_properties_model_header
  348. (function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by, site, bu_no)
  349. values (#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy}, #{site}, #{buNo})
  350. </insert>
  351. <update id="eamPropertiesModelEdit">
  352. update eam_properties_model_header
  353. set version = version + 1,
  354. code_desc = #{codeDesc},
  355. active = #{active},
  356. update_by = #{updateBy},
  357. update_date = GetDate()
  358. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  359. </update>
  360. <select id="checkPropertiesModel" resultType="EamPropertiesModelHeaderData">
  361. SELECT
  362. function_type,
  363. code_no,
  364. code_desc,
  365. active,
  366. created_date,
  367. created_by,
  368. update_date,
  369. update_by,
  370. delflag,
  371. version
  372. FROM eam_properties_model_header
  373. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  374. </select>
  375. <delete id="deleteModelDetail">
  376. delete from eam_properties_model_detail
  377. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  378. </delete>
  379. <delete id="eamPropertiesModelDelete" >
  380. delete from eam_properties_model_header where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  381. </delete>
  382. <select id="searchModalDetails" resultType="EamPropertiesModelDetailData">
  383. SELECT
  384. a.site,
  385. a.bu_no,
  386. a.function_type,
  387. a.code_no,
  388. a.properties_item_no itemNo,
  389. a.seq_no,
  390. b.ItemDesc,
  391. b.DefaultValue,
  392. b.ValueType,
  393. b.ValueType_DB,
  394. b.ValueChooseFlag,
  395. b.MaxValue,
  396. b.MinValue,
  397. b.ItemRemark,
  398. b.ItemType
  399. FROM eam_properties_model_detail a
  400. 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
  401. where a.function_type = #{functionType} and a.code_no = #{codeNo} and a.site = #{site} and a.bu_no = #{buNo}
  402. </select>
  403. <select id="checkItem" resultType="EamPropertiesModelDetailData">
  404. SELECT
  405. ItemDesc
  406. FROM eam_properties_item
  407. where itemType = #{functionType} and itemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  408. </select>
  409. <select id="checkModalDetails" resultType="EamPropertiesModelDetailData">
  410. SELECT
  411. site,
  412. bu_no,
  413. function_type,
  414. code_no,
  415. properties_item_no itemNo,
  416. seq_no
  417. FROM eam_properties_model_detail
  418. where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  419. </select>
  420. <select id="getModalDetailSeqNo" resultType="Integer">
  421. SELECT
  422. isnull(max(seq_no),0) + 1
  423. from eam_properties_model_detail
  424. where function_type = #{functionType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo}
  425. </select>
  426. <insert id="saveModalDetails">
  427. insert into eam_properties_model_detail
  428. (function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, bu_no)
  429. values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{buNo})
  430. </insert>
  431. <delete id="deleteModalDetails">
  432. delete from eam_properties_model_detail
  433. where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  434. </delete>
  435. <select id="eamWorkPlanOverviewSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  436. SELECT
  437. a.site,
  438. a.bu_no,
  439. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  440. a.plan_id,
  441. a.plan_desc,
  442. a.status,
  443. a.plan_start_date,
  444. a.plan_end_date,
  445. a.created_date,
  446. a.created_by,
  447. a.update_date,
  448. a.update_by,
  449. a.remark,
  450. a.next_work_date,
  451. a.delete_flag,
  452. a.operator,
  453. a.operator_name,
  454. a.checker,
  455. a.checker_name,
  456. a.function_type,
  457. a.properties_code,
  458. a.plan_period,
  459. d.code_desc,
  460. a.work_order_rule,
  461. a.plan_cycle,
  462. a.task_start_date,
  463. a.plan_halt_date,
  464. a.auto_renewal
  465. FROM eam_workPlan_overview as a
  466. 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
  467. <where>
  468. a.site in (select site from eam_access_site where username = #{query.userName})
  469. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  470. and a.delete_flag = 'N' AND a.function_type = #{query.functionType}
  471. <if test="query.buDesc != null and query.buDesc != ''">
  472. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  473. </if>
  474. <if test="query.planID != null and query.planID != ''">
  475. AND a.plan_id like '%' + #{query.planID} +'%'
  476. </if>
  477. <if test="query.planDesc != null and query.planDesc != ''">
  478. AND a.plan_desc like '%' + #{query.planDesc}+'%'
  479. </if>
  480. <if test="query.status != null and query.status != ''">
  481. AND a.status = #{query.status}
  482. </if>
  483. <if test="query.startDate != null ">
  484. AND a.plan_start_date >= #{query.startDate}
  485. </if>
  486. <if test="query.endDate != null ">
  487. AND #{query.endDate} >= a.plan_start_date
  488. </if>
  489. </where>
  490. ORDER BY a.created_date DESC
  491. </select>
  492. <select id="eamWorkPlanSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  493. SELECT
  494. a.Site,
  495. a.PlanID,
  496. a.PlanDesc,
  497. a.ObjectID,
  498. a.FunctionType,
  499. a.PropertiesCode,
  500. a.Operator,
  501. a.checker,
  502. a.PlanPeriod,
  503. a.Status,
  504. a.PlanStartDate,
  505. a.PlanEndDate,
  506. a.CreatedDate,
  507. a.CreatedBy,
  508. a.UpdateDate,
  509. a.UpdateBy,
  510. a.Version,
  511. a.Remark,
  512. a.NextWorkDate,
  513. b.ObjectDesc,
  514. d.code_desc
  515. FROM eam_workPlan a
  516. left join eam_object b on a.Site = b.Site and a.ObjectID = b.ObjectID
  517. left join eam_properties_model_header d on a.FunctionType = d.function_type and a.PropertiesCode = d.code_no
  518. <where>
  519. AND a.DeleteFlag = 'N'
  520. AND a.FunctionType = #{query.functionType}
  521. <if test="query.planID != null and query.planID != ''">
  522. AND a.PlanID like '%' + #{query.planID} +'%'
  523. </if>
  524. <if test="query.planDesc != null and query.planDesc != ''">
  525. AND a.PlanDesc like '%' + #{query.planDesc}+'%'
  526. </if>
  527. <if test="query.status != null and query.status != ''">
  528. AND a.status = #{query.status}
  529. </if>
  530. <if test="query.startDate != null ">
  531. AND a.PlanStartDate >= #{query.startDate}
  532. </if>
  533. <if test="query.endDate != null ">
  534. AND #{query.endDate} >= a.PlanStartDate
  535. </if>
  536. </where>
  537. </select>
  538. <select id="selectNameById" resultType="string" parameterType="string">
  539. SELECT
  540. AdminName
  541. FROM eam_admin
  542. WHERE AdminID = #{s}
  543. </select>
  544. <select id="searchPlanItems" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData">
  545. SELECT
  546. a.Site,
  547. a.bu_no,
  548. a.PlanID,
  549. a.ItemNo,
  550. a.ItemDesc,
  551. a.DefaultValue,
  552. a.ValueType,
  553. a.ValueType_DB,
  554. a.ValueChooseFlag,
  555. a.UpdateDate,
  556. a.UpdateBy,
  557. a.MaxValue,
  558. a.MinValue,
  559. a.ItemRemark,
  560. a.ItemType,
  561. a.CreatedDate,
  562. a.CreatedBy,
  563. a.ObjectID
  564. FROM eam_workPlan_item a
  565. <where>
  566. a.PlanID = #{planID} and a.Site = #{site} and a.ItemType = #{functionType} and bu_no = #{buNo}
  567. <if test = "objectID != null and objectID != ''">
  568. AND a.ObjectID = #{objectID}
  569. </if>
  570. </where>
  571. </select>
  572. <select id="searchPlanItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemAvailableData">
  573. SELECT
  574. Site,
  575. bu_no,
  576. PlanID,
  577. ItemNo,
  578. ItemType,
  579. ValueNo,
  580. AvailableValue,
  581. CreatedDate,
  582. CreatedBy,
  583. UpdateDate,
  584. UpdateBy,
  585. ObjectID
  586. from eam_workPlan_item_available
  587. where PlanID = #{planID} and itemNo = #{itemNo} and site = #{site} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  588. </select>
  589. <update id="updatePlanItems">
  590. update eam_workPlan_item
  591. set DefaultValue = #{defaultValue},
  592. ValueType = #{valueType},
  593. ValueType_DB = #{valueTypeDb},
  594. ValueChooseFlag = #{valueChooseFlag},
  595. UpdateDate = GetDate(),
  596. UpdateBy = #{createdBy},
  597. MaxValue = #{maxValue,jdbcType=FLOAT},
  598. MinValue = #{minValue,jdbcType=FLOAT},
  599. ItemRemark = #{itemRemark}
  600. where site = #{site} and planID = #{planID} and ItemType = #{itemType} and ItemNo = #{itemNo} and ObjectID = #{objectID} and bu_no = #{buNo}
  601. </update>
  602. <update id="updatePlanItemsForNull">
  603. update eam_workPlan_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  604. ,ValueChooseFlag=#{valueChooseFlag},UpdateDate=GetDate(),UpdateBy=#{createdBy},MaxValue=null,MinValue=null,
  605. ItemRemark=#{itemRemark}
  606. where site=#{site} and planID=#{planID} and ItemType=#{itemType}
  607. and ItemNo=#{itemNo}
  608. </update>
  609. <insert id="saveItemAvailableForPlan">
  610. insert into eam_workPlan_item_available
  611. (Site, PlanID, ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType, ObjectID, bu_no)
  612. values(#{site}, #{planID}, #{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{objectID}, #{buNo})
  613. </insert>
  614. <update id="updateItemAvailableForPlan">
  615. update eam_workPlan_item_available
  616. set AvailableValue = #{availableValue},
  617. updateBy = #{createdBy},
  618. updateDate = GetDate()
  619. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
  620. </update>
  621. <delete id="deletePlanItemAvailable">
  622. delete from eam_workPlan_item_available
  623. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID} and bu_no = #{buNo}
  624. </delete>
  625. <select id="objectIDBlur" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  626. select objectID,ObjectDesc from eam_object where active='Y' and Site=#{site} and ObjectID=#{objectID}
  627. </select>
  628. <select id="modalCodeBlur" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  629. select code_no,code_desc from eam_properties_model_header where active = 'Y' and function_type = #{functionType} and code_no = #{codeNo}
  630. </select>
  631. <select id="eamWorkOrderSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  632. SELECT
  633. a.Site,
  634. a.bu_no,
  635. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  636. a.OrderNo,
  637. a.PlanID,
  638. a.PlanDesc,
  639. a.PropertiesCode,
  640. a.ObjectID,
  641. a.Status,
  642. a.PlanOperator,
  643. a.checker,
  644. a.ActualOperator,
  645. a.PlanDate,
  646. a.ActualDate,
  647. a.FunctionType,
  648. a.CreateDate,
  649. d.operator_name as createBy,
  650. a.Remark,
  651. a.StartTime,
  652. a.EndTime,
  653. a.WorkTime,
  654. a.PlanOperatorName,
  655. a.checkerName,
  656. dbo.eam_Get_eamAdminName(a.Site, a.ActualOperator) ActualOperatorName,
  657. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) objectDesc,
  658. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) codeDesc,
  659. a.result,
  660. b.urgency,
  661. a.checkResult,
  662. b.DefectID,
  663. c.DefectDesc,
  664. a.disposal_measures,
  665. a.check_work_plan_id,
  666. a.check_item_no,
  667. a.reach_date,
  668. a.reach_operator,
  669. a.reach_operator_name,
  670. b.FeedBackDesc,
  671. dbo.joint_id(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as adminID,
  672. dbo.joint_name(a.Site, a.bu_no, a.OrderNo, a.FunctionType) as operator,
  673. a.check_remark,
  674. a.document_source
  675. FROM eam_workOrder a
  676. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  677. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  678. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  679. left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID and eo.bu_no = a.bu_no
  680. 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
  681. 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
  682. left join sys_user as ea on ead.username = ea.username
  683. 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
  684. <where>
  685. a.site in (select site from eam_access_site where username = #{query.userName})
  686. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  687. and ea.username = #{query.userName}
  688. <if test="query.buDesc != null and query.buDesc != ''">
  689. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  690. </if>
  691. <if test="query.orderNo != null and query.orderNo != ''">
  692. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  693. </if>
  694. <if test="query.planID != null and query.planID != ''">
  695. AND a.PlanID like '%' + #{query.planID} +'%'
  696. </if>
  697. <if test="query.planDesc != null and query.planDesc != ''">
  698. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  699. </if>
  700. <if test="query.objectID != null and query.objectID != ''">
  701. AND a.ObjectID like '%' + #{query.objectID} +'%'
  702. </if>
  703. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  704. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  705. </if>
  706. <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '>
  707. AND a.status != '已取消'
  708. </if>
  709. <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '>
  710. AND a.status = #{query.status}
  711. </if>
  712. <if test='query.functionType == "A" and query.searchType == "reportCheck" '>
  713. AND a.status = '未开工'
  714. </if>
  715. <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  716. AND a.status != '已取消'
  717. </if>
  718. <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '>
  719. AND a.status = #{query.status}
  720. </if>
  721. <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '>
  722. AND (a.status = '未开工' or a.status = '已到达')
  723. </if>
  724. <if test='(query.status == null || query.status == "") and query.functionType == "C" and query.searchType == "reportDefect" '>
  725. AND (a.status = '未开工' or a.status = '已到达')
  726. </if>
  727. <if test='query.status != null and query.status != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  728. AND a.status = #{query.status}
  729. </if>
  730. <if test='query.documentSource != null and query.documentSource != "" and query.functionType == "C" and query.searchType == "reportDefect" '>
  731. AND a.document_source = #{query.documentSource}
  732. </if>
  733. <if test="query.planDate != null">
  734. AND a.PlanDate = #{query.planDate}
  735. </if>
  736. <if test="query.startDate != null ">
  737. AND a.PlanDate >= #{query.startDate}
  738. </if>
  739. <if test="query.endDate != null ">
  740. AND #{query.endDate} >= a.PlanDate
  741. </if>
  742. <if test="query.endDate == null ">
  743. AND getDate() >= a.PlanDate
  744. </if>
  745. <if test='query.functionType == "A"'>
  746. and getDate() >= dbo.compare_date(ewo.task_start_date)
  747. </if>
  748. AND a.FunctionType = #{query.functionType}
  749. </where>
  750. ORDER BY a.CreateDate,
  751. CASE WHEN b.urgency = '特急' THEN 1
  752. WHEN b.urgency = '紧急' THEN 2
  753. WHEN b.urgency = '一般' THEN 3
  754. END
  755. </select>
  756. <select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  757. SELECT
  758. a.Site,
  759. a.bu_no,
  760. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  761. a.OrderNo,
  762. a.PlanID,
  763. a.ObjectID,
  764. a.Status,
  765. a.PlanOperator,
  766. a.ActualOperator,
  767. a.PlanDate,
  768. a.ActualDate,
  769. a.FunctionType,
  770. a.CreateDate,
  771. d.operator_name as createBy,
  772. a.Remark,
  773. a.StartTime,
  774. a.EndTime,
  775. a.WorkTime,
  776. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName,
  777. b.DefectID,
  778. c.DefectDesc,
  779. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) as objectDesc,
  780. dbo.eam_Get_eam_properties_CodeDesc(a.site, a.bu_no, a.FunctionType, a.PropertiesCode) as codeDesc,
  781. a.result,
  782. b.urgency,
  783. a.disposal_measures,
  784. a.difficulty_level,
  785. a.difficulty_remark,
  786. f.department_name,
  787. a.reach_date,
  788. b.CreatedDate,
  789. a.handling_method,
  790. dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc,
  791. CASE
  792. WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0
  793. ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date)
  794. END AS responseTime,
  795. b.FeedBackDesc,
  796. dbo.joint_name(a.Site,a.bu_no,a.OrderNo,a.FunctionType) as actualOperatorName,
  797. a.fault_reason,
  798. a.preventive_measure,
  799. a.document_source
  800. FROM eam_workOrder a
  801. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID and a.bu_no = b.bu_no
  802. left join eam_defect c on b.DefectID = c.DefectID
  803. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  804. 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
  805. 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
  806. 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
  807. left join sys_user as ea on ead.username = ea.username
  808. <where>
  809. a.site in (select site from eam_access_site where username = #{query.userName})
  810. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  811. and ea.username = #{query.userName}
  812. <if test="query.buDesc != null and query.buDesc != ''">
  813. AND dbo.get_bu_desc ( a.site, a.bu_no ) = #{query.buDesc}
  814. </if>
  815. <if test="query.deptArr != null">
  816. AND
  817. <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")">
  818. f.department_name like '%' + #{item} + '%'
  819. </foreach>
  820. </if>
  821. <if test="query.orderNo != null and query.orderNo != ''">
  822. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  823. </if>
  824. <if test="query.planID != null and query.planID != ''">
  825. AND a.PlanID like '%' + #{query.planID} +'%'
  826. </if>
  827. <if test="query.objectID != null and query.objectID != ''">
  828. AND a.ObjectID like '%' + #{query.objectID} +'%'
  829. </if>
  830. <if test="query.planOperator != null and query.planOperator != ''">
  831. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  832. </if>
  833. <if test="query.status != null and query.status != ''">
  834. AND a.status = #{query.status}
  835. </if>
  836. <if test="query.documentSource != null and query.documentSource != ''">
  837. AND a.document_source = #{query.documentSource}
  838. </if>
  839. <if test="query.startDate != null ">
  840. AND a.PlanDate >= #{query.startDate}
  841. </if>
  842. <if test="query.endDate != null ">
  843. AND #{query.endDate} >= a.PlanDate
  844. </if>
  845. and a.FunctionType =#{query.functionType}
  846. </where>
  847. ORDER BY a.PlanDate,
  848. CASE WHEN b.urgency = '特急' THEN 1
  849. WHEN b.urgency = '紧急' THEN 2
  850. WHEN b.urgency = '一般' THEN 3
  851. END
  852. </select>
  853. <select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData">
  854. SELECT
  855. DefectID,
  856. DefectDesc,
  857. Active,
  858. create_date,
  859. create_by,
  860. update_date,
  861. update_by,
  862. fault_type
  863. FROM eam_defect
  864. <where>
  865. <if test="query.buDesc != null and query.buDesc != ''">
  866. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  867. </if>
  868. <if test="query.defectID != null and query.defectID != ''">
  869. AND defectID like '%' + #{query.defectID} + '%'
  870. </if>
  871. <if test="query.defectDesc != null and query.defectDesc != ''">
  872. AND defectDesc like '%' + #{query.defectDesc} + '%'
  873. </if>
  874. <if test="query.active != null and query.active != ''">
  875. AND active = #{query.active}
  876. </if>
  877. </where>
  878. order by id
  879. </select>
  880. <select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  881. SELECT
  882. a.site,
  883. a.ObjectID,
  884. a.DefectID,
  885. a.Active,
  886. a.id,
  887. b.ObjectDesc,
  888. c.DefectDesc,
  889. a.create_date,
  890. a.create_by,
  891. a.update_date,
  892. a.update_by
  893. FROM eam_object_defect a
  894. left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID
  895. left join eam_defect c on a.DefectID=c.DefectID
  896. <where>
  897. <if test="query.objectID != null and query.objectID != ''">
  898. AND a.ObjectID like '%' + #{query.objectID} + '%'
  899. </if>
  900. <if test="query.objectDesc != null and query.objectDesc != ''">
  901. AND b.ObjectDesc like '%' + #{query.objectDesc} + '%'
  902. </if>
  903. <if test="query.defectID != null and query.defectID != ''">
  904. AND a.defectID like '%' + #{query.defectID} + '%'
  905. </if>
  906. <if test="query.defectDesc != null and query.defectDesc != ''">
  907. AND c.defectDesc like '%' + #{query.defectDesc} + '%'
  908. </if>
  909. <if test="query.active != null and query.active != ''">
  910. AND a.active = #{query.active}
  911. </if>
  912. </where>
  913. order by a.id
  914. </select>
  915. <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  916. SELECT
  917. a.Site,
  918. a.ObjectID,
  919. a.ObjectDesc,
  920. a.LocationID,
  921. a.FamilyID,
  922. a.GroupID,
  923. b.FamilyDesc,
  924. c.LocationName
  925. FROM eam_object a
  926. LEFT JOIN eam_family b ON a.site = b.site and a.FamilyID = b.FamilyID and a.bu_no = b.bu_no
  927. LEFT JOIN eam_location as c ON a.LocationID = c.LocationID and a.site = c.site and a.bu_no = c.bu_no
  928. <where>
  929. <if test="objectID != null and objectID != ''">
  930. AND a.ObjectID like '%' + #{objectID} + '%'
  931. </if>
  932. <if test="objectDesc != null and objectDesc != ''">
  933. AND a.ObjectDesc like '%' + #{objectDesc} + '%'
  934. </if>
  935. AND a.site = #{site} AND a.active = 'Y' and a.bu_no = #{buNo}
  936. </where>
  937. </select>
  938. <select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  939. SELECT
  940. a.site,
  941. a.objectID
  942. from eam_object as a
  943. left join eam_family as b on a.site = b.site and a.FamilyID = b.FamilyID
  944. where a.site = '2' and (b.son_id like #{sonId} + '%' or a.FamilyID = #{familyID})
  945. </select>
  946. <select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  947. SELECT site, objectID from eam_object where site = #{site} and GroupID = #{groupID}
  948. </select>
  949. <select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  950. SELECT site ,objectID from eam_object where site=#{site} and LocationID=#{locationID}
  951. </select>
  952. <select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  953. SELECT
  954. a.Site,
  955. a.bu_no,
  956. c.OrderNo,
  957. a.ItemNo,
  958. a.ItemDesc,
  959. a.DefaultValue,
  960. a.ValueType,
  961. a.ValueType_DB,
  962. a.ValueChooseFlag,
  963. a.MaxValue,
  964. a.MinValue,
  965. a.ItemRemark,
  966. a.ItemType,
  967. a.image_flag,
  968. a.produce_control_flag,
  969. CASE WHEN b.id is null THEN 'N'
  970. ELSE 'Y'
  971. END as uploadFlag,
  972. a.item_notes
  973. from eam_workPlan_item as a
  974. left join eam_workOrder as c on a.site = c.site and a.PlanID = c.PlanID and a.bu_no = c.bu_no
  975. left join (SELECT MAX (id) as id, order_ref1, order_ref2, order_ref3, order_ref4 FROM sys_oss GROUP BY order_ref1, order_ref2, order_ref3, order_ref4) as b
  976. on b.order_ref1 = a.site and b.order_ref2 = c.OrderNo and b.order_ref3 = a.ItemNo and order_ref4 = a.bu_no
  977. where a.site = #{site} and c.orderNo = #{orderNo} and a.ObjectID = #{objectID} and a.bu_no = #{buNo}
  978. </select>
  979. <select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  980. SELECT
  981. Site,
  982. status,
  983. OrderNo
  984. from eam_workOrder
  985. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  986. </select>
  987. <select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  988. SELECT username as adminID
  989. from sys_user
  990. where username = #{mesUser}
  991. </select>
  992. <update id="updateDefectResult" >
  993. update eam_defect_feedBack
  994. set Status = #{result},
  995. FinishDate = GetDate(),
  996. DefectID = #{defectID}
  997. where Site = #{site} and FeedBackID = #{planID} and bu_no = #{buNo}
  998. </update>
  999. <update id="reportWorkOrder" parameterType="EamWorkOrderInData">
  1000. update eam_workOrder
  1001. set Status = '待审核',
  1002. ActualOperator = #{actualOperator},
  1003. ActualDate = #{actualDate},
  1004. Remark = #{remark},
  1005. disposal_measures = #{disposalMeasures},
  1006. WorkTime = CASE
  1007. WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0
  1008. ELSE ceiling(floor(DATEDIFF(SECOND, reach_date, #{actualDate}) / 30) / 2)
  1009. END,
  1010. result = #{result,jdbcType=VARCHAR},
  1011. checkResult = #{checkResult},
  1012. handling_method = #{handlingMethod},
  1013. fault_reason = #{faultReason},
  1014. preventive_measure = #{preventiveMeasure}
  1015. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1016. </update>
  1017. <update id="reportWorkOrder2" parameterType="EamWorkOrderInData">
  1018. update eam_workOrder
  1019. set Status = '待审核',
  1020. ActualOperator = #{actualOperator},
  1021. ActualDate = #{actualDate},
  1022. Remark = #{remark},
  1023. disposal_measures = #{disposalMeasures},
  1024. WorkTime = #{workTime},
  1025. result = #{result,jdbcType=VARCHAR},
  1026. checkResult = #{checkResult},
  1027. handling_method = #{handlingMethod},
  1028. check_remark = #{checkRemark}
  1029. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1030. </update>
  1031. <update id="defectReportWorkOrder" >
  1032. update eam_workOrder
  1033. set Status = '已完工',
  1034. ActualOperator = #{actualOperator},
  1035. ActualDate = GetDate(),
  1036. Remark = #{remark},
  1037. disposal_measures = #{disposalMeasures},
  1038. WorkTime = #{workTime},
  1039. result = #{result,jdbcType=VARCHAR},
  1040. checkResult = #{checkResult}
  1041. where site = #{site}
  1042. and orderNo = #{orderNo}
  1043. </update>
  1044. <insert id="saveWorkOrderItem">
  1045. INSERT into eam_workOrder_item
  1046. (Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
  1047. 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})
  1048. </insert>
  1049. <!-- 修改 eam_workPlan 状态为已结束 -->
  1050. <update id="closePlanWithCheck">
  1051. update eam_workPlan
  1052. set status = '已结束'
  1053. where site = #{site}
  1054. and PlanID = #{planID}
  1055. and ObjectID = #{objectID}
  1056. and GetDate() > PlanEndDate
  1057. </update>
  1058. <!-- 报工后更新下一个工作日期 -->
  1059. <update id="updatePlanNextDate">
  1060. update eam_workPlan_overview
  1061. 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)
  1062. where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
  1063. </update>
  1064. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1065. SELECT
  1066. Site,
  1067. bu_no,
  1068. OrderNo,
  1069. ItemNo,
  1070. ItemDesc,
  1071. DefaultValue,
  1072. ValueType,
  1073. ValueType_DB,
  1074. ValueChooseFlag,
  1075. MaxValue,
  1076. MinValue,
  1077. ItemRemark,
  1078. ItemType,
  1079. TextValue,
  1080. NumberValue,
  1081. CreatedDate,
  1082. CreatedBy,
  1083. FinishFlag,
  1084. itemResult,
  1085. item_notes
  1086. from eam_workOrder_item
  1087. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1088. </select>
  1089. <update id="cancelOrder" parameterType="EamWorkOrderInData">
  1090. update eam_workOrder
  1091. set Status = '已取消'
  1092. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1093. </update>
  1094. <update id="cancelOrderAll" parameterType="EamWorkOrderInData">
  1095. update eam_workOrder
  1096. set Status = '已取消'
  1097. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
  1098. </update>
  1099. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1100. SELECT
  1101. site,
  1102. bu_no,
  1103. status
  1104. from eam_workPlan_overview
  1105. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1106. </select>
  1107. <update id="planOrder">
  1108. update eam_workPlan
  1109. set Status = '已计划',
  1110. NextWorkDate = null
  1111. where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1112. </update>
  1113. <update id="cancelPlan">
  1114. update eam_workPlan_overview
  1115. set status = '已取消',
  1116. next_work_date = null
  1117. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1118. </update>
  1119. <update id="updateWorkPlanStatus">
  1120. update eam_workPlan
  1121. set Status = '已取消',
  1122. NextWorkDate = null
  1123. where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1124. </update>
  1125. <update id="cancelOrderWithPlanID">
  1126. update eam_workOrder
  1127. set Status = '已取消'
  1128. where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
  1129. </update>
  1130. <update id="deleteOrderDetailWithPlanID">
  1131. delete from eam_workOrder_item
  1132. where site = #{site} and bu_no = #{buNo}
  1133. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  1134. </update>
  1135. <update id="deleteOrderWithPlanID">
  1136. delete from eam_workOrder
  1137. where site = #{site} and bu_no = #{buNo}
  1138. and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
  1139. </update>
  1140. <update id="updateOrderPlanOperator">
  1141. update eam_workOrder
  1142. set PlanOperator = #{planOperator}
  1143. where site = #{site} and orderNo = #{orderNo}
  1144. </update>
  1145. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1146. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  1147. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  1148. <where>
  1149. <if test="partNo != null and partNo != ''">
  1150. AND a.part_no like '%' + #{partNo} + '%'
  1151. </if>
  1152. <if test="partDescription != null and partDescription != ''">
  1153. AND a.part_description like '%' + #{partDescription} + '%'
  1154. </if>
  1155. and a.site=#{site} and a.active='Y'
  1156. </where>
  1157. </select>
  1158. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1159. select part_no
  1160. from resource_spare
  1161. where site = #{site}
  1162. and resource_id = #{objectID}
  1163. and part_no = #{partNo}
  1164. </select>
  1165. <insert id="savePartSpare" >
  1166. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1167. values(#{objectID},#{partNo},'',0,#{site})
  1168. </insert>
  1169. <delete id="deletePartSpare">
  1170. delete from resource_spare
  1171. where resource_id = #{objectID}
  1172. and site = #{site}
  1173. </delete>
  1174. <insert id="copyPartSpare" >
  1175. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1176. select #{objectID},part_no,delflag,0,site from resource_spare where resource_id=#{oldObjectID} and site=#{site}
  1177. </insert>
  1178. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1179. SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status,
  1180. a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark
  1181. ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
  1182. FROM eam_workPlan a
  1183. left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID
  1184. left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID
  1185. left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no
  1186. where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N'
  1187. and status in ('已计划','进行中')
  1188. </select>
  1189. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1190. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  1191. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  1192. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  1193. where a.site=#{site} and a.ObjectID=#{objectID}
  1194. and a.ItemType=#{itemType}
  1195. </select>
  1196. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1197. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  1198. from eam_object_defect a left join eam_defect b
  1199. on a.DefectID=b.DefectID
  1200. where a.site=#{site} and a.ObjectID=#{objectID}
  1201. </select>
  1202. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1203. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1204. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1205. </select>
  1206. <insert id="saveNewEamObjectItem" >
  1207. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1208. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  1209. </insert>
  1210. <update id="editEamObjectItem">
  1211. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  1212. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  1213. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1214. and ItemNo=#{itemNo}
  1215. </update>
  1216. <delete id="deleteObjectItem">
  1217. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1218. and ItemNo=#{itemNo}
  1219. </delete>
  1220. <insert id="saveNewEamObjectItemAvailable">
  1221. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1222. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1223. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1224. </insert>
  1225. <delete id="deleteEamObjectItemAvailable">
  1226. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1227. and ItemNo=#{itemNo}
  1228. </delete>
  1229. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1230. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1231. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1232. </select>
  1233. <select id="getItemValueNoForObject" resultType="Double">
  1234. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1235. </select>
  1236. <insert id="saveObjectItemAvailable">
  1237. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1238. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1239. </insert>
  1240. <update id="updateObjectItemAvailable">
  1241. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1242. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1243. </update>
  1244. <delete id="deleteObjectItemAvailable">
  1245. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1246. </delete>
  1247. <delete id="deleteObjectItemForCopy">
  1248. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1249. </delete>
  1250. <delete id="deleteObjectItemAvailableForCopy">
  1251. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1252. </delete>
  1253. <insert id="copyObjectItem" >
  1254. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1255. ItemType)
  1256. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1257. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1258. </insert>
  1259. <insert id="copyObjectItemAvailable">
  1260. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1261. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1262. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1263. </insert>
  1264. <delete id="deleteObjectDefectForCopy">
  1265. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1266. </delete>
  1267. <insert id="copyObjectDefect">
  1268. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1269. select #{site},#{objectID},DefectID,Active
  1270. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1271. </insert>
  1272. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1273. select
  1274. a.Site,
  1275. a.bu_no,
  1276. a.FeedBackID,
  1277. a.FeedBackDesc,
  1278. a.ObjectID,
  1279. a.DefectID,
  1280. a.FunctionType,
  1281. a.PlanOperator,
  1282. a.ActualOperator,
  1283. a.Status,
  1284. a.PlanDate,
  1285. a.Remark,
  1286. a.urgency,
  1287. a.deleteFlag,
  1288. a.CreatedDate,
  1289. a.CreatedBy,
  1290. c.operator_name as feedbackBy,
  1291. a.UpdateDate,
  1292. a.UpdateBy,
  1293. a.Version,
  1294. a.DefectDate,
  1295. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
  1296. b.defectDesc,
  1297. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) ObjectDesc,
  1298. FinishDate,
  1299. 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
  1300. from eam_defect_feedBack a
  1301. left join eam_defect b on a.DefectID = b.DefectID
  1302. left join operator as c on a.site = c.site and a.CreatedBy = c.operator_id
  1303. 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
  1304. 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
  1305. 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
  1306. left join sys_user as ea on ead.username = ea.username
  1307. <where>
  1308. a.site in (select site from eam_access_site where username = #{query.userName})
  1309. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1310. and ea.username = #{query.userName}
  1311. <if test="query.feedBackID != null and query.feedBackID != ''">
  1312. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1313. </if>
  1314. <if test="query.defectDesc != null and query.defectDesc != ''">
  1315. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1316. </if>
  1317. <if test="query.objectID != null and query.objectID != ''">
  1318. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1319. </if>
  1320. <if test="query.planOperator != null and query.planOperator != ''">
  1321. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1322. </if>
  1323. <if test="query.status != null and query.status != ''">
  1324. AND a.status = #{query.status}
  1325. </if>
  1326. <if test="query.startDate != null ">
  1327. AND a.defectDate >= #{query.startDate}
  1328. </if>
  1329. <if test="query.endDate != null ">
  1330. AND #{query.endDate} >= a.defectDate
  1331. </if>
  1332. and a.FunctionType = #{query.functionType}
  1333. </where>
  1334. ORDER BY a.DefectDate,
  1335. CASE WHEN a.urgency = '特急' THEN 1
  1336. WHEN a.urgency = '紧急' THEN 2
  1337. WHEN a.urgency = '一般' THEN 3
  1338. END
  1339. </select>
  1340. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1341. select Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, Status from eam_defect_feedBack where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1342. </select>
  1343. <update id="cancelFeedBack" >
  1344. update eam_defect_feedBack
  1345. set status = '已取消'
  1346. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1347. </update>
  1348. <update id="updateFeedBack">
  1349. update eam_defect_feedBack
  1350. set status = '已下达',
  1351. PlanOperator = #{planOperator},
  1352. UpdateDate = GetDate(),
  1353. UpdateBy = #{updateBy}
  1354. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1355. </update>
  1356. <insert id="saveDefectOrder">
  1357. INSERT INTO eam_workOrder
  1358. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1359. 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})
  1360. </insert>
  1361. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1362. SELECT
  1363. a.site,
  1364. a.bu_no,
  1365. a.itemNo,
  1366. a.ItemDesc,
  1367. a.ItemRemark
  1368. FROM eam_properties_item a
  1369. 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
  1370. <where>
  1371. a.ItemType = #{functionType}
  1372. and a.site = #{site} and a.bu_no = #{buNo}
  1373. AND b.code_no is null
  1374. <if test = "itemNo != null and itemNo != ''">
  1375. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1376. </if>
  1377. <if test = "itemDesc != null and itemDesc != ''">
  1378. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1379. </if>
  1380. </where>
  1381. </select>
  1382. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1383. select
  1384. a.site,
  1385. a.bu_no,
  1386. a.properties_item_no itemNo,
  1387. b.ItemDesc,
  1388. b.ItemRemark
  1389. from eam_properties_model_detail a
  1390. 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
  1391. where a.site = #{site} and a.bu_no = #{buNo} and a.code_no = #{codeNo}
  1392. and a.function_type = #{functionType}
  1393. </select>
  1394. <delete id="deleteObjectFile">
  1395. delete from sys_oss where id = #{id}
  1396. </delete>
  1397. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1398. SELECT id, url, create_date, file_name, new_file_name, created_by,
  1399. order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1400. FROM sys_oss
  1401. WHERE order_ref2 = #{orderNo}
  1402. AND order_ref1 = #{site}
  1403. AND order_ref3 = 'reportSparPart'
  1404. </select>
  1405. <!-- 获取机修人员列表 -->
  1406. <select id="getOperatorList" resultType="EamAdminData" parameterType="EamAdminData">
  1407. SELECT
  1408. ea.AdminID,
  1409. ea.AdminName,
  1410. ea.Phone,
  1411. dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName,
  1412. ea.Email,
  1413. ea.Tel,
  1414. ea.LevelID,
  1415. eal.AdminLevelDesc,
  1416. ea.MesUser,
  1417. ea.Active,
  1418. ea.CreatedDate
  1419. FROM eam_admin as ea
  1420. LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1421. <where>
  1422. ea.Active = 'Y'
  1423. AND ea.Site = #{site}
  1424. <if test = "adminID != null and adminID != ''">
  1425. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1426. </if>
  1427. <if test = "adminName != null and adminName != ''">
  1428. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1429. </if>
  1430. </where>
  1431. </select>
  1432. <!-- 获取审核人员列表 -->
  1433. <select id="getCheckerList" resultType="EamAdminData" parameterType="EamAdminData">
  1434. SELECT
  1435. a.user_id,
  1436. a.username as adminID,
  1437. a.email,
  1438. a.mobile as phone,
  1439. a.user_display as adminName,
  1440. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  1441. d.role_id,
  1442. e.role_name
  1443. FROM sys_user as a
  1444. LEFT JOIN eam_access_site as b on a.username = b.username
  1445. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  1446. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  1447. LEFT JOIN sys_role as e on d.role_id = e.role_id
  1448. <where>
  1449. b.site = #{site} and c.bu_no = #{buNo}
  1450. <if test = "adminID != null and adminID != ''">
  1451. AND a.username LIKE '%' + #{adminID}+'%'
  1452. </if>
  1453. <if test = "adminName != null and adminName != ''">
  1454. AND a.user_display LIKE '%' + #{adminName}+'%'
  1455. </if>
  1456. <if test = "buDesc != null and buDesc != ''">
  1457. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc}+'%'
  1458. </if>
  1459. <if test = "roleName != null and roleName != ''">
  1460. AND e.role_name LIKE '%' + #{roleName}+'%'
  1461. </if>
  1462. </where>
  1463. </select>
  1464. <!-- 点检工单审核 -->
  1465. <update id="checkWorkOrder" parameterType="EamWorkOrderInData">
  1466. UPDATE eam_workOrder
  1467. SET Status = '已完工'
  1468. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1469. </update>
  1470. <update id="cancelCheckWorkOrder" parameterType="EamWorkOrderInData">
  1471. UPDATE eam_workOrder
  1472. SET Status = '待审核'
  1473. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1474. </update>
  1475. <!-- 查看点检工单状态 -->
  1476. <select id="checkWorkOrderStatus" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1477. SELECT
  1478. OrderNo
  1479. FROM eam_workOrder
  1480. WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' and bu_no = #{buNo}
  1481. </select>
  1482. <!-- 点检工单审核 -->
  1483. <update id="updateWorkPlanOverviewStatus" parameterType="EamWorkOrderInData">
  1484. UPDATE eam_workPlan_overview
  1485. SET status = '已结束'
  1486. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1487. </update>
  1488. <!-- 新增点检计划 -->
  1489. <insert id="saveWorkPlan" parameterType="EamWorkPlanInData">
  1490. INSERT INTO eam_workPlan_overview
  1491. (site, plan_id, plan_desc, status, plan_start_date, plan_end_date, created_date, created_by, update_date, update_by, remark, delete_flag, operator, operator_name, checker, checker_name, function_type, properties_code, plan_period, work_order_rule, plan_cycle, task_start_date, plan_halt_date, auto_renewal, bu_no)
  1492. VALUES (#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy}, #{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod}, #{workOrderRule}, #{planCycle}, #{taskStartDate}, #{planHaltDate}, #{autoRenewal}, #{buNo})
  1493. </insert>
  1494. <!-- 生成工单ID -->
  1495. <select id="selectOrderId" resultType="string" parameterType="EamWorkPlanInData">
  1496. SELECT
  1497. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1498. FROM eam_workPlan
  1499. WHERE site = #{site} AND FunctionType = #{functionType} and bu_no = #{buNo}
  1500. </select>
  1501. <!-- 查询计划中的设备列表 -->
  1502. <select id="getPlanDetailList" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1503. SELECT
  1504. ewp.PlanID,
  1505. ewp.PlanDesc,
  1506. ewp.ObjectID,
  1507. eo.ObjectDesc,
  1508. eo.FamilyID,
  1509. ef.FamilyDesc,
  1510. eo.LocationID,
  1511. el.LocationName
  1512. FROM eam_workPlan as ewP
  1513. LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site and ewP.bu_no = eo.bu_no
  1514. LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site and ewP.bu_no = ef.bu_no
  1515. LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site and ewP.bu_no = el.bu_no
  1516. <where>
  1517. ewP.site = #{site} and ewP.bu_no = #{buNo}
  1518. AND ewp.PlanID = #{planID}
  1519. <if test = "objectID != null and objectID != ''">
  1520. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  1521. </if>
  1522. <if test = "objectDesc != null and objectDesc != ''">
  1523. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  1524. </if>
  1525. </where>
  1526. </select>
  1527. <!-- 删除计划中的设备 -->
  1528. <delete id="delPlanDetail" parameterType="WorkPlanDetailData">
  1529. DELETE FROM eam_workPlan
  1530. WHERE Site = #{site}
  1531. AND PlanID = #{planID}
  1532. AND ObjectID = #{objectID}
  1533. </delete>
  1534. <!-- 获取当前计划不包含的设备 -->
  1535. <select id="getObjList1" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1536. SELECT
  1537. a.ObjectID,
  1538. a.ObjectDesc,
  1539. a.FamilyID,
  1540. ef.FamilyDesc,
  1541. a.LocationID,
  1542. el.LocationName
  1543. FROM eam_object a
  1544. 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
  1545. LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1546. LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1547. WHERE a.site = #{site} and a.bu_no = #{buNo} and b.PlanID is null
  1548. </select>
  1549. <!-- 获取当前计划包含的设备 -->
  1550. <select id="getObjList2" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1551. SELECT
  1552. a.ObjectID,
  1553. b.ObjectDesc,
  1554. b.FamilyID,
  1555. ef.FamilyDesc,
  1556. b.LocationID,
  1557. el.LocationName
  1558. FROM eam_workPlan a
  1559. LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1560. LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1561. LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1562. WHERE a.PlanID = #{planID} and a.site = #{site} and a.bu_no = #{buNo}
  1563. </select>
  1564. <!-- 添加计划设备 -->
  1565. <insert id="addObject" parameterType="EamWorkPlanInData">
  1566. INSERT INTO eam_workPlan
  1567. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  1568. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  1569. </insert>
  1570. <!-- 修改工单计划 -->
  1571. <update id="updateWorkPlan" parameterType="EamWorkPlanInData">
  1572. UPDATE eam_workPlan_overview
  1573. SET plan_desc = #{planDesc},
  1574. properties_code = #{propertiesCode},
  1575. plan_start_date = #{planStartDate},
  1576. plan_end_date = #{planEndDate},
  1577. plan_period = #{planPeriod},
  1578. remark = #{remark},
  1579. operator = #{operator},
  1580. operator_name = #{operatorName},
  1581. checker = #{checker},
  1582. checker_name = #{checkerName},
  1583. work_order_rule = #{workOrderRule},
  1584. task_start_date = #{taskStartDate},
  1585. plan_cycle = #{planCycle},
  1586. plan_halt_date = #{planHaltDate},
  1587. auto_renewal = #{autoRenewal}
  1588. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1589. </update>
  1590. <!-- 删除该计划的旧设备 -->
  1591. <delete id="delWorkPlanObject" parameterType="EamWorkPlanInData">
  1592. DELETE FROM eam_workPlan
  1593. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1594. </delete>
  1595. <!-- 删除该计划的旧设备item -->
  1596. <delete id="delWorkPlanItem" parameterType="EamWorkPlanInData">
  1597. DELETE FROM eam_workPlan_item
  1598. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1599. </delete>
  1600. <!-- 删除该计划的旧设备itemAvailable-->
  1601. <delete id="delWorkPlanItemAvailable">
  1602. DELETE FROM eam_workPlan_item_available
  1603. WHERE Site = #{site}
  1604. AND PlanID = #{planID}
  1605. AND ObjectID = #{objectID}
  1606. </delete>
  1607. <!-- 查询该计划的设备 -->
  1608. <select id="planObjectSearch" resultType="EamWorkPlanItemData" parameterType="EamWorkPlanItemData">
  1609. SELECT DISTINCT
  1610. a.ObjectID,
  1611. b.ObjectDesc
  1612. FROM eam_workPlan_item as a
  1613. LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1614. WHERE a.Site = #{site} AND a.PlanID = #{planID} and a.bu_no = #{buNo}
  1615. </select>
  1616. <!-- 修改该计划状态 -->
  1617. <update id="updateOverviewStatus" parameterType="EamWorkPlanInData">
  1618. UPDATE eam_workPlan_overview
  1619. SET status = '进行中',
  1620. next_work_date = plan_start_date
  1621. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1622. </update>
  1623. <!-- 查询文件路径 -->
  1624. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1625. SELECT
  1626. id,
  1627. url,
  1628. file_name
  1629. FROM sys_oss WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} and order_ref4 = #{buNo}
  1630. </select>
  1631. <!-- 新增子明细信息 -->
  1632. <insert id="saveOperator" parameterType="EamWorkOrderInData">
  1633. INSERT INTO eam_actual_operator
  1634. (site, order_no, function_type, operator, bu_no)
  1635. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
  1636. </insert>
  1637. <!-- AND Status = '已完工' AND PlanOperator is not null-->
  1638. <!-- 查询实际维修人员 -->
  1639. <select id="getActualOperatorList2" resultType="EamAdminData">
  1640. SELECT
  1641. ea.AdminID,
  1642. ea.AdminName
  1643. FROM eam_actual_operator as eao
  1644. LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site
  1645. LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo
  1646. WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID}
  1647. </select>
  1648. <!-- 查询实际维修人员 -->
  1649. <select id="getActualOperatorList" resultType="EamAdminData">
  1650. SELECT
  1651. ea.username as adminID,
  1652. ea.user_display as AdminName
  1653. FROM eam_actual_operator as eao
  1654. LEFT JOIN sys_user as ea ON eao.operator = ea.username
  1655. WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} and eao.bu_no = #{buNo}
  1656. </select>
  1657. <!-- 查询设备所属部门 -->
  1658. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  1659. SELECT ved.department_name
  1660. FROM eam_object as eo
  1661. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  1662. WHERE eo.site = #{site}
  1663. AND eo.ObjectID = #{objectID}
  1664. </select>
  1665. <!-- 查询用户所属部门 -->
  1666. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  1667. SELECT AdminID
  1668. FROM eam_admin
  1669. WHERE site = #{site}
  1670. AND MesUser = #{username}
  1671. </select>
  1672. <!-- &lt;!&ndash; 查询部门列表 &ndash;&gt;-->
  1673. <!-- <select id="getDeptList" resultType="string" parameterType="string">-->
  1674. <!-- SELECT-->
  1675. <!-- ved.department_name-->
  1676. <!-- FROM eam_admin_dept as ead-->
  1677. <!-- LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id-->
  1678. <!-- LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID-->
  1679. <!-- WHERE ead.site = #{site} AND ea.MesUser = #{username}-->
  1680. <!-- </select>-->
  1681. <!-- 查询部门列表 -->
  1682. <select id="getDeptList" resultType="string" parameterType="string">
  1683. SELECT
  1684. distinct c.department_name
  1685. from sys_user as a
  1686. left join Access_dept as b on a.username = b.username
  1687. left join sys_department as c on c.site in (select site from eam_access_site where username = #{username})
  1688. and (c.site + '-' + c.bu_no) in (select * from dbo.query_bu(#{userName}))
  1689. and b.department_id = c.department_id
  1690. where a.username = #{username}
  1691. </select>
  1692. <!-- 生成新的维修工单 -->
  1693. <insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData">
  1694. INSERT INTO eam_workOrder
  1695. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no, document_source)
  1696. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource})
  1697. </insert>
  1698. <!-- 创建count表 -->
  1699. <insert id="saveDefectRecordCount2" parameterType="EamWorkOrderInData">
  1700. INSERT INTO eam_workOrder_count
  1701. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no)
  1702. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo})
  1703. </insert>
  1704. <!-- 获取旧工单的基础信息 -->
  1705. <select id="queryOldWorkOrderMessage" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1706. select
  1707. PlanOperator,
  1708. PlanOperatorName,
  1709. checker,
  1710. checkerName
  1711. from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1712. </select>
  1713. <!-- 生成新的维保工单 -->
  1714. <insert id="saveMaintenanceWorkOrder" parameterType="EamWorkOrderInData">
  1715. INSERT INTO eam_workOrder
  1716. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1717. VALUES (#{site}, #{buNo}, (select 'W' + Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) from eam_workOrder where site = #{site} and FunctionType = 'B' and bu_no = #{buNo}),
  1718. #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  1719. </insert>
  1720. <!-- 检查系统操作人和审核人员是否一致 -->
  1721. <select id="selectNameByMes" resultType="EamAdminData" parameterType="EamAdminData">
  1722. SELECT AdminName
  1723. FROM eam_admin
  1724. WHERE site = #{site}
  1725. AND MesUser = #{mesUser}
  1726. </select>
  1727. <!-- 维修审核确认 -->
  1728. <update id="submitDefect" parameterType="EamWorkOrderInData">
  1729. UPDATE eam_workOrder
  1730. SET Status = #{status},
  1731. difficulty_level = #{difficultyLevel},
  1732. difficulty_remark = #{difficultyRemark}
  1733. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1734. </update>
  1735. <!-- 查询设备的点检和维保历史记录 -->
  1736. <select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1737. SELECT
  1738. top 10
  1739. ewo.OrderNo,
  1740. ewo.PlanID,
  1741. ewo.PlanDesc,
  1742. ewo.ActualDate,
  1743. ewo.ObjectID,
  1744. eo.ObjectDesc,
  1745. ewo.Remark,
  1746. dbo.eam_Get_eamAdminName(ewo.site,ewo.ActualOperator) ActualOperatorName,
  1747. ewo.checkResult
  1748. FROM eam_workOrder as ewo
  1749. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1750. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND ewo.Status = '已完工' and ewo.bu_no = #{buNo}
  1751. ORDER BY ewo.ActualDate desc
  1752. </select>
  1753. <!-- 查询设备的维修历史记录 -->
  1754. <select id="queryDefectHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1755. SELECT
  1756. top 10
  1757. ewo.OrderNo,
  1758. ewo.PlanID,
  1759. ewo.PlanDesc,
  1760. ewo.ActualDate,
  1761. ewo.Remark,
  1762. ewo.Result,
  1763. ewo.disposal_measures,
  1764. ed.DefectDesc,
  1765. ewo.WorkTime
  1766. FROM eam_workOrder as ewo
  1767. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1768. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID and ewo.bu_no = edf.bu_no
  1769. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  1770. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND ewo.Status = '已完工' and ewo.bu_no = #{buNo} ORDER BY ewo.ActualDate desc
  1771. </select>
  1772. <!-- 查询部门列表 -->
  1773. <select id="getEmpyDeptList" resultType="EmpyDept" parameterType="EmpyDept">
  1774. SELECT
  1775. site,
  1776. department_id as deptId,
  1777. department_name as deptName
  1778. FROM sys_department
  1779. <where>
  1780. site in (select site from eam_access_site where username = #{userName})
  1781. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  1782. <if test = "deptId != null and deptId != ''">
  1783. AND department_id LIKE '%' + #{deptId}+'%'
  1784. </if>
  1785. <if test = "deptName != null and deptName != ''">
  1786. AND department_name LIKE '%' + #{deptName}+'%'
  1787. </if>
  1788. </where>
  1789. </select>
  1790. <!-- 生成新的维修工单 -->
  1791. <insert id="saveAdminDepartment">
  1792. INSERT INTO eam_admin_dept
  1793. (Site, admin_id, dept_id)
  1794. VALUES (#{site}, #{adminID}, #{deptId})
  1795. </insert>
  1796. <!-- 查询部门详情 -->
  1797. <select id="getDeptDetail" resultType="EamAdminData" parameterType="string">
  1798. SELECT
  1799. ved.department_id as department,
  1800. ved.department_name as departmentName
  1801. FROM eam_admin_dept as ead
  1802. 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
  1803. WHERE ead.site in (select site from eam_access_site where username = #{userName})
  1804. and (ead.site + '-' + ead.bu_no) in (select * from dbo.query_bu(#{userName}))
  1805. AND ead.admin_id = #{adminID}
  1806. </select>
  1807. <!-- 删除旧数据-->
  1808. <delete id="deleteAdminDepartment">
  1809. DELETE FROM eam_admin_dept
  1810. WHERE site = #{site}
  1811. AND admin_id = #{adminID}
  1812. </delete>
  1813. <!-- 获取可用的MES账号 -->
  1814. <select id="getMesList" resultType="SysUserEntity" parameterType="SysUserEntity">
  1815. SELECT
  1816. a.username,
  1817. a.user_display
  1818. FROM sys_user a
  1819. LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site
  1820. WHERE a.site = #{site}
  1821. AND b.MesUser is null
  1822. </select>
  1823. <!-- 查询点检项目 -->
  1824. <select id="eamPropertiesItemSearch" parameterType="EamPropertiesItemData" resultType="EamPropertiesItemData">
  1825. SELECT
  1826. site,
  1827. bu_no,
  1828. dbo.get_bu_desc(site, bu_no) as buDesc,
  1829. ItemNo,
  1830. ItemDesc,
  1831. DefaultValue,
  1832. ValueType,
  1833. ValueType_DB as valueTypeDb,
  1834. ValueChooseFlag,
  1835. CreatedDate,
  1836. CreatedBy,
  1837. update_date,
  1838. update_by,
  1839. MaxValue,
  1840. MinValue,
  1841. ItemRemark,
  1842. ItemType,
  1843. image_flag,
  1844. produce_control_flag
  1845. FROM eam_properties_item
  1846. <where>
  1847. site in (select site from eam_access_site where username = #{query.userName})
  1848. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1849. and ItemType = #{query.itemType}
  1850. <if test="query.buDesc != null and query.buDesc != ''">
  1851. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  1852. </if>
  1853. <if test="query.itemNo != null and query.itemNo != ''">
  1854. AND ItemNo LIKE '%' + #{query.itemNo}+'%'
  1855. </if>
  1856. <if test="query.itemDesc != null and query.itemDesc != ''">
  1857. AND ItemDesc LIKE '%' + #{query.itemDesc}+'%'
  1858. </if>
  1859. </where>
  1860. </select>
  1861. <!-- 删除图片-->
  1862. <delete id="imageDelete" parameterType="SysOssEntity">
  1863. DELETE FROM sys_oss
  1864. WHERE id = #{id}
  1865. </delete>
  1866. <!-- 检查该日期内是否已有该设备的计划 -->
  1867. <select id="checkObjectPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1868. SELECT
  1869. a.PlanID,
  1870. a.ObjectID
  1871. FROM eam_workPlan a
  1872. 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
  1873. WHERE a.site = #{site} and a.bu_no = #{buNo}
  1874. AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N'
  1875. AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  1876. or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  1877. or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0)
  1878. )
  1879. and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod}
  1880. and b.Status not in ('已取消','已完成','待审核')
  1881. </select>
  1882. <!-- 查询当前计划 -->
  1883. <select id="queryWorkPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1884. SELECT
  1885. site,
  1886. bu_no,
  1887. plan_id,
  1888. plan_desc,
  1889. properties_code,
  1890. #{objectID} as objectID,
  1891. status,
  1892. operator,
  1893. delete_flag,
  1894. plan_start_date,
  1895. plan_end_date,
  1896. plan_period,
  1897. function_type,
  1898. checker,
  1899. checker_name,
  1900. operator_name,
  1901. work_order_rule,
  1902. plan_cycle
  1903. FROM eam_workPlan_overview
  1904. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1905. </select>
  1906. <!-- 获得工单号 -->
  1907. <select id="queryPlanOrderNo" resultType="string" parameterType="EamWorkPlanInData">
  1908. SELECT
  1909. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  1910. FROM eam_workOrder
  1911. WHERE site = #{site} and bu_no = #{buNo} AND FunctionType = #{functionType}
  1912. </select>
  1913. <!-- 新增工单 -->
  1914. <insert id="insertWorkOrder" parameterType="EamWorkPlanInData">
  1915. INSERT INTO eam_workOrder
  1916. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1917. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1918. </insert>
  1919. <!-- 循环新增工单 -->
  1920. <insert id="forInsertWorkOrder" parameterType="EamWorkPlanInData">
  1921. INSERT INTO eam_workOrder
  1922. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1923. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1924. </insert>
  1925. <!-- 更改plan表的状态为进行中 -->
  1926. <update id="updatePlanStatus" parameterType="EamWorkPlanInData">
  1927. update eam_workPlan
  1928. set status = '进行中',
  1929. NextWorkDate = PlanStartDate
  1930. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1931. </update>
  1932. <!-- 获得工单号 -->
  1933. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="EamWorkOrderItemInData">
  1934. SELECT
  1935. id,
  1936. file_name
  1937. FROM sys_oss
  1938. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  1939. </select>
  1940. <!-- 删除原来工单项目-->
  1941. <delete id="deleteWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1942. DELETE FROM eam_workPlan_item
  1943. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1944. </delete>
  1945. <!-- 删除原来的可选值-->
  1946. <delete id="deleteWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1947. DELETE FROM eam_workPlan_item_available
  1948. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1949. </delete>
  1950. <!-- 添加新项目 -->
  1951. <insert id="saveWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1952. 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)
  1953. select
  1954. #{site},
  1955. #{buNo},
  1956. #{planID},
  1957. #{objectID},
  1958. a.ItemNo,
  1959. a.ItemDesc,
  1960. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  1961. case when c.site is not null then c.ValueType else a.ValueType end,
  1962. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  1963. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  1964. case when c.site is not null then c.MaxValue else a.MaxValue end,
  1965. case when c.site is not null then c.MinValue else a.MinValue end,
  1966. a.ItemRemark,
  1967. a.ItemType,
  1968. GetDate(),
  1969. #{userId},
  1970. a.image_flag,
  1971. a.produce_control_flag
  1972. from eam_properties_item a
  1973. 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
  1974. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  1975. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  1976. </insert>
  1977. <!-- 添加新项目可选值 -->
  1978. <insert id="saveWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1979. INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  1980. SELECT DISTINCT
  1981. #{site},
  1982. #{buNo},
  1983. #{planID},
  1984. #{objectID},
  1985. a.ItemNo,
  1986. a.ItemType,
  1987. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  1988. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  1989. GetDate(),
  1990. #{userId}
  1991. FROM eam_properties_item_available a
  1992. 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
  1993. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  1994. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  1995. </insert>
  1996. <!-- 检查维修任务号是否已存在 -->
  1997. <select id="getEamGzData" resultType="EamDefectFeedBackData" parameterType="EamDefectFeedBackData">
  1998. select
  1999. a.Site,
  2000. a.bu_no,
  2001. a.FeedBackID,
  2002. a.FeedBackDesc,
  2003. a.ObjectID,
  2004. a.Status
  2005. from eam_defect_feedBack a
  2006. left join eam_defect b on a.DefectID = b.DefectID
  2007. <where>
  2008. a.site = #{site} and a.deleteFlag = 'N' and a.bu_no = #{buNo}
  2009. <if test="feedBackID != null and feedBackID != ''">
  2010. AND a.FeedBackID LIKE '%' + #{feedBackID}+'%'
  2011. </if>
  2012. <if test="feedBackDesc != null and feedBackDesc != ''">
  2013. AND a.FeedBackDesc LIKE '%' + #{feedBackDesc}+'%'
  2014. </if>
  2015. <if test="objectInfo != null and objectInfo != ''">
  2016. AND (a.ObjectID like '%' + #{objectInfo} + '%' or dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) like '%' + #{objectInfo} + '%')
  2017. </if>
  2018. <if test="defectInfo != null and defectInfo != ''">
  2019. AND (a.DefectID like '%' + #{defectInfo} + '%' or b.defectDesc like '%' + #{defectInfo} + '%')
  2020. </if>
  2021. </where>
  2022. </select>
  2023. <!-- 保存故障信息 -->
  2024. <insert id="saveEamGzBbData" parameterType="EamDefectFeedBackData">
  2025. INSERT INTO eam_defect_feedBack
  2026. (Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate, Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency)
  2027. VALUES (#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate}, #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency})
  2028. </insert>
  2029. <!-- 查看现场动控是否开启 -->
  2030. <select id="selectControlBaseData" resultType="SysSceneDynamicControlModelEntity" parameterType="string">
  2031. SELECT
  2032. type,
  2033. base_data,
  2034. base_desc,
  2035. status,
  2036. remark,
  2037. third_type,
  2038. second_type,
  2039. page_control,
  2040. control_style
  2041. FROM sys_scene_dynamic_control_model
  2042. where site = #{site} and control_no = #{controlNo}
  2043. </select>
  2044. <!-- 修改反馈状态为已下达 -->
  2045. <update id="updateDefectFeedBackStatus" parameterType="EamDefectFeedBackData">
  2046. UPDATE eam_defect_feedBack
  2047. SET Status = '已下达'
  2048. WHERE Site = #{site} AND FeedBackID = #{feedBackID} and bu_no = #{buNo}
  2049. </update>
  2050. <!-- 查询工单号 -->
  2051. <select id="getOrderNo" resultType="string" parameterType="EamWorkOrderInData">
  2052. select
  2053. 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2054. from eam_workOrder
  2055. where site = #{site} and FunctionType = 'C' and bu_no = #{buNo}
  2056. </select>
  2057. <!-- 创建维修工单 -->
  2058. <insert id="saveWorkOrder" parameterType="EamDefectFeedBackData">
  2059. INSERT INTO eam_workOrder
  2060. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source)
  2061. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource})
  2062. </insert>
  2063. <!-- 创建维修count表数据 -->
  2064. <insert id="saveDefectRecordCount" parameterType="EamDefectFeedBackData">
  2065. INSERT INTO eam_workOrder_count
  2066. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc)
  2067. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc})
  2068. </insert>
  2069. <!-- 修改工单 -->
  2070. <update id="updateWorkOrder" parameterType="EamWorkOrderInData">
  2071. update eam_workOrder
  2072. set update_by = #{mesUser},
  2073. update_date = GetDate(),
  2074. Remark = #{remark},
  2075. <if test='functionType == "B"'>
  2076. reach_date = #{reachDate},
  2077. ActualDate = #{actualDate},
  2078. WorkTime = CASE WHEN (DATEDIFF(SECOND, #{reachDate}, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 60.0
  2079. ELSE ceiling(floor(DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 30) / 2)
  2080. END,
  2081. </if>
  2082. <if test='functionType == "A"'>
  2083. WorkTime = #{workTime},
  2084. </if>
  2085. <if test='functionType == "B" and checkResult == "合格"'>
  2086. disposal_measures = '',
  2087. </if>
  2088. <if test='functionType == "B" and checkResult == "异常"'>
  2089. disposal_measures = #{disposalMeasures},
  2090. </if>
  2091. checkResult = #{checkResult},
  2092. check_remark = #{checkRemark},
  2093. fault_reason = #{faultReason},
  2094. preventive_measure = #{preventiveMeasure}
  2095. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  2096. </update>
  2097. <!-- 修改工单项目 -->
  2098. <update id="updateWorkOrderItem" parameterType="EamWorkOrderItemInData">
  2099. update eam_workOrder_item
  2100. set update_by = #{updateBy},
  2101. update_date = GetDate(),
  2102. <if test='valueTypeDb == "T"'>
  2103. TextValue = #{textValue},
  2104. </if>
  2105. <if test='valueTypeDb == "N"'>
  2106. NumberValue = #{numberValue},
  2107. </if>
  2108. itemResult = #{itemResult}
  2109. where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
  2110. </update>
  2111. <!-- 删除之前的协同人员-->
  2112. <delete id="delOperator" parameterType="EamWorkOrderInData">
  2113. DELETE FROM eam_actual_operator
  2114. WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
  2115. </delete>
  2116. <!-- 到达 -->
  2117. <update id="reach" parameterType="EamWorkOrderInData">
  2118. update eam_workOrder
  2119. set Status = #{status},
  2120. reach_date = GetDate(),
  2121. reach_operator = #{reachOperator},
  2122. reach_operator_name = #{reachOperatorName}
  2123. where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_No = #{buNo}
  2124. </update>
  2125. <!-- 查询是否已经上传图片 -->
  2126. <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2127. SELECT
  2128. id
  2129. FROM sys_oss
  2130. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo}
  2131. </select>
  2132. <!-- 查询文件路径 -->
  2133. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2134. SELECT
  2135. id,
  2136. url,
  2137. file_name
  2138. FROM sys_oss
  2139. WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2140. </select>
  2141. <!-- 根据工单号查询知识库记录 -->
  2142. <select id="selectKnowledgeRecordByOrderNo" resultType="EamKnowledgeBaseData" parameterType="EamWorkOrderInData">
  2143. SELECT
  2144. site,
  2145. bu_no,
  2146. num
  2147. FROM eam_knowledge_base
  2148. WHERE site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2149. </select>
  2150. <!-- 根据工单号修改知识库记录 -->
  2151. <update id="updateKnowledgeRecordByOrderNo" parameterType="EamWorkOrderInData">
  2152. update eam_knowledge_base
  2153. set update_date = getDate(),
  2154. update_by = #{updateBy}
  2155. where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2156. </update>
  2157. <!-- 新增设备知识库记录 -->
  2158. <insert id="saveKnowledgeRecord" parameterType="EamWorkOrderInData">
  2159. INSERT INTO eam_knowledge_base
  2160. (site, bu_no, num, file_type, defect_describe, disposal_measures, create_date, create_by, object_id, defect_id, order_no)
  2161. VALUES (#{site}, #{buNo}, (select 'ZS'+ Right('0000000000' + convert(VARCHAR(10), isnull(max(convert(INT, SUBSTRING(num, 3, 10))), 0) + 1), 8) from eam_knowledge_base where site = #{site}), '维修', #{planDesc}, #{disposalMeasures}, getDate(), #{createBy}, #{objectID}, #{defectID}, #{orderNo})
  2162. </insert>
  2163. <!-- 修改反馈状态为已取消 -->
  2164. <update id="updateFeedBackStatus" parameterType="EamWorkOrderInData">
  2165. UPDATE eam_defect_feedBack
  2166. SET Status = '已取消'
  2167. WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
  2168. </update>
  2169. <!-- 获取所有分类 -->
  2170. <select id="getFamilyTree" resultType="EamFamilyData" parameterType="EamFamilyData">
  2171. SELECT
  2172. site,
  2173. bu_no,
  2174. FamilyID,
  2175. FamilyDesc,
  2176. parent_id,
  2177. son_id,
  2178. Active
  2179. FROM eam_family
  2180. WHERE site in (select site from eam_access_site where username = #{userName})
  2181. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2182. and Active = 'Y'
  2183. </select>
  2184. <!-- 获得sonId -->
  2185. <select id="getSonId" resultType="string" parameterType="EamFamilyData">
  2186. SELECT
  2187. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2)
  2188. FROM eam_family
  2189. WHERE site = #{site} and bu_no = #{buNo} and son_id like #{parentId} + '%'
  2190. </select>
  2191. <!-- 删除该分类以及其子类-->
  2192. <delete id="eamFamilyDelete" parameterType="EamFamilyData">
  2193. DELETE FROM eam_family
  2194. WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID} and son_id like #{sonId} + '%'
  2195. </delete>
  2196. <select id="getEamWorkOrder" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  2197. EXEC EAM_WORK_ORDER #{site}, #{username}, #{orderNo}, #{planID}, #{objectID}, #{status}, #{startDate}, #{endDate}, #{functionType}, '*'
  2198. </select>
  2199. <!-- 修改执行结果 -->
  2200. <update id="updateReportResult" parameterType="EamWorkOrderInData">
  2201. update eam_workOrder
  2202. set ActualDate = #{actualDate},
  2203. reach_date = #{reachDate},
  2204. fault_reason = #{faultReason},
  2205. handling_method = #{handlingMethod},
  2206. preventive_measure = #{preventiveMeasure},
  2207. Remark = #{remark},
  2208. WorkTime = CASE
  2209. WHEN (DATEDIFF(SECOND, #{reachDate}, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 60.0
  2210. ELSE ceiling(floor(DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 30) / 2)
  2211. END
  2212. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2213. </update>
  2214. <!-- 根据设备查所属部门 -->
  2215. <select id="queryDepartmentByObjectId" resultType="EamObjectAdminData" parameterType="EamDefectFeedBackData">
  2216. SELECT
  2217. eo.site,
  2218. eo.bu_no,
  2219. eo.ObjectDesc,
  2220. eo.dept_id,
  2221. el.LocationName
  2222. FROM eam_object as eo
  2223. LEFT JOIN eam_location as el on eo.site = el.site and eo.LocationID = el.LocationID and eo.bu_no = el.bu_no
  2224. WHERE eo.site = #{site} and eo.ObjectID = #{objectID} and eo.bu_no = #{buNo}
  2225. </select>
  2226. <!-- 根据部门ID查机修人员电话 -->
  2227. <select id="queryPhoneByDepartmentId" resultType="EamObjectAdminData" parameterType="EamObjectAdminData">
  2228. SELECT
  2229. ed.user_display as adminName,
  2230. ed.mobile as phone
  2231. FROM Access_dept as edd
  2232. LEFT JOIN sys_user ed on edd.username = ed.username and edd.site in (select site from eam_access_site where username = ed.username)
  2233. and (edd.site + '-' + edd.bu_no) in (select * from dbo.query_bu(ed.username))
  2234. WHERE edd.site = #{site} and edd.department_id = #{deptId} and edd.bu_no = #{buNo}
  2235. </select>
  2236. <!-- 保存短信记录 -->
  2237. <insert id="saveMessageRecord" parameterType="MessageRecordData">
  2238. INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
  2239. VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
  2240. </insert>
  2241. <!-- 查出计划结束日期为今天并且自动续期标识为Y的计划 -->
  2242. <select id="selectPlanToday" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  2243. SELECT
  2244. site,
  2245. plan_id,
  2246. plan_desc,
  2247. status,
  2248. plan_start_date,
  2249. plan_end_date,
  2250. created_date,
  2251. created_by,
  2252. update_date,
  2253. update_by,
  2254. remark,
  2255. next_work_date,
  2256. delete_flag,
  2257. operator,
  2258. operator_name,
  2259. checker,
  2260. checker_name,
  2261. function_type,
  2262. properties_code,
  2263. plan_period,
  2264. work_order_rule,
  2265. plan_cycle,
  2266. task_start_date,
  2267. plan_halt_date,
  2268. auto_renewal
  2269. FROM eam_workPlan_overview
  2270. WHERE site = #{site} and status != #{status} and delete_flag = #{deleteFlag} and DATEDIFF(day, plan_end_date, getdate()) = 0 and auto_renewal = #{autoRenewal}
  2271. </select>
  2272. <!-- 查出老计划的设备 -->
  2273. <select id="selectObjectByPlanID" resultType="EamObjectInData" parameterType="EamWorkPlanInData">
  2274. SELECT
  2275. Site,
  2276. PlanID,
  2277. PlanDesc,
  2278. ObjectID,
  2279. FunctionType,
  2280. PropertiesCode,
  2281. Status
  2282. FROM eam_workPlan
  2283. WHERE site = #{site} and PlanID = #{planID} and FunctionType = #{functionType}
  2284. </select>
  2285. <!-- 获取用户 bu -->
  2286. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  2287. SELECT
  2288. a.site,
  2289. c.sitename,
  2290. (a.site + '_' + a.bu_no) as buNo,
  2291. b.bu_desc
  2292. FROM AccessBu as a
  2293. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2294. left join site as c on a.site = c.siteid
  2295. WHERE a.username = #{username}
  2296. </select>
  2297. </mapper>