OffSiteTransportationController.java 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. package com.steerinfo.dil.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.steerinfo.dil.gaode.SearchPoint2;
  5. import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
  6. import com.steerinfo.dil.service.ITmstruckReceiptResultService;
  7. import com.steerinfo.dil.service.impl.OffSiteTransportationServiceImpl;
  8. import com.steerinfo.dil.util.BaseRESTfulController;
  9. import com.steerinfo.dil.util.ColumnDataUtil;
  10. import com.steerinfo.dil.util.DataChange;
  11. import com.steerinfo.dil.util.PageListAdd;
  12. import com.steerinfo.framework.controller.RESTfulResult;
  13. import com.steerinfo.framework.service.pagehelper.PageHelper;
  14. import com.steerinfo.route.config.ImageFileUtils;
  15. import com.steerinfo.route.service.impl.RouteServiceImpl;
  16. import com.steerinfo.route.threeRequest.ZhongJiaoXingLu;
  17. import com.steerinfo.route.util.DataConversionTool;
  18. import com.steerinfo.route.util.HTTPRequestUtils;
  19. import com.steerinfo.route.vo.FullPathVisualizationTo.ViewVisualization;
  20. import com.steerinfo.route.vo.Map.RouteVo;
  21. import com.steerinfo.route.vo.ResultWarn;
  22. import com.steerinfo.route.vo.currentLocation.CurrentLocation;
  23. import com.steerinfo.route.vo.currentLocation.CurrentLocationResult;
  24. import com.steerinfo.route.vo.resultJson.SearchPoint;
  25. import io.swagger.annotations.Api;
  26. import io.swagger.annotations.ApiImplicitParam;
  27. import io.swagger.annotations.ApiImplicitParams;
  28. import io.swagger.annotations.ApiOperation;
  29. import org.springframework.beans.factory.annotation.Autowired;
  30. import org.springframework.beans.factory.annotation.Value;
  31. import org.springframework.data.redis.core.RedisTemplate;
  32. import org.springframework.http.MediaType;
  33. import org.springframework.util.StringUtils;
  34. import org.springframework.web.bind.annotation.*;
  35. import org.springframework.web.multipart.MultipartFile;
  36. import org.springframework.web.multipart.MultipartRequest;
  37. import java.math.BigDecimal;
  38. import java.net.URLEncoder;
  39. import java.text.SimpleDateFormat;
  40. import java.util.*;
  41. import java.util.concurrent.CompletableFuture;
  42. import java.util.concurrent.TimeUnit;
  43. @Api("厂外运输接口")
  44. @RestController
  45. @RequestMapping("/${api.version}/pathDisplay")
  46. public class OffSiteTransportationController extends BaseRESTfulController {
  47. @Autowired
  48. private ITmstruckLeaveFactoryResultService tmstruckLeaveFactoryResultService;
  49. @Autowired
  50. private RouteServiceImpl routeService;
  51. @Autowired
  52. ColumnDataUtil columnDataUtil;
  53. @Autowired
  54. ImageFileUtils imageFileUtils;
  55. @Autowired
  56. private ZhongJiaoXingLu zhongJiaoXingLu;
  57. @Value("${str.tengxun.key}")
  58. private String key;
  59. @Value("${redis.prefix.order}")
  60. private String prefixOrder;
  61. @Value("${redis.prefix.line}")
  62. private String prefixLine;
  63. @Value("${redis.prefix.suffix}")
  64. private String suffix;
  65. @Autowired
  66. private RedisTemplate redisTemplate;
  67. private String gaodeTonken = "6488b963467353c2837c955cbb03104f";
  68. @Autowired
  69. ITmstruckReceiptResultService tmstruckReceiptResultService;
  70. private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  71. @Autowired
  72. OffSiteTransportationServiceImpl offSiteTransportationService;
  73. @ApiOperation("保存路径")
  74. @PostMapping("/savePath")
  75. public CompletableFuture<String> savePath() throws Exception {
  76. Map<String, Object> parem=tmstruckLeaveFactoryResultService.getTruckFactoryResult("WYSDD2022040600045906");
  77. parem.put("turnOf","0");
  78. return routeService.createTotalResult(parem);
  79. //运输订单号:orderNumber、车牌号:capacityNumber、出厂时间:resultOutGateTime、预警开关:turnOf、发货地址:shipperName、收货地址:receiveAddress
  80. //初始化请求参数
  81. // HashMap<String,Object> mapValue=new HashMap<>();
  82. // mapValue.put("orderNumber","WYSDD2021091000000001");
  83. // mapValue.put("capacityNumber","豫SB6238");
  84. // mapValue.put("resultOutGateTime","2021-11-17 14:20:19");
  85. // mapValue.put("turnOf","0");
  86. // mapValue.put("shipperName","四川达州钢铁集团有限");
  87. // mapValue.put("receiveAddress","长沙市");
  88. // return routeService.createTotalResult(mapValue);
  89. }
  90. @ApiOperation("全路径查询")
  91. @PostMapping("/fullPath")
  92. public RESTfulResult fullPath(String orderNumber) throws Exception {
  93. //运输订单号:orderNumber、车牌号:capacityNumber、出厂时间:resultOutGateTime、预警开关:turnOf、发货地址:shipperName、收货地址:receiveAddress
  94. //初始化请求参数
  95. //判断订单是否可以查看路径
  96. // int watch = offSiteTransportationService.checkOrder(orderNumber);
  97. // if (watch==1){
  98. HashMap<String,Object> mapValue=new HashMap<>();
  99. mapValue.put("orderNumber",orderNumber);
  100. return success(routeService.fullPathVisualization(mapValue).get());
  101. // }else {
  102. // return failed("-1");
  103. // }
  104. }
  105. @ApiOperation("查询在途运输")
  106. @ApiImplicitParams({
  107. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  108. @ApiImplicitParam(name = "apiId", value = "动态表头", required = false, dataType = "Integer"),
  109. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  110. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer")
  111. })
  112. @PostMapping("/getInTransitTransportation")
  113. public RESTfulResult getInTransitTransportation(@RequestBody Map<String,Object> mapValue,
  114. @RequestParam(required = true,defaultValue = "468",name = "apiId")Integer apiId,
  115. @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum,
  116. @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize
  117. )
  118. {
  119. if(mapValue.containsKey("startTime")&&mapValue.containsKey("endTime")){
  120. Date startDate=new Date(Long.parseLong(mapValue.get("startTime").toString())) ;
  121. Date endDate=new Date(Long.parseLong(mapValue.get("endTime").toString())) ;
  122. Calendar ca = Calendar.getInstance();
  123. ca.setTime(endDate);
  124. ca.add(Calendar.DATE,1);
  125. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  126. String startTime1=simpleDateFormat.format(startDate);
  127. String endTime1=simpleDateFormat.format(ca.getTime());
  128. mapValue.replace("startTime",startTime1);
  129. mapValue.replace("endTime",endTime1);
  130. }else {
  131. Date startDate=new Date() ;
  132. Date endDate=new Date() ;
  133. Calendar ca = Calendar.getInstance();
  134. ca.setTime(endDate);
  135. ca.add(Calendar.DATE,1);
  136. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  137. String startTime1=simpleDateFormat.format(startDate);
  138. String endTime1=simpleDateFormat.format(ca.getTime());
  139. mapValue.put("startTime",startTime1);
  140. mapValue.put("endTime",endTime1);
  141. }
  142. //执行中
  143. mapValue.put("orderStatus",5);
  144. List<Map<String,Object>> filter= offSiteTransportationService.getInTransitTransportation(mapValue);
  145. PageHelper.startPage(pageNum, pageSize);
  146. List<Map<String,Object>> list= offSiteTransportationService.getInTransitTransportation(mapValue);
  147. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, filter,list);
  148. return success(pageList);
  149. }
  150. @ApiOperation("有异常")
  151. @ApiImplicitParams({
  152. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  153. @ApiImplicitParam(name = "apiId", value = "动态表头", required = false, dataType = "Integer"),
  154. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  155. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer")
  156. })
  157. @PostMapping("/getHaveAbnormalTruckOrderInfo")
  158. public RESTfulResult getHaveAbnormalTruckOrderInfo(@RequestBody Map<String,Object> mapValue,
  159. @RequestParam(required = true,defaultValue = "468",name = "apiId")Integer apiId,
  160. @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum,
  161. @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize
  162. )
  163. {
  164. if(mapValue.containsKey("startTime")&&mapValue.containsKey("endTime")){
  165. Date startDate=new Date(Long.parseLong(mapValue.get("startTime").toString())) ;
  166. Date endDate=new Date(Long.parseLong(mapValue.get("endTime").toString())) ;
  167. Calendar ca = Calendar.getInstance();
  168. ca.setTime(endDate);
  169. ca.add(Calendar.DATE,1);
  170. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  171. String startTime1=simpleDateFormat.format(startDate);
  172. String endTime1=simpleDateFormat.format(ca.getTime());
  173. mapValue.replace("startTime",startTime1);
  174. mapValue.replace("endTime",endTime1);
  175. }else {
  176. Date startDate=new Date() ;
  177. Date endDate=new Date() ;
  178. Calendar ca = Calendar.getInstance();
  179. ca.setTime(endDate);
  180. ca.add(Calendar.DATE,1);
  181. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  182. String startTime1=simpleDateFormat.format(startDate);
  183. String endTime1=simpleDateFormat.format(ca.getTime());
  184. mapValue.put("startTime",startTime1);
  185. mapValue.put("endTime",endTime1);
  186. }
  187. if (mapValue.containsKey("abnormalType")&&mapValue.get("abnormalType")!=null){
  188. switch(mapValue.get("abnormalType").toString()){
  189. case "其他":
  190. mapValue.put("abnormalType","0");
  191. break;
  192. case "偏离":
  193. mapValue.put("abnormalType","1");
  194. break;
  195. case "停车":
  196. mapValue.put("abnormalType","2");
  197. break;
  198. case "离线":
  199. mapValue.put("abnormalType","3");
  200. break;
  201. default:
  202. mapValue.remove("abnormalType");
  203. break;
  204. }
  205. }
  206. List<Map<String,Object>> filter= offSiteTransportationService.getHaveAbnormalTruckOrderInfo(mapValue);
  207. PageHelper.startPage(pageNum, pageSize);
  208. List<Map<String,Object>> list= offSiteTransportationService.getHaveAbnormalTruckOrderInfo(mapValue);
  209. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, filter,list);
  210. return success(pageList);
  211. }
  212. @ApiOperation("查询在途运输")
  213. @ApiImplicitParams({
  214. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  215. @ApiImplicitParam(name = "apiId", value = "动态表头", required = false, dataType = "Integer"),
  216. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  217. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer")
  218. })
  219. @PostMapping("/getFinishTruckOrderInfo")
  220. public RESTfulResult getFinishTruckOrderInfo(@RequestBody Map<String,Object> mapValue,
  221. @RequestParam(required = true,defaultValue = "468",name = "apiId")Integer apiId,
  222. @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum,
  223. @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize
  224. )
  225. {
  226. if(mapValue.containsKey("startTime")&&mapValue.containsKey("endTime")){
  227. Date startDate=new Date(Long.parseLong(mapValue.get("startTime").toString())) ;
  228. Date endDate=new Date(Long.parseLong(mapValue.get("endTime").toString())) ;
  229. Calendar ca = Calendar.getInstance();
  230. ca.setTime(endDate);
  231. ca.add(Calendar.DATE,1);
  232. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  233. String startTime1=simpleDateFormat.format(startDate);
  234. String endTime1=simpleDateFormat.format(ca.getTime());
  235. mapValue.replace("startTime",startTime1);
  236. mapValue.replace("endTime",endTime1);
  237. }else {
  238. Date startDate=new Date() ;
  239. Date endDate=new Date() ;
  240. Calendar ca = Calendar.getInstance();
  241. ca.setTime(endDate);
  242. ca.add(Calendar.DATE,1);
  243. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  244. String startTime1=simpleDateFormat.format(startDate);
  245. String endTime1=simpleDateFormat.format(ca.getTime());
  246. mapValue.put("startTime",startTime1);
  247. mapValue.put("endTime",endTime1);
  248. }
  249. //已经完成
  250. mapValue.put("orderStatus",2);
  251. List<Map<String,Object>> filter= offSiteTransportationService.getInTransitTransportation(mapValue);
  252. PageHelper.startPage(pageNum, pageSize);
  253. List<Map<String,Object>> list= offSiteTransportationService.getInTransitTransportation(mapValue);
  254. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, filter,list);
  255. return success(pageList);
  256. }
  257. @PostMapping(value = "/addTmstruckReceiptResult" )
  258. public synchronized RESTfulResult addTmstruckReceiptResult(@RequestBody Map<String,Object> value , Integer num, String orderNumber, String resultArrivalAddress, Integer imgcount3, Integer imgcount4) throws Exception {
  259. Map<String,Object> map = new HashMap<String,Object>();
  260. map.put("orderNumber",orderNumber);
  261. map.put("resultArrivalAddress",resultArrivalAddress);
  262. Integer orderStatus = offSiteTransportationService.getOrderStatus(map);
  263. //判断是否已经结束
  264. if (orderStatus!=null&&orderStatus==2){
  265. return failed(-3);
  266. }
  267. map.putAll(value);
  268. //添加入库实绩
  269. Integer resTfulResult = offSiteTransportationService.addTmstruckReceiptResult(map);
  270. if (resTfulResult!=4){
  271. //保存路线
  272. String redisJson = (String) redisTemplate.opsForValue().get(prefixOrder+":"+orderNumber);
  273. HashMap mapValue = JSON.parseObject(redisJson, HashMap.class);
  274. String json = zhongJiaoXingLu.visualRoute(mapValue);
  275. ViewVisualization to=null;
  276. if (json!=null){
  277. //设置60天后过期
  278. Calendar calendar=Calendar.getInstance();
  279. long agoTime= calendar.getTime().getTime();
  280. calendar.add(Calendar.MONTH,2);
  281. long lateTime= calendar.getTime().getTime();
  282. long saveTime=(lateTime-agoTime)/1000;
  283. redisTemplate.opsForValue().set(prefixLine+":"+orderNumber, json, saveTime, TimeUnit.SECONDS);
  284. //删除订单
  285. redisTemplate.delete(prefixOrder+":"+orderNumber);
  286. redisTemplate.delete(prefixOrder+":"+orderNumber+suffix);
  287. //添加运输距离
  288. to= (ViewVisualization) JSON.parseObject(json,ViewVisualization.class);
  289. }else {
  290. HashMap<String,Object> hashMap=new HashMap();
  291. hashMap.put("orderNumber",orderNumber);
  292. Map<String,Object> resultMap= offSiteTransportationService.getStartAndEndCapacityNumber(hashMap);
  293. if (resultMap!=null){
  294. json= getPathJSON(resultMap.get("capacityNumber").toString(),resultMap.get("resultOutGateTime").toString());
  295. if (json!=null&&!json.equals("")){
  296. to= (ViewVisualization) JSON.parseObject(json,ViewVisualization.class);
  297. }
  298. }
  299. }
  300. //设置运输距离,并且结束订单
  301. if (to!=null&&to.getResult()!=null&&to.getResult().getRunDistance()!=null){
  302. Map<String,Object> ordermap=new HashMap<>();
  303. ordermap.put("orderNumber",orderNumber);
  304. ordermap.put("orderMileage",to.getResult().getRunDistance()==null?"1":to.getResult().getRunDistance());
  305. offSiteTransportationService.insertOrderMileage(ordermap);
  306. }else {
  307. if (to!=null&&to.getStatus()==1006){
  308. Map<String,Object> ordermap=new HashMap<>();
  309. ordermap.put("orderNumber",orderNumber);
  310. ordermap.put("orderMileage","-1");
  311. offSiteTransportationService.insertOrderMileage(ordermap);
  312. }else if (to!=null&&to.getStatus()==1001){
  313. Map<String,Object> ordermap=new HashMap<>();
  314. ordermap.put("orderNumber",orderNumber);
  315. ordermap.put("orderMileage","1");
  316. offSiteTransportationService.insertOrderMileage(ordermap);
  317. } else {
  318. Map<String,Object> ordermap=new HashMap<>();
  319. ordermap.put("orderNumber",orderNumber);
  320. ordermap.put("orderMileage","-1");
  321. offSiteTransportationService.insertOrderMileage(ordermap);
  322. }
  323. }
  324. //关闭运输订单
  325. offSiteTransportationService.orderClose(orderNumber);
  326. }
  327. return success(resTfulResult);
  328. }
  329. //如果内容丢失重新获得
  330. public String getPathJSON(String capacityNumber,String resultOutGateTime) throws Exception {
  331. //入网验证
  332. String netValidationResult = zhongJiaoXingLu.netValidation(capacityNumber);
  333. Map netValidationMap = (Map) JSONObject.parse(netValidationResult);
  334. if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){
  335. String searchPointJson = HTTPRequestUtils.sendGet("https://restapi.amap.com/v3/geocode/geo", "address="+ URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key="+gaodeTonken);
  336. SearchPoint2 searchPoint= JSON.parseObject(searchPointJson, SearchPoint2.class);
  337. String searchPointJson2 = HTTPRequestUtils.sendGet("https://restapi.amap.com/v3/geocode/geo", "address="+URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key="+gaodeTonken);
  338. SearchPoint2 searchPoint2= JSON.parseObject(searchPointJson2, SearchPoint2.class);
  339. //运单生成之后保存
  340. HashMap<String,String> redisMap=new HashMap<>();
  341. String location = searchPoint.getGeocodes().get(0).getLocation();
  342. String[] split = StringUtils.split(location, ",");
  343. String Lng = split[0];
  344. String Lat = split[1];
  345. redisMap.put("startLonlat", Lng.substring(0, 9) + "," + Lat.substring(0, 8));
  346. String location2 = searchPoint2.getGeocodes().get(0).getLocation();
  347. String[] split2 = StringUtils.split(location2, ",");
  348. String Lng2 = split2[0];
  349. String Lat2 = split2[1];
  350. redisMap.put("endLonlat", Lng2.substring(0, 9) + "," + Lat2.substring(0, 8));
  351. redisMap.put("vclN", capacityNumber);
  352. redisMap.put("vco","2");
  353. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
  354. String qryBtm=resultOutGateTime;
  355. //获得23小时、45分钟之后的时间
  356. Date parse = simpleDateFormat.parse(qryBtm);
  357. //时间添加
  358. Calendar calendar = Calendar.getInstance();
  359. calendar.setTime(parse);
  360. calendar.add(Calendar.HOUR_OF_DAY, 23);
  361. calendar.add(Calendar.SECOND, 45);
  362. redisMap.put("qryBtm", qryBtm);
  363. redisMap.put("qryEtm",simpleDateFormat.format(calendar.getTime()));
  364. System.out.println(redisMap);
  365. String json = zhongJiaoXingLu.visualRoute(redisMap);
  366. System.out.println(json.length()>100?json.substring(0,100):json);
  367. return json;
  368. }
  369. return null;
  370. }
  371. public String removeData(){
  372. offSiteTransportationService.removeDate();
  373. return "success";
  374. }
  375. /**查询是否开启运输报警状态
  376. * warnSwitch
  377. * @param
  378. * @return
  379. */
  380. @ApiOperation(value="查询是否开启运输报警状态")
  381. @ApiImplicitParams({
  382. })
  383. @PostMapping(value = "/selectWarnSwitch")
  384. public RESTfulResult selectWarnSwitch() {
  385. Map<String,Object> warnSwitch = offSiteTransportationService.selectWarnSwitch();
  386. return success(warnSwitch);
  387. }
  388. /**是否开启运输报警状态
  389. * warnSwitchaddTmstruckTotalResult
  390. * @param
  391. * @returninTransitOrderMileage
  392. */
  393. @ApiOperation(value="是否开启运输报警状态")
  394. @ApiImplicitParams({
  395. @ApiImplicitParam(name = "warnSwitch", value = "运输报警状态", required = false, dataType = "String")
  396. })
  397. @PostMapping(value = "/inTransitWarn")
  398. public RESTfulResult inTransitWarn(@RequestParam String warnSwitch,@RequestParam String radio) {
  399. int i = offSiteTransportationService.updateWarnSwitch(warnSwitch,radio);
  400. return success(i);
  401. }
  402. @PostMapping("/abnormalLineWarn")
  403. public String abnormalLineWarn(@RequestParam(value = "data") String data) throws Exception {
  404. ResultWarn resultWarn= (ResultWarn) JSON.parseObject(data, ResultWarn.class);
  405. Map<String, Object> map= DataConversionTool.objectToMap(resultWarn);
  406. int i= offSiteTransportationService.addTransportationAlarm(map);
  407. return "success";
  408. }
  409. @PostMapping("/parkWarn")
  410. public String parkWarn(@RequestParam(value = "data",required = false) String data) throws Exception {
  411. ResultWarn resultWarn= (ResultWarn) JSON.parseObject(data, ResultWarn.class);
  412. Map<String, Object> map= DataConversionTool.objectToMap(resultWarn);
  413. int i=offSiteTransportationService.addTransportationAlarm(map);
  414. return "success";
  415. }
  416. @PostMapping("/offLineWarn")
  417. public String offLineWarn(@RequestParam(value = "data") String data) throws Exception {
  418. ResultWarn resultWarn= (ResultWarn) JSON.parseObject(data, ResultWarn.class);
  419. Map<String, Object> map= DataConversionTool.objectToMap(resultWarn);
  420. int i=offSiteTransportationService.addTransportationAlarm(map);
  421. return "success";
  422. }
  423. @ApiOperation(value="展示运输在途异常信息")
  424. @ApiImplicitParams({
  425. @ApiImplicitParam(name = "apiId(472)", value = "表头", required = false, dataType = "Interger")
  426. })
  427. @PostMapping("/getTransportAbnormalInfo")
  428. public RESTfulResult getTransportAbnormalInfo(@RequestBody(required=false) Map<String,Object> mapValue,
  429. @RequestParam(name = "apiId",defaultValue = "472") Integer apiId,
  430. @RequestParam(name = "pageNum") Integer pageNum,
  431. @RequestParam(name = "pageSize") Integer pageSize){
  432. List<Map<String, Object>> transportAbnormalInfo = offSiteTransportationService.getTransportAbnormalInfo(mapValue);
  433. PageHelper.startPage(pageNum,pageSize);
  434. List<Map<String, Object>> transportAbnormalInfo1 = offSiteTransportationService.getTransportAbnormalInfo(mapValue);
  435. PageListAdd pageList = columnDataUtil.tableColumnData(apiId,transportAbnormalInfo,transportAbnormalInfo1);
  436. return success(pageList);
  437. }
  438. @ApiOperation(value="查询路径")
  439. @ApiImplicitParams({
  440. @ApiImplicitParam(name = "mapValue", value = "查询条件", required = false, dataType = "HashMap")
  441. })
  442. @PostMapping("/fullPathVisualizationByCarNumber")
  443. public RESTfulResult fullPathVisualizationByCarNumber(@RequestBody HashMap mapValue) throws Exception {
  444. //判断是否自提
  445. /*int count = offSiteTransportationService.isSelfMention(mapValue.get("capacityNumber").toString());
  446. if (count==0){*/
  447. CompletableFuture<RouteVo> createOrder =routeService.fullPathVisualizationByCarNumber(mapValue);
  448. return success(createOrder.get());
  449. /* }else {
  450. return failed(-1);
  451. }*/
  452. }
  453. @ApiOperation(value="展示抵达实绩信息")
  454. @ApiImplicitParams({
  455. @ApiImplicitParam(name = "apiId(470)", value = "表头", required = false, dataType = "Interger")
  456. })
  457. @PostMapping("/getReceiptResult")
  458. public RESTfulResult getReceiptResult(@RequestBody(required=false) Map<String, Object> mapValue,
  459. Integer apiId,
  460. Integer pageNum,
  461. Integer pageSize,
  462. String startTime,
  463. String endTime,
  464. String con){
  465. if (con != null && (con.equals("") || con.equals("undefined")) ) {
  466. con = null;
  467. }
  468. if (con != null && con.length() != 0) {
  469. mapValue.put("con","%" + con + "%");
  470. }
  471. DataChange.queryDataByDateTime(startTime, endTime, mapValue, sdfDateTime);
  472. PageHelper.startPage(pageNum,pageSize);
  473. List<Map<String, Object>> receiptResultInfo = tmstruckReceiptResultService.getReceiptResultInfo(mapValue);
  474. PageListAdd pageList = columnDataUtil.tableColumnData(apiId,null,receiptResultInfo);
  475. return success(pageList);
  476. }
  477. @PostMapping("/createTotalResult")
  478. public RESTfulResult createTotalResult(@RequestBody(required=true) Map<String, Object> mapValue) throws Exception {
  479. //判断是否自提
  480. int count = offSiteTransportationService.isSelfMention(mapValue.get("capacityNumber").toString());
  481. if (count==0){
  482. CompletableFuture<String> totalResult = routeService.createTotalResult(mapValue);
  483. return success(totalResult);
  484. }else {
  485. return failed(-1);
  486. }
  487. }
  488. @GetMapping("/getCurrentLocation")
  489. public RESTfulResult getCurrentLocation(@RequestParam("capcityNumber") String capcityNumber) throws Exception {
  490. CurrentLocationResult currentLocationResult = routeService.getCurrentLocation(capcityNumber);
  491. return success(currentLocationResult);
  492. }
  493. //在途订单列表
  494. @PostMapping("/transportationPerformance")
  495. public RESTfulResult transportationPerformance(@RequestBody Map<String,Object> mapValue,
  496. @RequestParam(required = true,defaultValue = "479",name = "apiId")Integer apiId,
  497. @RequestParam(required = false,name = "pageNum")Integer pageNum,
  498. @RequestParam(required = false,name = "pageSize")Integer pageSize){
  499. if(mapValue.containsKey("startTime")&&mapValue.containsKey("endTime")){
  500. Date startDate=new Date(Long.parseLong(mapValue.get("startTime").toString())) ;
  501. Date endDate=new Date(Long.parseLong(mapValue.get("endTime").toString())) ;
  502. Calendar ca = Calendar.getInstance();
  503. ca.setTime(endDate);
  504. ca.add(Calendar.DATE,1);
  505. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  506. String startTime1=simpleDateFormat.format(startDate);
  507. String endTime1=simpleDateFormat.format(ca.getTime());
  508. mapValue.replace("startTime",startTime1);
  509. mapValue.replace("endTime",endTime1);
  510. }else {
  511. Date startDate=new Date() ;
  512. Date endDate=new Date() ;
  513. Calendar ca = Calendar.getInstance();
  514. ca.setTime(endDate);
  515. ca.add(Calendar.DATE,1);
  516. SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  517. String startTime1=simpleDateFormat.format(startDate);
  518. String endTime1=simpleDateFormat.format(ca.getTime());
  519. mapValue.put("startTime",startTime1);
  520. mapValue.put("endTime",endTime1);
  521. }
  522. //执行中
  523. List<Map<String,Object>> filter= offSiteTransportationService.transportationPerformance(mapValue);
  524. PageHelper.startPage(pageNum, pageSize);
  525. List<Map<String,Object>> list= offSiteTransportationService.transportationPerformance(mapValue);
  526. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, filter,list);
  527. return success(pageList);
  528. }
  529. @GetMapping("/getLocationForAddress")
  530. public RESTfulResult getAddress(@RequestParam("address") String address) {
  531. try{
  532. return success(routeService.getLocationForAddress(address));
  533. }catch (Exception e){
  534. e.printStackTrace();
  535. return failed("没有查询到地址!请检查输入");
  536. }
  537. }
  538. }