| | |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyCityService; |
| | | import com.stylefeng.guns.modular.system.service.IPhoneService; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | |
| | | @Resource |
| | | private PhoneMapper phoneMapper; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取所有系统电话 |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<Phone> queryPhones(Double lat, Double lnt) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt); |
| | | public List<Phone> queryPhones(Integer uid, Double lat, Double lnt) throws Exception { |
| | | String tripId = redisUtil.getValue("trip" + uid); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt, tripId); |
| | | if(null == reverseGeocode){ |
| | | return new ArrayList<>(); |
| | | } |
| | |
| | | for (int i = 0; i < addressComponentsVos.length; i++) { |
| | | city[i] = addressComponentsVos[i].getLongName(); |
| | | } |
| | | List<Phone> list = phoneMapper.queryPhones(city); |
| | | List<Company> companies = companyCityService.query2(city); |
| | | List<Integer> collect = companies.stream().map(Company::getId).collect(Collectors.toList()); |
| | | List<Phone> list = phoneMapper.queryPhones(collect); |
| | | return list; |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Map<String, Object> queryCustomerPhone(Double lat, Double lnt) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt); |
| | | public Map<String, Object> queryCustomerPhone(Integer uid, Double lat, Double lnt) throws Exception { |
| | | String tripId = redisUtil.getValue("trip" + uid); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt, tripId); |
| | | if(null == reverseGeocode){ |
| | | return new HashMap<>(); |
| | | } |
| | |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //平台电话 |
| | | Phone query = phoneMapper.query(2, 1, city); |
| | | Phone query = phoneMapper.query(2, 1, null); |
| | | map.put("platform", null != query ? query.getPhone() : ""); |
| | | |
| | | |
| | | Company company = companyCityService.query1(city); |
| | | //公司 |
| | | query = phoneMapper.query(2, 2, city); |
| | | query = phoneMapper.query(2, 2, company.getId()); |
| | | map.put("company", null != query ? query.getPhone() : ""); |
| | | return map; |
| | | } |