今天下午在家办公遇到个问题,手动调用公式计算得分,需要对之前的得分进行修改操作,条件是根据多个字段,确实难搞哇,弄了一下午
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
public List<SupplierComscore> comScoreUpsert(SupplierComscore scoreParam, String evaluationType, List<SupplierComscore> calculateScoreList) {
List<SupplierComscore> updateList = new ArrayList<>();
List<SupplierComscore> scoreList = supplierComscoreService.selectComscoreList(scoreParam, evaluationType);
List<SupplierComscore> resultList = calculateScoreList.stream() .filter(item -> scoreList.stream().map(e -> e.getSupplierCode() + "|" + e.getProductType()) .collect(Collectors.toList()).contains(item.getSupplierCode() + "|" + item.getProductType())) .collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(resultList)) { resultList.forEach(item -> { scoreList.stream().filter(e -> e.getSupplierCode().equals(item.getSupplierCode()) && e.getProductType().equals(item.getProductType())) .findFirst().ifPresent(s -> { item.setId(s.getId());
if (s.getBaseScore() != null) { item.setBaseScore(item.getScore()); item.setScore(s.getScore()); }
if (StrUtil.isNotBlank(s.getBaseIndexData())) { item.setBaseIndexData(item.getIndexData()); item.setIndexData(s.getIndexData()); }
if (s.getBaseSupplierLevel() != null) { item.setBaseSupplierLevel(item.getSupplierLevel()); item.setSecretLevel(s.getSecretLevel()); }
item.setStatus(s.getStatus()); }); }); updateList = resultList.stream().filter(e -> StrUtil.toString(e.getStatus()).equals(SalmKpiConstants.ASSESS_STATUS_EVALUATE_RELEASED) || StrUtil.toString(e.getStatus()).equals(SalmKpiConstants.ASSESS_STATUS_EVALUATE_REJECTED)) .collect(Collectors.toList()); }
List<SupplierComscore> otherList = calculateScoreList.stream().filter(item -> !resultList.contains(item)).collect(Collectors.toList()); return ListUtils.union(otherList, updateList); }
|