linwe
2024-09-03 764d883b5ea3bdc06abbec548b6df0511e567978
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.police.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.AuthUtils;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.grid.entity.GridEntity;
import org.springblade.modules.grid.service.IGridService;
import org.springblade.modules.police.entity.PoliceAffairsGridEntity;
import org.springblade.modules.police.entity.PoliceAlarmRecordsEntity;
import org.springblade.modules.police.service.IPoliceAffairsGridService;
import org.springblade.modules.police.vo.PoliceAlarmRecordsVO;
import org.springblade.modules.police.mapper.PoliceAlarmRecordsMapper;
import org.springblade.modules.police.service.IPoliceAlarmRecordsService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
 
import java.util.List;
 
/**
 * 报警记录 服务实现类
 *
 * @author BladeX
 * @since 2024-03-13
 */
@Service
public class PoliceAlarmRecordsServiceImpl extends ServiceImpl<PoliceAlarmRecordsMapper, PoliceAlarmRecordsEntity> implements IPoliceAlarmRecordsService {
 
    @Override
    public IPage<PoliceAlarmRecordsVO> selectPoliceAlarmRecordsPage(IPage<PoliceAlarmRecordsVO> page, PoliceAlarmRecordsVO policeAlarmRecords) {
        policeAlarmRecords.setPoliceId(AuthUtil.getUserId());
        CommonParamSet commonParamSet = new CommonParamSet<>().invoke(PoliceAlarmRecordsVO.class, policeAlarmRecords);
        return page.setRecords(baseMapper.selectPoliceAlarmRecordsPage(page, policeAlarmRecords,
            commonParamSet.getIsAdministrator(),
            commonParamSet.getRegionChildCodesList(),
            commonParamSet.getGridCodeList()
            ));
    }
 
    /**
     * 报警记录 新增
     */
    @Override
    public boolean savePoliceAlarmRecordsEntity(PoliceAlarmRecordsEntity policeAlarmRecords) {
        // 根据位置设置网格,警格编号
        IGridService gridService = SpringUtils.getBean(IGridService.class);
        IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class);
        String point = "'POINT(" + policeAlarmRecords.getLongitude() + " " + policeAlarmRecords.getLatitude() + ")'";
        //点坐标解析网格
        List<GridEntity> gridEntityList = gridService.spatialAnalysis(point);
        if (gridEntityList.size()>0){
            GridEntity gridEntity = gridEntityList.get(0);
            policeAlarmRecords.setGridCode(gridEntity.getGridCode());
        }
        //点坐标解析警格
        List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point);
        if (policeAffairsGridEntityList.size()>0){
            PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0);
            policeAlarmRecords.setJwGridCode(policeAffairsGridEntity.getJwGridCode());
        }
        // 插入
        return save(policeAlarmRecords);
    }
}