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.

951 lines
35 KiB

2 years ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 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.spring.modules.base.dao.PropertiesMapper">
  4. <!-- 查询点检项目 -->
  5. <select id="plmPropertiesItemSearch" parameterType="PlmPropertiesItemData" resultType="PlmPropertiesItemData">
  6. SELECT ppi.site,
  7. ItemNo,
  8. ItemDesc,
  9. DefaultValue,
  10. ValueType,
  11. ValueType_DB as valueTypeDb,
  12. ValueChooseFlag,
  13. CreatedDate,
  14. CreatedBy,
  15. ppi.update_date,
  16. ppi.update_by,
  17. MaxValue,
  18. MinValue,
  19. ItemType,
  20. pt.function_type_desc
  21. FROM plm_properties_item ppi
  22. left join properties_type pt on pt.function_type = ppi.itemType
  23. <where>
  24. ppi.site = #{query.site}
  25. <if test="query.itemType != null and query.itemType != ''">
  26. and ppi.ItemType = #{query.itemType}
  27. </if>
  28. <if test="query.itemNo != null and query.itemNo != ''">
  29. AND ppi.ItemNo LIKE '%' + #{query.itemNo} + '%'
  30. </if>
  31. <if test="query.itemDesc != null and query.itemDesc != ''">
  32. AND ppi.ItemDesc LIKE '%' + #{query.itemDesc} + '%'
  33. </if>
  34. <if test="query.valueType != null and query.valueType != ''">
  35. AND ppi.valueType LIKE '%' + #{query.valueType} + '%'
  36. </if>
  37. </where>
  38. order by ppi.ItemType, ppi.ItemNo
  39. </select>
  40. <select id="checkPlmPropertiesItem" resultType="PlmPropertiesItemData">
  41. SELECT ItemNo, ItemDesc
  42. FROM plm_properties_item
  43. WHERE ItemNo = #{itemNo}
  44. and ItemType = #{itemType}
  45. and site = #{site}
  46. </select>
  47. <insert id="saveNewPlmPropertiesItem">
  48. Insert into plm_properties_item ( site, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag
  49. , CreatedDate
  50. , CreatedBy, MaxValue, MinValue, ItemType)
  51. values (#{site}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag},
  52. GetDate(),
  53. #{createdBy}, #{maxValue,jdbcType=DOUBLE}, #{minValue,jdbcType=DOUBLE}, #{itemType})
  54. </insert>
  55. <update id="plmPropertiesItemEdit">
  56. update plm_properties_item
  57. set ItemDesc=#{itemDesc},
  58. DefaultValue=#{defaultValue},
  59. ValueType=#{valueType},
  60. ValueType_DB=#{valueTypeDb},
  61. ValueChooseFlag=#{valueChooseFlag},
  62. update_date=GetDate()
  63. ,
  64. update_by=#{updateBy},
  65. MaxValue=#{maxValue,jdbcType=DOUBLE},
  66. MinValue=#{minValue,jdbcType=DOUBLE},
  67. ItemType=#{itemType}
  68. WHERE ItemNo = #{itemNo}
  69. and ItemType = #{itemType}
  70. and site = #{site}
  71. </update>
  72. <delete id="propertiesItemDelete">
  73. Delete
  74. FROM plm_properties_item
  75. WHERE ItemNo = #{itemNo}
  76. and ItemType = #{itemType}
  77. and site = #{site}
  78. </delete>
  79. <select id="searchItemAvailable" resultType="PlmPropertiesItemAvailableData">
  80. SELECT site,
  81. ItemNo,
  82. ValueNo,
  83. AvailableValue,
  84. CreatedDate,
  85. CreatedBy,
  86. ItemType
  87. from plm_properties_item_available
  88. where itemNo = #{itemNo}
  89. and ItemType = #{itemType}
  90. and site = #{site}
  91. </select>
  92. <select id="getItemValueNo" resultType="Double">
  93. SELECT isnull(max(valueNo), 0) + 1
  94. from plm_properties_item_available
  95. where itemNo = #{itemNo}
  96. and ItemType = #{itemType}
  97. and site = #{site}
  98. </select>
  99. <insert id="saveItemAvailable">
  100. insert into plm_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType,
  101. site)
  102. values (#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site})
  103. </insert>
  104. <update id="updateItemAvailable">
  105. update plm_properties_item_available
  106. set AvailableValue = #{availableValue}
  107. where itemNo = #{itemNo}
  108. and ItemType = #{itemType}
  109. and ValueNo = #{valueNo}
  110. and site = #{site}
  111. </update>
  112. <delete id="deleteItemAvailable">
  113. delete
  114. from plm_properties_item_available
  115. where itemNo = #{itemNo}
  116. and ItemType = #{itemType}
  117. and ValueNo = #{valueNo}
  118. and site = #{site}
  119. </delete>
  120. <select id="plmPropertiesModelSearch" parameterType="PlmPropertiesModelHeaderData"
  121. resultType="PlmPropertiesModelHeaderData">
  122. SELECT pmh.site,
  123. pmh.function_type,
  124. pmh.code_no,
  125. pmh.code_desc,
  126. pmh.active,
  127. pmh.created_date,
  128. pmh.created_by,
  129. pmh.update_date,
  130. pmh.update_by,
  131. pmh.delflag,
  132. pmh.version,
  133. pmh.is_system,
  134. pr.function_group_desc,
  135. pg.menu_id as [group],
  136. pmh.function_group,
  137. pt.function_type_desc
  138. FROM plm_properties_model_header pmh
  139. left join properties_group pg
  140. on pg.site = pmh.site and pg.function_type = pmh.function_type and pg.code_no = pmh.code_no
  141. left join properties_bu bu
  142. on bu.site = pmh.site and bu.function_type = pmh.function_type and bu.code_no = pmh.code_no
  143. left join properties_type pt on pt.function_type = pmh.function_type
  144. left join properties_relationship pr
  145. on pr.function_group = pmh.function_group and pr.function_type = pmh.function_type
  146. <where>
  147. pmh.site = #{query.site}
  148. <if test="query.codeNo != null and query.codeNo != ''">
  149. AND pmh.code_no like '%' + #{query.codeNo} + '%'
  150. </if>
  151. <if test="query.codeDesc != null and query.codeDesc != ''">
  152. AND pmh.code_desc like '%' + #{query.codeDesc} + '%'
  153. </if>
  154. <if test="query.active != null and query.active != ''">
  155. AND pmh.active = #{query.active}
  156. </if>
  157. <if test="query.functionType != null and query.functionType != ''">
  158. and pmh.function_type = #{query.functionType}
  159. </if>
  160. <if test="query.group != null and query.group != ''">
  161. and pg.menu_id = #{query.group}
  162. </if>
  163. <if test="query.functionGroup != null and query.functionGroup != ''">
  164. and pmh.function_group = #{query.functionGroup}
  165. </if>
  166. <if test="query.buNo != null and query.buNo != ''">
  167. and bu.bu_no = #{query.buNo}
  168. </if>
  169. <if test="query.buNo == null or query.buNo == ''">
  170. and bu.bu_no is null
  171. </if>
  172. </where>
  173. </select>
  174. <insert id="plmPropertiesModelSave">
  175. insert into plm_properties_model_header
  176. (function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by,
  177. site, function_group)
  178. values (#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(),
  179. #{updateBy}, #{site}, #{functionGroup})
  180. </insert>
  181. <update id="plmPropertiesModelEdit">
  182. update plm_properties_model_header
  183. set version = version + 1,
  184. code_desc = #{codeDesc},
  185. function_group = #{functionGroup},
  186. active = #{active},
  187. update_by = #{updateBy},
  188. update_date = GetDate()
  189. where function_type = #{functionType}
  190. and code_no = #{codeNo}
  191. and site = #{site}
  192. </update>
  193. <select id="checkPropertiesModel" resultType="PlmPropertiesModelHeaderData">
  194. SELECT function_type,
  195. code_no,
  196. code_desc,
  197. active,
  198. created_date,
  199. created_by,
  200. update_date,
  201. update_by,
  202. delflag,
  203. version
  204. FROM plm_properties_model_header
  205. where function_type = #{functionType}
  206. and code_no = #{codeNo}
  207. and site = #{site}
  208. </select>
  209. <delete id="plmPropertiesModelDelete">
  210. delete
  211. from plm_properties_model_header
  212. where function_type = #{functionType}
  213. and code_no = #{codeNo}
  214. and site = #{site}
  215. </delete>
  216. <select id="searchModalDetails" resultType="PlmPropertiesModelDetailData">
  217. SELECT a.site,
  218. a.function_type,
  219. a.code_no,
  220. a.properties_item_no itemNo,
  221. a.seq_no,
  222. b.ItemDesc,
  223. b.DefaultValue,
  224. b.ValueType,
  225. b.ValueType_DB,
  226. b.ValueChooseFlag,
  227. b.MaxValue,
  228. b.MinValue,
  229. b.ItemType,
  230. order_id
  231. FROM plm_properties_model_detail a
  232. left join plm_properties_item b
  233. on a.function_type = b.itemType and a.properties_item_no = b.itemNo and a.site = b.site
  234. where a.function_type = #{functionType}
  235. and a.code_no = #{codeNo}
  236. and a.site = #{site}
  237. order by order_id
  238. </select>
  239. <select id="checkItem" resultType="PlmPropertiesModelDetailData">
  240. SELECT ItemDesc
  241. FROM plm_properties_item
  242. where itemType = #{functionType}
  243. and itemNo = #{itemNo}
  244. and site = #{site}
  245. </select>
  246. <select id="checkModalDetails" resultType="PlmPropertiesModelDetailData">
  247. SELECT function_type,
  248. code_no,
  249. properties_item_no itemNo,
  250. seq_no
  251. FROM plm_properties_model_detail
  252. where function_type = #{functionType}
  253. and code_no = #{codeNo}
  254. and properties_item_no = #{itemNo}
  255. and site = #{site}
  256. </select>
  257. <select id="getModalDetailSeqNo" resultType="Integer">
  258. SELECT isnull(max(seq_no), 0) + 1
  259. from plm_properties_model_detail
  260. where function_type = #{functionType}
  261. and code_no = #{codeNo}
  262. and site = #{site}
  263. </select>
  264. <insert id="saveModalDetails">
  265. insert into plm_properties_model_detail
  266. (function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, order_id)
  267. values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{orderId})
  268. </insert>
  269. <delete id="deleteModalDetails">
  270. delete
  271. from plm_properties_model_detail
  272. where function_type = #{functionType}
  273. and code_no = #{codeNo}
  274. and properties_item_no = #{itemNo}
  275. and site = #{site}
  276. </delete>
  277. <select id="getItemLists" resultType="PlmPropertiesItemData">
  278. SELECT a.itemNo,
  279. a.ItemDesc
  280. FROM plm_properties_item a
  281. LEFT JOIN plm_properties_model_detail b
  282. on b.function_type = #{functionType} and b.code_no = #{codeNo} and
  283. b.properties_item_no = a.ItemNo and a.site = b.site
  284. <where>
  285. a.ItemType = #{functionType}
  286. and a.site = #{site}
  287. AND b.code_no is null
  288. <if test="itemNo != null and itemNo != ''">
  289. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  290. </if>
  291. <if test="itemDesc != null and itemDesc != ''">
  292. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  293. </if>
  294. </where>
  295. </select>
  296. <select id="getModelItemLists" resultType="PlmPropertiesItemData">
  297. select a.properties_item_no itemNo,
  298. b.ItemDesc
  299. from plm_properties_model_detail a
  300. left join plm_properties_item b
  301. on a.properties_item_no = b.ItemNo and a.function_type = b.ItemType and a.site = b.site
  302. where a.code_no = #{codeNo}
  303. and a.function_type = #{functionType}
  304. and a.site = #{site}
  305. </select>
  306. <select id="getItemListsForPartAndCode" resultType="PlmPropertiesItemData">
  307. select a.PropertiesItemNo itemNo,
  308. b.ItemDesc
  309. from PartSubPropertiesValue a
  310. left join plm_properties_item b
  311. on a.PropertiesItemNo = b.ItemNo and a.RecordType = b.ItemType and a.site = b.site
  312. where a.code_no = #{codeNo}
  313. and a.RecordType = #{functionType}
  314. and a.site = #{site}
  315. and a.partNo = #{partNo}
  316. </select>
  317. <select id="searchPropertiesUnChoose" resultType="PlmPropertiesItemData">
  318. SELECT b.site,
  319. b.ItemType as functionType,
  320. b.ItemNo,
  321. b.ItemDesc,
  322. b.DefaultValue,
  323. b.ValueType,
  324. b.ValueType_DB,
  325. b.ValueChooseFlag,
  326. b.MaxValue,
  327. b.MinValue
  328. FROM plm_properties_item b
  329. where b.ItemType = #{codeType}
  330. and b.site = #{site}
  331. <if test="list != null and list.size() != 0">
  332. and b.ItemNo not in (
  333. <foreach collection="list" item="item" separator=",">
  334. #{item}
  335. </foreach>
  336. )
  337. </if>
  338. </select>
  339. <select id="checkValueHeaderData" resultType="PartSubPropertiesValueHeaderData">
  340. SELECT PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType
  341. from PartSubPropertiesValueHeader
  342. where PartNo = #{testPartNo}
  343. and site = #{site}
  344. and CodeNo = #{codeNo}
  345. and RecordType = 'IP'
  346. </select>
  347. <delete id="deletePartSubPropertiesValueHeader">
  348. delete
  349. from PartSubPropertiesValueHeader
  350. where PartNo = #{testPartNo}
  351. and site = #{site}
  352. and RecordType = 'IP'
  353. </delete>
  354. <delete id="deletePartSubPropertiesValue">
  355. delete
  356. from PartSubPropertiesValue
  357. where PartNo = #{testPartNo}
  358. and site = #{site}
  359. and RecordType = 'IP'
  360. </delete>
  361. <insert id="savePartSubPropertiesValueHeader">
  362. insert into PartSubPropertiesValueHeader (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
  363. select #{testPartNo}, #{site}, #{codeNo}, 1, Code_Desc, 'IP'
  364. from plm_properties_model_header
  365. where Code_No = #{codeNo}
  366. and site = #{site}
  367. and function_type = 'IP'
  368. </insert>
  369. <insert id="savePartSubPropertiesValue">
  370. insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
  371. , ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
  372. select #{testPartNo},
  373. #{site},
  374. #{codeNo},
  375. 1,
  376. a.Code_Desc,
  377. b.seq_No,
  378. b.properties_item_no,
  379. case
  380. when c.ValueType_DB = 'T' then c.DefaultValue
  381. else null end,
  382. case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue else null end,
  383. 'IP'
  384. from plm_properties_model_header a
  385. left join plm_properties_model_detail b
  386. on a.Code_No = b.Code_No and a.site = b.site and a.function_type = b.function_type
  387. left join plm_properties_item c
  388. on b.properties_item_no = c.ItemNo and b.site = c.site and a.function_type = c.itemType
  389. where a.Code_No = #{codeNo}
  390. and a.site = #{site}
  391. AND B.SITE IS NOT NULL
  392. AND A.function_type = 'IP'
  393. </insert>
  394. <select id="getItemModal" resultType="PartSubPropertiesValueData">
  395. SELECT a.PartNo
  396. , a.Site
  397. , a.CodeNo
  398. , a.SubCodeSeqNo
  399. , a.SubCodeDesc
  400. , a.ItemNo
  401. , a.PropertiesItemNo
  402. , a.TextValue
  403. , a.NumValue
  404. , a.RecordType
  405. , b.ItemDesc ItemDesc
  406. , b.ValueType
  407. , b.ValueType_DB
  408. , b.ValueChooseFlag
  409. FROM PartSubPropertiesValue a
  410. left join plm_properties_item b
  411. on a.PropertiesItemNo = b.ItemNo and a.site = b.site and a.RecordType = b.ItemType
  412. <where>
  413. AND a.site = #{site}
  414. and RecordType = 'IP'
  415. AND a.PartNo = #{partNo,jdbcType=VARCHAR}
  416. </where>
  417. </select>
  418. <select id="checkItemNo" resultType="PartSubPropertiesValueData">
  419. select ValueType_DB
  420. from plm_properties_item
  421. where itemNo = #{propertiesItemNo}
  422. and site = #{site}
  423. and ItemType = 'IP'
  424. </select>
  425. <select id="getAvailableValueList" resultType="PlmPropertiesItemAvailableData">
  426. select ItemNo, ValueNo, AvailableValue
  427. from plm_properties_item_available
  428. where itemNo = #{propertiesItemNo}
  429. and site = #{site}
  430. and ItemType = 'IP'
  431. </select>
  432. <update id="updateToolItem">
  433. update PartSubPropertiesValue
  434. set TextValue=#{textValue},
  435. NumValue=#{numValue,jdbcType=DOUBLE}
  436. where PropertiesItemNo = #{propertiesItemNo}
  437. and site = #{site}
  438. and PartNo = #{partNo}
  439. and RecordType = 'IP'
  440. </update>
  441. <insert id="refreshItemModal">
  442. insert into PartSubPropertiesValue(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc,
  443. ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
  444. select #{partNo},
  445. #{site},
  446. a.CodeNo,
  447. 1,
  448. a.SubCodeDesc,
  449. b.seq_No,
  450. b.properties_item_no,
  451. case
  452. when e.ValueType_DB = 'T' then e.DefaultValue
  453. else null end,
  454. case when e.ValueType_DB = 'N' and e.DefaultValue != '' then e.DefaultValue else null end,
  455. 'IP'
  456. from PartSubPropertiesValueHeader a
  457. left join plm_properties_model_detail b
  458. on a.CodeNo = b.Code_No and a.site = b.site and a.RecordType = b.function_type
  459. left join PartSubPropertiesValue c
  460. on c.Site = #{site} and c.PartNo = #{partNo} and c.RecordType = 'IP' and
  461. b.seq_no = c.ItemNo and a.RecordType = b.function_type
  462. left join plm_properties_item e
  463. on b.properties_item_no = e.ItemNo and a.site = e.site and a.RecordType = e.ItemType
  464. where c.ItemNo is null
  465. and a.RecordType = 'IP'
  466. and a.PartNo = #{partNo}
  467. and a.site = #{site}
  468. </insert>
  469. <select id="propertiesModelSearchForBM" parameterType="PlmBmModelHeaderData" resultType="PlmBmModelHeaderData">
  470. SELECT site,
  471. bu_no,
  472. dbo.plm_get_bu_desc(site, bu_no) buDesc,
  473. function_type,
  474. code_no,
  475. code_desc,
  476. active,
  477. created_date,
  478. created_by,
  479. update_date,
  480. update_by,
  481. delflag,
  482. version,
  483. edit_flag,
  484. properties_code_no,
  485. dbo.get_properties_codeDesc(site, function_type, properties_code_no) properties_code_desc
  486. FROM plm_bm_model_header
  487. <where>
  488. site = #{query.site}
  489. <if test="query.codeNo != null and query.codeNo != ''">
  490. AND code_no like '%' + #{query.codeNo} + '%'
  491. </if>
  492. <if test="query.codeDesc != null and query.codeDesc != ''">
  493. AND code_desc like '%' + #{query.codeDesc} + '%'
  494. </if>
  495. <if test="query.active != null and query.active != ''">
  496. AND active = #{query.active}
  497. </if>
  498. <if test="query.buNo != null and query.buNo != ''">
  499. AND bu_no = #{query.buNo}
  500. </if>
  501. <if test="query.functionType != null and query.functionType != ''">
  502. and function_type = #{query.functionType}
  503. </if>
  504. <if test="query.editFlag != null and query.editFlag != ''">
  505. and edit_flag = #{query.editFlag}
  506. </if>
  507. <if test="query.username != null and query.username != '' and query.username != 'admin'">
  508. AND bu_no in (select bu_no from AccessBu where site = #{query.site} and username = #{query.username})
  509. </if>
  510. </where>
  511. order by bu_no, order_id
  512. </select>
  513. <select id="searchModalDetailsForBM" resultType="PlmBmModelDetailData">
  514. SELECT a.site,
  515. a.function_type,
  516. a.code_no,
  517. pd.properties_item_no itemNo,
  518. pd.seq_no,
  519. b.ItemDesc,
  520. b.DefaultValue,
  521. b.ValueType,
  522. b.ValueType_DB,
  523. b.ValueChooseFlag,
  524. b.MaxValue,
  525. b.MinValue,
  526. a.bu_no,
  527. b.ItemType,
  528. pd.order_id
  529. FROM plm_bm_model_header a
  530. left join plm_properties_model_detail pd
  531. on a.site = pd.site and pd.function_type = 'BM' and a.properties_code_no = pd.code_no
  532. left join plm_properties_item b
  533. on pd.function_type = b.itemType and pd.properties_item_no = b.itemNo and pd.site = b.site
  534. where a.function_type = #{functionType}
  535. and a.code_no = #{codeNo}
  536. and a.site = #{site}
  537. and a.bu_No = #{buNo}
  538. and pd.properties_item_no is not null
  539. order by order_id
  540. </select>
  541. <select id="getItemListsForBM" resultType="PlmPropertiesItemData">
  542. SELECT a.itemNo,
  543. a.ItemDesc
  544. FROM plm_properties_item a
  545. LEFT JOIN plm_bm_model_detail b on b.function_type = #{functionType} and b.code_no = #{codeNo} and
  546. b.properties_item_no = a.ItemNo and a.site = b.site and
  547. b.bu_no = #{buNo}
  548. <where>
  549. a.ItemType = #{functionType}
  550. and a.site = #{site}
  551. AND b.code_no is null
  552. <if test="itemNo != null and itemNo != ''">
  553. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  554. </if>
  555. <if test="itemDesc != null and itemDesc != ''">
  556. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  557. </if>
  558. </where>
  559. </select>
  560. <select id="getModelItemListsForBM" resultType="PlmPropertiesItemData">
  561. select a.properties_item_no itemNo,
  562. b.ItemDesc
  563. from plm_bm_model_detail a
  564. left join plm_properties_item b
  565. on a.properties_item_no = b.ItemNo and a.function_type = b.ItemType and a.site = b.site
  566. where a.code_no = #{codeNo}
  567. and a.function_type = #{functionType}
  568. and a.site = #{site}
  569. and a.bu_no = #{buNo}
  570. </select>
  571. <select id="checkModalDetailsForBM" resultType="PlmBmModelDetailData">
  572. SELECT function_type,
  573. code_no,
  574. properties_item_no itemNo,
  575. seq_no
  576. FROM plm_bm_model_detail
  577. where function_type = #{functionType}
  578. and code_no = #{codeNo}
  579. and properties_item_no = #{itemNo}
  580. and site = #{site}
  581. and bu_No = #{buNo}
  582. </select>
  583. <select id="getModalDetailSeqNoForBM" resultType="Integer">
  584. SELECT isnull(max(seq_no), 0) + 1
  585. from plm_bm_model_detail
  586. where function_type = #{functionType}
  587. and code_no = #{codeNo}
  588. and site = #{site}
  589. and bu_no = #{buNo}
  590. </select>
  591. <select id="getModalDetailOrderId" resultType="Integer">
  592. SELECT isnull(max(order_id), 0) + 1
  593. from plm_properties_model_detail
  594. where function_type = #{functionType}
  595. and code_no = #{codeNo}
  596. and site = #{site}
  597. </select>
  598. <insert id="saveModalDetailsForBM">
  599. insert into plm_bm_model_detail
  600. (function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, bu_no,
  601. order_id)
  602. values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{buNo},
  603. #{orderId})
  604. </insert>
  605. <select id="getPropertiesListByPartAndCodeNo" resultType="PartSubPropertiesValueData">
  606. SELECT a.PartNo
  607. , a.Site
  608. , a.CodeNo
  609. , a.SubCodeSeqNo
  610. , a.SubCodeDesc
  611. , a.ItemNo
  612. , a.PropertiesItemNo
  613. , a.TextValue
  614. , a.NumValue
  615. , a.RecordType
  616. , b.ItemDesc ItemDesc
  617. , b.ValueType
  618. , b.ValueType_DB
  619. , b.ValueChooseFlag
  620. FROM PartSubPropertiesValue a
  621. left join plm_properties_item b
  622. on a.PropertiesItemNo = b.ItemNo and a.site = b.site and a.RecordType = b.ItemType
  623. <where>
  624. AND a.site = #{site}
  625. and a.RecordType = #{recordType}
  626. and a.codeNo = #{codeNo}
  627. AND a.PartNo = #{partNo,jdbcType=VARCHAR}
  628. </where>
  629. order by a.order_id
  630. </select>
  631. <update id="updatePropertiesList">
  632. update PartSubPropertiesValue
  633. set TextValue=#{textValue},
  634. NumValue=#{numValue,jdbcType=DOUBLE}
  635. where Site = #{site}
  636. and CodeNo = #{codeNo}
  637. and PartNo = #{partNo}
  638. and SubCodeSeqNo = #{subCodeSeqNo}
  639. and itemNo = #{itemNo}
  640. </update>
  641. <delete id="deleteModalDetailsForBM">
  642. delete
  643. from plm_bm_model_detail
  644. where function_type = #{functionType}
  645. and code_no = #{codeNo}
  646. and properties_item_no = #{itemNo}
  647. and site = #{site}
  648. and bu_no = #{buNo}
  649. </delete>
  650. <select id="getUpItemdata" resultType="com.spring.modules.base.entity.PlmPropertiesModelDetail">
  651. select top 1 site,
  652. function_type,
  653. code_no,
  654. properties_item_no,
  655. seq_no,
  656. created_date,
  657. created_by,
  658. update_date,
  659. update_by,
  660. delflag,
  661. version,
  662. order_id
  663. from plm_properties_model_detail
  664. where #{orderId} > order_id
  665. and site = #{site}
  666. and code_no = #{codeNo}
  667. and function_type = #{functionType}
  668. order by order_id desc
  669. </select>
  670. <select id="getDownItemdata" resultType="com.spring.modules.base.entity.PlmPropertiesModelDetail">
  671. select top 1 site,
  672. function_type,
  673. code_no,
  674. properties_item_no,
  675. seq_no,
  676. created_date,
  677. created_by,
  678. update_date,
  679. update_by,
  680. delflag,
  681. version,
  682. order_id
  683. from plm_properties_model_detail
  684. where order_id > #{orderId}
  685. and site = #{site}
  686. and code_no = #{codeNo}
  687. and function_type = #{functionType}
  688. order by order_id
  689. </select>
  690. <update id="updatePlmPropertiesModelDetailOrder">
  691. update plm_properties_model_detail
  692. set order_id=#{orderId}
  693. where site = #{site}
  694. and code_no = #{codeNo}
  695. and function_type = #{functionType}
  696. and seq_no = #{seqNo}
  697. </update>
  698. <select id="propertiesListSearch" resultType="com.spring.modules.base.entity.PlmPropertiesModelHeader">
  699. SELECT site,
  700. function_type,
  701. code_no,
  702. code_desc,
  703. active,
  704. created_date,
  705. created_by,
  706. update_date,
  707. update_by,
  708. delflag,
  709. version
  710. FROM plm_properties_model_header
  711. <where>
  712. site = #{site}
  713. and active = 'Y'
  714. <if test="codeNo != null and codeNo != ''">
  715. AND code_no like '%' + #{codeNo} + '%'
  716. </if>
  717. <if test="codeDesc != null and codeDesc != ''">
  718. AND code_desc like '%' + #{codeDesc} + '%'
  719. </if>
  720. <if test="functionType != null and functionType != ''">
  721. and function_type = #{functionType}
  722. </if>
  723. </where>
  724. </select>
  725. <select id="searchWorkCenterBMType" resultType="WorkCenterBMTypeData">
  726. select a.site, a.work_center_no, a.work_center_desc, b.itemType, c.type_desc
  727. from work_center a
  728. left join WorkCenter_BMType b on a.site = b.site and a.work_center_no = b.workCenterNo
  729. left join plm_route_itemType c on b.itemType = c.item_type
  730. where a.site = #{site}
  731. </select>
  732. <delete id="deleteWorkCenterBMType">
  733. delete
  734. from WorkCenter_BMType
  735. where site = #{site}
  736. and workCenterNo = #{workCenterNo}
  737. </delete>
  738. <update id="updateWorkCenterBMType">
  739. update WorkCenter_BMType
  740. set itemType=#{itemType},
  741. update_by=#{updateBy},
  742. update_date=GetDate()
  743. where site = #{site}
  744. and workCenterNo = #{workCenterNo}
  745. </update>
  746. <insert id="insertWorkCenterBMType">
  747. insert into WorkCenter_BMType (site, workCenterNo, itemType, update_by, update_date)
  748. values (#{site}, #{workCenterNo}, #{itemType}, #{updateBy}, GetDate())
  749. </insert>
  750. <select id="getPlmRouteItemType" resultType="PlmRouteItemType">
  751. select item_type, type_desc
  752. from plm_route_itemType
  753. </select>
  754. <select id="searchMenuAllListId" resultType="com.spring.modules.sys.entity.SysMenuEntity">
  755. select menu_id, name
  756. from sys_menu
  757. where parent_id = 0
  758. and menu_id not in (999)
  759. and menu_type = 'pc'
  760. </select>
  761. <select id="searchBUList" resultType="com.spring.modules.base.entity.Bu">
  762. select bu_no, bu_desc
  763. from BU
  764. where site = #{site}
  765. and active = 'Y'
  766. </select>
  767. <select id="searchBUPropertiesList" resultType="com.spring.modules.base.entity.Bu">
  768. select a.bu_no, b.bu_desc
  769. from properties_bu a
  770. left join BU b on a.site = b.site and a.bu_no = b.bu_no
  771. <where>
  772. <if test="functionType != null and functionType != ''">
  773. and a.function_type = #{functionType}
  774. </if>
  775. <if test="codeNo != null and codeNo != ''">
  776. and a.code_no = #{codeNo}
  777. </if>
  778. <if test="site != null and site != ''">
  779. and a.site = #{site}
  780. </if>
  781. </where>
  782. </select>
  783. <select id="searchAllItemTypeList" resultType="com.spring.modules.sys.entity.DictData">
  784. select dict_label, dict_value
  785. from sys_dict_data
  786. where site = #{site}
  787. and dict_type in
  788. (select menu_id from sys_menu where parent_id = 0 and menu_id not in (999) and menu_type = 'pc')
  789. </select>
  790. <select id="searchAllTypeList" resultType="java.util.Map">
  791. select function_type as functionType, function_type_desc as functionTypeDesc
  792. from properties_type
  793. </select>
  794. <select id="searchAllTypeRelationshipList" resultType="java.util.Map">
  795. select function_group as functionGroup, function_group_desc as functionGroupDesc
  796. from properties_relationship
  797. where function_type = #{type}
  798. </select>
  799. <insert id="saveSubPropertiesValue">
  800. insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
  801. , ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id)
  802. select #{partNo},
  803. #{site},
  804. #{codeNo},
  805. 1,
  806. a.Code_Desc,
  807. b.seq_No,
  808. b.properties_item_no,
  809. case
  810. when c.ValueType_DB = 'T' then c.DefaultValue
  811. else null end,
  812. case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue else null end,
  813. #{recordType},
  814. isnull(b.order_id, 999)
  815. from plm_properties_model_header a
  816. left join plm_properties_model_detail b
  817. on a.Code_No = b.Code_No and a.site = b.site and a.function_type = b.function_type
  818. left join plm_properties_item c
  819. on b.properties_item_no = c.ItemNo and b.site = c.site and a.function_type = c.itemType
  820. where a.Code_No = #{codeNo}
  821. and a.site = #{site}
  822. AND B.SITE IS NOT NULL
  823. AND A.function_type = #{recordType}
  824. </insert>
  825. <insert id="saveSubPropertiesValueHeader">
  826. insert into PartSubPropertiesValueHeader (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
  827. select #{partNo}, #{site}, #{codeNo}, 1, Code_Desc, #{recordType}
  828. from plm_properties_model_header
  829. where Code_No = #{codeNo}
  830. and site = #{site}
  831. and function_type = #{recordType}
  832. </insert>
  833. <insert id="saveSubPropertiesValueForAlone">
  834. insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
  835. , ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id)
  836. select #{partNo},
  837. #{site},
  838. #{codeNo},
  839. 1,
  840. d.SubCodeDesc,
  841. #{itemNo,jdbcType=DOUBLE},
  842. #{propertiesItemNo},
  843. case
  844. when c.ValueType_DB = 'T' then c.DefaultValue
  845. else null end,
  846. case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue else null end,
  847. #{recordType},
  848. #{itemNo,jdbcType=DOUBLE}
  849. from plm_properties_item c
  850. left join PartSubPropertiesValueHeader d
  851. on d.PartNo = #{partNo} and d.site = #{site} and CodeNo = #{codeNo} and
  852. RecordType = #{recordType}
  853. where c.ItemNo = #{propertiesItemNo}
  854. and c.site = #{site}
  855. and c.itemType = #{recordType}
  856. </insert>
  857. <delete id="deleteSubPropertiesValueForAlone">
  858. delete
  859. from PartSubPropertiesValue
  860. where Site = #{site}
  861. and PartNo = #{partNo}
  862. and CodeNo = #{codeNo}
  863. and PropertiesItemNo = #{propertiesItemNo}
  864. and RecordType = #{recordType}
  865. </delete>
  866. <select id="getNewSeqNoForAlone" resultType="Double">
  867. select isnull(Max(itemNo) + 1, 1)
  868. from PartSubPropertiesValue
  869. where Site = #{site}
  870. and PartNo = #{partNo}
  871. and CodeNo = #{codeNo}
  872. and RecordType = #{recordType}
  873. </select>
  874. <delete id="removeSubPropertiesValue">
  875. delete
  876. from PartSubPropertiesValue
  877. where Site = #{site}
  878. and PartNo = #{partNo}
  879. and CodeNo = #{codeNo}
  880. and RecordType = #{recordType}
  881. </delete>
  882. <delete id="removeSubPropertiesValueHeader">
  883. delete from PartSubPropertiesValueHeader
  884. where Site = #{site}
  885. and PartNo = #{partNo}
  886. and CodeNo = #{codeNo}
  887. and RecordType = #{recordType}
  888. </delete>
  889. </mapper>