OTMSController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. package com.steerinfo.dil.controller;
  2. import com.steerinfo.dil.config.ImageFileUtils;
  3. import com.steerinfo.dil.feign.OtmsFeign;
  4. import com.steerinfo.dil.feign.TmsTruckFeign;
  5. import com.steerinfo.dil.util.PageListAdd;
  6. import com.steerinfo.dil.util.SaleLogUtil;
  7. import com.steerinfo.framework.controller.RESTfulResult;
  8. import com.steerinfo.framework.service.pagehelper.PageHelper;
  9. import io.swagger.annotations.ApiImplicitParam;
  10. import io.swagger.annotations.ApiImplicitParams;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.http.MediaType;
  14. import org.springframework.util.MultiValueMap;
  15. import org.springframework.web.bind.annotation.*;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import org.springframework.web.multipart.MultipartRequest;
  18. import java.awt.*;
  19. import java.io.File;
  20. import java.util.ArrayList;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. @RestController
  25. @RequestMapping("${api.version}/otms")
  26. public class OTMSController {
  27. @Autowired
  28. private OtmsFeign otmsFeign;
  29. @Autowired
  30. private ImageFileUtils imageFileUtils;
  31. @Autowired
  32. private SaleLogUtil saleLogUtil;
  33. @ApiOperation(value="全路径展示接口")
  34. @PostMapping("/fullPath")
  35. public Object fullPath(@RequestParam("orderNumber") String orderNumber) throws Exception {
  36. return otmsFeign.fullPath(orderNumber);
  37. }
  38. @ApiOperation(value = "在途订单列表")
  39. @PostMapping("/getInTransitTransportation")
  40. public RESTfulResult getInTransitTransportation(@RequestBody(required=false) Map<String,Object> mapValue,
  41. @RequestParam(required = true,defaultValue = "468",name = "apiId")Integer apiId,
  42. @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum,
  43. @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize
  44. )
  45. {
  46. return otmsFeign.getInTransitTransportation(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize);
  47. }
  48. @ApiOperation(value = "有异常订单列表")
  49. @PostMapping("/getHaveAbnormalTruckOrderInfo")
  50. public RESTfulResult getHaveAbnormalTruckOrderInfo(@RequestBody(required=false) Map<String,Object> mapValue,
  51. @RequestParam(required = true,defaultValue = "468",name = "apiId")Integer apiId,
  52. @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum,
  53. @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize
  54. )
  55. {
  56. return otmsFeign.getHaveAbnormalTruckOrderInfo(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize);
  57. }
  58. @ApiOperation("已完成订单列表")
  59. @ApiImplicitParams({
  60. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  61. @ApiImplicitParam(name = "apiId", value = "动态表头", required = false, dataType = "Integer"),
  62. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  63. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer")
  64. })
  65. @PostMapping("/getFinishTruckOrderInfo")
  66. public RESTfulResult getFinishTruckOrderInfo(@RequestBody(required = false) Map<String,Object> mapValue,
  67. @RequestParam(required = false,defaultValue = "468",name = "apiId")Integer apiId,
  68. @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum,
  69. @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize
  70. ){
  71. return otmsFeign.getFinishTruckOrderInfo(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize);
  72. }
  73. @ApiOperation(value = "新增抵达")
  74. @PostMapping(value = "/addtmstruckArrivalResult")
  75. public RESTfulResult addtmstruckArrivalResult(@RequestParam("orderNumber") String orderNumber, @RequestParam("resultArrivalAddress")String resultArrivalAddress, Long arrivalTime,String userName, MultipartRequest request) throws Exception {
  76. //添加到files数组
  77. List<MultipartFile> files = new ArrayList<>();
  78. int index=-1;
  79. for(int i=0;i<21;i++){
  80. MultipartFile file = request.getFile("file"+i);
  81. if(file!=null){
  82. files.add(file);
  83. if(index<0){
  84. index=i;
  85. }
  86. }
  87. }
  88. //没有上传,当做重复上传
  89. if(files.size() == 0){
  90. return new RESTfulResult("201","请勿重复上传!","请勿重复上传!");
  91. }
  92. //上传图片,拼接在一个url里
  93. Map<String,Object> mapValue=new HashMap<>();
  94. String url="";
  95. try{
  96. //如果存在预览图片,查询,把那个位置的图片截取下来
  97. if(index > 0){
  98. String[] arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber).split(";");
  99. for(int i=0;i<index;i++){
  100. url=url+arrivalPhoto[i]+";";
  101. }
  102. }
  103. }catch (Exception e){
  104. }
  105. //上传图片
  106. for (int i=0;i<files.size();i++){
  107. MultipartFile file=files.get(i);
  108. url += imageFileUtils.updateFile(file,i)+';';
  109. }
  110. mapValue.put("url",url);
  111. mapValue.put("arrivalTime",arrivalTime);
  112. RESTfulResult result = otmsFeign.addtmstruckArrivalResult(mapValue,orderNumber,resultArrivalAddress,url);
  113. if(userName!=null){
  114. //记录日志
  115. saleLogUtil.logOrder(orderNumber,"网页端操作抵达签收",userName,SaleLogUtil.UPDATE);
  116. }
  117. return result;
  118. }
  119. @ApiOperation(value = "新增签收")
  120. @PostMapping(value = "/addTmstruckReceiptResult")
  121. public synchronized RESTfulResult addTmstruckReceiptResult(MultipartRequest request, Integer num, String orderNumber, String resultArrivalAddress, Integer imgcount3, Integer imgcount4) throws Exception {
  122. //添加到files数组
  123. List<MultipartFile> files = new ArrayList<>();
  124. for(int i=0;i<21;i++){
  125. MultipartFile file = request.getFile("file"+i);
  126. if(file!=null){
  127. files.add(file);
  128. }else{
  129. break;
  130. }
  131. }
  132. if(files.size()<2){
  133. return new RESTfulResult("201","至少上传两张图片!","至少上传两张图片!");
  134. }
  135. //上传图片,拼接在一个url里
  136. Map<String,Object> mapValue=new HashMap<>();
  137. String url="";
  138. for (int i=0;i<files.size();i++){
  139. MultipartFile file=files.get(i);
  140. url += imageFileUtils.updateFile(file,i)+';';
  141. }
  142. mapValue.put("url",url);
  143. return otmsFeign.addTmstruckReceiptResult(mapValue,orderNumber,resultArrivalAddress);
  144. }
  145. @ApiOperation(value = "新增签收网页端")
  146. @PostMapping(value = "/addTmstruckReceiptResultForWeb")
  147. public synchronized RESTfulResult addTmstruckReceiptResultForWeb(MultipartRequest request,Long receiptTime, String orderNumber, String resultArrivalAddress) throws Exception {
  148. //添加到files数组
  149. List<MultipartFile> files = new ArrayList<>();
  150. int index=-1;
  151. for(int i=0;i<21;i++){
  152. MultipartFile file = request.getFile("file"+i);
  153. if(file!=null){
  154. files.add(file);
  155. if(index<0){
  156. index=i;
  157. }
  158. }
  159. }
  160. //没有上传,当做重复上传
  161. if(files.size() == 0){
  162. return new RESTfulResult("201","若要重复上传,必须两张都是新图片!","请勿重复上传!");
  163. }
  164. //上传图片,拼接在一个url里
  165. Map<String,Object> mapValue=new HashMap<>();
  166. String url="";
  167. try{
  168. //如果存在预览图片,查询,把那个位置的图片截取下来
  169. if(index > 0){
  170. String[] receivePhoto=otmsFeign.getReceivingPhotoByUrl(orderNumber).split(";");
  171. for(int i=0;i<index;i++){
  172. url=url+receivePhoto[i]+";";
  173. }
  174. }
  175. }catch (Exception e){
  176. }
  177. //上传图片
  178. for (int i=0;i<files.size();i++){
  179. MultipartFile file=files.get(i);
  180. url += imageFileUtils.updateFile(file,i)+';';
  181. }
  182. mapValue.put("url",url);
  183. mapValue.put("receiptTime",receiptTime);
  184. return otmsFeign.addTmstruckReceiptResult(mapValue,orderNumber,resultArrivalAddress);
  185. }
  186. @ApiOperation(value="查询当前报警类型")
  187. @PostMapping(value = "/selectWarnSwitch")
  188. public RESTfulResult selectWarnSwitch(){
  189. return otmsFeign.selectWarnSwitch();
  190. }
  191. @ApiOperation(value="是否开启运输报警状态")
  192. @ApiImplicitParams({
  193. @ApiImplicitParam(name = "warnSwitch", value = "运输报警状态", required = false, dataType = "String")
  194. })
  195. @PostMapping(value = "/inTransitWarn")
  196. public RESTfulResult inTransitWarn(@RequestParam String warnSwitch,@RequestParam String radio){
  197. return otmsFeign.inTransitWarn(warnSwitch,radio);
  198. }
  199. @ApiOperation(value="获得异常信息")
  200. @PostMapping("/getTransportAbnormalInfo")
  201. public RESTfulResult getTransportAbnormalInfo(@RequestBody(required=false) Map<String,Object> mapValue,
  202. @RequestParam(name = "apiId",defaultValue = "472") Integer apiId,
  203. @RequestParam(name = "pageNum") Integer pageNum,
  204. @RequestParam(name = "orderNumbers") String orderNumbers,
  205. @RequestParam(name = "pageSize") Integer pageSize){
  206. mapValue=mapValue!=null?mapValue:new HashMap<>();
  207. mapValue.put("orderNumbers",orderNumbers);
  208. return otmsFeign.getTransportAbnormalInfo(mapValue,apiId,pageNum,pageSize);
  209. }
  210. @ApiOperation(value="车牌号和时间查询路径")
  211. @PostMapping("/fullPathVisualizationByCarNumber")
  212. public Object fullPathVisualizationByCarNumber(@RequestBody HashMap mapValue) throws Exception{
  213. return otmsFeign.fullPathVisualizationByCarNumber(mapValue);
  214. }
  215. @ApiOperation("厂外抵达作业")
  216. @PostMapping("/getArrivalResult")
  217. public Map<String,Object> getArrivalResult(@RequestBody(required = false) Map<String,Object> mapValue,
  218. Integer apiId,
  219. Integer pageNum,
  220. Integer pageSize,
  221. String con,
  222. String startTime,
  223. String endTime){
  224. return otmsFeign.getArrivalResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime);
  225. }
  226. @ApiOperation("查询抵达图片")
  227. @PostMapping("/getArrivalPhoto")
  228. public List<String> getArrivalPhoto(@RequestParam String orderNumber) throws Exception{
  229. try{
  230. String arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber);
  231. return getPhotoByUrl(arrivalPhoto);
  232. }catch (Exception e){
  233. return null;
  234. }
  235. }
  236. @ApiOperation("厂外抵达作业")
  237. @PostMapping("/getReceiptResult")
  238. public Map<String,Object> getReceiptResult(@RequestBody(required = false) Map<String,Object> mapValue,
  239. Integer apiId,
  240. Integer pageNum,
  241. Integer pageSize,
  242. String con,
  243. String startTime,
  244. String endTime){
  245. return otmsFeign.getReceiptResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime);
  246. }
  247. @ApiOperation("查询签收图片")
  248. @PostMapping("/getReceivingPhotoByUrl")
  249. public List<String> getReceivingPhotoByUrl(@RequestParam String orderNumber) throws Exception {
  250. try{
  251. String receivePhoto=otmsFeign.getReceivingPhotoByUrl(orderNumber);
  252. return getPhotoByUrl(receivePhoto);
  253. }catch (Exception e){
  254. return null;
  255. }
  256. }
  257. //切割字符串,下载图片并返回
  258. private List<String> getPhotoByUrl(String urls) throws Exception {
  259. List<String> results=new ArrayList<>();
  260. String files[]=urls.split(";");
  261. for(int i=0;i<files.length && files[i].length()>5;i++){
  262. results.add((String)imageFileUtils.downloadFile(files[i]));
  263. }
  264. return results;
  265. }
  266. @GetMapping("/getCurrentLocation")
  267. public RESTfulResult getCurrentLocation(@RequestParam("capcityNumber") String capcityNumber) throws Exception{
  268. return otmsFeign.getCurrentLocation(capcityNumber);
  269. }
  270. //获取地图顶点
  271. @GetMapping(value = "/mapvertexs/findAllAvailableVertex")
  272. public RESTfulResult findAllAvailableVertex(){
  273. return otmsFeign.findAllAvailableVertex();
  274. }
  275. //获取最佳路径
  276. @GetMapping(value = "/mapvertexs/getObtainTheOptimalPath")
  277. public RESTfulResult getObtainTheOptimalPath(@RequestParam("startPoint") String startPoint,@RequestParam("endPoint") String endPoint) throws Exception{
  278. return otmsFeign.getObtainTheOptimalPath(startPoint,endPoint);
  279. }
  280. @ApiOperation(value="获取当前订单导航路径")
  281. @GetMapping(value = "/mapvertexs/getPathByOrderID")
  282. public RESTfulResult getPathByOrderID(@RequestParam("orderId") String orderId,@RequestParam("startStep") String startStep,@RequestParam("endStep") String endStep) throws Exception {
  283. return otmsFeign.getPathByOrderID(orderId,startStep,endStep);
  284. }
  285. @ApiOperation(value="查询所有可选地点")
  286. @GetMapping(value = "/mapvertexs/findSelections")
  287. public RESTfulResult findSelections(){
  288. return otmsFeign.findSelections();
  289. }
  290. @ApiOperation(value="查询点")
  291. @PostMapping(value = "/getMapVertex")
  292. public RESTfulResult getMapVertex(@RequestBody Map<String,Object> map,
  293. @RequestParam Integer apiId,
  294. @RequestParam Integer pageNum,
  295. @RequestParam Integer pageSize){
  296. if(map==null){
  297. map=new HashMap<>();
  298. }
  299. return otmsFeign.getMapVertex(map,apiId,pageNum,pageSize);
  300. }
  301. @ApiOperation(value="查询边")
  302. @PostMapping(value = "/getMapEdge")
  303. public RESTfulResult getMapEdge(@RequestBody Map<String,Object> map,
  304. @RequestParam Integer apiId,
  305. @RequestParam Integer pageNum,
  306. @RequestParam Integer pageSize){
  307. if(map==null){
  308. map=new HashMap<>();
  309. }
  310. return otmsFeign.getMapEdge(map,apiId,pageNum,pageSize);
  311. }
  312. @ApiOperation(value="新增点")
  313. @PostMapping(value = "/addMapVertex")
  314. public RESTfulResult addMapVertex(@RequestBody Map<String,Object> map){
  315. if(map==null){
  316. map=new HashMap<>();
  317. }
  318. return otmsFeign.addMapVertex(map);
  319. }
  320. @ApiOperation(value="新增边")
  321. @PostMapping(value = "/addMapEdge")
  322. public RESTfulResult addMapEdge(@RequestBody Map<String,Object> map){
  323. if(map==null){
  324. map=new HashMap<>();
  325. }
  326. return otmsFeign.addMapEdge(map);
  327. }
  328. @ApiOperation(value="删除点")
  329. @PostMapping(value = "/delMapVertex")
  330. public RESTfulResult delMapVertex(@RequestBody Map<String,Object> map){
  331. if(map==null){
  332. map=new HashMap<>();
  333. }
  334. return otmsFeign.delMapVertex(map);
  335. }
  336. @ApiOperation(value="删除边")
  337. @PostMapping(value = "/delMapEdge")
  338. public RESTfulResult delMapEdge(@RequestBody Map<String,Object> map){
  339. if(map==null){
  340. map=new HashMap<>();
  341. }
  342. return otmsFeign.delMapEdge(map);
  343. }
  344. //在途订单列表
  345. @PostMapping("/transportationPerformance")
  346. public RESTfulResult transportationPerformance(@RequestBody(required = false) Map<String,Object> mapValue,
  347. @RequestParam(required = true,defaultValue = "479",name = "apiId")Integer apiId,
  348. @RequestParam(required = false,name = "pageNum")Integer pageNum,
  349. @RequestParam(required = false,name = "pageSize")Integer pageSize){
  350. return otmsFeign.transportationPerformance(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize);
  351. }
  352. @GetMapping("/getLocationForAddress")
  353. public RESTfulResult getLocationForAddress(@RequestParam("address") String address){
  354. return otmsFeign.getLocationForAddress(address);
  355. }
  356. @PostMapping("/getAddress")
  357. public RESTfulResult getAddress(@RequestBody Map<String,Object> map){
  358. return otmsFeign.getAddress(map);
  359. }
  360. }