WarehouseMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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.usoftchina.saas.document.mapper.WarehouseMapper">
  4. <resultMap id="WarehouseResultMapper" type="com.usoftchina.saas.document.entities.Warehouse">
  5. <id column="wh_id" property="id" jdbcType="INTEGER" />
  6. <result column="wh_code" property="wh_code" jdbcType="VARCHAR" />
  7. <result column="wh_type" property="wh_type" jdbcType="VARCHAR" />
  8. <result column="wh_description" property="wh_description" jdbcType="VARCHAR" />
  9. <result column="wh_statuscode" property="wh_statuscode" jdbcType="VARCHAR" />
  10. <result column="wh_status" property="wh_status" jdbcType="TIMESTAMP" />
  11. <result column="wh_date" property="wh_date" jdbcType="INTEGER" />
  12. <result column="companyId" property="companyId" jdbcType="INTEGER" />
  13. <result column="updatemanid" property="updaterId" jdbcType="INTEGER" />
  14. <result column="updatedate" property="updateTime" jdbcType="TIMESTAMP" />
  15. <result column="wh_text1" property="wh_text1" jdbcType="VARCHAR" />
  16. <result column="wh_text2" property="wh_text2" jdbcType="VARCHAR" />
  17. <result column="wh_text3" property="wh_text3" jdbcType="VARCHAR" />
  18. <result column="wh_text4" property="wh_text4" jdbcType="VARCHAR" />
  19. <result column="wh_text5" property="wh_text5" jdbcType="VARCHAR" />
  20. </resultMap>
  21. <select id="post" parameterMap="postParamMap" statementType="CALLABLE">
  22. CALL SP_COMMITPRODINOUT(?, ?, ?, ?, ?)
  23. </select>
  24. <select id="unPost" parameterMap="postParamMap" statementType="CALLABLE">
  25. CALL SP_UNCOMMITPRODINOUT(?, ?, ?, ?, ?)
  26. </select>
  27. <parameterMap id="postParamMap" type="java.util.Map">
  28. <parameter property="inoutNo" jdbcType="VARCHAR" mode="IN" />
  29. <parameter property="class" jdbcType="VARCHAR" mode="IN" />
  30. <parameter property="commitid" jdbcType="INTEGER" mode="IN" />
  31. <parameter property="companyId" jdbcType="INTEGER" mode="IN" />
  32. <parameter property="result" jdbcType="VARCHAR" mode="OUT" />
  33. </parameterMap>
  34. <select id="validPeriod" parameterType="map" resultType="java.lang.Short">
  35. SELECT IFNULL(PD_STATUS,0) PD_STATUS FROM PERIODSDETAIL WHERE companyId=#{companyId} AND PD_DETNO=#{period}
  36. </select>
  37. <sql id="Example_Where_Clause">
  38. <where>
  39. <foreach collection="oredCriteria" item="criteria" separator="or">
  40. <if test="criteria.valid">
  41. <trim prefix="(" prefixOverrides="and" suffix=")">
  42. <foreach collection="criteria.criteria" item="criterion">
  43. <choose>
  44. <when test="criterion.noValue">
  45. and ${criterion.condition}
  46. </when>
  47. <when test="criterion.singleValue">
  48. and ${criterion.condition} #{criterion.value}
  49. </when>
  50. <when test="criterion.betweenValue">
  51. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  52. </when>
  53. <when test="criterion.listValue">
  54. and ${criterion.condition}
  55. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  56. #{listItem}
  57. </foreach>
  58. </when>
  59. </choose>
  60. </foreach>
  61. </trim>
  62. </if>
  63. </foreach>
  64. </where>
  65. </sql>
  66. <sql id="Update_By_Example_Where_Clause">
  67. <where>
  68. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  69. <if test="criteria.valid">
  70. <trim prefix="(" prefixOverrides="and" suffix=")">
  71. <foreach collection="criteria.criteria" item="criterion">
  72. <choose>
  73. <when test="criterion.noValue">
  74. and ${criterion.condition}
  75. </when>
  76. <when test="criterion.singleValue">
  77. and ${criterion.condition} #{criterion.value}
  78. </when>
  79. <when test="criterion.betweenValue">
  80. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  81. </when>
  82. <when test="criterion.listValue">
  83. and ${criterion.condition}
  84. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  85. #{listItem}
  86. </foreach>
  87. </when>
  88. </choose>
  89. </foreach>
  90. </trim>
  91. </if>
  92. </foreach>
  93. </where>
  94. </sql>
  95. <sql id="Base_Column_List">
  96. wh_id, wh_code, wh_type, wh_description, wh_statuscode, wh_status, wh_date, companyId, updaterId, updateTime, wh_text1, wh_text2, wh_text3,
  97. wh_text4, wh_text5
  98. </sql>
  99. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="WarehouseResultMapper">
  100. select
  101. <include refid="Base_Column_List" />
  102. from warehouse
  103. where wh_id = #{id}
  104. </select>
  105. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  106. delete from warehouse
  107. where wh_id = #{id}
  108. </delete>
  109. <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Warehouse">
  110. <selectKey resultType="java.lang.Long" keyProperty="id">
  111. SELECT LAST_INSERT_ID() AS ID
  112. </selectKey>
  113. insert into warehouse (wh_code, wh_type,
  114. wh_description, wh_statuscode, wh_status, wh_date,
  115. companyId, updaterId, updateTime,
  116. wh_text1, wh_text2, wh_text3,
  117. wh_text4, wh_text5,
  118. creatorId,createTime,creatorName)
  119. values (#{wh_code,jdbcType=VARCHAR}, #{wh_type,jdbcType=VARCHAR},
  120. #{wh_description,jdbcType=VARCHAR}, #{wh_statuscode,jdbcType=VARCHAR}, #{wh_status,jdbcType=VARCHAR},
  121. #{wh_date,jdbcType=TIMESTAMP},
  122. #{companyId,jdbcType=INTEGER}, #{updaterId,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP},
  123. #{wh_text1,jdbcType=VARCHAR}, #{wh_text2,jdbcType=VARCHAR}, #{wh_text3,jdbcType=VARCHAR},
  124. #{wh_text4,jdbcType=VARCHAR}, #{wh_text5,jdbcType=VARCHAR},
  125. #{creatorId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{creatorName,jdbcType=VARCHAR})
  126. </insert>
  127. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Warehouse">
  128. <selectKey resultType="java.lang.Long" keyProperty="id">
  129. SELECT LAST_INSERT_ID() AS ID
  130. </selectKey>
  131. insert into warehouse
  132. <trim prefix="(" suffix=")" suffixOverrides=",">
  133. <if test="wh_code != null">
  134. wh_code,
  135. </if>
  136. <if test="wh_type != null">
  137. wh_type,
  138. </if>
  139. <if test="wh_description != null">
  140. wh_description,
  141. </if>
  142. <if test="wh_statuscode != null">
  143. wh_statuscode,
  144. </if>
  145. <if test="wh_status != null">
  146. wh_status,
  147. </if>
  148. <if test="wh_date != null">
  149. wh_date,
  150. </if>
  151. <if test="companyId != null">
  152. companyId,
  153. </if>
  154. <if test="updaterId != null">
  155. updaterId,
  156. </if>
  157. <if test="updateTime != null">
  158. updateTime,
  159. </if>
  160. <if test="wh_text1 != null">
  161. wh_text1,
  162. </if>
  163. <if test="wh_text2 != null">
  164. wh_text2,
  165. </if>
  166. <if test="wh_text3 != null">
  167. wh_text3,
  168. </if>
  169. <if test="wh_text4 != null">
  170. wh_text4,
  171. </if>
  172. <if test="wh_text5 != null">
  173. wh_text5,
  174. </if>
  175. <if test="creatorId != null" >
  176. creatorId,
  177. </if>
  178. <if test="createTime != null" >
  179. createTime,
  180. </if>
  181. <if test="creatorName != null" >
  182. creatorName,
  183. </if>
  184. </trim>
  185. <trim prefix="values (" suffix=")" suffixOverrides=",">
  186. <if test="wh_code != null">
  187. #{wh_code,jdbcType=VARCHAR},
  188. </if>
  189. <if test="wh_type != null">
  190. #{wh_type,jdbcType=VARCHAR},
  191. </if>
  192. <if test="wh_description != null">
  193. #{wh_description,jdbcType=VARCHAR},
  194. </if>
  195. <if test="wh_statuscode != null">
  196. #{wh_statuscode,jdbcType=VARCHAR},
  197. </if>
  198. <if test="wh_status != null">
  199. #{wh_status,jdbcType=VARCHAR},
  200. </if>
  201. <if test="wh_date != null">
  202. #{wh_date,jdbcType=TIMESTAMP},
  203. </if>
  204. <if test="companyId != null">
  205. #{companyId,jdbcType=INTEGER},
  206. </if>
  207. <if test="updaterId != null">
  208. #{updaterId,jdbcType=INTEGER},
  209. </if>
  210. <if test="updateTime != null">
  211. #{updateTime,jdbcType=TIMESTAMP},
  212. </if>
  213. <if test="wh_text1 != null">
  214. #{wh_text1,jdbcType=VARCHAR},
  215. </if>
  216. <if test="wh_text2 != null">
  217. #{wh_text2,jdbcType=VARCHAR},
  218. </if>
  219. <if test="wh_text3 != null">
  220. #{wh_text3,jdbcType=VARCHAR},
  221. </if>
  222. <if test="wh_text4 != null">
  223. #{wh_text4,jdbcType=VARCHAR},
  224. </if>
  225. <if test="wh_text5 != null">
  226. #{wh_text5,jdbcType=VARCHAR},
  227. </if>
  228. <if test="creatorId != null" >
  229. #{creatorId,jdbcType=INTEGER},
  230. </if>
  231. <if test="createTime != null" >
  232. #{createTime,jdbcType=TIMESTAMP},
  233. </if>
  234. <if test="creatorName != null" >
  235. #{creatorName,jdbcType=VARCHAR},
  236. </if>
  237. </trim>
  238. </insert>
  239. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Warehouse">
  240. update warehouse
  241. <set>
  242. <if test="wh_code != null">
  243. wh_code = #{wh_code,jdbcType=VARCHAR},
  244. </if>
  245. <if test="wh_type != null">
  246. wh_type = #{wh_type,jdbcType=VARCHAR},
  247. </if>
  248. <if test="wh_description != null">
  249. wh_description = #{wh_description,jdbcType=VARCHAR},
  250. </if>
  251. <if test="wh_statuscode != null">
  252. wh_statuscode = #{wh_statuscode,jdbcType=VARCHAR},
  253. </if>
  254. <if test="wh_status != null">
  255. wh_status = #{wh_status,jdbcType=VARCHAR},
  256. </if>
  257. <if test="wh_date != null">
  258. wh_date = #{wh_date,jdbcType=TIMESTAMP},
  259. </if>
  260. <if test="companyId != null">
  261. companyId = #{companyId,jdbcType=INTEGER},
  262. </if>
  263. <if test="updaterId != null">
  264. updaterId = #{updaterId,jdbcType=INTEGER},
  265. </if>
  266. <if test="updateTime != null">
  267. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  268. </if>
  269. <if test="wh_text1 != null">
  270. wh_text1 = #{wh_text1,jdbcType=VARCHAR},
  271. </if>
  272. <if test="wh_text2 != null">
  273. wh_text2 = #{wh_text2,jdbcType=VARCHAR},
  274. </if>
  275. <if test="wh_text3 != null">
  276. wh_text3 = #{wh_text3,jdbcType=VARCHAR},
  277. </if>
  278. <if test="wh_text4 != null">
  279. wh_text4 = #{wh_text4,jdbcType=VARCHAR},
  280. </if>
  281. <if test="wh_text5 != null">
  282. wh_text5 = #{wh_text5,jdbcType=VARCHAR},
  283. </if>
  284. </set>
  285. where wh_id = #{id}
  286. </update>
  287. <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Warehouse">
  288. update warehouse
  289. set wh_code = #{wh_code,jdbcType=VARCHAR},
  290. wh_type = #{wh_type,jdbcType=VARCHAR},
  291. wh_description = #{wh_description,jdbcType=VARCHAR},
  292. wh_statuscode = #{wh_statuscode,jdbcType=VARCHAR},
  293. wh_status = #{wh_status,jdbcType=VARCHAR},
  294. wh_date = #{wh_date,jdbcType=TIMESTAMP},
  295. companyId = #{companyId,jdbcType=INTEGER},
  296. updaterId = #{updaterId,jdbcType=INTEGER},
  297. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  298. wh_text1 = #{wh_text1,jdbcType=VARCHAR},
  299. wh_text2 = #{wh_text2,jdbcType=VARCHAR},
  300. wh_text3 = #{wh_text3,jdbcType=VARCHAR},
  301. wh_text4 = #{wh_text4,jdbcType=VARCHAR},
  302. wh_text5 = #{wh_text5,jdbcType=VARCHAR}
  303. where wh_id = #{id}
  304. </update>
  305. <select id="validateCodeWhenInsert" resultType="int">
  306. select count(*) from WAREHOUSE where WH_CODE = #{code} and companyId =#{companyId}
  307. </select>
  308. <select id="validateCodeWhenUpdate" resultType="int" >
  309. select count(*) from WAREHOUSE where WH_CODE = #{code} and WH_ID != #{id} and companyId =#{companyId}
  310. </select>
  311. <select id="selectWarehouseListByCondition" resultMap="WarehouseResultMapper">
  312. select * from warehouse
  313. <where>
  314. <if test="con != null">
  315. ${con}
  316. </if>
  317. <if test="companyId != null">
  318. and companyid = #{companyId}
  319. </if>
  320. </where>
  321. order by wh_id DESC
  322. </select>
  323. <select id="selectCountByName" resultType="int">
  324. SELECT COUNT(*) FROM warehouse
  325. <where>
  326. <if test="name!=null">
  327. and wh_description=#{name}
  328. </if>
  329. <if test="companyId!=0 and companyId!=null">
  330. and COMPANYID=#{companyId}
  331. </if>
  332. <if test="id!=0 and id!=null">
  333. and wh_id!=#{id}
  334. </if>
  335. </where>
  336. </select>
  337. <select id="selectCountByCode" resultType="int">
  338. SELECT COUNT(*) FROM warehouse
  339. <where>
  340. <if test="code!=null">
  341. and wh_code=#{code}
  342. </if>
  343. <if test="companyId!=0 and companyId!=null">
  344. and COMPANYID=#{companyId}
  345. </if>
  346. <if test="id!=0 and id!=null">
  347. and wh_id!=#{id}
  348. </if>
  349. </where>
  350. </select>
  351. <select id="selectCodeById" resultType="string" parameterType="long">
  352. select wh_code from warehouse where wh_id=#{id}
  353. </select>
  354. <select id="deleteCheckProduct" resultType="integer">
  355. select count(1) from product where pr_whid = #{id} and companyId = #{companyId}
  356. </select>
  357. <select id="deleteCheckWH" resultType="integer">
  358. select count(1) from productwh where pw_whid = #{id} and pw_onhand > 0
  359. and companyId = #{companyId}
  360. </select>
  361. <select id="deleteCheckProdIO" resultType="int">
  362. SELECT COUNT(*) FROM PRODIODETAIL WHERE pd_whid = #{id} and companyid = #{companyId}
  363. </select>
  364. <select id="selectWareHouse" resultMap="WarehouseResultMapper">
  365. select * from warehouse where wh_code=#{code} and companyId=#{companyId}
  366. </select>
  367. </mapper>