O
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.

1915 lines
73 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
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
  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
  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
  22. ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  23. <where>
  24. <if test="query.site != null and query.site != ''">
  25. AND ea.site = #{query.site}
  26. </if>
  27. <if test="query.adminID != null and query.adminID != ''">
  28. AND ea.adminID like '%' + #{query.adminID} +'%'
  29. </if>
  30. <if test="query.adminName != null and query.adminName != ''">
  31. AND ea.adminName like '%' + #{query.adminName}+'%'
  32. </if>
  33. <if test="query.active != null and query.active != ''">
  34. AND ea.active = #{query.active}
  35. </if>
  36. </where>
  37. </select>
  38. <select id="eamFamilySearch" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData" resultType="com.xujie.sys.modules.pms.data.EamFamilyData">
  39. SELECT
  40. Site,
  41. FamilyID,
  42. FamilyDesc,
  43. Active,
  44. create_date,
  45. create_by,
  46. update_date,
  47. update_by
  48. FROM eam_family
  49. <where>
  50. <if test="query.site != null and query.site != ''">
  51. AND site = #{query.site}
  52. </if>
  53. <if test="query.familyID != null and query.familyID != ''">
  54. AND familyID like '%' + #{query.familyID} +'%'
  55. </if>
  56. <if test="query.familyDesc != null and query.familyDesc != ''">
  57. AND familyDesc like '%' + #{query.familyDesc} +'%'
  58. </if>
  59. <if test="query.active != null and query.active != ''">
  60. AND active = #{query.active}
  61. </if>
  62. </where>
  63. </select>
  64. <select id="eamGroupSearch" parameterType="com.xujie.sys.modules.pms.data.EamGroupData" resultType="com.xujie.sys.modules.pms.data.EamGroupData">
  65. SELECT
  66. Site,
  67. GroupID,
  68. GroupDesc,
  69. Active,
  70. create_date,
  71. create_by,
  72. update_date,
  73. update_by
  74. FROM eam_group
  75. <where>
  76. <if test="query.site != null and query.site != ''">
  77. AND site = #{query.site}
  78. </if>
  79. <if test="query.groupID != null and query.groupID != ''">
  80. AND groupID like '%' + #{query.groupID}
  81. </if>
  82. <if test="query.groupDesc != null and query.groupDesc != ''">
  83. AND groupDesc like '%' + #{query.groupDesc}
  84. </if>
  85. <if test="query.active != null and query.active != ''">
  86. AND active = #{query.active}
  87. </if>
  88. </where>
  89. </select>
  90. <select id="eamLocationSearch" parameterType="com.xujie.sys.modules.pms.data.EamLocationData" resultType="com.xujie.sys.modules.pms.data.EamLocationData">
  91. SELECT
  92. Site,
  93. LocationID,
  94. LocationName,
  95. Active,
  96. create_date,
  97. create_by,
  98. update_date,
  99. update_by
  100. FROM eam_location
  101. <where>
  102. <if test="query.site != null and query.site != ''">
  103. AND site = #{query.site}
  104. </if>
  105. <if test="query.locationID != null and query.locationID != ''">
  106. AND locationID like '%' + #{query.locationID} +'%'
  107. </if>
  108. <if test="query.locationName != null and query.locationName != ''">
  109. AND locationName like '%' + #{query.locationName} +'%'
  110. </if>
  111. <if test="query.active != null and query.active != ''">
  112. AND active = #{query.active}
  113. </if>
  114. </where>
  115. </select>
  116. <select id="eamManufacturerSearch" parameterType="com.xujie.sys.modules.pms.data.EamManufacturerData" resultType="com.xujie.sys.modules.pms.data.EamManufacturerData">
  117. SELECT
  118. Site,
  119. ManufacturerID,
  120. ManufacturerName,
  121. Active,
  122. Contact,
  123. Phone,
  124. Address,
  125. Email,
  126. Remark,
  127. create_date,
  128. create_by,
  129. update_date,
  130. update_by
  131. FROM eam_manufacturer
  132. <where>
  133. <if test="query.site != null and query.site != ''">
  134. AND site = #{query.site}
  135. </if>
  136. <if test="query.manufacturerID != null and query.manufacturerID != ''">
  137. AND manufacturerID like '%' + #{query.manufacturerID} +'%'
  138. </if>
  139. <if test="query.manufacturerName != null and query.manufacturerName != ''">
  140. AND manufacturerName like '%' + #{query.manufacturerName} +'%'
  141. </if>
  142. <if test="query.active != null and query.active != ''">
  143. AND active = #{query.active}
  144. </if>
  145. </where>
  146. </select>
  147. <select id="eamAdminLevelSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminLevelData" resultType="com.xujie.sys.modules.pms.data.EamAdminLevelData">
  148. SELECT
  149. Site,
  150. AdminLevelID,
  151. AdminLevelDesc,
  152. Active,
  153. create_date,
  154. create_by,
  155. update_date,
  156. update_by
  157. FROM eam_adminLevel
  158. <where>
  159. <if test="query.site != null and query.site != ''">
  160. AND site = #{query.site}
  161. </if>
  162. <if test="query.adminLevelID != null and query.adminLevelID != ''">
  163. AND adminLevelID like '%' + #{query.adminLevelID} +'%'
  164. </if>
  165. <if test="query.adminLevelDesc != null and query.adminLevelDesc != ''">
  166. AND adminLevelDesc like '%' + #{query.adminLevelDesc}+'%'
  167. </if>
  168. <if test="query.active != null and query.active != ''">
  169. AND active = #{query.active}
  170. </if>
  171. </where>
  172. </select>
  173. <select id="eamSupplierSearch" parameterType="com.xujie.sys.modules.pms.data.EamSupplierData" resultType="com.xujie.sys.modules.pms.data.EamSupplierData">
  174. SELECT
  175. Site,
  176. SupplierID,
  177. SupplierName,
  178. [Group],
  179. Active,
  180. Contact,
  181. Phone,
  182. Address,
  183. Email,
  184. Remark,
  185. create_date,
  186. create_by,
  187. update_date,
  188. update_by
  189. FROM eam_supplier
  190. <where>
  191. <if test="query.site != null and query.site != ''">
  192. AND site = #{query.site}
  193. </if>
  194. <if test="query.supplierID != null and query.supplierID != ''">
  195. AND supplierID like '%' + #{query.supplierID} +'%'
  196. </if>
  197. <if test="query.supplierName != null and query.supplierName != ''">
  198. AND supplierName like '%' + #{query.supplierName} +'%'
  199. </if>
  200. <if test="query.active != null and query.active != ''">
  201. AND active = #{query.active}
  202. </if>
  203. </where>
  204. </select>
  205. <select id="searchItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemAvailableData">
  206. SELECT ItemNo,ValueNo,AvailableValue,CreatedDate,CreatedBy,ItemType
  207. from eam_properties_item_available where itemNo=#{itemNo} and ItemType=#{itemType}
  208. </select>
  209. <select id="getItemValueNo" resultType="Double">
  210. SELECT isnull( max(valueNo),0)+1 from eam_properties_item_available where itemNo=#{itemNo} and ItemType=#{itemType}
  211. </select>
  212. <select id="getItemValueNoForPlan" resultType="Double">
  213. SELECT isnull( max(valueNo),0)+1 from eam_workPlan_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and PlanID=#{planID}
  214. </select>
  215. <insert id="saveItemAvailable">
  216. insert into eam_properties_item_available (ItemNo,ValueNo,AvailableValue,CreatedDate,CreatedBy,ItemType)
  217. values(#{itemNo},#{valueNo},#{availableValue},GetDate(),#{createdBy},#{itemType})
  218. </insert>
  219. <update id="updateItemAvailable">
  220. update eam_properties_item_available set AvailableValue=#{availableValue} where itemNo=#{itemNo} and ItemType=#{itemType} and ValueNo=#{valueNo}
  221. </update>
  222. <delete id="deleteItemAvailable">
  223. delete from eam_properties_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and ValueNo=#{valueNo}
  224. </delete>
  225. <select id="eamPropertiesModelSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  226. SELECT
  227. function_type,
  228. code_no,
  229. code_desc,
  230. active,
  231. created_date,
  232. created_by,
  233. update_date,
  234. update_by,
  235. delflag,
  236. version
  237. FROM eam_properties_model_header
  238. <where>
  239. <if test="query.codeNo != null and query.codeNo != ''">
  240. AND code_no like '%' + #{query.codeNo} +'%'
  241. </if>
  242. <if test="query.codeDesc != null and query.codeDesc != ''">
  243. AND code_desc like '%' + #{query.codeDesc}+'%'
  244. </if>
  245. <if test="query.active != null and query.active != ''">
  246. AND active = #{query.active}
  247. </if>
  248. and function_type =#{query.functionType}
  249. </where>
  250. </select>
  251. <insert id="eamPropertiesModelSave" >
  252. insert into eam_properties_model_header
  253. (function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by)
  254. values(#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy})
  255. </insert>
  256. <update id="eamPropertiesModelEdit">
  257. update eam_properties_model_header
  258. set version = version + 1,
  259. code_desc = #{codeDesc},
  260. active = #{active},
  261. update_by = #{updateBy},
  262. update_date = GetDate()
  263. where function_type = #{functionType}
  264. and code_no = #{codeNo}
  265. </update>
  266. <select id="checkPropertiesModel" resultType="EamPropertiesModelHeaderData">
  267. SELECT function_type,code_no,code_desc,active,created_date,created_by,update_date,update_by,delflag,version FROM eam_properties_model_header
  268. where function_type=#{functionType} and code_no=#{codeNo}
  269. </select>
  270. <delete id="eamPropertiesModelDelete" >
  271. delete from eam_properties_model_header where function_type=#{functionType} and code_no=#{codeNo}
  272. </delete>
  273. <select id="searchModalDetails" resultType="EamPropertiesModelDetailData">
  274. SELECT a.function_type,a.code_no,a.properties_item_no itemNo,a.seq_no,b.ItemDesc
  275. ,b.DefaultValue,b.ValueType,b.ValueType_DB,b.ValueChooseFlag,b.MaxValue,
  276. b.MinValue,b.ItemRemark,b.ItemType
  277. FROM eam_properties_model_detail a
  278. left join eam_properties_item b on a.function_type=b.itemType and a.properties_item_no=b.itemNo
  279. where a.function_type=#{functionType} and a.code_no=#{codeNo}
  280. </select>
  281. <select id="checkItem" resultType="EamPropertiesModelDetailData">
  282. SELECT
  283. ItemDesc
  284. FROM eam_properties_item
  285. where itemType = #{functionType}
  286. and itemNo = #{itemNo}
  287. </select>
  288. <select id="checkModalDetails" resultType="EamPropertiesModelDetailData">
  289. SELECT
  290. a.function_type,
  291. a.code_no,
  292. a.properties_item_no itemNo,
  293. a.seq_no
  294. FROM eam_properties_model_detail a
  295. where a.function_type = #{functionType}
  296. and a.code_no = #{codeNo}
  297. and properties_item_no = #{itemNo}
  298. </select>
  299. <select id="getModalDetailSeqNo" resultType="Integer">
  300. SELECT
  301. isnull(max(seq_no),0) + 1
  302. from eam_properties_model_detail
  303. where function_type = #{functionType} and code_no = #{codeNo}
  304. </select>
  305. <insert id="saveModalDetails" >
  306. insert into eam_properties_model_detail
  307. (function_type,code_no,properties_item_no,seq_no,created_date,created_by,delflag,version)
  308. values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0)
  309. </insert>
  310. <delete id="deleteModalDetails" >
  311. delete from eam_properties_model_detail
  312. where function_type = #{functionType}
  313. and code_no = #{codeNo}
  314. and properties_item_no = #{itemNo}
  315. </delete>
  316. <select id="eamWorkPlanOverviewSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  317. SELECT
  318. a.site,
  319. a.plan_id,
  320. a.plan_desc,
  321. a.status,
  322. a.plan_start_date,
  323. a.plan_end_date,
  324. a.created_date,
  325. a.created_by,
  326. a.update_date,
  327. a.update_by,
  328. a.remark,
  329. a.next_work_date,
  330. a.delete_flag,
  331. a.operator,
  332. a.operator_name,
  333. a.checker,
  334. a.checker_name,
  335. a.function_type,
  336. a.properties_code,
  337. a.plan_period,
  338. d.code_desc,
  339. a.work_order_rule,
  340. a.plan_cycle
  341. FROM eam_workPlan_overview a
  342. LEFT JOIN eam_properties_model_header d
  343. ON a.function_type = d.function_type and a.properties_code = d.code_no
  344. <where>
  345. a.delete_flag = 'N'
  346. AND a.function_type = #{query.functionType}
  347. <if test="query.planID != null and query.planID != ''">
  348. AND a.plan_id like '%' + #{query.planID} +'%'
  349. </if>
  350. <if test="query.planDesc != null and query.planDesc != ''">
  351. AND a.plan_desc like '%' + #{query.planDesc}+'%'
  352. </if>
  353. <if test="query.status != null and query.status != ''">
  354. AND a.status = #{query.status}
  355. </if>
  356. <if test="query.startDate != null ">
  357. AND a.plan_start_date >= #{query.startDate}
  358. </if>
  359. <if test="query.endDate != null ">
  360. AND #{query.endDate} >= a.plan_start_date
  361. </if>
  362. </where>
  363. ORDER BY a.created_date DESC
  364. </select>
  365. <select id="eamWorkPlanSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  366. SELECT
  367. a.Site,
  368. a.PlanID,
  369. a.PlanDesc,
  370. a.ObjectID,
  371. a.FunctionType,
  372. a.PropertiesCode,
  373. a.Operator,
  374. a.checker,
  375. a.PlanPeriod,
  376. a.Status,
  377. a.PlanStartDate,
  378. a.PlanEndDate,
  379. a.CreatedDate,
  380. a.CreatedBy,
  381. a.UpdateDate,
  382. a.UpdateBy,
  383. a.Version,
  384. a.Remark,
  385. a.NextWorkDate,
  386. b.ObjectDesc,
  387. d.code_desc
  388. FROM eam_workPlan a
  389. left join eam_object b on a.Site = b.Site and a.ObjectID = b.ObjectID
  390. left join eam_properties_model_header d on a.FunctionType = d.function_type and a.PropertiesCode = d.code_no
  391. <where>
  392. AND a.DeleteFlag = 'N'
  393. AND a.FunctionType = #{query.functionType}
  394. <if test="query.planID != null and query.planID != ''">
  395. AND a.PlanID like '%' + #{query.planID} +'%'
  396. </if>
  397. <if test="query.planDesc != null and query.planDesc != ''">
  398. AND a.PlanDesc like '%' + #{query.planDesc}+'%'
  399. </if>
  400. <if test="query.status != null and query.status != ''">
  401. AND a.status = #{query.status}
  402. </if>
  403. <if test="query.startDate != null ">
  404. AND a.PlanStartDate >= #{query.startDate}
  405. </if>
  406. <if test="query.endDate != null ">
  407. AND #{query.endDate} >= a.PlanStartDate
  408. </if>
  409. </where>
  410. </select>
  411. <select id="selectNameById" resultType="string" parameterType="string">
  412. SELECT
  413. AdminName
  414. FROM eam_admin
  415. WHERE AdminID = #{s}
  416. </select>
  417. <select id="searchPlanItems" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData">
  418. SELECT
  419. a.Site,
  420. a.PlanID,
  421. a.ItemNo,
  422. a.ItemDesc,
  423. a.DefaultValue,
  424. a.ValueType,
  425. a.ValueType_DB,
  426. a.ValueChooseFlag,
  427. a.UpdateDate,
  428. a.UpdateBy,
  429. a.MaxValue,
  430. a.MinValue,
  431. a.ItemRemark,
  432. a.ItemType,
  433. a.CreatedDate,
  434. a.CreatedBy,
  435. a.ObjectID
  436. FROM eam_workPlan_item a
  437. <where>
  438. and a.PlanID = #{planID}
  439. and a.Site = #{site}
  440. and a.ItemType = #{functionType}
  441. <if test = "objectID != null and objectID != ''">
  442. AND a.ObjectID = #{objectID}
  443. </if>
  444. </where>
  445. </select>
  446. <select id="searchPlanItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemAvailableData">
  447. SELECT
  448. Site,
  449. PlanID,
  450. ItemNo,
  451. ItemType,
  452. ValueNo,
  453. AvailableValue,
  454. CreatedDate,
  455. CreatedBy,
  456. UpdateDate,
  457. UpdateBy,
  458. ObjectID
  459. from eam_workPlan_item_available
  460. where PlanID = #{planID}
  461. and itemNo = #{itemNo}
  462. and site = #{site}
  463. and ItemType = #{itemType}
  464. and ObjectID = #{objectID}
  465. </select>
  466. <update id="updatePlanItems">
  467. update eam_workPlan_item
  468. set DefaultValue = #{defaultValue},
  469. ValueType = #{valueType},
  470. ValueType_DB = #{valueTypeDb},
  471. ValueChooseFlag = #{valueChooseFlag},
  472. UpdateDate = GetDate(),
  473. UpdateBy = #{createdBy},
  474. MaxValue = #{maxValue,jdbcType=FLOAT},
  475. MinValue = #{minValue,jdbcType=FLOAT},
  476. ItemRemark = #{itemRemark}
  477. where site = #{site}
  478. and planID = #{planID}
  479. and ItemType = #{itemType}
  480. and ItemNo = #{itemNo}
  481. and ObjectID = #{objectID}
  482. </update>
  483. <update id="updatePlanItemsForNull">
  484. update eam_workPlan_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  485. ,ValueChooseFlag=#{valueChooseFlag},UpdateDate=GetDate(),UpdateBy=#{createdBy},MaxValue=null,MinValue=null,
  486. ItemRemark=#{itemRemark}
  487. where site=#{site} and planID=#{planID} and ItemType=#{itemType}
  488. and ItemNo=#{itemNo}
  489. </update>
  490. <insert id="saveItemAvailableForPlan">
  491. insert into eam_workPlan_item_available
  492. (Site,PlanID,ItemNo,ValueNo,AvailableValue,CreatedDate,CreatedBy,ItemType,ObjectID)
  493. values(#{site},#{planID},#{itemNo},#{valueNo},#{availableValue},GetDate(),#{createdBy},#{itemType},#{objectID})
  494. </insert>
  495. <update id="updateItemAvailableForPlan">
  496. update eam_workPlan_item_available
  497. set AvailableValue = #{availableValue},
  498. updateBy = #{createdBy},
  499. updateDate = GetDate()
  500. where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID}
  501. </update>
  502. <delete id="deletePlanItemAvailable">
  503. delete from eam_workPlan_item_available
  504. where itemNo=#{itemNo} and ItemType=#{itemType} and ValueNo=#{valueNo} AND site=#{site} and planID=#{planID} and ObjectID = #{objectID}
  505. </delete>
  506. <select id="objectIDBlur" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  507. select objectID,ObjectDesc from eam_object where active='Y' and Site=#{site} and ObjectID=#{objectID}
  508. </select>
  509. <select id="modalCodeBlur" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData">
  510. select code_no,code_desc from eam_properties_model_header where active='Y' and function_type=#{functionType} and code_no=#{codeNo}
  511. </select>
  512. <select id="eamWorkOrderSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  513. SELECT
  514. a.Site,
  515. a.OrderNo,
  516. a.PlanID,
  517. a.PlanDesc,
  518. a.PropertiesCode,
  519. a.ObjectID,
  520. a.Status,
  521. a.PlanOperator,
  522. a.checker,
  523. a.ActualOperator,
  524. a.PlanDate,
  525. a.ActualDate,
  526. a.FunctionType,
  527. a.CreateDate,
  528. d.operator_name as createBy,
  529. a.Remark,
  530. a.StartTime,
  531. a.EndTime,
  532. a.WorkTime,
  533. a.PlanOperatorName,
  534. a.checkerName,
  535. dbo.eam_Get_eamAdminName(a.Site,a.ActualOperator) ActualOperatorName,
  536. dbo.eam_Get_eamObjectDesc(a.Site,a.ObjectID) objectDesc,
  537. dbo.eam_Get_eam_properties_CodeDesc(a.FunctionType,a.PropertiesCode) codeDesc,
  538. a.result,
  539. b.urgency,
  540. a.checkResult,
  541. b.DefectID,
  542. c.DefectDesc,
  543. a.disposal_measures
  544. FROM eam_workOrder a
  545. LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID
  546. LEFT JOIN eam_defect c on b.DefectID = c.DefectID
  547. LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  548. <where>
  549. and a.Site = #{query.site}
  550. <if test="query.orderNo != null and query.orderNo != ''">
  551. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  552. </if>
  553. <if test="query.planID != null and query.planID != ''">
  554. AND a.PlanID like '%' + #{query.planID} +'%'
  555. </if>
  556. <if test="query.planDesc != null and query.planDesc != ''">
  557. AND a.PlanDesc like '%' + #{query.planDesc} +'%'
  558. </if>
  559. <if test="query.objectID != null and query.objectID != ''">
  560. AND a.ObjectID like '%' + #{query.objectID} +'%'
  561. </if>
  562. <if test="query.planOperatorName != null and query.planOperatorName != ''">
  563. AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%'
  564. </if>
  565. <if test="query.status != null and query.status != ''">
  566. AND a.status = #{query.status}
  567. </if>
  568. <if test="query.planDate != null">
  569. AND a.PlanDate = #{query.planDate}
  570. </if>
  571. <if test="query.startDate != null ">
  572. AND a.PlanDate >= #{query.startDate}
  573. </if>
  574. <if test="query.endDate != null ">
  575. AND #{query.endDate} >= a.PlanDate
  576. </if>
  577. <if test="query.endDate == null ">
  578. AND getDate() >= a.PlanDate
  579. </if>
  580. AND a.FunctionType = #{query.functionType}
  581. </where>
  582. ORDER BY a.CreateDate,
  583. CASE WHEN b.urgency = '事故' THEN 1
  584. WHEN b.urgency = '紧急' THEN 2
  585. WHEN b.urgency = '正常' THEN 3
  586. END
  587. </select>
  588. <select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  589. SELECT
  590. a.Site,
  591. a.OrderNo,
  592. a.PlanID,
  593. a.ObjectID,
  594. a.Status,
  595. a.PlanOperator,
  596. a.ActualOperator,
  597. a.PlanDate,
  598. a.ActualDate,
  599. a.FunctionType,
  600. a.CreateDate,
  601. d.operator_name as createBy,
  602. a.Remark,
  603. a.StartTime,
  604. a.EndTime,
  605. a.WorkTime,
  606. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
  607. b.DefectID,
  608. c.DefectDesc,
  609. dbo.eam_Get_eamObjectDesc(a.Site,a.ObjectID) ObjectDesc,
  610. dbo.eam_Get_eam_properties_CodeDesc(a.FunctionType,a.PropertiesCode) codeDesc,
  611. a.result,
  612. b.urgency,
  613. a.disposal_measures,
  614. a.difficulty_level,
  615. a.difficulty_remark
  616. FROM eam_workOrder a
  617. left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID
  618. left join eam_defect c on b.DefectID = c.DefectID
  619. left join operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y'
  620. <where>
  621. and a.Site = #{query.site}
  622. <if test="query.orderNo != null and query.orderNo != ''">
  623. AND a.OrderNo like '%' + #{query.orderNo} +'%'
  624. </if>
  625. <if test="query.planID != null and query.planID != ''">
  626. AND a.PlanID like '%' + #{query.planID} +'%'
  627. </if>
  628. <if test="query.objectID != null and query.objectID != ''">
  629. AND a.ObjectID like '%' + #{query.objectID} +'%'
  630. </if>
  631. <if test="query.planOperator != null and query.planOperator != ''">
  632. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  633. </if>
  634. <if test="query.status != null and query.status != ''">
  635. AND a.status=#{query.status}
  636. </if>
  637. <if test="query.startDate != null ">
  638. AND a.PlanDate >= #{query.startDate}
  639. </if>
  640. <if test="query.endDate != null ">
  641. AND #{query.endDate} >= a.PlanDate
  642. </if>
  643. and a.FunctionType =#{query.functionType}
  644. </where>
  645. ORDER BY a.PlanDate,
  646. CASE WHEN b.urgency = '事故' THEN 1
  647. WHEN b.urgency = '紧急' THEN 2
  648. WHEN b.urgency = '正常' THEN 3
  649. END
  650. </select>
  651. <select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData">
  652. SELECT
  653. DefectID,
  654. DefectDesc,
  655. Active,
  656. create_date,
  657. create_by,
  658. update_date,
  659. update_by,
  660. fault_type
  661. FROM eam_defect
  662. <where>
  663. <if test="query.defectID != null and query.defectID != ''">
  664. AND defectID like '%' + #{query.defectID} + '%'
  665. </if>
  666. <if test="query.defectDesc != null and query.defectDesc != ''">
  667. AND defectDesc like '%' + #{query.defectDesc} + '%'
  668. </if>
  669. <if test="query.active != null and query.active != ''">
  670. AND active = #{query.active}
  671. </if>
  672. </where>
  673. order by id
  674. </select>
  675. <select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  676. SELECT
  677. a.site,
  678. a.ObjectID,
  679. a.DefectID,
  680. a.Active,
  681. a.id,
  682. b.ObjectDesc,
  683. c.DefectDesc,
  684. a.create_date,
  685. a.create_by,
  686. a.update_date,
  687. a.update_by
  688. FROM eam_object_defect a
  689. left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID
  690. left join eam_defect c on a.DefectID=c.DefectID
  691. <where>
  692. <if test="query.objectID != null and query.objectID != ''">
  693. AND a.ObjectID like '%' + #{query.objectID} + '%'
  694. </if>
  695. <if test="query.objectDesc != null and query.objectDesc != ''">
  696. AND b.ObjectDesc like '%' + #{query.objectDesc} + '%'
  697. </if>
  698. <if test="query.defectID != null and query.defectID != ''">
  699. AND a.defectID like '%' + #{query.defectID} + '%'
  700. </if>
  701. <if test="query.defectDesc != null and query.defectDesc != ''">
  702. AND c.defectDesc like '%' + #{query.defectDesc} + '%'
  703. </if>
  704. <if test="query.active != null and query.active != ''">
  705. AND a.active = #{query.active}
  706. </if>
  707. </where>
  708. order by a.id
  709. </select>
  710. <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  711. SELECT
  712. a.Site,
  713. a.ObjectID,
  714. a.ObjectDesc,
  715. a.LocationID,
  716. a.FamilyID,
  717. a.GroupID,
  718. b.FamilyDesc,
  719. c.LocationName
  720. FROM eam_object a
  721. LEFT JOIN eam_family b
  722. ON a.site = b.site and a.FamilyID = b.FamilyID
  723. LEFT JOIN eam_location as c
  724. ON a.LocationID = c.LocationID and a.site = c.site
  725. <where>
  726. <if test="objectID != null and objectID != ''">
  727. AND a.ObjectID like '%' + #{objectID} + '%'
  728. </if>
  729. <if test="objectDesc != null and objectDesc != ''">
  730. AND a.ObjectDesc like '%' + #{objectDesc} + '%'
  731. </if>
  732. AND a.site = #{site}
  733. AND a.active = 'Y'
  734. </where>
  735. </select>
  736. <select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  737. SELECT site ,objectID from eam_object where site=#{site} and FamilyID=#{familyID}
  738. </select>
  739. <select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  740. SELECT site ,objectID from eam_object where site=#{site} and GroupID=#{groupID}
  741. </select>
  742. <select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData">
  743. SELECT site ,objectID from eam_object where site=#{site} and LocationID=#{locationID}
  744. </select>
  745. <select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  746. SELECT
  747. Site,
  748. #{orderNo} as orderNo,
  749. ItemNo,
  750. ItemDesc,
  751. DefaultValue,
  752. ValueType,
  753. ValueType_DB,
  754. ValueChooseFlag,
  755. MaxValue,
  756. MinValue,
  757. ItemRemark,
  758. ItemType,
  759. image_flag
  760. from eam_workPlan_item
  761. where site = #{site}
  762. and planID = #{planID}
  763. AND ObjectID = #{objectID}
  764. </select>
  765. <select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData">
  766. SELECT
  767. Site,
  768. status,
  769. OrderNo
  770. from eam_workOrder
  771. where site = #{site}
  772. and orderNo = #{orderNo}
  773. </select>
  774. <select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  775. SELECT adminID from eam_admin where site=#{site} and mesUser=#{mesUser} and active='Y'
  776. </select>
  777. <update id="updateDefectResult" >
  778. update eam_defect_feedBack
  779. set Status = #{result},
  780. FinishDate = GetDate(),
  781. DefectID = #{defectID}
  782. where Site = #{site}
  783. and FeedBackID = #{planID}
  784. </update>
  785. <update id="reportWorkOrder" >
  786. update eam_workOrder
  787. set Status = '待审核',
  788. ActualOperator = #{actualOperator},
  789. ActualDate = GetDate(),
  790. Remark = #{remark},
  791. disposal_measures = #{disposalMeasures},
  792. WorkTime = #{workTime},
  793. result = #{result,jdbcType=VARCHAR},
  794. checkResult = #{checkResult}
  795. where site = #{site}
  796. and orderNo = #{orderNo}
  797. </update>
  798. <update id="defectReportWorkOrder" >
  799. update eam_workOrder
  800. set Status = '已完工',
  801. ActualOperator = #{actualOperator},
  802. ActualDate = GetDate(),
  803. Remark = #{remark},
  804. disposal_measures = #{disposalMeasures},
  805. WorkTime = #{workTime},
  806. result = #{result,jdbcType=VARCHAR},
  807. checkResult = #{checkResult}
  808. where site = #{site}
  809. and orderNo = #{orderNo}
  810. </update>
  811. <insert id="saveWorkOrderItem">
  812. INSERT into eam_workOrder_item
  813. (Site,OrderNo,ItemNo,ItemDesc,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,MaxValue,MinValue,ItemRemark,ItemType,TextValue,NumberValue,CreatedDate,CreatedBy,FinishFlag,itemResult)
  814. values (#{site},#{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})
  815. </insert>
  816. <!-- 修改 eam_workPlan 状态为已结束 -->
  817. <update id="closePlanWithCheck">
  818. update eam_workPlan
  819. set status = '已结束'
  820. where site = #{site}
  821. and PlanID = #{planID}
  822. and ObjectID = #{objectID}
  823. and GetDate() > PlanEndDate
  824. </update>
  825. <!-- 报工后更新下一个工作日期 -->
  826. <update id="updatePlanNextDate">
  827. update eam_workPlan_overview
  828. set next_work_date = (select top 1 PlanDate from eam_workOrder where site = #{site} and PlanID = #{planID} and PlanDate > GetDate() and status = '未开工' order by PlanDate)
  829. where site = #{site} and plan_id = #{planID}
  830. </update>
  831. <select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData">
  832. SELECT
  833. Site,
  834. OrderNo,
  835. ItemNo,
  836. ItemDesc,
  837. DefaultValue,
  838. ValueType,
  839. ValueType_DB,
  840. ValueChooseFlag,
  841. MaxValue,
  842. MinValue,
  843. ItemRemark,
  844. ItemType,
  845. TextValue,
  846. NumberValue,
  847. CreatedDate,
  848. CreatedBy,
  849. FinishFlag,
  850. itemResult
  851. from eam_workOrder_item
  852. where site = #{site}
  853. and orderNo = #{orderNo}
  854. </select>
  855. <update id="cancelOrder" parameterType="EamWorkOrderInData">
  856. update eam_workOrder
  857. set Status = '已取消'
  858. where site = #{site}
  859. and orderNo = #{orderNo}
  860. and FunctionType = #{functionType}
  861. </update>
  862. <update id="cancelOrderAll" parameterType="EamWorkOrderInData">
  863. update eam_workOrder
  864. set Status = '已取消'
  865. where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status}
  866. </update>
  867. <select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  868. SELECT
  869. site,
  870. status
  871. from eam_workPlan_overview
  872. where site = #{site}
  873. and plan_id = #{planID}
  874. and delete_flag = 'N'
  875. </select>
  876. <update id="planOrder">
  877. update eam_workPlan
  878. set Status = '已计划',
  879. NextWorkDate = null
  880. where site = #{site}
  881. and PlanID = #{planID}
  882. and deleteFlag = 'N'
  883. </update>
  884. <update id="cancelPlan">
  885. update eam_workPlan_overview
  886. set status = '已取消',
  887. next_work_date = null
  888. where site = #{site}
  889. and plan_id = #{planID}
  890. and delete_flag = 'N'
  891. </update>
  892. <update id="updateWorkPlanStatus">
  893. update eam_workPlan
  894. set Status = '已取消',
  895. NextWorkDate = null
  896. where Site = #{site}
  897. and PlanID = #{planID}
  898. and deleteFlag = 'N'
  899. </update>
  900. <update id="cancelOrderWithPlanID">
  901. update eam_workOrder
  902. set Status = '已取消'
  903. where site = #{site}
  904. and PlanID = #{planID}
  905. and status = '未开工'
  906. </update>
  907. <update id="deleteOrderDetailWithPlanID">
  908. delete from eam_workOrder_item
  909. where site = #{site}
  910. and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 )
  911. </update>
  912. <update id="deleteOrderWithPlanID">
  913. delete from eam_workOrder
  914. where site = #{site}
  915. and PlanID = #{planID}
  916. and status = '未开工'
  917. and PlanDate > GetDate() - 1
  918. </update>
  919. <update id="updateOrderPlanOperator">
  920. update eam_workOrder
  921. set PlanOperator = #{planOperator}
  922. where site = #{site} and orderNo = #{orderNo}
  923. </update>
  924. <select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  925. select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a
  926. left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID}
  927. <where>
  928. <if test="partNo != null and partNo != ''">
  929. AND a.part_no like '%' + #{partNo} + '%'
  930. </if>
  931. <if test="partDescription != null and partDescription != ''">
  932. AND a.part_description like '%' + #{partDescription} + '%'
  933. </if>
  934. and a.site=#{site} and a.active='Y'
  935. </where>
  936. </select>
  937. <select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData">
  938. select part_no
  939. from resource_spare
  940. where site = #{site}
  941. and resource_id = #{objectID}
  942. and part_no = #{partNo}
  943. </select>
  944. <insert id="savePartSpare" >
  945. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  946. values(#{objectID},#{partNo},'',0,#{site})
  947. </insert>
  948. <delete id="deletePartSpare">
  949. delete from resource_spare
  950. where resource_id = #{objectID}
  951. and site = #{site}
  952. </delete>
  953. <insert id="copyPartSpare" >
  954. INSERT Into resource_spare (resource_id,part_no,delflag,version,site)
  955. select #{objectID},part_no,delflag,0,site from resource_spare where resource_id=#{oldObjectID} and site=#{site}
  956. </insert>
  957. <select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData">
  958. SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status,
  959. a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark
  960. ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
  961. FROM eam_workPlan a
  962. left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID
  963. left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID
  964. left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no
  965. where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N'
  966. and status in ('已计划','进行中')
  967. </select>
  968. <select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  969. SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy,
  970. a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b
  971. on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType
  972. where a.site=#{site} and a.ObjectID=#{objectID}
  973. and a.ItemType=#{itemType}
  974. </select>
  975. <select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData">
  976. SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc
  977. from eam_object_defect a left join eam_defect b
  978. on a.DefectID=b.DefectID
  979. where a.site=#{site} and a.ObjectID=#{objectID}
  980. </select>
  981. <select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData">
  982. select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  983. ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  984. </select>
  985. <insert id="saveNewEamObjectItem" >
  986. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  987. ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})
  988. </insert>
  989. <update id="editEamObjectItem">
  990. update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb}
  991. ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
  992. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  993. and ItemNo=#{itemNo}
  994. </update>
  995. <delete id="deleteObjectItem">
  996. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  997. and ItemNo=#{itemNo}
  998. </delete>
  999. <insert id="saveNewEamObjectItemAvailable">
  1000. insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1001. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available
  1002. where ItemNo=#{itemNo} and ItemType=#{itemType}
  1003. </insert>
  1004. <delete id="deleteEamObjectItemAvailable">
  1005. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1006. and ItemNo=#{itemNo}
  1007. </delete>
  1008. <select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData">
  1009. select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available
  1010. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}
  1011. </select>
  1012. <select id="getItemValueNoForObject" resultType="Double">
  1013. SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}
  1014. </select>
  1015. <insert id="saveObjectItemAvailable">
  1016. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1017. values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})
  1018. </insert>
  1019. <update id="updateObjectItemAvailable">
  1020. update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy}
  1021. where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1022. </update>
  1023. <delete id="deleteObjectItemAvailable">
  1024. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}
  1025. </delete>
  1026. <delete id="deleteObjectItemForCopy">
  1027. delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1028. </delete>
  1029. <delete id="deleteObjectItemAvailableForCopy">
  1030. delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}
  1031. </delete>
  1032. <insert id="copyObjectItem" >
  1033. insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue,
  1034. ItemType)
  1035. select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType
  1036. from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1037. </insert>
  1038. <insert id="copyObjectItemAvailable">
  1039. insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy)
  1040. select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy}
  1041. from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}
  1042. </insert>
  1043. <delete id="deleteObjectDefectForCopy">
  1044. delete from eam_object_defect where site=#{site} and objectID=#{objectID}
  1045. </delete>
  1046. <insert id="copyObjectDefect">
  1047. insert into eam_object_defect(site,ObjectID,DefectID,Active)
  1048. select #{site},#{objectID},DefectID,Active
  1049. from eam_object_defect where site=#{site} and objectID=#{oldObjectID}
  1050. </insert>
  1051. <select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1052. select
  1053. a.Site,
  1054. a.FeedBackID,
  1055. a.FeedBackDesc,
  1056. a.ObjectID,
  1057. a.DefectID,
  1058. a.FunctionType,
  1059. a.PlanOperator,
  1060. a.ActualOperator,
  1061. a.Status,
  1062. a.PlanDate,
  1063. a.Remark,
  1064. a.urgency,
  1065. a.deleteFlag,
  1066. a.CreatedDate,
  1067. a.CreatedBy,
  1068. c.operator_name as feedbackBy,
  1069. a.UpdateDate,
  1070. a.UpdateBy,
  1071. a.Version,
  1072. a.DefectDate,
  1073. dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
  1074. b.defectDesc,
  1075. dbo.eam_Get_eamObjectDesc(a.Site,a.ObjectID) ObjectDesc,
  1076. FinishDate
  1077. from eam_defect_feedBack a
  1078. left join eam_defect b on a.DefectID = b.DefectID
  1079. left join operator as c on a.site = c.site and a.CreatedBy = c.operator_id and c.active = 'Y'
  1080. <where>
  1081. and a.Site = #{query.site}
  1082. <if test="query.feedBackID != null and query.feedBackID != ''">
  1083. AND a.feedBackID like '%' + #{query.feedBackID} +'%'
  1084. </if>
  1085. <if test="query.defectDesc != null and query.defectDesc != ''">
  1086. AND b.defectDesc like '%' + #{query.defectDesc} +'%'
  1087. </if>
  1088. <if test="query.objectID != null and query.objectID != ''">
  1089. AND a.ObjectID like '%' + #{query.objectID} +'%'
  1090. </if>
  1091. <if test="query.planOperator != null and query.planOperator != ''">
  1092. AND a.PlanOperator like '%' + #{query.planOperator} +'%'
  1093. </if>
  1094. <if test="query.status != null and query.status != ''">
  1095. AND a.status = #{query.status}
  1096. </if>
  1097. <if test="query.startDate != null ">
  1098. AND a.defectDate > #{query.startDate}
  1099. </if>
  1100. <if test="query.endDate != null ">
  1101. AND #{query.endDate} > a.defectDate
  1102. </if>
  1103. and a.FunctionType = #{query.functionType}
  1104. </where>
  1105. ORDER BY a.DefectDate,
  1106. CASE WHEN a.urgency = '事故' THEN 1
  1107. WHEN a.urgency = '紧急' THEN 2
  1108. WHEN a.urgency = '正常' THEN 3
  1109. END
  1110. </select>
  1111. <select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData">
  1112. select Site,FeedBackID,FeedBackDesc,ObjectID,DefectID,Status from eam_defect_feedBack where FeedBackID=#{feedBackID} and site=#{site}
  1113. </select>
  1114. <update id="cancelFeedBack" >
  1115. update eam_defect_feedBack set status='已取消' where FeedBackID=#{feedBackID} and site=#{site}
  1116. </update>
  1117. <update id="updateFeedBack">
  1118. update eam_defect_feedBack
  1119. set status = '已下达',
  1120. PlanOperator = #{planOperator},
  1121. UpdateDate = GetDate(),
  1122. UpdateBy = #{updateBy}
  1123. where FeedBackID = #{feedBackID}
  1124. and site = #{site}
  1125. </update>
  1126. <insert id="saveDefectOrder">
  1127. INSERT INTO eam_workOrder
  1128. (Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy)
  1129. values(#{site}, (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' ), #{feedBackID}, '', #{objectID}, '未开工', #{planOperator}, #{planDate}, 'C', GetDate(), #{userId})
  1130. </insert>
  1131. <select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1132. SELECT
  1133. a.itemNo,
  1134. a.ItemDesc,
  1135. a.ItemRemark
  1136. FROM eam_properties_item a
  1137. LEFT JOIN eam_properties_model_detail b on b.function_type = #{functionType} and b.code_no = #{codeNo} and b.properties_item_no = a.ItemNo
  1138. <where>
  1139. a.ItemType = #{functionType}
  1140. AND b.code_no is null
  1141. <if test = "itemNo != null and itemNo != ''">
  1142. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  1143. </if>
  1144. <if test = "itemDesc != null and itemDesc != ''">
  1145. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  1146. </if>
  1147. </where>
  1148. </select>
  1149. <select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  1150. select
  1151. a.properties_item_no itemNo,
  1152. b.ItemDesc,
  1153. b.ItemRemark
  1154. from eam_properties_model_detail a
  1155. left join eam_properties_item b on a.properties_item_no = b.ItemNo and a.function_type = b.ItemType
  1156. where a.code_no = #{codeNo}
  1157. and a.function_type = #{functionType}
  1158. </select>
  1159. <delete id="deleteObjectFile">
  1160. delete from sys_oss where id = #{id}
  1161. </delete>
  1162. <select id="checkSparPartImage" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1163. SELECT id, url, create_date, file_name, new_file_name, created_by,
  1164. order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code
  1165. FROM sys_oss
  1166. WHERE order_ref2 = #{orderNo}
  1167. AND order_ref1 = #{site}
  1168. AND order_ref3 = 'reportSparPart'
  1169. </select>
  1170. <!-- 获取机修人员列表 -->
  1171. <select id="getOperatorList" resultType="EamAdminData" parameterType="EamAdminData">
  1172. SELECT
  1173. ea.AdminID,
  1174. ea.AdminName,
  1175. ea.Phone,
  1176. ea.Department,
  1177. ea.Email,
  1178. ea.Tel,
  1179. ea.LevelID,
  1180. eal.AdminLevelDesc,
  1181. ea.MesUser,
  1182. ea.Active,
  1183. ea.CreatedDate
  1184. FROM eam_admin as ea
  1185. LEFT JOIN eam_adminLevel as eaL
  1186. ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site
  1187. <where>
  1188. ea.Active = 'Y'
  1189. AND ea.Site = #{site}
  1190. <if test = "adminID != null and adminID != ''">
  1191. AND ea.AdminID LIKE '%' + #{adminID}+'%'
  1192. </if>
  1193. <if test = "adminName != null and adminName != ''">
  1194. AND ea.AdminName LIKE '%' + #{adminName}+'%'
  1195. </if>
  1196. </where>
  1197. </select>
  1198. <!-- 获取审核人员列表 -->
  1199. <select id="getCheckerList" resultType="EamAdminData" parameterType="EamAdminData">
  1200. SELECT
  1201. site,
  1202. user_id,
  1203. username as adminID,
  1204. email,
  1205. mobile as phone,
  1206. user_display as adminName
  1207. FROM sys_user
  1208. <where>
  1209. AND site = #{site}
  1210. <if test = "adminID != null and adminID != ''">
  1211. AND username LIKE '%' + #{adminID}+'%'
  1212. </if>
  1213. <if test = "adminName != null and adminName != ''">
  1214. AND user_display LIKE '%' + #{adminName}+'%'
  1215. </if>
  1216. </where>
  1217. </select>
  1218. <!-- 点检工单审核 -->
  1219. <update id="checkWorkOrder" parameterType="EamWorkOrderInData">
  1220. UPDATE eam_workOrder
  1221. SET Status = '已完工'
  1222. WHERE Site = #{site}
  1223. AND OrderNo = #{orderNo}
  1224. </update>
  1225. <update id="cancelCheckWorkOrder" parameterType="EamWorkOrderInData">
  1226. UPDATE eam_workOrder
  1227. SET Status = '待审核'
  1228. WHERE Site = #{site}
  1229. AND OrderNo = #{orderNo}
  1230. </update>
  1231. <!-- 查看点检工单状态 -->
  1232. <select id="checkWorkOrderStatus" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1233. SELECT
  1234. OrderNo
  1235. FROM eam_workOrder
  1236. WHERE site = #{site}
  1237. AND PlanID = #{planID}
  1238. AND Status != '已完工'
  1239. </select>
  1240. <!-- 点检工单审核 -->
  1241. <update id="updateWorkPlanOverviewStatus" parameterType="EamWorkOrderInData">
  1242. UPDATE eam_workPlan_overview
  1243. SET status = '已结束'
  1244. WHERE site = #{site}
  1245. AND plan_id = #{planID}
  1246. </update>
  1247. <!-- 新增点检计划 -->
  1248. <insert id="saveWorkPlan" parameterType="EamWorkPlanInData">
  1249. INSERT INTO eam_workPlan_overview
  1250. (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)
  1251. VALUES (#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy}, #{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod}, #{workOrderRule}, #{planCycle})
  1252. </insert>
  1253. <!-- 生成工单ID -->
  1254. <select id="selectOrderId" resultType="string" parameterType="EamWorkPlanInData">
  1255. SELECT
  1256. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8)
  1257. FROM eam_workPlan
  1258. WHERE site = #{site}
  1259. AND FunctionType = #{functionType}
  1260. </select>
  1261. <!-- 查询计划中的设备列表 -->
  1262. <select id="getPlanDetailList" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1263. SELECT
  1264. ewp.PlanID,
  1265. ewp.PlanDesc,
  1266. ewp.ObjectID,
  1267. eo.ObjectDesc,
  1268. eo.FamilyID,
  1269. ef.FamilyDesc,
  1270. eo.LocationID,
  1271. el.LocationName
  1272. FROM eam_workPlan as ewP
  1273. LEFT JOIN eam_object as eo
  1274. ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site
  1275. LEFT JOIN eam_family as ef
  1276. ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site
  1277. LEFT JOIN eam_location as el
  1278. ON eo.LocationID = el.LocationID and ewP.Site = el.Site
  1279. <where>
  1280. ewP.site = #{site}
  1281. AND ewp.PlanID = #{planID}
  1282. <if test = "objectID != null and objectID != ''">
  1283. AND eo.ObjectID LIKE '%' + #{objectID}+'%'
  1284. </if>
  1285. <if test = "objectDesc != null and objectDesc != ''">
  1286. AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%'
  1287. </if>
  1288. </where>
  1289. </select>
  1290. <!-- 删除计划中的设备 -->
  1291. <delete id="delPlanDetail" parameterType="WorkPlanDetailData">
  1292. DELETE FROM eam_workPlan
  1293. WHERE Site = #{site}
  1294. AND PlanID = #{planID}
  1295. AND ObjectID = #{objectID}
  1296. </delete>
  1297. <!-- 获取当前计划不包含的设备 -->
  1298. <select id="getObjList1" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1299. SELECT
  1300. a.ObjectID,
  1301. a.ObjectDesc,
  1302. a.FamilyID,
  1303. ef.FamilyDesc,
  1304. a.LocationID,
  1305. el.LocationName
  1306. FROM eam_object a
  1307. LEFT JOIN eam_workPlan b
  1308. ON b.PlanID = #{planID} and b.ObjectID = a.ObjectID
  1309. LEFT JOIN eam_family as ef
  1310. ON a.FamilyID = ef.FamilyID
  1311. LEFT JOIN eam_location as el
  1312. ON a.LocationID = el.LocationID
  1313. WHERE b.PlanID is null
  1314. </select>
  1315. <!-- 获取当前计划包含的设备 -->
  1316. <select id="getObjList2" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData">
  1317. SELECT
  1318. a.ObjectID,
  1319. b.ObjectDesc,
  1320. b.FamilyID,
  1321. ef.FamilyDesc,
  1322. b.LocationID,
  1323. el.LocationName
  1324. FROM eam_workPlan a
  1325. LEFT JOIN eam_object b
  1326. ON a.ObjectID = b.ObjectID
  1327. LEFT JOIN eam_family as ef
  1328. ON b.FamilyID = ef.FamilyID
  1329. LEFT JOIN eam_location as el
  1330. ON b.LocationID = el.LocationID
  1331. WHERE a.PlanID = #{planID}
  1332. </select>
  1333. <!-- 添加计划设备 -->
  1334. <insert id="addObject" parameterType="EamWorkPlanInData">
  1335. INSERT INTO eam_workPlan
  1336. (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag)
  1337. values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N')
  1338. </insert>
  1339. <!-- 修改工单计划 -->
  1340. <update id="updateWorkPlan" parameterType="EamWorkPlanInData">
  1341. UPDATE eam_workPlan_overview
  1342. SET plan_desc = #{planDesc},
  1343. properties_code = #{propertiesCode},
  1344. plan_start_date = #{planStartDate},
  1345. plan_end_date = #{planEndDate},
  1346. plan_period = #{planPeriod},
  1347. remark = #{remark},
  1348. operator = #{operator},
  1349. operator_name = #{operatorName},
  1350. checker = #{checker},
  1351. checker_name = #{checkerName},
  1352. work_order_rule = #{workOrderRule}
  1353. WHERE site = #{site}
  1354. AND plan_id = #{planID}
  1355. AND function_type = #{functionType}
  1356. </update>
  1357. <!-- 删除该计划的旧设备 -->
  1358. <delete id="delWorkPlanObject" parameterType="EamWorkPlanInData">
  1359. DELETE FROM eam_workPlan
  1360. WHERE Site = #{site}
  1361. AND PlanID = #{planID}
  1362. </delete>
  1363. <!-- 删除该计划的旧设备item -->
  1364. <delete id="delWorkPlanItem" parameterType="EamWorkPlanInData">
  1365. DELETE FROM eam_workPlan_item
  1366. WHERE Site = #{site}
  1367. AND PlanID = #{planID}
  1368. </delete>
  1369. <!-- 删除该计划的旧设备itemAvailable-->
  1370. <delete id="delWorkPlanItemAvailable">
  1371. DELETE FROM eam_workPlan_item_available
  1372. WHERE Site = #{site}
  1373. AND PlanID = #{planID}
  1374. AND ObjectID = #{objectID}
  1375. </delete>
  1376. <!-- 查询该计划的设备 -->
  1377. <select id="planObjectSearch" resultType="EamWorkPlanItemData" parameterType="EamWorkPlanItemData">
  1378. SELECT DISTINCT
  1379. a.ObjectID,
  1380. b.ObjectDesc
  1381. FROM eam_workPlan_item as a
  1382. LEFT JOIN eam_object as b
  1383. ON a.ObjectID = b.ObjectID
  1384. WHERE a.Site = #{site}
  1385. AND a.PlanID = #{planID}
  1386. </select>
  1387. <!-- 修改该计划状态 -->
  1388. <update id="updateOverviewStatus" parameterType="EamWorkPlanInData">
  1389. UPDATE eam_workPlan_overview
  1390. SET status = '进行中',
  1391. next_work_date = #{planStartDate}
  1392. WHERE site = #{site}
  1393. AND plan_id = #{planID}
  1394. </update>
  1395. <!-- 查询文件路径 -->
  1396. <select id="searchFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderInData">
  1397. SELECT
  1398. id,
  1399. url,
  1400. file_name
  1401. FROM sys_oss
  1402. WHERE order_ref1 = #{site}
  1403. AND order_ref2 = #{orderNo}
  1404. AND order_ref3 = #{folder}
  1405. </select>
  1406. <!-- 新增子明细信息 -->
  1407. <insert id="saveOperator" parameterType="EamWorkOrderInData">
  1408. INSERT INTO eam_actual_operator
  1409. (site, order_no, function_type, operator)
  1410. VALUES (#{site}, #{orderNo}, #{functionType}, #{operator})
  1411. </insert>
  1412. <!-- 查询工单号 -->
  1413. <select id="getOrderNo" resultType="string">
  1414. SELECT OrderNo
  1415. FROM eam_workOrder
  1416. WHERE site = #{site}
  1417. AND PlanID = #{planID}
  1418. AND FunctionType = #{functionType}
  1419. AND Status = '已完工'
  1420. AND PlanOperator is not null
  1421. </select>
  1422. <!-- 查询实际维修人员 -->
  1423. <select id="getActualOperatorList" resultType="string">
  1424. SELECT ea.AdminName
  1425. FROM eam_actual_operator as eao
  1426. LEFT JOIN eam_admin as ea
  1427. ON eao.operator = ea.AdminID and eao.site = ea.Site
  1428. WHERE eao.site = #{site}
  1429. AND eao.order_no = #{orderNo}
  1430. AND eao.function_type = #{functionType}
  1431. </select>
  1432. <!-- 查询设备所属部门 -->
  1433. <select id="selectDeptByObjectID" resultType="string" parameterType="string">
  1434. SELECT ved.department_name
  1435. FROM eam_object as eo
  1436. LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id
  1437. WHERE eo.site = #{site}
  1438. AND eo.ObjectID = #{objectID}
  1439. </select>
  1440. <!-- 查询用户所属部门 -->
  1441. <select id="selectAdminIdByUserName" resultType="string" parameterType="string">
  1442. SELECT AdminID
  1443. FROM eam_admin
  1444. WHERE site = #{site}
  1445. AND MesUser = #{username}
  1446. </select>
  1447. <!-- 生成新的维修工单 -->
  1448. <insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData">
  1449. INSERT INTO eam_workOrder
  1450. (Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy)
  1451. VALUES (#{site}, (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'),
  1452. #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy})
  1453. </insert>
  1454. <!-- 获取旧工单的基础信息 -->
  1455. <select id="queryOldWorkOrderMessage" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1456. select
  1457. PlanOperator,
  1458. PlanOperatorName,
  1459. checker,
  1460. checkerName
  1461. from eam_workOrder
  1462. where site = #{site}
  1463. and OrderNo = #{orderNo}
  1464. and FunctionType = #{functionType}
  1465. </select>
  1466. <!-- 生成新的维保工单 -->
  1467. <insert id="saveMaintenanceWorkOrder" parameterType="EamWorkOrderInData">
  1468. INSERT INTO eam_workOrder
  1469. (Site, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1470. VALUES (#{site}, (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'),
  1471. #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName})
  1472. </insert>
  1473. <!-- 检查系统操作人和审核人员是否一致 -->
  1474. <select id="selectNameByMes" resultType="EamAdminData" parameterType="EamAdminData">
  1475. SELECT AdminName
  1476. FROM eam_admin
  1477. WHERE site = #{site}
  1478. AND MesUser = #{mesUser}
  1479. </select>
  1480. <!-- 维修审核确认 -->
  1481. <update id="submitDefect" parameterType="EamWorkOrderInData">
  1482. UPDATE eam_workOrder
  1483. SET Status = #{status},
  1484. difficulty_level = #{difficultyLevel},
  1485. difficulty_remark = #{difficultyRemark}
  1486. WHERE Site = #{site}
  1487. AND OrderNo = #{orderNo}
  1488. </update>
  1489. <!-- 查询设备的点检和维保历史记录 -->
  1490. <select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1491. SELECT
  1492. top 10
  1493. ewo.OrderNo,
  1494. ewo.PlanID,
  1495. ewo.PlanDesc,
  1496. ewo.ActualDate,
  1497. ewo.ObjectID,
  1498. eo.ObjectDesc,
  1499. ewo.Remark,
  1500. dbo.eam_Get_eamAdminName(ewo.site,ewo.ActualOperator) ActualOperatorName,
  1501. ewo.checkResult
  1502. FROM eam_workOrder as ewo
  1503. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID
  1504. WHERE ewo.site = #{site}
  1505. AND ewo.ObjectID = #{objectID}
  1506. AND ewo.FunctionType = #{functionType}
  1507. AND ewo.Status = '已完工'
  1508. ORDER BY ewo.ActualDate desc
  1509. </select>
  1510. <!-- 查询设备的维修历史记录 -->
  1511. <select id="queryDefectHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
  1512. SELECT
  1513. top 10
  1514. ewo.OrderNo,
  1515. ewo.PlanID,
  1516. ewo.PlanDesc,
  1517. ewo.ActualDate,
  1518. ewo.Remark,
  1519. ewo.Result,
  1520. ewo.disposal_measures,
  1521. ed.DefectDesc,
  1522. ewo.WorkTime
  1523. FROM eam_workOrder as ewo
  1524. LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID
  1525. LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID
  1526. LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID
  1527. WHERE ewo.site = #{site}
  1528. AND ewo.ObjectID = #{objectID}
  1529. AND ewo.FunctionType = #{functionType}
  1530. AND ewo.Status = '已完工'
  1531. ORDER BY ewo.ActualDate desc
  1532. </select>
  1533. <!-- AND datediff(week, ewo.ActualDate, getdate()) = 0-->
  1534. <!-- 查询部门列表 -->
  1535. <select id="getEmpyDeptList" resultType="EmpyDept" parameterType="EmpyDept">
  1536. SELECT
  1537. site,
  1538. department_id as deptId,
  1539. department_name as deptName
  1540. FROM sys_department
  1541. <where>
  1542. site = #{site}
  1543. <if test = "deptId != null and deptId != ''">
  1544. AND department_id LIKE '%' + #{deptId}+'%'
  1545. </if>
  1546. <if test = "deptName != null and deptName != ''">
  1547. AND department_name LIKE '%' + #{deptName}+'%'
  1548. </if>
  1549. </where>
  1550. </select>
  1551. <!-- 生成新的维修工单 -->
  1552. <insert id="saveAdminDepartment">
  1553. INSERT INTO eam_admin_dept
  1554. (Site, admin_id, dept_id)
  1555. VALUES (#{site}, #{adminID}, #{deptId})
  1556. </insert>
  1557. <!-- 查询部门详情 -->
  1558. <select id="getDeptDetail" resultType="EamAdminData" parameterType="string">
  1559. SELECT
  1560. ved.department_id as department,
  1561. ved.department_name as departmentName
  1562. FROM eam_admin_dept as ead
  1563. LEFT JOIN sys_department as ved
  1564. ON ead.site = ved.site and ead.dept_id = ved.department_id
  1565. WHERE ead.site = #{site}
  1566. AND ead.admin_id = #{adminID}
  1567. </select>
  1568. <!-- 查询部门列表 -->
  1569. <select id="getDeptList" resultType="string" parameterType="string">
  1570. SELECT
  1571. ved.department_name
  1572. FROM eam_admin_dept as ead
  1573. LEFT JOIN sys_department as ved
  1574. ON ead.site = ved.site and ead.dept_id = ved.department_id
  1575. WHERE ead.site = #{site}
  1576. AND ead.admin_id = #{adminID}
  1577. </select>
  1578. <!-- 删除旧数据-->
  1579. <delete id="deleteAdminDepartment">
  1580. DELETE FROM eam_admin_dept
  1581. WHERE site = #{site}
  1582. AND admin_id = #{adminID}
  1583. </delete>
  1584. <!-- 获取可用的MES账号 -->
  1585. <select id="getMesList" resultType="SysUserEntity" parameterType="SysUserEntity">
  1586. SELECT
  1587. a.username,
  1588. a.user_display
  1589. FROM sys_user a
  1590. LEFT JOIN eam_admin b
  1591. ON b.MesUser = a.username and a.site = b.site
  1592. WHERE a.site = #{site}
  1593. AND b.MesUser is null
  1594. </select>
  1595. <!-- 查询点检模板 -->
  1596. <select id="eamPropertiesItemSearch" parameterType="EamPropertiesItemData" resultType="EamPropertiesItemData">
  1597. SELECT
  1598. ItemNo,
  1599. ItemDesc,
  1600. DefaultValue,
  1601. ValueType,
  1602. ValueType_DB as valueTypeDb,
  1603. ValueChooseFlag,
  1604. CreatedDate,
  1605. CreatedBy,
  1606. update_date,
  1607. update_by,
  1608. MaxValue,
  1609. MinValue,
  1610. ItemRemark,
  1611. ItemType,
  1612. image_flag
  1613. FROM eam_properties_item
  1614. <where>
  1615. ItemType = #{query.itemType}
  1616. <if test="query.itemNo != null and query.itemNo != ''">
  1617. AND ItemNo LIKE '%' + #{query.itemNo}+'%'
  1618. </if>
  1619. <if test="query.itemDesc != null and query.itemDesc != ''">
  1620. AND ItemDesc LIKE '%' + #{query.itemDesc}+'%'
  1621. </if>
  1622. </where>
  1623. </select>
  1624. <!-- 删除图片-->
  1625. <delete id="imageDelete" parameterType="SysOssEntity">
  1626. DELETE FROM sys_oss
  1627. WHERE id = #{id}
  1628. </delete>
  1629. <!-- 检查该日期内是否已有该设备的计划 -->
  1630. <select id="checkObjectPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1631. SELECT
  1632. PlanID,
  1633. ObjectID
  1634. FROM eam_workPlan
  1635. WHERE site = #{site}
  1636. AND ObjectID = #{objectID}
  1637. AND FunctionType = #{functionType}
  1638. AND Status in ('已计划','进行中')
  1639. AND deleteFlag = 'N'
  1640. AND (convert(varchar(10), PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
  1641. or convert(varchar(10), PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
  1642. or (DATEDIFF(day, PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, PlanEndDate) >= 0)
  1643. )
  1644. </select>
  1645. <!-- 获取可用的MES账号 -->
  1646. <select id="queryWorkPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData">
  1647. SELECT
  1648. site,
  1649. plan_id,
  1650. plan_desc,
  1651. properties_code,
  1652. #{objectID} as objectID,
  1653. status,
  1654. operator,
  1655. delete_flag,
  1656. plan_start_date,
  1657. plan_end_date,
  1658. plan_period,
  1659. function_type,
  1660. checker,
  1661. checker_name,
  1662. operator_name,
  1663. work_order_rule,
  1664. plan_cycle
  1665. FROM eam_workPlan_overview
  1666. WHERE site = #{site}
  1667. AND plan_id = #{planID}
  1668. AND function_type = #{functionType}
  1669. </select>
  1670. <!-- 获得工单号 -->
  1671. <select id="queryPlanOrderNo" resultType="string" parameterType="EamWorkPlanInData">
  1672. SELECT
  1673. Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8)
  1674. FROM eam_workOrder
  1675. WHERE site = #{site}
  1676. AND FunctionType = #{functionType}
  1677. </select>
  1678. <!-- 新增工单 -->
  1679. <insert id="insertWorkOrder" parameterType="EamWorkPlanInData">
  1680. INSERT INTO eam_workOrder
  1681. (Site, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1682. VALUES (#{site}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1683. </insert>
  1684. <!-- 循环新增工单 -->
  1685. <insert id="forInsertWorkOrder" parameterType="EamWorkPlanInData">
  1686. INSERT INTO eam_workOrder
  1687. (Site, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName)
  1688. VALUES (#{site}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName})
  1689. </insert>
  1690. <!-- 更改plan表的状态为进行中 -->
  1691. <update id="updatePlanStatus" parameterType="EamWorkPlanInData">
  1692. update eam_workPlan
  1693. set status = '进行中',
  1694. NextWorkDate = PlanStartDate
  1695. where site = #{site}
  1696. and PlanID = #{planID}
  1697. and FunctionType = #{functionType}
  1698. and ObjectID = #{objectID}
  1699. </update>
  1700. <!-- 获得工单号 -->
  1701. <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="EamWorkOrderItemInData">
  1702. SELECT
  1703. id,
  1704. file_name
  1705. FROM sys_oss
  1706. WHERE order_ref1 = #{site}
  1707. AND order_ref2 = #{orderNo}
  1708. AND order_ref3 = #{itemNo}
  1709. </select>
  1710. <!-- 删除原来工单项目-->
  1711. <delete id="deleteWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1712. DELETE FROM eam_workPlan_item
  1713. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID}
  1714. </delete>
  1715. <!-- 删除原来的可选值-->
  1716. <delete id="deleteWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1717. DELETE FROM eam_workPlan_item_available
  1718. WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID}
  1719. </delete>
  1720. <!-- 添加新项目 -->
  1721. <insert id="saveWorkPlanItem" parameterType="EamWorkOrderItemInData">
  1722. INSERT INTO eam_workPlan_item (Site,PlanID,ObjectID,ItemNo,ItemDesc,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,MaxValue,MinValue,ItemRemark,ItemType,CreatedDate,CreatedBy,image_flag)
  1723. select
  1724. #{site},
  1725. #{planID},
  1726. #{objectID},
  1727. a.ItemNo,
  1728. a.ItemDesc,
  1729. case when c.site is not null then c.DefaultValue else a.DefaultValue end,
  1730. case when c.site is not null then c.ValueType else a.ValueType end,
  1731. case when c.site is not null then c.ValueType_DB else a.ValueType_DB end,
  1732. case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end,
  1733. case when c.site is not null then c.MaxValue else a.MaxValue end,
  1734. case when c.site is not null then c.MinValue else a.MinValue end,
  1735. a.ItemRemark,
  1736. a.ItemType,
  1737. GetDate(),
  1738. #{userId},
  1739. a.image_flag
  1740. from eam_properties_item a
  1741. left join eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no
  1742. left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID}
  1743. where a.ItemType = #{itemType} and b.code_no = #{propertiesCode}
  1744. </insert>
  1745. <!-- 添加新项目可选值 -->
  1746. <insert id="saveWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData">
  1747. INSERT INTO eam_workPlan_item_available (Site, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy)
  1748. SELECT DISTINCT
  1749. #{site},
  1750. #{planID},
  1751. #{objectID},
  1752. a.ItemNo,
  1753. a.ItemType,
  1754. case when c.ValueNo is not null then c.ValueNo else a.ValueNo end,
  1755. case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end,
  1756. GetDate(),
  1757. #{userId}
  1758. FROM eam_properties_item_available a
  1759. LEFT JOIN eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no
  1760. LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID}
  1761. WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode}
  1762. </insert>
  1763. </mapper>