Forráskód Böngészése

feat:运单新增结算里程字段

wangweiyu 4 éve
szülő
commit
0420d798bd

+ 6 - 0
src/main/java/com/aoyang/tms/controller/vo/TruckOrderStatisticsVO.java

@@ -54,4 +54,10 @@ public class TruckOrderStatisticsVO implements Serializable {
     @ApiModelProperty(value = "未执行运单")
     private Integer unExecuted;
 
+    @ApiModelProperty(value = "空车未派装车单")
+    private Integer emptyUnAllocated;
+
+    @ApiModelProperty(value = "重车未派卸车单")
+    private Integer heavyUnAllocated;
+
 }

+ 2 - 0
src/main/java/com/aoyang/tms/mapper/TruckMapper.java

@@ -27,4 +27,6 @@ public interface TruckMapper extends BaseMapper<Truck> {
 
     int getUnAllocatedTruckCount(@Param("orgId") Long orgId);
 
+    int getUnAllocatedOrderCount(@Param("orgId") Long orgId, @Param("orderType") Integer type);
+
 }

+ 52 - 0
src/main/java/com/aoyang/tms/service/impl/CommonServiceImpl.java

@@ -17,6 +17,7 @@ import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.http.HttpEntity;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -54,6 +55,10 @@ public class CommonServiceImpl implements CommonService {
     @Resource
     private WorkCycleService workCycleService;
 
+    final static String BAIDUMAP_AK = "Zvd6FzmertUwjhZih5Zfq0D8uTUhvqsH";
+
+    final static String BAIDUMAP_URL = "http://api.map.baidu.com/reverse_geocoding/v3/?output=json&coordtype=BD09&pois=1";
+
     @Override
     public Org findOrg(Long orgId) {
         Org orgParam = new Org();
@@ -273,6 +278,10 @@ public class CommonServiceImpl implements CommonService {
 
     @Override
     public List<String> getLocationtrip(Long truckId, LocalDateTime startDate, LocalDateTime endDate) {
+        if (startDate == null || endDate == null) {
+            log.error("getLocationtrip 查询时间错误");
+            return Collections.EMPTY_LIST;
+        }
         QueryWrapper<TruckSimCard> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("truck_id", truckId);
         TruckSimCard truckSimCard = truckSimCardService.getOne(queryWrapper);
@@ -291,4 +300,47 @@ public class CommonServiceImpl implements CommonService {
         return result;
     }
 
+    public String longitudeToAddress(float lat, float lng) {
+        //拼接请求路径
+        String url = BAIDUMAP_URL + "&ak=" + BAIDUMAP_AK + "&location=" + lat + "," + lng;
+        log.info("请求url:" + url);
+        String res = doGet(url);
+        String Addresslocation= JSON.parseObject(res).getJSONObject("result").getString("formatted_address");
+        System.out.println(Addresslocation);
+        return Addresslocation;
+    }
+
+    public static String doGet(String url) {
+//        //创建一个Http客户端
+//        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
+//        //创建一个get请求
+//        HttpGet httpGet = new HttpGet(url);
+//        //响应模型
+//        CloseableHttpResponse response = null;
+//        try {
+//            //由客户端发送get请求
+//            response = httpClient.execute(httpGet);
+//            //从响应模型中获取响应实体
+//            HttpEntity responseEntity = response.getEntity();
+//            if (responseEntity != null) {
+//                return EntityUtils.toString(responseEntity);
+//            }
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        } finally {
+//            try {
+//                if (httpClient != null) {
+//                    httpClient.close();
+//                }
+//                if (response != null) {
+//                    response.close();
+//                }
+//            } catch (IOException e) {
+//                e.printStackTrace();
+//            }
+//
+//        }
+        return null;
+    }
+
 }

+ 4 - 1
src/main/java/com/aoyang/tms/service/impl/WorkOrderServiceImpl.java

@@ -120,7 +120,10 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
         vo.setUnExecuted(getOrgOrderCount(orgId, null, WorkOrderEnum.TODO.orderStatus()));
         //未派单
         vo.setUnAllocated(truckMapper.getUnAllocatedTruckCount(orgId));
-
+        //空车未派装车单
+        vo.setEmptyUnAllocated(truckMapper.getUnAllocatedOrderCount(orgId, 1));
+        //重车未派卸车单
+        vo.setHeavyUnAllocated(truckMapper.getUnAllocatedOrderCount(orgId, 2));
         return vo;
     }
 

+ 21 - 3
src/main/resources/mapper/TruckMapper.xml

@@ -109,12 +109,13 @@
             <if test="param!=null and param.surplusCount == 1">
                 and two.id is null
             </if>
-            <if test="param!=null and param.unAllocated == 1">
-                and two.id is null
-            </if>
             <if test="param!=null and param.unExecuted == 1">
                 and two.order_status = 0
             </if>
+            <if test="param!=null and param.unAllocated == 1">
+                and two.id is null
+            </if>
+
         </where>
         group by truck.truck_id
     </select>
@@ -136,4 +137,21 @@
         WHERE truck.org_id = #{orgId} and wo.id is null
     </select>
 
+    <!-- 查询未派指定类型运单车车辆 -->
+    <select id="getUnAllocatedOrderCount" resultType="java.lang.Integer">
+        SELECT count(1)
+        FROM
+        truck
+        left join tms_work_order wo on truck.truck_id = wo.truck_id
+        left join tms_work_cycle wc on truck.truck_id = wc.truck_id and wc.status = 1
+        and 40 > wo.order_status
+        <if test="orderType != null and orderType == 1">
+            and wc.jing_weight = 0 and wo.type = #{orderType}
+        </if>
+        <if test="orderType != null and orderType == 2">
+            and wc.jing_weight > 0 and wo.type = #{orderType}
+        </if>
+        WHERE truck.org_id = #{orgId} and wo.id is null
+    </select>
+
 </mapper>