DictionaryMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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="tldId != null and tldId != ''">
  34. and tld_id = #{tldId}
  35. </if>
  36. <if test="id != null and id != ''">
  37. and id = #{id}
  38. </if>
  39. </trim>
  40. </select>
  41. <!-- 查询字典内容分页 -->
  42. <select id="getDictionaryPage" resultType="com.tld.model.Dictionary">
  43. select
  44. *
  45. from ${tableName}
  46. <trim prefix="WHERE" prefixOverrides="and |or">
  47. <if test="name != null and name != ''">
  48. and name like CONCAT(CONCAT('%', #{name}), '%')
  49. </if>
  50. <if test="code != null and code != ''">
  51. and code like CONCAT(CONCAT('%', #{code}), '%')
  52. </if>
  53. <if test="wllbClass != null and wllbClass != ''">
  54. and wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  55. </if>
  56. <if test="materialType != null and materialType != ''">
  57. and part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  58. </if>
  59. <if test="isNotDisable != null and isNotDisable != ''">
  60. and is_not_disable = #{isNotDisable}
  61. </if>
  62. <if test="isRecommend != null and isRecommend != ''">
  63. and is_recommend = #{isRecommend}
  64. </if>
  65. <if test="tldId != null and tldId != ''">
  66. and tld_id = #{tldId}
  67. </if>
  68. <if test="typeVal != null and typeVal != ''">
  69. and type = #{typeVal}
  70. </if>
  71. </trim>
  72. order by id desc
  73. </select>
  74. <!-- 库账对存字典新增 -->
  75. <insert id="addTreasuryAccount">
  76. insert into tld_inventory_gs(material_id, amount, account_sleeve)
  77. values (#{materialId}, #{num}, #{typeVal})
  78. </insert>
  79. <!-- 查询仓库id -->
  80. <select id="getWarehouse" resultType="String">
  81. select warehouse_where
  82. from tld_storage_location
  83. where storage_location_code = #{storageLocationCode}
  84. </select>
  85. <!-- 查询仓库字典 -->
  86. <select id="getWarehouseInfo" resultType="com.tld.model.Dictionary">
  87. select code, name, tld_id
  88. from tld_warehouse
  89. where tld_id = #{askGoodsWarehouseId}
  90. </select>
  91. <!-- 查询物料库存内容 -->
  92. <select id="getInventorySumAmount" resultType="int">
  93. select ifnull(sum(amount), 0)
  94. from tld_inventory
  95. where material_id = #{tldId}
  96. </select>
  97. <!-- 查询字典内容分页 -->
  98. <select id="getDictionaryMaterialPage" resultType="com.tld.model.Dictionary">
  99. select
  100. a.*,b.name as materialType,c.user_name as modifyUser
  101. from ${tableName} a
  102. left join tld_material_type b on a.wllb_class = b.tld_id
  103. left join tld_user c on a.modify_user = c.id
  104. <trim prefix="WHERE" prefixOverrides="and |or">
  105. <if test="name != null and name != ''">
  106. and a.name = #{name}
  107. </if>
  108. <if test="code != null and code != ''">
  109. and a.code = #{code}
  110. </if>
  111. <if test="tldId != null and tldId != ''">
  112. and a.tld_id = #{tldId}
  113. </if>
  114. <if test="typeVal != null and typeVal != ''">
  115. and a.type = #{typeVal}
  116. </if>
  117. </trim>
  118. </select>
  119. <!--判断是否是重复数据-->
  120. <select id="getTableNameList" resultType="com.tld.model.Dictionary">
  121. select *
  122. from ${tableName}
  123. where code = #{code}
  124. </select>
  125. <!--物料字典导出-->
  126. <select id="export" resultType="java.util.LinkedHashMap">
  127. select
  128. code,
  129. name,
  130. if(part_type = '', null , part_type),
  131. if(wllb_class = '', null , wllb_class),
  132. if(size = '', null , size),
  133. if(max_num = '', null , max_num),
  134. if(min_num = '', null , min_num),
  135. if(is_not_disable = '1', '是' , '否'),
  136. if(is_recommend = '1', '是' , '否' )
  137. from tld_material
  138. <trim prefix="WHERE" prefixOverrides="and |or">
  139. <if test="name != null and name != ''">
  140. and name like CONCAT(CONCAT('%', #{name}), '%')
  141. </if>
  142. <if test="code != null and code != ''">
  143. and code like CONCAT(CONCAT('%', #{code}), '%')
  144. </if>
  145. <if test="wllbClass != null and wllbClass != ''">
  146. and wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  147. </if>
  148. <if test="materialType != null and materialType != ''">
  149. and part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  150. </if>
  151. <if test="isNotDisable != null and isNotDisable != ''">
  152. and is_not_disable = #{isNotDisable}
  153. </if>
  154. <if test="isRecommend != null and isRecommend != ''">
  155. and is_recommend = #{isRecommend}
  156. </if>
  157. <if test="tldId != null and tldId != ''">
  158. and tld_id = #{tldId}
  159. </if>
  160. </trim>
  161. order by id desc
  162. </select>
  163. <!--查询物料字典内容分页-->
  164. <select id="getDictionaryPageMaterial" resultType="com.tld.model.Dictionary">
  165. select
  166. a.*,
  167. f.user_name as modifyUser
  168. from tld_material a
  169. left join tld_user f on a.modify_user = f.id
  170. <trim prefix="WHERE" prefixOverrides="and |or">
  171. <if test="name != null and name != ''">
  172. and a.name like CONCAT(CONCAT('%', #{name}), '%')
  173. </if>
  174. <if test="code != null and code != ''">
  175. and a.code like CONCAT(CONCAT('%', #{code}), '%')
  176. </if>
  177. <if test="wllbClass != null and wllbClass != ''">
  178. and a.wllb_class like CONCAT(CONCAT('%', #{wllbClass}), '%')
  179. </if>
  180. <if test="materialType != null and materialType != ''">
  181. and a.part_type like CONCAT(CONCAT('%', #{materialType}), '%')
  182. </if>
  183. <if test="isNotDisable != null and isNotDisable != ''">
  184. and a.is_not_disable = #{isNotDisable}
  185. </if>
  186. <if test="isRecommend != null and isRecommend != ''">
  187. and a.is_recommend = #{isRecommend}
  188. </if>
  189. <if test="tldId != null and tldId != ''">
  190. and a.tld_id = #{tldId}
  191. </if>
  192. <if test="typeVal != null and typeVal != ''">
  193. and a.type = #{typeVal}
  194. </if>
  195. </trim>
  196. order by a.id desc
  197. </select>
  198. <!-- 修改物料字典内容 -->
  199. <update id="updateMaterial">
  200. update tld_material
  201. <set>
  202. <trim suffixOverrides=",">
  203. <if test="code != null">
  204. code = #{code},
  205. </if>
  206. <if test="name != null">
  207. name = #{name},
  208. </if>
  209. <if test="tldId != null">
  210. tld_id = #{tldId},
  211. </if>
  212. <if test="specificationAndModel != null">
  213. specification_and_model = #{specificationAndModel},
  214. </if>
  215. <if test="unitOfMeasurement != null">
  216. unit_of_measurement = #{unitOfMeasurement},
  217. </if>
  218. <if test="size != null">
  219. size = #{size},
  220. </if>
  221. <if test="wllbClass != null">
  222. wllb_class = #{wllbClass},
  223. </if>
  224. <if test="isNotDisable != null">
  225. is_not_disable = #{isNotDisable},
  226. </if>
  227. <if test="isRecommend != null">
  228. is_recommend = #{isRecommend},
  229. </if>
  230. <if test="partType != null">
  231. part_type = #{partType},
  232. </if>
  233. <if test="minNum != null">
  234. min_num = #{minNum},
  235. </if>
  236. <if test="maxNum != null">
  237. max_num = #{maxNum},
  238. </if>
  239. <if test="companyNumber != null">
  240. company_number = #{companyNumber},
  241. </if>
  242. modify_user = #{modifyUser},modify_time=now(),
  243. </trim>
  244. </set>
  245. where id = #{id}
  246. </update>
  247. <!-- 库存对账 -->
  248. <update id="updateTreasuryAccount">
  249. update tld_material
  250. <set>
  251. <if test="materialId != null">
  252. material_id = #{materialId},
  253. </if>
  254. <if test="code != null">
  255. code = #{code},
  256. </if>
  257. <if test="name != null">
  258. name = #{name},
  259. </if>
  260. <if test="tldId != null">
  261. tld_id = #{tldId},
  262. </if>
  263. </set>
  264. where id = #{id}
  265. </update>
  266. <!-- 修改字典内容 -->
  267. <update id="updateDictionary">
  268. update ${tableName}
  269. <set>
  270. <if test="materialId != null">
  271. material_id = #{materialId},
  272. </if>
  273. <if test="code != null">
  274. code = #{code},
  275. </if>
  276. <if test="name != null">
  277. name = #{name},
  278. </if>
  279. <if test="tldId != null">
  280. tld_id = #{tldId},
  281. </if>
  282. </set>
  283. where id = #{id}
  284. </update>
  285. <!-- 删除字典内容 -->
  286. <delete id="deleteDictionary">
  287. delete
  288. from ${tableName}
  289. where id = #{id}
  290. </delete>
  291. <!--删除所有gs库存-->
  292. <delete id="deleteRepertory">
  293. delete
  294. from tld_inventory_gs
  295. </delete>
  296. <!-- 新增日志 -->
  297. <insert id="addAccess">
  298. insert into tld_access(type, data, scrq) value (#{type},#{data},now())
  299. </insert>
  300. <!-- 新增操作日志 -->
  301. <insert id="addLogdata">
  302. insert into tld_log_data(user_id, scrq, data, type, document_type) value (#{userId},now(),#{data},#{type},#{documentType})
  303. </insert>
  304. <!-- 增加仓库的时候新增库位信息-->
  305. <insert id="addStorageLocation">
  306. insert into tld_storage_location(storage_location_code, storage_location_name, warehouse_where) value (#{storageLocationCode},#{storageLocationName},#{warehouseWhere})
  307. </insert>
  308. </mapper>