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); 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); } } } 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"/> 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"); } } 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