DictionaryMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 from tld_dictionary_pulic where name = #{type}
  8. </select>
  9. <!-- 物料字典新增 -->
  10. <insert id="addMaterial">
  11. insert into tld_material(code,name,tld_id,specification_and_model,unit_of_measurement,size,is_not_disable,is_recommend,min_num,max_num,typ,company_number)
  12. values(#{code},#{name},#{tldId},#{specificationAndModel},#{unitOfMeasurement},'0','0','0',"0","0",#{typeVal},#{companyNumber})
  13. </insert>
  14. <!-- 字典新增 -->
  15. <insert id="addDictionary">
  16. insert into ${tableName}(code,name,tld_id,type)
  17. values(#{code},#{name},#{tldId},#{typeVal})
  18. </insert>
  19. <!-- 查询字典内容 -->
  20. <select id="getDictionary" resultType="com.tld.model.Dictionary">
  21. select * from ${tableName}
  22. <trim prefix="WHERE" prefixOverrides="and |or">
  23. <if test="name != null and name != ''">
  24. and name like CONCAT(CONCAT('%', #{name}), '%')
  25. </if>
  26. <if test="code != null and code != ''">
  27. and code like CONCAT(CONCAT('%', #{code}), '%')
  28. </if>
  29. <if test="tldId != null and tldId != ''">
  30. and tld_id = #{tldId}
  31. </if>
  32. </trim>
  33. </select>
  34. <!-- 查询字典内容分页 -->
  35. <select id="getDictionaryPage" resultType="com.tld.model.Dictionary">
  36. select
  37. *
  38. from ${tableName}
  39. <trim prefix="WHERE" prefixOverrides="and |or">
  40. <if test="name != null and name != ''">
  41. and name = #{name}
  42. </if>
  43. <if test="code != null and code != ''">
  44. and code = #{code}
  45. </if>
  46. <if test="tldId != null and tldId != ''">
  47. and tld_id = #{tldId}
  48. </if>
  49. <if test="typeVal != null and typeVal != ''">
  50. and type = #{typeVal}
  51. </if>
  52. </trim>
  53. order by id desc
  54. </select>
  55. <!-- 库账对存字典新增 -->
  56. <insert id="addTreasuryAccount">
  57. insert into tld_treasury_account(material_id,code,name,num,type)
  58. values(#{materialId},#{code},#{name},#{num},#{typeVal})
  59. </insert>
  60. <!-- 查询仓库id -->
  61. <select id="getWarehouse" resultType="String">
  62. select warehouse_where from tld_storage_location where storage_location_code = #{storageLocationCode}
  63. </select>
  64. <!-- 查询仓库字典 -->
  65. <select id="getWarehouseInfo" resultType="com.tld.model.Dictionary">
  66. select code,name,tld_id from tld_warehouse where code = #{askGoodsWarehouseId}
  67. </select>
  68. <!-- 查询物料库存内容 -->
  69. <select id="getInventorySumAmount" resultType="int">
  70. select ifnull(sum(amount), 0) from tld_inventory where material_id = #{tldId}
  71. </select>
  72. <!-- 查询字典内容分页 -->
  73. <select id="getDictionaryMaterialPage" resultType="com.tld.model.Dictionary">
  74. select
  75. a.*,b.name as materialType,c.user_name as modifyUser
  76. from ${tableName} a
  77. left join tld_material_type b on a.wllb_class = b.tld_id
  78. left join tld_user c on a.modify_user = c.id
  79. <trim prefix="WHERE" prefixOverrides="and |or">
  80. <if test="name != null and name != ''">
  81. and a.name = #{name}
  82. </if>
  83. <if test="code != null and code != ''">
  84. and a.code = #{code}
  85. </if>
  86. <if test="tldId != null and tldId != ''">
  87. and a.tld_id = #{tldId}
  88. </if>
  89. <if test="typeVal != null and typeVal != ''">
  90. and a.type = #{typeVal}
  91. </if>
  92. </trim>
  93. </select>
  94. <!-- 修改物料字典内容 -->
  95. <update id="updateMaterial">
  96. update tld_material
  97. <set>
  98. <trim suffixOverrides=",">
  99. <if test="code != null and code != ''">
  100. code = #{code},
  101. </if>
  102. <if test="name != null and name != ''">
  103. name = #{name},
  104. </if>
  105. <if test="tldId != null and tldId != ''">
  106. tld_id = #{tldId},
  107. </if>
  108. <if test="specificationAndModel != null and specificationAndModel != ''">
  109. specification_and_model = #{specificationAndModel},
  110. </if>
  111. <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
  112. unit_of_measurement = #{unitOfMeasurement},
  113. </if>
  114. <if test="size != null and size != ''">
  115. size = #{size},
  116. </if>
  117. <if test="wllbClass != null and wllbClass != ''">
  118. wllb_class = #{wllbClass},
  119. </if>
  120. <if test="isNotDisable != null and isNotDisable != ''">
  121. is_not_disable = #{isNotDisable},
  122. </if>
  123. <if test="isRecommend != null and isRecommend != ''">
  124. is_recommend = #{isRecommend},
  125. </if>
  126. <if test="partType != null and partType != ''">
  127. part_type = #{partType},
  128. </if>
  129. <if test="minNum != null and minNum != ''">
  130. min_num = #{minNum},
  131. </if>
  132. <if test="maxNum != null and maxNum != ''">
  133. max_num = #{maxNum},
  134. </if>
  135. <if test="companyNumber != null and companyNumber != ''">
  136. company_number = #{companyNumber},
  137. </if>
  138. modify_user = #{modifyUser},modify_time=now(),
  139. </trim>
  140. </set>
  141. where id = #{id}
  142. </update>
  143. <!-- 库存对账 -->
  144. <update id="updateTreasuryAccount">
  145. update tld_material
  146. <set>
  147. <if test="materialId != null and materialId != ''">
  148. material_id = #{materialId},
  149. </if>
  150. <if test="code != null and code != ''">
  151. code = #{code},
  152. </if>
  153. <if test="name != null and name != ''">
  154. name = #{name},
  155. </if>
  156. <if test="tldId != null and tldId != ''">
  157. tld_id = #{tldId},
  158. </if>
  159. </set>
  160. where id = #{id}
  161. </update>
  162. <!-- 修改字典内容 -->
  163. <update id="updateDictionary">
  164. update ${tableName}
  165. <set>
  166. <if test="materialId != null and materialId != ''">
  167. material_id = #{materialId},
  168. </if>
  169. <if test="code != null and code != ''">
  170. code = #{code},
  171. </if>
  172. <if test="name != null and name != ''">
  173. name = #{name},
  174. </if>
  175. <if test="tldId != null and tldId != ''">
  176. tld_id = #{tldId},
  177. </if>
  178. </set>
  179. where id = #{id}
  180. </update>
  181. <!-- 删除字典内容 -->
  182. <delete id="deleteDictionary">
  183. delete from ${tableName} where id = #{id}
  184. </delete>
  185. <!-- 新增日志 -->
  186. <insert id="addAccess">
  187. insert into tld_access(type,data,scrq) value(#{type},#{data},now())
  188. </insert>
  189. </mapper>