yaozhixue 1 year ago
parent
commit
061f603deb

+ 5 - 2
src/main/java/com/zfire/jiasm/syncdata/service/UploadWorkeCertificateService.java

@@ -7,15 +7,18 @@ import java.text.ParseException;
 
 public interface UploadWorkeCertificateService {
 
-    void procesUploadWorkeCert();
+
 
     void procesInitWorkeBx() throws ParseException, IOException;
 
     void procesUploadWorkeBx();
+    void procesUploadWorkeCert();
+    void procesUploadWorkeFace();
 
 
     Boolean uploadWorkeBx(OutWorkerUpload owu);
     Boolean UploadWorkeCert(OutWorkerUpload owu);
+    Boolean uploadWorkeFace(OutWorkerUpload owu);
+
 
-    void procesUploadWorkeFace();
 }

+ 155 - 3
src/main/java/com/zfire/jiasm/syncdata/service/impl/UploadWorkeCertificateServiceImpl.java

@@ -499,10 +499,94 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
     }
 
     @Override
+    public Boolean uploadWorkeFace(OutWorkerUpload owu){
+        List<WorkerCertGree> wcgs = new ArrayList<>();
+        String fileo = "";
+
+        // 查看指定网点、师傅的人脸面像数据是否已生成
+        WorkerCertGree workerbx = workerCertGreeService.lambdaQuery()
+                .eq(WorkerCertGree::getWorkerId,owu.getWorkerId())
+                .eq(WorkerCertGree::getBrandWebsitId,owu.getBrandWebsitId())
+                .eq(WorkerCertGree::getCertFlag,9)
+                .last("limit 1").one();
+        // 已存在 无需再同步
+        if (workerbx != null){
+            return Boolean.TRUE;
+        }
+
+        // 提取品牌信息 用于多品牌数据同步目前仅格力,可以先不用做
+        Brand brand = baseService.getBrand();
+        if (brand == null) {
+            updateOutWorkerUploadError(owu,"格力品牌信息不存在");
+            return Boolean.FALSE;
+        }
+
+        // 获取指定师傅、网点的人脸面像
+        Worker item = workerService.lambdaQuery()
+                .eq(Worker::getWorkerId,owu.getWorkerId())
+                .one();
+
+        if (item == null){
+            updateOutWorkerUploadError(owu,"无人脸面像信息请核实Worker");
+            return Boolean.FALSE;
+        }
+        // 无人脸面像数据不处理
+        if (StringUtils.isEmpty(item.getOutAuthHeadImage())){
+            updateOutWorkerUploadError(owu,"师傅未人脸面像实名认证");
+            return Boolean.FALSE;
+        }
+        // 若存在待同步的暂不处理
+        if (StringUtils.isNotEmpty(item.getAuthHeadImage()) &&
+                StringUtils.isEmpty(item.getOutAuthHeadImage())){
+            updateOutWorkerUploadError(owu,"等待同步人脸面像信息信息");
+            return Boolean.FALSE;
+        }
+
+        try{
+            //  查看师傅是否已选中品牌商网点(这里只提取选中格力品牌商的师傅数据)
+            WorkerBrandAccount wbaRecord = workerBrandAccountService.lambdaQuery()
+                    .eq(WorkerBrandAccount::getWorkerId, owu.getWorkerId())
+                    .eq(WorkerBrandAccount::getBrandWebsitId, owu.getBrandWebsitId())
+                    .eq(WorkerBrandAccount::getGroupCompanyId, brand.getBrandId()).last("limit 1").one();
+
+            // 未选择品牌商
+            if (wbaRecord ==null ){
+                owu.setSyncStatus(99);
+                updateOutWorkerUploadError(owu,"师傅未选择格力品牌商信息");
+                return Boolean.FALSE;
+            }
+            // 上传
+            fileo = uploadInsureFace(item,wbaRecord);
+            // 同步失败
+            if (StringUtils.isEmpty(fileo)){
+                updateOutWorkerUploadError(owu,"同步师傅人脸面像失败【"+owu.getWebsitId() + "】");
+                return Boolean.FALSE;
+            }
+            // 生成网点保险数据实体
+            getWorkerCertFaceGree(wcgs, item, wbaRecord);
+
+            // 保存本地表
+            extractedUploadBxEnd(wcgs);
+            // 文件清除
+            delfile("", "", fileo);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            log.info("同步师傅人脸面像失败:【" + item.getWorkerId() + "】");
+            String msg = "同步师傅人脸面像失败:";
+            if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(ex.getMessage())){
+                msg = msg + ex.getMessage();
+            }
+            updateOutWorkerUploadError(owu,msg);
+            return Boolean.FALSE;
+        }
+
+        return Boolean.TRUE;
+    }
+
+    @Override
     public Boolean UploadWorkeCert(OutWorkerUpload owu){
         List<WorkerCertGree> workerbx = new ArrayList<>();
         List<String> workerbxList = new ArrayList<>();
-        Boolean isok = Boolean.TRUE;
         List<WorkerCertGree> wcgs = new ArrayList<>();
 
         // 提取师傅的证件数据
@@ -526,7 +610,6 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
         }
 
         for (WorkerCert item :recs){
-            isok = Boolean.FALSE;
             // 证件已同步无需再次同步或是更新
 
             // 若存在待同步的暂不处理
@@ -757,6 +840,19 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
         wcgs.add(awc);
     }
 
