| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路已被优化,已无法计算原始路线路程数"); |
| | | } |
| | | checkJketchCustomerLocation(model,true); |
| | | model.setEditDate(new Date()); |
| | | model.setDistance(model.getOriginDistance()); |
| | | jkSketchMapper.updateById(model); |
| | | return model; |
| | | JkSketch update = new JkSketch(); |
| | | update.setId(model.getId()); |
| | | update.setEditDate(new Date()); |
| | | update.setDistance(model.getOriginDistance()); |
| | | update.setOriginDistance(model.getOriginDistance()); |
| | | jkSketchMapper.updateById(update); |
| | | return update; |
| | | } |
| | | |
| | | @Override |
| | |
| | | queryWrapper.selectAll(JkSketchCustomer.class ) |
| | | .selectAs(JkCustomer::getName,JkSketchCustomer::getName) |
| | | .selectAs(JkCustomer::getCode,JkSketchCustomer::getCode) |
| | | .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | // .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | .selectAs(JkCustomer::getLongitude,JkSketchCustomer::getLongitude) |
| | | .selectAs(JkCustomer::getLatitude,JkSketchCustomer::getLatitude) |
| | | .selectAs(JkCustomer::getStartDistance,JkSketchCustomer::getStartDistance) |
| | |
| | | queryWrapper.selectAll(JkSketchCustomer.class ) |
| | | .selectAs(JkCustomer::getName,JkSketchCustomer::getName) |
| | | .selectAs(JkCustomer::getCode,JkSketchCustomer::getCode) |
| | | .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | // .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | .selectAs(JkCustomer::getLongitude,JkSketchCustomer::getLongitude) |
| | | .selectAs(JkCustomer::getLatitude,JkSketchCustomer::getLatitude) |
| | | .selectAs(JkCustomer::getStartDistance,JkSketchCustomer::getStartDistance) |
| | |
| | | } |
| | | for(JkSketchCustomer c : customerList){ |
| | | List<DistanceMapParam> tmpList = new ArrayList<>(); |
| | | List<DistanceMapParam> distanceMapParamList = getListFromJsonStr(c.getDistanceJson()); |
| | | // List<DistanceMapParam> distanceMapParamList = getListFromJsonStr(c.getDistanceJson()); |
| | | DistanceMapParam t0 = new DistanceMapParam(); |
| | | t0.setId(-2);//表示返回园区 |
| | | t0.setDistance(Constants.formatLongNum(c.getStartDistance()) ); |
| | |
| | | DistanceMapParam t = new DistanceMapParam(); |
| | | t.setId(cm.getCustomerId()); |
| | | t.setDistance(0); |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList); |
| | | t.setDistance(DistanceCalculator.calculateDistanceDecinal(cm.getLatitude(),cm.getLongitude(),c.getLatitude(),c.getLongitude())); |
| | | /* DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList); |
| | | if(param!=null){//如果之前已经获取过 |
| | | t = param; |
| | | } |
| | | }*/ |
| | | tmpList.add(t); |
| | | } |
| | | DistanceMapParam tt = new DistanceMapParam(); |
| | |
| | | } |
| | | for(JkSketchCustomer c : customerList){ |
| | | List<DistanceMapParam> tmpList = new ArrayList<>(); |
| | | List<DistanceMapParam> distanceMapParamList = getListFromJsonStr(c.getDistanceJson()); |
| | | //====标记==忽略交通规划距离===== |
| | | // List<DistanceMapParam> distanceMapParamList = getListFromJsonStr(c.getDistanceJson()); |
| | | DistanceMapParam t0 = new DistanceMapParam(); |
| | | t0.setId(-2);//表示返回园区 |
| | | t0.setDistance(Constants.formatLongNum(c.getStartDistance()) ); |
| | | t0.setId(-2);// |
| | | t0.setDistance(DistanceCalculator.calculateDistanceDecinal(cLatitude,cLongitude,c.getLatitude(),c.getLongitude())); |
| | | |
| | | //====标记==忽略交通规划距离===== |
| | | /* t0.setDistance(Constants.formatLongNum(c.getStartDistance()) ); |
| | | if(Constants.formatLongNum(c.getStartDistance()) <= 0){ |
| | | //园区前往该客户的距离,如果之前未获取过 |
| | | t0.setDistance(DistanceCalculator.calculateDistanceDecinal(cLatitude,cLongitude,c.getLatitude(),c.getLongitude())); |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客户:"+c.getName()+"交通规划尚未完成,不满足优化条件!"); |
| | | } |
| | | }*/ |
| | | tmpList.add(t0); |
| | | for(JkSketchCustomer cm : customerList){ |
| | | //客户和客户之间的距离信息 |
| | | DistanceMapParam t = new DistanceMapParam(); |
| | | t.setId(cm.getCustomerId()); |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList); |
| | | t.setDistance(DistanceCalculator.calculateDistanceDecinal(cm.getLatitude(),cm.getLongitude(),c.getLatitude(),c.getLongitude())); |
| | | //====标记==忽略交通规划距离===== |
| | | /* DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList); |
| | | if(param!=null && t.getDistance()>0){//如果之前已经获取过 |
| | | t = param; |
| | | }else{ |
| | | //如果未规划,按照直线距离 |
| | | t.setDistance(DistanceCalculator.calculateDistanceDecinal(cm.getLatitude(),cm.getLongitude(),c.getLatitude(),c.getLongitude())); |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客户:"+c.getName()+"与客户:"+cm.getName()+"简交通规划尚未完成,不满足路程计算条件!"); |
| | | } |
| | | }*/ |
| | | tmpList.add(t); |
| | | } |
| | | DistanceMapParam tt = new DistanceMapParam(); |
| | | tt.setId(-2);//表示返回园区 |
| | | tt.setDistance(Constants.formatLongNum(c.getEndDistance())); |
| | | tt.setDistance(DistanceCalculator.calculateDistanceDecinal(cLatitude,cLongitude,c.getLatitude(),c.getLongitude())); |
| | | |
| | | //====标记==忽略交通规划距离===== |
| | | /* tt.setDistance(Constants.formatLongNum(c.getEndDistance())); |
| | | if(Constants.formatLongNum(c.getEndDistance()) <= 0){ |
| | | //该客户返回园区的距离 ,如果之前未获取过 |
| | | tt.setDistance(DistanceCalculator.calculateDistanceDecinal(cLatitude,cLongitude,c.getLatitude(),c.getLongitude())); |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客户:"+c.getName()+"与起点交通规划尚未完成,不满足路程计算条件!"); |
| | | } |
| | | }*/ |
| | | tmpList.add(tt); |
| | | c.setDistanceMapParamList(tmpList); |
| | | } |
| | |
| | | int index =0; |
| | | for(JkSketchCustomer c : customers){ |
| | | if(index ==0){ |
| | | if(Constants.formatLongNum(c.getStartDistance()) >0){ |
| | | |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude); |
| | | //====标记==忽略交通规划距离===== |
| | | /* if(Constants.formatLongNum(c.getStartDistance()) >0){ |
| | | lineDistance+= Constants.formatLongNum(c.getStartDistance()); |
| | | }else{ |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude); |
| | | } |
| | | }*/ |
| | | } |
| | | if(index == customers.size()-1){ |
| | | if(Constants.formatLongNum(c.getEndDistance())>0){ |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude); |
| | | //====标记==忽略交通规划距离===== |
| | | /* if(Constants.formatLongNum(c.getEndDistance())>0){ |
| | | lineDistance+= Constants.formatLongNum(c.getEndDistance()); |
| | | }else{ |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude); |
| | | } |
| | | }*/ |
| | | break; |
| | | } |
| | | JkSketchCustomer end = customers.get(index+1); |
| | | DistanceMapParam param1 = getParamByCustomerIds(end.getCustomerId(),getListFromJsonStr(c.getDistanceJson())); |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),end.getLatitude(),end.getLongitude()); |
| | | //====标记==忽略交通规划距离===== |
| | | /* DistanceMapParam param1 = getParamByCustomerIds(end.getCustomerId(),getListFromJsonStr(c.getDistanceJson())); |
| | | if(param1 !=null && param1.getDistance()>0){ |
| | | lineDistance += param1.getDistance(); |
| | | }else{ |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),end.getLatitude(),end.getLongitude()); |
| | | } |
| | | index++; |
| | | /* for(JkSketchCustomer cm : customers){ |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),getListFromJsonStr(c.getDistanceJson())); |
| | | lineDistance += param.getDistance(); |
| | | }*/ |
| | | index++; |
| | | } |
| | | if(updateLineDistance && Constants.equalsInteger(model.getStatus(),Constants.ZERO) ){ |
| | | line.setDistance(lineDistance); |
| | |
| | | .selectAs(JkCustomer::getName,JkSketchCustomer::getName) |
| | | .selectAs(JkCustomer::getCode,JkSketchCustomer::getCode) |
| | | .selectAs(JkCustomer::getDistanceStatus,JkSketchCustomer::getDistanceStatus) |
| | | .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | // .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | .selectAs(JkCustomer::getLongitude,JkSketchCustomer::getLongitude) |
| | | .selectAs(JkCustomer::getLatitude,JkSketchCustomer::getLatitude) |
| | | .selectAs(JkCustomer::getStartDistance,JkSketchCustomer::getStartDistance) |