企业官网建站费用,企业邮箱是干嘛用的,青岛网站建设公司大全,建设一个网站需要做哪些工作1、在windows系统下启动rocketmq操作#xff1a; 在bin目录下使用cmd 分别输入 start mqnamesrv.cmd start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnabletrue
2、在stream流中需要new对象时#xff0c;可能会出现new很多对象堆积在堆中#xff0c;这是需要用try,…1、在windows系统下启动rocketmq操作 在bin目录下使用cmd 分别输入 start mqnamesrv.cmd start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnabletrue
2、在stream流中需要new对象时可能会出现new很多对象堆积在堆中这是需要用try,finally在finally中将new的对象为null并用gc收集 如下
ListChildModelParamDTO childModelParamDTOS childModels.stream().map(childModel - {ChildModelParamDTO childModelParamDTOnew ChildModelParamDTO();try {LambdaQueryWrapperPredictionModelParam eq1 new QueryWrapperPredictionModelParam().lambda().eq(PredictionModelParam::getPredictionModelId, childModel.getId());PredictionModelParam predictionModelParam predictionModelParamMapper.selectOne(eq1);childModelParamDTO.setCode(childModel.getCode());childModelParamDTO.setName(childModel.getName());childModelParamDTO.setParameterWeight(predictionModelParam.getParameterWeight());return childModelParamDTO;}finally {childModelParamDTOnull;System.gc();}}).collect(Collectors.toList());
3、在使用easyexcel时由于监听器无法被spring管理所以无法在监听器内部使用mp此时可以用重写的方式将 excel中数据添加进数据库中如 EasyExcel.read(file, PredictionParamExcelDTO.class, new ReadListenerPredictionParamExcelDTO() {Overridepublic void invoke(PredictionParamExcelDTO predictionParamExcelDTO, AnalysisContext analysisContext) {PredictionParam predictionParam null;try {predictionParam new PredictionParam();predictionParam.setMaterialCode(predictionParamExcelDTO.getMaterialCode());predictionParam.setMaterialName(predictionParamExcelDTO.getMaterialName());predictionParam.setProductionLine(predictionParamExcelDTO.getProductionLine());predictionParam.setCapacity(Integer.valueOf(predictionParamExcelDTO.getCapacity()));predictionParamService.save(predictionParam);} catch (Exception e) {e.printStackTrace();log.error(模板上传失败);throw e;}}Overridepublic void doAfterAllAnalysed(AnalysisContext analysisContext) {}}).sheet().doRead();
4、下载excel的同时将数据写入excel中
try {httpServletResponse.setContentType(application/vnd.ms-excel);String fileName URLEncoder.encode(D:/idea/idea_projects/mwlc-dcm-requirement-backend/predictionParamExcel.xlsx, UTF-8);httpServletResponse.setHeader(content-disposition, attachment;filenamefileName);ServletOutputStream outputStream;outputStreamhttpServletResponse.getOutputStream();EasyExcel.write(outputStream).head(PredictionParamExcelDTO.class).excelType(ExcelTypeEnum.XLSX).sheet(日基准产能表模板).doWrite(这里放需要写入excel的数据);outputStream.close();}catch (IOException o){throw new RuntimeException(o);}