1. Java dynamically generates Excel input files
Key code implementation:
// header data String[] header = {"index","stationName","stationTypeId","x","y","time","AQI","PM25","PM10","SO2" ,"NO2","CO","O3","PMI"}; //Site name time pressure (hpa) air temperature (℃) humidity (%) wind direction (deg) wind speed (m/s) precipitation (mm) Visibility (km) PM10 PM2.5 //Declare a workbook HSSFWorkbook workbook = new HSSFWorkbook(); //Generate a form HSSFSheet sheet = workbook.createSheet("sheet1"); // Write to the header HSSFRow headrow = sheet. createRow(0); for (int i=0; i<header.length; i++) { headrow.createCell(i).setCellValue(header[i]); } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH :mm"); for (int i=0; i<datalist.size(); i++) { HSSFRow row = sheet.createRow(i+1); StationWithData data = datalist.get(i); row.createCell(0).setCellValue(i+1); row.createCell(1).setCellValue(data.getStationName()); row.createCell(2).setCellValue(data.getStationTypeId()); if (data.getLongitude() != null) { row.createCell(3).setCellValue(data.getLongitude().doubleValue()); } if (data.getLatitude() != null) { row.createCell(4).setCellValue(data.getLatitude().doubleValue()); } if (data.getMonitorTime() != null) { row.createCell(5).setCellValue(dateFormat.format(data.getMonitorTime())); } if (data.getAqi() != null) { row.createCell(6).setCellValue(data.getAqi().doubleValue()); } if (data.getPm25() != null) { row.createCell(7).setCellValue(data.getPm25().doubleValue()); } if (data.getPm10() != null) { row.createCell(8).setCellValue(data.getPm10().doubleValue()); } if (data.getSo2() != null) { row.createCell(9).setCellValue(data.getSo2().doubleValue()); } if (data.getNo2() != null) { row.createCell(10).setCellValue(data.getNo2().doubleValue()); } if (data.getCo() != null) { row.createCell(11).setCellValue(data.getCo().doubleValue()); } if (data.getO3() != null) { row.createCell(12).setCellValue(data.getO3().doubleValue()); } if (data.getPmi() != null) { row.createCell(13).setCellValue(data.getPmi().doubleValue()); } } try { //workbook将Excel写入到文件 File file = new File(excelPath); if (!file.exists()) { boolean flag = file.mkdirs(); System.out.println(flag); } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH"); FileOutputStream os = new FileOutputStream(excelPath + "\\" + sdf.format(new Date()) + ".xls"); workbook.write(os); //刷新缓冲 os.flush(); os.close(); //this.execPython(scriptPath, pythonParam, pythonParam + File.separator + "wryt" + File.separator + "wrytexcel" + File.separator + sdf.format(new Date()) + ".xls"); this.execPython(scriptPath, pythonParam, excelPath + File.separator + sdf.format(new Date()) + ".xls"); } catch(Exception e) { e.printStackTrace(); }
Two, write python code to achieve
3. Write java service code and call python to generate pollution rose diagram result file
4. Network call
5. Generate the results of the pollution rose diagram
Technical cooperation and exchange qq: 2401315930
6. Visualization of the diffusion direction, orientation and concentration of pollutants within the display period integrated with GIS