diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java index 9af6d05c..e2e3bf91 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java @@ -592,7 +592,7 @@ public class MaterialController { * 商品库存查询 * @param currentPage * @param pageSize - * @param depotId + * @param depotIds * @param categoryId * @param materialParam * @param mpList @@ -606,7 +606,7 @@ public class MaterialController { @ApiOperation(value = "商品库存查询") public BaseResponseInfo getListWithStock(@RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize, - @RequestParam(value = "depotId", required = false) Long depotId, + @RequestParam(value = "depotIds", required = false) String depotIds, @RequestParam(value = "categoryId", required = false) Long categoryId, @RequestParam("materialParam") String materialParam, @RequestParam("zeroStock") Integer zeroStock, @@ -618,13 +618,24 @@ public class MaterialController { Map map = new HashMap<>(); try { List idList = new ArrayList<>(); + List depotList = new ArrayList<>(); if(categoryId != null){ idList = materialService.getListByParentId(categoryId); } - List dataList = materialService.getListWithStock(depotId, idList, StringUtil.toNull(materialParam), zeroStock, + if(StringUtil.isNotEmpty(depotIds)) { + depotList = StringUtil.strToLongList(depotIds); + } else { + //未选择仓库时默认为当前用户有权限的仓库 + JSONArray depotArr = depotService.findDepotByCurrentUser(); + for(Object obj: depotArr) { + JSONObject object = JSONObject.parseObject(obj.toString()); + depotList.add(object.getLong("id")); + } + } + List dataList = materialService.getListWithStock(depotList, idList, StringUtil.toNull(materialParam), zeroStock, StringUtil.safeSqlParse(column), StringUtil.safeSqlParse(order), (currentPage-1)*pageSize, pageSize); - int total = materialService.getListWithStockCount(depotId, idList, StringUtil.toNull(materialParam), zeroStock); - MaterialVo4Unit materialVo4Unit= materialService.getTotalStockAndPrice(depotId, idList, StringUtil.toNull(materialParam)); + int total = materialService.getListWithStockCount(depotList, idList, StringUtil.toNull(materialParam), zeroStock); + MaterialVo4Unit materialVo4Unit= materialService.getTotalStockAndPrice(depotList, idList, StringUtil.toNull(materialParam)); map.put("total", total); map.put("currentStock", materialVo4Unit.getCurrentStock()); map.put("currentStockPrice", materialVo4Unit.getCurrentStockPrice()); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java index 3ae6f746..711af239 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java @@ -89,7 +89,7 @@ public interface MaterialMapperEx { List getMaterialByBarCode(@Param("barCodeArray") String [] barCodeArray); List getListWithStock( - @Param("depotId") Long depotId, + @Param("depotList") List depotList, @Param("idList") List idList, @Param("materialParam") String materialParam, @Param("zeroStock") Integer zeroStock, @@ -99,13 +99,13 @@ public interface MaterialMapperEx { @Param("rows") Integer rows); int getListWithStockCount( - @Param("depotId") Long depotId, + @Param("depotList") List depotList, @Param("idList") List idList, @Param("materialParam") String materialParam, @Param("zeroStock") Integer zeroStock); MaterialVo4Unit getTotalStockAndPrice( - @Param("depotId") Long depotId, + @Param("depotList") List depotList, @Param("idList") List idList, @Param("materialParam") String materialParam); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java index 9c532349..b5dac5d2 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java @@ -872,17 +872,17 @@ public class MaterialService { return materialMapperEx.getMaterialByBarCode(barCodeArray); } - public List getListWithStock(Long depotId, List idList, String materialParam, Integer zeroStock, + public List getListWithStock(List depotList, List idList, String materialParam, Integer zeroStock, String column, String order, Integer offset, Integer rows) { - return materialMapperEx.getListWithStock(depotId, idList, materialParam, zeroStock, column, order, offset, rows); + return materialMapperEx.getListWithStock(depotList, idList, materialParam, zeroStock, column, order, offset, rows); } - public int getListWithStockCount(Long depotId, List idList, String materialParam, Integer zeroStock) { - return materialMapperEx.getListWithStockCount(depotId, idList, materialParam, zeroStock); + public int getListWithStockCount(List depotList, List idList, String materialParam, Integer zeroStock) { + return materialMapperEx.getListWithStockCount(depotList, idList, materialParam, zeroStock); } - public MaterialVo4Unit getTotalStockAndPrice(Long depotId, List idList, String materialParam) { - return materialMapperEx.getTotalStockAndPrice(depotId, idList, materialParam); + public MaterialVo4Unit getTotalStockAndPrice(List depotList, List idList, String materialParam) { + return materialMapperEx.getTotalStockAndPrice(depotList, idList, materialParam); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) diff --git a/jshERP-boot/src/main/resources/mapper_xml/MaterialMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/MaterialMapperEx.xml index 0f5f0bd6..de41cab7 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/MaterialMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/MaterialMapperEx.xml @@ -339,8 +339,11 @@ select m.*, me.commodity_unit unitName, mc.name categoryName, me.bar_code, ifnull(me.purchase_decimal,0) purchase_decimal, (select ifnull(sum(mis.number),0) from jsh_material_initial_stock mis where mis.material_id = m.id - - and mis.depot_id = #{depotId} + + and mis.depot_id in + + #{item} + ) initialStock, ifnull(sum(mcs.current_number),0) currentStock, @@ -352,8 +355,11 @@ left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1' where 1=1 and me.default_flag=1 - - and mcs.depot_id = #{depotId} + + and mcs.depot_id in + + #{item} + and m.category_id in @@ -390,8 +396,11 @@ left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1' where 1=1 and me.default_flag=1 - - and mcs.depot_id = #{depotId} + + and mcs.depot_id in + + #{item} + and m.category_id in @@ -422,8 +431,11 @@ left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1' where 1=1 and me.default_flag=1 - - and mcs.depot_id = #{depotId} + + and mcs.depot_id in + + #{item} + and m.category_id in