yb
昨天 dadf90a142175590766a8bfdbc2a5486d707fa43
倍率统计报表
已修改1个文件
40 ■■■■■ 文件已修改
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
@@ -8,8 +8,12 @@
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mdc.dto.*;
import org.jeecg.modules.mdc.entity.*;
import org.jeecg.modules.mdc.dto.MdcEquProDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto;
import org.jeecg.modules.mdc.entity.Equipment;
import org.jeecg.modules.mdc.entity.MdcDriveTypeParamConfig;
import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification;
import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection;
import org.jeecg.modules.mdc.mapper.MdcEquipmentMagnificationMapper;
import org.jeecg.modules.mdc.service.*;
import org.jeecg.modules.mdc.util.DateUtils;
@@ -17,7 +21,6 @@
import org.jeecg.modules.mdc.vo.MdcMagnificationEquipmentVo;
import org.jeecg.modules.mdc.vo.MdcMagnificationVo;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -31,6 +34,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class MdcEquipmentMagnificationServiceImpl extends ServiceImpl<MdcEquipmentMagnificationMapper, MdcEquipmentMagnification> implements IMdcEquipmentMagnificationService {
@@ -329,8 +333,35 @@
        avg.setEquipmentName("平均值");
        avg.setEquipmentType("平均值");
        //计算平均值
        avg.setMdcBeilvVoList(null);
        avg.setMdcBeilvVoList(calculateOpenAverage(result.getMdcMagnificationVos()));
        result.getMdcMagnificationVos().add(avg);
        return result;
    }
    /**
     * 计算平均值
     *
     * @param mdcMagnificationVos
     * @return
     */
    private List<MdcEquipmentMagnificationDto> calculateOpenAverage(List<MdcMagnificationEquipmentVo> mdcMagnificationVos) {
        List<MdcEquipmentMagnificationDto> result = new ArrayList<>();
        List<MdcEquipmentMagnificationDto> dataList = new ArrayList<>();
        for (MdcMagnificationEquipmentVo mdcMagnificationEquipmentVo : mdcMagnificationVos) {
            dataList.addAll(mdcMagnificationEquipmentVo.getMdcBeilvVoList());
        }
        dataList.parallelStream().collect(Collectors.groupingBy(MdcEquipmentMagnificationDto::getTheDate, Collectors.toList()))
                .forEach((theDate, mert) -> {
                    mert.stream().reduce((a, b) -> new MdcEquipmentMagnificationDto(
                            a.getTheDate(),
                            a.getFeedbeilv().add(b.getFeedbeilv()),
                            a.getSpindlebeilv().add(b.getSpindlebeilv()))).ifPresent(result::add);
                });
        for (MdcEquipmentMagnificationDto mdcEquipmentMagnificationDto : result) {
            mdcEquipmentMagnificationDto.setSpindlebeilv(mdcEquipmentMagnificationDto.getSpindlebeilv().divide(new BigDecimal(mdcMagnificationVos.size()), 2, RoundingMode.HALF_UP));
            mdcEquipmentMagnificationDto.setFeedbeilv(mdcEquipmentMagnificationDto.getFeedbeilv().divide(new BigDecimal(mdcMagnificationVos.size()), 2, RoundingMode.HALF_UP));
        }
        result.sort(Comparator.comparing(MdcEquipmentMagnificationDto::getTheDate));
        return result;
    }
@@ -342,6 +373,7 @@
                    result.setEquipmentId(equipmentId);
                    result.setSpindlebeilv(mdcEquipmentMagnificationDto.getSpindlebeilv());
                    result.setFeedbeilv(mdcEquipmentMagnificationDto.getFeedbeilv());
                    result.setTheDate(date);
                }
            }
        } else {