zhibing.pu
2024-04-19 2e366b939271b6ea338641f8a72d1bcd2182dbe7
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java
@@ -30,6 +30,8 @@
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.*;
/**
@@ -43,9 +45,6 @@
    @Autowired
    private IOrderTaxiService orderTaxiService;
    @Autowired
    private GDMapElectricFenceUtil gdMapElectricFenceUtil;
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
@@ -85,6 +84,41 @@
        map.put("orderId", orderId);
        map.put("orderType", orderType);
        map.put("state", state);
        jsonObject.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", jsonObject.toJSONString());
        params.add("id", String.valueOf(uid));
        params.add("type", String.valueOf(type));
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            System.err.println(jsonObject1.getString("msg"));
        }
    }
    /**
     * 线下支付数据推送
     * @param type
     * @param uid
     * @param orderId
     * @param orderType
     */
    public void pushOfflinePayment(Integer type, Integer uid, Integer orderId, Integer orderType){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 200);
        jsonObject.put("msg", "SUCCESS");
        jsonObject.put("method", "OFFLINE_PAYMENT");
        Map<String, Object> map = new HashMap<>();
        map.put("orderId", orderId);
        map.put("orderType", orderType);
        jsonObject.put("data", map);
        //调用推送
@@ -312,8 +346,8 @@
                    t = distancematrix.getDuration().toString();//时间s
                }
            }
            d = new BigDecimal(d).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
            t = new BigDecimal(t).divide(new BigDecimal(60)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + "";
            d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString();
            t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + "";
            map.put("reservationMileage", d);//当前位置距离预约点的剩余里程
            map.put("reservationTime", t);//当前位置距离预约点的剩余分钟
            map.put("servedMileage", "0");//距离起点已经服务的里程
@@ -342,8 +376,8 @@
                }
            }
            d = new BigDecimal(d).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
            t = new BigDecimal(t).divide(new BigDecimal(60)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + "";
            d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString();
            t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + "";
            map.put("laveMileage", d);//距离终点剩余未服务的里程数
            map.put("laveTime", t);//距离终端剩余未服务的预计时间
        }
@@ -458,8 +492,9 @@
     * @param orderId
     * @param orderType
     * @param money
     * @param status 1=申请,2=同意,3=拒绝
     */
    public void pushPayDifference(Integer type, Integer uid, Integer orderId, Integer orderType, Double money){
    public void pushPayDifference(Integer type, Integer uid, Integer orderId, Integer orderType, Double money, Integer status){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 200);
        jsonObject.put("msg", "SUCCESS");
@@ -468,6 +503,7 @@
        map.put("orderId", orderId);
        map.put("orderType", orderType);
        map.put("money", money);
        map.put("status", status);
        jsonObject.put("data", map);
        //调用推送
@@ -500,4 +536,79 @@
            pushMap.remove(orderId + "_" + orderType);
        }
    }
    /**
     * 修改目的地推送通知
     * @param type
     * @param uid
     * @param orderId
     * @param orderType
     * @param status 1=申请,2=同意,3=拒绝
     */
    public void pushModifyAddress(Integer type, Integer uid, Integer orderId, Integer orderType, Integer status){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 200);
        jsonObject.put("msg", "SUCCESS");
        jsonObject.put("method", "MODIFY_ADDRESS");
        Map<String, Object> map = new HashMap<>();
        map.put("orderId", orderId);
        map.put("orderType", orderType);
        map.put("status", status);
        jsonObject.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", jsonObject.toJSONString());
        params.add("id", String.valueOf(uid));
        params.add("type", String.valueOf(type));
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            System.err.println(jsonObject1.getString("msg"));
        }
    }
    /**
     * 司机超时推送
     * @param type
     * @param uid
     * @param orderId
     * @param orderType
     * @param describe
     */
    public void pushOrderTimeOut(Integer type, Integer uid, Integer orderId, Integer orderType, String describe){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 200);
        jsonObject.put("msg", "SUCCESS");
        jsonObject.put("method", "ORDER_TIME_OUT");
        Map<String, Object> map = new HashMap<>();
        map.put("orderId", orderId);
        map.put("orderType", orderType);
        map.put("describe", describe);
        jsonObject.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", jsonObject.toJSONString());
        params.add("id", String.valueOf(uid));
        params.add("type", String.valueOf(type));
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            System.err.println(jsonObject1.getString("msg"));
        }
    }
}