MaterialMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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.jsh.erp.datasource.mappers.MaterialMapper">
  4. <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.Material">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="category_id" jdbcType="BIGINT" property="categoryId" />
  7. <result column="name" jdbcType="VARCHAR" property="name" />
  8. <result column="model" jdbcType="VARCHAR" property="model" />
  9. <result column="standard" jdbcType="VARCHAR" property="standard" />
  10. <result column="brand" jdbcType="VARCHAR" property="brand" />
  11. <result column="mnemonic" jdbcType="VARCHAR" property="mnemonic" />
  12. <result column="color" jdbcType="VARCHAR" property="color" />
  13. <result column="unit" jdbcType="VARCHAR" property="unit" />
  14. <result column="remark" jdbcType="VARCHAR" property="remark" />
  15. <result column="img_name" jdbcType="VARCHAR" property="imgName" />
  16. <result column="unit_id" jdbcType="BIGINT" property="unitId" />
  17. <result column="weight" jdbcType="DECIMAL" property="weight" />
  18. <result column="enabled" jdbcType="BIT" property="enabled" />
  19. <result column="other_field1" jdbcType="VARCHAR" property="otherField1" />
  20. <result column="other_field2" jdbcType="VARCHAR" property="otherField2" />
  21. <result column="other_field3" jdbcType="VARCHAR" property="otherField3" />
  22. <result column="enable_serial_number" jdbcType="VARCHAR" property="enableSerialNumber" />
  23. <result column="enable_batch_number" jdbcType="VARCHAR" property="enableBatchNumber" />
  24. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  25. <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
  26. <result column="system_sku" jdbcType="VARCHAR" property="systemSku" />
  27. <result column="moving_pin_reminder_cycle" jdbcType="VARCHAR" property="movingPinReminderCycle" />
  28. </resultMap>
  29. <sql id="Example_Where_Clause">
  30. <where>
  31. <foreach collection="oredCriteria" item="criteria" separator="or">
  32. <if test="criteria.valid">
  33. <trim prefix="(" prefixOverrides="and" suffix=")">
  34. <foreach collection="criteria.criteria" item="criterion">
  35. <choose>
  36. <when test="criterion.noValue">
  37. and ${criterion.condition}
  38. </when>
  39. <when test="criterion.singleValue">
  40. and ${criterion.condition} #{criterion.value}
  41. </when>
  42. <when test="criterion.betweenValue">
  43. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  44. </when>
  45. <when test="criterion.listValue">
  46. and ${criterion.condition}
  47. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  48. #{listItem}
  49. </foreach>
  50. </when>
  51. </choose>
  52. </foreach>
  53. </trim>
  54. </if>
  55. </foreach>
  56. </where>
  57. </sql>
  58. <sql id="Update_By_Example_Where_Clause">
  59. <where>
  60. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  61. <if test="criteria.valid">
  62. <trim prefix="(" prefixOverrides="and" suffix=")">
  63. <foreach collection="criteria.criteria" item="criterion">
  64. <choose>
  65. <when test="criterion.noValue">
  66. and ${criterion.condition}
  67. </when>
  68. <when test="criterion.singleValue">
  69. and ${criterion.condition} #{criterion.value}
  70. </when>
  71. <when test="criterion.betweenValue">
  72. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  73. </when>
  74. <when test="criterion.listValue">
  75. and ${criterion.condition}
  76. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  77. #{listItem}
  78. </foreach>
  79. </when>
  80. </choose>
  81. </foreach>
  82. </trim>
  83. </if>
  84. </foreach>
  85. </where>
  86. </sql>
  87. <sql id="Base_Column_List">
  88. id, category_id, name, model, standard, brand, mnemonic, color, unit, remark,
  89. img_name, unit_id, weight, enabled, other_field1, other_field2, other_field3,
  90. enable_serial_number, enable_batch_number, tenant_id, delete_flag, system_sku, moving_pin_reminder_cycle
  91. </sql>
  92. <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="BaseResultMap">
  93. select
  94. <if test="distinct">
  95. distinct
  96. </if>
  97. <include refid="Base_Column_List" />
  98. from jsh_material
  99. <if test="_parameter != null">
  100. <include refid="Example_Where_Clause" />
  101. </if>
  102. <if test="orderByClause != null">
  103. order by ${orderByClause}
  104. </if>
  105. </select>
  106. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  107. select
  108. <include refid="Base_Column_List" />
  109. from jsh_material
  110. where id = #{id,jdbcType=BIGINT}
  111. </select>
  112. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  113. delete from jsh_material
  114. where id = #{id,jdbcType=BIGINT}
  115. </delete>
  116. <delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample">
  117. delete from jsh_material
  118. <if test="_parameter != null">
  119. <include refid="Example_Where_Clause" />
  120. </if>
  121. </delete>
  122. <insert id="insert" parameterType="com.jsh.erp.datasource.entities.Material">
  123. insert into jsh_material (id, category_id, name,
  124. model, standard,
  125. brand, mnemonic, color,
  126. unit, remark, img_name,
  127. unit_id, expiry_num, weight,
  128. enabled, other_field1, other_field2,
  129. other_field3, enable_serial_number, enable_batch_number,
  130. tenant_id, delete_flag
  131. )
  132. values (#{id,jdbcType=BIGINT}, #{categoryId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
  133. #{model,jdbcType=VARCHAR}, #{standard,jdbcType=VARCHAR},
  134. #{brand,jdbcType=VARCHAR}, #{mnemonic,jdbcType=VARCHAR}, #{color,jdbcType=VARCHAR},
  135. #{unit,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{imgName,jdbcType=VARCHAR},
  136. #{unitId,jdbcType=BIGINT}, #{weight,jdbcType=DECIMAL},
  137. #{enabled,jdbcType=BIT}, #{otherField1,jdbcType=VARCHAR}, #{otherField2,jdbcType=VARCHAR},
  138. #{otherField3,jdbcType=VARCHAR}, #{enableSerialNumber,jdbcType=VARCHAR}, #{enableBatchNumber,jdbcType=VARCHAR},
  139. #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
  140. )
  141. </insert>
  142. <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Material">
  143. insert into jsh_material
  144. <trim prefix="(" suffix=")" suffixOverrides=",">
  145. <if test="id != null">
  146. id,
  147. </if>
  148. <if test="categoryId != null">
  149. category_id,
  150. </if>
  151. <if test="name != null">
  152. name,
  153. </if>
  154. <if test="model != null">
  155. model,
  156. </if>
  157. <if test="standard != null">
  158. standard,
  159. </if>
  160. <if test="brand != null">
  161. brand,
  162. </if>
  163. <if test="mnemonic != null">
  164. mnemonic,
  165. </if>
  166. <if test="color != null">
  167. color,
  168. </if>
  169. <if test="unit != null">
  170. unit,
  171. </if>
  172. <if test="remark != null">
  173. remark,
  174. </if>
  175. <if test="imgName != null">
  176. img_name,
  177. </if>
  178. <if test="unitId != null">
  179. unit_id,
  180. </if>
  181. <if test="weight != null">
  182. weight,
  183. </if>
  184. <if test="enabled != null">
  185. enabled,
  186. </if>
  187. <if test="otherField1 != null">
  188. other_field1,
  189. </if>
  190. <if test="otherField2 != null">
  191. other_field2,
  192. </if>
  193. <if test="otherField3 != null">
  194. other_field3,
  195. </if>
  196. <if test="enableSerialNumber != null">
  197. enable_serial_number,
  198. </if>
  199. <if test="enableBatchNumber != null">
  200. enable_batch_number,
  201. </if>
  202. <if test="tenantId != null">
  203. tenant_id,
  204. </if>
  205. <if test="deleteFlag != null">
  206. delete_flag,
  207. </if>
  208. </trim>
  209. <trim prefix="values (" suffix=")" suffixOverrides=",">
  210. <if test="id != null">
  211. #{id,jdbcType=BIGINT},
  212. </if>
  213. <if test="categoryId != null">
  214. #{categoryId,jdbcType=BIGINT},
  215. </if>
  216. <if test="name != null">
  217. #{name,jdbcType=VARCHAR},
  218. </if>
  219. <if test="model != null">
  220. #{model,jdbcType=VARCHAR},
  221. </if>
  222. <if test="standard != null">
  223. #{standard,jdbcType=VARCHAR},
  224. </if>
  225. <if test="brand != null">
  226. #{brand,jdbcType=VARCHAR},
  227. </if>
  228. <if test="mnemonic != null">
  229. #{mnemonic,jdbcType=VARCHAR},
  230. </if>
  231. <if test="color != null">
  232. #{color,jdbcType=VARCHAR},
  233. </if>
  234. <if test="unit != null">
  235. #{unit,jdbcType=VARCHAR},
  236. </if>
  237. <if test="remark != null">
  238. #{remark,jdbcType=VARCHAR},
  239. </if>
  240. <if test="imgName != null">
  241. #{imgName,jdbcType=VARCHAR},
  242. </if>
  243. <if test="unitId != null">
  244. #{unitId,jdbcType=BIGINT},
  245. </if>
  246. <if test="weight != null">
  247. #{weight,jdbcType=DECIMAL},
  248. </if>
  249. <if test="enabled != null">
  250. #{enabled,jdbcType=BIT},
  251. </if>
  252. <if test="otherField1 != null">
  253. #{otherField1,jdbcType=VARCHAR},
  254. </if>
  255. <if test="otherField2 != null">
  256. #{otherField2,jdbcType=VARCHAR},
  257. </if>
  258. <if test="otherField3 != null">
  259. #{otherField3,jdbcType=VARCHAR},
  260. </if>
  261. <if test="enableSerialNumber != null">
  262. #{enableSerialNumber,jdbcType=VARCHAR},
  263. </if>
  264. <if test="enableBatchNumber != null">
  265. #{enableBatchNumber,jdbcType=VARCHAR},
  266. </if>
  267. <if test="tenantId != null">
  268. #{tenantId,jdbcType=BIGINT},
  269. </if>
  270. <if test="deleteFlag != null">
  271. #{deleteFlag,jdbcType=VARCHAR},
  272. </if>
  273. </trim>
  274. </insert>
  275. <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="java.lang.Long">
  276. select count(*) from jsh_material
  277. <if test="_parameter != null">
  278. <include refid="Example_Where_Clause" />
  279. </if>
  280. </select>
  281. <update id="updateByExampleSelective" parameterType="map">
  282. update jsh_material
  283. <set>
  284. <if test="record.id != null">
  285. id = #{record.id,jdbcType=BIGINT},
  286. </if>
  287. <if test="record.categoryId != null">
  288. category_id = #{record.categoryId,jdbcType=BIGINT},
  289. </if>
  290. <if test="record.name != null">
  291. name = #{record.name,jdbcType=VARCHAR},
  292. </if>
  293. <if test="record.model != null">
  294. model = #{record.model,jdbcType=VARCHAR},
  295. </if>
  296. <if test="record.standard != null">
  297. standard = #{record.standard,jdbcType=VARCHAR},
  298. </if>
  299. <if test="record.brand != null">
  300. brand = #{record.brand,jdbcType=VARCHAR},
  301. </if>
  302. <if test="record.mnemonic != null">
  303. mnemonic = #{record.mnemonic,jdbcType=VARCHAR},
  304. </if>
  305. <if test="record.color != null">
  306. color = #{record.color,jdbcType=VARCHAR},
  307. </if>
  308. <if test="record.unit != null">
  309. unit = #{record.unit,jdbcType=VARCHAR},
  310. </if>
  311. <if test="record.remark != null">
  312. remark = #{record.remark,jdbcType=VARCHAR},
  313. </if>
  314. <if test="record.imgName != null">
  315. img_name = #{record.imgName,jdbcType=VARCHAR},
  316. </if>
  317. <if test="record.unitId != null">
  318. unit_id = #{record.unitId,jdbcType=BIGINT},
  319. </if>
  320. <if test="record.weight != null">
  321. weight = #{record.weight,jdbcType=DECIMAL},
  322. </if>
  323. <if test="record.enabled != null">
  324. enabled = #{record.enabled,jdbcType=BIT},
  325. </if>
  326. <if test="record.otherField1 != null">
  327. other_field1 = #{record.otherField1,jdbcType=VARCHAR},
  328. </if>
  329. <if test="record.otherField2 != null">
  330. other_field2 = #{record.otherField2,jdbcType=VARCHAR},
  331. </if>
  332. <if test="record.otherField3 != null">
  333. other_field3 = #{record.otherField3,jdbcType=VARCHAR},
  334. </if>
  335. <if test="record.enableSerialNumber != null">
  336. enable_serial_number = #{record.enableSerialNumber,jdbcType=VARCHAR},
  337. </if>
  338. <if test="record.enableBatchNumber != null">
  339. enable_batch_number = #{record.enableBatchNumber,jdbcType=VARCHAR},
  340. </if>
  341. <if test="record.tenantId != null">
  342. tenant_id = #{record.tenantId,jdbcType=BIGINT},
  343. </if>
  344. <if test="record.deleteFlag != null">
  345. delete_flag = #{record.deleteFlag,jdbcType=VARCHAR},
  346. </if>
  347. </set>
  348. <if test="_parameter != null">
  349. <include refid="Update_By_Example_Where_Clause" />
  350. </if>
  351. </update>
  352. <update id="updateByExample" parameterType="map">
  353. update jsh_material
  354. set id = #{record.id,jdbcType=BIGINT},
  355. category_id = #{record.categoryId,jdbcType=BIGINT},
  356. name = #{record.name,jdbcType=VARCHAR},
  357. model = #{record.model,jdbcType=VARCHAR},
  358. standard = #{record.standard,jdbcType=VARCHAR},
  359. brand = #{record.brand,jdbcType=VARCHAR},
  360. mnemonic = #{record.mnemonic,jdbcType=VARCHAR},
  361. color = #{record.color,jdbcType=VARCHAR},
  362. unit = #{record.unit,jdbcType=VARCHAR},
  363. remark = #{record.remark,jdbcType=VARCHAR},
  364. img_name = #{record.imgName,jdbcType=VARCHAR},
  365. unit_id = #{record.unitId,jdbcType=BIGINT},
  366. weight = #{record.weight,jdbcType=DECIMAL},
  367. enabled = #{record.enabled,jdbcType=BIT},
  368. other_field1 = #{record.otherField1,jdbcType=VARCHAR},
  369. other_field2 = #{record.otherField2,jdbcType=VARCHAR},
  370. other_field3 = #{record.otherField3,jdbcType=VARCHAR},
  371. enable_serial_number = #{record.enableSerialNumber,jdbcType=VARCHAR},
  372. enable_batch_number = #{record.enableBatchNumber,jdbcType=VARCHAR},
  373. tenant_id = #{record.tenantId,jdbcType=BIGINT},
  374. delete_flag = #{record.deleteFlag,jdbcType=VARCHAR}
  375. <if test="_parameter != null">
  376. <include refid="Update_By_Example_Where_Clause" />
  377. </if>
  378. </update>
  379. <update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.Material">
  380. update jsh_material
  381. <set>
  382. <if test="categoryId != null">
  383. category_id = #{categoryId,jdbcType=BIGINT},
  384. </if>
  385. <if test="name != null">
  386. name = #{name,jdbcType=VARCHAR},
  387. </if>
  388. <if test="model != null">
  389. model = #{model,jdbcType=VARCHAR},
  390. </if>
  391. <if test="standard != null">
  392. standard = #{standard,jdbcType=VARCHAR},
  393. </if>
  394. <if test="brand != null">
  395. brand = #{brand,jdbcType=VARCHAR},
  396. </if>
  397. <if test="mnemonic != null">
  398. mnemonic = #{mnemonic,jdbcType=VARCHAR},
  399. </if>
  400. <if test="color != null">
  401. color = #{color,jdbcType=VARCHAR},
  402. </if>
  403. <if test="unit != null">
  404. unit = #{unit,jdbcType=VARCHAR},
  405. </if>
  406. <if test="remark != null">
  407. remark = #{remark,jdbcType=VARCHAR},
  408. </if>
  409. <if test="imgName != null">
  410. img_name = #{imgName,jdbcType=VARCHAR},
  411. </if>
  412. <if test="unitId != null">
  413. unit_id = #{unitId,jdbcType=BIGINT},
  414. </if>
  415. <if test="weight != null">
  416. weight = #{weight,jdbcType=DECIMAL},
  417. </if>
  418. <if test="enabled != null">
  419. enabled = #{enabled,jdbcType=BIT},
  420. </if>
  421. <if test="otherField1 != null">
  422. other_field1 = #{otherField1,jdbcType=VARCHAR},
  423. </if>
  424. <if test="otherField2 != null">
  425. other_field2 = #{otherField2,jdbcType=VARCHAR},
  426. </if>
  427. <if test="otherField3 != null">
  428. other_field3 = #{otherField3,jdbcType=VARCHAR},
  429. </if>
  430. <if test="enableSerialNumber != null">
  431. enable_serial_number = #{enableSerialNumber,jdbcType=VARCHAR},
  432. </if>
  433. <if test="enableBatchNumber != null">
  434. enable_batch_number = #{enableBatchNumber,jdbcType=VARCHAR},
  435. </if>
  436. <if test="tenantId != null">
  437. tenant_id = #{tenantId,jdbcType=BIGINT},
  438. </if>
  439. <if test="deleteFlag != null">
  440. delete_flag = #{deleteFlag,jdbcType=VARCHAR},
  441. </if>
  442. <if test="deleteFlag != null">
  443. delete_flag = #{deleteFlag,jdbcType=VARCHAR},
  444. </if>
  445. <if test="movingPinReminderCycle != null">
  446. moving_pin_reminder_cycle = #{movingPinReminderCycle,jdbcType=VARCHAR},
  447. </if>
  448. </set>
  449. where id = #{id,jdbcType=BIGINT}
  450. </update>
  451. <update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.Material">
  452. update jsh_material
  453. set category_id = #{categoryId,jdbcType=BIGINT},
  454. name = #{name,jdbcType=VARCHAR},
  455. model = #{model,jdbcType=VARCHAR},
  456. standard = #{standard,jdbcType=VARCHAR},
  457. brand = #{brand,jdbcType=VARCHAR},
  458. mnemonic = #{mnemonic,jdbcType=VARCHAR},
  459. color = #{color,jdbcType=VARCHAR},
  460. unit = #{unit,jdbcType=VARCHAR},
  461. remark = #{remark,jdbcType=VARCHAR},
  462. img_name = #{imgName,jdbcType=VARCHAR},
  463. unit_id = #{unitId,jdbcType=BIGINT},
  464. weight = #{weight,jdbcType=DECIMAL},
  465. enabled = #{enabled,jdbcType=BIT},
  466. other_field1 = #{otherField1,jdbcType=VARCHAR},
  467. other_field2 = #{otherField2,jdbcType=VARCHAR},
  468. other_field3 = #{otherField3,jdbcType=VARCHAR},
  469. enable_serial_number = #{enableSerialNumber,jdbcType=VARCHAR},
  470. enable_batch_number = #{enableBatchNumber,jdbcType=VARCHAR},
  471. tenant_id = #{tenantId,jdbcType=BIGINT},
  472. delete_flag = #{deleteFlag,jdbcType=VARCHAR}
  473. where id = #{id,jdbcType=BIGINT}
  474. </update>
  475. <select id="inventoryInquiryList" parameterType="com.jsh.erp.datasource.pda.dto.PDAInventoryDTO" resultType="com.jsh.erp.datasource.pda.vo.PDADepotItemVO">
  476. SELECT
  477. m.id materialId,
  478. me.id materialExtendId,
  479. m.name materialName,
  480. m.standard materialStandard,
  481. me.position,
  482. me.bar_code,
  483. me.commodity_unit,
  484. m.img_name,
  485. CAST(IFNULL(mi.inventory,0) / me.ratio AS DECIMAL(10,0)) inventory
  486. FROM jsh_material m
  487. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  488. left JOIN (SELECT material_id,SUM(current_number) AS 'inventory' FROM jsh_material_current_stock GROUP BY material_id) mi ON m.id = mi.material_id
  489. <where>
  490. m.enabled = 1 and me.id is not null
  491. <if test="keyword != null and keyword !=''">
  492. <bind name="bindKey" value="'%'+keyword+'%'"/>
  493. and (m.name like #{bindKey} or me.bar_code like #{bindKey})
  494. </if>
  495. <if test="categoryId != null">
  496. and m.category_id IN (
  497. <foreach collection="categoryIds" item="item" separator=",">
  498. #{item}
  499. </foreach>
  500. )
  501. </if>
  502. <if test="materialIds != null">
  503. and m.id IN (
  504. <foreach collection="materialIds" item="item" separator=",">
  505. #{item}
  506. </foreach>
  507. )
  508. </if>
  509. <if test="type == 'have'">
  510. and mi.inventory > 0
  511. </if>
  512. <if test="type == 'none'">
  513. and ifnull(mi.inventory,0) &lt;= 0
  514. </if>
  515. and ifnull(me.delete_flag,'0') !='1'
  516. </where>
  517. </select>
  518. </mapper>