Przeglądaj źródła

Merge branch 'master' of http://git.zthymaoyi.com/gongdecai/wangluohuoyun

ccj 2 lat temu
rodzic
commit
8fd888f676

+ 2 - 0
winsea-haixin-platform-backend/src/main/resources/application.yml

@@ -163,6 +163,8 @@ auth:
     - /login/*
     - /hyPublicConsultation/**/*
     - /hyPublicConsultation/*
+    - /hyReleaseGoodsInfo/**/*
+    - /hyReleaseGoodsInfo/*
   expire-in: 2592000
   login-url: /login.html
   logout-url: /auth/api/logout

+ 52 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/HyReleaseGoodsInfo.java

@@ -173,6 +173,14 @@ public class HyReleaseGoodsInfo extends BaseModel<HyReleaseGoodsInfo> {
      * 货源状态(已上架/已下架)
      */
     private String status;
+    /**
+     * 头像
+     */
+    private String headSculpture;
+    /**
+     * 备用
+     */
+    private String standby;
     /**
      * 查询类型(1发布中2发布记录3常发货源)
      */
@@ -183,6 +191,50 @@ public class HyReleaseGoodsInfo extends BaseModel<HyReleaseGoodsInfo> {
      */
     @TableField(exist = false)
     private String searchKeyWord;
+    /**
+     * 装货地
+     */
+    @TableField(exist = false)
+    private String loadingPlace;
+
+    /**
+     * 装货地市
+     */
+    @TableField(exist = false)
+    private String loadingPlaceCity;
+
+    /**
+     * 卸货地
+     */
+    @TableField(exist = false)
+    private String unLoadingPlace;
+
+    /**
+     * 卸货地市
+     */
+    @TableField(exist = false)
+    private String unLoadingPlaceCity;
+    /**
+     * 司机经度
+     */
+    @TableField(exist = false)
+    private String driverLongitude;
+
+    /**
+     * 司机纬度
+     */
+    @TableField(exist = false)
+    private String driverLatitude;
+    /**
+     * 周边货运信息(1是)
+     */
+    @TableField(exist = false)
+    private String peripheralInfo;
+    /**
+     * 司机(1是)
+     */
+    @TableField(exist = false)
+    private String driverFlag;
 
     @Override
     protected Serializable pkVal() {

+ 8 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/HyReleaseGoodsInfoMapper.java

@@ -2,6 +2,7 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 
 import com.yh.saas.plugin.yiliangyiyun.entity.HyReleaseGoodsInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.yh.saas.plugin.yiliangyiyun.entity.PublishTaskInfo;
 
 import java.util.List;
 import java.util.Map;
@@ -19,4 +20,11 @@ public interface HyReleaseGoodsInfoMapper extends BaseMapper<HyReleaseGoodsInfo>
     Integer getCountByCondition(Map<String, Object> pageView);
 
     List<HyReleaseGoodsInfo> getListByCondition(Map<String, Object> pageView);
+    /**
+     * 查询货源列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<HyReleaseGoodsInfo> getAllListsByCondition(Map<String, Object> pageView);
 }

+ 172 - 8
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/HyReleaseGoodsInfoServiceImpl.java

@@ -1,18 +1,24 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.google.common.collect.Lists;
 import com.yh.saas.common.support.util.IdGenerator;
+import com.yh.saas.common.support.util.StringUtils;
 import com.yh.saas.plugin.yiliangyiyun.entity.HyReleaseGoodsInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.PublishTaskInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.HyReleaseGoodsInfoMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.IHyReleaseGoodsInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.plugin.yiliangyiyun.util.EntCoordUtil;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * <p>
@@ -22,12 +28,19 @@ import java.util.Map;
  * @author Gdc
  * @since 2023-06-02
  */
+@EnableScheduling
 @Service
 public class HyReleaseGoodsInfoServiceImpl extends ServiceImpl<HyReleaseGoodsInfoMapper, HyReleaseGoodsInfo> implements IHyReleaseGoodsInfoService {
 
+    /**
+     * 地球半径,单位 km
+     */
+    private static final double EARTH_RADIUS = 6378.137;
+
     @Override
     public Page<HyReleaseGoodsInfo> selectTask(HyReleaseGoodsInfo hyReleaseGoodsInfo) {
         Map<String, Object> pageView = new HashMap<>();
+        Page<HyReleaseGoodsInfo> page = new Page<>();
         pageView.put("startRecord", (hyReleaseGoodsInfo.getCurrentPage() - 1)
                 * hyReleaseGoodsInfo.getPageSize());
         //用户id
@@ -36,12 +49,136 @@ public class HyReleaseGoodsInfoServiceImpl extends ServiceImpl<HyReleaseGoodsInf
         pageView.put("searchKeyWord", hyReleaseGoodsInfo.getSearchKeyWord());
         pageView.put("pageSize", hyReleaseGoodsInfo.getPageSize());
         pageView.put("currentPage", hyReleaseGoodsInfo.getCurrentPage());
-        // 查询总数
-        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        pageView.put("loadingPlaceCity", hyReleaseGoodsInfo.getLoadingPlaceCity());
+        pageView.put("unLoadingPlaceCity", hyReleaseGoodsInfo.getUnLoadingPlaceCity());
+        if(hyReleaseGoodsInfo.getLoadingPlace() != null && !hyReleaseGoodsInfo.getLoadingPlace().isEmpty()){
+            String result = "";
+            String[] array = hyReleaseGoodsInfo.getLoadingPlace().split(",");
+            for (String tmp:array) {
+                result += "'"+tmp+"',";
+            }
+            if(result.length() > 0){
+                result = result.substring(0,result.length()-1);
+            }
+            else{
+                result = "'"+hyReleaseGoodsInfo.getLoadingPlace()+"'";
+            }
+            pageView.put("loadingPlace", result);
+        }
+        if(hyReleaseGoodsInfo.getUnLoadingPlace() != null && !hyReleaseGoodsInfo.getUnLoadingPlace().isEmpty()){
+            String result = "";
+            String[] array = hyReleaseGoodsInfo.getUnLoadingPlace().split(",");
+            for (String tmp:array) {
+                result += "'"+tmp+"',";
+            }
+            if(result.length() > 0){
+                result = result.substring(0,result.length()-1);
+            }
+            else{
+                result = "'"+hyReleaseGoodsInfo.getUnLoadingPlace()+"'";
+            }
+            pageView.put("unLoadingPlace", result);
+        }
+        //货源列表
+        List<HyReleaseGoodsInfo> hyReleaseGoodsInfoList = new ArrayList<>();
+        //按时间排序货源列表
         List<HyReleaseGoodsInfo> dataList = baseMapper.getListByCondition(pageView);
-        Page<HyReleaseGoodsInfo> page = new Page<>();
-        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
-        page.setTotal(dataCount == null ? 0 : dataCount);
+        if (!CollectionUtils.isEmpty(dataList)) {
+            //查询发货地经纬度
+            for (int i = 0; i < dataList.size(); i++) {
+                HyReleaseGoodsInfo hyReleaseGoodsInfo1 = dataList.get(i);
+                //发货地经纬度
+                double lat2 = Math.toRadians(Double.valueOf(hyReleaseGoodsInfo1.getSendLatitude()));
+                double lng2 = Math.toRadians(Double.valueOf(hyReleaseGoodsInfo1.getSendLongitude()));
+                //根据司机经纬度求货距
+                if (!StringUtils.isEmpty(hyReleaseGoodsInfo.getDriverLatitude()) && !StringUtils.isEmpty(hyReleaseGoodsInfo.getDriverLongitude())) {
+                    double lat1 = Math.toRadians(Double.valueOf(hyReleaseGoodsInfo.getDriverLatitude()));
+                    double lng1 = Math.toRadians(Double.valueOf(hyReleaseGoodsInfo.getDriverLongitude()));
+                    // 纬度之差
+                    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;
+                    hyReleaseGoodsInfo1.setCargoDistance(Math.floor(s));
+                }
+                //根据装货城市求货距
+                else if (!StringUtils.isEmpty(hyReleaseGoodsInfo.getLoadingPlaceCity())) {
+                    //根据装货城市获取经纬度
+                    String str = EntCoordUtil.getCoordinate(hyReleaseGoodsInfo.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;
+                    hyReleaseGoodsInfo1.setCargoDistance(Math.floor(s));
+                }
+            }
+        }
+        hyReleaseGoodsInfoList.addAll(dataList);
+        //司机标识
+        if (hyReleaseGoodsInfo.getDriverFlag()!=null) {
+            if (hyReleaseGoodsInfo.getLoadingPlace() == null && hyReleaseGoodsInfo.getLoadingPlaceCity() == null) {
+                page.setRecords(Lists.newArrayList());
+                page.setTotal(0);
+                page.setCurrent(hyReleaseGoodsInfo.getCurrentPage());
+                page.setSize(hyReleaseGoodsInfo.getPageSize());
+                return page;
+            }
+            //周边信息列表
+            List<HyReleaseGoodsInfo> dataList1 = baseMapper.getAllListsByCondition(pageView);
+            dataList1.removeAll(dataList);
+            if (!CollectionUtils.isEmpty(dataList1)) {
+                if (!StringUtils.isEmpty(hyReleaseGoodsInfo.getLoadingPlaceCity())) {
+                    //查询发货地经纬度
+                    for (int i = 0; i < dataList1.size(); i++) {
+                        HyReleaseGoodsInfo hyReleaseGoodsInfo1 = dataList1.get(i);
+                        //发货地经纬度
+                        double lng2 = Math.toRadians(Double.valueOf(hyReleaseGoodsInfo1.getSendLongitude()));
+                        double lat2 = Math.toRadians(Double.valueOf(hyReleaseGoodsInfo1.getSendLatitude()));
+                        //根据装货城市获取经纬度
+                        String str = EntCoordUtil.getCoordinate(hyReleaseGoodsInfo.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公里,放入周边信息列表
+                            hyReleaseGoodsInfo1.setCargoDistance(Math.floor(s));
+                            hyReleaseGoodsInfo1.setPeripheralInfo("1");
+                            hyReleaseGoodsInfoList.add(hyReleaseGoodsInfo1);
+                        }
+                    }
+                }
+            }
+        }
+        page.setRecords(hyReleaseGoodsInfoList == null ? Lists.newArrayList() : hyReleaseGoodsInfoList);
+        page.setTotal(hyReleaseGoodsInfoList.size() == 0 ? 0 : hyReleaseGoodsInfoList.size());
         page.setCurrent(hyReleaseGoodsInfo.getCurrentPage());
         page.setSize(hyReleaseGoodsInfo.getPageSize());
         return page;
@@ -86,4 +223,31 @@ public class HyReleaseGoodsInfoServiceImpl extends ServiceImpl<HyReleaseGoodsInf
             this.updateById(hyReleaseGoodsInfo);
         }
     }
+
+    /**
+     * 48小时自动下架
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Scheduled(cron = "0 0 */1 * * ?")
+    public String autoDown(){
+        Calendar calendar = Calendar.getInstance();
+        //设置小时
+        calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 48);
+        //格式化时间
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        //48小时之前
+        String time=df.format(calendar.getTime());
+        List<HyReleaseGoodsInfo> hyReleaseGoodsInfoList=this.selectList(new EntityWrapper<HyReleaseGoodsInfo>()
+            .eq("status","已上架")
+            .le("update_date",time));
+        if (!CollectionUtils.isEmpty(hyReleaseGoodsInfoList)){
+            for (HyReleaseGoodsInfo hyReleaseGoodsInfo:hyReleaseGoodsInfoList){
+                hyReleaseGoodsInfo.setStatus("已下架");
+                this.updateById(hyReleaseGoodsInfo);
+            }
+        }
+        return "OK";
+
+    }
 }

+ 93 - 14
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/HyReleaseGoodsInfoMapper.xml

@@ -10,13 +10,17 @@
         <if test="commonId != null and commonId != ''">
             AND common_id = #{commonId}
         </if>
-        <if test="searchKeyWord != null and searchKeyWord != ''">
-            AND (lower(send_private) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(send_city) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(send_area) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(unload_private) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(unload_area) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(unload_city) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        <if test="loadingPlaceCity != null and loadingPlaceCity != ''">
+            AND (lower(send_city) like lower(CONCAT('%',#{loadingPlaceCity},'%')))
+        </if>
+        <if test="unLoadingPlaceCity != null and unLoadingPlaceCity != ''">
+            AND (lower(unload_city) like lower(CONCAT('%',#{unLoadingPlaceCity},'%')))
+        </if>
+        <if test="loadingPlace != null and loadingPlace != ''">
+            AND send_area in (${loadingPlace})
+        </if>
+        <if test="unLoadingPlace != null and unLoadingPlace != ''">
+            AND unload_area in (${unLoadingPlace})
         </if>
         <if test="searchType != null and searchType != ''">
             <if test="searchType == 1">
@@ -73,14 +77,89 @@
         <if test="commonId != null and commonId != ''">
             AND common_id = #{commonId}
         </if>
-        <if test="searchKeyWord != null and searchKeyWord != ''">
-            AND (lower(send_private) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(send_city) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(send_area) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(unload_private) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(unload_area) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(unload_city) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        <if test="loadingPlaceCity != null and loadingPlaceCity != ''">
+            AND (lower(send_city) like lower(CONCAT('%',#{loadingPlaceCity},'%')))
+        </if>
+        <if test="unLoadingPlaceCity != null and unLoadingPlaceCity != ''">
+            AND (lower(unload_city) like lower(CONCAT('%',#{unLoadingPlaceCity},'%')))
+        </if>
+        <if test="loadingPlace != null and loadingPlace != ''">
+            AND send_area in (${loadingPlace})
+        </if>
+        <if test="unLoadingPlace != null and unLoadingPlace != ''">
+            AND unload_area in (${unLoadingPlace})
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND status!='已下架' and delete_flag = '0'
+            </if>
+            <if test="searchType == 2">
+                AND delete_flag = '0'
+            </if>
+            <if test="searchType == 3">
+                AND often_flag = '1'
+            </if>
+        </if>
+        ORDER BY update_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
+    <select id="getAllListsByCondition" parameterType="Map" resultType="com.yh.saas.plugin.yiliangyiyun.entity.HyReleaseGoodsInfo">
+        SELECT
+        id,
+        common_id as commonId,
+        send_private as sendPrivate,
+        send_city as sendCity,
+        send_area as sendArea,
+        send_detailed_address as sendDetailedAddress,
+        send_longitude as sendLongitude,
+        send_latitude as sendLatitude,
+        unsend_longitude as unsendLongitude,
+        unsend_latitude as unsendLatitude,
+        unload_private as unloadPrivate,
+        unload_city as unloadCity,
+        unload_area as unloadArea,
+        unload_detailed_address as unloadDetailedAddress,
+        cargo_distance as cargoDistance,
+        goods_name as goodsName,
+        package_type as packageType,
+        measuring_method as measuringMethod,
+        weight,
+        volume,
+        expected_num as expectedNum,
+        billing_method as billingMethod,
+        freight_price as freightPrice,
+        contacts,
+        contacts_phone as contactsPhone,
+        freight_station_name as freightStationName,
+        period_of_time as periodOfTime,
+        loading_date as loadingDate,
+        car_length as carLength,
+        remark,
+        station_fee as stationFee,
+        often_flag as oftenFlag,
+        car_model as carModel,
+        status,
+        create_date as createDate,
+        update_date as updateDate
+        FROM hy_release_goods_info
+        WHERE 1=1
+        <if test="commonId != null and commonId != ''">
+            AND common_id = #{commonId}
         </if>
+<!--        <if test="loadingPlaceCity != null and loadingPlaceCity != '' and (loadingPlace == null or loadingPlace == '' or unLoadingPlace == null or unLoadingPlace == '')">-->
+<!--            AND (lower(send_city) not like lower(CONCAT('%',#{loadingPlaceCity},'%')))-->
+<!--        </if>-->
+<!--        <if test="unLoadingPlaceCity != null and unLoadingPlaceCity != '' and( unLoadingPlace == null or unLoadingPlace == ''or loadingPlace == null or loadingPlace == '')">-->
+<!--            AND (lower(unload_city) not like lower(CONCAT('%',#{unLoadingPlaceCity},'%')))-->
+<!--        </if>-->
+<!--        <if test="loadingPlace != null and loadingPlace != ''">-->
+<!--            AND send_area not in (${loadingPlace})-->
+<!--        </if>-->
+<!--        <if test="unLoadingPlace != null and unLoadingPlace != ''">-->
+<!--            AND unload_area not in (${unLoadingPlace})-->
+<!--        </if>-->
         <if test="searchType != null and searchType != ''">
             <if test="searchType == 1">
                 AND status!='已下架' and delete_flag = '0'