|
@@ -2,6 +2,7 @@ package com.steerinfo.dil.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.steerinfo.dil.gaode.SearchPoint2;
|
|
|
import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
|
|
|
import com.steerinfo.dil.service.ITmstruckReceiptResultService;
|
|
|
import com.steerinfo.dil.service.impl.OffSiteTransportationServiceImpl;
|
|
@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.http.MediaType;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartRequest;
|
|
@@ -67,6 +69,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
private String suffix;
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
+ private String gaodeTonken = "6488b963467353c2837c955cbb03104f";
|
|
|
|
|
|
@Autowired
|
|
|
ITmstruckReceiptResultService tmstruckReceiptResultService;
|
|
@@ -99,15 +102,15 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
public RESTfulResult fullPath(String orderNumber) throws Exception {
|
|
|
//运输订单号:orderNumber、车牌号:capacityNumber、出厂时间:resultOutGateTime、预警开关:turnOf、发货地址:shipperName、收货地址:receiveAddress
|
|
|
//初始化请求参数
|
|
|
- //判断是否自提
|
|
|
- int count = offSiteTransportationService.isSelfMentionByOrderNumber(orderNumber);
|
|
|
- if (count==0){
|
|
|
+ //判断订单是否可以查看路径
|
|
|
+// int watch = offSiteTransportationService.checkOrder(orderNumber);
|
|
|
+// if (watch==1){
|
|
|
HashMap<String,Object> mapValue=new HashMap<>();
|
|
|
mapValue.put("orderNumber",orderNumber);
|
|
|
return success(routeService.fullPathVisualization(mapValue).get());
|
|
|
- }else {
|
|
|
- return failed("-1");
|
|
|
- }
|
|
|
+// }else {
|
|
|
+// return failed("-1");
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -283,7 +286,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
map.putAll(value);
|
|
|
//添加入库实绩
|
|
|
Integer resTfulResult = offSiteTransportationService.addTmstruckReceiptResult(map);
|
|
|
- if (!resTfulResult.equals("4")){
|
|
|
+ if (resTfulResult!=4){
|
|
|
//保存路线
|
|
|
String redisJson = (String) redisTemplate.opsForValue().get(prefixOrder+":"+orderNumber);
|
|
|
HashMap mapValue = JSON.parseObject(redisJson, HashMap.class);
|
|
@@ -301,7 +304,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
redisTemplate.delete(prefixOrder+":"+orderNumber);
|
|
|
redisTemplate.delete(prefixOrder+":"+orderNumber+suffix);
|
|
|
//添加运输距离
|
|
|
- to= (ViewVisualization) DataConversionTool.jsonToBean(json,ViewVisualization.class);
|
|
|
+ to= (ViewVisualization) JSON.parseObject(json,ViewVisualization.class);
|
|
|
|
|
|
}else {
|
|
|
HashMap<String,Object> hashMap=new HashMap();
|
|
@@ -313,7 +316,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
|
|
|
|
|
|
if (json!=null&&!json.equals("")){
|
|
|
- to= (ViewVisualization) DataConversionTool.jsonToBean(json,ViewVisualization.class);
|
|
|
+ to= (ViewVisualization) JSON.parseObject(json,ViewVisualization.class);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -349,7 +352,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- return success(1);
|
|
|
+ return success(resTfulResult);
|
|
|
}
|
|
|
|
|
|
//如果内容丢失重新获得
|
|
@@ -359,18 +362,22 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
String netValidationResult = zhongJiaoXingLu.netValidation(capacityNumber);
|
|
|
Map netValidationMap = (Map) JSONObject.parse(netValidationResult);
|
|
|
if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){
|
|
|
- String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
|
|
|
- SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class);
|
|
|
- String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
|
|
|
- SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
|
|
|
+ String searchPointJson = HTTPRequestUtils.sendGet("https://restapi.amap.com/v3/geocode/geo", "address="+ URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key="+gaodeTonken);
|
|
|
+ SearchPoint2 searchPoint= JSON.parseObject(searchPointJson, SearchPoint2.class);
|
|
|
+ String searchPointJson2 = HTTPRequestUtils.sendGet("https://restapi.amap.com/v3/geocode/geo", "address="+URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key="+gaodeTonken);
|
|
|
+ SearchPoint2 searchPoint2= JSON.parseObject(searchPointJson2, SearchPoint2.class);
|
|
|
//运单生成之后保存
|
|
|
HashMap<String,String> redisMap=new HashMap<>();
|
|
|
- String startLon=searchPoint.getResult().getLocation().getLng().toString().length()>9?searchPoint.getResult().getLocation().getLng().toString().substring(0,9):searchPoint.getResult().getLocation().getLng().toString();
|
|
|
- String startLat=searchPoint.getResult().getLocation().getLat().toString().length()>9?searchPoint.getResult().getLocation().getLat().toString().substring(0,8):searchPoint.getResult().getLocation().getLat().toString();
|
|
|
- redisMap.put("startLonlat", startLon+","+startLat);
|
|
|
- String endLon= searchPoint2.getResult().getLocation().getLng().toString().length()>9?searchPoint2.getResult().getLocation().getLng().toString().substring(0,9):searchPoint2.getResult().getLocation().getLng().toString();
|
|
|
- String endLat= searchPoint2.getResult().getLocation().getLat().toString().length()>9?searchPoint2.getResult().getLocation().getLat().toString().substring(0,8):searchPoint2.getResult().getLocation().getLat().toString();
|
|
|
- redisMap.put("endLonlat",endLon+","+endLat);
|
|
|
+ String location = searchPoint.getGeocodes().get(0).getLocation();
|
|
|
+ String[] split = StringUtils.split(location, ",");
|
|
|
+ String Lng = split[0];
|
|
|
+ String Lat = split[1];
|
|
|
+ redisMap.put("startLonlat", Lng.substring(0, 9) + "," + Lat.substring(0, 8));
|
|
|
+ String location2 = searchPoint2.getGeocodes().get(0).getLocation();
|
|
|
+ String[] split2 = StringUtils.split(location2, ",");
|
|
|
+ String Lng2 = split2[0];
|
|
|
+ String Lat2 = split2[1];
|
|
|
+ redisMap.put("endLonlat", Lng2.substring(0, 9) + "," + Lat2.substring(0, 8));
|
|
|
redisMap.put("vclN", capacityNumber);
|
|
|
redisMap.put("vco","2");
|
|
|
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
|
|
@@ -429,7 +436,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
@PostMapping("/abnormalLineWarn")
|
|
|
public String abnormalLineWarn(@RequestParam(value = "data") String data) throws Exception {
|
|
|
|
|
|
- ResultWarn resultWarn= (ResultWarn) DataConversionTool.jsonToBean(data, ResultWarn.class);
|
|
|
+ ResultWarn resultWarn= (ResultWarn) JSON.parseObject(data, ResultWarn.class);
|
|
|
Map<String, Object> map= DataConversionTool.objectToMap(resultWarn);
|
|
|
int i= offSiteTransportationService.addTransportationAlarm(map);
|
|
|
return "success";
|
|
@@ -437,7 +444,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
@PostMapping("/parkWarn")
|
|
|
public String parkWarn(@RequestParam(value = "data",required = false) String data) throws Exception {
|
|
|
|
|
|
- ResultWarn resultWarn= (ResultWarn) DataConversionTool.jsonToBean(data, ResultWarn.class);
|
|
|
+ ResultWarn resultWarn= (ResultWarn) JSON.parseObject(data, ResultWarn.class);
|
|
|
Map<String, Object> map= DataConversionTool.objectToMap(resultWarn);
|
|
|
int i=offSiteTransportationService.addTransportationAlarm(map);
|
|
|
|
|
@@ -446,7 +453,7 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
@PostMapping("/offLineWarn")
|
|
|
public String offLineWarn(@RequestParam(value = "data") String data) throws Exception {
|
|
|
|
|
|
- ResultWarn resultWarn= (ResultWarn) DataConversionTool.jsonToBean(data, ResultWarn.class);
|
|
|
+ ResultWarn resultWarn= (ResultWarn) JSON.parseObject(data, ResultWarn.class);
|
|
|
Map<String, Object> map= DataConversionTool.objectToMap(resultWarn);
|
|
|
int i=offSiteTransportationService.addTransportationAlarm(map);
|
|
|
return "success";
|
|
@@ -475,14 +482,13 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
public RESTfulResult fullPathVisualizationByCarNumber(@RequestBody HashMap mapValue) throws Exception {
|
|
|
|
|
|
//判断是否自提
|
|
|
- int count = offSiteTransportationService.isSelfMention(mapValue.get("capacityNumber").toString());
|
|
|
- if (count==0){
|
|
|
+ /*int count = offSiteTransportationService.isSelfMention(mapValue.get("capacityNumber").toString());
|
|
|
+ if (count==0){*/
|
|
|
CompletableFuture<RouteVo> createOrder =routeService.fullPathVisualizationByCarNumber(mapValue);
|
|
|
-
|
|
|
return success(createOrder.get());
|
|
|
- }else {
|
|
|
+ /* }else {
|
|
|
return failed(-1);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
}
|
|
|
|
|
@@ -524,16 +530,8 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
}
|
|
|
@GetMapping("/getCurrentLocation")
|
|
|
public RESTfulResult getCurrentLocation(@RequestParam("capcityNumber") String capcityNumber) throws Exception {
|
|
|
-// //判断是否自提
|
|
|
-// int count = offSiteTransportationService.isSelfMention(capcityNumber);
|
|
|
-// if (count==0){
|
|
|
- CurrentLocationResult currentLocationResult = routeService.getCurrentLocation(capcityNumber);
|
|
|
- return success(currentLocationResult);
|
|
|
-// }else {
|
|
|
-// return failed(-1);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
+ CurrentLocationResult currentLocationResult = routeService.getCurrentLocation(capcityNumber);
|
|
|
+ return success(currentLocationResult);
|
|
|
}
|
|
|
//在途订单列表
|
|
|
@PostMapping("/transportationPerformance")
|
|
@@ -571,4 +569,14 @@ public class OffSiteTransportationController extends BaseRESTfulController {
|
|
|
PageListAdd pageList = columnDataUtil.tableColumnData(apiId, filter,list);
|
|
|
return success(pageList);
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/getLocationForAddress")
|
|
|
+ public RESTfulResult getAddress(@RequestParam("address") String address) {
|
|
|
+ try{
|
|
|
+ return success(routeService.getLocationForAddress(address));
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return failed("没有查询到地址!请检查输入");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|