package com.steerinfo.dil.controller; import com.steerinfo.dil.config.ImageFileUtils; import com.steerinfo.dil.feign.OtmsFeign; import com.steerinfo.dil.feign.TmsTruckFeign; import com.steerinfo.dil.util.PageListAdd; import com.steerinfo.dil.util.SaleLogUtil; import com.steerinfo.framework.controller.RESTfulResult; import com.steerinfo.framework.service.pagehelper.PageHelper; 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.http.MediaType; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartRequest; import java.awt.*; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @RestController @RequestMapping("${api.version}/otms") public class OTMSController { @Autowired private OtmsFeign otmsFeign; @Autowired private ImageFileUtils imageFileUtils; @Autowired private SaleLogUtil saleLogUtil; @ApiOperation(value="全路径展示接口") @PostMapping("/fullPath") public Object fullPath(@RequestParam("orderNumber") String orderNumber) throws Exception { return otmsFeign.fullPath(orderNumber); } @ApiOperation(value = "在途订单列表") @PostMapping("/getInTransitTransportation") public RESTfulResult getInTransitTransportation(@RequestBody(required=false) Map mapValue, @RequestParam(required = true,defaultValue = "468",name = "apiId")Integer apiId, @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum, @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize ) { return otmsFeign.getInTransitTransportation(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize); } @ApiOperation(value = "有异常订单列表") @PostMapping("/getHaveAbnormalTruckOrderInfo") public RESTfulResult getHaveAbnormalTruckOrderInfo(@RequestBody(required=false) Map mapValue, @RequestParam(required = true,defaultValue = "468",name = "apiId")Integer apiId, @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum, @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize ) { return otmsFeign.getHaveAbnormalTruckOrderInfo(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize); } @ApiOperation("已完成订单列表") @ApiImplicitParams({ @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"), @ApiImplicitParam(name = "apiId", value = "动态表头", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer") }) @PostMapping("/getFinishTruckOrderInfo") public RESTfulResult getFinishTruckOrderInfo(@RequestBody(required = false) Map mapValue, @RequestParam(required = false,defaultValue = "468",name = "apiId")Integer apiId, @RequestParam(required = false,defaultValue = "1",name = "pageNum")Integer pageNum, @RequestParam(required = false,defaultValue = "20",name = "pageSize")Integer pageSize ){ return otmsFeign.getFinishTruckOrderInfo(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize); } @ApiOperation(value = "新增抵达") @PostMapping(value = "/addtmstruckArrivalResult") public RESTfulResult addtmstruckArrivalResult(@RequestParam("orderNumber") String orderNumber, @RequestParam("resultArrivalAddress")String resultArrivalAddress, Long arrivalTime,String userName, MultipartRequest request) throws Exception { //添加到files数组 List files = new ArrayList<>(); int index=-1; for(int i=0;i<21;i++){ MultipartFile file = request.getFile("file"+i); if(file!=null){ files.add(file); if(index<0){ index=i; } } } //没有上传,当做重复上传 if(files.size() == 0){ return new RESTfulResult("201","请勿重复上传!","请勿重复上传!"); } //上传图片,拼接在一个url里 Map mapValue=new HashMap<>(); String url=""; try{ //如果存在预览图片,查询,把那个位置的图片截取下来 if(index > 0){ String[] arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber).split(";"); for(int i=0;i files = new ArrayList<>(); for(int i=0;i<21;i++){ MultipartFile file = request.getFile("file"+i); if(file!=null){ files.add(file); }else{ break; } } if(files.size()<2){ return new RESTfulResult("201","至少上传两张图片!","至少上传两张图片!"); } //上传图片,拼接在一个url里 Map mapValue=new HashMap<>(); String url=""; for (int i=0;i files = new ArrayList<>(); int index=-1; for(int i=0;i<21;i++){ MultipartFile file = request.getFile("file"+i); if(file!=null){ files.add(file); if(index<0){ index=i; } } } //没有上传,当做重复上传 if(files.size() == 0){ return new RESTfulResult("201","若要重复上传,必须两张都是新图片!","请勿重复上传!"); } //上传图片,拼接在一个url里 Map mapValue=new HashMap<>(); String url=""; try{ //如果存在预览图片,查询,把那个位置的图片截取下来 if(index > 0){ String[] receivePhoto=otmsFeign.getReceivingPhotoByUrl(orderNumber).split(";"); for(int i=0;i mapValue, @RequestParam(name = "apiId",defaultValue = "472") Integer apiId, @RequestParam(name = "pageNum") Integer pageNum, @RequestParam(name = "orderNumbers") String orderNumbers, @RequestParam(name = "pageSize") Integer pageSize){ mapValue=mapValue!=null?mapValue:new HashMap<>(); mapValue.put("orderNumbers",orderNumbers); return otmsFeign.getTransportAbnormalInfo(mapValue,apiId,pageNum,pageSize); } @ApiOperation(value="车牌号和时间查询路径") @PostMapping("/fullPathVisualizationByCarNumber") public Object fullPathVisualizationByCarNumber(@RequestBody HashMap mapValue) throws Exception{ return otmsFeign.fullPathVisualizationByCarNumber(mapValue); } @ApiOperation("厂外抵达作业") @PostMapping("/getArrivalResult") public Map getArrivalResult(@RequestBody(required = false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, String con, String startTime, String endTime){ return otmsFeign.getArrivalResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime); } @ApiOperation("查询抵达图片") @PostMapping("/getArrivalPhoto") public List getArrivalPhoto(@RequestParam String orderNumber) throws Exception{ try{ String arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber); return getPhotoByUrl(arrivalPhoto); }catch (Exception e){ return null; } } @ApiOperation("厂外抵达作业") @PostMapping("/getReceiptResult") public Map getReceiptResult(@RequestBody(required = false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, String con, String startTime, String endTime){ return otmsFeign.getReceiptResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime); } @ApiOperation("查询签收图片") @PostMapping("/getReceivingPhotoByUrl") public List getReceivingPhotoByUrl(@RequestParam String orderNumber) throws Exception { try{ String receivePhoto=otmsFeign.getReceivingPhotoByUrl(orderNumber); return getPhotoByUrl(receivePhoto); }catch (Exception e){ return null; } } //切割字符串,下载图片并返回 private List getPhotoByUrl(String urls) throws Exception { List results=new ArrayList<>(); String files[]=urls.split(";"); for(int i=0;i5;i++){ results.add((String)imageFileUtils.downloadFile(files[i])); } return results; } @GetMapping("/getCurrentLocation") public RESTfulResult getCurrentLocation(@RequestParam("capcityNumber") String capcityNumber) throws Exception{ return otmsFeign.getCurrentLocation(capcityNumber); } //获取地图顶点 @GetMapping(value = "/mapvertexs/findAllAvailableVertex") public RESTfulResult findAllAvailableVertex(){ return otmsFeign.findAllAvailableVertex(); } //获取最佳路径 @GetMapping(value = "/mapvertexs/getObtainTheOptimalPath") public RESTfulResult getObtainTheOptimalPath(@RequestParam("startPoint") String startPoint,@RequestParam("endPoint") String endPoint) throws Exception{ return otmsFeign.getObtainTheOptimalPath(startPoint,endPoint); } @ApiOperation(value="获取当前订单导航路径") @GetMapping(value = "/mapvertexs/getPathByOrderID") public RESTfulResult getPathByOrderID(@RequestParam("orderId") String orderId,@RequestParam("startStep") String startStep,@RequestParam("endStep") String endStep) throws Exception { return otmsFeign.getPathByOrderID(orderId,startStep,endStep); } @ApiOperation(value="查询所有可选地点") @GetMapping(value = "/mapvertexs/findSelections") public RESTfulResult findSelections(){ return otmsFeign.findSelections(); } @ApiOperation(value="查询点") @PostMapping(value = "/getMapVertex") public RESTfulResult getMapVertex(@RequestBody Map map, @RequestParam Integer apiId, @RequestParam Integer pageNum, @RequestParam Integer pageSize){ if(map==null){ map=new HashMap<>(); } return otmsFeign.getMapVertex(map,apiId,pageNum,pageSize); } @ApiOperation(value="查询边") @PostMapping(value = "/getMapEdge") public RESTfulResult getMapEdge(@RequestBody Map map, @RequestParam Integer apiId, @RequestParam Integer pageNum, @RequestParam Integer pageSize){ if(map==null){ map=new HashMap<>(); } return otmsFeign.getMapEdge(map,apiId,pageNum,pageSize); } @ApiOperation(value="新增点") @PostMapping(value = "/addMapVertex") public RESTfulResult addMapVertex(@RequestBody Map map){ if(map==null){ map=new HashMap<>(); } return otmsFeign.addMapVertex(map); } @ApiOperation(value="新增边") @PostMapping(value = "/addMapEdge") public RESTfulResult addMapEdge(@RequestBody Map map){ if(map==null){ map=new HashMap<>(); } return otmsFeign.addMapEdge(map); } @ApiOperation(value="删除点") @PostMapping(value = "/delMapVertex") public RESTfulResult delMapVertex(@RequestBody Map map){ if(map==null){ map=new HashMap<>(); } return otmsFeign.delMapVertex(map); } @ApiOperation(value="删除边") @PostMapping(value = "/delMapEdge") public RESTfulResult delMapEdge(@RequestBody Map map){ if(map==null){ map=new HashMap<>(); } return otmsFeign.delMapEdge(map); } //在途订单列表 @PostMapping("/transportationPerformance") public RESTfulResult transportationPerformance(@RequestBody(required = false) Map mapValue, @RequestParam(required = true,defaultValue = "479",name = "apiId")Integer apiId, @RequestParam(required = false,name = "pageNum")Integer pageNum, @RequestParam(required = false,name = "pageSize")Integer pageSize){ return otmsFeign.transportationPerformance(mapValue!=null?mapValue:new HashMap<>(),apiId,pageNum,pageSize); } @GetMapping("/getLocationForAddress") public RESTfulResult getLocationForAddress(@RequestParam("address") String address){ return otmsFeign.getLocationForAddress(address); } @PostMapping("/getAddress") public RESTfulResult getAddress(@RequestBody Map map){ return otmsFeign.getAddress(map); } }