From 82de9480fd0ea3d97f7e182e5ac927e9677e500b Mon Sep 17 00:00:00 2001 From: rengp Date: Fri, 19 Apr 2024 23:32:00 +0800 Subject: [PATCH] no message --- .../action/AddArchivesRecordAction.java | 60 + .../archives/action/WorkflowToDocCus.java | 19 +- .../archives/corn/PushArchivesCorn.java | 34 +- .../archives/entity/PushArchivesBean.java | 217 + .../service/ReceivingPushArchivesService.java | 488 ++ .../service/SendingPushArchivesService.java | 514 ++ .../SignReportPushArchivesService.java | 84 + .../service/impl/HtmlToPdfServiceCusImpl.java | 14 +- .../ArchivesUtil.java} | 1697 ++-- .../requestForm/RequestDocPropManagerCus.java | 7 +- .../biz/requestForm/SaveDocDetailBizCus.java | 17 +- .../biz/requestForm/WfToDocBizCus.java | 9 +- .../biz/requestLog/RequestLogCusBiz.java | 100 +- .../requestLog/LoadRequestLogDataCusCmd.java | 24 +- .../service/impl/TJBKWorkFlowServiceImpl.java | 2 +- .../tjbankSocket/impl/CWGLSocketExecute.java | 10 +- com/engine/util/SocketClientUtil.java | 36 +- com/engine/web/tjbk/TjbkServerSocket.java | 170 +- .../cmd/mobileCenter/GetListResultCmd.java | 37 +- .../cmd/requestList/GetListResultCmd.java | 1135 +++ interface/transfer/mobile/testDemo3.jsp | 47 + weaver/general/WorkFlowTransMethod.java | 7356 +++++++++++++++++ weavernorth/com/testDateKey.jsp | 25 + 23 files changed, 10924 insertions(+), 1178 deletions(-) create mode 100644 com/engine/custom/archives/action/AddArchivesRecordAction.java create mode 100644 com/engine/custom/archives/entity/PushArchivesBean.java create mode 100644 com/engine/custom/archives/service/ReceivingPushArchivesService.java create mode 100644 com/engine/custom/archives/service/SendingPushArchivesService.java create mode 100644 com/engine/custom/archives/service/SignReportPushArchivesService.java rename com/engine/custom/archives/{service/PushArchivesCornService.java => util/ArchivesUtil.java} (70%) create mode 100644 com/engine/workflow/cmd/requestList/GetListResultCmd.java create mode 100644 interface/transfer/mobile/testDemo3.jsp create mode 100644 weaver/general/WorkFlowTransMethod.java create mode 100644 weavernorth/com/testDateKey.jsp diff --git a/com/engine/custom/archives/action/AddArchivesRecordAction.java b/com/engine/custom/archives/action/AddArchivesRecordAction.java new file mode 100644 index 0000000..fc04c6b --- /dev/null +++ b/com/engine/custom/archives/action/AddArchivesRecordAction.java @@ -0,0 +1,60 @@ +package com.engine.custom.archives.action; + +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +/** + * 添加流程到推送记录 + */ +public class AddArchivesRecordAction extends BaseBean implements Action { + String SQL = "insert into uf_pushArchivesLog (request,type,ddsj) values (?,?,?) "; + + @Override + public String execute(RequestInfo requestInfo) { + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String reveive = Util.null2String(Prop.getPropValue("archives", "reveive")); + String send = Util.null2String(Prop.getPropValue("archives", "send")); + String SignOff = Util.null2String(Prop.getPropValue("archives", "SignOff")); + //痩文 + List reveiveArr = Arrays.asList( reveive.split(",")); + //发文 + List sendArr = Arrays.asList(send.split(",")); + //签报 + List SignOffArr = Arrays.asList(SignOff.split(",")); + String type = ""; + if (sendArr.contains(workflowid)){ + type = "0"; + }else if(reveiveArr.contains(workflowid)){ + type = "1"; + }else if(SignOffArr.contains(workflowid)){ + type = "2"; + }else { + //不匹配跳过insert + return Action.SUCCESS; + } + RecordSet recordSet = new RecordSet(); + Date date = new Date(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String dateStr = format.format(date); + recordSet.executeUpdate(SQL,requestid,type,dateStr); + return null; + } + + + public static void main(String[] args) { + + + + } +} diff --git a/com/engine/custom/archives/action/WorkflowToDocCus.java b/com/engine/custom/archives/action/WorkflowToDocCus.java index 6b3d2b2..e99234f 100644 --- a/com/engine/custom/archives/action/WorkflowToDocCus.java +++ b/com/engine/custom/archives/action/WorkflowToDocCus.java @@ -11,6 +11,7 @@ import com.engine.custom.archives.workflow.biz.requestForm.WfToDocBizCus; import com.engine.workflow.biz.requestForm.WfWaterMark4WfToDocBiz; import com.engine.workflow.entity.WorkflowToDocSettingInfoEntity; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; @@ -52,11 +53,12 @@ import java.util.regex.Pattern; * @version 1.0 */ +@Slf4j public class WorkflowToDocCus { String SUCCESS = "1"; String FAILURE_AND_CONTINUE = "0"; - private static final Logger log = LoggerFactory.getLogger(WorkflowToDocCus.class); + // private static final Logger log = LoggerFactory.getLogger(WorkflowToDocCus.class); private final static int THREAD_NUM = 10;//10个固定线程池 private final static ExecutorService expPool = Executors.newFixedThreadPool(THREAD_NUM);//使用线程池进行线程管理 @@ -78,7 +80,7 @@ public class WorkflowToDocCus { try { class_MultiLangFilter = Class.forName("weaver.filter.MultiLangFilter"); } catch (ClassNotFoundException e) { - log.info("class MultiLangFilter doesn't exist"); + new BaseBean().writeLog("class MultiLangFilter doesn't exist"); } } @@ -153,6 +155,13 @@ public class WorkflowToDocCus { com.api.workflow.util.ServiceUtil serviceUtil = new ServiceUtil(); if (!isfromaction) nodeid = serviceUtil.getCurrentNode(requestid,user); + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from workflowactionset where workflowid = ? and INTERFACEID = 'WorkflowToDoc'",workflowid); + log.error("oldnodeid:"+nodeid); + if (rs.next()){ + nodeid = Util.getIntValue(rs.getString("nodeid")); + } + log.error("newnodeid:"+nodeid); String modeid = wfbiz.getModeid(Util.getIntValue(workflowid),Util.getIntValue(requestid),nodeid); int keepsign = getKeepSign(workflowid); @@ -630,7 +639,7 @@ public class WorkflowToDocCus { try { ResourceComInfo = new ResourceComInfo(); } catch (Exception e) { - log.error(e); + log.error("异常:",e); } String sql = ""; int doclangurage = 7; @@ -733,7 +742,7 @@ public class WorkflowToDocCus { } } catch (Exception e) { - log.error(e); + log.error("异常",e); } int isHistory = 0; int approveType = 0; @@ -1080,7 +1089,7 @@ public class WorkflowToDocCus { }catch (Exception e) { success = false; log.error("RequestDocPropManagerCus Error:requestid="+requestid+"###docids="+docids); - log.error(e); + log.error("异常"+e); } log.error("success:"+success); return success; diff --git a/com/engine/custom/archives/corn/PushArchivesCorn.java b/com/engine/custom/archives/corn/PushArchivesCorn.java index 70561e0..458b91a 100644 --- a/com/engine/custom/archives/corn/PushArchivesCorn.java +++ b/com/engine/custom/archives/corn/PushArchivesCorn.java @@ -1,10 +1,18 @@ package com.engine.custom.archives.corn; -import com.engine.custom.archives.service.PushArchivesCornService; +import com.engine.custom.archives.service.ReceivingPushArchivesService; +import com.engine.custom.archives.service.SendingPushArchivesService; +import com.engine.custom.archives.service.SignReportPushArchivesService; +import com.engine.custom.archives.util.ArchivesUtil; import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.interfaces.schedule.BaseCronJob; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; /*** @@ -12,24 +20,34 @@ import java.util.HashMap; * @author rengp * @date 2024/4/7 */ -@Slf4j + public class PushArchivesCorn extends BaseCronJob { - public String filePath = "/opt/weaver/filesys/test"; + public String filePath = "/opt/weaver/archivesFile"; public String Url = "http://14.1.206.240:18080/fcscloud/composite/upload"; - public String templatePath = "/opt/weaver/filesys/template.docx"; + public String templatePath = "/opt/weaver/archivesFile/template/"; public String reqid = ""; + public static Logger log = LoggerFactory.getLogger("Archives"); - PushArchivesCornService service = new PushArchivesCornService(); + ReceivingPushArchivesService receivingservice = new ReceivingPushArchivesService(); + SendingPushArchivesService sendingservice = new SendingPushArchivesService(); + SignReportPushArchivesService signReportservice =new SignReportPushArchivesService(); @Override public void execute() { log.info("PushArchivesCorn====Begin========"); + Date date = ArchivesUtil.getDate(); + String dateStr = new SimpleDateFormat("yyyyMMdd").format(date); HashMap param = new HashMap<>(); - param.put("filePath",filePath); + param.put("filePath",filePath+ File.separator+dateStr); param.put("Url",Url); param.put("requestid",reqid); param.put("templatePath",templatePath); - service.setProp(param); - service.pushArchives(param); + // receivingservice.setProp(param); + // receivingservice.pushArchives(param); + sendingservice.setProp(param); + sendingservice.pushArchives(param); + signReportservice.setProp(param); + signReportservice.pushArchives(param); + } } diff --git a/com/engine/custom/archives/entity/PushArchivesBean.java b/com/engine/custom/archives/entity/PushArchivesBean.java new file mode 100644 index 0000000..b80940e --- /dev/null +++ b/com/engine/custom/archives/entity/PushArchivesBean.java @@ -0,0 +1,217 @@ +package com.engine.custom.archives.entity; + +public class PushArchivesBean { + + + private int id; + private String requestId; + private int request; + private String content; + private String zt; + private String ddsj; + private String tssj; + private String zw; + private String fj; + private String cbd; + private String lzxx; + private String zlc; + private String esbtxtml; + private String esbwjml; + private String formModeId; + private String modeDataCreater; + private String modeDataCreatertype; + private String modeDataCreatedate; + private String modeDataCreatetime; + private String modeDataModifier; + private String modeDataModifydatetime; + private String formBizId; + private String type; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public int getRequest() { + return request; + } + + public void setRequest(int request) { + this.request = request; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getZt() { + return zt; + } + + public void setZt(String zt) { + this.zt = zt; + } + + public String getDdsj() { + return ddsj; + } + + public void setDdsj(String ddsj) { + this.ddsj = ddsj; + } + + public String getTssj() { + return tssj; + } + + public void setTssj(String tssj) { + this.tssj = tssj; + } + + public String getZw() { + return zw; + } + + public void setZw(String zw) { + this.zw = zw; + } + + public String getFj() { + return fj; + } + + public void setFj(String fj) { + this.fj = fj; + } + + public String getCbd() { + return cbd; + } + + public void setCbd(String cbd) { + this.cbd = cbd; + } + + public String getLzxx() { + return lzxx; + } + + public void setLzxx(String lzxx) { + this.lzxx = lzxx; + } + + public String getZlc() { + return zlc; + } + + public void setZlc(String zlc) { + this.zlc = zlc; + } + + public String getEsbtxtml() { + return esbtxtml; + } + + public void setEsbtxtml(String esbtxtml) { + this.esbtxtml = esbtxtml; + } + + public String getEsbwjml() { + return esbwjml; + } + + public void setEsbwjml(String esbwjml) { + this.esbwjml = esbwjml; + } + + public String getFormModeId() { + return formModeId; + } + + public void setFormModeId(String formModeId) { + this.formModeId = formModeId; + } + + public String getModeDataCreater() { + return modeDataCreater; + } + + public void setModeDataCreater(String modeDataCreater) { + this.modeDataCreater = modeDataCreater; + } + + public String getModeDataCreatertype() { + return modeDataCreatertype; + } + + public void setModeDataCreatertype(String modeDataCreatertype) { + this.modeDataCreatertype = modeDataCreatertype; + } + + public String getModeDataCreatedate() { + return modeDataCreatedate; + } + + public void setModeDataCreatedate(String modeDataCreatedate) { + this.modeDataCreatedate = modeDataCreatedate; + } + + public String getModeDataCreatetime() { + return modeDataCreatetime; + } + + public void setModeDataCreatetime(String modeDataCreatetime) { + this.modeDataCreatetime = modeDataCreatetime; + } + + public String getModeDataModifier() { + return modeDataModifier; + } + + public void setModeDataModifier(String modeDataModifier) { + this.modeDataModifier = modeDataModifier; + } + + public String getModeDataModifydatetime() { + return modeDataModifydatetime; + } + + public void setModeDataModifydatetime(String modeDataModifydatetime) { + this.modeDataModifydatetime = modeDataModifydatetime; + } + + public String getFormBizId() { + return formBizId; + } + + public void setFormBizId(String formBizId) { + this.formBizId = formBizId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + + + +} diff --git a/com/engine/custom/archives/service/ReceivingPushArchivesService.java b/com/engine/custom/archives/service/ReceivingPushArchivesService.java new file mode 100644 index 0000000..6309e30 --- /dev/null +++ b/com/engine/custom/archives/service/ReceivingPushArchivesService.java @@ -0,0 +1,488 @@ +package com.engine.custom.archives.service; + + +import com.dcfs.fts.common.error.FtpException; +import com.engine.custom.archives.util.ArchivesUtil; +import com.engine.custom.hg.util.HgUtils; +import com.icbc.api.internal.apache.http.impl.cookie.S; +import lombok.extern.slf4j.Slf4j; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Calendar; +import java.util.Date; +import java.nio.charset.StandardCharsets; +import java.io.*; +import java.util.*; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; +import weaver.general.StringUtil; +import weaver.general.Util; +import com.alibaba.fastjson.JSONObject; +import weaver.file.ImageFileManager; + +import java.net.URL; + +import org.apache.commons.io.FileUtils; +import okhttp3.*; + +import java.net.URLEncoder; + +import weaver.soa.workflow.request.RequestService; +import weaver.soa.workflow.request.RequestInfo; +import com.engine.custom.archives.action.WorkflowToDocCus; +import weaver.docs.docs.DocRecycleManager; +import weaver.hrm.User; +import com.api.workflow.service.RequestAuthenticationService; +import weaver.workflow.workflow.WorkflowConfigComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.crm.Maint.CustomerInfoComInfo; +import com.alibaba.fastjson.JSON; +import weaver.workflow.monitor.Monitor; +import com.engine.workflow.biz.RobotNode.RobotNodeServiceBiz; +import com.api.workflow.util.ServiceUtil; +import com.engine.workflow.biz.RobotNode.RobotNodeBiz; +import weaver.general.TimeUtil; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import cn.afterturn.easypoi.word.WordExportUtil; +import cn.hutool.core.util.ZipUtil; +import freemarker.template.Configuration; +import freemarker.template.TemplateExceptionHandler; +import freemarker.template.Template; +import java.nio.charset.StandardCharsets; + + + +public class ReceivingPushArchivesService { + private static String filePath; + private static String Url; + private static String templatePath; // 模板文件路径 + private static final String zwdir = "正文"; + private static final String fjdir = "附件"; + private static final String cbddir = "承办单"; + private static final String zlcdir = "承办单" + File.separator + "子流程"; + private static final String lzxxdir = "流转信息"; + private static final String fjFile = "附件"; + public static Logger log = LoggerFactory.getLogger("Archives"); + + + public void setProp(Map param) { + filePath = Util.null2String(param.get("filePath")); + Url = Util.null2String(param.get("Url")); + templatePath = Util.null2String(param.get("templatePath")); + } + + + public void pushArchives(Map param) { + log.info("PushArchivesCorn====Begin========{}", param); + try { + + ZipUtil zipUtil = new ZipUtil(); + Date date = ArchivesUtil.getDate(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + String format = dateFormat.format(date); + SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + // 获取当前时间的第一秒 + String firstSecond = yyyyMMddHHmmss.format(getFirstSecondOfDate(date)); + // 获取当前时间的最后一秒 + String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date)); + + Integer requestid = Util.getIntValue(param.get("requestid")); + + log.error("requestid:{}", requestid); + String context = extracted(requestid); + log.error("context:{}", context); + File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); + log.error("textfile:{}", file.getAbsolutePath()); + ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true); + File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip"); + log.error("textZipFile:{}", txtzip.getAbsolutePath()); + OutputStream outputStream = new FileOutputStream(txtzip); + File writename = new File(file.getPath() + "/" + file.getName() + ".txt"); + com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName()); + log.error("writename:{}",writename.getName()); + String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName()); + updateRecord(requestid, s); + log.error("textZip:{}", s); + } catch (Exception e) { + log.info("PushArchivesCorn====Exception========{}", e.getMessage()); + e.printStackTrace(); + } + + } + + private void updateRecord(int requestids, String s) { + String sql = "update uf_pushArchivesLog set esbtxtml = ? where request in ( " + requestids + " )"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(sql, s); + } + + private String extracted(int requestid) throws FtpException, IOException { + Map requesData = getRequestByid(requestid); + log.info("requesData:{}", requesData); + String fj = Util.null2String(requesData.get("fj")); + String zwkbj = Util.null2String(requesData.get("zwkbj")); + //增加签字意见中的附件到附件文件夹中 + Map signFiles = ArchivesUtil.getSignFiles(requestid,true); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + Map zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj); + List zwFileName = new ArrayList<>(); + List fjFileName = new ArrayList<>(); + final int[] i = {1}; + //附件 + fjMap.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); + fjFileName.add(imageFileManager.getImageFileName()); + log.info("生成附件路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回数据:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); + } + } catch (IOException e) { + e.printStackTrace(); + } + }); + + //签字意见附件 + signFiles.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); + fjFileName.add(imageFileManager.getImageFileName()); + log.info("生成签字意见附件路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回数据:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); + } + } catch (IOException e) { + e.printStackTrace(); + } + }); + + //正文 + zwkbjMap.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + zwFileName.add(imageFileManager.getImageFileName()); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName(); + log.info("生成正文路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); + } + } catch (IOException e) { + e.printStackTrace(); + } + }); + //开始承办单 先获取主流程的承办单 + List requestDocid = ArchivesUtil.generaRequestFormPdf(requestid,1); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid)); + log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap)); + //log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap)); + docids.addAll(requestDocid); + // 3.去掉生成子流程承办单 + // docids.addAll(subRequestDocid); + //附件 + reqDocMap.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName(); + log.info("主流程承办单路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName() + ".pdf"); + } + i[0]++; + } catch (IOException e) { + e.printStackTrace(); + } + }); +//正文 + + i[0] = 1; + // 4.去掉生成子流程承办单 + // subReqDocMap.forEach((docid, imageid) -> { + // ImageFileManager imageFileManager = new ImageFileManager(); + // imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + // InputStream inputStream = imageFileManager.getInputStream(); + // //中文路径/中文文件名 + // String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName()); + // imageFileName = codeUtf8(imageFileName); + // log.info("子流程承办单路径:{}", imageFileName); + // try { + // File file = saveInputStreamToFile(inputStream, imageFileName); + // String jsonStr = callApi(Url, file); + // log.error("永中接口返回:{}", jsonStr); + // JSONObject result = JSONObject.parseObject(jsonStr); + // String errorcode = result.getString("errorcode"); + // if ("0".equals(errorcode)) { + // JSONObject data = result.getJSONObject("data"); + // String destFileName = data.getString("destFileName"); + // String viewUrl = data.getString("viewUrl"); + // downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf"); + // } + // i[0]++; + // } catch (IOException e) { + // e.printStackTrace(); + // } + // }); + log.error(JSONObject.toJSONString(requestDocid)); + // log.error(JSONObject.toJSONString(subRequestDocid)); + for (String docid : docids) { + log.error("删除了" + docid); + ArchivesUtil.deleteDocByid(docid); + } + //-------------------------------------------------------------------- + RequestService requestService = new RequestService(); + RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); + + String logFile = ArchivesUtil.getSignLog(requestid, cbddir+File.separator+lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription(),templatePath,filePath,true); + String s = ArchivesUtil.callApi(Url, new File(logFile)); + log.error(s); + JSONObject result = JSONObject.parseObject(s); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); + } + String zipName = filePath + File.separator + requestid + ".zip"; + ZipUtil.zip(filePath + File.separator + requestid, zipName); + log.error("zipName:{}", zipName); + String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); + log.error("ftpFilePath:{}", ftpFilePath); + String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip"); + log.error("ftpFilePathNew:{}", ftpFilePathNew); + String context = getContext(requestid, requesData, requestid + ".zip", zwFileName, fjFileName); + insertRecord(requestid, context, ftpFilePath); + log.error("context:{}", context); + return context; + } + + + + private void insertRecord(int requestid, String context, String ftpFilePath) { + String sql = "insert into uf_pushArchivesLog (request ,content,esbwjml) VALUES (?,?,?)"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(sql, requestid, context, ftpFilePath); + } + + + // 获取指定日期的第一秒 + public static Date getFirstSecondOfDate(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTime(); + } + + // 获取指定日期的最后一秒 + public static Date getLastSecondOfDate(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + calendar.set(Calendar.MILLISECOND, 999); + return calendar.getTime(); + } + + + + /*** + * 封装数据 + * @param requestid + * @return + */ + public Map getRequestByid(int requestid) { + HashMap record = new HashMap<>(); + String sql = "select * from formtable_main_30 where requestid = ?"; + String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, requestid); + if (rs.next()) { + String fj = Util.null2String(rs.getString("fj")); + String zwkbj = Util.null2String(rs.getString("zwkbj")); // 正文可编辑字段 + record.put("fj", fj); + record.put("zwkbj", zwkbj); + record.put("zwyyglgwmk", Util.null2String(rs.getString("zwyyglgwmk"))); + record.put("lwh", Util.null2String(rs.getString("lwh"))); + record.put("mj", Util.null2String(rs.getString("mj"))); + record.put("lwrq", Util.null2String(rs.getString("lwrq"))); + record.put("swrq", Util.null2String(rs.getString("swrq"))); + record.put("blqx", Util.null2String(rs.getString("blqx"))); + record.put("sfdb", Util.null2String(rs.getString("sfdb"))); + record.put("wjlx", Util.null2String(rs.getString("wjlx"))); + record.put("fssj", Util.null2String(rs.getString("fssj"))); + record.put("gdh", Util.null2String(rs.getString("gdh"))); + record.put("swh", Util.null2String(rs.getString("swh"))); + record.put("ngbm", Util.null2String(rs.getString("ngbm"))); + record.put("ngr", Util.null2String(rs.getString("ngr"))); + record.put("ngrq", Util.null2String(rs.getString("ngrq"))); + record.put("swlx", Util.null2String(rs.getString("swlx"))); + record.put("jghwt", Util.null2String(rs.getString("jghwt"))); + record.put("lwdwmc", Util.null2String(rs.getString("lwdwmc"))); + record.put("bgqx", Util.null2String(rs.getString("bgqx"))); + record.put("ys", Util.null2String(rs.getString("ys"))); + record.put("wz", Util.null2String(rs.getString("wz"))); + record.put("lb", Util.null2String(rs.getString("lb"))); + record.put("bz", Util.null2String(rs.getString("bz"))); + record.put("yffbm", Util.null2String(rs.getString("yffbm"))); + record.put("ffbmb", Util.null2String(rs.getString("ffbmb"))); + record.put("yffbm", Util.null2String(rs.getString("yffbm"))); + } + rs.executeQuery(reqsql, requestid); + if (rs.next()) { + record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME"))); + } + return record; + } + + + private String getContext(int requestid, Map requesData, String zipName, List zwFileName, List fjFileName) { + StringBuilder context = new StringBuilder(); + try { + + String swrq = Util.null2String(requesData.get("swrq")); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate date = LocalDate.parse(swrq, formatter); + int year = date.getYear(); + context.append(year).append("|"); + String jghwt = Util.null2String(requesData.get("jghwt")); + context.append(jghwt).append("|"); + String swh = Util.null2String(requesData.get("swh")); + context.append(swh).append("|"); + String requestname = Util.null2String(requesData.get("REQUESTNAME")); + context.append(requestname).append("|"); + String lwdwmc = Util.null2String(requesData.get("lwdwmc")); //5 责任者 -> 来文单位 + context.append(lwdwmc).append("|"); + String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限 + context.append(bgqx).append("|"); + String lwrq = Util.null2String(requesData.get("lwrq")); //7 日期 -> 原发文日期 + context.append(lwrq).append("|"); + String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数 + context.append(ys).append("|"); + String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种 + context.append(wz).append("|"); + String ngbm = Util.null2String(requesData.get("ngbm")); + String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm); + context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 + context.append(deptData[1]).append("|"); //11 行名称 + context.append("").append("|"); // 12 保管期限编号 + context.append("").append("|"); // 13 保管期限及编号 + context.append("").append("|"); // 14 是否开放 + context.append("").append("|"); // 15 互见号 + String lb = Util.null2String(requesData.get("lb")); + context.append(lb).append("|"); //16 类别 -> 类别 + //TODO + String xgbm = Util.null2String(getAssociatedDepts(requesData)); + context.append(xgbm).append("|"); //17 相关部门 -> 流经部门 + String lwh = Util.null2String(requesData.get("lwh"));// 18 收文号 -> 来文文号 + context.append(lwh).append("|"); + String fs = ""; + context.append(fs).append("|"); // 19 份数 -> 份数 + String bz = Util.null2String(requesData.get("bz")); + context.append(bz).append("|"); // 20 备注 -> 备注 + String yywh = Util.null2String(requesData.get("yywh")); + context.append(yywh).append("|"); // 21 引用文号 -> 引用文号 + String wjlx = Util.null2String(requesData.get("wjlx")); + context.append(wjlx).append("|"); // 22 文件类型 -> 空 + String fwlx = Util.null2String(requesData.get("fwlx")); + context.append(fwlx).append("|"); // 23 文件类型 -> 空 + String f = Util.null2String(requesData.get("f")); + context.append(f).append("|"); // 24 发 -> 空 + String ngr = Util.null2String(requesData.get("ngr")); + context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人 + context.append(deptData[1]).append("|"); // 26 拟稿部门 -> 拟稿部门名称 + context.append("收文").append("|"); // 27 公文类型 -> "收文" + //TODO + context.append(ArchivesUtil.getAssociatedPersons(requestid,true)).append("|"); // 28 相关人员 -> 参与人员 + context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源 + context.append(year).append("|"); // 30 形成年度 -> 年份 + context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 + context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 + context.append(requestid).append("|"); // 33 主键 + context.append("").append("|"); // 34 关联主键 + context.append("").append("|"); // 35 被关联主键 + context.append(zipName);// 36 压缩包名称 + } catch (Exception e) { + e.printStackTrace(); + log.error("getContextError:{}", e.getMessage()); + } + + return context.toString(); + } + + private String getAssociatedDepts(Map requesData) { + HashSet records = new HashSet<>(); + records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); + records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbm")).split(","))); + records.addAll(Arrays.asList(Util.null2String(requesData.get("yffbm")).split(","))); + records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbmb")).split(","))); + records.addAll(Arrays.asList(Util.null2String(requesData.get("zfbm")).split(","))); + return String.join("&&", records); + } + +} diff --git a/com/engine/custom/archives/service/SendingPushArchivesService.java b/com/engine/custom/archives/service/SendingPushArchivesService.java new file mode 100644 index 0000000..aad0863 --- /dev/null +++ b/com/engine/custom/archives/service/SendingPushArchivesService.java @@ -0,0 +1,514 @@ +package com.engine.custom.archives.service; + +import cn.hutool.core.util.ZipUtil; +import com.alibaba.fastjson.JSONObject; +import com.dcfs.fts.common.error.FtpException; +import com.engine.custom.archives.entity.PushArchivesBean; +import com.engine.custom.archives.util.ArchivesUtil; +import com.engine.custom.hg.util.HgUtils; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.StringUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.authority.manager.HrmDepartmentManager; +import weaver.hrm.company.DepartmentComInfo; +import weaver.soa.hrm.Department; +import weaver.soa.workflow.request.RequestInfo; +import weaver.soa.workflow.request.RequestService; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + + +public class SendingPushArchivesService { + public static Logger log = LoggerFactory.getLogger("Archives"); + private static String filePath; + private static String Url; + private static String templatePath; // 模板文件路径 + private static final String zwdir = "正文"; + private static final String fjdir = "附件"; + private static final String cbddir = "承办单"; + private static final String zlcdir = "承办单" + File.separator + "子流程"; + private static final String lzxxdir = "流转信息"; + private static final String fjFile = "附件"; + private static final String fjWord = "附件"; + private static final String zwWord = "正文"; + private static final String lhgWord = "留痕稿"; + private static final String lcfjWord = "流程附件"; + private static final String qzyjfjWord = "签字意见附件"; + private static final String wjcldWord = "文件处理单"; + private static final String wjlzxxWord = "文件流转信息"; + + public void setProp(Map param) { + filePath = Util.null2String(param.get("filePath")); + Url = Util.null2String(param.get("Url")); + templatePath = Util.null2String(param.get("templatePath")); + } + + public void pushArchives(Map param) { + log.info("PushArchivesCorn====Begin========{}", param); + Date date = ArchivesUtil.getDate(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + String format = dateFormat.format(date); + SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + // 获取当前时间的第一秒 + String firstSecond = yyyyMMddHHmmss.format(ArchivesUtil.getFirstSecondOfDate(date)); + // 获取当前时间的最后一秒 + String lastSecond = yyyyMMddHHmmss.format(ArchivesUtil.getLastSecondOfDate(date)); + RecordSet recordSet = new RecordSet(); + List result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 0); + log.error("推送发文的数量:{}", result.size()); + File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); + log.error("textfile:{}", file.getAbsolutePath()); + for (PushArchivesBean pushArchivesBean : result) { + int id = pushArchivesBean.getId(); + int request = pushArchivesBean.getRequest(); + log.error("推送的requestId:{}", request); + try { + String context = generateFile(request); + ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true); + File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip"); + log.error("textZipFile:{}", txtzip.getAbsolutePath()); + OutputStream outputStream = new FileOutputStream(txtzip); + File writename = new File(file.getPath() + "/" + file.getName() + ".txt"); + com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName()); + log.error("writename:{}", writename.getName()); + String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName()); + updateRecord(request, s); + log.error("textZip:{}", s); + } catch (FtpException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + + + private String generateFile(int requestid) throws FtpException, IOException { + Map requesData = getRequestByid(requestid); + log.info("requesData:{}", requesData); + String fj = Util.null2String(requesData.get("fj")); + String dwd = Util.null2String(requesData.get("dwd")); + String zw = Util.null2String(requesData.get("zw")); + String qgqhj = Util.null2String(requesData.get("qgqhj")); + String thhlh = Util.null2String(requesData.get("thhlh")); + + + //增加签字意见中的附件到附件文件夹中 + Map signFiles = ArchivesUtil.getSignFiles(requestid,false); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + Map dwdMap = ArchivesUtil.getFileIdByDocId(dwd); + Map zwMap = ArchivesUtil.getFileIdByDocId(zw); + Map qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj); + Map thhlhMap = ArchivesUtil.getFileIdByDocId(thhlh); + List zwFileName = new ArrayList<>(); + List fjFileName = new ArrayList<>(); + final int[] i = {1}; + //附件 + fjMap.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName(); + fjFileName.add(imageFileManager.getImageFileName()); + log.info("生成附件路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回数据:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + lcfjWord + "-" + imageFileManager.getImageFileName() + ".pdf"); + } + } catch (IOException e) { + e.printStackTrace(); + } + }); + + //签字意见附件 + signFiles.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName(); + fjFileName.add(imageFileManager.getImageFileName()); + log.info("生成签字意见附件路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回数据:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" + imageFileManager.getImageFileName() + ".pdf"); + } + } catch (IOException e) { + e.printStackTrace(); + } + }); + + //多文档 + // dwdMap.forEach((docid, imageid) -> { + // ImageFileManager imageFileManager = new ImageFileManager(); + // imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + // InputStream inputStream = imageFileManager.getInputStream(); + // zwFileName.add(imageFileManager.getImageFileName()); + // //中文路径/中文文件名 + // String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName(); + // log.info("生成多文档路径:{}", imageFileName); + // imageFileName = ArchivesUtil.codeUtf8(imageFileName); + // try { + // File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + // String jsonStr = ArchivesUtil.callApi(Url, file); + // log.error("永中接口返回:{}", jsonStr); + // JSONObject result = JSONObject.parseObject(jsonStr); + // String errorcode = result.getString("errorcode"); + // if ("0".equals(errorcode)) { + // JSONObject data = result.getJSONObject("data"); + // String destFileName = data.getString("destFileName"); + // String viewUrl = data.getString("viewUrl"); + // ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName() + ".pdf"); + // } + // } catch (IOException e) { + // e.printStackTrace(); + // } + // i[0]++; + // }); + //正文 + zwMap.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + + String newFile = fjWord + i[0] + "_" + zwWord + "-" + imageFileManager.getImageFileName(); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile; + zwFileName.add(newFile); + log.info("生成正文路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile + ".pdf"); + } + } catch (IOException e) { + e.printStackTrace(); + } + i[0]++; + }); + //清稿前痕迹 + qgqhjMap.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + + String newFile = fjWord + i[0] + "_" + lhgWord + "-" + imageFileManager.getImageFileName(); + zwFileName.add(newFile); + //中文路径/中文文件名 + String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile; + log.info("生成清稿前痕迹路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile + ".pdf"); + } + } catch (IOException e) { + e.printStackTrace(); + } + i[0]++; + }); + //套红后留痕 + // thhlhMap.forEach((docid, imageid) -> { + // ImageFileManager imageFileManager = new ImageFileManager(); + // imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + // InputStream inputStream = imageFileManager.getInputStream(); + // zwFileName.add(imageFileManager.getImageFileName()); + // //中文路径/中文文件名 + // String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName(); + // log.info("生成套红后留痕路径:{}", imageFileName); + // imageFileName = ArchivesUtil.codeUtf8(imageFileName); + // try { + // File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + // String jsonStr = ArchivesUtil.callApi(Url, file); + // log.error("永中接口返回:{}", jsonStr); + // JSONObject result = JSONObject.parseObject(jsonStr); + // String errorcode = result.getString("errorcode"); + // if ("0".equals(errorcode)) { + // JSONObject data = result.getJSONObject("data"); + // String destFileName = data.getString("destFileName"); + // String viewUrl = data.getString("viewUrl"); + // ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName() + ".pdf"); + // } + // } catch (IOException e) { + // e.printStackTrace(); + // } + // i[0]++; + // }); + + //开始承办单 先获取主流程的承办单 + List requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid)); + log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap)); + //log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap)); + docids.addAll(requestDocid); + // 3.去掉生成子流程承办单 + // docids.addAll(subRequestDocid); + i[0] = 1; + //主流程承办单 + reqDocMap.forEach((docid, imageid) -> { + ImageFileManager imageFileManager = new ImageFileManager(); + imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); + InputStream inputStream = imageFileManager.getInputStream(); + //中文路径/中文文件名 + // String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName(); + String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf"; + log.info("主流程承办单路径:{}", imageFileName); + imageFileName = ArchivesUtil.codeUtf8(imageFileName); + try { + File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName); + String jsonStr = ArchivesUtil.callApi(Url, file); + log.error("永中接口返回:{}", jsonStr); + JSONObject result = JSONObject.parseObject(jsonStr); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord + ".pdf" + ".pdf"); + } + i[0]++; + } catch (IOException e) { + e.printStackTrace(); + } + }); +//正文 + + + log.error(JSONObject.toJSONString(requestDocid)); + for (String docid : docids) { + log.error("删除了" + docid); + ArchivesUtil.deleteDocByid(docid); + } + //-------------------------------------------------------------------- + RequestService requestService = new RequestService(); + RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); + + String logFile = ArchivesUtil.getSignLog(requestid, cbddir + File.separator + lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription(), templatePath, filePath,false); + String s = ArchivesUtil.callApi(Url, new File(logFile)); + log.error(s); + JSONObject result = JSONObject.parseObject(s); + String errorcode = result.getString("errorcode"); + if ("0".equals(errorcode)) { + JSONObject data = result.getJSONObject("data"); + String destFileName = data.getString("destFileName"); + String viewUrl = data.getString("viewUrl"); + ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); + } + String zipName = filePath + File.separator + requestid + ".zip"; + ZipUtil.zip(filePath + File.separator + requestid, zipName); + log.error("zipName:{}", zipName); + String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); + log.error("ftpFilePath:{}", ftpFilePath); + // String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip"); + // log.error("ftpFilePathNew:{}", ftpFilePathNew); + String context = getContext(requestid, requesData, requestid + ".zip", zwFileName, fjFileName); + // insertRecord(requestid, context, ftpFilePath); + log.error("context:{}", context); + return context; + } + + + /*** + * 封装数据 + * @param requestid + * @return + */ + public Map getRequestByid(int requestid) { + HashMap record = new HashMap<>(); + String sql = "select * from formtable_main_11 where requestid = ?"; + String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, requestid); + if (rs.next()) { + record.put("fj", Util.null2String(rs.getString("fj"))); + record.put("dwd", Util.null2String(rs.getString("dwd"))); + record.put("zw", Util.null2String(rs.getString("zw"))); + record.put("ngrq", Util.null2String(rs.getString("ngrq"))); + record.put("jghwt", Util.null2String(rs.getString("jghwt"))); + record.put("bh", Util.null2String(rs.getString("bh"))); + record.put("ngbm", Util.null2String(rs.getString("ngbm"))); + record.put("bgqx", Util.null2String(rs.getString("bgqx"))); + record.put("cwrq", Util.null2String(rs.getString("cwrq"))); + record.put("ys", Util.null2String(rs.getString("ys"))); + record.put("wz", Util.null2String(rs.getString("wz"))); + record.put("ngbm", Util.null2String(rs.getString("ngbm"))); + record.put("lb", Util.null2String(rs.getString("lb"))); + record.put("bz", Util.null2String(rs.getString("bz"))); + record.put("yywh", Util.null2String(rs.getString("yywh"))); + record.put("wjlx", Util.null2String(rs.getString("wjlx"))); + record.put("fwlx", Util.null2String(rs.getString("fwlx"))); + record.put("f", Util.null2String(rs.getString("f"))); + record.put("ngr", Util.null2String(rs.getString("ngr"))); + record.put("qgqhj", Util.null2String(rs.getString("qgqhj"))); + record.put("thhlh", Util.null2String(rs.getString("thhlh"))); + + } + rs.executeQuery(reqsql, requestid); + if (rs.next()) { + record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME"))); + } + return record; + } + + private String getContext(int requestid, Map requesData, String zipName, List zwFileName, List fjFileName) { + StringBuilder context = new StringBuilder(); + try { + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + String ngrq = Util.null2String(requesData.get("ngrq")); //拟稿日期 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate date = LocalDate.parse(ngrq, formatter); + int year = date.getYear(); + context.append(year).append("|"); //1.年度 -> 拟稿日期 + String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题 + context.append(jghwt).append("|"); + String bh = Util.null2String(requesData.get("bh"));// 3.文号 -> 编号 + context.append(bh).append("|"); + String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称 + context.append(requestname).append("|"); + String ngbmName = Util.null2String(departmentComInfo.getDepartmentname(requesData.get("ngbm"))); //5 责任者 -> 拟稿部门 + context.append(ngbmName).append("|"); + String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限 + context.append(bgqx).append("|"); + String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期 + context.append(cwrq).append("|"); + String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数 + context.append(ys).append("|"); + String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种 + context.append(wz).append("|"); + String ngbm = Util.null2String(requesData.get("ngbm")); + String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm); + context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 + context.append(deptData[1]).append("|"); //11 行名称 + context.append("").append("|"); // 12 保管期限编号 + context.append("").append("|"); // 13 保管期限及编号 + context.append("").append("|"); // 14 是否开放 + context.append("").append("|"); // 15 互见号 + String lb = Util.null2String(requesData.get("lb")); + context.append(lb).append("|"); //16 类别 -> 类别 + //TODO + String xgbm = Util.null2String(getAssociatedDepts(requesData)); + context.append(xgbm).append("|"); //17 相关部门 -> 流经部门 + // String lwh = Util.null2String(requesData.get("lwh")); + context.append("").append("|");// 18 收文号 -> 空 + String fs = ""; + context.append(fs).append("|"); // 19 份数 -> 份数 + String bz = Util.null2String(requesData.get("bz")); + context.append("").append("|"); // 20 备注 -> 备注 + String yywh = Util.null2String(requesData.get("yywh")); + context.append("").append("|"); // 21 引用文号 -> 引用文号 + String wjlx = Util.null2String(requesData.get("wjlx")); + context.append("").append("|"); // 22 文件类型 -> 空 + String fwlx = Util.null2String(requesData.get("fwlx")); + context.append("总行发文").append("|"); // 23 发文类型 -> 空 + String f = Util.null2String(requesData.get("f")); + context.append(f).append("|"); // 24 发 -> 空 + String ngr = Util.null2String(requesData.get("ngr")); + context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人 + context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称 + context.append("发文").append("|"); // 27 公文类型 -> "收文" + //TODO + context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员 + context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源 + context.append(year).append("|"); // 30 形成年度 -> 年份 + context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 + context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 + context.append(requestid).append("|"); // 33 主键 + context.append("").append("|"); // 34 关联主键 + context.append("").append("|"); // 35 被关联主键 + context.append(zipName);// 36 压缩包名称 + } catch (Exception e) { + e.printStackTrace(); + log.error("getContextError:{}", e.getMessage()); + } + + return context.toString(); + } + + + private String getAssociatedDepts(Map requesData) { + HashSet records = new HashSet<>(); + records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 会签部门 + records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); // 拟稿部门 + records.addAll(Arrays.asList(Util.null2String(requesData.get("bmyb")).split(","))); // 部门阅办 + records.addAll(Arrays.asList(Util.null2String(requesData.get("cs")).split(","))); // 抄送 + records.addAll(Arrays.asList(Util.null2String(requesData.get("nbfs")).split(","))); // 本行发送 + records.addAll(Arrays.asList(Util.null2String(requesData.get("zs")).split(","))); // 主送 + records.addAll(Arrays.asList(Util.null2String(requesData.get("dqbm")).split(","))); // 当前部门 + records.addAll(Arrays.asList(Util.null2String(requesData.get("cb")).split(","))); // 抄报 + records.addAll(Arrays.asList(Util.null2String(requesData.get("bmhqzj")).split(","))); // 部门会签(追加) + records.addAll(Arrays.asList(Util.null2String(requesData.get("bmybzj")).split(","))); // 部门阅办(追加) + ArrayList deptName = new ArrayList<>(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + for (String record : records) { + try { + String departmentName = departmentComInfo.getDepartmentName(record); + deptName.add(departmentName); + } catch (Exception e) { + e.printStackTrace(); + } + } + + return String.join("&&", deptName); + } + + private void updateRecord(int requestid, String s) { + String sql = "update uf_pushArchivesLog set esbtxtml = ? where request = ?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(sql, s, requestid); + } + + +} diff --git a/com/engine/custom/archives/service/SignReportPushArchivesService.java b/com/engine/custom/archives/service/SignReportPushArchivesService.java new file mode 100644 index 0000000..b166829 --- /dev/null +++ b/com/engine/custom/archives/service/SignReportPushArchivesService.java @@ -0,0 +1,84 @@ +package com.engine.custom.archives.service; + +import cn.hutool.core.util.ZipUtil; +import com.dcfs.fts.common.error.FtpException; +import com.engine.custom.archives.entity.PushArchivesBean; +import com.engine.custom.archives.util.ArchivesUtil; +import com.engine.custom.hg.util.HgUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; + +public class SignReportPushArchivesService { + public static Logger log = LoggerFactory.getLogger("Archives"); + private static String filePath; + private static String Url; + private static String templatePath; // 模板文件路径 + private static final String zwdir = "正文"; + private static final String fjdir = "附件"; + private static final String cbddir = "承办单"; + private static final String zlcdir = "承办单" + File.separator + "子流程"; + private static final String lzxxdir = "流转信息"; + private static final String fjFile = "附件"; + private static final String fjWord = "附件"; + private static final String zwWord = "正文"; + private static final String lhgWord = "留痕稿"; + private static final String lcfjWord = "流程附件"; + private static final String qzyjfjWord = "签字意见附件"; + private static final String wjcldWord = "文件处理单"; + private static final String wjlzxxWord = "文件流转信息"; + + public void setProp(Map param) { + filePath = Util.null2String(param.get("filePath")); + Url = Util.null2String(param.get("Url")); + templatePath = Util.null2String(param.get("templatePath")); + } + + public void pushArchives(Map param) { + Date date = ArchivesUtil.getDate(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + String format = dateFormat.format(date); + SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + // 获取当前时间的第一秒 + String firstSecond = yyyyMMddHHmmss.format(ArchivesUtil.getFirstSecondOfDate(date)); + // 获取当前时间的最后一秒 + String lastSecond = yyyyMMddHHmmss.format(ArchivesUtil.getLastSecondOfDate(date)); + RecordSet recordSet = new RecordSet(); + List result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 0); + log.error("推送发文的数量:{}", result.size()); + File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); + log.error("textfile:{}", file.getAbsolutePath()); + for (PushArchivesBean pushArchivesBean : result) { + int id = pushArchivesBean.getId(); + int request = pushArchivesBean.getRequest(); + log.error("推送的requestId:{}", request); + try { + // String context = generateFile(request); + ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true); + File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip"); + log.error("textZipFile:{}", txtzip.getAbsolutePath()); + OutputStream outputStream = new FileOutputStream(txtzip); + File writename = new File(file.getPath() + "/" + file.getName() + ".txt"); + com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName()); + log.error("writename:{}", writename.getName()); + String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName()); + // updateRecord(request, s); + log.error("textZip:{}", s); + } catch (FtpException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java b/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java index 364ad5d..0dadc36 100644 --- a/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java +++ b/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java @@ -11,6 +11,8 @@ import com.engine.workflow.cmd.requestForm.*; import com.engine.workflow.entity.requestForm.TableInfo; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.Util; @@ -25,6 +27,7 @@ import java.util.List; import java.util.Map; public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfServiceCus { + public static Logger log = LoggerFactory.getLogger("Archives"); @Override public Map getHtml(Map reqpParams, User user) { return null; @@ -55,7 +58,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService requestMap.put("modeid",modeid); requestMap.put("limitauth",Util.null2String(reqpParams.get("limitauth"))); requestMap.put("forceNoPaging",1); //明细强制不分页 - new BaseBean().writeLog("HtmltoPdfServiceimpl ---requestid:"+requestid+"-----modeid:"+modeid); + log.error("HtmltoPdfServiceimpl ---requestid:"+requestid+"-----modeid:"+modeid); long start2 = System.currentTimeMillis(); //第一步:获取基础信息参数 @@ -110,6 +113,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService } + log.error("ismode:"+ismode); //第五步:模板布局 if (ismode == 0 || (ismode == 2 && layoutversion == 2)) { @@ -117,7 +121,9 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService if (ismode == 0) { //普通模式 layoutStr = Util.null2String(commonLayout.get("layoutStr")); } else if (ismode == 2) { //html模式 + int layoutid = Util.getIntValue(Util.null2String(params.get("modeid")), 0); + log.error("layoutid:"+layoutid); layoutStr = new LayoutInfoBiz().getLayoutStr(layoutid); } apidatas.put("datajson",layoutStr); @@ -168,10 +174,10 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService params.put("isSubrequest",reqpParams.get("isSubrequest")); Map requestlog =commandExecutor.execute(new LoadRequestLogDataCusCmd(request, user, params,"topdf")); apidatas.put("requestLog",requestlog); - new BaseBean().writeLog(JSONObject.toJSONString(apidatas)); + log.error(JSONObject.toJSONString(apidatas)); long end2 = System.currentTimeMillis()-start2; BaseBean baseBean = new BaseBean(); - baseBean.writeLog("loadform接口+底部签字意见+detail耗时:"+end2); + log.error("loadform接口+底部签字意见+detail耗时:"+end2); //是否开启水印 apidatas.put("isOpenWaterMark",reqpParams.get("isOpenWaterMark")); @@ -181,7 +187,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService result.putAll(html); long end = System.currentTimeMillis()-start2; - baseBean.writeLog("【pdf】 总耗时:"+end); + log.error("【pdf】 总耗时:"+end); return html; } diff --git a/com/engine/custom/archives/service/PushArchivesCornService.java b/com/engine/custom/archives/util/ArchivesUtil.java similarity index 70% rename from com/engine/custom/archives/service/PushArchivesCornService.java rename to com/engine/custom/archives/util/ArchivesUtil.java index 4615ba5..af3a7ed 100644 --- a/com/engine/custom/archives/service/PushArchivesCornService.java +++ b/com/engine/custom/archives/util/ArchivesUtil.java @@ -1,352 +1,71 @@ -package com.engine.custom.archives.service; +package com.engine.custom.archives.util; - -import com.dcfs.fts.common.error.FtpException; -import com.engine.custom.hg.util.HgUtils; -import com.icbc.api.internal.apache.http.impl.cookie.S; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.api.workflow.service.RequestAuthenticationService; +import com.api.workflow.util.ServiceUtil; +import com.engine.custom.archives.action.WorkflowToDocCus; +import com.engine.custom.archives.entity.PushArchivesBean; +import com.engine.workflow.biz.RobotNode.RobotNodeBiz; +import com.engine.workflow.biz.RobotNode.RobotNodeServiceBiz; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateExceptionHandler; import lombok.extern.slf4j.Slf4j; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Calendar; -import java.util.Date; -import java.nio.charset.StandardCharsets; -import java.io.*; -import java.util.*; - +import okhttp3.*; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.conn.RecordSet; +import weaver.crm.Maint.CustomerInfoComInfo; +import weaver.docs.docs.DocRecycleManager; import weaver.general.StringUtil; +import weaver.general.TimeUtil; import weaver.general.Util; -import com.alibaba.fastjson.JSONObject; -import weaver.file.ImageFileManager; - -import java.net.URL; - -import org.apache.commons.io.FileUtils; -import okhttp3.*; - -import java.net.URLEncoder; - -import weaver.soa.workflow.request.RequestService; -import weaver.soa.workflow.request.RequestInfo; -import com.engine.custom.archives.action.WorkflowToDocCus; -import weaver.docs.docs.DocRecycleManager; import weaver.hrm.User; -import com.api.workflow.service.RequestAuthenticationService; -import weaver.workflow.workflow.WorkflowConfigComInfo; import weaver.hrm.resource.ResourceComInfo; -import weaver.crm.Maint.CustomerInfoComInfo; -import com.alibaba.fastjson.JSON; +import weaver.soa.workflow.request.RequestInfo; +import weaver.soa.workflow.request.RequestService; import weaver.workflow.monitor.Monitor; -import com.engine.workflow.biz.RobotNode.RobotNodeServiceBiz; -import com.api.workflow.util.ServiceUtil; -import com.engine.workflow.biz.RobotNode.RobotNodeBiz; -import weaver.general.TimeUtil; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import cn.afterturn.easypoi.word.WordExportUtil; -import cn.hutool.core.util.ZipUtil; -import freemarker.template.Configuration; -import freemarker.template.TemplateExceptionHandler; -import freemarker.template.Template; -import java.nio.charset.StandardCharsets; - - -@Slf4j -public class PushArchivesCornService { - private static String filePath; - private static String Url; - private static String templatePath; // 模板文件路径 - private static final String zwdir = "正文"; - private static final String fjdir = "附件"; - private static final String cbddir = "承办单"; - private static final String zlcdir = "承办单" + File.separator + "子流程"; - private static final String lzxxdir = "流转信息"; - private static final String fjFile = "附件"; - - - public void setProp(Map param) { - filePath = Util.null2String(param.get("filePath")); - Url = Util.null2String(param.get("Url")); - templatePath = Util.null2String(param.get("templatePath")); - } - - - public void pushArchives(Map param) { - log.info("PushArchivesCorn====Begin========{}", param); - try { - - ZipUtil zipUtil = new ZipUtil(); - Date date = getDate(); - - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); - String format = dateFormat.format(date); - SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - // 获取当前时间的第一秒 - String firstSecond = yyyyMMddHHmmss.format(getFirstSecondOfDate(date)); - // 获取当前时间的最后一秒 - String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date)); - String requestid = Util.null2String(param.get("requestid")); - log.error("requestid:{}", requestid); - String context = extracted(requestid); - log.error("context:{}", context); - File file = crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); - log.error("textfile:{}", file.getAbsolutePath()); - writeToTxt(file.getPath(), file.getName(), context, true); - File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip"); - log.error("textZipFile:{}", txtzip.getAbsolutePath()); - OutputStream outputStream = new FileOutputStream(txtzip); - File writename = new File(file.getPath() + "/" + file.getName() + ".txt"); - com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName()); - log.error("writename:{}",writename.getName()); - String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName()); - updateRecord(requestid, s); - log.error("textZip:{}", s); - - // HgUtils.putFile(""); - } catch (Exception e) { - log.info("PushArchivesCorn====Exception========{}", e.getMessage()); - e.printStackTrace(); - } - - } - - private void updateRecord(String requestids, String s) { - String sql = "update uf_pushArchivesLog set esbtxtml = ? where request in ( " + requestids + " )"; - RecordSet recordSet = new RecordSet(); - recordSet.executeUpdate(sql, s); - } - - private String extracted(String requestid) throws FtpException, IOException { - Map requesData = getRequestByid(requestid); - log.info("requesData:{}", requesData); - String fj = Util.null2String(requesData.get("fj")); - String zwkbj = Util.null2String(requesData.get("zwkbj")); - //增加签字意见中的附件到附件文件夹中 - Map signFiles = getSignFiles(requestid); +import weaver.workflow.workflow.WorkflowConfigComInfo; +import java.io.*; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.*; - List docids = new ArrayList<>(); - // docids.addAll(Arrays.asList(fj.split(","))); - // docids.addAll(Arrays.asList(zwkbj.split(","))); - Map fjMap = getFileIdByDocId(fj); - Map zwkbjMap = getFileIdByDocId(zwkbj); - List zwFileName = new ArrayList<>(); - List fjFileName = new ArrayList<>(); - final int[] i = {1}; - //附件 - fjMap.forEach((docid, imageid) -> { - ImageFileManager imageFileManager = new ImageFileManager(); - imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); - InputStream inputStream = imageFileManager.getInputStream(); - //中文路径/中文文件名 - String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); - fjFileName.add(imageFileManager.getImageFileName()); - log.info("生成附件路径:{}", imageFileName); - imageFileName = codeUtf8(imageFileName); - try { - File file = saveInputStreamToFile(inputStream, imageFileName); - String jsonStr = callApi(Url, file); - log.error("永中接口返回数据:{}", jsonStr); - JSONObject result = JSONObject.parseObject(jsonStr); - String errorcode = result.getString("errorcode"); - if ("0".equals(errorcode)) { - JSONObject data = result.getJSONObject("data"); - String destFileName = data.getString("destFileName"); - String viewUrl = data.getString("viewUrl"); - downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); - } - } catch (IOException e) { - e.printStackTrace(); - } - }); - - //签字意见附件 - signFiles.forEach((docid, imageid) -> { - ImageFileManager imageFileManager = new ImageFileManager(); - imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); - InputStream inputStream = imageFileManager.getInputStream(); - //中文路径/中文文件名 - String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); - fjFileName.add(imageFileManager.getImageFileName()); - log.info("生成签字意见附件路径:{}", imageFileName); - imageFileName = codeUtf8(imageFileName); - try { - File file = saveInputStreamToFile(inputStream, imageFileName); - String jsonStr = callApi(Url, file); - log.error("永中接口返回数据:{}", jsonStr); - JSONObject result = JSONObject.parseObject(jsonStr); - String errorcode = result.getString("errorcode"); - if ("0".equals(errorcode)) { - JSONObject data = result.getJSONObject("data"); - String destFileName = data.getString("destFileName"); - String viewUrl = data.getString("viewUrl"); - downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); - } - } catch (IOException e) { - e.printStackTrace(); - } - }); - - //正文 - zwkbjMap.forEach((docid, imageid) -> { - ImageFileManager imageFileManager = new ImageFileManager(); - imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); - InputStream inputStream = imageFileManager.getInputStream(); - zwFileName.add(imageFileManager.getImageFileName()); - //中文路径/中文文件名 - String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName(); - log.info("生成正文路径:{}", imageFileName); - imageFileName = codeUtf8(imageFileName); - try { - File file = saveInputStreamToFile(inputStream, imageFileName); - String jsonStr = callApi(Url, file); - log.error("永中接口返回:{}", jsonStr); - JSONObject result = JSONObject.parseObject(jsonStr); - String errorcode = result.getString("errorcode"); - if ("0".equals(errorcode)) { - JSONObject data = result.getJSONObject("data"); - String destFileName = data.getString("destFileName"); - String viewUrl = data.getString("viewUrl"); - downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); - } - } catch (IOException e) { - e.printStackTrace(); - } - }); - //开始承办单 先获取主流程的承办单 - List requestDocid = generaRequestFormPdf(requestid); - // 1.去掉生成子流程承办单 - // List subRequestDocid = generaSubRequestFormPdf(requestid); - Map reqDocMap = getFileIdByDocId(String.join(",", requestDocid)); - // 2.去掉生成子流程承办单 - // Map subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid)); - log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap)); - //log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap)); - docids.addAll(requestDocid); - // 3.去掉生成子流程承办单 - // docids.addAll(subRequestDocid); - //附件 - reqDocMap.forEach((docid, imageid) -> { - ImageFileManager imageFileManager = new ImageFileManager(); - imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); - InputStream inputStream = imageFileManager.getInputStream(); - //中文路径/中文文件名 - String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName(); - log.info("主流程承办单路径:{}", imageFileName); - imageFileName = codeUtf8(imageFileName); - try { - File file = saveInputStreamToFile(inputStream, imageFileName); - String jsonStr = callApi(Url, file); - log.error("永中接口返回:{}", jsonStr); - JSONObject result = JSONObject.parseObject(jsonStr); - String errorcode = result.getString("errorcode"); - if ("0".equals(errorcode)) { - JSONObject data = result.getJSONObject("data"); - String destFileName = data.getString("destFileName"); - String viewUrl = data.getString("viewUrl"); - downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName() + ".pdf"); - } - i[0]++; - } catch (IOException e) { - e.printStackTrace(); - } - }); -//正文 - - i[0] = 1; - // 4.去掉生成子流程承办单 - // subReqDocMap.forEach((docid, imageid) -> { - // ImageFileManager imageFileManager = new ImageFileManager(); - // imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); - // InputStream inputStream = imageFileManager.getInputStream(); - // //中文路径/中文文件名 - // String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName()); - // imageFileName = codeUtf8(imageFileName); - // log.info("子流程承办单路径:{}", imageFileName); - // try { - // File file = saveInputStreamToFile(inputStream, imageFileName); - // String jsonStr = callApi(Url, file); - // log.error("永中接口返回:{}", jsonStr); - // JSONObject result = JSONObject.parseObject(jsonStr); - // String errorcode = result.getString("errorcode"); - // if ("0".equals(errorcode)) { - // JSONObject data = result.getJSONObject("data"); - // String destFileName = data.getString("destFileName"); - // String viewUrl = data.getString("viewUrl"); - // downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf"); - // } - // i[0]++; - // } catch (IOException e) { - // e.printStackTrace(); - // } - // }); - log.error(JSONObject.toJSONString(requestDocid)); - // log.error(JSONObject.toJSONString(subRequestDocid)); - for (String docid : docids) { - log.error("删除了" + docid); - deleteDocByid(docid); - } - //-------------------------------------------------------------------- - RequestService requestService = new RequestService(); - RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); - String logFile = getSignLog(requestid, cbddir+File.separator+lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription()); - String s = callApi(Url, new File(logFile)); - log.error(s); - JSONObject result = JSONObject.parseObject(s); - String errorcode = result.getString("errorcode"); - if ("0".equals(errorcode)) { - JSONObject data = result.getJSONObject("data"); - String destFileName = data.getString("destFileName"); - String viewUrl = data.getString("viewUrl"); - downloadFile(viewUrl, logFile + ".pdf"); - } - String zipName = filePath + File.separator + requestid + ".zip"; - ZipUtil.zip(filePath + File.separator + requestid, zipName); - log.error("zipName:{}", zipName); - String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); - log.error("ftpFilePath:{}", ftpFilePath); - String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip"); - log.error("ftpFilePathNew:{}", ftpFilePathNew); - String context = getContext(requestid, requesData, requestid + ".zip", zwFileName, fjFileName); - insertRecord(requestid, context, ftpFilePath); - log.error("context:{}", context); - return context; - } - private Map getSignFiles(String requestid) { - RecordSet recordSet = new RecordSet(); - ArrayList docids = new ArrayList<>(); - List subRequest = getSubRequestIds(requestid); - String sql = "select * from WORKFLOW_REQUESTLOG where REQUESTID in ( " + - String.join(",",subRequest) + " )" + - " and (annexdocids is not null or annexdocids <> '')"; - recordSet.executeQuery(sql); - while (recordSet.next()){ - String annexdocids = Util.null2String(recordSet.getString("annexdocids")) ; - if (annexdocids.length()>0){ - if (annexdocids.contains(",")){ - // annexdocids.split(",") - docids.addAll(Arrays.asList(annexdocids.split(","))); - }else { - docids.add(annexdocids); - } - } - } - return getFileIdByDocId(String.join(",",docids)) ; - } +public class ArchivesUtil { + public static Logger log = LoggerFactory.getLogger("Archives"); + public static final String SQL = "select * from uf_pushArchivesLog where ddsj >= ? and ddsj <= ? " + + " and type = ? and ( zt is null or zt = 1 ) "; - private void insertRecord(String requestid, String context, String ftpFilePath) { - String sql = "insert into uf_pushArchivesLog (request ,content,esbwjml) VALUES (?,?,?)"; - RecordSet recordSet = new RecordSet(); - recordSet.executeUpdate(sql, requestid, context, ftpFilePath); + /** + * 获取前一天的date + * + * @return + */ + public static Date getDate() { + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + //把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天) + calendar.add(Calendar.DATE, -1); + date = calendar.getTime(); + return date; } - // 获取指定日期的第一秒 + /** + * 获取指定日期的第一秒 + * + * @param date + * @return + */ public static Date getFirstSecondOfDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); @@ -357,7 +76,13 @@ public class PushArchivesCornService { return calendar.getTime(); } - // 获取指定日期的最后一秒 + + /** + * 获取指定日期的最后一秒 + * + * @param date + * @return + */ public static Date getLastSecondOfDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); @@ -368,617 +93,311 @@ public class PushArchivesCornService { return calendar.getTime(); } + /** - * 生成子流程承办单 + * 获取推送档案的bean * - * @param requestid 主流程id + * @param beginTime + * @param endTime + * @param type + * @return */ - private List generaSubRequestFormPdf(String requestid) { - log.error("generaSubRequestFormPdf,requestid:{}",requestid); - Map subRequest = getSubRequest(requestid); - for (String s : subRequest.keySet()) { - requestid = subRequest.get(s); - break; - } - List docids = new ArrayList<>(); - // for (String wfid : subRequest.keySet()) { - RequestService requestService = new RequestService(); - RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid) , 100); - WorkflowToDocCus workflowToDoc = new WorkflowToDocCus(); - requestInfo.setLastoperator("1"); - requestInfo.setDescription(getWfNameByid(requestInfo.getWorkflowid()) + "-" + requestInfo.getDescription()); - log.error("generaSubRequestFormPdf,requestInfo:{}",JSON.toJSONString(requestInfo)); - List subDocids = workflowToDoc.execute(requestInfo, 1); - docids.addAll(subDocids); - log.error("generaSubRequestFormPdf,requestInfo:{}",JSON.toJSONString(subDocids)); + public static List getResultList(RecordSet rs, String beginTime, String endTime, int type) { - // } - return docids; + rs.executeQuery(SQL, beginTime, endTime, type); + // Field[] fields = PushArchivesBean.class.getDeclaredFields(); + + LinkedList result = new LinkedList<>(); + while (rs.next()) { + PushArchivesBean pushArchivesBean = new PushArchivesBean(); + pushArchivesBean.setId(Util.getIntValue(rs.getString("id"))); + pushArchivesBean.setRequest(Util.getIntValue(rs.getString("request"))); + result.add(pushArchivesBean); + } + return result; } /** - * 生成主流程承办单 + * 获取流程自动发起的节点 * - * @param requestid - */ - private static List generaRequestFormPdf(String requestid) { - log.error("generaRequestFormPdf,requestid:{}",requestid); - RequestService requestService = new RequestService(); - RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); - WorkflowToDocCus workflowToDoc = new WorkflowToDocCus(); - requestInfo.setLastoperator("1"); - requestInfo.setDescription(getWfNameByid(requestInfo.getWorkflowid()) + "-" + requestInfo.getDescription()); - log.error("generaRequestFormPdf,requestInfo:{}",JSON.toJSONString(requestInfo)); - return workflowToDoc.execute(requestInfo, 0); - } - - /*** - * 封装数据 - * @param requestid + * @param mainAndSubRequestId * @return */ - public Map getRequestByid(String requestid) { - HashMap record = new HashMap<>(); - String sql = "select * from formtable_main_30 where requestid = ?"; - String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?"; - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, requestid); - if (rs.next()) { - String fj = Util.null2String(rs.getString("fj")); - String zwkbj = Util.null2String(rs.getString("zwkbj")); // 正文可编辑字段 - record.put("fj", fj); - record.put("zwkbj", zwkbj); - record.put("zwyyglgwmk", Util.null2String(rs.getString("zwyyglgwmk"))); - record.put("lwh", Util.null2String(rs.getString("lwh"))); - record.put("mj", Util.null2String(rs.getString("mj"))); - record.put("lwrq", Util.null2String(rs.getString("lwrq"))); - record.put("swrq", Util.null2String(rs.getString("swrq"))); - record.put("blqx", Util.null2String(rs.getString("blqx"))); - record.put("sfdb", Util.null2String(rs.getString("sfdb"))); - record.put("wjlx", Util.null2String(rs.getString("wjlx"))); - record.put("fssj", Util.null2String(rs.getString("fssj"))); - record.put("gdh", Util.null2String(rs.getString("gdh"))); - record.put("swh", Util.null2String(rs.getString("swh"))); - record.put("ngbm", Util.null2String(rs.getString("ngbm"))); - record.put("ngr", Util.null2String(rs.getString("ngr"))); - record.put("ngrq", Util.null2String(rs.getString("ngrq"))); - record.put("swlx", Util.null2String(rs.getString("swlx"))); - record.put("jghwt", Util.null2String(rs.getString("jghwt"))); - record.put("lwdwmc", Util.null2String(rs.getString("lwdwmc"))); - record.put("bgqx", Util.null2String(rs.getString("bgqx"))); - record.put("ys", Util.null2String(rs.getString("ys"))); - record.put("wz", Util.null2String(rs.getString("wz"))); - record.put("lb", Util.null2String(rs.getString("lb"))); - record.put("bz", Util.null2String(rs.getString("bz"))); - record.put("yffbm", Util.null2String(rs.getString("yffbm"))); - record.put("ffbmb", Util.null2String(rs.getString("ffbmb"))); - record.put("yffbm", Util.null2String(rs.getString("yffbm"))); - } - rs.executeQuery(reqsql, requestid); - if (rs.next()) { - record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME"))); + public static ArrayList getAutoInitNodeIds(String mainAndSubRequestId) { + RecordSet recordSet = new RecordSet(); + ArrayList nodeids = new ArrayList<>(); + String sql = "select node.NODEID nodeid , nodegroup.GROUPNAME from workflow_flownode node " + + " left join workflow_nodegroup nodegroup " + + " on node.nodeid = nodegroup.nodeid " + + " left join workflow_groupdetail detail " + + "on nodegroup.id = detail.GROUPID " + + "where node.WORKFLOWID in (select distinct WORKFLOWID from WORKFLOW_REQUESTBASE where REQUESTID in ( " + mainAndSubRequestId + " ) ) and detail.id is null"; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String nodeid = recordSet.getString("nodeid"); + if (!StringUtils.isEmpty(nodeid)) { + nodeids.add(nodeid); + } } - return record; + return nodeids; } - private String getContext(String requestid, Map requesData, String zipName, List zwFileName, List fjFileName) { - StringBuilder context = new StringBuilder(); - try { - - String swrq = Util.null2String(requesData.get("swrq")); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate date = LocalDate.parse(swrq, formatter); - int year = date.getYear(); - context.append(year).append("|"); - String jghwt = Util.null2String(requesData.get("jghwt")); - context.append(jghwt).append("|"); - String swh = Util.null2String(requesData.get("swh")); - context.append(swh).append("|"); - String requestname = Util.null2String(requesData.get("REQUESTNAME")); - context.append(requestname).append("|"); - String lwdwmc = Util.null2String(requesData.get("lwdwmc")); //5 责任者 -> 来文单位 - context.append(lwdwmc).append("|"); - String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限 - context.append(bgqx).append("|"); - String lwrq = Util.null2String(requesData.get("lwrq")); //7 日期 -> 原发文日期 - context.append(lwrq).append("|"); - String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数 - context.append(ys).append("|"); - String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种 - context.append(wz).append("|"); - String ngbm = Util.null2String(requesData.get("ngbm")); - String[] deptData = getDeptNameAndCode(ngbm); - context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 - context.append(deptData[1]).append("|"); //11 行名称 - context.append("").append("|"); // 12 保管期限编号 - context.append("").append("|"); // 13 保管期限及编号 - context.append("").append("|"); // 14 是否开放 - context.append("").append("|"); // 15 互见号 - String lb = Util.null2String(requesData.get("lb")); - context.append(lb).append("|"); //16 类别 -> 类别 - //TODO - String xgbm = Util.null2String(getAssociatedDepts(requesData)); - context.append(xgbm).append("|"); //17 相关部门 -> 流经部门 - String lwh = Util.null2String(requesData.get("lwh"));// 18 收文号 -> 来文文号 - context.append(lwh).append("|"); - String fs = ""; - context.append(fs).append("|"); // 19 份数 -> 份数 - String bz = Util.null2String(requesData.get("bz")); - context.append(bz).append("|"); // 20 备注 -> 备注 - String yywh = Util.null2String(requesData.get("yywh")); - context.append(yywh).append("|"); // 21 引用文号 -> 引用文号 - String wjlx = Util.null2String(requesData.get("wjlx")); - context.append(wjlx).append("|"); // 22 文件类型 -> 空 - String fwlx = Util.null2String(requesData.get("fwlx")); - context.append(fwlx).append("|"); // 23 文件类型 -> 空 - String f = Util.null2String(requesData.get("f")); - context.append(f).append("|"); // 24 发 -> 空 - String ngr = Util.null2String(requesData.get("ngr")); - context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人 - context.append(deptData[1]).append("|"); // 26 拟稿部门 -> 拟稿部门名称 - context.append("收文").append("|"); // 27 公文类型 -> "收文" - //TODO - context.append(getAssociatedPersons(requestid)).append("|"); // 28 相关人员 -> 参与人员 - context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源 - context.append(year).append("|"); // 30 形成年度 -> 年份 - context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 - context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 - context.append(requestid).append("|"); // 33 主键 - context.append("").append("|"); // 34 关联主键 - context.append("").append("|"); // 35 被关联主键 - context.append(zipName);// 36 压缩包名称 - } catch (Exception e) { - e.printStackTrace(); - log.error("getContextError:{}", e.getMessage()); - } + /** + * @param TemplatePath 模版存放目录 + * @param TemplateName 模版名 + * @param root 填充的数据 + * @param GenerateFilename 生成文件名 + * @throws Exception + */ - return context.toString(); - } + public static String generate(String TemplatePath, String TemplateName, Map root, String GenerateFilename) throws Exception { + Configuration cfg = new Configuration(); + //指定模板文件的来源目录 + cfg.setDirectoryForTemplateLoading(new File(TemplatePath)); + cfg.setDefaultEncoding("UTF-8"); + //设置错误的显示方式(日志) + //在生产系统中:TemplateExceptionHandler.RETHROW_HANDLER 默认值 + //在开发HTML模板期间:TemplateExceptionHandler.HTML_DEBUG_HANDLER + //在开发非HTML模板期间:TemplateExceptionHandler.DEBUG_HANDLER + cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); + cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); - private String getAssociatedDepts(Map requesData) { - HashSet records = new HashSet<>(); - records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); - records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbm")).split(","))); - records.addAll(Arrays.asList(Util.null2String(requesData.get("yffbm")).split(","))); - records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbmb")).split(","))); - records.addAll(Arrays.asList(Util.null2String(requesData.get("zfbm")).split(","))); - return String.join("&&", records); - } + //获取模板文件 + Template temp = cfg.getTemplate(TemplateName); + //合并模板和数据模型 + // File file = new File(TemplatePath + "new-built"); + //如果文件夹不存在,则创建文件夹 + // if (!file.exists()) { + // //file.mkdirs();//多级目录 + // file.mkdir();//只创建一级目录 + // } + //Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(TemplatePath + "new-built/" + GenerateFilename)));//输出文件 + // FileWriter out = new FileWriter(TemplatePath + "new-built/" + GenerateFilename); + //Writer out = new OutputStreamWriter(System.out);//输出控制台 + //StringWriter out = new StringWriter();//输出为字符串,可作为接口动态返回 + File file = new File(GenerateFilename); + File parentDir = file.getParentFile(); - private String getAssociatedPersons(String requestid) { - List subRequest = getSubRequestIds(requestid); - String sql = "select distinct b.LOGINID loginid from WORKFLOW_REQUESTLOG a left join HRMRESOURCE b " + - " on a.OPERATOR = b.ID " + - " where a.OPERATOR is not null and a.OPERATOR != 1 and a.REQUESTID in ( " + String.join(",", subRequest) + " )"; - RecordSet recordSet = new RecordSet(); - HashSet set = new HashSet<>(); - recordSet.executeQuery(sql); - while (recordSet.next()) { - String loginid = Util.null2String(recordSet.getString("loginid")); - if (StringUtil.isEmpty(loginid)) { - continue; - } - //处理下子账号 - if (loginid.length() > 8) { - loginid = loginid.substring(0, 8); + // 检查父目录是否存在 + if (!parentDir.exists()) { + // 父目录不存在,创建所有必需的父目录 + boolean dirsCreated = parentDir.mkdirs(); + if (dirsCreated) { + System.out.println("所有必需的父目录已创建."); + } else { + System.out.println("无法创建目录,请检查权限或路径是否正确."); } - set.add(loginid); + } else { + System.out.println("父目录已存在,无需创建."); } - return String.join("&&", set); - } - - private String[] getFileName(String docids) { - return new String[0]; - } - private String[] getDeptNameAndCode(String ngbm) { - String sql = "select DEPARTMENTNAME , DAPYBH from hrmdepartment a left join hrmdepartmentdefined b " + - " on a.ID = b.DEPTID " + - " where a.ID = ? "; - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery(sql, ngbm); - recordSet.next(); - return new String[]{recordSet.getString("DAPYBH"), recordSet.getString("DEPARTMENTNAME")}; + FileOutputStream fos = new FileOutputStream(GenerateFilename); + Writer out = new OutputStreamWriter(fos, StandardCharsets.UTF_8); + temp.process(root, out); + out.flush();//可不手动调用 + return GenerateFilename; } /** - * 将gbk转为UTF-8,创建ISO-8859-1编码的字符串, - * ISO-8859-1编码是一个字节对应一个字符,因此不会使最后一个字节错误。 + * 写入txt * - * @param text - * @return + * @param path + * @param title + * @param content + * @param append */ - public static String codeUtf8(String text) { - String ISOtext = null; - ISOtext = new String(text.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); - return new String(ISOtext.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); - - } - - /** - * 获取当前流程下的所有子流程(最大5层) - * - * @param requestid - * @return - */ - public static Map getSubRequest(String requestid) { - HashMap records = new HashMap<>(); - RecordSet rs = new RecordSet(); - String ids = requestid; - for (int i = 0; i < 5; i++) { - ArrayList idList = new ArrayList<>(); - String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; - rs.executeQuery(sql); - while (rs.next()) { - String subrequestid = Util.null2String(rs.getString("requestid")); - String workflowid = Util.null2String(rs.getString("workflowid")); - idList.add(subrequestid); - // 使用map自动去重,一种流程类型只取一个requestid - records.put(workflowid, subrequestid); - } - ids = String.join(",", idList); - } - - - // String sql = "select requestid from workflow_requestbase where mainrequestid = ?"; - // RecordSet rs = new RecordSet(); - // rs.executeQuery(sql, requestid); - // if (rs.next()) { - // String subrequestid = Util.null2String(rs.getString("requestid")); - // records.add(subrequestid); - // } - return records; - } - - public static List getSubRequestIds(String requestid) { - List reqids = new ArrayList<>(); - RecordSet rs = new RecordSet(); - String ids = requestid; - reqids.add(requestid); - for (int i = 0; i < 5; i++) { - ArrayList idList = new ArrayList<>(); - String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; - log.error("subrequestSql:{}", sql); - rs.executeQuery(sql); - while (rs.next()) { - String subrequestid = Util.null2String(rs.getString("requestid")); - // String workflowid = Util.null2String(rs.getString("workflowid")); - idList.add(subrequestid); - reqids.add(subrequestid); - // 使用map自动去重,一种流程类型只取一个requestid - + public static void writeToTxt(String path, String title, String content, Boolean append) { + try { + /* 写入Txt文件 */ + File mkdirsName = new File(path); + // 相对路径 + if (!mkdirsName.exists()) { + mkdirsName.mkdirs(); } - ids = String.join(",", idList); - if (ids.length() == 0) { - break; + File writename = new File(path + "/" + title + ".txt"); + // 存在即根据操作系统添加换行符 + if (!writename.exists() && append == true) { + // 创建新文件 + writename.createNewFile(); + } else if ("del".equals(content) && append == false) { + writename.delete(); + return; + } else if (!writename.exists() && append == false) { + writename.createNewFile(); + } else { + String osName = System.getProperties().getProperty("os.name"); + System.out.println(osName); + if ("Linux".equals(osName)) { + content = "\r" + content; + } else { + content = "\r\n" + content; + } } + // 如果是在原有基础上写入则append属性为true,默认为false + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(writename, append), StandardCharsets.UTF_8)); + // 写入TXT + out.write(content); + // 把缓存区内容压入文件 + out.flush(); + // 最后记得关闭文件 + out.close(); + } catch (Exception e) { + e.printStackTrace(); } - - - // String sql = "select requestid from workflow_requestbase where mainrequestid = ?"; - // RecordSet rs = new RecordSet(); - // rs.executeQuery(sql, requestid); - // if (rs.next()) { - // String subrequestid = Util.null2String(rs.getString("requestid")); - // records.add(subrequestid); - // } - return reqids; } /** - * 获取imageid Map + * 创建文件夹 * - * @param ids + * @param pathName * @return */ - public static Map getFileIdByDocId(String ids) { - HashMap records = new HashMap<>(); - - String sql = "select docid,df.imagefileid imgid from docimagefile df left join imagefile imf on df.imagefileid = imf.imagefileid where DOCID in (" + ids + ")"; - RecordSet recordSet = new RecordSet(); - recordSet.execute(sql); - while (recordSet.next()) { - String docid = Util.null2String(recordSet.getString("docid")); - String imgid = Util.null2String(recordSet.getString("imgid")); - records.put(docid, imgid); + public static File crFile(String pathName) { + // bean.writeLog("创建文件夹==="+pathName); + File file = new File(pathName); + try { + // bean.writeLog("创建文件夹==="+file.exists()); + if (!file.exists()) { + file.mkdir(); + } + } catch (Exception E) { + // bean.writeLog("Exception"+E.getMessage()); } - return records; + return file; } + /** - * 将InputStream写入本地文件 + * 生成流转意见 意见 * - * @param inputStream 输入流 - * @param localFilePath 本地文件路径 + * @param requestid + * @param dirName + * @param requestName * @return - * @throws IOException 如果发生输入输出异常 */ - public static File saveInputStreamToFile(InputStream inputStream, String localFilePath) throws IOException { - File targetFile = new File(localFilePath); + public static String getSignLog(int requestid, String dirName, String requestName, String TemplatePath, String filePath, boolean isSubReq) { + List subRequestIds = getSubRequestIds(requestid, isSubReq); + ArrayList> lists = new ArrayList<>(); + List autoInitNodeIds = getAutoInitNodeIds(String.join(",", subRequestIds)); + RecordSet recordSet = new RecordSet(); + String getWFNameByReqId = "select WORKFLOWNAME from WORKFLOW_REQUESTBASE req " + + " left join WORKFLOW_BASE wf on req.WORKFLOWID = wf.ID " + + " where REQUESTID = ? "; + for (String reqid : subRequestIds) { + recordSet.executeQuery(getWFNameByReqId, reqid); + String wfName = ""; + if (recordSet.next()) { + wfName = recordSet.getString("WORKFLOWNAME"); + } + HashMap params = new HashMap<>(); + params.put("requestid", reqid); + params.put("desremark", "all"); + params.put("pageSize", "999"); + params.put("isfirst", "true"); + // params.put("request", request); + Map data = ArchivesUtil.getSignLogCmd(params, new User(1)); + log.info("流转信息:{}", data); + log.error(JSONObject.toJSONString(data)); + Map datas = (Map) data.get("datas"); + List> entries = new ArrayList<>(datas.entrySet()); + entries.sort(new Comparator>() { + @Override + public int compare(Map.Entry o1, Map.Entry o2) { + Integer key1 = Util.getIntValue((Util.null2String(o1.getKey())).replace("key", "")); + Integer key2 = Util.getIntValue((Util.null2String(o2.getKey())).replace("key", "")); + return key1 - key2; + } + }); // 自然顺序 - // 确保目标文件的父目录存在 - File parentDir = targetFile.getParentFile(); - if (parentDir != null && !parentDir.exists()) { - parentDir.mkdirs(); - } + ArrayList> results = new ArrayList<>(); + // log.error(JSONObject.toJSONString(entries)); + for (Map.Entry entry : entries) { + Map value = (Map) entry.getValue(); + List> list = (List) value.get("list"); + String nodeid = Util.null2String(value.get("nodeid")); + if (autoInitNodeIds.contains(nodeid)) { + continue; + } + for (Map item : list) { + String operator = (String) item.get("operator"); + String operatorid = (String) item.get("operatorid"); + if ("6771".equals(operatorid)) { + operator = "子流程处理"; + } + String operatortype = (String) item.get("operatortype"); + String operatedate = (String) item.get("operatedate"); + String receivedate = (String) item.get("receivedate"); + String nodename = (String) value.get("nodename"); + String statuscode = (String) item.get("statuscode"); + HashMap itemMap = new HashMap<>(); + itemMap.put("operator", operator); + itemMap.put("operatorid", operatorid); + itemMap.put("operatortype", operatortype); + itemMap.put("operatedate", StringUtil.isEmpty(operatedate) ? receivedate : operatedate); + itemMap.put("nodename", nodename); + itemMap.put("nodename", nodename); + itemMap.put("requestName", (String) value.get("requestName")); + //1:未查看, 2::以查看, 3:已提交, 4:暂停, 5:撤销, 6:启用 7:已查阅 8:退回 9:被撤回 + String action = ""; + if ("1".equals(statuscode)) { + action = "未查看"; + } else if ("2".equals(statuscode)) { + action = "已查看"; + } else if ("3".equals(statuscode)) { + action = "已提交"; + } else if ("4".equals(statuscode)) { + action = "暂停"; + } else if ("5".equals(statuscode)) { + action = "撤销"; + } else if ("6".equals(statuscode)) { + action = "启用"; + } else if ("7".equals(statuscode)) { + action = "已查阅"; + } else if ("8".equals(statuscode)) { + action = "退回"; + } else if ("9".equals(statuscode)) { + action = "被撤回"; + } + itemMap.put("statuscode", "3".equals(statuscode) ? "提交" : "查看"); + itemMap.put("action", action); - // 使用try-with-resources语句确保流的正确关闭 - try (InputStream in = inputStream; - OutputStream outputStream = new FileOutputStream(targetFile)) { - int read; - byte[] bytes = new byte[1024]; - while ((read = in.read(bytes)) != -1) { - outputStream.write(bytes, 0, read); + results.add(itemMap); + } } - } // 自动关闭 in 和 outputStream - return targetFile; - } - - - /** - * 根据链接下载文件 - * - * @param fileURL - * @param saveDir - */ - public static void downloadFile(String fileURL, String saveDir) { - log.info("文件下载地址:{}", fileURL); - log.info("文件保存地址:{}", saveDir); + log.error("排序结果:{}", JSONObject.toJSONString(results)); + HashMap records = new HashMap<>(); + records.put("results", results); + String requestName1 = (String) data.get("requestName"); + records.put("requestName", "【" + wfName + "】-" + requestName1); + log.error("requestName1:{}", requestName1); + log.error("records:{}", JSONObject.toJSONString(records)); + lists.add(records); + } try { - saveDir = codeUtf8(saveDir); - URL url = new URL(fileURL); - File file = new File(saveDir); - FileUtils.copyURLToFile(url, file); - log.error("Download completed successfully."); - } catch (IOException e) { + Map dataMap = new HashMap<>(); + dataMap.put("lists", lists); // 将用户列表添加到数据映射中 + log.error("dataMap:{}", JSONObject.toJSONString(dataMap)); + // String TemplatePath = "/opt/weaver/filesys/"; + //String TemplateName = "html模版.ftl"; + String TemplateName = "temp.ftl"; + // 加载模板并填充数据 + log.error("模板路径:{}", TemplatePath); + // 导出Word文档 + String outputPath = filePath + File.separator + requestid + File.separator + dirName + File.separator + "文件流转信息" + ".docx"; // 输出文件路径 + log.error("生成文件路径:{}", TemplatePath); + + return generate(TemplatePath, TemplateName, dataMap, outputPath); + } catch (Exception e) { + log.error("errorerrorerror"); + log.error(e.getMessage()); e.printStackTrace(); - log.error("Download failed."); } - } - - - /** - * 调用永中接口 - * - * @param BASE_URL - * @param file - * @return - * @throws IOException - */ - public static String callApi(String BASE_URL, File file) { - OkHttpClient client = new OkHttpClient(); - // Debugging: Check if the file exists and can be read - if (file.exists() && file.canRead()) { - log.error("File exists and is readable. File path: " + file.getAbsolutePath()); - } else { - log.error("File does not exist or cannot be read. File path: " + file.getAbsolutePath()); - } - RequestBody requestBody = null; - String code = getCodeByFileType(file.getName()); - String fileName = null; - try { - fileName = URLEncoder.encode(file.getName(), StandardCharsets.UTF_8.toString()); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - try { - requestBody = new MultipartBody.Builder() - .setType(MultipartBody.FORM) - .addFormDataPart("convertType", code) - .addFormDataPart("file", fileName, RequestBody.create(MediaType.parse("application/zip"), file)) - .build(); - } catch (Exception e) { - log.error(e.getMessage()); - e.printStackTrace(); - } - - Request request = new Request.Builder() - .url(BASE_URL) - .post(requestBody) - .build(); - - try (Response response = client.newCall(request).execute()) { - return response.body().string(); - } catch (IOException e) { - e.printStackTrace(); - } - return ""; - } - - /** - * 根据文件类型获取转为pdf的编码 - * - * @param FileName - * @return - */ - - public static String getCodeByFileType(String FileName) { - String extName = FileName.substring(FileName.lastIndexOf(".") + 1); - String convertType = ""; - if (extName.matches("(doc|dot|dtd|docx|docm|dotx|ppt|pptx|ppsx|potx|xlsx|xlsm|wps|dps|et|wpt|xls|xlc|xlt|xlm|xlw|DOC|DOT|DTD|DOCX|DOCM|DOTX|PPT|PPTX|PPSX|POTX|XLSX|XLSM|WPS|DPS|ET|WPT|XLS|XLC|XLT|XLM|XLW)")) { - convertType = "3"; - } else if (extName.matches("(ofd|OFD)")) { - convertType = "57"; - } else if (extName.matches("(GIF|JPEG|JPG|BMP|PNG|gif|jpeg|jpg|bmp|png)")) { - convertType = "44"; - } else if (extName.matches("(PDF|pdf)")) { - convertType = "34"; - } - return convertType; - } - - - /*** - * 获取关键词 - * @param id - * @return - */ - public static String getKeyword(String id) { - String sql = "select * from uf_test where id = ?"; - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, id); - rs.next(); - return Util.null2String(rs.getString("label")); - } - - /** - * 删除文档及附件,调用移到回收站,再从回收站删除 - * - * @param docid - */ - public static void deleteDocByid(String docid) { - DocRecycleManager docRecycleManager = new DocRecycleManager(); - User user = new User(1); - docRecycleManager.moveDocToRecycle(user.getUID(), user.getLogintype(), Util.getIntValue(docid), "127.0.0.1"); - docRecycleManager.deleteDocFromRecycle(user.getUID(), user.getLogintype(), weaver.general.Util.getIntValue(docid), "127.0.0.1"); - } - - /** - * 获取流程类型名称 - * - * @param wfid - * @return - */ - - public static String getWfNameByid(String wfid) { - String sql = "select WORKFLOWNAME from WORKFLOW_BASE where id = ?"; - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, wfid); - rs.next(); - return Util.null2String(rs.getString("WORKFLOWNAME")); - } - - - /** - * 生成流转意见 意见 - * - * @param requestid - * @param dirName - * @param requestName - * @return - */ - public static String getSignLog(String requestid, String dirName, String requestName) { - List subRequestIds = getSubRequestIds(requestid); - ArrayList> lists = new ArrayList<>(); - List autoInitNodeIds = getAutoInitNodeIds(String.join(",", subRequestIds)); - RecordSet recordSet = new RecordSet(); - String getWFNameByReqId = "select WORKFLOWNAME from WORKFLOW_REQUESTBASE req " + - " left join WORKFLOW_BASE wf on req.WORKFLOWID = wf.ID " + - " where REQUESTID = ? "; - for (String reqid : subRequestIds) { - recordSet.executeQuery(getWFNameByReqId,reqid); - String wfName = ""; - if (recordSet.next()){ - wfName = recordSet.getString("WORKFLOWNAME"); - } - HashMap params = new HashMap<>(); - params.put("requestid", reqid); - params.put("desremark", "all"); - params.put("pageSize", "999"); - params.put("isfirst", "true"); - // params.put("request", request); - Map data = getSignLogCmd(params, new User(1)); - log.info("流转信息:{}", data); - log.error(JSONObject.toJSONString(data)); - Map datas = (Map) data.get("datas"); - List> entries = new ArrayList<>(datas.entrySet()); - entries.sort(new Comparator>() { - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - Integer key1 = Util.getIntValue((Util.null2String(o1.getKey())).replace("key", "")); - Integer key2 = Util.getIntValue((Util.null2String(o2.getKey())).replace("key", "")); - return key1 - key2; - } - }); // 自然顺序 - - ArrayList> results = new ArrayList<>(); - // log.error(JSONObject.toJSONString(entries)); - for (Map.Entry entry : entries) { - - Map value = (Map) entry.getValue(); - List> list = (List) value.get("list"); - String nodeid = Util.null2String(value.get("nodeid")) ; - if (autoInitNodeIds.contains(nodeid)){ - continue; - } - for (Map item : list) { - String operator = (String) item.get("operator"); - String operatorid = (String) item.get("operatorid"); - String operatortype = (String) item.get("operatortype"); - String operatedate = (String) item.get("operatedate"); - String receivedate = (String) item.get("receivedate"); - String nodename = (String) value.get("nodename"); - String statuscode = (String) item.get("statuscode"); - HashMap itemMap = new HashMap<>(); - itemMap.put("operator", operator); - itemMap.put("operatorid", operatorid); - itemMap.put("operatortype", operatortype); - itemMap.put("operatedate", StringUtil.isEmpty(operatedate) ? receivedate : operatedate); - itemMap.put("nodename", nodename); - itemMap.put("nodename", nodename); - itemMap.put("requestName", (String) value.get("requestName")); - //1:未查看, 2::以查看, 3:已提交, 4:暂停, 5:撤销, 6:启用 7:已查阅 8:退回 9:被撤回 - String action = ""; - if ("1".equals(statuscode)){ - action = "未查看"; - }else if("2".equals(statuscode)){ - action = "已查看"; - }else if("3".equals(statuscode)){ - action = "已提交"; - }else if("4".equals(statuscode)){ - action = "暂停"; - }else if("5".equals(statuscode)){ - action = "撤销"; - }else if("6".equals(statuscode)){ - action = "启用"; - }else if("7".equals(statuscode)){ - action = "已查阅"; - }else if("8".equals(statuscode)){ - action = "退回"; - }else if("9".equals(statuscode)){ - action = "被撤回"; - } - itemMap.put("statuscode", "3".equals(statuscode) ? "提交" : "查看" ); - itemMap.put("action", action ); - - results.add(itemMap); - } - } - log.error("排序结果:{}", JSONObject.toJSONString(results)); - HashMap records = new HashMap<>(); - records.put("results",results); - String requestName1 = (String) data.get("requestName"); - records.put("requestName","【"+wfName+"】-"+requestName1); - log.error("requestName1:{}", requestName1); - log.error("records:{}", JSONObject.toJSONString(records)); - lists.add(records); - } - - try { - Map dataMap = new HashMap<>(); - dataMap.put("lists", lists); // 将用户列表添加到数据映射中 - log.error("dataMap:{}", JSONObject.toJSONString(dataMap)); - String TemplatePath = "/opt/weaver/filesys/"; - //String TemplateName = "html模版.ftl"; - String TemplateName = "temp.ftl"; - // 加载模板并填充数据 - log.error("模板路径:{}", templatePath); - // 导出Word文档 - String outputPath = filePath + File.separator + requestid + File.separator + dirName + File.separator + requestName + ".docx"; // 输出文件路径 - log.error("生成文件路径:{}", templatePath); - - return generate(TemplatePath, TemplateName, dataMap, outputPath); - } catch (Exception e) { - log.error("errorerrorerror"); - log.error(e.getMessage()); - e.printStackTrace(); - } - return requestid; + return Util.null2String(requestid); } @@ -1563,7 +982,6 @@ public class PushArchivesCornService { _statusmap.put("nodetype", nodetype); - //所有节点 nodeallstatuslist.add(_statusmap); //查看状态 1:未查看, 2::以查看, 3:已提交, 4:暂停, 5:撤销, 6:启用 7:已查阅 @@ -1626,166 +1044,399 @@ public class PushArchivesCornService { return result; } - //创建文件夹 - public File crFile(String pathName) { - // bean.writeLog("创建文件夹==="+pathName); - File file = new File(pathName); - try { - // bean.writeLog("创建文件夹==="+file.exists()); - if (!file.exists()) { - file.mkdir(); + + /** + * 获取当前流程下的所有子流程(最大5层) + * + * @param requestid + * @return + */ + public static Map getSubRequest(String requestid) { + HashMap records = new HashMap<>(); + RecordSet rs = new RecordSet(); + String ids = requestid; + for (int i = 0; i < 5; i++) { + ArrayList idList = new ArrayList<>(); + String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; + rs.executeQuery(sql); + while (rs.next()) { + String subrequestid = Util.null2String(rs.getString("requestid")); + String workflowid = Util.null2String(rs.getString("workflowid")); + idList.add(subrequestid); + // 使用map自动去重,一种流程类型只取一个requestid + records.put(workflowid, subrequestid); } - } catch (Exception E) { - // bean.writeLog("Exception"+E.getMessage()); + ids = String.join(",", idList); } - return file; - } - public void writeToTxt(String path, String title, String content, Boolean append) { - try { - /* 写入Txt文件 */ - File mkdirsName = new File(path); - // 相对路径 - if (!mkdirsName.exists()) { - mkdirsName.mkdirs(); - } - File writename = new File(path + "/" + title + ".txt"); - // 存在即根据操作系统添加换行符 - if (!writename.exists() && append == true) { - // 创建新文件 - writename.createNewFile(); - } else if ("del".equals(content) && append == false) { - writename.delete(); - return; - } else if (!writename.exists() && append == false) { - writename.createNewFile(); + + // String sql = "select requestid from workflow_requestbase where mainrequestid = ?"; + // RecordSet rs = new RecordSet(); + // rs.executeQuery(sql, requestid); + // if (rs.next()) { + // String subrequestid = Util.null2String(rs.getString("requestid")); + // records.add(subrequestid); + // } + return records; + } + + public static List getSubRequestIds(int requestid, boolean isSubReq) { + List reqids = new ArrayList<>(); + String mainwfid = ""; + String subwfid = ""; + if (!isSubReq) { + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery("select * from WORKFLOW_REQUESTBASE where REQUESTID = ?", requestid); + String wfid = ""; + if (recordSet.next()) { + wfid = Util.null2String(recordSet.getString("WORKFLOWID")); + } + recordSet.executeQuery("select * from uf_ArchivesSet where mainwfid = ? ", wfid); + + if (recordSet.next()) { + mainwfid = Util.null2String(recordSet.getString("mainwfid")); + subwfid = Util.null2String(recordSet.getString("subwfid")); } else { - String osName = System.getProperties().getProperty("os.name"); - System.out.println(osName); - if ("Linux".equals(osName)) { - content = "\r" + content; - } else { - content = "\r\n" + content; - } + reqids.add(requestid + ""); + return reqids; } - // 如果是在原有基础上写入则append属性为true,默认为false - BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(writename, append), StandardCharsets.UTF_8)); - // 写入TXT - out.write(content); - // 把缓存区内容压入文件 - out.flush(); - // 最后记得关闭文件 - out.close(); - } catch (Exception e) { - e.printStackTrace(); } - } + RecordSet rs = new RecordSet(); + String ids = requestid + ""; + reqids.add(requestid + ""); + for (int i = 0; i < 5; i++) { + ArrayList idList = new ArrayList<>(); + String sql; + if (isSubReq) { + sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; + } else { + sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " ) and workflowid in ( " + subwfid + " ) "; + } + log.error("subrequestSql:{}", sql); + rs.executeQuery(sql); + while (rs.next()) { + String subrequestid = Util.null2String(rs.getString("requestid")); + // String workflowid = Util.null2String(rs.getString("workflowid")); + idList.add(subrequestid); + reqids.add(subrequestid); + // 使用map自动去重,一种流程类型只取一个requestid + } + ids = String.join(",", idList); + if (ids.length() == 0) { + break; + } + } - private Date getDate() { - Date date = new Date(); - // if (day != null) { - // try { - // date = new SimpleDateFormat("yyyyMMdd").parse(day); - // } catch (ParseException e) { - // // writeLog("时间格式错误,重新发送指定日期失败"); - // e.printStackTrace(); - // } + + // String sql = "select requestid from workflow_requestbase where mainrequestid = ?"; + // RecordSet rs = new RecordSet(); + // rs.executeQuery(sql, requestid); + // if (rs.next()) { + // String subrequestid = Util.null2String(rs.getString("requestid")); + // records.add(subrequestid); // } - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - //把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天) - calendar.add(Calendar.DATE, -1); - date = calendar.getTime(); - return date; + return reqids; } + /** - * @param TemplatePath 模版存放目录 - * @param TemplateName 模版名 - * @param root 填充的数据 - * @param GenerateFilename 生成文件名 - * @throws Exception + * 获取imageid Map + * + * @param ids + * @return */ - public static String generate(String TemplatePath, String TemplateName, Map root, String GenerateFilename) throws Exception { - Configuration cfg = new Configuration(); - //指定模板文件的来源目录 - cfg.setDirectoryForTemplateLoading(new File(TemplatePath)); - cfg.setDefaultEncoding("UTF-8"); - //设置错误的显示方式(日志) - //在生产系统中:TemplateExceptionHandler.RETHROW_HANDLER 默认值 - //在开发HTML模板期间:TemplateExceptionHandler.HTML_DEBUG_HANDLER - //在开发非HTML模板期间:TemplateExceptionHandler.DEBUG_HANDLER - cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); - cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); + public static Map getFileIdByDocId(String ids) { + HashMap records = new HashMap<>(); + String sql = "select docid,df.imagefileid imgid from docimagefile df left join imagefile imf on df.imagefileid = imf.imagefileid where DOCID in (" + ids + ")"; + RecordSet recordSet = new RecordSet(); + recordSet.execute(sql); + while (recordSet.next()) { + String docid = Util.null2String(recordSet.getString("docid")); + String imgid = Util.null2String(recordSet.getString("imgid")); + records.put(docid, imgid); + } + return records; + } - //获取模板文件 - Template temp = cfg.getTemplate(TemplateName); - //合并模板和数据模型 - // File file = new File(TemplatePath + "new-built"); - //如果文件夹不存在,则创建文件夹 - // if (!file.exists()) { - // //file.mkdirs();//多级目录 - // file.mkdir();//只创建一级目录 - // } - //Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(TemplatePath + "new-built/" + GenerateFilename)));//输出文件 - // FileWriter out = new FileWriter(TemplatePath + "new-built/" + GenerateFilename); - //Writer out = new OutputStreamWriter(System.out);//输出控制台 - //StringWriter out = new StringWriter();//输出为字符串,可作为接口动态返回 - File file = new File(GenerateFilename); - File parentDir = file.getParentFile(); + /** + * 将InputStream写入本地文件 + * + * @param inputStream 输入流 + * @param localFilePath 本地文件路径 + * @return + * @throws IOException 如果发生输入输出异常 + */ + public static File saveInputStreamToFile(InputStream inputStream, String localFilePath) throws IOException { + File targetFile = new File(localFilePath); - // 检查父目录是否存在 - if (!parentDir.exists()) { - // 父目录不存在,创建所有必需的父目录 - boolean dirsCreated = parentDir.mkdirs(); - if (dirsCreated) { - System.out.println("所有必需的父目录已创建."); - } else { - System.out.println("无法创建目录,请检查权限或路径是否正确."); + // 确保目标文件的父目录存在 + File parentDir = targetFile.getParentFile(); + if (parentDir != null && !parentDir.exists()) { + parentDir.mkdirs(); + } + + + // 使用try-with-resources语句确保流的正确关闭 + try (InputStream in = inputStream; + OutputStream outputStream = new FileOutputStream(targetFile)) { + int read; + byte[] bytes = new byte[1024]; + while ((read = in.read(bytes)) != -1) { + outputStream.write(bytes, 0, read); } + } // 自动关闭 in 和 outputStream + return targetFile; + } + + + /** + * 根据链接下载文件 + * + * @param fileURL + * @param saveDir + */ + public static void downloadFile(String fileURL, String saveDir) { + log.info("文件下载地址:{}", fileURL); + log.info("文件保存地址:{}", saveDir); + + try { + saveDir = codeUtf8(saveDir); + URL url = new URL(fileURL); + File file = new File(saveDir); + FileUtils.copyURLToFile(url, file); + log.error("Download completed successfully."); + } catch (IOException e) { + e.printStackTrace(); + log.error("Download failed."); + } + } + + + /** + * 调用永中接口 + * + * @param BASE_URL + * @param file + * @return + * @throws IOException + */ + public static String callApi(String BASE_URL, File file) { + OkHttpClient client = new OkHttpClient(); + // Debugging: Check if the file exists and can be read + if (file.exists() && file.canRead()) { + log.error("File exists and is readable. File path: " + file.getAbsolutePath()); } else { - System.out.println("父目录已存在,无需创建."); + log.error("File does not exist or cannot be read. File path: " + file.getAbsolutePath()); + } + RequestBody requestBody = null; + String code = getCodeByFileType(file.getName()); + String fileName = null; + try { + fileName = URLEncoder.encode(file.getName(), StandardCharsets.UTF_8.toString()); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + try { + requestBody = new MultipartBody.Builder() + .setType(MultipartBody.FORM) + .addFormDataPart("convertType", code) + .addFormDataPart("file", fileName, RequestBody.create(MediaType.parse("application/zip"), file)) + .build(); + } catch (Exception e) { + log.error(e.getMessage()); + e.printStackTrace(); } - FileOutputStream fos = new FileOutputStream(GenerateFilename); - Writer out = new OutputStreamWriter(fos, StandardCharsets.UTF_8); - temp.process(root, out); - out.flush();//可不手动调用 - return GenerateFilename; + Request request = new Request.Builder() + .url(BASE_URL) + .post(requestBody) + .build(); + + try (Response response = client.newCall(request).execute()) { + return response.body().string(); + } catch (IOException e) { + e.printStackTrace(); + } + return ""; } - public static void main(String[] args) { - String s = "25441,45465,545"; - System.out.println(); - String[] ss = s.split(","); - for (String s1 : ss) { - System.out.println(s1); + /** + * 根据文件类型获取转为pdf的编码 + * + * @param FileName + * @return + */ + + public static String getCodeByFileType(String FileName) { + String extName = FileName.substring(FileName.lastIndexOf(".") + 1); + String convertType = ""; + if (extName.matches("(doc|dot|dtd|docx|docm|dotx|ppt|pptx|ppsx|potx|xlsx|xlsm|wps|dps|et|wpt|xls|xlc|xlt|xlm|xlw|DOC|DOT|DTD|DOCX|DOCM|DOTX|PPT|PPTX|PPSX|POTX|XLSX|XLSM|WPS|DPS|ET|WPT|XLS|XLC|XLT|XLM|XLW)")) { + convertType = "3"; + } else if (extName.matches("(ofd|OFD)")) { + convertType = "57"; + } else if (extName.matches("(GIF|JPEG|JPG|BMP|PNG|gif|jpeg|jpg|bmp|png)")) { + convertType = "44"; + } else if (extName.matches("(PDF|pdf)")) { + convertType = "34"; } + return convertType; + } + + + /*** + * 获取关键词 + * @param id + * @return + */ + public static String getKeyword(String id) { + String sql = "select * from uf_test where id = ?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, id); + rs.next(); + return Util.null2String(rs.getString("label")); } /** - * 获取流程自动发起的节点 - * @param mainAndSubRequestId + * 删除文档及附件,调用移到回收站,再从回收站删除 + * + * @param docid + */ + public static void deleteDocByid(String docid) { + DocRecycleManager docRecycleManager = new DocRecycleManager(); + User user = new User(1); + docRecycleManager.moveDocToRecycle(user.getUID(), user.getLogintype(), Util.getIntValue(docid), "127.0.0.1"); + docRecycleManager.deleteDocFromRecycle(user.getUID(), user.getLogintype(), weaver.general.Util.getIntValue(docid), "127.0.0.1"); + } + + /** + * 获取流程类型名称 + * + * @param wfid * @return */ - private static ArrayList getAutoInitNodeIds(String mainAndSubRequestId) { + + public static String getWfNameByid(String wfid) { + String sql = "select WORKFLOWNAME from WORKFLOW_BASE where id = ?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, wfid); + rs.next(); + return Util.null2String(rs.getString("WORKFLOWNAME")); + } + + public static String[] getDeptNameAndCode(String ngbm) { + String sql = "select DEPARTMENTNAME , DAPYBH from hrmdepartment a left join hrmdepartmentdefined b " + + " on a.ID = b.DEPTID " + + " where a.ID = ? "; RecordSet recordSet = new RecordSet(); - ArrayList nodeids = new ArrayList<>(); - String sql = "select node.NODEID nodeid , nodegroup.GROUPNAME from workflow_flownode node " + - " left join workflow_nodegroup nodegroup " + - " on node.nodeid = nodegroup.nodeid " + - " left join workflow_groupdetail detail " + - "on nodegroup.id = detail.GROUPID " + - "where node.WORKFLOWID in (select distinct WORKFLOWID from WORKFLOW_REQUESTBASE where REQUESTID in ( "+ mainAndSubRequestId +" ) ) and detail.id is null"; + recordSet.executeQuery(sql, ngbm); + recordSet.next(); + return new String[]{recordSet.getString("DAPYBH"), recordSet.getString("DEPARTMENTNAME")}; + } + + /** + * 将gbk转为UTF-8,创建ISO-8859-1编码的字符串, + * ISO-8859-1编码是一个字节对应一个字符,因此不会使最后一个字节错误。 + * + * @param text + * @return + */ + public static String codeUtf8(String text) { + String ISOtext = null; + ISOtext = new String(text.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); + return new String(ISOtext.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + + } + + public static String getAssociatedPersons(int requestid, boolean isSubReq) { + List subRequest = getSubRequestIds(requestid, isSubReq); + String sql = "select distinct b.LOGINID loginid from WORKFLOW_REQUESTLOG a left join HRMRESOURCE b " + + " on a.OPERATOR = b.ID " + + " where a.OPERATOR is not null and a.OPERATOR != 1 and a.REQUESTID in ( " + String.join(",", subRequest) + " )"; + RecordSet recordSet = new RecordSet(); + HashSet set = new HashSet<>(); recordSet.executeQuery(sql); - while (recordSet.next()){ - String nodeid = recordSet.getString("nodeid"); - if (!StringUtils.isEmpty(nodeid)){ - nodeids.add(nodeid); + while (recordSet.next()) { + String loginid = Util.null2String(recordSet.getString("loginid")); + if (StringUtil.isEmpty(loginid)) { + continue; + } + //处理下子账号 + if (loginid.length() > 8) { + loginid = loginid.substring(0, 8); } + set.add(loginid); } - return nodeids; + return String.join("&&", set); + } + + + public static Map getSignFiles(int requestid, boolean isSubReq) { + RecordSet recordSet = new RecordSet(); + ArrayList docids = new ArrayList<>(); + List subRequest = ArchivesUtil.getSubRequestIds(requestid, isSubReq); + String sql = "select * from WORKFLOW_REQUESTLOG where REQUESTID in ( " + + String.join(",", subRequest) + " )" + + " and (annexdocids is not null or annexdocids <> '')"; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String annexdocids = Util.null2String(recordSet.getString("annexdocids")); + if (annexdocids.length() > 0) { + if (annexdocids.contains(",")) { + // annexdocids.split(",") + docids.addAll(Arrays.asList(annexdocids.split(","))); + } else { + docids.add(annexdocids); + } + } + } + return ArchivesUtil.getFileIdByDocId(String.join(",", docids)); + } + + /** + * 生成子流程承办单 + * + * @param requestid 主流程id + */ + public static List generaSubRequestFormPdf(String requestid) { + log.error("generaSubRequestFormPdf,requestid:{}", requestid); + Map subRequest = ArchivesUtil.getSubRequest(requestid); + for (String s : subRequest.keySet()) { + requestid = subRequest.get(s); + break; + } + List docids = new ArrayList<>(); + // for (String wfid : subRequest.keySet()) { + RequestService requestService = new RequestService(); + RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); + WorkflowToDocCus workflowToDoc = new WorkflowToDocCus(); + requestInfo.setLastoperator("1"); + requestInfo.setDescription(ArchivesUtil.getWfNameByid(requestInfo.getWorkflowid()) + "-" + requestInfo.getDescription()); + log.error("generaSubRequestFormPdf,requestInfo:{}", JSON.toJSONString(requestInfo)); + + List subDocids = workflowToDoc.execute(requestInfo, 1); + docids.addAll(subDocids); + log.error("generaSubRequestFormPdf,requestInfo:{}", JSON.toJSONString(subDocids)); + + // } + return docids; + } + + /** + * 生成主流程承办单 + * + * @param requestid 生成表单时的签字意见是否需要子流程的签字意见 + */ + public static List generaRequestFormPdf(int requestid, int reqType) { + log.error("generaRequestFormPdf,requestid:{}", requestid); + RequestService requestService = new RequestService(); + RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); + WorkflowToDocCus workflowToDoc = new WorkflowToDocCus(); + requestInfo.setLastoperator("1"); + requestInfo.setDescription(ArchivesUtil.getWfNameByid(requestInfo.getWorkflowid()) + "-" + requestInfo.getDescription()); + log.error("generaRequestFormPdf,requestInfo:{}", JSON.toJSONString(requestInfo)); + return workflowToDoc.execute(requestInfo, reqType); } + } diff --git a/com/engine/custom/archives/workflow/biz/requestForm/RequestDocPropManagerCus.java b/com/engine/custom/archives/workflow/biz/requestForm/RequestDocPropManagerCus.java index 96829d1..7751d29 100644 --- a/com/engine/custom/archives/workflow/biz/requestForm/RequestDocPropManagerCus.java +++ b/com/engine/custom/archives/workflow/biz/requestForm/RequestDocPropManagerCus.java @@ -8,6 +8,8 @@ package com.engine.custom.archives.workflow.biz.requestForm; import com.engine.workflow.biz.requestForm.WfToDocBiz; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.Util; @@ -28,8 +30,9 @@ import java.util.Map; public class RequestDocPropManagerCus extends BaseBean { - - //private RecordSet rs;//277481: [90]集成中心-解决代码质量问题修复--操作数据库的对象不能作为成员变量 + public static Logger log = LoggerFactory.getLogger("Archives"); + + //private RecordSet rs;//277481: [90]集成中心-解决代码质量问题修复--操作数据库的对象不能作为成员变量 //private RecordSet rsTwo;//277481: [90]集成中心-解决代码质量问题修复--操作数据库的对象不能作为成员变量 private char flag = Util.getSeparator(); diff --git a/com/engine/custom/archives/workflow/biz/requestForm/SaveDocDetailBizCus.java b/com/engine/custom/archives/workflow/biz/requestForm/SaveDocDetailBizCus.java index 1e1fbf1..e350802 100644 --- a/com/engine/custom/archives/workflow/biz/requestForm/SaveDocDetailBizCus.java +++ b/com/engine/custom/archives/workflow/biz/requestForm/SaveDocDetailBizCus.java @@ -5,6 +5,8 @@ import com.engine.hrm.biz.HrmClassifiedProtectionBiz; import com.engine.workflow.biz.requestForm.RequestSecLevelBiz; import com.engine.workflow.biz.requestForm.WfToDocBiz; import oracle.sql.CLOB; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.conn.ConnStatement; import weaver.conn.RecordSet; import weaver.docs.DocDetailLog; @@ -21,6 +23,7 @@ import java.util.ArrayList; import java.util.Map; public class SaveDocDetailBizCus extends BaseBean { + public static Logger log = LoggerFactory.getLogger("Archives"); private int docid; private int maincategory; private int subcategory; @@ -827,7 +830,7 @@ public class SaveDocDetailBizCus extends BaseBean { } } }catch(Exception ex) { - writeLog("添加文档信息至虚拟目录出错:" + ex); + log.error("添加文档信息至虚拟目录出错:" + ex); } //更新文档密级 @@ -848,12 +851,12 @@ public class SaveDocDetailBizCus extends BaseBean { try { DocManager.AddShareInfo(); } catch (Exception e) { - writeLog("添加文档共享信息出错:" + e); + log.error("添加文档共享信息出错:" + e); } try { new DocViewer().setDocShareByDoc("" + docid); } catch (Exception e) { - writeLog("添加文档共享信息出错:" + e); + log.error("添加文档共享信息出错:" + e); } return docid; } @@ -867,15 +870,15 @@ public class SaveDocDetailBizCus extends BaseBean { boolean success = true; String docids = docid+""; try{ - writeLog("saveDocProp:" + docid +" "+requestid); + log.error("saveDocProp:" + docid +" "+requestid); RequestDocPropManagerCus requestDocPropManager=new RequestDocPropManagerCus(wfbiz); requestDocPropManager.changeDocProp(requestManager,docids); }catch (Exception e) { success = false; - writeLog("RequestDocPropManagerCus Error:requestid="+requestid+"###docids="+docids); - writeLog(e); + log.error("RequestDocPropManagerCus Error:requestid="+requestid+"###docids="+docids); + log.error(e.getMessage()); } - writeLog("success:"+success); + log.error("success:"+success); return success; } diff --git a/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java b/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java index 43c24a4..566c497 100644 --- a/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java +++ b/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java @@ -7,6 +7,8 @@ import com.engine.custom.archives.service.impl.HtmlToPdfServiceCusImpl; import com.engine.workflow.biz.freeNode.FreeNodeBiz; import com.engine.workflow.entity.freeNode.FreeNodeEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.conn.RecordSet; import weaver.docs.share.DocShareUtil; import weaver.file.FileSecurityUtil; @@ -29,6 +31,7 @@ import java.util.Map; public class WfToDocBizCus extends BaseBean { + public static Logger log = LoggerFactory.getLogger("Archives"); //底部签字意见列表显示数量 private int pageSize =100; @@ -174,7 +177,7 @@ public class WfToDocBizCus extends BaseBean { //是否使用wk,在config表中读配置 WorkflowConfigComInfo configComInfo = new WorkflowConfigComInfo(); useWk = Util.null2String(configComInfo.getValue("htmltopdf_usewk")); - new BaseBean().writeLog("jymjym……useWk ="+useWk); + log.error("jymjym……useWk ="+useWk); //是否使用Itext7 String useItext7 = Util.null2String(configComInfo.getValue("workflowtodoc_useitext7")); params.put("useItext7", useItext7); @@ -266,7 +269,7 @@ public class WfToDocBizCus extends BaseBean { int fileid = imageFileManager.saveImageFile(); if (fileid <= 0) { - writeLog("保存离线HTML/PDF文件失败"); + log.error("保存离线HTML/PDF文件失败"); return ""; } FileSecurityUtil.deleteFile(file); @@ -440,7 +443,7 @@ public class WfToDocBizCus extends BaseBean { agentids = agentids.substring(1); agenttypes = agenttypes.substring(1); } - new BaseBean().writeLog("docShare------userids="+userids+"-------agentids="+agentids+"-----docid="+docids); + log.error("docShare------userids="+userids+"-------agentids="+agentids+"-----docid="+docids); User user = new User(docowner); //文档共享 DocShareUtil dsu = new DocShareUtil(); diff --git a/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java b/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java index 51576e8..28a1654 100644 --- a/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java +++ b/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java @@ -13,12 +13,12 @@ import com.engine.workflow.entity.core.NodeInfoEntity; import com.engine.workflow.entity.requestLog.RequestLogEntity; import com.engine.workflow.util.CollectionUtil; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.conn.ConnStatement; import weaver.conn.RecordSet; import weaver.general.Util; import weaver.hrm.User; -import weaver.workflow.logging.Logger; -import weaver.workflow.logging.LoggerFactory; import weaver.workflow.request.RequestOperationMsgManager; import weaver.workflow.request.RequestSignRelevanceWithMe; import weaver.workflow.request.WFLinkInfo; @@ -33,7 +33,7 @@ import java.util.*; */ public class RequestLogCusBiz { - private final static Logger log = LoggerFactory.getLogger(RequestLogCusBiz.class); + public static Logger log = LoggerFactory.getLogger("Archives"); /** * 获得流程流转日志总记录数 @@ -103,7 +103,7 @@ public class RequestLogCusBiz { int max = pagenumber * pageSize; String sql = getLogSql(requestid, workflowid, viewLogIds, orderby, sqlwhere ,isSubrequest); - System.out.println("requestlogsql==>"+ sql); + log.error("requestlogsql==>"+ sql); StringBuffer splitinertSql = new StringBuffer(); if ("sqlserver".equals(rs.getDBType())) { splitinertSql.append(" select * from ( select"); @@ -140,7 +140,7 @@ public class RequestLogCusBiz { mssqlTopflg = " top 100 percent "; } String thisviewLogIds = getViewLogIds(viewLogIds, requestid, workflowid); - String autoInitNodeIds = getAutoInitNodeIds(mainAndSubRequestId); + String autoInitNodeIds = getAutoInitNodeIds(workflowid); String robotNodeid = getRobotNodeid(thisviewLogIds); String selectfields = " nodeid,destnodeid,operatedate,operatetime,logtype,remark,isMobile,logid,operatortype,operator," + "agenttype,agentorbyagentid,receivedPersonids,requestLogId,annexdocids,operatorDept,signdocids," + @@ -157,7 +157,8 @@ public class RequestLogCusBiz { String sql = "select " + mssqlTopflg + selectfields + " from workflow_requestlog t1 " + " where t1.requestid in ( " + mainAndSubRequestId + ") and t1.logtype != '1' " + - " and t1.nodeid not in (" + autoInitNodeIds + " )"; + " and t1.nodeid not in (" + autoInitNodeIds + " )" + " " + + " and t1.operator != 1 and t1.OPERATOR != (select id from HRMRESOURCE where loginid = 'fenfa')"; if (sqlwhere != null && !sqlwhere.equals("")) { sql = sql + sqlwhere; } @@ -170,6 +171,7 @@ public class RequestLogCusBiz { sql += " and logid not in (select logid from workflow_requestlog where "+Util.getSubINClause(robotNodeid, "t1.nodeid", "in")+" and operator = '0' and isRobotNode='1')"; } sql = sql + " order by t1.operatedate " + orderby + ",t1.operatetime " + orderby + ",t1.logtype " + orderby + ",t1.logid " + orderby; + log.error("sqlsql:"+sql); return sql; } @@ -178,52 +180,42 @@ public class RequestLogCusBiz { * @param mainAndSubRequestId * @return */ - private static String getAutoInitNodeIds(String mainAndSubRequestId) { + // private static String getAutoInitNodeIds(String mainAndSubRequestId) { + private static String getAutoInitNodeIds(int workflowid) { RecordSet recordSet = new RecordSet(); - ArrayList nodeids = new ArrayList<>(); - String sql = "select node.NODEID nodeid , nodegroup.GROUPNAME from workflow_flownode node " + - " left join workflow_nodegroup nodegroup " + - " on node.nodeid = nodegroup.nodeid " + - " left join workflow_groupdetail detail " + - "on nodegroup.id = detail.GROUPID " + - "where node.WORKFLOWID in (select distinct WORKFLOWID from WORKFLOW_REQUESTBASE where REQUESTID in ( "+ mainAndSubRequestId +" ) ) and detail.id is null"; - recordSet.executeQuery(sql); - while (recordSet.next()){ - String nodeid = recordSet.getString("nodeid"); - if (!StringUtils.isEmpty(nodeid)){ - nodeids.add(nodeid); - } - } - return String.join(",",nodeids); + // ArrayList nodeids = new ArrayList<>(); + // String sql = "select node.NODEID nodeid , nodegroup.GROUPNAME from workflow_flownode node " + + // " left join workflow_nodegroup nodegroup " + + // " on node.nodeid = nodegroup.nodeid " + + // " left join workflow_groupdetail detail " + + // "on nodegroup.id = detail.GROUPID " + + // "where node.WORKFLOWID in (select distinct WORKFLOWID from WORKFLOW_REQUESTBASE where REQUESTID in ( "+ mainAndSubRequestId +" ) ) and detail.id is null"; + String sql = "select * from uf_ArchivesSet where mainwfid = ? "; + recordSet.executeQuery(sql,workflowid); + // while (recordSet.next()){ + // String nodeid = recordSet.getString("nodeid"); + // if (!StringUtils.isEmpty(nodeid)){ + // nodeids.add(nodeid); + // } + // } + if (recordSet.next()){ + return recordSet.getString("exclusenodeid"); + } + return "1"; } private static String getMainOrSubRequest(int requestid, boolean isSubrequest) { + log.error("isSubrequest:"+isSubrequest); if (isSubrequest){ - // RecordSet rs = new RecordSet(); - // ArrayList results = new ArrayList<>(); - // String mainSql = "select mainrequestid from workflow_requestbase where requestid = ? "; - // String mainRequestId = ""; - // rs.executeQuery(mainSql,requestid); - // if (rs.next()){ - // mainRequestId = Util.null2String(rs.getString("mainrequestid")); - // }else { - // return Util.null2String(requestid); - // } - // // results.add(requestid+""); - // String subSql = "select requestid from workflow_requestbase where mainrequestid = ? "; - // rs.executeQuery(subSql , mainRequestId); - // while (rs.next()){ - // results.add(rs.getString("requestid")); - // } List reqids = new ArrayList<>(); RecordSet rs = new RecordSet(); String ids = requestid+""; - // reqids.add(requestid); + reqids.add(requestid+""); for (int i = 0; i < 5; i++) { ArrayList idList = new ArrayList<>(); String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; - log.error("subrequestSql:{}" + sql); + log.error("subrequestSql:" + sql); rs.executeQuery(sql); while (rs.next()) { String subrequestid = Util.null2String(rs.getString("requestid")); @@ -241,17 +233,31 @@ public class RequestLogCusBiz { log.error("子流程的id:"+String.join(",", reqids)); return String.join(",", reqids); }else { + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery("select * from WORKFLOW_REQUESTBASE where REQUESTID = ?",requestid); + String wfid = ""; + if (recordSet.next()){ + wfid = Util.null2String(recordSet.getString("WORKFLOWID")); + } + recordSet.executeQuery("select * from uf_ArchivesSet where mainwfid = ? ",wfid); + String mainwfid = ""; + String subwfid = ""; + if(recordSet.next()){ + mainwfid = Util.null2String(recordSet.getString("mainwfid")); + subwfid = Util.null2String(recordSet.getString("subwfid")); + }else { + return Util.null2String(requestid); + } List reqids = new ArrayList<>(); - RecordSet rs = new RecordSet(); - String ids = requestid+""; reqids.add(requestid+""); + String ids = requestid+""; for (int i = 0; i < 5; i++) { ArrayList idList = new ArrayList<>(); - String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; - log.error("subrequestSql:{}" + sql); - rs.executeQuery(sql); - while (rs.next()) { - String subrequestid = Util.null2String(rs.getString("requestid")); + String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " ) and workflowid in ( " + subwfid + " ) "; + log.error("subrequestSql:" + sql); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String subrequestid = Util.null2String(recordSet.getString("requestid")); // String workflowid = Util.null2String(rs.getString("workflowid")); idList.add(subrequestid); reqids.add(subrequestid); diff --git a/com/engine/custom/archives/workflow/cmd/requestLog/LoadRequestLogDataCusCmd.java b/com/engine/custom/archives/workflow/cmd/requestLog/LoadRequestLogDataCusCmd.java index 272396f..4fb83cb 100644 --- a/com/engine/custom/archives/workflow/cmd/requestLog/LoadRequestLogDataCusCmd.java +++ b/com/engine/custom/archives/workflow/cmd/requestLog/LoadRequestLogDataCusCmd.java @@ -30,6 +30,8 @@ import com.engine.workflow.service.RequestSecondAuthService; import com.engine.workflow.service.impl.RequestSecondAuthServiceImpl; import com.engine.workflow.util.MenuOrderSetUtil; import com.google.common.base.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import weaver.conn.RecordSet; import weaver.crm.Maint.CustomerInfoComInfo; import weaver.dateformat.DateTransformer; @@ -62,6 +64,7 @@ import java.util.regex.Pattern; */ public class LoadRequestLogDataCusCmd extends AbstractCommonCommand> { + public static Logger log = LoggerFactory.getLogger("Archives"); /***方便使用参数***/ private int requestid; private int workflowid; @@ -164,9 +167,10 @@ public class LoadRequestLogDataCusCmd extends AbstractCommonCommand1010157060000081243025801570102311000120230905104426true500130004130157202309050600000812430todogetCountuserNum10913026任广鹏是个大刷币"; - // System.out.println(str); + // System.out.println(request); //读取服务器端数据 BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); //向服务器端发送数据 @@ -71,46 +72,25 @@ public class SocketClientUtil { // return "-1"; } - static class UpdateLogThread extends Thread { - @Override - public void run() { - try { - Thread.sleep(3000); - System.out.println("33333333"); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - } + //测试 public static void main(String[] args) throws Exception { - for (int i = 0; i < 5000; i++) { + for (int i = 0; i < 2000; i++) { new Thread(){ @Override public void run(){ SocketClientUtil socket = new SocketClientUtil("14.1.209.146", 8090); try { - socket.send("000005971010157060000065445025801570102311000120240315092648true500130004120157202403150600000654450todogetCount2userNum10110047"); + + + socket.send("000005971010157060000065445025801570102311000120240315092648true500130004120157202403150600000654450todogetCount2userNum10110047"); + } catch (Exception e) { e.printStackTrace(); } } }.start(); } - - - } - - - public static String cece(){ - System.out.println("1111"); - UpdateLogThread updateLogThread = new UpdateLogThread(); - updateLogThread.start(); - return "222"; - } - - } diff --git a/com/engine/web/tjbk/TjbkServerSocket.java b/com/engine/web/tjbk/TjbkServerSocket.java index b585cde..fddabc3 100644 --- a/com/engine/web/tjbk/TjbkServerSocket.java +++ b/com/engine/web/tjbk/TjbkServerSocket.java @@ -18,6 +18,8 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TjbkServerSocket implements ServletContextListener { private SocketThread socketThread; @@ -34,7 +36,7 @@ public class TjbkServerSocket implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent arg0) { // TODO Auto-generated method stub - new BaseBean().writeLog("contextInitialized启动"); + // new BaseBean().writeLog("contextInitialized启动"); ServletContext servletContext = arg0.getServletContext(); if (socketThread == null) { socketThread = new SocketThread(null, servletContext); @@ -50,6 +52,7 @@ class SocketThread extends Thread { private ServletContext servletContext; private ServerSocket serverSocket; private ExecutorService executorService; // 线程池 + public static Logger logger = LoggerFactory.getLogger("ESBSocket"); public SocketThread(ServerSocket serverSocket, ServletContext servletContext) { this.servletContext = servletContext; @@ -72,9 +75,10 @@ class SocketThread extends Thread { while (!this.isInterrupted()) { // 线程未中断执行循环 try { - new BaseBean().writeLog("SocketThread线程启动"); + Socket socket = serverSocket.accept(); if (socket != null) { + logger.error("SocketThread线程启动"); // new ProcessSocketData(socket, this.servletContext).start(); executorService.submit(new ProcessSocketData(socket, servletContext)); } @@ -100,6 +104,7 @@ class ProcessSocketData implements Runnable { private Socket socket; private ServletContext servletContext; + private Logger logger = LoggerFactory.getLogger("ESBSocket"); public ProcessSocketData() { super(); @@ -108,69 +113,166 @@ class ProcessSocketData implements Runnable { public ProcessSocketData(Socket socket, ServletContext servletContext) { this.socket = socket; this.servletContext = servletContext; + } @Override public void run() { + PrintWriter pw = null; + BufferedReader in = null; + Socket localSocket = this.socket; + try { // BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); - new BaseBean().writeLog("ServerSocket线程启动"+Thread.currentThread().getName()); + logger.error("ServerSocket线程启动"+Thread.currentThread().getName()); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8); - PrintWriter pw = new PrintWriter(outputStreamWriter); + // PrintWriter pw = new PrintWriter(outputStreamWriter); + pw = new PrintWriter(outputStreamWriter); InputStream inputStream = socket.getInputStream(); - BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + // BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + in = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); char[] datalen=new char[8];//报文前八位为报文体总长度 in.read(datalen,0,8); String lendata=new String (datalen); + String clientIPAddress = localSocket.getInetAddress().getHostAddress(); // 获取客户端IP地址 + logger.error("Client connected from IP: " + clientIPAddress); + logger.error("request.length:"+lendata); int length=Integer.parseInt(lendata); - new BaseBean().writeLog("报文长度"+length); + logger.error("报文长度"+length); // byte[] data=new byte[length]; char[] data=new char[length]; int datalength = in.read(data,0,length); String requestData = new String(data); - new BaseBean().writeLog("requestData",requestData); + logger.error("requestData",requestData); String s = ""; if (!StringUtil.isEmpty(requestData.toString())) { - new BaseBean().writeLog("requestData",requestData); - s = execute(requestData.toString()); + logger.error("requestData",requestData); + s = execute(requestData.toString()); } // 执行自定义的请求解析方法,生成响应response pw.println(s); pw.flush(); // 刷新缓冲区 - pw.close(); - socket.close(); + // pw.close(); + // socket.close(); // System.out.println(sb); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); - System.out.println(e); + logger.error("error:"+e.getMessage()); + }finally { + if (pw != null) { + pw.close(); + } + if (in != null) { + try { + in.close(); + } catch (IOException e) { + e.printStackTrace(); + logger.error("error:"+e.getMessage()); + } + } + if (localSocket != null) { + try { + localSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + logger.error("error:"+e.getMessage()); + } + } } } private String execute(String XMLparam){ - new BaseBean().writeLog(this.getClass().getName()+":XMLparam=="+XMLparam); - - Map paramMap = XMLUtils.parseXMLToMap(XMLparam); - new BaseBean().writeLog(this.getClass().getName()+":paramMap=="+paramMap); - StringEscapeUtils.unescapeXml(XMLparam); - //目标系统代码 - String system_id = paramMap.get("system_id"); - // 请求方系统代码 - String requester_id = paramMap.get("requester_id"); - // 请求方机构代号 - String branch_id = paramMap.get("branch_id"); - new BaseBean().writeLog(this.getClass().getName()+":requester_id=="+requester_id); - SocketExecute socketExecute = null; - if ("0157".equals(requester_id)){ - socketExecute = new GetToCountSocketExecute(); - new BaseBean().writeLog(this.getClass().getName()+":GetToCountSocketExecute"); - }else if("0170".equals(requester_id)){ - socketExecute = new CWGLSocketExecute(); - new BaseBean().writeLog(this.getClass().getName()+":CWGLSocketExecute"); + + try { + logger.error("XMLparam=="+XMLparam); + Map paramMap = XMLUtils.parseXMLToMap(XMLparam); + logger.error("paramMap=="+paramMap); + StringEscapeUtils.unescapeXml(XMLparam); + //目标系统代码 + String system_id = paramMap.get("system_id"); + // 请求方系统代码 + String requester_id = paramMap.get("requester_id"); + // 请求方机构代号 + String branch_id = paramMap.get("branch_id"); + logger.error("requester_id=="+requester_id); + SocketExecute socketExecute = null; + if ("0157".equals(requester_id)){ + logger.error("GetToCountSocketExecute-Start"); + socketExecute = new GetToCountSocketExecute(); + logger.error("GetToCountSocketExecute-end"); + }else if("0170".equals(requester_id)){ + logger.error("GetToCountSocketExecute-Start"); + socketExecute = new CWGLSocketExecute(); + logger.error("CWGLSocketExecute-end"); + } + String execute = socketExecute.execute(paramMap); + logger.error("socketExecute:return"+execute); + return execute; + }catch (Exception e) { + e.printStackTrace(); + logger.error("error:"+e.getMessage()); + return ""; } - String execute = socketExecute.execute(paramMap); - return execute; + } + + + + // public void run() { + // try { + // (new BaseBean()).writeLog("ServerSocket线程启动"); + // OutputStreamWriter outputStreamWriter = new OutputStreamWriter(this.socket.getOutputStream(), StandardCharsets.UTF_8); + // PrintWriter pw = new PrintWriter(outputStreamWriter); + // InputStream inputStream = this.socket.getInputStream(); + // BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); + // char[] datalen = new char[8]; + // in.read(datalen, 0, 8); + // String lendata = new String(datalen); + // int length = Integer.parseInt(lendata); + // (new BaseBean()).writeLog("报文长度" + length); + // char[] data = new char[length]; + // in.read(data, 0, length); + // String requestData = new String(data); + // (new BaseBean()).writeLog("requestData", requestData); + // String s = ""; + // if (!StringUtil.isEmpty(requestData.toString())) { + // (new BaseBean()).writeLog("requestData", requestData); + // s = this.execute(requestData.toString()); + // } + // + // pw.println(s); + // pw.flush(); + // pw.close(); + // this.socket.close(); + // } catch (IOException var12) { + // var12.printStackTrace(); + // System.out.println(var12); + // } + // + // } + // + // private String execute(String XMLparam) { + // (new BaseBean()).writeLog(this.getClass().getName() + ":XMLparam==" + XMLparam); + // Map paramMap = XMLUtils.parseXMLToMap(XMLparam); + // (new BaseBean()).writeLog(this.getClass().getName() + ":paramMap==" + paramMap); + // StringEscapeUtils.unescapeXml(XMLparam); + // String system_id = (String)paramMap.get("system_id"); + // String requester_id = (String)paramMap.get("requester_id"); + // String branch_id = (String)paramMap.get("branch_id"); + // (new BaseBean()).writeLog(this.getClass().getName() + ":requester_id==" + requester_id); + // SocketExecute socketExecute = null; + // if ("0157".equals(requester_id)) { + // socketExecute = new GetToCountSocketExecute(); + // (new BaseBean()).writeLog(this.getClass().getName() + ":GetToCountSocketExecute"); + // } else if ("0170".equals(requester_id)) { + // socketExecute = new CWGLSocketExecute(); + // (new BaseBean()).writeLog(this.getClass().getName() + ":CWGLSocketExecute"); + // } + // + // String execute = ((SocketExecute)socketExecute).execute(XMLparam); + // return execute; + // } } diff --git a/com/engine/workflow/cmd/mobileCenter/GetListResultCmd.java b/com/engine/workflow/cmd/mobileCenter/GetListResultCmd.java index 1e11526..8c800b4 100644 --- a/com/engine/workflow/cmd/mobileCenter/GetListResultCmd.java +++ b/com/engine/workflow/cmd/mobileCenter/GetListResultCmd.java @@ -25,6 +25,7 @@ import weaver.conn.RecordSet; import weaver.crm.Maint.CustomerInfoComInfo; import weaver.fullsearch.util.SearchBrowserUtils; import weaver.general.BaseBean; +import weaver.general.StringUtil; import weaver.general.Util; import weaver.hrm.User; import weaver.hrm.resource.ResourceComInfo; @@ -32,6 +33,8 @@ import weaver.system.RequestDefaultComInfo; import weaver.systeminfo.SystemEnv; import weaver.workflow.request.todo.OfsSettingObject; import weaver.workflow.request.todo.RequestUtil; +import weaver.workflow.workflow.WorkflowBillComInfo; +import weaver.workflow.workflow.WorkflowComInfo; import weaver.workflow.workflow.WorkflowConfigComInfo; import javax.servlet.http.HttpServletRequest; @@ -303,12 +306,15 @@ public class GetListResultCmd extends AbstractCommonCommand>{ orderby = OrderByListUtil.appendRequestIdOrderBy(orderby); String firstFloor = bean.getFirstFloor();//建模表类型对应的数据id,根据这个id来获取这类流程需要额外展示的字段列 + String wfid = reqparams.get("workflowid"); String orderrule = "";//0--升序 1--降序 String sysorder = "";//排序系统字段 0-紧急程度 1-创建日期 2-接收日期 3-操作时间 4-流程编号 String order_qc = ""; String order_by = ""; + String orderfieldname = ""; + List orderfieldnameList = new ArrayList<>(); if (!"".equals(firstFloor)) { - RecordSet.executeQuery("select orderrule,sysorder from uf_treelistsetting where id = ?", Util.getIntValue(firstFloor)); + RecordSet.executeQuery("select orderrule,sysorder,orderfieldname from uf_treelistsetting where id = ?", Util.getIntValue(firstFloor)); if (RecordSet.next()){ orderrule = RecordSet.getString("orderrule"); if ("0".equals(orderrule)){ @@ -318,6 +324,13 @@ public class GetListResultCmd extends AbstractCommonCommand>{ order_by = "desc"; } sysorder = RecordSet.getString("sysorder"); + if (wfid.contains("S")){ + String[] split = wfid.split("_"); + if (split.length>1){ + wfid = split[1].substring(1); + orderfieldname = RecordSet.getString("orderfieldname"); + } + } } } if (!"".equals(firstFloor) && !"".equals(sysorder)) { @@ -345,6 +358,28 @@ public class GetListResultCmd extends AbstractCommonCommand>{ } } + WorkflowBillComInfo wcInfo = new WorkflowBillComInfo(); + WorkflowComInfo wf = new WorkflowComInfo(); + if (!StringUtil.isEmpty(wfid)&&!StringUtil.isEmpty(orderfieldname)){ + String formId = wf.getFormId(wfid); + String tablename = wcInfo.getTablename(formId); + String[] split = orderfieldname.split(","); + String orderfieldnamesqlsql = ""; + String order_cus = ""; + if (StringUtil.isEmpty(order_by)){ + order_by = "desc"; + } + for (String s : split) { + orderfieldnamesqlsql = orderfieldnamesqlsql + ", (select " + s + " from "+tablename +" where requestid = t1.requestid ) as "+ s; + order_cus = orderfieldname +" "+ order_by+"," + order_cus ; + } + // if (order_qc.startsWith(",")){ + // order_qc = order_qc.substring(1); + // } + backfields0 = backfields0 + orderfieldnamesqlsql; + orderby = order_cus + orderby; + tableBean.setBackfields(backfields0); + } tableBean.setSqlorderby(orderby); diff --git a/com/engine/workflow/cmd/requestList/GetListResultCmd.java b/com/engine/workflow/cmd/requestList/GetListResultCmd.java new file mode 100644 index 0000000..b657843 --- /dev/null +++ b/com/engine/workflow/cmd/requestList/GetListResultCmd.java @@ -0,0 +1,1135 @@ +package com.engine.workflow.cmd.requestList; + +import com.api.workflow.service.RequestAuthenticationService; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.core.interceptor.CommandContext; +import com.engine.encrypt.biz.WfEncryptBiz; +import com.engine.hrm.biz.HrmClassifiedProtectionBiz; +import com.engine.workflow.biz.RequestQuickSearchBiz; +import com.engine.workflow.biz.WorkflowCenterBiz; +import com.engine.workflow.biz.freeNode.FreeNodeBiz; +import com.engine.workflow.biz.requestList.GenerateDataInfoBiz; +import com.engine.workflow.biz.requestList.OfsRequestListBiz; +import com.engine.workflow.biz.requestList.RequestAttentionBiz; +import com.engine.workflow.biz.requestList.RequestListBiz; +import com.engine.workflow.constant.PageUidConst; +import com.engine.workflow.constant.SecondAuthType; +import com.engine.workflow.entity.RequestListDataInfoEntity; +import com.engine.workflow.entity.requestList.ListInfoEntity; +import com.engine.workflow.service.RequestSecondAuthService; +import com.engine.workflow.service.impl.RequestSecondAuthServiceImpl; +import com.engine.workflow.util.OrderByListUtil; +import weaver.conn.RecordSet; +import weaver.fullsearch.util.SearchBrowserUtils; +import weaver.general.PageIdConst; +import weaver.general.StringUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.request.WFForwardManager; +import weaver.workflow.request.todo.OfsSettingObject; +import weaver.workflow.request.todo.RequestUtil; +import weaver.workflow.workflow.WorkflowConfigComInfo; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +/** + * PC端-流程待办/已办/我的请求分页列表数据 + * @author liuzy 2018-08-10 + */ +public class GetListResultCmd extends AbstractCommonCommand>{ + + private HttpServletRequest request; + + /** + * 列表上一些可以个性化的信息, 供个性化使用(后续可继续完善) + */ + private ListInfoEntity listInfoEntity; + + public GetListResultCmd(HttpServletRequest request, User user){ + this.request = request; + this.user = user; + this.listInfoEntity = new ListInfoEntity(); + this.params = ParamUtil.request2Map(request); + } + + public GetListResultCmd(){ + + } + + public Map execute(CommandContext commandContext) { + Map result = new HashMap(); + try { + RequestListDataInfoEntity bean = new GenerateDataInfoBiz().generateEntity(request, user); + result = this.getResult(bean); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + private Map getResult(RequestListDataInfoEntity bean) throws Exception { + Map apidatas = new HashMap(); + RecordSet RecordSet = new RecordSet(); + RequestUtil requestutil = new RequestUtil(); + OfsSettingObject ofso = requestutil.getOfsSetting(); + boolean isopenos = ofso.getIsuse() == 1 && new OfsRequestListBiz().supportOfs4OtherCall(user);// 是否开启异构系统待办 + boolean showdone = "1".equals(ofso.getShowdone());//异构系统是否显示已办数据 + int userid = user.getUID(); + // 处理查看人员卡片 start + int resourceid = Util.getIntValue(Util.null2String(params.get("resourceid")), -1); + boolean isNeedHideBtn = resourceid != -1 && resourceid != userid; // 查看别人卡片需要隐藏checkbox,操作按钮等 + + WorkflowConfigComInfo wfconfig = new WorkflowConfigComInfo(); + int usequicksearch = Util.getIntValue(wfconfig.getValue("use_quicksearch_wflist"));//流程入口,是否使用微搜 + String usequicksearchUser = Util.null2String(wfconfig.getValue("use_quicksearch_user"));//流程入口,使用微搜人员id + String scope = Util.null2String(params.get("viewScope")); + if(!"true".equals(Util.null2String(params.get("doNotUseQuickSearch"))) && ((usequicksearch == 1 && "mine".equals(scope)) || (usequicksearch == 2 && (("," + usequicksearchUser + ",").contains("," + user.getUID() + ",") || "mine".equals(scope)))) && this.supportQuickSerach(isopenos,scope)){//满足微搜条件调用微搜,等于1只支持我的请求走微搜,等于2则待办已办也支持 + params.put("forWfreqlist",usequicksearch == 2 && ("," + usequicksearchUser + ",").contains("," + user.getUID() + ",") ? -1 : 0); + return new RequestQuickSearchBiz().getRequestList4WfList(params, user,false); + } + //流程名称反射方法(兼容E8) + String workflownamereflectmethod = "weaver.workflow.workflow.WorkflowComInfo.getWorkflowname"; + if(isopenos) + workflownamereflectmethod = "weaver.general.WorkFlowTransMethod.getWorkflowname"; + String requestnamereflectclass = "com.api.workflow.util.WorkFlowSPATransMethod"; + Map reqparams = bean.getReqparams(); + boolean showBatchSubmit = (!isNeedHideBtn && bean.isShowBatchSubmit()); + boolean isMergeShow = bean.isMergeShow(); + String CurrentUser = bean.getCurrentUser(); + String userIDAll = bean.getUserIDAll(); + String orderby = bean.getOrderclause(); + String orderbyos = bean.getOrderclause_os(); + String sqlwhere = bean.getWhereclause(); + String sqlwhereos = bean.getWhereclause_os(); + String sqlwhereosDone = bean.getWhereclause_osDone();//集成分表--统一已办表 + + String firstFloor = bean.getFirstFloor();//建模表类型对应的数据id,根据这个id来获取这类流程需要额外展示的字段列 + String extrafieldname = ""; + String orderfieldname = ""; + String orderrule = "";//0--升序 1--降序 + String sysorder = "";//排序系统字段 0-紧急程度 1-创建日期 2-接收日期 3-操作时间 4-流程编号 + String order_qc = ""; + String order_by = ""; + ArrayList fieldNameList = new ArrayList<>(); + ArrayList fieldLableList = new ArrayList<>(); + if (!"".equals(firstFloor)) { + RecordSet.executeQuery("select extrafieldname,orderfieldname,orderrule,sysorder from uf_treelistsetting where id = ?", Util.getIntValue(firstFloor)); + if (RecordSet.next()){ + extrafieldname = RecordSet.getString("extrafieldname"); + orderfieldname = RecordSet.getString("orderfieldname"); + orderrule = RecordSet.getString("orderrule"); + if ("0".equals(orderrule)){ + order_by = "asc"; + } + if ("1".equals(orderrule)){ + order_by = "desc"; + } + sysorder = RecordSet.getString("sysorder"); + } + } + + int usertype = "2".equals(user.getLogintype()) ? 1 : 0; + int sysId = Util.getIntValue(reqparams.get("sysId"), 0); + boolean isDoing = "doing".equals(scope); + reqparams.put("isMergeShow",isMergeShow && !userIDAll.equals(String.valueOf(user.getUID()))?"1":"0");//设置开启并且有次账号 + boolean isQueryByNewTable = RequestListBiz.isQueryByNewTable(user,reqparams); + apidatas.put("isQueryByNewTable",isQueryByNewTable); + + // 处理已办排序 start + String operateDateTimeFieldSql0 = ""; + String operateDateTimeFieldSql = ""; + String operateDateTimeFieldSqlOs = ""; + String tableOrderStr = isopenos ? orderbyos : orderby; + if (tableOrderStr.toLowerCase().indexOf("operatedate") != -1) { + operateDateTimeFieldSql0 = ",operatedate"; + operateDateTimeFieldSql = ", (case WHEN t2.operatedate IS NULL THEN t2.receivedate ELSE t2.operatedate END) operatedate "; + operateDateTimeFieldSqlOs = ", (case WHEN operatedate IS NULL THEN receivedate ELSE operatedate END) operatedate "; + } + + if (tableOrderStr.toLowerCase().indexOf("operatetime") != -1) { + operateDateTimeFieldSql0 += ",operatetime"; + operateDateTimeFieldSql += ", (case WHEN t2.operatetime IS NULL THEN t2.receivetime ELSE t2.operatetime END) operatetime "; + operateDateTimeFieldSqlOs += ", (case WHEN operatetime IS NULL THEN receivetime ELSE operatetime END) operatetime "; + } + // 处理已办排序 end + // 最外层查询字段 + String backfields0 = " requestid,requestmark,createdate, createtime,creater, creatertype, workflowid, requestname, requestnamenew, " + + "status,requestlevel,currentnodeid,viewtype,userid,receivedate,receivetime,isremark,nodeid,agentorbyagentid,agenttype,isprocessed " + + operateDateTimeFieldSql0 + ",systype,workflowtype,isbereject,takisremark,requestnamehtmlnew"; + // 原始查询字段 + String backfields = " t1.requestid,t1.requestmark,t1.createdate, t1.createtime,t1.creater, t1.creatertype, t1.workflowid, t1.requestname, t1.requestnamenew," + + " t1.status,t1.requestlevel,t1.currentnodeid,t2.viewtype,t2.userid,t2.receivedate,t2.receivetime,t2.isremark,t2.nodeid,t2.agentorbyagentid,t2.agenttype,t2.isprocessed " + + operateDateTimeFieldSql + " ,t1.seclevel,'0' as systype,t2.workflowtype,t2.isbereject,t2.takisremark,t1.requestnamehtmlnew"; + // 异构系统查询字段 + String backfieldsOs = " requestid,'' as requestmark,createdate, createtime,creatorid as creater, 0 as creatertype, workflowid, requestname, requestname as requestnamenew, " + + "'' as status,requestlevel,-1 as currentnodeid,viewtype,userid,receivedate,receivetime,isremark,0 as nodeid, -1 as agentorbyagentid,'0' as agenttype,'0' as isprocessed " + + operateDateTimeFieldSqlOs + " ,'"+new HrmClassifiedProtectionBiz().getDefaultResourceSecLevel()+"' as secLevel,'1' as systype, sysid as workflowtype,'' as isbereject,0 as takisremark,'' as requestnamehtmlnew"; + //反馈黄点提示字段 + backfields0 += ",viewDate,viewTime,lastFeedBackDate,lastFeedBackTime,needwfback,lastFeedBackOperator"; + backfields += ",t2.viewDate,t2.viewTime,t1.lastFeedBackDate,t1.lastFeedBackTime,t2.needwfback,t1.lastFeedBackOperator"; + backfieldsOs += ",'' as viewDate,'' as viewTime,'' as lastFeedBackDate,'' as lastFeedBackTime,'' as needwfback,0 as lastFeedBackOperator"; + ArrayList orderField = new ArrayList<>(); + String workflowid = (String)params.get("workflowid"); + String billName = ""; + if (!StringUtil.isEmpty(workflowid)&&workflowid.contains("F")&&workflowid.contains("S")){ + String[] wfarr = workflowid.split("_"); + if (wfarr.length > 1){ + RecordSet.executeQuery("select bill.TABLENAME from WORKFLOW_BASE wf left join WORKFLOW_BILL bill\n" + + "on wf.FORMID = bill.ID where wf.id = ?",wfarr[1].substring(1)); + if (RecordSet.next()){ + billName = Util.null2String(RecordSet.getString(1)); + } + } + } + + if (!"".equals(extrafieldname)){ + String[] addFieldArr = extrafieldname.split(","); + String backfields0_temp = ""; + String backfields_temp = ""; + String backfieldsOs_temp = ""; + for(String addField : addFieldArr){ + if (StringUtil.isEmpty(billName)){ + backfields0_temp += "requestid as "+addField + ","; + backfields_temp += " t1.requestid as "+addField + ","; + backfieldsOs_temp += " '' as "+addField + ","; + }else { + backfields0_temp += "(select "+addField +" from "+billName+" where requestid = t1.requestid) as "+addField + ","; + // backfields_temp += "(select "+addField +" from "+billName+" where requestid = t1.requestid ) as "+addField + ","; + // backfieldsOs_temp += " '' as "+addField + ","; + backfields_temp += " t1.requestid as "+addField + ","; + backfieldsOs_temp += " '' as "+addField + ","; + } + + fieldNameList.add(addField); + RecordSet.executeQuery("select fieldlabel from workflow_billfield where fieldname = ?",addField); + if (RecordSet.next()){ + fieldLableList.add(RecordSet.getInt(1)); + } + } + if (backfields0_temp.endsWith(",")) backfields0_temp = backfields0_temp.substring(0,backfields0_temp.length()-1); + if (backfields_temp.endsWith(",")) backfields_temp = backfields_temp.substring(0,backfields_temp.length()-1); + if (backfieldsOs_temp.endsWith(",")) backfieldsOs_temp = backfieldsOs_temp.substring(0,backfieldsOs_temp.length()-1); + backfields0 += ","+backfields0_temp; + backfields += ","+backfields_temp; + backfieldsOs += ","+backfieldsOs_temp; + } + + if (!StringUtil.isEmpty(orderfieldname)){ + String[] orderFieldArr = orderfieldname.split(","); + String backfields0_temp = ""; + String backfields_temp = ""; + String backfieldsOs_temp = ""; + for (String orderFieldStr : orderFieldArr) { + if(!fieldNameList.contains(orderFieldStr)){ + if (StringUtil.isEmpty(billName)){ + backfields0_temp += "requestid as "+orderFieldStr + ","; + backfields_temp += " t1.requestid as "+orderFieldStr + ","; + backfieldsOs_temp += " '' as "+orderFieldStr + ","; + }else { + backfields0_temp += "(select "+orderFieldStr +" from "+billName+" where requestid = t1.requestid) as "+orderFieldStr + ","; + // backfields_temp += "(select "+addField +" from "+billName+" where requestid = t1.requestid ) as "+addField + ","; + // backfieldsOs_temp += " '' as "+addField + ","; + backfields_temp += " t1.requestid as "+orderFieldStr + ","; + backfieldsOs_temp += " '' as "+orderFieldStr + ","; + } + } + } + if (backfields0_temp.endsWith(",")) backfields0_temp = backfields0_temp.substring(0,backfields0_temp.length()-1); + if (backfields_temp.endsWith(",")) backfields_temp = backfields_temp.substring(0,backfields_temp.length()-1); + if (backfieldsOs_temp.endsWith(",")) backfieldsOs_temp = backfieldsOs_temp.substring(0,backfieldsOs_temp.length()-1); + if (!StringUtil.isEmpty(backfields0_temp)){backfields0 += ","+backfields0_temp;} + if (!StringUtil.isEmpty(backfields_temp)){backfields += ","+backfields_temp;} + if (!StringUtil.isEmpty(backfieldsOs_temp)){backfieldsOs += ","+backfieldsOs_temp;} + + } + + //反馈黄点提示字段 + String fromSql = " from workflow_requestbase t1,workflow_currentoperator t2,workflow_base t3 "; + if("done".equals(scope)){ + backfields0 += ",operatedateNew,operatetimeNew"; + backfields += ",t2.operatedate as operatedateNew,t2.operatetime as operatetimeNew"; + backfieldsOs += ",operatedate as operatedateNew,operatetime as operatetimeNew"; + } + + String para2 = "column:requestid+column:workflowid+column:viewtype+0+" + user.getLanguage() + + "+column:nodeid+column:isremark+" + user.getUID() + + "+column:agentorbyagentid+column:agenttype+column:isprocessed+column:userid+0+column:creater+scope_"+scope+"_scope"; + String para4 = user.getLanguage() + "+" + user.getUID() + "+column:userid"; + + para2 = "S+column:viewDate+column:viewTime+column:lastFeedBackDate+column:lastFeedBackTime+column:needwfback+column:lastFeedBackOperator+column:userid+S+" + para2; + String reqNameParams = "S+column:viewDate+column:viewTime+column:lastFeedBackDate+column:lastFeedBackTime+column:needwfback+column:lastFeedBackOperator+column:userid+S"//反馈参数不动 + + "+column:requestid+column:workflowid+column:viewtype+" + user.getLanguage() + + "+column:nodeid+column:isremark+" + user.getUID() + + "+column:agentorbyagentid+column:agenttype+column:isprocessed+column:userid+column:creater+scope_"+scope+"_scope+column:isbereject+column:takisremark+column:requestnamehtmlnew";//流程标题解析新方法新参数 + String reqNameTransMethod = "com.api.workflow.util.WorkFlowSPATransMethod.commonReqNameTransMethod_AttentionTag"; + + //处理紧急程度自定义排序问题 + String requestleve_str = "requestlevelorder";//统一使用这个紧急程度顺序排序,以前是紧急程度排序 + OrderByListUtil obu = new OrderByListUtil(this.user); + String myorderby = "",colname="",isordertype=""; + if(isDoing) { + myorderby = obu.getMyOrderByStr(this.user.getUID(), PageUidConst.WF_LIST_DOING); + if("".equals(myorderby)) {//如果为空 + myorderby += " receivedate desc, receivetime desc"; + } + } + if("wfcenter_todo".equals(params.get("source"))){//流程中心more页面不走默认排序设置 + myorderby = Util.null2String(WorkflowCenterBiz.getWfCenterSetting(userid+"",usertype+"","doing","").get("ordercolDoing")); + } + + if(isQueryByNewTable){//走新表时,使用提前缓存的已办排序时间代替实时case when排序 + backfields0 += ",optorderdate,optordertime"; + backfields += ",t2.optorderdate,optordertime"; + backfieldsOs += ",operatedate as optorderdate,operatetime as optordertime"; + orderby = orderbyos.replaceAll("operatedate","optorderdate").replaceAll("operatetime","optordertime"); + orderbyos = orderbyos.replaceAll("operatedate","optorderdate").replaceAll("operatetime","optordertime"); + myorderby = orderbyos.replaceAll("operatedate","optorderdate").replaceAll("operatetime","optordertime"); + } + + String pageUid = ""; + String urlType = ""; + if (scope.equals("doing")) { + urlType = "1"; + pageUid = PageUidConst.WF_LIST_DOING; + } else if (scope.equals("done")) { + urlType = "2"; + pageUid = PageUidConst.WF_LIST_DONE; + } else if (scope.equals("complete")) { + urlType = "3"; + } else if (scope.equals("mine")) { + urlType = "4"; + pageUid = PageUidConst.WF_LIST_MINE; + } else { + urlType = "0"; + } + String pageId = PageIdConst.getWFPageId(urlType); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + String operateString = ""; + String tableString = ""; + String temptableString = ""; + String temptablerowString = ""; + if (isopenos) { + para2 = "column:requestid+column:workflowid+column:viewtype+0+" + user.getLanguage() + + "+column:nodeid+column:isremark+" + user.getUID() + + "+column:agentorbyagentid+column:agenttype+column:isprocessed+column:userid+0+column:creater+column:systype+column:workflowtype+scope_"+scope+"_scope"; + para2 = "S+column:viewDate+column:viewTime+column:lastFeedBackDate+column:lastFeedBackTime+column:needwfback+column:lastFeedBackOperator+column:userid+S+" + para2; + if("done".equals(scope)){//异构系统不显示已办可以直接不查已办表 + if(showdone){ + fromSql = " from (select " + backfields0 + " from (select " + backfields + " " + fromSql + "" + sqlwhere + + " union (select distinct " + backfieldsOs + " from ofs_done_data " + sqlwhereosDone + ") ) t1 ) t1 "; + }else{ + fromSql = " from (select " + backfields0 + " from (select " + backfields + " " + fromSql + "" + sqlwhere + " ) t1 ) t1 "; + } + }else if("mine".equals(scope) && showdone){//异构系统不显示已办时,我的请求sql和待办sql一致 + fromSql = " from (select " + backfields0 + " from (select " + backfields + " " + fromSql + "" + sqlwhere + + " union (select distinct " + backfieldsOs + " from ofs_todo_data " + sqlwhereos + ") union (select distinct " + backfieldsOs + " from ofs_done_data" + sqlwhereosDone + ") ) t1 ) t1 "; + }else{ + fromSql = " from (select " + backfields0 + " from (select " + backfields + " " + fromSql + "" + sqlwhere + + " union (select distinct " + backfieldsOs + " from ofs_todo_data " + sqlwhereos + ") ) t1 ) t1 "; + } + + //处理紧急程度自定义排序问题 + backfields0 = obu.getOrderByFrom(this.user.getLanguage()) + backfields0; + if(isDoing) {//需要特殊处理 待办 + orderbyos = myorderby; + } + if (!"".equals(firstFloor) && !"".equals(sysorder)) { + String[] orderArr = sysorder.split(","); + for (String id : orderArr){ + if ("0".equals(id)){ + order_qc += ",requestlevel " + order_by ; + } + if ("1".equals(id)){ + order_qc += ",createdate " + order_by + ",createtime " + order_by ; + } + if ("2".equals(id)){ + order_qc += ",receivedate " + order_by + ",receivetime " + order_by ; + } + if ("3".equals(id)){ + order_qc += ",operatedate " + order_by + ",operatetime " + order_by ; + } + if ("4".equals(id)){ + order_qc += ",requestmark " + order_by ; + } + } + orderbyos = order_qc; + if (orderbyos.startsWith(",")){ + orderbyos = orderbyos.substring(1); + } + + } + + if (!StringUtil.isEmpty(orderfieldname)){ + String[] orderfieldArr = orderfieldname.split(","); + if (StringUtil.isEmpty(order_by)){ + order_by = "desc"; + } + String order_temp = ""; + for (String orderfieldStr : orderfieldArr) { + order_temp += orderfieldStr+ " " + order_by +","; + } + orderbyos = order_temp+orderbyos; + } + + temptableString = " "; + String showname = ofso.getShowsysname(); + if (!showname.equals("0")) { + temptablerowString = ""; + } + } else { + backfields = obu.getOrderByFrom(this.user.getLanguage()) + backfields; + if(orderby.toLowerCase().indexOf("operatedate") != -1 || orderby.toLowerCase().indexOf("operatetime") != -1){ + //已办含case when情况排序特殊处理 + if(isDoing) {//需要特殊处理 待办 + orderby = myorderby; + } + if (!"".equals(firstFloor) && !"".equals(sysorder)) { + String[] orderArr = sysorder.split(","); + for (String id : orderArr){ + if ("0".equals(id)){ + order_qc += ",requestlevel " + order_by ; + } + if ("1".equals(id)){ + order_qc += ",createdate " + order_by + ",createtime " + order_by ; + } + if ("2".equals(id)){ + order_qc += ",receivedate " + order_by + ",receivetime " + order_by ; + } + if ("3".equals(id)){ + order_qc += ",operatedate " + order_by + ",operatetime " + order_by ; + } + if ("4".equals(id)){ + order_qc += ",requestmark " + order_by ; + } + } + orderby = order_qc; + if (orderby.startsWith(",")){ + orderby = orderby.substring(1); + } + } + if (!StringUtil.isEmpty(orderfieldname)){ + String[] orderfieldArr = orderfieldname.split(","); + if (StringUtil.isEmpty(order_by)){ + order_by = "desc"; + } + String order_temp = ""; + for (String orderfieldStr : orderfieldArr) { + order_temp += orderfieldStr+ " " + order_by +","; + } + orderbyos = order_temp+orderbyos; + } + + + fromSql = " from (select " + backfields + " " + fromSql + "" + sqlwhere + ") t1 "; + orderby = orderby.replace("t2.", "t1."); + temptableString = " "; + }else{ + // if(myorderby.trim().length()>0) {//需要特殊处理 + if(isDoing) {//需要特殊处理 待办 + orderby = myorderby; + } + if (!"".equals(firstFloor) && !"".equals(sysorder)) { + String[] orderArr = sysorder.split(","); + for (String id : orderArr){ + if ("0".equals(id)){ + order_qc += ",requestlevel " + order_by ; + } + if ("1".equals(id)){ + order_qc += ",createdate " + order_by + ",createtime " + order_by ; + } + if ("2".equals(id)){ + order_qc += ",receivedate " + order_by + ",receivetime " + order_by ; + } + if ("3".equals(id)){ + order_qc += ",operatedate " + order_by + ",operatetime " + order_by ; + } + if ("4".equals(id)){ + order_qc += ",requestmark " + order_by ; + } + } + orderby = order_qc; + if (orderby.startsWith(",")){ + orderby = orderby.substring(1); + } + } + temptableString = " "; + } + } + + //System.err.println("select "+backfields+fromSql+sqlwhere+" order by "+orderby); + //================sql串拼装结束,拼接分页组件tablestring========= + + boolean hasrequestname = true; + boolean hascreater = false; + boolean hascreatedate = false; + boolean hasworkflowname = false; + boolean hasrequestlevel = false; + boolean hasreceivetime = false; + boolean hasstatus = false; + boolean hasreceivedpersons = true; + boolean hascurrentnode = false; + boolean hasrequestmark = false; + if (scope.equals("doing")) { + hascreater = true; + hascreatedate = true; + } else if (scope.equals("done") || scope.equals("complete")) { + hasworkflowname = true; + hascreater = true; + hasreceivetime = true; + hascurrentnode = true; + } else if (scope.equals("mine")) { + hasworkflowname = true; + hascreatedate = true; + hascurrentnode = true; + } else { + hasworkflowname = true; + hascreater = true; + hascreatedate = true; + hascurrentnode = true; + } + + if (!userIDAll.equals(String.valueOf(user.getUID()))) { + //请求名称列串统一 + String requestNameColumnStr = ""; + String currentUserpara = "column:userid"; + String currentUserpara2 = "column:userid+column:nodeid+column:workflowid+column:agentorbyagentid+column:agenttype+"+user.getUID(); + String popedomOtherpara = "S+column:viewDate+column:viewTime+column:lastFeedBackDate+column:lastFeedBackTime+column:needwfback+column:lastFeedBackOperator+column:userid+S+" + "column:viewtype+column:isremark+column:isprocessed+column:nodeid+column:workflowid+"+ scope+"+column:userid"; + String popedomUserpara = userid + "_" + usertype; + String popedomLogpara = "column:nodeid"; + String checkBoxParam = "column:requestid+column:userid+column:workflowid+"+usertype; + if(!isNeedHideBtn){ + operateString = ""; + operateString += " "; + + + //标记为已读 + operateString += " "; + //转发 + if (!user.getLogintype().equals("2")) { + operateString += " "; + } + //督办 + operateString += ""; + //短信催办 + operateString += ""; + //邮件催办 + operateString += ""; + //打印 + operateString += " "; + //表单日志 + operateString += " "; + //关注 + operateString += " "; + operateString += ""; + } + if (showBatchSubmit && isDoing) { + if (isMergeShow) { + tableString = " "; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + tableString += requestNameColumnStr; + } else { + tableString = "
"; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + ""; + tableString += requestNameColumnStr; + } + tableString += temptablerowString; + tableString += ""; + tableString += ""; + + tableString += " "; + tableString += ""; + tableString += ""; + tableString += ""; + + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + } else if ("mine".equals(scope)) { + if (isMergeShow) { + sqlwhere += " and t1.creater = t2.userid"; + tableString = "
"; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + tableString += requestNameColumnStr; + } else { + tableString = "
"; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + tableString += requestNameColumnStr; + } + tableString += temptablerowString; + tableString += " "; + + tableString += " "; + tableString += ""; + tableString += " "; + tableString += " "; + + tableString += " "; + tableString += " "; + tableString += ""; + tableString += ""; + tableString += ""; + } else { + if (isMergeShow) { + tableString = "
"; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + tableString += requestNameColumnStr; + } else { + tableString = "
"; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + tableString += requestNameColumnStr; + } + tableString += temptablerowString; + tableString += " "; + + tableString += " "; + tableString += ""; + tableString += " "; + + if("done".equals(scope)){ + tableString += ""; + }else{ + tableString += ""; + } + tableString += " "; + + tableString += " "; + tableString += " "; + tableString += ""; + tableString += ""; + } + } else { + //请求名称列串统一 + String requestNameColumnStr = ""; + if(isQueryByNewTable){ + requestNameColumnStr = ""; + }else{ + requestNameColumnStr = ""; + } + String currentUserpara = "column:userid"; + String currentUserpara2 = "column:userid+column:nodeid+column:workflowid+column:agentorbyagentid+column:agenttype+"+user.getUID(); + String popedomOtherpara = "S+column:viewDate+column:viewTime+column:lastFeedBackDate+column:lastFeedBackTime+column:needwfback+column:lastFeedBackOperator+column:userid+S+" + "column:viewtype+column:isremark+column:isprocessed+column:nodeid+column:workflowid+" + scope +"+column:userid"; + String popedomUserpara = userid + "_" + usertype; + String popedomLogpara = "column:nodeid"; + String checkBoxParam = "column:requestid+column:userid+column:workflowid+"+usertype; + if(!isNeedHideBtn){ + operateString = ""; + operateString += " "; + + //标记为已读 + operateString += " "; + //转发 + if (!user.getLogintype().equals("2")) { + operateString += " "; + } + //督办 + operateString += ""; + //短信催办 + operateString += ""; + //邮件催办 + operateString += ""; + //打印 + operateString += " "; + //表单日志 + operateString += " "; + //关注 + operateString += " "; + operateString += ""; + } + + if (showBatchSubmit && isDoing) { + tableString = "
"; + + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + + tableString += requestNameColumnStr; + tableString += temptablerowString; + tableString += ""; + tableString += ""; + + tableString += " "; + tableString += ""; + tableString += ""; + tableString += ""; + + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + } else if ("mine".equals(scope)) { + tableString = "
"; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + + tableString += temptablerowString; + tableString += requestNameColumnStr; + tableString += " "; + + tableString += " "; + tableString += ""; + tableString += " "; + + tableString += " "; + tableString += " "; + + tableString += " "; + tableString += " "; + tableString += ""; + tableString += ""; + } else { + tableString = "
"; + tableString += temptableString; + tableString += operateString + (isNeedHideBtn ? "" : getCheckBoxString(scope, checkBoxParam)) + " "; + tableString += temptablerowString; + tableString += requestNameColumnStr; + tableString += " "; + + tableString += " "; + tableString += " "; + tableString += " "; + + if("done".equals(scope)){ + tableString += ""; + }else{ + tableString += ""; + } + tableString += " "; + + tableString += " "; + tableString += " "; + tableString += ""; + tableString += ""; + } + } + + if(!"".equals(extrafieldname)){ + for (int i = 0; i < fieldNameList.size(); i++) { + tableString += " "; + } + } + + if(!"".equals(tableString)){ + tableString += ""; + tableString += "" + "
"; + } + + String sessionkey = pageUid+"_"+Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + //批量提交是否需要签字意见 + int multisubmitnotinputsign = 0; + if(showBatchSubmit && isDoing){ + RecordSet.executeQuery("select multisubmitnotinputsign from workflow_RequestUserDefault where userId=?", userid); + if(RecordSet.next()) + multisubmitnotinputsign = Util.getIntValue(Util.null2String(RecordSet.getString("multisubmitnotinputsign")), 0); + } + + Map sharearg = new HashMap(); + sharearg.put("multisubmitnotinputsign", multisubmitnotinputsign+""); + if(showBatchSubmit && isDoing && sysId != 5 && sysId != 8) + sharearg.put("hasBatchSubmitBtn", "true"); + sharearg.put("hasBatchReadBtn", (!isNeedHideBtn && isDoing && CurrentUser.equals(userid+""))+""); //自己待办才显示全部只读按钮 + + boolean showBatchAttentionBtn = (!isNeedHideBtn && new RequestAttentionBiz().showBatchAttentionBtn(scope)); + sharearg.put("showBatchAttentionBtn", showBatchAttentionBtn+""); + sharearg.put("showBatchForwardBtn", isNeedHideBtn ? "false" : "true"); + sharearg.put("showBtn", isNeedHideBtn ? "false" : "true"); + apidatas.put("sessionkey", sessionkey); + apidatas.put("sharearg", sharearg); + return apidatas; + } + + /** + * 获取checkbox的xml节点 + * @param scope + * @param params + * @return + */ + private String getCheckBoxString(String scope,String params){ + StringBuffer result = new StringBuffer(); + + if("done".equals(scope) || "mine".equals(scope) || "doing".equals(scope)){ + result.append(""); + + if("doing".equals(scope)){ + //批量提交 + //获取trancemethod信息 + String multSubmitParam = this.listInfoEntity.getListOperateInfoEntity().getMultSubmitParam(); + String multSubmitMethod = this.listInfoEntity.getListOperateInfoEntity().getMultSubmitMethod(); + + result.append(""); + } + + //批量关注 + result.append(""); + + //批量督办 + result.append(""); + + //批量转发 + result.append(""); + + result.append(""); + } + + return result.toString(); + } + + + /** + * 是否有督办权限 + * @param inStr("column:requestid+column:userid+column:workflowid) + * @return + */ + public String getBatchSupervisorCheckbox(String inStr){ + + String[] tempStr = Util.TokenizerString2(inStr, "+"); + String requestid = Util.null2String(tempStr[0]); + String userid = Util.null2String(tempStr[1]);//当前登录用户的userid + + boolean hasSupervisorRight = RequestListBiz.hasSupervisorRight(userid, requestid); + + return hasSupervisorRight ? "true" : "false"; + } + + /** + * 是否有转发权限 + * @param inStr + * @return + */ + public String getBatchForwardCheckbox(String inStr){ + String[] tempStr = Util.TokenizerString2(inStr, "+"); + String requestid = Util.null2String(tempStr[0]); + String userid = Util.null2String(tempStr[1]);//当前登录用户的userid + String workflowid = Util.null2String(tempStr[2]); + String usertype = Util.null2String(tempStr[3]); + RecordSet rs = new RecordSet(); + rs.executeQuery("select prohibitBatchForward from workflow_base where id = ?",Util.getIntValue(workflowid)); + if(rs.next()) { + if("1".equals(rs.getString("prohibitBatchForward"))) return "false"; + } + + int currentNodeType = 0; + rs.executeQuery("select currentnodetype from workflow_requestbase where requestid = ?",requestid); + if(rs.next()) { + currentNodeType = rs.getInt("currentnodetype"); + } + + RequestAuthenticationService authenticationService = new RequestAuthenticationService(); + User user = new User(); + user.setUid(Util.getIntValue(userid)); + user.setLogintype("0".equals(usertype) ? "1" : "2" ); + authenticationService.setUser(user); + if(!authenticationService.getRequestUserRight(null, Util.getIntValue(requestid))) return "false"; + Map authInfo = authenticationService.getAuthInfo(); + int currentOperateId = Util.getIntValue(Util.null2String(authInfo.get("wfcurrrid"))); + int nodeId = Util.getIntValue(Util.null2String(authInfo.get("nodeid"))); + int isremark = Util.getIntValue(Util.null2String(authInfo.get("isremarkForRM"))); + int takisremark = Util.getIntValue(Util.null2String(authInfo.get("takisremark"))); + int preisremark = Util.getIntValue(Util.null2String(authInfo.get("preisremark"))); + int agenttype = Util.getIntValue(Util.null2String(authInfo.get("agentType"))); + int nodetype = Util.getIntValue(Util.null2String(authInfo.get("nodetype"))); + + int isFromWFRemark = -1; + if (currentNodeType == 3) { + isFromWFRemark = 2; + if(isremark == 8 || isremark == 9) { + isFromWFRemark = 0; + } + } else { + if (isremark == 1 || isremark == 0 || isremark == 7 || isremark == 8 || isremark == 9 || isremark == 11) { + //未回复意见征询人 + if(isremark == 0 && takisremark == -2) { + isFromWFRemark = 1; + } else { + isFromWFRemark = 0; + } + } else if (isremark == 2) { + isFromWFRemark = 1; + } + } + + int extendnodeid = nodeId; + if(FreeNodeBiz.isFreeNode(extendnodeid)) { + extendnodeid = FreeNodeBiz.getExtendNodeId(nodeId); + } + + int wfid = Util.getIntValue(workflowid); + + //判断节点是否开启限制接收人范围 + rs.executeQuery("select isopen from workflow_FwLimitSet where fwtype='1' and nodeid= ? and wfid= ?",nodeId,wfid); + if(rs.next()) { + if("1".equals(rs.getString("isopen"))) { + return "false"; + } + } + + WFForwardManager wfForwardManager = new WFForwardManager(); + wfForwardManager.init(); + wfForwardManager.setWorkflowid(wfid); + wfForwardManager.setNodeid(extendnodeid); + wfForwardManager.setIsremark(Util.null2String(isremark)); + wfForwardManager.setTakIsremark(takisremark+""); + wfForwardManager.setRequestid(Util.getIntValue(requestid)); + wfForwardManager.setBeForwardid(currentOperateId); + wfForwardManager.getWFNodeInfo(preisremark); + String IsPendingForward = wfForwardManager.getIsPendingForward(); + String IsTakingOpinions = wfForwardManager.getIsTakingOpinions(); + String IsHandleForward = wfForwardManager.getIsHandleForward(); + String IsBeForward = wfForwardManager.getIsBeForward(); + String IsSubmitedOpinion = wfForwardManager.getIsSubmitedOpinion(); + String IsSubmitForward = wfForwardManager.getIsSubmitForward(); + String IsAlreadyForward = wfForwardManager.getIsAlreadyForward(); + String IsWaitForwardOpinion = wfForwardManager.getIsWaitForwardOpinion(); + String IsBeForwardSubmit = wfForwardManager.getIsBeForwardSubmit(); + String IsBeForwardModify = wfForwardManager.getIsBeForwardModify(); + String IsBeForwardPending = wfForwardManager.getIsBeForwardPending(); + String IsBeForwardTodo = wfForwardManager.getIsBeForwardTodo(); + String IsBeForwardSubmitAlready = wfForwardManager.getIsBeForwardSubmitAlready(); + String IsBeForwardAlready = wfForwardManager.getIsBeForwardAlready(); + String IsBeForwardSubmitNotaries = wfForwardManager.getIsBeForwardSubmitNotaries(); + //转发记录 + if(preisremark == 1 && takisremark != 2) { + isFromWFRemark = Util.getIntValue(wfForwardManager.getIsFromWFRemark()); + } + boolean canForwd = false; + switch (isFromWFRemark) { + case 0: //待办 + if (isremark == 0 || isremark == 7 || isremark == 8 || isremark == 9 || isremark == 11) { + canForwd = "1".equals(IsPendingForward); + } else if(isremark == 1) { + if(takisremark == 2) { + canForwd = "1".equals(IsPendingForward); + } else { + canForwd = "1".equals(IsBeForwardTodo); + } + } + if(preisremark == 1 && takisremark != 2) { + canForwd = "1".equals(IsBeForwardTodo); + } + break; + case 1: //已办 + if(preisremark == 0 || preisremark == 7 || preisremark == 8 || preisremark == 9 || preisremark == 11 || (preisremark == 2 && agenttype == 1)) { + canForwd = "1".equals(IsAlreadyForward); + } else if (preisremark == 1) { + if(takisremark == 2) { + canForwd = "1".equals(IsAlreadyForward); + } else { + canForwd = "1".equals(IsBeForwardAlready); + } + } + break; + case 2: //归档 + if(preisremark == 0 || preisremark == 7 || preisremark == 8 || preisremark == 9 || preisremark == 4 || (preisremark == 2 && agenttype == 1)) { + canForwd = "1".equals(IsSubmitForward); + } else if (preisremark == 1) { + canForwd = "1".equals(IsBeForward); + } + break; + } + + RequestSecondAuthService service = ServiceUtil.getService(RequestSecondAuthServiceImpl.class, user); + Map params = new HashMap(); + + params.put("workflowid", wfid); + params.put("nodeid", extendnodeid + ""); + + Map result = service.getSecondAuthConfig4Checkbox(params); + String isEnableAuth = Util.null2String(result.get("isEnableAuth")); + String isEnableProtect = Util.null2String(result.get("isEnableProtect")); + int protectType = Util.getIntValue(Util.null2String(result.get("protectType"))); //数据保护的方式 + int secondAuthType = Util.getIntValue(Util.null2String(result.get("secondAuthType"))); //二次认证的方式 + int qysSignWay = Util.getIntValue(Util.null2String(result.get("qysSignWay"))); //2 契约锁服务 或者 1 契约锁单体 + + if (("1".equals(isEnableAuth) && secondAuthType == SecondAuthType.RealIDAuth.getId()) || "1".equals(isEnableProtect)) { + canForwd = false; + } + + return canForwd ? "true" : "false"; + } + + //列表是否满足走微搜条件判断 + private boolean supportQuickSerach(boolean isopenos,String scope){ + int viewcondition = Util.getIntValue(Util.null2String(params.get("viewcondition")), 0); + List supportViewconList = Arrays.asList(0,10,16); + if(!isopenos && "".equals(Util.null2String(params.get("resourceid"))) && "".equals(Util.null2String(params.get("tabkeys"))) && supportViewconList.contains(viewcondition)){//满足微搜条件调用微搜 + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from HrmUserSetting where resourceId=?", user.getUID());//主次账号统一显示不走微搜,因为微搜暂时无法传给transmethod对应的userid + String belongtoshow = ""; + if(rs.next()){ + belongtoshow = Util.null2String(rs.getString("belongtoshow")); + } + String Belongtoids = user.getBelongtoids(); + String doingStatus = Util.null2String(params.get("doingStatus")); + String unophrmid = Util.null2String(params.get("unophrmid")); + String creatertype = Util.null2String(params.get("creatertype")); + String recievedateselect = Util.null2String(params.get("recievedateselect")); + String operatedateselect = Util.null2String(params.get("operatedateselect")); + if((!"1".equals(belongtoshow) || ("1".equals(belongtoshow) && "".equals(Belongtoids))) && ("0".equals(doingStatus) || "".equals(doingStatus)) && "".equals(unophrmid) && ("".equals(creatertype) || "0".equals(creatertype))){ + return (SearchBrowserUtils.quickSearchValidate("WFSEARCH",user.getLanguage() + "") && SearchBrowserUtils.isSupportWfRemarkStatus() && + (SearchBrowserUtils.isSupportWfReqList() || "mine".equals(scope)) && ("".equals(operatedateselect) || "0".equals(operatedateselect)) && ("".equals(recievedateselect) || "0".equals(recievedateselect))); + } + } + return false; + } + + /** + * 是否有批量关注权限 + * @param inStr + * @return + */ + public String getBatchAttentionCheckbox(String inStr){ + return "true"; + } + + public HttpServletRequest getRequest() { + return request; + } + + public void setRequest(HttpServletRequest request) { + this.request = request; + } + + public ListInfoEntity getListInfoEntity() { + return listInfoEntity; + } + + public void setListInfoEntity(ListInfoEntity listInfoEntity) { + this.listInfoEntity = listInfoEntity; + } +} diff --git a/interface/transfer/mobile/testDemo3.jsp b/interface/transfer/mobile/testDemo3.jsp new file mode 100644 index 0000000..da90363 --- /dev/null +++ b/interface/transfer/mobile/testDemo3.jsp @@ -0,0 +1,47 @@ +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.io.FileInputStream" %> +<%@ page import="java.io.File" %> +<%@ page import="org.apache.poi.ss.usermodel.Workbook" %> +<%@ page import="org.apache.poi.xssf.usermodel.XSSFWorkbook" %> +<%@ page import="org.apache.poi.ss.usermodel.Sheet" %> +<%@ page import="org.apache.poi.ss.usermodel.Row" %> +<%@ page import="java.util.Iterator" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="com.engine.custom.archives.entity.Dept" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.soa.workflow.request.RequestService" %> +<%@ page import="weaver.soa.workflow.request.RequestInfo" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="com.engine.custom.archives.action.WorkflowToDocCus" %> +<%@ page import="com.engine.custom.archives.util.ArchivesUtil" %> +<%@ page import="com.alibaba.fastjson.JSON" %> + + +<% + + generaRequestFormPdf(895895,0); + +%> + +<%! + /** + * 生成主流程承办单 + * + * @param requestid + * 生成表单时的签字意见是否需要子流程的签字意见 + * + */ + public static List generaRequestFormPdf(int requestid ,int reqType) { + // log.error("generaRequestFormPdf,requestid:{}",requestid); + RequestService requestService = new RequestService(); + RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); + WorkflowToDocCus workflowToDoc = new WorkflowToDocCus(); + requestInfo.setLastoperator("1"); + requestInfo.setDescription(ArchivesUtil.getWfNameByid(requestInfo.getWorkflowid()) + "-" + requestInfo.getDescription()); + // log.error("generaRequestFormPdf,requestInfo:{}", JSON.toJSONString(requestInfo)); + return workflowToDoc.execute(requestInfo, reqType); + } +%> + + diff --git a/weaver/general/WorkFlowTransMethod.java b/weaver/general/WorkFlowTransMethod.java new file mode 100644 index 0000000..d22aab0 --- /dev/null +++ b/weaver/general/WorkFlowTransMethod.java @@ -0,0 +1,7356 @@ +package weaver.general; + +import com.api.browser.bean.BrowserValueInfo; +import com.api.browser.service.BrowserValueInfoService; +import com.engine.common.util.ServiceUtil; +import com.engine.workflow.biz.SelectNextFlowBiz; +import com.engine.workflow.biz.WorkflowBaseBiz; +import com.engine.workflow.biz.freeNode.FreeNodeBiz; +import com.engine.workflow.biz.requestList.RequestAttentionBiz; +import com.engine.workflow.biz.requestList.RequestListBiz; +import com.engine.workflow.constant.SecondAuthType; +import com.engine.workflow.entity.freeNode.FreeNodeEntity; +import com.engine.workflow.service.RequestSecondAuthService; +import com.engine.workflow.service.impl.RequestSecondAuthServiceImpl; +import com.engine.workflow.util.ChuanyueUtil; +import com.weaver.cssRenderHandler.JsonUtils; +import org.apache.commons.lang.StringUtils; +import weaver.conn.ConnectionPool; +import weaver.conn.RecordSet; +import weaver.cpt.capital.CapitalComInfo; +import weaver.crm.Maint.CustomerInfoComInfo; +import weaver.docs.docs.DocComInfo; +import weaver.docs.docs.DocImageManager; +import weaver.docs.senddoc.DocReceiveUnitComInfo; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.browser.Browser; +import weaver.interfaces.workflow.browser.BrowserBean; +import weaver.ofs.manager.utils.OfsTodoDataUtils; +import weaver.proj.Maint.ProjectInfoComInfo; +import weaver.rtx.RTXConfig; +import weaver.system.RequestDefaultComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.setting.HrmUserSettingComInfo; +import weaver.workflow.field.BrowserComInfo; +import weaver.workflow.monitor.Monitor; +import weaver.workflow.monitor.MonitorDTO; +import weaver.workflow.request.*; +import weaver.workflow.request.todo.OfsSettingObject; +import weaver.workflow.request.todo.RequestUtil; +import weaver.workflow.workflow.*; + +import java.text.DecimalFormat; +import java.util.*; + +/* + * Created on 2006-05-18 + * Copyright (c) 2001-2006 泛微软件 + * 泛微协同商务系统,版权所有。 + * + */ + +/** + * 流程列表页数据库值和显示名的转化 + * + * @author xwj + * @version10. + */ +public class WorkFlowTransMethod extends BaseBean { + private ResourceComInfo rc = null; + private CustomerInfoComInfo cci = null; + private WorkflowBillComInfo wcInfo = null; + + private WorkflowComInfo wf = null; + private WorkflowComInfo WorkflowComInfo = null; + private DepartmentComInfo DepartmentComInfo1 = null; + private JobTitlesComInfo JobTitlesComInfo1 = null; + private ProjectInfoComInfo ProjectInfoComInfo1 = null; + private DocComInfo DocComInfo1 = null; + private BrowserComInfo BrowserComInfo = null; + private DocImageManager DocImageManager = null; + private WorkflowRequestComInfo WorkflowRequestComInfo1 = null; + private CapitalComInfo CapitalComInfo1 = null; + private RequestDefaultComInfo RequestDefaultComInfo = null; + private ResourceConditionManager rcm = null; + private DocReceiveUnitComInfo duc = null; + private WorkflowComInfo wci = null; + private RequestUtil ru = null; + public int count = 0; + private RequestBaseUtil rbu = null; + private static final String STYLE_STR = ""; // 返回的的returnStr包含 主次账号图标时需要使用此样式包裹 + private String contextPath = "";//系统路径 + + public WorkFlowTransMethod() { + try { + cci = new CustomerInfoComInfo(); + rc = new ResourceComInfo(); + wcInfo = new WorkflowBillComInfo(); + wf = new WorkflowComInfo(); + RequestDefaultComInfo = new RequestDefaultComInfo(); + DocComInfo1 = new DocComInfo(); + ProjectInfoComInfo1 = new ProjectInfoComInfo(); + BrowserComInfo = new BrowserComInfo(); + DepartmentComInfo1 = new DepartmentComInfo(); + JobTitlesComInfo1 = new JobTitlesComInfo(); + DocImageManager = new DocImageManager(); + WorkflowRequestComInfo1 = new WorkflowRequestComInfo(); + CapitalComInfo1 = new CapitalComInfo(); + rcm = new ResourceConditionManager(); + duc = new DocReceiveUnitComInfo(); + wci = new WorkflowComInfo(); + ru = new RequestUtil(); + rbu = new RequestBaseUtil(); + contextPath = Util.null2String(GCONST.getContextPath()); + } catch (Exception ex) { + writeLog(ex); + } + } + + /** + * 判断当前请求节点设置了必须新增明细后,明细中有没有数据 + * + * @param workflowid + * @param requestid + * @return 返回false-表示明细没有数据 + */ + public boolean haveDetailMustAdd(String workflowid, int requestid) { + boolean flag = true; + String sql = ""; + int isbill = 0; + int formid = 0; + int nodeid = 0; + int groupid = 0; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + sql = "select formid,isbill from workflow_base where id=" + workflowid; + rs.executeSql(sql); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + } + sql = "select currentnodeid from workflow_requestbase where requestid=" + requestid; + rs.executeSql(sql); + if (rs.next()) { + nodeid = rs.getInt(1); + } + //检查当前节点 是否设置了 必须新增明细 + sql = "select groupid from workflow_NodeFormGroup where isneed=1 and nodeid=" + nodeid; + rs.executeSql(sql); + while (rs.next()) { + groupid = rs.getInt(1); + //判断是新表单还是老表单,明细表不一样 + if (formid > 0 && isbill == 0) {//老表单 + //检查明细是否有数据 + sql = "select id from workflow_formdetail where requestid=" + requestid + " and groupid=" + groupid; + rs1.executeSql(sql); + if (rs1.next()) { + + } else { + return false; + } + } + if (formid < 0 && isbill == 1) {//新表单 + int dt = groupid + 1; + int mainT = -formid; + //检查明细是否有数据 + sql = "select id from formtable_main_" + mainT + "_dt" + dt + " where mainid=(select id from formtable_main_" + mainT + " where requestid=" + requestid + ")"; + rs1.executeSql(sql); + if (rs1.next()) { + + } else { + return false; + } + } + } + return flag; + } + + /** + * 重写,加上当前节点id + * 判断当前请求节点设置了必须新增明细后,明细中有没有数据 + * + * @param workflowid + * @param requestid + * @param nodeid + * @return 返回false-表示明细没有数据 + */ + public boolean haveDetailMustAdd(String workflowid, int requestid, int nodeid) { + boolean flag = true; + String sql = ""; + String checksql = ""; + int isbill = 0; + int formid = 0; + int groupid = 0; + int checks = 0; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + sql = "select formid,isbill from workflow_base where id=" + workflowid; + rs.executeSql(sql); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + } + //修改,主要是针对客户复制了明细表,然后直接删除了明细字段 + if (formid > 0 && isbill == 0) { //老表单 + checksql = "SELECT count(fieldid) FROM workflow_formfield WHERE formid=" + formid + " and isdetail is not null"; + rs.executeSql(checksql); + if (rs.next()) { + checks = rs.getInt(1); + } + if (checks > 0) { + //检查当前节点 是否设置了 必须新增明细 + sql = "select groupid from workflow_NodeFormGroup where isneed=1 and nodeid=" + nodeid; + rs1.executeSql(sql); + while (rs1.next()) { + groupid = rs1.getInt(1); + //判断是新表单还是老表单,明细表不一样 + if (formid > 0 && isbill == 0) {//老表单 + //检查明细是否有数据 + sql = "select id from workflow_formdetail where requestid=" + requestid + " and groupid=" + groupid; + rs2.executeSql(sql); + if (rs2.next()) { + + } else { + return false; + } + } + if (formid < 0 && isbill == 1) {//新表单 + int dt = groupid + 1; + int mainT = -formid; + //检查明细是否有数据 + rs2.executeQuery("select 1 from WORKFLOW_BILLDETAILTABLE where billid = ? and tablename='formtable_main_" + mainT + "_dt" + dt + "'", formid); + if (!rs2.next()) { + continue; + } + //检查明细是否有数据 + sql = "select id from formtable_main_" + mainT + "_dt" + dt + " where mainid=(select id from formtable_main_" + mainT + " where requestid=" + requestid + ")"; + rs2.executeSql(sql); + if (rs2.next()) { + + } else { + return false; + } + } + } + } else { + + } + } + if (formid < 0 && isbill == 1) {//新表单 + checksql = "select COUNT(id) from workflow_billfield where billid=" + formid + " AND viewtype =1"; + rs.executeSql(checksql); + if (rs.next()) { + checks = rs.getInt(1); + } + + List detailNames = new ArrayList<>(); + rs.executeQuery("select tablename from workflow_billdetailtable where billid = ?", formid); + while (rs.next()) { + detailNames.add(rs.getString("tablename")); + } + + if (checks > 0) { + //检查当前节点 是否设置了 必须新增明细 + sql = "select groupid from workflow_NodeFormGroup where isneed=1 and nodeid=" + nodeid; + rs1.executeSql(sql); + while (rs1.next()) { + groupid = rs1.getInt(1); + //判断是新表单还是老表单,明细表不一样 + if (formid > 0 && isbill == 0) {//老表单 + //检查明细是否有数据 + sql = "select id from workflow_formdetail where requestid=" + requestid + " and groupid=" + groupid; + rs2.executeSql(sql); + if (rs2.next()) { + + } else { + return false; + } + } + if (formid < 0 && isbill == 1) {//新表单 + int dt = groupid + 1; + int mainT = -formid; + if (detailNames.indexOf("formtable_main_" + mainT + "_dt" + dt) == -1) { + continue; + } + //检查明细是否有数据 + sql = "select id from formtable_main_" + mainT + "_dt" + dt + " where mainid=(select id from formtable_main_" + mainT + " where requestid=" + requestid + ")"; + rs2.executeSql(sql); + if (rs2.next()) { + + } else { + return false; + } + } + } + } else { + + } + } + return flag; + } + + /** + * 是否在列表显示选择筐 待审批显示复选框 + * + * @param request 流程ID + * @return true/false + */ + public String getOpUserResultCheckBox(String request) { + String[] tempStr = Util.splitString(request, "+"); + String requestid = Util.null2String(tempStr[0]); + String userid = Util.null2String(tempStr[1]); + RecordSet rs = new RecordSet(); + rs.executeSql("select distinct userid from workflow_currentoperator where (isremark in ('0','1') or (isremark='4' and viewtype=0)) and requestid =" + requestid + " and userid=" + userid); + return "" + rs.next(); + } + + + /** + * 将流程删除人id转为name + * + * @param id 创建人ID + * @param type 内部/外部 + * @return 显示中文名 + */ + public String getDelResultName(String id, String type) { + String returnStr = ""; + if ("1".equals(type) || "1.0".equals(type)) { //外部 + returnStr =cci.getCustomerInfoname(id); + } else { //内部 + returnStr =rc.getResourcename(id); + } + return returnStr; + } + + /** + * 把流程创建人由ID转为显示中文名 + * + * @param id 创建人ID + * @param type 内部/外部 + * @return 显示中文名 + */ + public String getWFSearchResultName(String id, String type) { + String returnStr = ""; + if ("1".equals(type) || "1.0".equals(type)) { //外部 + returnStr = + "" + + cci.getCustomerInfoname(id) + + ""; + } else { //内部 + returnStr = + "" + + rc.getResourcename(id) + + ""; + } + return returnStr; + } + + /** + * 把流程名称和流程ID作为流程名称一起显示 + * + * @param requestname 流程名称 + * @param para1 + * @return 显示名 + */ + public String getWFSearchResultFlowName(String requestname, String para1) { + RecordSet rs = new RecordSet(); + String returnStr = ""; + String[] tempStr = Util.splitString(para1, "+"); + String requestid = Util.null2String(tempStr[0]); + int isview = Util.getIntValue(tempStr[1], 0); + + int workflowid = Util.getIntValue(Util.null2String(tempStr[2]), 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[3]), 7); + int isbill = 0; + int formid = 0; + ////根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + + requestname = rbu.formatRequestname(requestname, workflowid + "", requestid, isbill, formid, userlang); + returnStr = requestname + "(" + requestid + ")"; + if (isview == 1) { + returnStr = "" + returnStr + ""; + } + return returnStr; + } + + /** + * 把流程紧急程度由代码转为显示中文名 + * + * @param urgencyType 流程紧急程度 + * @return 显示中文名 + */ + public String getWFSearchResultUrgencyDegree(String urgencyType, String userLanguage) { + String returnStr = ""; + if("".equals(Util.null2String(urgencyType).trim())){//sqlserver、mysql默认会对数字型列做空串转数字处理,例如urgencyType等于空的情况下会查到表中id等于0的数据 + return returnStr; + } + String sql = "SELECT id, defaultname, customname FROM workflow_customlevel where id=?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, urgencyType); + if (rs.next()) { + String customname = Util.null2String(rs.getString("customname")); + String defaultname = Util.null2String(rs.getString("defaultname")); + returnStr = "".equals(customname) ? SystemEnv.getHtmlLabelNames(defaultname, Integer.parseInt(userLanguage)) : customname; + } + /*if ("0".equals(urgencyType)) { + returnStr = SystemEnv.getHtmlLabelName(225,Integer.parseInt(userLanguage)); + } else if ("1".equals(urgencyType)) { + returnStr = SystemEnv.getHtmlLabelName(15533,Integer.parseInt(userLanguage)); + } else if ("2".equals(urgencyType)) { + returnStr = SystemEnv.getHtmlLabelName(2087,Integer.parseInt(userLanguage)); + } else { + + }*/ + return returnStr; + } + + /** + * 格式化显示创建时间 + * + * @param day 日期 + * @param time 时间 + * @return 日期+ " " + 时间 + */ + public String getWFSearchResultCreateTime(String day, String time) { + return day + " " + time; + } + + + /** + * 是否在列表显示选择筐 + * + * @param workflowid 流程ID + * @return true/false + */ + public String getWFSearchResultCheckBox(String workflowid) { + RecordSet RecordSet = new RecordSet(); + String[] tempStr = Util.splitString(workflowid, "+"); + String wfid = Util.null2String(tempStr[0]); + String isremark = Util.null2String(tempStr[1]); + int requestid = Util.getIntValue(tempStr[2]); + int nodeid = Util.getIntValue(tempStr[3]); + int userid = Util.getIntValue(tempStr[4]); + /** + * 是否是手机端的checkbox + */ + boolean isFromMobile = false; + if (tempStr.length > 5) { + isFromMobile = "1".equals(Util.null2String(tempStr[5]).trim()); + } + + int Forwardid = 0; + int takisremark = -1; + boolean canSubmit = true; + // System.out.println("---266--sql-"+"select + // isremark,isreminded,preisremark,id,groupdetailid,nodeid from + // workflow_currentoperator where requestid="+requestid+" and + // userid="+userid+" and nodeid="+nodeid+" order by isremark,id"); + if ("1".equals(isremark)) { + RecordSet + .executeSql("select takisremark,isremark,isreminded,preisremark,id,groupdetailid,nodeid from workflow_currentoperator where requestid=" + + requestid + + " and userid=" + + userid + + " and nodeid=" + nodeid + " and islasttimes = 1 order by isremark,id"); + while (RecordSet.next()) { + Forwardid = Util.getIntValue(RecordSet.getString("id")); + takisremark = Util.getIntValue(RecordSet + .getString("takisremark")); + } + + String wfSQL = "select * from workflow_Forward where requestid=" + + requestid + " and BeForwardid=" + Forwardid; + RecordSet.executeSql(wfSQL); + if (RecordSet.next()) { + String IsFromWFRemark_T = Util.null2String(RecordSet + .getString("IsFromWFRemark")); // 待办提交后被转发人是否可提交意见 + String IsSubmitedOpinion = Util.null2String(RecordSet + .getString("IsSubmitedOpinion")); // 待办提交后被转发人是否可提交意见 + String IsBeForwardTodo = Util.null2String(RecordSet + .getString("IsBeForwardTodo")); // 待办可转发 + String IsBeForwardSubmitAlready = Util.null2String(RecordSet + .getString("IsBeForwardSubmitAlready")); // 允许已办被转发人可提交意见 + String IsBeForwardAlready = Util.null2String(RecordSet + .getString("IsBeForwardAlready")); // 已办被转发人可转发 + String IsBeForwardSubmitNotaries = Util.null2String(RecordSet + .getString("IsBeForwardSubmitNotaries")); // 允许办结被转发人可提交意见 + String IsBeForward = Util.null2String(RecordSet + .getString("IsBeForward")); // 办结被转发人是否可转发 + if (takisremark != 2) { + if (("0".equals(IsFromWFRemark_T) && "1" + .equals(IsSubmitedOpinion)) + || ("1".equals(IsFromWFRemark_T) && "1" + .equals(IsBeForwardSubmitAlready)) + || ("2".equals(IsFromWFRemark_T) && "1" + .equals(IsBeForwardSubmitNotaries))) { + canSubmit = true; + } else { + canSubmit = false; + } + } + if (takisremark == 2) { + canSubmit = true; + } + } + } + String flag = "false"; + if (isremark.equals("0")) { + if ("1".equals(getWFMultiSubmit(wfid, nodeid, isremark, takisremark))) + flag = "true"; + if (flag.equals("true")) { + boolean needJudgeMustInput = true; + int extendnodeid = nodeid; + if (FreeNodeBiz.isFreeNode(nodeid)) { + FreeNodeEntity nodeEntity = FreeNodeBiz.getCurrentFreeNodeEntity(requestid, nodeid); + if (nodeEntity != null) { + if (!nodeEntity.isAllowModify()) { + needJudgeMustInput = false; + } + extendnodeid = nodeEntity.getExtendnodeid(); + } + } + if (needJudgeMustInput) { + if (flag.equals("true") && haveMustInput(requestid, extendnodeid)) { + flag = "false"; + } else { + if (haveDetailMustAdd(wfid, requestid, extendnodeid)) { + flag = "true"; + } else { + flag = "false"; + } + } + } + } + //查阅类型暂不支持批量提交 + if (flag.equals("true")) { + if (FreeNodeBiz.isFreeNode(nodeid)) { + FreeNodeEntity nodeEntity = FreeNodeBiz.getCurrentFreeNodeEntity(requestid, nodeid); + if (nodeEntity != null && nodeEntity.getNodetype() == 4) { + flag = "false"; + } + } + } + } else if (isremark.equals("9")) { + if ("1".equals(getWFMultiSubmit(wfid, nodeid, isremark, takisremark))) { + flag = "true"; + } + } else if (isremark.equals("11")) { + if ("1".equals(getWFMultiSubmit(wfid, nodeid, isremark, takisremark)) && ChuanyueUtil.isSubmitSignByRequestId(Util.getIntValue(wfid),requestid,nodeid,userid,"1".equals(new User(userid).getLogintype()) ? 0 : 1,11+"",true)) { + flag = "true"; + } + } else if (isremark.equals("1")) { + if (canSubmit && "1".equals(getWFMultiSubmit(wfid, nodeid, isremark, takisremark))) { + + flag = "true"; + } else { + + flag = "false"; + } + } else if ("8".equals(isremark)) { + //要判断一下是否有传阅的记录,如果有则要验证传阅能否批示,不能才返回false + RecordSet.executeQuery("select isremark from workflow_currentoperator where isremark=11 and requestid=? and userid=?", requestid, userid); + if (RecordSet.next() && "1".equals(getWFMultiSubmit(wfid, nodeid, isremark, takisremark))) { + flag = "true"; + } else { + flag = "false"; + } + } + + + User user = new User(userid); + RequestSecondAuthService service = ServiceUtil.getService(RequestSecondAuthServiceImpl.class, user); + Map params = new HashMap(); + + int extendnodeid = nodeid; + if(FreeNodeBiz.isFreeNode(extendnodeid)) { + extendnodeid = FreeNodeBiz.getExtendNodeId(nodeid); + } + + params.put("workflowid", wfid); + params.put("nodeid", extendnodeid + ""); + + Map result = service.getSecondAuthConfig4Checkbox(params); + String isEnableAuth = Util.null2String(result.get("isEnableAuth")); + String isEnableProtect = Util.null2String(result.get("isEnableProtect")); + int protectType = Util.getIntValue(Util.null2String(result.get("protectType"))); //数据保护的方式 + int secondAuthType = Util.getIntValue(Util.null2String(result.get("secondAuthType"))); //二次认证的方式 + int qysSignWay = Util.getIntValue(Util.null2String(result.get("qysSignWay"))); //2 契约锁服务 或者 1 契约锁单体 + + //移动端,如果开启二次密码校验,不显示check框(手机端参数为6个) + if ("true".equals(flag)) { + if (isFromMobile) { + if ("1".equals(isEnableAuth) || "1".equals(isEnableProtect)) { + flag = "false"; + } + } else { + //因为CA暂没有批量数据签名的接口,因此流程开启了CA数据保护时,PC端不允许批量提交 + if (("1".equals(isEnableProtect) && protectType == SecondAuthType.CAAuth.getId()) + || ("1".equals(isEnableProtect) && protectType == SecondAuthType.QYS.getId() && qysSignWay == 1) + || ("1".equals(isEnableAuth) && secondAuthType == SecondAuthType.RealIDAuth.getId())) { + flag = "false"; + } + } + } + + if ("true".equals(flag) && SelectNextFlowBiz.hasSelectNextFlow(nodeid)) {//开启了指定流转,不允许批量提交 + flag = "false"; + } + + return flag; + } + + + /** + * 是否在列表显示选择筐,批量标记为已读 + * + * @param otherInfo 流程ID + * @return true/false + */ + public String getWFSearchRstCkBoxForMsg(String otherInfo) { + String isread = "false"; + boolean isprocessed; + String[] otherInfos = Util.splitString(otherInfo, "+"); + String viewtype = Util.null2String(otherInfos[0]); + String isremark_tmp = Util.null2String(otherInfos[1]); + String isprocessed_tmp = Util.null2String(otherInfos[2]); + if ((isremark_tmp.equals("0") && !isprocessed_tmp.equals("1")) || isremark_tmp.equals("5")) { + isprocessed = true; + } else { + isprocessed = false; + } + if (viewtype.equals("0")) { + //if(isprocessed){ + isread = "true"; + //} + } + return isread; + } + + /** + * 流程操作按钮判断 + * add by Dracula @2014-1-15 + * + * @param + * @param otherInfo + * @return + */ + public List getWFSearchResultOperation(String requestid, String otherInfo, String userInfo) { + String showMarkReadBtn = "false"; //显示标记为已读 + String showRansmitBtn = "false"; //显示转发按钮 + //String showtakingOpBtn = "false"; //显示转办按钮 + //String showHandlForBtn = "false"; //显示意见征询按钮 + String showPrintBtn = "false"; //显示打印按钮 + String showNewflowBtn = "false"; //显示新建流程按钮 + String showNewMessageBtn = "false"; //显示新建短信按钮 + String showFormLogBtn = "false"; //显示表单日志按钮 + + boolean isread = false; + boolean canransmit = false; + //boolean cantakingOp = false; + //boolean canHandlFor = false; + boolean canprint = true; //打印是无论如何都会出现,不管有没有打印模板 + boolean cannewflow = false; + boolean cannewmessage = false; + boolean canseelog = false; + List result = new ArrayList(); + String currentType = getCurrentType(requestid); + + String[] otherInfos = null; + boolean isNeedBack = false; + if(otherInfo.startsWith("S")){ + String[] tempStr_tmp = Util.splitString(otherInfo, "+"); + otherInfos = Arrays.copyOfRange(tempStr_tmp,9,tempStr_tmp.length); + isNeedBack = isNeedBack(Arrays.copyOfRange(tempStr_tmp,1,8),Util.null2String(otherInfos[0])); + }else{ + otherInfos = Util.splitString(otherInfo, "+"); + } + String viewtype = Util.null2String(otherInfos[0]); + String isremark_tmp = Util.null2String(otherInfos[1]); + String isprocessed_tmp = Util.null2String(otherInfos[2]); + String nodeid_tmp = Util.null2String(otherInfos[3]); + String workflowid_tmp = Util.null2String(otherInfos[4]); + String scope = Util.null2String(otherInfos[5]); + String userid = Util.null2String(otherInfos[6]); + + String[] userInfos = Util.splitString(userInfo, "_"); + String userid_tmp = Util.null2String(userInfos[0]); + String usertype_tmp = Util.null2String(userInfos[1]); + + List belogtoids = new ArrayList<>(); + if (!"".equals(userid_tmp) && "0".equals(usertype_tmp)) { + HrmUserSettingComInfo userSetting = new HrmUserSettingComInfo(); + boolean belongtoshow = "1".equals(userSetting.getBelongtoshowByUserId(userid_tmp));//是否开启 + belogtoids.add(userid_tmp); + if (belongtoshow) { + User user = User.getUser(Util.getIntValue(userid_tmp), 0); + belogtoids.addAll(Util.splitString2List(user.getBelongtoids(), ",")); + } + } else { + belogtoids.add(userid_tmp); + } + + String haswfrm = "";//是否使用新建流程按钮 + String hassmsrm = "";//是否使用新建短信按钮 + //判断是否已读=========== + boolean isprocessed; + if ((isremark_tmp.equals("0") && !isprocessed_tmp.equals("1")) || isremark_tmp.equals("5")) { + isprocessed = true; + } else { + isprocessed = false; + } + if (viewtype.equals("0") || viewtype.equals("-1") || isNeedBack) {//未读和反馈流程都加上标记为已读按钮 + //if(isprocessed){ +// BDNew//新的 + isread = true; + //} + } + //其他按钮逻辑查询 + String isremarkForRM = ""; + int preisremark = -1; + RecordSet RecordSet = new RecordSet(); + RecordSet _rs = new RecordSet(); + int wfcurtid = 0; + int wfcurnodeid = 0; + int takisremark = -1; + int handleforwardid = -1; + String wfcurnodetype = ""; + _rs.executeQuery(com.api.workflow.util.ServiceUtil.calculateCurrentNodeSql(requestid+"", Util.getIntValue(userid_tmp), Util.getIntValue(usertype_tmp))); + //_rs.executeSql("select handleforwardid,takisremark,isremark,isreminded,preisremark,id,groupdetailid,nodeid,(CASE WHEN isremark=9 THEN 7.5 ELSE isremark END) orderisremark from workflow_currentoperator where requestid=" + requestid + " and userid in (" + CollectionUtil.list2String(belogtoids, ",") + ") and usertype=" + usertype_tmp + " order by orderisremark,id "); + while (_rs.next()) { + String isremark = Util.null2String(_rs.getString("isremark")); + wfcurtid = Util.getIntValue(Util.null2String(_rs.getString("id"))); + isremarkForRM = isremark; + preisremark = Util.getIntValue(_rs.getString("preisremark"), 0); + takisremark = Util.getIntValue(_rs.getString("takisremark"), 0); + handleforwardid = Util.getIntValue(_rs.getString("handleforwardid"), -1); + int tmpnodeid = Util.getIntValue(_rs.getString("nodeid")); + + /*if (isremark.equals("1") || isremark.equals("9")) { + wfcurnodeid = tmpnodeid; + WFLinkInfo wfLinkInfo = new WFLinkInfo(); + wfcurnodetype = wfLinkInfo.getNodeType(wfcurnodeid); + break; + }*/ + + if (isremark.equals("1") || isremark.equals("5") || isremark.equals("7") || isremark.equals("8") || isremark.equals("9") || (isremark.equals("0") && !wfcurnodetype.equals("3")) || isremark.equals("11")) { + wfcurnodeid = tmpnodeid; + WFLinkInfo wfLinkInfo = new WFLinkInfo(); + wfcurnodetype = wfLinkInfo.getNodeType(wfcurnodeid); + break; + } + + /* + if( isremark.equals("1")||isremark.equals("5") || isremark.equals("7")|| isremark.equals("9") ||(isremark.equals("0") && !currentType.equals("3")) ) { + wfcurnodeid=tmpnodeid; + WFLinkInfo wfLinkInfo = new WFLinkInfo(); + wfcurnodetype=wfLinkInfo.getNodeType(wfcurnodeid); + break; + } + if(isremark.equals("8")){ + break; + } + */ + } + _rs.executeSql("select * from workflow_requestbase where requestid=" + requestid); + while (_rs.next()) { + wfcurnodetype = Util.null2String(_rs.getString("currentnodetype")); + + } + + int extendnodeid = FreeNodeBiz.getExtendNodeId(Util.getIntValue(requestid), Util.getIntValue(nodeid_tmp)); + WFForwardManager wfmange = new WFForwardManager(); + wfmange.init(); + wfmange.setWorkflowid(Util.getIntValue(workflowid_tmp, 0)); + wfmange.setNodeid(extendnodeid); + wfmange.setRequestid(Util.getIntValue(requestid, 0)); + wfmange.setIsremark(isremark_tmp); + wfmange.setBeForwardid(wfcurtid); + wfmange.getWFNodeInfo(); + //转发============= + String IsPendingForward = Util.null2String(wfmange.getIsPendingForward());//允许代办事宜转发 + String IsBeForwardTodo = Util.null2String(wfmange.getIsBeForwardTodo()); + String IsBeForwardSubmitAlready = Util.null2String(wfmange.getIsBeForwardSubmitAlready()); + String IsBeForwardSubmitNotaries = Util.null2String(wfmange.getIsBeForwardSubmitNotaries()); + String IsFromWFRemark_T = Util.null2String(wfmange.getIsFromWFRemark()); + String IsBeForwardAlready = Util.null2String(wfmange.getIsBeForwardAlready()); // 已办转发 + String IsAlreadyForward = Util.null2String(wfmange.getIsAlreadyForward()); // 已办转发 + String IsSubmitForward = Util.null2String(wfmange.getIsSubmitForward()); // 归档转发 + String IsTakingOpinions = Util.null2String(wfmange.getIsTakingOpinions()); + String IsHandleForward = Util.null2String(wfmange.getIsHandleForward()); + String IsBeForward = Util.null2String(wfmange.getIsBeForward()); + String isformprint = Util.null2String(wfmange.getIsformprint()); + + + boolean canForwd = false; + if (isremark_tmp.equals("1") || isremark_tmp.equals("9")) { + if (("0".equals(IsFromWFRemark_T) && "1".equals(IsBeForwardTodo)) || "1".equals(IsFromWFRemark_T) && "1".equals(IsBeForwardAlready) || ("2".equals(IsFromWFRemark_T) && "1".equals(IsBeForward))) + canForwd = true; + if ((isremark_tmp.equals("1") && canForwd) || (isremark_tmp.equals("9") && IsPendingForward.equals("1"))) { + canransmit = true; + } + } + if (IsPendingForward.equals("1") && (!isremark_tmp.equals("2") && !isremark_tmp.equals("4")) && takisremark != -2) { + canransmit = true; + } + + if (IsAlreadyForward.equals("1") && takisremark == -2 && isremark_tmp.equals("0")) { + canransmit = true; + + } + if (!"3".equals(wfcurnodetype) && IsAlreadyForward.equals("1") && isremark_tmp.equals("2") && (preisremark == 0 || preisremark == 2 || preisremark == 4 || preisremark == 8 || preisremark == 9 || preisremark == 11 || (preisremark == 1 && takisremark == 2))) { + canransmit = true; + } + if ("3".equals(wfcurnodetype) && IsSubmitForward.equals("1") && (isremark_tmp.equals("2") || isremark_tmp.equals("4")) && (preisremark == 0 || preisremark == 2 || preisremark == 4 || preisremark == 8 || preisremark == 9 || (preisremark == 1 && takisremark == 2))) { + canransmit = true; + } + + /* if(IsTakingOpinions.equals("1") && isremark_tmp.equals("0")){ + cantakingOp = true; + } + if(IsHandleForward.equals("1") && isremark_tmp.equals("0")){ + canHandlFor = true; + } +*/ + if (handleforwardid < 0 && takisremark != 2 && preisremark == 1 && isremark_tmp.equals("2") && otherInfos.length > 5) {//是否是被转发 已办 + int Forwardid = 0; + + RecordSet.executeSql("select isremark,isreminded,preisremark,id,groupdetailid,nodeid from workflow_currentoperator where requestid=" + requestid + " and userid=" + userid_tmp + " and usertype=" + usertype_tmp + " order by isremark,id"); + while (RecordSet.next()) { + Forwardid = Util.getIntValue(RecordSet.getString("id")); + } + String wfSQL = "select * from workflow_Forward where requestid=" + requestid + " and BeForwardid=" + Forwardid; + RecordSet.executeSql(wfSQL); + if (RecordSet.next()) { + IsFromWFRemark_T = Util.null2String(RecordSet.getString("IsFromWFRemark")); //待办提交后被转发人是否可提交意见 +//IsSubmitedOpinion=Util.null2String(RecordSet.getString("IsSubmitedOpinion")); //待办提交后被转发人是否可提交意见 + IsBeForwardTodo = Util.null2String(RecordSet.getString("IsBeForwardTodo")); //待办可转发 + +//IsBeForwardSubmitAlready =Util.null2String(RecordSet.getString("IsBeForwardSubmitAlready")); //允许已办被转发人可提交意见 + + IsBeForwardAlready = Util.null2String(RecordSet.getString("IsBeForwardAlready")); //已办被转发人可转发 + +//IsBeForwardSubmitNotaries =Util.null2String(RecordSet.getString("IsBeForwardSubmitNotaries")); //允许办结被转发人可提交意见 + + IsBeForward = Util.null2String(RecordSet.getString("IsBeForward")); //办结被转发人是否可转发 + + } + if (("0".equals(IsFromWFRemark_T) && "1".equals(IsBeForwardTodo)) || "1".equals(IsFromWFRemark_T) && "1".equals(IsBeForwardAlready) || ("2".equals(IsFromWFRemark_T) && "1".equals(IsBeForward))) + canForwd = true; + if ((preisremark == 1 && canForwd)) { + canransmit = true; + } + } + /* + * 转发功能补充,前面逻辑不改动,增加查看已办,办结事宜时,分页控件是否显示转发按钮 + */ + if (preisremark != 1 && !isremark_tmp.equals("1") && !isremark_tmp.equals("2") && otherInfos.length > 5) { + String IsAreadyForward = Util.null2String(wfmange.getIsAlreadyForward());//允许已办事宜转发 + //String IsSubmitForward=Util.null2String(wfmange.getIsSubmitForward());//允许办结事宜转发 + /* if(scope.equals("doing")&&IsTakingOpinions.equals("1")){ + cantakingOp = true; + }else{ + cantakingOp = false; + } + if(scope.equals("doing")&&IsHandleForward.equals("1")){ + canHandlFor = true; + }else{ + canHandlFor = false; + }*/ + if ((scope.equals("done") && IsAreadyForward.equals("1") && !"3".equals(wfcurnodetype)) + || IsSubmitForward.equals("1") && "3".equals(wfcurnodetype) + || (scope.equals("doing") && IsPendingForward.equals("1")) || canForwd || ("mine".equals(scope) && canransmit)) { + canransmit = true; + } else { + canransmit = false; + } + } + + + if (handleforwardid < 0 && takisremark != 2 && isremark_tmp.equals("1") && otherInfos.length > 5) {//是否是被转发 + //IsBeForwardTodo //待办被转发人可转发 + //IsBeForwardAlready //已办被转发人可转发 + //IsBeForward //是否允许已办及办结事宜转发 + /*if(scope.equals("doing")&&IsTakingOpinions.equals("1")){ + cantakingOp = true; + }else{ + cantakingOp = false; + } + if(scope.equals("doing")&&IsHandleForward.equals("1")){ + canHandlFor = true; + }else{ + canHandlFor = false; + }*/ + if (canForwd) { + canransmit = true; + } else { + canransmit = false; + } + } + //============== + //新建流程、新建短信========== + String sqlselectName = "select * from workflow_nodecustomrcmenu where wfid=" + workflowid_tmp + " and nodeid=" + nodeid_tmp; + if (isremark_tmp.equals("0")) { + RecordSet.executeSql("select nodeid from workflow_currentoperator c where c.requestid=" + requestid + " and c.userid in(" + userid_tmp + ") and c.usertype=" + usertype_tmp + " and c.isremark='" + isremark_tmp + "' "); + String tmpnodeid = ""; + if (RecordSet.next()) { + tmpnodeid = Util.null2String(RecordSet.getString("nodeid")); + } + sqlselectName = "select * from workflow_nodecustomrcmenu where wfid=" + workflowid_tmp + " and nodeid=" + tmpnodeid; + + if (!"".equals(tmpnodeid)) { + RecordSet.executeSql(sqlselectName); + if (RecordSet.next()) { + haswfrm = Util.null2String(RecordSet.getString("haswfrm")); + hassmsrm = Util.null2String(RecordSet.getString("hassmsrm")); + } + } + } + + //是否拥有新建流程功能 + if ("1".equals(haswfrm)) { + RequestCheckUser rcu = new RequestCheckUser(); + rcu.setUserid(Util.getIntValue(userid_tmp, 0)); + rcu.setWorkflowid(Util.getIntValue(workflowid_tmp)); + rcu.setLogintype(usertype_tmp); + try { + rcu.checkUser(); + int t_hasright = rcu.getHasright(); + if (t_hasright == 1) { + cannewflow = true; + } + } catch (Exception e) { + cannewflow = false; + } + } + //是否拥有发短信按钮 + RTXConfig rtxconfig = new RTXConfig(); + String temV = rtxconfig.getPorp(rtxconfig.CUR_SMS_SERVER_IS_VALID); + boolean valid = false; + if (temV != null && temV.equalsIgnoreCase("true")) { + valid = true; + } else { + valid = false; + } + User user = getUser(Util.getIntValue(userid_tmp, 0)); + if (valid == true && "1".equals(hassmsrm) && HrmUserVarify.checkUserRight("CreateSMS:View", user)) { + cannewmessage = true; + } + + //表单日志 + String isModifyLog = ""; + RecordSet.executeSql("select t1.isShowModifyLog,t2.currentstatus from workflow_base t1, workflow_requestbase t2 where t1.id=t2.workflowid and t2.requestid=" + requestid); + if (RecordSet.next()) { + isModifyLog = RecordSet.getString("isShowModifyLog"); + } + if ("1".equals(isModifyLog)) { + canseelog = true; + } + if (ru.getOfsSetting().getIsuse() == 1 && Util.getIntValue(requestid) < 0) { + canransmit = false; + canprint = false; + cannewflow = false; + cannewmessage = false; + canseelog = false; + } + //System.out.println("--534-canHandlFor---"+canHandlFor); + //System.out.println("--534-cantakingOp---"+cantakingOp); + if (isread) //标记为已读 + showMarkReadBtn = "true"; + if (canransmit) //转发 + showRansmitBtn = "true"; + if (canprint) //打印 + showPrintBtn = "true"; + if (cannewflow)//新建流程 + showNewflowBtn = "false"; + if (cannewmessage)//新建短信 + showNewMessageBtn = "false"; + if (canseelog) //表单日志 + showFormLogBtn = "true"; + + /*if (Util.getIntValue(requestid) < 0) { + showMarkReadBtn = "false"; + }*/ + + if (!"1".equals(isformprint)) { + showPrintBtn = "false"; + } + + result.add(showMarkReadBtn); + result.add(showRansmitBtn); + result.add(showPrintBtn); + result.add(showNewflowBtn); + result.add(showNewMessageBtn); + result.add(showFormLogBtn); + + //增加督办菜单的权限 + result.addAll(RequestListBiz.getSuperviseBtns(userid, requestid, scope)); + + String showAttentionBtn = new RequestAttentionBiz().showAttention(scope) ? "true" : "false"; + result.add(showAttentionBtn); + + return result; + } + + + /** + * 代理流程收回菜单判断 + * add by lsj @2014-1-22 + * + * @param + * @param + * @return + */ + public List getWFAgentBackOperation(String agentid, String outparaminfo) { + List res = new ArrayList(); + String[] params = outparaminfo.split("_"); + String userid = params[0]; + String agentinfo = params[1]; + if ("0".equals(agentinfo)) { + res.add("true"); + + } else if ("1".equals(agentinfo)) { + User user = getUser(Util.getIntValue(userid, 0)); + boolean hasRights = HrmUserVarify.checkUserRight("WorkflowAgent:All", user); + res.add(hasRights + ""); + } + return res; + } + + /** + * 得到当前节点的类型 + * + * @param requestid + * @return 当前节点的类型 + */ + public String getCurrentType(String requestid) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + rs.executeSql("SELECT * FROM workflow_Requestbase WHERE requestid = '" + requestid + "'"); + if (rs.next()) { + returnStr = rs.getString("currentnodetype"); + } + return returnStr; + } + + /** + * 代理流程收回check判断是否显示 + * add by lsj @2014-1-22 + * + * @param + * @param + * @return + */ + public String getWFAgentBackOperationCheckBox(String outparaminfo) { + String rs = "false"; + String[] params = outparaminfo.split("_"); + String userid = params[0]; + String agentinfo = params[1]; + if ("0".equals(agentinfo)) { + rs = "true"; + + } else if ("1".equals(agentinfo)) { + User user = getUser(Integer.parseInt(userid)); + boolean hasRights = HrmUserVarify.checkUserRight("WorkflowAgent:All", user); + rs = hasRights + ""; + } + return rs; + } + + /** + * 督办标记已读 + * + * @param requestname 流程标题 + * @param para2 流程ID+,+显示类型+,+用户语言 + * @return "true" or "false" + */ + public List getWfUrgerNewOperation(String requestname, String para2) { + RecordSet rs = new RecordSet(); + List rsdata = new ArrayList(); + String[] tempStr = Util.splitString(para2, "+"); + int requestid = Util.getIntValue(Util.null2String(tempStr[0])); + int userid = Util.getIntValue(Util.null2String(tempStr[2]), 0); + int usertype = Util.getIntValue(Util.null2String(tempStr[3]), 0); + String isnew = "false"; + + String newsql = "select b.lastoperatedate,b.lastoperatetime,b.creater,b.lastoperator, b.lastoperatortype from workflow_requestbase b where b.requestid = " + + requestid; + String requestdate = ""; + String viewdate = ""; + rs.execute(newsql); + if (rs.next()) { + if (userid != rs.getInt(4) || usertype != rs.getInt(5)) { + if ("".equals(Util.null2String(rs.getString(1))) || "".equals(Util.null2String(rs.getString(2)))) { + if (rs.getInt(3) != userid) { + newsql = "select w.viewdate from workflow_requestviewlog w where w.viewer=" + + userid + " and id=" + requestid; + rs.execute(newsql); + if (!rs.next()) { + isnew = "true"; + } + } + } else { + requestdate = rs.getString(1) + rs.getString(2); + newsql = "select max(w.viewdate) as viewdate,max(w.viewtime) as viewtime from workflow_requestviewlog w where w.viewer=" + + userid + " and id=" + requestid + " group by id"; + rs.execute(newsql); + if (rs.next()) { + viewdate = rs.getString(1) + rs.getString(2); + if (viewdate.compareTo(requestdate) < 0) { + isnew = "true"; + } + } else { + isnew = "true"; + } + } + } + } + rsdata.add(isnew); + return rsdata; + } + + /** + * 督办标记已读(checkbox) + * + * @param + * @param para2 流程ID+,+显示类型+,+用户语言 + * @return "true" or "false" + */ + public String getWfUrgerNewOperationCheckBox(String para2) { + RecordSet rs = new RecordSet(); + String[] tempStr = Util.splitString(para2, "+"); + int requestid = Util.getIntValue(Util.null2String(tempStr[0])); + int userid = Util.getIntValue(Util.null2String(tempStr[2]), 0); + int usertype = Util.getIntValue(Util.null2String(tempStr[3]), 0); + String isnew = "false"; + + String newsql = "select b.lastoperatedate,b.lastoperatetime,b.creater,b.lastoperator, b.lastoperatortype from workflow_requestbase b where b.requestid = " + + requestid; + String requestdate = ""; + String viewdate = ""; + rs.execute(newsql); + if (rs.next()) { + if (userid != rs.getInt(4) || usertype != rs.getInt(5)) { + if ("".equals(Util.null2String(rs.getString(1))) || "".equals(Util.null2String(rs.getString(2)))) { + if (rs.getInt(3) != userid) { + newsql = "select w.viewdate from workflow_requestviewlog w where w.viewer=" + + userid + " and id=" + requestid; + rs.execute(newsql); + if (!rs.next()) { + isnew = "true"; + } + } + } else { + requestdate = rs.getString(1) + rs.getString(2); + newsql = "select max(w.viewdate) as viewdate,max(w.viewtime) as viewtime from workflow_requestviewlog w where w.viewer=" + + userid + " and id=" + requestid + " group by id"; + rs.execute(newsql); + if (rs.next()) { + viewdate = rs.getString(1) + rs.getString(2); + if (viewdate.compareTo(requestdate) < 0) { + isnew = "true"; + } + } else { + isnew = "true"; + } + } + } + } + return isnew; + } + + + private User getUser(int userid) { + User user = new User(); + try { + ResourceComInfo rc = new ResourceComInfo(); + DepartmentComInfo dc = new DepartmentComInfo(); + + user.setUid(userid); + user.setLoginid(rc.getLoginID("" + userid)); + user.setFirstname(rc.getFirstname("" + userid)); + user.setLastname(rc.getLastname("" + userid)); + user.setLogintype("1"); + // user.setAliasname(rc.getAssistantID(""+userid)); + // user.setTitle(rs.getString("title")); + // user.setTitlelocation(rc.getLocationid(""+userid)); + user.setSex(rc.getSexs("" + userid)); + user.setLanguage(7); + // user.setTelephone(rc); + // user.setMobile(rc.getm); + // user.setMobilecall(rs.getString("mobilecall")); + user.setEmail(rc.getEmail("" + userid)); + // user.setCountryid(); + user.setLocationid(rc.getLocationid("" + userid)); + user.setResourcetype(rc.getResourcetype("" + userid)); + // user.setStartdate(rc.gets); + // user.setEnddate(rc.gete); + // user.setContractdate(rc.getc); + user.setJobtitle(rc.getJobTitle("" + userid)); + // user.setJobgroup(rs.getString("jobgroup")); + // user.setJobactivity(rs.getString("jobactivity")); + user.setJoblevel(rc.getJoblevel("" + userid)); + user.setSeclevel(rc.getSeclevel("" + userid)); + user.setUserDepartment(Util.getIntValue(rc.getDepartmentID("" + userid), 0)); + user.setUserSubCompany1(Util.getIntValue(dc.getSubcompanyid1(user.getUserDepartment() + ""), 0)); + // user.setUserSubCompany2(Util.getIntValue(rs.getString("subcompanyid2"),0)); + // user.setUserSubCompany3(Util.getIntValue(rs.getString("subcompanyid3"),0)); + // user.setUserSubCompany4(Util.getIntValue(rs.getString("subcompanyid4"),0)); + user.setManagerid(rc.getManagerID("" + userid)); + user.setAssistantid(rc.getAssistantID("" + userid)); + // user.setPurchaselimit(rc.getPropValue(""+userid)); + // user.setCurrencyid(rc.getc); + // user.setLastlogindate(rc.get); + } catch (Exception e) { + e.printStackTrace(); + } + return user; + } + + /** + * 判断当前请求当前节点是否有必填项没有填写 + * + * @param requestid + * @return + */ + public boolean haveMustInput(int requestid) { + boolean flag = false; + String sql = "select currentnodeid,workflowid from workflow_requestbase where requestid=" + requestid; + ////System.out.println("查询当前流程节点:"+sql); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + rs.executeSql(sql); + if (rs.next()) { + int nodeid = rs.getInt(1); + int workflowid = rs.getInt(2); + sql = "select ismode,showdes,printdes,toexcel from workflow_flownode where workflowid=" + workflowid + " and nodeid=" + nodeid; + //System.out.println("查询当前流程模式:"+sql); + rs.executeSql(sql); + if (rs.next()) { + String ismode = Util.null2String(rs.getString("ismode")); + int showdes = Util.getIntValue(Util.null2String(rs.getString("showdes")), 0); + int modeid = 0; + int isbill = 0; + int formid = 0; + String sqlwhere = ""; + String viewtablename = "workflow_nodeform"; + sql = "select formid,isbill from workflow_base where id=" + workflowid; + //System.out.println("查询当前流程formid:"+sql); + rs.executeSql(sql); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + } + if (ismode.equals("1") && showdes != 1) { + sql = "select id from workflow_nodemode where isprint='0' and workflowid=" + workflowid + " and nodeid=" + nodeid; + rs.executeSql(sql); + if (rs.next()) { + modeid = rs.getInt("id"); + } else { + sql = "select id from workflow_formmode where isprint='0' and formid=" + formid + " and isbill=" + isbill; + rs.executeSql(sql); + if (rs.next()) { + modeid = rs.getInt("id"); + } + } + } + //模板模式 + if (modeid > 0) { + viewtablename = "workflow_modeview"; + } + //System.out.println("formid:"+formid+",isbill="+isbill); + //表单 + if (isbill == 0) { + //主字段 + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_formdict ff where nf.fieldid=ff.id and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 "; + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = rs.getString(1) + " is null"; + else + sqlwhere += " or " + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere = rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0"; + } else + sqlwhere = rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0"; + } else { + sqlwhere = rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere += " or (" + rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0)"; + } else + sqlwhere += " or (" + rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0)"; + } else { + sqlwhere += " or " + rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select requestid from workflow_form where requestid=" + requestid + " and (" + sqlwhere + ")"; + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + //明细字段 + sqlwhere = ""; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_formdictdetail ff where nf.fieldid=ff.id and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 "; + //System.out.println("查询明细字段"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = rs.getString(1) + " is null"; + else + sqlwhere += " or " + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere = rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0"; + } else + sqlwhere = rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0"; + } else { + sqlwhere = rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere += " or (" + rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0)"; + } else + sqlwhere += " or (" + rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0)"; + } else { + sqlwhere += " or " + rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select requestid from workflow_formdetail where requestid=" + requestid + " and (" + sqlwhere + ")"; + //System.out.println("284查询是否可以进行批量提交"+sql); + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + } else if (isbill == 1) { //单据 + //主字段 + String maintablename = ""; + String detailkey = ""; + sql = "select tablename,detailkeyfield from workflow_bill where id=" + formid; + //System.out.println("295:"+sql); + rs.executeSql(sql); + if (rs.next()) { + maintablename = rs.getString(1); + detailkey = Util.null2String(rs.getString(2)); + } + if (detailkey.equals("")) detailkey = "mainid"; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_billfield ff where (ff.viewtype is null or ff.viewtype=0) and nf.fieldid=ff.id and ff.billid=" + formid + " and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 "; + //System.out.println("303:"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = rs.getString(1) + " is null"; + else + sqlwhere += " or " + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere = rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0"; + } else + sqlwhere = rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0"; + } else { + sqlwhere = rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere += " or (" + rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0)"; + } else + sqlwhere += " or (" + rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0)"; + } else { + sqlwhere += " or " + rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select requestid from " + maintablename + " where requestid=" + requestid + " and (" + sqlwhere + ")"; + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + //明细字段 + sql = "select tablename from workflow_billdetailtable where billid=" + formid; + //System.out.println("336:"+sql); + rs1.executeSql(sql); + while (rs1.next()) { + String detailtablename = rs1.getString(1); + sqlwhere = ""; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_billfield ff where ff.viewtype=1 and nf.fieldid=ff.id and ff.billid=" + formid + " and ff.detailtable='" + detailtablename + "' and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 order by ff.detailtable "; + //System.out.println("342:"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = detailtablename + "." + rs.getString(1) + " is null"; + else + sqlwhere += " or " + detailtablename + "." + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + detailtablename + "." + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + String _t = " " + detailtablename + "." + rs.getString(1) + " "; + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere = _t + " is null or getlength(" + _t + ") = 0"; + } else + sqlwhere = _t + " is null or dbms_lob.getlength(" + _t + ") = 0"; + } else { + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere += " or (" + _t + " is null or getlength(" + _t + ") = 0)"; + } else + sqlwhere += " or (" + _t + " is null or dbms_lob.getlength(" + _t + ") = 0)"; + } else { + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select " + maintablename + ".requestid from " + maintablename + "," + detailtablename + " where " + maintablename + ".id=" + detailtablename + "." + detailkey + " and " + maintablename + ".requestid=" + requestid + " and (" + sqlwhere + ")"; + //System.out.println("366:"+sql); + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + } + if (rs1.getCounts() < 1) { + sql = "select detailtablename from workflow_bill where id=" + formid; + //////System.out.println("375:"+sql); + rs.executeSql(sql); + if (rs.next()) { + String detailtablename = rs.getString(1); + sqlwhere = ""; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf , workflow_billfield ff where ff.viewtype=1 and nf.fieldid=ff.id and ff.billid=" + formid + " and ff.detailtable='" + detailtablename + "' and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 order by ff.detailtable "; + //System.out.println("380:"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = detailtablename + "." + rs.getString(1) + " is null"; + else + sqlwhere += " or " + detailtablename + "." + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + detailtablename + "." + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + String _t = " " + detailtablename + "." + rs.getString(1) + " "; + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere = _t + " is null or getlength(" + _t + ") = 0"; + } else + sqlwhere = _t + " is null or dbms_lob.getlength(" + _t + ") = 0"; + } else { + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere += " or (" + _t + " is null or getlength(" + _t + ") = 0)"; + } else + sqlwhere += " or (" + _t + " is null or dbms_lob.getlength(" + _t + ") = 0)"; + } else { + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select " + maintablename + ".requestid from " + maintablename + "," + detailtablename + " where " + maintablename + ".id=" + detailtablename + "." + detailkey + " and " + maintablename + ".requestid=" + requestid + " and (" + sqlwhere + ")"; + //System.out.println("400查询是否可以进行批量提交"+sql); + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + } + } + } + } + } + return flag; + } + + /** + * 重写,加上当前节点id + * 判断当前请求当前节点是否有必填项没有填写 + * + * @param requestid + * @param nodeid + * @return + */ + public boolean haveMustInput(int requestid, int nodeid) { + boolean flag = false; + String sql = "select currentnodeid,workflowid from workflow_requestbase where requestid=" + requestid; + ////System.out.println("查询当前流程节点:"+sql); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + rs.executeSql(sql); + if (rs.next()) { + //int nodeid = rs.getInt(1); + int workflowid = rs.getInt(2); + sql = "select ismode,showdes,printdes,toexcel from workflow_flownode where workflowid=" + workflowid + " and nodeid=" + nodeid; + //System.out.println("查询当前流程模式:"+sql); + rs.executeSql(sql); + if (rs.next()) { + String ismode = Util.null2String(rs.getString("ismode")); + int showdes = Util.getIntValue(Util.null2String(rs.getString("showdes")), 0); + int modeid = 0; + int isbill = 0; + int formid = 0; + String sqlwhere = ""; + String viewtablename = "workflow_nodeform"; + sql = "select formid,isbill from workflow_base where id=" + workflowid; + //System.out.println("查询当前流程formid:"+sql); + rs.executeSql(sql); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + } + if (ismode.equals("1") && showdes != 1) { + sql = "select id from workflow_nodemode where isprint='0' and workflowid=" + workflowid + " and nodeid=" + nodeid; + rs.executeSql(sql); + if (rs.next()) { + modeid = rs.getInt("id"); + } else { + sql = "select id from workflow_formmode where isprint='0' and formid=" + formid + " and isbill=" + isbill; + rs.executeSql(sql); + if (rs.next()) { + modeid = rs.getInt("id"); + } + } + } + //模板模式 + if (modeid > 0) { + viewtablename = "workflow_modeview"; + } + //System.out.println("formid:"+formid+",isbill="+isbill); + //表单 + if (isbill == 0) { + //主字段 + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_formdict ff where nf.fieldid=ff.id and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 "; + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = rs.getString(1) + " is null"; + else + sqlwhere += " or " + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere = rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0"; + } else + sqlwhere = rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0"; + } else { + sqlwhere = rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere += " or (" + rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0)"; + + } else + + sqlwhere += " or (" + rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0)"; + } else { + sqlwhere += " or " + rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select requestid from workflow_form where requestid=" + requestid + " and (" + sqlwhere + ")"; + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + //明细字段 + sqlwhere = ""; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_formdictdetail ff where nf.fieldid=ff.id and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 "; + //System.out.println("查询明细字段"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = rs.getString(1) + " is null"; + else + sqlwhere += " or " + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())) { + sqlwhere = rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0"; + } else + sqlwhere = rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0"; + } else { + sqlwhere = rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){ + sqlwhere += " or (" + rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0)"; + }else + + sqlwhere += " or (" + rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0)"; + } else { + sqlwhere += " or " + rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select requestid from workflow_formdetail where requestid=" + requestid + " and (" + sqlwhere + ")"; + //System.out.println("284查询是否可以进行批量提交"+sql); + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + } else if (isbill == 1) { //单据 + //主字段 + String maintablename = ""; + String detailkey = ""; + sql = "select tablename,detailkeyfield from workflow_bill where id=" + formid; + //System.out.println("295:"+sql); + rs.executeSql(sql); + if (rs.next()) { + maintablename = rs.getString(1); + detailkey = Util.null2String(rs.getString(2)); + } + if (detailkey.equals("")) detailkey = "mainid"; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_billfield ff where (ff.viewtype is null or ff.viewtype=0) and nf.fieldid=ff.id and ff.billid=" + formid + " and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 "; + //System.out.println("303:"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + if (sqlwhere.equals("")) + sqlwhere = rs.getString(1) + " is null"; + else + sqlwhere += " or " + rs.getString(1) + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){ + sqlwhere = rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0"; + }else + sqlwhere = rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0"; + } else { + sqlwhere = rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){ + sqlwhere += " or (" + rs.getString(1) + " is null or getlength(" + rs.getString(1) + ") = 0)"; + }else + + sqlwhere += " or (" + rs.getString(1) + " is null or dbms_lob.getlength(" + rs.getString(1) + ") = 0)"; + } else { + sqlwhere += " or " + rs.getString(1) + " is null or " + rs.getString(1) + "='' or " + rs.getString(1) + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select requestid from " + maintablename + " where requestid=" + requestid + " and (" + sqlwhere + ")"; + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + //明细字段 + sql = "select tablename from workflow_billdetailtable where billid=" + formid; + //System.out.println("336:"+sql); + rs1.executeSql(sql); + while (rs1.next()) { + String detailtablename = rs1.getString(1); + sqlwhere = ""; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf ,workflow_billfield ff where ff.viewtype=1 and nf.fieldid=ff.id and ff.billid=" + formid + " and ff.detailtable='" + detailtablename + "' and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 order by ff.detailtable "; + //System.out.println("342:"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + String _t = " " + detailtablename + "." + rs.getString(1) + " "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null"; + else + sqlwhere += " or " + _t + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + detailtablename + "." + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + String _t = " " + detailtablename + "." + rs.getString(1) + " "; + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){ + sqlwhere = _t + " is null or getlength(" + _t + ") = 0"; + }else + sqlwhere = _t + " is null or dbms_lob.getlength(" + _t + ") = 0"; + } else { + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){ + sqlwhere += " or (" + _t + " is null or getlength(" + _t + ") = 0)"; + }else + sqlwhere += " or (" + _t + " is null or dbms_lob.getlength(" + _t + ") = 0)"; + } else { + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select " + maintablename + ".requestid from " + maintablename + "," + detailtablename + " where " + maintablename + ".id=" + detailtablename + "." + detailkey + " and " + maintablename + ".requestid=" + requestid + " and (" + sqlwhere + ")"; + //System.out.println("366:"+sql); + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + } + if (rs1.getCounts() < 1) { + sql = "select detailtablename from workflow_bill where id=" + formid; + //////System.out.println("375:"+sql); + rs.executeSql(sql); + if (rs.next()) { + String detailtablename = rs.getString(1); + sqlwhere = ""; + sql = "select ff.fieldname,ff.fielddbtype from " + viewtablename + " nf , workflow_billfield ff where ff.viewtype=1 and nf.fieldid=ff.id and ff.billid=" + formid + " and ff.detailtable='" + detailtablename + "' and nf.nodeid=" + nodeid + " and nf.ismandatory='1' and nf.fieldid>0 order by ff.detailtable "; + //System.out.println("380:"+sql); + rs.executeSql(sql); + while (rs.next()) { + String fielddbtype = Util.null2String(rs.getString(2)); + if (fielddbtype.toLowerCase().indexOf("int") > -1 || fielddbtype.toLowerCase().indexOf("float") > -1 || fielddbtype.toLowerCase().indexOf("number") > -1 || fielddbtype.toLowerCase().indexOf("decimal") > -1) { + String _t = " " + detailtablename + "." + rs.getString(1) + " "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null"; + else + sqlwhere += " or " + _t + " is null"; + } else { + if (rs.getDBType().equals("sqlserver")) { + String _t = " convert(varchar," + detailtablename + "." + rs.getString(1) + ") "; + if (sqlwhere.equals("")) + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + else + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } else { + String _t = " " + detailtablename + "." + rs.getString(1) + " "; + if (sqlwhere.equals("")) { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){ + sqlwhere = _t + " is null or getlength(" + _t + ") = 0"; + }else + sqlwhere = _t + " is null or dbms_lob.getlength(" + _t + ") = 0"; + } else { + sqlwhere = _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } else { + if (fielddbtype.toLowerCase().indexOf("clob") > -1) { + if ("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){ + sqlwhere += " or (" + _t + " is null or getlength(" + _t + ") = 0)"; + + }else + + sqlwhere += " or (" + _t + " is null or dbms_lob.getlength(" + _t + ") = 0)"; + } else { + sqlwhere += " or " + _t + " is null or " + _t + "='' or " + _t + "=' '"; + } + } + } + } + } + if (!sqlwhere.equals("")) { + sql = "select " + maintablename + ".requestid from " + maintablename + "," + detailtablename + " where " + maintablename + ".id=" + detailtablename + "." + detailkey + " and " + maintablename + ".requestid=" + requestid + " and (" + sqlwhere + ")"; + //System.out.println("400查询是否可以进行批量提交"+sql); + rs.executeSql(sql); + if (rs.next()) { + return true; + } + } + } + } + } + } + } + return flag; + } + + /** + * 是否可以进行批量提交处理(EXT) + * + * @param workflowid 流程ID + * @param isremark + * @return true/false + */ + public String getCanMultiSubmitExt(String workflowid, String isremark, String requestid) { + String flag = "false"; + if (isremark.equals("0")) { + if ("1".equals(wf.getMultiSubmit(workflowid))) flag = "true"; + if (flag.equals("true") && haveMustInput(Util.getIntValue(requestid))) { + flag = "false"; + } + } + return flag; + } + + /** + * 流程标题显示样式 + * + * @param requestname 流程标题 + * @param requestid 请求id + * @return 流程标题显示样式 + */ + public String getWfOnlyNewLink(String requestname, String requestid) { + return "" + requestname + ""; + } + + /** + * 流程标题显示样式。只查看,不跳转到编辑页面 + * + * @param requestname 流程标题 + * @param requestid 请求id + * @return 流程标题显示样式 + */ + public String getWfOnlyViewLink(String requestname, String requestid) { + return "" + requestname + ""; + } + + /** + * 流程标题显示样式(是否加图片等) + * + * @param requestname 流程标题 + * @param para2 流程ID+,+显示类型+,+是否超时 + * @return 流程标题显示样式 + */ + public String getWfNewLink(String requestname, String para2) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + int isbill = 0; + int formid = 0; + ////根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + + boolean isprocessed = false; + rs.executeSql("select isprocessed from workflow_currentoperator where ((isremark='0' and (isprocessed='0' or isprocessed='3' or isprocessed='2')) or isremark='5') and requestid = " + requestid); + if (rs.next()) { + isprocessed = true; + } + if(isovertime == -8){//批量打印进来的 + isovertime = 0; + isprocessed = false; + } + if (viewtype.equals("0")) { + //新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + requestname + ""; + } else { + returnStr = "" + requestname + ""; + } + } else if (viewtype.equals("-1")) { + //旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + requestname + ""; + } else { + returnStr = "" + requestname + ""; + } + } else { + //旧流程,普通链接 + if (isprocessed) { + returnStr = "" + requestname + ""; + } else { + returnStr = "" + requestname + ""; + } + } + return returnStr; + } + + /** + * 流程标题显示样式(是否加图片等),区分颜色 + * + * @param requestname 流程标题 + * @param para2 请求ID + 流程ID + 显示类型 + 是否超时 + 用户语言 + 节点ID currentnodeid + 操作人类性isremark+用户id userID+ 代理人/被代理人ID + 代理/被代理类型 + * @return 流程标题显示样式 + */ + public String getWfNewLinkWithTitle(String requestname, String para2) { + return this.getWfNewLinkWithTitle(requestname, para2, true); + } + + public String getWfNewLinkWithTitle_AttentionTag(String requestname, String para2) { + return this.getWfNewLinkWithTitle_AttentionTag(requestname, para2, true, true); + } + + public String getWfNewLinkWithTitle(String requestname, String para2, boolean needFormat) { + return this.getWfNewLinkWithTitle(requestname, para2, needFormat, ""); + } + + public String getWfNewLinkWithTitle_AttentionTag(String requestname, String para2, boolean needFormat) { + return this.getWfNewLinkWithTitle(requestname, para2, needFormat, "", true); + } + + public String getWfNewLinkWithTitle_AttentionTag(String requestname, String para2, boolean needFormat, boolean showAttentionTag) { + return this.getWfNewLinkWithTitle(requestname, para2, needFormat, "", showAttentionTag); + } + + public String getWfNewLinkWithTitle(String requestname, String para2, boolean needFormat, String urlParams) { + return getWfNewLinkWithTitle(requestname, para2, needFormat, urlParams, false); + } + + /** + * 增加urlParams作为一些特殊场景自动携带一些参数:比如默认携带监控参数,主要用在后台的权限转移,其他入口进来urlParams默认是空 luosy 2019/1/17 + * + * @param requestname + * @param para2 + * @param needFormat + * @param urlParams + * @return + */ + public String getWfNewLinkWithTitle(String requestname, String para2, boolean needFormat, String urlParams, boolean showAttentionTag) { + String[] tempStr = null; + boolean isNeedBack = false; + if (para2.startsWith("S")) { + String[] tempStr_tmp = Util.splitString(para2, "+"); + tempStr = Arrays.copyOfRange(tempStr_tmp, 9, tempStr_tmp.length); + isNeedBack = isNeedBack(Arrays.copyOfRange(tempStr_tmp, 1, 8), Util.null2String(tempStr[2])); + } else { + tempStr = Util.splitString(para2, "+"); + } + RecordSet rs = new RecordSet(); + String returnStr = ""; + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + String agentorbyagentid = ""; + String agenttype = ""; + String workflowtype = ""; + + if (tempStr.length >= 10) { + agenttype = Util.null2String(tempStr[9]); + } + String paramstr = ""; + if (tempStr.length >= 13 && Util.getIntValue(requestid) < 0) { + String _userid = Util.null2String(tempStr[11]); + String myrequest = Util.null2String(tempStr[12]); + String creater = Util.null2String(tempStr[13]); + String syscode = Util.null2String(tempStr[14]); + workflowtype = Util.null2String(tempStr[15]); + } + paramstr = "&_workflowid=" + workflowid + "&_workflowtype=" + workflowtype;//方便异构系统使用 + String nodetitle = ""; + if (needFormat) { + int isbill = 0; + int formid = 0; + // //根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + } + + int autoReloadWfListTime = RequestListBiz.getAutoReloadWfListTime(requestid,"0"); + boolean isprocessed = false; + boolean canContinue = false; + //新增是否显示[退回][代理]前缀显示 + boolean hasAgentTip = false; + boolean hasRejectTip = false; + rs.executeSql("select isprocessed, isremark, userid, nodeid,islasttimes,agenttype,isbereject,takisremark from workflow_currentoperator where requestid = " + + requestid + + " and userid=" + userID + + " order by receivedate desc, receivetime desc"); + while (rs.next()) { + String isbereject = Util.null2String(rs.getString("isbereject")); + String islasttimes = Util.null2String(rs.getString("islasttimes")); + String takisremark = Util.null2String(rs.getString("takisremark")); + String agenttype1 = Util.null2String(rs.getString("agenttype")); + String isremark_tmp = Util.null2String(rs.getString("isremark")); + String isprocessed_tmp = Util.null2String(rs.getString("isprocessed")); + String userid_tmp = Util.null2String(rs.getString("userid")); + if ((isremark_tmp.equals("0") && (isprocessed_tmp.equals("0") || isprocessed_tmp.equals("3") || isprocessed_tmp.equals("2"))) + || isremark_tmp.equals("5")) { + isprocessed = true; + } + //判断是否显示【退回】【代理】标识 + if ("1".equals(islasttimes) && "2".equals(agenttype1) && (("0".equals(isremark) && !"-2".equals(takisremark)) || "1".equals(isremark) || "7".equals(isremark) || "8".equals(isremark) || "9".equals(isremark) || "11".equals(isremark))) { + hasAgentTip = true; + } + if ("1".equals(islasttimes) && "1".equals(isbereject) && ("0".equals(isremark) && !"-2".equals(takisremark))) { + hasRejectTip = true; + } + // 如果是被抄送或转发,判断是否正是某节点的操作人,取最后一次 + if (("8".equals(isremark) || "9".equals(isremark) || "1" + .equals(isremark)) + && userID.equals(userid_tmp) + && "0".equals(isremark_tmp) + && canContinue == false) { + int nodeid_tmp = Util.getIntValue(rs.getString("nodeid"), 0); + if (nodeid_tmp != 0) { + isremark = isremark_tmp; + nodeid = "" + nodeid_tmp; + canContinue = true; + } + } + if (isprocessed == true && canContinue == true) { + break; + } + } + // 改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs + .executeSql("select nodetitle from workflow_flownode where workflowid=" + + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + if (hasAgentTip) { + requestname = SystemEnv.getHtmlLabelName(390272, userlang) + requestname; + } + if (hasRejectTip) { + requestname = SystemEnv.getHtmlLabelName(390271, userlang) + requestname; + } + + String attentionTag = ""; + if (showAttentionTag) + attentionTag = new RequestAttentionBiz().getAttentionTag(Util.getIntValue(requestid), Util.getIntValue(userID), 0, userlang); + + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } + return returnStr; + } + + public String getTitle4Mobile(String requestname, String para2) { + RecordSet rs = new RecordSet(); + String returnStr = ""; + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + String agentorbyagentid = ""; + String agenttype = ""; + String workflowtype = ""; + + if (tempStr.length >= 10) { + agenttype = Util.null2String(tempStr[9]); + } + String paramstr = ""; + if (tempStr.length >= 13 && Util.getIntValue(requestid) < 0) { + String _userid = Util.null2String(tempStr[11]); + String myrequest = Util.null2String(tempStr[12]); + String creater = Util.null2String(tempStr[13]); + String syscode = Util.null2String(tempStr[14]); + workflowtype = Util.null2String(tempStr[15]); + } + paramstr = "&_workflowid=" + workflowid + "&_workflowtype=" + workflowtype;//方便异构系统使用 + String nodetitle = ""; + if (true) { + int isbill = 0; + int formid = 0; + // //根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + } + + boolean isprocessed = false; + boolean canContinue = false; + if ("0".equals(isremark)) { + isprocessed = false; + } else if ("5".equals(isremark)) { + isprocessed = true; + } else { + rs.executeSql("select isprocessed, isremark, userid, nodeid from workflow_currentoperator where requestid = " + + requestid + + " and userid=" + userID + + " order by receivedate desc, receivetime desc"); + while (rs.next()) { + String isremark_tmp = Util.null2String(rs.getString("isremark")); + String isprocessed_tmp = Util.null2String(rs + .getString("isprocessed")); + String userid_tmp = Util.null2String(rs.getString("userid")); + if ((isremark_tmp.equals("0") && (isprocessed_tmp.equals("0") || isprocessed_tmp + .equals("3") || isprocessed_tmp.equals("2"))) + || isremark_tmp.equals("5")) { + isprocessed = true; + } + // 如果是被抄送或转发,判断是否正是某节点的操作人,取最后一次 + if (("8".equals(isremark) || "9".equals(isremark) || "1" + .equals(isremark)) + && userID.equals(userid_tmp) + && "0".equals(isremark_tmp) + && canContinue == false) { + int nodeid_tmp = Util.getIntValue(rs.getString("nodeid"), 0); + if (nodeid_tmp != 0) { + isremark = isremark_tmp; + nodeid = "" + nodeid_tmp; + canContinue = true; + } + } + if (isprocessed == true && canContinue == true) { + break; + } + } + } + // 改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs + .executeSql("select nodetitle from workflow_flownode where workflowid=" + + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + if (true) + return requestname; + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } else if (viewtype.equals("-1")) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } + return returnStr; + } + + /** + * 流程标题显示样式(是否加图片等),区分颜色 + * + * @param requestname 流程标题 + * @param para2 请求ID + 流程ID + 显示类型 + 是否超时 + 用户语言 + 节点ID currentnodeid + 操作人类性isremark+用户id userID+ 代理人/被代理人ID + 代理/被代理类型 + * @return 流程标题显示样式 + * @throws Exception + */ + + public String getWfNewLinkWithTitle2(String requestname, String para2) throws Exception { + return getWfNewLinkWithTitle2(requestname, para2, 2); + } + + public String getWfNewLinkWithTitle2(String requestname, String para2, int flag) throws Exception { + return getWfNewLinkWithTitle2(requestname, para2, flag, true); + } + + public String getWfNewLinkWithTitle2(String requestname, String para2, int flag, boolean needFormat) throws Exception { + return getWfNewLinkWithTitle2(requestname, para2, flag, needFormat, false); + } + + public String getWfNewLinkWithTitle_AttentionTag2(String requestname, String para2, int flag, boolean needFormat) throws Exception { + return getWfNewLinkWithTitle2(requestname, para2, flag, needFormat, true); + } + + public String getWfNewLinkWithTitle_AttentionTag2(String requestname, String para2, int flag, boolean needFormat, boolean showAttentionTag) throws Exception { + return getWfNewLinkWithTitle2(requestname, para2, flag, needFormat, showAttentionTag); + } + + public String getWfNewLinkWithTitle2(String requestname, String para2, int flag, boolean needFormat, boolean showAttentionTag) + throws Exception { + String[] tempStr = null; + boolean isNeedBack = false; + boolean isAgent0 = false;//根据scope告知transmethod,代理--交办他人流程列表f_weaver_belongto_userid应取被代理人id,agentFlag=0:交办他人流程列表,agentFlag=1代他人处理流程列表 + if(para2.indexOf("scope_") > -1 && para2.indexOf("_scope") > -1) { + String scope = ""; + scope = para2.substring(para2.indexOf("scope_"), para2.indexOf("_scope")); + isAgent0 = "agent0".equals(scope.replace("scope_", "")); + } + if (para2.startsWith("S")) { + String[] tempStr_tmp = Util.splitString(para2, "+"); + tempStr = Arrays.copyOfRange(tempStr_tmp, 9, tempStr_tmp.length); + isNeedBack = isNeedBack(Arrays.copyOfRange(tempStr_tmp, 1, 8), Util.null2String(tempStr[2])); + } else { + tempStr = Util.splitString(para2, "+"); + } + DepartmentComInfo dc = new DepartmentComInfo(); + JobTitlesComInfo jc = new JobTitlesComInfo(); + String returnStr = ""; + RecordSet rs = new RecordSet(); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + String userid3 = Util.null2String(tempStr[11]); + String username = rc.getResourcename(userid3); + String ownDepid = rc.getDepartmentID(userid3); + String depName = dc.getDepartmentname(ownDepid); + String jobName = jc.getJobTitlesname(rc.getJobTitle(userid3)); + String agentorbyagentid = Util.null2String(tempStr[8]);//前面的userid3已经取到11了 + String agenttype = ""; + String realUser = userID; + if (userID != userid3) { + realUser = userid3; + } + + if (tempStr.length >= 10) { + agenttype = Util.null2String(tempStr[9]); + } + + /*String eid = ""; + String ebaseid = ""; + + if (tempStr.length >= 13) { + eid = Util.null2String(tempStr[12]); + } + if (tempStr.length >= 14) { + ebaseid = Util.null2String(tempStr[13]); + }*/ + + String workflowtype = ""; + if (tempStr.length >= 16 && Util.getIntValue(requestid) < 0) { + workflowtype = Util.null2String(tempStr[15]); + } + String paramstr = "&_workflowid=" + workflowid + "&_workflowtype=" + workflowtype;//方便异构系统使用 + + String nodetitle = ""; + if (needFormat) { + int isbill = 0; + int formid = 0; + // //根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + } + + //获取次账号id + String userIDAll = userID; + rs.executeQuery("select belongtoshow from HrmUserSetting where resourceId = " + userID); + String belongtoshow = ""; + if (rs.next()) { + belongtoshow = rs.getString("belongtoshow"); + } + if ("1".equals(belongtoshow)) { + String Belongtoids = getUser(Util.getIntValue(userID, 0)).getBelongtoids(); + if (!"".equals(Belongtoids)) + userIDAll = userIDAll + "," + Belongtoids; + } + + int autoReloadWfListTime = RequestListBiz.getAutoReloadWfListTime(requestid,"0"); + boolean isprocessed = false; + boolean canContinue = false; + //新增是否显示[退回][代理]前缀显示 + boolean hasAgentTip = false; + boolean hasRejectTip = false; + rs.executeSql("select userid,isprocessed, isremark, userid, nodeid,islasttimes,agenttype,isbereject,takisremark from workflow_currentoperator where requestid = " + + requestid + + " and userid =" + realUser + + " order by receivedate desc, receivetime desc"); + while (rs.next()) { + String isbereject = Util.null2String(rs.getString("isbereject")); + String islasttimes = Util.null2String(rs.getString("islasttimes")); + String takisremark = Util.null2String(rs.getString("takisremark")); + String agenttype1 = Util.null2String(rs.getString("agenttype")); + String isremark_tmp = Util.null2String(rs.getString("isremark")); + String userid_temp = Util.null2String(rs.getString("userid")); + String isprocessed_tmp = Util.null2String(rs + .getString("isprocessed")); + String userid_tmp = Util.null2String(rs.getString("userid")); + if (((isremark_tmp.equals("0") && (isprocessed_tmp.equals("0") || isprocessed_tmp + .equals("3") || isprocessed_tmp.equals("2"))) + || isremark_tmp.equals("5"))) { + isprocessed = true; + } + //判断是否显示【退回】【代理】标识 + if ("1".equals(islasttimes) && "2".equals(agenttype1) && (("0".equals(isremark) && !"-2".equals(takisremark)) || "1".equals(isremark) || "7".equals(isremark) || "8".equals(isremark) || "9".equals(isremark) || "11".equals(isremark))) { + hasAgentTip = true; + } + if ("1".equals(islasttimes) && "1".equals(isbereject) && ("0".equals(isremark) && !"-2".equals(takisremark))) { + hasRejectTip = true; + } + // 如果是被抄送或转发,判断是否正是某节点的操作人,取最后一次 + if ((("8".equals(isremark) || "9".equals(isremark) || "1" + .equals(isremark)) + && "0".equals(isremark_tmp) + && canContinue == false)) { + int nodeid_tmp = Util.getIntValue(rs.getString("nodeid"), 0); + if (nodeid_tmp != 0) { + isremark = isremark_tmp; + nodeid = "" + nodeid_tmp; + canContinue = true; + } + } + if (isprocessed == true && canContinue == true) { + break; + } + } + // 改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs + .executeSql("select nodetitle from workflow_flownode where workflowid=" + + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + if (hasAgentTip) { + requestname = SystemEnv.getHtmlLabelName(390272, userlang) + requestname; + } + if (hasRejectTip) { + requestname = SystemEnv.getHtmlLabelName(390271, userlang) + requestname; + } + /*if (!"".equals(eid) && !"".equals(ebaseid)) { + String prefix = ""; + String suffix = ""; + requestname = prefix + requestname + suffix; + }*/ + String attentionTag = ""; + if (showAttentionTag) + attentionTag = new RequestAttentionBiz().getAttentionTag(Util.getIntValue(requestid), Util.getIntValue(userID), 0, userlang); + if (flag == 2) { + if (!userID.equals(userid3)) { + rs + .executeSql("select * from workflow_currentoperator where userid=" + + userid3 + + " and workflowid=" + + workflowid + + " and nodeid=" + + nodeid + + " and requestid=" + + requestid); + + if (rs.next() || Util.getIntValue(requestid) < 0) {//次账号的异构系统流程 + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } + + } + } else { + + // System.out.println("--usrid2-1615-"+usrid2); + + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + + // System.out.println("--usrid2-1615-"+usrid2); + + returnStr = "" + + requestname + + "" + attentionTag; + + } else { + + // System.out.println("--usrid2-1615-"+usrid2); + + returnStr = "" + + requestname + + "" + attentionTag; + + } + } + } + } + if (flag == 1) { + if (!userID.equals(userid3)) { + rs + .executeSql("select * from workflow_currentoperator where userid=" + + userid3 + + " and workflowid=" + + workflowid + + " and nodeid=" + + nodeid + + " and requestid=" + + requestid); + + if (rs.next() || Util.getIntValue(requestid) < 0) {//次账号的异构系统流程 + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } + + } + } else { + + // System.out.println("--usrid2-1615-"+usrid2); + + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + + // System.out.println("--usrid2-1615-"+usrid2); + + returnStr = "" + + requestname + + "" + attentionTag; + + } else { + + // System.out.println("--usrid2-1615-"+usrid2); + + returnStr = "" + + requestname + + "" + attentionTag; + + } + } + } + } + //System.out.println("--returnStr-1956-" + returnStr); + returnStr = STYLE_STR + returnStr + ""; + return returnStr; + + } + + + /** + * 流程标题显示样式(是否加图片等),区分颜色 + * + * @param requestname 流程标题 + * @param para2 请求ID + 流程ID + 显示类型 + 是否超时 + 用户语言 + 节点ID currentnodeid + 操作人类性isremark+用户id userID+ 代理人/被代理人ID + 代理/被代理类型 + * @return 流程标题显示样式 + */ + + public String getWfShareLinkWithTitle(String requestname, String para2) { + return getWfShareLinkWithTitle(requestname, para2, false, null); + } + + public String getWfShareLinkWithTitle(String requestname, String para2, String paraNeedBack) { + return getWfShareLinkWithTitle(requestname, para2, false, paraNeedBack); + } + + public String getWfShareLinkWithTitle(String requestname, String para2, boolean showAttentionTag, String paraNeedBack) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + + boolean isNeedBack = false; + if (paraNeedBack != null) { + isNeedBack = isNeedBack(paraNeedBack, viewtype); + } + + String agentorbyagentid = ""; + String agenttype = ""; + String currentid = ""; + + + if (tempStr.length >= 12) { + agenttype = Util.null2String(tempStr[9]); + currentid = Util.null2String(tempStr[11]); + } + + String workflowtype = ""; + String paramstr = ""; + try { + workflowtype = Util.null2String(tempStr[13]); + } catch (Exception e) { + + } + String creater = ""; + try { + String _userid = Util.null2String(tempStr[12]); + creater = Util.null2String(tempStr[14]); + /* + if(!_userid.equals(userID)&&Util.getIntValue(requestid,0)<0){ + viewtype = "1"; + } + */ + } catch (Exception e) { + + } + paramstr = "&_workflowid=" + workflowid + "&_workflowtype=" + workflowtype;//方便异构系统使用 + String nodetitle = ""; + int isbill = 0; + int formid = 0; + ////根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + + boolean isprocessed = false; + boolean canContinue = false; + //新增是否显示[退回][代理]前缀显示 + boolean hasAgentTip = false; + boolean hasRejectTip = false; + rs.executeSql("select isprocessed, isremark, userid, nodeid,islasttimes,agenttype,isbereject,takisremark from workflow_currentoperator where requestid = " + requestid + " and userid=" + userID + " order by receivedate desc, receivetime desc"); + while (rs.next()) { + String isbereject = Util.null2String(rs.getString("isbereject")); + String islasttimes = Util.null2String(rs.getString("islasttimes")); + String takisremark = Util.null2String(rs.getString("takisremark")); + String agenttype1 = Util.null2String(rs.getString("agenttype")); + String isremark_tmp = Util.null2String(rs.getString("isremark")); + String isprocessed_tmp = Util.null2String(rs.getString("isprocessed")); + String userid_tmp = Util.null2String(rs.getString("userid")); + if ((isremark_tmp.equals("0") && (isprocessed_tmp.equals("0") || isprocessed_tmp.equals("3") || isprocessed_tmp.equals("2"))) || isremark_tmp.equals("5")) { + isprocessed = true; + } + //判断是否显示【退回】【代理】标识 + if ("1".equals(islasttimes) && "2".equals(agenttype1) && (("0".equals(isremark) && !"-2".equals(takisremark)) || "1".equals(isremark) || "7".equals(isremark) || "8".equals(isremark) || "9".equals(isremark) || "11".equals(isremark))) { + hasAgentTip = true; + } + if ("1".equals(islasttimes) && "1".equals(isbereject) && ("0".equals(isremark) && !"-2".equals(takisremark))) { + hasRejectTip = true; + } + //如果是被抄送或转发,判断是否正是某节点的操作人,取最后一次 + if (("8".equals(isremark) || "9".equals(isremark) || "1".equals(isremark)) && userID.equals(userid_tmp) && "0".equals(isremark_tmp) && canContinue == false) { + int nodeid_tmp = Util.getIntValue(rs.getString("nodeid"), 0); + if (nodeid_tmp != 0) { + isremark = isremark_tmp; + nodeid = "" + nodeid_tmp; + canContinue = true; + } + } + if (isprocessed == true && canContinue == true) { + break; + } + } + //改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs.executeSql("select nodetitle from workflow_flownode where workflowid=" + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + if (hasAgentTip) { + requestname = SystemEnv.getHtmlLabelName(390272, userlang) + requestname; + } + if (hasRejectTip) { + requestname = SystemEnv.getHtmlLabelName(390271, userlang) + requestname; + } + + String allrequestids = ""; + if (!"".equals(currentid) && !"".equals(currentid.trim())) { + rs.executeSql("select requestid from workflow_currentoperator where id in(" + currentid + ")"); + while (rs.next()) { + if ("".equals(allrequestids)) { + allrequestids = Util.null2String(rs.getString("requestid")); + } else { + allrequestids += "," + Util.null2String(rs.getString("requestid")); + } + } + } + + boolean checkwfshare = false; + if (!"".equals(allrequestids)) { + String checkquestids = "," + allrequestids + ","; + if (checkquestids.indexOf(requestid) > -1) { + checkwfshare = true; + } + } + + String attentionTag = ""; + if (showAttentionTag) + attentionTag = new RequestAttentionBiz().getAttentionTag(Util.getIntValue(requestid), Util.getIntValue(userID), 0, userlang); + + if (checkwfshare) { + returnStr = "" + requestname + "" + attentionTag; + } else { + if (viewtype.equals("0")) { + //新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + requestname + "" + attentionTag; + } else if ("1".equals(agenttype)) { + returnStr = "" + requestname + "" + attentionTag; + } else { + returnStr = "" + requestname + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + //旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + requestname + "" + attentionTag; + } else { + returnStr = "" + requestname + "" + attentionTag; + } + } else { + //旧流程,普通链接 + if (isprocessed) { + returnStr = "" + requestname + "" + attentionTag; + } else { + returnStr = "" + requestname + "" + attentionTag; + } + } + } + return returnStr; + } + + + /** + * 流程标题显示样式(是否加图片等),区分颜色 + * + * @param requestname 流程标题 + * @param para2 请求ID + 流程ID + 显示类型 + 是否超时 + 用户语言 + 节点ID currentnodeid + 操作人类性isremark+用户id userID+ 代理人/被代理人ID + 代理/被代理类型 + * @return 流程标题显示样式 + * @throws Exception + */ + public String getWfShareLinkWithTitle2(String requestname, String para2) + throws Exception { + return getWfShareLinkWithTitle2(requestname, para2, false, null); + } + + public String getWfShareLinkWithTitle2(String requestname, String para2, String paraNeedBack) + throws Exception { + return getWfShareLinkWithTitle2(requestname, para2, false, paraNeedBack); + } + + public String getWfShareLinkWithTitle2(String requestname, String para2, boolean showAttentionTag, String paraNeedBack) + throws Exception { + RecordSet rs = new RecordSet(); + String returnStr = ""; + ResourceComInfo rc = new ResourceComInfo(); + DepartmentComInfo dc = new DepartmentComInfo(); + JobTitlesComInfo jc = new JobTitlesComInfo(); + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + + boolean isNeedBack = false; + if (paraNeedBack != null) { + isNeedBack = isNeedBack(paraNeedBack, viewtype); + } + String agentorbyagentid = ""; + String agenttype = ""; + String currentid = ""; + String nowuserid = ""; + if (tempStr.length >= 12) { + agenttype = Util.null2String(tempStr[9]); + currentid = Util.null2String(tempStr[11]); + nowuserid = Util.null2String(tempStr[12]); + } + + String workflowtype = ""; + String paramstr = ""; + try { + workflowtype = Util.null2String(tempStr[13]); + } catch (Exception e) { + + } + paramstr = "&_workflowid=" + workflowid + "&_workflowtype=" + workflowtype;//方便异构系统使用 + + String username = rc.getResourcename(nowuserid); + String ownDepid = rc.getDepartmentID(nowuserid); + String depName = dc.getDepartmentname(ownDepid); + String jobName = jc.getJobTitlesname(rc.getJobTitle(nowuserid)); + + String nodetitle = ""; + int isbill = 0; + int formid = 0; + // //根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + + //获取次账号id + String userIDAll = userID; + rs.executeQuery("select belongtoshow from HrmUserSetting where resourceId = " + userID); + String belongtoshow = ""; + if (rs.next()) { + belongtoshow = rs.getString("belongtoshow"); + } + if ("1".equals(belongtoshow)) { + String Belongtoids = getUser(Util.getIntValue(userID, 0)).getBelongtoids(); + if (!"".equals(Belongtoids)) + userIDAll = userIDAll + "," + Belongtoids; + } + List useridAllList = Util.splitString2List(userIDAll, ","); + boolean isprocessed = false; + boolean canContinue = false; + //新增是否显示[退回][代理]前缀显示 + boolean hasAgentTip = false; + boolean hasRejectTip = false; + rs.executeSql("select isprocessed, isremark, userid, nodeid,islasttimes,agenttype,isbereject,takisremark from workflow_currentoperator where requestid = " + + requestid + + " order by receivedate desc, receivetime desc"); + while (rs.next()) { + String isbereject = Util.null2String(rs.getString("isbereject")); + String islasttimes = Util.null2String(rs.getString("islasttimes")); + String takisremark = Util.null2String(rs.getString("takisremark")); + String agenttype1 = Util.null2String(rs.getString("agenttype")); + String isremark_tmp = Util.null2String(rs.getString("isremark")); + String isprocessed_tmp = Util.null2String(rs + .getString("isprocessed")); + String userid_tmp = Util.null2String(rs.getString("userid")); + if ((isremark_tmp.equals("0") && (isprocessed_tmp.equals("0") || isprocessed_tmp + .equals("3") || isprocessed_tmp.equals("2"))) + || isremark_tmp.equals("5")) { + isprocessed = true; + } + //判断是否显示【退回】【代理】标识 + if (useridAllList.contains(userid_tmp) && "1".equals(islasttimes) && "2".equals(agenttype1) && (("0".equals(isremark) && !"-2".equals(takisremark)) || "1".equals(isremark) || "7".equals(isremark) || "8".equals(isremark) || "9".equals(isremark) || "11".equals(isremark))) { + hasAgentTip = true; + } + if (useridAllList.contains(userid_tmp) && "1".equals(islasttimes) && "1".equals(isbereject) && ("0".equals(isremark_tmp) && !"-2".equals(takisremark))) { + hasRejectTip = true; + } + // 如果是被抄送或转发,判断是否正是某节点的操作人,取最后一次 + if (("8".equals(isremark) || "9".equals(isremark) || "1" + .equals(isremark)) + && userID.equals(userid_tmp) + && "0".equals(isremark_tmp) + && canContinue == false) { + int nodeid_tmp = Util.getIntValue(rs.getString("nodeid"), 0); + if (nodeid_tmp != 0) { + isremark = isremark_tmp; + nodeid = "" + nodeid_tmp; + canContinue = true; + } + } + if (isprocessed == true && canContinue == true) { + break; + } + } + // 改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs + .executeSql("select nodetitle from workflow_flownode where workflowid=" + + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + if (hasAgentTip) { + requestname = SystemEnv.getHtmlLabelName(390272, userlang) + requestname; + } + if (hasRejectTip) { + requestname = SystemEnv.getHtmlLabelName(390271, userlang) + requestname; + } + String allrequestids = ""; + if (!"".equals(currentid)) { + rs + .executeSql("select requestid from workflow_currentoperator where id in(" + + currentid + ")"); + while (rs.next()) { + if ("".equals(allrequestids)) { + allrequestids = Util.null2String(rs.getString("requestid")); + } else { + allrequestids += "," + + Util.null2String(rs.getString("requestid")); + } + } + } + + boolean checkwfshare = false; + if (!"".equals(allrequestids)) { + String checkquestids = "," + allrequestids + ","; + if (checkquestids.indexOf(requestid) > -1) { + checkwfshare = true; + } + } + + String attentionTag = ""; + if (showAttentionTag) + attentionTag = new RequestAttentionBiz().getAttentionTag(Util.getIntValue(requestid), Util.getIntValue(userID), 0, userlang); + if (!userID.equals(nowuserid)) { + + if (checkwfshare) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } + + } + } else { + if (checkwfshare) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + + // System.out.println("--usrid2-1615-"+usrid2); + + returnStr = "" + + requestname + + "" + attentionTag; + + } else { + + // System.out.println("--usrid2-1615-"+usrid2); + + returnStr = "" + + requestname + + "" + attentionTag; + + } + } + } + } + returnStr = STYLE_STR + returnStr + ""; + return returnStr; + } + + + /** + * 流程标题显示样式(是否加图片等),区分颜色 + * + * @param requestname 主次账号图标 + * @param para2 请求ID + 流程ID + 显示类型 + 是否超时 + 用户语言 + 节点ID currentnodeid + + * 操作人类性isremark+用户id userID+ 代理人/被代理人ID + 代理/被代理类型 + * @return 流程标题显示样式 + * @throws Exception + */ + public String getWfMainSubPic(String requestname, String para2) + throws Exception { + ResourceComInfo rc = new ResourceComInfo(); + DepartmentComInfo dc = new DepartmentComInfo(); + JobTitlesComInfo jc = new JobTitlesComInfo(); + RecordSet rs = new RecordSet(); + String returnStr = ""; + + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + String usrid2 = Util.null2String(tempStr[11]); + String[] arr2 = null; + ArrayList userlist = new ArrayList(); + int Belongtoid = 0; + if (!"".equals(usrid2)) { + arr2 = usrid2.split(","); + for (int i = 0; i < arr2.length; i++) { + Belongtoid = Util.getIntValue(arr2[i]); + userlist.add(Belongtoid + ""); + } + } + + for (int k = 0; k < userlist.size(); k++) { + String userid2 = Util.null2String((String) userlist.get(k)); + String username = rc.getResourcename((String) userlist.get(k)); + String ownDepid = rc.getDepartmentID((String) userlist.get(k)); + String depName = dc.getDepartmentname(ownDepid); + String jobName = jc.getJobTitlesname(rc + .getJobTitle((String) userlist.get(k))); + // System.out.println("-----1393----workflowtm---jobName==="+jobName); + String agentorbyagentid = ""; + String agenttype = ""; + + if (tempStr.length >= 10) { + agenttype = Util.null2String(tempStr[9]); + } + + String nodetitle = ""; + int isbill = 0; + int formid = 0; + // //根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + + boolean isprocessed = false; + boolean canContinue = false; + rs + .executeSql("select isprocessed, isremark, userid, nodeid from workflow_currentoperator where requestid = " + + requestid + + " order by receivedate desc, receivetime desc"); + while (rs.next()) { + String isremark_tmp = Util + .null2String(rs.getString("isremark")); + String isprocessed_tmp = Util.null2String(rs + .getString("isprocessed")); + String userid_tmp = Util.null2String(rs.getString("userid")); + if ((isremark_tmp.equals("0") && (isprocessed_tmp.equals("0") || isprocessed_tmp + .equals("3") || isprocessed_tmp.equals("2"))) + || isremark_tmp.equals("5")) { + isprocessed = true; + } + // 如果是被抄送或转发,判断是否正是某节点的操作人,取最后一次 + if (("8".equals(isremark) || "9".equals(isremark) || "1" + .equals(isremark)) + && userID.equals(userid_tmp) + && "0".equals(isremark_tmp) && canContinue == false) { + int nodeid_tmp = Util + .getIntValue(rs.getString("nodeid"), 0); + if (nodeid_tmp != 0) { + isremark = isremark_tmp; + nodeid = "" + nodeid_tmp; + canContinue = true; + } + } + if (isprocessed == true && canContinue == true) { + break; + } + } + // 改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs + .executeSql("select nodetitle from workflow_flownode where workflowid=" + + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + + if (!userID.equals(userid2)) { + rs + .executeSql("select * from workflow_currentoperator where userid=" + + userid2 + + " and workflowid=" + + workflowid + + " and nodeid=" + + nodeid + + " and requestid=" + + requestid); + if (rs.next()) { + + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } else if (viewtype.equals("-1")) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } else { + // 旧流程,普通链接 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } + + } + } else { + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } else if (viewtype.equals("-1")) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } else { + //旧流程,普通链接 + if (isprocessed) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + ""; + } + } + } + } + return returnStr; + } + + + /** + * 返回正文 + * + * @param + * @param + * @return + */ + public String getContentNewLinkWithTitle(String requestid, String para2) { + String returnStr = ""; + String[] tempStr = Util.splitString(para2, "+"); + RecordSet rs = new RecordSet(); + //String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + String docids = ""; + rs.executeSql("select docids from workflow_requestbase where requestid=" + requestid); + if (rs.next()) { + docids = Util.null2String(rs.getString(1)); + } + if (!docids.equals("") && !docids.equals("0")) { + if (docids.indexOf(",") == -1) {//只有一个文档,直接算为正文 + returnStr = "" + DocComInfo1.getDocname(docids) + ""; + } else {//多个文档,需要查找到哪个字段是正文字段 + rs.executeSql("select flowDocField from workflow_createdoc where workflowid=" + workflowid + " order by id desc"); + if (rs.next()) { + int fieldid = Util.getIntValue(rs.getString(1), -1); + if (fieldid > 0) { + int isbill = 0; + int formid = 0; + rs.execute("select formid,isbill from workflow_base where id=" + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + if (isbill == 1) {//新表单或者单据 + rs.executeSql("select fieldname from workflow_billfield where id=" + fieldid + " and billid=" + formid); + if (rs.next()) { + String fieldname = Util.null2String(rs.getString(1)); + if (!fieldname.equals("")) { + if (formid < 0) {//新表单 + rs.executeSql("select " + fieldname + " from formtable_main_" + (formid * -1) + " where requestid=" + requestid); + if (rs.next()) { + returnStr = "" + DocComInfo1.getDocname("" + Util.getIntValue(rs.getString(1), 0)) + ""; + } + } else {//单据 + rs.executeSql("select tablename from workflow_bill where id=" + formid); + if (rs.next()) { + String tablename = Util.null2String(rs.getString(1)); + if (!tablename.equals("")) { + rs.executeSql("select " + fieldname + " from " + tablename + " where requestid=" + requestid); + if (rs.next()) { + returnStr = "" + DocComInfo1.getDocname("" + Util.getIntValue(rs.getString(1), 0)) + ""; + } + } + } + } + } + } + } else {//老表单 + rs.executeSql("select fieldname from workflow_formdict where id=" + fieldid); + if (rs.next()) { + String fieldname = Util.null2String(rs.getString(1)); + if (!fieldname.equals("")) { + rs.executeSql("select " + fieldname + " from workflow_form where requestid=" + requestid); + if (rs.next()) { + returnStr = "" + DocComInfo1.getDocname("" + Util.getIntValue(rs.getString(1), 0)) + ""; + } + } + } + } + } + + } + } + } + return returnStr; + } + + /** + * 流程标题显示样式(是否加图片等),区分颜色 + * + * @param requestname 流程标题 + * @param para2 请求ID + 流程ID + 显示类型 + 是否超时 + 用户语言 + 节点ID currentnodeid + 操作人类性isremark + * @return 流程标题显示样式 + */ + public String getWfNewLinkWithTitleExt(String requestname, String para2) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + String nodetitle = ""; + int isbill = 0; + int formid = 0; + ////根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + boolean isprocessed = false; + boolean canContinue = false; + rs.executeSql("select isprocessed, isremark, userid, nodeid from workflow_currentoperator where requestid = " + requestid + " order by receivedate desc, receivetime desc"); + while (rs.next()) { + String isremark_tmp = Util.null2String(rs.getString("isremark")); + String isprocessed_tmp = Util.null2String(rs.getString("isprocessed")); + String userid_tmp = Util.null2String(rs.getString("userid")); + if ((isremark_tmp.equals("0") && (isprocessed_tmp.equals("0") || isprocessed_tmp.equals("3") || isprocessed_tmp.equals("2"))) || isremark_tmp.equals("5")) { + isprocessed = true; + } + //如果是被抄送或转发,判断是否正是某节点的操作人,取最后一次 + if (("8".equals(isremark) || "9".equals(isremark) || "1".equals(isremark)) && userID.equals(userid_tmp) && "0".equals(isremark_tmp) && canContinue == false) { + int nodeid_tmp = Util.getIntValue(rs.getString("nodeid"), 0); + if (nodeid_tmp != 0) { + isremark = isremark_tmp; + nodeid = "" + nodeid_tmp; + canContinue = true; + } + } + if (isprocessed == true && canContinue == true) { + break; + } + } + //改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs.executeSql("select nodetitle from workflow_flownode where workflowid=" + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + + if (viewtype.equals("0")) { + //新流程,粗体链接加图片 + + returnStr = "" + requestname + ""; + + } else if (viewtype.equals("-1")) { + //旧流程,有新的提交信息未查看,普通链接加图片 + + returnStr = "" + requestname + ""; + + } else { + + returnStr = "" + requestname + ""; + + + } + return returnStr; + } + + public String getWfViewTypeExt(String viewtype, String requestid) { + boolean isprocessed = false; + RecordSet rs = new RecordSet(); + rs.executeSql("select isprocessed from workflow_currentoperator where ((isremark='0' and (isprocessed='0' or isprocessed='3' or isprocessed='2')) or isremark='5') and requestid = " + requestid); + if (rs.next()) { + isprocessed = true; + } + String returnStr = ""; + if (viewtype.equals("0")) { + //新流程,粗体链接加图片 + if (isprocessed) { + returnStr = ""; + } else { + returnStr = ""; + } + } else if (viewtype.equals("-1")) { + //旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = ""; + } else { + returnStr = ""; + } + } else { + //旧流程,普通链接 + if (isprocessed) { + returnStr = ""; + } else { + returnStr = "         "; + } + } + return returnStr; + } + + /** + * 请求状态图标 + * + * @param viewtype 请求状态 + * @param para2 请求ID + 代理人/被代理人ID + 代理/被代理类型 + * @return 请求状态图标 + */ + public String getWfViewTypeExtIncludeAgent(String viewtype, String para2) { + + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String agentorbyagentid = Util.null2String(tempStr[1]); + String agenttype = Util.null2String(tempStr[2]); + + RecordSet rs = new RecordSet(); + boolean isprocessed = false; + rs.executeSql("select isprocessed from workflow_currentoperator where ((isremark='0' and (isprocessed='0' or isprocessed='3' or isprocessed='2')) or isremark='5') and requestid = " + requestid); + if (rs.next()) { + isprocessed = true; + } + String returnStr = ""; + if (viewtype.equals("0")) { + //新流程,粗体链接加图片 + if (isprocessed) { + returnStr = ""; + } else if ("1".equals(agenttype)) { + returnStr = "         "; + } else { + returnStr = ""; + } + } else if (viewtype.equals("-1")) { + //旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = ""; + } else { + returnStr = ""; + } + } else { + //旧流程,普通链接 + if (isprocessed) { + returnStr = ""; + } else { + returnStr = "         "; + } + } + return returnStr; + } + + /** + * 得到未操作者 + * + * @param requestid 流程ID + * @return 未操作者 + */ + public String getUnOperators(String requestid, String para) { + if(requestid == null){ + return "";//走微搜时,微搜可能会返回已删除的数据 + } + String[] tempStr = Util.splitString(para, "+"); + + String userLanguage = Util.null2String(tempStr[0]); + RecordSet rs = new RecordSet(); + String userid = Util.null2String(tempStr[1]); + String mainsubuserid = Util.null2String(tempStr[2]); + String returnStr = "
"; + String divid = mainsubuserid + requestid + "div"; + returnStr += "" + SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)) + ""; + //returnStr=SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)); + returnStr += "
"; + String showoperators = ""; + try { + + showoperators = "0".equals(RequestDefaultComInfo.getShowoperator("" + userid)) ? "0" : "1"; + } catch (Exception eshows) { + } + if (showoperators.equals("1")) { + if (requestid.indexOf("-") == -1) { + returnStr = ""; + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid,isremark,showorder,id,groupid from workflow_currentoperator where (isremark in ('0','1','5','7','8','9','11') or (isremark='4' and viewtype=0)) and requestid = " + requestid + " order by isremark,groupid,showorder asc ,id asc"); + Set unOperators = new HashSet<>(); + while (rs.next()) { + //去除重复 + String key = rs.getString("userid") + ":" + rs.getString("usertype") + ":" + rs.getString("agenttype") + ":" + rs.getString("agentorbyagentid"); + if (unOperators.contains(key)) { + continue; + } else { + unOperators.add(key); + } + if (returnStr.equals("")) { + if (rs.getInt("usertype") == 0) { + //if(rs.getInt("agenttype")==2) + // returnStr += rc.getResourcename(rs.getString("agentorbyagentid"))+"->"+rc.getResourcename(rs.getString("userid")); + //else + // returnStr += rc.getResourcename(rs.getString("userid")); + if (rs.getInt("agenttype") == 2) { + returnStr += rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + //判断是否被代理者,如果是,则不显示该记录 + } else if (rs.getInt("agenttype") == 1 && rs.getInt("isremark") == 4) { + continue; + } else { + returnStr += rc.getResourcename(rs.getString("userid")); + } + } else { + returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } else { + if (rs.getInt("usertype") == 0) { + //if(rs.getInt("agenttype")==2) + // returnStr += ","+rc.getResourcename(rs.getString("agentorbyagentid"))+"->"+rc.getResourcename(rs.getString("userid")); + //else + // returnStr += ","+rc.getResourcename(rs.getString("userid")); + if (rs.getInt("agenttype") == 2) { + returnStr += "," + rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + //判断是否被代理者,如果是,则不显示该记录 + } else if (rs.getInt("agenttype") == 1 && rs.getInt("isremark") == 4) { + continue; + } else { + returnStr += "," + rc.getResourcename(rs.getString("userid")); + } + } else { + //TD11591(人力资源与客户同时存在时、加','处理) + returnStr += "," + cci.getCustomerInfoname(rs.getString("userid")); + } + } + } + } else { + returnStr = ""; + rs.executeSql("select distinct userid from ofs_todo_data where requestid=" + requestid + " and isremark in(0,8,9) "); + while (rs.next()) { + returnStr += rc.getResourcename(rs.getString("userid")) + ","; + } + if (returnStr.endsWith(",")) { + returnStr = returnStr.substring(0, returnStr.length() - 1); + } + } + } + return returnStr; + } + + + /** + * 得到未操作者 + * + * @param requestid 流程ID + * @return 未操作者 + */ + public String getUnOperators2(String requestid, String para) { + String[] tempStr = Util.splitString(para, "+"); + RecordSet rs = new RecordSet(); + String userLanguage = Util.null2String(tempStr[0]); + + String userid = Util.null2String(tempStr[1]); + //String mainsubuserid = Util.null2String(tempStr[2]); + String returnStr = "
"; + String divid = userid + requestid + "div"; + returnStr += "" + SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)) + ""; + //returnStr=SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)); + returnStr += "
"; + String showoperators = ""; + try { + + showoperators = "0".equals(RequestDefaultComInfo.getShowoperator("" + userid)) ? "0" : "1"; + } catch (Exception eshows) { + } + if (showoperators.equals("1")) { + returnStr = ""; + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + Set operatorSets = new HashSet<>(); + while (rs.next()) { + String key = rs.getString("userid") + "_" + rs.getInt("usertype") + "_" + rs.getInt("agenttype") + "_" + rs.getString("agentorbyagentid"); + if (operatorSets.contains(key)) { + continue; + } + if (returnStr.equals("")) { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += rc.getResourcename(rs.getString("userid")); + } else { + returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } else { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += "," + rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += "," + rc.getResourcename(rs.getString("userid")); + } else { + //TD11591(人力资源与客户同时存在时、加','处理) + returnStr += "," + cci.getCustomerInfoname(rs.getString("userid")); + } + } + } + + } + return returnStr; + } + + + /** + * 得到未操作者 + * + * @param requestid 流程ID + * @return 未操作者 + */ + public String getMUnOperators(String requestid, String para) { + String[] tempStr = Util.splitString(para, "+"); + + String userLanguage = Util.null2String(tempStr[0]); + RecordSet rs = new RecordSet(); + String userid = Util.null2String(tempStr[1]); + String returnStr = "
"; + String divid = requestid + "div"; + returnStr += "" + SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)) + ""; + //returnStr=SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)); + returnStr += "
"; + String showoperators = ""; + try { + + showoperators = "0".equals(RequestDefaultComInfo.getShowoperator("" + userid)) ? "0" : "1"; + } catch (Exception eshows) { + } + if (showoperators.equals("1")) { + returnStr = ""; + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + + while (rs.next()) { + if (returnStr.equals("")) { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += rc.getResourcename(rs.getString("userid")); + } else { + returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } else { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += "," + rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += "," + rc.getResourcename(rs.getString("userid")); + } else { + //TD11591(人力资源与客户同时存在时、加','处理) + returnStr += "," + cci.getCustomerInfoname(rs.getString("userid")); + } + } + } + + } + return returnStr; + } + + /** + * 得到流程报表未操作者 + * + * @param requestid 流程ID + * @return 未操作者 + */ + public String getUnOptInRep(String requestid) { + + String returnStr = ""; + RecordSet rs = new RecordSet(); + //returnStr =""+ rc.getResourcename(id)+ ""; + + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + + String usid = ""; + String usname = ""; + while (rs.next()) { + if (returnStr.equals("")) { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) { + usid = rs.getString("agentorbyagentid"); + usname = rc.getResourcename(usid); + returnStr += "" + usname + "->"; + returnStr += "" + rc.getResourcename("userid") + ""; + //returnStr += rc.getResourcename(rs.getString("agentorbyagentid"))+"->"+rc.getResourcename(rs.getString("userid")); + } else { + usid = rs.getString("userid"); + usname = rc.getResourcename(usid); + returnStr += "" + usname + ""; + } + } else { + usid = rs.getString("userid"); + usname = cci.getCustomerInfoname(usid); + returnStr += "" + usname + ""; + //returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } else { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) { + usid = rs.getString("agentorbyagentid"); + usname = rc.getResourcename(usid); + returnStr += "," + usname + "->"; + returnStr += "" + rc.getResourcename("userid") + ""; + //returnStr += ","+rc.getResourcename(rs.getString("agentorbyagentid"))+"->"+rc.getResourcename(rs.getString("userid")); + } else { + usid = rs.getString("userid"); + usname = rc.getResourcename(usid); + returnStr += "," + usname + ""; + //returnStr += ","+rc.getResourcename(rs.getString("userid")); + } + } else { + //TD11591(人力资源与客户同时存在时、加','处理) + usid = rs.getString("userid"); + usname = cci.getCustomerInfoname(usid); + returnStr += "," + usname + ""; + //returnStr += ","+cci.getCustomerInfoname(rs.getString("userid")); + } + } + } + + return returnStr; + } + + /** + * 得到流程报表导出未操作者 + * + * @param requestid 流程ID + * @return 未操作者 + */ + public String getUnOptOutPutExcel(String requestid) { + + String returnStr = ""; + RecordSet rs = new RecordSet(); + //returnStr =""+ rc.getResourcename(id)+ ""; + + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + + String usid = ""; + String usname = ""; + while (rs.next()) { + if (returnStr.equals("")) { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) { + usid = rs.getString("agentorbyagentid"); + usname = rc.getResourcename(usid); + returnStr += usname + "->"; + returnStr += rc.getResourcename(Util.null2String(rs.getString("userid"))); + //returnStr += rc.getResourcename(rs.getString("agentorbyagentid"))+"->"+rc.getResourcename(rs.getString("userid")); + } else { + usid = rs.getString("userid"); + usname = rc.getResourcename(usid); + returnStr += usname; + } + } else { + usid = rs.getString("userid"); + usname = cci.getCustomerInfoname(usid); + returnStr += usname; + //returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } else { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) { + usid = rs.getString("agentorbyagentid"); + usname = rc.getResourcename(usid); + returnStr += "," + usname + "->"; + returnStr += rc.getResourcename(Util.null2String(rs.getString("userid"))); + //returnStr += ","+rc.getResourcename(rs.getString("agentorbyagentid"))+"->"+rc.getResourcename(rs.getString("userid")); + } else { + usid = rs.getString("userid"); + usname = rc.getResourcename(usid); + returnStr += "," + usname; + //returnStr += ","+rc.getResourcename(rs.getString("userid")); + } + } else { + //TD11591(人力资源与客户同时存在时、加','处理) + usid = rs.getString("userid"); + usname = cci.getCustomerInfoname(usid); + returnStr += "," + usname; + //returnStr += ","+cci.getCustomerInfoname(rs.getString("userid")); + } + } + } + + return returnStr; + } + + public String getUnOperatorsExt(String requestid, String para) { + String[] tempStr = Util.splitString(para, "+"); + String userLanguage = Util.null2String(tempStr[0]); + RecordSet rs = new RecordSet(); + String userid = Util.null2String(tempStr[1]); + String returnStr = "
"; + String divid = requestid + "div"; + returnStr += "" + SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)) + ""; + //returnStr=SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)); + returnStr += "
"; + + String showoperators = ""; + try { + + showoperators = "0".equals(RequestDefaultComInfo.getShowoperator("" + userid)) ? "0" : "1"; + } catch (Exception eshows) { + } + if (showoperators.equals("1")) { + returnStr = ""; + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid from workflow_currentoperator where (isremark in ('0','1') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + + while (rs.next()) { + if (returnStr.equals("")) { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += rc.getResourcename(rs.getString("userid")); + } else { + returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } else { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += "," + rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += "," + rc.getResourcename(rs.getString("userid")); + } else { + //TD11591(人力资源与客户同时存在时、加','处理) + returnStr += "," + cci.getCustomerInfoname(rs.getString("userid")); + } + } + } + + } + + return returnStr; + } + + /** + * 得到流程报表签字意见 + * + * @param reqid 流程ID + * @param languageid 语言id + * @param isExport 是否导出 + * @return 签字意见 + */ + public String getRequestLogInRep(String reqid, int languageid, boolean isExport) { + String logStr = ""; + String title = ""; + int requestid = Util.getIntValue(Util.null2String(reqid), 0); + + RequestLogOperateName requestLogOperateName = new RequestLogOperateName(); + RecordSet rs = new RecordSet(); + String separator = isExport ? "\n" : " "; + String titleSeparator = "<br>"; //
+ String remarkSeparator = "

"; + String remarkSeparator2 = "
"; + + int workflowid = 0; + String orderby = ""; + rs.executeSql("select * from workflow_base where id = (select workflowid from workflow_requestbase where requestid=" + requestid + ")"); + if (rs.next()) { + workflowid = Util.getIntValue(Util.null2String(rs.getString("id")), 0); + if ("2".equals(Util.null2String(rs.getString("orderbytype")))) { + orderby = "asc"; + } + } + + String viewNodeIds = "-1"; + rs.executeSql("SELECT nodeid FROM workflow_flownode WHERE workflowid= " + workflowid + " AND EXISTS(SELECT 1 FROM workflow_nodebase WHERE id=workflow_flownode.nodeid AND (requestid IS NULL OR requestid=" + requestid + "))"); + while (rs.next()) { + viewNodeIds += "," + Util.getIntValue(Util.null2String(rs.getString("nodeid")), -1); + } + + WFLinkInfo wfLinkInfo = new WFLinkInfo(); + wfLinkInfo.setIsprint(true); + ArrayList logs = wfLinkInfo.getRequestLog(requestid, workflowid, viewNodeIds, orderby); + for (int i = 0; i < logs.size(); i++) { + Hashtable log = (Hashtable) logs.get(i); + String operatedate = Util.null2String(log.get("operatedate")); + String operatetime = Util.null2String(log.get("operatetime")); + String nodename = Util.null2String(log.get("nodename")); + int nodeid = Util.getIntValue(Util.null2String(log.get("nodeid")), 0); + String logtype = Util.null2String(log.get("logtype")); + String operator = Util.null2String(log.get("operator")); + String operatortype = Util.null2String(log.get("operatortype")); + String agenttype = Util.null2String(log.get("agenttype")); + String agentorbyagentid = Util.null2String(log.get("agentorbyagentid")); + String remark = Util.null2String(log.get("remark")).replace("

", remarkSeparator).trim(); + remark = remark.replace("", remarkSeparator).replace("", remarkSeparator); + remark = remark.replace("
", remarkSeparator2).replace("
", remarkSeparator2).replace("
", remarkSeparator2).replace("
", remarkSeparator2).replace("
", remarkSeparator2); + + String operatorName = ""; + if ("0".equals(operatortype)) { + if ("2".equals(agenttype)) { + operatorName = Util.null2String(rc.getResourcename(agentorbyagentid)) + " -> "; + } + operatorName += Util.null2String(rc.getResourcename(operator)); + } else if ("1".equals(operatortype)) { + operatorName = Util.null2String(cci.getCustomerInfoname(operator)); + } else { + operatorName = SystemEnv.getHtmlLabelName(468, languageid); + } + + String operateName = requestLogOperateName.getOperateName("" + workflowid, "" + requestid, "" + nodeid, logtype, operator, languageid); + + logStr += "[" + nodename + " / " + operateName + "]" + separator; + title += "<span style='color: #0099FF;'>[" + nodename + " / " + operateName + "]</span>" + titleSeparator; + if (!"".equals(remark)) { + String remark0 = ""; + String remark1 = remark; + do { + int index = -1; + int length = 0; + int index1 = remark1.indexOf(remarkSeparator); + int index2 = remark1.indexOf(remarkSeparator2); + if (index1 > -1 || index2 > -1) { + if (index1 > -1 && (index2 == -1 || index1 <= index2)) { + index = index1; + length = remarkSeparator.length(); + } else { + index = index2; + length = remarkSeparator2.length(); + } + } + if (index > -1) { + remark0 = remark1.substring(0, index); + remark1 = remark1.substring(index + length); + } else { + remark0 = remark1; + remark1 = ""; + } + remark0 = Util.delHtml(remark0).trim(); + remark0 = remark0.replace("&", "&"); + remark0 = remark0.replace("\"", "%quot;"); + if (!"".equals(remark0)) { + logStr += remark0 + separator; + title += "<span>" + remark0 + "</span>" + titleSeparator; + } + } while (!"".equals(remark1)); + } + logStr += operatorName + " " + operatedate + " " + operatetime + separator + separator; + title += "<span style='color: #999999;'>" + operatorName + " " + operatedate + " " + operatetime + "</span>" + titleSeparator + titleSeparator; + + } + if (isExport) { + if (!"".equals(logStr)) { + logStr = logStr.substring(0, (logStr.length() - (separator.length() * 2))); + } + } else { + logStr = "" + logStr + ""; + } + + return logStr; + } + + public String getWfMonLink(String requestname, String requestid) { + String returnStr = "" + requestname + ""; + return returnStr; + } + + public String getFlowPendingLink(String requestname, String requestid) { + String returnStr = "" + requestname + ""; + return returnStr; + } + + public String getFlowDocLink(String requestname, String requestid) { + String returnStr = "" + requestname + ""; + return returnStr; + } + + /** + * 得到当前节点的显示名 + * + * @param currentnodeid 节点ID + * @return 当前节点的显示名 + */ + public String getCurrentNode(String currentnodeid) { + return WorkflowBaseBiz.getWorkflowNodeName(Util.getIntValue(currentnodeid)); + } + + + /** + * 展示流程监控列表操作菜单 + * add by 黄宝 @2014-1-15 + * + * @param + * @param + * @return + */ + @Deprecated + public List getWFMonitorListOperation(String workflowid_rs, String para2) { + String showDeleteBtn = "false"; //显示删除按钮 + String showStopBtn = "false"; //显示暂停按钮 + String showCancelBtn = "false"; //显示撤销按钮 + String showRestartBtn = "false"; //显示启用按钮 + String showOvmBtn = "false"; //显示强制归档按钮 + String showRbmBtn = "false"; //显示强制收回按钮 + String showInterventionBtn = "false"; //显示流程干预按钮 + RecordSet rs = new RecordSet(); + //记录返回结果 + List result = new ArrayList(); + + + String[] tempStr = Util.splitString(para2, "+"); + String workflowid = ""; + int formid = 0; + int isbill = 0; + String requestid = Util.null2String(tempStr[0]); + int userid = Integer.parseInt(Util.null2String(tempStr[1])); + int usertype = Integer.parseInt(Util.null2String(tempStr[2])); + int userlang = Integer.parseInt(Util.null2String(tempStr[3])); + int currentstatus = Util.getIntValue((Util.null2String(tempStr[4])), -1); + int creater = Util.getIntValue(Util.null2String(tempStr[5]), -1); + int currentnodetype = Util.getIntValue((Util.null2String(tempStr[6])), -1); +// String isNew = ""; +// try{ +// isNew = Util.null2String(tempStr[4]); +// }catch(Exception e){ +// } + + boolean isForceDrawBack = false; + boolean isForceOver = false; + boolean issooperator = false; + //rs.executeSql("select isForceDrawBack,isForceOver,issooperator from workflow_monitor_bound where monitorhrmid="+userid+" and EXISTS(select 1 from workflow_requestbase where currentnodetype!='3' and workflowid=workflow_monitor_bound.workflowid and requestid="+requestid+")"); + rs.executeSql("select isForceDrawBack,isForceOver,issooperator from workflow_monitor_bound where monitorhrmid=" + userid + " and EXISTS(select 1 from workflow_requestbase where currentnodetype!='3' and workflowid=workflow_monitor_bound.workflowid and requestid=" + requestid + ")"); + while (rs.next()) { + if (!isForceDrawBack) + isForceDrawBack = Util.getIntValue(rs.getString("isForceDrawBack")) == 1 ? true : false; + if (!isForceOver) + isForceOver = Util.getIntValue(rs.getString("isForceOver")) == 1 ? true : false; + if (!issooperator) + issooperator = Util.getIntValue(rs.getString("issooperator")) == 1 ? true : false; + } + rs.executeSql("select workflowid from workflow_requestbase where requestid=" + requestid); + if (rs.next()) { + workflowid = rs.getString("workflowid"); + } + WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil(); + + User user = new User(); + user.setUid(userid); + WfFunctionManageUtil WfFunctionManageUtil = new WfFunctionManageUtil(); + boolean haveStopright = WfFunctionManageUtil.haveStopright(currentstatus, creater, user, "" + currentnodetype, -1, issooperator);//流程不为暂停或者撤销状态,当前用户为流程发起人或者系统管理员,并且流程状态不为创建和归档 + boolean haveCancelright = WfFunctionManageUtil.haveCancelright(currentstatus, creater, user, "" + currentnodetype, -1, issooperator);//流程不为撤销状态,当前用户为流程发起人,并且流程状态不为创建和归档 + boolean haveRestartright = WfFunctionManageUtil.haveRestartright(currentstatus, creater, user, "" + currentnodetype, -1, issooperator);//流程为暂停或者撤销状态,当前用户为系统管理员,并且流程状态不为创建和归档 + + haveStopright = haveStopright && !((formid == 158 || formid == 156) && isbill == 1); + haveCancelright = haveCancelright && !((formid == 158 || formid == 156) && isbill == 1); + haveRestartright = haveRestartright && !((formid == 158 || formid == 156) && isbill == 1); + //判断是否有删除权限 + String delStr = workflowid + "+" + userid + "+" + usertype; + boolean haveDelright = getWFMonitorCheckBox(delStr).equals("true") ? true : false; + + if (haveDelright) { + showDeleteBtn = "true"; + } + + ////System.out.println("haveStopright : "+haveStopright+" haveCancelright : "+haveCancelright+" haveRestartright : "+haveRestartright+" currentstatus : "+currentstatus+" currentnodetype : "+currentnodetype+" creater : "+creater+" userid : "+userid); + if (haveStopright) { + //returnStr+=""+SystemEnv.getHtmlLabelName(20387, userlang)+""; + showStopBtn = "true"; + + } + if (haveCancelright) { + //returnStr+="
"+SystemEnv.getHtmlLabelName(16210, userlang)+""; + showCancelBtn = "true"; + } + if (haveRestartright) { + //returnStr+="
"+SystemEnv.getHtmlLabelName(18095, userlang)+""; + showRestartBtn = "true"; + } + if (!haveRestartright || ((formid == 158 || formid == 156) && isbill == 1)) { + HashMap map = wfFunctionManageUtil.wfFunctionMonitorByNodeid(workflowid, userid + ""); + String ov = (String) map.get("ov"); + String rb = (String) map.get("rb"); + WfForceOver wfForceOver = new WfForceOver(); + if (isForceOver && "1".equals(ov) && !wfForceOver.isOver(Integer.parseInt(requestid))) { + // returnStr+="
"+SystemEnv.getHtmlLabelName(18360, userlang)+""; + //returnStr+="
"+SystemEnv.getHtmlLabelName(18360, userlang)+""; + //ishead=false; + showOvmBtn = "true";//强制归档 + } + int tempuser = 1; + int tempusertype = 0; + rs.executeSql("select userid,usertype from workflow_currentoperator where requestid = " + requestid + " and isremark = '2' order by operatedate desc ,operatetime desc"); + if (rs.next()) { + tempuser = rs.getInt("userid"); + tempusertype = rs.getInt("usertype"); + } + int nodecounts = 0;//流程没有真正流转,没有强制收回 + rs.executeSql("select count(distinct nodeid) as nodecounts from workflow_currentoperator where requestid=" + requestid); + if (rs.next()) { + nodecounts = rs.getInt("nodecounts"); + } + WfForceDrawBack wfForceDrawBack = new WfForceDrawBack(); + //现改为查看后也能收回,条件是对该流程有监控权限、不在发起与归档节点、在后台设置强制收回权限 + //if(nodecounts>1&&isForceDrawBack&&!"0".equals(rb) && wfForceDrawBack.isHavePurview(Integer.parseInt(requestid),userid,usertype,tempuser,tempusertype)){ + if (nodecounts > 1 && isForceDrawBack && !"0".equals(rb)) { + //returnStr+="
"+SystemEnv.getHtmlLabelName(18359, userlang)+""; + showRbmBtn = "true"; //强制收回 + } + if (GCONST.getWorkflowIntervenorByMonitor()) { + rs.executeSql("select workflowid from workflow_monitor_bound where monitorhrmid=" + userid + " and isintervenor='1' and EXISTS(select 1 from workflow_requestbase where currentnodetype!='3' and workflowid=workflow_monitor_bound.workflowid and requestid=" + requestid + ")"); + if (rs.next()) { + //returnStr+="
"+SystemEnv.getHtmlLabelName(18913, userlang)+""; + showInterventionBtn = "true";//流程干预 + } + } + } + + + result.add(showDeleteBtn); + result.add(showStopBtn); + result.add(showCancelBtn); + result.add(showRestartBtn); + result.add(showOvmBtn); + result.add(showRbmBtn); + result.add(showInterventionBtn); + + return result; + } + + + /** + * 表格中显示强制归档和强制回收 + * + * @param workflowid_rs + * @param para2 流程id+用户ID+用户类型+用户显示语言 + * @return 强制归档和强制回收显示 + */ + public String getMonitorLink(String workflowid_rs, String para2) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + String[] tempStr = Util.splitString(para2, "+"); + String workflowid = ""; + int formid = 0; + int isbill = 0; + String requestid = Util.null2String(tempStr[0]); + int userid = Integer.parseInt(Util.null2String(tempStr[1])); + int usertype = Integer.parseInt(Util.null2String(tempStr[2])); + int userlang = Integer.parseInt(Util.null2String(tempStr[3])); + int currentstatus = Util.getIntValue((Util.null2String(tempStr[4])), -1); + int creater = Util.getIntValue(Util.null2String(tempStr[5]), -1); + int currentnodetype = Util.getIntValue((Util.null2String(tempStr[6])), -1); +// String isNew = ""; +// try{ +// isNew = Util.null2String(tempStr[4]); +// }catch(Exception e){ +// } + + returnStr = ""; + boolean ishead = true; + boolean isForceDrawBack = false; + boolean isForceOver = false; + boolean issooperator = false; + rs.executeSql("select workflowid from workflow_requestbase where requestid=" + requestid); + if (rs.next()) { + workflowid = rs.getString("workflowid"); + } + Monitor monitor = new Monitor(); + MonitorDTO monitorInfo = monitor.getMonitorInfo(userid + "", creater + "", workflowid); + isForceDrawBack = monitorInfo.getIsforcedrawback(); + isForceOver = monitorInfo.getIsforceover(); + issooperator = monitorInfo.getIssooperator(); + + WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil(); + + User user = new User(); + user.setUid(userid); + WfFunctionManageUtil WfFunctionManageUtil = new WfFunctionManageUtil(); + boolean haveStopright = WfFunctionManageUtil.haveStopright(currentstatus, creater, user, "" + currentnodetype, -1, issooperator);//流程不为暂停或者撤销状态,当前用户为流程发起人或者系统管理员,并且流程状态不为创建和归档 + boolean haveCancelright = WfFunctionManageUtil.haveCancelright(currentstatus, creater, user, "" + currentnodetype, -1, issooperator);//流程不为撤销状态,当前用户为流程发起人,并且流程状态不为创建和归档 + boolean haveRestartright = WfFunctionManageUtil.haveRestartright(currentstatus, creater, user, "" + currentnodetype, -1, issooperator);//流程为暂停或者撤销状态,当前用户为系统管理员,并且流程状态不为创建和归档 + + haveStopright = haveStopright && !((formid == 158 || formid == 156) && isbill == 1); + haveCancelright = haveCancelright && !((formid == 158 || formid == 156) && isbill == 1); + haveRestartright = haveRestartright && !((formid == 158 || formid == 156) && isbill == 1); + + ////System.out.println("haveStopright : "+haveStopright+" haveCancelright : "+haveCancelright+" haveRestartright : "+haveRestartright+" currentstatus : "+currentstatus+" currentnodetype : "+currentnodetype+" creater : "+creater+" userid : "+userid); + if (haveStopright) { + if (ishead) { + returnStr += "
" + SystemEnv.getHtmlLabelName(20387, userlang) + ""; + ishead = false; + } else { + returnStr += "
" + SystemEnv.getHtmlLabelName(20387, userlang) + ""; + ishead = false; + } + + } + if (haveCancelright) { + if (ishead) { + returnStr += "
" + SystemEnv.getHtmlLabelName(16210, userlang) + ""; + ishead = false; + } else { + returnStr += "
" + SystemEnv.getHtmlLabelName(16210, userlang) + ""; + ishead = false; + } + } + if (haveRestartright) { + if (ishead) { + returnStr += "
" + SystemEnv.getHtmlLabelName(18095, userlang) + ""; + ishead = false; + } else { + returnStr += "
" + SystemEnv.getHtmlLabelName(18095, userlang) + ""; + ishead = false; + } + } + if (!haveRestartright || ((formid == 158 || formid == 156) && isbill == 1)) { + HashMap map = wfFunctionManageUtil.wfFunctionManageAsMonitor(Integer.parseInt(workflowid_rs)); + String ov = (String) map.get("ov"); + String rb = (String) map.get("rb"); + WfForceOver wfForceOver = new WfForceOver(); + if (isForceOver && "1".equals(ov) && !wfForceOver.isOver(Integer.parseInt(requestid))) { + // returnStr+="
"+SystemEnv.getHtmlLabelName(18360, userlang)+""; + returnStr += "
" + SystemEnv.getHtmlLabelName(18360, userlang) + ""; + ishead = false; + } + int tempuser = 1; + int tempusertype = 0; + rs.executeSql("select userid,usertype from workflow_currentoperator where requestid = " + requestid + " and isremark = '2' order by operatedate desc ,operatetime desc"); + if (rs.next()) { + tempuser = rs.getInt("userid"); + tempusertype = rs.getInt("usertype"); + } + int nodecounts = 0;//流程没有真正流转,没有强制收回 + rs.executeSql("select count(distinct nodeid) as nodecounts from workflow_currentoperator where requestid=" + requestid); + if (rs.next()) { + nodecounts = rs.getInt("nodecounts"); + } + WfForceDrawBack wfForceDrawBack = new WfForceDrawBack(); + if (nodecounts > 1 && isForceDrawBack && !"0".equals(rb) && wfForceDrawBack.isHavePurview(Integer.parseInt(requestid), userid, usertype, tempuser, tempusertype)) { + if (ishead) { + // returnStr+="
"+SystemEnv.getHtmlLabelName(18359, userlang)+""; + returnStr += "
" + SystemEnv.getHtmlLabelName(18359, userlang) + ""; + ishead = false; + } else { + // returnStr+="
"+SystemEnv.getHtmlLabelName(18359, userlang)+""; + returnStr += "
" + SystemEnv.getHtmlLabelName(18359, userlang) + ""; + ishead = false; + } + } + if (GCONST.getWorkflowIntervenorByMonitor()) { + if (monitorInfo.getIsintervenor() && currentnodetype != 3) { + if (ishead) { + returnStr += "
" + SystemEnv.getHtmlLabelName(18913, userlang) + ""; + ishead = false; + } else { + returnStr += "
" + SystemEnv.getHtmlLabelName(18913, userlang) + ""; + ishead = false; + } + } + } + } + if (!ishead) returnStr += "
"; + //System.out.println("======="+returnStr); + return returnStr; + } + + /** + * 获得子流程链接 + * + * @param requestId + * @param userLanguage 用户显示语言 + * @return 子流程链接 + */ + public String getSubWFLink(String requestId, String userLanguage) { + return this.getSubWFLink(requestId,userLanguage,true); + } + + /** + * 获得子流程链接 + * + * @param requestId + * @param userLanguage 用户显示语言 + * @return 子流程链接 + */ + public String getSubWFLink(String requestId, String userLanguage,boolean needCheck) { + int intUserLanguage = 7; + if (userLanguage != null && !userLanguage.equals("")) { + intUserLanguage = Integer.parseInt(userLanguage); + } + RecordSet rs = new RecordSet(); + String returnStr = ""; + rs.executeSql("select requestid from workflow_requestbase where mainRequestId=" + requestId); + if (rs.next() || !needCheck) { + returnStr = "" + SystemEnv.getHtmlLabelName(361, intUserLanguage) + ""; + } + return returnStr; + } + + /** + * 获得子流程链接 + * + * @param requestId + * @param userLanguage 用户显示语言 + * @return 子流程链接 + */ + public String getSubWFLinkNew(String requestId, String userLanguage) { + int intUserLanguage = 7; + if (userLanguage != null && !userLanguage.equals("")) { + intUserLanguage = Integer.parseInt(userLanguage); + } + String returnStr = "" + SystemEnv.getHtmlLabelName(361, intUserLanguage) + ""; + + return returnStr; + } + + /** + * 获得取消监控链接 + * + * @param workflowid + * @param hrmiduserLanguage 监控人 + * @return 取消监控链接 + */ + public String getCancleMoniter(String workflowid, String hrmiduserLanguage) { + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String userLanguage = Util.null2String(tempStr[1]); + String userid = Util.null2String(tempStr[2]); + int intUserLanguage = 7; + if (userLanguage != null && !userLanguage.equals("")) { + intUserLanguage = Integer.parseInt(userLanguage); + } + int operatelevel = 0; + if (tempStr.length > 3) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[3]), -1); + } + int detachable = 0; + if (tempStr.length > 4) { + detachable = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + String typeid = ""; + if (tempStr.length > 5) { + typeid = Util.null2String(tempStr[5]); + } + String subcompanyid = ""; + if (tempStr.length > 6) { + subcompanyid = Util.null2String(tempStr[6]); + } + String returnStr = ""; + + if (userid.equals("1")) {//系统管理员 + returnStr = "" + SystemEnv.getHtmlLabelName(10000154,intUserLanguage) + ""; + } else { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel > 0) {//有权限 + returnStr = "" + SystemEnv.getHtmlLabelName(10000154,intUserLanguage) + ""; + } else {//无权限 + returnStr = SystemEnv.getHtmlLabelName(10000154,intUserLanguage); + } + } else { + returnStr = "" + SystemEnv.getHtmlLabelName(10000154,intUserLanguage) + ""; + } + } + //String returnStr=""+SystemEnv.getHtmlLabelName(201,intUserLanguage)+SystemEnv.getHtmlLabelName(665,intUserLanguage)+""; + + return returnStr; + } + + /** + * 获得子流程列表的接收人 + * 子流程第二个节点(创建节点后节点)的操作人,当节点操作人为多个时显示多个 + * + * @param requestId 子流程的请求id + * @return 子流程列表的接收人 + */ + public String getSubWFReceiver(String requestId) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + int workflowId = 0; + int firstNodeId = 0; + int secondNodeId = 0; + String secondNodeIdStr = "0"; + int userId = 0; + int userType = 0; + + + rs.executeSql(" select workflowid from workflow_requestbase where requestid=" + requestId); + if (rs.next()) { + workflowId = rs.getInt(1); + } + + rs.executeSql("select nodeId from workflow_flownode where workflowid=" + workflowId + " and nodeType='0'"); + if (rs.next()) { + firstNodeId = rs.getInt(1); + } + + rs.executeSql("select destnodeid from workflow_nodelink where wfrequestid is null and workflowId=" + workflowId + " and EXISTS(select 1 from workflow_nodebase b where workflow_nodelink.destnodeid=b.id and (b.IsFreeNode is null or b.IsFreeNode!='1')) and nodeId=" + firstNodeId); + while (rs.next()) { + secondNodeId = rs.getInt(1); + secondNodeIdStr += "," + secondNodeId; + } + + rs.executeSql(" select userId,userType from workflow_currentoperator where requestid=" + requestId + " and nodeId in(" + secondNodeIdStr + ") "); + while (rs.next()) { + userId = rs.getInt(1); + userType = rs.getInt(2); + if (userType == 0) { + returnStr += " " + + "" + + rc.getResourcename(String.valueOf(userId)) + + ""; + } else if (userType == 1) { + returnStr += + "" + + cci.getCustomerInfoname(String.valueOf(userId)) + + ""; + } + } + + return returnStr; + } + + /** + * 获得子流程列表的请求说明 + * + * @param requestName 子流程的请求id + * @param paraTwo 流程id+用户ID + * 当前用户不是子流程操作人时,只显示名称,不能链接进入,否则可通过链接进入流程查看页面 + * @return 子流程列表的请求说明 + */ + public String getSubWFRequestDescription(String requestName, String paraTwo) { + RecordSet rs = new RecordSet(); + String returnStr = ""; + + String[] tempStr = Util.splitString(paraTwo, "+"); + String requestId = Util.null2String(tempStr[0]); + String userId = Util.null2String(tempStr[1]); + + boolean canView = false; + rs.executeSql("select requestId from workflow_currentoperator where requestid=" + requestId + " and userId=" + userId); + if (rs.next()) { + canView = true; + } + if (canView) { + returnStr = "" + requestName + ""; + } else { + returnStr = requestName; + } + ; + + return returnStr; + } + + /** + * 获得自定义显示字段的显示内容 + * + * @param paraTwo 字段ID+"+"+字段类型+"+"+字段类型+"+"+显示语言 + * @return 显示内容 + */ + public String getOthers(String fieldvalue, String paraTwo) { + RecordSet rs = new RecordSet(); + RecordSet RecordSet = new RecordSet(); + String returnStr = ""; + String sql = ""; + String[] tempStr = Util.splitString(paraTwo, "+"); + String fieldid = Util.null2String(tempStr[1]); + String fieldhtmltype = Util.null2String(tempStr[2]); + String fieldtype = Util.null2String(tempStr[3]); + int userlanguage = Util.getIntValue(Util.null2String(tempStr[4])); + String requestid = Util.null2String(tempStr[0]); + char flag = Util.getSeparator(); + String isbill = Util.null2String(tempStr[5]); + String dbtype = Util.null2String(tempStr[6]); + try { + if (fieldtype.equals("118")) { + returnStr = "" + SystemEnv.getHtmlLabelName(2193, userlanguage) + ""; + } + if (fieldhtmltype.equals("1") || fieldhtmltype.equals("2")) { // 单行,多行文本框 + + if (fieldhtmltype.equals("1") && fieldtype.equals("4")) { + returnStr = Util.milfloatFormat(fieldvalue); + //returnStr= Util.numtochinese(fieldvalue); + + } else { + returnStr = Util.toHtmlSearch(fieldvalue); + } + + } // 单行,多行文本框条件结束 + else if (fieldhtmltype.equals("3")) { // 浏览按钮 (涉及workflow_broswerurl表) + if (fieldtype.equals("2") || fieldtype.equals("19")) { // 日期和时间 + returnStr = fieldvalue; + + } else if (!fieldvalue.equals("")) { + String url = BrowserComInfo.getBrowserurl(fieldtype); // 浏览按钮弹出页面的url + String linkurl = BrowserComInfo.getLinkurl(fieldtype); // 浏览值点击的时候链接的url + String showname = ""; // 值显示的名称 + String showid = ""; // 值 + + ArrayList tempshowidlist = Util.TokenizerString(fieldvalue, ","); + if (fieldtype.equals("8") || fieldtype.equals("135")) { + //项目,多项目 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (!linkurl.equals("")) { + showname += "" + ProjectInfoComInfo1.getProjectInfoname((String) tempshowidlist.get(k)) + " "; + } else { + showname += ProjectInfoComInfo1.getProjectInfoname((String) tempshowidlist.get(k)) + " "; + } + } + } else if (fieldtype.equals("1") || fieldtype.equals("17")) { + //人员,多人员 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (!linkurl.equals("")) { + if ("/hrm/resource/HrmResource.jsp?id=".equals(linkurl)) { + showname += "" + rc.getResourcename((String) tempshowidlist.get(k)) + " "; + } else + showname += "" + rc.getResourcename((String) tempshowidlist.get(k)) + " "; + } else { + showname += rc.getResourcename((String) tempshowidlist.get(k)) + " "; + } + } + } else if (fieldtype.equals("7") || fieldtype.equals("18")) { + //客户,多客户 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (!linkurl.equals("")) { + showname += "" + cci.getCustomerInfoname((String) tempshowidlist.get(k)) + " "; + } else { + showname += cci.getCustomerInfoname((String) tempshowidlist.get(k)) + " "; + } + } + } else if (fieldtype.equals("4") || fieldtype.equals("57")) { + //部门,多部门 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (!linkurl.equals("")) { + showname += "" + DepartmentComInfo1.getDepartmentname((String) tempshowidlist.get(k)) + " "; + } else { + showname += DepartmentComInfo1.getDepartmentname((String) tempshowidlist.get(k)) + " "; + } + } + } else if (fieldtype.equals("9") || fieldtype.equals("37")) { + //文档,多文档 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (k > 0) showname += "
"; + + { + if (!linkurl.equals("")) { + showname += "" + DocComInfo1.getDocname((String) tempshowidlist.get(k)) + ""; + } else { + showname += DocComInfo1.getDocname((String) tempshowidlist.get(k)); + } + } + } + } else if (fieldtype.equals("23")) { + //资产 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (!linkurl.equals("")) { + showname += "" + CapitalComInfo1.getCapitalname((String) tempshowidlist.get(k)) + " "; + } else { + showname += CapitalComInfo1.getCapitalname((String) tempshowidlist.get(k)) + " "; + } + } + } else if (fieldtype.equals("16") || fieldtype.equals("152") || fieldtype.equals("171")) { + //相关请求 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (k > 0) showname += "
"; + if (!linkurl.equals("")) { + int tempnum = 0; + tempnum++; + + showname += "" + WorkflowRequestComInfo1.getRequestName((String) tempshowidlist.get(k)) + ""; + } else { + showname += WorkflowRequestComInfo1.getRequestName((String) tempshowidlist.get(k)); + } + } + } else if (fieldtype.equals("141")) { + //人力资源条件 + showname += rcm.getFormShowName(fieldvalue, userlanguage); + } +//add by fanggsh for TD4528 20060621 end + //added by alan for td:10814 + else if (fieldtype.equals("142")) { + //收发文单位 + for (int k = 0; k < tempshowidlist.size(); k++) { + if (!linkurl.equals("")) { + showname += "" + duc.getReceiveUnitName("" + tempshowidlist.get(k)) + " "; + } else { + showname += duc.getReceiveUnitName("" + tempshowidlist.get(k)) + " "; + } + } + } + //end by alan for td:10814 + else if (fieldtype.equals("161")) {//自定义单选 + showname = ""; // 新建时候默认值显示的名称 + String showdesc = ""; + showid = fieldvalue; // 新建时候默认值 + try { + Browser browser = (Browser) StaticObj.getServiceByFullname(dbtype, Browser.class); + BrowserBean bb = browser.searchById(showid); + String desc = Util.null2String(bb.getDescription()); + String name = Util.null2String(bb.getName()); +// showname=""+name+" "; + String href = Util.null2String(bb.getHref()); + if (href.equals("")) { + showname = "" + name + " "; + } else { + showname = "" + name + " "; + } + } catch (Exception e) { + } + } else if (fieldtype.equals("162")) {//自定义多选 + showname = ""; // 新建时候默认值显示的名称 + showid = fieldvalue; // 新建时候默认值 + try { + Browser browser = (Browser) StaticObj.getServiceByFullname(dbtype, Browser.class); + List l = Util.TokenizerString(showid, ","); + for (int j = 0; j < l.size(); j++) { + String curid = (String) l.get(j); + BrowserBean bb = browser.searchById(curid); + String name = Util.null2String(bb.getName()); + ////System.out.println("showname:"+showname); + String desc = Util.null2String(bb.getDescription()); +// showname+=""+name+" "; + String href = Util.null2String(bb.getHref()); + if (href.equals("")) { + showname += "" + name + " "; + } else { + showname += "" + name + " "; + } + } + } catch (Exception e) { + } + } else if (fieldtype.equals("224") || fieldtype.equals("225") || fieldtype.equals("226") || fieldtype.equals("227")) {//集成浏览按钮 + //System.out.println(paraTwo+"内容"+fieldvalue); + showname = fieldvalue; + } else { + String tablename = BrowserComInfo.getBrowsertablename(fieldtype); //浏览框对应的表,比如人力资源表 + String columname = BrowserComInfo.getBrowsercolumname(fieldtype); //浏览框对应的表名称字段 + String keycolumname = BrowserComInfo.getBrowserkeycolumname(fieldtype); //浏览框对应的表值字段 + fieldvalue = deleteFirstAndEndchar(fieldvalue, ","); + if (fieldvalue.indexOf(",") != -1) { + sql = "select " + keycolumname + "," + columname + " from " + tablename + " where " + keycolumname + " in( " + fieldvalue + ")"; + } else { + sql = "select " + keycolumname + "," + columname + " from " + tablename + " where " + keycolumname + "=" + fieldvalue; + } + RecordSet.executeSql(sql); + while (RecordSet.next()) { + if (!linkurl.equals("")) { + showname += "" + Util.toScreen(RecordSet.getString(2), userlanguage) + " "; + } else { + showname += Util.toScreen(RecordSet.getString(2), userlanguage) + " "; + } + } // end of while + } + + returnStr = showname; + + } + } // 浏览按钮条件结束 + else if (fieldhtmltype.equals("4")) { // check框 + returnStr = fieldvalue; + } // check框条件结束 + else if (fieldhtmltype.equals("5")) { // 选择框 select + // 查询选择框的所有可以选择的值 + rs.executeProc("workflow_SelectItemSelectByid", "" + fieldid + flag + isbill); + while (rs.next()) { + String tmpselectvalue = Util.null2String(rs.getString("selectvalue")); + String tmpselectname = Util.toScreen(rs.getString("selectname"), userlanguage); + if (fieldvalue.equals(tmpselectvalue)) { + returnStr = tmpselectname; + } + } + } else if (fieldhtmltype.equals("6")) { + if (!fieldvalue.equals("")) { + sql = "select id,docsubject,accessorycount from docdetail where id in(" + fieldvalue + ") order by id asc"; + int linknum = -1; + RecordSet.executeSql(sql); + while (RecordSet.next()) { + linknum++; + if (linknum > 0) returnStr += "
"; + String showid = Util.null2String(RecordSet.getString(1)); + String tempshowname = Util.toScreen(RecordSet.getString(2), userlanguage); + int accessoryCount = RecordSet.getInt(3); + + DocImageManager.resetParameter(); + DocImageManager.setDocid(Integer.parseInt(showid)); + DocImageManager.selectDocImageInfo(); + + String docImagefileid = ""; + long docImagefileSize = 0; + String docImagefilename = ""; + String fileExtendName = ""; + int versionId = 0; + + if (DocImageManager.next()) { + docImagefileid = DocImageManager.getImagefileid(); + docImagefileSize = DocImageManager.getImageFileSize(Util.getIntValue(docImagefileid)); + docImagefilename = DocImageManager.getImagefilename(); + fileExtendName = docImagefilename.substring(docImagefilename.lastIndexOf(".") + 1).toLowerCase(); + versionId = DocImageManager.getVersionId(); + } + + if (accessoryCount == 1 && (fileExtendName.equalsIgnoreCase("xls") || fileExtendName.equalsIgnoreCase("doc") || fileExtendName.equalsIgnoreCase("pdf"))) { + //returnStr= ""+docImagefilename+" "; + returnStr += "" + docImagefilename + " "; + } else { + returnStr += "" + tempshowname + " "; + } + } + } + } + } catch (Exception e) { + returnStr = ""; + } + return returnStr; + + } + + public String getWfNewLinkByUrger(String requestname, String para2) { + return this.getWfNewLinkByUrger(requestname, para2, false); + } + + public String getWfNewLinkByUrger(String requestname, String para2, boolean ismobile) { + return this.getWfNewLinkByUrger(requestname, para2, ismobile, false); + } + + public String getWfNewLinkByUrger_AttentionTag(String requestname, String para2, boolean ismobile) { + return this.getWfNewLinkByUrger(requestname, para2, ismobile, true); + } + + public String getWfNewLinkByUrger_AttentionTag(String requestname, String para2) { + return this.getWfNewLinkByUrger(requestname, para2, false, true); + } + + /** + * 流程标题显示样式(是否加图片等) + * + * @param requestname 流程标题 + * @param para2 流程ID+,+显示类型+,+用户语言 + * @return 流程标题显示样式 + */ + public String getWfNewLinkByUrger(String requestname, String para2, boolean ismobile, boolean showAttentionTag) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + String[] tempStr = Util.splitString(para2, "+"); + int requestid = Util.getIntValue(Util.null2String(tempStr[0])); + int workflowid = Util.getIntValue(Util.null2String(tempStr[1])); + int userid = Util.getIntValue(Util.null2String(tempStr[2]), 0); + int usertype = Util.getIntValue(Util.null2String(tempStr[3]), 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + int isbill = 0; + int formid = 0; + boolean isnew = false; +// String viewerSql = "select a.viewdate,a.viewtime from workflow_requestviewlog a "+ +// " where a.id="+requestid+ +// " and a.viewer="+userid+ +// " order by a.viewdate desc,a.viewtime desc"; +// +// String logSql = "select b.operator, b.operatedate,b.operatetime from workflow_requestlog b "+ +// " where b.requestid="+requestid+ +// " order by b.operatedate desc ,b.operatetime desc"; + //td + String newsql = "select b.lastoperatedate,b.lastoperatetime,b.creater,b.lastoperator, b.lastoperatortype from workflow_requestbase b where b.requestid = " + + requestid; + String requestdate = ""; + String viewdate = ""; + rs.execute(newsql); + if (rs.next()) { + if (userid != rs.getInt(4) || usertype != rs.getInt(5)) { + if ("".equals(Util.null2String(rs.getString(1))) || "".equals(Util.null2String(rs.getString(2)))) { + if (rs.getInt(3) != userid) { + newsql = "select w.viewdate from workflow_requestviewlog w where w.viewer=" + + userid + " and id=" + requestid; + rs.execute(newsql); + if (!rs.next()) { + isnew = true; + } + } + } else { + requestdate = rs.getString(1) + rs.getString(2); + newsql = "select max(w.viewdate) as viewdate,max(w.viewtime) as viewtime from workflow_requestviewlog w where w.viewer=" + + userid + " and id=" + requestid + " group by id"; + rs.execute(newsql); + if (rs.next()) { + viewdate = rs.getString(1) + rs.getString(2); + if (viewdate.compareTo(requestdate) < 0) { + isnew = true; + } + } else { + isnew = true; + } + } + } + } + ////根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + } + requestname = rbu.formatRequestname(requestname, workflowid + "", requestid + "", isbill, formid, userlang); + + String attentionTag = ""; + if (showAttentionTag) + attentionTag = new RequestAttentionBiz().getAttentionTag(requestid, userid, usertype, userlang); + + if (ismobile) { + if (isnew) { + requestname += ""; + } + return requestname + attentionTag; + } + if (isnew) { + //新流程,粗体链接加图片 + returnStr = "" + requestname + "" + attentionTag; + } else { + returnStr = "" + requestname + "" + attentionTag; + } + return returnStr; + } + + public String getWfNewLinkByUrgerExt(String requestname, String para2) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + String[] tempStr = Util.splitString(para2, "+"); + int requestid = Util.getIntValue(Util.null2String(tempStr[0])); + int workflowid = Util.getIntValue(Util.null2String(tempStr[1])); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + int isbill = 0; + int formid = 0; + + ////根据后台设置在MAIL标题后加上流程中重要的字段 + rs.execute("select formid,isbill from workflow_base where id=" + workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + } + requestname = rbu.formatRequestname(requestname, workflowid + "", requestid + "", isbill, formid, userlang); + + returnStr = "" + requestname + ""; + + return returnStr; + } + + public String getWfNewLinkImageExt(String requestid, String userid) { + + String returnStr = ""; + RecordSet rs = new RecordSet(); + String viewerSql = "select a.viewdate,a.viewtime from workflow_requestviewlog a " + + " where a.id=" + requestid + + " and a.viewer=" + userid + + " order by a.viewdate desc,a.viewtime desc"; + String logSql = "select b.operator, b.operatedate,b.operatetime from workflow_requestlog b " + + " where b.requestid=" + requestid + + " order by b.operatedate desc ,b.operatetime desc"; + String viewdate = ""; + String logdate = ""; + int operator = -1; + rs.execute(viewerSql); + if (rs.next()) { + viewdate = rs.getString(1) + rs.getString(2); + } + rs.execute(logSql); + if (rs.next()) { + operator = rs.getInt(1); + logdate = rs.getString(2) + rs.getString(3); + } + ////根据后台设置在MAIL标题后加上流程中重要的字段 + + + if (!(operator + "").equals(userid)) { + int compareResult = viewdate.compareTo(logdate); + if (compareResult < 0) { + //新流程,粗体链接加图片 + returnStr = ""; + } else { + returnStr = ""; + } + } else { + returnStr = ""; + } + return returnStr; + } + + /** + * 获得是否能查看流程内容 + * + * @param isview + * @param hrmiduserLanguage + * @return 是否能查看流程内容 + */ + public String getViewWorkflow(String isview, String hrmiduserLanguage) { + String returnstr = ""; + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + int intUserLanguage = Util.getIntValue(tempStr[2], 7); + String userid = Util.null2String(tempStr[3]); + int operatelevel = 0; + if (tempStr.length > 4) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + int detachable = 0; + if (tempStr.length > 5) { + detachable = Util.getIntValue(Util.null2String(tempStr[5]), -1); + } + String editString = ""; + if (!userid.equals("1")) { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel <= 0) {//无权限 + editString = " disabled "; + } + } + } + StringBuffer sb = new StringBuffer(); + if (Util.getIntValue(isview, 0) > 0) { + sb.append(""); + } else { + sb.append(""); + } + //if(Util.getIntValue(isview, 0)>0){ + //returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; + //}else{ + //returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; + //} + return sb.toString(); + } + + /** + * 获得是否能编辑流程表单 + * + * @param isview + * @param hrmiduserLanguage + * @return 是否能编辑流程表单 + */ + public String getEditWorkflow(String isview, String hrmiduserLanguage) { + String returnstr = ""; + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + int intUserLanguage = Util.getIntValue(tempStr[2], 7); + String userid = Util.null2String(tempStr[3]); + int operatelevel = 0; + if (tempStr.length > 4) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + int detachable = 0; + if (tempStr.length > 5) { + detachable = Util.getIntValue(Util.null2String(tempStr[5]), -1); + } + String editString = ""; + if (!userid.equals("1")) { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel <= 0) {//无权限 + editString = " disabled "; + } + } + } + StringBuffer sb = new StringBuffer(); + if (Util.getIntValue(isview, 0) > 0) { + sb.append(""); + } else { + sb.append(""); + } + //if(Util.getIntValue(isview, 0)>0){ + //returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; + //}else{ + //returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; + //} + return sb.toString(); + } + + /** + * 获得是否允许流程干预 + * + * @param isintervenor + * @param hrmiduserLanguage + * @return 是否允许流程干预 + */ + public String getIntervenorWorkflow(String isintervenor, String hrmiduserLanguage) { + String returnstr = ""; + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + int intUserLanguage = Util.getIntValue(tempStr[2], 7); + String userid = Util.null2String(tempStr[3]); + int operatelevel = 0; + if (tempStr.length > 4) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + int detachable = 0; + if (tempStr.length > 5) { + detachable = Util.getIntValue(Util.null2String(tempStr[5]), -1); + } + String editString = ""; + if (!userid.equals("1")) { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel <= 0) {//无权限 + editString = " disabled "; + } + } + } + StringBuffer sb = new StringBuffer(); + if (Util.getIntValue(isintervenor, 0) > 0) { + sb.append(""); + } else { + sb.append(""); + } +// if(Util.getIntValue(isintervenor, 0)>0){ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// }else{ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// } + return sb.toString(); + } + + /** + * 获得是否允许删除 + * + * @param isdelete + * @param hrmiduserLanguage + * @return 是否允许流程干预 + */ + public String getDelWorkflow(String isdelete, String hrmiduserLanguage) { + String returnstr = ""; + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + int intUserLanguage = Util.getIntValue(tempStr[2], 7); + String userid = Util.null2String(tempStr[3]); + int operatelevel = 0; + if (tempStr.length > 4) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + int detachable = 0; + if (tempStr.length > 5) { + detachable = Util.getIntValue(Util.null2String(tempStr[5]), -1); + } + String editString = ""; + if (!userid.equals("1")) { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel <= 0) {//无权限 + editString = " disabled "; + } + } + } + StringBuffer sb = new StringBuffer(); + if (Util.getIntValue(isdelete, 0) > 0) { + sb.append(""); + } else { + sb.append(""); + } +// if(Util.getIntValue(isdelete, 0)>0){ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// }else{ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// } + return sb.toString(); + } + + /** + * 获得是否允许强制归档 + * + * @param isforceover + * @param hrmiduserLanguage + * @return 是否允许流程干预 + */ + public String getFOWorkflow(String isforceover, String hrmiduserLanguage) { + String returnstr = ""; + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + int intUserLanguage = Util.getIntValue(tempStr[2], 7); + String userid = Util.null2String(tempStr[3]); + int operatelevel = 0; + if (tempStr.length > 4) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + int detachable = 0; + if (tempStr.length > 5) { + detachable = Util.getIntValue(Util.null2String(tempStr[5]), -1); + } + String editString = ""; + if (!userid.equals("1")) { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel <= 0) {//无权限 + editString = " disabled "; + } + } + } + StringBuffer sb = new StringBuffer(); + if (Util.getIntValue(isforceover, 0) > 0) { + sb.append(""); + } else { + sb.append(""); + } +// if(Util.getIntValue(isforceover, 0)>0){ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// }else{ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// } + return sb.toString(); + } + + /** + * 获得是否暂停撤销启用 + * + * @param + * @param hrmiduserLanguage + * @return 是否暂停撤销启用 + */ + public String getSOWorkflow(String issooperator, String hrmiduserLanguage) { + String returnstr = ""; + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + int intUserLanguage = Util.getIntValue(tempStr[2], 7); + String userid = Util.null2String(tempStr[3]); + int operatelevel = 0; + if (tempStr.length > 4) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + int detachable = 0; + if (tempStr.length > 5) { + detachable = Util.getIntValue(Util.null2String(tempStr[5]), -1); + } + String editString = ""; + if (!userid.equals("1")) { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel <= 0) {//无权限 + editString = " disabled "; + } + } + } + StringBuffer sb = new StringBuffer(); + if (Util.getIntValue(issooperator, 0) > 0) { + sb.append(""); + } else { + sb.append(""); + } +// if(Util.getIntValue(issooperator, 0)>0){ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// }else{ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// } + return sb.toString(); + } + + /** + * 获得是否允许强制收回 + * + * @param isForceDrawBack + * @param hrmiduserLanguage + * @return 是否允许流程干预 + */ + public String getFBWorkflow(String isForceDrawBack, String hrmiduserLanguage) { + String returnstr = ""; + String[] tempStr = Util.splitString(hrmiduserLanguage, "+"); + String hrmid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + int intUserLanguage = Util.getIntValue(tempStr[2], 7); + String userid = Util.null2String(tempStr[3]); + int operatelevel = 0; + if (tempStr.length > 4) { + operatelevel = Util.getIntValue(Util.null2String(tempStr[4]), -1); + } + int detachable = 0; + if (tempStr.length > 5) { + detachable = Util.getIntValue(Util.null2String(tempStr[5]), -1); + } + String editString = ""; + if (!userid.equals("1")) { + /*rs.executeSql("select detachable from SystemSet"); + int detachable=0; + if(rs.next()){ + detachable=rs.getInt("detachable"); + }*/ + if (detachable == 1) {//分权情况下要判断是否有权限删除 + //rs.executeSql("select * from workflow_monitor_bound where monitorhrmid="+hrmid+" and workflowid="+workflowid+" and operator="+userid); + if (operatelevel <= 0) {//无权限 + editString = " disabled "; + } + } + } + StringBuffer sb = new StringBuffer(); + if (Util.getIntValue(isForceDrawBack, 0) > 0) { + sb.append(""); + } else { + sb.append(""); + } +// if(Util.getIntValue(isForceDrawBack, 0)>0){ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// }else{ +// returnstr= ""+SystemEnv.getHtmlLabelName(115,intUserLanguage)+""+SystemEnv.getHtmlLabelName(17875,intUserLanguage)+""; +// } + return sb.toString(); + } + + /** + * 是否在列表显示选择筐 + * + * @param workflowid 流程ID + * @return true/false + */ + @Deprecated + public String getWFMonitorCheckBox(String workflowid) { + String[] tempStr = Util.splitString(workflowid, "+"); + RecordSet rs = new RecordSet(); + int wfid = Util.getIntValue(tempStr[0]); + int hrmid = Util.getIntValue(tempStr[1]); + int logintype = Util.getIntValue(tempStr[2], 1); + String flag = "false"; + if (logintype == 1) { + rs.executeSql("select workflowid from workflow_monitor_bound where (isdelete='1' or isforceover='1') and workflowid=" + wfid + " and monitorhrmid=" + hrmid); + if (rs.next()) { + flag = "true"; + } + } + return flag; + } + + /** + * 获得流程耗时统计报表里的未操作者 + * + * @param requestid + * @return + */ + public String getUnOperatorsForStat(String requestid) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid from workflow_currentoperator where (isremark in ('0','1') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + while (rs.next()) { + if (returnStr.equals("")) { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += rc.getResourcename(rs.getString("userid")); + } else { + returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } else { + if (rs.getInt("usertype") == 0) { + if (rs.getInt("agenttype") == 2) + returnStr += "," + rc.getResourcename(rs.getString("agentorbyagentid")) + "->" + rc.getResourcename(rs.getString("userid")); + else + returnStr += "," + rc.getResourcename(rs.getString("userid")); + } else { + returnStr += cci.getCustomerInfoname(rs.getString("userid")); + } + } + } + return returnStr; + } + + /** + * 去除前后指定字符 + * + * @param str + * @param splitstr + * @return + */ + public String deleteFirstAndEndchar(String str, String splitstr) { + boolean needround = false; + if (str.substring(0, splitstr.length()).equals(splitstr)) { + str = str.substring(splitstr.length()); + needround = true; + } + if (str.substring(str.length() - splitstr.length()).equals(splitstr)) { + str = str.substring(0, str.length() - splitstr.length()); + needround = true; + } + if (needround) { + return deleteFirstAndEndchar(str, splitstr); + } else { + return str; + } + } + + public String getIsmultiprintStr(String ismultiprint, String language) { + String retStr = ""; + try { + int languageid = Util.getIntValue(language, 7); + if ("1".equals(ismultiprint)) { + retStr = SystemEnv.getHtmlLabelName(27046, languageid); + } else { + retStr = SystemEnv.getHtmlLabelName(27045, languageid); + } + } catch (Exception e) { + retStr = SystemEnv.getHtmlLabelName(27045, 7); + } + return retStr; + } + + /** + * 流程标题显示样式(是否加图片等),区分颜色 + * + * @param requestname 流程标题 + * @param para2 请求ID + 流程ID + 显示类型 + 是否超时 + 用户语言 + 节点ID currentnodeid + 操作人类性isremark+用户id userID+ 代理人/被代理人ID + 代理/被代理类型 + * @return 流程标题显示样式 + */ + public String getWfNewLinkWithTitleNoAdditional(String requestname, String para2) { + String returnStr = ""; + + String[] tempStr = Util.splitString(para2, "+"); + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int isovertime = Util.getIntValue(tempStr[3], 0); + int userlang = Util.getIntValue(Util.null2String(tempStr[4]), 7); + String nodeid = Util.null2String(tempStr[5]); + String isremark = Util.null2String(tempStr[6]); + String userID = Util.null2String(tempStr[7]); + String isprocessedvalue = ""; + if (tempStr.length >= 11) { + isprocessedvalue = Util.null2String(tempStr[10]); + } + + String agentorbyagentid = ""; + String agenttype = ""; + + if (tempStr.length >= 10) { + agenttype = Util.null2String(tempStr[9]); + } + boolean isprocessed = false; + if ((isremark.equals("0") && (isprocessedvalue.equals("0") || isprocessedvalue.equals("3") || isprocessedvalue.equals("2"))) || isremark.equals("5")) { + isprocessed = true; + } + if (viewtype.equals("0")) { + //新流程,粗体链接加图片 + if (isprocessed) { + returnStr = "" + requestname + ""; + } else if ("1".equals(agenttype)) { + returnStr = "" + requestname + ""; + } else { + returnStr = "" + requestname + ""; + } + } else if (viewtype.equals("-1")) { + //旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessed) { + returnStr = "" + requestname + ""; + } else { + returnStr = "" + requestname + ""; + } + } else { + //旧流程,普通链接 + if (isprocessed) { + returnStr = "" + requestname + ""; + } else { + returnStr = "" + requestname + ""; + } + } + return returnStr; + } + + /** + * 流程接口部署列表的checkbox框 + */ + public String getInterfaceChecBox(String deployStatus) { + deployStatus = Util.null2String(deployStatus); + if (deployStatus.equals("1")) { + return "false"; + } + return "true"; + } + + /** + * 流程接口部署详细的checkbox框 + */ + public String getInterfaceDetailChecBox(String id) { + return "true"; + } + + /** + * 流程接口部署状态描述 + */ + public String getDeployDesc(String value) { + value = Util.null2String(value); + if (value.equals("1")) { + return ""+ SystemEnv.getHtmlLabelName(388229, ThreadVarLanguage.getLang())+""; + } + return ""+ SystemEnv.getHtmlLabelName(10003627, ThreadVarLanguage.getLang())+""; + } + + /** + * 流程接口封存状态描述 + */ + public String getClosedDesc(String value) { + value = Util.null2String(value); + if (value.equals("1")) { + return ""+ SystemEnv.getHtmlLabelName(22151, ThreadVarLanguage.getLang())+""; + } + return ""+ SystemEnv.getHtmlLabelName(1984, ThreadVarLanguage.getLang())+""; + } + + /** + * 类型描述 + */ + public String getTypeDesc(String isnode, String ispreadd) { + isnode = Util.null2String(isnode); + ispreadd = Util.null2String(ispreadd); + if (isnode.equals("0")) { + return ""+ SystemEnv.getHtmlLabelName(15587, ThreadVarLanguage.getLang())+""; + } + if (ispreadd.equals("0")) { + return ""+ SystemEnv.getHtmlLabelName(31705, ThreadVarLanguage.getLang())+""; + } + return ""+ SystemEnv.getHtmlLabelName(31706, ThreadVarLanguage.getLang())+""; + } + + /** + * 流程接口部署显示操作 + */ + public List getInterfaceOperate(String id, String deployStatus, String closed) { + List returnList = new ArrayList(); + if (deployStatus.equals("1")) { + returnList.add("false"); + returnList.add("true"); + } else { + returnList.add("true"); + returnList.add("false"); + } + if (closed.equals("1")) { + returnList.add("false"); + returnList.add("true"); + } else { + returnList.add("true"); + returnList.add("false"); + } + return returnList; + } + + /** + * 流程接口部署详细显示操作 + */ + public List getInterfaceDetailOperate(String id) { + List returnList = new ArrayList(); + returnList.add("true"); + return returnList; + } + + public List getshowTransOperate(String id) { + List delList = new ArrayList(); + delList.add("true"); + return delList; + } + + /** + * 仅用于浏览按钮功能的演示,请不要用于真实的场景 + * 该功能最终的目的是返回一个JSON格式的字符串, + * 具体的格式为:[{"browserValue":"11111","browserSpanValue":"张三"},{"browserValue":"2222","browserSpanValue":"李四"}] + * browserValue对应的是页面上的浏览按钮的隐藏域中的值,比如人的ID、客户的ID等 + * browserSpanValue对应的是页面上的浏览按钮显示的中文名称,比如人的名称、客户的名称等 + * 从对象到字符串的转换可以用JsonUtils.list2json,非常方便;当然你也可以自己写其他的方法去拼,只要格式正确就可以 + */ + public String getBrowserPerson(String requestid, String para) { + String[] tempStr = Util.splitString(para, "+"); + String userid = Util.null2String(tempStr[1]); + String showoperators = ""; + RecordSet rs = new RecordSet(); + try { + showoperators = "0".equals(RequestDefaultComInfo.getShowoperator("" + userid)) ? "0" : "1"; + } catch (Exception eshows) { + } + ArrayList> maps = new ArrayList>(); + if (showoperators.equals("1")) { + rs.executeSql("select distinct userid,usertype,agenttype,agentorbyagentid from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + + while (rs.next()) { + if (rs.getInt("usertype") == 0) { + String personId = rs.getString("userid"); + String persoonName = rc.getResourcename(personId); + HashMap map = new HashMap(); + map.put("browserValue", personId); + map.put("browserSpanValue", persoonName); + maps.add(map); + } + } + } + return JsonUtils.list2json(maps); + } + + public String getWFMultiSubmit(String wfid, int nodeid, String isremark, int takisremark) { + String returnstr = "0"; + RecordSet rs = new RecordSet(); + + if (!"".equals(wfid.trim()) && StringUtils.isNumeric(wfid)) { + rs.execute("select multiSubmit,submittype from WORKFLOW_BASE WHERE ID = " + wfid); + while (rs.next()) { + int multiSubmit = Util.getIntValue(rs.getString("multiSubmit"), 0); + int submittype = Util.getIntValue(rs.getString("submittype"), 0); + + if (multiSubmit == 1) { + if (("1".equals(isremark) && takisremark != 2) || "9".equals(isremark)) {//转发,抄送只判断有没有开启批量提交开关,不判断节点 + returnstr = "1"; + } else { + if (submittype == 0) {//全部 + returnstr = "1"; + } else { + //自由节点,集成发起节点的配置 + rs.execute("select startnodeid from workflow_nodebase where isfreenode = 1 and id = " + nodeid); + if (rs.next()) { + int startnodeid = Util.getIntValue(rs.getString(1), -1); + if (startnodeid != -1) + nodeid = startnodeid; + } + nodeid = FreeNodeBiz.getExtendNodeId(nodeid); + rs.execute("select 1 from workflow_flownode where workflowid = " + wfid + " and nodeid = " + nodeid + " and batchsubmit = 1"); + if (submittype == 1) {//选择节点 + if (rs.next()) { + returnstr = "1"; + } + } else if (submittype == 2) {//排除节点 + if (!rs.next()) { + returnstr = "1"; + } + } + } + } + } + } + } + return returnstr; + } + + // modigy by wwp 20190906 + public String getWorkflowname(String workflowid, String sysid) { + String rtnStr = ""; + if (workflowid.indexOf("-") != -1) { + RecordSet rs = new RecordSet(); + rs.executeSql("select workflowname from ofs_workflow where workflowid=" + workflowid); + rs.next(); + rtnStr = Util.null2String(rs.getString(1)); + } else { + rtnStr = wci.getWorkflowname(workflowid); + } + // 下面方法使返回的 【系统名称】- 流程名称 + if (sysid != null) { + RequestUtil requestutil = new RequestUtil(); + OfsSettingObject ofso = requestutil.getOfsSetting(); + String showSysname = ofso.getShowsysname(); + if ("1".equals(showSysname) || "2".equals(showSysname)) { + // workflowid < 0 为异构系统 >0 为泛微oa 获取简称 或全称 + if (workflowid.indexOf("-") != -1) { + if (sysid == "") { + RecordSet recordSet = new RecordSet(); + String getSysidSql = " select sysid from ofs_workflow where workflowid = ? "; + recordSet.executeQuery(getSysidSql, workflowid); + recordSet.next(); + sysid = recordSet.getString("sysid"); + } + rtnStr = "【" + requestutil.getSysname(sysid, showSysname) + "】-" + rtnStr; // 要添加的异构系统前缀 + + } else { + if ("1".equals(showSysname)) { + rtnStr = "【" + ofso.getOashortname() + "】-" + rtnStr; + } else if ("2".equals(showSysname)) { + rtnStr = "【" + ofso.getOafullname() + "】-" + rtnStr; + } + } + } + + + } + return rtnStr; + } + + public String getWorkflowname(String workflowid) { + /*if(workflowid.indexOf("-")!=-1){ + RecordSet rs = new RecordSet(); + rs.executeSql("select workflowname from ofs_workflow where workflowid="+workflowid); + rs.next(); + return Util.null2String(rs.getString(1)); + }else{ + return wci.getWorkflowname(workflowid); + }*/ + return this.getWorkflowname(workflowid, null); + } + + public String getCurrentNode(String currentnodeid, String requestid) { + String returnStr = ""; + RecordSet rs = new RecordSet(); + if (currentnodeid.equals("-1")) { + if(rs.getDBType().equals("oracle")){ + rs.executeSql("select nodename from (select nodename,operatedate, operatetime from ofs_todo_data where requestid = "+requestid + " union all select nodename,operatedate, operatetime from ofs_done_data where requestid = "+requestid +") t1 where rownum = 1 order by operatedate desc, operatetime desc" ); + }else if(rs.getDBType().equals("mysql")){ + rs.executeSql("select nodename from (select nodename,operatedate, operatetime from ofs_todo_data where requestid = "+requestid + " union all select nodename,operatedate, operatetime from ofs_done_data where requestid = "+requestid +") t1 order by operatedate desc, operatetime desc limit 1" ); + }else if(rs.getDBType().equals("postgresql")){ + rs.executeSql("select nodename from (select nodename,operatedate, operatetime from ofs_todo_data where requestid = "+requestid + " union all select nodename,operatedate, operatetime from ofs_done_data where requestid = "+requestid +") t1 order by operatedate desc, operatetime desc limit 1" ); + }else{ + rs.executeSql("select top 1 nodename from (select nodename,operatedate, operatetime from ofs_todo_data where requestid = "+requestid + " union all select nodename,operatedate, operatetime from ofs_done_data where requestid = "+requestid +") t1 order by operatedate desc, operatetime desc" ); + } + } else { + return WorkflowBaseBiz.getWorkflowNodeName(Util.getIntValue(currentnodeid)); + } + if (rs.next()) { + returnStr = rs.getString("nodename"); + } + + return returnStr; + } + + /** + * 获取接收时间 + * + * @param requestid + * @param para + * @return + */ + public String getWFUrgerRecievedate(String requestid, String para) { + RecordSet rs = new RecordSet(); + String returnStr = ""; + if (rs.getDBType().equals("oracle")) { + rs.executeSql("select max(receivedate||' '||receivetime) as receivedatetime from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + } else if (rs.getDBType().equals("mysql")) { + rs.executeSql("select max(concat(receivedate, ' ' ,receivetime)) as receivedatetime from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + } + else if (rs.getDBType().equals("postgresql")) { + rs.executeSql("select max(receivedate||' '||receivetime) as receivedatetime from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + } + else { + rs.executeSql("select max(receivedate +' '+ receivetime) as receivedatetime from workflow_currentoperator where (isremark in ('0','1','5','7','8','9') or (isremark='4' and viewtype=0)) and requestid = " + requestid); + } + if (rs.next()) { + returnStr = Util.null2String(rs.getString("receivedatetime")); + } + return returnStr; + } + + //获取异构系统的url + public String getAppUrl(String requestid, String para) { + String[] tempStr = Util.splitString(para, "+"); + String sysid = tempStr[0]; + String workflowid = tempStr[1]; + String userid = tempStr[2]; + String showtype = tempStr[3]; + //RequestUtil ru = new RequestUtil(); + if (Util.getIntValue(requestid) > 0 || "".equals(Util.null2String(requestid))) { + return ""; + } else { + OfsTodoDataUtils ofsUtils = new OfsTodoDataUtils(); + return ofsUtils.getShowUrl(sysid,requestid,userid,showtype);//集成新方法获取appurl + //return ru.getShowUrl(sysid, workflowid, requestid, userid, showtype); + } + } + + /** + * 格式化金额 + * + * @param amt + * @param para + * @return + */ + public String formatAmount(String amt, String para) { + DecimalFormat df = new DecimalFormat("####################################################0.00"); + if ("".equals(amt)) { + amt = "0.00"; + } + String amtStr = df.format(Util.getDoubleValue(amt, 0.00)); + return "" + df.format(Math.abs(Util.getDoubleValue(amtStr))) + ""; + } + + /** + * 格式化金额2 + * + * @param amt + * @param para + * @return + */ + public String formatAmount2(String amt, String para) { + DecimalFormat df = new DecimalFormat("####################################################0.00"); + if ("".equals(amt)) { + amt = "0.00"; + } + String amtStr = df.format(Util.getDoubleValue(amt, 0.00)); + return df.format(Math.abs(Util.getDoubleValue(amtStr))); + } + + //反馈黄点提示判断 + public boolean isNeedBack(String paraNeedBack, String viewtype) { + String tempStr4NeedBack[] = Util.splitString(paraNeedBack, "+"); + return isNeedBack(tempStr4NeedBack, viewtype); + } + + //反馈黄点提示判断 + public static boolean isNeedBack(String tempStr4NeedBack[], String viewtype) { + String viewDate = Util.null2String(tempStr4NeedBack[0]).trim(); + String viewTime = Util.null2String(tempStr4NeedBack[1]).trim(); + String lastFeedBackDate = Util.null2String(tempStr4NeedBack[2]).trim(); + String lastFeedBackTime = Util.null2String(tempStr4NeedBack[3]).trim(); + String needwfback = Util.null2String(tempStr4NeedBack[4]).trim(); + String lastFeedBackOperator = Util.null2String(tempStr4NeedBack[5]).trim(); + String userid = Util.null2String(tempStr4NeedBack[6]).trim(); + if ("".equals(lastFeedBackDate) || "".equals(lastFeedBackTime) || lastFeedBackOperator.equals(userid) || ("".equals(lastFeedBackOperator) && !"".equals(lastFeedBackDate))) { + return false; + } else { + return ("-2".equals(viewtype) && "1".equals(needwfback) && (lastFeedBackDate + " " + lastFeedBackTime).compareTo((viewDate + " " + viewTime).trim()) > 0); + } + } + + public String getUnoperatorNew(String requestid,String para){ + String paraArr[] = Util.splitString(para,"+"); + String userid = paraArr[0]; + String userLanguage = paraArr[1]; + String realuserid = paraArr.length > 2 ? paraArr[2] : ""; + String moduleId = paraArr.length > 3 ? Util.null2String(paraArr[3]) : "";//用于区分同一个页面,两个不同模块都显示未操作者,区分spanid + if("0".equals(RequestDefaultComInfo.getShowoperator("" + userid))){//开启默认显示未操作者,则和原本的处理方式相同,并且受控折行开关 + String returnStr = ""; + returnStr += "" + SystemEnv.getHtmlLabelName(89, Util.getIntValue(userLanguage)) + ""; + returnStr += ""; + return returnStr; + }else{//否则异步加载 + return ""; + } + } + + /** + * 增加urlParams作为一些特殊场景自动携带一些参数:比如默认携带监控参数,主要用在后台的权限转移,其他入口进来urlParams默认是空 luosy 2019/1/17 + * + * @param requestname + * @param para2 + * @param needFormat + * @param urlParams + * @return + */ + public String commonReqNameTransMethod(String requestname, String para2, boolean needFormat, String urlParams, boolean showAttentionTag) { + String[] tempStr = null; + boolean isNeedBack = false; + if (para2.startsWith("S")) { + String[] tempStr_tmp = Util.splitString(para2, "+"); + tempStr = Arrays.copyOfRange(tempStr_tmp, 9, tempStr_tmp.length); + isNeedBack = isNeedBack(Arrays.copyOfRange(tempStr_tmp, 1, 8), Util.null2String(tempStr[2])); + } else { + tempStr = Util.splitString(para2, "+"); + } + RecordSet rs = new RecordSet(); + String returnStr = ""; + String requestid = Util.null2String(tempStr[0]); + String workflowid = Util.null2String(tempStr[1]); + String viewtype = Util.null2String(tempStr[2]); + int userlang = Util.getIntValue(Util.null2String(tempStr[3]), 7); + String nodeid = Util.null2String(tempStr[4]); + String isremark = Util.null2String(tempStr[5]); + String userID = Util.null2String(tempStr[6]); + String agenttype = Util.null2String(tempStr[8]); + String isbereject = Util.null2String(tempStr[13]); + String isprocessed = Util.null2String(tempStr[9]); + String takisremark = Util.null2String(tempStr[14]); + + String nodetitle = ""; + if (needFormat) { + int isbill = 0; + int formid = 0; + // //根据后台设置在MAIL标题后加上流程中重要的字段 + rs.executeQuery("select formid,isbill from workflow_base where id=?",workflowid); + if (rs.next()) { + formid = rs.getInt(1); + isbill = rs.getInt(2); + + } + requestname = rbu.formatRequestname(requestname, workflowid, requestid, isbill, formid, userlang); + } + + //判断是否显示【退回】【代理】标识及超时紫点 + boolean isprocessedTip = false; + boolean hasAgentTip = false; + boolean hasRejectTip = false; + if ((isremark.equals("0") && (isprocessed.equals("0") || isprocessed.equals("3") || isprocessed.equals("2"))) || isremark.equals("5")) { + isprocessedTip = true; + } + if ("2".equals(agenttype) && (("0".equals(isremark) && !"-2".equals(takisremark)) || "1".equals(isremark) || "7".equals(isremark) || "8".equals(isremark) || "9".equals(isremark) || "11".equals(isremark))) { + hasAgentTip = true; + } + if ("1".equals(isbereject) && ("0".equals(isremark) && !"-2".equals(takisremark))) { + hasRejectTip = true; + } + + // 改为按要求显示自定义流程标题的前缀信息 + if ("0".equals(isremark)) { + rs.executeSql("select nodetitle from workflow_flownode where workflowid=" + workflowid + " and nodeid=" + nodeid); + if (rs.next()) { + nodetitle = Util.null2String(rs.getString("nodetitle")); + } + } + if (!"".equals(nodetitle) && !"null".equalsIgnoreCase(nodetitle)) { + nodetitle = "(" + nodetitle + ")"; + requestname = nodetitle + requestname; + } + if (hasAgentTip) { + requestname = SystemEnv.getHtmlLabelName(390272, userlang) + requestname; + } + if (hasRejectTip) { + requestname = SystemEnv.getHtmlLabelName(390271, userlang) + requestname; + } + + String attentionTag = ""; + if (showAttentionTag) + attentionTag = new RequestAttentionBiz().getAttentionTag(Util.getIntValue(requestid), Util.getIntValue(userID), 0, userlang); + + if (viewtype.equals("0")) { + // 新流程,粗体链接加图片 + if (isprocessedTip) { + returnStr = "" + + requestname + + "" + attentionTag; + } else if ("1".equals(agenttype)) { + returnStr = "" + + requestname + + ""; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else if (viewtype.equals("-1") || isNeedBack) { + // 旧流程,有新的提交信息未查看,普通链接加图片 + if (isprocessedTip) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } else { + // 旧流程,普通链接 + if (isprocessedTip) { + returnStr = "" + + requestname + + "" + attentionTag; + } else { + returnStr = "" + + requestname + + "" + attentionTag; + } + } + return returnStr; + } + + public String getFormValue(String requestid,String para){ + writeLog("getFormValue:requestid::"+requestid); + writeLog("getFormValue:para::"+para); + String returnStr = ""; + String paraArr[] = Util.splitString(para,"+"); + String fieldName = paraArr[0]; + String workflowid = paraArr[1]; + requestid = paraArr[2]; + RecordSet rs = new RecordSet(); + String formId = wf.getFormId(workflowid); + String tablename = wcInfo.getTablename(formId); + String fieldid = ""; + String fieldhtmltype = ""; + String fielddbtype = ""; + String fieldvalue = ""; + String type = ""; + rs.executeQuery("select id,fieldhtmltype,fielddbtype,type from workflow_billfield where billid = ? and fieldname = ?",Util.getIntValue(formId),fieldName); + if(rs.next()){ + fieldid = rs.getString(1); + fieldhtmltype = rs.getString(2); + fielddbtype = rs.getString(3); + type = rs.getString(4); + } + rs.executeQuery("select "+fieldName +" from "+tablename + " where requestid = ?", Util.getIntValue(requestid)); + if(rs.next()){ + fieldvalue = rs.getString(1); + } + if ("3".equals(fieldhtmltype)){ + List browserFieldValue = this.getBrowserFieldValue(type, fieldvalue, fielddbtype); + for(BrowserValueInfo info : browserFieldValue){ + String name = info.getName(); + returnStr += name +","; + } + if (returnStr.endsWith(",")){ + returnStr = returnStr.substring(0,returnStr.length()-1); + } + } + if ("5".equals(fieldhtmltype)){ + returnStr = this.getSelectFieldValue(fieldid, fieldvalue); + } + return returnStr; + } + + /** + * 获取选择框选中值 + * */ + public String getSelectFieldValue(String fieldId, String selectValue) { + String selectValueName = ""; + RecordSet rs = new RecordSet(); + String sql = "select selectvalue,selectname from workflow_selectitem where selectvalue = ? and fieldid=? and (cancel<>'1' or cancel is null) order by listorder,selectvalue"; + rs.executeQuery(sql,selectValue, fieldId); + if (rs.next()) { + selectValueName = Util.null2String(rs.getString("selectname")); + } + return selectValueName; + } + + /** + * 获取浏览按钮的值 + * */ + public List getBrowserFieldValue(String fieldType, String fieldValue, String fieldDbType) { + BrowserValueInfoService browserValueInfoService = new BrowserValueInfoService(); + List result = new ArrayList<>(); + try { + result= browserValueInfoService.getBrowserValueInfo(fieldType, fieldDbType, 0, fieldValue, 7, "", ""); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } +} diff --git a/weavernorth/com/testDateKey.jsp b/weavernorth/com/testDateKey.jsp new file mode 100644 index 0000000..8d994c2 --- /dev/null +++ b/weavernorth/com/testDateKey.jsp @@ -0,0 +1,25 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.BaseBean" %> + +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.common.util.ParamUtil" %> +<%@ page import="java.util.Map" %> +<%@ page import="com.weaverboot.weaComponent.impl.weaTable.table.impl.DefaultWeaTable" %> +<%@ page import="com.weaverboot.tools.componentTools.table.WeaTableTools" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> + + +<%! + +%> +<% + + + Map param = ParamUtil.request2Map(request); + String dataKey = (String) param.get("dataKey"); + DefaultWeaTable defaultWeaTable = WeaTableTools.checkTableStringConfig(dataKey, DefaultWeaTable.class); + + +%> +