|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.jsh.erp.constants.BusinessConstants;
|
|
import com.jsh.erp.constants.BusinessConstants;
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
|
|
+import com.jsh.erp.datasource.dto.MaterialDto;
|
|
import com.jsh.erp.datasource.entities.*;
|
|
import com.jsh.erp.datasource.entities.*;
|
|
import com.jsh.erp.datasource.mappers.*;
|
|
import com.jsh.erp.datasource.mappers.*;
|
|
import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
|
|
import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
|
|
@@ -15,7 +16,6 @@ import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
|
|
import com.jsh.erp.datasource.pda.vo.PDATypeTree;
|
|
import com.jsh.erp.datasource.pda.vo.PDATypeTree;
|
|
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
|
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
|
import com.jsh.erp.datasource.vo.MaterialWarnListVo;
|
|
import com.jsh.erp.datasource.vo.MaterialWarnListVo;
|
|
-import com.jsh.erp.datasource.vo.TreeNode;
|
|
|
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
|
import com.jsh.erp.exception.JshException;
|
|
import com.jsh.erp.exception.JshException;
|
|
import com.jsh.erp.query.LambdaQueryWrapperX;
|
|
import com.jsh.erp.query.LambdaQueryWrapperX;
|
|
@@ -88,6 +88,9 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
@Resource
|
|
@Resource
|
|
private DepotMapperEx depotMapperEx;
|
|
private DepotMapperEx depotMapperEx;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private MaterialBatchService materialBarCodeService;
|
|
|
|
+
|
|
@Value(value="${file.uploadType}")
|
|
@Value(value="${file.uploadType}")
|
|
private Long fileUploadType;
|
|
private Long fileUploadType;
|
|
|
|
|
|
@@ -130,9 +133,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 查询商品管理-商品信息列表查询
|
|
|
|
- */
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<MaterialVo4Unit> select(String materialParam, String standard, String model, String color, String brand, String mfrs,
|
|
public List<MaterialVo4Unit> select(String materialParam, String standard, String model, String color, String brand, String mfrs,
|
|
String materialOther, String weight, String expiryNum, String enableSerialNumber,
|
|
String materialOther, String weight, String expiryNum, String enableSerialNumber,
|
|
@@ -178,51 +179,52 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
@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);
|
|
m.setEnabled(true);
|
|
//获取类型编码
|
|
//获取类型编码
|
|
Long serial_no = materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
Long serial_no = materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
- String sku = serial_no + DateUtils.dateTimeNow();
|
|
|
|
|
|
+ String sku = serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(4);
|
|
//设置系统sku
|
|
//设置系统sku
|
|
m.setSystemSku(sku);
|
|
m.setSystemSku(sku);
|
|
User user = userService.getCurrentUser();
|
|
User user = userService.getCurrentUser();
|
|
- m.setTenantId(user.getId());
|
|
|
|
try{
|
|
try{
|
|
//添加商品
|
|
//添加商品
|
|
materialMapperEx.insertSelectiveEx(m);
|
|
materialMapperEx.insertSelectiveEx(m);
|
|
Long mId = m.getId();
|
|
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++) {
|
|
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);
|
|
|
|
+ //此时id为仓库id,仓库di、最低安全库存数量不为空
|
|
|
|
+ if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null) {
|
|
|
|
+ BigDecimal lowSafeStock = jsonObj.getLowSafeStock();
|
|
BigDecimal highSafeStock = null;
|
|
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");
|
|
|
|
- if(StringUtil.isNotEmpty(number) && Double.parseDouble(number)>0 || 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(number), lowSafeStock, highSafeStock);
|
|
|
|
|
|
+ materialInitialStockMapper.insertSelective(jsonObj);
|
|
|
|
+ //insertInitialStockByMaterialAndDepot(jsonObj);
|
|
//设置当前库
|
|
//设置当前库
|
|
//insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
|
//insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
|
//更新当前库存
|
|
//更新当前库存
|
|
- depotItemService.updateCurrentStockFun(mId, depotId);
|
|
|
|
|
|
+ //depotItemService.updateCurrentStockFun(mId, depotId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
logService.insertLog("商品",
|
|
logService.insertLog("商品",
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
|
|
return 1;
|
|
return 1;
|
|
@@ -243,43 +245,39 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
@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{
|
|
try{
|
|
//修改商品属性
|
|
//修改商品属性
|
|
materialMapper.updateByPrimaryKeySelective(material);
|
|
materialMapper.updateByPrimaryKeySelective(material);
|
|
- //
|
|
|
|
if(material.getUnitId() == null) {
|
|
if(material.getUnitId() == null) {
|
|
materialMapperEx.setUnitIdToNull(material.getId());
|
|
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++) {
|
|
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;
|
|
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();
|
|
MaterialInitialStockExample example = new MaterialInitialStockExample();
|
|
example.createCriteria().andMaterialIdEqualTo(material.getId()).andDepotIdEqualTo(depotId);
|
|
example.createCriteria().andMaterialIdEqualTo(material.getId()).andDepotIdEqualTo(depotId);
|
|
materialInitialStockMapper.deleteByExample(example);
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1198,29 +1196,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 depotId 仓库id
|
|
* @param mId 商品id
|
|
* @param mId 商品id
|
|
@@ -1465,7 +1440,12 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
@Override
|
|
@Override
|
|
public List<MaterialVo4Unit> getMaterialByBarCode(String barCode) {
|
|
public List<MaterialVo4Unit> getMaterialByBarCode(String barCode) {
|
|
String [] barCodeArray=barCode.split(",");
|
|
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()));
|
|
|
|
+ v.setInventory(getMaterialStockByMid(v.getId()));
|
|
|
|
+ });
|
|
|
|
+ return list;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1761,6 +1741,25 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
}
|
|
}
|
|
for (int i = 2; i < rightRows; i++) {
|
|
for (int i = 2; i < rightRows; i++) {
|
|
String name = ExcelUtils.getContent(src, i, 0); //名称
|
|
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); //备注
|
|
|
|
+ String depotName = ExcelUtils.getContent(src, i, 17); //仓库名称
|
|
|
|
+ String position = ExcelUtils.getContent(src, i, 18); //仓位货架
|
|
|
|
+ //校验字段
|
|
//名称为空
|
|
//名称为空
|
|
if(StringUtil.isEmpty(name)) {
|
|
if(StringUtil.isEmpty(name)) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
|
|
@@ -1771,21 +1770,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_OVER_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_OVER_CODE,
|
|
String.format(ExceptionConstants.MATERIAL_NAME_OVER_MSG, i+1));
|
|
String.format(ExceptionConstants.MATERIAL_NAME_OVER_MSG, i+1));
|
|
}
|
|
}
|
|
- String standard = ExcelUtils.getContent(src, i, 1); //规格
|
|
|
|
//规格长度超出
|
|
//规格长度超出
|
|
if(StringUtil.isNotEmpty(standard) && standard.length()>100) {
|
|
if(StringUtil.isNotEmpty(standard) && standard.length()>100) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STANDARD_OVER_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STANDARD_OVER_CODE,
|
|
String.format(ExceptionConstants.MATERIAL_STANDARD_OVER_MSG, i+1));
|
|
String.format(ExceptionConstants.MATERIAL_STANDARD_OVER_MSG, i+1));
|
|
}
|
|
}
|
|
- String model = ExcelUtils.getContent(src, i, 2); //型号
|
|
|
|
//型号长度超出
|
|
//型号长度超出
|
|
if(StringUtil.isNotEmpty(model) && model.length()>100) {
|
|
if(StringUtil.isNotEmpty(model) && model.length()>100) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_MODEL_OVER_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_MODEL_OVER_CODE,
|
|
String.format(ExceptionConstants.MATERIAL_MODEL_OVER_MSG, i+1));
|
|
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)) {
|
|
if(StringUtil.isEmpty(categoryName)) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_Category_Name_EMPTY_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_Category_Name_EMPTY_CODE,
|
|
@@ -1798,7 +1792,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_CODE,
|
|
String.format(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_MSG, i+1));
|
|
String.format(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_MSG, i+1));
|
|
}
|
|
}
|
|
- String weight = ExcelUtils.getContent(src, i, 6); //基础重量(kg)
|
|
|
|
if(StringUtil.isNotEmpty(weight)) {
|
|
if(StringUtil.isNotEmpty(weight)) {
|
|
//校验基础重量是否是数字(含小数)
|
|
//校验基础重量是否是数字(含小数)
|
|
if(!StringUtil.isPositiveBigDecimal(weight)) {
|
|
if(!StringUtil.isPositiveBigDecimal(weight)) {
|
|
@@ -1806,51 +1799,18 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
|
|
String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- String unit = ExcelUtils.getContent(src, i, 7); //基本单位
|
|
|
|
//基本单位为空
|
|
//基本单位为空
|
|
if(StringUtil.isEmpty(unit)) {
|
|
if(StringUtil.isEmpty(unit)) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
|
|
String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
|
|
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)) {
|
|
if(!"1".equals(enabled) && !"0".equals(enabled)) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
|
|
String.format(ExceptionConstants.MATERIAL_ENABLED_ERROR_MSG, i+1));
|
|
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));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- String barCode = ExcelUtils.getContent(src, i, 20); //商品条码
|
|
|
|
- String depotName = ExcelUtils.getContent(src, i, 21); //仓库名称
|
|
|
|
Long depotId = null;
|
|
Long depotId = null;
|
|
- if(StringUtil.isNotEmpty(supplier)) {
|
|
|
|
|
|
+ if(StringUtil.isNotEmpty(depotName)) {
|
|
//根据仓库名查询仓库id
|
|
//根据仓库名查询仓库id
|
|
depotId = depotMapperEx.selectByConditionDepot(depotName,null,null).get(0).getId();
|
|
depotId = depotMapperEx.selectByConditionDepot(depotName,null,null).get(0).getId();
|
|
if (depotId == null){
|
|
if (depotId == null){
|
|
@@ -1859,12 +1819,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
String.format(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_MSG, i+1));
|
|
String.format(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_MSG, i+1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- 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); //备注
|
|
|
|
MaterialWithInitStock m = new MaterialWithInitStock();
|
|
MaterialWithInitStock m = new MaterialWithInitStock();
|
|
//设置商品名字、规格、型号、颜色、品牌、类型id
|
|
//设置商品名字、规格、型号、颜色、品牌、类型id
|
|
m.setName(name);
|
|
m.setName(name);
|
|
@@ -1890,7 +1844,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
//获取类型编码
|
|
//获取类型编码
|
|
Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
//设置系统sku
|
|
//设置系统sku
|
|
- m.setSystemSku(serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6));
|
|
|
|
|
|
+ m.setSystemSku(serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(4));
|
|
m.setOtherField1(StringUtil.isNotEmpty(otherField1)?otherField1:null);
|
|
m.setOtherField1(StringUtil.isNotEmpty(otherField1)?otherField1:null);
|
|
m.setOtherField2(StringUtil.isNotEmpty(otherField2)?otherField2:null);
|
|
m.setOtherField2(StringUtil.isNotEmpty(otherField2)?otherField2:null);
|
|
m.setOtherField3(StringUtil.isNotEmpty(otherField3)?otherField3:null);
|
|
m.setOtherField3(StringUtil.isNotEmpty(otherField3)?otherField3:null);
|
|
@@ -1899,16 +1853,16 @@ 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", unit); //商品单位
|
|
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("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("inventory",inventory); //库存
|
|
basicObj.put("depotId",depotId); //仓库id
|
|
basicObj.put("depotId",depotId); //仓库id
|
|
basicObj.put("position",position); //仓位货架
|
|
basicObj.put("position",position); //仓位货架
|
|
materialExObj.put("basic", basicObj);
|
|
materialExObj.put("basic", basicObj);
|
|
@@ -2013,6 +1967,30 @@ 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();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 解析excel表格数据为商品对象
|
|
* 解析excel表格数据为商品对象
|
|
*/
|
|
*/
|
|
public List<Material> parseMapByExcelData(List<MaterialWithInitStock> mList){
|
|
public List<Material> parseMapByExcelData(List<MaterialWithInitStock> mList){
|