DictionaryMapper.xml 7.6 KB

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