|
@@ -81,11 +81,36 @@ public class OTMSController {
|
|
|
//添加到files数组
|
|
|
List<MultipartFile> files = new ArrayList<>();
|
|
|
String file="";
|
|
|
+ int index=0;
|
|
|
//第一张和第二张必填
|
|
|
- files.add(request.getFile("file1"));
|
|
|
- files.add(request.getFile("file2"));
|
|
|
- for(MultipartFile item:files){
|
|
|
- file+=imageFileUtils.updateFile(item)+';';
|
|
|
+ for(int i=1;i<=2;i++){
|
|
|
+ MultipartFile temp = request.getFile("file"+i);
|
|
|
+ if(temp!=null){
|
|
|
+ files.add(temp);
|
|
|
+ index=i;//记录是新上传了第一张还是第二张图片
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //没有上传,当做重复上传
|
|
|
+ if(files.size() == 0){
|
|
|
+ return new RESTfulResult("201","若要重复上传,必须两张都是新图片!","请勿重复上传!");
|
|
|
+ }
|
|
|
+ //上传图片
|
|
|
+ for(int i=0;i<files.size();i++){
|
|
|
+ file+=imageFileUtils.updateFile(files.get(i),i)+';';
|
|
|
+ }
|
|
|
+ //只上传了一张图片,补足另一张
|
|
|
+ if(files.size() == 1){
|
|
|
+ try{
|
|
|
+ String arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber);
|
|
|
+ String[] olds=arrivalPhoto.split(";");
|
|
|
+ if(index==1){
|
|
|
+ file=file+olds[1]+";";
|
|
|
+ }else if(index==2){
|
|
|
+ file=olds[0]+";"+file;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
return otmsFeign.addtmstruckArrivalResult(orderNumber,resultArrivalAddress,file);
|
|
|
}
|
|
@@ -95,31 +120,25 @@ public class OTMSController {
|
|
|
public synchronized RESTfulResult addTmstruckReceiptResult(MultipartRequest request, Integer num, String orderNumber, String resultArrivalAddress, Integer imgcount3, Integer imgcount4) throws Exception {
|
|
|
//添加到files数组
|
|
|
List<MultipartFile> files = new ArrayList<>();
|
|
|
- //第一张和第二张必填
|
|
|
- files.add(request.getFile("file0"));
|
|
|
- files.add(request.getFile("file1"));
|
|
|
- //第三张选填
|
|
|
- if (request.getFile("file2")!=null){
|
|
|
- files.add(request.getFile("file2"));
|
|
|
- }
|
|
|
- //追加的三张,num=6则取到file3,4,5
|
|
|
- for(int i=3;i<num;i++){
|
|
|
- if(request.getFile("file"+i)!=null){
|
|
|
- files.add(request.getFile("file"+i));
|
|
|
+ for(int i=0;i<11;i++){
|
|
|
+ MultipartFile file = request.getFile("file"+i);
|
|
|
+ if(file!=null){
|
|
|
+ files.add(file);
|
|
|
+ }else{
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
- //上传图片,追加的三张图片放在fourFiles里
|
|
|
- List<String> fourFiles=new ArrayList<>();
|
|
|
+ if(files.size()<3){
|
|
|
+ return new RESTfulResult("201","至少上传三张图片!","至少上传三张图片!");
|
|
|
+ }
|
|
|
+ //上传图片,拼接在一个url里
|
|
|
Map<String,Object> mapValue=new HashMap<>();
|
|
|
+ String url="";
|
|
|
for (int i=0;i<files.size();i++){
|
|
|
MultipartFile file=files.get(i);
|
|
|
- String url = imageFileUtils.updateFile(file);
|
|
|
- mapValue.put("url"+i,url);
|
|
|
- if(i>=3) {
|
|
|
- fourFiles.add(url);
|
|
|
- }
|
|
|
+ url += imageFileUtils.updateFile(file,i)+';';
|
|
|
}
|
|
|
- mapValue.put("fourFiles",fourFiles);
|
|
|
+ mapValue.put("url",url);
|
|
|
return otmsFeign.addTmstruckReceiptResult(mapValue,num,orderNumber,resultArrivalAddress,imgcount3,imgcount4);
|
|
|
}
|
|
|
|
|
@@ -169,17 +188,12 @@ public class OTMSController {
|
|
|
return otmsFeign.getArrivalResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("展示满货箱的照片")
|
|
|
+ @ApiOperation("查询抵达图片")
|
|
|
@PostMapping("/getArrivalPhoto")
|
|
|
public List<String> getArrivalPhoto(@RequestParam String orderNumber) throws Exception{
|
|
|
try{
|
|
|
String arrivalPhoto=otmsFeign.getArrivalPhoto(orderNumber);
|
|
|
- String files[]=arrivalPhoto.split(";");
|
|
|
- List<String> file=new ArrayList<>();
|
|
|
- for(int i=0;i<files.length&& files[i].length()>5;i++){
|
|
|
- file.add((String)imageFileUtils.downloadFile(files[i]));
|
|
|
- }
|
|
|
- return file;
|
|
|
+ return getPhotoByUrl(arrivalPhoto);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
@@ -198,41 +212,26 @@ public class OTMSController {
|
|
|
return otmsFeign.getReceiptResult(mapValue==null?new HashMap<>():mapValue, apiId, pageNum, pageSize,con,startTime,endTime);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("展示收货的照片")
|
|
|
+ @ApiOperation("查询签收图片")
|
|
|
@PostMapping("/getReceivingPhotoByUrl")
|
|
|
- public Map<String,Object> getReceivingPhotoByUrl(@RequestParam String orderNumber) throws Exception {
|
|
|
- Map<String,Object> map=otmsFeign.getReceivingPhotoByUrl(orderNumber);
|
|
|
- if(map==null){
|
|
|
- map =new HashMap<>();
|
|
|
- return map;
|
|
|
- }
|
|
|
- if(map.containsKey("resultEmptyContainerPhoto") && map.get("resultEmptyContainerPhoto")!=null){
|
|
|
- String resultEmptyContainerPhoto = (String) imageFileUtils.downloadFile(map.get("resultEmptyContainerPhoto").toString());
|
|
|
- map.put("resultEmptyContainerPhoto",resultEmptyContainerPhoto);
|
|
|
- }
|
|
|
- if(map.containsKey("resultSignedNotePhoto") && map.get("resultSignedNotePhoto")!=null){
|
|
|
- String resultSignedNotePhoto = (String) imageFileUtils.downloadFile(map.get("resultSignedNotePhoto").toString());
|
|
|
- map.put("resultSignedNotePhoto",resultSignedNotePhoto);
|
|
|
- }
|
|
|
- if(map.containsKey("resultReceiveNotePhoto") && map.get("resultReceiveNotePhoto")!=null){
|
|
|
- String resultSignedNotePhoto = (String) imageFileUtils.downloadFile(map.get("resultReceiveNotePhoto").toString());
|
|
|
- map.put("resultReceiveNotePhoto",resultSignedNotePhoto);
|
|
|
- }
|
|
|
- //追加的图片
|
|
|
- if(map.containsKey("otherPhoto1") && map.get("otherPhoto1")!=null){
|
|
|
- String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto1").toString());
|
|
|
- map.put("otherPhoto1",resultSignedNotePhoto);
|
|
|
- }
|
|
|
- if(map.containsKey("otherPhoto2") && map.get("otherPhoto2") !=null){
|
|
|
- String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto2").toString());
|
|
|
- map.put("otherPhoto2",resultSignedNotePhoto);
|
|
|
- }
|
|
|
- if(map.containsKey("otherPhoto3") && map.get("otherPhoto3") !=null){
|
|
|
- String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto3").toString());
|
|
|
- map.put("otherPhoto3",resultSignedNotePhoto);
|
|
|
+ public List<String> getReceivingPhotoByUrl(@RequestParam String orderNumber) throws Exception {
|
|
|
+ try{
|
|
|
+ String receivePhoto=otmsFeign.getReceivingPhotoByUrl(orderNumber);
|
|
|
+ return getPhotoByUrl(receivePhoto);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- return map;
|
|
|
+ //切割字符串,下载图片并返回
|
|
|
+ private List<String> getPhotoByUrl(String urls) throws Exception {
|
|
|
+ List<String> results=new ArrayList<>();
|
|
|
+ String files[]=urls.split(";");
|
|
|
+ for(int i=0;i<files.length && files[i].length()>5;i++){
|
|
|
+ results.add((String)imageFileUtils.downloadFile(files[i]));
|
|
|
+ }
|
|
|
+ return results;
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getCurrentLocation")
|