|
@@ -7,14 +7,8 @@ import com.zfire.jiasm.syncdata.gree.GreeLogic;
|
|
import com.zfire.jiasm.syncdata.helper.GreeFileResponseHelper;
|
|
import com.zfire.jiasm.syncdata.helper.GreeFileResponseHelper;
|
|
import com.zfire.jiasm.syncdata.helper.GreeFileSaveHelper;
|
|
import com.zfire.jiasm.syncdata.helper.GreeFileSaveHelper;
|
|
import com.zfire.jiasm.syncdata.http.PostObjectSample;
|
|
import com.zfire.jiasm.syncdata.http.PostObjectSample;
|
|
-import com.zfire.jiasm.syncdata.plus.entity.Brand;
|
|
|
|
-import com.zfire.jiasm.syncdata.plus.entity.InsureWorkerRecord;
|
|
|
|
-import com.zfire.jiasm.syncdata.plus.entity.WorkerBrandAccount;
|
|
|
|
-import com.zfire.jiasm.syncdata.plus.entity.WorkerCert;
|
|
|
|
-import com.zfire.jiasm.syncdata.plus.service.InsureWorkerRecordService;
|
|
|
|
-import com.zfire.jiasm.syncdata.plus.service.WebsitWorkerService;
|
|
|
|
-import com.zfire.jiasm.syncdata.plus.service.WorkerBrandAccountService;
|
|
|
|
-import com.zfire.jiasm.syncdata.plus.service.WorkerCertService;
|
|
|
|
|
|
+import com.zfire.jiasm.syncdata.plus.entity.*;
|
|
|
|
+import com.zfire.jiasm.syncdata.plus.service.*;
|
|
import com.zfire.jiasm.syncdata.response.ResultData;
|
|
import com.zfire.jiasm.syncdata.response.ResultData;
|
|
import com.zfire.jiasm.syncdata.service.PublicService;
|
|
import com.zfire.jiasm.syncdata.service.PublicService;
|
|
import com.zfire.jiasm.syncdata.service.UploadWorkeCertificateService;
|
|
import com.zfire.jiasm.syncdata.service.UploadWorkeCertificateService;
|
|
@@ -46,6 +40,12 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
PublicService publicService;
|
|
PublicService publicService;
|
|
@Resource
|
|
@Resource
|
|
InsureWorkerRecordService insureWorkerRecordService;
|
|
InsureWorkerRecordService insureWorkerRecordService;
|
|
|
|
+ @Resource
|
|
|
|
+ InsureWorkerCommercialService insureWorkerCommercialService;
|
|
|
|
+ @Resource
|
|
|
|
+ InsureWorkerCommercialFileService insureWorkerCommercialFileService;
|
|
|
|
+ @Resource
|
|
|
|
+ WorkerMrbxService workerMrbxService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -113,10 +113,15 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
|
|
|
|
// 上传图片 按网点上传
|
|
// 上传图片 按网点上传
|
|
for (WorkerBrandAccount wdno: workerWdnos){
|
|
for (WorkerBrandAccount wdno: workerWdnos){
|
|
|
|
+ if (StringUtils.isEmpty(wdno.getBrandWebsitId())){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
uploadFileexc(fileo, filet,wdno.getBrandWebsitId(),item);
|
|
uploadFileexc(fileo, filet,wdno.getBrandWebsitId(),item);
|
|
delfilet(fid3);
|
|
delfilet(fid3);
|
|
// 保险数据同步 保险证不在证件表中
|
|
// 保险数据同步 保险证不在证件表中
|
|
- fid3 = uploadInsureCert(wdno);
|
|
|
|
|
|
+ // fid3 = uploadInsureCert(wdno);
|
|
|
|
+ fid3 = uploadInsureBx(wdno);
|
|
}
|
|
}
|
|
|
|
|
|
// 文件清除
|
|
// 文件清除
|
|
@@ -191,6 +196,136 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
return fid1;
|
|
return fid1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private String uploadInsureBx(WorkerBrandAccount wdno) throws Exception {
|
|
|
|
+ SimpleDateFormat sdfs = new SimpleDateFormat("yyyyMM/");
|
|
|
|
+ String fileo ="";
|
|
|
|
+ String fid1 = "";
|
|
|
|
+
|
|
|
|
+ InsureWorkerCommercial iwc = insureWorkerCommercialService.lambdaQuery()
|
|
|
|
+ .eq(InsureWorkerCommercial::getWorkerId, wdno.getWorkerId())
|
|
|
|
+ .eq(InsureWorkerCommercial::getWebsitId, wdno.getWebsitId())
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (iwc != null){
|
|
|
|
+ InsureWorkerCommercialFile iwcf = insureWorkerCommercialFileService.lambdaQuery()
|
|
|
|
+ .eq(InsureWorkerCommercialFile::getInsureWorkerCommercialId,iwc.getId())
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (iwcf !=null){
|
|
|
|
+ if (StringUtils.isNotEmpty(iwcf.getOutZjlj())){
|
|
|
|
+ // 已上传就不需要再上传
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(iwcf.getFileUrl())){
|
|
|
|
+ // 上传
|
|
|
|
+ fid1 = publicService.path(iwcf.getFileUrl());
|
|
|
|
+ File nFile = publicService.createf(fid1);
|
|
|
|
+ baseService.saveToFile(ossUtil.getUrlWw(iwcf.getFileUrl()),nFile);
|
|
|
|
+ fileo = fid1;
|
|
|
|
+ uploadInitFile(fileo, fid1, wdno.getBrandWebsitId(),iwcf);
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 查家用保险
|
|
|
|
+ InsureWorkerRecord wk = insureWorkerRecordService.lambdaQuery()
|
|
|
|
+ .eq(InsureWorkerRecord::getWorkerId, wdno.getWorkerId())
|
|
|
|
+ .eq(InsureWorkerRecord::getWebsitId, wdno.getWebsitId())
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (wk !=null){
|
|
|
|
+ if (StringUtils.isNotEmpty(wk.getOutVoucher())){
|
|
|
|
+ // 已上传就不需要再上传
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(wk.getVoucher())){
|
|
|
|
+ // 上传
|
|
|
|
+ fid1 = publicService.path(wk.getVoucher());
|
|
|
|
+ File nFile = publicService.createf(fid1);
|
|
|
|
+ baseService.saveToFile(ossUtil.getUrlWw(wk.getVoucher()),nFile);
|
|
|
|
+ fileo = fid1;
|
|
|
|
+ uploadInitFileexc(fileo, fid1, wdno.getBrandWebsitId(),wk);
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 加上getWebsitId条件找不到时,去掉getWebsitId条件
|
|
|
|
+ InsureWorkerCommercial iwcc = insureWorkerCommercialService.lambdaQuery()
|
|
|
|
+ .eq(InsureWorkerCommercial::getWorkerId, wdno.getWorkerId())
|
|
|
|
+ // .eq(InsureWorkerCommercial::getWebsitId, wdno.getWebsitId())
|
|
|
|
+ .orderByDesc(InsureWorkerCommercial::getEndTime)
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (iwcc != null){
|
|
|
|
+ InsureWorkerCommercialFile iwcf = insureWorkerCommercialFileService.lambdaQuery()
|
|
|
|
+ .eq(InsureWorkerCommercialFile::getInsureWorkerCommercialId,iwcc.getId())
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (iwcf !=null){
|
|
|
|
+ if (StringUtils.isNotEmpty(iwcf.getOutZjlj())){
|
|
|
|
+ // 已上传就不需要再上传
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(iwcf.getFileUrl())){
|
|
|
|
+ // 上传
|
|
|
|
+ fid1 = publicService.path(iwcf.getFileUrl());
|
|
|
|
+ File nFile = publicService.createf(fid1);
|
|
|
|
+ baseService.saveToFile(ossUtil.getUrlWw(iwcf.getFileUrl()),nFile);
|
|
|
|
+ fileo = fid1;
|
|
|
|
+ uploadInitFile(fileo, fid1, wdno.getBrandWebsitId(),iwcf);
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 查家用保险
|
|
|
|
+ InsureWorkerRecord wkk = insureWorkerRecordService.lambdaQuery()
|
|
|
|
+ .eq(InsureWorkerRecord::getWorkerId, wdno.getWorkerId())
|
|
|
|
+ // .eq(InsureWorkerRecord::getWebsitId, wdno.getWebsitId())
|
|
|
|
+ .orderByDesc(InsureWorkerRecord::getEndTime)
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (wkk !=null){
|
|
|
|
+ if (StringUtils.isNotEmpty(wkk.getOutVoucher())){
|
|
|
|
+ // 已上传就不需要再上传
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(wkk.getVoucher())){
|
|
|
|
+ // 上传
|
|
|
|
+ fid1 = publicService.path(wkk.getVoucher());
|
|
|
|
+ File nFile = publicService.createf(fid1);
|
|
|
|
+ baseService.saveToFile(ossUtil.getUrlWw(wkk.getVoucher()),nFile);
|
|
|
|
+ fileo = fid1;
|
|
|
|
+ uploadInitFileexc(fileo, fid1, wdno.getBrandWebsitId(),wkk);
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 师傅必买保险,所以不会不存在
|
|
|
|
+ return fid1;
|
|
|
|
+
|
|
|
|
+ /*// 增加一个已上传过的表判断
|
|
|
|
+ WorkerMrbx mbx = workerMrbxService.lambdaQuery()
|
|
|
|
+ .eq(WorkerMrbx::getWorkerId, wdno.getWorkerId())
|
|
|
|
+ .eq(WorkerMrbx::getWebsitId, wdno.getWebsitId())
|
|
|
|
+ .isNotNull(WorkerMrbx::getOutZjlj)
|
|
|
|
+ .last("limit 1").one();
|
|
|
|
+ if (mbx != null){
|
|
|
|
+ // 存在上传过的默认就不再上传 无论传的是哪一个师傅的 统一使用一个默认的
|
|
|
|
+ return fid1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 都没有时上传 默认
|
|
|
|
+ WorkerMrbx wmrbx = new WorkerMrbx();
|
|
|
|
+ wmrbx.setId(IdWorker.getIdStr());
|
|
|
|
+ wmrbx.setWorkerId(wdno.getWorkerId());
|
|
|
|
+ wmrbx.setWebsitId(wdno.getWebsitId());
|
|
|
|
+ fid1 = publicService.path("bx.jpg");
|
|
|
|
+ baseService.initFile(fid1);
|
|
|
|
+ fileo = fid1;
|
|
|
|
+ uploadInitMRFileexc(fileo, fid1, wdno.getBrandWebsitId(),wmrbx);
|
|
|
|
+
|
|
|
|
+ return fid1;*/
|
|
|
|
+ }
|
|
|
|
+
|
|
private Boolean uploadFileexc(String fileo, String filet, String wdno,WorkerCert item) throws Exception {
|
|
private Boolean uploadFileexc(String fileo, String filet, String wdno,WorkerCert item) throws Exception {
|
|
Boolean uploadfile = Boolean.TRUE;
|
|
Boolean uploadfile = Boolean.TRUE;
|
|
Boolean onlyone = Boolean.FALSE;
|
|
Boolean onlyone = Boolean.FALSE;
|
|
@@ -325,6 +460,88 @@ public class UploadWorkeCertificateServiceImpl implements UploadWorkeCertificate
|
|
return Boolean.FALSE;
|
|
return Boolean.FALSE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private Boolean uploadInitMRFileexc(String fileo, String fid1,String wdno,WorkerMrbx wk) throws Exception {
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isEmpty(wdno)){
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(fileo)){
|
|
|
|
+ // 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);
|
|
|
|
+ // 2:文件上传
|
|
|
|
+ PostObjectSample ossPostObject = new PostObjectSample();
|
|
|
|
+ String result = ossPostObject.PostObject(fileo, resultData.getExtData());
|
|
|
|
+ // 3: 保存文件
|
|
|
|
+ if (StringUtils.isEmpty(result.trim())){
|
|
|
|
+ Map<String,String>req = new HashMap<>();
|
|
|
|
+ // 生成对象
|
|
|
|
+ getSaveFileInfo(fid1, resultData, req);
|
|
|
|
+ GreeFileSaveHelper responses = greeLogic.greePostSaveFile(req);
|
|
|
|
+
|
|
|
|
+ if (responses.getStatusCode() == 200){
|
|
|
|
+ // 保存文件ID responses.getData().getId()
|
|
|
|
+ wk.setOutZjlj(responses.getData().getId());
|
|
|
|
+ wk.setSyncTime(new Date());
|
|
|
|
+ workerMrbxService.save(wk);
|
|
|
|
+ } else {
|
|
|
|
+ // 失败
|
|
|
|
+ log.info("保存保险证件文件到格力总部失败");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.info("保险证件上传图片到OSS失败");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.info("获取签名信息失败");
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Boolean.FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Boolean uploadInitFile(String fileo, String fid1,String wdno,InsureWorkerCommercialFile wk) throws Exception {
|
|
|
|
+ if (StringUtils.isNotEmpty(fileo)){
|
|
|
|
+ // 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);
|
|
|
|
+ // 2:文件上传
|
|
|
|
+ PostObjectSample ossPostObject = new PostObjectSample();
|
|
|
|
+ String result = ossPostObject.PostObject(fileo, resultData.getExtData());
|
|
|
|
+ // 3: 保存文件
|
|
|
|
+ if (StringUtils.isEmpty(result.trim())){
|
|
|
|
+ Map<String,String>req = new HashMap<>();
|
|
|
|
+ // 生成对象
|
|
|
|
+ getSaveFileInfo(fid1, resultData, req);
|
|
|
|
+ GreeFileSaveHelper responses = greeLogic.greePostSaveFile(req);
|
|
|
|
+
|
|
|
|
+ if (responses.getStatusCode() == 200){
|
|
|
|
+ // 保存文件ID responses.getData().getId()
|
|
|
|
+ wk.setOutZjlj(responses.getData().getId());
|
|
|
|
+ wk.setOutZjljProcess(1);
|
|
|
|
+ wk.updateById();
|
|
|
|
+ } else {
|
|
|
|
+ // 失败
|
|
|
|
+ log.info("保存保险证件文件到格力总部失败");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.info("保险证件上传图片到OSS失败");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.info("获取签名信息失败");
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Boolean.FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
private Integer getCount(List<WorkerBrandAccount> workerWdnos, Integer count) {
|
|
private Integer getCount(List<WorkerBrandAccount> workerWdnos, Integer count) {
|
|
for (WorkerBrandAccount w: workerWdnos){
|
|
for (WorkerBrandAccount w: workerWdnos){
|
|
if (StringUtils.isEmpty(w.getBrandWebsitId())){
|
|
if (StringUtils.isEmpty(w.getBrandWebsitId())){
|