+    private void getWorkerCertFaceGree(List<WorkerCertGree> wcgs, Worker item, WorkerBrandAccount wdno) {
+        WorkerCertGree  awc = new WorkerCertGree();
+        awc.setWorkerCertGreeId(IdWorker.getIdStr());
+        awc.setWorkerId(wdno.getWorkerId());
+        awc.setBrandWebsitId(wdno.getBrandWebsitId());
+        awc.setCertName("人脸面像");
+        awc.setCertNo(item.getSafeNo());
+        awc.setCreateTime(new Date());
+        awc.setOutFileUrl(item.getOutAuthHeadImage());
+        publicService.setCertFlag(awc.getCertName(), awc);
+        wcgs.add(awc);
+    }
+
     @Transactional(rollbackFor = Exception.class)
     public void extractedBxEnd(List<WorkerCertGree> wcgs, WebsitWorker item) throws Exception {
         try{
@@ -1053,6 +1149,29 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
         return fileAdnPath;
     }
 
+    private String uploadInsureFace(Worker item,WorkerBrandAccount wdno) throws Exception {
+        String fileAdnPath = "";
+        String outInsureCert = "";
+        String bxf="";
+        String fileId = "";
+
+        // 路径
+        fileId = IdWorker.getIdStr() + ".jpeg";
+        fileAdnPath = publicService.pathToGree(fileId);
+        // 新文件 方便写入
+        File nFile = publicService.createf(fileAdnPath);
+        baseService.saveToFile(ossUtil.getUrlWw(item.getAuthHeadImage()),nFile);
+        bxf = uploadInitFileFace(fileAdnPath, fileId, wdno.getBrandWebsitId());
+        if (StringUtils.isEmpty(bxf)){
+            return bxf;
+        }
+        outInsureCert = bxf;
+        nFile.delete();
+
+        item.setOutAuthHeadImage(outInsureCert);
+        return fileAdnPath;
+    }
+
     private Boolean uploadFileexc(String fileo, String filet, String wdno,WorkerCert item) throws Exception {
         Boolean uploadfile = Boolean.TRUE;
         Boolean onlyone = Boolean.FALSE;
@@ -1371,7 +1490,6 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
                     // 生成对象
                     getSaveFileInfo(fidId, resultData, req);
                     GreeFileSaveHelper responses = greeLogic.greePostSaveFile(req);
-
                     if (responses.getStatusCode() == 200){
                         fileId = responses.getData().getId();
                     } else {
@@ -1389,6 +1507,40 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
         return fileId;
     }
 
+    private String uploadInitFileFace(String fileAdnPath, String fidId,String wdno) throws Exception {
+        String fileId="";
+        if (StringUtils.isNotEmpty(fileAdnPath)){
+            // 1: 获取签名信息
+            GreeFileResponseHelper response =  greeLogic.ossGetSignt(wdno,"GET");
+            if (response.getStatusCode() == 200){
+                ResultData resultData = JSONObject.parseObject(response.getData().toString(), ResultData.class);
+                resultData.getExtData().setDir(resultData.getExtData().getDir()+"/"+fidId);
+                // 2:文件上传
+                PostObjectSample ossPostObject = new PostObjectSample();
+                String result = ossPostObject.PostObject(fileAdnPath, resultData.getExtData());
+                // 3: 保存文件
+                if (StringUtils.isEmpty(result.trim())){
+                    Map<String,String>req = new HashMap<>();
+                    // 生成对象
+                    getSaveFileInfo(fidId, resultData, req);
+                    GreeFileSaveHelper responses = greeLogic.greePostSaveFile(req);
+                    if (responses.getStatusCode() == 200){
+                        fileId = responses.getData().getId();
+                    } else {
+                        // 失败
+                        log.info("保存人脸面像文件到格力总部失败");
+                    }
+                } else {
+                    log.info("人脸面像上传图片到OSS失败");
+                }
+            } else {
+                log.info("获取签名信息失败");
+            }
+        }
+
+        return fileId;
+    }
+
     private Integer getCount(List<WorkerBrandAccount> workerWdnos, Integer count) {
         for (WorkerBrandAccount w: workerWdnos){
             if (StringUtils.isEmpty(w.getBrandWebsitId())){

+ 17 - 4
src/main/java/com/zfire/jiasm/syncdata/service/impl/UploadWorkerTOGreeServiceImpl.java

@@ -186,7 +186,7 @@ public class UploadWorkerTOGreeServiceImpl implements UploadWorkerTOGreeService
                      * 1:身份证、2:保险,3:高空证(复审时间必填)  这三个条件必备否则无法同步
                      * 制冷证可以没有,如果填了复审时间则必填
                      */
-                    if (checkNecessary(item, workerCertificateInfo)){
+                    if (checkNecessary(item, workerCertificateInfo,worker)){
                         continue;
                     }
 
@@ -344,6 +344,10 @@ public class UploadWorkerTOGreeServiceImpl implements UploadWorkerTOGreeService
                 if (!uploadWorkeCertificateService.UploadWorkeCert(item)){
                     continue;
                 }
+
+                // 再同步人脸面像 非必备条件
+                uploadWorkeCertificateService.uploadWorkeFace(item);
+
             } catch (Exception ex) {
                 ex.printStackTrace();
                 String msg ="向总部同步师傅入驻指定网点证件失败";
@@ -448,7 +452,7 @@ public class UploadWorkerTOGreeServiceImpl implements UploadWorkerTOGreeService
                      * 1:身份证、2:保险,3:高空证(复审时间必填)  这三个条件必备否则无法同步
                      * 制冷证可以没有,如果填了复审时间则必填
                      */
-                    if (checkNecessary(item, workerCertificateInfo)){
+                    if (checkNecessary(item, workerCertificateInfo,worker)){
                         continue;
                     }
 
@@ -853,7 +857,7 @@ public class UploadWorkerTOGreeServiceImpl implements UploadWorkerTOGreeService
         return result;
     }
 
-    private Boolean checkNecessary(OutWorkerUpload item, WorkerCertificateInfo workerCertificateInfo) {
+    private Boolean checkNecessary(OutWorkerUpload item, WorkerCertificateInfo workerCertificateInfo,Worker worker) {
         if (StringUtils.isEmpty(workerCertificateInfo.getSfzbh())){
             updateWorkerUploadLag(item,"师傅缺失身份证信息,不上传");
             return Boolean.TRUE;
@@ -880,6 +884,14 @@ public class UploadWorkerTOGreeServiceImpl implements UploadWorkerTOGreeService
             }
         }
 
+        // 已进行人脸面像认证未上传不同步
+        if (StringUtils.isNotEmpty(worker.getAuthHeadImage()) &&
+                StringUtils.isEmpty(workerCertificateInfo.getFacepath())){
+            updateWorkerUploadLag(item,"师傅人脸面像待同步中");
+            return Boolean.TRUE;
+        }
+
+
         return Boolean.FALSE;
     }
 
@@ -1075,7 +1087,8 @@ public class UploadWorkerTOGreeServiceImpl implements UploadWorkerTOGreeService
                     !("制冷工证".equals(item.getCertName())) &&
                     !("驾驶证".equals(item.getCertName())) &&
                     !("电工证".equals(item.getCertName())) &&
-                    !("焊工证".equals(item.getCertName()))){
+                    !("焊工证".equals(item.getCertName())) &&
+                    !("人脸面像".equals(item.getCertName()))){
                 wcg= item;
                 WorkerCertificateOther other = new WorkerCertificateOther();
 

+ 2 - 2
src/main/java/com/zfire/jiasm/syncdata/upload/worker/UploadWorkBx.java

@@ -13,7 +13,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 
 /**
- * 同步师傅保险证件到格力总部 为师傅入驻总部网点做准备   更新到格力总部时由 UploadWorkerTOGree 完成
+ * 同步师傅保险证件到格力总部 为师傅入驻总部网点或证件更新做准备   更新到格力总部时由 UploadWorkerTOGree 完成
  * WebsitWorker.getInsureStatus=2 && isNotNull(WebsitWorker.getInsureFiles)
  * 网点证件表保存一份供同步师傅信息使用
  *
@@ -28,7 +28,7 @@ public class UploadWorkBx {
     UploadWorkeCertificateService uploadWorkeCertificateService;
 
 
-    /** 这里只上传保险证件到总部,为师傅入驻做准备
+    /** 这里只上传保险证件到总部,为师傅入驻新网点或证件更新做准备
      * 按师傅所在格力总部网点更新保险证件数据
      * 1:上传到格力总部网点
      * 2:本地保留一份

+ 2 - 2
src/main/java/com/zfire/jiasm/syncdata/upload/worker/UploadWorkeCertificate.java

@@ -12,7 +12,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 
 /**
- * 师傅证件照同步到格力总部 这里只用于同步证件,为师傅入驻新网点做准备
+ * 师傅证件照同步到格力总部 这里只用于同步证件,为师傅入驻新网点或证件更新做准备
  * 用于更新已入驻的网点证件照数据
  * 更新证件到格力总部(师傅已入驻 且平台网点与格力总部网点有对应关系)
  * .in(WorkerCert::getOutSyncStatus,0,99)
@@ -30,7 +30,7 @@ public class UploadWorkeCertificate {
 
 
     /**
-     * 师傅证件照同步到格力总部 这里只用于同步证件,为师傅入驻新网点做准备
+     * 师傅证件照同步到格力总部 这里只用于同步证件,为师傅入驻新网点或证件更新做准备
      * 按师傅所在格力总部网点同步除保险外的所有证件
      * 1:上传到格力总部网点
      * 2:本地保留一份

+ 2 - 3
src/main/java/com/zfire/jiasm/syncdata/upload/worker/UploadWorkeFace.java

@@ -12,7 +12,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 
 /**
- * 同步师傅人脸照到格力总部,为师傅入驻新网点做准备
+ * 同步师傅人脸照到格力总部,为师傅入驻新网点或证件更新做准备
  *
  * 用于更新已入驻的网点证件照数据
  * 更新证件到格力总部(师傅已入驻 且平台网点与格力总部网点有对应关系)
@@ -31,8 +31,7 @@ public class UploadWorkeFace {
 
 
     /**
-     * 师傅证件照同步到格力总部 这里只用于同步证件,为师傅入驻新网点做准备
-     * 按师傅所在格力总部网点同步除保险外的所有证件
+     * 师傅人脸面像同步到格力总部 为师傅入驻新网点或证件更新做准备
      * 1:上传到格力总部网点
      * 2:本地保留一份
      */

+ 2 - 2
src/main/java/com/zfire/jiasm/syncdata/upload/worker/UploadWorkerTOGree.java

@@ -39,7 +39,7 @@ public class UploadWorkerTOGree {
 
 
 
-    /** 更新师傅证件信息到格力总部 - 更新所有证件
+    /** 更新师傅证件信息到格力总部 - 更新所有证件(这里只做更新同步,取证件照路径)
      * 无论新增或是修改-所有证件都必须重新上传一次
      * 师傅所在网点都要上传一次
      */
@@ -58,7 +58,7 @@ public class UploadWorkerTOGree {
         return;
     }
 
-    // 师傅入驻格力新网点前 同步证件数据(保险+其他证件照)
+    // 师傅入驻格力新网点前 同步证件数据(保险+其他证件照)  已同步过无需再同步证件
     @Scheduled(fixedDelayString = "${inbefore}")
     public void workAddCertProcess() throws Exception {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 4 - 4
src/main/resources/bootstrap-prd.properties

@@ -169,13 +169,13 @@ gdbaseurl=http://47.115.43.13:8112/
 
 ######################## 同步定时任务时间隔 ########################
 #师傅 证件、师傅、工单子表信息
-workercertificate=60000
+workercertificate=30000
 workercerupload=60000
 detaildown=2000
-workercertbx=60000
-inbefore=60000
+workercertbx=30000
+inbefore=30000
 workerrz=60000
-workerface=60000
+workerface=30000
 #安装工单下载 、入本地表
 installdown=2000
 installin=5000