|
@@ -40,6 +40,12 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLConnection;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
@@ -73,7 +79,7 @@ public class UserViewProjectContractController {
|
|
|
@PostMapping("/queryCurrentUserData")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "获取用户信息")
|
|
|
- public R<UserVO> queryCurrentUserData() {
|
|
|
+ public R<UserVO> queryCurrentUserData() throws Exception {
|
|
|
User user = this.userClient.userInfoById(AuthUtil.getUserId()).getData();
|
|
|
if (user != null) {
|
|
|
//获取部门
|
|
@@ -88,7 +94,47 @@ public class UserViewProjectContractController {
|
|
|
//获取个人签字文件
|
|
|
List<SignPfxFile> pfxFiles = this.signPfxClient.querySignPfxByUserIdOrContractId(user.getId().toString(), "");
|
|
|
if (pfxFiles != null && pfxFiles.size() > 0) {
|
|
|
- userVO.setSignatureUrl(pfxFiles.get(0).getSignatureFileUrl());
|
|
|
+ SignPfxFile signPfxFile = pfxFiles.get(0);
|
|
|
+ String signatureFileUrl = pfxFiles.get(0).getSignatureFileUrl();
|
|
|
+ userVO.setSignatureUrl(signatureFileUrl);
|
|
|
+ Double wide = signPfxFile.getWide();
|
|
|
+ Double high = signPfxFile.getHigh();
|
|
|
+ if(ObjectUtil.isNotEmpty(wide) && ObjectUtil.isNotEmpty(high)){
|
|
|
+ BigDecimal wideBigDecimal = new BigDecimal(wide);
|
|
|
+ BigDecimal highBigDecimal = new BigDecimal(high);
|
|
|
+ //分别乘以1.29 保留两位小数
|
|
|
+ BigDecimal wideDecima = wideBigDecimal.multiply(new BigDecimal(1.29)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal highDecima = highBigDecimal.multiply(new BigDecimal(1.29)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wide = wideDecima.doubleValue();
|
|
|
+ high = highDecima.doubleValue();
|
|
|
+ }else {
|
|
|
+ //获取图片本身大小 设置默认值
|
|
|
+ URL url = new URL(signatureFileUrl);
|
|
|
+ URLConnection urlConnection = url.openConnection();
|
|
|
+ InputStream inputStreamByUrl = urlConnection.getInputStream();
|
|
|
+ //InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(signatureFileUrl);
|
|
|
+ BufferedImage image = ImageIO.read(inputStreamByUrl);
|
|
|
+ wide = Double.valueOf(image.getWidth());
|
|
|
+ high = Double.valueOf(image.getHeight());
|
|
|
+ BigDecimal wideBigDecimal = new BigDecimal(wide);
|
|
|
+ BigDecimal highBigDecimal = new BigDecimal(high);
|
|
|
+ if(wide.equals(high)){
|
|
|
+ wide = 170.00;
|
|
|
+ high = 170.00;
|
|
|
+ }else if(Double.compare(wide, high) > 0 ){
|
|
|
+ BigDecimal ratio = new BigDecimal(30);
|
|
|
+ BigDecimal scaleFactor = ratio.divide(highBigDecimal,2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wide = wideBigDecimal.multiply(scaleFactor).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ high = 30.00;
|
|
|
+ }else {
|
|
|
+ BigDecimal ratio = new BigDecimal(170);
|
|
|
+ BigDecimal scaleFactor = ratio.divide(highBigDecimal,2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wide = wideBigDecimal.multiply(scaleFactor).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ high = 170.00;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userVO.setWide(wide);
|
|
|
+ userVO.setHigh(high);
|
|
|
}
|
|
|
//获取角色信息
|
|
|
if (StringUtils.isNotEmpty(userVO.getRoleId())) {
|