|
@@ -981,10 +981,10 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
|
|
|
/**
|
|
/**
|
|
* 缓存各个仓库的库存信息
|
|
* 缓存各个仓库的库存信息
|
|
- * @param src
|
|
|
|
|
|
+ * @param src 行数据
|
|
* @param depotCount
|
|
* @param depotCount
|
|
* @param depotMap
|
|
* @param depotMap
|
|
- * @param i
|
|
|
|
|
|
+ * @param i 行数
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@@ -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中有无重复商品,是指名称、规格、型号、颜色、单位
|
|
* 批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位
|
|
* @param mList
|
|
* @param mList
|
|
*/
|
|
*/
|
|
@@ -1058,8 +1087,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//EXCEL中有条码在系统中已存在
|
|
//EXCEL中有条码在系统中已存在
|
|
- int count = materialExtendService.getCountByManyBarCodeWithoutUs(barCode, barCode);
|
|
|
|
- if (count>0) {
|
|
|
|
|
|
+ MaterialExtend materialExtend = materialExtendService.getInfoByBarCode(barCode);
|
|
|
|
+ if (materialExtend != null && !materialExtend.getBarCode().isEmpty()) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_SYSTEM_EXIST_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_SYSTEM_EXIST_CODE,
|
|
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_SYSTEM_EXIST_MSG, barCode));
|
|
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_SYSTEM_EXIST_MSG, barCode));
|
|
}
|
|
}
|
|
@@ -1746,8 +1775,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
String otherField2 = ExcelUtils.getContent(src, i, 14); //自定义2
|
|
String otherField2 = ExcelUtils.getContent(src, i, 14); //自定义2
|
|
String otherField3 = ExcelUtils.getContent(src, i, 15); //自定义3
|
|
String otherField3 = ExcelUtils.getContent(src, i, 15); //自定义3
|
|
String remark = ExcelUtils.getContent(src, i, 16); //备注
|
|
String remark = ExcelUtils.getContent(src, i, 16); //备注
|
|
- String depotName = ExcelUtils.getContent(src, i, 17); //仓库名称
|
|
|
|
- String position = ExcelUtils.getContent(src, i, 18); //仓位货架
|
|
|
|
//校验字段
|
|
//校验字段
|
|
//名称为空
|
|
//名称为空
|
|
if(StringUtil.isEmpty(name)) {
|
|
if(StringUtil.isEmpty(name)) {
|
|
@@ -1810,16 +1837,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
}
|
|
}
|
|
//批量校验excel中有无重复条码(1-文档自身校验,2-和数据库里面的商品校验)
|
|
//批量校验excel中有无重复条码(1-文档自身校验,2-和数据库里面的商品校验)
|
|
batchCheckExistBarCodeByParam(mList, barCode, null);
|
|
batchCheckExistBarCodeByParam(mList, barCode, null);
|
|
- Long depotId = null;
|
|
|
|
- if(StringUtil.isNotEmpty(depotName)) {
|
|
|
|
- //根据仓库名查询仓库id
|
|
|
|
- depotId = depotMapperEx.selectByConditionDepot(depotName,null,null).get(0).getId();
|
|
|
|
- if (depotId == null){
|
|
|
|
- //仓库不存在
|
|
|
|
- throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_CODE,
|
|
|
|
- String.format(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_MSG, i+1));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// Long depotId = null;
|
|
|
|
+// if(StringUtil.isNotEmpty(depotName)) {
|
|
|
|
+// //根据仓库名查询仓库id
|
|
|
|
+// depotId = depotMapperEx.selectByConditionDepot(depotName,null,null).get(0).getId();
|
|
|
|
+// if (depotId == null){
|
|
|
|
+// //仓库不存在
|
|
|
|
+// throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_CODE,
|
|
|
|
+// String.format(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_MSG, i+1));
|
|
|
|
+// }
|
|
|
|
+// }
|
|
MaterialWithInitStock m = new MaterialWithInitStock();
|
|
MaterialWithInitStock m = new MaterialWithInitStock();
|
|
//设置商品名字、规格、型号、颜色、品牌、类型id
|
|
//设置商品名字、规格、型号、颜色、品牌、类型id
|
|
m.setName(name);
|
|
m.setName(name);
|
|
@@ -1854,18 +1881,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
JSONObject materialExObj = new JSONObject();
|
|
JSONObject materialExObj = new JSONObject();
|
|
JSONObject basicObj = new JSONObject();
|
|
JSONObject basicObj = new JSONObject();
|
|
basicObj.put("commodityUnit", manyUnit.isEmpty() ? unit : manyUnit); //商品单位
|
|
basicObj.put("commodityUnit", manyUnit.isEmpty() ? unit : manyUnit); //商品单位
|
|
- //basicObj.put("sku", sku); //商品属性
|
|
|
|
-// basicObj.put("purchaseDecimal", purchaseDecimal); //采购价格
|
|
|
|
-// basicObj.put("commodityDecimal", commodityDecimal); //零售价格
|
|
|
|
-// basicObj.put("wholesaleDecimal", wholesaleDecimal); //销售价格
|
|
|
|
-// basicObj.put("lowDecimal", lowDecimal); //最低售价
|
|
|
|
-// basicObj.put("productionDate",productionDate); //生产日期
|
|
|
|
-// basicObj.put("expiryNum",expiryNum); //保质期天数
|
|
|
|
-// basicObj.put("supplierId",supplierId); //供应商id
|
|
|
|
basicObj.put("barCode", barCode); //商品条码
|
|
basicObj.put("barCode", barCode); //商品条码
|
|
-// basicObj.put("inventory",inventory); //库存
|
|
|
|
- basicObj.put("depotId",depotId); //仓库id
|
|
|
|
- basicObj.put("position",position); //仓位货架
|
|
|
|
materialExObj.put("basic", basicObj);
|
|
materialExObj.put("basic", basicObj);
|
|
if(StringUtil.isNotEmpty(manyUnit) && StringUtil.isNotEmpty(ratio)){ //多单位
|
|
if(StringUtil.isNotEmpty(manyUnit) && StringUtil.isNotEmpty(ratio)){ //多单位
|
|
//校验比例是否是数字(含小数)
|
|
//校验比例是否是数字(含小数)
|
|
@@ -1878,20 +1894,13 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
m.setUnitId(unitId);
|
|
m.setUnitId(unitId);
|
|
m.setUnit("");
|
|
m.setUnit("");
|
|
}
|
|
}
|
|
-// JSONObject otherObj = new JSONObject();
|
|
|
|
-// otherObj.put("commodityUnit", manyUnit);
|
|
|
|
-// otherObj.put("purchaseDecimal", parsePrice(purchaseDecimal,ratio));
|
|
|
|
-// otherObj.put("commodityDecimal", parsePrice(commodityDecimal,ratio));
|
|
|
|
-// otherObj.put("wholesaleDecimal", parsePrice(wholesaleDecimal,ratio));
|
|
|
|
-// otherObj.put("lowDecimal", parsePrice(lowDecimal,ratio));
|
|
|
|
-// materialExObj.put("other", otherObj);
|
|
|
|
} else {
|
|
} else {
|
|
m.setUnit(unit);
|
|
m.setUnit(unit);
|
|
m.setUnitId(null);
|
|
m.setUnitId(null);
|
|
}
|
|
}
|
|
m.setMaterialExObj(materialExObj);
|
|
m.setMaterialExObj(materialExObj);
|
|
- //设置库存
|
|
|
|
- m.setStockMap(getStockMapCache(src, depotCount, depotMap, i));
|
|
|
|
|
|
+ //设置仓库库位
|
|
|
|
+ m.setDepotMap(getExcelDepot(src, depotCount, depotMap, i));
|
|
mList.add(m);
|
|
mList.add(m);
|
|
}
|
|
}
|
|
//处理表单信息,转为对象集合
|
|
//处理表单信息,转为对象集合
|
|
@@ -1899,6 +1908,21 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
for (Material material : materialList) {
|
|
for (Material material : materialList) {
|
|
//添加商品信息
|
|
//添加商品信息
|
|
materialMapperEx.insertSelectiveEx(material);
|
|
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()) {
|
|
for (MaterialExtend materialExtend : material.getList()) {
|
|
//设置商品id
|
|
//设置商品id
|
|
@@ -2053,6 +2077,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
material.setSystemSku(m.getSystemSku());
|
|
material.setSystemSku(m.getSystemSku());
|
|
List<MaterialExtend> list = new ArrayList<>();
|
|
List<MaterialExtend> list = new ArrayList<>();
|
|
material.setList(list);
|
|
material.setList(list);
|
|
|
|
+ material.setDepotMap(m.getDepotMap());
|
|
materialMap.put(str,material);
|
|
materialMap.put(str,material);
|
|
}
|
|
}
|
|
//添加子表信息
|
|
//添加子表信息
|