|
@@ -56,6 +56,8 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
InsureWorkerInitService insureWorkerInitService;
|
|
|
@Resource
|
|
|
WorkerCertGreeService workerCertGreeService;
|
|
|
+ @Resource
|
|
|
+ WorkerService workerService;
|
|
|
|
|
|
|
|
|
|
|
@@ -183,7 +185,6 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
log.info("同步师傅证件失败:【" + item.getId() + "】");
|
|
|
- log.info("同步师傅证件失败:{}",JSONObject.toJSONString(wcgs));
|
|
|
String msg = "同步师傅证件失败:";
|
|
|
if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(ex.getMessage())){
|
|
|
msg = msg + ex.getMessage();
|
|
@@ -193,6 +194,106 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void procesUploadWorkeFace() {
|
|
|
+ List<WorkerBrandAccount> workerWdnos = new ArrayList<>();
|
|
|
+ String filePatho ="";
|
|
|
+ String fileIdo ="";
|
|
|
+ Integer count = 0;
|
|
|
+ Boolean upf = Boolean.TRUE;
|
|
|
+ String outFile="";
|
|
|
+ List<WorkerCertGree> wcgs = new ArrayList<>();
|
|
|
+ Map<String,String> wcgids = new HashMap<>();
|
|
|
+ List<Worker> workers = new ArrayList<>();
|
|
|
+
|
|
|
+ // 提取品牌信息 用于多品牌数据同步目前仅格力,可以先不用做
|
|
|
+ Brand brand = baseService.getBrand();
|
|
|
+ if (brand == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WorkerCertGree> wcgsold = workerCertGreeService.lambdaQuery().list();
|
|
|
+ if (CollectionUtils.isNotEmpty(wcgsold)){
|
|
|
+ wcgsold.stream().forEach(event->{
|
|
|
+ wcgids.put(event.getWorkerId() + event.getBrandWebsitId() + event.getCertName(),event.getWorkerCertGreeId());
|
|
|
+ });
|
|
|
+ wcgsold.clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提取需同步的人脸面像数据
|
|
|
+ workers = getWorkers();
|
|
|
+
|
|
|
+ for (Worker item:workers){
|
|
|
+ count = 0;
|
|
|
+ try{
|
|
|
+ // 查看师傅是否已选中品牌商网点(这里只提取选中格力品牌商的师傅数据)
|
|
|
+ workerWdnos = workerBrandAccountService.lambdaQuery()
|
|
|
+ .eq(WorkerBrandAccount::getWorkerId, item.getWorkerId())
|
|
|
+ .eq(WorkerBrandAccount::getBrandWorkerStatus,"ON")
|
|
|
+ .eq(WorkerBrandAccount::getDel,0)
|
|
|
+ .eq(WorkerBrandAccount::getGroupCompanyId, brand.getBrandId()).list();
|
|
|
+
|
|
|
+ // 未选择品牌商
|
|
|
+ if (workerWdnos.size()<1){
|
|
|
+ updateWorkFaceError(item,"师傅未选择格力品牌商信息");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断师傅入驻的商户网点
|
|
|
+ count = getCount(workerWdnos, count);
|
|
|
+ if (count.equals(workerWdnos.size())){
|
|
|
+ updateWorkFaceError(item,"师傅未入驻品牌商网点");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成图片 System.getProperty("java.io.tmpdir")
|
|
|
+ fileIdo = IdWorker.getIdStr() + ".jpeg";
|
|
|
+ filePatho = publicService.pathToGree(fileIdo);
|
|
|
+ File nFile = publicService.createf(filePatho);
|
|
|
+ // 下载文件生成新文件 fid1
|
|
|
+ baseService.saveToFile(ossUtil.getUrlWw(item.getAuthHeadImage()),nFile);
|
|
|
+
|
|
|
+ // 上传图片 按网点上传
|
|
|
+ for (WorkerBrandAccount wdno: workerWdnos){
|
|
|
+ outFile="";
|
|
|
+ upf=Boolean.TRUE;
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(wdno.getBrandWebsitId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(filePatho)){
|
|
|
+ outFile = uploadWdnoFaceFile(wdno.getBrandWebsitId(), item, filePatho, fileIdo);
|
|
|
+ if (StringUtils.isEmpty(outFile)){
|
|
|
+ upf=Boolean.FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 网点上传成功 生成对像
|
|
|
+ if (upf){
|
|
|
+ getWorkerFaceGreeInfo(outFile, wcgs, wdno, wcgids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 上传完后师傅所在网点的证件保存,并写入更新表待师傅证件修改
|
|
|
+ // 最后保存网点图,目的下次无需再同步图片
|
|
|
+ extractedFeceEnd(wcgs, item, outFile);
|
|
|
+
|
|
|
+ // 文件清除
|
|
|
+ delfile(filePatho, "", "");
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ log.info("同步师傅人脸面像失败:【" + item.getWorkerId() + "】");
|
|
|
+ log.info("同步师傅人脸面像失败:{}",JSONObject.toJSONString(wcgs));
|
|
|
+ String msg = "同步师傅人脸面像失败:";
|
|
|
+ if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(ex.getMessage())){
|
|
|
+ msg = msg + ex.getMessage();
|
|
|
+ }
|
|
|
+ updateWorkFaceError(item,msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void extractedEnd(List<WorkerCertGree> wcgs, WorkerCert item, String file, String filet) throws Exception {
|
|
|
try{
|
|
@@ -209,6 +310,22 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void extractedFeceEnd(List<WorkerCertGree> wcgs, Worker item, String file ) throws Exception {
|
|
|
+ try{
|
|
|
+ if (wcgs.size()>0){
|
|
|
+ workerCertGreeService.saveOrUpdateBatch(wcgs);
|
|
|
+ wcgs.clear();
|
|
|
+ }
|
|
|
+ updateWorkFaceSyncStat(item, file);
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ // 抛异常目的是把前期的数据操作回滚
|
|
|
+ throw new Exception(ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void getWorkerCertGreeInfo(String outFile, String outFilet,
|
|
|
List<WorkerCertGree> wcgs, WorkerCert item,
|
|
|
WorkerBrandAccount wdno, Map<String,String> wcgids) {
|
|
@@ -230,6 +347,23 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
wcgs.add(awc);
|
|
|
}
|
|
|
|
|
|
+ private void getWorkerFaceGreeInfo(String outFile,
|
|
|
+ List<WorkerCertGree> wcgs,
|
|
|
+ WorkerBrandAccount wdno, Map<String,String> wcgids) {
|
|
|
+ WorkerCertGree awc = new WorkerCertGree();
|
|
|
+ awc.setWorkerCertGreeId(IdWorker.getIdStr());
|
|
|
+ awc.setWorkerId(wdno.getWorkerId());
|
|
|
+ awc.setBrandWebsitId(wdno.getBrandWebsitId());
|
|
|
+ awc.setCertName("人脸面像");
|
|
|
+ awc.setCertNo("");
|
|
|
+ awc.setCreateTime(new Date());
|
|
|
+ awc.setOutFileUrl(outFile);
|
|
|
+ publicService.setCertFlag(awc.getCertName(), awc);
|
|
|
+ // 存在进行修改
|
|
|
+ publicService.setWorkerCertGreeId(awc, wcgids);
|
|
|
+ wcgs.add(awc);
|
|
|
+ }
|
|
|
+
|
|
|
private void getWorkerCertGreeOtherInfo(String outFile, String outFilet,
|
|
|
List<WorkerCertGree> wcgs, WorkerCert item,
|
|
|
OutWorkerUpload owu) {
|
|
@@ -1053,6 +1187,48 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private String uploadWdnoFaceFile(String wdno,Worker item,String filePath, String fileId) throws Exception {
|
|
|
+ String msg = "";
|
|
|
+ String outFile="";
|
|
|
+
|
|
|
+ // 上传图片
|
|
|
+ // 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()+"/"+fileId);
|
|
|
+ // 2:文件上传
|
|
|
+ PostObjectSample ossPostObject = new PostObjectSample();
|
|
|
+ String result = ossPostObject.PostObject(filePath, resultData.getExtData());
|
|
|
+
|
|
|
+ // 3: 保存文件
|
|
|
+ if (StringUtils.isEmpty(result.trim())){
|
|
|
+ Map<String,String> req = new HashMap<>();
|
|
|
+ // 生成对象
|
|
|
+ getSaveFileInfo(fileId, resultData, req);
|
|
|
+ GreeFileSaveHelper responses = greeLogic.greePostSaveFile(req);
|
|
|
+ if (responses.getStatusCode() == 200){
|
|
|
+ // 保存文件ID responses.getData().getId()
|
|
|
+ // 返回文件
|
|
|
+ outFile = responses.getData().getId();
|
|
|
+ } else {
|
|
|
+ msg = "上传证件到格力总部失败";
|
|
|
+ if (StringUtils.isNotEmpty(responses.getMsg())){
|
|
|
+ msg = msg + responses.getMsg();
|
|
|
+ }
|
|
|
+ updateWorkFaceError(item,msg);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ updateWorkFaceError(item,"上传图片到OSS失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ updateWorkFaceError(item,"获取签名信息失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return outFile;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private Boolean uploadInitFileexc(String fileo, String fid1,String wdno,InsureWorkerRecord wk) throws Exception {
|
|
|
|
|
|
if (StringUtils.isEmpty(wdno)){
|
|
@@ -1234,6 +1410,17 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
workerCertService.updateById(v);
|
|
|
}
|
|
|
|
|
|
+ private void updateWorkFaceError(Worker item, String msg) {
|
|
|
+ item.setOutSyncTime(new Date());
|
|
|
+ item.setOutSyncTimes(item.getOutSyncTimes() + 1);
|
|
|
+ item.setOutSyncErrorMsg(msg);
|
|
|
+ if (msg.length()>250){
|
|
|
+ item.setOutSyncErrorMsg(msg.substring(0,250));
|
|
|
+ }
|
|
|
+
|
|
|
+ item.updateById();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void updateWebsitWorkererror(WebsitWorker item, String msg) {
|
|
|
WebsitWorker v = new WebsitWorker();
|
|
@@ -1291,6 +1478,16 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void updateWorkFaceSyncStat(Worker item, String file) {
|
|
|
+ item.setOutSyncTimes(1);
|
|
|
+ item.setOutSyncTime(new Date());
|
|
|
+ item.setOutSyncErrorMsg("成功");
|
|
|
+ item.setOutAuthHeadImage(file);
|
|
|
+
|
|
|
+ item.updateById();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void getSaveFileInfo(String fileId, ResultData resultData, Map<String, String> req) {
|
|
|
req.put("bizAppId","flydiy-auto-sit-default-front-greeshmerge");
|
|
|
req.put("bizTable","default");
|
|
@@ -1301,11 +1498,15 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 该表只进行增加数据
|
|
|
- * 相同类型数据只取最大ID
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ private List<Worker> getWorkers() {
|
|
|
+ return workerService.lambdaQuery()
|
|
|
+ .eq(Worker::getIsReal,"YES")
|
|
|
+ .isNotNull(Worker::getAuthHeadImage)
|
|
|
+ .isNull(Worker::getOutAuthHeadImage)
|
|
|
+ .list();
|
|
|
+ }
|
|
|
+
|
|
|
private List<WorkerCert> getWorkerUploads() {
|
|
|
// 同步标志-synStatus(0:待同步;1:已同步;99:同步失败)
|
|
|
return workerCertService.lambdaQuery()
|