| | |
| | | import com.moral.api.pojo.vo.excel.ExcelVo; |
| | | import com.moral.api.service.ExcelService; |
| | | import com.moral.api.utils.ExcelUtils; |
| | | import com.moral.pojo.AQI; |
| | | import com.moral.util.AQIUtils; |
| | | |
| | | import com.moral.util.DateUtils; |
| | | |
| | | |
| | |
| | | private ExcelMapper excelMapper; |
| | | |
| | | /** |
| | | * 导入 |
| | | * 高新区导入 |
| | | * @param files |
| | | * @param params |
| | | * @return |
| | |
| | | */ |
| | | @Override |
| | | public ExcelBO importTemplate(List<MultipartFile> files, Map<String, Object> params) throws IOException { |
| | | Date date2 = new Date(); |
| | | String time = (String) params.get("time"); |
| | | String code = (String) params.get("code"); |
| | | String time1 = (String) params.get("date"); |
| | | // String time1 = (String) params.get("date"); |
| | | Date date = DateUtils.getDate(time, "yyyy-MM-dd"); |
| | | Date date1 = DateUtils.getDate(time1, "yyyy-MM-dd"); |
| | | // Date date1 = DateUtils.getDate(time1, "yyyy-MM-dd"); |
| | | ExcelBO excelBO = new ExcelBO(); |
| | | QueryWrapper<TbExcel> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("time",date).eq("code",code); |
| | |
| | | MultipartFile file5 = files.get(4); |
| | | Map<String, Object> map5 = getMap5(file5); |
| | | map.put("c5",map5); |
| | | MultipartFile file6 = files.get(5); |
| | | Map<String, Object> map6 = getMap6(file6); |
| | | map.put("c6",map6); |
| | | if (files.size()>5){ |
| | | MultipartFile file6 = files.get(5); |
| | | Map<String, Object> map6 = getMap6(file6); |
| | | map.put("c6",map6); |
| | | } |
| | | String s = JSON.toJSONString(map); |
| | | excel1.setValue(s); |
| | | excel1.setTime(date); |
| | | excel1.setCode(code); |
| | | excel1.setDate(date1); |
| | | excel1.setDate(date2); |
| | | excelMapper.insert(excel1); |
| | | excelBO.setId(excel1.getId()); |
| | | excelBO.setTime(excel1.getTime()); |
| | | excelBO.setDate(excel1.getDate()); |
| | | excelBO.setDate(date2); |
| | | |
| | | }else { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | |
| | | MultipartFile file5 = files.get(4); |
| | | Map<String, Object> map5 = getMap5(file5); |
| | | map.put("c5",map5); |
| | | MultipartFile file6 = files.get(5); |
| | | Map<String, Object> map6 = getMap6(file6); |
| | | map.put("c6",map6); |
| | | if (files.size()>5){ |
| | | MultipartFile file6 = files.get(5); |
| | | Map<String, Object> map6 = getMap6(file6); |
| | | map.put("c6",map6); |
| | | } |
| | | String s = JSON.toJSONString(map); |
| | | excel.setValue(s); |
| | | excelMapper.updateById(excel); |
| | | excelBO.setId(excel.getId()); |
| | | excelBO.setTime(excel.getTime()); |
| | | excelBO.setDate(excel.getDate()); |
| | | excelBO.setDate(date2); |
| | | } |
| | | return excelBO; |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | * 高新区导出 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ExcelVo export(Integer id) { |
| | | |
| | | |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | ArrayList<Map<String,Object>> list1 = new ArrayList<>(); |
| | | ArrayList<Map<String,Object>> list2 = new ArrayList<>(); |
| | |
| | | Map map5 = JSON.parseObject(s, Map.class); |
| | | Set set1s = map5.keySet(); |
| | | for (Object set1 : set1s) { |
| | | Object o1 = map5.get(set1); |
| | | String s1 = JSON.toJSONString(o1); |
| | | Map map6 = JSON.parseObject(s1, Map.class); |
| | | map6.put("place",set1); |
| | | list3.add(map6); |
| | | if (set1.equals("高新区")){ |
| | | Object o1 = map5.get(set1); |
| | | String s1 = JSON.toJSONString(o1); |
| | | Map map6 = JSON.parseObject(s1, Map.class); |
| | | map6.put("place","国控站"); |
| | | list3.add(map6); |
| | | }else { |
| | | Object o1 = map5.get(set1); |
| | | String s1 = JSON.toJSONString(o1); |
| | | Map map6 = JSON.parseObject(s1, Map.class); |
| | | map6.put("place",set1.toString().substring(3)); |
| | | list3.add(map6); |
| | | } |
| | | } |
| | | } |
| | | if (set.equals("c4")){ |
| | |
| | | // "臭氧8小时滑动平均值90百分位数浓度为"+O3y+"微克/立方米,同比"+code5+"%。" + |
| | | // "空气质量优良天数比例为"+AQIy+"%,同比"+code6+"%。"; |
| | | |
| | | excelVo.setQuality(s3+s4); |
| | | excelVo.setQuality(s4+s3); |
| | | excelVo.setSu(s1); |
| | | excelVo.setCount(count); |
| | | excelVo.setPM10(PM10); |
| | |
| | | objects[j] = value; |
| | | } |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("place", objects[0]); |
| | | if (objects[0].toString().equals("高新区")){ |
| | | map.put("place", "国控站"); |
| | | }else { |
| | | map.put("place",objects[0].toString().substring(3)); |
| | | } |
| | | map.put("日期", objects[1]); |
| | | map.put("SO2", objects[2]); |
| | | map.put("SO2分指数", objects[3]); |