|
@@ -6,9 +6,11 @@ import com.google.common.collect.Lists;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.view.GoodsSourceView;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.PublishTaskInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.PublishTaskInfoMapper;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.*;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.util.EntCoordUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -81,7 +83,7 @@ public class PublishTaskInfoServiceImpl extends ServiceImpl<PublishTaskInfoMappe
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Page<PublishTaskInfo> selectGoodsSource(PublishTaskInfo publishTaskInfo) {
|
|
|
|
|
|
+ public Page<GoodsSourceView> selectGoodsSource(PublishTaskInfo publishTaskInfo) {
|
|
Map<String, Object> pageView = new HashMap<>();
|
|
Map<String, Object> pageView = new HashMap<>();
|
|
pageView.put("startRecord", (publishTaskInfo.getCurrentPage() - 1)
|
|
pageView.put("startRecord", (publishTaskInfo.getCurrentPage() - 1)
|
|
* publishTaskInfo.getPageSize());
|
|
* publishTaskInfo.getPageSize());
|
|
@@ -96,22 +98,20 @@ public class PublishTaskInfoServiceImpl extends ServiceImpl<PublishTaskInfoMappe
|
|
pageView.put("currentPage", publishTaskInfo.getCurrentPage());
|
|
pageView.put("currentPage", publishTaskInfo.getCurrentPage());
|
|
// 查询货源总数
|
|
// 查询货源总数
|
|
Integer dataCount = baseMapper.getCounstByCondition(pageView);
|
|
Integer dataCount = baseMapper.getCounstByCondition(pageView);
|
|
- Page<PublishTaskInfo> page = new Page<>();
|
|
|
|
|
|
+ Page<GoodsSourceView> page = new Page<>();
|
|
|
|
+ //货源列表
|
|
|
|
+ List<GoodsSourceView> goodsSourceViews = new ArrayList<>();
|
|
|
|
+ //新增货源对象
|
|
|
|
+ GoodsSourceView goodsSourceView = new GoodsSourceView();
|
|
//推荐货源列表
|
|
//推荐货源列表
|
|
if("1".equals(publishTaskInfo.getSearchKeyWord())){
|
|
if("1".equals(publishTaskInfo.getSearchKeyWord())){
|
|
List<PublishTaskInfo> dataList = baseMapper.getListsByCondition(pageView);
|
|
List<PublishTaskInfo> dataList = baseMapper.getListsByCondition(pageView);
|
|
- page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
- page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
- page.setCurrent(publishTaskInfo.getCurrentPage());
|
|
|
|
- page.setSize(publishTaskInfo.getPageSize());
|
|
|
|
|
|
+ goodsSourceView.setPublishTaskInfoList(dataList);
|
|
}
|
|
}
|
|
//按时间排序货源列表
|
|
//按时间排序货源列表
|
|
else if("2".equals(publishTaskInfo.getSearchKeyWord())) {
|
|
else if("2".equals(publishTaskInfo.getSearchKeyWord())) {
|
|
List<PublishTaskInfo> dataList = baseMapper.getListByTimeCondition(pageView);
|
|
List<PublishTaskInfo> dataList = baseMapper.getListByTimeCondition(pageView);
|
|
- page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
- page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
- page.setCurrent(publishTaskInfo.getCurrentPage());
|
|
|
|
- page.setSize(publishTaskInfo.getPageSize());
|
|
|
|
|
|
+ goodsSourceView.setPublishTaskInfoList(dataList);
|
|
}
|
|
}
|
|
//按距离排序货源列表
|
|
//按距离排序货源列表
|
|
else{
|
|
else{
|
|
@@ -141,11 +141,53 @@ public class PublishTaskInfoServiceImpl extends ServiceImpl<PublishTaskInfoMappe
|
|
dataList.sort(Comparator.comparing(PublishTaskInfo::getCargoDistance));
|
|
dataList.sort(Comparator.comparing(PublishTaskInfo::getCargoDistance));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
- page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
- page.setCurrent(publishTaskInfo.getCurrentPage());
|
|
|
|
- page.setSize(publishTaskInfo.getPageSize());
|
|
|
|
|
|
+ //新增货源对象
|
|
|
|
+ goodsSourceView.setPublishTaskInfoList(dataList);
|
|
}
|
|
}
|
|
|
|
+ //周边信息列表
|
|
|
|
+ List<PublishTaskInfo> publishTaskInfoList = new ArrayList<>();
|
|
|
|
+ //所有货源列表
|
|
|
|
+ List<PublishTaskInfo> dataList1 = baseMapper.getAllListsByCondition(pageView);
|
|
|
|
+ if (!CollectionUtils.isEmpty(dataList1)){
|
|
|
|
+ //查询发货地经纬度
|
|
|
|
+ for(int i = 0; i < dataList1.size(); i++){
|
|
|
|
+ PublishTaskInfo publishTaskInfo1 = dataList1.get(i);
|
|
|
|
+ //发货地经纬度
|
|
|
|
+ double lng2 = Math.toRadians(Double.valueOf(publishTaskInfo1.getSendLongitude()));
|
|
|
|
+ double lat2 = Math.toRadians(Double.valueOf(publishTaskInfo1.getSendLatitude()));
|
|
|
|
+ //根据装货城市获取经纬度
|
|
|
|
+ String str = EntCoordUtil.getCoordinate(publishTaskInfo.getLoadingPlaceCity());
|
|
|
|
+ String str1 = str.substring(0, str.indexOf(","));//经度
|
|
|
|
+ String str2 = str.substring(str1.length()+1, str.length());//纬度
|
|
|
|
+ //装货地经纬度
|
|
|
|
+ double lng1 = Math.toRadians(Double.valueOf(str1));
|
|
|
|
+ double lat1 = Math.toRadians(Double.valueOf(str2));
|
|
|
|
+ // 纬度之差
|
|
|
|
+ double a = lat1 - lat2;
|
|
|
|
+ // 经度之差
|
|
|
|
+ double b = lng1 - lng2;
|
|
|
|
+ // 计算两点距离的公式
|
|
|
|
+ double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
|
|
|
|
+ Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
|
|
|
|
+ // 弧长乘地球半径, 返回单位: 千米
|
|
|
|
+ s = s * EARTH_RADIUS;
|
|
|
|
+ if (s <= 300){
|
|
|
|
+ //货距小于300公里,放入周边信息列表
|
|
|
|
+ publishTaskInfo1.setCargoDistance(Math.floor(s));
|
|
|
|
+ publishTaskInfoList.add(publishTaskInfo1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //按货距排序,倒序
|
|
|
|
+ publishTaskInfoList.sort(Comparator.comparing(PublishTaskInfo::getCargoDistance));
|
|
|
|
+ //新增周边信息列表
|
|
|
|
+ goodsSourceView.setPublishTaskInfoLists(publishTaskInfoList);
|
|
|
|
+ }
|
|
|
|
+ //将货源对象放入货源列表
|
|
|
|
+ goodsSourceViews.add(goodsSourceView);
|
|
|
|
+ page.setRecords(goodsSourceViews == null ? Lists.newArrayList() : goodsSourceViews);
|
|
|
|
+ page.setTotal(dataCount == null ? publishTaskInfoList.size() : dataCount + publishTaskInfoList.size());
|
|
|
|
+ page.setCurrent(publishTaskInfo.getCurrentPage());
|
|
|
|
+ page.setSize(publishTaskInfo.getPageSize());
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|