diff --git a/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java b/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java index 0722372..f7f97bb 100644 --- a/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java +++ b/casic-metering-service/src/main/java/com/casic/missiles/service/Impl/eqpt/standard/impl/PressureGaugeHandler.java @@ -2,6 +2,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.stream.CollectorUtil; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.casic.missiles.core.application.service.AbstractDictService; import com.casic.missiles.dto.business.deviceMeasure.MeasureEquipmentInfoDTO; @@ -31,6 +32,7 @@ import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.stream.Collector; import java.util.stream.Collectors; /** @@ -115,7 +117,7 @@ //准备封面参数 prepareCoverParams(map, measureItemInfo.getLabCode()); //参数 - customParam(map,measureItemInfo.getMeasureDataPistonGaugeList().get(0)); + customParam(map, measureItemInfo.getMeasureDataPistonGaugeList().get(0)); List equipmentList = bizBusinessDeviceMeasureEquipmentMapper.selectEquipmentListByDataId(measureItemInfo.getDataId()); if (CollectionUtils.isEmpty(equipmentList)) { equipmentList = new ArrayList<>(); @@ -208,9 +210,9 @@ map.put("pointerDeflectionStability", pistonGauge.getPointerDeflectionStability() ? "合格" : "不合格*");//指针偏转平稳性 map.put("zeroDriftResult", pistonGauge.getTightness() ? "合格" : "不合格*");//零点漂移 map.put("indicationError", pistonGauge.getIndicationError() ? "合格" : "不合格*");//示值误差、回程误差、轻敲位移 - if(pistonGauge.getZeroDrift()){ + if (pistonGauge.getZeroDrift()) { map.put("upToStandard", "\uF052"); - }else { + } else { map.put("belowStandard", "\uF052"); } } else { @@ -248,49 +250,58 @@ */ private void handlerCheckData(Map map, BizEquipmentStandardCheckRecordApproval request) { //直流电压 - Map voltageMap = request.getCheckDataPistonGaugeList().stream().filter( + List voltageList = request.getCheckDataPistonGaugeList().stream().filter( e -> e.getParams().contains("电压") - ).collect(Collectors.toMap(BizEquipmentStandardCheckDataPistonGauge::getCheckPoint, e -> e, (e1, e2) -> e1)); - List voltageCheckPoints = Arrays.asList("5", "10", "20"); - - populateCheckData(map, voltageMap, voltageCheckPoints, "voltages", "maxs1", UNIT_V); + ).sorted((e1, e2) -> Integer.valueOf(e1.getCheckPoint()) - Integer.valueOf(e2.getCheckPoint())) + .collect(Collectors.toList()); + populateCheckData(map, voltageList, "voltages", "maxs1", UNIT_V,"1"); //直流电流 - Map electricityMap = request.getCheckDataPistonGaugeList().stream().filter( + List electricityList = request.getCheckDataPistonGaugeList().stream().filter( e -> e.getParams().contains("电流") - ).collect(Collectors.toMap(BizEquipmentStandardCheckDataPistonGauge::getCheckPoint, e -> e, (e1, e2) -> e1)); - List electricityCheckPoints = Arrays.asList("4", "10", "20"); - populateCheckData(map, electricityMap, electricityCheckPoints, "electricitys", "maxs2", UNIT_I); + ).sorted((e1, e2) -> Integer.valueOf(e1.getCheckPoint()) - Integer.valueOf(e2.getCheckPoint())) + .collect(Collectors.toList()); + populateCheckData(map, electricityList, "electricitys", "maxs2", UNIT_I,"2"); } /** - * @param checkDataMap + * @param dataPistonGaugeList * @param paramKey * @param maximumKey */ - private void populateCheckData(Map map, Map checkDataMap, - List checkPoints, - String paramKey, String maximumKey, String unitParam) { + private void populateCheckData(Map map, List dataPistonGaugeList, + String paramKey, String maximumKey, String unitParam,String index) { + if (CollectionUtils.isEmpty(dataPistonGaugeList)) { + return; + } //创建数据list List> standardCheckList = new ArrayList<>(); map.put(paramKey, standardCheckList); if (ObjectUtils.isEmpty(map.get("technologyFile"))) { map.put("technologyFile", "无"); } + List checkPointMapList = new ArrayList<>(); //创建最大界限值list List> maximumList = new ArrayList<>(); map.put(maximumKey, maximumList); //数据填充处理 - for (String checkPoint : checkPoints) { - if (checkDataMap.containsKey(checkPoint)) { - BizEquipmentStandardCheckDataPistonGauge checkDataPistonGauge = checkDataMap.get(checkPoint); + for (int i = 0; i < 3; i++) { + if (i < dataPistonGaugeList.size()) { + BizEquipmentStandardCheckDataPistonGauge checkDataPistonGauge = dataPistonGaugeList.get(i); map.put(unitParam, checkDataPistonGauge.getUnit()); + Map checkPointMap = new HashMap<>(); + checkPointMap.put("point", checkDataPistonGauge.getCheckPoint()); + checkPointMapList.add(checkPointMap); doPopulateCheckData(map, checkDataPistonGauge, paramKey, maximumKey); } else { //如果没有,则进行填充空的对象 BizEquipmentStandardCheckDataPistonGauge pistonGauge = new BizEquipmentStandardCheckDataPistonGauge(); doPopulateCheckData(map, pistonGauge, paramKey, maximumKey); + Map checkPointMap = new HashMap<>(); + checkPointMap.put("point", "/"); + checkPointMapList.add(checkPointMap); } } + map.put("checkPoints"+index, checkPointMapList); } /**