Browse Source

师傅签名确认书调整

FengChaoYu 3 months ago
parent
commit
434c95d939

+ 16 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/worker/WorkerSignResultBean.java

@@ -0,0 +1,16 @@
+package com.gree.mall.miniapp.bean.worker;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel
+public class WorkerSignResultBean {
+
+    @ApiModelProperty(value = "结果")
+    private Boolean status;
+
+    @ApiModelProperty(value = "原因")
+    private String reason;
+}

+ 3 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/constant/Constant.java

@@ -64,6 +64,9 @@ public class Constant {
         public final static String QUERY_ALLINPAY_ORDER = "jsm:sxb:lock:a:query:order:";
         public final static String QUERY_ALLINPAY_ORDER = "jsm:sxb:lock:a:query:order:";
         public static final String PARTS_SALES = "jsm:sxb:lock:parts:sales:";
         public static final String PARTS_SALES = "jsm:sxb:lock:parts:sales:";
         public static final String WRITE_SALES_ITEM = "jsm:sxb:parts:write:sales:item:";
         public static final String WRITE_SALES_ITEM = "jsm:sxb:parts:write:sales:item:";
+
+        // 师傅签确认书次数
+        public final static String WORKER_SIGN_CONFIRM = "jsm:sxb:lock:worker:sign:confirm:";
     }
     }
 
 
     //礼品卡支持的市
     //礼品卡支持的市

+ 11 - 3
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/user/WorkerController.java

@@ -7,6 +7,7 @@ import com.gree.mall.miniapp.bean.policy.PolicyDetail;
 import com.gree.mall.miniapp.bean.policy.PolicyOrderDetail;
 import com.gree.mall.miniapp.bean.policy.PolicyOrderDetail;
 import com.gree.mall.miniapp.bean.policy.WorkerRemind;
 import com.gree.mall.miniapp.bean.policy.WorkerRemind;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
+import com.gree.mall.miniapp.bean.worker.WorkerSignResultBean;
 import com.gree.mall.miniapp.constant.Constant;
 import com.gree.mall.miniapp.constant.Constant;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.helper.ResponseHelper;
 import com.gree.mall.miniapp.helper.ResponseHelper;
