Browse Source

1.新增映射品类子类导入功能

dev
zhenghaoyu 1 month ago
parent
commit
ee2fdfe560
  1. 4
      blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesWorkOrderServiceImpl.java
  2. 10
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataFactoryCategoryController.java
  3. 10
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataFactoryCategoryExcel.java
  4. 171
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataFactoryCategoryImporter.java
  5. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java
  6. 8
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java

4
blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesWorkOrderServiceImpl.java

@ -26,7 +26,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.aftersales.bean.Resp;
import com.logpm.aftersales.dto.*;
import com.logpm.aftersales.entity.*;
import com.logpm.aftersales.excel.*;
@ -43,7 +42,6 @@ import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataStoreBusinessClient;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.distribution.feign.IDistributionDeliveryListClient;
import com.logpm.distribution.vo.DistributionDeliveryListVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
@ -70,7 +68,6 @@ import org.springblade.system.cache.DictBizCache;
import org.springblade.system.entity.DictBiz;
import org.springblade.system.entity.User;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.feign.IUserClient;
import org.springblade.system.feign.IUserSearchClient;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -2212,6 +2209,7 @@ public class AftersalesWorkOrderServiceImpl extends BaseServiceImpl<AftersalesWo
aftersaleSurveyRecordDTO.setStatus(1);
aftersaleSurveyRecordDTO.setIsDeleted(0);
aftersaleSurveyRecordDTO.setTypesOf("1");
aftersaleSurveyRecordDTO.setAddDepartment(myCurrentWarehouse.getName());
aftersaleSurveyRecordDTO.setContent(myCurrentWarehouse.getName() + "提交处理结果!");
aftersaleSurveyRecordDTO.setProcessingResults(myCurrentWarehouse.getName() + "提交了处理结果" + aftersalesProcessingResultsDTO.getResultType());
aftersaleSurveyRecordDTO.setDifference("3");

10
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataFactoryCategoryController.java

