|
@@ -1009,6 +1009,35 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取excel仓库库位信息
|
|
|
+ * @param src 行数据
|
|
|
+ * @param depotCount 仓库数量
|
|
|
+ * @param depotMap 仓库集合
|
|
|
+ * @param i
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private Map<Long, String> getExcelDepot(Sheet src, int depotCount, Map<String, Long> depotMap, int i) throws Exception {
|
|
|
+ Map<Long, String> stockMap = new HashMap<>();
|
|
|
+ for(int j = 1; j<= depotCount; j++) {
|
|
|
+ int col = 16 + j;
|
|
|
+ if(col < src.getColumns()){
|
|
|
+ String depotName = ExcelUtils.getContent(src, 1, col); //获取仓库名称
|
|
|
+ if(StringUtil.isNotEmpty(depotName)) {
|
|
|
+ Long depotId = depotMap.get(depotName);
|
|
|
+ if(depotId!=null && depotId!=0L){
|
|
|
+ String stockStr = ExcelUtils.getContent(src, i, col);
|
|
|
+ if(StringUtil.isNotEmpty(stockStr)) {
|
|
|
+ stockMap.put(depotId, stockStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return stockMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位
|
|
|
* @param mList
|
|
|
*/
|
|
@@ -1871,7 +1900,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
}
|
|
|
m.setMaterialExObj(materialExObj);
|
|
|
//设置仓库库位
|
|
|
- m.setStockMap(getStockMapCache(src, depotCount, depotMap, i));
|
|
|
+ m.setDepotMap(getExcelDepot(src, depotCount, depotMap, i));
|
|
|
mList.add(m);
|
|
|
}
|
|
|
//处理表单信息,转为对象集合
|
|
@@ -1879,6 +1908,21 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
for (Material material : materialList) {
|
|
|
//添加商品信息
|
|
|
materialMapperEx.insertSelectiveEx(material);
|
|
|
+ //获取excel商品添加库存
|
|
|
+ Map<Long, String> stockMap = material.getDepotMap();
|
|
|
+ for(Depot depot: depotList){
|
|
|
+ Long depotId = depot.getId();
|
|
|
+ //excel里面的当前库位
|
|
|
+ String position = stockMap.get(depot.getId());
|
|
|
+ //新增或更新初始库存
|
|
|
+ if(StringUtil.isNotEmpty(position)) {
|
|
|
+ MaterialInitialStock materialInitialStock = new MaterialInitialStock();
|
|
|
+ materialInitialStock.setDepotId(depotId);
|
|
|
+ materialInitialStock.setMaterialId(material.getId());
|
|
|
+ materialInitialStock.setPosition(position);
|
|
|
+ materialInitialStockMapper.insertSelective(materialInitialStock);
|
|
|
+ }
|
|
|
+ }
|
|
|
//添加商品子信息
|
|
|
for (MaterialExtend materialExtend : material.getList()) {
|
|
|
//设置商品id
|
|
@@ -2033,6 +2077,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
material.setSystemSku(m.getSystemSku());
|
|
|
List<MaterialExtend> list = new ArrayList<>();
|
|
|
material.setList(list);
|
|
|
+ material.setDepotMap(m.getDepotMap());
|
|
|
materialMap.put(str,material);
|
|
|
}
|
|
|
//添加子表信息
|