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.

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