@ -4,13 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.basicdata.dto.BasicdataFactoryCategoryDTO;
import com.logpm.basicdata.entity.BasicdataFactoryCategoryEntity;
import com.logpm.basicdata.excel.BasicdataCategoryExcel;
import com.logpm.basicdata.excel.BasicdataCategoryImporter;
import com.logpm.basicdata.excel.BasicdataFactoryCategoryExcel;
import com.logpm.basicdata.excel.BasicdataFactoryCategoryImporter;
import com.logpm.basicdata.service.IBasicdataBrandService;
import com.logpm.basicdata.service.IBasicdataCategoryService;
import com.logpm.basicdata.service.IBasicdataFactoryCategoryService;
import com.logpm.basicdata.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
@ -37,6 +33,8 @@ public class BasicdataFactoryCategoryController extends BladeController {
private final IBasicdataFactoryCategoryService basicdataFactoryCategoryService;
private final IBasicdataBrandService basicdataBrandService;
private final IBasicdataCategoryService basicdataCategoryService;
private final IBasicdataMainCategoryService basicdataMainCategoryService;
private final IBasicdataMainService mainService;
@ResponseBody
@PostMapping("/pageList")
@ -115,7 +113,7 @@ public class BasicdataFactoryCategoryController extends BladeController {
@ApiOperationSupport(order = 12)
@ApiOperation(value = "导入品类", notes = "传入excel")
public R importCategory(MultipartFile file) {
BasicdataFactoryCategoryImporter basicdataFactoryCategoryImporter = new BasicdataFactoryCategoryImporter(basicdataFactoryCategoryService,basicdataBrandService,basicdataCategoryService);
BasicdataFactoryCategoryImporter basicdataFactoryCategoryImporter = new BasicdataFactoryCategoryImporter(basicdataFactoryCategoryService,basicdataBrandService,basicdataCategoryService,basicdataMainCategoryService,mainService);
ExcelUtil.save(file, basicdataFactoryCategoryImporter, BasicdataFactoryCategoryExcel.class);
return R.success("操作成功");
}

10
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataFactoryCategoryExcel.java

@ -21,7 +21,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ -41,6 +40,7 @@ public class BasicdataFactoryCategoryExcel implements Serializable {
private static final long serialVersionUID = 1L;
private Long factoryCategoryId;
@ColumnWidth(20)
@ExcelProperty("品牌")
@ -70,4 +70,12 @@ public class BasicdataFactoryCategoryExcel implements Serializable {
@ExcelProperty("物料名称")
private String materielName;
@ColumnWidth(20)
@ExcelProperty("主体名称")
private String mainName;
@ColumnWidth(20)
@ExcelProperty("主体品类")
private String mainCategory;
}

171
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/excel/BasicdataFactoryCategoryImporter.java

@ -1,22 +1,21 @@
package com.logpm.basicdata.excel;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.logpm.basicdata.entity.BasicdataBrandEntity;
import com.logpm.basicdata.entity.BasicdataCategoryEntity;
import com.logpm.basicdata.entity.BasicdataFactoryCategoryEntity;
import com.logpm.basicdata.service.IBasicdataBrandService;
import com.logpm.basicdata.service.IBasicdataCategoryService;
import com.logpm.basicdata.service.IBasicdataFactoryCategoryService;
import com.logpm.basicdata.entity.*;
import com.logpm.basicdata.service.*;
import lombok.AllArgsConstructor;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@AllArgsConstructor
public class BasicdataFactoryCategoryImporter implements ExcelImporter<BasicdataFactoryCategoryExcel> {
@ -24,6 +23,8 @@ public class BasicdataFactoryCategoryImporter implements ExcelImporter<Basicdata
private final IBasicdataFactoryCategoryService basicdataFactoryCategoryService;
private final IBasicdataBrandService basicdataBrandService;
private final IBasicdataCategoryService basicdataCategoryService;
private final IBasicdataMainCategoryService basicdataMainCategoryService;
private final IBasicdataMainService mainService;
@Transactional(rollbackFor = CustomerException.class)
@Override
@ -37,16 +38,41 @@ public class BasicdataFactoryCategoryImporter implements ExcelImporter<Basicdata
LambdaQueryWrapper<BasicdataCategoryEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BasicdataCategoryEntity::getIsDeleted, 0);
List<BasicdataCategoryEntity> basicdataCategoryEntities = basicdataCategoryService.list(lambdaQueryWrapper);
//把basicdataCategoryEntities转成以name为Key的Map
Map<String, BasicdataCategoryEntity> categoryMap = basicdataCategoryEntities.stream()
.collect(Collectors.toMap(BasicdataCategoryEntity::getName, entity -> entity));
LambdaQueryWrapper<BasicdataMainCategoryEntity> mainCategoryQueryWrapper = new LambdaQueryWrapper<>();
mainCategoryQueryWrapper.eq(BasicdataMainCategoryEntity::getIsDeleted, 0);
List<BasicdataMainCategoryEntity> basicdataMainCategoryEntities = basicdataMainCategoryService.list(mainCategoryQueryWrapper);
//把basicdataMainCategoryEntities通过factoryCategoryId进行分组
Map<Long, List<BasicdataMainCategoryEntity>> groupedByFactoryCategoryId = basicdataMainCategoryEntities.stream()
.collect(Collectors.groupingBy(BasicdataMainCategoryEntity::getFactoryCategoryId));
LambdaQueryWrapper<BasicdataMainEntity> mainqueryWrapper = new LambdaQueryWrapper<>();
mainqueryWrapper.eq(BasicdataMainEntity::getIsDeleted, 0);
List<BasicdataMainEntity> mainlist = mainService.list(mainqueryWrapper);
//把mainlist转成以name为Key的Map
Map<String, BasicdataMainEntity> mainMap = mainlist.stream()
.collect(Collectors.toMap(BasicdataMainEntity::getName, entity -> entity));
LambdaQueryWrapper<BasicdataFactoryCategoryEntity> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(BasicdataFactoryCategoryEntity::getIsDeleted, 0);
List<BasicdataFactoryCategoryEntity> allBasicdataFactoryCategoryEntities = basicdataFactoryCategoryService.list(lambdaQueryWrapper1);
//todo 这里的优化 是最好能进行品牌分组 获取对应的品牌数据 来进行匹配 这样可以减少循环次数
//把allBasicdataFactoryCategoryEntities转成以id为key的map
Map<Long, BasicdataFactoryCategoryEntity> allBasicdataFactoryCategoryEntityMap = allBasicdataFactoryCategoryEntities.stream()
.collect(Collectors.toMap(BasicdataFactoryCategoryEntity::getId, entity -> entity));
List<BasicdataFactoryCategoryExcel> newAddList = new ArrayList<>();
List<BasicdataFactoryCategoryEntity> basicdataFactoryCategoryEntities = new ArrayList<>();
for (BasicdataFactoryCategoryExcel datum : data) {
List<BasicdataMainCategoryEntity> newMainCategoryEntities = new ArrayList<>();
data.forEach(datum -> {
boolean isBrandFound = list.stream()
.anyMatch(entity -> entity.getBrandName().equals(datum.getBrand()));
@ -65,21 +91,123 @@ public class BasicdataFactoryCategoryImporter implements ExcelImporter<Basicdata
}
// 需要判断目前增加的三方物料在系统中是否已经存在
checkAllBasicdataFactoryCategoryEntities(allBasicdataFactoryCategoryEntities, datum);
Long factoryCategoryId = checkAllBasicdataFactoryCategoryEntities(allBasicdataFactoryCategoryEntities, datum);
if(Objects.isNull(factoryCategoryId)){
//如果没有id,需要存入三方品类信息存入和三方品类的主体映射需要存入
datum.setFactoryCategoryId(factoryCategoryId);
newAddList.add(datum);
}else{
String mainName = datum.getMainName();
String mainCategory1 = datum.getMainCategory();
List<BasicdataMainCategoryEntity> mainCategoryEntityList = groupedByFactoryCategoryId.get(factoryCategoryId);
//把mainCategoryEntityList转成以mainName为Key的Map
Map<String, BasicdataMainCategoryEntity> mainCategoryEntityMap = mainCategoryEntityList.stream()
.collect(Collectors.toMap(BasicdataMainCategoryEntity::getMainName, entity -> entity));
BasicdataMainCategoryEntity mainCategory = mainCategoryEntityMap.get(mainName);
if (Objects.isNull(mainCategory)){
mainCategory = new BasicdataMainCategoryEntity();
mainCategory.setFactoryCategoryId(factoryCategoryId);
}
mainCategory.setMainName(mainName);
BasicdataMainEntity basicdataMainEntity = mainMap.get(mainName);
if(!Objects.isNull(basicdataMainEntity)){
mainCategory.setMainId(basicdataMainEntity.getId());
}
BasicdataCategoryEntity basicdataCategoryEntity = categoryMap.get(mainCategory1);
if(!Objects.isNull(basicdataCategoryEntity)){
mainCategory.setCategoryId(basicdataCategoryEntity.getId());
}
mainCategory.setCategory(mainCategory1);
newMainCategoryEntities.add(mainCategory);
}
});
if(CollUtil.isNotEmpty(newAddList)){
//把newAddList通过buildEqualString2()方法返回值进行分组
Map<String, List<BasicdataFactoryCategoryExcel>> groupedByBuildEqualString2 = newAddList.stream()
.collect(Collectors.groupingBy(this::buildEqualString2));
groupedByBuildEqualString2.keySet().forEach(key -> {
List<BasicdataFactoryCategoryExcel> basicdataFactoryCategoryExcels = groupedByBuildEqualString2.get(key);
if(CollUtil.isNotEmpty(basicdataFactoryCategoryExcels)) {
BasicdataFactoryCategoryExcel basicdataFactoryCategoryExcel = basicdataFactoryCategoryExcels.get(0);
BasicdataFactoryCategoryEntity basicdataFactoryCategoryEntity = BeanUtil.copy(basicdataFactoryCategoryExcel, BasicdataFactoryCategoryEntity.class);
if (ObjectUtil.isNotEmpty(basicdataFactoryCategoryEntity)) {
assert basicdataFactoryCategoryEntity != null;
basicdataFactoryCategoryEntity.setBrandId(list.stream().filter(entity -> entity.getBrandName().equals(basicdataFactoryCategoryEntity.getBrand())).findFirst().get().getId());
basicdataFactoryCategoryEntity.setCategoryId(categoryMap.get(basicdataFactoryCategoryExcel.getCategory()).getId());
}
basicdataFactoryCategoryEntities.add(basicdataFactoryCategoryEntity);
BasicdataFactoryCategoryEntity basicdataFactoryCategoryEntity = BeanUtil.copy(datum, BasicdataFactoryCategoryEntity.class);
}
if (ObjectUtil.isNotEmpty(basicdataFactoryCategoryEntity)) {
assert basicdataFactoryCategoryEntity != null;
basicdataFactoryCategoryEntity.setBrandId(list.stream().filter(entity -> entity.getBrandName().equals(basicdataFactoryCategoryEntity.getBrand())).findFirst().get().getId());
basicdataFactoryCategoryEntity.setCategoryId(basicdataCategoryEntities.stream().filter(entity -> entity.getName().equals(basicdataFactoryCategoryEntity.getCategory())).findFirst().get().getId());
});
if(CollUtil.isNotEmpty(basicdataFactoryCategoryEntities)){
basicdataFactoryCategoryService.saveBatch(basicdataFactoryCategoryEntities);
}
basicdataFactoryCategoryEntities.add(basicdataFactoryCategoryEntity);
basicdataFactoryCategoryEntities.forEach(basicdataFactoryCategoryEntity -> {
Long factoryCategoryEntityId = basicdataFactoryCategoryEntity.getId();
String equestString = buildEqualString(basicdataFactoryCategoryEntity);
List<BasicdataFactoryCategoryExcel> basicdataFactoryCategoryExcels = groupedByBuildEqualString2.get(equestString);
if(CollUtil.isNotEmpty(basicdataFactoryCategoryExcels)){
basicdataFactoryCategoryExcels.forEach(basicdataFactoryCategoryExcel -> {
String mainName = basicdataFactoryCategoryExcel.getMainName();
String mainCategory1 = basicdataFactoryCategoryExcel.getMainCategory();
List<BasicdataMainCategoryEntity> mainCategoryEntityList = groupedByFactoryCategoryId.get(factoryCategoryEntityId);
//把mainCategoryEntityList转成以mainName为Key的Map
Map<String, BasicdataMainCategoryEntity> mainCategoryEntityMap = mainCategoryEntityList.stream()
.collect(Collectors.toMap(BasicdataMainCategoryEntity::getMainName, entity -> entity));
BasicdataMainCategoryEntity mainCategory = mainCategoryEntityMap.get(mainName);
if (Objects.isNull(mainCategory)){
mainCategory = new BasicdataMainCategoryEntity();
mainCategory.setFactoryCategoryId(factoryCategoryEntityId);
}
mainCategory.setMainName(mainName);
BasicdataMainEntity basicdataMainEntity = mainMap.get(mainName);
if(!Objects.isNull(basicdataMainEntity)){
mainCategory.setMainId(basicdataMainEntity.getId());
}
BasicdataCategoryEntity basicdataCategoryEntity = categoryMap.get(mainCategory1);
if(!Objects.isNull(basicdataCategoryEntity)){
mainCategory.setCategoryId(basicdataCategoryEntity.getId());
}
mainCategory.setCategory(mainCategory1);
newMainCategoryEntities.add(mainCategory);
});
}
});
}
if(CollUtil.isNotEmpty(newMainCategoryEntities)){
basicdataMainCategoryService.saveBatch(newMainCategoryEntities);
}
basicdataFactoryCategoryService.saveBatch(basicdataFactoryCategoryEntities);
}
@ -89,16 +217,17 @@ public class BasicdataFactoryCategoryImporter implements ExcelImporter<Basicdata
* @param allBasicdataFactoryCategoryEntities
* @param datum
*/
private void checkAllBasicdataFactoryCategoryEntities(List<BasicdataFactoryCategoryEntity> allBasicdataFactoryCategoryEntities, BasicdataFactoryCategoryExcel datum) {
private Long checkAllBasicdataFactoryCategoryEntities(List<BasicdataFactoryCategoryEntity> allBasicdataFactoryCategoryEntities, BasicdataFactoryCategoryExcel datum) {
for (BasicdataFactoryCategoryEntity allBasicdataFactoryCategoryEntity : allBasicdataFactoryCategoryEntities) {
String equalString = buildEqualString(allBasicdataFactoryCategoryEntity);
String equalString2 = buildEqualString2(datum);
if (equalString2.equals(equalString)) {
throw new CustomerException("品牌:" + datum.getBrand() + " 品类:" + datum.getCategory() + "已存在相同的配置内容");
// throw new CustomerException("品牌:" + datum.getBrand() + " 品类:" + datum.getCategory() + "已存在相同的配置内容");
// datum.setFactoryCategoryId(allBasicdataFactoryCategoryEntity.getId());
return allBasicdataFactoryCategoryEntity.getId();
}
}
return null;
}
/**

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java

@ -596,7 +596,7 @@ public class InComingServiceImpl implements IInComingService {
String a = audio.get();
if (StringUtil.isNotBlank(a)) {
return Resp.scanFail(200, a, a);
return Resp.scanFail(2001, a, a);
}
return R.success("入库成功");

8
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java

@ -1009,10 +1009,16 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
}
}
Integer typeService = basicdataClientEntity.getTypeService();
updateEntity.setMallId(consigneeId1);
updateEntity.setMallCode(basicdataClientEntity.getClientCode());
updateEntity.setMallName(basicdataClientEntity.getClientName());
updateEntity.setTypeService(basicdataClientEntity.getTypeService() + "");
updateEntity.setTypeService("1");
if(!Objects.isNull(typeService)){
updateEntity.setTypeService(basicdataClientEntity.getTypeService() + "");
}
updateEntity.setConsigneePerson(waybillEntity.getConsigneeName());
updateEntity.setConsigneeMobile(waybillEntity.getConsigneeMobile());
updateEntity.setConsigneeAddress(waybillEntity.getConsigneeAddress());

Loading…
Cancel
Save