|
@@ -63,8 +63,10 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
public void procesUploadWorkeCert() {
|
|
|
List<WorkerCert> recs = new ArrayList<>();
|
|
|
List<WorkerBrandAccount> workerWdnos = new ArrayList<>();
|
|
|
- String fileo ="";
|
|
|
- String filet ="";
|
|
|
+ String filePatho ="";
|
|
|
+ String filePatht ="";
|
|
|
+ String fileIdo ="";
|
|
|
+ String fileIdt ="";
|
|
|
Integer count = 0;
|
|
|
Boolean upf=Boolean.TRUE;
|
|
|
String outFile="";
|
|
@@ -95,11 +97,7 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
recs = getWorkerUploadstest();
|
|
|
|
|
|
for (WorkerCert item:recs){
|
|
|
- fileo ="";
|
|
|
- filet ="";
|
|
|
count = 0;
|
|
|
- outFile="";
|
|
|
- outFilet="";
|
|
|
|
|
|
try{
|
|
|
// 证件已同步无需再次同步或是更新
|
|
@@ -129,36 +127,40 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
|
|
|
// 生成图片 System.getProperty("java.io.tmpdir")
|
|
|
if (StringUtils.isNotEmpty(item.getFileUrl()) && (StringUtils.isEmpty(item.getOutFileUrl()))){
|
|
|
- fileo = publicService.pathToGree(item.getFileUrl());
|
|
|
- File nFile = publicService.createf(fileo);
|
|
|
+ fileIdo = IdWorker.getIdStr() + ".jpeg";
|
|
|
+ filePatho = publicService.pathToGree(fileIdo);
|
|
|
+ File nFile = publicService.createf(filePatho);
|
|
|
// 下载文件生成新文件 fid1
|
|
|
baseService.saveToFile(ossUtil.getUrlWw(item.getFileUrl()),nFile);
|
|
|
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(item.getFileUrl2()) && (StringUtils.isEmpty(item.getOutFileUrl2()))){
|
|
|
- filet = publicService.pathToGree(item.getFileUrl2());
|
|
|
- File nFile = publicService.createf(filet);
|
|
|
+ fileIdt = IdWorker.getIdStr() + ".jpeg";
|
|
|
+ filePatht = publicService.pathToGree(fileIdt);
|
|
|
+ File nFile = publicService.createf(filePatht);
|
|
|
// 下载文件生成新文件 fid2
|
|
|
baseService.saveToFile(ossUtil.getUrlWw(item.getFileUrl2()),nFile);
|
|
|
}
|
|
|
|
|
|
// 上传图片 按网点上传
|
|
|
for (WorkerBrandAccount wdno: workerWdnos){
|
|
|
+ outFile="";
|
|
|
+ outFilet="";
|
|
|
upf=Boolean.TRUE;
|
|
|
|
|
|
if (StringUtils.isEmpty(wdno.getBrandWebsitId())){
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(fileo)){
|
|
|
- outFile = uploadWdnoFile(wdno.getBrandWebsitId(), item, fileo);
|
|
|
+ if (StringUtils.isNotEmpty(filePatho)){
|
|
|
+ outFile = uploadWdnoFile(wdno.getBrandWebsitId(), item, filePatho, fileIdo);
|
|
|
if (StringUtils.isEmpty(outFile)){
|
|
|
upf=Boolean.FALSE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(filet)){
|
|
|
- outFilet = uploadWdnoFile(wdno.getBrandWebsitId(), item, filet);
|
|
|
+ if (StringUtils.isNotEmpty(filePatht)){
|
|
|
+ outFilet = uploadWdnoFile(wdno.getBrandWebsitId(), item, filePatht, fileIdt);
|
|
|
if (StringUtils.isEmpty(outFilet)){
|
|
|
upf=Boolean.FALSE;
|
|
|
}
|
|
@@ -173,7 +175,7 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
extractedEnd(wcgs, item, outFile, outFilet);
|
|
|
|
|
|
// 文件清除
|
|
|
- delfile(fileo, filet, "");
|
|
|
+ delfile(filePatho, filePatht, "");
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
log.info("同步师傅证件失败:【" + item.getId() + "】");
|
|
@@ -620,10 +622,10 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
|
|
|
private String uploadInsureBx(WebsitWorker item,WorkerBrandAccount wdno) throws Exception {
|
|
|
- String fileo ="";
|
|
|
- String fid1 = "";
|
|
|
+ String fileAdnPath = "";
|
|
|
String outInsureCert = "";
|
|
|
String bxf="";
|
|
|
+ String fileId = "";
|
|
|
|
|
|
// 上传
|
|
|
if (item.getInsureFiles().contains(",")){
|
|
@@ -631,11 +633,12 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
|
|
|
List<String> result = Arrays.asList(item.getInsureFiles().split(","));
|
|
|
for (String p:result){
|
|
|
- fid1 = publicService.pathToGree(p);
|
|
|
- File nFile = publicService.createf(fid1);
|
|
|
- baseService.saveToFile(ossUtil.getUrlWw(item.getFileUrl()),nFile);
|
|
|
- fileo = fid1;
|
|
|
- bxf = uploadInitFileBx(fileo, fid1, wdno.getBrandWebsitId());
|
|
|
+ // 路径
|
|
|
+ fileId = IdWorker.getIdStr() + ".jpeg";
|
|
|
+ fileAdnPath = publicService.pathToGree(fileId);
|
|
|
+ File nFile = publicService.createf(fileAdnPath);
|
|
|
+ baseService.saveToFile(ossUtil.getUrlWw(p),nFile);
|
|
|
+ bxf = uploadInitFileBx(fileAdnPath, fileId, wdno.getBrandWebsitId());
|
|
|
if (StringUtils.isEmpty(bxf)){
|
|
|
return bxf;
|
|
|
}
|
|
@@ -645,24 +648,26 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
} else {
|
|
|
outInsureCert= outInsureCert +","+bxf;
|
|
|
}
|
|
|
- new File(fid1).delete();
|
|
|
+ nFile.delete();
|
|
|
num = num +1 ;
|
|
|
}
|
|
|
} else {
|
|
|
- fid1 = publicService.pathToGree(item.getInsureFiles());
|
|
|
- File nFile = publicService.createf(fid1);
|
|
|
- baseService.saveToFile(ossUtil.getUrlWw(item.getFileUrl()),nFile);
|
|
|
- fileo = fid1;
|
|
|
- bxf = uploadInitFileBx(fileo, fid1, wdno.getBrandWebsitId());
|
|
|
+ // 路径
|
|
|
+ fileId = IdWorker.getIdStr() + ".jpeg";
|
|
|
+ fileAdnPath = publicService.pathToGree(fileId);
|
|
|
+ // 新文件 方便写入
|
|
|
+ File nFile = publicService.createf(fileAdnPath);
|
|
|
+ baseService.saveToFile(ossUtil.getUrlWw(item.getInsureFiles()),nFile);
|
|
|
+ bxf = uploadInitFileBx(fileAdnPath, fileId, wdno.getBrandWebsitId());
|
|
|
if (StringUtils.isEmpty(bxf)){
|
|
|
return bxf;
|
|
|
}
|
|
|
outInsureCert = bxf;
|
|
|
- new File(fid1).delete();
|
|
|
+ nFile.delete();
|
|
|
}
|
|
|
item.setOutInsureCert(outInsureCert);
|
|
|
// 师傅必买保险,所以不会不存在
|
|
|
- return fid1;
|
|
|
+ return fileAdnPath;
|
|
|
}
|
|
|
|
|
|
private Boolean uploadFileexc(String fileo, String filet, String wdno,WorkerCert item) throws Exception {
|
|
@@ -757,7 +762,7 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
|
|
|
|
|
|
- private String uploadWdnoFile(String wdno,WorkerCert item,String certfile) throws Exception {
|
|
|
+ private String uploadWdnoFile(String wdno,WorkerCert item,String filePath, String fileId) throws Exception {
|
|
|
String msg = "";
|
|
|
String outFile="";
|
|
|
|
|
@@ -766,16 +771,16 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
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()+"/"+certfile);
|
|
|
+ resultData.getExtData().setDir(resultData.getExtData().getDir()+"/"+fileId);
|
|
|
// 2:文件上传
|
|
|
PostObjectSample ossPostObject = new PostObjectSample();
|
|
|
- String result = ossPostObject.PostObject(certfile, resultData.getExtData());
|
|
|
+ String result = ossPostObject.PostObject(filePath, resultData.getExtData());
|
|
|
|
|
|
// 3: 保存文件
|
|
|
if (StringUtils.isEmpty(result.trim())){
|
|
|
Map<String,String> req = new HashMap<>();
|
|
|
// 生成对象
|
|
|
- getSaveFileInfo(certfile, resultData, req);
|
|
|
+ getSaveFileInfo(fileId, resultData, req);
|
|
|
GreeFileSaveHelper responses = greeLogic.greePostSaveFile(req);
|
|
|
if (responses.getStatusCode() == 200){
|
|
|
// 保存文件ID responses.getData().getId()
|
|
@@ -924,22 +929,22 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
|
|
|
|
|
|
- private String uploadInitFileBx(String fileo, String fid1,String wdno) throws Exception {
|
|
|
+ private String uploadInitFileBx(String fileAdnPath, String fidId,String wdno) throws Exception {
|
|
|
String fileId="";
|
|
|
- if (StringUtils.isNotEmpty(fileo)){
|
|
|
+ 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()+"/"+fid1);
|
|
|
+ resultData.getExtData().setDir(resultData.getExtData().getDir()+"/"+fidId);
|
|
|
// 2:文件上传
|
|
|
PostObjectSample ossPostObject = new PostObjectSample();
|
|
|
- String result = ossPostObject.PostObject(fileo, resultData.getExtData());
|
|
|
+ String result = ossPostObject.PostObject(fileAdnPath, resultData.getExtData());
|
|
|
// 3: 保存文件
|
|
|
if (StringUtils.isEmpty(result.trim())){
|
|
|
Map<String,String>req = new HashMap<>();
|
|
|
// 生成对象
|
|
|
- getSaveFileInfo(fid1, resultData, req);
|
|
|
+ getSaveFileInfo(fidId, resultData, req);
|
|
|
GreeFileSaveHelper responses = greeLogic.greePostSaveFile(req);
|
|
|
|
|
|
if (responses.getStatusCode() == 200){
|
|
@@ -1029,13 +1034,13 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void getSaveFileInfo(String id1, ResultData resultData, Map<String, String> req) {
|
|
|
+ private void getSaveFileInfo(String fileId, ResultData resultData, Map<String, String> req) {
|
|
|
req.put("bizAppId","flydiy-auto-sit-default-front-greeshmerge");
|
|
|
req.put("bizTable","default");
|
|
|
req.put("bizType","default");
|
|
|
req.put("accessType","auth");
|
|
|
req.put("url", resultData.getExtData().getDir());
|
|
|
- req.put("name", id1);
|
|
|
+ req.put("name", fileId);
|
|
|
}
|
|
|
|
|
|
|