|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jsh.erp.constants.BusinessConstants;
|
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
|
+import com.jsh.erp.datasource.dto.MaterialDto;
|
|
|
import com.jsh.erp.datasource.entities.*;
|
|
|
import com.jsh.erp.datasource.mappers.*;
|
|
|
import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
|
|
@@ -15,7 +16,7 @@ import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
|
|
|
import com.jsh.erp.datasource.pda.vo.PDATypeTree;
|
|
|
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
|
|
import com.jsh.erp.datasource.vo.MaterialWarnListVo;
|
|
|
-import com.jsh.erp.datasource.vo.TreeNode;
|
|
|
+import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
|
|
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
|
|
import com.jsh.erp.exception.JshException;
|
|
|
import com.jsh.erp.query.LambdaQueryWrapperX;
|
|
@@ -87,6 +88,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
private SupplierService supplierService;
|
|
|
@Resource
|
|
|
private DepotMapperEx depotMapperEx;
|
|
|
+ @Resource
|
|
|
+ private MaterialBatchService materialBatchService;
|
|
|
|
|
|
@Value(value="${file.uploadType}")
|
|
|
private Long fileUploadType;
|
|
@@ -130,9 +133,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 查询商品管理-商品信息列表查询
|
|
|
- */
|
|
|
+
|
|
|
@Override
|
|
|
public List<MaterialVo4Unit> select(String materialParam, String standard, String model, String color, String brand, String mfrs,
|
|
|
String materialOther, String weight, String expiryNum, String enableSerialNumber,
|
|
@@ -178,48 +179,52 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
|
- public int insertMaterial(JSONObject obj, HttpServletRequest request)throws Exception {
|
|
|
+ public int insertMaterial(MaterialDto obj, HttpServletRequest request)throws Exception {
|
|
|
//商品主表信息
|
|
|
- Material m = JSONObject.parseObject(obj.toJSONString(), Material.class);
|
|
|
+ Material m = obj;
|
|
|
+ //设置状态
|
|
|
m.setEnabled(true);
|
|
|
//获取类型编码
|
|
|
Long serial_no = materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
|
- String sku = serial_no + DateUtils.dateTimeNow();
|
|
|
+ String sku = serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6);
|
|
|
//设置系统sku
|
|
|
m.setSystemSku(sku);
|
|
|
User user = userService.getCurrentUser();
|
|
|
- m.setTenantId(user.getId());
|
|
|
try{
|
|
|
//添加商品
|
|
|
materialMapperEx.insertSelectiveEx(m);
|
|
|
Long mId = m.getId();
|
|
|
- //添加商品拓展记录
|
|
|
- materialExtendService.saveDetials(obj, obj.getString("sortList"), mId, "insert");
|
|
|
+ //添加商品条码信息
|
|
|
+ materialExtendService.saveDetails(obj.getMbList(),obj.getSortList().toJSONString(),mId,"insert");
|
|
|
+ //materialExtendService.saveDetials(null, obj.getSortList(), mId, "insert");
|
|
|
//设置初始库存
|
|
|
- if(obj.get("stock")!=null) {
|
|
|
- JSONArray stockArr = obj.getJSONArray("stock");
|
|
|
+ if(obj.getStock()!=null) {
|
|
|
+ List<MaterialInitialStock> stockArr = obj.getStock();
|
|
|
for (int i = 0; i < stockArr.size(); i++) {
|
|
|
- JSONObject jsonObj = stockArr.getJSONObject(i);
|
|
|
- //最低安全库存数量不为空
|
|
|
- if(jsonObj.get("id")!=null && jsonObj.get("lowSafeStock")!=null) {
|
|
|
- BigDecimal lowSafeStock = jsonObj.getBigDecimal("lowSafeStock");
|
|
|
+ MaterialInitialStock jsonObj = stockArr.get(i);
|
|
|
+ //此时id为仓库id,仓库di、最低安全库存数量不为空
|
|
|
+ if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null) {
|
|
|
+ BigDecimal lowSafeStock = jsonObj.getLowSafeStock();
|
|
|
BigDecimal highSafeStock = null;
|
|
|
- if(jsonObj.get("highSafeStock")!=null) {
|
|
|
- highSafeStock = jsonObj.getBigDecimal("highSafeStock");
|
|
|
+ if(jsonObj.getHighSafeStock() != null) {
|
|
|
+ highSafeStock = jsonObj.getHighSafeStock();
|
|
|
}
|
|
|
- Long depotId = jsonObj.getLong("id");
|
|
|
- if(lowSafeStock!=null || highSafeStock!=null) {
|
|
|
+ Long depotId = jsonObj.getId();
|
|
|
+ jsonObj.setDepotId(depotId);
|
|
|
+ jsonObj.setMaterialId(mId);
|
|
|
+ jsonObj.setId(null);
|
|
|
+ if(lowSafeStock != null || highSafeStock != null || jsonObj.getPosition() != null) {
|
|
|
//设置初始库
|
|
|
- insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx("0"), lowSafeStock, highSafeStock);
|
|
|
+ materialInitialStockMapper.insertSelective(jsonObj);
|
|
|
+ //insertInitialStockByMaterialAndDepot(jsonObj);
|
|
|
//设置当前库
|
|
|
//insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
|
|
//更新当前库存
|
|
|
- depotItemService.updateCurrentStockFun(mId, depotId);
|
|
|
+ //depotItemService.updateCurrentStockFun(mId, depotId);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
logService.insertLog("商品",
|
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
|
|
|
return 1;
|
|
@@ -240,50 +245,50 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
|
- public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
|
|
|
- Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
|
|
|
+ public int updateMaterial(MaterialDto obj, HttpServletRequest request) throws Exception{
|
|
|
+ Material material = obj;
|
|
|
try{
|
|
|
//修改商品属性
|
|
|
materialMapper.updateByPrimaryKeySelective(material);
|
|
|
- //
|
|
|
if(material.getUnitId() == null) {
|
|
|
materialMapperEx.setUnitIdToNull(material.getId());
|
|
|
}
|
|
|
-// if(material.getExpiryNum() == null) {
|
|
|
-// materialMapperEx.setExpiryNumToNull(material.getId());
|
|
|
-// }
|
|
|
- materialExtendService.saveDetials(obj, obj.getString("sortList"),material.getId(), "update");
|
|
|
- if(obj.get("stock")!=null) {
|
|
|
- JSONArray stockArr = obj.getJSONArray("stock");
|
|
|
+ materialExtendService.saveDetails(obj.getMbList(), obj.getSortList().toJSONString(),material.getId(), "update");
|
|
|
+ if(obj.getStock()!=null) {
|
|
|
+ List<MaterialInitialStock> stockArr = obj.getStock();
|
|
|
for (int i = 0; i < stockArr.size(); i++) {
|
|
|
- JSONObject jsonObj = stockArr.getJSONObject(i);
|
|
|
- if (jsonObj.get("id") != null && jsonObj.get("initStock") != null) {
|
|
|
- String number = jsonObj.getString("initStock");
|
|
|
- BigDecimal lowSafeStock = null;
|
|
|
+ MaterialInitialStock jsonObj = stockArr.get(i);
|
|
|
+ if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null) {
|
|
|
+ BigDecimal lowSafeStock = jsonObj.getLowSafeStock();
|
|
|
BigDecimal highSafeStock = null;
|
|
|
- if(jsonObj.get("lowSafeStock")!=null) {
|
|
|
- lowSafeStock = jsonObj.getBigDecimal("lowSafeStock");
|
|
|
- }
|
|
|
- if(jsonObj.get("highSafeStock")!=null) {
|
|
|
- highSafeStock = jsonObj.getBigDecimal("highSafeStock");
|
|
|
+ if(jsonObj.getHighSafeStock() != null) {
|
|
|
+ highSafeStock = jsonObj.getHighSafeStock();
|
|
|
}
|
|
|
- Long depotId = jsonObj.getLong("id");
|
|
|
+ Long depotId = jsonObj.getId();
|
|
|
+ jsonObj.setMaterialId(material.getId());
|
|
|
+ jsonObj.setDepotId(depotId);
|
|
|
+ jsonObj.setId(null);
|
|
|
//初始库存-先清除再插入
|
|
|
MaterialInitialStockExample example = new MaterialInitialStockExample();
|
|
|
example.createCriteria().andMaterialIdEqualTo(material.getId()).andDepotIdEqualTo(depotId);
|
|
|
materialInitialStockMapper.deleteByExample(example);
|
|
|
- if (StringUtil.isNotEmpty(number) || lowSafeStock!=null || highSafeStock!=null) {
|
|
|
- insertInitialStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx(number), lowSafeStock, highSafeStock);
|
|
|
+ if (lowSafeStock!=null || highSafeStock!=null || jsonObj.getPosition() != null) {
|
|
|
+ //insertInitialStockByMaterialAndDepot(depotId, material.getId(), parseBigDecimalEx("0"), lowSafeStock, highSafeStock);
|
|
|
+ materialInitialStockMapper.insertSelective(jsonObj);
|
|
|
}
|
|
|
//更新当前库存
|
|
|
- depotItemService.updateCurrentStockFun(material.getId(), depotId);
|
|
|
+ //depotItemService.updateCurrentStockFun(material.getId(), depotId);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
logService.insertLog("商品",
|
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(material.getName()).toString(), request);
|
|
|
return 1;
|
|
|
- }catch(Exception e){
|
|
|
+ }
|
|
|
+ catch (BusinessRunTimeException ex) {
|
|
|
+ throw new BusinessRunTimeException(ex.getCode(), ex.getMessage());
|
|
|
+ }
|
|
|
+ catch(Exception e){
|
|
|
JshException.writeFail(logger, e);
|
|
|
return 0;
|
|
|
}
|
|
@@ -564,16 +569,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
//遇到多个副条码的情况,只加第一个
|
|
|
otherMaterialMap.putIfAbsent(me.getMaterialId(), me);
|
|
|
}
|
|
|
- String nameStr = "名称*,规格,型号,颜色,品牌,类别,基础重量(kg),基本单位*,副单位,基本条码*,副条码,比例,多属性," +
|
|
|
- "采购价,零售价,销售价,最低售价,状态*,序列号,批号,自定义1,自定义2,自定义3,备注,系统sku,生产日期,保质期,供应商,商品条码,批次号,仓库名称,仓位货架";
|
|
|
+ String nameStr = "名称*,规格,型号,颜色,品牌,类别,基础重量(kg),基本单位*,副单位,比例,多属性," +
|
|
|
+ "状态*,序列号,系统sku,商品条码,自定义1,自定义2,自定义3,备注";
|
|
|
List<String> nameList = StringUtil.strToStringList(nameStr);
|
|
|
//仓库列表
|
|
|
List<Depot> depotList = depotService.getAllList();
|
|
|
- if (nameList != null) {
|
|
|
- for(Depot depot: depotList) {
|
|
|
- nameList.add(depot.getName());
|
|
|
- }
|
|
|
- }
|
|
|
+// if (nameList != null) {
|
|
|
+// for(Depot depot: depotList) {
|
|
|
+// nameList.add(depot.getName());
|
|
|
+// }
|
|
|
+// }
|
|
|
//期初库存缓存
|
|
|
List<MaterialInitialStock> misList = materialInitialStockMapperEx.getListExceptZero();
|
|
|
Map<String, BigDecimal> misMap = new HashMap<>();
|
|
@@ -597,36 +602,23 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
objs[6] = m.getWeight() == null ? "" : m.getWeight().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
objs[7] = m.getCommodityUnit();
|
|
|
objs[8] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getCommodityUnit();
|
|
|
- objs[9] = m.getmBarCode();
|
|
|
- objs[10] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getBarCode();
|
|
|
- objs[11] = m.getRatio() == null ? "" : m.getRatio().toString();
|
|
|
- objs[12] = m.getSku();
|
|
|
- objs[13] = m.getPurchaseDecimal() == null ? "" : m.getPurchaseDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
- objs[14] = m.getCommodityDecimal() == null ? "" : m.getCommodityDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
- objs[15] = m.getWholesaleDecimal() == null ? "" : m.getWholesaleDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
- objs[16] = m.getLowDecimal() == null ? "" : m.getLowDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
- objs[17] = m.getEnabled() ? "1" : "0";
|
|
|
- objs[18] = m.getEnableSerialNumber();
|
|
|
- objs[19] = m.getEnableBatchNumber();
|
|
|
- objs[20] = m.getOtherField1();
|
|
|
- objs[21] = m.getOtherField2();
|
|
|
- objs[22] = m.getOtherField3();
|
|
|
- objs[23] = m.getRemark();
|
|
|
- objs[24] = m.getSystemSku();
|
|
|
- objs[25] = m.getProductionDate() == null ? "" : m.getProductionDate().toString();
|
|
|
- objs[26] = m.getExpiryNum() == null ? "" : m.getExpiryNum().toString();
|
|
|
- objs[27] = m.getSupplierId() == null ? "" : m.getSupplierId().toString();
|
|
|
- objs[28] = m.getBarCode();
|
|
|
- objs[29] = m.getBatchNumber();
|
|
|
- objs[30] = m.getDepotId() == null ? "" : m.getDepotId().toString();
|
|
|
- objs[31] = m.getPosition();
|
|
|
+ objs[9] = m.getRatio() == null ? "" : m.getRatio().toString();
|
|
|
+ objs[10] = m.getSku();
|
|
|
+ objs[11] = m.getEnabled() ? "1" : "0";
|
|
|
+ objs[12] = m.getEnableSerialNumber();
|
|
|
+ objs[13] = m.getSystemSku();
|
|
|
+ objs[14] = m.getBarCode();
|
|
|
+ objs[15] = m.getOtherField1();
|
|
|
+ objs[16] = m.getOtherField2();
|
|
|
+ objs[17] = m.getOtherField3();
|
|
|
+ objs[18] = m.getRemark();
|
|
|
//仓库期初库存
|
|
|
- int i = 32;
|
|
|
- for(Depot depot: depotList) {
|
|
|
- BigDecimal number = misMap.get(m.getId() + "_" + depot.getId());
|
|
|
- objs[i] = number == null ? "0" : number.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
- i++;
|
|
|
- }
|
|
|
+ int i = 19;
|
|
|
+// for(Depot depot: depotList) {
|
|
|
+// BigDecimal number = misMap.get(m.getId() + "_" + depot.getId());
|
|
|
+// objs[i] = number == null ? "0" : number.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
+// i++;
|
|
|
+// }
|
|
|
objects.add(objs);
|
|
|
}
|
|
|
}
|
|
@@ -992,10 +984,10 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
|
|
|
/**
|
|
|
* 缓存各个仓库的库存信息
|
|
|
- * @param src
|
|
|
+ * @param src 行数据
|
|
|
* @param depotCount
|
|
|
* @param depotMap
|
|
|
- * @param i
|
|
|
+ * @param i 行数
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
@@ -1020,6 +1012,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
|
|
|
*/
|
|
@@ -1068,6 +1089,12 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_MSG, manyBarCode));
|
|
|
}
|
|
|
}
|
|
|
+ //EXCEL中有条码在系统中已存在
|
|
|
+ MaterialExtend materialExtend = materialExtendService.getInfoByBarCode(barCode);
|
|
|
+ if (materialExtend != null && !materialExtend.getBarCode().isEmpty()) {
|
|
|
+ throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_SYSTEM_EXIST_CODE,
|
|
|
+ String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_SYSTEM_EXIST_MSG, barCode));
|
|
|
+ }
|
|
|
for(MaterialWithInitStock material: mList){
|
|
|
JSONObject materialExObj = material.getMaterialExObj();
|
|
|
String basicBarCode = "";
|
|
@@ -1195,29 +1222,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 写入初始库存
|
|
|
- * @param depotId 仓库id
|
|
|
- * @param mId 商品id
|
|
|
- * @param stock 库存数量
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
|
- public void insertInitialStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock, BigDecimal lowSafeStock, BigDecimal highSafeStock){
|
|
|
- MaterialInitialStock materialInitialStock = new MaterialInitialStock();
|
|
|
- materialInitialStock.setDepotId(depotId);
|
|
|
- materialInitialStock.setMaterialId(mId);
|
|
|
- stock = stock == null? BigDecimal.ZERO: stock;
|
|
|
- materialInitialStock.setNumber(stock);
|
|
|
- if(lowSafeStock!=null) {
|
|
|
- materialInitialStock.setLowSafeStock(lowSafeStock);
|
|
|
- }
|
|
|
- if(highSafeStock!=null) {
|
|
|
- materialInitialStock.setHighSafeStock(highSafeStock);
|
|
|
- }
|
|
|
- materialInitialStockMapper.insertSelective(materialInitialStock); //存入初始库存
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 写入当前库存
|
|
|
* @param depotId 仓库id
|
|
|
* @param mId 商品id
|
|
@@ -1319,9 +1323,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
List<MaterialInitialStock> list = materialInitialStockMapper.selectByExample(example);
|
|
|
if(list!=null && list.size()>0) {
|
|
|
for(MaterialInitialStock ms: list) {
|
|
|
- if(ms!=null) {
|
|
|
- stock = stock.add(ms.getNumber());
|
|
|
- }
|
|
|
+ stock = stock.add(ms.getNumber() == null ? BigDecimal.ZERO : ms.getNumber());
|
|
|
}
|
|
|
}
|
|
|
return stock;
|
|
@@ -1462,7 +1464,11 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
@Override
|
|
|
public List<MaterialVo4Unit> getMaterialByBarCode(String barCode) {
|
|
|
String [] barCodeArray=barCode.split(",");
|
|
|
- return materialMapperEx.getMaterialByBarCode(barCodeArray);
|
|
|
+ List<MaterialVo4Unit> list = materialMapperEx.getMaterialByBarCode(barCodeArray);
|
|
|
+ list.forEach(v -> {
|
|
|
+ v.setUnitList(v.getUnitId() == null ? null : unitService.getUnitListByID(v.getUnitId()));
|
|
|
+ });
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1607,20 +1613,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据批次号查询商品信息
|
|
|
- * @param batchNumber 批次号
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<MaterialVo4Unit> getMaterialByBatchNumber(String batchNumber) {
|
|
|
- String [] batchNumberArray=batchNumber.split(",");
|
|
|
- List<MaterialVo4Unit> list = materialMapperEx.getMaterialByBatchNumber(batchNumberArray);
|
|
|
- list.forEach(v -> {
|
|
|
- v.setUnitList(v.getUnitId() == null ? null : unitService.getUnitListByID(v.getUnitId()));
|
|
|
- });
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 根据商品id查询主表及子表信息
|
|
|
* @param id 商品id
|
|
|
* @return
|
|
@@ -1664,10 +1656,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
MaterialExample materialExample = new MaterialExample();
|
|
|
materialExample.createCriteria().andDeleteFlagEqualTo("0");
|
|
|
List<Material> materials = materialMapper.selectByExample(materialExample);
|
|
|
- //获取商品子表信息
|
|
|
- MaterialExtendExample materialExtendExample = new MaterialExtendExample();
|
|
|
- materialExtendExample.createCriteria().andDeleteFlagEqualTo("0");
|
|
|
- List<MaterialExtend> extendList = materialExtendMapper.selectByExample(materialExtendExample);
|
|
|
+ //获取商品批次信息
|
|
|
+ List<MaterialBatch> extendList = materialBatchService.list(new LambdaQueryWrapperX<MaterialBatch>().eq(MaterialBatch::getDeleteFlag,"0"));
|
|
|
//无动销提醒
|
|
|
materials.stream().filter( v -> v.getMovingPinReminderCycle() != null && !"".equals(v.getMovingPinReminderCycle()))
|
|
|
.forEach(v -> {
|
|
@@ -1736,7 +1726,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
if(StringUtil.isNotEmpty(fileName)) {
|
|
|
String fileExt = fileName.substring(fileName.indexOf(".")+1);
|
|
|
- if(!"xls".equals(fileExt)) {
|
|
|
+ if(!"xls".equals(fileExt) && !"xlsx".equals(fileExt)) {
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXTENSION_ERROR_CODE,
|
|
|
ExceptionConstants.MATERIAL_EXTENSION_ERROR_MSG);
|
|
|
}
|
|
@@ -1758,6 +1748,23 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
}
|
|
|
for (int i = 2; i < rightRows; i++) {
|
|
|
String name = ExcelUtils.getContent(src, i, 0); //名称
|
|
|
+ String standard = ExcelUtils.getContent(src, i, 1); //规格
|
|
|
+ String model = ExcelUtils.getContent(src, i, 2); //型号
|
|
|
+ String color = ExcelUtils.getContent(src, i, 3); //颜色
|
|
|
+ String brand = ExcelUtils.getContent(src, i, 4); //品牌
|
|
|
+ String categoryName = ExcelUtils.getContent(src, i, 5); //类别
|
|
|
+ String weight = ExcelUtils.getContent(src, i, 6); //基础重量(kg)
|
|
|
+ String unit = ExcelUtils.getContent(src, i, 7); //基本单位
|
|
|
+ String manyUnit = ExcelUtils.getContent(src, i, 8); //副单位
|
|
|
+ String ratio = ExcelUtils.getContent(src, i, 9); //比例
|
|
|
+ String enabled = ExcelUtils.getContent(src, i, 10); //状态
|
|
|
+ String enableSerialNumber = ExcelUtils.getContent(src, i, 11); //序列号
|
|
|
+ String barCode = ExcelUtils.getContent(src, i, 12); //商品条码
|
|
|
+ String otherField1 = ExcelUtils.getContent(src, i, 13); //自定义1
|
|
|
+ String otherField2 = ExcelUtils.getContent(src, i, 14); //自定义2
|
|
|
+ String otherField3 = ExcelUtils.getContent(src, i, 15); //自定义3
|
|
|
+ String remark = ExcelUtils.getContent(src, i, 16); //备注
|
|
|
+ //校验字段
|
|
|
//名称为空
|
|
|
if(StringUtil.isEmpty(name)) {
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
|
|
@@ -1768,21 +1775,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_OVER_CODE,
|
|
|
String.format(ExceptionConstants.MATERIAL_NAME_OVER_MSG, i+1));
|
|
|
}
|
|
|
- String standard = ExcelUtils.getContent(src, i, 1); //规格
|
|
|
//规格长度超出
|
|
|
if(StringUtil.isNotEmpty(standard) && standard.length()>100) {
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STANDARD_OVER_CODE,
|
|
|
String.format(ExceptionConstants.MATERIAL_STANDARD_OVER_MSG, i+1));
|
|
|
}
|
|
|
- String model = ExcelUtils.getContent(src, i, 2); //型号
|
|
|
//型号长度超出
|
|
|
if(StringUtil.isNotEmpty(model) && model.length()>100) {
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_MODEL_OVER_CODE,
|
|
|
String.format(ExceptionConstants.MATERIAL_MODEL_OVER_MSG, i+1));
|
|
|
}
|
|
|
- String color = ExcelUtils.getContent(src, i, 3); //颜色
|
|
|
- String brand = ExcelUtils.getContent(src, i, 4); //品牌
|
|
|
- String categoryName = ExcelUtils.getContent(src, i, 5); //类别
|
|
|
//类别为空
|
|
|
if(StringUtil.isEmpty(categoryName)) {
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_Category_Name_EMPTY_CODE,
|
|
@@ -1795,7 +1797,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_CODE,
|
|
|
String.format(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_MSG, i+1));
|
|
|
}
|
|
|
- String weight = ExcelUtils.getContent(src, i, 6); //基础重量(kg)
|
|
|
if(StringUtil.isNotEmpty(weight)) {
|
|
|
//校验基础重量是否是数字(含小数)
|
|
|
if(!StringUtil.isPositiveBigDecimal(weight)) {
|
|
@@ -1803,65 +1804,38 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
|
|
|
}
|
|
|
}
|
|
|
- String unit = ExcelUtils.getContent(src, i, 7); //基本单位
|
|
|
//基本单位为空
|
|
|
if(StringUtil.isEmpty(unit)) {
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
|
|
|
String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
|
|
|
}
|
|
|
- String manyUnit = ExcelUtils.getContent(src, i, 8); //副单位
|
|
|
- String ratio = ExcelUtils.getContent(src, i, 9); //比例
|
|
|
- String sku = ExcelUtils.getContent(src, i, 10); //多属性
|
|
|
- String purchaseDecimal = ExcelUtils.getContent(src, i, 11); //采购价
|
|
|
- String commodityDecimal = ExcelUtils.getContent(src, i, 12); //零售价
|
|
|
- String wholesaleDecimal = ExcelUtils.getContent(src, i, 13); //销售价
|
|
|
- String lowDecimal = ExcelUtils.getContent(src, i, 14); //最低售价
|
|
|
- String enabled = ExcelUtils.getContent(src, i, 15); //状态
|
|
|
//状态格式错误
|
|
|
if(!"1".equals(enabled) && !"0".equals(enabled)) {
|
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
|
|
|
String.format(ExceptionConstants.MATERIAL_ENABLED_ERROR_MSG, i+1));
|
|
|
}
|
|
|
- String enableSerialNumber = ExcelUtils.getContent(src, i, 16); //序列号
|
|
|
- String productionDate = ExcelUtils.getContent(src, i, 17); //生产日期
|
|
|
- String expiryNum = ExcelUtils.getContent(src, i, 18); //保质期天数
|
|
|
- if(StringUtil.isNotEmpty(expiryNum)) {
|
|
|
- //校验保质期是否是正整数
|
|
|
- if(!StringUtil.isPositiveLong(expiryNum)) {
|
|
|
- throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_CODE,
|
|
|
- String.format(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_MSG, i+1));
|
|
|
- }
|
|
|
- }
|
|
|
- String supplier = ExcelUtils.getContent(src, i, 19); //供应商
|
|
|
- Long supplierId = null;
|
|
|
- if(StringUtil.isNotEmpty(supplier)) {
|
|
|
- //根据供应商查询供应商id
|
|
|
- Supplier s = supplierService.getOne(new LambdaQueryWrapperX<Supplier>().eq(Supplier::getSupplier,supplier));
|
|
|
- supplierId = s.getId();
|
|
|
- if (supplierId == null){
|
|
|
- //供应商不存在
|
|
|
- throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_SUPPLIER_NOT_DECIMAL_CODE,
|
|
|
- String.format(ExceptionConstants.MATERIAL_SUPPLIER_NOT_DECIMAL_MSG, i+1));
|
|
|
- }
|
|
|
+ //商品条码为空
|
|
|
+ if(StringUtil.isEmpty(barCode)) {
|
|
|
+ throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BARCODE_EMPTY_CODE,
|
|
|
+ String.format(ExceptionConstants.MATERIAL_BARCODE_EMPTY_MSG, i+1));
|
|
|
}
|
|
|
- String barCode = ExcelUtils.getContent(src, i, 20); //商品条码
|
|
|
- String depotName = ExcelUtils.getContent(src, i, 21); //仓库名称
|
|
|
- Long depotId = null;
|
|
|
- if(StringUtil.isNotEmpty(supplier)) {
|
|
|
- //根据仓库名查询仓库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));
|
|
|
- }
|
|
|
+ //校验基本条码长度为4到40位
|
|
|
+ if(!StringUtil.checkBarCodeLength(barCode)) {
|
|
|
+ throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BARCODE_LENGTH_ERROR_CODE,
|
|
|
+ String.format(ExceptionConstants.MATERIAL_BARCODE_LENGTH_ERROR_MSG, barCode));
|
|
|
}
|
|
|
- String position = ExcelUtils.getContent(src, i, 22); //仓位货架
|
|
|
- String inventory = ExcelUtils.getContent(src,i,23);//库存
|
|
|
- String otherField1 = ExcelUtils.getContent(src, i, 24); //自定义1
|
|
|
- String otherField2 = ExcelUtils.getContent(src, i, 25); //自定义2
|
|
|
- String otherField3 = ExcelUtils.getContent(src, i, 26); //自定义3
|
|
|
- String remark = ExcelUtils.getContent(src, i, 27); //备注
|
|
|
+ //批量校验excel中有无重复条码(1-文档自身校验,2-和数据库里面的商品校验)
|
|
|
+ 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));
|
|
|
+// }
|
|
|
+// }
|
|
|
MaterialWithInitStock m = new MaterialWithInitStock();
|
|
|
//设置商品名字、规格、型号、颜色、品牌、类型id
|
|
|
m.setName(name);
|
|
@@ -1875,7 +1849,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
//设置单位、备注、基础重量
|
|
|
m.setUnit(unit);
|
|
|
m.setRemark(remark);
|
|
|
- m.setWeight(new BigDecimal(weight));
|
|
|
+ m.setWeight(weight.isEmpty() ? null : new BigDecimal(weight));
|
|
|
//设置商品是否启用
|
|
|
m.setEnabled("1".equals(enabled));
|
|
|
//设置商品是否开启序列号
|
|
@@ -1895,19 +1869,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
//设置商品拓展属性
|
|
|
JSONObject materialExObj = new JSONObject();
|
|
|
JSONObject basicObj = new JSONObject();
|
|
|
- basicObj.put("commodityUnit", unit); //商品单位
|
|
|
- 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("commodityUnit", manyUnit.isEmpty() ? unit : manyUnit); //商品单位
|
|
|
basicObj.put("barCode", barCode); //商品条码
|
|
|
- basicObj.put("inventory",inventory); //库存
|
|
|
- basicObj.put("depotId",depotId); //仓库id
|
|
|
- basicObj.put("position",position); //仓位货架
|
|
|
materialExObj.put("basic", basicObj);
|
|
|
if(StringUtil.isNotEmpty(manyUnit) && StringUtil.isNotEmpty(ratio)){ //多单位
|
|
|
//校验比例是否是数字(含小数)
|
|
@@ -1920,20 +1883,13 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
m.setUnitId(unitId);
|
|
|
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 {
|
|
|
m.setUnit(unit);
|
|
|
m.setUnitId(null);
|
|
|
}
|
|
|
m.setMaterialExObj(materialExObj);
|
|
|
- //设置库存
|
|
|
- m.setStockMap(getStockMapCache(src, depotCount, depotMap, i));
|
|
|
+ //设置仓库库位
|
|
|
+ m.setDepotMap(getExcelDepot(src, depotCount, depotMap, i));
|
|
|
mList.add(m);
|
|
|
}
|
|
|
//处理表单信息,转为对象集合
|
|
@@ -1941,6 +1897,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
|
|
@@ -1967,27 +1938,50 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * PDA库存查询
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO){
|
|
|
+ return materialMapper.inventoryInquiryList(pdaInventoryDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据库位查询商品id集合
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Long> selectMaterialIdByPosition(String position) {
|
|
|
+ return materialInitialStockMapper.selectMaterialIdByPosition(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据类型id查询子类型集合
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO) throws Exception {
|
|
|
- //查询类型id的子类型
|
|
|
- pdaInventoryDTO.setCategoryIds(selectCategoryIds(pdaInventoryDTO.getCategoryId()));
|
|
|
- return materialMapperEx.inventoryInquiry(pdaInventoryDTO);
|
|
|
+ public List<Long> selectCategoryIds(Long id) {
|
|
|
+ List<Long> longs = new ArrayList<>();
|
|
|
+ longs.add(id);
|
|
|
+ List<MaterialCategory> list = materialCategoryService.list(new LambdaQueryWrapperX<MaterialCategory>().eq(MaterialCategory::getParentId,id).eq(MaterialCategory::getDeleteFlag,"0"));
|
|
|
+ for (MaterialCategory materialCategory : list) {
|
|
|
+ longs.addAll(selectCategoryIds(materialCategory.getId()));
|
|
|
+ }
|
|
|
+ return longs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询库位树
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<PDATypeTree> selectPosition() {
|
|
|
- List<String> positions = materialExtendMapper.selectPosition();
|
|
|
+ public List<PDATypeTree> selectPosition(Long depotId) {
|
|
|
+ List<String> positions = materialInitialStockMapper.selectPosition(depotId);
|
|
|
Map<String,List<String>> map = new HashMap<>();
|
|
|
for (String s : positions) {
|
|
|
- String [] str = s.split("-");
|
|
|
+ String [] str = s.split("-",2);
|
|
|
if (map.get(str[0]) == null){
|
|
|
List<String> list = new ArrayList<>();
|
|
|
map.put(str[0],list);
|
|
|
}
|
|
|
- if (str.length > 2){
|
|
|
+ if (str.length > 1){
|
|
|
map.get(str[0]).add(str[1]);
|
|
|
}
|
|
|
}
|
|
@@ -2010,9 +2004,46 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取仓库id、商品id获取商品库位信息
|
|
|
+ * @param did 仓库id
|
|
|
+ * @param mid 商品id
|
|
|
+ * @return 库位
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getPositionByDidAndMid(Long did, Long mid) {
|
|
|
+ MaterialInitialStock stock = materialInitialStockMapper.selectOne(new QueryWrapperX<MaterialInitialStock>().eq("depot_id",did).eq("material_id",mid));
|
|
|
+ return stock == null ? null : stock.getPosition();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据商品id查询商品库存
|
|
|
+ * @param mid 商品id
|
|
|
+ * @return 商品库存
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BigDecimal getMaterialStockByMid(Long mid){
|
|
|
+ List<Long> materialIdList = Arrays.asList(mid);
|
|
|
+ List<MaterialCurrentStock> mcsList = materialCurrentStockMapperEx.getCurrentStockMapByIdList(materialIdList);
|
|
|
+ return mcsList.size() == 0 ? BigDecimal.ZERO : mcsList.get(0).getCurrentNumber();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据商品id和仓库id查询商品当前库存
|
|
|
+ *
|
|
|
+ * @param mid 商品id
|
|
|
+ * @param did 仓库id
|
|
|
+ * @return 商品库存
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BigDecimal getMaterialStockByMidAndDid(Long mid, Long did) {
|
|
|
+ MaterialCurrentStock materialCurrentStock = materialCurrentStockMapper.selectOne(new LambdaQueryWrapperX<MaterialCurrentStock>().eq(MaterialCurrentStock::getMaterialId,mid).eq(MaterialCurrentStock::getDepotId,did).eq(MaterialCurrentStock::getDeleteFlag,"0"));
|
|
|
+ return materialCurrentStock == null ? BigDecimal.ZERO : materialCurrentStock.getCurrentNumber();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 解析excel表格数据为商品对象
|
|
|
*/
|
|
|
- public List<Material> parseMapByExcelData(List<MaterialWithInitStock> mList){
|
|
|
+ private List<Material> parseMapByExcelData(List<MaterialWithInitStock> mList){
|
|
|
List<Material> materials = new ArrayList<>();
|
|
|
Map<String,Material> materialMap = new HashMap<>();
|
|
|
for (MaterialWithInitStock m : mList) {
|
|
@@ -2030,8 +2061,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
+ "-" + m.getStandard()
|
|
|
+ "-" + m.getBrand()
|
|
|
+ "-" + m.getColor()
|
|
|
- + "-" + m.getUnit()
|
|
|
- + "-" + materialSku;
|
|
|
+ + "-" + m.getUnit();
|
|
|
if (materialMap.get(str) == null) {
|
|
|
//商品主表不存在,创建商品主表
|
|
|
Material material = new Material();
|
|
@@ -2071,52 +2101,21 @@ 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);
|
|
|
}
|
|
|
//添加子表信息
|
|
|
MaterialExtend materialExtend = new MaterialExtend();
|
|
|
//商品单位
|
|
|
- materialExtend.setCommodityUnit(m.getUnit());
|
|
|
+ materialExtend.setCommodityUnit(basicObj.getString("commodityUnit"));
|
|
|
//商品属性
|
|
|
materialExtend.setSku(materialSku);
|
|
|
- //采购价格
|
|
|
- materialExtend.setPurchaseDecimal(basicObj.getBigDecimal("purchaseDecimal"));
|
|
|
- //零售价格
|
|
|
- materialExtend.setCommodityDecimal(basicObj.getBigDecimal("commodityDecimal"));
|
|
|
- //销售价格
|
|
|
- materialExtend.setWholesaleDecimal(basicObj.getBigDecimal("wholesaleDecimal"));
|
|
|
- //最低售价
|
|
|
- materialExtend.setLowDecimal(basicObj.getBigDecimal("lowDecimal"));
|
|
|
- //生产日期
|
|
|
- materialExtend.setProductionDate(basicObj.getDate("productionDate"));
|
|
|
- //保质期天数
|
|
|
- materialExtend.setExpiryNum(basicObj.getInteger("expiryNum"));
|
|
|
- //供应商id
|
|
|
- materialExtend.setSupplierId(basicObj.getLong("supplierId"));
|
|
|
//商品条码
|
|
|
materialExtend.setBarCode(basicObj.getString("barCode"));
|
|
|
- //设置批次号
|
|
|
- String batchNumber = DateUtils.dateTimeNow("yyyyMMdd") + RandomHelper.getRandomStr(6);
|
|
|
- materialExtend.setBatchNumber(batchNumber);
|
|
|
- //仓库id
|
|
|
- materialExtend.setDepotId(basicObj.getLong("depotId"));
|
|
|
- //仓位货架
|
|
|
- materialExtend.setPosition(basicObj.getString("position"));
|
|
|
- //库存
|
|
|
- materialExtend.setInventory(basicObj.getBigDecimal("inventory"));
|
|
|
+
|
|
|
materialMap.get(str).getList().add(materialExtend);
|
|
|
}
|
|
|
materialMap.values().forEach(v -> materials.add(v));
|
|
|
return materials;
|
|
|
}
|
|
|
-
|
|
|
- public List<Long> selectCategoryIds(Long id) throws Exception {
|
|
|
- List<Long> longs = new ArrayList<>();
|
|
|
- longs.add(id);
|
|
|
- List<MaterialCategory> list = materialCategoryService.list(new LambdaQueryWrapperX<MaterialCategory>().eq(MaterialCategory::getParentId,id).eq(MaterialCategory::getDeleteFlag,"0"));
|
|
|
- for (MaterialCategory materialCategory : list) {
|
|
|
- longs.addAll(selectCategoryIds(materialCategory.getId()));
|
|
|
- }
|
|
|
- return longs;
|
|
|
- }
|
|
|
}
|