| | |
| | | if (StringUtils.isNotBlank(ecOrderParamDTO.getStartTime()) && StringUtils.isNotEmpty(ecOrderParamDTO.getEndTime())) { |
| | | ecOrderQueryWrapper.between("import_time", ecOrderParamDTO.getStartTime(), ecOrderParamDTO.getEndTime()); |
| | | } |
| | | // System.out.println("**********参数**************************" + JSON.toJSONString(ecOrderParamDTO)); |
| | | long count = count(ecOrderQueryWrapper); |
| | | System.out.println("**********总数**************************" + count); |
| | | int totalPages = (int) Math.ceil((double) count / pageSize); // 计算总页数 |
| | | |
| | | for (int pageNum = 1; pageNum <= totalPages; pageNum++) { |
| | | Page<EcOrder> page = new Page<>(pageNum, pageSize); |
| | | QueryWrapper<EcOrder> objectQueryWrapper = new QueryWrapper<>(); |
| | | IPage<EcOrder> resultPage = baseMapper.selectPage(page, objectQueryWrapper); |
| | | IPage<EcOrder> resultPage = baseMapper.selectPage(page, ecOrderQueryWrapper); |
| | | List<EcOrder> records = resultPage.getRecords(); |
| | | List<ECallEventTwoEntity> recordEntityList = BeanUtil.copy(records, ECallEventTwoEntity.class); |
| | | List<ECallEventTwoEntity> arrayList = new ArrayList<>(); |
| | | List<ECallEventTwoEntity> addList = new ArrayList<>(); |
| | | List<ECallEventTwoEntity> updateList = new ArrayList<>(); |
| | | // 过滤出已同步的订单 |
| | | recordEntityList.forEach(record -> { |
| | | long count1 = ecOrderService.count(Wrappers.<ECallEventTwoEntity>lambdaQuery().eq(ECallEventTwoEntity::getOrderId, record.getOrderId())); |
| | | long count1 = ecOrderService.count(Wrappers.<ECallEventTwoEntity>lambdaQuery().eq(ECallEventTwoEntity::getOrderCode, record.getOrderCode())); |
| | | if (count1 == 0) { |
| | | arrayList.add(record); |
| | | setGridInfo(record); |
| | | addList.add(record); |
| | | } else { |
| | | setGridInfo(record); |
| | | updateList.add(record); |
| | | } |
| | | }); |
| | | // 同步订单 |
| | | boolean b = false; |
| | | if (arrayList.size() > 0) { |
| | | b = ecOrderService.saveOrUpdateBatch(arrayList); |
| | | if (addList.size() > 0) { |
| | | b = ecOrderService.saveBatch(addList); |
| | | } |
| | | if (updateList.size() > 0) { |
| | | b = ecOrderService.saveOrUpdateBatch(updateList); |
| | | } |
| | | 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()); |
| | | try { |
| | | 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()); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("获取警格网格信息失败" + e); |
| | | } |
| | | } |
| | | |