diff --git a/src/main/java/com/sipai/controller/work/MPointController.java b/src/main/java/com/sipai/controller/work/MPointController.java index d9264fb7..7f0dd728 100644 --- a/src/main/java/com/sipai/controller/work/MPointController.java +++ b/src/main/java/com/sipai/controller/work/MPointController.java @@ -432,7 +432,12 @@ public class MPointController { // 比对ES全量数据总数和数据库全量数据总数 long dbCount = this.mPointService.getDbTotalCount(); - long esCount = this.mPointService.getEsTotalCount(); + long esCount = 0; + try { + esCount = this.mPointService.getEsTotalCount(); + } catch (Exception e) { + logger.warn("ES数据查询异常,跳过ES", e); + } logger.info("getlistES数据比对 -> DB总数:" + dbCount + ", ES总数:" + esCount); String result; @@ -543,34 +548,21 @@ public class MPointController { units.add(unit); } - String bizids = ""; + StringBuilder bizids = new StringBuilder(); if (searchName != null && !searchName.isEmpty()) { - int lastMatchNum = 1; - String keyword = ""; - char[] sNchars = searchName.toCharArray(); - for (int u = 0; u < units.size(); u++) { - int matchNum = 0; - for (char item : sNchars) { - if (units.get(u).getSname().contains(String.valueOf(item))) { - matchNum++; - } - } - if (matchNum > lastMatchNum) { - keyword = units.get(u).getId(); - } - } + String keyword = getKeyword(searchName, units); if (!keyword.isEmpty()) { units = this.getParent(keyword, units); - bizids = keyword; + bizids = new StringBuilder(keyword); } } - for (int u = 0; u < units.size(); u++) { - if (!bizids.isEmpty()) { - bizids += " "; + for (Unit value : units) { + if (bizids.length() > 0) { + bizids.append(" "); } - bizids += units.get(u).getId(); + bizids.append(value.getId()); } - childBoolQueryBuilder.must(QueryBuilders.matchQuery("bizid", bizids)); + childBoolQueryBuilder.must(QueryBuilders.matchQuery("bizid", bizids.toString())); } boolQueryBuilder.should(childBoolQueryBuilder); @@ -582,7 +574,7 @@ public class MPointController { // 查询工艺段 for (MPoint mp : list) { List processSections = processSectionService.selectSimpleListByWhere("where code = '" + mp.getProcesssectioncode() + "'"); - if (processSections != null && processSections.size() > 0) { + if (processSections != null && !processSections.isEmpty()) { mp.setProcessSection(processSections.get(0)); } } @@ -595,6 +587,24 @@ public class MPointController { return new ModelAndView("result"); } + private static String getKeyword(String searchName, List units) { + int lastMatchNum = 1; + String keyword = ""; + char[] sNchars = searchName.toCharArray(); + for (int u = 0; u < units.size(); u++) { + int matchNum = 0; + for (char item : sNchars) { + if (units.get(u).getSname().contains(String.valueOf(item))) { + matchNum++; + } + } + if (matchNum > lastMatchNum) { + keyword = units.get(u).getId(); + } + } + return keyword; + } + @RequestMapping("/getKPIList.do") public ModelAndView getKPIList(HttpServletRequest request, Model model, @RequestParam(value = "page") Integer page, @@ -4520,7 +4530,7 @@ public class MPointController { } PageHelper.startPage(page, rows); - List list = mPointHistoryService.selectMpHisDataLeftMpHisChange(bizid, mpid,"'"+mpid+"'", wherestr + orderstr, dbname); + List list = mPointHistoryService.selectMpHisDataLeftMpHisChange(bizid, mpid, "'" + mpid + "'", wherestr + orderstr, dbname); PageInfo pi = new PageInfo(list); JSONArray json = JSONArray.fromObject(list); @@ -4668,7 +4678,7 @@ public class MPointController { */ @RequestMapping("/hisDataImportExcel.do") public ModelAndView hisDataImportExcel(@RequestParam(value = "filelist", required = false) - MultipartFile file, HttpServletRequest request, Model model) throws IOException { + MultipartFile file, HttpServletRequest request, Model model) throws IOException { MultipartRequest multipartRequest = (MultipartRequest) request; MultipartFile excelFile = multipartRequest.getFile("filelist"); @@ -4709,7 +4719,7 @@ public class MPointController { */ @RequestMapping("/hisDataMultipleImportExcel.do") public ModelAndView hisDataMultipleImportExcel(@RequestParam(value = "filelist", required = false) - MultipartFile file, HttpServletRequest request, Model model) throws IOException { + MultipartFile file, HttpServletRequest request, Model model) throws IOException { MultipartRequest multipartRequest = (MultipartRequest) request; MultipartFile excelFile = multipartRequest.getFile("filelist"); @@ -4859,7 +4869,7 @@ public class MPointController { */ @RequestMapping("/saveExcelData.do") public ModelAndView dosaveExcelData(@RequestParam(value = "filelist", required = false) - MultipartFile file, HttpServletRequest request, Model model) throws IOException { + MultipartFile file, HttpServletRequest request, Model model) throws IOException { MultipartRequest multipartRequest = (MultipartRequest) request; MultipartFile excelFile = multipartRequest.getFile("filelist");