DictionaryMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.tld.mapper.DictionaryMapper">
  5. <!-- 查询字典表明 -->
  6. <select id="getTableName" resultType="String">
  7. select table_name
  8. from tld_dictionary_pulic
  9. where name = #{type}
  10. </select>
  11. <!-- 物料字典新增 -->
  12. <insert id="addMaterial">
  13. insert into tld_material(code, name, tld_id, specification_and_model, unit_of_measurement, size, is_not_disable,
  14. is_recommend, min_num, max_num, type, company_number)
  15. values (#{code}, #{name}, #{tldId}, #{specificationAndModel}, #{unitOfMeasurement}, '0', '0', '0', "0", "0",
  16. #{typeVal}, '0')
  17. </insert>
  18. <!-- 字典新增 -->
  19. <insert id="addDictionary">
  20. insert into ${tableName}(code, name, tld_id, type)
  21. values (#{code}, #{name}, #{tldId}, #{typeVal})
  22. </insert>
  23. <!-- 查询字典内容 -->
  24. <select id="getDictionary" resultType="com.tld.model.Dictionary">
  25. select * from ${tableName}
  26. <trim prefix="WHERE" prefixOverrides="and |or">
  27. <if test="name != null and name != ''">
  28. and name like CONCAT(CONCAT('%', #{name}), '%')
  29. </if>
  30. <if test="code != null and code != ''">
  31. and code like CONCAT(CONCAT('%', #{code}), '%')
  32. </if>
  33. <if test="nameOrCode != null and nameOrCode != ''">
  34. and (code like CONCAT(CONCAT('%', #{nameOrCode}), '%') or name like CONCAT(CONCAT('%', #{nameOrCode}), '%'))
  35. </if>
  36. <if test="tldId != null and tldId != ''">
  37. and tld_id = #{tldId}
  38. </if>
  39. <if test="id != null and id != ''">
  40. and id = #{id}
  41. </if>
  42. </trim>
  43. </select>
  44. <!-- 查询字典内容分页 -->
  45. <select id="getDictionaryPage" resultType="com.tld.model.Dictionary">
  46. select
  47. *
  48. from ${tableName}
  49. <trim prefix="WHERE" prefixOverrides="and |or">
  50. <if test="name != null and name != ''">
  51. and name like CONCAT(CONCAT('%', #{name}), '%')
  52. </if>
  53. <if test="code != null and code != ''">
  54. and code like CONCAT(CONCAT('%', #{code}), '%')
  55. </if>
  56. <if test="wllbClass != null and wllbClass != ''">
  57. and wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  58. </if>
  59. <if test="materialType != null and materialType != ''">
  60. and part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  61. </if>
  62. <if test="isNotDisable != null and isNotDisable != ''">
  63. and is_not_disable = #{isNotDisable}
  64. </if>
  65. <if test="isRecommend != null and isRecommend != ''">
  66. and is_recommend = #{isRecommend}
  67. </if>
  68. <if test="tldId != null and tldId != ''">
  69. and tld_id like CONCAT(CONCAT('%', #{tldId}), '%')
  70. </if>
  71. <if test="typeVal != null and typeVal != ''">
  72. and type = #{typeVal}
  73. </if>
  74. <if test="nameOrCode != null and nameOrCode != ''">
  75. and code like CONCAT(CONCAT('%', #{code}), '%') or name like CONCAT(CONCAT('%', #{name}), '%')
  76. </if>
  77. </trim>
  78. order by id desc
  79. </select>
  80. <!-- 库账对存字典新增 -->
  81. <insert id="addTreasuryAccount">
  82. insert into tld_inventory_gs(material_id, amount, account_sleeve)
  83. values (#{materialId}, #{num}, #{typeVal})
  84. </insert>
  85. <!-- 查询仓库id -->
  86. <select id="getWarehouse" resultType="String">
  87. select warehouse_where
  88. from tld_storage_location
  89. where storage_location_code = #{storageLocationCode}
  90. </select>
  91. <!-- 查询仓库字典 -->
  92. <select id="getWarehouseInfo" resultType="com.tld.model.Dictionary">
  93. select code, name, tld_id
  94. from tld_warehouse
  95. where tld_id = #{askGoodsWarehouseId}
  96. </select>
  97. <!-- 查询物料库存内容 -->
  98. <select id="getInventorySumAmount" resultType="int">
  99. select ifnull(sum(amount), 0)
  100. from tld_inventory
  101. where material_id = #{tldId}
  102. </select>
  103. <!-- 查询字典内容分页 -->
  104. <select id="getDictionaryMaterialPage" resultType="com.tld.model.Dictionary">
  105. select
  106. a.*,b.name as materialType,c.user_name as modifyUser
  107. from ${tableName} a
  108. left join tld_material_type b on a.wllb_class = b.tld_id
  109. left join tld_user c on a.modify_user = c.id
  110. <trim prefix="WHERE" prefixOverrides="and |or">
  111. <if test="name != null and name != ''">
  112. and a.name = #{name}
  113. </if>
  114. <if test="code != null and code != ''">
  115. and a.code = #{code}
  116. </if>
  117. <if test="tldId != null and tldId != ''">
  118. and a.tld_id = #{tldId}
  119. </if>
  120. <if test="typeVal != null and typeVal != ''">
  121. and a.type = #{typeVal}
  122. </if>
  123. </trim>
  124. </select>
  125. <!--判断是否是重复数据-->
  126. <select id="getTableNameList" resultType="com.tld.model.Dictionary">
  127. select *
  128. from ${tableName}
  129. where code = #{code}
  130. </select>
  131. <!--物料字典导出-->
  132. <select id="export" resultType="java.util.LinkedHashMap">
  133. select
  134. a.code,
  135. a.name,
  136. if(a.part_type = '', null , a.part_type) as partType ,
  137. if(a.wllb_class = '', null ,a.wllb_class) as wllbClass ,
  138. if(a.size = '', null , size) as size,
  139. if(a.max_num = '', null , a.max_num) as maxNum,
  140. if(a.min_num = '', null , a.min_num) as minNum,
  141. if(a.is_not_disable = '1', '是' , '否') as isNotdisable ,
  142. if(a.is_recommend = '1', '是' , '否' ) as isRecommend
  143. from tld_material a
  144. left join tld_user f on a.modify_user = f.id
  145. <trim prefix="WHERE" prefixOverrides="and |or">
  146. <if test="name != null and name != ''">
  147. and a.name like CONCAT(CONCAT('%', #{name}), '%')
  148. </if>
  149. <if test="code != null and code != ''">
  150. and a.code like CONCAT(CONCAT('%', #{code}), '%')
  151. </if>
  152. <if test="wllbClass != null and wllbClass != ''">
  153. and a.wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  154. </if>
  155. <if test="materialType != null and materialType != ''">
  156. and a.part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  157. </if>
  158. <if test="modifyUser != null and modifyUser != ''">
  159. and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
  160. </if>
  161. <if test="isNotDisable != null and isNotDisable != ''">
  162. and a.is_not_disable = #{isNotDisable}
  163. </if>
  164. <if test="isRecommend != null and isRecommend != ''">
  165. and a.is_recommend = #{isRecommend}
  166. </if>
  167. <if test="tldId != null and tldId != ''">
  168. and a.tld_id = #{tldId}
  169. </if>
  170. </trim>
  171. order by a.id desc
  172. </select>
  173. <!-- 查询物料字典内容分页 -->
  174. <select id="getDictionaryPageMaterial" resultType="com.tld.model.Dictionary">
  175. select
  176. a.*,
  177. f.user_name as modifyUser
  178. from tld_material a
  179. left join tld_user f on a.modify_user = f.id
  180. <trim prefix="WHERE" prefixOverrides="and |or">
  181. <if test="name != null and name != ''">
  182. and a.name like CONCAT(CONCAT('%', #{name}), '%')
  183. </if>
  184. <if test="code != null and code != ''">
  185. and a.code like CONCAT(CONCAT('%', #{code}), '%')
  186. </if>
  187. <if test="wllbClass != null and wllbClass != ''">
  188. and a.wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  189. </if>
  190. <if test="materialType != null and materialType != ''">
  191. and a.part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  192. </if>
  193. <if test="modifyUser != null and modifyUser != ''">
  194. and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
  195. </if>
  196. <if test="isNotDisable != null and isNotDisable != ''">
  197. and a.is_not_disable = #{isNotDisable}
  198. </if>
  199. <if test="isRecommend != null and isRecommend != ''">
  200. and a.is_recommend = #{isRecommend}
  201. </if>
  202. <if test="tldId != null and tldId != ''">
  203. and a.tld_id like CONCAT(CONCAT('%', #{tldId}), '%')
  204. </if>
  205. <if test="typeVal != null and typeVal != ''">
  206. and a.type = #{typeVal}
  207. </if>
  208. <if test="nameOrCode != null and nameOrCode != ''">
  209. and code like CONCAT(CONCAT('%', #{nameOrCode}), '%') or name like CONCAT(CONCAT('%', #{nameOrCode}), '%')
  210. </if>
  211. </trim>
  212. order by a.id desc
  213. </select>
  214. <!--查询仓库字典分页内容-->
  215. <select id="getDictionaryPageWarehouse" resultType="com.tld.model.Dictionary">
  216. select
  217. a.id,
  218. a.code,
  219. a.name,
  220. a.tld_id,
  221. a.type,
  222. case a.warehouse_type when '0' then '原材料仓库' when '1' then '半成品仓库' when '2' then '产成品仓库'
  223. else null
  224. end as warehouseType
  225. from tld_warehouse a
  226. <trim prefix="WHERE" prefixOverrides="and |or">
  227. <if test="name != null and name != ''">
  228. and a.name like CONCAT(CONCAT('%', #{name}), '%')
  229. </if>
  230. <if test="code != null and code != ''">
  231. and a.code like CONCAT(CONCAT('%', #{code}), '%')
  232. </if>
  233. <if test="wllbClass != null and wllbClass != ''">
  234. and a.wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  235. </if>
  236. <if test="materialType != null and materialType != ''">
  237. and a.part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  238. </if>
  239. <if test="isNotDisable != null and isNotDisable != ''">
  240. and a.is_not_disable = #{isNotDisable}
  241. </if>
  242. <if test="warehouseType != null and warehouseType != ''">
  243. and a.warehouse_type = #{warehouseType}
  244. </if>
  245. <if test="isRecommend != null and isRecommend != ''">
  246. and a.is_recommend = #{isRecommend}
  247. </if>
  248. <if test="tldId != null and tldId != ''">
  249. and a.tld_id like CONCAT(CONCAT('%', #{tldId}), '%')
  250. </if>
  251. <if test="typeVal != null and typeVal != ''">
  252. and a.type = #{typeVal}
  253. </if>
  254. </trim>
  255. order by a.id desc
  256. </select>
  257. <!--导出其他字典-->
  258. <select id="elseExport" resultType="java.util.LinkedHashMap">
  259. select
  260. code,
  261. name,
  262. tld_id
  263. from ${tableName}
  264. <trim prefix="WHERE" prefixOverrides="and |or">
  265. <if test="name != null and name != ''">
  266. and name like CONCAT(CONCAT('%', #{name}), '%')
  267. </if>
  268. <if test="code != null and code != ''">
  269. and code like CONCAT(CONCAT('%', #{code}), '%')
  270. </if>
  271. <if test="wllbClass != null and wllbClass != ''">
  272. and wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  273. </if>
  274. <if test="materialType != null and materialType != ''">
  275. and part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  276. </if>
  277. <if test="isNotDisable != null and isNotDisable != ''">
  278. and is_not_disable = #{isNotDisable}
  279. </if>
  280. <if test="isRecommend != null and isRecommend != ''">
  281. and is_recommend = #{isRecommend}
  282. </if>
  283. <if test="tldId != null and tldId != ''">
  284. and tld_id like CONCAT(CONCAT('%', #{tldId}), '%')
  285. </if>
  286. <if test="typeVal != null and typeVal != ''">
  287. and type = #{typeVal}
  288. </if>
  289. </trim>
  290. order by id desc
  291. </select>
  292. <!--仓库字典导出-->
  293. <select id="warehouseExport" resultType="java.util.LinkedHashMap">
  294. select
  295. code,
  296. name,
  297. tld_id,
  298. case warehouse_type when '0' then '原材料仓库' when '1' then '半成品仓库' when '2' then '产成品仓库' else null end
  299. from tld_warehouse
  300. <trim prefix="WHERE" prefixOverrides="and |or">
  301. <if test="name != null and name != ''">
  302. and name like CONCAT(CONCAT('%', #{name}), '%')
  303. </if>
  304. <if test="code != null and code != ''">
  305. and code like CONCAT(CONCAT('%', #{code}), '%')
  306. </if>
  307. <if test="wllbClass != null and wllbClass != ''">
  308. and wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  309. </if>
  310. <if test="materialType != null and materialType != ''">
  311. and part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  312. </if>
  313. <if test="isNotDisable != null and isNotDisable != ''">
  314. and is_not_disable = #{isNotDisable}
  315. </if>
  316. <if test="warehouseType != null and warehouseType != ''">
  317. and warehouse_type = #{warehouseType}
  318. </if>
  319. <if test="isRecommend != null and isRecommend != ''">
  320. and is_recommend = #{isRecommend}
  321. </if>
  322. <if test="tldId != null and tldId != ''">
  323. and tld_id like CONCAT(CONCAT('%', #{tldId}), '%')
  324. </if>
  325. <if test="typeVal != null and typeVal != ''">
  326. and type = #{typeVal}
  327. </if>
  328. </trim>
  329. order by id desc
  330. </select>
  331. <!--查询物料-->
  332. <select id="getMaterial" resultType="java.util.Map">
  333. select
  334. id,
  335. code,
  336. name,
  337. tld_id as tldId
  338. from tld_material
  339. <trim prefix="WHERE" prefixOverrides="and |or">
  340. <if test="partType != null and partType != ''">
  341. and part_type like CONCAT(CONCAT('%', #{partType}), '%')
  342. </if>
  343. <if test="code != null and code != ''">
  344. and code like CONCAT(CONCAT('%', #{code}), '%')
  345. </if>
  346. <if test="name != null and name != ''">
  347. and name like CONCAT(CONCAT('%', #{name}), '%')
  348. </if>
  349. <if test="nameOrCode != null and nameOrCode != ''">
  350. and (code like CONCAT(CONCAT('%', #{nameOrCode}), '%') or name like CONCAT(CONCAT('%', #{nameOrCode}), '%'))
  351. </if>
  352. </trim>
  353. </select>
  354. <!-- 查询枪线内容 -->
  355. <select id="getGunLine" resultType="com.tld.model.GunLine">
  356. select
  357. id,
  358. code,
  359. name,
  360. type
  361. from tld_gun_line
  362. <trim prefix="WHERE" prefixOverrides="and |or">
  363. <if test="type != null and type != ''">
  364. and type = #{type}
  365. </if>
  366. <if test="code != null and code != ''">
  367. and code like CONCAT('%', #{code}, '%')
  368. </if>
  369. <if test="name != null and name != ''">
  370. and name like CONCAT('%', #{name}, '%')
  371. </if>
  372. </trim>
  373. </select>
  374. <!-- 修改物料字典内容 -->
  375. <update id="updateMaterial">
  376. update tld_material
  377. <set>
  378. <trim suffixOverrides=",">
  379. <if test="code != null">
  380. code = #{code},
  381. </if>
  382. <if test="name != null">
  383. name = #{name},
  384. </if>
  385. <if test="tldId != null">
  386. tld_id = #{tldId},
  387. </if>
  388. <if test="specificationAndModel != null">
  389. specification_and_model = #{specificationAndModel},
  390. </if>
  391. <if test="unitOfMeasurement != null">
  392. unit_of_measurement = #{unitOfMeasurement},
  393. </if>
  394. <if test="size != null">
  395. size = #{size},
  396. </if>
  397. <if test="wllbClass != null">
  398. wllb_class = #{wllbClass},
  399. </if>
  400. <if test="isNotDisable != null">
  401. is_not_disable = #{isNotDisable},
  402. </if>
  403. <if test="isRecommend != null">
  404. is_recommend = #{isRecommend},
  405. </if>
  406. <if test="partType != null">
  407. part_type = #{partType},
  408. </if>
  409. <if test="minNum != null">
  410. min_num = #{minNum},
  411. </if>
  412. <if test="maxNum != null">
  413. max_num = #{maxNum},
  414. </if>
  415. <if test="companyNumber != null">
  416. company_number = #{companyNumber},
  417. </if>
  418. modify_user = #{modifyUser},modify_time=now(),
  419. </trim>
  420. </set>
  421. where id = #{id}
  422. </update>
  423. <!-- 库存对账 -->
  424. <update id="updateTreasuryAccount">
  425. update tld_material
  426. <set>
  427. <if test="materialId != null">
  428. material_id = #{materialId},
  429. </if>
  430. <if test="code != null">
  431. code = #{code},
  432. </if>
  433. <if test="name != null">
  434. name = #{name},
  435. </if>
  436. <if test="tldId != null">
  437. tld_id = #{tldId},
  438. </if>
  439. </set>
  440. where id = #{id}
  441. </update>
  442. <!-- 修改字典内容 -->
  443. <update id="updateDictionary">
  444. update ${tableName}
  445. <set>
  446. <if test="materialId != null">
  447. material_id = #{materialId},
  448. </if>
  449. <if test="code != null">
  450. code = #{code},
  451. </if>
  452. <if test="name != null">
  453. name = #{name},
  454. </if>
  455. <if test="tldId != null">
  456. tld_id = #{tldId},
  457. </if>
  458. </set>
  459. where id = #{id}
  460. </update>
  461. <!-- 修改枪线内容 -->
  462. <update id="updateGunLine">
  463. update tld_gun_line
  464. <set>
  465. <if test="code != null">
  466. code = #{code},
  467. </if>
  468. <if test="name != null">
  469. name = #{name},
  470. </if>
  471. <if test="type != null">
  472. type = #{type},
  473. </if>
  474. </set>
  475. where id = #{id}
  476. </update>
  477. <!-- 删除字典内容 -->
  478. <delete id="deleteDictionary">
  479. delete
  480. from ${tableName}
  481. where id = #{id}
  482. </delete>
  483. <!--新增之前删除所有gs库存-->
  484. <delete id="deleteRepertory">
  485. delete
  486. from tld_inventory_gs
  487. </delete>
  488. <!-- 删除枪线内容 -->
  489. <delete id="delGunLine">
  490. delete from tld_gun_line where id = #{id}
  491. </delete>
  492. <!-- 新增日志 -->
  493. <insert id="addAccess">
  494. insert into tld_access(type, data, scrq,access_type) value (#{type},#{data},now(),#{accessType})
  495. </insert>
  496. <!-- 新增操作日志 -->
  497. <insert id="addLogdata">
  498. insert into tld_log_data(user_id, scrq, data, type, document_type) value (#{userId},now(),#{data},#{type},#{documentType})
  499. </insert>
  500. <!-- 增加仓库的时候新增库位信息-->
  501. <insert id="addStorageLocation">
  502. insert into tld_storage_location(storage_location_code, storage_location_name, warehouse_where) value (#{storageLocationCode},#{storageLocationName},#{warehouseWhere})
  503. </insert>
  504. <!-- 新增枪线内容 -->
  505. <insert id="addGunLine">
  506. insert into tld_gun_line(code,name,type) value(#{code},#{name},#{type})
  507. </insert>
  508. </mapper>