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.

2481 lines
108 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
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}) * 1.0 / 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. reach_date = #{reachDate},
  1022. ActualDate = #{actualDate},
  1023. Remark = #{remark},
  1024. disposal_measures = #{disposalMeasures},
  1025. WorkTime = #{workTime},
  1026. result = #{result,jdbcType=VARCHAR},
  1027. checkResult = #{checkResult},
  1028. handling_method = #{handlingMethod},
  1029. check_remark = #{checkRemark}
  1030. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1031. </update>
  1032. <update id="defectReportWorkOrder" >
  1033. update eam_workOrder
  1034. set Status = '已完工',
  1035. ActualOperator = #{actualOperator},
  1036. ActualDate = GetDate(),
  1037. Remark = #{remark},
  1038. disposal_measures = #{disposalMeasures},
  1039. WorkTime = #{workTime},
  1040. result = #{result,jdbcType=VARCHAR},
  1041. checkResult = #{checkResult}
  1042. where site = #{site}
  1043. and orderNo = #{orderNo}
  1044. </update>
  1045. <insert id="saveWorkOrderItem">
  1046. INSERT into eam_workOrder_item
  1047. (Site, bu_no, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes)
  1048. 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})
  1049. </insert>
  1050. <!-- 修改 eam_workPlan 状态为已结束 -->
  1051. <update id="closePlanWithCheck">
  1052. update eam_workPlan
  1053. set status = '已结束'
  1054. where site = #{site}
  1055. and PlanID = #{planID}
  1056. and ObjectID = #{objectID}
  1057. and GetDate() > PlanEndDate
  1058. </update>
  1059. <!-- 报工后更新下一个工作日期 -->
  1060. <update id="updatePlanNextDate">
  1061. update eam_workPlan_overview
  1062. 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)
  1063. where site = #{site} and plan_id = #{planID} and bu_no = #{buNo}
  1064. </update>
  1065. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  1066. SELECT
  1067. Site,
  1068. bu_no,
  1069. OrderNo,
  1070. ItemNo,
  1071. ItemDesc,
  1072. DefaultValue,
  1073. ValueType,
  1074. ValueType_DB,
  1075. ValueChooseFlag,
  1076. MaxValue,
  1077. MinValue,
  1078. ItemRemark,
  1079. ItemType,
  1080. TextValue,
  1081. NumberValue,
  1082. CreatedDate,
  1083. CreatedBy,
  1084. FinishFlag,
  1085. itemResult,
  1086. item_notes
  1087. from eam_workOrder_item
  1088. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  1089. </select>
  1090. <update id="cancelOrder" parameterType="EamWorkOrderInData">
  1091. update eam_workOrder
  1092. set Status = '已取消'
  1093. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1094. </update>
  1095. <update id="cancelOrderAll" parameterType="EamWorkOrderInData">
  1096. update eam_workOrder
  1097. set Status = '已取消'
  1098. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} and bu_no = #{buNo}
  1099. </update>
  1100. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1101. SELECT
  1102. site,
  1103. bu_no,
  1104. status
  1105. from eam_workPlan_overview
  1106. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1107. </select>
  1108. <update id="planOrder">
  1109. update eam_workPlan
  1110. set Status = '已计划',
  1111. NextWorkDate = null
  1112. where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1113. </update>
  1114. <update id="cancelPlan">
  1115. update eam_workPlan_overview
  1116. set status = '已取消',
  1117. next_work_date = null
  1118. where site = #{site} and plan_id = #{planID} and delete_flag = 'N' and bu_no = #{buNo}
  1119. </update>
  1120. <update id="updateWorkPlanStatus">
  1121. update eam_workPlan
  1122. set Status = '已取消',
  1123. NextWorkDate = null
  1124. where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' and bu_no = #{buNo}
  1125. </update>
  1126. <update id="cancelOrderWithPlanID">
  1127. update eam_workOrder
  1128. set Status = '已取消'
  1129. where site = #{site} and PlanID = #{planID} and status = '未开工' and bu_no = #{buNo}
  1130. </update>
  1131. <update id="deleteOrderDetailWithPlanID">
  1132. delete from eam_workOrder_item
  1133. where site = #{site} and bu_no = #{buNo}
  1134. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  1135. </update>
  1136. <update id="deleteOrderWithPlanID">
  1137. delete from eam_workOrder
  1138. where site = #{site} and bu_no = #{buNo}
  1139. and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1
  1140. </update>
  1141. <update id="updateOrderPlanOperator">
  1142. update eam_workOrder
  1143. set PlanOperator = #{planOperator}
  1144. where site = #{site} and orderNo = #{orderNo}
  1145. </update>
  1146. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1147. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  1148. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  1149. <where>
  1150. <if test="partNo != null and partNo != ''">
  1151. AND a.part_no like '%' + #{partNo} + '%'
  1152. </if>
  1153. <if test="partDescription != null and partDescription != ''">
  1154. AND a.part_description like '%' + #{partDescription} + '%'
  1155. </if>
  1156. and a.site=#{site} and a.active='Y'
  1157. </where>
  1158. </select>
  1159. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  1160. select part_no
  1161. from resource_spare
  1162. where site = #{site}
  1163. and resource_id = #{objectID}
  1164. and part_no = #{partNo}
  1165. </select>
  1166. <insert id="savePartSpare" >
  1167. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1168. values(#{objectID},#{partNo},'',0,#{site})
  1169. </insert>
  1170. <delete id="deletePartSpare">
  1171. delete from resource_spare
  1172. where resource_id = #{objectID}
  1173. and site = #{site}
  1174. </delete>
  1175. <insert id="copyPartSpare" >
  1176. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  1177. select #{objectID},part_no,delflag,0,site from resource_spare where resource_id=#{oldObjectID} and site=#{site}
  1178. </insert>
  1179. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  1180. SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status,
  1181. a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark
  1182. ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
  1183. FROM eam_workPlan a
  1184. left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID
  1185. left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID
  1186. left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no
  1187. where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N'
  1188. and status in ('已计划','进行中')
  1189. </select>
  1190. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1191. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  1192. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  1193. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  1194. where a.site=#{site} and a.ObjectID=#{objectID}
  1195. and a.ItemType=#{itemType}
  1196. </select>
  1197. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  1198. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  1199. from eam_object_defect a left join eam_defect b
  1200. on a.DefectID=b.DefectID
  1201. where a.site=#{site} and a.ObjectID=#{objectID}
  1202. </select>
  1203. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  1204. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1205. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1206. </select>
  1207. <insert id="saveNewEamObjectItem" >
  1208. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1209. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  1210. </insert>
  1211. <update id="editEamObjectItem">
  1212. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  1213. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  1214. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1215. and ItemNo=#{itemNo}
  1216. </update>
  1217. <delete id="deleteObjectItem">
  1218. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1219. and ItemNo=#{itemNo}
  1220. </delete>
  1221. <insert id="saveNewEamObjectItemAvailable">
  1222. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1223. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1224. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1225. </insert>
  1226. <delete id="deleteEamObjectItemAvailable">
  1227. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1228. and ItemNo=#{itemNo}
  1229. </delete>
  1230. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1231. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1232. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1233. </select>
  1234. <select id="getItemValueNoForObject" resultType="Double">
  1235. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1236. </select>
  1237. <insert id="saveObjectItemAvailable">
  1238. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1239. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1240. </insert>
  1241. <update id="updateObjectItemAvailable">
  1242. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1243. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1244. </update>
  1245. <delete id="deleteObjectItemAvailable">
  1246. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1247. </delete>
  1248. <delete id="deleteObjectItemForCopy">
  1249. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1250. </delete>
  1251. <delete id="deleteObjectItemAvailableForCopy">
  1252. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1253. </delete>
  1254. <insert id="copyObjectItem" >
  1255. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1256. ItemType)
  1257. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1258. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1259. </insert>
  1260. <insert id="copyObjectItemAvailable">
  1261. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1262. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1263. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1264. </insert>
  1265. <delete id="deleteObjectDefectForCopy">
  1266. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1267. </delete>
  1268. <insert id="copyObjectDefect">
  1269. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1270. select #{site},#{objectID},DefectID,Active
  1271. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1272. </insert>
  1273. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1274. select
  1275. a.Site,
  1276. a.bu_no,
  1277. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1278. a.FeedBackID,
  1279. a.FeedBackDesc,
  1280. a.ObjectID,
  1281. a.DefectID,
  1282. a.FunctionType,
  1283. a.PlanOperator,
  1284. a.ActualOperator,
  1285. a.Status,
  1286. a.PlanDate,
  1287. a.Remark,
  1288. a.urgency,
  1289. a.deleteFlag,
  1290. a.CreatedDate,
  1291. a.CreatedBy,
  1292. c.operator_name as feedbackBy,
  1293. a.UpdateDate,
  1294. a.UpdateBy,
  1295. a.Version,
  1296. a.DefectDate,
  1297. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
  1298. b.defectDesc,
  1299. dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) ObjectDesc,
  1300. FinishDate,
  1301. 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
  1302. from eam_defect_feedBack a
  1303. left join eam_defect b on a.DefectID = b.DefectID
  1304. left join operator as c on a.site = c.site and a.CreatedBy = c.operator_id
  1305. 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
  1306. 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
  1307. 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
  1308. left join sys_user as ea on ead.username = ea.username
  1309. <where>
  1310. a.site in (select site from eam_access_site where username = #{query.userName})
  1311. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1312. and ea.username = #{query.userName}
  1313. <if test="query.buDesc != null and query.buDesc != ''">
  1314. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  1315. </if>
  1316. <if test="query.feedBackID != null and query.feedBackID != ''">
  1317. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1318. </if>
  1319. <if test="query.defectDesc != null and query.defectDesc != ''">
  1320. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1321. </if>
  1322. <if test="query.objectID != null and query.objectID != ''">
  1323. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1324. </if>
  1325. <if test="query.planOperator != null and query.planOperator != ''">
  1326. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1327. </if>
  1328. <if test="query.status != null and query.status != ''">
  1329. AND a.status = #{query.status}
  1330. </if>
  1331. <if test="query.startDate != null ">
  1332. AND a.defectDate >= #{query.startDate}
  1333. </if>
  1334. <if test="query.endDate != null ">
  1335. AND #{query.endDate} >= a.defectDate
  1336. </if>
  1337. and a.FunctionType = #{query.functionType}
  1338. </where>
  1339. ORDER BY a.DefectDate,
  1340. CASE WHEN a.urgency = '特急' THEN 1
  1341. WHEN a.urgency = '紧急' THEN 2
  1342. WHEN a.urgency = '一般' THEN 3
  1343. END
  1344. </select>
  1345. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1346. select Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, Status from eam_defect_feedBack where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1347. </select>
  1348. <update id="cancelFeedBack" >
  1349. update eam_defect_feedBack
  1350. set status = '已取消'
  1351. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1352. </update>
  1353. <update id="updateFeedBack">
  1354. update eam_defect_feedBack
  1355. set status = '已下达',
  1356. PlanOperator = #{planOperator},
  1357. UpdateDate = GetDate(),
  1358. UpdateBy = #{updateBy}
  1359. where FeedBackID = #{feedBackID} and site = #{site} and bu_no = #{buNo}
  1360. </update>
  1361. <insert id="saveDefectOrder">
  1362. INSERT INTO eam_workOrder
  1363. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1364. 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})
  1365. </insert>
  1366. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1367. SELECT
  1368. a.site,
  1369. a.bu_no,
  1370. a.itemNo,
  1371. a.ItemDesc,
  1372. a.ItemRemark
  1373. FROM eam_properties_item a
  1374. 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
  1375. <where>
  1376. a.ItemType = #{functionType}
  1377. and a.site = #{site} and a.bu_no = #{buNo}
  1378. AND b.code_no is null
  1379. <if test = "itemNo != null and itemNo != ''">
  1380. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1381. </if>
  1382. <if test = "itemDesc != null and itemDesc != ''">
  1383. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1384. </if>
  1385. </where>
  1386. </select>
  1387. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1388. select
  1389. a.site,
  1390. a.bu_no,
  1391. a.properties_item_no itemNo,
  1392. b.ItemDesc,
  1393. b.ItemRemark
  1394. from eam_properties_model_detail a
  1395. 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
  1396. where a.site = #{site} and a.bu_no = #{buNo} and a.code_no = #{codeNo}
  1397. and a.function_type = #{functionType}
  1398. </select>
  1399. <delete id="deleteObjectFile">
  1400. delete from sys_oss where id = #{id}
  1401. </delete>
  1402. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1403. SELECT id, url, create_date, file_name, new_file_name, created_by,
  1404. order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1405. FROM sys_oss
  1406. WHERE order_ref2 = #{orderNo}
  1407. AND order_ref1 = #{site}
  1408. AND order_ref3 = 'reportSparPart'
  1409. </select>
  1410. <!-- 获取机修人员列表 -->
  1411. <select id="getOperatorList" resultType="EamAdminData" parameterType="EamAdminData">
  1412. SELECT
  1413. ea.AdminID,
  1414. ea.AdminName,
  1415. ea.Phone,
  1416. dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName,
  1417. ea.Email,
  1418. ea.Tel,
  1419. ea.LevelID,
  1420. eal.AdminLevelDesc,
  1421. ea.MesUser,
  1422. ea.Active,
  1423. ea.CreatedDate
  1424. FROM eam_admin as ea
  1425. LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1426. <where>
  1427. ea.Active = 'Y'
  1428. AND ea.Site = #{site}
  1429. <if test = "adminID != null and adminID != ''">
  1430. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1431. </if>
  1432. <if test = "adminName != null and adminName != ''">
  1433. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1434. </if>
  1435. </where>
  1436. </select>
  1437. <!-- 获取审核人员列表 -->
  1438. <select id="getCheckerList" resultType="EamAdminData" parameterType="EamAdminData">
  1439. SELECT
  1440. a.user_id,
  1441. a.username as adminID,
  1442. a.email,
  1443. a.mobile as phone,
  1444. a.user_display as adminName,
  1445. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  1446. d.role_id,
  1447. e.role_name
  1448. FROM sys_user as a
  1449. LEFT JOIN eam_access_site as b on a.username = b.username
  1450. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  1451. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  1452. LEFT JOIN sys_role as e on d.role_id = e.role_id
  1453. <where>
  1454. b.site = #{site} and c.bu_no = #{buNo}
  1455. <if test = "adminID != null and adminID != ''">
  1456. AND a.username LIKE '%' + #{adminID}+'%'
  1457. </if>
  1458. <if test = "adminName != null and adminName != ''">
  1459. AND a.user_display LIKE '%' + #{adminName}+'%'
  1460. </if>
  1461. <if test = "buDesc != null and buDesc != ''">
  1462. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc}+'%'
  1463. </if>
  1464. <if test = "roleName != null and roleName != ''">
  1465. AND e.role_name LIKE '%' + #{roleName}+'%'
  1466. </if>
  1467. </where>
  1468. </select>
  1469. <!-- 点检工单审核 -->
  1470. <update id="checkWorkOrder" parameterType="EamWorkOrderInData">
  1471. UPDATE eam_workOrder
  1472. SET Status = '已完工'
  1473. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1474. </update>
  1475. <update id="cancelCheckWorkOrder" parameterType="EamWorkOrderInData">
  1476. UPDATE eam_workOrder
  1477. SET Status = '待审核'
  1478. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1479. </update>
  1480. <!-- 查看点检工单状态 -->
  1481. <select id="checkWorkOrderStatus" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1482. SELECT
  1483. OrderNo
  1484. FROM eam_workOrder
  1485. WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' and bu_no = #{buNo}
  1486. </select>
  1487. <!-- 点检工单审核 -->
  1488. <update id="updateWorkPlanOverviewStatus" parameterType="EamWorkOrderInData">
  1489. UPDATE eam_workPlan_overview
  1490. SET status = '已结束'
  1491. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1492. </update>
  1493. <!-- 新增点检计划 -->
  1494. <insert id="saveWorkPlan" parameterType="EamWorkPlanInData">
  1495. INSERT INTO eam_workPlan_overview
  1496. (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)
  1497. 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})
  1498. </insert>
  1499. <!-- 生成工单ID -->
  1500. <select id="selectOrderId" resultType="string" parameterType="EamWorkPlanInData">
  1501. SELECT
  1502. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1503. FROM eam_workPlan
  1504. WHERE site = #{site} AND FunctionType = #{functionType} and bu_no = #{buNo}
  1505. </select>
  1506. <!-- 查询计划中的设备列表 -->
  1507. <select id="getPlanDetailList" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1508. SELECT
  1509. ewp.PlanID,
  1510. ewp.PlanDesc,
  1511. ewp.ObjectID,
  1512. eo.ObjectDesc,
  1513. eo.FamilyID,
  1514. ef.FamilyDesc,
  1515. eo.LocationID,
  1516. el.LocationName
  1517. FROM eam_workPlan as ewP
  1518. LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site and ewP.bu_no = eo.bu_no
  1519. LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site and ewP.bu_no = ef.bu_no
  1520. LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site and ewP.bu_no = el.bu_no
  1521. <where>
  1522. ewP.site = #{site} and ewP.bu_no = #{buNo}
  1523. AND ewp.PlanID = #{planID}
  1524. <if test = "objectID != null and objectID != ''">
  1525. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  1526. </if>
  1527. <if test = "objectDesc != null and objectDesc != ''">
  1528. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  1529. </if>
  1530. </where>
  1531. </select>
  1532. <!-- 删除计划中的设备 -->
  1533. <delete id="delPlanDetail" parameterType="WorkPlanDetailData">
  1534. DELETE FROM eam_workPlan
  1535. WHERE Site = #{site}
  1536. AND PlanID = #{planID}
  1537. AND ObjectID = #{objectID}
  1538. </delete>
  1539. <!-- 获取当前计划不包含的设备 -->
  1540. <select id="getObjList1" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1541. SELECT
  1542. a.ObjectID,
  1543. a.ObjectDesc,
  1544. a.FamilyID,
  1545. ef.FamilyDesc,
  1546. a.LocationID,
  1547. el.LocationName
  1548. FROM eam_object a
  1549. 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
  1550. LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1551. LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1552. WHERE a.site = #{site} and a.bu_no = #{buNo} and b.PlanID is null
  1553. </select>
  1554. <!-- 获取当前计划包含的设备 -->
  1555. <select id="getObjList2" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1556. SELECT
  1557. a.ObjectID,
  1558. b.ObjectDesc,
  1559. b.FamilyID,
  1560. ef.FamilyDesc,
  1561. b.LocationID,
  1562. el.LocationName
  1563. FROM eam_workPlan a
  1564. LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1565. LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site and a.bu_no = ef.bu_no
  1566. LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site and a.bu_no = el.bu_no
  1567. WHERE a.PlanID = #{planID} and a.site = #{site} and a.bu_no = #{buNo}
  1568. </select>
  1569. <!-- 添加计划设备 -->
  1570. <insert id="addObject" parameterType="EamWorkPlanInData">
  1571. INSERT INTO eam_workPlan
  1572. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  1573. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  1574. </insert>
  1575. <!-- 修改工单计划 -->
  1576. <update id="updateWorkPlan" parameterType="EamWorkPlanInData">
  1577. UPDATE eam_workPlan_overview
  1578. SET plan_desc = #{planDesc},
  1579. properties_code = #{propertiesCode},
  1580. plan_start_date = #{planStartDate},
  1581. plan_end_date = #{planEndDate},
  1582. plan_period = #{planPeriod},
  1583. remark = #{remark},
  1584. operator = #{operator},
  1585. operator_name = #{operatorName},
  1586. checker = #{checker},
  1587. checker_name = #{checkerName},
  1588. work_order_rule = #{workOrderRule},
  1589. task_start_date = #{taskStartDate},
  1590. plan_cycle = #{planCycle},
  1591. plan_halt_date = #{planHaltDate},
  1592. auto_renewal = #{autoRenewal}
  1593. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1594. </update>
  1595. <!-- 删除该计划的旧设备 -->
  1596. <delete id="delWorkPlanObject" parameterType="EamWorkPlanInData">
  1597. DELETE FROM eam_workPlan
  1598. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1599. </delete>
  1600. <!-- 删除该计划的旧设备item -->
  1601. <delete id="delWorkPlanItem" parameterType="EamWorkPlanInData">
  1602. DELETE FROM eam_workPlan_item
  1603. WHERE Site = #{site} AND PlanID = #{planID} and bu_no = #{buNo}
  1604. </delete>
  1605. <!-- 删除该计划的旧设备itemAvailable-->
  1606. <delete id="delWorkPlanItemAvailable">
  1607. DELETE FROM eam_workPlan_item_available
  1608. WHERE Site = #{site}
  1609. AND PlanID = #{planID}
  1610. AND ObjectID = #{objectID}
  1611. </delete>
  1612. <!-- 查询该计划的设备 -->
  1613. <select id="planObjectSearch" resultType="EamWorkPlanItemData" parameterType="EamWorkPlanItemData">
  1614. SELECT DISTINCT
  1615. a.ObjectID,
  1616. b.ObjectDesc
  1617. FROM eam_workPlan_item as a
  1618. LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  1619. WHERE a.Site = #{site} AND a.PlanID = #{planID} and a.bu_no = #{buNo}
  1620. </select>
  1621. <!-- 修改该计划状态 -->
  1622. <update id="updateOverviewStatus" parameterType="EamWorkPlanInData">
  1623. UPDATE eam_workPlan_overview
  1624. SET status = '进行中',
  1625. next_work_date = plan_start_date
  1626. WHERE site = #{site} AND plan_id = #{planID} and bu_no = #{buNo}
  1627. </update>
  1628. <!-- 查询文件路径 -->
  1629. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1630. SELECT
  1631. id,
  1632. url,
  1633. file_name
  1634. FROM sys_oss WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} and order_ref4 = #{buNo}
  1635. </select>
  1636. <!-- 新增子明细信息 -->
  1637. <insert id="saveOperator" parameterType="EamWorkOrderInData">
  1638. INSERT INTO eam_actual_operator
  1639. (site, order_no, function_type, operator, bu_no)
  1640. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}, #{buNo})
  1641. </insert>
  1642. <!-- AND Status = '已完工' AND PlanOperator is not null-->
  1643. <!-- 查询实际维修人员 -->
  1644. <select id="getActualOperatorList2" resultType="EamAdminData">
  1645. SELECT
  1646. ea.AdminID,
  1647. ea.AdminName
  1648. FROM eam_actual_operator as eao
  1649. LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site
  1650. LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo
  1651. WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID}
  1652. </select>
  1653. <!-- 查询实际维修人员 -->
  1654. <select id="getActualOperatorList" resultType="EamAdminData">
  1655. SELECT
  1656. ea.username as adminID,
  1657. ea.user_display as AdminName
  1658. FROM eam_actual_operator as eao
  1659. LEFT JOIN sys_user as ea ON eao.operator = ea.username
  1660. WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} and eao.bu_no = #{buNo}
  1661. </select>
  1662. <!-- 查询设备所属部门 -->
  1663. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  1664. SELECT ved.department_name
  1665. FROM eam_object as eo
  1666. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  1667. WHERE eo.site = #{site}
  1668. AND eo.ObjectID = #{objectID}
  1669. </select>
  1670. <!-- 查询用户所属部门 -->
  1671. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  1672. SELECT AdminID
  1673. FROM eam_admin
  1674. WHERE site = #{site}
  1675. AND MesUser = #{username}
  1676. </select>
  1677. <!-- &lt;!&ndash; 查询部门列表 &ndash;&gt;-->
  1678. <!-- <select id="getDeptList" resultType="string" parameterType="string">-->
  1679. <!-- SELECT-->
  1680. <!-- ved.department_name-->
  1681. <!-- FROM eam_admin_dept as ead-->
  1682. <!-- LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id-->
  1683. <!-- LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID-->
  1684. <!-- WHERE ead.site = #{site} AND ea.MesUser = #{username}-->
  1685. <!-- </select>-->
  1686. <!-- 查询部门列表 -->
  1687. <select id="getDeptList" resultType="string" parameterType="string">
  1688. SELECT
  1689. distinct c.department_name
  1690. from sys_user as a
  1691. left join Access_dept as b on a.username = b.username
  1692. left join sys_department as c on c.site in (select site from eam_access_site where username = #{username})
  1693. and (c.site + '-' + c.bu_no) in (select * from dbo.query_bu(#{username}))
  1694. and b.department_id = c.department_id
  1695. where a.username = #{username}
  1696. </select>
  1697. <!-- 生成新的维修工单 -->
  1698. <insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData">
  1699. INSERT INTO eam_workOrder
  1700. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no, document_source)
  1701. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}, #{documentSource})
  1702. </insert>
  1703. <!-- 创建count表 -->
  1704. <insert id="saveDefectRecordCount2" parameterType="EamWorkOrderInData">
  1705. INSERT INTO eam_workOrder_count
  1706. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no)
  1707. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo})
  1708. </insert>
  1709. <!-- 获取旧工单的基础信息 -->
  1710. <select id="queryOldWorkOrderMessage" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1711. select
  1712. PlanOperator,
  1713. PlanOperatorName,
  1714. checker,
  1715. checkerName
  1716. from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  1717. </select>
  1718. <!-- 生成新的维保工单 -->
  1719. <insert id="saveMaintenanceWorkOrder" parameterType="EamWorkOrderInData">
  1720. INSERT INTO eam_workOrder
  1721. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1722. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  1723. </insert>
  1724. <!-- 检查系统操作人和审核人员是否一致 -->
  1725. <select id="selectNameByMes" resultType="EamAdminData" parameterType="EamAdminData">
  1726. SELECT AdminName
  1727. FROM eam_admin
  1728. WHERE site = #{site}
  1729. AND MesUser = #{mesUser}
  1730. </select>
  1731. <!-- 维修审核确认 -->
  1732. <update id="submitDefect" parameterType="EamWorkOrderInData">
  1733. UPDATE eam_workOrder
  1734. SET Status = #{status},
  1735. difficulty_level = #{difficultyLevel},
  1736. difficulty_remark = #{difficultyRemark}
  1737. WHERE Site = #{site} AND OrderNo = #{orderNo} and bu_no = #{buNo}
  1738. </update>
  1739. <!-- 查询设备的点检和维保历史记录 -->
  1740. <select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1741. SELECT
  1742. top 10
  1743. ewo.OrderNo,
  1744. ewo.PlanID,
  1745. ewo.PlanDesc,
  1746. ewo.ActualDate,
  1747. ewo.ObjectID,
  1748. eo.ObjectDesc,
  1749. ewo.Remark,
  1750. dbo.eam_Get_eamAdminName(ewo.site,ewo.ActualOperator) ActualOperatorName,
  1751. ewo.checkResult
  1752. FROM eam_workOrder as ewo
  1753. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1754. WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND ewo.Status = '已完工' and ewo.bu_no = #{buNo}
  1755. ORDER BY ewo.ActualDate desc
  1756. </select>
  1757. <!-- 查询设备的维修历史记录 -->
  1758. <select id="queryDefectHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1759. SELECT
  1760. top 10
  1761. ewo.OrderNo,
  1762. ewo.PlanID,
  1763. ewo.PlanDesc,
  1764. ewo.ActualDate,
  1765. ewo.Remark,
  1766. ewo.Result,
  1767. ewo.disposal_measures,
  1768. ed.DefectDesc,
  1769. ewo.WorkTime
  1770. FROM eam_workOrder as ewo
  1771. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID and ewo.bu_no = eo.bu_no
  1772. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID and ewo.bu_no = edf.bu_no
  1773. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  1774. 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
  1775. </select>
  1776. <!-- 查询部门列表 -->
  1777. <select id="getEmpyDeptList" resultType="EmpyDept" parameterType="EmpyDept">
  1778. SELECT
  1779. site,
  1780. department_id as deptId,
  1781. department_name as deptName
  1782. FROM sys_department
  1783. <where>
  1784. site in (select site from eam_access_site where username = #{userName})
  1785. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  1786. <if test = "deptId != null and deptId != ''">
  1787. AND department_id LIKE '%' + #{deptId}+'%'
  1788. </if>
  1789. <if test = "deptName != null and deptName != ''">
  1790. AND department_name LIKE '%' + #{deptName}+'%'
  1791. </if>
  1792. </where>
  1793. </select>
  1794. <!-- 生成新的维修工单 -->
  1795. <insert id="saveAdminDepartment">
  1796. INSERT INTO eam_admin_dept
  1797. (Site, admin_id, dept_id)
  1798. VALUES (#{site}, #{adminID}, #{deptId})
  1799. </insert>
  1800. <!-- 查询部门详情 -->
  1801. <select id="getDeptDetail" resultType="EamAdminData" parameterType="string">
  1802. SELECT
  1803. ved.department_id as department,
  1804. ved.department_name as departmentName
  1805. FROM eam_admin_dept as ead
  1806. 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
  1807. WHERE ead.site in (select site from eam_access_site where username = #{userName})
  1808. and (ead.site + '-' + ead.bu_no) in (select * from dbo.query_bu(#{userName}))
  1809. AND ead.admin_id = #{adminID}
  1810. </select>
  1811. <!-- 删除旧数据-->
  1812. <delete id="deleteAdminDepartment">
  1813. DELETE FROM eam_admin_dept
  1814. WHERE site = #{site}
  1815. AND admin_id = #{adminID}
  1816. </delete>
  1817. <!-- 获取可用的MES账号 -->
  1818. <select id="getMesList" resultType="SysUserEntity" parameterType="SysUserEntity">
  1819. SELECT
  1820. a.username,
  1821. a.user_display
  1822. FROM sys_user a
  1823. LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site
  1824. WHERE a.site = #{site}
  1825. AND b.MesUser is null
  1826. </select>
  1827. <!-- 查询点检项目 -->
  1828. <select id="eamPropertiesItemSearch" parameterType="EamPropertiesItemData" resultType="EamPropertiesItemData">
  1829. SELECT
  1830. site,
  1831. bu_no,
  1832. dbo.get_bu_desc(site, bu_no) as buDesc,
  1833. ItemNo,
  1834. ItemDesc,
  1835. DefaultValue,
  1836. ValueType,
  1837. ValueType_DB as valueTypeDb,
  1838. ValueChooseFlag,
  1839. CreatedDate,
  1840. CreatedBy,
  1841. update_date,
  1842. update_by,
  1843. MaxValue,
  1844. MinValue,
  1845. ItemRemark,
  1846. ItemType,
  1847. image_flag,
  1848. produce_control_flag
  1849. FROM eam_properties_item
  1850. <where>
  1851. site in (select site from eam_access_site where username = #{query.userName})
  1852. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1853. and ItemType = #{query.itemType}
  1854. <if test="query.buDesc != null and query.buDesc != ''">
  1855. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  1856. </if>
  1857. <if test="query.itemNo != null and query.itemNo != ''">
  1858. AND ItemNo LIKE '%' + #{query.itemNo}+'%'
  1859. </if>
  1860. <if test="query.itemDesc != null and query.itemDesc != ''">
  1861. AND ItemDesc LIKE '%' + #{query.itemDesc}+'%'
  1862. </if>
  1863. </where>
  1864. </select>
  1865. <!-- 删除图片-->
  1866. <delete id="imageDelete" parameterType="SysOssEntity">
  1867. DELETE FROM sys_oss
  1868. WHERE id = #{id}
  1869. </delete>
  1870. <!-- 检查该日期内是否已有该设备的计划 -->
  1871. <select id="checkObjectPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1872. SELECT
  1873. a.PlanID,
  1874. a.ObjectID
  1875. FROM eam_workPlan a
  1876. 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
  1877. WHERE a.site = #{site} and a.bu_no = #{buNo}
  1878. AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N'
  1879. AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  1880. or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  1881. or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0)
  1882. )
  1883. and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod}
  1884. and b.Status not in ('已取消','已完成','待审核')
  1885. </select>
  1886. <!-- 查询当前计划 -->
  1887. <select id="queryWorkPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1888. SELECT
  1889. site,
  1890. bu_no,
  1891. plan_id,
  1892. plan_desc,
  1893. properties_code,
  1894. #{objectID} as objectID,
  1895. status,
  1896. operator,
  1897. delete_flag,
  1898. plan_start_date,
  1899. plan_end_date,
  1900. plan_period,
  1901. function_type,
  1902. checker,
  1903. checker_name,
  1904. operator_name,
  1905. work_order_rule,
  1906. plan_cycle
  1907. FROM eam_workPlan_overview
  1908. WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} and bu_no = #{buNo}
  1909. </select>
  1910. <!-- 获得工单号 -->
  1911. <select id="queryPlanOrderNo" resultType="string" parameterType="EamWorkPlanInData">
  1912. SELECT
  1913. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  1914. FROM eam_workOrder
  1915. WHERE site = #{site} and bu_no = #{buNo} AND FunctionType = #{functionType}
  1916. </select>
  1917. <!-- 新增工单 -->
  1918. <insert id="insertWorkOrder" parameterType="EamWorkPlanInData">
  1919. INSERT INTO eam_workOrder
  1920. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1921. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1922. </insert>
  1923. <!-- 循环新增工单 -->
  1924. <insert id="forInsertWorkOrder" parameterType="EamWorkPlanInData">
  1925. INSERT INTO eam_workOrder
  1926. (Site, bu_no, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1927. VALUES (#{site}, #{buNo}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1928. </insert>
  1929. <!-- 更改plan表的状态为进行中 -->
  1930. <update id="updatePlanStatus" parameterType="EamWorkPlanInData">
  1931. update eam_workPlan
  1932. set status = '进行中',
  1933. NextWorkDate = PlanStartDate
  1934. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1935. </update>
  1936. <!-- 获得工单号 -->
  1937. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="EamWorkOrderItemInData">
  1938. SELECT
  1939. id,
  1940. file_name
  1941. FROM sys_oss
  1942. WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  1943. </select>
  1944. <!-- 删除原来工单项目-->
  1945. <delete id="deleteWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1946. DELETE FROM eam_workPlan_item
  1947. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1948. </delete>
  1949. <!-- 删除原来的可选值-->
  1950. <delete id="deleteWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1951. DELETE FROM eam_workPlan_item_available
  1952. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} and bu_no = #{buNo}
  1953. </delete>
  1954. <!-- 添加新项目 -->
  1955. <insert id="saveWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1956. 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)
  1957. select
  1958. #{site},
  1959. #{buNo},
  1960. #{planID},
  1961. #{objectID},
  1962. a.ItemNo,
  1963. a.ItemDesc,
  1964. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  1965. case when c.site is not null then c.ValueType else a.ValueType end,
  1966. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  1967. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  1968. case when c.site is not null then c.MaxValue else a.MaxValue end,
  1969. case when c.site is not null then c.MinValue else a.MinValue end,
  1970. a.ItemRemark,
  1971. a.ItemType,
  1972. GetDate(),
  1973. #{userId},
  1974. a.image_flag,
  1975. a.produce_control_flag
  1976. from eam_properties_item a
  1977. 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
  1978. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  1979. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  1980. </insert>
  1981. <!-- 添加新项目可选值 -->
  1982. <insert id="saveWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1983. INSERT INTO eam_workPlan_item_available (Site, bu_no, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  1984. SELECT DISTINCT
  1985. #{site},
  1986. #{buNo},
  1987. #{planID},
  1988. #{objectID},
  1989. a.ItemNo,
  1990. a.ItemType,
  1991. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  1992. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  1993. GetDate(),
  1994. #{userId}
  1995. FROM eam_properties_item_available a
  1996. 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
  1997. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  1998. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} and a.site = #{site} and a.bu_no = #{buNo}
  1999. </insert>
  2000. <!-- 检查维修任务号是否已存在 -->
  2001. <select id="getEamGzData" resultType="EamDefectFeedBackData" parameterType="EamDefectFeedBackData">
  2002. select
  2003. a.Site,
  2004. a.bu_no,
  2005. a.FeedBackID,
  2006. a.FeedBackDesc,
  2007. a.ObjectID,
  2008. a.Status
  2009. from eam_defect_feedBack a
  2010. left join eam_defect b on a.DefectID = b.DefectID
  2011. <where>
  2012. a.site = #{site} and a.deleteFlag = 'N' and a.bu_no = #{buNo}
  2013. <if test="feedBackID != null and feedBackID != ''">
  2014. AND a.FeedBackID LIKE '%' + #{feedBackID}+'%'
  2015. </if>
  2016. <if test="feedBackDesc != null and feedBackDesc != ''">
  2017. AND a.FeedBackDesc LIKE '%' + #{feedBackDesc}+'%'
  2018. </if>
  2019. <if test="objectInfo != null and objectInfo != ''">
  2020. AND (a.ObjectID like '%' + #{objectInfo} + '%' or dbo.eam_Get_eamObjectDesc(a.Site, a.bu_no, a.ObjectID) like '%' + #{objectInfo} + '%')
  2021. </if>
  2022. <if test="defectInfo != null and defectInfo != ''">
  2023. AND (a.DefectID like '%' + #{defectInfo} + '%' or b.defectDesc like '%' + #{defectInfo} + '%')
  2024. </if>
  2025. </where>
  2026. </select>
  2027. <!-- 保存故障信息 -->
  2028. <insert id="saveEamGzBbData" parameterType="EamDefectFeedBackData">
  2029. INSERT INTO eam_defect_feedBack
  2030. (Site, bu_no, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate, Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency)
  2031. VALUES (#{site}, #{buNo}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate}, #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency})
  2032. </insert>
  2033. <!-- 查看现场动控是否开启 -->
  2034. <select id="selectControlBaseData" resultType="SysSceneDynamicControlModelEntity" parameterType="string">
  2035. SELECT
  2036. type,
  2037. base_data,
  2038. base_desc,
  2039. status,
  2040. remark,
  2041. third_type,
  2042. second_type,
  2043. page_control,
  2044. control_style
  2045. FROM sys_scene_dynamic_control_model
  2046. where site = #{site} and control_no = #{controlNo}
  2047. </select>
  2048. <!-- 修改反馈状态为已下达 -->
  2049. <update id="updateDefectFeedBackStatus" parameterType="EamDefectFeedBackData">
  2050. UPDATE eam_defect_feedBack
  2051. SET Status = '已下达'
  2052. WHERE Site = #{site} AND FeedBackID = #{feedBackID} and bu_no = #{buNo}
  2053. </update>
  2054. <!-- 查询工单号 -->
  2055. <select id="getOrderNo" resultType="string" parameterType="EamWorkOrderInData">
  2056. select
  2057. 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  2058. from eam_workOrder
  2059. where site = #{site} and FunctionType = 'C' and bu_no = #{buNo}
  2060. </select>
  2061. <!-- 创建维修工单 -->
  2062. <insert id="saveWorkOrder" parameterType="EamDefectFeedBackData">
  2063. INSERT INTO eam_workOrder
  2064. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc, document_source)
  2065. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}, #{documentSource})
  2066. </insert>
  2067. <!-- 创建维修count表数据 -->
  2068. <insert id="saveDefectRecordCount" parameterType="EamDefectFeedBackData">
  2069. INSERT INTO eam_workOrder_count
  2070. (Site, bu_no, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc)
  2071. VALUES (#{site}, #{buNo}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc})
  2072. </insert>
  2073. <!-- 修改工单 -->
  2074. <update id="updateWorkOrder" parameterType="EamWorkOrderInData">
  2075. update eam_workOrder
  2076. set update_by = #{mesUser},
  2077. update_date = GetDate(),
  2078. Remark = #{remark},
  2079. reach_date = #{reachDate},
  2080. ActualDate = #{actualDate},
  2081. WorkTime = #{workTime},
  2082. <if test='functionType == "B" and checkResult == "合格"'>
  2083. disposal_measures = '',
  2084. </if>
  2085. <if test='functionType == "B" and checkResult == "异常"'>
  2086. disposal_measures = #{disposalMeasures},
  2087. </if>
  2088. checkResult = #{checkResult},
  2089. check_remark = #{checkRemark},
  2090. fault_reason = #{faultReason},
  2091. preventive_measure = #{preventiveMeasure}
  2092. where site = #{site} and orderNo = #{orderNo} and bu_no = #{buNo}
  2093. </update>
  2094. <!-- 修改工单项目 -->
  2095. <update id="updateWorkOrderItem" parameterType="EamWorkOrderItemInData">
  2096. update eam_workOrder_item
  2097. set update_by = #{updateBy},
  2098. update_date = GetDate(),
  2099. <if test='valueTypeDb == "T"'>
  2100. TextValue = #{textValue},
  2101. </if>
  2102. <if test='valueTypeDb == "N"'>
  2103. NumberValue = #{numberValue},
  2104. </if>
  2105. itemResult = #{itemResult}
  2106. where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} and bu_no = #{buNo}
  2107. </update>
  2108. <!-- 删除之前的协同人员-->
  2109. <delete id="delOperator" parameterType="EamWorkOrderInData">
  2110. DELETE FROM eam_actual_operator
  2111. WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} and bu_no = #{buNo}
  2112. </delete>
  2113. <!-- 到达 -->
  2114. <update id="reach" parameterType="EamWorkOrderInData">
  2115. update eam_workOrder
  2116. set Status = #{status},
  2117. reach_date = GetDate(),
  2118. reach_operator = #{reachOperator},
  2119. reach_operator_name = #{reachOperatorName}
  2120. where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} and bu_No = #{buNo}
  2121. </update>
  2122. <!-- 查询是否已经上传图片 -->
  2123. <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2124. SELECT
  2125. id
  2126. FROM sys_oss
  2127. where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo}
  2128. </select>
  2129. <!-- 查询文件路径 -->
  2130. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderItemData">
  2131. SELECT
  2132. id,
  2133. url,
  2134. file_name
  2135. FROM sys_oss
  2136. WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2137. </select>
  2138. <!-- 根据工单号查询知识库记录 -->
  2139. <select id="selectKnowledgeRecordByOrderNo" resultType="EamKnowledgeBaseData" parameterType="EamWorkOrderInData">
  2140. SELECT
  2141. site,
  2142. bu_no,
  2143. num
  2144. FROM eam_knowledge_base
  2145. WHERE site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2146. </select>
  2147. <!-- 根据工单号修改知识库记录 -->
  2148. <update id="updateKnowledgeRecordByOrderNo" parameterType="EamWorkOrderInData">
  2149. update eam_knowledge_base
  2150. set update_date = getDate(),
  2151. update_by = #{updateBy}
  2152. where site = #{site} and order_no = #{orderNo} and bu_no = #{buNo}
  2153. </update>
  2154. <!-- 新增设备知识库记录 -->
  2155. <insert id="saveKnowledgeRecord" parameterType="EamWorkOrderInData">
  2156. INSERT INTO eam_knowledge_base
  2157. (site, bu_no, num, file_type, defect_describe, disposal_measures, create_date, create_by, object_id, defect_id, order_no)
  2158. 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})
  2159. </insert>
  2160. <!-- 修改反馈状态为已取消 -->
  2161. <update id="updateFeedBackStatus" parameterType="EamWorkOrderInData">
  2162. UPDATE eam_defect_feedBack
  2163. SET Status = '已取消'
  2164. WHERE Site = #{site} AND FeedBackID = #{planID} and bu_no = #{buNo}
  2165. </update>
  2166. <!-- 获取所有分类 -->
  2167. <select id="getFamilyTree" resultType="EamFamilyData" parameterType="EamFamilyData">
  2168. SELECT
  2169. site,
  2170. bu_no,
  2171. FamilyID,
  2172. FamilyDesc,
  2173. parent_id,
  2174. son_id,
  2175. Active
  2176. FROM eam_family
  2177. WHERE site in (select site from eam_access_site where username = #{userName})
  2178. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{userName}))
  2179. and Active = 'Y'
  2180. </select>
  2181. <!-- 获得sonId -->
  2182. <select id="getSonId" resultType="string" parameterType="EamFamilyData">
  2183. SELECT
  2184. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2)
  2185. FROM eam_family
  2186. WHERE site = #{site} and bu_no = #{buNo} and son_id like #{parentId} + '%'
  2187. </select>
  2188. <!-- 删除该分类以及其子类-->
  2189. <delete id="eamFamilyDelete" parameterType="EamFamilyData">
  2190. DELETE FROM eam_family
  2191. WHERE site = #{site} and bu_no = #{buNo} and FamilyID = #{familyID}
  2192. <if test="sonId != null and sonId != ''">
  2193. and son_id like #{sonId} + '%'
  2194. </if>
  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 = #{workTime}
  2209. where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} and bu_no = #{buNo}
  2210. </update>
  2211. <!-- 根据设备查所属部门 -->
  2212. <select id="queryDepartmentByObjectId" resultType="EamObjectAdminData" parameterType="EamDefectFeedBackData">
  2213. SELECT
  2214. eo.site,
  2215. eo.bu_no,
  2216. eo.ObjectDesc,
  2217. eo.dept_id,
  2218. el.LocationName
  2219. FROM eam_object as eo
  2220. LEFT JOIN eam_location as el on eo.site = el.site and eo.LocationID = el.LocationID and eo.bu_no = el.bu_no
  2221. WHERE eo.site = #{site} and eo.ObjectID = #{objectID} and eo.bu_no = #{buNo}
  2222. </select>
  2223. <!-- 根据部门ID查机修人员电话 -->
  2224. <select id="queryPhoneByDepartmentId" resultType="EamObjectAdminData" parameterType="EamObjectAdminData">
  2225. SELECT
  2226. ed.user_display as adminName,
  2227. ed.mobile as phone
  2228. FROM Access_dept as edd
  2229. LEFT JOIN sys_user ed on edd.username = ed.username and edd.site in (select site from eam_access_site where username = ed.username)
  2230. and (edd.site + '-' + edd.bu_no) in (select * from dbo.query_bu(ed.username))
  2231. WHERE edd.site = #{site} and edd.department_id = #{deptId} and edd.bu_no = #{buNo} and ed.mobile is not null
  2232. </select>
  2233. <!-- 保存短信记录 -->
  2234. <insert id="saveMessageRecord" parameterType="MessageRecordData">
  2235. INSERT INTO send_message_record (site, bu_no, plan_id, object_id, defect_id, feed_back_desc, sender, recipient, phone, send_date)
  2236. VALUES (#{site}, #{buNo}, #{planId}, #{objectId}, #{defectId}, #{feedBackDesc}, #{sender}, #{recipient}, #{phone}, getDate())
  2237. </insert>
  2238. <!-- 查出计划结束日期为今天并且自动续期标识为Y的计划 -->
  2239. <select id="selectPlanToday" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  2240. SELECT
  2241. site,
  2242. plan_id,
  2243. plan_desc,
  2244. status,
  2245. plan_start_date,
  2246. plan_end_date,
  2247. created_date,
  2248. created_by,
  2249. update_date,
  2250. update_by,
  2251. remark,
  2252. next_work_date,
  2253. delete_flag,
  2254. operator,
  2255. operator_name,
  2256. checker,
  2257. checker_name,
  2258. function_type,
  2259. properties_code,
  2260. plan_period,
  2261. work_order_rule,
  2262. plan_cycle,
  2263. task_start_date,
  2264. plan_halt_date,
  2265. auto_renewal
  2266. FROM eam_workPlan_overview
  2267. WHERE site = #{site} and status != #{status} and delete_flag = #{deleteFlag} and DATEDIFF(day, plan_end_date, getdate()) = 0 and auto_renewal = #{autoRenewal}
  2268. </select>
  2269. <!-- 查出老计划的设备 -->
  2270. <select id="selectObjectByPlanID" resultType="EamObjectInData" parameterType="EamWorkPlanInData">
  2271. SELECT
  2272. Site,
  2273. PlanID,
  2274. PlanDesc,
  2275. ObjectID,
  2276. FunctionType,
  2277. PropertiesCode,
  2278. Status
  2279. FROM eam_workPlan
  2280. WHERE site = #{site} and PlanID = #{planID} and FunctionType = #{functionType}
  2281. </select>
  2282. <!-- 获取用户 bu -->
  2283. <select id="getSiteAndBuByUserName" resultType="BuData" parameterType="BuData">
  2284. SELECT
  2285. a.site,
  2286. c.sitename,
  2287. (a.site + '_' + a.bu_no) as buNo,
  2288. b.bu_desc
  2289. FROM AccessBu as a
  2290. left join bu as b on a.bu_no = b.bu_no and a.site = b.site
  2291. left join site as c on a.site = c.siteid
  2292. WHERE a.username = #{username}
  2293. </select>
  2294. </mapper>