123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849 |
- package com.steerinfo.route.service.impl;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
- import com.steerinfo.dil.service.OffSiteTransportationService;
- import com.steerinfo.dil.service.impl.OffSiteTransportationServiceImpl;
- import com.steerinfo.dil.util.PageListAdd;
- import com.steerinfo.framework.controller.RESTfulResult;
- import com.steerinfo.framework.service.pagehelper.PageHelper;
- import com.steerinfo.route.service.RouteService;
- import com.steerinfo.route.threeRequest.ZhongJiaoXingLu;
- import com.steerinfo.route.util.DataConversionTool;
- import com.steerinfo.route.util.HTTPRequestUtils;
- import com.steerinfo.route.util.LngLonUtil;
- import com.steerinfo.route.vo.FullPathVisualizationTo.ViewVisualization;
- import com.steerinfo.route.vo.Map.Point;
- import com.steerinfo.route.vo.Map.RouteVo;
- import com.steerinfo.route.vo.Map.RunRoutePoint;
- import com.steerinfo.route.vo.Map.StartAndEndRoute;
- import com.steerinfo.route.vo.resultJson.SearchPoint;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.stereotype.Service;
- import org.springframework.util.StringUtils;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import java.math.BigDecimal;
- import java.net.URLEncoder;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.concurrent.CompletableFuture;
- import java.util.concurrent.TimeUnit;
- import java.util.stream.Collectors;
- @Service(value = "xmsService")
- public class RouteServiceImpl implements RouteService {
- @Autowired
- private RedisTemplate redisTemplate;
- @Autowired
- private ZhongJiaoXingLu zhongJiaoXingLu;
- @Autowired
- private ITmstruckLeaveFactoryResultService tmstruckLeaveFactoryResultService;
- @Autowired
- private OffSiteTransportationServiceImpl offSiteTransportationService;
- @Value("${str.tengxun.key}")
- private String key;
- @Value("${redis.prefix.order}")
- private String prefixOrder;
- @Value("${redis.prefix.line}")
- private String prefixLine;
- @Value("${redis.prefix.suffix}")
- private String suffix;
-
- public CompletableFuture<String> createTotalResult(Map mapValue) throws Exception {
- if (mapValue.containsKey("capacityNumber")&&mapValue.containsKey("receiveAddress")&&mapValue.containsKey("shipperName")&&mapValue.containsKey("orderNumber")){
- }
-
- SimpleDateFormat dateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- if (true) {
-
- HashMap materieldesMap=new HashMap();
-
-
- String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+URLEncoder.encode(mapValue.get("shipperName")==null?"安钢集团信阳钢铁有限责任公司":mapValue.get("shipperName").toString(),"utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
- SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class);
- if (searchPoint.getStatus()==0){
- materieldesMap.put("addressLongitude",searchPoint.getResult().getLocation().getLng());
- materieldesMap.put("addressLatitude",searchPoint.getResult().getLocation().getLat());
- }else {
- materieldesMap.put("addressLongitude",new BigDecimal(114.036293));
- materieldesMap.put("addressLatitude",new BigDecimal(32.483276));
- }
-
- String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+URLEncoder.encode(mapValue.get("receiveAddress").toString()==null?"长沙市":mapValue.get("receiveAddress").toString(),"utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
- SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
- if (searchPoint2.getStatus()==0&&searchPoint2.getResult()!=null){
- if (searchPoint2.getResult().getAddress_components()!=null){
- materieldesMap.put("addressProvince",searchPoint2.getResult().getAddress_components().getProvince()==null?"湖南省":searchPoint2.getResult().getAddress_components().getProvince());
- materieldesMap.put("addressDistrict",searchPoint2.getResult().getAddress_components().getDistrict()==null?"开福区":searchPoint2.getResult().getAddress_components().getDistrict());
- materieldesMap.put("addressTown",searchPoint2.getResult().getAddress_components().getCity()==null?"长沙市":searchPoint2.getResult().getAddress_components().getCity());
- }else {
- materieldesMap.put("addressProvince","湖南省");
- materieldesMap.put("addressDistrict","开福区");
- materieldesMap.put("addressTown","长沙市");
- }
- materieldesMap.put("addressDeliveryAddress",mapValue.get("receiveAddress").toString()==null?"长沙市":mapValue.get("receiveAddress").toString());
- if (searchPoint2.getResult().getLocation()!=null){
- materieldesMap.put("addressLongitude",searchPoint2.getResult().getLocation().getLng()==null?new BigDecimal(112.98626):searchPoint2.getResult().getLocation().getLng());
- materieldesMap.put("addressLatitude",searchPoint2.getResult().getLocation().getLat()==null?new BigDecimal(28.25591):searchPoint2.getResult().getLocation().getLat());
- }else {
- materieldesMap.put("addressLongitude",new BigDecimal(112.98626));
- materieldesMap.put("addressLatitude",new BigDecimal(28.25591));
- }
- if (searchPoint2.getResult().getAd_info()!=null){
- materieldesMap.put("destCode",searchPoint2.getResult().getAd_info().getAdcode()==null?"无信息":searchPoint2.getResult().getAd_info().getAdcode());
- }else {
- materieldesMap.put("destCode","无信息");
- }
- }else {
-
- materieldesMap.put("addressProvince","湖南省");
- materieldesMap.put("addressDistrict","开福区");
- materieldesMap.put("addressTown","长沙市");
- materieldesMap.put("destCode","430105");
- materieldesMap.put("addressDeliveryAddress","长沙市");
- materieldesMap.put("addressLongitude",new BigDecimal(112.98626));
- materieldesMap.put("addressLatitude",new BigDecimal(28.25591));
- }
-
- String netValidationResult = zhongJiaoXingLu.netValidation(mapValue.get("capacityNumber").toString());
- Map netValidationMap = (Map) JSONObject.parse(netValidationResult);
- if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){
-
- 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= materieldesMap.get("addressLongitude").toString().length()>9?materieldesMap.get("addressLongitude").toString().substring(0,9):materieldesMap.get("addressLongitude").toString();
- String endLat= materieldesMap.get("addressLatitude").toString().length()>9?materieldesMap.get("addressLatitude").toString().substring(0,8):materieldesMap.get("addressLatitude").toString();
- redisMap.put("endLonlat",endLon+","+endLat);
- redisMap.put("vclN", mapValue.get("capacityNumber").toString());
- redisMap.put("vco","2");
- SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
- String qryBtm=mapValue.get("resultOutGateTime").toString();
-
- Date parse = simpleDateFormat.parse(qryBtm);
-
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(parse);
-
- calendar.add(Calendar.HOUR_OF_DAY, 23);
- calendar.add(Calendar.SECOND, 45);
-
- long agetime = parse.getTime();
- long lateTime = calendar.getTimeInMillis();
-
- long reductionTime1=lateTime-agetime;
- long currentTime = new Date().getTime();
-
- long reductionTime2=currentTime-agetime;
-
- long saveTime=(reductionTime1-reductionTime2)/1000;
- redisMap.put("qryBtm", simpleDateFormat.format(simpleDateFormat.parse(qryBtm)));
- String qryEtm= simpleDateFormat.format(calendar.getTime());
- redisMap.put("qryEtm",qryEtm );
- String orderUrl=prefixOrder+":"+mapValue.get("orderNumber").toString();
- String redisJson=JSON.toJSONString(redisMap);
- if (saveTime>0){
- redisTemplate.opsForValue().set(orderUrl, redisJson, saveTime, TimeUnit.SECONDS);
- }else {
- redisTemplate.opsForValue().set(orderUrl, redisJson, 36000, TimeUnit.SECONDS);
- }
- redisTemplate.opsForValue().set(orderUrl+suffix, redisJson);
-
- Map<String,Object> resTfulResultValues = offSiteTransportationService.selectWarnSwitch();
- if(!resTfulResultValues.get("switch").toString().equals("0")){
- redisMap.put("startCode",searchPoint.getResult().getAd_info().getAdcode());
- redisMap.put("destCode",materieldesMap.get("destCode").toString());
- redisMap.put("qryBtm",parse.toString());
- redisMap.put("qryEtm",calendar.getTime().toString());
- redisMap.put("type",resTfulResultValues.get("type").toString());
- String subAbnormalLineWarnV2Json = zhongJiaoXingLu.subAbnormalLineWarnV2(redisMap);
- JSONObject jsonObject = JSONObject.parseObject(subAbnormalLineWarnV2Json);
- if (jsonObject!=null&&jsonObject.get("status").toString().equals(1001+"")){
- HashMap<String,Object> tripMap=new HashMap();
- tripMap.put("orderNumber",mapValue.get("orderNumber").toString());
- tripMap.put("rid",jsonObject.get("result").toString());
- int i=offSiteTransportationService.insertOrderTripId(tripMap);
- }
- }
- }
- return CompletableFuture.completedFuture("successful");
- }
- return CompletableFuture.completedFuture("fail");
- }
-
- public boolean checkTurnOff(String matrial,String selectStr) {
-
- int index=0;
- String[] matrialList=new String[]{"带钢","微粉","螺纹钢","盘螺","盘圆","钢坯","其他"};
-
- lable:for (int i=0;i<matrialList.length;i++){
- if (matrial.contains(matrialList[i])) {
- if(4>=i&&i>=2){
-
- index=3;
- }else if (i==5){
-
- index=4;
- }else if (i==6) {
-
- index=5;
- }else{
- index=i+1;
- }
- break lable;
- }
- }
-
- if (index!=0&&selectStr.contains(String.valueOf(index))){
- return true;
- }
- return false;
- }
-
- @Override
- public CompletableFuture<String> saveRoute(Map mapValue) throws Exception {
-
- SimpleDateFormat dateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date gateTime = dateFormat.parse(mapValue.get("resultOutGateTime").toString());
- String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(mapValue.get("shipperName").toString()==null?"四川省达州钢铁集团有限责任公司":mapValue.get("shipperName").toString(),"utf-8")+"&key="+key);
- SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class);
-
- String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(mapValue.get("receiveAddress").toString()==null?"长沙市":mapValue.get("receiveAddress").toString(),"utf-8")+"&key="+key);
- SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
-
- String netValidationResult = zhongJiaoXingLu.netValidation(mapValue.get("capacityNumber").toString());
- Map netValidationMap = (Map) JSONObject.parse(netValidationResult);
- if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){
-
- HashMap<String, String> redisMap=new HashMap<>();
- redisMap.put("startLonlat", searchPoint.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint.getResult().getLocation().getLat().toString().substring(0,8));
- redisMap.put("endLonlat", searchPoint2.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint2.getResult().getLocation().getLat().toString().substring(0,8));
- redisMap.put("vclN", mapValue.get("capacityNumber").toString());
- redisMap.put("vco","2");
- SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
- String qryBtm=mapValue.get("resultOutGateTime").toString();
-
- Date parse = simpleDateFormat.parse(qryBtm);
-
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(parse);
- calendar.add(Calendar.DAY_OF_MONTH, 2);
- calendar.add(Calendar.HOUR_OF_DAY, 23);
- calendar.add(Calendar.SECOND, 45);
-
- long agetime = parse.getTime();
- long lateTime = calendar.getTimeInMillis();
-
- long reductionTime1=lateTime-agetime;
- long currentTime = new Date().getTime();
-
- long reductionTime2=currentTime-agetime;
-
- long saveTime=(reductionTime1-reductionTime2)/1000;
- redisMap.put("qryBtm", simpleDateFormat.format(simpleDateFormat.parse(qryBtm)));
- String qryEtm= simpleDateFormat.format(calendar.getTime());
- redisMap.put("qryEtm",qryEtm );
- String orderUrl=prefixOrder+":"+mapValue.get("orderNumber").toString();
- String redisJson= JSON.toJSONString(redisMap);
-
- redisTemplate.opsForValue().set(orderUrl, redisJson, saveTime, TimeUnit.SECONDS);
- redisTemplate.opsForValue().set(orderUrl+suffix, redisJson);
-
- if(mapValue.get("turnOf").toString().equals("0")){
- redisMap.put("startCode",searchPoint.getResult().getAd_info().getAdcode());
- redisMap.put("destCode",searchPoint2.getResult().getAd_info().getAdcode());
- redisMap.put("qryBtm",parse.toString());
- redisMap.put("qryEtm",calendar.getTime().toString());
- String subAbnormalLineWarnV2Json = zhongJiaoXingLu.subAbnormalLineWarnV2(redisMap);
- JSONObject jsonObject = JSONObject.parseObject(subAbnormalLineWarnV2Json);
- if (jsonObject!=null&&jsonObject.get("status").toString().equals(1001+"")) {
- HashMap<String, Object> tripMap = new HashMap();
- tripMap.put("orderNumber", mapValue.get("orderNumber").toString());
- tripMap.put("rid", jsonObject.get("result").toString());
-
- }
- }
- return CompletableFuture.completedFuture("successful");
- }
- return CompletableFuture.completedFuture("fail");
- }
-
- @Override
- public CompletableFuture<String> saveRequstionDate(Map mapValue) throws Exception {
-
- SimpleDateFormat dateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date gateTime = dateFormat.parse(mapValue.get("resultOutGateTime").toString());
- String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(mapValue.get("shipperName").toString()==null?"四川省达州钢铁集团有限责任公司":mapValue.get("shipperName").toString(),"utf-8")+"&key="+key);
- SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class);
-
- String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(mapValue.get("receiveAddress").toString()==null?"长沙市":mapValue.get("receiveAddress").toString(),"utf-8")+"&key="+key);
- SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
-
- String netValidationResult = zhongJiaoXingLu.netValidation(mapValue.get("capacityNumber").toString());
- Map netValidationMap = (Map) JSONObject.parse(netValidationResult);
- if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){
-
- HashMap<String, String> redisMap=new HashMap<>();
- redisMap.put("startLonlat", searchPoint.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint.getResult().getLocation().getLat().toString().substring(0,8));
- redisMap.put("endLonlat", searchPoint2.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint2.getResult().getLocation().getLat().toString().substring(0,8));
- redisMap.put("vclN", mapValue.get("capacityNumber").toString());
- redisMap.put("vco","2");
- SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
- String qryBtm=mapValue.get("resultOutGateTime").toString();
-
- Date parse = simpleDateFormat.parse(qryBtm);
-
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(parse);
- calendar.add(Calendar.DAY_OF_MONTH, 2);
- calendar.add(Calendar.HOUR_OF_DAY, 23);
- calendar.add(Calendar.SECOND, 45);
-
- long agetime = parse.getTime();
- long lateTime = calendar.getTimeInMillis();
-
- long reductionTime1=lateTime-agetime;
- long currentTime = new Date().getTime();
-
- long reductionTime2=currentTime-agetime;
-
- long saveTime=(reductionTime1-reductionTime2)/1000;
- redisMap.put("qryBtm", simpleDateFormat.format(simpleDateFormat.parse(qryBtm)));
- String qryEtm= simpleDateFormat.format(calendar.getTime());
- redisMap.put("qryEtm",qryEtm );
- String orderUrl=prefixOrder+":"+mapValue.get("orderNumber").toString();
- String redisJson= JSON.toJSONString(redisMap);
-
- redisTemplate.opsForValue().set(orderUrl, redisJson, saveTime, TimeUnit.SECONDS);
- redisTemplate.opsForValue().set(orderUrl+suffix, redisJson);
-
- if(mapValue.get("turnOf").toString().equals("0")){
- redisMap.put("startCode",searchPoint.getResult().getAd_info().getAdcode());
- redisMap.put("destCode",searchPoint2.getResult().getAd_info().getAdcode());
- redisMap.put("qryBtm",parse.toString());
- redisMap.put("qryEtm",calendar.getTime().toString());
- String subAbnormalLineWarnV2Json = zhongJiaoXingLu.subAbnormalLineWarnV2(redisMap);
- JSONObject jsonObject = JSONObject.parseObject(subAbnormalLineWarnV2Json);
- if (jsonObject!=null&&jsonObject.get("status").toString().equals(1001+"")) {
- HashMap<String, Object> tripMap = new HashMap();
- tripMap.put("orderNumber", mapValue.get("orderNumber").toString());
- tripMap.put("rid", jsonObject.get("result").toString());
-
- }
- }
- return CompletableFuture.completedFuture("successful");
- }
- return CompletableFuture.completedFuture("fail");
- }
- @Override
- public CompletableFuture<RouteVo> fullPathVisualization(HashMap mapValue) throws Exception {
- String redisJson =null;
- if (redisTemplate.hasKey(prefixOrder + ":" + mapValue.get("orderNumber"))){
- redisJson=(String) redisTemplate.opsForValue().get(prefixOrder + ":" + mapValue.get("orderNumber"));
- }
- HashMap routeMap = JSON.parseObject(redisJson, HashMap.class);
- String json="";
- if (routeMap!=null)
- {
- json =zhongJiaoXingLu.visualRoute(routeMap);
- }else{
- String j=prefixLine + ":" + mapValue.get("orderNumber");
- if (redisTemplate.hasKey(prefixLine + ":" + mapValue.get("orderNumber"))){
- json = (String) redisTemplate.opsForValue().get(prefixLine + ":" + mapValue.get("orderNumber"));
- }
- if (json==null||json.equals("")){
- HashMap<String,Object> hashMap=new HashMap();
- hashMap.put("orderNumber",mapValue.get("orderNumber"));
- Map<String, Object> resultMap=tmstruckLeaveFactoryResultService.getTruckFactoryResult(mapValue.get("orderNumber").toString());
-
- String netValidationResult = zhongJiaoXingLu.netValidation(resultMap.get("capacityNumber").toString());
- 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(resultMap.get("receiveAddress")==null||"".equals(String.valueOf(resultMap.get("receiveAddress")))?"长沙市":resultMap.get("receiveAddress").toString(),"utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
- SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.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);
- redisMap.put("vclN", resultMap.get("capacityNumber").toString());
- redisMap.put("vco","2");
- SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
- String qryBtm=resultMap.get("resultOutGateTime").toString();
-
- Date parse = simpleDateFormat.parse(qryBtm);
-
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(parse);
-
- calendar.add(Calendar.HOUR_OF_DAY, 23);
- calendar.add(Calendar.SECOND, 45);
-
- long agetime = parse.getTime();
- long lateTime = calendar.getTimeInMillis();
-
- long reductionTime1=lateTime-agetime;
- long currentTime = new Date().getTime();
-
- long reductionTime2=currentTime-agetime;
-
- long saveTime=(reductionTime1-reductionTime2)/1000;
- redisMap.put("qryBtm", simpleDateFormat.format(simpleDateFormat.parse(qryBtm)));
- String qryEtm= simpleDateFormat.format(calendar.getTime());
- redisMap.put("qryEtm", qryEtm);
- if (saveTime>1800){
- String orderUrl=prefixOrder+":"+mapValue.get("orderNumber").toString();
- String redisStr=JSON.toJSONString(redisMap);
- json = zhongJiaoXingLu.visualRoute(redisMap);
- redisTemplate.opsForValue().set(orderUrl, redisStr, saveTime<0?1000:saveTime, TimeUnit.SECONDS);
- redisTemplate.opsForValue().set(orderUrl+suffix, redisStr);
- }else {
-
- Calendar calendar2=Calendar.getInstance();
- long agoTime= calendar2.getTime().getTime();
- calendar2.add(Calendar.MONTH,2);
- long late= calendar2.getTime().getTime();
- long save=(lateTime-agoTime)/1000;
- json = zhongJiaoXingLu.visualRoute(redisMap);
- if (json!=null){
- redisTemplate.opsForValue().set(prefixLine+":"+mapValue.get("orderNumber").toString(), json, save>0?save:3184000, TimeUnit.SECONDS);
- }
- }
- }
- }else {
- }
- }
- JSONObject jsonObject = JSONObject.parseObject(json);
- if (json!=null&&jsonObject!=null&&jsonObject.get("status").toString().equals(1001+"")){
-
- List<StartAndEndRoute> startAndEndRouteList=new ArrayList<>();
-
- StartAndEndRoute startAndEndRoute=new StartAndEndRoute();
- ViewVisualization to= (ViewVisualization) DataConversionTool.jsonToBean(json,ViewVisualization.class);
-
- RouteVo vo=new RouteVo();
-
- if ((!StringUtils.isEmpty(to.getResult().getLat()))&& (!StringUtils.isEmpty(to.getResult().getLon()))){
- Double[] centerpoint = LngLonUtil.gps84_To_Gcj02((Double.valueOf(to.getResult().getLat()) / 600000), (Double.valueOf(to.getResult().getLon()) / 600000));
-
- Point currentPoint=new Point();
- currentPoint.setLat(centerpoint[0]+"");
- currentPoint.setLon(centerpoint[1]+"");
- startAndEndRoute.setCurrentPoint(currentPoint);
- }
-
- startAndEndRoute.setCurrentPointName(to.getResult().getAdr());
-
- if (to.getResult().getRunRoute()!=null){
- List<RunRoutePoint> routes =new ArrayList();
- List<Double[]> routesPath =new ArrayList();
- for(RunRoutePoint item : to.getResult().getRunRoute()){
- RunRoutePoint runRoutePoint=item;
-
- Double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000));
- routesPath.add(new Double[]{points[1],points[0]});
-
- runRoutePoint.setLat(points[0]+"");
- runRoutePoint.setLon(points[1]+"");
-
- routes.add(runRoutePoint);
- }
-
- Point startPoint=new Point();
- startPoint.setLat(routes.get(0).getLat());
- startPoint.setLon(routes.get(0).getLon());
- startAndEndRoute.setStartPoint(startPoint);
-
- startAndEndRoute.setRunPath(routesPath);
-
- startAndEndRoute.setRunRoute(routes);
- }
-
- if (to.getResult().getEstimateRoute()!=null){
- List<Point> estimateRoute= new ArrayList<>();
- List<Double[]> estimatePath =new ArrayList();
- for(Point item :to.getResult().getEstimateRoute()){
- Point er=new Point();
- Double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000));
- estimatePath.add(new Double[]{points[1],points[0]});
- er.setLat(points[0]+"");
- er.setLon(points[1]+"");
- estimateRoute.add(er);
- }
-
- startAndEndRoute.setEstimatePath(estimatePath);
-
- startAndEndRoute.setEndPoint(estimateRoute.get(estimateRoute.size()-1));
-
- startAndEndRoute.setEstimateRoute(estimateRoute);
- }
-
- String mil=to.getResult().getRunDistance()+"km";
- startAndEndRoute.setMiled(mil);
- startAndEndRouteList.add(startAndEndRoute);
- vo.setStartAndEndRoutes(startAndEndRouteList);
-
-
- return CompletableFuture.completedFuture(vo) ;
- }else {
- return CompletableFuture.completedFuture(new RouteVo());
- }
- }
-
- public CompletableFuture<RouteVo> fullPaht(HashMap mapValue) throws Exception {
-
- String redisJson = (String) redisTemplate.opsForValue().get(prefixOrder + ":" + mapValue.get("orderNumber"));
- HashMap routeMap = JSON.parseObject(redisJson, HashMap.class);
- String json="";
-
- if (routeMap!=null)
- {
-
- json =zhongJiaoXingLu.visualRoute(routeMap);
-
- }else{
- json = (String) redisTemplate.opsForValue().get(prefixLine + ":" + mapValue.get("orderNumber"));
-
- if (json==null){
- HashMap<String, Object> hashMap=new HashMap();
- hashMap.put("orderNumber",mapValue.get("orderNumber"));
-
- RESTfulResult startAndEndCapacityNumber =null;
- HashMap<String, Object> resultMap= (HashMap<String, Object>) startAndEndCapacityNumber.getData();
-
- String netValidationResult = zhongJiaoXingLu.netValidation(resultMap.get("capacityNumber").toString());
- 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(resultMap.get("shipperName").toString(),"utf-8")+"&key="+key);
- SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class);
- String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(resultMap.get("addressDeliveryAddress").toString(),"utf-8")+"&key="+key);
- SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
-
- HashMap<String, String> redisMap=new HashMap<>();
- redisMap.put("startLonlat", searchPoint.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint.getResult().getLocation().getLat().toString().substring(0,8));
- redisMap.put("endLonlat", searchPoint2.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint2.getResult().getLocation().getLat().toString().substring(0,8));
- redisMap.put("vclN", resultMap.get("capacityNumber").toString());
- redisMap.put("vco","2");
- SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
- String qryBtm=resultMap.get("resultOutGateTime").toString();
-
- Date parse = simpleDateFormat.parse(qryBtm);
-
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(parse);
- calendar.add(Calendar.DAY_OF_MONTH, 2);
- calendar.add(Calendar.HOUR_OF_DAY, 23);
- calendar.add(Calendar.SECOND, 45);
-
- long agetime = parse.getTime();
- long lateTime = calendar.getTimeInMillis();
-
- long reductionTime1=lateTime-agetime;
- long currentTime = new Date().getTime();
-
- long reductionTime2=currentTime-agetime;
-
- long saveTime=(reductionTime1-reductionTime2)/1000;
- redisMap.put("qryBtm", simpleDateFormat.format(simpleDateFormat.parse(qryBtm)));
- String qryEtm= simpleDateFormat.format(calendar.getTime());
- redisMap.put("qryEtm",qryEtm );
- if (saveTime>1800){
- String orderUrl=prefixOrder+":"+mapValue.get("orderNumber").toString();
- String redisStr= JSON.toJSONString(redisMap);
- redisTemplate.opsForValue().set(orderUrl, redisStr, saveTime, TimeUnit.SECONDS);
- }else {
-
- Calendar calendar2= Calendar.getInstance();
- long agoTime= calendar2.getTime().getTime();
- calendar2.add(Calendar.MONTH,2);
- long late= calendar2.getTime().getTime();
- long save=(lateTime-agoTime)/1000;
- json = zhongJiaoXingLu.visualRoute(redisMap);
- redisTemplate.opsForValue().set(prefixLine+":"+mapValue.get("orderNumber").toString(), json, save, TimeUnit.SECONDS);
- }
- }
- }
- }
-
- JSONObject jsonObject = JSONObject.parseObject(json);
- if (json!=null&&jsonObject.get("status").toString().equals(1001+"")){
-
- List<StartAndEndRoute> startAndEndRouteList=new ArrayList<>();
-
- StartAndEndRoute startAndEndRoute=new StartAndEndRoute();
- ViewVisualization to= (ViewVisualization) DataConversionTool.jsonToBean(json,ViewVisualization.class);
-
- RouteVo vo=new RouteVo();
-
- if ((!StringUtils.isEmpty(to.getResult().getLat()))&& (!StringUtils.isEmpty(to.getResult().getLon()))){
- Double[] centerpoint = LngLonUtil.gps84_To_Gcj02((Double.valueOf(to.getResult().getLat()) / 600000), (Double.valueOf(to.getResult().getLon()) / 600000));
-
- Point currentPoint=new Point();
- currentPoint.setLat(centerpoint[0]+"");
- currentPoint.setLon(centerpoint[1]+"");
- startAndEndRoute.setCurrentPoint(currentPoint);
- }
-
- startAndEndRoute.setCurrentPointName(to.getResult().getAdr());
-
- if (to.getResult().getRunRoute()!=null){
- List<RunRoutePoint> routes =new ArrayList();
- List<Double[]> routesPath =new ArrayList();
- for(RunRoutePoint item : to.getResult().getRunRoute()){
- RunRoutePoint runRoutePoint=item;
-
- Double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000));
- routesPath.add(new Double[]{points[1],points[0]});
-
- runRoutePoint.setLat(points[0]+"");
- runRoutePoint.setLon(points[1]+"");
-
- routes.add(runRoutePoint);
- }
-
- Point startPoint=new Point();
- startPoint.setLat(routes.get(0).getLat());
- startPoint.setLon(routes.get(0).getLon());
- startAndEndRoute.setStartPoint(startPoint);
-
- startAndEndRoute.setRunPath(routesPath);
-
- startAndEndRoute.setRunRoute(routes);
- }
-
- if (to.getResult().getEstimateRoute()!=null){
- List<Point> estimateRoute= new ArrayList<>();
- List<Double[]> estimatePath =new ArrayList();
- for(Point item :to.getResult().getEstimateRoute()){
- Point er=new Point();
- Double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000));
- estimatePath.add(new Double[]{points[1],points[0]});
- er.setLat(points[0]+"");
- er.setLon(points[1]+"");
- estimateRoute.add(er);
- }
-
- startAndEndRoute.setEstimatePath(estimatePath);
-
- startAndEndRoute.setEndPoint(estimateRoute.get(estimateRoute.size()-1));
-
- startAndEndRoute.setEstimateRoute(estimateRoute);
- }
-
- String mil=to.getResult().getRunDistance()+"km";
- startAndEndRoute.setMiled(mil);
- startAndEndRouteList.add(startAndEndRoute);
- vo.setStartAndEndRoutes(startAndEndRouteList);
-
-
- return CompletableFuture.completedFuture(vo) ;
- }else {
- return CompletableFuture.completedFuture(new RouteVo());
- }
- }
- @Override
- public CompletableFuture<RouteVo> fullPathVisualizationByCarNumber(HashMap mapValue) throws Exception {
- 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);
-
- 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);
- redisMap.put("vclN", mapValue.get("capacityNumber").toString());
- redisMap.put("vco","2");
- redisMap.put("qryBtm", mapValue.get("startTime").toString());
- redisMap.put("qryEtm",mapValue.get("endTime").toString());
- String json = zhongJiaoXingLu.visualRoute2(redisMap);
- JSONObject jsonObject = JSONObject.parseObject(json);
- if (json!=null&&jsonObject.get("status").toString().equals(1001+"")){
-
- List<StartAndEndRoute> startAndEndRouteList=new ArrayList<>();
-
- StartAndEndRoute startAndEndRoute=new StartAndEndRoute();
- ViewVisualization to= (ViewVisualization) DataConversionTool.jsonToBean(json,ViewVisualization.class);
-
- RouteVo vo=new RouteVo();
-
-
- if ((!StringUtils.isEmpty(to.getResult().getLat()))&& (!StringUtils.isEmpty(to.getResult().getLon()))){
- Double[] centerpoint = LngLonUtil.gps84_To_Gcj02((Double.valueOf(to.getResult().getLat()) / 600000), (Double.valueOf(to.getResult().getLon()) / 600000));
-
- Point currentPoint=new Point();
- currentPoint.setLat(centerpoint[0]+"");
- currentPoint.setLon(centerpoint[1]+"");
- startAndEndRoute.setCurrentPoint(currentPoint);
- }
-
- startAndEndRoute.setCurrentPointName(to.getResult().getAdr());
-
- if (to.getResult().getRunRoute()!=null){
- List<RunRoutePoint> routes =new ArrayList();
- List<Double[]> routesPath =new ArrayList();
- for(RunRoutePoint item : to.getResult().getRunRoute()){
- RunRoutePoint runRoutePoint=item;
-
- Double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000));
- routesPath.add(new Double[]{points[1],points[0]});
-
- runRoutePoint.setLat(points[0]+"");
- runRoutePoint.setLon(points[1]+"");
-
- routes.add(runRoutePoint);
- }
-
- Point startPoint=new Point();
- startPoint.setLat(routes.get(0).getLat());
- startPoint.setLon(routes.get(0).getLon());
- startAndEndRoute.setStartPoint(startPoint);
-
- startAndEndRoute.setRunPath(routesPath);
-
- startAndEndRoute.setRunRoute(routes);
- }
-
- String mil=to.getResult().getRunDistance()+"km";
- startAndEndRoute.setMiled(mil);
- startAndEndRouteList.add(startAndEndRoute);
- vo.setStartAndEndRoutes(startAndEndRouteList);
-
-
- return CompletableFuture.completedFuture(vo) ;
- }else {
- return CompletableFuture.completedFuture(new RouteVo());
- }
- }
- }
|