Pu Zhibing
2025-05-09 8580866e175ad0050ee9c5ea3f757856fc242c39
Merge remote-tracking branch 'origin/master'
5个文件已修改
4个文件已添加
197 ■■■■■ 已修改文件
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/CallingAreaMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/CallingArea.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ICallingAreaService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ICompanyCityService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/IDriverService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/CallingAreaServiceImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/CompanyCityServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/TaxiCallbackController.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/CallingAreaMapper.java
New file
@@ -0,0 +1,12 @@
package com.stylefeng.guns.modular.system.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.stylefeng.guns.modular.system.model.CallingArea;
import com.stylefeng.guns.modular.system.model.OpenCity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CallingAreaMapper extends BaseMapper<CallingArea> {
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/CallingArea.java
New file
@@ -0,0 +1,62 @@
package com.stylefeng.guns.modular.system.model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
/**
 * 电召区域
 */
@TableName("t_calling_area")
public class CallingArea {
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    @TableField("id")
    private Integer id;
    /**
     * 区域 1.咸安  2.通山 3.崇阳  5.通城  6.赤壁  7.嘉鱼
     */
    @TableField("area")
    private String area;
    /**
     * 区域code
     */
    @TableField("areaCode")
    private String areaCode;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getArea() {
        return area;
    }
    public void setArea(String area) {
        this.area = area;
    }
    public String getAreaCode() {
        return areaCode;
    }
    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }
    @Override
    public String toString() {
        return "CallingArea{" +
                "id=" + id +
                ", area='" + area + '\'' +
                ", areaCode='" + areaCode + '\'' +
                '}';
    }
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ICallingAreaService.java
New file
@@ -0,0 +1,20 @@
package com.stylefeng.guns.modular.system.service;
import com.baomidou.mybatisplus.service.IService;
import com.stylefeng.guns.modular.system.model.CallingArea;
import com.stylefeng.guns.modular.system.model.Notice;
import java.util.List;
import java.util.Map;
/**
 * <p>
 * 通知表 服务类
 * </p>
 *
 * @author stylefeng123
 * @since 2018-02-22
 */
public interface ICallingAreaService extends IService<CallingArea> {
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ICompanyCityService.java
@@ -4,6 +4,8 @@
import com.stylefeng.guns.modular.system.model.Company;
import com.stylefeng.guns.modular.system.model.CompanyCity;
import java.util.List;
public interface ICompanyCityService extends IService<CompanyCity> {
@@ -24,4 +26,5 @@
     * @throws Exception
     */
    Company query(String code) throws Exception;
    List<Company> queryCall(String code) throws Exception;
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/IDriverService.java
@@ -20,6 +20,7 @@
     */
    List<Driver> queryIdleDriver(Integer type, Double lon, Double lat, Double distance, Integer companyId) throws Exception;
    List<Driver> queryIdleDriverAll(Integer type, Double lon, Double lat, Double distance, Integer companyId) throws Exception;
    List<Driver> queryIdleDriverAllCall(Integer type, Double lon, Double lat, Double distance, List<Integer> companyIds) throws Exception;
    /**
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/CallingAreaServiceImpl.java
New file
@@ -0,0 +1,25 @@
package com.stylefeng.guns.modular.system.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.dao.CallingAreaMapper;
import com.stylefeng.guns.modular.system.dao.NoticeMapper;
import com.stylefeng.guns.modular.system.model.CallingArea;
import com.stylefeng.guns.modular.system.model.Notice;
import com.stylefeng.guns.modular.system.service.ICallingAreaService;
import com.stylefeng.guns.modular.system.service.INoticeService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * <p>
 * 通知表 服务实现类
 * </p>
 *
 * @author stylefeng123
 * @since 2018-02-22
 */
@Service
public class CallingAreaServiceImpl extends ServiceImpl<CallingAreaMapper, CallingArea> implements ICallingAreaService {
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/CompanyCityServiceImpl.java
@@ -68,4 +68,17 @@
        }
        return null;
    }
    /**
     * 根据行政编号获取所属企业
     * @param code
     * @return
     * @throws Exception
     */
    @Override
    public List<Company> queryCall(String code) throws Exception {
        String province = code.substring(0, 2) + "0000";
        String city = code.substring(0, 4) + "00";
        List<Company> query = companyMapper.query(province, city, code);
        return query;
    }
}
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java
@@ -14,11 +14,13 @@
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements IDriverService {
@@ -89,6 +91,21 @@
        return list;
    }
    @Override
    public List<Driver> queryIdleDriverAllCall(Integer type, Double lon, Double lat, Double distance, List<Integer> companyIds) throws Exception {
        if(CollectionUtils.isEmpty(companyIds)){
            System.err.println("-----未查询到该区域分公司进行推单------");
            return new ArrayList<>();
        }
        companyIds = companyIds.stream().distinct().collect(Collectors.toList());
        List<Driver> allDrivers = new ArrayList<>();
        for (Integer companyId : companyIds) {
            List<Driver> drivers = driverMapper.queryIdleDriver(type, companyId);
            allDrivers.addAll(drivers);
        }
        System.err.println("-----符合条件的司机"+allDrivers);
        return allDrivers;
    }
    /**
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/TaxiCallbackController.java
@@ -1,14 +1,9 @@
package com.stylefeng.guns.modular.taxi.controller;
import cn.hutool.json.JSONObject;
import com.stylefeng.guns.modular.system.model.Company;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.PushOrder;
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.service.ICompanyService;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IPushOrderService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.PushUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.SignVerificationUtil;
@@ -25,6 +20,8 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * 支付回调控制器
@@ -46,6 +43,10 @@
    private OrderTaxiMapper orderTaxiMapper;
    @Autowired
    private IUserInfoService userInfoService;
    @Autowired
    private ICallingAreaService callingAreaService;
    @Autowired
    private ICompanyCityService companyCityService;
    @ResponseBody
    @PostMapping("/callback")
    @ApiOperation(value = "AI回调", tags = {"AI回调"}, notes = "")
@@ -66,10 +67,11 @@
        // 遍历列表以获取每个结果的地址信息
        OrderTaxi orderTaxi = new OrderTaxi();
        String audioPath = req.getStr("audioPath");
        String phone = req.getStr("phone");
        JSONObject outputParam = req.getJSONObject("outputParam");
        String area = outputParam.getStr("area");
        System.err.println("phone++++"+phone);
        String downloadUrl = ""
;
@@ -91,8 +93,15 @@
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        // 打印或处理地址信息
        System.out.println("地址信息:" + area);
        // 查询电召区域
        CallingArea callingArea = callingAreaService.selectOne(new EntityWrapper<CallingArea>().eq("areaCode", area));
        if(Objects.nonNull(callingArea)){
            // 打印或处理地址信息
            System.out.println("地址信息:" + callingArea.getArea());
            orderTaxi.setStartAddress(callingArea.getArea());
        }else {
            return ResultUtil.error("电召未开通该区域城市");
        }
        //创建订单
        orderTaxi.setAudioLinkUrl(downloadUrl);
        orderTaxi.setInsertTime(new Date());
@@ -103,7 +112,6 @@
        orderTaxi.setPassengersPhone(phone);
        orderTaxi.setTravelTime(new Date());
        orderTaxi.setOrderType(1);
        orderTaxi.setStartAddress(area);
        orderTaxiMapper.insert(orderTaxi);
        new Thread(new Runnable() {
            @Override
@@ -117,7 +125,7 @@
        if(orderTaxi.getState() == 1){
            //推送司机抢单
            try {
                this.pushOrder(orderTaxi);
                this.pushOrder(orderTaxi,callingArea);
            }catch (Exception e){
            }
        }
@@ -132,7 +140,7 @@
    }
    public static List<Integer> orderIds = new ArrayList<>();
    public void pushOrder(OrderTaxi orderTaxi) throws Exception{
    public void pushOrder(OrderTaxi orderTaxi,CallingArea callingArea) throws Exception{
        new Thread(new Runnable() {
            @Override
            public void run() {
@@ -140,16 +148,20 @@
                    orderIds.add(orderTaxi.getId());//添加记录,防止调用接口重复提醒无人接单
                    Company query = companyService.selectById(1);//获取起点所属分公司
                    List<PushOrder> querys = pushOrderService.querys(null, 2, query.getId());//获取需要推送的次数
                    // 优先查询区域
                    List<Company> companys = companyCityService.queryCall(callingArea.getAreaCode());
                    System.err.println("根据区域查询出来的分公司======"+companys);
                    List<Integer> companyIds = companys.stream().map(Company::getId).collect(Collectors.toList());
                    for(int i = 1; i <= querys.size(); i++){
                        PushOrder pushOrder = pushOrderService.querys(i, 2, query.getId()).get(0);
                        //获取空闲司机
                        List<Driver> list = driverService.queryIdleDriverAll(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机
                        List<Driver> list = driverService.queryIdleDriverAllCall(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), companyIds);//所有附近空闲司机
//                        List<Driver> list = driverService.queryIdleDriverAll(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机
                        if(list.size() > 0){
                            double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数
                            int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取)
                            list = list.subList(0, lastIndex);//获取空闲司机中占比数据
                            for(Driver driver : list){//开始进行推送
                                pushUtil.pushOrderStateVedio(2, driver.getId(), orderTaxi.getId(), 2, orderTaxi.getState(), pushOrder.getPushTime(),orderTaxi.getAudioLinkUrl());
                            }
                        }