Merge branch 'develop_3' into 'develop_master'
Develop 3 See merge request LiuChao/foton-slrs-system-rest!231
This commit is contained in:
@@ -25,6 +25,9 @@ public class Analysis {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Contrast.class);
|
||||
|
||||
private int sortColumn=0;
|
||||
|
||||
|
||||
public void run(MultipartFile file, MultipartFile sort) throws IOException {
|
||||
|
||||
InputStream inputStream = file.getInputStream();
|
||||
@@ -37,7 +40,7 @@ public class Analysis {
|
||||
for (Row row : sheet) {
|
||||
if (row.getCell(1)!=null){
|
||||
//获取表1的标准号
|
||||
String value = row.getCell(1).toString().trim();
|
||||
String value = row.getCell(1).toString();
|
||||
Cell sortCell = row.createCell(11);
|
||||
Cell sortNumber = row.createCell(12);
|
||||
Cell sortYear = row.createCell(13);
|
||||
@@ -96,13 +99,24 @@ public class Analysis {
|
||||
}
|
||||
}
|
||||
}
|
||||
File result = new File("C:\\Users\\22501\\Desktop\\foton标准数据\\拆分标准号-海外.xlsx");
|
||||
File result = new File("C:\\Users\\22501\\Desktop\\foton标准数据\\拆分标准号-企标.xlsx");
|
||||
FileOutputStream os = new FileOutputStream(result);
|
||||
workbook.write(os);
|
||||
// HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setSortColumn(int sortColumn){
|
||||
this.sortColumn=sortColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标准类别set集合
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private HashSet<String> getSet(MultipartFile file) throws IOException {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||
@@ -114,8 +128,8 @@ public class Analysis {
|
||||
HashSet<String> stringHashSet= new HashSet<>();
|
||||
|
||||
for (Row row : sheet) {
|
||||
if (row.getCell(0)!=null){
|
||||
stringHashSet.add(row.getCell(0).toString().trim());
|
||||
if (row.getCell(sortColumn)!=null){
|
||||
stringHashSet.add(row.getCell(sortColumn).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.adc.da.slrs.ImportExcelDatas.comment;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
@Component
|
||||
public class Contrast {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Contrast.class);
|
||||
|
||||
public void run(MultipartFile file,MultipartFile sort) throws IOException {
|
||||
|
||||
InputStream inputStream = file.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
HashSet<String> set = getSet(sort);
|
||||
for (Row row : sheet) {
|
||||
if (row.getCell(0)!=null){
|
||||
//获取表1的标准号
|
||||
String value = row.getCell(0).toString().trim();
|
||||
Cell cell = row.createCell(11);
|
||||
|
||||
//对比在表2中是否存在
|
||||
if (set.contains(value.trim())){
|
||||
logger.info("*");
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue("1");
|
||||
}else {
|
||||
logger.info("-");
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue("0");
|
||||
}
|
||||
}
|
||||
}
|
||||
File result = new File("C:\\Users\\22501\\Desktop\\foton标准数据\\海外对比全数据.xlsx");
|
||||
FileOutputStream os = new FileOutputStream(result);
|
||||
workbook.write(os);
|
||||
// HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
private HashSet<String> getSet(MultipartFile file) throws IOException {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
||||
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
// int lastNum = sheet.getLastRowNum();
|
||||
|
||||
HashSet<String> stringHashSet= new HashSet<>();
|
||||
|
||||
for (Row row : sheet) {
|
||||
if (row.getCell(1)!=null){
|
||||
stringHashSet.add(row.getCell(1).toString().trim());
|
||||
}
|
||||
}
|
||||
|
||||
return stringHashSet;
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -152,6 +152,7 @@ public class ImportExcelController extends BaseController<ImportDto> {
|
||||
@PostMapping("/analysis")
|
||||
public void analysis(MultipartFile exclFile,MultipartFile standSort) throws IOException {
|
||||
Analysis analysis = new Analysis();
|
||||
analysis.setSortColumn(1);
|
||||
analysis.run(exclFile,standSort);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -6,6 +6,7 @@ import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarStandUnqualified.entity.BusinessDeptIssue;
|
||||
import com.adc.da.slrs.sarStandUnqualified.entity.BusinessDeptIssueVo;
|
||||
import com.adc.da.slrs.sarStandUnqualified.service.IBusinessDeptIssueService;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -91,10 +92,15 @@ public class BusinessDeptIssueController extends BaseController {
|
||||
}
|
||||
String fileName = URLEncoder.encode(issue.getFileName(), "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
// List<SarStandUnqualified> data=sarStandUnqualifiedService.getStandUnqualifiedExcelData(standUnqualifiedExcelVO);
|
||||
|
||||
|
||||
/**
|
||||
* 重写了get方法,无法使用net.sf.json.JSONObject转换对象
|
||||
*/
|
||||
// net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(issue.getExportContent());
|
||||
// BusinessDeptIssueVo businessDeptIssueVo = (BusinessDeptIssueVo) net.sf.json.JSONObject.toBean(jsonObject, BusinessDeptIssueVo.class);
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(issue.getExportContent());
|
||||
|
||||
BusinessDeptIssueVo businessDeptIssueVo = JSONObject.toJavaObject(jsonObject, BusinessDeptIssueVo.class);
|
||||
IPage<BusinessDeptIssue> page = iBusinessDeptIssueService.getBusinessDeptIssue(businessDeptIssueVo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user