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