package com.steerinfo.meterwork.meterworkdatacount.service.impl;

import com.steerinfo.baseinfo.combaseinfo.mapper.ComBaseInfoMapper;
import com.steerinfo.baseinfo.combaseinfo.model.ComBaseInfo;
import com.steerinfo.baseinfo.meterbaseoperationlog.mapper.MeterBaseOperationLogMapper;
import com.steerinfo.baseinfo.meterbasespotinfo.mapper.MeterBaseSpotInfoMapper;
import com.steerinfo.baseinfo.meterbasespotinfo.model.MeterBaseSpotInfo;
import com.steerinfo.framework.controller.RESTfulResult;
import com.steerinfo.framework.service.pagehelper.PageHelper;
import com.steerinfo.framework.service.pagehelper.PageList;
import com.steerinfo.framework.user.UserPayload;
import com.steerinfo.meterwork.meterworkcaractual.mapper.MeterWorkCarActualMapper;
import com.steerinfo.meterwork.meterworkcaractual.model.MeterWorkCarActual;
import com.steerinfo.meterwork.meterworkcaractualfirst.mapper.MeterWorkCarActualFirstMapper;
import com.steerinfo.meterwork.meterworkdatacount.mapper.MeterWorkDataCountMapper;
import com.steerinfo.meterwork.meterworkdatacount.model.*;
import com.steerinfo.meterwork.meterworkdatacount.service.IMeterWorkDataCountService;
import com.steerinfo.meterwork.meterworkrailwayactfirst.mapper.MeterWorkRailwayActFirstMapper;
import com.steerinfo.meterwork.meterworkrailwayactual.mapper.MeterWorkRailwayActualMapper;
import com.steerinfo.meterwork.meterworkrailwayactual.model.MeterWorkRailwayActual;
import com.steerinfo.util.StringUtils;
import org.apache.poi.hssf.record.ArrayRecord;
import org.apache.shiro.crypto.hash.Hash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

import static java.lang.Math.abs;

@Service
public class MeterWorkDataCountServiceImpl implements IMeterWorkDataCountService {

    private static final Logger log = LoggerFactory.getLogger(MeterWorkDataCountServiceImpl.class);
    @Resource
    private MeterWorkDataCountMapper meterWorkDataCountMapper;

    @Resource
    private MeterBaseSpotInfoMapper meterBaseSpotInfoMapper;

    @Resource
    private MeterWorkCarActualMapper meterWorkCarActualMapper;

    @Resource
    private MeterWorkCarActualFirstMapper meterWorkCarActualFirstMaper;

    @Resource
    private MeterBaseOperationLogMapper meterBaseOperationLogMapper;

    @Resource
    private MeterWorkRailwayActualMapper meterWorkRailwayActualMapper;
    @Resource
    private MeterWorkRailwayActFirstMapper meterWorkRailwayActFirstMapper;

    @Resource
    ComBaseInfoMapper comBaseInfoMapper;

    @Override
    public List<HashMap> countFirstAndActual(HashMap<String, Object> params) {
        List<HashMap> models = meterWorkDataCountMapper.countFirstAndActual(params);
        return models;
    }

