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 @Component
public class ExcelDepositoryInfoConverter implements Converter<Integer> { public class ExcelDepositoryInfoConverter implements Converter<Integer> {
private static ExcelDepositoryInfoConverter excelDepositoryInfoConverter;
@Autowired @Autowired
private DepositoryService depositoryService; private DepositoryService depositoryService;
private static ExcelDepositoryInfoConverter excelDepositoryInfoConverter;
@Override @Override
public Class supportJavaTypeKey() { public Class supportJavaTypeKey() {
return Integer.class; return Integer.class;
@ -40,12 +39,10 @@ public class ExcelDepositoryInfoConverter implements Converter<Integer> {
@Override @Override
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
List<Depository> depositoryAll = excelDepositoryInfoConverter.depositoryService.findDepositoryAll();
Integer data = 0; Integer data = 0;
for (int i = 0; i < depositoryAll.size(); i++) { Depository depository = excelDepositoryInfoConverter.depositoryService.findDepositoryByCode(cellData.getStringValue());
if(cellData.getStringValue().equals(depositoryAll.get(i).getCode())){ if (depository != null) {
data = depositoryAll.get(i).getId(); data = depository.getId();
}
} }
if (data == 0) { if (data == 0) {
throw new RuntimeException("没有该仓库"); throw new RuntimeException("没有该仓库");
@ -55,13 +52,12 @@ public class ExcelDepositoryInfoConverter implements Converter<Integer> {
@Override @Override
public WriteCellData<String> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { 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 = ""; String data = "";
for (int i = 0; i < depositoryAll.size(); i++) { if(depository != null) {
if(Integer.compare(value,depositoryAll.get(i).getId()) == 0){ data = depository.getCode();
data = depositoryAll.get(i).getCode();
}
} }
return new WriteCellData<>(data); 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(); List<Depository> findDepositoryAll();
/** /**
* 根据主键id将仓库状态改为删除 * 根据主键id将仓库状态改为删除
* @param 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); errMsg.addAll(strings);
} }
} }
System.out.println(ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber()).size()); List<ExcelInfoForMaterial> userExcelMaterialInfo = ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber());
if(userExcelMaterialInfo == null){
readResult.put("dataList", ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber())); userExcelMaterialInfo = new ArrayList<>();
}
readResult.put("dataList", userExcelMaterialInfo);
// 4.2删除临时文件 // 4.2删除临时文件
boolean deleteFile = FileUtil.deleteFile(new File(filePath)); 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删除临时文件 // 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删除临时文件 // 4.2删除临时文件
boolean deleteFile = FileUtil.deleteFile(new File(filePath)); boolean deleteFile = FileUtil.deleteFile(new File(filePath));

Loading…
Cancel
Save