/** * 2 得到你要修改的样品所有检查项--手动选择--是其中一项 * * @return */ public String sfProjects() { fslibProjList = new ArrayList<TemplateProjectVo>(); List<StandardProject> spList = new ArrayList<StandardProject>(); List<StandardProject> resultList = new ArrayList<StandardProject>(); // 加载所有的项目 WorkPlaceQuality wq = workPlaceQualityBiz.getEntityById(WorkPlaceQuality.class, wplaceQualityId); List<StandardLibray> alllibs = workPlaceSampleBiz.getLib(wq); for (StandardLibray sl : alllibs) { List<StandardProject> newProjList = standardProjectBiz.getEntitiesByTwoColumn( StandardProject.class, "standardLibray", sl, "del_flag", false); for (StandardProject newproj : newProjList) { spList.add(newproj); } } // 加载所有的选择的项 resultList = workPlaceSampleBiz.getProj(wq); if (resultList != null && resultList.size() > 0) { spList = removeSpDuplicate(spList); for (StandardProject spro : spList) { TemplateProjectVo vo = new TemplateProjectVo(); vo.setId(spro.getId()); vo.setName(spro.getName()); vo.setSp_code(spro.getSp_code()); vo.setSp_code_name(spro.getSp_code_name()); vo.setDetection(spro.getDetection()); vo.setLocale_detection(spro.getLocale_detection()); vo.setSp_company_name(spro.getSp_company_name()); vo.setSp_target(spro.getSp_target()); vo.setSp_according(spro.getSp_according()); vo.setRemark(spro.getRemark()); for (StandardProject tp : resultList) { if (tp.getSp_according() .replaceAll(" ", "") .equals(spro.getSp_according().replaceAll(" ", "")) && tp.getSp_code_name() .replaceAll(" ", "") .equals(spro.getSp_code_name().replaceAll(" ", ""))) { vo.setTemplId(spro.getId()); } } fslibProjList.add(vo); } } return "allProj_list"; }
/** * 去重复 * * @param list * @return */ private List<StandardProject> removeSpDuplicate(List<StandardProject> list) { for (int i = 0; i < list.size() - 1; i++) { for (int j = list.size() - 1; j > i; j--) { StandardProject first = list.get(j); StandardProject second = list.get(i); if (first .getSp_according() .replaceAll(" ", "") .equals(second.getSp_according().replaceAll(" ", "")) && first .getSp_code_name() .replaceAll(" ", "") .equals(second.getSp_code_name().replaceAll(" ", ""))) { list.remove(j); } } } return list; }