重构
This commit is contained in:
@ -2,11 +2,9 @@ package com.xkrs.service.impl;
|
||||
|
||||
import com.xkrs.dao.FileDao;
|
||||
import com.xkrs.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.model.entity.DataSource;
|
||||
import com.xkrs.model.entity.FileEntity;
|
||||
import com.xkrs.model.qo.FileQo;
|
||||
import com.xkrs.service.FileService;
|
||||
import com.xkrs.util.DataSourceQuery;
|
||||
import com.xkrs.util.ExcelUploadUtil;
|
||||
import com.xkrs.util.ExportExcel;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
@ -31,8 +29,8 @@ public class FileServiceImpl implements FileService {
|
||||
@Resource
|
||||
private FileDao fileDao;
|
||||
|
||||
@Resource
|
||||
private DataSourceQuery dataSourceQuery;
|
||||
// @Resource
|
||||
// private DataSourceQuery dataSourceQuery;
|
||||
|
||||
/**
|
||||
* 添加模板信息
|
||||
@ -77,28 +75,29 @@ public class FileServiceImpl implements FileService {
|
||||
@Transactional(rollbackOn = Exception.class)
|
||||
@Override
|
||||
public String exportExcel(FileQo fileQo) throws IOException, InvalidFormatException {
|
||||
String lotNo = fileQo.getLotNo();
|
||||
String machineNo = fileQo.getMachineNo();
|
||||
String materialNo = fileQo.getMaterialNo();
|
||||
String modelNo = fileQo.getModelNo();
|
||||
String machineTypeNo = fileQo.getMachineTypeNo();
|
||||
String craftItemName = fileQo.getCraftItemName();
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Optional<FileEntity> fileEntity = fileDao.selectFile(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
|
||||
if (fileEntity.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的模板,请添加!", locale);
|
||||
}
|
||||
String fileUploadPath = fileEntity.get().getFileUploadPath();
|
||||
List<DataSource> dataSources = dataSourceQuery.selectDataSource(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
|
||||
if (dataSources == null || dataSources.size() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的信息!", locale);
|
||||
}
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (DataSource dataSource : dataSources) {
|
||||
map.put(dataSource.getInspectionItemCode(), dataSource.getInspectValue());
|
||||
}
|
||||
String fill = ExportExcel.exportToProveExcel(map, fileUploadPath);
|
||||
fileDao.updateFileDownloadPath(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName, fill);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, fill, locale);
|
||||
return null;
|
||||
// String lotNo = fileQo.getLotNo();
|
||||
// String machineNo = fileQo.getMachineNo();
|
||||
// String materialNo = fileQo.getMaterialNo();
|
||||
// String modelNo = fileQo.getModelNo();
|
||||
// String machineTypeNo = fileQo.getMachineTypeNo();
|
||||
// String craftItemName = fileQo.getCraftItemName();
|
||||
// Locale locale = LocaleContextHolder.getLocale();
|
||||
// Optional<FileEntity> fileEntity = fileDao.selectFile(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
|
||||
// if (fileEntity.isEmpty()) {
|
||||
// return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的模板,请添加!", locale);
|
||||
// }
|
||||
// String fileUploadPath = fileEntity.get().getFileUploadPath();
|
||||
// List<DataSource> dataSources = dataSourceQuery.selectDataSource(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName);
|
||||
// if (dataSources == null || dataSources.size() == 0) {
|
||||
// return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的信息!", locale);
|
||||
// }
|
||||
// Map<String, String> map = new HashMap<>();
|
||||
// for (DataSource dataSource : dataSources) {
|
||||
// map.put(dataSource.getInspectionItemCode(), dataSource.getInspectValue());
|
||||
// }
|
||||
// String fill = ExportExcel.exportToProveExcel(map, fileUploadPath);
|
||||
// fileDao.updateFileDownloadPath(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName, fill);
|
||||
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, fill, locale);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user