增加修复库存的接口

This commit is contained in:
季圣华
2021-10-24 22:03:03 +08:00
parent 4b23754c4f
commit 0e5374e1d4
4 changed files with 53 additions and 9 deletions

View File

@@ -547,6 +547,7 @@ public class MaterialController {
@RequestParam("depotId") Long depotId,
@RequestParam("categoryId") Long categoryId,
@RequestParam("materialParam") String materialParam,
@RequestParam("zeroStock") Integer zeroStock,
@RequestParam("mpList") String mpList,
@RequestParam("column") String column,
@RequestParam("order") String order,
@@ -558,9 +559,9 @@ public class MaterialController {
if(categoryId != null){
idList = materialService.getListByParentId(categoryId);
}
List<MaterialVo4Unit> dataList = materialService.getListWithStock(depotId, idList, StringUtil.toNull(materialParam),
List<MaterialVo4Unit> dataList = materialService.getListWithStock(depotId, idList, StringUtil.toNull(materialParam), zeroStock,
StringUtil.safeSqlParse(column), StringUtil.safeSqlParse(order), (currentPage-1)*pageSize, pageSize);
int total = materialService.getListWithStockCount(depotId, idList, StringUtil.toNull(materialParam));
int total = materialService.getListWithStockCount(depotId, idList, StringUtil.toNull(materialParam), zeroStock);
MaterialVo4Unit materialVo4Unit= materialService.getTotalStockAndPrice(depotId, idList, StringUtil.toNull(materialParam));
map.put("total", total);
map.put("currentStock", materialVo4Unit.getCurrentStock());
@@ -576,4 +577,24 @@ public class MaterialController {
}
return res;
}
/**
* 批量设置商品当前的实时库存(按每个仓库)
* @param jsonObject
* @param request
* @return
* @throws Exception
*/
@PostMapping(value = "/batchSetMaterialCurrentStock")
public String batchSetMaterialCurrentStock(@RequestBody JSONObject jsonObject,
HttpServletRequest request)throws Exception {
String ids = jsonObject.getString("ids");
Map<String, Object> objectMap = new HashMap<>();
int res = materialService.batchSetMaterialCurrentStock(ids);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
}

View File

@@ -92,6 +92,7 @@ public interface MaterialMapperEx {
@Param("depotId") Long depotId,
@Param("idList") List<Long> idList,
@Param("materialParam") String materialParam,
@Param("zeroStock") Integer zeroStock,
@Param("column") String column,
@Param("order") String order,
@Param("offset") Integer offset,
@@ -100,7 +101,8 @@ public interface MaterialMapperEx {
int getListWithStockCount(
@Param("depotId") Long depotId,
@Param("idList") List<Long> idList,
@Param("materialParam") String materialParam);
@Param("materialParam") String materialParam,
@Param("zeroStock") Integer zeroStock);
MaterialVo4Unit getTotalStockAndPrice(
@Param("depotId") Long depotId,

View File

@@ -818,16 +818,30 @@ public class MaterialService {
return materialMapperEx.getMaterialByBarCode(barCodeArray);
}
public List<MaterialVo4Unit> getListWithStock(Long depotId, List<Long> idList, String materialParam,
public List<MaterialVo4Unit> getListWithStock(Long depotId, List<Long> idList, String materialParam, Integer zeroStock,
String column, String order, Integer offset, Integer rows) {
return materialMapperEx.getListWithStock(depotId, idList, materialParam, column, order, offset, rows);
return materialMapperEx.getListWithStock(depotId, idList, materialParam, zeroStock, column, order, offset, rows);
}
public int getListWithStockCount(Long depotId, List<Long> idList, String materialParam) {
return materialMapperEx.getListWithStockCount(depotId, idList, materialParam);
public int getListWithStockCount(Long depotId, List<Long> idList, String materialParam, Integer zeroStock) {
return materialMapperEx.getListWithStockCount(depotId, idList, materialParam, zeroStock);
}
public MaterialVo4Unit getTotalStockAndPrice(Long depotId, List<Long> idList, String materialParam) {
return materialMapperEx.getTotalStockAndPrice(depotId, idList, materialParam);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetMaterialCurrentStock(String ids) throws Exception {
int res = 0;
List<Long> idList = StringUtil.strToLongList(ids);
List<Depot> depotList = depotService.getAllList();
for(Long mId: idList) {
for(Depot depot: depotList) {
depotItemService.updateCurrentStockFun(mId, depot.getId());
res = 1;
}
}
return res;
}
}