liujie
2023-10-15 1707d15796d7dc78812f19b9c34868c8cb38a714
src/main/java/com/stylefeng/guns/modular/system/service/impl/TOrderServiceImpl.java
@@ -8,10 +8,10 @@
    import com.stylefeng.guns.core.util.ToolUtil;
    import com.stylefeng.guns.modular.system.dao.*;
    import com.stylefeng.guns.modular.system.model.*;
    import com.stylefeng.guns.modular.system.service.ITBoxSizeService;
    import com.stylefeng.guns.modular.system.service.ITDriverService;
    import com.stylefeng.guns.modular.system.service.ITOrderService;
    import com.stylefeng.guns.modular.system.service.*;
    import com.stylefeng.guns.modular.system.utils.GoogleMap.GeocodeVo;
    import com.stylefeng.guns.modular.system.utils.GoogleMap.GoogleMapUtil;
    import com.stylefeng.guns.modular.system.utils.RedisUtil;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
@@ -248,8 +248,12 @@
            }
            // 获取卡车公司收入
            Double companyIncome = this.baseMapper.getCompanyIncome(id, sTime, eTime);
            if(companyIncome==null){
                indexInfo.setAccountsReceivable(new BigDecimal(0));
            }else {
            indexInfo.setAccountsReceivable(new BigDecimal(companyIncome));
                indexInfo.setAccountsReceivable(new BigDecimal(companyIncome));
            }
            // 获取卡车公司支出-》 是否存在承运商  -》算价格
            EntityWrapper<TOrder> wrapper = new EntityWrapper<>();
            wrapper.eq("company_id",id);
