导出TC数据
This commit is contained in:
parent
151539abb9
commit
123276fd98
@ -10,6 +10,7 @@ import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -27,5 +28,25 @@ public class TcDataQueryController {
|
||||
Map<String, List<EngineParamDetailPojo>> stringListHashMap = tcDataQueryService.tcDataSelectAllByPartsName(analysisRequest);
|
||||
return Response.ok().data(stringListHashMap);
|
||||
}
|
||||
//下载TC数据ads_prd_f_yfsjglpt_fdjlbjcjb
|
||||
@PostMapping("/syncA")
|
||||
public Response excelExportA(HttpServletResponse response) {
|
||||
try {
|
||||
tcDataQueryService.excelExportA(response);
|
||||
} catch (Exception e) {
|
||||
return Response.error("导出失败" + e.getMessage());
|
||||
}
|
||||
return Response.ok().data("导出成功");
|
||||
}
|
||||
//下载TC数据ads_prd_f_tc_flsxb
|
||||
@PostMapping("/syncB")
|
||||
public Response excelExportB(HttpServletResponse response) {
|
||||
try {
|
||||
tcDataQueryService.excelExportB(response);
|
||||
} catch (Exception e) {
|
||||
return Response.error("导出失败" + e.getMessage());
|
||||
}
|
||||
return Response.ok().data("导出成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xdap.self_development.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.definesys.mpaas.query.annotation.Table;
|
||||
import com.definesys.mpaas.query.model.MpaasBasePojo;
|
||||
import lombok.Data;
|
||||
@ -10,9 +11,12 @@ import lombok.EqualsAndHashCode;
|
||||
@Table("ads_prd_f_tc_flsxb")
|
||||
public class ClassificationAttribute extends MpaasBasePojo {
|
||||
//图号
|
||||
@ExcelProperty("PITEM_ID")
|
||||
private String pitemId;
|
||||
//参数名称
|
||||
@ExcelProperty("IDATTRTBUTEHAME")
|
||||
private String idattrtbutehame;
|
||||
//参数值
|
||||
@ExcelProperty("FIELDVALUE")
|
||||
private String fieldvalue;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xdap.self_development.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.definesys.mpaas.query.annotation.Table;
|
||||
import com.definesys.mpaas.query.model.MpaasBasePojo;
|
||||
import lombok.Data;
|
||||
@ -10,9 +11,12 @@ import lombok.EqualsAndHashCode;
|
||||
@Table("ads_prd_f_yfsjglpt_fdjlbjcjb")
|
||||
public class EnginePartsCollection extends MpaasBasePojo {
|
||||
// 状态机 -> 状态代号
|
||||
@ExcelProperty("ztj")
|
||||
private String ztj;
|
||||
// 零部件名称
|
||||
@ExcelProperty("lbjmc")
|
||||
private String lbjmc;
|
||||
// 零部件图号
|
||||
@ExcelProperty("lbjth")
|
||||
private String lbjth;
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.xdap.self_development.pojo.EngineParamDetailPojo;
|
||||
import com.xdap.self_development.pojo.Parameter;
|
||||
import com.xdap.self_development.pojo.dto.EngineParamDetailDTO;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -20,4 +21,7 @@ public interface TcDataQueryService {
|
||||
|
||||
Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest);
|
||||
|
||||
void excelExportA(HttpServletResponse response);
|
||||
|
||||
void excelExportB(HttpServletResponse response);
|
||||
}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
package com.xdap.self_development.service.impl;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.definesys.mpaas.query.MpaasQueryFactory;
|
||||
import com.xdap.self_development.config.BusinessDatabase;
|
||||
import com.xdap.self_development.controller.request.AnalysisRequest;
|
||||
import com.xdap.self_development.controller.request.EngineParamDetailExcel;
|
||||
import com.xdap.self_development.exception.ExcelImportException;
|
||||
import com.xdap.self_development.pojo.*;
|
||||
import com.xdap.self_development.pojo.dto.EngineParamDetailDTO;
|
||||
import com.xdap.self_development.service.DataEntryEngineModelService;
|
||||
@ -11,9 +16,13 @@ import com.xdap.self_development.service.TcDataQueryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.omg.CORBA.PRIVATE_MEMBER;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -84,6 +93,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
|
||||
|
||||
@Override
|
||||
public Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest) {
|
||||
long a = System.currentTimeMillis();
|
||||
String engineModelID = analysisRequest.getEngineModelID();
|
||||
|
||||
List<String> subsystemTypes = analysisRequest.getSubsystemParts();
|
||||
@ -162,7 +172,65 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
|
||||
}
|
||||
Map<String, List<EngineParamDetailPojo>> valueBySubSysName =
|
||||
allPojos.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName));
|
||||
long b = System.currentTimeMillis();
|
||||
throw new RuntimeException(String.valueOf(b - a));
|
||||
// return valueBySubSysName;
|
||||
}
|
||||
|
||||
return valueBySubSysName;
|
||||
@Override
|
||||
public void excelExportA(HttpServletResponse response) {
|
||||
|
||||
try {
|
||||
setupResponse(response, "参数值导入模板" + (new Date()));
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build()) {
|
||||
ArrayList<EnginePartsCollection> enginePartsCollections = new ArrayList<>();
|
||||
List<EnginePartsCollection> lbjmcs = bd.getTCDatabase()
|
||||
.doQuery(EnginePartsCollection.class);
|
||||
for (EnginePartsCollection parameter : lbjmcs) {
|
||||
EnginePartsCollection engineParamDetailExcel = new EnginePartsCollection();
|
||||
engineParamDetailExcel.setZtj(parameter.getZtj());
|
||||
engineParamDetailExcel.setLbjth(parameter.getLbjth());
|
||||
engineParamDetailExcel.setLbjmc(parameter.getLbjmc());
|
||||
enginePartsCollections.add(engineParamDetailExcel);
|
||||
}
|
||||
WriteSheet sheet = EasyExcel.writerSheet()
|
||||
.head(EnginePartsCollection.class) // 所有Sheet使用相同的表头
|
||||
.build();
|
||||
excelWriter.write(enginePartsCollections, sheet); // 写入数据,只生成表头
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excelExportB(HttpServletResponse response) {
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build()) {
|
||||
ArrayList<ClassificationAttribute> enginePartsCollections = new ArrayList<>();
|
||||
List<ClassificationAttribute> lbjmcs = bd.getTCDatabase()
|
||||
.doQuery(ClassificationAttribute.class);
|
||||
for (ClassificationAttribute parameter : lbjmcs) {
|
||||
ClassificationAttribute engineParamDetailExcel = new ClassificationAttribute();
|
||||
engineParamDetailExcel.setFieldvalue(parameter.getFieldvalue());
|
||||
engineParamDetailExcel.setIdattrtbutehame(parameter.getIdattrtbutehame());
|
||||
engineParamDetailExcel.setPitemId(parameter.getPitemId());
|
||||
enginePartsCollections.add(engineParamDetailExcel);
|
||||
}
|
||||
WriteSheet sheet = EasyExcel.writerSheet()
|
||||
.head(ClassificationAttribute.class) // 所有Sheet使用相同的表头
|
||||
.build();
|
||||
excelWriter.write(enginePartsCollections, sheet); // 写入数据,只生成表头
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupResponse(HttpServletResponse response, String fileName) throws IOException {
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + encodedFileName + ".xlsx");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user