MaterialMapperEx.xml 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  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.MaterialMapperEx">
  4. <resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultMapList" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  5. <result column="unitName" jdbcType="VARCHAR" property="unitName" />
  6. <result column="ratio" jdbcType="DECIMAL" property="ratio" />
  7. <result column="categoryName" jdbcType="VARCHAR" property="categoryName" />
  8. <result column="bar_code" jdbcType="VARCHAR" property="mBarCode" />
  9. <result column="commodity_unit" jdbcType="VARCHAR" property="commodityUnit" />
  10. <result column="purchase_decimal" jdbcType="VARCHAR" property="purchaseDecimal" />
  11. <result column="commodity_decimal" jdbcType="VARCHAR" property="commodityDecimal" />
  12. <result column="wholesale_decimal" jdbcType="VARCHAR" property="wholesaleDecimal" />
  13. <result column="low_decimal" jdbcType="VARCHAR" property="lowDecimal" />
  14. <result column="sku" jdbcType="VARCHAR" property="sku" />
  15. </resultMap>
  16. <resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultMapListWithStock" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  17. <result column="unitName" jdbcType="VARCHAR" property="unitName" />
  18. <result column="categoryName" jdbcType="VARCHAR" property="categoryName" />
  19. <result column="mBarCode" jdbcType="VARCHAR" property="mBarCode" />
  20. <result column="purchaseDecimal" jdbcType="VARCHAR" property="purchaseDecimal" />
  21. <result column="currentUnitPrice" jdbcType="VARCHAR" property="currentUnitPrice" />
  22. <result column="initialStock" jdbcType="DECIMAL" property="initialStock" />
  23. <result column="currentStock" jdbcType="DECIMAL" property="currentStock" />
  24. <result column="currentStockPrice" jdbcType="DECIMAL" property="currentStockPrice" />
  25. <result column="currentStockMovePrice" jdbcType="DECIMAL" property="currentStockMovePrice" />
  26. <result column="currentWeight" jdbcType="DECIMAL" property="currentWeight" />
  27. </resultMap>
  28. <resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultAndUnitMap" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  29. <result column="meId" jdbcType="BIGINT" property="meId" />
  30. <result column="unit_name" jdbcType="VARCHAR" property="unitName" />
  31. <result column="sku" jdbcType="VARCHAR" property="sku" />
  32. <result column="production_date" jdbcType="DATE" property="productionDate" />
  33. <result column="expiry_num" jdbcType="INTEGER" property="expiryNum" />
  34. <result column="supplier_id" jdbcType="BIGINT" property="supplierId" />
  35. <result column="bar_code" jdbcType="VARCHAR" property="barCode" />
  36. <result column="batch_number" jdbcType="VARCHAR" property="batchNumber" />
  37. <result column="inventory" jdbcType="BIGINT" property="inventory" />
  38. <result column="depot_id" jdbcType="BIGINT" property="depotId" />
  39. <result column="position" jdbcType="VARCHAR" property="position" />
  40. <result column="depotName" jdbcType="VARCHAR" property="depotName" />
  41. </resultMap>
  42. <resultMap id="InitialStockWithMaterialMap" type="com.jsh.erp.datasource.entities.MaterialInitialStockWithMaterial">
  43. <result column="material_id" jdbcType="BIGINT" property="materialId" />
  44. <result column="number" jdbcType="DECIMAL" property="number" />
  45. </resultMap>
  46. <select id="selectByConditionMaterial" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  47. select
  48. jm.id, jm.category_id, jm.name, jm.brand, jm.mnemonic, jm.remark, jm.img_name, jm.enabled,
  49. jm.other_field1, jm.other_field2, jm.other_field3, jm.enable_serial_number, jm.system_spu,
  50. jm.moving_pin_reminder_cycle, jm.expiry_num, jm.default_purchase_decimal, jm.default_wholesale_decimal, jm.reminder,
  51. mc.name categoryName,
  52. jme.sku, jme.model, jme.standard, jme.color, jme.weight, jme.commodity_unit
  53. from (select m.id, min(me.id) meId
  54. from jsh_material m
  55. left join jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  56. where 1=1
  57. <if test="materialParam != null and materialParam !=''">
  58. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  59. and (me.sku like #{bindKey} or me.batch_number like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.system_spu like #{bindKey}
  60. or me.model like #{bindKey} or me.color like #{bindKey} or m.brand like #{bindKey})
  61. </if>
  62. <if test="standard != null and standard !=''">
  63. <bind name="bindStandard" value="'%'+standard+'%'"/>
  64. and me.standard like #{bindStandard}
  65. </if>
  66. <if test="model != null and model !=''">
  67. <bind name="bindModel" value="'%'+model+'%'"/>
  68. and me.model like #{bindModel}
  69. </if>
  70. <if test="color != null and color !=''">
  71. <bind name="bindColor" value="'%'+color+'%'"/>
  72. and me.color like #{bindColor}
  73. </if>
  74. <if test="brand != null and brand !=''">
  75. <bind name="bindBrand" value="'%'+brand+'%'"/>
  76. and m.brand like #{bindBrand}
  77. </if>
  78. <if test="materialOther != null and materialOther !=''">
  79. <bind name="bindOther" value="'%'+materialOther+'%'"/>
  80. and (m.other_field1 like #{bindOther} or m.other_field2 like #{bindOther} or m.other_field3 like #{bindOther})
  81. </if>
  82. <if test="weight != null and weight !=''">
  83. and me.weight = #{weight}
  84. </if>
  85. <if test="expiryNum != null and expiryNum !=''">
  86. and m.expiry_num = #{expiryNum}
  87. </if>
  88. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  89. and m.enable_serial_number = #{enableSerialNumber}
  90. </if>
  91. <if test="enabled != null and enabled !=''">
  92. and m.enabled = #{enabled}
  93. </if>
  94. <if test="remark != null and remark !=''">
  95. <bind name="bindRemark" value="'%'+remark+'%'"/>
  96. and m.remark like #{bindRemark}
  97. </if>
  98. <if test="reminder != null and reminder !=''">
  99. <bind name="bindReminder" value="'%'+reminder+'%'"/>
  100. and m.reminder like #{bindReminder}
  101. </if>
  102. <if test="idList.size()>0">
  103. and m.category_id in
  104. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  105. #{item}
  106. </foreach>
  107. </if>
  108. and ifnull(m.delete_flag,'0') !='1'
  109. group by m.id
  110. order by m.id desc) tb
  111. left join jsh_material jm on tb.id = jm.id and ifnull(jm.delete_Flag,'0') !='1'
  112. left join jsh_material_extend jme on tb.meId = jme.id and ifnull(jme.delete_Flag,'0') !='1'
  113. left join jsh_material_category mc on jm.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  114. order by tb.id desc
  115. </select>
  116. <insert id="insertSelectiveEx" parameterType="com.jsh.erp.datasource.entities.Material" useGeneratedKeys="true" keyProperty="id">
  117. insert into jsh_material
  118. <trim prefix="(" suffix=")" suffixOverrides=",">
  119. <if test="id != null">
  120. id,
  121. </if>
  122. <if test="categoryId != null">
  123. category_id,
  124. </if>
  125. <if test="name != null">
  126. name,
  127. </if>
  128. <if test="brand != null">
  129. brand,
  130. </if>
  131. <if test="mnemonic != null">
  132. mnemonic,
  133. </if>
  134. <if test="unit != null">
  135. unit,
  136. </if>
  137. <if test="remark != null">
  138. remark,
  139. </if>
  140. <if test="imgName != null">
  141. img_name,
  142. </if>
  143. <if test="unitId != null">
  144. unit_id,
  145. </if>
  146. <if test="enabled != null">
  147. enabled,
  148. </if>
  149. <if test="otherField1 != null">
  150. other_field1,
  151. </if>
  152. <if test="otherField2 != null">
  153. other_field2,
  154. </if>
  155. <if test="otherField3 != null">
  156. other_field3,
  157. </if>
  158. <if test="enableSerialNumber != null">
  159. enable_serial_number,
  160. </if>
  161. <if test="enableBatchNumber != null">
  162. enable_batch_number,
  163. </if>
  164. <if test="tenantId != null">
  165. tenant_id,
  166. </if>
  167. <if test="deleteFlag != null">
  168. delete_flag,
  169. </if>
  170. <if test="systemSpu != null">
  171. system_spu,
  172. </if>
  173. <if test="movingPinReminderCycle != null">
  174. moving_pin_reminder_cycle,
  175. </if>
  176. <if test="expiryNum != null">
  177. expiry_num,
  178. </if>
  179. <if test="defaultPurchaseDecimal != null">
  180. default_purchase_decimal,
  181. </if>
  182. <if test="defaultWholesaleDecimal != null">
  183. default_wholesale_decimal,
  184. </if>
  185. </trim>
  186. <trim prefix="values (" suffix=")" suffixOverrides=",">
  187. <if test="id != null">
  188. #{id,jdbcType=BIGINT},
  189. </if>
  190. <if test="categoryId != null">
  191. #{categoryId,jdbcType=BIGINT},
  192. </if>
  193. <if test="name != null">
  194. #{name,jdbcType=VARCHAR},
  195. </if>
  196. <if test="brand != null">
  197. #{brand,jdbcType=VARCHAR},
  198. </if>
  199. <if test="mnemonic != null">
  200. #{mnemonic,jdbcType=VARCHAR},
  201. </if>
  202. <if test="unit != null">
  203. #{unit,jdbcType=VARCHAR},
  204. </if>
  205. <if test="remark != null">
  206. #{remark,jdbcType=VARCHAR},
  207. </if>
  208. <if test="imgName != null">
  209. #{imgName,jdbcType=VARCHAR},
  210. </if>
  211. <if test="unitId != null">
  212. #{unitId,jdbcType=BIGINT},
  213. </if>
  214. <if test="enabled != null">
  215. #{enabled,jdbcType=BIT},
  216. </if>
  217. <if test="otherField1 != null">
  218. #{otherField1,jdbcType=VARCHAR},
  219. </if>
  220. <if test="otherField2 != null">
  221. #{otherField2,jdbcType=VARCHAR},
  222. </if>
  223. <if test="otherField3 != null">
  224. #{otherField3,jdbcType=VARCHAR},
  225. </if>
  226. <if test="enableSerialNumber != null">
  227. #{enableSerialNumber,jdbcType=VARCHAR},
  228. </if>
  229. <if test="enableBatchNumber != null">
  230. #{enableBatchNumber,jdbcType=VARCHAR},
  231. </if>
  232. <if test="tenantId != null">
  233. #{tenantId,jdbcType=BIGINT},
  234. </if>
  235. <if test="deleteFlag != null">
  236. #{deleteFlag,jdbcType=VARCHAR},
  237. </if>
  238. <if test="systemSpu != null">
  239. #{systemSpu},
  240. </if>
  241. <if test="movingPinReminderCycle != null">
  242. #{movingPinReminderCycle,jdbcType=VARCHAR},
  243. </if>
  244. <if test="expiryNum != null">
  245. #{expiryNum},
  246. </if>
  247. <if test="defaultPurchaseDecimal != null">
  248. #{defaultPurchaseDecimal},
  249. </if>
  250. <if test="defaultWholesaleDecimal != null">
  251. #{defaultWholesaleDecimal},
  252. </if>
  253. </trim>
  254. </insert>
  255. <select id="findUnitList" resultType="com.jsh.erp.datasource.entities.Unit">
  256. select u.* from jsh_unit u
  257. left join jsh_material m on m.unit_id=u.id and ifnull(m.delete_flag,'0') !='1'
  258. where m.id = #{mId}
  259. and ifnull(u.delete_flag,'0') !='1'
  260. </select>
  261. <select id="findById" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
  262. select m.*,u.name unit_name from jsh_material m
  263. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_flag,'0') !='1'
  264. where m.id = #{id}
  265. and ifnull(m.delete_flag,'0') !='1'
  266. </select>
  267. <select id="findByIdWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
  268. select m.*,u.name unit_name,me.bar_code m_bar_code, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,
  269. me.wholesale_decimal, me.low_decimal
  270. from jsh_material m
  271. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  272. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  273. where me.id = #{meId}
  274. and ifnull(m.delete_flag,'0') !='1'
  275. </select>
  276. <select id="getMaterialByParam" resultType="com.jsh.erp.datasource.vo.MaterialVoSearch">
  277. select me.bar_code, m.name, m.mnemonic, m.standard, m.model, m.color, me.commodity_unit unit, me.batch_number
  278. from jsh_material m
  279. left join jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  280. where m.enabled=1 and me.id is not null
  281. <if test="materialParam != null and materialParam !=''">
  282. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  283. and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey} or m.mnemonic like #{bindKey})
  284. </if>
  285. and ifnull(m.delete_flag,'0') !='1'
  286. order by m.id desc, me.default_flag desc, me.id asc
  287. limit 0,20
  288. </select>
  289. <select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  290. select m.*,u.name unit_name,mc.name categoryName,me.bar_code,me.id meId,me.commodity_unit,me.sku,
  291. me.production_date,me.expiry_num,me.supplier_id,me.batch_number,me.depot_id,me.position,d.`name` depotName,s.supplier supplierName,me.inventory
  292. from jsh_material m
  293. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  294. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  295. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  296. left JOIN jsh_depot d on me.depot_id = d.id and ifnull(d.delete_Flag,'0') !='1'
  297. left JOIN jsh_supplier s on me.supplier_id = s.id and ifnull(s.delete_Flag,'0') !='1'
  298. where m.enabled=1 and me.id is not null
  299. <if test="q != null and q !=''">
  300. <bind name="bindKey" value="'%'+q+'%'"/>
  301. and (me.bar_code like #{bindKey} or me.batch_number like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey}
  302. or m.model like #{bindKey} or m.color like #{bindKey} or m.brand like #{bindKey} )
  303. </if>
  304. <if test="standardOrModel != null and standardOrModel !=''">
  305. <bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
  306. and (m.standard like #{bindStandardOrModel} or m.model like #{bindStandardOrModel})
  307. </if>
  308. <if test="color != null and color !=''">
  309. <bind name="bindColor" value="'%'+color+'%'"/>
  310. and m.color like #{bindColor}
  311. </if>
  312. <if test="brand != null and brand !=''">
  313. <bind name="bindBrand" value="'%'+brand+'%'"/>
  314. and m.brand like #{bindBrand}
  315. </if>
  316. <if test="idList.size()>0">
  317. and m.category_id in
  318. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  319. #{item}
  320. </foreach>
  321. </if>
  322. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  323. and m.enable_serial_number = #{enableSerialNumber}
  324. </if>
  325. <if test="enableBatchNumber != null and enableBatchNumber !=''">
  326. and m.enable_batch_number = #{enableBatchNumber}
  327. </if>
  328. <if test="depotId != null and depotId !=''">
  329. and me.depot_id = #{depotId}
  330. </if>
  331. and ifnull(m.delete_flag,'0') !='1'
  332. ORDER BY m.id desc, me.default_flag desc, me.id asc
  333. <if test="offset != null and rows != null">
  334. limit #{offset},#{rows}
  335. </if>
  336. </select>
  337. <select id="findBySelectWithSku" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  338. select
  339. m.id, m.name, m.brand,
  340. mc.name categoryName,
  341. me.id meId, me.sku, me.commodity_unit, me.standard, me.color, me.model, me.weight
  342. from jsh_material m
  343. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  344. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  345. where m.enabled = 1 AND me.id is not null AND me.enabled = 1
  346. <if test="q != null and q !=''">
  347. <bind name="bindKey" value="'%'+q+'%'"/>
  348. and (me.sku like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or me.standard like #{bindKey}
  349. or me.model like #{bindKey} or me.color like #{bindKey} or m.brand like #{bindKey} )
  350. </if>
  351. <if test="standardOrModel != null and standardOrModel !=''">
  352. <bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
  353. and (me.standard like #{bindStandardOrModel} or me.model like #{bindStandardOrModel})
  354. </if>
  355. <if test="color != null and color !=''">
  356. <bind name="bindColor" value="'%'+color+'%'"/>
  357. and me.color like #{bindColor}
  358. </if>
  359. <if test="brand != null and brand !=''">
  360. <bind name="bindBrand" value="'%'+brand+'%'"/>
  361. and m.brand like #{bindBrand}
  362. </if>
  363. <if test="idList.size()>0">
  364. and m.category_id in
  365. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  366. #{item}
  367. </foreach>
  368. </if>
  369. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  370. and m.enable_serial_number = #{enableSerialNumber}
  371. </if>
  372. and ifnull(m.delete_flag,'0') !='1'
  373. ORDER BY m.id desc, me.default_flag desc, me.id asc
  374. <if test="offset != null and rows != null">
  375. limit #{offset},#{rows}
  376. </if>
  377. </select>
  378. <select id="findBySelectWithBarCodeCount" resultType="java.lang.Integer">
  379. select count(1) from jsh_material m
  380. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  381. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  382. where m.enabled=1 and me.id is not null
  383. <if test="q != null and q !=''">
  384. <bind name="bindKey" value="'%'+q+'%'"/>
  385. and (me.bar_code like #{bindKey} or me.batch_number like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey}
  386. or m.model like #{bindKey} or m.color like #{bindKey} or m.brand like #{bindKey})
  387. </if>
  388. <if test="standardOrModel != null and standardOrModel !=''">
  389. <bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
  390. and (m.standard like #{bindStandardOrModel} or m.model like #{bindStandardOrModel})
  391. </if>
  392. <if test="color != null and color !=''">
  393. <bind name="bindColor" value="'%'+color+'%'"/>
  394. and m.color like #{bindColor}
  395. </if>
  396. <if test="brand != null and brand !=''">
  397. <bind name="bindBrand" value="'%'+brand+'%'"/>
  398. and m.brand like #{bindBrand}
  399. </if>
  400. <if test="idList.size()>0">
  401. and m.category_id in
  402. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  403. #{item}
  404. </foreach>
  405. </if>
  406. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  407. and m.enable_serial_number = #{enableSerialNumber}
  408. </if>
  409. <if test="enableBatchNumber != null and enableBatchNumber !=''">
  410. and m.enable_batch_number = #{enableBatchNumber}
  411. </if>
  412. <if test="depotId != null and depotId !=''">
  413. and me.depot_id = #{depotId}
  414. </if>
  415. and ifnull(m.delete_flag,'0') !='1'
  416. </select>
  417. <select id="findBySelectWithSkuCount" resultType="java.lang.Integer">
  418. select count(1) from jsh_material m
  419. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  420. where m.enabled = 1 AND me.id is not null AND me.enabled = 1
  421. <if test="q != null and q !=''">
  422. <bind name="bindKey" value="'%'+q+'%'"/>
  423. and (me.sku like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or me.standard like #{bindKey}
  424. or me.model like #{bindKey} or me.color like #{bindKey} or m.brand like #{bindKey})
  425. </if>
  426. <if test="standardOrModel != null and standardOrModel !=''">
  427. <bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
  428. and (me.standard like #{bindStandardOrModel} or me.model like #{bindStandardOrModel})
  429. </if>
  430. <if test="color != null and color !=''">
  431. <bind name="bindColor" value="'%'+color+'%'"/>
  432. and me.color like #{bindColor}
  433. </if>
  434. <if test="brand != null and brand !=''">
  435. <bind name="bindBrand" value="'%'+brand+'%'"/>
  436. and m.brand like #{bindBrand}
  437. </if>
  438. <if test="idList.size()>0">
  439. and m.category_id in
  440. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  441. #{item}
  442. </foreach>
  443. </if>
  444. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  445. and m.enable_serial_number = #{enableSerialNumber}
  446. </if>
  447. and ifnull(m.delete_flag,'0') !='1'
  448. </select>
  449. <select id="exportExcel" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  450. select m.*,u.name unitName, u.ratio, mc.name categoryName,me.bar_code,me.commodity_unit,me.purchase_decimal, me.commodity_decimal,
  451. me.wholesale_decimal, me.low_decimal, me.sku, me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.depot_id, me.position
  452. from jsh_material m
  453. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  454. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  455. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  456. where 1=1
  457. and (me.default_flag=1 or (me.sku is not null and me.sku!=''))
  458. <if test="materialParam != null and materialParam !=''">
  459. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  460. and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
  461. </if>
  462. <if test="color != null and color !=''">
  463. <bind name="bindColor" value="'%'+color+'%'"/>
  464. and m.color like #{bindColor}
  465. </if>
  466. <if test="materialOther != null and materialOther !=''">
  467. <bind name="bindOther" value="'%'+materialOther+'%'"/>
  468. and (m.other_field1 like #{bindOther}
  469. or m.other_field2 like #{bindOther} or m.other_field3 like #{bindOther})
  470. </if>
  471. <if test="weight != null and weight !=''">
  472. and m.weight = #{weight}
  473. </if>
  474. <if test="expiryNum != null and expiryNum !=''">
  475. and m.expiry_num = #{expiryNum}
  476. </if>
  477. <if test="enabled != null and enabled !=''">
  478. and m.enabled = #{enabled}
  479. </if>
  480. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  481. and m.enable_serial_number = #{enableSerialNumber}
  482. </if>
  483. <if test="enableBatchNumber != null and enableBatchNumber !=''">
  484. and m.enable_batch_number = #{enableBatchNumber}
  485. </if>
  486. <if test="remark != null and remark !=''">
  487. <bind name="bindRemark" value="'%'+remark+'%'"/>
  488. and m.remark like #{bindRemark}
  489. </if>
  490. <if test="idList.size()>0">
  491. and m.category_id in
  492. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  493. #{item}
  494. </foreach>
  495. </if>
  496. and ifnull(m.delete_flag,'0') !='1'
  497. order by m.id desc, me.default_flag desc, me.id asc
  498. </select>
  499. <select id="getOtherMaterialList" resultType="com.jsh.erp.datasource.entities.MaterialExtend">
  500. select me.material_id, me.bar_code, me.commodity_unit from jsh_material_extend me
  501. where me.default_flag=0 and (me.sku='' or me.sku is null)
  502. and ifnull(me.delete_Flag,'0') !='1'
  503. group by me.material_id, me.bar_code, me.commodity_unit
  504. </select>
  505. <select id="findByMaterialName" resultType="com.jsh.erp.datasource.entities.Material">
  506. select m.*
  507. FROM jsh_material m
  508. where 1=1
  509. <if test="name != null">
  510. and m.name =#{name}
  511. </if>
  512. and ifnull(m.delete_flag,'0') !='1'
  513. </select>
  514. <select id="getMaterialEnableSerialNumberList" parameterType="java.util.Map" resultMap="ResultAndUnitMap">
  515. select m.*,me.bar_code m_bar_code from jsh_material m
  516. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  517. where 1=1
  518. and m.enabled=1
  519. and m.enable_serial_number ='1'
  520. <if test="q != null and q !=''">
  521. <bind name="bindKey" value="'%'+q+'%'"/>
  522. and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
  523. </if>
  524. and ifnull(m.delete_flag,'0') !='1'
  525. order by m.id desc
  526. <if test="offset != null and rows != null">
  527. limit #{offset},#{rows}
  528. </if>
  529. </select>
  530. <select id="getMaterialEnableSerialNumberCount" resultType="java.lang.Long">
  531. select count(me.id) from jsh_material m
  532. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  533. where 1=1
  534. and m.enabled ='1'
  535. and m.enable_serial_number ='1'
  536. <if test="q != null and q !=''">
  537. <bind name="bindKey" value="'%'+q+'%'"/>
  538. and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
  539. </if>
  540. and ifnull(m.delete_flag,'0') !='1'
  541. </select>
  542. <update id="batchDeleteMaterialByIds">
  543. update jsh_material
  544. set delete_flag='1'
  545. where 1=1
  546. and ifnull(delete_flag,'0') !='1'
  547. and id in (
  548. <foreach collection="ids" item="id" separator=",">
  549. #{id}
  550. </foreach>
  551. )
  552. </update>
  553. <select id="getMaterialListByCategoryIds" resultMap="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap">
  554. select
  555. <include refid="com.jsh.erp.datasource.mappers.MaterialMapper.Base_Column_List" />
  556. from jsh_material
  557. where 1=1
  558. and category_id in (
  559. <foreach collection="categoryIds" item="categoryId" separator=",">
  560. #{categoryId}
  561. </foreach>
  562. )
  563. and ifnull(delete_flag,'0') !='1'
  564. </select>
  565. <select id="getMaterialListByUnitIds" resultMap="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap">
  566. select
  567. <include refid="com.jsh.erp.datasource.mappers.MaterialMapper.Base_Column_List" />
  568. from jsh_material
  569. where 1=1
  570. and unit_id in (
  571. <foreach collection="unitIds" item="unitId" separator=",">
  572. #{unitId}
  573. </foreach>
  574. )
  575. and ifnull(delete_flag,'0') !='1'
  576. </select>
  577. <select id="getBarCodeList" resultType="java.lang.String">
  578. select me.bar_code from jsh_material_extend me
  579. where ifnull(me.delete_Flag,'0') !='1'
  580. </select>
  581. <select id="getMaterialByMeId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
  582. select m.*,me.bar_code,u.name unitName, mc.name categoryName
  583. FROM jsh_material m
  584. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  585. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_flag,'0') !='1'
  586. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  587. where 1=1
  588. <if test="meId != null">
  589. and me.id = #{meId}
  590. </if>
  591. and ifnull(m.delete_flag,'0') !='1'
  592. </select>
  593. <select id="getMaterialNameList" resultType="java.lang.String">
  594. select m.name from jsh_material m
  595. where m.name is not null and m.name !='' and ifnull(m.delete_flag,'0') !='1'
  596. group by m.name
  597. order by m.name asc
  598. </select>
  599. <select id="getMaterialByBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
  600. select m.*,u.name unit_name, me.id meId,me.bar_code m_bar_code, me.commodity_unit,
  601. me.sku, me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.depot_id,me.ratio
  602. from jsh_material m
  603. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  604. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  605. where
  606. me.sku in (
  607. <foreach collection="barCodeArray" item="barCode" separator=",">
  608. #{barCode}
  609. </foreach>
  610. )
  611. and ifnull(m.delete_flag,'0') !='1'
  612. order by m.id desc, me.default_flag desc, me.id asc
  613. </select>
  614. <select id="getMaterialBySku" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  615. select
  616. m.id, m.name, m.expiry_num, m.default_purchase_decimal, m.default_wholesale_decimal,
  617. me.id meId, me.sku, me.commodity_unit, me.standard
  618. from jsh_material m
  619. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  620. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  621. where
  622. me.sku in (
  623. <foreach collection="skuArray" item="sku" separator=",">
  624. #{sku}
  625. </foreach>
  626. )
  627. and ifnull(m.delete_flag,'0') !='1'
  628. order by m.id desc, me.default_flag desc, me.id asc
  629. </select>
  630. <select id="getMaterialByBarCodeAndWithOutMId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
  631. select m.*,u.name unit_name, me.id meId,me.bar_code m_bar_code, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,
  632. me.wholesale_decimal, me.low_decimal, me.sku
  633. from jsh_material m
  634. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  635. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  636. where
  637. me.bar_code in (
  638. <foreach collection="barCodeArray" item="barCode" separator=",">
  639. #{barCode}
  640. </foreach>
  641. )
  642. and me.material_id!=#{mId}
  643. and ifnull(m.delete_flag,'0') !='1'
  644. order by me.id desc
  645. </select>
  646. <update id="setUnitIdToNull">
  647. update jsh_material
  648. set unit_id = null
  649. where 1=1
  650. and ifnull(delete_flag,'0') !='1'
  651. and id = #{id}
  652. </update>
  653. <update id="setExpiryNumToNull">
  654. update jsh_material
  655. set expiry_num = null
  656. where 1=1
  657. and ifnull(delete_flag,'0') !='1'
  658. and id = #{id}
  659. </update>
  660. <select id="getInitialStockWithMaterial" resultMap="InitialStockWithMaterialMap">
  661. select material_id, ifnull(sum(mis.number),0) number
  662. from jsh_material_initial_stock mis
  663. where 1=1
  664. <if test="depotList.size()>0">
  665. and mis.depot_id in
  666. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  667. #{item}
  668. </foreach>
  669. </if>
  670. group by mis.material_id
  671. </select>
  672. <select id="getListWithStock" resultMap="ResultMapListWithStock">
  673. select m.id, m.name, m.standard, m.model, m.color,
  674. me.commodity_unit unitName, mc.name categoryName, me.bar_code mBarCode,
  675. ifnull(me.purchase_decimal,0) purchaseDecimal,
  676. ifnull(mcs.current_unit_price,0) currentUnitPrice,
  677. ifnull(sum(mcs.current_number),0) currentStock,
  678. sum(ifnull(me.purchase_decimal, 0) * ifnull(mcs.current_number, 0)) currentStockPrice,
  679. sum(ifnull(mcs.current_unit_price, 0) * ifnull(mcs.current_number, 0)) currentStockMovePrice,
  680. sum(ifnull(m.weight, 0) * ifnull(mcs.current_number, 0)) currentWeight
  681. FROM jsh_material m
  682. left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  683. left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
  684. <if test="depotList.size()>0">
  685. and mcs.depot_id in
  686. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  687. #{item}
  688. </foreach>
  689. </if>
  690. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  691. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  692. where 1=1
  693. and me.default_flag=1
  694. <if test="idList.size()>0">
  695. and m.category_id in
  696. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  697. #{item}
  698. </foreach>
  699. </if>
  700. <if test="position != null and position !=''">
  701. <bind name="bindPosition" value="'%'+position+'%'"/>
  702. and m.position like #{bindPosition}
  703. </if>
  704. <if test="materialParam != null">
  705. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  706. and (me.bar_code like #{bindKey} or me.batch_number like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
  707. or m.color like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
  708. or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
  709. </if>
  710. and ifnull(m.delete_flag,'0') !='1'
  711. group by m.id, m.name, m.standard, m.model, m.color, m.brand,
  712. me.commodity_unit, mc.name, me.bar_code, me.purchase_decimal, mcs.current_unit_price
  713. <if test="zeroStock == 0">
  714. having ifnull(sum(mcs.current_number),0)!=0
  715. </if>
  716. <if test="column == 'createTime'">
  717. order by m.id desc
  718. </if>
  719. <if test="column != 'createTime'">
  720. order by ${column} ${order}
  721. </if>
  722. <if test="offset != null and rows != null">
  723. limit #{offset},#{rows}
  724. </if>
  725. </select>
  726. <select id="getListWithStockCount" resultType="java.lang.Integer">
  727. select count(tb.id) from
  728. (select m.id, ifnull(sum(mcs.current_number),0) currentStock from jsh_material m
  729. left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  730. left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
  731. <if test="depotList.size()>0">
  732. and mcs.depot_id in
  733. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  734. #{item}
  735. </foreach>
  736. </if>
  737. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  738. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  739. where 1=1
  740. and me.default_flag=1
  741. <if test="idList.size()>0">
  742. and m.category_id in
  743. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  744. #{item}
  745. </foreach>
  746. </if>
  747. <if test="position != null and position !=''">
  748. <bind name="bindPosition" value="'%'+position+'%'"/>
  749. and m.position like #{bindPosition}
  750. </if>
  751. <if test="materialParam != null">
  752. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  753. and (me.bar_code like #{bindKey} or me.batch_number like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
  754. or m.color like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
  755. or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
  756. </if>
  757. and ifnull(m.delete_flag,'0') !='1'
  758. group by m.id
  759. <if test="zeroStock == 0">
  760. having ifnull(sum(mcs.current_number),0)!=0
  761. </if>
  762. ) tb
  763. </select>
  764. <select id="getTotalStockAndPrice" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  765. select
  766. ifnull(sum(mcs.current_number),0) currentStock,
  767. sum(ifnull(me.purchase_decimal,0)*ifnull(mcs.current_number,0)) currentStockPrice,
  768. sum(ifnull(mcs.current_unit_price,0)*ifnull(mcs.current_number,0)) currentStockMovePrice,
  769. sum(ifnull(m.weight,0)*ifnull(mcs.current_number,0)) currentWeight
  770. from jsh_material m
  771. left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  772. left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
  773. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  774. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  775. where 1=1
  776. and me.default_flag=1
  777. <if test="depotList.size()>0">
  778. and mcs.depot_id in
  779. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  780. #{item}
  781. </foreach>
  782. </if>
  783. <if test="idList.size()>0">
  784. and m.category_id in
  785. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  786. #{item}
  787. </foreach>
  788. </if>
  789. <if test="position != null and position !=''">
  790. <bind name="bindPosition" value="'%'+position+'%'"/>
  791. and m.position like #{bindPosition}
  792. </if>
  793. <if test="materialParam != null">
  794. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  795. and (me.bar_code like #{bindKey} or me.batch_number like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
  796. or m.color like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
  797. or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
  798. </if>
  799. and ifnull(m.delete_flag,'0') !='1'
  800. </select>
  801. <select id="checkIsExist" resultType="java.lang.Integer">
  802. select count(1) from jsh_material m
  803. where ifnull(m.delete_flag,'0') !='1'
  804. <if test="name != null">
  805. and m.name = #{name}
  806. </if>
  807. <if test="model != null">
  808. and m.model = #{model}
  809. </if>
  810. <if test="color != null">
  811. and m.color = #{color}
  812. </if>
  813. <if test="standard != null">
  814. and m.standard = #{standard}
  815. </if>
  816. <if test="otherField1 != null">
  817. and m.other_field1 = #{otherField1}
  818. </if>
  819. <if test="otherField2 != null">
  820. and m.other_field2 = #{otherField2}
  821. </if>
  822. <if test="otherField3 != null">
  823. and m.other_field3 = #{otherField3}
  824. </if>
  825. <if test="unit != null">
  826. and m.unit = #{unit}
  827. </if>
  828. <if test="unitId != null">
  829. and m.unit_id = #{unitId}
  830. </if>
  831. <if test="id != null">
  832. and m.id != #{id}
  833. </if>
  834. </select>
  835. <select id="getMaterialExtendBySerialNumber" resultType="com.jsh.erp.datasource.entities.MaterialExtend">
  836. select me.bar_code
  837. from jsh_material m
  838. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_flag,'0') !='1'
  839. left join jsh_serial_number sn on sn.material_id=m.id and ifnull(sn.delete_flag,'0') !='1'
  840. where sn.serial_number = #{serialNumber}
  841. and me.default_flag=1
  842. and ifnull(m.delete_flag,'0') !='1'
  843. limit 0,1
  844. </select>
  845. <select id="getMaterialBySystemSku" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  846. WITH RankedExtend AS (
  847. SELECT
  848. me.*,
  849. ROW_NUMBER() OVER (PARTITION BY me.material_id ORDER BY me.batch_number DESC) AS rn
  850. FROM jsh_material_extend me
  851. LEFT JOIN jsh_material m ON m.id = me.material_id
  852. WHERE ifnull(me.delete_Flag, '0') != '1'
  853. AND m.system_sku IN (
  854. <foreach collection="systemSkuArray" item="systemSku" separator=",">
  855. #{systemSku}
  856. </foreach>
  857. )
  858. )
  859. SELECT
  860. m.*,
  861. re.id AS meId,
  862. re.bar_code AS m_bar_code,
  863. re.commodity_unit,
  864. re.purchase_decimal,
  865. re.commodity_decimal,
  866. re.wholesale_decimal,
  867. re.low_decimal,
  868. me.sku,
  869. me.production_date,
  870. me.expiry_num,
  871. me.supplier_id,
  872. me.bar_code,
  873. me.batch_number,
  874. me.inventory,
  875. me.depot_id,
  876. me.POSITION
  877. FROM jsh_material m
  878. LEFT JOIN RankedExtend re ON m.id = re.material_id AND re.rn = 1
  879. LEFT JOIN jsh_material_extend me ON re.bar_code = me.bar_code
  880. WHERE ifnull(m.delete_flag, '0') != '1' AND re.id IS NOT NULL
  881. ORDER BY m.id DESC, me.default_flag DESC, me.production_date,me.batch_number ASC
  882. </select>
  883. <select id="getMaterialCurrentPriceByIdList" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku">
  884. WITH RankedExtend AS (
  885. SELECT
  886. me.*,
  887. ROW_NUMBER() OVER (PARTITION BY me.material_id ORDER BY me.batch_number DESC) AS rn
  888. FROM jsh_material_extend me
  889. LEFT JOIN jsh_material m ON m.id = me.material_id
  890. WHERE ifnull(me.delete_Flag, '0') != '1'
  891. AND m.id IN (
  892. <foreach collection="idList" item="systemSku" separator=",">
  893. #{systemSku}
  894. </foreach>
  895. )
  896. )
  897. SELECT
  898. m.id AS mId,
  899. m.name AS mName,
  900. m.unit AS unit,
  901. m.unit_id AS unitId,
  902. m.system_sku AS systemSku,
  903. re.wholesale_decimal AS basicUnitSalePrice
  904. FROM jsh_material m
  905. LEFT JOIN RankedExtend re ON m.id = re.material_id AND re.rn = 1
  906. WHERE ifnull(m.delete_flag, '0') != '1' AND re.id IS NOT NULL
  907. ORDER BY m.id DESC
  908. </select>
  909. <select id="pdaPrintMaterial" parameterType="java.lang.Long" resultType="com.jsh.erp.datasource.pda.vo.PDAPrintVo">
  910. SELECT s.supplier customerName,dh.number,m.system_spu barCode,mb.batch_number
  911. FROM
  912. jsh_depot_item di
  913. LEFT JOIN jsh_depot_head dh ON di.header_id = dh.id
  914. LEFT JOIN jsh_material m ON di.material_id = m.id
  915. LEFT JOIN jsh_supplier s ON dh.organ_id = s.id
  916. LEFT JOIN material_batch mb ON (SELECT id FROM jsh_depot_item WHERE link_id = di.id LIMIT 1) = mb.depot_item_id
  917. WHERE di.id = #{depotItemId}
  918. </select>
  919. </mapper>