rk
12 小时以前 4898564fb2510dcdbe10d01eaa94886512aebc77
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkSketchServiceImpl.java
@@ -287,7 +287,7 @@
                        int index =0;
                        for (int j = start; j < end; j++) {
                            try {
                                log.error("交通规划========"+customerList.get(j).getName()+"========cirle:"+finalI+"==="+index++);
                                log.error("交通规划========"+cate.getId()+"/"+cate.getName()+"/"+customerList.get(j).getName()+"=======cirle/index:"+finalI+"/"+index++);
                                dealDistancePerCustomer(customerList.get(j),url,date, finalCLatitude, finalCLongitude,customerList);
                            }catch (Exception e){
@@ -321,7 +321,7 @@
        List<JkCustomerNavigation> navigationList = new ArrayList<>();
        List<DistanceMapParam> tmpList = new ArrayList<>();
        List<DistanceMapParam> distanceMapParamList  = getListFromJsonStr(c.getDistance());
        boolean isNew = false;
        boolean isNew = false,hasError =false;
        JkCustomer u =new JkCustomer();
        DistanceMapParam t0 = new DistanceMapParam();
        t0.setId(-2);//表示返回园区
@@ -344,13 +344,14 @@
                    //如果有路径信息
                    u.setStartSteps(dm.getPolyline());
                }
            }else{
                hasError=true;
            }
        }
        tmpList.add(t0);
        for(JkCustomer cm : customerList){
            //客户和客户之间的距离信息
            Thread.sleep(500);
            DistanceMapParam t = new DistanceMapParam();
            t.setId(cm.getId());
            DistanceMapParam param = getParamByCustomerIds( cm.getId(),distanceMapParamList);
@@ -373,10 +374,15 @@
                }else{
                    DistanceCustomerModel dm = DistanceCalculator.calculateDistanceGaode(url,c,cm);
                    t.setDistance(dm.getDistance() );
                    if(dm.getLocations().size()>0){
                        //如果有路径信息
                        navigation.setSteps(dm.getPolyline());
                    if(dm.getCode() == 1){
                        if(dm.getLocations().size()>0){
                            //如果有路径信息
                            navigation.setSteps(dm.getPolyline());
                        }
                    }else{
                        hasError=true;
                    }
                }
                navigation.setIdIndex(c.getId()+"-"+cm.getId());
                navigation.setDistance(t.getDistance());
@@ -405,12 +411,14 @@
                    //如果有路径信息
                    u.setEndSteps(dm.getPolyline());
                }
            }else{
                hasError=true;
            }
        }
        tmpList.add(tt);
        if(isNew){//
            u.setDistanceStatus(Constants.ONE);
            u.setDistanceStatus(hasError?Constants.ZERO:Constants.ONE);//所有都成功才标注已规划
            u.setId(c.getId());
            u.setDistance(JSONObject.toJSONString(tmpList));
            updateCustomerList.add(u);
@@ -470,8 +478,8 @@
                .eq(JkCustomer::getIsdeleted,Constants.ZERO)
                .eq(JkLine::getCategoryId,model.getCategoryId() );
        List<JkCustomer> customerList = jkCustomerMapper.selectJoinList(JkCustomer.class,queryWrapper1);
        List<JkCustomer> needList =checkNeedDistanceDo(customerList);
        if(needList == null || needList.size() == 0){
         List<JkCustomer> needList =checkNeedDistanceDo(customerList);
        if(Constants.equalsInteger(model.getForceUpdate(),0)&& (needList == null || needList.size() == 0)){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该主线下无需要进行距离计算的客户信息!");
        }
        String errorMsg ="";
@@ -485,7 +493,7 @@
        }
        c.setStatus(Constants.TWO);
        categoryMapper.updateById(c);//更新任务执行状态
        c.setCustomerList(customerList);
        c.setCustomerList(Constants.equalsInteger(model.getForceUpdate(),0)?needList:customerList);
        return  c;
    }
@@ -1518,15 +1526,33 @@
                        .filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())
                                && Objects.nonNull(i.getDistance())
                                &&Constants.equalsInteger(i.getType(),Constants.ONE)&&Constants.equalsInteger(i.getIsdeleted(),Constants.ZERO)).collect(Collectors.toList());
        if(sketchList!=null){
            for (JkSketch jkSketch:sketchList) {
                TelecomCategoryDataVO telecomCategoryDataVO = new TelecomCategoryDataVO();
                telecomCategoryDataVO.setId(jkSketch.getCategoryId());
                telecomCategoryDataVO.setName(jkSketch.getCategoryName());
                //优化前数据
                List<JkSketchLine> beforeList = jkSketchLineList.stream()
                        .filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())&&Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList());
                telecomCategoryDataVO.setDistance(
                        beforeList.stream().map(i->i.getDistance()).reduce(Long.valueOf(0),Long::sum)
                );
                if(Constants.equalsInteger(jkSketch.getOptStatus(),Constants.ZERO)){
                    telecomCategoryDataVO.setDistanceAfter(telecomCategoryDataVO.getDistance());
                }else{
                    //优化后数据
                    List<JkSketchLine> afterList = jkSketchLineList.stream()
                            .filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())&&Constants.equalsInteger(i.getType(),Constants.ONE)&&Constants.equalsInteger(i.getIsdeleted(),Constants.ZERO)).collect(Collectors.toList());
                Long distanceAfter = 0L;
                for (JkSketchLine jkSketchLine:afterList) {
                    Long distanceAfter = 0L;
                    for (JkSketchLine jkSketchLine:afterList) {
                        distanceAfter = distanceAfter + jkSketchLine.getDistance();
                }
                telecomCategoryDataVO.setDistanceAfter(distanceAfter);
                    }
                    telecomCategoryDataVO.setDistanceAfter(distanceAfter);
                }
                telecomCategoryDataVOList.add(telecomCategoryDataVO);
            }
            telecomCategoryDataVOList.add(telecomCategoryDataVO);
        }
        return telecomCategoryDataVOList;
    }