|
@@ -9,11 +9,17 @@ import com.jsh.erp.constants.BusinessConstants;
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
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.vo.PDADepotItemVO;
|
|
|
|
+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.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;
|
|
|
|
+import com.jsh.erp.query.QueryWrapperX;
|
|
import com.jsh.erp.service.*;
|
|
import com.jsh.erp.service.*;
|
|
import com.jsh.erp.utils.*;
|
|
import com.jsh.erp.utils.*;
|
|
import jxl.Sheet;
|
|
import jxl.Sheet;
|
|
@@ -209,11 +215,14 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
//设置初始库
|
|
//设置初始库
|
|
insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number), lowSafeStock, highSafeStock);
|
|
insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number), lowSafeStock, highSafeStock);
|
|
//设置当前库
|
|
//设置当前库
|
|
- insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
|
|
|
|
|
+ //insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
|
|
|
|
+ //更新当前库存
|
|
|
|
+ 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;
|
|
@@ -236,7 +245,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
|
|
public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
|
|
Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
|
|
Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
|
|
-
|
|
|
|
try{
|
|
try{
|
|
//修改商品属性
|
|
//修改商品属性
|
|
materialMapper.updateByPrimaryKeySelective(material);
|
|
materialMapper.updateByPrimaryKeySelective(material);
|
|
@@ -1633,9 +1641,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
if (CollectionUtil.isEmpty(systemSkuList)){
|
|
if (CollectionUtil.isEmpty(systemSkuList)){
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- String[] systemSkuArray = systemSkuList.toArray(new String[0]);
|
|
|
|
- List<MaterialVo4Unit> list = materialMapperEx.getMaterialBySystemSku(systemSkuArray);
|
|
|
|
- return list;
|
|
|
|
|
|
+ String[] systemSkuArray = systemSkuList.toArray(new String[systemSkuList.size()]);
|
|
|
|
+ return materialMapperEx.getMaterialBySystemSku(systemSkuArray);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(List<Long> idList) {
|
|
|
|
+ if (CollectionUtil.isEmpty(idList)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return materialMapperEx.getMaterialCurrentPriceByIdList(idList);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1715,13 +1730,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
return vo;
|
|
return vo;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 导入表格
|
|
|
|
- * @param file
|
|
|
|
- * @param request
|
|
|
|
- * @return
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
@Override
|
|
@Override
|
|
public BaseResponseInfo importExcelTwo(MultipartFile file, HttpServletRequest request) throws Exception {
|
|
public BaseResponseInfo importExcelTwo(MultipartFile file, HttpServletRequest request) throws Exception {
|
|
BaseResponseInfo info = new BaseResponseInfo();
|
|
BaseResponseInfo info = new BaseResponseInfo();
|
|
@@ -1740,6 +1748,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
Sheet src = workbook.getSheet(0);
|
|
Sheet src = workbook.getSheet(0);
|
|
//获取真实的行数,剔除掉空白行
|
|
//获取真实的行数,剔除掉空白行
|
|
int rightRows = ExcelUtils.getRightRows(src);
|
|
int rightRows = ExcelUtils.getRightRows(src);
|
|
|
|
+ //获取所有仓库
|
|
List<Depot> depotList= depotService.getDepot();
|
|
List<Depot> depotList= depotService.getDepot();
|
|
int depotCount = depotList.size();
|
|
int depotCount = depotList.size();
|
|
Map<String, Long> depotMap = parseDepotToMap(depotList);
|
|
Map<String, Long> depotMap = parseDepotToMap(depotList);
|
|
@@ -1752,33 +1761,6 @@ 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 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); //状态
|
|
|
|
- String enableSerialNumber = ExcelUtils.getContent(src, i, 16); //序列号
|
|
|
|
- String productionDate = ExcelUtils.getContent(src, i, 17); //生产日期
|
|
|
|
- String expiryNum = ExcelUtils.getContent(src, i, 18); //保质期天数
|
|
|
|
- String supplier = ExcelUtils.getContent(src, i, 19); //供应商
|
|
|
|
- String barCode = ExcelUtils.getContent(src, i, 20); //商品条码
|
|
|
|
- String depotName = ExcelUtils.getContent(src, i, 21); //仓库名称
|
|
|
|
- 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); //备注
|
|
|
|
//名称为空
|
|
//名称为空
|
|
if(StringUtil.isEmpty(name)) {
|
|
if(StringUtil.isEmpty(name)) {
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
|
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
|
|
@@ -1789,21 +1771,21 @@ 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));
|
|
}
|
|
}
|
|
- //基本单位为空
|
|
|
|
- if(StringUtil.isEmpty(unit)) {
|
|
|
|
- throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
|
|
|
|
- String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_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,
|
|
@@ -1816,8 +1798,46 @@ 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.isPositiveBigDecimal(weight)) {
|
|
|
|
+ throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_CODE,
|
|
|
|
+ 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;
|
|
Long supplierId = null;
|
|
- if (supplier != null && !supplier.isEmpty()){
|
|
|
|
|
|
+ if(StringUtil.isNotEmpty(supplier)) {
|
|
//根据供应商查询供应商id
|
|
//根据供应商查询供应商id
|
|
Supplier s = supplierService.getOne(new LambdaQueryWrapperX<Supplier>().eq(Supplier::getSupplier,supplier));
|
|
Supplier s = supplierService.getOne(new LambdaQueryWrapperX<Supplier>().eq(Supplier::getSupplier,supplier));
|
|
supplierId = s.getId();
|
|
supplierId = s.getId();
|
|
@@ -1827,8 +1847,10 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
String.format(ExceptionConstants.MATERIAL_SUPPLIER_NOT_DECIMAL_MSG, i+1));
|
|
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 (depotName != null && !depotName.isEmpty()){
|
|
|
|
|
|
+ if(StringUtil.isNotEmpty(supplier)) {
|
|
//根据仓库名查询仓库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){
|
|
@@ -1837,6 +1859,12 @@ 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);
|
|
@@ -1847,53 +1875,42 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
m.setCategoryId(categoryId);
|
|
m.setCategoryId(categoryId);
|
|
//通过名称生成助记码
|
|
//通过名称生成助记码
|
|
m.setMnemonic(PinYinUtil.getFirstLettersLo(name));
|
|
m.setMnemonic(PinYinUtil.getFirstLettersLo(name));
|
|
|
|
+ //设置单位、备注、基础重量
|
|
|
|
+ m.setUnit(unit);
|
|
|
|
+ m.setRemark(remark);
|
|
|
|
+ m.setWeight(new BigDecimal(weight));
|
|
|
|
+ //设置商品是否启用
|
|
|
|
+ m.setEnabled("1".equals(enabled));
|
|
|
|
+ //设置商品是否开启序列号
|
|
|
|
+ if(StringUtil.isNotEmpty(enableSerialNumber) && "1".equals(enableSerialNumber)) {
|
|
|
|
+ m.setEnableSerialNumber("1");
|
|
|
|
+ } else {
|
|
|
|
+ m.setEnableSerialNumber("0");
|
|
|
|
+ }
|
|
//获取类型编码
|
|
//获取类型编码
|
|
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());
|
|
|
|
- if(StringUtil.isNotEmpty(weight)) {
|
|
|
|
- //校验基础重量是否是数字(含小数)
|
|
|
|
- if(!StringUtil.isPositiveBigDecimal(weight)) {
|
|
|
|
- throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_CODE,
|
|
|
|
- String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
|
|
|
|
- }
|
|
|
|
- m.setWeight(new BigDecimal(weight));
|
|
|
|
- }
|
|
|
|
- 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));
|
|
|
|
- }
|
|
|
|
- //m.setExpiryNum(Integer.parseInt(expiryNum));
|
|
|
|
- }
|
|
|
|
|
|
+ m.setSystemSku(serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6));
|
|
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);
|
|
m.setRemark(remark);
|
|
m.setRemark(remark);
|
|
- //状态格式错误
|
|
|
|
- if(!"1".equals(enabled) && !"0".equals(enabled)) {
|
|
|
|
- throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
|
|
|
|
- String.format(ExceptionConstants.MATERIAL_ENABLED_ERROR_MSG, i+1));
|
|
|
|
- }
|
|
|
|
- //批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位、多属性
|
|
|
|
- //batchCheckExistMaterialListByParam(mList, name, standard, model, color, unit, sku);
|
|
|
|
//设置商品拓展属性
|
|
//设置商品拓展属性
|
|
JSONObject materialExObj = new JSONObject();
|
|
JSONObject materialExObj = new JSONObject();
|
|
JSONObject basicObj = 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);
|
|
|
|
- basicObj.put("barCode", barCode);
|
|
|
|
- basicObj.put("inventory",inventory);
|
|
|
|
- basicObj.put("depotId",depotId);
|
|
|
|
- basicObj.put("position",position);
|
|
|
|
|
|
+ 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("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)){ //多单位
|
|
//校验比例是否是数字(含小数)
|
|
//校验比例是否是数字(含小数)
|
|
@@ -1906,68 +1923,34 @@ 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);
|
|
|
|
|
|
+// 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.setEnabled("1".equals(enabled));
|
|
|
|
- //设置商品是否开启序列号
|
|
|
|
- if(StringUtil.isNotEmpty(enableSerialNumber) && "1".equals(enableSerialNumber)) {
|
|
|
|
- m.setEnableSerialNumber("1");
|
|
|
|
- } else {
|
|
|
|
- m.setEnableSerialNumber("0");
|
|
|
|
- }
|
|
|
|
- //批号去掉
|
|
|
|
-// if(StringUtil.isNotEmpty(enableBatchNumber) && "1".equals(enableBatchNumber)) {
|
|
|
|
-// m.setEnableBatchNumber("1");
|
|
|
|
-// } else {
|
|
|
|
-// m.setEnableBatchNumber("0");
|
|
|
|
-// }
|
|
|
|
-// if("1".equals(enableSerialNumber) && "1".equals(enableBatchNumber)) {
|
|
|
|
-// throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLE_MUST_ONE_CODE,
|
|
|
|
-// String.format(ExceptionConstants.MATERIAL_ENABLE_MUST_ONE_MSG, barCode));
|
|
|
|
-// }
|
|
|
|
//设置库存
|
|
//设置库存
|
|
m.setStockMap(getStockMapCache(src, depotCount, depotMap, i));
|
|
m.setStockMap(getStockMapCache(src, depotCount, depotMap, i));
|
|
mList.add(m);
|
|
mList.add(m);
|
|
}
|
|
}
|
|
//处理表单信息,转为对象集合
|
|
//处理表单信息,转为对象集合
|
|
List<Material> materialList = parseMapByExcelData(mList);
|
|
List<Material> materialList = parseMapByExcelData(mList);
|
|
- List<Long> deleteInitialStockMaterialIdList = new ArrayList<>();
|
|
|
|
- List<Long> deleteCurrentStockMaterialIdList = new ArrayList<>();
|
|
|
|
- List<MaterialInitialStock> insertInitialStockMaterialList = new ArrayList<>();
|
|
|
|
- List<MaterialCurrentStock> insertCurrentStockMaterialList = new ArrayList<>();
|
|
|
|
- //防止初始库存和当前库存出现重复
|
|
|
|
- Map<String, String> materialDepotInitialMap = new HashMap<>();
|
|
|
|
- Map<String, String> materialDepotCurrentMap = new HashMap<>();
|
|
|
|
for (Material material : materialList) {
|
|
for (Material material : materialList) {
|
|
- //添加商品
|
|
|
|
|
|
+ //添加商品信息
|
|
materialMapperEx.insertSelectiveEx(material);
|
|
materialMapperEx.insertSelectiveEx(material);
|
|
- //
|
|
|
|
- Long mId = material.getId();
|
|
|
|
|
|
+ //添加商品子信息
|
|
for (MaterialExtend materialExtend : material.getList()) {
|
|
for (MaterialExtend materialExtend : material.getList()) {
|
|
- materialExtend.setMaterialId(mId);
|
|
|
|
|
|
+ //设置商品id
|
|
|
|
+ materialExtend.setMaterialId( material.getId());
|
|
materialExtendService.insertMaterialExtend(materialExtend);
|
|
materialExtendService.insertMaterialExtend(materialExtend);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //批量更新库存,先删除后新增
|
|
|
|
-// if(insertInitialStockMaterialList.size()>0) {
|
|
|
|
-// batchDeleteInitialStockByMaterialList(deleteInitialStockMaterialIdList);
|
|
|
|
-// materialInitialStockMapperEx.batchInsert(insertInitialStockMaterialList);
|
|
|
|
-// }
|
|
|
|
-// if(insertCurrentStockMaterialList.size()>0) {
|
|
|
|
-// batchDeleteCurrentStockByMaterialList(deleteCurrentStockMaterialIdList);
|
|
|
|
-// materialCurrentStockMapperEx.batchInsert(insertCurrentStockMaterialList);
|
|
|
|
-// }
|
|
|
|
//添加日志
|
|
//添加日志
|
|
logService.insertLog("商品",
|
|
logService.insertLog("商品",
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
|
|
@@ -1987,6 +1970,48 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
return info;
|
|
return info;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO) throws Exception {
|
|
|
|
+ //查询类型id的子类型
|
|
|
|
+ pdaInventoryDTO.setCategoryIds(selectCategoryIds(pdaInventoryDTO.getCategoryId()));
|
|
|
|
+ return materialMapperEx.inventoryInquiry(pdaInventoryDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询库位树
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<PDATypeTree> selectPosition() {
|
|
|
|
+ List<String> positions = materialExtendMapper.selectPosition();
|
|
|
|
+ Map<String,List<String>> map = new HashMap<>();
|
|
|
|
+ for (String s : positions) {
|
|
|
|
+ String [] str = s.split("-");
|
|
|
|
+ if (map.get(str[0]) == null){
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
+ map.put(str[0],list);
|
|
|
|
+ }
|
|
|
|
+ if (str.length > 2){
|
|
|
|
+ map.get(str[0]).add(str[1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<PDATypeTree> typeTrees = new ArrayList<>();
|
|
|
|
+ map.forEach((key,value) -> {
|
|
|
|
+ PDATypeTree typeTree = new PDATypeTree();
|
|
|
|
+ typeTree.setLabel(key);
|
|
|
|
+ typeTree.setValue(key);
|
|
|
|
+ List<PDATypeTree> children = new ArrayList<>();
|
|
|
|
+ for (String s : value) {
|
|
|
|
+ PDATypeTree childrenTree = new PDATypeTree();
|
|
|
|
+ childrenTree.setLabel(key + "-" + s);
|
|
|
|
+ childrenTree.setValue(key + "-" + s);
|
|
|
|
+ children.add(childrenTree);
|
|
|
|
+ }
|
|
|
|
+ typeTree.setChildren(children);
|
|
|
|
+ typeTrees.add(typeTree);
|
|
|
|
+ });
|
|
|
|
+ return typeTrees;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 解析excel表格数据为商品对象
|
|
* 解析excel表格数据为商品对象
|
|
*/
|
|
*/
|
|
@@ -2025,10 +2050,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
material.setMnemonic(m.getMnemonic());
|
|
material.setMnemonic(m.getMnemonic());
|
|
//颜色
|
|
//颜色
|
|
material.setColor(m.getColor());
|
|
material.setColor(m.getColor());
|
|
|
|
+ //商品类别
|
|
|
|
+ material.setCategoryId(m.getCategoryId());
|
|
//单位-单个
|
|
//单位-单个
|
|
material.setUnit(m.getUnit());
|
|
material.setUnit(m.getUnit());
|
|
//计量单位Id
|
|
//计量单位Id
|
|
material.setUnitId(m.getUnitId());
|
|
material.setUnitId(m.getUnitId());
|
|
|
|
+ //备注
|
|
|
|
+ material.setRemark(m.getRemark());
|
|
|
|
+ //基础重量
|
|
|
|
+ material.setWeight(m.getWeight());
|
|
//启用 0-禁用 1-启用
|
|
//启用 0-禁用 1-启用
|
|
material.setEnabled(m.getEnabled());
|
|
material.setEnabled(m.getEnabled());
|
|
//自定义1
|
|
//自定义1
|
|
@@ -2074,6 +2105,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
materialExtend.setDepotId(basicObj.getLong("depotId"));
|
|
materialExtend.setDepotId(basicObj.getLong("depotId"));
|
|
//仓位货架
|
|
//仓位货架
|
|
materialExtend.setPosition(basicObj.getString("position"));
|
|
materialExtend.setPosition(basicObj.getString("position"));
|
|
|
|
+ //库存
|
|
materialExtend.setInventory(basicObj.getBigDecimal("inventory"));
|
|
materialExtend.setInventory(basicObj.getBigDecimal("inventory"));
|
|
materialMap.get(str).getList().add(materialExtend);
|
|
materialMap.get(str).getList().add(materialExtend);
|
|
}
|
|
}
|
|
@@ -2081,4 +2113,13 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
return materials;
|
|
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;
|
|
|
|
+ }
|
|
}
|
|
}
|