    @Override
    public HashMap productionAndOperationDaily(HashMap<String, Object> params) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        SimpleDateFormat sdfD = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = params.get("filterdate").toString().substring(0, 10);
        String[] str = dateStr.split("-");
        params.put("startTime", dateStr + " 00:00:00");
        params.put("endTime", dateStr + " 23:59:59");
        HashMap models = meterWorkDataCountMapper.productionAndOperationDaily(params);
        UserPayload payload = UserPayload.getCurrUser();
        String userId = payload.getUserCode();
        String userName = payload.getUserName();
        models.put("userId", userId);
        models.put("userName", userName);
        models.put("myDate", str[0] + '年' + str[1] + '月' + str[2] + '日');
        return models;
    }

    @Override
    public RESTfulResult carRegularComparison(HashMap<String, Object> params) {
        RESTfulResult rm = new RESTfulResult();
        rm.setFailed();
        try {
            List<CarRegularComparison> models = new ArrayList<>();
            List<CarRegularComparison> modelsA = meterWorkDataCountMapper.carRegularComparisonA(params);
            if (modelsA.size() >= 1) {
                for (CarRegularComparison model : modelsA) {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Calendar beforeTime = Calendar.getInstance();
                    Calendar afterTime = Calendar.getInstance();
                    beforeTime.setTime(model.getCreateTime());     //设置时间
                    afterTime.setTime(model.getCreateTime());     //设置时间
                    beforeTime.add(Calendar.MINUTE, -30);// 5分钟之前的时间
                    afterTime.add(Calendar.MINUTE, 30);// 5分钟之后的时间
                    Date beforeD = beforeTime.getTime();
                    Date afterD = afterTime.getTime();
                    String startTime = sdf.format(beforeD);
                    String endTime = sdf.format(afterD);
                    HashMap<String, Object> map = new HashMap<>();
                    map.put("startTime", startTime);
                    map.put("endTime", endTime);
                    map.put("createTime", sdf.format(model.getCreateTime()));
                    map.put("actualFirstNo", model.getActualFirstNo());
                    map.put("carNo", model.getCarNo());
                    List<CarRegularComparison> modelsB = modelsA.stream()
                            .filter(s -> s.getCarNo().equals(model.getCarNo())
                                    && !s.getActualFirstNo().equals(model.getActualFirstNo())
                                    && s.getCreateTime().compareTo(model.getCreateTime()) != 0
                                    && s.getCreateTime().getTime() >= beforeD.getTime()
                                    && s.getCreateTime().getTime() <= afterD.getTime()).collect(Collectors.toList());
//                    List<CarRegularComparison> modelsB = meterWorkDataCountMapper.carRegularComparisonB(map);
                    if (modelsB.size() >= 1) {
                        //去重
                        long count = models.stream().filter(item -> item.getActualFirstNo().equals(modelsB.get(0).getActualFirstNo())).count();
                        //一次作业编号不存在，则添加，否者，跳过
                        if (count < 1) {
                            SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            Date timeDate1 = simpleFormat.parse(sdf.format(modelsB.get(0).getCreateTime()));
                            Date timeDate2 = simpleFormat.parse(sdf.format(model.getCreateTime()));
                            long time1 = timeDate1.getTime();
                            long time2 = timeDate2.getTime();
                            int minutes = abs((int) ((time1 - time2) / (1000 * 60)));
                            if (StringUtils.isEmpty(model.getWeightType()) || StringUtils.isEmpty(modelsB.get(0).getWeightType())) {
                                if (modelsB.get(0).getSpotAreaNo().equals(model.getSpotAreaNo())
                                        && minutes <= 20) {
                                    model.setMemo("双秤比对");
                                    model.setSubstract(model.getMeterWeight().subtract(modelsB.get(0).getMeterWeight()));
                                    models.add(model);
                                    models.add(modelsB.get(0));
                                } else if (!modelsB.get(0).getSpotAreaNo().equals(model.getSpotAreaNo())
                                        && minutes >= 30 && minutes <= 60) {
                                    model.setMemo("异地比对");
                                    model.setSubstract(model.getMeterWeight().subtract(modelsB.get(0).getMeterWeight()));
                                    models.add(model);
                                    models.add(modelsB.get(0));
                                }
                            } else if (StringUtils.isNotEmpty(model.getWeightType()) && StringUtils.isNotEmpty(modelsB.get(0).getWeightType())
                                    && !(modelsB.get(0).getWeightType().equals("0") && model.getWeightType().equals("1"))
                                    && !(modelsB.get(0).getWeightType().equals("1") && model.getWeightType().equals("0"))
                                    && !(modelsB.get(0).getWeightType().equals("0") && model.getWeightType().equals("2"))
                                    && !(modelsB.get(0).getWeightType().equals("2") && model.getWeightType().equals("0"))) {
                                if (modelsB.get(0).getSpotAreaNo().equals(model.getSpotAreaNo())
                                        && minutes <= 20) {
                                    model.setMemo("双秤比对");
                                    model.setSubstract(model.getMeterWeight().subtract(modelsB.get(0).getMeterWeight()));
                                    models.add(model);
                                    models.add(modelsB.get(0));
                                } else if (!modelsB.get(0).getSpotAreaNo().equals(model.getSpotAreaNo())
                                        && minutes >= 30 && minutes <= 60) {
                                    model.setMemo("异地比对");
                                    model.setSubstract(model.getMeterWeight().subtract(modelsB.get(0).getMeterWeight()));
                                    models.add(model);
                                    models.add(modelsB.get(0));
                                }
                            }

                        }
                    }
                }
            }
            rm.setSucceed(true);
            rm.setData(models);
            rm.setMessage("操作成功！！");
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作失败：>>>" + e.getMessage());
        }
        return rm;
    }

    @Override
    public List<HashMap> countDayAllSpot(HashMap<String, Object> params) {

        if (params.get("netSpot3NoStr") != null) {
            String[] spotNoStr = params.get("netSpot3NoStr").toString().split(",");
            params.put("spotNoStr", spotNoStr);
        }
        if (params.get("createManNoStr") != null) {
            String[] manNoStr = params.get("createManNoStr").toString().split(",");
            params.put("manNoStr", manNoStr);
        }
        List<HashMap> paramsList = new ArrayList<>();
        //总结净
        long countActualTemp = 0L;
        //总一次
        long countFirstTemp = 0L;
        //结净未匹配委托总数
        long countActualValidTemp = 0L;
        //未结净有效一次总数
        long countFirstValidTemp = 0L;
        {
            HashMap params01 = new HashMap();
            List<HashMap> paramsList02 = new ArrayList<>();
            List<MeterBaseSpotInfo> spotModelList = meterBaseSpotInfoMapper.carSpotGroupByActualAndFirst(params);

            //总结净数
            HashMap<String, Object> actualMap = new HashMap<>();
            actualMap.put("startTime", params.get("startTime"));
            actualMap.put("endTime", params.get("endTime"));
            if (params.get("netSpot3NoStr") != null) {
                actualMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                actualMap.put("spotNoStr", params.get("spotNoStr"));
            }
            if (params.get("createManNoStr") != null) {
                actualMap.put("createManNoStr", params.get("createManNoStr"));
                actualMap.put("manNoStr", params.get("manNoStr"));
            }
            actualMap.put("validFlag", "1");
            List<HashMap> carActualTotal = meterWorkCarActualMapper.countDayAllState(actualMap);
            if (carActualTotal.size() >= 1) {
                for (HashMap modelTemp : carActualTotal) {
                    countActualTemp += Long.parseLong(modelTemp.get("COUNT_ACTUAL").toString());
                }
            }
            //作废结净总数
            HashMap<String, Object> actualVoidMap = new HashMap<>();
            actualVoidMap.put("startTime", params.get("startTime"));
            actualVoidMap.put("endTime", params.get("endTime"));
            if (params.get("netSpot3NoStr") != null) {
                actualVoidMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                actualVoidMap.put("spotNoStr", params.get("spotNoStr"));
            }
            if (params.get("createManNoStr") != null) {
                actualVoidMap.put("createManNoStr", params.get("createManNoStr"));
                actualVoidMap.put("manNoStr", params.get("manNoStr"));
            }
            actualVoidMap.put("valueFlag", "0");
            List<HashMap> carActualVoidTotal = meterWorkCarActualMapper.countDayAllState(actualVoidMap);
            //结净未匹配委托总数
            HashMap<String, Object> actualNotMatchScaleMap = new HashMap<>();
            actualNotMatchScaleMap.put("startTime", params.get("startTime"));
            actualNotMatchScaleMap.put("endTime", params.get("endTime"));
            if (params.get("netSpot3NoStr") != null) {
                actualNotMatchScaleMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                actualNotMatchScaleMap.put("spotNoStr", params.get("spotNoStr"));
            }
            if (params.get("createManNoStr") != null) {
                actualNotMatchScaleMap.put("createManNoStr", params.get("createManNoStr"));
                actualNotMatchScaleMap.put("manNoStr", params.get("manNoStr"));
            }
            actualNotMatchScaleMap.put("isPreScale", "0");
            actualNotMatchScaleMap.put("validFlag", "1");
            List<HashMap> carActualNotMatchTotal = meterWorkCarActualMapper.countDayAllState(actualNotMatchScaleMap);
            if (carActualNotMatchTotal.size() >= 1) {
                for (HashMap modelTemp : carActualNotMatchTotal) {
                    countActualValidTemp += Long.parseLong(modelTemp.get("COUNT_ACTUAL").toString());
                }
            }
            //一次计量总数
            HashMap<String, Object> firstMap = new HashMap<>();
            firstMap.put("startTime", params.get("startTime"));
            firstMap.put("endTime", params.get("endTime"));
            if (params.get("netSpot3NoStr") != null) {
                firstMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                firstMap.put("spotNoStr", params.get("spotNoStr"));
            }
            if (params.get("createManNoStr") != null) {
                firstMap.put("createManNoStr", params.get("createManNoStr"));
                firstMap.put("manNoStr", params.get("manNoStr"));
            }
            firstMap.put("validFlag", "1");
            List<HashMap> carFirstTotal = meterWorkCarActualFirstMaper.countDayAllState(firstMap);
            if (carFirstTotal.size() >= 1) {
                for (HashMap modelTemp : carFirstTotal) {
                    countFirstTemp += Long.parseLong(modelTemp.get("COUNT_FIRST").toString());
                }
            }
            //未结净有效一次总数
            HashMap<String, Object> firstNotNetMap = new HashMap<>();
            firstNotNetMap.put("startTime", params.get("startTime"));
            firstNotNetMap.put("endTime", params.get("endTime"));
            if (params.get("netSpot3NoStr") != null) {
                firstNotNetMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                firstNotNetMap.put("spotNoStr", params.get("spotNoStr"));
            }
            if (params.get("createManNoStr") != null) {
                firstNotNetMap.put("createManNoStr", params.get("createManNoStr"));
                firstNotNetMap.put("manNoStr", params.get("manNoStr"));
            }
            firstNotNetMap.put("valueFlag", "1");
            List<HashMap> carFirst = meterWorkCarActualFirstMaper.countDayAllState(firstNotNetMap);
            if (carFirst.size() >= 1) {
                for (HashMap modelTemp : carFirst) {
                    countFirstValidTemp += Long.parseLong(modelTemp.get("COUNT_FIRST").toString());
                }
            }
            HashMap<String, Object> firstResetMap = new HashMap<>();
            firstResetMap.put("startTime", params.get("startTime"));
            firstResetMap.put("endTime", params.get("endTime"));
            if (params.get("netSpot3NoStr") != null) {
                firstResetMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                firstResetMap.put("spotNoStr", params.get("spotNoStr"));
            }
            if (params.get("createManNoStr") != null) {
                firstResetMap.put("createManNoStr", params.get("createManNoStr"));
                firstResetMap.put("manNoStr", params.get("manNoStr"));
            }
            List<HashMap> carFirstLog = meterBaseOperationLogMapper.countAllFirstState02(firstResetMap);

            HashMap<String, Object> obj = new HashMap<>();
            obj.put("startTime", params.get("startTime"));
            obj.put("endTime", params.get("endTime"));
            if (params.get("netSpot3NoStr") != null) {
                obj.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                obj.put("spotNoStr", params.get("spotNoStr"));
            }
            if (params.get("createManNoStr") != null) {
                obj.put("createManNoStr", params.get("createManNoStr"));
                obj.put("manNoStr", params.get("manNoStr"));
            }
            List<WorkLoadReportInfo> models = meterWorkDataCountMapper.groupByDayCarReportInfo(obj);
            if (spotModelList.size() >= 1) {
                for (MeterBaseSpotInfo spotModel : spotModelList) {
                    //写入返回值
                    HashMap<String, Object> params02 = new HashMap<>();
                    params02.put("baseSpotNo", spotModel.getBaseSpotNo());
                    params02.put("baseSpotName", spotModel.getBaseSpotName());
                    List<HashMap> carMap02List = new ArrayList<>();

                    //根据秤点和时间查询操作人编号、操作人名称、计量方式编号、计量方式名称、计量类型
                    List<WorkLoadReportInfo> modelTemp = models.stream()
                            .filter(item -> item.getBaseSpotNo().equals(spotModel.getBaseSpotNo())
                                    && item.getBaseSpotName().equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                    if (modelTemp.size() >= 1) {
                        //总结净数
                        List<HashMap> carActualTotalTemp01 = carActualTotal.stream().filter(item ->
                                item.get("NET_SPOT3_NO").equals(spotModel.getBaseSpotNo())
                                        && item.get("NET_SPOT3_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                        //作废结净总数
                        List<HashMap> carActualVoidTotalTemp01 = carActualVoidTotal.stream().filter(item ->
                                item.get("NET_SPOT3_NO").equals(spotModel.getBaseSpotNo())
                                        && item.get("NET_SPOT3_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                        //一次计量总数
                        List<HashMap> carFirstTotalTemp01 = carFirstTotal.stream().filter(item ->
                                item.get("BASE_SPOT_NO").equals(spotModel.getBaseSpotNo())
                                        && item.get("BASE_SPOT_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                        //修改车号总数
                        List<HashMap> carFirstLogTemp01 = carFirstLog.stream().filter(item ->
                                item.get("BASE_SPOT_NO").equals(spotModel.getBaseSpotNo())
                                        && item.get("BASE_SPOT_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());

                        for (WorkLoadReportInfo model : modelTemp) {
                            HashMap<String, Object> carMap = new HashMap<>();
                            carMap.put("createManNo", model.getCreateManNo());
                            carMap.put("createManName", model.getCreateManName());
                            carMap02List.add(carMap);

                            long countActualSum = 0L;
                            long countActualValidSum = 0L;
                            long countFirstSum = 0L;
//                            long countFirsValidtSum = 0L;
                            long carFirstLogSum = 0L;
                            if (carActualTotalTemp01 != null && carActualTotalTemp01.size() >= 1) {
                                List<HashMap> carActualTotalTemp02 = carActualTotalTemp01.stream().filter(item ->
                                        (item.get("NET_MAN_NO") == null || StringUtils.isEmpty(item.get("NET_MAN_NO").toString())
                                                || StringUtils.isEmpty(model.getCreateManNo()) || item.get("NET_MAN_NO").equals(model.getCreateManNo()))
                                                && (item.get("NET_MAN_NAME") == null || StringUtils.isEmpty(item.get("NET_MAN_NAME").toString())
                                                || StringUtils.isEmpty(model.getCreateManName()) || item.get("NET_MAN_NAME").equals(model.getCreateManName()))).collect(Collectors.toList());
                                if (carActualTotalTemp02 != null && carActualTotalTemp02.size() >= 1) {
                                    countActualSum = Long.parseLong(carActualTotalTemp02.get(0).get("COUNT_ACTUAL").toString());
                                }
                            }
                            if (carActualVoidTotalTemp01 != null && carActualVoidTotalTemp01.size() >= 1) {
                                List<HashMap> carActualVoidTotalTemp02 = carActualVoidTotalTemp01.stream().filter(item ->
                                        (item.get("NET_MAN_NO") == null || StringUtils.isEmpty(item.get("NET_MAN_NO").toString())
                                                || StringUtils.isEmpty(model.getCreateManNo()) || item.get("NET_MAN_NO").equals(model.getCreateManNo()))
                                                && (item.get("NET_MAN_NAME") == null || StringUtils.isEmpty(item.get("NET_MAN_NAME").toString())
                                                || StringUtils.isEmpty(model.getCreateManName()) || item.get("NET_MAN_NAME").equals(model.getCreateManName()))).collect(Collectors.toList());
                                if (carActualVoidTotalTemp02 != null && carActualVoidTotalTemp02.size() >= 1) {
                                    countActualValidSum = Long.parseLong(carActualVoidTotalTemp02.get(0).get("COUNT_ACTUAL").toString());
                                }
                            }
                            if (carFirstTotalTemp01 != null && carFirstTotalTemp01.size() >= 1) {
                                List<HashMap> carFirstTotalTemp02 = carFirstTotalTemp01.stream().filter(item ->
                                        (item.get("CREATE_MAN_NO") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NO").toString())
                                                || StringUtils.isEmpty(model.getCreateManNo()) || item.get("CREATE_MAN_NO").equals(model.getCreateManNo()))
                                                && (item.get("CREATE_MAN_NAME") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NAME").toString())
                                                || StringUtils.isEmpty(model.getCreateManName()) || item.get("CREATE_MAN_NAME").equals(model.getCreateManName()))).collect(Collectors.toList());
                                if (carFirstTotalTemp02 != null && carFirstTotalTemp02.size() >= 1) {
                                    countFirstSum = Long.parseLong(carFirstTotalTemp02.get(0).get("COUNT_FIRST").toString());
                                }
                            }
                            if (carFirstLogTemp01 != null && carFirstLogTemp01.size() >= 1) {
                                List<HashMap> carFirstLogTemp02 = carFirstLogTemp01.stream().filter(item ->
                                        (item.get("CREATE_MAN_NO") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NO").toString())
                                                || StringUtils.isEmpty(model.getCreateManNo()) || item.get("CREATE_MAN_NO").toString().equals(model.getCreateManNo()))
                                                && (item.get("CREATE_MAN_NAME") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NAME").toString())
                                                || StringUtils.isEmpty(model.getCreateManName()) || item.get("CREATE_MAN_NAME").toString().equals(model.getCreateManName()))).collect(Collectors.toList());
                                if (carFirstLogTemp02 != null && carFirstLogTemp02.size() >= 1) {
                                    carFirstLogSum = Long.parseLong(carFirstLogTemp02.get(0).get("COUNT_RESETCAR").toString());
                                }
                            }
                            carMap.put("countActualSum", countActualSum);
                            carMap.put("countActualValidSum", countActualValidSum);
                            carMap.put("countFirstSum", countFirstSum);
                            carMap.put("carFirstLogSum", carFirstLogSum);

//                            countActualTemp += countActualSum;
//                            countFirstTemp += countFirstSum;
//                            countActualValidTemp += countActualValidSum;
//                            countFirstValidTemp += countFirsValidtSum;
                        }
                        params02.put("childrenBase", carMap02List);
                    } else {
                        HashMap<String, Object> carMap = new HashMap<>();
                        carMap.put("createManNo", null);
                        carMap.put("createManName", null);
                        carMap02List.add(carMap);
                        carMap.put("countActualSum", 0L);
                        carMap.put("countFirstSum", 0L);
                        carMap.put("carFirstLogSum", 0L);
                        params02.put("childrenBase", carMap02List);
                    }
                    paramsList02.add(params02);
                }
                params01.put("countActualTemp", countActualValidTemp);
                params01.put("countFirstTemp", countFirstValidTemp);
                params01.put("type", "汽车衡");
                params01.put("countFirst", countFirstTemp);
                params01.put("countActual", countActualTemp);
                params01.put("children", paramsList02);
                paramsList.add(params01);
            }
        }

        {
            String[][] railwayTypeNoList = new String[][]{{"001019001"}, {"001019002"}, {"001019003", "001019004"}, {"001019005"}};
            for (int i = 0; i <= railwayTypeNoList.length - 1; i++) {
                String[] railwayTypeNo = railwayTypeNoList[i];
                HashMap params01 = new HashMap();
                List<HashMap> paramsList02 = new ArrayList<>();
                //总结净
                countActualTemp = 0L;
                //总一次
                countFirstTemp = 0L;
                //结净未匹配委托总数
                countActualValidTemp = 0L;
                //未结净有效一次总数
                countFirstValidTemp = 0L;
                //静态轨道衡
//                String[] railwayTypeNo = new String[]{"001019001"};
                HashMap<String, Object> spotModelMap = new HashMap<>();
                spotModelMap.put("startTime", params.get("startTime"));
                spotModelMap.put("endTime", params.get("endTime"));
                spotModelMap.put("railwayTypeNo", railwayTypeNo);
                if (params.get("netSpot3NoStr") != null) {
                    spotModelMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    spotModelMap.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    String[] manNoStr = params.get("createManNoStr").toString().split(",");
                    params.put("manNoStr", manNoStr);
                }
                List<MeterBaseSpotInfo> spotModelList = meterBaseSpotInfoMapper.staticSpotGroupByActualAndFirst(spotModelMap);

                //总结净数
                HashMap<String, Object> actualMap = new HashMap<>();
                actualMap.put("startTime", params.get("startTime"));
                actualMap.put("endTime", params.get("endTime"));
                actualMap.put("railwayTypeNo", railwayTypeNo);
                if (params.get("netSpot3NoStr") != null) {
                    actualMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    actualMap.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    actualMap.put("createManNoStr", params.get("createManNoStr"));
                    actualMap.put("manNoStr", params.get("manNoStr"));
                }
                actualMap.put("validFlag", "1");
                List<HashMap> carActualTotal = meterWorkRailwayActualMapper.countDayAllState(actualMap);
                if (carActualTotal.size() >= 1) {
                    for (HashMap modelTemp : carActualTotal) {
                        countActualTemp += Long.parseLong(modelTemp.get("COUNT_ACTUAL").toString());
                    }
                }
                //作废结净总数
                HashMap<String, Object> actualVoidMap = new HashMap<>();
                actualVoidMap.put("startTime", params.get("startTime"));
                actualVoidMap.put("endTime", params.get("endTime"));
                actualVoidMap.put("railwayTypeNo", railwayTypeNo);
                if (params.get("netSpot3NoStr") != null) {
                    actualVoidMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    actualVoidMap.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    actualVoidMap.put("createManNoStr", params.get("createManNoStr"));
                    actualVoidMap.put("manNoStr", params.get("manNoStr"));
                }
                actualVoidMap.put("valueFlag", "0");
                List<HashMap> carActualVoidTotal = meterWorkRailwayActualMapper.countDayAllState(actualVoidMap);
                //结净未匹配委托总数
                HashMap<String, Object> actualNotMatchScaleMap = new HashMap<>();
                actualNotMatchScaleMap.put("startTime", params.get("startTime"));
                actualNotMatchScaleMap.put("endTime", params.get("endTime"));
                actualNotMatchScaleMap.put("railwayTypeNo", railwayTypeNo);
                if (params.get("netSpot3NoStr") != null) {
                    actualNotMatchScaleMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    actualNotMatchScaleMap.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    actualNotMatchScaleMap.put("createManNoStr", params.get("createManNoStr"));
                    actualNotMatchScaleMap.put("manNoStr", params.get("manNoStr"));
                }
                actualNotMatchScaleMap.put("isPreSacale", "0");
                actualNotMatchScaleMap.put("validFlag", "1");
                List<HashMap> carActualNotMatchTotal = meterWorkRailwayActualMapper.countDayAllState(actualNotMatchScaleMap);
                if (carActualNotMatchTotal.size() >= 1) {
                    for (HashMap modelTemp : carActualNotMatchTotal) {
                        countActualValidTemp += Long.parseLong(modelTemp.get("COUNT_ACTUAL").toString());
                    }
                }
                //一次计量总数
                HashMap<String, Object> firstMap = new HashMap<>();
                firstMap.put("startTime", params.get("startTime"));
                firstMap.put("endTime", params.get("endTime"));
                if (params.get("netSpot3NoStr") != null) {
                    firstMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    firstMap.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    firstMap.put("createManNoStr", params.get("createManNoStr"));
                    firstMap.put("manNoStr", params.get("manNoStr"));
                }
                firstMap.put("railwayTypeNo", railwayTypeNo);
                firstMap.put("validFlag", "1");
                List<HashMap> carFirstTotal = meterWorkRailwayActFirstMapper.countDayAllState(firstMap);
                if (carFirstTotal.size() >= 1) {
                    for (HashMap modelTemp : carFirstTotal) {
                        countFirstTemp += Long.parseLong(modelTemp.get("COUNT_FIRST").toString());
                    }
                }
                //未结净有效一次总数
                HashMap<String, Object> firstNotNetMap = new HashMap<>();
                firstNotNetMap.put("startTime", params.get("startTime"));
                firstNotNetMap.put("endTime", params.get("endTime"));
                firstNotNetMap.put("railwayTypeNo", railwayTypeNo);
                if (params.get("netSpot3NoStr") != null) {
                    firstNotNetMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    firstNotNetMap.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    firstNotNetMap.put("createManNoStr", params.get("createManNoStr"));
                    firstNotNetMap.put("manNoStr", params.get("manNoStr"));
                }
                firstNotNetMap.put("valueFlag", "1");
                List<HashMap> carFirst = meterWorkRailwayActFirstMapper.countDayAllState(firstNotNetMap);
                if (carFirst.size() >= 1) {
                    for (HashMap modelTemp : carFirst) {
                        countFirstValidTemp += Long.parseLong(modelTemp.get("COUNT_FIRST").toString());
                    }
                }
                HashMap<String, Object> firstResetMap = new HashMap<>();
                firstResetMap.put("startTime", params.get("startTime"));
                firstResetMap.put("endTime", params.get("endTime"));
                firstResetMap.put("railwayTypeNo", railwayTypeNo);
                if (params.get("netSpot3NoStr") != null) {
                    firstResetMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    firstResetMap.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    firstResetMap.put("createManNoStr", params.get("createManNoStr"));
                    firstResetMap.put("manNoStr", params.get("manNoStr"));
                }
                List<HashMap> carFirstLog = meterBaseOperationLogMapper.countAllFirstState03(firstResetMap);

                HashMap<String, Object> obj = new HashMap<>();
                obj.put("startTime", params.get("startTime"));
                obj.put("endTime", params.get("endTime"));
                obj.put("railwayTypeNo", railwayTypeNo);
                if (params.get("netSpot3NoStr") != null) {
                    obj.put("netSpot3NoStr", params.get("netSpot3NoStr"));
                    obj.put("spotNoStr", params.get("spotNoStr"));
                }
                if (params.get("createManNoStr") != null) {
                    obj.put("createManNoStr", params.get("createManNoStr"));
                    obj.put("manNoStr", params.get("manNoStr"));
                }
                List<WorkLoadReportInfo> models = meterWorkDataCountMapper.groupByDayStaticReportInfo(obj);
                if (spotModelList.size() >= 1) {
                    for (MeterBaseSpotInfo spotModel : spotModelList) {
                        //写入返回值
                        HashMap<String, Object> params02 = new HashMap<>();
                        params02.put("baseSpotNo", spotModel.getBaseSpotNo());
                        params02.put("baseSpotName", spotModel.getBaseSpotName());
                        List<HashMap> carMap02List = new ArrayList<>();
                        //根据秤点和时间查询操作人编号、操作人名称、计量方式编号、计量方式名称、计量类型
                        List<WorkLoadReportInfo> modelTemp = models.stream()
                                .filter(item -> item.getBaseSpotNo().equals(spotModel.getBaseSpotNo())
                                        && item.getBaseSpotName().equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                        if (modelTemp.size() >= 1) {
                            //总结净数
                            List<HashMap> carActualTotalTemp01 = carActualTotal.stream().filter(item ->
                                    item.get("NET_SPOT3_NO").equals(spotModel.getBaseSpotNo())
                                            && item.get("NET_SPOT3_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                            //作废结净总数
                            List<HashMap> carActualVoidTotalTemp01 = carActualVoidTotal.stream().filter(item ->
                                    item.get("NET_SPOT3_NO").equals(spotModel.getBaseSpotNo())
                                            && item.get("NET_SPOT3_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                            //一次计量总数
                            List<HashMap> carFirstTotalTemp01 = carFirstTotal.stream().filter(item ->
                                    item.get("BASE_SPOT_NO").equals(spotModel.getBaseSpotNo())
                                            && item.get("BASE_SPOT_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                            //修改车号总数
                            List<HashMap> carFirstLogTemp01 = carFirstLog.stream().filter(item ->
                                    item.get("BASE_SPOT_NO").equals(spotModel.getBaseSpotNo())
                                            && item.get("BASE_SPOT_NAME").equals(spotModel.getBaseSpotName())).collect(Collectors.toList());
                            for (WorkLoadReportInfo model : modelTemp) {
                                HashMap<String, Object> carMap = new HashMap<>();
                                carMap.put("createManNo", model.getCreateManNo());
                                carMap.put("createManName", model.getCreateManName());
                                carMap02List.add(carMap);

                                long countActualSum = 0L;
                                long countActualValidSum = 0L;
                                long countFirstSum = 0L;
//                            long countFirsValidtSum = 0L;
                                long carFirstLogSum = 0L;
                                if (carActualTotalTemp01 != null && carActualTotalTemp01.size() >= 1) {
                                    List<HashMap> carActualTotalTemp02 = carActualTotalTemp01.stream().filter(item ->
                                            (item.get("NET_MAN_NO") == null || StringUtils.isEmpty(item.get("NET_MAN_NO").toString())
                                                    || StringUtils.isEmpty(model.getCreateManNo()) || item.get("NET_MAN_NO").equals(model.getCreateManNo()))
                                                    && (item.get("NET_MAN_NAME") == null || StringUtils.isEmpty(item.get("NET_MAN_NAME").toString())
                                                    || StringUtils.isEmpty(model.getCreateManName()) || item.get("NET_MAN_NAME").equals(model.getCreateManName()))).collect(Collectors.toList());
                                    if (carActualTotalTemp02 != null && carActualTotalTemp02.size() >= 1) {
                                        countActualSum = Long.parseLong(carActualTotalTemp02.get(0).get("COUNT_ACTUAL").toString());
                                    }
                                }
                                if (carActualVoidTotalTemp01 != null && carActualVoidTotalTemp01.size() >= 1) {
                                    List<HashMap> carActualVoidTotalTemp02 = carActualVoidTotalTemp01.stream().filter(item ->
                                            (item.get("NET_MAN_NO") == null || StringUtils.isEmpty(item.get("NET_MAN_NO").toString())
                                                    || StringUtils.isEmpty(model.getCreateManNo()) || item.get("NET_MAN_NO").equals(model.getCreateManNo()))
                                                    && (item.get("NET_MAN_NAME") == null || StringUtils.isEmpty(item.get("NET_MAN_NAME").toString())
                                                    || StringUtils.isEmpty(model.getCreateManName()) || item.get("NET_MAN_NAME").equals(model.getCreateManName()))).collect(Collectors.toList());
                                    if (carActualVoidTotalTemp02 != null && carActualVoidTotalTemp02.size() >= 1) {
                                        countActualValidSum = Long.parseLong(carActualVoidTotalTemp02.get(0).get("COUNT_ACTUAL").toString());
                                    }
                                }
                                if (carFirstTotalTemp01 != null && carFirstTotalTemp01.size() >= 1) {
                                    List<HashMap> carFirstTotalTemp02 = carFirstTotalTemp01.stream().filter(item ->
                                            (item.get("CREATE_MAN_NO") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NO").toString())
                                                    || StringUtils.isEmpty(model.getCreateManNo()) || item.get("CREATE_MAN_NO").equals(model.getCreateManNo()))
                                                    && (item.get("CREATE_MAN_NAME") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NAME").toString())
                                                    || StringUtils.isEmpty(model.getCreateManName()) || item.get("CREATE_MAN_NAME").equals(model.getCreateManName()))).collect(Collectors.toList());
                                    if (carFirstTotalTemp02 != null && carFirstTotalTemp02.size() >= 1) {
                                        countFirstSum = Long.parseLong(carFirstTotalTemp02.get(0).get("COUNT_FIRST").toString());
                                    }
                                }
                                if (carFirstLogTemp01 != null && carFirstLogTemp01.size() >= 1) {
                                    List<HashMap> carFirstLogTemp02 = carFirstLogTemp01.stream().filter(item ->
                                            (item.get("CREATE_MAN_NO") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NO").toString())
                                                    || StringUtils.isEmpty(model.getCreateManNo()) || item.get("CREATE_MAN_NO").toString().equals(model.getCreateManNo()))
                                                    && (item.get("CREATE_MAN_NAME") == null || StringUtils.isEmpty(item.get("CREATE_MAN_NAME").toString())
                                                    || StringUtils.isEmpty(model.getCreateManName()) || item.get("CREATE_MAN_NAME").toString().equals(model.getCreateManName()))).collect(Collectors.toList());
                                    if (carFirstLogTemp02 != null && carFirstLogTemp02.size() >= 1) {
                                        carFirstLogSum = Long.parseLong(carFirstLogTemp02.get(0).get("COUNT_RESETCAR").toString());
                                    }
                                }
                                carMap.put("countActualSum", countActualSum);
                                carMap.put("countActualValidSum", countActualValidSum);
                                carMap.put("countFirstSum", countFirstSum);
                                carMap.put("carFirstLogSum", carFirstLogSum);

//                                countActualTemp += countActualSum;
//                                countFirstTemp += countFirstSum;
//                                countActualValidTemp += countActualValidSum;
//                            countFirstValidTemp += countFirsValidtSum;
                            }
                            params02.put("childrenBase", carMap02List);
                        } else {
                            HashMap<String, Object> carMap = new HashMap<>();
                            carMap.put("createManNo", null);
                            carMap.put("createManName", null);
                            carMap02List.add(carMap);
                            carMap.put("countActualSum", 0L);
                            carMap.put("countFirstSum", 0L);
                            carMap.put("carFirstLogSum", 0L);
                            params02.put("childrenBase", carMap02List);
                        }
                        paramsList02.add(params02);
                    }
                    params01.put("countActualTemp", countActualValidTemp);
                    params01.put("countFirstTemp", countFirstValidTemp);
                    if (i == 0) {
                        params01.put("type", "静态轨轨道衡");
                    } else if (i == 1) {
                        params01.put("type", "动态轨轨道衡");
                    } else if (i == 2) {
                        params01.put("type", "铁水衡");
                    } else if (i == 3) {
                        params01.put("type", "吊钩秤");
                    }
                    params01.put("countFirst", countFirstTemp);
                    params01.put("countActual", countActualTemp);
                    params01.put("children", paramsList02);
                    paramsList.add(params01);
                }
            }
        }
        return paramsList;
    }

    @Override
    public PageList<TruckHisTareComparison> truckHisTareComparison(HashMap<String, Object> params) {
        ComBaseInfo comBaseInfo = comBaseInfoMapper.selectByPrimaryKey("001067001");
        Double base = 0.0;
        try {
            base = Double.parseDouble(comBaseInfo.getBaseName());
        }catch (Exception e){
            e.printStackTrace();
            log.error("数据类型不符",e);
        }
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<TruckHisTareComparison> models = meterWorkDataCountMapper.truckHisTareComparison(params);
        for (TruckHisTareComparison model : models) {
            model.setBase(base);
        }
        PageList<TruckHisTareComparison> rows = new PageList<>(models);
        return rows;
    }

    @Override
    public List<String> measurementAccuracyAnalysisFunction(HashMap<String, Object> params) {
        List<String> models = meterWorkDataCountMapper.measurementAccuracyAnalysisFunction(params);
        return models;
    }

    @Override
    public PageList<MeasurementAccuracyAnalysis> measurementAccuracyAnalysis(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        if(params.get("operationFunction") != null) {
            String[] operationFunctionList =  params.get("operationFunction").toString().split(",");
            params.put("operationFunctionList", operationFunctionList);
        }

        if(params.get("operationPage") != null) {
            String[] operationFunctionList =  params.get("operationPage").toString().split(",");
            params.put("operationPageList", operationFunctionList);
        }

        if(params.get("createManName") != null) {
            String[] operationFunctionList =  params.get("createManName").toString().split(",");
            params.put("createManNameList", operationFunctionList);
        }
        List<MeasurementAccuracyAnalysis> models = meterWorkDataCountMapper.measurementAccuracyAnalysis(params);
        if (models.size() >= 1) {
            for (MeasurementAccuracyAnalysis model : models) {
                if (StringUtils.isNotEmpty(model.getBeforeFix())) {
                    String str = model.getBeforeFix();
                    if(str.indexOf("MeterWorkCarActualFirst") >= 0){
                        model.setBeforeFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkCarActual") >= 0) {
                        model.setBeforeFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkRailwayActFirst") >= 0) {
                        model.setBeforeFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkRailwayActual") >= 0) {
                        model.setBeforeFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkRailwayReceived") >= 0) {
                        model.setBeforeFix(translationModel(str));
                    }
                }
                if (StringUtils.isNotEmpty(model.getAfterFix())) {
                    String str = model.getAfterFix();
                    if(str.indexOf("MeterWorkCarActualFirst") >= 0){
                        model.setAfterFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkCarActual") >= 0) {
                        model.setAfterFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkRailwayActFirst") >= 0) {
                        model.setAfterFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkRailwayActual") >= 0) {
                        model.setAfterFix(translationModel(str));
                    }else if(str.indexOf("MeterWorkRailwayReceived") >= 0) {
                        model.setAfterFix(translationModel(str));
                    }
                }
            }
        }
        PageList<MeasurementAccuracyAnalysis> rows = new PageList<>(models);
        return rows;
    }

    public String translationModel(String str) {
        String strAll = "";
        if(str.indexOf("MeterWorkCarActualFirst") >= 0){
            if(str.indexOf("predictionNo=") >= 1) {
                str = str.substring(str.indexOf("predictionNo="));
                strAll += "委托号:" + str.substring("predictionNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("carNo=") >= 1) {
                str = str.substring(str.indexOf("carNo="));
                strAll += ", 车号:" + str.substring("carNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("meterWeight=") >= 1) {
                str = str.substring(str.indexOf("meterWeight="));
                String meterWeightStr = str.substring("meterWeight=".length(), str.indexOf(","));
                String meterWeight = "0.00";
                if(!meterWeightStr.equals("null")) {
                    meterWeight = String.format("%.2f", Double.parseDouble(meterWeightStr)/1000);
                }
                strAll += ", 重量:" + meterWeight + "t";
            }
            if(str.indexOf("baseSpotName=") >= 1) {
                str = str.substring(str.indexOf("baseSpotName="));
                strAll += ", 计量点:" + str.substring("baseSpotName=".length(), str.indexOf(","));
            }
        }
        if(str.indexOf("MeterWorkCarActual") >= 0){
            if(str.indexOf("predictionNo=") >= 1) {
                str = str.substring(str.indexOf("predictionNo="));
                strAll += "委托号:" + str.substring("predictionNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("carNo=") >= 1) {
                str = str.substring(str.indexOf("carNo="));
                strAll += ", 车号:" + str.substring("carNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("grossWeight=") >= 1) {
                str = str.substring(str.indexOf("grossWeight="));
                String grossStr = str.substring("grossWeight=".length(), str.indexOf(","));
                String grossWeight = "0.00";
                if(!grossStr.equals("null")) {
                    grossWeight = String.format("%.2f", Double.parseDouble(grossStr)/1000);
                }
                strAll += ", 毛重:" + grossWeight + "t";
            }
            if(str.indexOf("baseSpot1Name=") >= 1) {
                str = str.substring(str.indexOf("baseSpot1Name="));
                strAll += ", 毛重计量点:" + str.substring("baseSpot1Name=".length(), str.indexOf(","));
            }
            if(str.indexOf("tareWeight=") >= 1) {
                str = str.substring(str.indexOf("tareWeight="));
                String tareStr = str.substring("tareWeight=".length(), str.indexOf(","));
                String tareWeight = "0.00";
                if(!tareStr.equals("null")) {
                    tareWeight = String.format("%.2f", Double.parseDouble(tareStr)/1000);
                }
                strAll += ", 皮重:" + tareWeight + "t";
            }
            if(str.indexOf("baseSpot2Name=") >= 1) {
                str = str.substring(str.indexOf("baseSpot2Name="));
                strAll += ", 皮重计量点:" + str.substring("baseSpot2Name=".length(), str.indexOf(","));
            }
            if(str.indexOf("netWeight=") >= 1) {
                str = str.substring(str.indexOf("netWeight="));
                String netStr = str.substring("netWeight=".length(), str.indexOf(","));
                String netWeight = "0.00";
                if(!netStr.equals("null")) {
                    netWeight = String.format("%.2f", Double.parseDouble(netStr)/1000);
                }
                strAll += ", 净重:" + netWeight + "t";
            }
            if(str.indexOf("netSpot3Name=") >= 1) {
                str = str.substring(str.indexOf("netSpot3Name="));
                strAll += ", 净重计量点:" + str.substring("netSpot3Name=".length(), str.indexOf(","));
            }
        }
        if(str.indexOf("MeterWorkRailwayActFirst") >= 0){
            if(str.indexOf("predictionNo=") >= 1) {
                str = str.substring(str.indexOf("predictionNo="));
                strAll += "委托号:" + str.substring("predictionNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("railwayNo=") >= 1) {
                str = str.substring(str.indexOf("railwayNo="));
                strAll += ", 车号:" + str.substring("railwayNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("meterWeight=") >= 1) {
                str = str.substring(str.indexOf("meterWeight="));
                String meterWeightStr = str.substring("meterWeight=".length(), str.indexOf(","));
                String meterWeight = "0.00";
                if(!meterWeightStr.equals("null")) {
                    meterWeight = String.format("%.2f", Double.parseDouble(meterWeightStr)/1000);
                }
                strAll += ", 重量:" + meterWeight + "t";
            }
            if(str.indexOf("baseSpotName=") >= 1) {
                str = str.substring(str.indexOf("baseSpotName="));
                strAll += ", 计量点:" + str.substring("baseSpotName=".length(), str.indexOf(","));
            }
        }
        if(str.indexOf("MeterWorkRailwayActual") >= 0){
            if(str.indexOf("predictionNo=") >= 1) {
                str = str.substring(str.indexOf("predictionNo="));
                strAll += "委托号:" + str.substring("predictionNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("railwayNo=") >= 1) {
                str = str.substring(str.indexOf("railwayNo="));
                strAll += ", 车号:" + str.substring("railwayNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("grossWeight=") >= 1) {
                str = str.substring(str.indexOf("grossWeight="));
                String grossStr = str.substring("grossWeight=".length(), str.indexOf(","));
                String grossWeight = "0.00";
                if(!grossStr.equals("null")) {
                    grossWeight = String.format("%.2f", Double.parseDouble(grossStr)/1000);
                }
                strAll += ", 毛重:" + grossWeight + "t";
            }
            if(str.indexOf("baseSpot1Name=") >= 1) {
                str = str.substring(str.indexOf("baseSpot1Name="));
                strAll += ", 毛重计量点:" + str.substring("baseSpot1Name=".length(), str.indexOf(","));
            }
            if(str.indexOf("tareWeight=") >= 1) {
                str = str.substring(str.indexOf("tareWeight="));
                String tareStr = str.substring("tareWeight=".length(), str.indexOf(","));
                String tareWeight = "0.00";
                if(!tareStr.equals("null")) {
                    tareWeight = String.format("%.2f", Double.parseDouble(tareStr)/1000);
                }
                strAll += ", 皮重:" + tareWeight + "t";
            }
            if(str.indexOf("baseSpot2Name=") >= 1) {
                str = str.substring(str.indexOf("baseSpot2Name="));
                strAll += ", 皮重计量点:" + str.substring("baseSpot2Name=".length(), str.indexOf(","));
            }
            if(str.indexOf("netWeight=") >= 1) {
                str = str.substring(str.indexOf("netWeight="));
                String netStr = str.substring("netWeight=".length(), str.indexOf(","));
                String netWeight = "0.00";
                if(!netStr.equals("null")) {
                    netWeight = String.format("%.2f", Double.parseDouble(netStr)/1000);
                }
                strAll += ", 净重:" + netWeight + "t";
            }
            if(str.indexOf("netSpot3Name=") >= 1) {
                str = str.substring(str.indexOf("netSpot3Name="));
                strAll += ", 净重计量点:" + str.substring("netSpot3Name=".length(), str.indexOf(","));
            }
        }
        if(str.indexOf("MeterWorkRailwayReceived") >= 0){
            if(str.indexOf("predictionNo=") >= 1) {
                str = str.substring(str.indexOf("predictionNo="));
                strAll += "委托号:" + str.substring("predictionNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("railwayNo=") >= 1) {
                str = str.substring(str.indexOf("railwayNo="));
                strAll += ", 车号:" + str.substring("railwayNo=".length(), str.indexOf(","));
            }
            if(str.indexOf("meterWeight=") >= 1) {
                str = str.substring(str.indexOf("meterWeight="));
                String meterWeightStr = str.substring("meterWeight=".length(), str.indexOf(","));
                String meterWeight = "0.00";
                if(!meterWeightStr.equals("null")) {
                    meterWeight = String.format("%.2f", Double.parseDouble(meterWeightStr)/1000);
                }
                strAll += ", 重量:" + meterWeight + "t";
            }
            if(str.indexOf("baseSpotName=") >= 1) {
                str = str.substring(str.indexOf("baseSpotName="));
                strAll += ", 计量点:" + str.substring("baseSpotName=".length(), str.indexOf(","));
            }
        }
        return strAll;
    }

    @Override
    public PageList<HookTareWeightAndTheoryAmount> hookTareWeightAndTheoryAmount(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<HookTareWeightAndTheoryAmount> rows = meterWorkDataCountMapper.hookTareWeightAndTheoryAmount(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<TwoMillionTareWeightComparison> twoMillionTareWeightComparison(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<TwoMillionTareWeightComparison> rows = meterWorkDataCountMapper.twoMillionTareWeightComparison(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<StaticRailwayRemoteComparison> staticRailwayRemoteComparison(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<StaticRailwayRemoteComparison> rows = meterWorkDataCountMapper.staticRailwayRemoteComparison(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public List<HashMap> rfidIdentifyAnalysisSummary(HashMap<String, Object> params) {
        List<MeterBaseSpotInfo> spotModels = meterWorkDataCountMapper.rfidIdentifyAnalysisSummarySpot(params);
        List<RfidIdentifyAnalysis> rfidIdentifyList = meterWorkDataCountMapper.rfidIdentifyAnalysisSummary(params);
        List<HashMap> mapList = new ArrayList<>();
        if(spotModels.size() >= 1) {
            for(MeterBaseSpotInfo spotModel: spotModels) {
                if(!("1#公路汽车衡北秤".equals(spotModel.getBaseSpotName())
                        ||"1#公路汽车衡南秤".equals(spotModel.getBaseSpotName())
                        ||"200万料场汽车衡".equals(spotModel.getBaseSpotName())
                        ||"废钢汽车衡".equals(spotModel.getBaseSpotName()))){//限制
                    continue;
                }
                long countFirst = 0L;
                long countIdentifyYes = 0L;
                double countIdentifyRate = 0.0;
                long countIdentifyNo = 0L;
                long countOtherIdentify = 0L;
                if(rfidIdentifyList.size() >= 1) {
                    //一次计量数据总数
                    countFirst = rfidIdentifyList.stream().filter(item -> item.getBaseSpotNo().equals(spotModel.getBaseSpotNo())
                            && item.getBaseSpotName().equals(spotModel.getBaseSpotName())
                            && StringUtils.isNotEmpty(item.getActualFirstNo())).count();
                    //Rfid识别总数
                    countIdentifyYes = rfidIdentifyList.stream().filter(item -> item.getBaseSpotNo().equals(spotModel.getBaseSpotNo())
                            && item.getBaseSpotName().equals(spotModel.getBaseSpotName())
                            && item.getCarNoType().equals("Rfid识别")
                            && StringUtils.isNotEmpty(item.getRfidIdentifyRfidCarNo())).count();
                    //Rfid识别率
                    countIdentifyRate = Math.round((countIdentifyYes)/(countFirst*1.0)*100*100)/100.0;
                    //Rfid未识别总数
                    countIdentifyNo = rfidIdentifyList.stream().filter(item -> item.getBaseSpotNo().equals(spotModel.getBaseSpotNo())
                            && item.getBaseSpotName().equals(spotModel.getBaseSpotName())
                            && item.getCarNoType().equals("Rfid识别")
                            && StringUtils.isEmpty(item.getRfidIdentifyRfidCarNo())).count();
                    //其他视频识别总数
                    countOtherIdentify = rfidIdentifyList.stream().filter(item -> item.getBaseSpotNo().equals(spotModel.getBaseSpotNo())
                            && item.getBaseSpotName().equals(spotModel.getBaseSpotName())
                            && !item.getCarNoType().equals("Rfid识别")).count();
                }
                HashMap<String, Object> map = new HashMap<>();
                map.put("baseSpotNo", spotModel.getBaseSpotNo());
                map.put("baseSpotName", spotModel.getBaseSpotName());
                map.put("countFirst", countFirst);
                map.put("countIdentifyYes", countIdentifyYes);
                map.put("countIdentifyRate", countIdentifyRate);
                map.put("countIdentifyNo", countIdentifyNo);
                map.put("countOtherIdentify", countOtherIdentify);
                mapList.add(map);
            }
        }
        return mapList;
    }

    @Override
    public PageList<RfidIdentifyAnalysis> rfidIdentifyAnalysisDetail(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<RfidIdentifyAnalysis> rows = meterWorkDataCountMapper.rfidIdentifyAnalysisSummary(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public List<HashMap> pikaCarNumAnalysisSummary(HashMap<String, Object> params) {
        if(params.get("netSpot3NoStr") != null) {
            String[] spotNoStr = params.get("netSpot3NoStr").toString().split(",");
            params.put("spotNoStr", spotNoStr);
        }
        List<HashMap> instrumentTypeList = new ArrayList<>();

        //汽车衡
        HashMap<String, Object> map = new HashMap<>();
        List<MeterBaseSpotInfo> spotModels = meterBaseSpotInfoMapper.spotGroupCarActual(params);
        if(spotModels.size() >= 1) {
            HashMap<String, Object> instrumentTypeMap = new HashMap<>();
            instrumentTypeMap.put("instrumentType", "汽车衡");
            List<HashMap> spotList = new ArrayList<>();
            List<MeterWorkCarActual> carActual = meterWorkCarActualMapper.countAllState(params);
            for(MeterBaseSpotInfo spotModel: spotModels) {
                long countActual = 0L;
                long countMatchedActual = 0L;
                long countNotMatchActual = 0L;
                long countUploadActual = 0L;
                if(carActual.size() >= 1) {
                    countActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                        && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                        && !item.getValueFlag().equals("0")).count();
                    countMatchedActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                            && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                            && !item.getValueFlag().equals("0")
                            && item.getIsPreScale().equals("1")).count();
                    countNotMatchActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                            && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                            && !item.getValueFlag().equals("0")
                            && ( StringUtils.isEmpty(item.getIsPreScale()) || item.getIsPreScale().equals("0") )).count();
                    countUploadActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                            && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                            && !item.getValueFlag().equals("0")
                            && item.getIsPreScale().equals("1")
                            && item.getValueFlag().equals("1")
                            && item.getUploadFlag().equals("2")).count();

                }
                HashMap<String, Object> actualMap = new HashMap<>();
                actualMap.put("baseSpotNo", spotModel.getBaseSpotNo());
                actualMap.put("baseSpotName", spotModel.getBaseSpotName());
                actualMap.put("countActual", countActual);
                actualMap.put("countMatchedActual", countMatchedActual);
                actualMap.put("countNotMatchActual", countNotMatchActual);
                actualMap.put("countUploadActual", countUploadActual);
                spotList.add(actualMap);
            }
            instrumentTypeMap.put("spotList", spotList);
            instrumentTypeList.add(instrumentTypeMap);
        }

        String[][] railwayTypeNoList = new String[][]{{"001019001"}, {"001019002"}, {"001019003", "001019004"}, {"001019005"}};
        for (int i = 0; i <= railwayTypeNoList.length - 1; i++) {
            String[] typeNoStr = railwayTypeNoList[i];
            HashMap<String, Object> railwayMap = new HashMap<>();
            railwayMap.put("startTime", params.get("startTime"));
            railwayMap.put("endTime", params.get("endTime"));
            railwayMap.put("netSpot3NoStr", params.get("netSpot3NoStr"));
            railwayMap.put("spotNoStr", params.get("spotNoStr"));
            railwayMap.put("railwayTypeNoStr", "1");
            railwayMap.put("typeNoStr", typeNoStr);
            spotModels = meterBaseSpotInfoMapper.spotGroupRailwayActual(railwayMap);
            if(spotModels.size() >= 1) {
                HashMap<String, Object> instrumentTypeMap = new HashMap<>();
                if (i == 0) {
                    instrumentTypeMap.put("instrumentType", "静态轨轨道衡");
                } else if (i == 1) {
                    instrumentTypeMap.put("instrumentType", "动态轨轨道衡");
                } else if (i == 2) {
                    instrumentTypeMap.put("instrumentType", "铁水衡");
                } else if (i == 3) {
                    instrumentTypeMap.put("instrumentType", "吊钩秤");
                }
                List<HashMap> spotList = new ArrayList<>();
                List<MeterWorkRailwayActual> carActual = meterWorkRailwayActualMapper.carActualDataDetail(railwayMap);
                for(MeterBaseSpotInfo spotModel: spotModels) {
                    long countActual = 0L;
                    long countMatchedActual = 0L;
                    long countNotMatchActual = 0L;
                    long countUploadActual = 0L;
                    if(carActual.size() >= 1) {
                        countActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                                && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                                && !item.getValueFlag().equals("0")).count();
                        countMatchedActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                                && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                                && !item.getValueFlag().equals("0")
                                && item.getIsPreSacale().equals("1")).count();
                        countNotMatchActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                                && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                                && !item.getValueFlag().equals("0")
                                && ( StringUtils.isEmpty(item.getIsPreSacale()) || item.getIsPreSacale().equals("0") )).count();
                        countUploadActual = carActual.stream().filter(item -> item.getNetSpot3No().equals(spotModel.getBaseSpotNo())
                                && item.getNetSpot3Name().equals(spotModel.getBaseSpotName())
                                && !item.getValueFlag().equals("0")
                                && item.getIsPreSacale().equals("1")
                                && item.getValueFlag().equals("2")
                                && item.getUploadFlag().equals("2")).count();

                    }
                    HashMap<String, Object> actualMap = new HashMap<>();
                    actualMap.put("baseSpotNo", spotModel.getBaseSpotNo());
                    actualMap.put("baseSpotName", spotModel.getBaseSpotName());
                    actualMap.put("countActual", countActual);
                    actualMap.put("countMatchedActual", countMatchedActual);
                    actualMap.put("countNotMatchActual", countNotMatchActual);
                    actualMap.put("countUploadActual", countUploadActual);
                    spotList.add(actualMap);
                }
                instrumentTypeMap.put("spotList", spotList);
                instrumentTypeList.add(instrumentTypeMap);
            }
        }
        return instrumentTypeList;
    }

    @Override
    public PageList<CarActualTareWeightComparison> carActualTareWeightComparison(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<CarActualTareWeightComparison> rows = meterWorkDataCountMapper.carActualTareWeightComparison(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<CarActualTareWeightComparison> carActualTareWeightComparisonDetail(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        BigDecimal avgTareWeight = params.get("avgTareWeight") != null ? new BigDecimal(params.get("avgTareWeight").toString()): new BigDecimal(0);
        //查询所有结净数据
        List<CarActualTareWeightComparison> rowsActual = meterWorkDataCountMapper.carActualTareWeightComparison(params);
        //根据车号、物料编号、物料名称进行分组并求平均值
        List<CarActualTareWeightComparison> rowsDetail = meterWorkDataCountMapper.carActualTareWeightComparisonDetail(params);
        List<CarActualTareWeightComparison> rows = new ArrayList<>();
        if(rowsDetail.size() >= 1) {
            //循环分组List<车号、物料编号、物料名称>
            for(CarActualTareWeightComparison modelDetail: rowsDetail) {
                if(rowsActual.size() >= 1) {
                    for (CarActualTareWeightComparison modelActual: rowsActual) {
                        //判断车号、物料编号、物料名称是否一致、一致把平均值写入，并添加
                        if(modelDetail.getCarNo() != null && modelActual.getCarNo() != null && modelDetail.getCarNo().equals(modelActual.getCarNo())
                            && modelDetail.getMatterNo() != null && modelActual.getMatterNo() != null && modelDetail.getMatterNo().equals(modelActual.getMatterNo())
                            && modelDetail.getMatterName() != null && modelActual.getMatterName() != null && modelDetail.getMatterName().equals(modelActual.getMatterName())) {
                            //结净数据皮重-平均皮重大于等于输入值，就写入
                            BigDecimal sub = (modelActual.getTareWeight().subtract(modelDetail.getAvgTareWeight())).abs();
                            //avgTareWeight < sub
                            if(avgTareWeight.compareTo(sub) == -1) {
                                modelActual.setAvgTareWeight(modelDetail.getAvgTareWeight());
                                modelActual.setAvgTareWeightSub(sub);
                                rows.add(modelActual);
                            }
                        }
                    }
                }
            }
        }
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<CarActualTareWeightComparison> carActualNetWeightComparisonDetail(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        BigDecimal avgNetWeight = params.get("avgNetWeight") != null ? new BigDecimal(params.get("avgNetWeight").toString()): new BigDecimal(0);
        //查询所有结净数据
        List<CarActualTareWeightComparison> rowsActual = meterWorkDataCountMapper.carActualTareWeightComparison(params);
        //根据车号、物料编号、物料名称进行分组并求平均值
        List<CarActualTareWeightComparison> rowsDetail = meterWorkDataCountMapper.carActualNetWeightComparisonDetail(params);
        List<CarActualTareWeightComparison> rows = new ArrayList<>();
        if(rowsDetail.size() >= 1) {
            //循环分组List<车号、物料编号、物料名称>
            for(CarActualTareWeightComparison modelDetail: rowsDetail) {
                if(rowsActual.size() >= 1) {
                    for (CarActualTareWeightComparison modelActual: rowsActual) {
                        //判断车号、物料编号、物料名称是否一致、一致把平均值写入，并添加
                        if(modelDetail.getCarNo() != null && modelActual.getCarNo() != null && modelDetail.getCarNo().equals(modelActual.getCarNo())
                                && modelDetail.getMatterNo() != null && modelActual.getMatterNo() != null && modelDetail.getMatterNo().equals(modelActual.getMatterNo())
                                && modelDetail.getMatterName() != null && modelActual.getMatterName() != null && modelDetail.getMatterName().equals(modelActual.getMatterName())) {
                            //结净数据皮重-平均皮重大于等于输入值，就写入
                            BigDecimal sub = (modelActual.getNetWeight().subtract(modelDetail.getAvgNetWeight())).abs();
                            //avgTareWeight < sub
                            if(avgNetWeight.compareTo(sub) == -1) {
                                modelActual.setAvgNetWeight(modelDetail.getAvgNetWeight());
                                modelActual.setAvgNetWeightSub(sub);
                                rows.add(modelActual);
                            }
                        }
                    }
                }
            }
        }
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<RailwayActualGrossWeightComparison> railwayActualGrossWeightComparison(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<RailwayActualGrossWeightComparison> rows = meterWorkDataCountMapper.railwayActualGrossWeightComparison(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<RailwayActualGrossWeightComparison> railwayActualGrossWeightComparisonDetail(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        BigDecimal avgGrossWeight = params.get("avgGrossWeight") != null ? new BigDecimal(params.get("avgGrossWeight").toString()): new BigDecimal(0);
        //查询所有结净数据
        List<RailwayActualGrossWeightComparison> rowsActual = meterWorkDataCountMapper.railwayActualGrossWeightComparison(params);
        //根据车型、物料编号、物料名称进行分组并求平均值
        List<RailwayActualGrossWeightComparison> rowsDetail = meterWorkDataCountMapper.railwayActualGrossWeightComparisonDetail(params);
        List<RailwayActualGrossWeightComparison> rows = new ArrayList<>();
        if(rowsDetail.size() >= 1) {
            //循环分组List<车型、物料编号、物料名称>
            for(RailwayActualGrossWeightComparison modelDetail: rowsDetail) {
                if(rowsActual.size() >= 1) {
                    for (RailwayActualGrossWeightComparison modelActual: rowsActual) {
                        //判断车型、物料编号、物料名称是否一致、一致把平均值写入，并添加
                        if(((modelDetail.getConveyanceType()==null&&modelActual.getConveyanceType()==null)||modelDetail.getConveyanceType()!=null&&modelActual.getConveyanceType()!=null&&modelDetail.getConveyanceType().equals(modelActual.getConveyanceType()))
                                && modelDetail.getMatterNo() != null && modelActual.getMatterNo() != null && modelDetail.getMatterNo().equals(modelActual.getMatterNo())
                                && modelDetail.getMatterName() != null && modelActual.getMatterName() != null && modelDetail.getMatterName().equals(modelActual.getMatterName())) {
                            //结净数据毛重-平均毛重大于等于输入值，就写入
                            BigDecimal sub = (modelActual.getGrossWeight().subtract(modelDetail.getAvgGrossWeight()));
                            //avgGrossWeight < sub
                            if(avgGrossWeight.compareTo(sub.abs()) == -1) {
                                modelActual.setAvgGrossWeight(modelDetail.getAvgGrossWeight());
                                modelActual.setAvgGrossWeightSub(sub);
                                rows.add(modelActual);
                            }
                        }
                    }
                }
            }
        }
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<NetWeightAndTheoryAmount> railwayNetWeightAndTheoryAmount(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<NetWeightAndTheoryAmount> rows = meterWorkDataCountMapper.railwayNetWeightAndTheoryAmount(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<LongCarMeterWeightComparison> longCarMeterWeightComparison(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<LongCarMeterWeightComparison> rows = meterWorkDataCountMapper.longCarMeterWeightComparison(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<ScaleOrCarComparison> scaleOrCarComparison(HashMap<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<ScaleOrCarComparison> rows = meterWorkDataCountMapper.scaleOrCarComparison(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public List<String> measurementAccuracyOperationPage(HashMap params) {
        return meterWorkDataCountMapper.measurementAccuracyOperationPage(params);
    }

    @Override
    public List<String> measurementAccuracyCreateManName(HashMap params) {
        return meterWorkDataCountMapper.measurementAccuracyCreateManName(params);
    }

    @Override
    public PageList<RailwayActualGrossWeightComparison> railwayActualNetWeightComparisonDetail(HashMap params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        BigDecimal avgNetWeight = params.get("avgNetWeight") != null ? new BigDecimal(params.get("avgNetWeight").toString()): new BigDecimal(0);
        //查询所有结净数据
        List<RailwayActualGrossWeightComparison> rowsActual = meterWorkDataCountMapper.railwayActualGrossWeightComparison(params);
        //根据车型、物料编号、物料名称进行分组并求平均值
        List<RailwayActualGrossWeightComparison> rowsDetail = meterWorkDataCountMapper.railwayActualNetWeightComparisonDetail(params);
        List<RailwayActualGrossWeightComparison> rows = new ArrayList<>();
        if(rowsDetail.size() >= 1) {
            //循环分组List<车型、物料编号、物料名称>
            for(RailwayActualGrossWeightComparison modelDetail: rowsDetail) {
                if(rowsActual.size() >= 1) {
                    for (RailwayActualGrossWeightComparison modelActual: rowsActual) {
                        //判断车型、物料编号、物料名称是否一致、一致把平均值写入，并添加
                        if(((modelDetail.getConveyanceType()==null&&modelActual.getConveyanceType()==null)||modelDetail.getConveyanceType()!=null&&modelActual.getConveyanceType()!=null&&modelDetail.getConveyanceType().equals(modelActual.getConveyanceType()))
                                && modelDetail.getMatterNo() != null && modelActual.getMatterNo() != null && modelDetail.getMatterNo().equals(modelActual.getMatterNo())
                                && modelDetail.getMatterName() != null && modelActual.getMatterName() != null && modelDetail.getMatterName().equals(modelActual.getMatterName())) {
                            //结净数据毛重-平均毛重大于等于输入值，就写入
                            BigDecimal sub = (modelActual.getNetWeight().subtract(modelDetail.getAvgNetWeight()));
                            //avgGrossWeight < sub
                            if(avgNetWeight.compareTo(sub.abs()) == -1) {
                                modelActual.setAvgNetWeight(modelDetail.getAvgNetWeight());
                                modelActual.setAvgNetWeightSub(sub);
                                rows.add(modelActual);
                            }
                        }
                    }
                }
            }
        }
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public PageList<StaticRailwayRemoteComparison> dynamicRailwayRemoteComparison(HashMap params) {
        PageHelper.startPage(Integer.parseInt(params.get("pageNum").toString()), Integer.parseInt(params.get("pageSize").toString()));
        List<StaticRailwayRemoteComparison> rows = meterWorkDataCountMapper.dynamicRailwayRemoteComparison(params);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

}
