Browse Source

修改库存导入时bug

lwx_dev
erdanergou 3 years ago
parent
commit
a18f328b45
  1. 20
      src/main/java/com/dreamchaser/depository_manage/converter/ExcelDepositoryInfoConverter.java
  2. 1
      src/main/java/com/dreamchaser/depository_manage/service/DepositoryService.java
  3. 21
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

20
src/main/java/com/dreamchaser/depository_manage/converter/ExcelDepositoryInfoConverter.java

@ -23,11 +23,10 @@ import java.util.List;
@Component
public class ExcelDepositoryInfoConverter implements Converter<Integer> {
private static ExcelDepositoryInfoConverter excelDepositoryInfoConverter;
@Autowired
private DepositoryService depositoryService;
private static ExcelDepositoryInfoConverter excelDepositoryInfoConverter;
@Override
public Class supportJavaTypeKey() {
return Integer.class;
@ -40,12 +39,10 @@ public class ExcelDepositoryInfoConverter implements Converter<Integer> {
@Override
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
List<Depository> depositoryAll = excelDepositoryInfoConverter.depositoryService.findDepositoryAll();
Integer data = 0;
for (int i = 0; i < depositoryAll.size(); i++) {
if(cellData.getStringValue().equals(depositoryAll.get(i).getCode())){
data = depositoryAll.get(i).getId();
}
Depository depository = excelDepositoryInfoConverter.depositoryService.findDepositoryByCode(cellData.getStringValue());
if (depository != null) {
data = depository.getId();
}
if (data == 0) {
throw new RuntimeException("没有该仓库");
@ -55,13 +52,12 @@ public class ExcelDepositoryInfoConverter implements Converter<Integer> {
@Override
public WriteCellData<String> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
List<Depository> depositoryAll = excelDepositoryInfoConverter.depositoryService.findDepositoryAll();
Depository depository = excelDepositoryInfoConverter.depositoryService.findDepositoryById(value);
String data = "";
for (int i = 0; i < depositoryAll.size(); i++) {
if(Integer.compare(value,depositoryAll.get(i).getId()) == 0){
data = depositoryAll.get(i).getCode();
}
if(depository != null) {
data = depository.getCode();
}
return new WriteCellData<>(data);
}

1
src/main/java/com/dreamchaser/depository_manage/service/DepositoryService.java

@ -96,6 +96,7 @@ public interface DepositoryService {
List<Depository> findDepositoryAll();
/**
* 根据主键id将仓库状态改为删除
* @param id

21
src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

@ -158,9 +158,11 @@ public class ExcelServiceImpl implements ExcelService {
errMsg.addAll(strings);
}
}
System.out.println(ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber()).size());
readResult.put("dataList", ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber()));
List<ExcelInfoForMaterial> userExcelMaterialInfo = ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber());
if(userExcelMaterialInfo == null){
userExcelMaterialInfo = new ArrayList<>();
}
readResult.put("dataList", userExcelMaterialInfo);
// 4.2删除临时文件
boolean deleteFile = FileUtil.deleteFile(new File(filePath));
@ -269,7 +271,12 @@ public class ExcelServiceImpl implements ExcelService {
}
}
readResult.put("dataList", ExcelFileInfoPool.getUserExcelMaterialTypeInfo(userByPort.getNumber()));
List<ExcelInfoByMT> userExcelMaterialTypeInfo = ExcelFileInfoPool.getUserExcelMaterialTypeInfo(userByPort.getNumber());
if(userExcelMaterialTypeInfo == null){
userExcelMaterialTypeInfo = new ArrayList<>();
}
readResult.put("dataList", userExcelMaterialTypeInfo);
// 4.2删除临时文件
@ -382,7 +389,11 @@ public class ExcelServiceImpl implements ExcelService {
}
readResult.put("dataList", ExcelFileInfoPool.getUserExcelInventoryInfo(userByPort.getNumber()));
List<ExcelInfoByInventory> userExcelInventoryInfo = ExcelFileInfoPool.getUserExcelInventoryInfo(userByPort.getNumber());
if(userExcelInventoryInfo == null){
userExcelInventoryInfo = new ArrayList<>();
}
readResult.put("dataList", userExcelInventoryInfo);
// 4.2删除临时文件
boolean deleteFile = FileUtil.deleteFile(new File(filePath));

Loading…
Cancel
Save