package com.mosty.sjzx.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
import com.mosty.base.model.dto.base.SysDeptDTO;
import com.mosty.base.model.dto.jcgl.TbJcglKfdDto;
import com.mosty.base.model.dto.jcgl.TbJcglXfqyDto;
import com.mosty.base.model.dto.qwzx.TbQwXfbbQueryByJlDto;
import com.mosty.base.model.dto.sjzx.TbJqYjbjDto;
import com.mosty.base.model.dto.websocket.WebSocketObject;
import com.mosty.base.model.dto.yjzl.TbZlxxInsertDto;
import com.mosty.base.model.dto.yjzl.TbZlxxZxrDtoInsertDto;
import com.mosty.base.model.entity.lzother.VLz110Txj;
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
import com.mosty.base.model.entity.sjzx.*;
import com.mosty.base.model.entity.xinzhi.GxCjdb;
import com.mosty.base.model.entity.xinzhi.Jjdb;
import com.mosty.base.model.query.sjzx.TbJqCjdbQuery;
import com.mosty.base.model.query.sjzx.TbJqListQuery;
import com.mosty.base.model.query.sjzx.TbJqPageListQuery;
import com.mosty.base.model.query.sjzx.XftjQuery;
import com.mosty.base.model.vo.base.DeptInfoVo;
import com.mosty.base.model.vo.sjzx.TbJqVo;
import com.mosty.base.model.vo.xinzhi.GxAlarmAllVo;
import com.mosty.base.utils.*;
import com.mosty.common.base.exception.BusinessException;
import com.mosty.common.base.util.StringUtils;
import com.mosty.common.config.entity.SysDictItem;
import com.mosty.common.core.util.http.HttpUtils;
import com.mosty.common.redis.service.RedisService;
import com.mosty.common.token.UserInfo;
import com.mosty.common.token.UserInfoManager;
import com.mosty.common.util.PermissionsUtil;
import com.mosty.sjzx.mapper.*;
import com.mosty.sjzx.remote.*;
import com.mosty.sjzx.service.TbJqService;
import org.locationtech.jts.geom.Coordinate;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * @author zhangHaiJun
 * @since 2022-07-13 20:44:48
 * 警情表(TbJq)表服务实现类
 */
@Service
@AllArgsConstructor
public class TbJqServiceImpl extends ServiceImpl<TbJqMapper, TbJq> implements TbJqService {

    private final TbjqZxrMapper tbjqZxrMapper;
    private final TbSjMapper tbSjMapper;
    private final TbJqDzMapper tbJqDzMapper;
    private final TbJqCjdbMapper tbJqCjdbMapper;
    private final TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
    private final TbWebSocketAdaptRemoteService tbWebSocketAdaptRemoteService;
    private final TbJqAllMapper tbJqAllMapper;
    private final TbQwzxAdaptRemoteService tbQwzxAdaptRemoteService;
    private final TbYjzlAdaptRrmoteService tbYjzlAdaptRrmoteService;
    private final TbJcglAdaptRemoteService tbJcglAdaptRemoteService;
    private final RedisService redisService;


    // 5+2主城区城市代码
    private final String[] orgcodes = new String[]{"510104000000", "510105000000", "510106000000", "510107000000", "510108000000"
            , "510109000000", "510156000000"};
    // 街面警情
    private final String[] JmjqList = new String[]{"01110200", "01110300", "01120300", "01120400", "01120700", "01120800", "01121000",
            "01130100", "01140100", "01149900", "02030200", "02030300", "02030400", "02030500", "02040100", "02050100", "02050400",
            "02121700", "02130000"};
    // 违法犯罪警情
    private final String[] wffzList = new String[]{"01000000", "02000000"};
    // 街面刑事警情
    private final String[] jmxsjqList = new String[]{"01110200", "01110300", "01120300", "01120400", "01120700", "01120800",
            "01121000", "01130100", "01140100", "01149900"};
    // 街面行政警情
    private final String[] jmxzjqList = new String[]{"02030200", "02030300", "02030400", "02030500", "02040100", "02050100",
            "02050400", "02121700", "02130000"};