@@ -299,7 +303,7 @@
            for (int i = 0; i <12; i++) {
                if(i==0){
                    IndexMonth indexMonth = new IndexMonth();
                    int month = DateUtil.thisMonth();
                    int month = DateUtil.thisMonth()+1;
                    indexMonth.setMonth(month);
                    indexMonth.setOrderNumber(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",id).between("pay_time",DateUtil.beginOfMonth(new Date()),DateUtil.endOfMonth(new Date()))));
                    indexMonths.add(indexMonth);
@@ -307,7 +311,7 @@
                    IndexMonth indexMonth = new IndexMonth();
                    instance.add(Calendar.MONTH, -1);
                    Date time1 = instance.getTime();
                    int month = DateUtil.month(time1);
                    int month = DateUtil.month(time1)+1;
                    indexMonth.setMonth(month);
                    indexMonth.setOrderNumber(this.baseMapper.selectCount(new EntityWrapper<TOrder>().eq("company_id",id).between("pay_time",DateUtil.beginOfMonth(time1),DateUtil.endOfMonth(time1))));
                    indexMonths.add(indexMonth);
@@ -364,7 +368,7 @@
            }
            // 根据订单id 获取价格
            List<TPrice> prices = priceMapper.selectList(new EntityWrapper<TPrice>().eq("order_id", tOrder.getId()));
            List<TPrice> prices = priceMapper.selectList(new EntityWrapper<TPrice>().eq("order_id", tOrder.getId()).eq("status",1));
            ArrayList<TPriceVo> priceVos = new ArrayList<TPriceVo>();
            for (TPrice price : prices) {
@@ -430,28 +434,84 @@
            return goodsInfoVos;
        }
        @Autowired
        private RedisUtil redisUtil;
        @Resource
        private TTransportationService tTransportationService;
        @Autowired
        private ITExamSiteService examSiteService;
        @Autowired
        private TYardService yardService;
        private HashMap<String, String> getLat(String a){
            HashMap<String, String> map = new HashMap<>();
            try {
                GeocodeVo geocode = googleMapUtil.getGeocode(a);
                map.put("lon",String.valueOf(geocode.getLng()));
                map.put("lat",String.valueOf(geocode.getLat()));
            }catch (Exception e){
                e.printStackTrace();
                map.put("lon",null);
                map.put("lat",null);
            }
            return map;
        }
        @Override
        public OrderInfo getOrderInfo(Long orderId) {
        public  HashMap<String, Object> getOrderInfo(Long orderId) {
            OrderInfo orderInfo = new OrderInfo();
            ArrayList<LonLat> lonLats = new ArrayList<>();
            TOrder tOrder = this.baseMapper.selectById(orderId);
            String value = redisUtil.getValue(String.valueOf(orderId));
            orderInfo.setDriverLat(value);
            ArrayList<Map<String,String>> maps = new ArrayList<>();
                TPort tPort1 = portMapper.selectById(tOrder.getPort());
                maps.add(getLat(tPort1.getAddress()));
            if(tOrder.getExamSite()!=null){
                Integer examSite = tOrder.getExamSite();
                TExamSite tExamSite = examSiteService.selectById(examSite);
                // 第二个检查站
                maps.add(getLat(tExamSite.getAddress()));
            }
            TTransportation tTransportations1 = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", orderId).eq("type",2));
            if(tTransportations1!=null){
                Integer yardId = tTransportations1.getYardId();
                if(yardId!=null){
                    TYard tYard = yardService.selectById(yardId);
                    maps.add(getLat(tYard.getStreetAddress()));
                }
            }
            if(tOrder.geteAddress()!=null){
                maps.add(getLat(tOrder.geteAddress()));
            }
            orderInfo.setSlat(tOrder.getStartLat());
            orderInfo.setSlon(tOrder.getStartLon());
            orderInfo.setStatus(tOrder.getStatus());
            LonLat lonLat = new LonLat();
            lonLat.setLat(tOrder.getStartLat());
            lonLat.setLng(tOrder.getStartLon());
            lonLats.add(lonLat);
            String s = tOrder.geteAddress();
    //        GeocodeVo geocode = googleMapUtil.getGeocode(s);
    //        orderInfo.setElat(String.valueOf(geocode.getLat()));
    //        orderInfo.setElon(String.valueOf(geocode.getLng()));
            GeocodeVo geocode = googleMapUtil.getGeocode(s);
            orderInfo.setElat(String.valueOf(geocode.getLat()));
            orderInfo.setElon(String.valueOf(geocode.getLng()));
            lonLat=new LonLat();
            lonLat.setLng("-113.066919618184");
            lonLat.setLat("37.684389618184");
            lonLat.setLng(tOrder.getStartLon());
            lonLat.setLat(tOrder.getStartLat());
            lonLats.add(lonLat);
            orderInfo.setElat("37.684389618184");
            orderInfo.setElon("-113.066919618184");
            orderInfo.setElat(String.valueOf(geocode.getLat()));
            orderInfo.setElon(String.valueOf(geocode.getLng()));
            orderInfo.setLonLats(lonLats);
            Long quoteId = tQuoteMapper.selectList(new EntityWrapper<TQuote>().eq("order_id", tOrder.geteZipZ())).get(0).getId();
@@ -465,15 +525,17 @@
            Integer groupId = tUser.getGroupId();
            if(groupId!=null) {
                TGroup tGroup = tGroupMapper.selectById(groupId);
                orderInfo.setSalesGroup(tGroup.getName());
                Integer salesId = tGroup.getSalesId();
                User user = userMapper.selectById(salesId);
                orderInfo.setSales(user.getName());
                if(tGroup!=null) {
                    orderInfo.setSalesGroup(tGroup.getName());
                    Integer salesId = tGroup.getSalesId();
                    User user = userMapper.selectById(salesId);
                    orderInfo.setSales(user.getName());
                }
            }
            // 获取码头id  获取码头地址  pickup信息
            Integer portId = tOrder.getPort();
            TPort tPort = portMapper.selectById(portId);
            orderInfo.setAddress(tOrder.geteAddress());
            orderInfo.setAddress(tPort.getAddress());
            orderInfo.setContactName(tOrder.getsName());
            orderInfo.setContactPhone(tOrder.getsPhone());
            orderInfo.setContactEmail(tOrder.getsEmail());
@@ -485,9 +547,11 @@
            if(!"0".equals(warehouse)){
                TWarehouse tWarehouse = wareHouseMapper.selectList(new EntityWrapper<TWarehouse>().eq("company_id", tOrder.getCompanyId()).eq("code", warehouse)).get(0);
                orderInfo.setWareHouse(tWarehouse.getAddress());
                orderInfo.setEndAddress(tWarehouse.getAddress());
            }else {
                // destination信息
                orderInfo.setEndAddress(tOrder.geteAddress());
            }
            // destination信息
            orderInfo.setEndAddress(tOrder.geteAddress());
            orderInfo.setECompanyName(tOrder.geteCompanyName());
            orderInfo.setEContactName(tOrder.geteName());
            orderInfo.setEContactPhone(tOrder.getePhone());
@@ -501,6 +565,8 @@
            ArrayList<String> strings = new ArrayList<>();
            goods.forEach(e->{
                strings.add(e.getContainerNumber());
                strings.add(String.valueOf(e.getOrderId()));
                orderInfo.setGoodsId(e.getId());
                orderInfo.setBl(e.getBillNumber());
            });
            orderInfo.setContainer(strings);
@@ -523,7 +589,11 @@
            orderInfo.setNote(driverNoteVos);
            orderInfo.setTrouble(driverNoteVos1);
            orderInfo.setState(tOrder.getState());
            return orderInfo;
            HashMap<String, Object> map = new HashMap<>();
            map.put("lonlat",maps);
            map.put("data",orderInfo);
            return map;
        }
@@ -533,6 +603,17 @@
            return this.baseMapper.addOrderFile(orderId,url,name);
        }
        @Override
        public List<Map<String, Object>> queryAllOrderDatas() {
            return this.baseMapper.queryAllOrderDatas();
        }
        @Override
        public List<Map<String, Object>> getLonLat(Long orderId) {
            return this.baseMapper.getLonLat(orderId);
        }
        public static void main(String[] args) throws ParseException {