JudgmentService.java 4.91 KB
package cn.com.glsx.admin.modules.service;

import cn.com.glsx.admin.common.enums.TypeConverseEunm;
import cn.com.glsx.admin.modules.mapper.VehicleMapper;
import cn.com.glsx.admin.modules.model.export.JudgmentExport;
import cn.com.glsx.admin.modules.model.param.JudgmentSearch;
import cn.com.glsx.admin.modules.remote.RemoteStuJudgeAlarmService;
import cn.com.glsx.alarm.services.model.StuJudgeAlarmDto;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 大数据研判 service
 *
 * @author yll
 */
@Slf4j
@Service
public class JudgmentService {

    @Autowired
    private RemoteStuJudgeAlarmService remoteStuJudgeAlarmService;

    @Autowired
    private VehicleMapper vehicleMapper;

    /**
     * 查询大数据研判数据列表
     *
     * @param judgmentSearch
     * @return
     */
    public PageInfo findJudgmentList(JudgmentSearch judgmentSearch) {
        List<JudgmentExport> judgmentList = vehicleMapper.findJudgmentList(judgmentSearch);
        if (CollectionUtil.isEmpty(judgmentList)) {
            return new PageInfo<>();
        }
        log.info("查询大数据研判数据列表的条数" + judgmentList.size());
        List<String> snList = judgmentList.stream().map(JudgmentExport::getSn).collect(Collectors.toList());
        PageInfo stuJudgeAlarmListByPage = remoteStuJudgeAlarmService.searchStuJudgeAlarmListByPage(snList, judgmentSearch);
        List<StuJudgeAlarmDto> stuJudgeAlarmList = JSON.parseArray(JSON.toJSONString(stuJudgeAlarmListByPage.getList()), StuJudgeAlarmDto.class);
        if (CollectionUtil.isEmpty(stuJudgeAlarmList)) {
            return new PageInfo<>();
        }
        List<JudgmentExport> judgmentExportList = Lists.newArrayList();
        stuJudgeAlarmList.forEach(stuJudgeAlarm -> {
            for (JudgmentExport judgmentExportTemp : judgmentList) {
                if (stuJudgeAlarm.getSn().equals(judgmentExportTemp.getSn())) {
                    JudgmentExport judgmentExport = new JudgmentExport();
                    BeanUtils.copyProperties(judgmentExportTemp, judgmentExport);
                    judgmentExport.setAlarmType(stuJudgeAlarm.getAlarmType());
                    judgmentExport.setAlarmTypeStr(TypeConverseEunm.AlarmTypeEnum.getStrByAlarmType(stuJudgeAlarm.getAlarmType()));
                    judgmentExport.setGeoCode(stuJudgeAlarm.getGeoCode());
                    judgmentExport.setAlarmAddress(stuJudgeAlarm.getAlarmAddress());
                    judgmentExport.setAlarmBeginTime(stuJudgeAlarm.getAlarmBeginTime());
                    judgmentExport.setAlarmEndTime(stuJudgeAlarm.getAlarmEndTime());
                    judgmentExportList.add(judgmentExport);
                }
            }
        });
        stuJudgeAlarmListByPage.setList(judgmentExportList);
        return stuJudgeAlarmListByPage;
    }

    public List<JudgmentExport> exportJudgmentList(JudgmentSearch judgmentSearch) {
        List<JudgmentExport> judgmentList = vehicleMapper.findJudgmentList(judgmentSearch);
        if (ObjectUtil.isNull(judgmentList)) {
            return null;
        }
        log.info("查询大数据研判数据列表的条数" + judgmentList.size());
        List<String> snList = judgmentList.stream().map(JudgmentExport::getSn).collect(Collectors.toList());
        List<StuJudgeAlarmDto> stuJudgeAlarmDtoList = remoteStuJudgeAlarmService.searchStuJudgeAlarmDataList(snList, judgmentSearch);
        if (CollectionUtil.isEmpty(stuJudgeAlarmDtoList)) {
            return null;
        }
        List<JudgmentExport> judgmentExportList = Lists.newArrayList();
        stuJudgeAlarmDtoList.forEach(stuJudgeAlarm -> {
            for (JudgmentExport judgmentExportTemp : judgmentList) {
                if (stuJudgeAlarm.getSn().equals(judgmentExportTemp.getSn())) {
                    JudgmentExport judgmentExport = new JudgmentExport();
                    BeanUtils.copyProperties(judgmentExportTemp, judgmentExport);
                    judgmentExport.setAlarmType(stuJudgeAlarm.getAlarmType());
                    judgmentExport.setAlarmTypeStr(TypeConverseEunm.AlarmTypeEnum.getStrByAlarmType(stuJudgeAlarm.getAlarmType()));
                    judgmentExport.setGeoCode(stuJudgeAlarm.getGeoCode());
                    judgmentExport.setAlarmAddress(stuJudgeAlarm.getAlarmAddress());
                    judgmentExport.setAlarmBeginTime(stuJudgeAlarm.getAlarmBeginTime());
                    judgmentExport.setAlarmEndTime(stuJudgeAlarm.getAlarmEndTime());
                    judgmentExportList.add(judgmentExport);
                }
            }
        });
        return judgmentExportList;
    }
}