格式化代码
This commit is contained in:
parent
7690f14c0d
commit
a995d08f6f
@ -4,8 +4,9 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 输出信息对象
|
||||
* @author tajochen
|
||||
*
|
||||
* @param <T>
|
||||
* @author tajochen
|
||||
*/
|
||||
public class EncapsulationObejct<T> implements Serializable {
|
||||
|
||||
@ -50,10 +51,6 @@ public class EncapsulationObejct<T> implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EncapsulationObejct{" +
|
||||
"status=" + status +
|
||||
", msg='" + msg + '\'' +
|
||||
", data=" + data +
|
||||
'}';
|
||||
return "EncapsulationObejct{" + "status=" + status + ", msg='" + msg + '\'' + ", data=" + data + '}';
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 输出信息封装
|
||||
*
|
||||
* @author tajochen
|
||||
*/
|
||||
@Component
|
||||
@ -30,6 +31,7 @@ public class OutputEncapsulation {
|
||||
|
||||
/**
|
||||
* 读取多国语言文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static MessageSource messageSource() {
|
||||
@ -50,6 +52,7 @@ public class OutputEncapsulation {
|
||||
|
||||
/**
|
||||
* 封装输出数据
|
||||
*
|
||||
* @param promptMessageEnum
|
||||
* @param obj
|
||||
* @return
|
||||
@ -82,6 +85,7 @@ public class OutputEncapsulation {
|
||||
|
||||
/**
|
||||
* 输出请求值检验错误信息
|
||||
*
|
||||
* @param fieldErrors
|
||||
* @return
|
||||
*/
|
||||
|
@ -143,16 +143,6 @@ public class FileEntity {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileEntity{" +
|
||||
"id=" + id +
|
||||
", lotNo='" + lotNo + '\'' +
|
||||
", machineNo='" + machineNo + '\'' +
|
||||
", materialNo='" + materialNo + '\'' +
|
||||
", modelNo='" + modelNo + '\'' +
|
||||
", machineTypeNo='" + machineTypeNo + '\'' +
|
||||
", craftItemName='" + craftItemName + '\'' +
|
||||
", fileUploadPath='" + fileUploadPath + '\'' +
|
||||
", fileDownloadPath='" + fileDownloadPath + '\'' +
|
||||
'}';
|
||||
return "FileEntity{" + "id=" + id + ", lotNo='" + lotNo + '\'' + ", machineNo='" + machineNo + '\'' + ", materialNo='" + materialNo + '\'' + ", modelNo='" + modelNo + '\'' + ", machineTypeNo='" + machineTypeNo + '\'' + ", craftItemName='" + craftItemName + '\'' + ", fileUploadPath='" + fileUploadPath + '\'' + ", fileDownloadPath='" + fileDownloadPath + '\'' + '}';
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.xkrs.model.qo.FileQo;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@ -15,6 +14,7 @@ public interface FileService {
|
||||
|
||||
/**
|
||||
* 添加模板信息
|
||||
*
|
||||
* @param fileQo
|
||||
* @return
|
||||
*/
|
||||
@ -22,6 +22,7 @@ public interface FileService {
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param fileQo
|
||||
* @return
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.xkrs.service.impl;
|
||||
|
||||
import com.xkrs.dao.FileDao;
|
||||
import com.xkrs.dao.QcSourceDao;
|
||||
import com.xkrs.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.model.entity.FileEntity;
|
||||
import com.xkrs.model.qo.FileQo;
|
||||
@ -29,8 +30,8 @@ public class FileServiceImpl implements FileService {
|
||||
@Resource
|
||||
private FileDao fileDao;
|
||||
|
||||
// @Resource
|
||||
// private DataSourceQuery dataSourceQuery;
|
||||
@Resource
|
||||
private QcSourceDao qcSourceDao;
|
||||
|
||||
/**
|
||||
* 添加模板信息
|
||||
@ -75,29 +76,28 @@ public class FileServiceImpl implements FileService {
|
||||
@Transactional(rollbackOn = Exception.class)
|
||||
@Override
|
||||
public String exportExcel(FileQo fileQo) throws IOException, InvalidFormatException {
|
||||
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);
|
||||
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<Map<String, Object>> resultList = qcSourceDao.queryQcSource(lotNo, machineNo, materialNo, modelNo, machineTypeNo);
|
||||
if (resultList == null || resultList.size() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该产品的信息!", locale);
|
||||
}
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (Map<String, Object> result : resultList) {
|
||||
map.put((String) result.get("qcItemNo"), (String) result.get("qcValue"));
|
||||
}
|
||||
String fill = ExportExcel.exportToProveExcel(map, fileUploadPath);
|
||||
fileDao.updateFileDownloadPath(lotNo, machineNo, materialNo, modelNo, machineTypeNo, craftItemName, fill);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, fill, locale);
|
||||
}
|
||||
}
|
||||
|
@ -39,17 +39,17 @@ public class ExcelUploadUtil {
|
||||
String suffix = originalFilename.substring(index);
|
||||
//uuid生成新的文件名
|
||||
String newName = UUID.randomUUID().toString() + suffix;
|
||||
File file = new File("/Users/liuchengqian/Desktop/DaJiang/" + subDir);
|
||||
// File file = new File("/home/sxy/server/industrial_measurement/" + subDir);
|
||||
// File file = new File("/Users/liuchengqian/Desktop/DaJiang/" + subDir);
|
||||
File file = new File("/home/sxy/server/industrial_measurement/" + subDir);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
String path = "/Users/liuchengqian/Desktop/DaJiang/" + subDir + newName;
|
||||
// String path = "/home/sxy/server/industrial_measurement/" + subDir + newName;
|
||||
// String path = "/Users/liuchengqian/Desktop/DaJiang/" + subDir + newName;
|
||||
String path = "/home/sxy/server/industrial_measurement/" + subDir + newName;
|
||||
//实现上传
|
||||
fileInput.transferTo(new File(path));
|
||||
return path;
|
||||
// return subDir + newName;
|
||||
// return path;
|
||||
return subDir + newName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2,7 +2,8 @@ package com.xkrs.util;
|
||||
|
||||
import net.sf.jxls.transformer.XLSTransformer;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import java.io.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -39,8 +40,6 @@ public class ExportExcel {
|
||||
return "http://118.24.27.47:2088/excel/"+s;
|
||||
//return "http://192.168.2.139/"+s;
|
||||
}*/
|
||||
|
||||
|
||||
public static String exportToProveExcel(Map<String, String> dataMap, String srcFilePath) throws IOException, InvalidFormatException {
|
||||
String s = System.currentTimeMillis() + ".xlsx";
|
||||
//String path = "E:/shop/"+s;
|
||||
|
Loading…
Reference in New Issue
Block a user