| | |
| | | package org.springblade.modules.eCallEventTwo.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @Autowired |
| | | private IECallEventTwoService ecOrderService; |
| | | |
| | | protected static final Logger log = LoggerFactory.getLogger(EcOrderServiceImpl.class); |
| | | /** |
| | | * 查询工单 |
| | | * |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @DS("slave_1") |
| | | 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 = count(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 = page(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 |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 统计办结率 |
| | | */ |
| | | @Override |
| | | public Map<String, String> getCount(EcOrderParamDTO ecOrderParamDTO) { |
| | | public IPage<EcOrderDTO> getCount(IPage<EcOrderDTO> page, EcOrderParamDTO ecOrderParamDTO) { |
| | | // acpt_org_code |
| | | List<EcOrderDTO> result = baseMapper.getOrgCode(page, ecOrderParamDTO); |
| | | for (EcOrderDTO ecOrderDTO : result) { |
| | | if (ecOrderParamDTO.getTagMain().equals("Y")) { |
| | | ecOrderParamDTO.setSinkOrgCode(ecOrderDTO.getSinkOrgCode()); |
| | | } else { |
| | | ecOrderParamDTO.setSubjectOrgCode(ecOrderDTO.getSubjectOrgCode()); |
| | | } |
| | | // 统计办结率 |
| | | buildRate(ecOrderParamDTO, ecOrderDTO); |
| | | // 获取单位名称 |
| | | if (ecOrderParamDTO.getTagMain().equals("Y")) { |
| | | ecOrderDTO.setOrgCode(ecOrderDTO.getSinkOrgCode()); |
| | | ecOrderDTO.setOrgName(ecOrderDTO.getSinkOrgName()); |
| | | } else { |
| | | ecOrderDTO.setOrgCode(ecOrderDTO.getSubjectOrgCode()); |
| | | ecOrderDTO.setOrgName(ecOrderDTO.getSubjectOrgName()); |
| | | } |
| | | } |
| | | return page.setRecords(result); |
| | | } |
| | | |
| | | @NotNull |
| | | private void buildRate(EcOrderParamDTO ecOrderParamDTO, EcOrderDTO ecOrder) { |
| | | // 统计订单 |
| | | EcOrderDTO ecOrderDTO = BeanUtil.copy(ecOrderParamDTO, EcOrderDTO.class); |
| | | int i = baseMapper.selectEcOrderCount(ecOrderDTO); |
| | |
| | | EcOrderSuperviseDTO ecOrderSuperviseDTO = BeanUtil.copy(ecOrderParamDTO, EcOrderSuperviseDTO.class); |
| | | int i7 = baseMapper.selectEcOrderSuperviseCount(ecOrderSuperviseDTO); |
| | | // 工单数 派发单数 办理单数(率) 办结单数(率) 答复单数(率) 回访单数(率) 核实单数 督办单数 |
| | | Map<String, String> result = new HashMap<>(); |
| | | // Map<String, String> result = new HashMap<>(); |
| | | // 工单数 |
| | | result.put("orderNumber", String.valueOf(i)); |
| | | // result.put("orderNumber", String.valueOf(i)); |
| | | ecOrder.setOrderNumber(String.valueOf(i)); |
| | | // 派发单数(率) |
| | | result.put("dispatchRate", getRate(i1, i)); |
| | | result.put("dispatchNumber", String.valueOf(i1)); |
| | | // result.put("dispatchRate", getRate(i1, i)); |
| | | ecOrder.setDispatchRate(getRate(i1, i)); |
| | | // result.put("dispatchNumber", String.valueOf(i1)); |
| | | ecOrder.setDispatchNumber(String.valueOf(i1)); |
| | | // 办理单数(率) |
| | | result.put("handRate", getRate(i2, i)); |
| | | result.put("handNumber", String.valueOf(i2)); |
| | | // result.put("handRate", getRate(i2, i)); |
| | | ecOrder.setHandRate(getRate(i2, i)); |
| | | // result.put("handNumber", String.valueOf(i2)); |
| | | // 办结单数(率) |
| | | result.put("checkRate", getRate(i3, i)); |
| | | result.put("checkNumber", String.valueOf(i3)); |
| | | // result.put("checkRate", getRate(i3, i)); |
| | | ecOrder.setCheckRate(getRate(i3, i)); |
| | | // result.put("checkNumber", String.valueOf(i3)); |
| | | // 答复单数(率) |
| | | result.put("doneRate", getRate(i4, i)); |
| | | result.put("doneNumber", String.valueOf(i4)); |
| | | // result.put("doneRate", getRate(i4, i)); |
| | | ecOrder.setDoneRate(getRate(i4, i)); |
| | | // result.put("doneNumber", String.valueOf(i4)); |
| | | // 回访单数(率) |
| | | result.put("respRate", getRate(i5, i)); |
| | | result.put("respNumber", String.valueOf(i5)); |
| | | // result.put("respRate", getRate(i5, i)); |
| | | ecOrder.setRespRate(getRate(i5, i)); |
| | | // result.put("respNumber", String.valueOf(i5)); |
| | | // 核实单数(率) |
| | | result.put("reviewRate", getRate(i6, i)); |
| | | result.put("reviewNumber", String.valueOf(i6)); |
| | | // result.put("reviewRate", getRate(i6, i)); |
| | | ecOrder.setReviewRate(getRate(i6, i)); |
| | | // result.put("reviewNumber", String.valueOf(i6)); |
| | | // 督办单数 |
| | | result.put("superviseNumber", String.valueOf(i7)); |
| | | // result.put("superviseNumber", String.valueOf(i7)); |
| | | ecOrder.setSuperviseNumber(String.valueOf(i7)); |
| | | // 返回结果 |
| | | return result; |
| | | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String rate = getRate(10, 3); |
| | | System.out.println(rate); |
| | | // return result; |
| | | } |
| | | |
| | | |