|
@@ -0,0 +1,303 @@
|
|
|
+package com.jeeplus.modules.ruralprojectrecords.thread;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.jeeplus.common.config.Global;
|
|
|
+import com.jeeplus.common.oss.OSSClientUtil;
|
|
|
+import com.jeeplus.common.utils.SpringContextHolder;
|
|
|
+import com.jeeplus.modules.projectcontentinfo.dao.ProjectReportDataDao;
|
|
|
+import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
|
|
|
+import com.jeeplus.modules.projectcontentinfo.service.ProjectReportDataService;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.dao.RuralProjectMessageElectronicSealDao;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.entity.ProjectApprovalSignature;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.enums.ProjectStatusEnum;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectMessageService;
|
|
|
+import com.jeeplus.modules.sys.entity.Office;
|
|
|
+import com.jeeplus.modules.sys.entity.User;
|
|
|
+import com.jeeplus.modules.sys.entity.Workattachment;
|
|
|
+import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
|
+import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
+import com.jeeplus.modules.tools.utils.SignaturePostUtil;
|
|
|
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
|
|
|
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
|
|
|
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
|
|
|
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: 徐滕
|
|
|
+ * @create: 2021-12-17 15:45
|
|
|
+ **/
|
|
|
+public class JudgementThread extends Thread {
|
|
|
+
|
|
|
+ private ProjectReportDataService projectReportDataService = SpringContextHolder.getBean(ProjectReportDataService.class);
|
|
|
+ private WorkattachmentService workattachmentService = SpringContextHolder.getBean(WorkattachmentService.class);
|
|
|
+ private RuralProjectMessageService ruralProjectMessageService = SpringContextHolder.getBean(RuralProjectMessageService.class);
|
|
|
+ private WorkActivityProcessService workActivityProcessService = SpringContextHolder.getBean(WorkActivityProcessService.class);
|
|
|
+ private WorkProjectNotifyService workProjectNotifyService = SpringContextHolder.getBean(WorkProjectNotifyService.class);
|
|
|
+ private ProjectReportDataDao dao = SpringContextHolder.getBean(ProjectReportDataDao.class);
|
|
|
+
|
|
|
+ private RuralProjectRecords ruralProjectRecords;
|
|
|
+ private ProjectReportData projectReportData;
|
|
|
+
|
|
|
+
|
|
|
+ public JudgementThread(RuralProjectRecords ruralProjectRecords, ProjectReportData projectReportData)
|
|
|
+ {
|
|
|
+ this.ruralProjectRecords = ruralProjectRecords;
|
|
|
+ this.projectReportData = projectReportData;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void run(){
|
|
|
+ Boolean bool = true;
|
|
|
+ String disposeResult = "";
|
|
|
+ //下载审定单文件
|
|
|
+ String deleteFile = null;
|
|
|
+ try {
|
|
|
+ //进行签章调用
|
|
|
+ //根据项目id查询是否已经提交过了审定单签章
|
|
|
+ if(null == projectReportData){
|
|
|
+ disposeResult = "查询不到该项目的质量复核信息";
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ if(null!= projectReportData.getSignatureFlag() && 1 == projectReportData.getSignatureFlag()){
|
|
|
+ disposeResult = "该质量复核已经盖章完成";
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(ruralProjectRecords.getProjectMasterId())){
|
|
|
+ disposeResult = "项目负责人为空,无法进行签章";
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据项目id和附件类型的
|
|
|
+ Workattachment workClientAttachment = new Workattachment();
|
|
|
+ workClientAttachment.setAttachmentFlag("105");
|
|
|
+ workClientAttachment.setAttachmentId(ruralProjectRecords.getId());
|
|
|
+ workClientAttachment.setProjectId(ruralProjectRecords.getId());
|
|
|
+ workClientAttachment.setDivIdType("_judgement");
|
|
|
+ List<Workattachment> fileList = workattachmentService.findList(workClientAttachment);
|
|
|
+ if(fileList.size()>0){
|
|
|
+ Workattachment workattachment = fileList.get(0);
|
|
|
+ if(StringUtils.isBlank(workattachment.getUrl())){
|
|
|
+ disposeResult = "审定单文件存储路径为空,无法进行签章操作,请驳回后重新上传审定单";
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ //下载审定单文件
|
|
|
+ String path = null;
|
|
|
+ if(System.getProperty("os.name").toLowerCase().contains("win")){
|
|
|
+ path = "D:/attachment-file/";
|
|
|
+ }else{
|
|
|
+ path = "/attachment-file/";
|
|
|
+ }
|
|
|
+ String file = workattachment.getUrl();
|
|
|
+ file = file.replace("amp;","");
|
|
|
+ String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
+ String aliyunUrl = Global.getAliyunUrl();
|
|
|
+ String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
+ String cons = "";
|
|
|
+ if (file.contains(aliyunUrl)){
|
|
|
+ cons = aliyunUrl;
|
|
|
+ }else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
|
|
|
+ cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
+ }else {
|
|
|
+ cons = aliDownloadUrl;
|
|
|
+ }
|
|
|
+ String ossKey = file.split(cons+"/")[1];
|
|
|
+ new OSSClientUtil().downByStreamSaveLocal(ossKey,fileName,path+fileName);
|
|
|
+ //将下载下来的文件转换为file文件
|
|
|
+ File srcFile = new File(path+fileName);
|
|
|
+ File verticalInvalidFile = new File(path+fileName);
|
|
|
+ deleteFile = path+fileName;
|
|
|
+
|
|
|
+ //截取文件名称
|
|
|
+ String srcFileName = srcFile.getName().substring(0,srcFile.getName().lastIndexOf("."));
|
|
|
+ //截取文件后缀名
|
|
|
+ String substring = srcFile.getName().substring(srcFile.getName().lastIndexOf(".")+1, srcFile.getName().length());
|
|
|
+ if(!"doc".equals(substring.toLowerCase()) && !"docx".equals(substring.toLowerCase()) && !"pdf".equals(substring.toLowerCase()) && !"xls".equals(substring.toLowerCase()) && !"xlsx".equals(substring.toLowerCase())){
|
|
|
+ disposeResult = "请上传doc、docx、xls、xlsx或者pdf文件进行签章操作";
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ //获取真签单的documentId
|
|
|
+ HashMap hashMap = SignaturePostUtil.getDocument(srcFile);
|
|
|
+ String code = hashMap.get("code").toString();
|
|
|
+ String documentId = "";
|
|
|
+ if("0".equals(code)){
|
|
|
+ String result = hashMap.get("result").toString();
|
|
|
+ HashMap documentIdMap = JSON.parseObject(result, HashMap.class);
|
|
|
+ documentId = documentIdMap.get("documentId").toString();
|
|
|
+ if("".equals(documentId)){
|
|
|
+ disposeResult = "签章文件创建失败";
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ String message = hashMap.get("message").toString();
|
|
|
+ disposeResult = message;
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ List<String> documentList = Lists.newArrayList();
|
|
|
+ documentList.add(documentId);
|
|
|
+ //根据项目id 和 documentId生成合同id
|
|
|
+ long s1 = System.currentTimeMillis();
|
|
|
+ HashMap contractIdHashMap = new HashMap();
|
|
|
+ if("doc".equals(substring.toLowerCase()) || "docx".equals(substring.toLowerCase()) || "pdf".equals(substring.toLowerCase()) ){
|
|
|
+ contractIdHashMap = ruralProjectMessageService.getSignatureContractId(ruralProjectRecords.getId(), documentList,ruralProjectRecords.getProjectMasterId(),"");
|
|
|
+ }else if("xls".equals(substring.toLowerCase()) || "xlsx".equals(substring.toLowerCase())){
|
|
|
+ contractIdHashMap = ruralProjectMessageService.getSignatureExcelContractId(ruralProjectRecords.getId(), documentList,ruralProjectRecords.getProjectMasterId(),"");
|
|
|
+ }
|
|
|
+ String contractIdCode = contractIdHashMap.get("code").toString();
|
|
|
+ String contractId = "";
|
|
|
+ if("0".equals(contractIdCode)){
|
|
|
+ contractId = contractIdHashMap.get("contractId").toString();
|
|
|
+ if("".equals(contractId)){
|
|
|
+ disposeResult = "签章文件创建失败";
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ disposeResult = contractIdHashMap.get("message").toString();
|
|
|
+ bool = false;
|
|
|
+ }
|
|
|
+ long s2 = System.currentTimeMillis();
|
|
|
+ System.out.println("创建签章合同用时:" + (s2-s1));
|
|
|
+ //进行静默签署
|
|
|
+ /*HashMap signbyCompanyHashMap = ruralProjectMessageService.signbyCompany(contractId, documentList);
|
|
|
+ if(null != signbyCompanyHashMap){
|
|
|
+ String signbyCompany = signbyCompanyHashMap.get("code").toString();
|
|
|
+ if(!"0".equals(signbyCompany)){
|
|
|
+ disposeResult = signbyCompanyHashMap.get("message").toString();
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ //将documentId 和contractId存储到质量复核对应的数据种
|
|
|
+ //签章完成则进行数据的保存
|
|
|
+ notification(bool,disposeResult,documentId,contractId,srcFileName);
|
|
|
+ }else{
|
|
|
+ disposeResult = "审定单文件未找到,无法进行签章操作";
|
|
|
+ bool = false;
|
|
|
+ notification(bool,disposeResult,"","","");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }finally {
|
|
|
+ if(StringUtils.isNotBlank(deleteFile)){
|
|
|
+ //根据路径创建文件对象
|
|
|
+ File file = new File(deleteFile);
|
|
|
+ //路径是个文件且不为空时删除文件
|
|
|
+ if(file.isFile()&&file.exists()){
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void notification(Boolean bool,String disposeResult,String documentId,String contractId,String srcFileName){
|
|
|
+ if(bool){
|
|
|
+ //users.add(projectReportSignature.getCreateBy());
|
|
|
+ //审核完成提示框
|
|
|
+ String title = "报告号【"+projectReportData.getNumber()+"】审定单签章审批登记完成";
|
|
|
+ String content = "报告号【"+projectReportData.getNumber()+"】审定单签章审批登记完成,项目编号:"+ruralProjectRecords.getProjectId();
|
|
|
+ if ("yes".equals(projectReportData.getAct().getFlag())) {
|
|
|
+ projectReportData.setStatus("5");
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(projectReportData.getId());
|
|
|
+ //userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //users.add(projectReportSignature.getCreateBy());
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(projectReportData.getId(),
|
|
|
+ projectReportData.getCreateBy(),
|
|
|
+ projectReportData.getCompanyId(),
|
|
|
+ title,
|
|
|
+ content,
|
|
|
+ "105",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ "审批通过"));
|
|
|
+
|
|
|
+ } else {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(projectReportData.getId());
|
|
|
+ //userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //users.add(projectReportSignature.getCreateBy());
|
|
|
+ if (StringUtils.isNotBlank(projectReportData.getStatus()) && !projectReportData.getStatus().equals("3")){
|
|
|
+ projectReportData.setStatus("4");
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(projectReportData.getId(),
|
|
|
+ projectReportData.getCreateBy(),
|
|
|
+ projectReportData.getCompanyId(),
|
|
|
+ title,
|
|
|
+ content,
|
|
|
+ "105",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ "审批通过"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(projectReportData.getProcessInstanceId());
|
|
|
+
|
|
|
+ //签章完成则进行数据的保存
|
|
|
+ ruralProjectRecords.setQualitySignatureFlag(1);
|
|
|
+ ruralProjectRecords.setQualitySignatureDocumentId(documentId);
|
|
|
+ ruralProjectRecords.setQualitySignatureContractId(contractId);
|
|
|
+ ruralProjectRecords.setQualitySignatureFileName(srcFileName);
|
|
|
+ ruralProjectRecords.setQualitySignatureUploadFileUser(UserUtils.getUser());
|
|
|
+ ruralProjectRecords.setQualitySignatureUploadDate(new Date());
|
|
|
+ //修改签章对应信息文件
|
|
|
+ projectReportDataService.updateJudgementSignatureInfo(ruralProjectRecords);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //users.add(projectReportSignature.getCreateBy());
|
|
|
+ //审核完成提示框
|
|
|
+ String title = "报告号【"+projectReportData.getNumber()+"】审定单签章失败。原因:"+ disposeResult;
|
|
|
+ String content = "报告号【"+projectReportData.getNumber()+"】审定单签章失败。原因:"+ disposeResult;
|
|
|
+ if ("yes".equals(projectReportData.getAct().getFlag())) {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(projectReportData.getId());
|
|
|
+ //userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //users.add(projectReportSignature.getCreateBy());
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(projectReportData.getId(),
|
|
|
+ projectReportData.getCreateBy(),
|
|
|
+ projectReportData.getCompanyId(),
|
|
|
+ title,
|
|
|
+ content,
|
|
|
+ "105",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ "审批通过"));
|
|
|
+
|
|
|
+ } else {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(projectReportData.getId());
|
|
|
+ //userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //users.add(projectReportSignature.getCreateBy());
|
|
|
+ if (StringUtils.isNotBlank(projectReportData.getStatus()) && !projectReportData.getStatus().equals("3")){
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(projectReportData.getId(),
|
|
|
+ projectReportData.getCreateBy(),
|
|
|
+ projectReportData.getCompanyId(),
|
|
|
+ title,
|
|
|
+ content,
|
|
|
+ "105",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ "审批通过"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(projectReportData.getProcessInstanceId());
|
|
|
+
|
|
|
+ projectReportData.setStatus("1");
|
|
|
+ dao.update(projectReportData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|