MaterialMapperEx.xml 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  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.*,
  451. u.name unitName, u.ratio,
  452. mc.name categoryName,
  453. me.id AS meId,me.bar_code,me.commodity_unit,me.purchase_decimal, me.commodity_decimal,me.wholesale_decimal,
  454. me.low_decimal, me.sku, me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number,
  455. me.depot_id, me.position
  456. from jsh_material m
  457. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  458. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  459. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  460. where 1=1
  461. and (me.default_flag=1 or (me.sku is not null and me.sku!=''))
  462. <if test="materialParam != null and materialParam !=''">
  463. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  464. and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
  465. </if>
  466. <if test="color != null and color !=''">
  467. <bind name="bindColor" value="'%'+color+'%'"/>
  468. and m.color like #{bindColor}
  469. </if>
  470. <if test="materialOther != null and materialOther !=''">
  471. <bind name="bindOther" value="'%'+materialOther+'%'"/>
  472. and (m.other_field1 like #{bindOther}
  473. or m.other_field2 like #{bindOther} or m.other_field3 like #{bindOther})
  474. </if>
  475. <if test="weight != null and weight !=''">
  476. and m.weight = #{weight}
  477. </if>
  478. <if test="expiryNum != null and expiryNum !=''">
  479. and m.expiry_num = #{expiryNum}
  480. </if>
  481. <if test="enabled != null and enabled !=''">
  482. and m.enabled = #{enabled}
  483. </if>
  484. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  485. and m.enable_serial_number = #{enableSerialNumber}
  486. </if>
  487. <if test="enableBatchNumber != null and enableBatchNumber !=''">
  488. and m.enable_batch_number = #{enableBatchNumber}
  489. </if>
  490. <if test="remark != null and remark !=''">
  491. <bind name="bindRemark" value="'%'+remark+'%'"/>
  492. and m.remark like #{bindRemark}
  493. </if>
  494. <if test="idList.size()>0">
  495. and m.category_id in
  496. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  497. #{item}
  498. </foreach>
  499. </if>
  500. and ifnull(m.delete_flag,'0') !='1'
  501. order by m.id desc, me.default_flag desc, me.id asc
  502. </select>
  503. <select id="getOtherMaterialList" resultType="com.jsh.erp.datasource.entities.MaterialExtend">
  504. select me.material_id, me.bar_code, me.commodity_unit from jsh_material_extend me
  505. where me.default_flag=0 and (me.sku='' or me.sku is null)
  506. and ifnull(me.delete_Flag,'0') !='1'
  507. group by me.material_id, me.bar_code, me.commodity_unit
  508. </select>
  509. <select id="findByMaterialName" resultType="com.jsh.erp.datasource.entities.Material">
  510. select m.*
  511. FROM jsh_material m
  512. where 1=1
  513. <if test="name != null">
  514. and m.name =#{name}
  515. </if>
  516. and ifnull(m.delete_flag,'0') !='1'
  517. </select>
  518. <select id="getMaterialEnableSerialNumberList" parameterType="java.util.Map" resultMap="ResultAndUnitMap">
  519. select m.*,me.bar_code m_bar_code from jsh_material m
  520. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  521. where 1=1
  522. and m.enabled=1
  523. and m.enable_serial_number ='1'
  524. <if test="q != null and q !=''">
  525. <bind name="bindKey" value="'%'+q+'%'"/>
  526. and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
  527. </if>
  528. and ifnull(m.delete_flag,'0') !='1'
  529. order by m.id desc
  530. <if test="offset != null and rows != null">
  531. limit #{offset},#{rows}
  532. </if>
  533. </select>
  534. <select id="getMaterialEnableSerialNumberCount" resultType="java.lang.Long">
  535. select count(me.id) from jsh_material m
  536. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  537. where 1=1
  538. and m.enabled ='1'
  539. and m.enable_serial_number ='1'
  540. <if test="q != null and q !=''">
  541. <bind name="bindKey" value="'%'+q+'%'"/>
  542. and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
  543. </if>
  544. and ifnull(m.delete_flag,'0') !='1'
  545. </select>
  546. <update id="batchDeleteMaterialByIds">
  547. update jsh_material
  548. set delete_flag='1'
  549. where 1=1
  550. and ifnull(delete_flag,'0') !='1'
  551. and id in (
  552. <foreach collection="ids" item="id" separator=",">
  553. #{id}
  554. </foreach>
  555. )
  556. </update>
  557. <select id="getMaterialListByCategoryIds" resultMap="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap">
  558. select
  559. <include refid="com.jsh.erp.datasource.mappers.MaterialMapper.Base_Column_List" />
  560. from jsh_material
  561. where 1=1
  562. and category_id in (
  563. <foreach collection="categoryIds" item="categoryId" separator=",">
  564. #{categoryId}
  565. </foreach>
  566. )
  567. and ifnull(delete_flag,'0') !='1'
  568. </select>
  569. <select id="getMaterialListByUnitIds" resultMap="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap">
  570. select
  571. <include refid="com.jsh.erp.datasource.mappers.MaterialMapper.Base_Column_List" />
  572. from jsh_material
  573. where 1=1
  574. and unit_id in (
  575. <foreach collection="unitIds" item="unitId" separator=",">
  576. #{unitId}
  577. </foreach>
  578. )
  579. and ifnull(delete_flag,'0') !='1'
  580. </select>
  581. <select id="getBarCodeList" resultType="java.lang.String">
  582. select me.bar_code from jsh_material_extend me
  583. where ifnull(me.delete_Flag,'0') !='1'
  584. </select>
  585. <select id="getMaterialByMeId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
  586. select m.*,me.bar_code,u.name unitName, mc.name categoryName
  587. FROM jsh_material m
  588. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  589. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_flag,'0') !='1'
  590. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  591. where 1=1
  592. <if test="meId != null">
  593. and me.id = #{meId}
  594. </if>
  595. and ifnull(m.delete_flag,'0') !='1'
  596. </select>
  597. <select id="getMaterialNameList" resultType="java.lang.String">
  598. select m.name from jsh_material m
  599. where m.name is not null and m.name !='' and ifnull(m.delete_flag,'0') !='1'
  600. group by m.name
  601. order by m.name asc
  602. </select>
  603. <select id="getMaterialByBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
  604. select m.*,u.name unit_name, me.id meId,me.bar_code m_bar_code, me.commodity_unit,
  605. me.sku, me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.depot_id,me.ratio
  606. from jsh_material m
  607. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  608. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  609. where
  610. me.sku in (
  611. <foreach collection="barCodeArray" item="barCode" separator=",">
  612. #{barCode}
  613. </foreach>
  614. )
  615. and ifnull(m.delete_flag,'0') !='1'
  616. order by m.id desc, me.default_flag desc, me.id asc
  617. </select>
  618. <select id="getMaterialBySku" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  619. select
  620. m.id, m.name, m.expiry_num, m.default_purchase_decimal, m.default_wholesale_decimal,
  621. me.id meId, me.sku, me.commodity_unit, me.standard
  622. from jsh_material m
  623. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  624. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  625. where
  626. me.sku in (
  627. <foreach collection="skuArray" item="sku" separator=",">
  628. #{sku}
  629. </foreach>
  630. )
  631. and ifnull(m.delete_flag,'0') !='1'
  632. order by m.id desc, me.default_flag desc, me.id asc
  633. </select>
  634. <select id="getMaterialByBarCodeAndWithOutMId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
  635. select m.*,u.name unit_name, me.id meId,me.bar_code m_bar_code, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,
  636. me.wholesale_decimal, me.low_decimal, me.sku
  637. from jsh_material m
  638. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  639. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  640. where
  641. me.bar_code in (
  642. <foreach collection="barCodeArray" item="barCode" separator=",">
  643. #{barCode}
  644. </foreach>
  645. )
  646. and me.material_id!=#{mId}
  647. and ifnull(m.delete_flag,'0') !='1'
  648. order by me.id desc
  649. </select>
  650. <update id="setUnitIdToNull">
  651. update jsh_material
  652. set unit_id = null
  653. where 1=1
  654. and ifnull(delete_flag,'0') !='1'
  655. and id = #{id}
  656. </update>
  657. <update id="setExpiryNumToNull">
  658. update jsh_material
  659. set expiry_num = null
  660. where 1=1
  661. and ifnull(delete_flag,'0') !='1'
  662. and id = #{id}
  663. </update>
  664. <select id="getInitialStockWithMaterial" resultMap="InitialStockWithMaterialMap">
  665. select material_id, ifnull(sum(mis.number),0) number
  666. from jsh_material_initial_stock mis
  667. where 1=1
  668. <if test="depotList.size()>0">
  669. and mis.depot_id in
  670. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  671. #{item}
  672. </foreach>
  673. </if>
  674. group by mis.material_id
  675. </select>
  676. <select id="getListWithStock" resultMap="ResultMapListWithStock">
  677. select m.id, m.name, m.standard, m.model, m.color,
  678. me.commodity_unit unitName, mc.name categoryName, me.bar_code mBarCode,
  679. ifnull(me.purchase_decimal,0) purchaseDecimal,
  680. ifnull(mcs.current_unit_price,0) currentUnitPrice,
  681. ifnull(sum(mcs.current_number),0) currentStock,
  682. sum(ifnull(me.purchase_decimal, 0) * ifnull(mcs.current_number, 0)) currentStockPrice,
  683. sum(ifnull(mcs.current_unit_price, 0) * ifnull(mcs.current_number, 0)) currentStockMovePrice,
  684. sum(ifnull(m.weight, 0) * ifnull(mcs.current_number, 0)) currentWeight
  685. FROM jsh_material m
  686. left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  687. left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
  688. <if test="depotList.size()>0">
  689. and mcs.depot_id in
  690. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  691. #{item}
  692. </foreach>
  693. </if>
  694. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  695. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  696. where 1=1
  697. and me.default_flag=1
  698. <if test="idList.size()>0">
  699. and m.category_id in
  700. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  701. #{item}
  702. </foreach>
  703. </if>
  704. <if test="position != null and position !=''">
  705. <bind name="bindPosition" value="'%'+position+'%'"/>
  706. and m.position like #{bindPosition}
  707. </if>
  708. <if test="materialParam != null">
  709. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  710. 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}
  711. or m.color like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
  712. or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
  713. </if>
  714. and ifnull(m.delete_flag,'0') !='1'
  715. group by m.id, m.name, m.standard, m.model, m.color, m.brand,
  716. me.commodity_unit, mc.name, me.bar_code, me.purchase_decimal, mcs.current_unit_price
  717. <if test="zeroStock == 0">
  718. having ifnull(sum(mcs.current_number),0)!=0
  719. </if>
  720. <if test="column == 'createTime'">
  721. order by m.id desc
  722. </if>
  723. <if test="column != 'createTime'">
  724. order by ${column} ${order}
  725. </if>
  726. <if test="offset != null and rows != null">
  727. limit #{offset},#{rows}
  728. </if>
  729. </select>
  730. <select id="getListWithStockCount" resultType="java.lang.Integer">
  731. select count(tb.id) from
  732. (select m.id, ifnull(sum(mcs.current_number),0) currentStock from jsh_material m
  733. left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  734. left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
  735. <if test="depotList.size()>0">
  736. and mcs.depot_id in
  737. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  738. #{item}
  739. </foreach>
  740. </if>
  741. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  742. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  743. where 1=1
  744. and me.default_flag=1
  745. <if test="idList.size()>0">
  746. and m.category_id in
  747. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  748. #{item}
  749. </foreach>
  750. </if>
  751. <if test="position != null and position !=''">
  752. <bind name="bindPosition" value="'%'+position+'%'"/>
  753. and m.position like #{bindPosition}
  754. </if>
  755. <if test="materialParam != null">
  756. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  757. 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}
  758. or m.color like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
  759. or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
  760. </if>
  761. and ifnull(m.delete_flag,'0') !='1'
  762. group by m.id
  763. <if test="zeroStock == 0">
  764. having ifnull(sum(mcs.current_number),0)!=0
  765. </if>
  766. ) tb
  767. </select>
  768. <select id="getTotalStockAndPrice" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  769. select
  770. ifnull(sum(mcs.current_number),0) currentStock,
  771. sum(ifnull(me.purchase_decimal,0)*ifnull(mcs.current_number,0)) currentStockPrice,
  772. sum(ifnull(mcs.current_unit_price,0)*ifnull(mcs.current_number,0)) currentStockMovePrice,
  773. sum(ifnull(m.weight,0)*ifnull(mcs.current_number,0)) currentWeight
  774. from jsh_material m
  775. left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
  776. left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
  777. left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
  778. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  779. where 1=1
  780. and me.default_flag=1
  781. <if test="depotList.size()>0">
  782. and mcs.depot_id in
  783. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  784. #{item}
  785. </foreach>
  786. </if>
  787. <if test="idList.size()>0">
  788. and m.category_id in
  789. <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
  790. #{item}
  791. </foreach>
  792. </if>
  793. <if test="position != null and position !=''">
  794. <bind name="bindPosition" value="'%'+position+'%'"/>
  795. and m.position like #{bindPosition}
  796. </if>
  797. <if test="materialParam != null">
  798. <bind name="bindKey" value="'%'+materialParam+'%'"/>
  799. 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}
  800. or m.color like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
  801. or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
  802. </if>
  803. and ifnull(m.delete_flag,'0') !='1'
  804. </select>
  805. <select id="checkIsExist" resultType="java.lang.Integer">
  806. select count(1) from jsh_material m
  807. where ifnull(m.delete_flag,'0') !='1'
  808. <if test="name != null">
  809. and m.name = #{name}
  810. </if>
  811. <if test="model != null">
  812. and m.model = #{model}
  813. </if>
  814. <if test="color != null">
  815. and m.color = #{color}
  816. </if>
  817. <if test="standard != null">
  818. and m.standard = #{standard}
  819. </if>
  820. <if test="otherField1 != null">
  821. and m.other_field1 = #{otherField1}
  822. </if>
  823. <if test="otherField2 != null">
  824. and m.other_field2 = #{otherField2}
  825. </if>
  826. <if test="otherField3 != null">
  827. and m.other_field3 = #{otherField3}
  828. </if>
  829. <if test="unit != null">
  830. and m.unit = #{unit}
  831. </if>
  832. <if test="unitId != null">
  833. and m.unit_id = #{unitId}
  834. </if>
  835. <if test="id != null">
  836. and m.id != #{id}
  837. </if>
  838. </select>
  839. <select id="getMaterialExtendBySerialNumber" resultType="com.jsh.erp.datasource.entities.MaterialExtend">
  840. select me.bar_code
  841. from jsh_material m
  842. left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_flag,'0') !='1'
  843. left join jsh_serial_number sn on sn.material_id=m.id and ifnull(sn.delete_flag,'0') !='1'
  844. where sn.serial_number = #{serialNumber}
  845. and me.default_flag=1
  846. and ifnull(m.delete_flag,'0') !='1'
  847. limit 0,1
  848. </select>
  849. <select id="getMaterialBySystemSku" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  850. WITH RankedExtend AS (
  851. SELECT
  852. me.*,
  853. ROW_NUMBER() OVER (PARTITION BY me.material_id ORDER BY me.batch_number DESC) AS rn
  854. FROM jsh_material_extend me
  855. LEFT JOIN jsh_material m ON m.id = me.material_id
  856. WHERE ifnull(me.delete_Flag, '0') != '1'
  857. AND m.system_sku IN (
  858. <foreach collection="systemSkuArray" item="systemSku" separator=",">
  859. #{systemSku}
  860. </foreach>
  861. )
  862. )
  863. SELECT
  864. m.*,
  865. re.id AS meId,
  866. re.bar_code AS m_bar_code,
  867. re.commodity_unit,
  868. re.purchase_decimal,
  869. re.commodity_decimal,
  870. re.wholesale_decimal,
  871. re.low_decimal,
  872. me.sku,
  873. me.production_date,
  874. me.expiry_num,
  875. me.supplier_id,
  876. me.bar_code,
  877. me.batch_number,
  878. me.inventory,
  879. me.depot_id,
  880. me.POSITION
  881. FROM jsh_material m
  882. LEFT JOIN RankedExtend re ON m.id = re.material_id AND re.rn = 1
  883. LEFT JOIN jsh_material_extend me ON re.bar_code = me.bar_code
  884. WHERE ifnull(m.delete_flag, '0') != '1' AND re.id IS NOT NULL
  885. ORDER BY m.id DESC, me.default_flag DESC, me.production_date,me.batch_number ASC
  886. </select>
  887. <select id="getMaterialCurrentPriceByIdList" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku">
  888. WITH RankedExtend AS (
  889. SELECT
  890. me.*,
  891. ROW_NUMBER() OVER (PARTITION BY me.material_id ORDER BY me.batch_number DESC) AS rn
  892. FROM jsh_material_extend me
  893. LEFT JOIN jsh_material m ON m.id = me.material_id
  894. WHERE ifnull(me.delete_Flag, '0') != '1'
  895. AND m.id IN (
  896. <foreach collection="idList" item="systemSku" separator=",">
  897. #{systemSku}
  898. </foreach>
  899. )
  900. )
  901. SELECT
  902. m.id AS mId,
  903. m.name AS mName,
  904. m.unit AS unit,
  905. m.unit_id AS unitId,
  906. m.system_sku AS systemSku,
  907. re.wholesale_decimal AS basicUnitSalePrice
  908. FROM jsh_material m
  909. LEFT JOIN RankedExtend re ON m.id = re.material_id AND re.rn = 1
  910. WHERE ifnull(m.delete_flag, '0') != '1' AND re.id IS NOT NULL
  911. ORDER BY m.id DESC
  912. </select>
  913. </mapper>