Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjh 2025-12-18 11:07:01 +08:00
commit f7e5813d5b
5 changed files with 102 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -27,5 +28,25 @@ public class TcDataQueryController {
Map<String, List<EngineParamDetailPojo>> stringListHashMap = tcDataQueryService.tcDataSelectAllByPartsName(analysisRequest); Map<String, List<EngineParamDetailPojo>> stringListHashMap = tcDataQueryService.tcDataSelectAllByPartsName(analysisRequest);
return Response.ok().data(stringListHashMap); 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("导出成功");
}
} }

View File

@ -1,5 +1,6 @@
package com.xdap.self_development.pojo; package com.xdap.self_development.pojo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.definesys.mpaas.query.annotation.Table; import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo; import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.Data; import lombok.Data;
@ -10,9 +11,12 @@ import lombok.EqualsAndHashCode;
@Table("ads_prd_f_tc_flsxb") @Table("ads_prd_f_tc_flsxb")
public class ClassificationAttribute extends MpaasBasePojo { public class ClassificationAttribute extends MpaasBasePojo {
//图号 //图号
@ExcelProperty("PITEM_ID")
private String pitemId; private String pitemId;
//参数名称 //参数名称
@ExcelProperty("IDATTRTBUTEHAME")
private String idattrtbutehame; private String idattrtbutehame;
//参数值 //参数值
@ExcelProperty("FIELDVALUE")
private String fieldvalue; private String fieldvalue;
} }

View File

@ -1,5 +1,6 @@
package com.xdap.self_development.pojo; package com.xdap.self_development.pojo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.definesys.mpaas.query.annotation.Table; import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo; import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.Data; import lombok.Data;
@ -10,9 +11,12 @@ import lombok.EqualsAndHashCode;
@Table("ads_prd_f_yfsjglpt_fdjlbjcjb") @Table("ads_prd_f_yfsjglpt_fdjlbjcjb")
public class EnginePartsCollection extends MpaasBasePojo { public class EnginePartsCollection extends MpaasBasePojo {
// 状态机 -> 状态代号 // 状态机 -> 状态代号
@ExcelProperty("ztj")
private String ztj; private String ztj;
// 零部件名称 // 零部件名称
@ExcelProperty("lbjmc")
private String lbjmc; private String lbjmc;
// 零部件图号 // 零部件图号
@ExcelProperty("lbjth")
private String lbjth; private String lbjth;
} }

View File

@ -7,6 +7,7 @@ import com.xdap.self_development.pojo.EngineParamDetailPojo;
import com.xdap.self_development.pojo.Parameter; import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.pojo.dto.EngineParamDetailDTO; import com.xdap.self_development.pojo.dto.EngineParamDetailDTO;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -20,4 +21,7 @@ public interface TcDataQueryService {
Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest); Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest);
void excelExportA(HttpServletResponse response);
void excelExportB(HttpServletResponse response);
} }

View File

@ -1,8 +1,13 @@
package com.xdap.self_development.service.impl; 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.definesys.mpaas.query.MpaasQueryFactory;
import com.xdap.self_development.config.BusinessDatabase; import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.controller.request.AnalysisRequest; 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.*;
import com.xdap.self_development.pojo.dto.EngineParamDetailDTO; import com.xdap.self_development.pojo.dto.EngineParamDetailDTO;
import com.xdap.self_development.service.DataEntryEngineModelService; import com.xdap.self_development.service.DataEntryEngineModelService;
@ -11,9 +16,13 @@ import com.xdap.self_development.service.TcDataQueryService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.omg.CORBA.PRIVATE_MEMBER; import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -84,6 +93,7 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
@Override @Override
public Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest) { public Map<String, List<EngineParamDetailPojo>> tcDataSelectAllByPartsName(AnalysisRequest analysisRequest) {
long a = System.currentTimeMillis();
String engineModelID = analysisRequest.getEngineModelID(); String engineModelID = analysisRequest.getEngineModelID();
List<String> subsystemTypes = analysisRequest.getSubsystemParts(); List<String> subsystemTypes = analysisRequest.getSubsystemParts();
@ -162,7 +172,65 @@ public class TcDataQueryServiceImpl implements TcDataQueryService {
} }
Map<String, List<EngineParamDetailPojo>> valueBySubSysName = Map<String, List<EngineParamDetailPojo>> valueBySubSysName =
allPojos.stream().collect(Collectors.groupingBy(EngineParamDetailPojo::getSubsystemName)); 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");
} }
} }