Forráskód Böngészése

Merge branch 'master-nt' of https://git.flowbb.cn/RK-Dev/fqgz-server into master-nt

sakuya 2 éve
szülő
commit
109d40b4af

+ 54 - 240
eladmin-system/src/main/java/me/zhengjie/application/user/mini/controller/MiniUserController.java

@@ -1,274 +1,88 @@
 package me.zhengjie.application.user.mini.controller;
 
 import com.alibaba.fastjson.JSONObject;
+
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
+import me.zhengjie.application.bank.controller.BankAuthController;
+import me.zhengjie.application.bank.controller.vo.BankLoginVO;
 import me.zhengjie.application.bank.controller.vo.BankOrderVO;
+import me.zhengjie.application.bank.controller.vo.FileInfoVO;
+import me.zhengjie.application.bank.controller.vo.FileUploadVO;
+import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
 import me.zhengjie.application.user.vo.SmsVo;
 import me.zhengjie.application.user.vo.UserVo;
+import me.zhengjie.application.bank.service.BankLoginService;
 import me.zhengjie.application.bank.service.BankOrderService;
+import me.zhengjie.application.bank.service.FileInfoService;
 import me.zhengjie.application.bank.service.UserAXQInfoService;
 import me.zhengjie.application.user.service.ApiService;
 import me.zhengjie.application.user.service.UserOrderService;
 import me.zhengjie.base.ResponseDTO;
 import me.zhengjie.base.ResultCode;
 import me.zhengjie.base.mq.RedisCacheConfig;
+import me.zhengjie.base.util.DateUtils;
 import me.zhengjie.base.util.FileUploadUtil;
+import me.zhengjie.base.util.HandwritingUtil;
+import me.zhengjie.base.util.StatusEnum.StepStatusEnum;
 import me.zhengjie.dao.mybatis.OrderFileRepository;
+import me.zhengjie.dao.mybatis.UserAXQInfoRepository;
 import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
+import me.zhengjie.dao.mybatis.entity.UserAXQInfoEntity;
+
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
-import java.util.List;
 
+import java.util.ArrayList;
+import java.util.List;
+@Slf4j
 @RestController
 @RequestMapping("/minipro")
 public class MiniUserController {
 
 
-	@Autowired
-	private ApiService apiService;
-
-
-	@Autowired
-	OrderFileRepository orderFileRepository;
-
-	@Autowired
-	BankOrderService bankOrderService;
-	@Autowired
-    UserOrderService userOrderService;
-	@Autowired
-    UserAXQInfoService userAXQInfoService;
-	@Autowired
-	private RedisTemplate<String, String> redisTemplate;
-
-	/**
-	 * 
-	 * @param request
-	 * @return
-	 */
-	@AnonymousPostMapping("/sendSms")
-	public ResponseDTO<?> sendSms(@RequestBody String phonejson, HttpServletRequest request) {
-		JSONObject jsonObj = JSONObject.parseObject(phonejson);
-		String phone = jsonObj.getString("phone");
-		if (StringUtils.isEmpty(phone)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		return this.apiService.sendSms(request, phone);
-	}
-
-	@AnonymousPostMapping("/login")
-	public ResponseDTO<?> login(@RequestBody SmsVo sms) {
-		return this.apiService.login(sms);
-	}
-
-	@RequestMapping("/order/list")
-	public ResponseDTO<?> getOrderList(@Valid @RequestBody UserVo user) {
-
-		Integer startIndex = 1;
-
-		Integer size = Integer.MAX_VALUE;
-
-		List<BankOrderVO> list = this.apiService.getOrderList(user, startIndex, size);
-		return ResponseDTO.success(list);
-	}
-
-	@RequestMapping("/order/detail")
-	public ResponseDTO<?> getDetail(@RequestBody String json) {
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String businessNo = jsonObj.getString("businessNo");
-		String contractNo = jsonObj.getString("contractNo");
-		if (StringUtils.isEmpty(businessNo)||StringUtils.isEmpty(contractNo)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		BankOrderVO order = bankOrderService.getContractOrderWithBizNo(businessNo);
-		if (order == null) {
-			return ResponseDTO.error(ResultCode.ORDER_DATA_NOT_EXIST);
-		}
-		return ResponseDTO.success(order);
-	}
-	@RequestMapping("/order/search")
-	public ResponseDTO<?> orderSearch( @RequestBody BankOrderVO order ) {
-		 
-		if (order == null) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		 List<BankOrderVO> orders = this.apiService.getOrderByContion(order);
-		
-		return ResponseDTO.success(orders);
-	}
-
-//	@RequestMapping("/live/verify")
-//	public ResponseDTO<?> liveVerify(MultipartFile file, HttpServletRequest request) {
-//		return identityValidationService.liveVerify(file, request);
-//	}
-
-	@AnonymousPostMapping("/video/call")
-	public ResponseDTO<?> videoCall(@RequestBody String json) {
-		return this.apiService.videoCall(json);
-	}
-
-	@AnonymousPostMapping("/sendInfo")
-	public void sendInfo(@RequestBody String json) {
-		// 这里保存推送的数据
-		redisTemplate.convertAndSend(RedisCacheConfig.CHANNEL_WEB_SOCKET, json);
-	}
-
-	@RequestMapping("/order/pdf")
-	public ResponseDTO<?> getOrderPDF(@RequestBody String json) {
-
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String prodId = jsonObj.getString("prodId");
-		String businessNo = jsonObj.getString("businessNo");
-		if (StringUtils.isEmpty(prodId) || StringUtils.isEmpty(businessNo)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		ResponseDTO<?> order = this.apiService.getOrderPDF(businessNo,prodId);
-
-		return order;
-	}
-
-	@AnonymousPostMapping("/order/note")
-	public ResponseDTO<?> note(@RequestBody String json) {
-		
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String businessNo = jsonObj.getString("businessNo");
-		if (StringUtils.isEmpty(businessNo)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		//
-		OrderFileEntity orderFile = orderFileRepository.getOrderNote(businessNo);
-		// pdf的地址预览
-		String noteUrl = FileUploadUtil.getPreviewUrl(orderFile.getHtmlUrl());
-		
-		return ResponseDTO.success(noteUrl);
-	}
-
-	@RequestMapping("/video/complete")
-	public ResponseDTO<?> videoComplete(HttpServletRequest request) {
-		return this.apiService.videoComplete(request);
-	}
-
-//	@RequestMapping("/order/upfile")
-//	public ResponseDTO<?> appUpload(MultipartFile file, HttpServletRequest request) {
-//		return this.apiService.appUpload(file, request);
-//	}
-
-	// 功能点,云点播,视频通话,等杜
-//	@RequestMapping("/live/compare")
-//	public ResponseDTO<?> liveCompare(MultipartFile file, HttpServletRequest request) {
-//		return identityValidationService.liveCompare(file, request);
-//	}
-//
-//	@RequestMapping("/face/compare")
-//	public ResponseDTO<?> faceCompare(HttpServletRequest request) {
-//		return identityValidationService.faceCompare(request);
-//	}
-
-//	@RequestMapping("/pdf/sign")
-//	public ResponseDTO<?> sigin(MultipartFile file, Integer orderId) {
-//		// 判断订单号是否为空
-//		if (orderId == null) {
-//			return ResponseDTO.error(ResultCode.PARAM_NOT_COMPLETE);
-//		}
-//		return signService.sigin(file, orderId);
-//	}
-
-	@RequestMapping("/order/getFaceId")
-	public ResponseDTO<?> getFaceId(@RequestBody String json) throws Exception {
-
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String orderId = jsonObj.getString("orderId");
-		if (StringUtils.isEmpty(orderId)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-//		OrderDto order = this.apiService.getOrderDetail(orderId);
-//		JSONObject str = SdkTest.getFaceId(order.getUsername(), order.getIdCard(), orderId);
-		return ResponseDTO.success();
-	}
-
-	@RequestMapping("/order/updateStatus")
-	public ResponseDTO<?> updateOrderStatus(@RequestBody String json) throws Exception {
-
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String orderId = jsonObj.getString("orderId");
-		if (StringUtils.isEmpty(orderId)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		userOrderService.updateOrderStatus(orderId);
-
-		return ResponseDTO.success();
-	}
-
-	@RequestMapping("/axqRegister")
-	public ResponseDTO<?> axqRegister(@RequestBody String json) {
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String idCard = jsonObj.getString("idCard");
-		String phone = jsonObj.getString("phone");
-		String name = jsonObj.getString("name");
-		if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(phone) || StringUtils.isEmpty(name)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		return userAXQInfoService.registAXQUser(idCard, phone, name);
-	}
-
-	@RequestMapping("/getAuthStatus")
-	public ResponseDTO<?> getAuthStatus(@RequestBody String json) {
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String idCard = jsonObj.getString("idCard");
-		if (StringUtils.isEmpty(idCard)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		return userAXQInfoService.getAuthStatus(idCard);
-	}
-
-	@RequestMapping("/sendAuthMessage")
-	public ResponseDTO<?> sendAuthMessage(@RequestBody String json) {
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String idCard = jsonObj.getString("idCard");
-		if (StringUtils.isEmpty(idCard)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		return userAXQInfoService.sendAuthMessage(idCard);
-	}
-
-	@RequestMapping("/verifyAuthMessage")
-	public ResponseDTO<?> verifyAuthMessage(@RequestBody String json) {
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String idCard = jsonObj.getString("idCard");
-		String checkCode = jsonObj.getString("checkCode");
-		if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(checkCode)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		return userAXQInfoService.verifyAuthMessage(idCard, checkCode);
-	}
-
-	@RequestMapping("/uploadSeal")
-	public ResponseDTO<?> uploadSeal(@RequestBody String json) {
-//		JSONObject jsonObj = JSONObject.parseObject(json);
-//		String idCard = jsonObj.getString("idCard");
-//		String contractId = jsonObj.getString("contractId");
-//		String content = jsonObj.getString("content");
-//		if (StringUtils.isEmpty(idCard) || StringUtils.isEmpty(contractId) || StringUtils.isEmpty(content)) {
-//			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-//		}
-//		return userAXQInfoService.uploadSeal(idCard, contractId, content);
-		return null;
-	}
+    @Autowired
+    private Environment environment;
+    @Autowired
+    private  BankLoginService bankLoginService;
+    @Autowired
+    private  FileInfoService fileInfoService;
+    @Autowired
+    private  UserAXQInfoRepository userAXQInfoRepository;
+
+    /**
+     * 登录接口
+     *
+     * @param loginVo
+     * @return
+     */
+    @ApiOperation("登录")
+    @AnonymousPostMapping("/login")
+    public ResponseDTO<BankLoginVO> login(@Valid @RequestBody BankLoginVO loginVo) {
+        return bankLoginService.login(loginVo);
+    }
+
+    /**
+     * 得到业务编号
+     *
+     * @return
+     */
+    @RequestMapping("/businessNo")
+    public ResponseDTO<String> businessNo() {
+        String no = "110" + DateUtils.getNo();
+        return ResponseDTO.success(no);
+    }
 
-	@RequestMapping("/getNotarization")
-	public ResponseDTO<?> getNotarization(@RequestBody String json) {
-		JSONObject jsonObj = JSONObject.parseObject(json);
-		String businessNo = jsonObj.getString("businessNo");
-		if (StringUtils.isEmpty(businessNo)) {
-			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
-		}
-		OrderFileEntity orderFile = orderFileRepository.getOrderNotarization(businessNo);
-		return ResponseDTO.success(orderFile.getSignedPdfUrl());
-	}
 }

+ 71 - 0
eladmin-system/src/main/java/me/zhengjie/base/util/ImageUtil.java

@@ -0,0 +1,71 @@
+package me.zhengjie.base.util;
+
+
+import cn.hutool.core.io.IoUtil;
+import lombok.extern.slf4j.Slf4j;
+import net.coobird.thumbnailator.Thumbnails;
+import org.apache.commons.codec.binary.Base64;
+import sun.misc.BASE64Decoder;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * 图片压缩工具类
+ */
+@Slf4j
+public class ImageUtil {
+
+    /**
+     * 压缩base64编码至200k以内
+     *
+     * @param base64Img
+     * @return
+     */
+    public static String resizeImage(String base64Img) {
+        try {
+            BASE64Decoder decoder = new BASE64Decoder();
+            byte[] bytes1 = decoder.decodeBuffer(base64Img);
+            InputStream stream = new ByteArrayInputStream(bytes1);
+            BufferedImage src = ImageIO.read(stream);
+            //BufferedImage output = Thumbnails.of(src).size(src.getWidth() / 3, src.getHeight() / 3).asBufferedImage();
+            BufferedImage output = Thumbnails.of(src).size(300 , 300).asBufferedImage();
+            String base64 = imageToBase64(output);
+            if (base64.length() - base64.length() / 8 * 2 > 200000) {
+                output = Thumbnails.of(output).scale(1 / (base64.length() / 200000)).asBufferedImage();
+                base64 = imageToBase64(output);
+            }
+            return base64;
+        } catch (Exception e) {
+            return base64Img;
+        }
+    }
+
+    /**
+     * BufferedImage转换成base64,在这里需要设置图片格式,因为我需要jpg格式就设置了jpg
+     */
+    public static String imageToBase64(BufferedImage bufferedImage) {
+        Base64 encoder = new Base64();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            ImageIO.write(bufferedImage, "png", baos);
+        } catch (IOException e) {
+        }
+        return new String(encoder.encode((baos.toByteArray())));
+    }
+
+
+    /**
+     * 获取base64的kb大小
+     * @param base64
+     * @return
+     */
+    public static Integer imageSize(String base64){
+        Integer strLength = base64.length();
+        return (strLength-(strLength/8)*2)/1024;
+    }
+}

+ 13 - 0
eladmin-system/src/main/java/me/zhengjie/domain/notary/impl/NotaryDomainImpl.java

@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.application.admin.service.SmsTemplateService;
 import me.zhengjie.base.ResultCode;
 import me.zhengjie.base.face.FaceCompareUtil;
+import me.zhengjie.base.util.ImageUtil;
 import me.zhengjie.base.util.JuheServiceUtil;
 import me.zhengjie.base.util.tencent.utils.Img2Base64Util;
 import me.zhengjie.dao.mybatis.FaceCompareRepository;
@@ -61,6 +62,12 @@ public class NotaryDomainImpl implements NotaryDomain {
             return ResultCode.PARAM_IS_BLANK;
         }
         base64 = getBase64(base64);
+        //判断图片大小是否超过200KB
+        Integer size = ImageUtil.imageSize(base64);
+        log.info("接收的图片大小:{}",size);
+        if (size>=200){
+            base64 = ImageUtil.resizeImage(base64);
+        }
         String idCard = compareImageDomain.getIdCard();
         String nickName = compareImageDomain.getName();
         //根据业务编号获取订单 判断当事人名字
@@ -170,6 +177,12 @@ public class NotaryDomainImpl implements NotaryDomain {
             return ResultCode.PARAM_IS_BLANK;
         }
         base64 = getBase64(base64);
+        //判断图片大小是否超过200KB
+        Integer size = ImageUtil.imageSize(base64);
+        log.info("接收的图片大小:{}",size);
+        if (size>=200){
+            base64 = ImageUtil.resizeImage(base64);
+        }
         //先判断是银行客户经理还是当事人
         String roleId = compareImageDomain.getRoleId();
         SysUserEntity sysUserEntity = null;