瀏覽代碼

现在上传接口,认证接口调试

guojia 4 年之前
父節點
當前提交
c3a27ac0e9

+ 3 - 2
src/main/java/com/ebei/device/asset/weixin/auth/AuthUtils.java

@@ -20,8 +20,9 @@ public class AuthUtils {
 	public final static String REQ_TOKEN = "_req_token_";
 	public final static String REQ_BLANK = "_req_blank_";//参数中传递的token
 	
-	public final static Long TOKEN_EXPIRE_TIME = 7200L;//3个小时
-	
+//	public final static Long TOKEN_EXPIRE_TIME = 7200L;//3个小时
+	public final static Long TOKEN_EXPIRE_TIME =3L;//3天
+
     public static ServletRequestAttributes getRequestAttributes() {
     	RequestAttributes r = RequestContextHolder.currentRequestAttributes();
         return (ServletRequestAttributes)r;

+ 2 - 0
src/main/java/com/ebei/device/asset/weixin/config/CommProperties.java

@@ -22,4 +22,6 @@ public class CommProperties {
 
     private String[] whiteList;
 
+    private String rtwgOaPdfUrl;//融通地产OA,Pdf地址
+
 }

+ 0 - 15
src/main/java/com/ebei/device/asset/weixin/contorller/AssetProposalController.java

@@ -4,27 +4,12 @@ package com.ebei.device.asset.weixin.contorller;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.ebei.device.asset.weixin.model.entity.AssetProposal;
 import com.ebei.device.asset.weixin.service.AssetProposalService;
-import com.ebei.device.asset.weixin.util.FileUploadDownloadUtil;
 import com.ebei.device.asset.weixin.util.ResponseEx;
 import com.ebei.device.asset.weixin.util.ResponsePageEx;
-import com.google.common.annotations.VisibleForTesting;
-import com.itextpdf.text.Document;
-import com.itextpdf.text.Font;
-import com.itextpdf.text.Image;
-import com.itextpdf.text.PageSize;
-import com.itextpdf.text.pdf.BaseFont;
-import com.itextpdf.text.pdf.PdfPCell;
-import com.itextpdf.text.pdf.PdfPTable;
-import com.itextpdf.text.pdf.PdfWriter;
 import io.swagger.annotations.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.List;
 import java.util.Map;
 
 

+ 21 - 10
src/main/java/com/ebei/device/asset/weixin/contorller/AssetRectifyController.java

@@ -1,5 +1,7 @@
 package com.ebei.device.asset.weixin.contorller;
 
+import com.ebei.device.asset.weixin.config.CommProperties;
+import com.ebei.device.asset.weixin.util.ExceptionUtils;
 import com.ebei.device.asset.weixin.util.HttpRequestUtils;
 import com.ebei.device.asset.weixin.util.ResponseEx;
 import io.swagger.annotations.Api;
@@ -8,11 +10,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.http.HttpResponse;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.rendering.PDFRenderer;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.Base64Utils;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
@@ -37,12 +37,20 @@ import java.util.Map;
 @Slf4j
 public class AssetRectifyController {
 
+    @Autowired
+    CommProperties commProperties;
 
     @ApiOperation(value="获取pdf转换为图片list")
-    @PostMapping("/getPdfToImage/{taskId}")
+    @GetMapping("/getPdfToImage/{taskId}")
     public ResponseEx<Object> getPdfToImage(@PathVariable Long taskId ) throws Exception {
-
-        InputStream inputStream = HttpRequestUtils.getUrlConnection("http://101.200.225.123/device/assetApp/createHardwareWebPDF/"+taskId+"?preView=true", 1024*1024).getInputStream();
+        InputStream inputStream = null;
+        try {
+             inputStream = HttpRequestUtils.getUrlConnection(commProperties.getRtwgOaPdfUrl()+taskId+"?preView=true", 1024*1024).getInputStream();
+        }catch (Exception e){
+            log.error(ExceptionUtils.getExceptionDetail(e));
+            e.printStackTrace();
+            return ResponseEx.createError(taskId+"该任务没有签名图片");
+        }
         PDDocument pdDocument = PDDocument.load(inputStream);
         int pageCount = pdDocument.getNumberOfPages();
         PDFRenderer pdfRenderer = new PDFRenderer(pdDocument);
@@ -57,9 +65,6 @@ public class AssetRectifyController {
                 bufferedImage = pdfRenderer.renderImageWithDPI(pageIndex, 150);
                 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                 ImageIO.write(bufferedImage, "jpg", outputStream);// 写入流
-//                FileOutputStream fileOutputStream = null;
-//                fileOutputStream = new FileOutputStream("c:\\usr\\imgeTest\\"+System.currentTimeMillis()+".jpg");
-//                fileOutputStream.write(outputStream.toByteArray());
                 obj = new HashMap<String, Object>();
                 obj.put("index", pageIndex);
                 obj.put("pic", Base64Utils.encodeToString(outputStream.toByteArray()));
@@ -72,4 +77,10 @@ public class AssetRectifyController {
         return ResponseEx.createSuccess(resultinfo);
     }
 
+    @RequestMapping(value="/exportPDF/{taskId}",method = {RequestMethod.GET,RequestMethod.POST})
+    public ResponseEx<String> createHardwarePDF(@PathVariable("taskId") Long taskId) throws Exception {
+        String remoteFilePath =commProperties.getRtwgOaPdfUrl() +taskId+"?preView=true";
+        return ResponseEx.createSuccess(200, remoteFilePath);
+    }
+
 }

+ 112 - 0
src/main/java/com/ebei/device/asset/weixin/contorller/CommonController.java

@@ -0,0 +1,112 @@
+
+package com.ebei.device.asset.weixin.contorller;
+
+import com.ebei.device.asset.weixin.util.FileDownUtil;
+import com.ebei.device.asset.weixin.util.FileUploadDownloadUtil;
+import com.ebei.device.asset.weixin.util.ResponseEx;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.http.HttpResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.net.URLDecoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ * <p>
+ * 机房位置 前端控制器
+ * </p>
+ * @author yangsm
+ * @since 2018-08-16
+ */
+@RestController
+@RequestMapping("/common")
+@Api(value = "common" , description = "公共上传下载附件controller")
+public class CommonController {
+	private final static Logger logger = LoggerFactory.getLogger(CommonController.class);
+	
+	@ApiOperation(value = "上传文件(<input type='file' name='file'>)")
+	@PostMapping("/uploadFile")
+	public ResponseEx uploadFile(@RequestParam MultipartFile[] file, HttpServletRequest request) {
+		Map<String,Object> resultMap;
+		List<Map<String,Object>> resultList = new ArrayList<>();
+		for(MultipartFile fileOne : file){
+            try {
+                String uuid = UUID.randomUUID().toString();
+                String fileName = fileOne.getOriginalFilename();
+                //上传文件
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                //上传到文件服务器
+                boolean success = FileUploadDownloadUtil.commonFileUpload( uuid,fileOne.getInputStream(), dateFormat, fileOne.getOriginalFilename());
+                if (!success) {
+                    return ResponseEx.createError("文件上传失败");
+                } else {
+                    String filePath = FileUploadDownloadUtil.getRemoteFilePath(request,uuid);
+                    String fileFormat = fileName.substring(fileName.lastIndexOf(".") + 1);
+                    String fileType;
+                    if("jpgpngjpeggif".indexOf(fileFormat)!=-1){
+                        fileType = "1";
+                    }else if("3gpmp4avimpgwav".indexOf(fileFormat)!=-1){
+                        fileType = "2";
+                    }else if("mp3amr".indexOf(fileFormat)!=-1){
+                        fileType = "3";
+                    }else if("docxlspptdocxxlsxpptxpdf".indexOf(fileFormat)!=-1){
+                        fileType = "5";
+                    }else {
+                        fileType = "4";
+                    }
+                    resultMap = new HashMap<>();
+                    resultMap.put("fileId",uuid);
+                    resultMap.put("fileName",fileName);
+                    resultMap.put("filePath",filePath);
+                    resultMap.put("fileType",fileType);
+                    resultList.add(resultMap);
+                }
+            } catch (Exception e) {
+                logger.error("文件上传异常",e);
+                return ResponseEx.createError("文件上传失败");
+            }
+		}
+		return ResponseEx.createSuccess(resultList);
+	}
+
+	/**
+	 * Discription :附件下载 void
+	 */
+	@ApiOperation(value = "下载附件")
+	@GetMapping("/downFile")
+	public void downFile(String fileId,String fileName, HttpServletResponse response) {
+		logger.info("[服务器下载附件: downFile fileId:{}]" ,fileId);
+        try {
+            HttpResponse fileManagerResponse = FileUploadDownloadUtil.getFileManagerResponse(fileId);
+            if(fileName == null){
+                fileName = fileManagerResponse.getFirstHeader("filename").getValue();
+                fileName = URLDecoder.decode(fileName, "UTF-8");
+            }
+            InputStream is = fileManagerResponse.getEntity().getContent();
+//		    byte[] content = FileUploadDownloadUtil.fileMakeLocal(fileId);
+            //输出到客户端
+            FileDownUtil.downFile(is, fileName);
+        } catch (Exception e) {
+            logger.info("文件下载失败!{}",e);
+        }
+
+    }
+	/**
+	 * Discription :附件下载 void
+	 */
+	@ApiOperation(value = "获取文件URL")
+	@GetMapping("/getFilePath")
+	public ResponseEx<String> downFile(String fileId) {
+		logger.info("[服务器下载附件: downFile fileId:{}]" ,fileId);
+		return ResponseEx.createSuccess(FileUploadDownloadUtil.getRemoteFilePath(fileId,"127.0.0.1"));
+			
+	}
+}

+ 22 - 29
src/main/java/com/ebei/device/asset/weixin/contorller/LoginController.java

@@ -4,15 +4,15 @@ package com.ebei.device.asset.weixin.contorller;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.ebei.device.asset.weixin.auth.AuthUtils;
+import com.ebei.device.asset.weixin.constant.Constants;
+import com.ebei.device.asset.weixin.model.entity.AssetTask;
 import com.ebei.device.asset.weixin.model.entity.AssetTenantUser;
+import com.ebei.device.asset.weixin.model.vo.AssetTenantUserVO;
 import com.ebei.device.asset.weixin.service.AssetTenantUserService;
 import com.ebei.device.asset.weixin.service.UserSessionManager;
 import com.ebei.device.asset.weixin.util.MD5;
 import com.ebei.device.asset.weixin.util.ResponseEx;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -38,33 +38,26 @@ public class LoginController {
 	@Autowired
 	private UserSessionManager userSessionManager;
 
-	@ApiOperation(value = "登陆校验", notes = "登陆校验")
-	@ApiImplicitParams({ @ApiImplicitParam(name = "userAccount", value = "登录名", required = true, paramType = "query"),
-			@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query") })
-	@GetMapping("getCheckedLoginInfo")
-	public ResponseEx<Object> getCheckedLoginInfo(@RequestParam String userAccount, @RequestParam String password) {
-		return postCheckedLoginInfo(userAccount, password);
-	}
 
 	@ApiOperation(value = "安全登陆校验", notes = "安全登陆校验")
-	@ApiImplicitParams({ @ApiImplicitParam(name = "userAccount", value = "登录名", required = true, paramType = "query"),
-			@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query") })
 	@PostMapping("postCheckedLoginInfo")
-	public ResponseEx<Object> postCheckedLoginInfo(@RequestParam String userAccount, @RequestParam String password) {
+	public ResponseEx<Object> postCheckedLoginInfo(@RequestBody @ApiParam(name = "assetTenantUserVO", value = "{userAccount:111,pwd:111}", required = true) AssetTenantUserVO assetTenantUserVO) {
 
 		ResponseEx<Object> resultResponse = ResponseEx.createError("登录失败");
-		if ((userAccount != null && password != null) && (!"".equals(userAccount) && !"".equals(password))) {
+
+		String userAccount = assetTenantUserVO.getUserAccount();
+		String pwd = assetTenantUserVO.getPwd();
+		if ((userAccount != null && assetTenantUserVO.getPwd() != null) && (!"".equals(assetTenantUserVO.getUserAccount()) && !"".equals(pwd))) {
 			Wrapper wrapper = new EntityWrapper(new AssetTenantUser(userAccount));
 			AssetTenantUser assetTenantUser = assetTenantUserService.selectOne(wrapper);
 
-
 			/*校验用户登录信息-------------------开始*/
 			boolean isOk = false;
 			if (null != assetTenantUser) {
-				String pwd = assetTenantUser.getPwd();
-				String md5comparePwd = new MD5().getMD5ofStr(password);
+				String pwdReal = assetTenantUser.getPwd();
+				String md5comparePwd = new MD5().getMD5ofStr(pwdReal);
 				if (null != pwd) {
-					if (pwd.equals(password) || pwd.equals(md5comparePwd)) {
+					if (pwdReal.equals(pwd) || pwd.equals(md5comparePwd)) {
 						isOk = true;
 					}
 				}
@@ -122,30 +115,30 @@ public class LoginController {
 
 
 	@ApiOperation(value = "修改密码", notes = "修改密码")
-	@GetMapping("updatePassword")
-	public ResponseEx<Object> updatePassword(@RequestParam String userAccount, @RequestParam String oldPassword, @RequestParam String newPassword) {
-
-		AssetTenantUser assetTenantUser = new AssetTenantUser(userAccount);
+	@PostMapping("updatePassword")
+	public ResponseEx<Object> updatePassword(@RequestBody @ApiParam(name = "assetTenantUserVO", value = "{userAccount:111,pwd:111,newPwd:1111}", required = true)
+														 AssetTenantUserVO assetTenantUserVO) {
+		AssetTenantUser assetTenantUser = new AssetTenantUser(assetTenantUserVO.getUserAccount());
 		Wrapper<AssetTenantUser> wrapper = new EntityWrapper<>(assetTenantUser);
+		wrapper.eq("user_account",assetTenantUserVO.getUserAccount());
+		wrapper.eq("state", Constants.FLAG_IS_YES);
 		assetTenantUser = assetTenantUserService.selectOne(wrapper);
 		boolean isOk = false;
 		String pwd = assetTenantUser.getPwd();
-		String md5comparePwd = new MD5().getMD5ofStr(oldPassword);
+		String md5comparePwd = new MD5().getMD5ofStr(pwd);
 		if (null != pwd) {
-			if (pwd.equals(oldPassword) || pwd.equals(md5comparePwd)) {
+			if (pwd.equals(assetTenantUserVO.getPwd()) || md5comparePwd.equals(assetTenantUserVO.getPwd())) {
 				isOk = true;
 			}
 		}
 		if (isOk){
 			userSessionManager.clearToken(assetTenantUser.getToken(),true);
-
-			assetTenantUser.setPwd(newPassword);
+			assetTenantUser.setPwd(assetTenantUserVO.getNewPwd());
 			assetTenantUser.setToken(null);
 			assetTenantUserService.updateById(assetTenantUser);
-
 			return ResponseEx.createSuccess("修改成功");
 		}else {
-			return ResponseEx.createError("登陆失败,用户名或密码错误!");
+			return ResponseEx.createError("修改密码失败,用户名或密码错误!");
 		}
 
 	}

+ 102 - 0
src/main/java/com/ebei/device/asset/weixin/model/vo/AssetTenantUserVO.java

@@ -0,0 +1,102 @@
+
+package com.ebei.device.asset.weixin.model.vo;
+
+
+import com.baomidou.mybatisplus.activerecord.Model;
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableLogic;
+import com.baomidou.mybatisplus.annotations.TableName;
+import com.baomidou.mybatisplus.enums.IdType;
+import com.ebei.device.asset.weixin.model.entity.AssetUser;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 资产管护租户账号信息VO
+ * </p>
+ *
+ */
+@Data
+@NoArgsConstructor
+@ApiModel("资产管护租户账号信息")
+public class AssetTenantUserVO extends Model<AssetTenantUserVO> {
+
+    public AssetTenantUserVO(String userAccount){
+        this.userAccount = userAccount;
+    }
+
+    @ApiModelProperty(value="账号Id")
+    private Long userId;
+
+    @ApiModelProperty("账号")
+    private String userAccount;
+
+    @ApiModelProperty("用户姓名")
+    private String userName;
+
+    @ApiModelProperty("密码")
+    private String pwd;
+
+    @ApiModelProperty("新密码")
+    private String newPwd;
+
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+
+    @ApiModelProperty("创建人")
+    private Long creator;
+
+    @ApiModelProperty("修改时间")
+    private Date operateDate;
+
+    @ApiModelProperty("修改人")
+    private Long operator;
+
+    @ApiModelProperty("公司id")
+    private Long companyId;
+
+    @ApiModelProperty("租户Id")
+    private Long tenantId;
+
+    @ApiModelProperty("租户名称")
+    private String tenantName;
+
+    @ApiModelProperty("联系方式")
+    private String telephone;
+
+    @ApiModelProperty("区域id")
+    private Long areaId;
+
+    @ApiModelProperty(value="数据状态  1:正常,0:删除 默认 1")
+    private Integer state;
+
+    @ApiModelProperty("暂存token")
+    private String token;
+
+    @ApiModelProperty("最近一次登录时间")
+    private Date LastLoginDate;
+
+
+    @ApiModelProperty(value="资产信息")
+    private List<AssetUser> assetList;
+
+    @ApiModelProperty("区域名称")
+    private String areaName;
+
+
+
+
+
+    @Override
+    protected Serializable pkVal() {return null;}
+	
+
+}

+ 2 - 2
src/main/java/com/ebei/device/asset/weixin/service/impl/RedisUserSessionManager.java

@@ -57,7 +57,7 @@ public class RedisUserSessionManager implements UserSessionManager {
 		AuthUser auser = this.createAuthUser(user,companyId);
 		auser.setToken(token);
 		redisTemplate.opsForValue().set(AuthUtils.REQ_TOKEN+auser.getToken(), JSON.toJSON(auser).toString());
-		redisTemplate.expire(AuthUtils.REQ_TOKEN+auser.getToken(), AuthUtils.TOKEN_EXPIRE_TIME, TimeUnit.SECONDS);
+		redisTemplate.expire(AuthUtils.REQ_TOKEN+auser.getToken(), AuthUtils.TOKEN_EXPIRE_TIME, TimeUnit.DAYS);
 
 		return auser;
 	}
@@ -86,7 +86,7 @@ public class RedisUserSessionManager implements UserSessionManager {
 		}
 		AuthUser user = JSON.toJavaObject(JSON.parseObject(value),AuthUser.class);
 		if(user!=null) {
-			redisTemplate.expire(AuthUtils.REQ_TOKEN+token, AuthUtils.TOKEN_EXPIRE_TIME, TimeUnit.SECONDS);
+			redisTemplate.expire(AuthUtils.REQ_TOKEN+token, AuthUtils.TOKEN_EXPIRE_TIME, TimeUnit.DAYS);
 		}
 		return user;
 	}

+ 31 - 0
src/main/java/com/ebei/device/asset/weixin/util/ExceptionUtils.java

@@ -0,0 +1,31 @@
+package com.ebei.device.asset.weixin.util;
+
+/**
+ * 读取配置文件工具类
+ * 
+ * @author 姓名 工号
+ * @version [版本号, 2016年9月14日]
+ */
+public class ExceptionUtils {
+    /**
+     * 获取异常的详细信息
+     * @param e
+     * @return
+     */
+    public static String getExceptionDetail(Exception e) {
+        StringBuffer msg = new StringBuffer("");  
+        if (e != null) {
+            String message = e.toString();
+            int length = e.getStackTrace().length;  
+            if (length > 0) {  
+                msg.append(message + "\r\n");  
+                for (int i = 0; i < length; i++) {  
+                    msg.append("\t" + e.getStackTrace()[i] + "\r\n");  
+                }
+            } else {  
+                msg.append(message);  
+            }  
+        }  
+        return msg.toString();  
+    }
+}

+ 115 - 0
src/main/java/com/ebei/device/asset/weixin/util/FileDownUtil.java

@@ -0,0 +1,115 @@
+package com.ebei.device.asset.weixin.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+
+@Slf4j
+public class FileDownUtil {
+	
+	public final static String nofile = "<script>alert('无附件可供下载!');</script>";
+	
+	public static void downFile(byte[] bytes,String fname) {
+		ServletRequestAttributes holder =  getRequestAttributes();
+		HttpServletResponse response = holder.getResponse();
+		if(bytes==null||bytes.length<=0) {
+			nofile(response);
+			return;
+		}
+		response.reset();
+		response.setContentType("application/octet-stream");
+		try {
+//			HttpServletRequest request = holder.getRequest();
+			String foname = null;
+//			Object out = request.getAttribute(AuthUtils.REQ_BLANK);
+//			if(out!=null) {
+				foname = URLEncoder.encode(fname, "UTF-8");
+//			}else {
+//				foname = new String(fname.getBytes(),"ISO-8859-1");
+//			}
+			response.setHeader("Content-disposition", "attachment;filename="+foname);
+			response.getOutputStream().write(bytes);
+			response.flushBuffer();
+			log.debug("[get] [sucess] [{}]",fname);
+		}catch (Exception e) {
+			log.error("[get] [error] ["+fname+"]",e);
+		}
+		
+	}
+	public static void downFile(InputStream file,String fname) {
+		
+		if(file!=null) {
+			try {
+                ByteArrayOutputStream bo = new ByteArrayOutputStream();
+                byte[] data = new byte[1024];
+                int length = 0;
+                while((length = file.read(data)) > 0){
+                    bo.write(data, 0, length);
+                    bo.flush();
+                }
+                byte[] bytes = bo.toByteArray();
+                downFile(bytes,fname);
+				file.close();
+			}catch (Exception e) {
+				log.error("[get] [error] ["+fname+"]",e);
+			}
+		}else {
+			nofile(getRequestAttributes().getResponse());
+			log.warn("[get] [notfound] [{}]",fname);
+		}
+	}
+	public static void downFile(File file,String fname) {
+		if(fname==null) {
+			fname = file.getName();
+		}
+		if(file.exists()&&file.isFile()) {
+			try {
+				FileInputStream fin = new FileInputStream(file);
+				byte[] data = new byte[(int)file.length()];
+				fin.read(data);
+				downFile(data,fname);
+				fin.close();
+			}catch (Exception e) {
+				log.error("[get] [error] ["+fname+"]",e);
+			}
+		}else {
+			nofile(getRequestAttributes().getResponse());
+			log.warn("[get] [notfound] [{}]",fname);
+		}
+	}
+	private static void nofile(HttpServletResponse response) {
+		response.setContentType("text/html;charset=utf-8");
+		try {
+			response.getWriter().write(nofile);
+		} catch (IOException e) {}
+	}
+	/**
+	 * 下载文件流
+	 * @param file
+	 */
+	public static void downFile(File file) {
+		downFile(file,null);
+	}
+    public static ServletRequestAttributes getRequestAttributes() {
+    	RequestAttributes r = RequestContextHolder.currentRequestAttributes();
+        return (ServletRequestAttributes)r;
+    }
+	public static String getFileName(String filename) {
+		if (filename == null) {
+			return "";
+		}
+		int unixSep = filename.lastIndexOf("/");
+		int winSep = filename.lastIndexOf("\\");
+		int pos = (winSep > unixSep ? winSep : unixSep);
+		if (pos != -1)  {
+			return filename.substring(pos + 1);
+		}else {
+			return filename;
+		}
+	}
+}

+ 2 - 0
src/main/resources/application.yml

@@ -72,6 +72,8 @@ task:
   mqtt: true
   push-url: http://11.223.61.51:5903/MQTTProxy/mqtt_Mqtt_pub.do
 comm:
+#  rtwg-oa-pdf-url: http://101.200.225.123/device/assetApp/createHardwareWebPDF/
+  rtwg-oa-pdf-url: http://172.18.0.78:8089/device/assetApp/createHardwareWebPDF/
   white-list:
     - /login/*CheckedLoginInfo**
     - /login/clearToken**