zhongrj
2024-03-22 8a881a2c54673d4223425f17bc5cae8eef4e5649
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package org.springblade.modules.backblast.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.param.GridSet;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.backblast.entity.BackblastPubRecordEntity;
import org.springblade.modules.backblast.vo.BackblastPubRecordVO;
import org.springblade.modules.backblast.mapper.BackblastPubRecordMapper;
import org.springblade.modules.backblast.service.IBackblastPubRecordService;
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.service.IPoliceAffairsGridService;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
 
import java.util.List;
 
/**
 * 反炸宣传记录表 服务实现类
 *
 * @author BladeX
 * @since 2024-03-15
 */
@Service
public class BackblastPubRecordServiceImpl extends ServiceImpl<BackblastPubRecordMapper, BackblastPubRecordEntity> implements IBackblastPubRecordService {
 
    /**
     * 自定义分页列表查询
     * @param page
     * @param backblastPubRecord
     * @return
     */
    @Override
    public IPage<BackblastPubRecordVO> selectBackblastPubRecordPage(IPage<BackblastPubRecordVO> page, BackblastPubRecordVO backblastPubRecord) {
        CommonParamSet commonParamSet = new CommonParamSet<>().invoke(BackblastPubRecordVO.class, backblastPubRecord);
        return page.setRecords(baseMapper.selectBackblastPubRecordPage(page,
            backblastPubRecord,
            commonParamSet.getIsAdministrator(),
            commonParamSet.getRegionChildCodesList(),
            commonParamSet.getGridCodeList()));
    }
 
    /**
     * 反炸宣传记录表 自定义新增/修改
     * @param backblastPubRecord
     * @return
     */
    @Override
    public boolean addOrUpdateBackblastPubRecordEntity(BackblastPubRecordEntity backblastPubRecord) {
        // 点落面计算警格,网格,警格
        GridSet invoke = new GridSet().invoke(BackblastPubRecordEntity.class, backblastPubRecord,
            "lng", "lat", "gridCode", "jwGridCode");
        // 设置民警姓名电话(非民警暂时也记录)
        User user = SpringUtils.getBean(IUserService.class).getById(AuthUtil.getUserId());
        if (null!=user){
            backblastPubRecord.setPoliceman(user.getRealName());
            backblastPubRecord.setPolicemanPhone(user.getPhone());
        }
        if (null!=backblastPubRecord.getId()){
            // 更新
            return updateById(backblastPubRecord);
        }
        // 新增
        return save(backblastPubRecord);
    }
 
    /**
     * 设置警格网格信息
     * @param backblastPubRecord
     */
    public void setGridInfo(BackblastPubRecordEntity backblastPubRecord) {
        // 根据位置设置网格,警格编号
        IGridService gridService = SpringUtils.getBean(IGridService.class);
        IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class);
        String point = "'POINT(" + backblastPubRecord.getLng() + " " + backblastPubRecord.getLat() + ")'";
        //点坐标解析网格
        List<GridEntity> gridEntityList = gridService.spatialAnalysis(point);
        if (gridEntityList.size()>0){
            GridEntity gridEntity = gridEntityList.get(0);
            backblastPubRecord.setGridCode(gridEntity.getGridCode());
        }
        //点坐标解析警格
        List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point);
        if (policeAffairsGridEntityList.size()>0){
            PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0);
            backblastPubRecord.setJwGridCode(policeAffairsGridEntity.getJwGridCode());
        }
    }
 
    /**
     * 反炸宣传记录表 自定义详情
     * @param backblastPubRecord
     * @return
     */
    @Override
    public BackblastPubRecordVO getDetail(BackblastPubRecordVO backblastPubRecord) {
        return baseMapper.getDetail(backblastPubRecord);
    }
}