From 8d9286db8d1388019ffd326fc17f36f78080b594 Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期六, 14 九月 2024 15:46:57 +0800
Subject: [PATCH] export device no
---
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanCtrl.java | 25 +++++++++++-
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java | 2 +
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java | 3 +
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/QrCodeUtil.java | 29 ++++++++++++++
pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml | 6 +++
5 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java
index b0ff8ec..4f99b90 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java
@@ -43,6 +43,8 @@
List<JSONObject> selectByPlanName(@Param("planName") String planName);
+ PrAssemblyPlan selectByBatchId(@Param("batchId") Long batchId);
+
List<JSONObject> queryPlanList();
List<PrAssemblyPlan> selectAssyPlanList(PrAssemblyPlan params);
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/QrCodeUtil.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/QrCodeUtil.java
index b14a3ae..c259586 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/QrCodeUtil.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/util/QrCodeUtil.java
@@ -85,4 +85,33 @@
log.error("瀵煎嚭{}寮傚父",sheetName,e);
}
}
+ public static void downloadExcelSheets(HttpServletResponse response, String fileName, String sheetName, List<Converter> list){
+ if(CollectionUtils.isEmpty(list)){
+ return;
+ }
+ /*try(ExcelWriter excelWriter = EasyExcel.write(file).build()) {
+ WriteSheet writeSheet;
+ for (SheetInfoBean bean : sheetInfoList) {
+ // 鏋勫缓sheet瀵硅薄
+ writeSheet = EasyExcel.writerSheet(bean.getSheetName()).head(bean.getHeadClass()).build();
+ // 鍐欏嚭sheet鏁版嵁
+ excelWriter.write(bean.getDataList(), writeSheet);
+ }
+ // 鍏虫祦
+ excelWriter.finish();
+ } catch (Exception e) {
+ // do something you want
+ }*/
+ try{
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setCharacterEncoding("utf-8");
+ fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+ EasyExcel.write(response.getOutputStream(), list.get(0).getClass()).sheet(sheetName).doWrite(list);
+ }catch (Exception e){
+ log.error("瀵煎嚭{}寮傚父",sheetName,e);
+ }
+ }
+
+
}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
index 889e130..6531127 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml
@@ -104,6 +104,12 @@
from pr_assembly_plan
where id = #{id}
</select>
+ <select id="selectByBatchId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List"/>
+ from pr_assembly_plan
+ where batch_id = #{batchId,jdbcType=BIGINT}
+ </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanCtrl.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanCtrl.java
index 02566d8..7dfb822 100644
--- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanCtrl.java
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanCtrl.java
@@ -129,7 +129,7 @@
@GetMapping(path="exportDevice")
@SsoPowerAop(power = "10200001")
- @Log("瀵煎嚭璁惧鍙�")
+ @Log("瀵煎嚭璁惧鍙峰強浜岀淮鐮�")
public void exportDevice(Long batchId, HttpServletResponse response){
Date start = new Date() ;
List<Converter> list = new ArrayList<>();
@@ -146,8 +146,29 @@
}
list.add(vo);
});
- log.info("瀵煎嚭璁惧鍙疯�楁椂锛�"+(new Date().getTime()-start.getTime())+"ms");
+ log.info("瀵煎嚭璁惧鍙峰強浜岀淮鐮佽�楁椂锛�"+(new Date().getTime()-start.getTime())+"ms");
QrCodeUtil.downloadExcel(response, fileName,sheetName,list);
+ log.info("瀵煎嚭璁惧鍙峰強浜岀淮鐮佽�楁椂锛�"+(new Date().getTime()-start.getTime())+"ms");
+ }
+ @GetMapping(path="exportDeviceNo")
+ @SsoPowerAop(power = "10200001")
+ @Log("瀵煎嚭璁惧鍙�")
+ public void exportDeviceNo(Long batchId, HttpServletResponse response){
+ Date start = new Date() ;
+ List<Converter> list = new ArrayList<>();
+
+ List<PrDevice> deviceList = sv.selectDeviceByBatchId(batchId) ;
+ // 浣跨敤骞惰娴佹彁楂樻�ц兘
+ deviceList.parallelStream().forEach(device -> {
+ ExcelDeviceNoVo vo = new ExcelDeviceNoVo();
+ vo.deviceNo = device.deviceNo;
+ list.add(vo);
+ });
+ //鏍规嵁batchid鎵惧埌浠诲姟鍚嶇О
+ PrAssemblyPlan plan = sv.selectByBatchId(batchId);
+ String fileNameStr = plan.name +"-"+ fileName;
+ log.info("瀵煎嚭璁惧鍙疯�楁椂锛�"+(new Date().getTime()-start.getTime())+"ms");
+ QrCodeUtil.downloadExcel(response, fileNameStr,sheetName,list);
log.info("瀵煎嚭璁惧鍙疯�楁椂锛�"+(new Date().getTime()-start.getTime())+"ms");
}
}
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
index 0d8501b..23782ce 100644
--- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
@@ -268,6 +268,9 @@
return deviceDao.selectByBatchId(batchId);
}
+ public PrAssemblyPlan selectByBatchId(Long batchId){
+ return assemblyDao.selectByBatchId(batchId);
+ }
/**
* 鍙洿鏂扮姸鎬�,涓嶆洿鏂板叾浠栧瓧娈�
* @param plan
--
Gitblit v1.8.0