| | |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.eCallEventTwo.dto.*; |
| | | import org.springblade.modules.eCallEventTwo.entity.ECallEventTwoEntity; |
| | |
| | | import org.springblade.modules.eCallEventTwo.mapper.EcOrderMapper; |
| | | import org.springblade.modules.eCallEventTwo.service.EcOrderService; |
| | | import org.springblade.modules.eCallEventTwo.service.IECallEventTwoService; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean SynchronizeData(EcOrderParamDTO ecOrderParamDTO) { |
| | | processPages(100, ecOrderParamDTO); |
| | | return true; |
| | | } |
| | | |
| | | public void processPages(int pageSize, EcOrderParamDTO ecOrderParamDTO) { |
| | | long count = count(new QueryWrapper<>()); |
| | | QueryWrapper<EcOrder> ecOrderQueryWrapper = new QueryWrapper<>(); |
| | | ecOrderQueryWrapper.between("import_time", ecOrderParamDTO.getStartTime(), ecOrderParamDTO.getEndTime()); |
| | | long count = baseMapper.selectCount(ecOrderQueryWrapper); |
| | | int totalPages = (int) Math.ceil((double) count / pageSize); // 计算总页数 |
| | | |
| | | for (int pageNum = 1; pageNum <= totalPages; pageNum++) { |
| | | Page<EcOrder> page = new Page<>(pageNum, pageSize); |
| | | IPage<EcOrder> resultPage = baseMapper.selectPage(page, new QueryWrapper<>()); |
| | | QueryWrapper<EcOrder> objectQueryWrapper = new QueryWrapper<>(); |
| | | IPage<EcOrder> resultPage = baseMapper.selectPage(page, objectQueryWrapper); |
| | | List<EcOrder> records = resultPage.getRecords(); |
| | | List<ECallEventTwoEntity> recordEntityList = BeanUtil.copy(records, ECallEventTwoEntity.class); |
| | | boolean b = ecOrderService.saveOrUpdateBatch(recordEntityList); |
| | | recordEntityList.forEach(ecOrderEntity -> { |
| | | // 点落面 设置警格网格信息 |
| | | setGridInfo(ecOrderEntity); |
| | | }); |
| | | boolean b = ecOrderService.saveBatch(recordEntityList); |
| | | System.out.println("更新第" + pageNum + "页" + b); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置警格网格信息 |
| | | * |
| | | * @param ecOrderEntity |
| | | */ |
| | | public void setGridInfo(ECallEventTwoEntity ecOrderEntity) { |
| | | if (ecOrderEntity.getSceneGeoLng() == null || ecOrderEntity.getSceneGeoLat() == null) { |
| | | return; |
| | | } |
| | | // 根据位置设置网格,警格编号 |
| | | IGridService gridService = SpringUtils.getBean(IGridService.class); |
| | | IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class); |
| | | String point = "'POINT(" + ecOrderEntity.getSceneGeoLng().toString() + " " + ecOrderEntity.getSceneGeoLat().toString() + ")'"; |
| | | // 点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size() > 0) { |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | ecOrderEntity.setGridCode(gridEntity.getGridCode()); |
| | | } |
| | | // 点坐标解析警格 |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size() > 0) { |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | ecOrderEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取单位考核指标 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |