FengChaoYu hai 3 meses
pai
achega
286d348d38

+ 27 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/user/WorkerController.java

@@ -6,7 +6,11 @@ import com.gree.mall.miniapp.bean.PayDetail;
 import com.gree.mall.miniapp.bean.policy.PolicyDetail;
 import com.gree.mall.miniapp.bean.policy.PolicyOrderDetail;
 import com.gree.mall.miniapp.bean.policy.WorkerRemind;
+import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
+import com.gree.mall.miniapp.constant.Constant;
+import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.helper.ResponseHelper;
+import com.gree.mall.miniapp.logic.common.CommonLogic;
 import com.gree.mall.miniapp.logic.policy.WorkerLogic;
 import com.gree.mall.miniapp.plus.entity.*;
 import io.swagger.annotations.Api;
@@ -14,6 +18,7 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.integration.redis.util.RedisLockRegistry;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -23,6 +28,8 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
 
 @Slf4j
 @RestController
@@ -32,6 +39,10 @@ public class WorkerController {
 
     @Autowired
     WorkerLogic workerLogic;
+    @Autowired
+    CommonLogic commonLogic;
+    @Autowired
+    RedisLockRegistry redisLockRegistry;
 
 
     @PostMapping("/remind")
@@ -148,8 +159,22 @@ public class WorkerController {
             @ApiParam(required = true, value = "签名附件base64") @RequestParam String signFile2,
             @ApiParam(required = true, value = "地区 gz=广州 fs=佛山") @RequestParam String type
     ) throws Exception {
-        Boolean result = workerLogic.ocrHandwriting(file, signFile, signFile2, type);
-        return ResponseHelper.success(result);
+        CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_ORDER + currentCompanyWechat.getUserId());
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
+            throw new RemoteServiceException("请稍候提交...");
+        }
+        try {
+            Boolean result = workerLogic.ocrHandwriting(file, signFile, signFile2, type);
+            return ResponseHelper.success(result);
+        } catch(Exception e) {
+            log.error("【师傅签名手写OCR识别处理】失败", e);
+            throw e;
+        } finally {
+            obtain.unlock();
+        }
+
+
     }
 
     @PostMapping("/sign/confirm")

+ 13 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/policy/WorkerLogic.java

@@ -622,6 +622,17 @@ public class WorkerLogic {
         if (!user.getType().equals(UserTypeEnum.WORKER.getKey())) {
             throw new RemoteServiceException("非“师傅”类型账号, 操作失败");
         }
+
+        String code = type.equals("gz") ? Constant.gree.GUANGZHOUXIAOSI : Constant.gree.FOSHANXIAOSI;
+        String companyName = type.equals("gz") ? "广州" : "佛山";
+        final Integer count = workerSignConfirmService.lambdaQuery()
+                .eq(WorkerSignConfirm::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
+                .eq(WorkerSignConfirm::getBelongCompanyCode, code)
+                .eq(WorkerSignConfirm::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
+                .count();
+        if (count > 0) {
+            throw new RemoteServiceException("已签" + companyName + "的确认书");
+        }
 //        String path = System.getProperty("user.dir");
         // 生成的文件的存放路径
 
@@ -663,8 +674,8 @@ public class WorkerLogic {
 
         WorkerSignConfirm confirm = new WorkerSignConfirm();
         confirm.setCompanyWechatId(currentCompanyWechat.getCompanyWechatId())
-                .setBelongCompanyCode(type.equals("gz") ? Constant.gree.GUANGZHOUXIAOSI : Constant.gree.FOSHANXIAOSI)
-                .setBelongCompanyName(type.equals("gz") ? "广州" : "佛山")
+                .setBelongCompanyCode(code)
+                .setBelongCompanyName(companyName)
                 .setWorkerNumber(user.getWorkerNumber())
                 .setName(type.equals("gz") ? "广州嘉讯茂辅材费用确认书" : "佛山嘉讯茂辅材费用确认书")
                 .setUrl(commonFile.getUrl())