<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      List<Map<String,Object>>自定義排序

      參考文檔:  https://segmentfault.com/a/1190000039980921?utm_source=sf-similar-article

      【JAVA基礎】List、Map排序總結

      需求

      我需要 按照  資深 > 高級 > 中級 >初級 的排序方式 
      并且先寫 開發 然后寫測試
      最終排序    
          資深開發 > 高級開發 > 中級開發 >初級開發  >  資深測試 > 高級測試 > 中級測試 >初級測試
      寫入Word模板表格中
      
      
          @PostMapping("/writeOneTable")
          public void writeSycleOneTable(MultipartFile multipartFile) {
      
              Map<String, Object> wordDataMap = new HashMap<String, Object>();  // 存儲報表全部數據
              Map<String, Object> parametersMap = new HashMap<String, Object>();// 存儲報表中不循環的數據
              List<UserInfoDO> userInfoDOList = userInfoMapper.listAll();
              WordTemplate template = null;
              FileInputStream fileInputStream = null;
              FileOutputStream fos = null;
      //        File file = new File("C:\\Users\\18980\\Desktop\\2024年6月17日_需求開發\\簡歷模板.docx");   //可改成你本地模板文件所在目錄
              // 將上傳的MultipartFile轉換為File對象
              File file = null;   //可改成你本地模板文件所在目錄
              try {
                  file = convertMultipartFileToFile(multipartFile);
      //          file = new File("C:\\Users\\18980\\Desktop\\2024年6月17日_需求開發\\〖空〗簡歷模板以及要求_可修改.docx");
              } catch (IOException e) {
                  throw new RuntimeException(e);
              }
              String picPathDir = "C:\\Users\\18980\\Desktop\\2024年7月3日_簡歷需求\\測試崗\\證件照\\擬派團隊成員簡歷表\\";
              String outputPath = "C:\\Users\\18980\\Desktop\\2024年7月3日_簡歷需求\\〖正式人員名單〗\\導出數據\\";
      
      
              List<Map<String, Object>> downSurgeTable = new ArrayList<Map<String, Object>>();
              for (int k = 0; k < userInfoDOList.size(); k++) {
                  UserInfoDO userInfoDO1 = userInfoDOList.get(k);
                  Map<String, Object> map = new HashMap<>();
                  map.put("userName", userInfoDO1.getUserName());
                  map.put("education", userInfoDO1.getEducation());
                  map.put("major", userInfoDO1.getMajor());
                  map.put("profCertification", userInfoDO1.getProfCertification());
                  map.put("workYears", userInfoDO1.getWorkYears());
                  map.put("title", userInfoDO1.getTitle());
                  map.put("jobResponse", userInfoDO1.getJobResponse());
                  map.put("itLevel", userInfoDO1.getItLevel());
                  downSurgeTable.add(map);
              }
      
      
              Comparator<Map<String, Object>> comparator = (a1, a2) -> {
                  String a1Level = (String) a1.get("itLevel");
                  String a2Level = (String) a2.get("itLevel");
                  if (a1Level.equals("資深") && a2Level.equals("高級")) {
                      return 1;
                  } else if (a1Level.equals("資深") && a2Level.equals("中級")) {
                      return 1;
                  } else if (a1Level.equals("資深") && a2Level.equals("初級")) {
                      return 1;
                  } else if (a1Level.equals("中級") && a2Level.equals("高級")) {
                      return -1;
                  } else if (a1Level.equals("中級") && a2Level.equals("資深")) {
                      return -1;
                  } else if (a1Level.equals("中級") && a2Level.equals("初級")) {
                      return 1;
                  } else if (a1Level.equals("初級") && a2Level.equals("資深")) {
                      return -1;
                  } else if (a1Level.equals("初級") && a2Level.equals("高級")) {
                      return -1;
                  } else if (a1Level.equals("初級") && a2Level.equals("中級")) {
                      return -1;
                  } else if (a1Level.equals("高級") && a2Level.equals("資深")) {
                      return -1;
                  } else if (a1Level.equals("高級") && a2Level.equals("中級")) {
                      return 1;
                  } else if (a1Level.equals("高級") && a2Level.equals("初級")) {
                      return 1;
                  }
                  return 0;
              };
      
              downSurgeTable.sort(comparator);
              Collections.reverse(downSurgeTable);  // 上面排序正好相反,用這個方法 downSurgeTable.reverse(); 沒有這個方法
      
      
              Map map = new HashMap();
              List<Map<String, Object>> collectKF = downSurgeTable.stream().filter((map1) -> map1.get("title").toString().indexOf("開發") != -1).collect(Collectors.toList());
              List<Map<String, Object>> collectCS = downSurgeTable.stream().filter((map1) -> map1.get("title").toString().indexOf("測試") != -1).collect(Collectors.toList());
      
              collectKF.addAll(collectCS);  // List 合并
      
              wordDataMap.put("parametersMap", parametersMap);
      //        wordDataMap.put("writeSycleOneTable", downSurgeTable);  // 整體排序
              wordDataMap.put("writeSycleOneTable", collectKF);   // 先開發后測試
      
              try {
                  // 讀取word模板
                  fileInputStream = new FileInputStream(file);
                  template = new WordTemplate(fileInputStream);
      
      
                  // 替換數據
                  template.replaceDocument(wordDataMap);
      
                  //生成文件
                  String outputFileName = outputPath + "writeSycleOneTable" + ".docx";
                  File outputFile = new File(outputFileName);
                  fos = new FileOutputStream(outputFile);
                  template.getDocument().write(fos);
              } catch (Exception e) {
                  throw new RuntimeException(e);
              }
      
              try {
                  if (fileInputStream != null) {
                      fileInputStream.close();
                  }
                  if (fileInputStream != null) {
                      fileInputStream.close();
                  }
                  if (fos != null) {
                      fos.close();
                  }
              } catch (Exception e) {
                  throw new RuntimeException(e);
              }
          }
      
      
      

      知識點

      (1) comparator  不能少些, 一一對比只對比一次,因此需要把所有程序都寫全,否則 下一步  downSurgeTable.sort(comparator);  會報錯

      資深 > 高級 > 中級 >初級 
      
      總共寫了12種對比情況
      (1) 資深  高級	  
      (2) 資深  中級	  
      (3) 資深  初級	  
      (4) 中級  高級	  
      (5) 中級  資深	  
      (6) 中級  初級	  
      (7) 初級  資深	  
      (8) 初級  高級	  
      (9) 初級  中級	  
      (10) 高級  資深	  
      (11) 高級  中級	  
      (12) 高級  初級
      最終 自己和自己別沒寫對比,就是 return 0 即可
      
              Comparator<Map<String, Object>> comparator = (a1, a2) -> {
                  String a1Level = (String) a1.get("itLevel");
                  String a2Level = (String) a2.get("itLevel");
                  if (a1Level.equals("資深") && a2Level.equals("高級")) {
                      return 1;
                  } else if (a1Level.equals("資深") && a2Level.equals("中級")) {
                      return 1;
                  } else if (a1Level.equals("資深") && a2Level.equals("初級")) {
                      return 1;
                  } else if (a1Level.equals("中級") && a2Level.equals("高級")) {
                      return -1;
                  } else if (a1Level.equals("中級") && a2Level.equals("資深")) {
                      return -1;
                  } else if (a1Level.equals("中級") && a2Level.equals("初級")) {
                      return 1;
                  } else if (a1Level.equals("初級") && a2Level.equals("資深")) {
                      return -1;
                  } else if (a1Level.equals("初級") && a2Level.equals("高級")) {
                      return -1;
                  } else if (a1Level.equals("初級") && a2Level.equals("中級")) {
                      return -1;
                  } else if (a1Level.equals("高級") && a2Level.equals("資深")) {
                      return -1;
                  } else if (a1Level.equals("高級") && a2Level.equals("中級")) {
                      return 1;
                  } else if (a1Level.equals("高級") && a2Level.equals("初級")) {
                      return 1;
                  }
                  return 0;
              };
      
              downSurgeTable.sort(comparator);
      

      知識點2 : List 反向排序

      List downSurgeTable; 
      Collections.reverse(downSurgeTable);  // 發現結果排序正好相反,用這個方法 
      
       // 錯誤寫法  downSurgeTable.reverse();  沒有這個方法, 報錯
      

      知識點3 : List過濾

              List<Map<String, Object>> collectKF = downSurgeTable.stream().filter((map1) -> map1.get("title").toString().indexOf("開發") != -1).collect(Collectors.toList());
              
              List<Map<String, Object>> collectCS = downSurgeTable.stream().filter((map1) -> map1.get("title").toString().indexOf("測試") != -1).collect(Collectors.toList());
      

      知識點4 : 2個List和并

      
          collectKF.addAll(collectCS);  // List 合并
      
      posted on 2025-03-11 09:20  daniel_han2020  閱讀(73)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国内熟妇人妻色在线视频| 安泽县| 亚洲欧美自偷自拍视频图片| 亚洲精品久久麻豆蜜桃| 国产午夜福利精品视频| 国产成人a在线观看视频免费| 炉霍县| 国产高清午夜人成在线观看,| 免费全部高h视频无码| 午夜夜福利一区二区三区| 不卡一区二区国产在线| 国产网红主播精品一区| 伊人久久精品无码麻豆一区| 国产妇女馒头高清泬20p多| 久久九九日本韩国精品| 国产无人区码一区二区| 玛多县| 国产精品中文字幕日韩| 中文字幕亚洲资源网久久| 东京热av无码电影一区二区| 大陆一级毛片免费播放| 国产成人午夜一区二区三区| 国产精品久久久天天影视香蕉| 友谊县| 亚洲a片无码一区二区蜜桃| 国产四虎永久免费观看| 麻城市| 亚洲综合无码日韩国产加勒比 | 中文字幕精品av一区二区五区| 久久精品蜜芽亚洲国产AV| 国产主播精品福利午夜二区| 欧美亚洲高清日韩成人| 林甸县| 亚洲av无在线播放中文| 色爱综合激情五月激情| 国产无遮挡又黄又爽高潮| 99国产午夜福利在线观看| 中文字幕日韩精品人妻| 蜜芽久久人人超碰爱香蕉| 五月天丁香婷婷亚洲欧洲国产| 麻豆精品一区二区三区蜜臀|