@@ -153,7 +154,7 @@ public class WorkerController {
 
 
     @PostMapping("/ocr/handwriting")
     @PostMapping("/ocr/handwriting")
     @ApiOperation(value = "师傅签名手写OCR识别")
     @ApiOperation(value = "师傅签名手写OCR识别")
-    public ResponseHelper<Boolean> ocrHandwriting(
+    public ResponseHelper<WorkerSignResultBean> ocrHandwriting(
             @ApiParam(required = true, value = "拼接附件") @RequestParam MultipartFile file,
             @ApiParam(required = true, value = "拼接附件") @RequestParam MultipartFile file,
             @ApiParam(required = true, value = "签名附件") @RequestParam MultipartFile signFile,
             @ApiParam(required = true, value = "签名附件") @RequestParam MultipartFile signFile,
             @ApiParam(required = true, value = "签名附件base64") @RequestParam String signFile2,
             @ApiParam(required = true, value = "签名附件base64") @RequestParam String signFile2,
@@ -165,7 +166,7 @@ public class WorkerController {
             throw new RemoteServiceException("请稍候提交...");
             throw new RemoteServiceException("请稍候提交...");
         }
         }
         try {
         try {
-            Boolean result = workerLogic.ocrHandwriting(file, signFile, signFile2, type);
+            WorkerSignResultBean result = workerLogic.ocrHandwriting(file, signFile, signFile2, type);
             return ResponseHelper.success(result);
             return ResponseHelper.success(result);
         } catch(Exception e) {
         } catch(Exception e) {
             log.error("【师傅签名手写OCR识别处理】失败", e);
             log.error("【师傅签名手写OCR识别处理】失败", e);
@@ -173,8 +174,15 @@ public class WorkerController {
         } finally {
         } finally {
             obtain.unlock();
             obtain.unlock();
         }
         }
+    }
 
 
-
+    @PostMapping("/check/manual/sign/confirm")
+    @ApiOperation(value = "检查人工审核师傅签名确认书")
+    public ResponseHelper<Boolean> signConfirm(
+            @ApiParam(required = true, value = "地区 gz=广州 fs=佛山") @RequestParam String type
+    ) throws Exception {
+        Boolean result = workerLogic.checkManualSignConfirm(type);
+        return ResponseHelper.success(result);
     }
     }
 
 
     @PostMapping("/sign/confirm")
     @PostMapping("/sign/confirm")

+ 66 - 8
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/policy/WorkerLogic.java

@@ -11,17 +11,16 @@ import com.gree.mall.miniapp.bean.policy.PolicyDetail;
 import com.gree.mall.miniapp.bean.policy.PolicyOrderDetail;
 import com.gree.mall.miniapp.bean.policy.PolicyOrderDetail;
 import com.gree.mall.miniapp.bean.policy.WorkerRemind;
 import com.gree.mall.miniapp.bean.policy.WorkerRemind;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
+import com.gree.mall.miniapp.bean.worker.WorkerSignResultBean;
 import com.gree.mall.miniapp.constant.Constant;
 import com.gree.mall.miniapp.constant.Constant;
-import com.gree.mall.miniapp.enums.ExamineWorkerStatusEnum;
-import com.gree.mall.miniapp.enums.IsYesNoEnum;
-import com.gree.mall.miniapp.enums.PolicyOrderStutasEnum;
-import com.gree.mall.miniapp.enums.UserTypeEnum;
+import com.gree.mall.miniapp.enums.*;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.logic.common.CommonLogic;
 import com.gree.mall.miniapp.logic.common.CommonLogic;
 import com.gree.mall.miniapp.logic.common.outside.WechatLogic;
 import com.gree.mall.miniapp.logic.common.outside.WechatLogic;
 import com.gree.mall.miniapp.plus.entity.*;
 import com.gree.mall.miniapp.plus.entity.*;
 import com.gree.mall.miniapp.plus.service.*;
 import com.gree.mall.miniapp.plus.service.*;
 import com.gree.mall.miniapp.utils.IpUtil;
 import com.gree.mall.miniapp.utils.IpUtil;
+import com.gree.mall.miniapp.utils.RedisUtil;
 import com.gree.mall.miniapp.utils.StringUtil;
 import com.gree.mall.miniapp.utils.StringUtil;
 import com.gree.mall.miniapp.utils.ocr.OCRUtil;
 import com.gree.mall.miniapp.utils.ocr.OCRUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
@@ -87,6 +86,12 @@ public class WorkerLogic {
     @Autowired
     @Autowired
     WorkerSignConfirmService workerSignConfirmService;
     WorkerSignConfirmService workerSignConfirmService;
 
 
+    @Autowired
+    WorkerSignConfirmManualService workerSignConfirmManualService;
+
+    @Autowired
+    RedisUtil redisUtil;
+
 
 
 
 
     public List<WorkerRemind> remind() {
     public List<WorkerRemind> remind() {
@@ -616,7 +621,8 @@ public class WorkerLogic {
         return new ArrayList<>();
         return new ArrayList<>();
     }
     }
 
 
-    public Boolean ocrHandwriting(MultipartFile joinFile, MultipartFile signFile, String signFile2, String type) throws Exception {
+    public WorkerSignResultBean ocrHandwriting(MultipartFile joinFile, MultipartFile signFile, String signFile2, String type) throws Exception {
+        WorkerSignResultBean bean = new WorkerSignResultBean();
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
         final User user = currentCompanyWechat.getUser();
         final User user = currentCompanyWechat.getUser();
         if (!user.getType().equals(UserTypeEnum.WORKER.getKey())) {
         if (!user.getType().equals(UserTypeEnum.WORKER.getKey())) {
@@ -625,7 +631,7 @@ public class WorkerLogic {
 
 
         String code = type.equals("gz") ? Constant.gree.GUANGZHOUXIAOSI : Constant.gree.FOSHANXIAOSI;
         String code = type.equals("gz") ? Constant.gree.GUANGZHOUXIAOSI : Constant.gree.FOSHANXIAOSI;
         String companyName = type.equals("gz") ? "广州" : "佛山";
         String companyName = type.equals("gz") ? "广州" : "佛山";
-        final Integer count = workerSignConfirmService.lambdaQuery()
+        Integer count = workerSignConfirmService.lambdaQuery()
                 .eq(WorkerSignConfirm::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
                 .eq(WorkerSignConfirm::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
                 .eq(WorkerSignConfirm::getBelongCompanyCode, code)
                 .eq(WorkerSignConfirm::getBelongCompanyCode, code)
                 .eq(WorkerSignConfirm::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
                 .eq(WorkerSignConfirm::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
@@ -633,6 +639,16 @@ public class WorkerLogic {
         if (count > 0) {
         if (count > 0) {
             throw new RemoteServiceException("已签" + companyName + "的确认书");
             throw new RemoteServiceException("已签" + companyName + "的确认书");
         }
         }
+
+        count = workerSignConfirmManualService.lambdaQuery()
+                .eq(WorkerSignConfirmManual::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
+                .eq(WorkerSignConfirmManual::getBelongCompanyCode, code)
+                .eq(WorkerSignConfirmManual::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
+                .eq(WorkerSignConfirmManual::getStatus, ExamineStatusEnum.WAIT.getKey())
+                .count();
+        if (count > 0) {
+            throw new RemoteServiceException("待人工审核" + companyName + "的确认书");
+        }
 //        String path = System.getProperty("user.dir");
 //        String path = System.getProperty("user.dir");
         // 生成的文件的存放路径
         // 生成的文件的存放路径
 
 
@@ -666,8 +682,32 @@ public class WorkerLogic {
 //        final String name = ocrUtil.handwritingORC(new ByteArrayInputStream(baos.toByteArray()));
 //        final String name = ocrUtil.handwritingORC(new ByteArrayInputStream(baos.toByteArray()));
         String name = ocrUtil.handwritingORC(signFile2);
         String name = ocrUtil.handwritingORC(signFile2);
         log.info("OCR识别名称:" + name + ", 师傅名称:" + user.getNickName());
         log.info("OCR识别名称:" + name + ", 师傅名称:" + user.getNickName());
+
+        final String key = Constant.RedisPrefix.WORKER_SIGN_CONFIRM + user.getWorkerNumber();
         if (!StrUtil.equals(name, user.getNickName().replace(" ", ""))) {
         if (!StrUtil.equals(name, user.getNickName().replace(" ", ""))) {
-            return false;
+            final long signFailCount = redisUtil.incr(key, 1);
+            redisUtil.expire(key, 24 * 60 * 60);
+            if (signFailCount > 5) {
+                final CommonFile commonFile = commonLogic.uploadWorkerConfirmFile(joinFile);
+                WorkerSignConfirmManual confirmManual = new WorkerSignConfirmManual();
+                confirmManual.setCompanyWechatId(currentCompanyWechat.getCompanyWechatId())
+                        .setBelongCompanyCode(code)
+                        .setBelongCompanyName(companyName)
+                        .setWorkerNumber(user.getWorkerNumber())
+                        .setNickName(user.getNickName())
+                        .setMobile(user.getMobile())
+                        .setIdCard(user.getIdCard())
+                        .setName(type.equals("gz") ? "广州嘉讯茂辅材费用确认书" : "佛山嘉讯茂辅材费用确认书")
+                        .setUrl(commonFile.getUrl())
+                        .setStatus(ExamineStatusEnum.WAIT.getKey())
+                        .insert();
+                bean.setStatus(false);
+                bean.setReason("手写文字识别结果:" + name + ", 5次识别失败转人工审核");
+                return bean;
+            }
+            bean.setStatus(false);
+            bean.setReason("手写文字识别结果:" + name);
+            return bean;
         }
         }
 
 
         final CommonFile commonFile = commonLogic.uploadWorkerConfirmFile(joinFile);
         final CommonFile commonFile = commonLogic.uploadWorkerConfirmFile(joinFile);
@@ -680,13 +720,16 @@ public class WorkerLogic {
                 .setName(type.equals("gz") ? "广州嘉讯茂辅材费用确认书" : "佛山嘉讯茂辅材费用确认书")
                 .setName(type.equals("gz") ? "广州嘉讯茂辅材费用确认书" : "佛山嘉讯茂辅材费用确认书")
                 .setUrl(commonFile.getUrl())
                 .setUrl(commonFile.getUrl())
                 .insert();
                 .insert();
+
+        redisUtil.del(key);
 //        userService.lambdaUpdate()
 //        userService.lambdaUpdate()
 //                .set(type.equals("gz"), User::getWorkerSignGz, commonFile.getUrl())
 //                .set(type.equals("gz"), User::getWorkerSignGz, commonFile.getUrl())
 //                .set(type.equals("fs"), User::getWorkerSignFs, commonFile.getUrl())
 //                .set(type.equals("fs"), User::getWorkerSignFs, commonFile.getUrl())
 //                .eq(User::getUserId, user.getUserId())
 //                .eq(User::getUserId, user.getUserId())
 //                .update();
 //                .update();
 
 
-        return true;
+        bean.setStatus(true);
+        return bean;
     }
     }
 
 
     public List<WorkerSignConfirm> signConfirm() {
     public List<WorkerSignConfirm> signConfirm() {
@@ -696,4 +739,19 @@ public class WorkerLogic {
                 .eq(WorkerSignConfirm::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
                 .eq(WorkerSignConfirm::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
                 .list();
                 .list();
     }
     }
+
+    public Boolean checkManualSignConfirm(String type) {
+        CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
+        String code = type.equals("gz") ? Constant.gree.GUANGZHOUXIAOSI : Constant.gree.FOSHANXIAOSI;
+        Integer count = workerSignConfirmManualService.lambdaQuery()
+                .eq(WorkerSignConfirmManual::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
+                .eq(WorkerSignConfirmManual::getBelongCompanyCode, code)
+                .eq(WorkerSignConfirmManual::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
+                .eq(WorkerSignConfirmManual::getStatus, ExamineStatusEnum.WAIT.getKey())
+                .count();
+        if (count > 0) {
+            return false;
+        }
+        return true;
+    }
 }
 }

+ 56 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/worker/WorkerElecConfirmManualVO.java

@@ -0,0 +1,56 @@
+package com.gree.mall.manager.bean.worker;
+
+import com.gree.mall.manager.annotation.ZfireField;
+import com.gree.mall.manager.enums.ExamineStatusEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@ApiModel
+@ZfireField(tbName = "a")
+public class WorkerElecConfirmManualVO {
+
+    @ZfireField(hide = true)
+    private String id;
+
+    @ApiModelProperty(value = "所属公司编号")
+    private String belongCompanyCode;
+
+    @ApiModelProperty(value = "所属公司")
+    private String belongCompanyName;
+
+    @ApiModelProperty(value = "师傅编号")
+    private String workerNumber;
+
+    @ApiModelProperty(value = "师傅名称")
+    private String nickName;
+
+    @ApiModelProperty(value = "师傅手机号")
+    private String mobile;
+
+    @ApiModelProperty(value = "师傅身份证")
+    private String idCard;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "url")
+    private String url;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "文件名称")
+    private String name;
+
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    @ApiModelProperty(value = "状态")
+    private ExamineStatusEnum status;
+
+    @ApiModelProperty(value = "审核人")
+    private String confirmBy;
+
+    @ApiModelProperty(value = "审核时间")
+    private Date confirmTime;
+}

+ 5 - 2
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/CommonMapper.java

@@ -31,6 +31,7 @@ import com.gree.mall.manager.bean.settle.SettleExpenseVO;
 import com.gree.mall.manager.bean.settle.SettleMonthWagesVO;
 import com.gree.mall.manager.bean.settle.SettleMonthWagesVO;
 import com.gree.mall.manager.bean.settle.SettleMonthWagesWorkerVO;
 import com.gree.mall.manager.bean.settle.SettleMonthWagesWorkerVO;
 import com.gree.mall.manager.bean.settle.repair.*;
 import com.gree.mall.manager.bean.settle.repair.*;
+import com.gree.mall.manager.bean.worker.WorkerElecConfirmManualVO;
 import com.gree.mall.manager.bean.worker.WorkerElecConfirmVO;
 import com.gree.mall.manager.bean.worker.WorkerElecConfirmVO;
 import com.gree.mall.manager.bean.worker.WorkerTeamVO;
 import com.gree.mall.manager.bean.worker.WorkerTeamVO;
 import com.gree.mall.manager.bean.workorder.*;
 import com.gree.mall.manager.bean.workorder.*;
@@ -751,8 +752,10 @@ public interface CommonMapper {
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     Integer workerManagerCheckCount(@Param("ex")WorkerParamBean zfireParamBean);
     Integer workerManagerCheckCount(@Param("ex")WorkerParamBean zfireParamBean);
 
 
-    IPage<WorkerElecConfirmVO> workerSignConfirmPage(Page page,
-                                                     @Param("ex") ZfireParamBean zfireParamBean);
+    IPage<WorkerElecConfirmVO> workerSignConfirmPage(Page page, @Param("ex") ZfireParamBean zfireParamBean);
+
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     Integer workerSignConfirmCount();
     Integer workerSignConfirmCount();
+
+    IPage<WorkerElecConfirmManualVO> workerSignConfirmManualPage(Page page, @Param("ex") ZfireParamBean zfireParamBean);
 }
 }

+ 3 - 0
mall-server-api/src/main/java/com/gree/mall/manager/constant/Constant.java

@@ -115,6 +115,9 @@ public class Constant {
 
 
         public final static String LETTER_NUMBER = "LETTER_NUMBER:MALL:";
         public final static String LETTER_NUMBER = "LETTER_NUMBER:MALL:";
         public final static String LETTER_NUMBER_FS = "LETTER_NUMBER_FS:MALL:";
         public final static String LETTER_NUMBER_FS = "LETTER_NUMBER_FS:MALL:";
+
+        // 师傅签确认书次数
+        public final static String WORKER_SIGN_CONFIRM = "jsm:sxb:lock:worker:sign:confirm:";
     }
     }
     public class ChatMessage {
     public class ChatMessage {
         public final static String MSG_TYPE_DOC = "docmsg";
         public final static String MSG_TYPE_DOC = "docmsg";

+ 49 - 1
mall-server-api/src/main/java/com/gree/mall/manager/controller/worker/WorkerElecConfirmController.java

@@ -3,21 +3,28 @@ package com.gree.mall.manager.controller.worker;
 import cn.hutool.core.lang.TypeReference;
 import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.gree.mall.manager.annotation.ZfireList;
 import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.worker.WorkerElecConfirmManualVO;
 import com.gree.mall.manager.bean.worker.WorkerElecConfirmVO;
 import com.gree.mall.manager.bean.worker.WorkerElecConfirmVO;
+import com.gree.mall.manager.constant.Constant;
+import com.gree.mall.manager.enums.ExamineStatusEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.worker.WorkerElecConfirmLogic;
 import com.gree.mall.manager.logic.worker.WorkerElecConfirmLogic;
+import com.gree.mall.manager.plus.entity.WorkerSignConfirmManual;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.integration.redis.util.RedisLockRegistry;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
 
 
 @Slf4j
 @Slf4j
 @RestController
 @RestController
@@ -27,6 +34,8 @@ public class WorkerElecConfirmController {
 
 
     @Resource
     @Resource
     WorkerElecConfirmLogic workerElecConfirmLogic;
     WorkerElecConfirmLogic workerElecConfirmLogic;
+    @Resource
+    RedisLockRegistry redisLockRegistry;
 
 
     @ZfireList
     @ZfireList
     @PostMapping("/list")
     @PostMapping("/list")
@@ -57,9 +66,48 @@ public class WorkerElecConfirmController {
     }
     }
 
 
     @PostMapping("/count")
     @PostMapping("/count")
-    @ApiOperation("详情")
+    @ApiOperation("统计")
     public ResponseHelper<Integer> count() throws RemoteServiceException {
     public ResponseHelper<Integer> count() throws RemoteServiceException {
         Integer count = workerElecConfirmLogic.count();
         Integer count = workerElecConfirmLogic.count();
         return ResponseHelper.success(count);
         return ResponseHelper.success(count);
     }
     }
+
+    @ZfireList
+    @PostMapping("/manual/list")
+    @ApiOperation(value = "人工列表")
+    public ResponseHelper<IPage<WorkerElecConfirmManualVO>> manualList(@RequestBody ZfireParamBean zfireParamBean) {
+        IPage<WorkerElecConfirmManualVO> list = workerElecConfirmLogic.manualList(zfireParamBean);
+        return ResponseHelper.success(list, new TypeReference<WorkerElecConfirmManualVO>() {
+        });
+    }
+
+    @PostMapping("/manual/detail")
+    @ApiOperation("详情")
+    public ResponseHelper<WorkerSignConfirmManual> manualDetail(
+            @ApiParam(value = "id", required = true) @RequestParam String id
+    ) throws RemoteServiceException {
+        WorkerSignConfirmManual detail = workerElecConfirmLogic.manualDetail(id);
+        return ResponseHelper.success(detail);
+    }
+
+    @PostMapping("/manual/confirm")
+    @ApiOperation("详情")
+    public ResponseHelper manualConfirm(
+            @ApiParam(value = "id", required = true) @RequestParam String id,
+            @ApiParam(value = "状态 OK=通过 FAIL=驳回", required = true) @RequestParam ExamineStatusEnum status
+    ) throws Exception {
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_ORDER + id);
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
+            throw new RemoteServiceException("记录冻结中");
+        }
+        try {
+            workerElecConfirmLogic.manualConfirm(id, status);
+            return ResponseHelper.success();
+        } catch (Exception e) {
+            log.error("【人工审核处理】失败", e);
+            throw e;
+        } finally {
+            obtain.unlock();
+        }
+    }
 }
 }

+ 59 - 4
mall-server-api/src/main/java/com/gree/mall/manager/logic/worker/WorkerElecConfirmLogic.java

@@ -1,24 +1,28 @@
 package com.gree.mall.manager.logic.worker;
 package com.gree.mall.manager.logic.worker;
 
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.worker.WorkerElecConfirmManualVO;
 import com.gree.mall.manager.bean.worker.WorkerElecConfirmVO;
 import com.gree.mall.manager.bean.worker.WorkerElecConfirmVO;
 import com.gree.mall.manager.commonmapper.CommonMapper;
 import com.gree.mall.manager.commonmapper.CommonMapper;
+import com.gree.mall.manager.enums.ExamineStatusEnum;
 import com.gree.mall.manager.enums.WorkerElecSingConfirmEnum;
 import com.gree.mall.manager.enums.WorkerElecSingConfirmEnum;
+import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.SysDictCompany;
 import com.gree.mall.manager.plus.entity.SysDictCompany;
 import com.gree.mall.manager.plus.entity.User;
 import com.gree.mall.manager.plus.entity.User;
 import com.gree.mall.manager.plus.entity.WorkerSignConfirm;
 import com.gree.mall.manager.plus.entity.WorkerSignConfirm;
-import com.gree.mall.manager.plus.service.SysDictCompanyService;
-import com.gree.mall.manager.plus.service.UserService;
-import com.gree.mall.manager.plus.service.WebsitUserService;
-import com.gree.mall.manager.plus.service.WorkerSignConfirmService;
+import com.gree.mall.manager.plus.entity.WorkerSignConfirmManual;
+import com.gree.mall.manager.plus.service.*;
+import com.gree.mall.manager.utils.RedisUtil;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 
 import java.util.Objects;
 import java.util.Objects;
 
 
@@ -30,9 +34,11 @@ public class WorkerElecConfirmLogic {
     private final CommonLogic commonLogic;
     private final CommonLogic commonLogic;
     private final CommonMapper commonMapper;
     private final CommonMapper commonMapper;
     private final WorkerSignConfirmService workerSignConfirmService;
     private final WorkerSignConfirmService workerSignConfirmService;
+    private final WorkerSignConfirmManualService workerSignConfirmManualService;
     private final WebsitUserService websitUserService;
     private final WebsitUserService websitUserService;
     private final UserService userService;
     private final UserService userService;
     private final SysDictCompanyService sysDictCompanyService;
     private final SysDictCompanyService sysDictCompanyService;
+    private final RedisUtil redisUtil;
 
 
     public IPage<WorkerElecConfirmVO> list(ZfireParamBean zfireParamBean) {
     public IPage<WorkerElecConfirmVO> list(ZfireParamBean zfireParamBean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         AdminUserCom adminUser = commonLogic.getAdminUser();
@@ -85,4 +91,53 @@ public class WorkerElecConfirmLogic {
     public Integer count() {
     public Integer count() {
         return commonMapper.workerSignConfirmCount();
         return commonMapper.workerSignConfirmCount();
     }
     }
+
+    // 师傅签确认书次数
+    public final static String WORKER_SIGN_CONFIRM = "jsm:sxb:lock:worker:sign:confirm:";
+
+    public IPage<WorkerElecConfirmManualVO> manualList(ZfireParamBean zfireParamBean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        FieldUtils.materialParam(zfireParamBean, WorkerElecConfirmManualVO.class, adminUser);
+
+        return commonMapper.workerSignConfirmManualPage(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
+
+    }
+
+    public WorkerSignConfirmManual manualDetail(String id) {
+        return workerSignConfirmManualService.getById(id);
+    }
+
+    @Transactional
+    public void manualConfirm(String id, ExamineStatusEnum status) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        final WorkerSignConfirmManual manual = workerSignConfirmManualService.getById(id);
+
+        final Integer count = workerSignConfirmService.lambdaQuery()
+                .eq(WorkerSignConfirm::getCompanyWechatId, manual.getCompanyWechatId())
+                .eq(WorkerSignConfirm::getBelongCompanyCode, manual.getBelongCompanyCode())
+                .eq(WorkerSignConfirm::getWorkerNumber, manual.getWorkerNumber())
+                .count();
+
+        if (count > 0) {
+            throw new RemoteServiceException(manual.getNickName() + "师傅签名记录已存在");
+        }
+
+       manual.setConfirmBy(adminUser.getNickName())
+                .setConfirmTime(DateUtil.date())
+                .setStatus(status.getKey());
+
+        if (status.getKey().equals(ExamineStatusEnum.OK.getKey())) {
+            WorkerSignConfirm confirm = new WorkerSignConfirm();
+            confirm.setCompanyWechatId(manual.getCompanyWechatId())
+                    .setBelongCompanyCode(manual.getBelongCompanyCode())
+                    .setBelongCompanyName(manual.getBelongCompanyName())
+                    .setWorkerNumber(manual.getWorkerNumber())
+                    .setName(manual.getName())
+                    .setUrl(manual.getUrl())
+                    .insert();
+        }
+
+
+        redisUtil.del(WORKER_SIGN_CONFIRM + manual.getWorkerNumber());
+    }
 }
 }

+ 12 - 0
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -1699,6 +1699,18 @@
             b.belong_company_code,
             b.belong_company_code,
             a.worker_number
             a.worker_number
     </select>
     </select>
+    <select id="workerSignConfirmManualPage"
+            resultType="com.gree.mall.manager.bean.worker.WorkerElecConfirmManualVO">
+        SELECT
+        ${ex.selected}
+        FROM
+            worker_sign_confirm_manual a
+        ${ex.query}
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 
 
 
 
 </mapper>
 </mapper>