    @Override
    public Map<String, Object> getJqAndXfTj(XftjQuery dto) {
        if (StringUtils.isEmpty(dto.getKssj()) || StringUtils.isEmpty(dto.getJssj())) {
            throw new BusinessException("请选择查询时间");
        }
        Map<String, Object> map = new HashMap<>();
        if (dto.getKssj().equals(dto.getJssj())) {
            // 查询警情数据
            List<Map<String, Object>> jqList = this.baseMapper.getJqTj(dto.getKssj());
            List<String> timeList = ImmutableList.of("00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
                    "10", "11", "12", "13", "14", "15", "16", "17",
                    "18", "19", "20", "21", "22", "23");
            timeList.forEach(item -> {
                boolean flag = false;
                for (Map<String, Object> jq : jqList) {
                    String time = String.valueOf(jq.get("time")).length() == 1 ?
                            "0" + jq.get("time") : String.valueOf(jq.get("time"));
                    if (item.equals(time)) {
                        flag = true;
                    }
                }
                if (!flag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", item);
                    mp.put("count", 0);
                    jqList.add(mp);
                }
            });
            jqList.sort(Comparator.comparingInt(a -> Integer.parseInt(a.get("time").toString())));
            map.put("jqList", jqList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            // 查询寻访时长和巡防里程
            List<Map<String, Object>> wzList = this.baseMapper.getWzList(dto.getKssj());
            timeList.forEach(item -> {
                boolean flag = false;
                for (Map<String, Object> jq : wzList) {
                    String time = String.valueOf(jq.get("time")).length() == 1 ?
                            "0" + jq.get("time") : String.valueOf(jq.get("time"));
                    if (item.equals(time)) {
                        flag = true;
                    }
                }
                if (!flag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", item);
                    mp.put("xfsc", 0);
                    mp.put("xflc", 0);
                    wzList.add(mp);
                }
            });
            wzList.sort(Comparator.comparingInt(a -> Integer.parseInt(a.get("time").toString())));
            map.put("xflcList", wzList.stream().map(item ->
                    Integer.parseInt(item.get("xflc").toString()))
                    .collect(Collectors.toList()));
            map.put("xfscList", wzList.stream().map(item ->
                    Integer.parseInt(item.get("xfsc").toString()))
                    .collect(Collectors.toList()));
        } else {
            // 警情
            List<Map<String, Object>> jqList = this.baseMapper.getJqTjByTime(dto.getKssj(), dto.getJssj());
            // 巡逻时长和巡逻里程
            List<Map<String, Object>> bbList = this.baseMapper.getBbList(dto.getKssj(), dto.getJssj());
            Date kssj = DateUtils.strToDate(dto.getKssj(), "01");
            Date jssj = DateUtils.strToDate(dto.getJssj(), "01");
            while (kssj.getTime() <= jssj.getTime()) {
                boolean jqFlag = false;
                boolean bbFlag = false;
                for (Map<String, Object> item : jqList) {
                    if (String.valueOf(item.get("time")).equals(DateUtils.getQueryDateString(kssj, "01"))) {
                        jqFlag = true;
                    }
                }
                for (Map<String, Object> item : bbList) {
                    if (String.valueOf(item.get("time")).equals(DateUtils.getQueryDateString(kssj, "01"))) {
                        bbFlag = true;
                    }
                }
                if (!jqFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", DateUtils.getQueryDateString(kssj, "01"));
                    mp.put("count", 0);
                    jqList.add(mp);
                }
                if (!bbFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", DateUtils.getQueryDateString(kssj, "01"));
                    mp.put("xfsc", 0);
                    mp.put("xflc", 0);
                    bbList.add(mp);
                }
                kssj = DateUtils.getNextDate(kssj, "D", 1);
            }
            jqList.sort((a, b) -> { // Tzc
                Date k = DateUtils.strToDate(a.get("time").toString(), "01");
                Date j = DateUtils.strToDate(b.get("time").toString(), "01");
                return (int) (k.getTime() - j.getTime());
            });
            bbList.sort((a, b) -> {
                Date k = DateUtils.strToDate(a.get("time").toString(), "01");
                Date j = DateUtils.strToDate(b.get("time").toString(), "01");
                return (int) (k.getTime() - j.getTime());
            });
            map.put("jqList", jqList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            map.put("xflcList", bbList.stream().map(item ->
                    Integer.parseInt(item.get("xflc").toString()))
                    .collect(Collectors.toList()));
            map.put("xfscList", bbList.stream().map(item ->
                    Integer.parseInt(item.get("xfsc").toString()))
                    .collect(Collectors.toList()));
        }
        return map;
    }

    @Override
    public Map<String, Object> getJqAndPcTj(XftjQuery dto) {
        if (StringUtils.isEmpty(dto.getKssj()) || StringUtils.isEmpty(dto.getJssj())) {
            throw new BusinessException("请选择查询时间");
        }
        Map<String, Object> map = new HashMap<>();
        if (dto.getKssj().equals(dto.getJssj())) {
            // 查询警情数据
            List<Map<String, Object>> jqList = this.baseMapper.getJqTj(dto.getKssj());
            // 查询盘查人员数据
            List<Map<String, Object>> pcRyList = this.baseMapper.getPcryTj(dto.getKssj());
            // 查询盘查车辆数据
            List<Map<String, Object>> pcClList = this.baseMapper.getPcclTj(dto.getKssj());
            // 查询盘查重点人员数据
            List<Map<String, Object>> zdryList = this.baseMapper.getPcZdryTj(dto.getKssj());
            List<String> timeList = ImmutableList.of("00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
                    "10", "11", "12", "13", "14", "15", "16", "17",
                    "18", "19", "20", "21", "22", "23");
            timeList.forEach(item -> {
                boolean jqFlag = false;
                boolean ryFlag = false;
                boolean pcFlag = false;
                boolean zdFlag = false;
                for (Map<String, Object> jq : jqList) {
                    String time = String.valueOf(jq.get("time")).length() == 1 ?
                            "0" + jq.get("time") : String.valueOf(jq.get("time"));
                    if (item.equals(time)) {
                        jqFlag = true;
                    }
                }
                for (Map<String, Object> jq : pcRyList) {
                    String time = String.valueOf(jq.get("time")).length() == 1 ?
                            "0" + jq.get("time") : String.valueOf(jq.get("time"));
                    if (item.equals(time)) {
                        ryFlag = true;
                    }
                }
                for (Map<String, Object> jq : pcClList) {
                    String time = String.valueOf(jq.get("time")).length() == 1 ?
                            "0" + jq.get("time") : String.valueOf(jq.get("time"));
                    if (item.equals(time)) {
                        pcFlag = true;
                    }
                }
                for (Map<String, Object> jq : zdryList) {
                    String time = String.valueOf(jq.get("time")).length() == 1 ?
                            "0" + jq.get("time") : String.valueOf(jq.get("time"));
                    if (item.equals(time)) {
                        zdFlag = true;
                    }
                }
                if (!jqFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", item);
                    mp.put("count", 0);
                    jqList.add(mp);
                }
                if (!ryFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", item);
                    mp.put("count", 0);
                    pcRyList.add(mp);
                }
                if (!pcFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", item);
                    mp.put("count", 0);
                    pcClList.add(mp);
                }
                if (!zdFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", item);
                    mp.put("count", 0);
                    zdryList.add(mp);
                }
            });
            jqList.sort(Comparator.comparingInt(a -> Integer.parseInt(a.get("time").toString())));
            pcRyList.sort(Comparator.comparingInt(a -> Integer.parseInt(a.get("time").toString())));
            pcClList.sort(Comparator.comparingInt(a -> Integer.parseInt(a.get("time").toString())));
            zdryList.sort(Comparator.comparingInt(a -> Integer.parseInt(a.get("time").toString())));
            map.put("jqList", jqList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            map.put("pcRyList", pcRyList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            map.put("pcClList", pcClList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            map.put("zdryList", zdryList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
        } else {
            // 警情
            List<Map<String, Object>> jqList = this.baseMapper.getJqTjByTime(dto.getKssj(), dto.getJssj());
            // 查询盘查人员
            List<Map<String, Object>> pcRyList = this.baseMapper.getPcryByTime(dto.getKssj(), dto.getJssj());
            // 查询盘查车辆信息
            List<Map<String, Object>> pcClList = this.baseMapper.getPcclByTime(dto.getKssj(), dto.getJssj());
            // 查询重点人员信息
            List<Map<String, Object>> zdryList = this.baseMapper.getZdryByTime(dto.getKssj(), dto.getJssj());
            Date kssj = DateUtils.strToDate(dto.getKssj(), "01");
            Date jssj = DateUtils.strToDate(dto.getJssj(), "01");
            while (kssj.getTime() <= jssj.getTime()) {
                boolean jqFlag = false;
                boolean ryFlag = false;
                boolean clFlag = false;
                boolean zdFlag = false;
                for (Map<String, Object> item : jqList) {
                    if (String.valueOf(item.get("time")).equals(DateUtils.getQueryDateString(kssj, "01"))) {
                        jqFlag = true;
                    }
                }
                for (Map<String, Object> item : zdryList) {
                    if (String.valueOf(item.get("time")).equals(DateUtils.getQueryDateString(kssj, "01"))) {
                        zdFlag = true;
                    }
                }
                for (Map<String, Object> item : pcClList) {
                    if (String.valueOf(item.get("time")).equals(DateUtils.getQueryDateString(kssj, "01"))) {
                        clFlag = true;
                    }
                }
                for (Map<String, Object> item : pcRyList) { //Tzc
                    if (String.valueOf(item.get("time")).equals(DateUtils.getQueryDateString(kssj, "01"))) {
                        ryFlag = true;
                    }
                }
                if (!jqFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", DateUtils.getQueryDateString(kssj, "01"));
                    mp.put("count", 0);
                    jqList.add(mp);
                }
                if (!ryFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", DateUtils.getQueryDateString(kssj, "01"));
                    mp.put("count", 0);
                    pcRyList.add(mp);
                }
                if (!clFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", DateUtils.getQueryDateString(kssj, "01"));
                    mp.put("count", 0);
                    pcClList.add(mp);
                }
                if (!zdFlag) {
                    Map<String, Object> mp = new HashMap<>();
                    mp.put("time", DateUtils.getQueryDateString(kssj, "01"));
                    mp.put("count", 0);
                    zdryList.add(mp);
                }
                kssj = DateUtils.getNextDate(kssj, "D", 1);
            }
            jqList.sort((a, b) -> {
                Date k = DateUtils.strToDate(a.get("time").toString(), "01");
                Date j = DateUtils.strToDate(b.get("time").toString(), "01");
                return (int) (k.getTime() - j.getTime());
            });
            pcRyList.sort((a, b) -> {
                Date k = DateUtils.strToDate(a.get("time").toString(), "01");
                Date j = DateUtils.strToDate(b.get("time").toString(), "01");
                return (int) (k.getTime() - j.getTime());
            });
            pcClList.sort((a, b) -> {
                Date k = DateUtils.strToDate(a.get("time").toString(), "01");
                Date j = DateUtils.strToDate(b.get("time").toString(), "01");
                return (int) (k.getTime() - j.getTime());
            });
            zdryList.sort((a, b) -> {
                Date k = DateUtils.strToDate(a.get("time").toString(), "01");
                Date j = DateUtils.strToDate(b.get("time").toString(), "01");
                return (int) (k.getTime() - j.getTime());
            });
            map.put("jqList", jqList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            map.put("pcRyList", pcRyList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            map.put("pcClList", pcClList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
            map.put("zdryList", zdryList.stream().map(item -> item.get("count")).collect(Collectors.toList()));
        }
        return map;
    }

    @Override
    public void addYjbj(TbJqYjbjDto dto) {
        String sfdz;
        UserInfo user = UserInfoManager.get();
        TbJq jq = new TbJq();
        BeanUtils.copyProperties(dto, jq);
        if (dto.getJd() != null && dto.getWd() != null) {
//            jq.setZb(JtsUtils.getPoint(dto.getJd(), dto.getWd()));
//            jq.setZbhash(GeoHashKit.encode(dto.getJd(), dto.getWd()));
            sfdz = this.tbBaseAdaptRemoteService.getLocation(String.valueOf(dto.getJd()),
                    String.valueOf(dto.getWd()));
        } else {
            throw new BusinessException("没有获取到位置信息！！");
        }
        jq.setId(UUIDGenerator.getUUID());
        jq.setHrsj(new Date());
        jq.setBjrq(new Date());
        jq.setBjsj(new Date());
        jq.setJjsj(new Date());
        String time = DateUtils.getQueryDateString(jq.getBjsj(), "02");
        String jqfsksnf = time.substring(0, 4);
        String jqfsksyf = time.substring(5, 7);
        String jqfsksxs = time.substring(11, 13);
        String jqfsksny = jqfsksnf + jqfsksyf;
        Calendar ca = Calendar.getInstance();
        ca.setTime(jq.getBjsj());
        Integer jqfskszs = ca.get(Calendar.WEEK_OF_YEAR);
        jq.setJqfsksnf(Integer.valueOf(jqfsksnf));
        jq.setJqfsksyf(Integer.valueOf(jqfsksyf));
        jq.setJqfsksny(Integer.valueOf(jqfsksny));
        jq.setJqfskszs(jqfskszs);
        jq.setJqfsksxs(Integer.parseInt(jqfsksxs));
        jq.setJqfsksrq(jq.getBjsj());
        jq.setJqfskssj(jq.getBjsj());
        jq.setBjdh(user.getPhone());
        jq.setBjdhYhxm(user.getUserName());
        jq.setBjdhYhdz(sfdz);
        jq.setSfdz(sfdz);
        jq.setBjrSfzh(user.getIdEntityCard());
        jq.setBjrXm(user.getUserName());
        jq.setBjrXb(IDCardUtil.getSex(user.getIdEntityCard()));
        jq.setBjrLxdh(user.getPhone());
        jq.setSfdzxzqh(user.getDszDeptCode().substring(0, 6));
        jq.setBjnr("民警" + user.getUserName() + "于" + DateUtils.getQueryDateString(jq.getBjsj(), "02") +
                "在" + sfdz + "发出一键报警，请立即支援！！");
        jq.setJqjb("10");
        jq.setBjlb("90000000");
        jq.setBjlbmc("其他警情");
        jq.setBjlx("90900000");
        jq.setBjlxmc("其他警情");
        jq.setSfzdjq("1");
        jq.setCzzt("0");
        jq.setZdjqtjlx("03");
        jq.setSsbm(user.getDeptName());
        jq.setSsbmdm(user.getDeptCode());
        jq.setSsxgaj(user.getFxjDeptName());
        jq.setSsxgajdm(user.getFxjDeptCode());
        jq.setSssgaj(user.getDszDeptName());
        jq.setSssgajdm(user.getDszDeptCode());
        jq.setXtSjly("2");
        this.baseMapper.insertEntity(jq);
        // 发送警情数据到前端
        WebSocketObject obj = new WebSocketObject("01", jq, null);
        this.tbWebSocketAdaptRemoteService.sendMessage(obj);
        // 查询附近巡组发送指令最近的巡组
        this.sendZlxx(jq, user);
    }

    @Override
    public void updateJqCzzt(String id, String czzt) {
        this.baseMapper.updateJqCzzt(id, czzt);
    }

    // 查询周边巡组下发指令
    private void sendZlxx(TbJq jq, UserInfo user) {
        // 查询周边最近巡组
        TbQwXfbbQueryByJlDto dto = new TbQwXfbbQueryByJlDto();
        dto.setJd(jq.getJd());
        dto.setWd(jq.getWd());
        dto.setRadius(new BigDecimal("500"));
        TbQwXfbb bb = this.tbQwzxAdaptRemoteService.getBbxxByJi(dto);
        if (bb != null) {
            TbZlxxInsertDto zl = new TbZlxxInsertDto();
            zl.setId(UUIDGenerator.getUUID()).setYwId(jq.getId()).setZllx("05").setZlly("05").setZlzxlx("1")
                    .setZlbt("一键报警指令")
                    .setZlnr("民警" + user.getUserName() + "于" + DateUtils.getQueryDateString(jq.getBjsj(), "02") + "在" +
                            jq.getSfdz() + "发出一键报警，请立即支援！！")
                    .setZldj(jq.getJqjb()).setJd(jq.getJd()).setWd(jq.getWd()).setZlfsddxzqh(jq.getSfdzxzqh())
                    .setZlfsdd(jq.getSfdz()).setZljsdx("03")
                    .setSsbmid(bb.getSsbmid());
            List<TbZlxxZxrDtoInsertDto> zxrDtoList = new ArrayList<>();
            TbZlxxZxrDtoInsertDto zxr = new TbZlxxZxrDtoInsertDto();
            zxr.setZlId(zl.getId()).setZxrLx("03").setZxrXzid(bb.getId());
            zxrDtoList.add(zxr);
            zl.setZxrDtoList(zxrDtoList);
            this.tbYjzlAdaptRrmoteService.addZl(zl);
        }
    }

    @Override
    public TbJqVo queryById(String id) {
        TbJq jq = this.baseMapper.queryById(id);
        if (jq == null) {
            return null;
        }
        TbJqVo vo = new TbJqVo();
        BeanUtils.copyProperties(jq, vo);
        TbSj sj = this.tbSjMapper.selectOne(
                new LambdaQueryWrapper<TbSj>()
                        .eq(TbSj::getYwId, jq.getId())
        );
        vo.setSj(sj);
        return vo;
    }


    @Override
    public int insert(TbJq jq) {
        if (jq.getJd() != null && jq.getWd() != null) {
            // 计算hash值和经纬度坐标
            jq.setZb(JtsUtils.getPoint(jq.getJd(), jq.getWd()));
            jq.setZbhash(GeoHashKit.encode(jq.getJd(), jq.getWd()));
        }

        int integer = this.baseMapper.selectCount(new LambdaQueryWrapper<TbJq>().eq(TbJq::getJjdbh, jq.getJjdbh()));
        if (integer < 1) {
            //接警单编号存到redis
            int i = this.baseMapper.insertEntity(jq);
            if (i > 0) {
//                redisService.setCacheObject(Constant.JQ + jq.getJjdbh(), DateUtils.getQueryDateString(jq.getBjsj(), "02"), 3L, TimeUnit.HOURS);
//                //推送socket 发送警情数据到前端
//                jq.setZb(null);
//                WebSocketObject obj = new WebSocketObject("06", jq, null);
//                this.tbWebSocketAdaptRemoteService.sendBbMessage(obj);
//                this.xfzl(jq);
            }
            return i;
        }
        return 0;
    }


    @Override
    public void update(TbJq jq) {
        this.baseMapper.updateEntity(jq);
    }

    @Override
    public boolean deleteById(String id) {
        return this.baseMapper.deleteById(id) > 0;
    }

    @Override
    public IPage<TbJqVo> getPageListLz(TbJqPageListQuery dto) {
        List<String> jqjbList = StringUtils.isNotEmpty(dto.getJqjb()) ?
                Arrays.asList(dto.getJqjb().split(",")) : null;
        List<String> czztList = StringUtils.isNotEmpty(dto.getCzzt()) ?
                Arrays.asList(dto.getCzzt().split(",")) : null;
        Map<String, Object> map = new HashMap<>();
        map.put("dto", dto);
        map.put("pageIndex", (dto.getPageNum() - 1) * dto.getPageSize());
        map.put("pageSize", dto.getPageSize());
        map.put("list", jqjbList);
        map.put("czztList", czztList);
        int count = this.baseMapper.getCount(map);
        List<TbJq> list = this.baseMapper.getListByPage(map);
        List<TbJqVo> rList = new ArrayList<>();
        // 查询对应的处警状态
        list.forEach(item -> {
            TbJqVo vo = new TbJqVo();
            BeanUtils.copyProperties(item, vo);
            List<TbJqCjdb> cjdbList = this.tbJqCjdbMapper.selectList(
                    new LambdaQueryWrapper<TbJqCjdb>()
                            .eq(TbJqCjdb::getJjdbh, item.getJjdbh())
                            .orderByDesc(TbJqCjdb::getRksj)
            );
            vo.setCjdbList(cjdbList);
            rList.add(vo);
        });
        IPage<TbJqVo> page = new Page<>();
        page.setRecords(rList);
        page.setTotal(count);
        return page;
    }

    @Override
    public List<TbJqCjdb> getListCjd(String jjdbh) {
        List<TbJqCjdb> cjdbList = this.tbJqCjdbMapper.selectList(
                new LambdaQueryWrapper<TbJqCjdb>()
                        .eq(TbJqCjdb::getJjdbh, jjdbh)
                        .orderByDesc(TbJqCjdb::getRksj)
        );
        return cjdbList;
    }

    @Override
    public IPage<TbJqVo> selectPageList(TbJqPageListQuery dto) {
        List<String> jqjbList = StringUtils.isNotEmpty(dto.getJqjb()) ?
                Arrays.asList(dto.getJqjb().split(",")) : null;
        List<String> czztList = StringUtils.isNotEmpty(dto.getCzzt()) ?
                Arrays.asList(dto.getCzzt().split(",")) : null;
        List<String> bjlbList = StringUtils.isNotEmpty(dto.getBjlbs()) ?
                Arrays.asList(dto.getBjlbs().split(",")) : null;

        if (StringUtils.isNotBlank(dto.getType())) {
            if (dto.getType().equals("02") || dto.getType().equals("03")) {
                UserInfo user = UserInfoManager.getUser();
                if (user.getDeptName().substring(user.getDeptName().length() - 1).equals("队")) {
                    if (user.getDeptCode().substring(user.getDeptCode().length() - 4).equals("0000")) {
                        dto.setSsbmdm(user.getDeptCode().substring(0, 8));
                    } else {
                        dto.setSsbmdm(user.getDeptCode());
                    }
                } else {
                    dto.setSsbmdm(user.getDeptCode().substring(0, 8));
                }
            } else {
                dto.setSsbmdm(null);
            }
        } else {
            dto.setSsbmdm(this.tbBaseAdaptRemoteService.getSsbm(dto.getSsbmdm(), null));
        }

        Map<String, Object> map = new HashMap<>();
        map.put("dto", dto);
        map.put("pageIndex", (dto.getPageNum() - 1) * dto.getPageSize());
        map.put("pageSize", dto.getPageSize());
        map.put("list", jqjbList);
        map.put("czztList", czztList);
        map.put("bjlbList", bjlbList);
        int count = this.baseMapper.getCount(map);
        List<TbJq> list = this.baseMapper.getListByPage(map);
        List<TbJqVo> rList = new ArrayList<>();
        // 查询对应的处警状态
        list.forEach(item -> {
            TbJqVo vo = new TbJqVo();
            BeanUtils.copyProperties(item, vo);
//            List<TbJqCjdb> cjdbList = this.tbJqCjdbMapper.selectList(
//                    new LambdaQueryWrapper<TbJqCjdb>()
//                            .eq(TbJqCjdb::getJjdbh, item.getJjdbh())
//                            .orderByDesc(TbJqCjdb::getRksj)
//            );
//            vo.setCjdbList(cjdbList);
            rList.add(vo);
        });
        IPage<TbJqVo> page = new Page<>();
        page.setRecords(rList);
        page.setTotal(count);
        return page;
    }

    @Override
    public List<TbJqVo> getList(TbJqListQuery dto) {
        if (StringUtils.isNotBlank(dto.getStartTime()) && dto.getStartTime().length() < 19) {
            dto.setStartTime(dto.getStartTime() + " 00:00:00");
        }
        if (StringUtils.isNotBlank(dto.getEndTime()) && dto.getEndTime().length() < 19) {
            dto.setEndTime(dto.getEndTime() + " 23:59:59");
        }
        dto.setSsbmdm(this.tbBaseAdaptRemoteService.getSsbm(dto.getSsbmdm(), null));
        Map<String, Object> map = new HashMap<>();
        map.put("dto", dto);
        List<String> bjlbList = StringUtils.isNotEmpty(dto.getBjlbs()) ?
                Arrays.asList(dto.getBjlbs().split(",")) : null;
        List<String> mylbList = StringUtils.isNotEmpty(dto.getMylb()) ?
                Arrays.asList(dto.getMylb().split(",")) : null;
        List<String> nrlb = new ArrayList<>();
        if (!CollectionUtils.isEmpty(mylbList)) {
            for (String s : mylbList) {
                switch (s) {
                    case "1":
                        nrlb.add("打架");
                        nrlb.add("斗殴");
                        break;
                    case "2":
                        nrlb.add("抢");
                        nrlb.add("盗");
                        nrlb.add("窃");
                        break;
                }
            }
        }
        map.put("bjlbList", bjlbList);
        map.put("mylbList", nrlb);
        List<TbJq> list = this.baseMapper.getList(map);
        List<TbJqVo> rList = new ArrayList<>();
        // 查询对应的处警状态
        list.forEach(item -> {
            TbJqVo vo = new TbJqVo();
            BeanUtils.copyProperties(item, vo);
            rList.add(vo);
        });
        return rList;
    }

    @Override
    public List<Map<String, Object>> getJqHotMap(TbJqListQuery dto) {
        if (StringUtils.isNotBlank(dto.getStartTime())) {
            dto.setStartTime(dto.getStartTime() + " 00:00:00");
        }
        if (StringUtils.isNotBlank(dto.getEndTime())) {
            dto.setEndTime(dto.getEndTime() + " 23:59:59");
        }
        Map<String, Object> map = new HashMap<>();
        map.put("dto", dto);
        List<String> bjlbList = StringUtils.isNotEmpty(dto.getBjlbs()) ?
                Arrays.asList(dto.getBjlbs().split(",")) : null;
        map.put("bjlbList", bjlbList);
        dto.setSsbmdm(this.tbBaseAdaptRemoteService.getSsbm(dto.getSsbmdm(), null));
        List<Map<String, Object>> list = this.baseMapper.getJqHotMap(map);

        return list;
    }


    @Override
    public int getJqCount(TbJqListQuery dto) {
        if (StringUtils.isNotBlank(dto.getStartTime())) {
            dto.setStartTime(dto.getStartTime() + " 00:00:00");
        }
        if (StringUtils.isNotBlank(dto.getEndTime())) {
            dto.setEndTime(dto.getEndTime() + " 23:59:59");
        }
        return this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getXtSjzt, "1")
                        .eq(StringUtils.isNotEmpty(dto.getJqjb()), TbJq::getJqjb, dto.getJqjb())
                        .ge(StringUtils.isNotBlank(dto.getStartTime()), TbJq::getBjsj, dto.getStartTime())
                        .le(StringUtils.isNotBlank(dto.getEndTime()), TbJq::getBjsj, dto.getEndTime())
        );
    }

    // 查询今日当前24小时的警情趋势图
    @Override
    public Object getJqBy24h(String ssbmdm) {
        List<String> timeList = new ArrayList<String>() {{
            this.add("00-02");
            this.add("02-04");
            this.add("04-06");
            this.add("06-08");
            this.add("08-10");
            this.add("10-12");
            this.add("12-14");
            this.add("14-16");
            this.add("16-18");
            this.add("18-20");
            this.add("20-22");
            this.add("22-23");
        }};
        String date = DateUtils.getQueryDateString(new Date(), "01");
        List<Integer> list = new ArrayList<>();
        timeList.forEach(item -> {
            String kssj = date + " " + item.split("-")[0] + ":00:00";
            String jssj = date + " " + item.split("-")[1] + ":00:00";
            list.add(this.getJqCountByTime(ssbmdm, kssj, jssj));
        });
        Map<String, Object> map = new HashMap<>();
        map.put("time", timeList);
        map.put("count", list);
        return map;
    }

    @Override
    public IPage<TbJqVo> getZfgkList(TbJqPageListQuery dto) {
        if (StringUtils.isNotBlank(dto.getStartTime())) {
            dto.setStartTime(dto.getStartTime() + " 00:00:00");
        }
        if (StringUtils.isNotBlank(dto.getEndTime())) {
            dto.setEndTime(dto.getEndTime() + " 23:59:59");
        }
        Map<String, Object> map = new HashMap<>();
        map.put("dto", dto);
        map.put("pageIndex", (dto.getPageNum() - 1) * dto.getPageSize());
        map.put("pageSize", dto.getPageSize());
        UserInfo userInfo = UserInfoManager.get();
        map.put("useSql", userInfo != null ? PermissionsUtil.createSqlOfCode("", userInfo) : "");
        int count = this.baseMapper.getZfgkCount(map);
        List<TbJq> list = this.baseMapper.getZfgkList(map);
        List<TbJqVo> rList = new ArrayList<>();
        // 查询对应的处警状态
        list.forEach(item -> {
            TbJqVo vo = new TbJqVo();
            BeanUtils.copyProperties(item, vo);
            List<TbJqCjdb> cjdbList = this.tbJqCjdbMapper.selectList(
                    new LambdaQueryWrapper<TbJqCjdb>()
                            .eq(TbJqCjdb::getJjdbh, item.getJjdbh())
                            .orderByDesc(TbJqCjdb::getRksj)
            );
            vo.setCjdbList(cjdbList);
            rList.add(vo);
        });
        IPage<TbJqVo> page = new Page<>();
        page.setRecords(rList);
        page.setTotal(count);
        return page;
    }

    @Override
    public Object getjrjqczfx(String ssbmdm) {
        String date = DateUtils.getQueryDateString(new Date(), "01");
        // 查询警情信息列表
        List<TbJq> jqList = this.baseMapper.selectList(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getXtSjzt, "1")
                        .last(" and jqfsksrq >= '" + date + "'  and jqfsksrq <= '" + date + "'")
        );
        int data1 = 0;
        int data2 = 0;
        int data3 = 0;
        int data5 = 0;
        int data7 = 0;
        int data9 = 0;
        for (TbJq item : jqList) {// 查询警情的最新的处置状态
            TbJqZxr zxr = this.tbjqZxrMapper.selectOne(
                    new LambdaQueryWrapper<TbJqZxr>()
                            .eq(TbJqZxr::getJjdbh, item.getJjdbh())
                            .last(" order by czsj desc limit 1")
            );
            if (zxr != null) {
                if (1 == zxr.getZt()) {
                    data1++;
                } else if (2 == zxr.getZt()) {
                    data2++;
                } else if (3 == zxr.getZt()) {
                    data3++;
                } else if (5 == zxr.getZt()) {
                    data5++;
                } else if (7 == zxr.getZt()) {
                    data7++;
                } else if (9 == zxr.getZt()) {
                    data9++;
                }
            }
        }
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("type", "1");
        map.put("data", data1);
        list.add(map);
        map = new HashMap<>();
        map.put("type", "2");
        map.put("data", data2);
        list.add(map);
        map = new HashMap<>();
        map.put("type", "3");
        map.put("data", data3);
        list.add(map);
        map = new HashMap<>();
        map.put("type", "5");
        map.put("data", data5);
        list.add(map);
        map = new HashMap<>();
        map.put("type", "7");
        map.put("data", data7);
        list.add(map);
        map = new HashMap<>();
        map.put("type", "9");
        map.put("data", data9);
        list.add(map);
        return list;
    }

    @Override
    public Integer addXzjq(GxAlarmAllVo item) {
        TbJqAll jqAll = this.tbJqAllMapper.selectOne(
                new LambdaQueryWrapper<TbJqAll>()
                        .eq(TbJqAll::getJq110Id, item.getId())
                        .eq(TbJqAll::getXtSjzt, "1")
        );
        if (jqAll == null) {
            // 添加警情5+2主城区表
            jqAll = new TbJqAll();
            jqAll.setId(UUIDGenerator.getUUID());
            jqAll.setJq110Id(item.getId());
            jqAll.setJjdbh(item.getIncidentCode());
            jqAll.setJjdwbh(item.getMainOrgId());
            jqAll.setJjdwmc(item.getMainOrgName());
            jqAll.setGljjdbh(item.getRelatedIncidentCode());
            jqAll.setJjybh(item.getFirstReceivePersonId());
            jqAll.setJjyxm(item.getFirstReceivePersonName());
            jqAll.setHrsj(item.getFirstCallinTime());
            jqAll.setLhlxbh(item.getCallinType());
            jqAll.setBjfsbh(item.getAlarmMode());
            jqAll.setBjrq(item.getFirstCallinTime());
            jqAll.setBjsj(item.getFirstCallinTime());
            jqAll.setJqfsksnf(Integer.valueOf(DateUtils.getQueryDateString(item.getFirstCallinTime(), "13")));
            jqAll.setJqfsksyf(Integer.valueOf(DateUtils.getQueryDateString(item.getFirstCallinTime(), "14")));
            jqAll.setJqfsksny(Integer.valueOf(com.mosty.base.utils.DateUtils.getQueryDateString(item.getFirstCallinTime(), "15")));
            Calendar ca = Calendar.getInstance();
            ca.setTime(item.getFirstCallinTime());
            int yjfszs = ca.get(Calendar.WEEK_OF_YEAR);
            jqAll.setJqfskszs(yjfszs);
            jqAll.setJqfskssj(item.getFirstCallinTime());
            jqAll.setJqfsksxs(Integer.valueOf(com.mosty.base.utils.DateUtils.getQueryDateString(item.getFirstCallinTime(), "16")));
            jqAll.setBjdh(item.getContactTelNo());
            jqAll.setBjdhYhxm(item.getAlarmPersonName());
            jqAll.setBjrXm(item.getAlarmPersonName());
            jqAll.setBjrLxdh(item.getContactTelNo());
            jqAll.setSfdzxzqh(item.getAdminCode());
            jqAll.setSfdz(item.getAlarmAddress());
            jqAll.setBjnr(item.getAlarmContent());
            jqAll.setJqjb(item.getAlarmLevel());
            jqAll.setBjlbmc(item.getLbmc());
            jqAll.setBjlxmc(item.getLxmc());
            jqAll.setBjxlmc(item.getXlmc());
            jqAll.setBjlb(item.getAlarmMajorType());
            jqAll.setBjlx(item.getAlarmSubType());
            jqAll.setBjxl(item.getAlarmMinorType());
            jqAll.setSfzdjq("1".equals(jqAll.getJqjb()) ? "1" : "0");
            if (item.getLongitude() != null) {
                jqAll.setJd(item.getLongitude());
            }
            if (item.getLatitude() != null) {
                jqAll.setWd(item.getLatitude());
            }
            if (jqAll.getJd() != null && jqAll.getWd() != null) {
                jqAll.setZb(JtsUtils.getPoint(jqAll.getJd(), jqAll.getWd()));
                jqAll.setZbhash(GeoHashKit.encode(jqAll.getJd(), jqAll.getWd()));
            }
            jqAll.setSsbmdm(item.getMainOrgId());
            jqAll.setSsbm(item.getMainOrgName());
            jqAll.setSsxgajdm(item.getSubBureauId());
            jqAll.setSsxgaj(item.getSubBureauName());
            jqAll.setSssgaj(item.getFirstReceiveOrgName());
            jqAll.setSssgajdm(item.getFirstReceiveOrgId());
            jqAll.setXtSjly("1");
            jqAll.setCzzt("0");
            if ("510109000000".equals(item.getSubBureauId())) {
                TbJq jq = new TbJq();
                BeanUtils.copyProperties(jqAll, jq);
                // 添加所属派出所名称和所属分县局名称
                DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByOrgcode(jq.getSsbmdm());
                if (dept != null) {
                    jq.setSsbmdm(dept.getDeptcode());
                    jq.setSsbm(dept.getDeptname());
                    jq.setSsxgaj(dept.getFxjname());
                    jq.setSsxgajdm(dept.getFxjcode());
                    jq.setSssgaj(dept.getDszname());
                    jq.setSssgajdm(dept.getDszcode());
                }
                // 判断是否为街面警情
                this.checkJmjq(jq);
                this.insert(jq);
            }
            // 判断是否为街面警情
            this.checkJmjq(jqAll);
            return this.tbJqAllMapper.insertEntity(jqAll);
        }
        return 0;
    }

    // 添加警情地址
    private void addJqdz(TbJq jq, DeptInfoVo dept) {
        TbJqDz dz = new TbJqDz();
        dz.setId(UUIDGenerator.getUUID());
        dz.setJqId(jq.getId());
        dz.setDztzSj(jq.getBjsj());
        dz.setDztzRyid("-1");
        dz.setDztzRysfzh("000000");
        dz.setDztzRyxm("系统");
        if (jq.getJd() != null && jq.getWd() != null) {
            dz.setJd(jq.getJd());
            dz.setWd(jq.getWd());
            dz.setZb(JtsUtils.getPoint(jq.getJd(), jq.getWd()));
            dz.setZbhash(GeoHashKit.encode(jq.getJd(), jq.getWd()));
        }
        dz.setDzxzqh(jq.getSfdzxzqh());
        dz.setDz(jq.getSfdz());
        dz.setXtSjly("1");
        if (dept != null) {
            dz.setSsbmdm(dept.getDeptcode());
            dz.setSsbm(dept.getDeptname());
            dz.setSsxgaj(dept.getFxjname());
            dz.setSsxgajdm(dept.getFxjcode());
            dz.setSssgaj(dept.getDszname());
            dz.setSssgajdm(dept.getDszcode());
        }
        this.tbJqDzMapper.insertEntity(dz);
    }


    @Override
    public Map<String, Object> getStatistics(TbJqListQuery dto) {
        Map<String, Object> map = new HashMap<>();
        List<Map<String, Object>> list = this.baseMapper.getStatistics(dto);
        int xsCount = 0, xzCount = 0, jtCount = 0, qtCount = 0;
        for (Map<String, Object> item : list) {
            if ("01000000".equals(String.valueOf(item.get("bjlb")))) {
                xsCount += Integer.parseInt(String.valueOf(item.get("count")));
            } else if ("02000000".equals(String.valueOf(item.get("bjlb")))) {
                xzCount += Integer.parseInt(String.valueOf(item.get("count")));
            } else if ("03000000".equals(String.valueOf(item.get("bjlb")))) {
                jtCount += Integer.parseInt(String.valueOf(item.get("count")));
            } else {
                qtCount += Integer.parseInt(String.valueOf(item.get("count")));
            }
        }
        map.put("xsCount", xsCount);
        map.put("xzCount", xzCount);
        map.put("jtCount", jtCount);
        map.put("qtCount", qtCount);
        return map;
    }

    @Override
    public Map<String, Object> getAllStatistics() {
        String time = DateUtils.getQueryDateString(new Date(), "01");
        String yesterday = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
        Map<String, Object> map = new HashMap<>();
        map.put("xsjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "01000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xzjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "02000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("qt", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .notIn(TbJq::getBjlb, "02000000", "01000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xsjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "01000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        map.put("xzjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "02000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        map.put("qtY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .notIn(TbJq::getBjlb, "02000000", "01000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        return map;
    }

    @Override
    public Map<String, Object> getJmjqStatistics() {
        String time = DateUtils.getQueryDateString(new Date(), "01");
        String yesterday = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
        Map<String, Object> map = new HashMap<>();
        map.put("xsjmjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "01110200", "01110300", "01120300", "01120400", "01120700", "01120800",
                                "01121000", "01130100", "01140100", "01149900")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xzjmjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "02030200", "02030300", "02030400", "02030500", "02040100",
                                "02050100", "02050400", "02121700", "02130000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xsjmjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "01110200", "01110300", "01120300", "01120400", "01120700", "01120800",
                                "01121000", "01130100", "01140100", "01149900")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        map.put("xzjmjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "02030200", "02030300", "02030400", "02030500", "02040100",
                                "02050100", "02050400", "02121700", "02130000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        return map;
    }

    @Override
    public Map<String, Object> getWffzStatistics() {
        String time = DateUtils.getQueryDateString(new Date(), "01");
        String yesterday = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
        Map<String, Object> map = new HashMap<>();
        map.put("xsjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "01000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xzjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "02000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xsjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "01000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        map.put("xzjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getBjlb, "02000000")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        return map;
    }

    @Override
    public Map<String, Object> getDqscStatistics() {
        String time = DateUtils.getQueryDateString(new Date(), "01");
        String yesterday = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
        Map<String, Object> map = new HashMap<>();
        map.put("xsscjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "01120400", "01120800")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xzscjq", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "02030200", "02030300")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + time + "'")
        ));
        map.put("xsscjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "01120400", "01120800")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        map.put("xzscjqY", this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .in(TbJq::getBjxl, "02030200", "02030300")
                        .eq(TbJq::getSsxgajdm, "510109000000")
                        .last(" and date_format(bjrq,'%Y-%m-%d') = '" + yesterday + "'")
        ));
        return map;
    }

    @Override
    // 警情类型 1.总警情 2.街面警情 3.违法犯罪
    public Object jqtjDbFjjqzs(String type, String ssfjdm, String jqType) {
        Map<String, Object> map = new HashMap<>();
        List<String> timeList = new ArrayList<>();
        List<Integer> data1 = new ArrayList<>();
        List<Integer> data2 = new ArrayList<>();
        List<Integer> data3 = new ArrayList<>();
        if ("1".equals(type)) {
            String t = DateUtils.getQueryDateString(new Date(), "01") + " ";
            String m = ":00:00";
            String s = ":59:59";
            timeList.add(t + "23" + s);
            timeList.add(t + "20" + m);
            timeList.add(t + "16" + m);
            timeList.add(t + "12" + m);
            timeList.add(t + "08" + m);
            timeList.add(t + "04" + m);
            timeList.add(t + "00" + m);
        } else if ("2".equals(type)) {
            for (int i = 0; i < 8; i++) {
                timeList.add(DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -i), "02"));
            }
        } else if ("3".equals(type)) {
            for (int i = 0; i < 7; i++) {
                timeList.add(DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -i * 6), "02"));
            }
        } else if ("4".equals(type)) {
            for (int i = 0; i < 8; i++) {
                timeList.add(DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -i * 9), "02"));
            }
        }
        Collections.reverse(timeList);
        for (int i = 0; i < timeList.size() - 1; i++) {
            if ("1".equals(jqType)) {
                data1.add(this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(StringUtils.isNotEmpty(ssfjdm), TbJq::getSsxgajdm, ssfjdm)
                                .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') between '" + timeList.get(i) + "' and '" + timeList.get(i + 1) + "'")
                ));
                data2.add(this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(StringUtils.isNotEmpty(ssfjdm), TbJq::getSsxgajdm, ssfjdm)
                                .in(TbJq::getBjxl, Arrays.asList(JmjqList))
                                .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') between '" + timeList.get(i) + "' and '" + timeList.get(i + 1) + "'")
                ));
                data3.add(this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(StringUtils.isNotEmpty(ssfjdm), TbJq::getSsxgajdm, ssfjdm)
                                .in(TbJq::getBjlb, Arrays.asList(wffzList))
                                .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') between '" + timeList.get(i) + "' and '" + timeList.get(i + 1) + "'")
                ));
            } else if ("2".equals(jqType)) {
                data1.add(this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(StringUtils.isNotEmpty(ssfjdm), TbJq::getSsxgajdm, ssfjdm)
                                .in(TbJq::getBjxl, Arrays.asList(jmxsjqList))
                                .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') between '" + timeList.get(i) + "' and '" + timeList.get(i + 1) + "'")
                ));
                data2.add(this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(StringUtils.isNotEmpty(ssfjdm), TbJq::getSsxgajdm, ssfjdm)
                                .in(TbJq::getBjxl, Arrays.asList(jmxzjqList))
                                .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') between '" + timeList.get(i) + "' and '" + timeList.get(i + 1) + "'")
                ));
            } else if ("3".equals(jqType)) {
                data1.add(this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(StringUtils.isNotEmpty(ssfjdm), TbJq::getSsxgajdm, ssfjdm)
                                .eq(TbJq::getBjlb, "01000000")
                                .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') between '" + timeList.get(i) + "' and '" + timeList.get(i + 1) + "'")
                ));
                data2.add(this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(StringUtils.isNotEmpty(ssfjdm), TbJq::getSsxgajdm, ssfjdm)
                                .eq(TbJq::getBjlb, "02000000")
                                .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') between '" + timeList.get(i) + "' and '" + timeList.get(i + 1) + "'")
                ));
            }
        }
        timeList.remove(0);
        List<String> tempList = new ArrayList<>();
        timeList.forEach(item -> {
            String time = "";
            if ("1".equals(type)) {
                time = DateUtils.getQueryDateString(DateUtils.strToDate(item, "02"), "16");
            } else {
                time = DateUtils.getQueryDateString(DateUtils.strToDate(item, "02"), "18");
            }
            tempList.add(time);
        });
        timeList = tempList;
        map.put("timeList", timeList);
        map.put("data1", data1);
        map.put("data2", data2);
        map.put("data3", data3);
        return map;
    }

    @Override
    // type 查询类型 1.今日 2.近一周 3.近一月
    public Object jqtjDbCqfjhb(String type, String jqType) {
        // 各分局行政区划代码
        List<Map<String, String>> orgList = this.getCode();
        List<Map<String, Object>> list = new ArrayList<>();
        String kssj = "", jssj = "", startTime = "", endTime = "";
        if ("1".equals(type)) {
            kssj = DateUtils.getQueryDateString(new Date(), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
        } else if ("2".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -14), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
        } else if ("3".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -60), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
        } else if ("4".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -90), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -180), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -90), "01");
        }
        for (Map<String, String> org : orgList) {
            Map<String, Object> map = new HashMap<>();
            map.put("orgcode", org.get("orgcode"));
            map.put("orgname", org.get("orgname"));


            int count;
            int count1;
            int count2;
            count = this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .eq(TbJq::getSsxgajdm, org.get("orgcode"))
                            .in(StringUtils.isNotEmpty(jqType) && "2".equals(jqType), TbJq::getBjxl, Arrays.asList(JmjqList))
                            .in(StringUtils.isNotEmpty(jqType) && "3".equals(jqType), TbJq::getBjlb, Arrays.asList(wffzList))
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
            );
            count1 = this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .eq(TbJq::getSsxgajdm, org.get("orgcode"))
                            .in(StringUtils.isNotEmpty(jqType) && "2".equals(jqType), TbJq::getBjxl, Arrays.asList(JmjqList))
                            .in(StringUtils.isNotEmpty(jqType) && "3".equals(jqType), TbJq::getBjlb, Arrays.asList(wffzList))
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + startTime + "' and '" + endTime + "'")
            );
            count2 = this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .in(StringUtils.isNotEmpty(jqType) && "2".equals(jqType), TbJq::getBjxl, Arrays.asList(JmjqList))
                            .in(StringUtils.isNotEmpty(jqType) && "3".equals(jqType), TbJq::getBjlb, Arrays.asList(wffzList))
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
            );

            // 本
            map.put("count", count);
            // 上
            map.put("count1", count1);
            // 本-所有
            map.put("count2", count2);
            list.add(map);
        }
        return list;
    }

    @Override
    // type 查询类型 1.今日 2.近一周 3.近一月
    public Object jqtjDbCqfjhbTable(String type, String ssfjdm, String jqType) {
        List<Map<String, Object>> list = new ArrayList<>();
        List<Map<String, String>> orgList = this.getCode();
        List<Map<String, String>> bjlbList = this.getBjlbList();
        List<String> bjlbs = bjlbList.stream().map(item -> item.get("code")).collect(Collectors.toList());
        String kssj = "", jssj = "";
        if ("1".equals(type)) {
            kssj = DateUtils.getQueryDateString(new Date(), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        } else if ("2".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        } else if ("3".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        } else if ("4".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -90), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        }
        for (Map<String, String> bjlb : bjlbList) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", bjlb.get("code"));
            map.put("name", bjlb.get("name"));
            for (Map<String, String> org : orgList) {
                map.put(org.get("orgname"), this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(TbJq::getSsxgajdm, org.get("orgcode"))
                                .eq(TbJq::getBjlb, bjlb.get("code"))
                                .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
                ));

            }
            list.add(map);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("code", "00000000");
        map.put("name", "其他");
        for (Map<String, String> org : orgList) {
            map.put("orgcode", org.get("orgcode"));
            try {
                map.put(org.get("orgname"), this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(TbJq::getSsxgajdm, org.get("orgcode"))
                                .notIn(TbJq::getBjlb, bjlbs)
                                .between(TbJq::getBjsj, DateUtils.strToDate(kssj, "1").getTime(), DateUtils.strToDate(jssj, "1").getTime()))
                        .intValue());
            } catch (Exception e) {
                System.err.println("APP警情分析-对比分析-城区分局警情环比-列表 ES失败" + e.getMessage());
                map.put(org.get("orgname"), this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(TbJq::getSsxgajdm, org.get("orgcode"))
                                .notIn(TbJq::getBjlb, bjlbs)
                                .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
                ));
            }
        }
        list.add(map);
        return list;
    }

    @Override
    public Object jqtjDbPcsHb(String type, String ssfjdm, String jqType) {
        // 查询派出所代码
        List<SysDeptDTO> orgList = this.tbBaseAdaptRemoteService.getPcsByFxjdm(ssfjdm);
        List<Map<String, Object>> list = new ArrayList<>();
        String kssj = "", jssj = "", startTime = "", endTime = "";
        if ("1".equals(type)) {
            kssj = DateUtils.getQueryDateString(new Date(), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
        } else if ("2".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -14), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
        } else if ("3".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -60), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
        } else if ("4".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "M", -90), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "M", -180), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "M", -90), "01");
        }
        for (SysDeptDTO org : orgList) {
            Map<String, Object> map = new HashMap<>();
            map.put("orgcode", org.getOrgCode());
            map.put("orgname", org.getOrgJc());
            int count;
            int count1;
            int count2;
            count = this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .eq(TbJq::getSsbmdm, org.getOrgCode())
                            .in(StringUtils.isNotEmpty(jqType) && "2".equals(jqType), TbJq::getBjxl, Arrays.asList(JmjqList))
                            .in(StringUtils.isNotEmpty(jqType) && "3".equals(jqType), TbJq::getBjlb, Arrays.asList(wffzList))
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
            );
            count1 = this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .eq(TbJq::getSsbmdm, org.getOrgCode())
                            .in(StringUtils.isNotEmpty(jqType) && "2".equals(jqType), TbJq::getBjxl, Arrays.asList(JmjqList))
                            .in(StringUtils.isNotEmpty(jqType) && "3".equals(jqType), TbJq::getBjlb, Arrays.asList(wffzList))
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + startTime + "' and '" + endTime + "'")
            );
            count2 = this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .eq(TbJq::getSsxgajdm, ssfjdm)
                            .in(StringUtils.isNotEmpty(jqType) && "2".equals(jqType), TbJq::getBjxl, Arrays.asList(JmjqList))
                            .in(StringUtils.isNotEmpty(jqType) && "3".equals(jqType), TbJq::getBjlb, Arrays.asList(wffzList))
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
            );

            // 本
            map.put("count", count);
            // 上
            map.put("count1", count1);
            // 本-所有
            map.put("count2", count2);
            list.add(map);
        }
        return list;
    }

    @Override
    public Object jqtjDbPcsHbTable(String type, String ssfjdm, String jqType) {
        Map<String, Object> resMap = new HashMap<>();
        List<Map<String, Object>> list = new ArrayList<>();
        List<SysDeptDTO> orgList = this.tbBaseAdaptRemoteService.getPcsByFxjdm(ssfjdm);
        List<Map<String, String>> bjlbList = this.getBjlbList();
        List<String> bjlbs = bjlbList.stream().map(item -> item.get("code")).collect(Collectors.toList());
        String kssj = "", jssj = "", startTime = "", endTime = "";
        if ("1".equals(type)) {
            kssj = DateUtils.getQueryDateString(new Date(), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
        } else if ("2".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -14), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
        } else if ("3".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -60), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
        } else if ("4".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -90), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
            startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -180), "01");
            endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -90), "01");
        }
        for (Map<String, String> bjlb : bjlbList) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", bjlb.get("code"));
            map.put("name", bjlb.get("name"));
            for (SysDeptDTO org : orgList) {
                map.put(org.getOrgJc() + "_data1", this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(TbJq::getSsbmdm, org.getOrgCode())
                                .eq(TbJq::getBjlb, bjlb.get("code"))
                                .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
                ));
                map.put(org.getOrgJc() + "_data2", this.baseMapper.selectCount(
                        new LambdaQueryWrapper<TbJq>()
                                .eq(TbJq::getSsbmdm, org.getOrgCode())
                                .eq(TbJq::getBjlb, bjlb.get("code"))
                                .last(" and date_format(bjrq,'%Y-%m-%d') between '" + startTime + "' and '" + endTime + "'")
                ));


            }
            list.add(map);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("code", "00000000");
        map.put("name", "其他");
        for (SysDeptDTO org : orgList) {
            map.put(org.getOrgJc() + "_data1", this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .eq(TbJq::getSsbmdm, org.getOrgCode())
                            .notIn(TbJq::getBjlb, bjlbs)
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + kssj + "' and '" + jssj + "'")
            ));
            map.put(org.getOrgJc() + "_data2", this.baseMapper.selectCount(
                    new LambdaQueryWrapper<TbJq>()
                            .eq(TbJq::getSsbmdm, org.getOrgCode())
                            .notIn(TbJq::getBjlb, bjlbs)
                            .last(" and date_format(bjrq,'%Y-%m-%d') between '" + startTime + "' and '" + endTime + "'")
            ));

        }
        list.add(map);
        return list;
    }

    @Override
    public Object jqtjSgFirst(String type, String ssfjdm, String jqType, String sdlx) {
        String kssj = "", jssj = "";
        List<String> timeList = new ArrayList<>();
        if ("1".equals(type)) {
            kssj = DateUtils.getQueryDateString(new Date(), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        } else if ("2".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        } else if ("3".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        } else if ("4".equals(type)) {
            kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -90), "01");
            jssj = DateUtils.getQueryDateString(new Date(), "01");
        }
        return null;
    }

    @Override
    public List<TbJqVo> getGljq(String jjdbh) {
        List<TbJq> jqList = this.baseMapper.selectList(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getGljjdbh, jjdbh)
                        .or(item -> item.eq(TbJq::getJjdbh, jjdbh))
        );
        List<TbJqVo> voList = new ArrayList<>();
        jqList.forEach(item -> {
            TbJqVo vo = new TbJqVo();
            BeanUtils.copyProperties(item, vo);
            voList.add(vo);
        });
        return voList;
    }

    @Override
    public Integer addXzJqCjdb(GxCjdb cjdb) {
        TbJqCjdb jqCjdb = new TbJqCjdb();
        BeanUtils.copyProperties(cjdb, jqCjdb);
        jqCjdb.setXtSjly("1");
        jqCjdb.setId(UUIDGenerator.getUUID());
        return this.tbJqCjdbMapper.insert(jqCjdb);
    }

    @Override
    public IPage<TbJqCjdb> getCjList(TbJqCjdbQuery dto) {
        return this.tbJqCjdbMapper.selectPage(
                new Page<TbJqCjdb>(dto.getPageCurrent(), dto.getPageSize()),
                new LambdaQueryWrapper<TbJqCjdb>()
                        .eq(TbJqCjdb::getJjdbh, dto.getJjdbh())
                        .eq(TbJqCjdb::getXtSjzt, "1")
                        .orderByDesc(TbJqCjdb::getCjsj)
        );
    }

    @Override
    public int addRsJq(TbJq entity) {
        TbJq jq = this.baseMapper.selectOne(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getJq110Id, entity.getJq110Id())
        );
        if (jq == null) {
            entity.setId(UUIDGenerator.getUUID());
            // 判断是否为街面警情
            this.checkJmjq(entity);
            return this.insert(entity);
        }
        return 0;
    }

    @Override
    public TbJqVo getLastJq() {
        TbJq jq = this.baseMapper.selectOne(
                new LambdaQueryWrapper<TbJq>()
//                        .eq(TbJq::getBjrq, new Date())
                        .orderByDesc(TbJq::getBjsj)
                        .last(" limit 1")
        );
        if (jq != null) {
            TbJqVo vo = new TbJqVo();
            BeanUtils.copyProperties(jq, vo);
            return vo;
        }
        return null;
    }

    @Override
    public TbJqCjdb getLastJqCjdb() {
        return this.tbJqCjdbMapper.selectOne(
                new LambdaQueryWrapper<TbJqCjdb>()
                        .orderByDesc(TbJqCjdb::getRksj)
                        .last(" limit 1")
        );
    }

    @Override
    public void addRsCjdb(TbJqCjdb cjdb) {
        //补全警情经纬度
        TbJq tbJq = this.baseMapper.selectOne(new LambdaQueryWrapper<TbJq>().eq(TbJq::getJjdbh, cjdb.getJjdbh()).last(" limit 1"));
        if (ObjectUtils.isNotEmpty(tbJq) && ObjectUtils.isNotEmpty(cjdb.getFkdwxzb()) && !String.valueOf(cjdb.getFkdwxzb()).equals("0.00000")) {
            tbJq.setJd(cjdb.getFkdwxzb());
            tbJq.setWd(cjdb.getFkdwyzb());


            this.baseMapper.updateById(tbJq);
        }
        this.tbJqCjdbMapper.insert(cjdb);
    }


    @Override
    public JSONObject situation(String startTime, String endTime) {
        String url = Constant.XZ_URL + "faAlarm/situation";
        JSONObject map = new JSONObject();
        map.put("startTime", startTime);
        map.put("endTime", endTime);
        String res = HttpUtils.executePostJSON(url, map.toString(), null);
        if (res != null) return JSONObject.parseObject(res);
        return null;
    }

    @Override
    public JSONObject alarmSituation(String startTime, String endTime) {
        String url = Constant.XZ_URL + "synthesis/alarmSituation";
        JSONObject map = new JSONObject();
        map.put("startTime", startTime);
        map.put("endTime", endTime);
        String res = HttpUtils.executePostJSON(url, map.toString(), null);
        if (res != null) return JSONObject.parseObject(res);
        return null;
    }


    @Override
    public void addYbJq(Jjdb jjdb) {
        TbJq jq = new TbJq();
        jq.setId(UUIDGenerator.getUUID());
        jq.setJjdbh(jjdb.getJjdbh());
        jq.setJjdwbh(jjdb.getJjdwdm());
        DeptInfoVo dept1 = this.tbBaseAdaptRemoteService.getOrgByOrgcode(jjdb.getJjdwdm());
        if (dept1 != null) {
            jq.setJjdwmc(dept1.getDeptname());
        }
        jq.setGljjdbh(jjdb.getJjdbh());
        jq.setJjybh(jjdb.getJjybh());
        jq.setJjyxm(jjdb.getJjyxm());
        jq.setHrsj(jjdb.getBjsj());
        jq.setLhlxbh(jjdb.getLhlx());
        jq.setBjfsbh(jjdb.getJqlyfs());
        jq.setBjrq(jjdb.getBjsj());
        jq.setBjsj(jjdb.getBjsj());
        jq.setJjsj(jjdb.getBjsj());
        jq.setJjlyh(jjdb.getJjlyh());
        String time = DateUtils.getQueryDateString(jq.getBjsj(), "02");
        if (time != null) {
            String jqfsksnf = time.substring(0, 4);
            String jqfsksyf = time.substring(5, 7);
            String jqfsksxs = time.substring(11, 13);
            String jqfsksny = jqfsksnf + jqfsksyf;
            Calendar ca = Calendar.getInstance();
            ca.setTime(jjdb.getBjsj());
            Integer jqfskszs = ca.get(Calendar.WEEK_OF_YEAR);
            jq.setJqfsksnf(Integer.valueOf(jqfsksnf));
            jq.setJqfsksyf(Integer.valueOf(jqfsksyf));
            jq.setJqfsksny(Integer.valueOf(jqfsksny));
            jq.setJqfskszs(jqfskszs);
            jq.setJqfsksxs(Integer.parseInt(jqfsksxs));
            jq.setJqfsksrq(jq.getBjsj());
            jq.setJqfskssj(jq.getBjsj());
        }
        jq.setBjdh(jjdb.getBjdh());
        jq.setBjdhYhxm(jjdb.getBjdhyhm());
        jq.setBjdhYhdz(jjdb.getBjdhyhdz());
        jq.setBjrXm(jjdb.getBjrmc());
        jq.setBjrXb(jjdb.getBjrxbdm());
        jq.setBjrLxdh(jjdb.getLxdh());
        DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByOrgcode(jjdb.getGxdwdm());
        if (ObjectUtils.isEmpty(dept) || ObjectUtils.isEmpty(dept.getDeptid())) {
            dept = this.tbBaseAdaptRemoteService.getOrgByOrgcode(jjdb.getGxdwdm().substring(0, 6) + "000000");
        }
        if (ObjectUtils.isEmpty(dept) || ObjectUtils.isEmpty(dept.getDeptid())) {
            dept = this.tbBaseAdaptRemoteService.getOrgByOrgcode(jjdb.getGxdwdm().substring(0, 4) + "00000000");
        }
        jq.setSfdzxzqh((StringUtils.isNotEmpty(jjdb.getGxdwdm()) && jjdb.getGxdwdm().length() >= 6)
                ? jjdb.getGxdwdm().substring(0, 6) : "");
        jq.setSfdz(jjdb.getJqdz());
        jq.setBjnr(jjdb.getBjnr());
        jq.setJqjb(jjdb.getJqdjdm());
        jq.setBjlb(jjdb.getJqlbdm());
        jq.setBjlx(jjdb.getJqlxdm());
        jq.setBjxl(jjdb.getJqxldm());
        jq.setSfzdjq("0");
        if (jjdb.getFxdwjd() != null && !String.valueOf(jjdb.getFxdwjd()).equals("0.00000")) {
            jq.setJd(jjdb.getFxdwjd());
            jq.setWd(jjdb.getFxdwwd());
        }
        jq.setCzzt(jjdb.getJqclztdm());
        jq.setZdjqtjlx("01");
        if (dept != null) {
            jq.setSsbm(dept.getDeptname());
            jq.setSsbmdm(dept.getDeptcode());
            jq.setSsxgajdm(dept.getFxjcode());
            jq.setSsxgaj(dept.getFxjname());
            jq.setSssgaj(dept.getDszname());
            jq.setSssgajdm(dept.getDszcode());
        }
        jq.setXtSjly("1");
        if (StringUtils.isNotBlank(jq.getBjlb())) {
            SysDictItem d_bz_jqfl = this.baseMapper.selectDict("D_BZ_JQFL", jq.getBjlb());
            if (ObjectUtils.isNotEmpty(d_bz_jqfl)) {
                jq.setBjlbmc(d_bz_jqfl.getZdmc());
            }
        }
        if (StringUtils.isNotBlank(jq.getBjlx())) {
            SysDictItem d_bz_jqfl = this.baseMapper.selectDict("D_BZ_JQFL", jq.getBjlx());
            if (ObjectUtils.isNotEmpty(d_bz_jqfl)) {
                jq.setBjlxmc(d_bz_jqfl.getZdmc());
            }
        }
        if (StringUtils.isNotBlank(jq.getBjxl())) {
            SysDictItem d_bz_jqfl = this.baseMapper.selectDict("D_BZ_JQFL", jq.getBjxl());
            if (ObjectUtils.isNotEmpty(d_bz_jqfl)) {
                jq.setBjxlmc(d_bz_jqfl.getZdmc());
            }
        }

        this.checkJmjq(jq);
        // 判断是否重大警情
        this.checkZdjq(jq);
        // 判断是否颜色
        this.checkColor(jq);
        this.insert(jq);
    }

    @Override
    public void addLzJq(VLz110Txj lz110) {
        TbJq jq = new TbJq();
        jq.setId(UUIDGenerator.getUUID());
        jq.setJjdbh(lz110.getJjdbh());
        jq.setJjdwbh(lz110.getJjdwbh());
        DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByOrgcode(lz110.getJjdwbh());
        if (dept != null) {
            jq.setJjdwmc(dept.getDeptname());
        }
        jq.setGljjdbh(lz110.getGljjdbh());
        jq.setJjybh(lz110.getJjybh());
        jq.setJjyxm(lz110.getJjyxm());
        jq.setHrsj(lz110.getBjsj());
        jq.setLhlxbh((StringUtils.isNotEmpty(lz110.getLhlxbh()) && lz110.getLhlxbh().contains("teleType"))
                ? lz110.getLhlxbh().replace("teleType", "") : lz110.getLhlxbh());
        jq.setBjfsbh((StringUtils.isNotEmpty(lz110.getBjfsbh()) && lz110.getBjfsbh().contains("callMode"))
                ? lz110.getBjfsbh().replace("callMode", "") : lz110.getBjfsbh());
        jq.setBjrq(lz110.getBjsj());
        jq.setBjsj(lz110.getBjsj());
        jq.setJjsj(lz110.getJjsj());
        String time = DateUtils.getQueryDateString(jq.getBjsj(), "02");
        if (time != null) {
            String jqfsksnf = time.substring(0, 4);
            String jqfsksyf = time.substring(5, 7);
            String jqfsksxs = time.substring(11, 13);
            String jqfsksny = jqfsksnf + jqfsksyf;
            Calendar ca = Calendar.getInstance();
            ca.setTime(jq.getBjsj());
            Integer jqfskszs = ca.get(Calendar.WEEK_OF_YEAR);
            jq.setJqfsksnf(Integer.valueOf(jqfsksnf));
            jq.setJqfsksyf(Integer.valueOf(jqfsksyf));
            jq.setJqfsksny(Integer.valueOf(jqfsksny));
            jq.setJqfskszs(jqfskszs);
            jq.setJqfsksxs(Integer.parseInt(jqfsksxs));
            jq.setJqfsksrq(jq.getBjsj());
            jq.setJqfskssj(jq.getBjsj());
        }
        jq.setBjdh(lz110.getBjdh());
        jq.setBjdhYhxm(lz110.getBjdhyhxm());
        jq.setBjdhYhdz(lz110.getBjdhyhdz());
        jq.setBjrXm(lz110.getBjrxm());
        jq.setBjrXb((StringUtils.isNotEmpty(lz110.getBjrxb()) && lz110.getBjrxb().contains("sex")) ?
                lz110.getBjrxb().replace("sex", "") : "");
        jq.setBjrLxdh(lz110.getLxdh());
        jq.setSfdzxzqh((StringUtils.isNotEmpty(lz110.getGxdwbh()) && lz110.getGxdwbh().length() >= 6)
                ? lz110.getGxdwbh().substring(0, 6) : "");
        jq.setSfdz(lz110.getSfdz());
        jq.setBjnr(lz110.getBjnr());
        // TODO 确认警情级别
        jq.setJqjb("4");
//        this.setBjlblxxlMc(jq, lz110);
        jq.setSfzdjq("0");
        if (lz110.getSddwxzb() == null || lz110.getSddwxzb().equals(BigDecimal.ZERO)) {
            if (lz110.getZddwxzb() != null && !lz110.getZddwxzb().equals(BigDecimal.ZERO)) {
                jq.setJd(lz110.getZddwxzb());
            }
        } else {
            jq.setJd(lz110.getSddwxzb());
        }
        if (lz110.getSddwyzb() == null || lz110.getSddwyzb().equals(BigDecimal.ZERO)) {
            if (lz110.getZddwyzb() != null && !lz110.getZddwyzb().equals(BigDecimal.ZERO)) {
                jq.setWd(lz110.getZddwyzb());
            }
        } else {
            jq.setWd(lz110.getSddwyzb());
        }

//        if (jq.getJd() != null && jq.getWd() != null) {
//            jq.setZb(JtsUtils.getPoint(jq.getJd(), jq.getWd()));
//            jq.setZbhash(GeoHashKit.encode(jq.getJd(), jq.getWd()));
//        }
        jq.setCzzt("0");
        jq.setZdjqtjlx("01");
        if (dept != null) {
            jq.setSsbm(dept.getDeptname());
            jq.setSsbmdm(dept.getDeptcode());
            jq.setSsxgajdm(dept.getFxjcode());
            jq.setSsxgaj(dept.getFxjname());
            jq.setSssgaj(dept.getDszname());
            jq.setSssgajdm(dept.getDszcode());
        }
        jq.setXtSjly("1");
        // 判断是否为街面警情
        this.checkJmjq(jq);
        // 判断是否重大警情
        this.checkZdjq(jq);
        this.insert(jq);


    }

    private void xfzl(TbJq jq) {
        //如果是重大警情和走失 判断点位是那个巡防区快反点
        if ((jq.getSfzdjq().equals("1") || jq.getBjnr().contains("走失")) && ObjectUtils.isNotEmpty(jq.getJd()) && ObjectUtils.isNotEmpty(jq.getWd())) {
            //查询所有巡防区
            List<TbJcglXfqyDto> listXfqyAll = this.tbJcglAdaptRemoteService.getListXfqyAll();
            //现在暂时随便定一个单位
            String ssbmid = null;


            Set<String> xfq = new HashSet<>();
            if (!CollectionUtils.isEmpty(listXfqyAll)) {
                for (TbJcglXfqyDto dto : listXfqyAll) {
                    Coordinate[] coordinates = new Coordinate[dto.getPgis().size()];
                    for (int i = 0; i < dto.getPgis().size(); i++) {
                        BigDecimal[] jwd = dto.getPgis().get(i);
                        Coordinate coor = new Coordinate();
                        coor.x = jwd[0].doubleValue();
                        coor.y = jwd[1].doubleValue();
                        coordinates[i] = coor;
                    }
                    boolean s = Kit.isInGeometry(coordinates, jq.getJd() + "," + jq.getWd());
                    if (s) {
                        xfq.add(dto.getId());
                        ssbmid = dto.getSsbmid();
                    }
                }
            }
            //查询所有快反点
            List<TbJcglKfdDto> listKfdAll = this.tbJcglAdaptRemoteService.getListKfdAll();
            if (!CollectionUtils.isEmpty(listKfdAll)) {
                for (TbJcglKfdDto dto : listKfdAll) {
                    Coordinate[] coordinates = new Coordinate[dto.getWfzfw().size()];
                    for (int i = 0; i < dto.getWfzfw().size(); i++) {
                        BigDecimal[] jwd = dto.getWfzfw().get(i);
                        Coordinate coor = new Coordinate();
                        coor.x = jwd[0].doubleValue();
                        coor.y = jwd[1].doubleValue();
                        coordinates[i] = coor;
                    }
                    boolean s = Kit.isInGeometry(coordinates, jq.getJd() + "," + jq.getWd());
                    if (s) {
                        xfq.add(dto.getKfdId());
                        ssbmid = dto.getSsbmid();
                    }
                }
            }
            Set<String> setBbid = new HashSet<>();
            if (!CollectionUtils.isEmpty(xfq)) {
                for (String xqid : xfq) {
                    List<TbQwXfbb> bbidByXq = this.tbQwzxAdaptRemoteService.getBbidByXq(xqid);
                    if (!CollectionUtils.isEmpty(bbidByXq)) {
                        Set<String> bbids = bbidByXq.stream().map(TbQwXfbb::getId).collect(Collectors.toSet());
                        setBbid.addAll(bbids);
                    }
                }
            }
            if (!CollectionUtils.isEmpty(setBbid)) {
                String bbids = String.join(",", setBbid);
                System.out.println("警情下发指令报备id------------>" + bbids);
                this.tbYjzlAdaptRrmoteService.andJqZl(ssbmid, jq.getId(), bbids, "3");
            }

        }

    }

    // 判断是否为街面警情（抢夺、抢劫,入盗，行窃）
    private void checkJmjq(TbJq jq) {
        jq.setSfjmjq("0");
        String[] xlList = new String[]{"抢", "盗", "窃"};
        if (StringUtils.isNotEmpty(jq.getBjnr())) {
            for (String xl : xlList) {
                if (jq.getBjnr().contains(xl)) {
                    jq.setSfjmjq("1");
                    break;
                }
            }
        }
    }


    //判断颜色
    private void checkColor(TbJq jq) {
        jq.setColor("4");
        String[] yellow = new String[]{"走失", "走丢", "老人", "儿童", "小孩"};
        String[] orange = new String[]{"盗", "偷", "手机", "电瓶车", "电瓶", "盗窃"};
        String[] red = new String[]{"抢劫", "抢夺", "杀人", "自杀", "死亡", "跳楼", "跳河", "煤气", "暴恐", "袭击", "持刀", "劫持", "打架", "斗殴", "聚众", "爆炸", "杀", "刀", "暴", "死", "抢", "砍", "枪"};
        if (StringUtils.isNotEmpty(jq.getBjnr())) {
            for (String xl : yellow) {
                if (jq.getBjnr().contains(xl)) {
                    jq.setBz(xl);
                    jq.setColor("3");
                    break;
                }
            }
            for (String xl : orange) {
                if (jq.getBjnr().contains(xl)) {
                    jq.setBz(xl);
                    jq.setColor("2");
                    break;
                }
            }
            for (String xl : red) {
                if (jq.getBjnr().contains(xl) && !jq.getBjnr().contains("家暴") && !jq.getBjnr().contains("情况说明")) {
                    jq.setBz(xl);
                    jq.setColor("1");
                    break;
                }
            }
        }
    }


    //判断是否重大警情
    private void checkZdjq(TbJq jq) {
        jq.setSfzdjq("0");
        String[] xlList = new String[]{"杀", "爆炸", "恐吓", "抢", "袭击", "持刀", "劫持", "跳楼", "死亡", "打架", "斗殴"};
        if (StringUtils.isNotEmpty(jq.getBjnr())) {
            for (String xl : xlList) {
                if (jq.getBjnr().contains(xl) && !jq.getBjnr().contains("情况说明")) {
                    jq.setSfzdjq("1");
                    break;
                }
            }
        }
    }

    // 判断是否为街面警情（车财、汽车、扒窃、三车、入盗、抢夺、抢劫）
    private void checkJmjq(TbJqAll jqAll) {
        jqAll.setSfjmjq("0");
        String[] xlList = new String[]{"01120700", "01120300", "01121000", "01120800", "02030200", "02030300", "02030400",
                "02050100", "02020900", "01120100", "01120400"};
        String[] lxList = new String[]{"02150000", "01190000", "01160000"};
        if (StringUtils.isNotEmpty(jqAll.getBjxl()) && Arrays.asList(xlList).contains(jqAll.getBjxl())) {
            jqAll.setSfjmjq("1");
        }
        if (StringUtils.isNotEmpty(jqAll.getBjlx()) && Arrays.asList(lxList).contains(jqAll.getBjlx())) {
            jqAll.setSfjmjq("1");
        }
    }

    // 根据时间获取警情数量
    private int getJqCountByTime(String ssbmdm, String kssj, String jssj) {
        return this.baseMapper.selectCount(
                new LambdaQueryWrapper<TbJq>()
                        .eq(TbJq::getXtSjzt, "1")
                        .eq(StringUtils.isNotBlank(ssbmdm), TbJq::getSsbm, ssbmdm)
                        .last(" and date_format(bjsj,'%Y-%m-%d %H:%i:%s') >= '" + kssj +
                                "' and date_format(bjsj,'%Y-%m-%d %H:%i:%s') <= '" + jssj + "'")
        );
    }

    // 获取主城区城市代码
    private List<Map<String, String>> getCode() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map = new HashMap<>();
        map.put("orgcode", "510104000000");
        map.put("orgname", "锦江区");
        list.add(map);
        map = new HashMap<>();
        map.put("orgcode", "510105000000");
        map.put("orgname", "青羊区");
        list.add(map);
        map = new HashMap<>();
        map.put("orgcode", "510106000000");
        map.put("orgname", "金牛区");
        list.add(map);
        map = new HashMap<>();
        map.put("orgcode", "510107000000");
        map.put("orgname", "武侯区");
        list.add(map);
        map = new HashMap<>();
        map.put("orgcode", "510108000000");
        map.put("orgname", "成华区");
        list.add(map);
        map = new HashMap<>();
        map.put("orgcode", "510109000000");
        map.put("orgname", "高新区");
        list.add(map);
        map = new HashMap<>();
        map.put("orgcode", "510156000000");
        map.put("orgname", "天府新区");
        list.add(map);
        return list;
    }

    // 获取主要的警情类型代码
    private List<Map<String, String>> getBjlbList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map = new HashMap<>();
        map.put("code", "01000000");
        map.put("name", "刑事");
        list.add(map);
        map = new HashMap<>();
        map.put("code", "02000000");
        map.put("name", "行政");
        list.add(map);
        map = new HashMap<>();
        map.put("code", "08000000");
        map.put("name", "纠纷");
        list.add(map);
        map = new HashMap<>();
        map.put("code", "05000000");
        map.put("name", "求助");
        list.add(map);
        map = new HashMap<>();
        map.put("code", "11000000");
        map.put("name", "投诉");
        list.add(map);
        map = new HashMap<>();
        map.put("code", "03000000");
        map.put("name", "交通");
        list.add(map);
        return list;
    }

    @Override
    public List<String> selectJjdbh() {
        return this.baseMapper.selectJjdbh("1");
    }

    @Override
    public void updateJqJwd(Jjdb jjdb) {
        TbJq tbJq = new TbJq();
        tbJq.setJjdbh(jjdb.getJjdbh());
        tbJq.setJd(jjdb.getFxdwjd());
        tbJq.setWd(jjdb.getFxdwwd());
        tbJq.setZb(JtsUtils.getPoint(tbJq.getJd(), tbJq.getWd()));
        tbJq.setZbhash(GeoHashKit.encode(tbJq.getJd(), tbJq.getWd()));
        this.baseMapper.updateJqJwd(tbJq);
    }


    @Override
    @PostConstruct
    public void tbJjdhToRedis() {
        List<String> list = this.baseMapper.selectJjdbh(null);
        if (!CollectionUtils.isEmpty(list)) {
            for (String s : list) {
                redisService.setCacheObject(Constant.JQ + s, null, 3L, TimeUnit.HOURS);
            }
        }
        System.out.println("PostConstruct------------》存入redis数据");
    }


}

