master
rengp 1 year ago
parent 21a4b5e9b4
commit 4f6effbf9c

@ -18,8 +18,8 @@ public class Client {
// String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>1010157060000081243</service_sn><system_id>0258</system_id><requester_id>0157</requester_id><branch_id>010231100</branch_id><channel_id>01</channel_id><service_time>20230905104426</service_time><need_request>true</need_request><SvcCd>500130004</SvcCd><SvcScn>13</SvcScn><BnkSrlNo>015720230905060000081243</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><path>todo</path><method>getCount</method><args><entry><key>userNum</key><value>10913026任广鹏是个大刷币</value></entry></args></request></Service_Body></Service>"; // String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>1010157060000081243</service_sn><system_id>0258</system_id><requester_id>0157</requester_id><branch_id>010231100</branch_id><channel_id>01</channel_id><service_time>20230905104426</service_time><need_request>true</need_request><SvcCd>500130004</SvcCd><SvcScn>13</SvcScn><BnkSrlNo>015720230905060000081243</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><path>todo</path><method>getCount</method><args><entry><key>userNum</key><value>10913026任广鹏是个大刷币</value></entry></args></request></Service_Body></Service>";
// String str = "00000669<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>000000000004</service_sn><system_id>0258</system_id><requester_id>0170</requester_id><branch_id>951101</branch_id><channel_id>0170</channel_id><service_time>20230920195236</service_time><need_request>true</need_request><SvcCd>500120043</SvcCd><SvcScn>01</SvcScn><BnkSrlNo>017020230920000000000004</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><oaTrvlBnsExpnsAcctNo>BTSQD-202309210011</oaTrvlBnsExpnsAcctNo><apprvrNo>10110001</apprvrNo><apprvrName>测试审批人</apprvrName><flowStatus>2</flowStatus><sgntrOpn>驳回测试2</sgntrOpn></request></Service_Body></Service>"; // String str = "00000669<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>000000000004</service_sn><system_id>0258</system_id><requester_id>0170</requester_id><branch_id>951101</branch_id><channel_id>0170</channel_id><service_time>20230920195236</service_time><need_request>true</need_request><SvcCd>500120043</SvcCd><SvcScn>01</SvcScn><BnkSrlNo>017020230920000000000004</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><oaTrvlBnsExpnsAcctNo>BTSQD-202309210011</oaTrvlBnsExpnsAcctNo><apprvrNo>10110001</apprvrNo><apprvrName>测试审批人</apprvrName><flowStatus>2</flowStatus><sgntrOpn>驳回测试2</sgntrOpn></request></Service_Body></Service>";
// String str = "00000597<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>1010157000000001757</service_sn><system_id>0258</system_id><requester_id>0157</requester_id><branch_id>010231100</branch_id><channel_id>01</channel_id><service_time>20231018135840</service_time><need_request>true</need_request><SvcCd>500130004</SvcCd><SvcScn>13</SvcScn><BnkSrlNo>015720231018000000001757</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><path>todo</path><method>getCount2</method><args><entry><key>userNum</key><value>10110567</value></entry></args></request></Service_Body></Service>"; // String str = "00000597<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>1010157000000001757</service_sn><system_id>0258</system_id><requester_id>0157</requester_id><branch_id>010231100</branch_id><channel_id>01</channel_id><service_time>20231018135840</service_time><need_request>true</need_request><SvcCd>500130004</SvcCd><SvcScn>13</SvcScn><BnkSrlNo>015720231018000000001757</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><path>todo</path><method>getCount2</method><args><entry><key>userNum</key><value>10110567</value></entry></args></request></Service_Body></Service>";
String str = "00000596<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>1010157000000001757</service_sn><system_id>0258</system_id><requester_id>0157</requester_id><branch_id>010231100</branch_id><channel_id>01</channel_id><service_time>20231018135840</service_time><need_request>true</need_request><SvcCd>500130004</SvcCd><SvcScn>13</SvcScn><BnkSrlNo>015720231018000000001757</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><path>todo</path><method>getCount</method><args><entry><key>userNum</key><value>10110567</value></entry></args></request></Service_Body></Service>"; // String str = "00000596<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>1010157000000001757</service_sn><system_id>0258</system_id><requester_id>0157</requester_id><branch_id>010231100</branch_id><channel_id>01</channel_id><service_time>20231018135840</service_time><need_request>true</need_request><SvcCd>500130004</SvcCd><SvcScn>13</SvcScn><BnkSrlNo>015720231018000000001757</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><path>todo</path><method>getCount</method><args><entry><key>userNum</key><value>10110567</value></entry></args></request></Service_Body></Service>";
// ; String str = "00000664<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service><Service_Header><service_sn>000000000003</service_sn><system_id>0258</system_id><requester_id>0170</requester_id><branch_id>951101</branch_id><channel_id>0170</channel_id><service_time>20240329082246</service_time><need_request>true</need_request><SvcCd>500120043</SvcCd><SvcScn>01</SvcScn><BnkSrlNo>017020240329000000000003</BnkSrlNo><FileFlg>0</FileFlg></Service_Header><Service_Body><request><oaTrvlBnsExpnsAcctNo>FHBTSQD-202403250001</oaTrvlBnsExpnsAcctNo><apprvrNo>11010036</apprvrNo><apprvrName>赵圣熙</apprvrName><flowStatus>0</flowStatus><sgntrOpn>驳回测试</sgntrOpn></request></Service_Body></Service>"; // ;
// System.out.println(XMLUtils.parseXMLToMap(str)); // System.out.println(XMLUtils.parseXMLToMap(str));
// Map<String, String> stringStringMap = XMLUtils.parseXMLToMap(str); // Map<String, String> stringStringMap = XMLUtils.parseXMLToMap(str);
// System.out.println(stringStringMap); // System.out.println(stringStringMap);

@ -0,0 +1,368 @@
package com.engine.custom.action;
import com.dcfs.fts.common.error.FtpException;
import com.engine.custom.hg.util.HgUtils;
import com.engine.custom.sl.entity.*;
import com.engine.util.SocketClientUtil;
import com.engine.util.XMLUtils;
import com.weaver.general.Util;
import org.jsoup.Jsoup;
import weaver.conn.RecordSet;
import weaver.file.ImageFileManager;
import weaver.general.BaseBean;
import weaver.general.StringUtil;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.io.*;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* (
*
*/
public class PushCWAction extends BaseBean implements Action {
/**
* After selecting aciton after the process path node, this method will be executed after the node is submitted.
*/
@Override
public String execute(RequestInfo request) {
writeLog("推送商旅节点后附加操作====>");
// if(error) {
// request.getRequestManager().setMessageid("90001");
// request.getRequestManager().setMessagecontent("System Abnormal Termination Process Submission");
// }
String requestId = request.getRequestid();
String tablename = request.getRequestManager().getBillTableName();
TravelToEsbBean toEsbBean = new TravelToEsbBean();
//封装主表数据
RecordSet rs = new RecordSet();
String mainId = setMainForm(requestId, tablename, rs, toEsbBean);
writeLog("toEsbBean1====>"+toEsbBean);
writeLog("上传附件到ESB服务器====>");
try {
fileToEsb(toEsbBean,requestId);
} catch (Exception e) {
request.getRequestManager().setMessageid("10001");
request.getRequestManager().setMessagecontent(e.getMessage());
return Action.FAILURE_AND_CONTINUE;
}
setFormDt1(mainId,tablename,rs,toEsbBean);
writeLog("toEsbBean2====>"+toEsbBean);
setFormDt2(mainId,tablename,rs,toEsbBean);
writeLog("toEsbBean3====>"+toEsbBean);
String Service_Body = "<Service_Body><request>"+ toEsbBean.toXMLString()+"</request></Service_Body>" ;
writeLog("toEsbBean4====>"+Service_Body);
try{
EsbRequestHeader esbRequestHeader = new EsbRequestHeader(Util.getIntValue(mainId));
writeLog("esbRequestHeader====>"+esbRequestHeader);
String Service_Header = TravelToEsbBean.convertObjectToXml(esbRequestHeader,"Service_Header");
writeLog("esbRequestHeaderXML====>"+Service_Header);
String serviceXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Service>";
serviceXML = serviceXML + Service_Header + Service_Body;
serviceXML = serviceXML + "</Service>";
writeLog("esbRequestHeaderXML====>"+serviceXML);
int byteArray = serviceXML.getBytes("UTF-8").length;
// Calculate the length of the byte array
// int bytelength = byteArray.length;
String length = String.format("%08d", byteArray);
writeLog("XMLlength"+ length);
serviceXML = length + serviceXML;
writeLog("serviceXML==="+ serviceXML);
// serviceXML = new String(serviceXML.getBytes(StandardCharsets.UTF_8));
writeLog("UTF_8_serviceXML==="+ serviceXML);
SocketClientUtil scketClient = new SocketClientUtil("14.1.78.197",10149);
String send = scketClient.send(serviceXML);
String substring = send.substring(0, 8);
String substring1 = send.substring(8);
Map<String, String> map = XMLUtils.parseXMLToMap(substring1);
String retCd = map.get("retCd");
String retCdDsc = map.get("retCdDsc");
if ("9999".equals(retCd)){
request.getRequestManager().setMessageid("9999");
request.getRequestManager().setMessagecontent(retCdDsc);
return Action.FAILURE_AND_CONTINUE;
}
}catch (Exception e){
e.printStackTrace();
writeLog("构建XML异常"+e.getMessage());
request.getRequestManager().setMessageid("10001");
request.getRequestManager().setMessagecontent(e.getMessage());
return Action.FAILURE_AND_CONTINUE;
}
// setFormDt1();
return Action.SUCCESS;
}
private void fileToEsb(TravelToEsbBean toEsbBean, String requestId) throws Exception {
// HashMap<String, String> filePathMap = new HashMap<>();
List<acsryItem> acsryArray = toEsbBean.getAcsryArray();
for (acsryItem acsryItem : acsryArray) {
String acsryNm = acsryItem.getAcsryNm();
writeLog("acsryNm"+acsryNm);
ImageFileManager ifm = new ImageFileManager();
ifm.getImageFileInfoById(Util.getIntValue(acsryNm,0));
InputStream inputStream = ifm.getInputStream();
String imageFileName = ifm.getImageFileName();
writeLog("imageFileName"+imageFileName);
String[] filename = imageFileName.split("\\.");
int lastIndex = imageFileName.lastIndexOf('.');
String part1 = "";
String part2 = "";
if (lastIndex != -1) {
part1 = imageFileName.substring(0, lastIndex);
part2 = imageFileName.substring(lastIndex + 1);
}else {
part1 = imageFileName;
}
String tempFilePath = "";
try {
File tempFile = File.createTempFile(part1,part2.length() == 0 ? "" :part2);
// 创建一个输出流,将数据写入临时文件
OutputStream outputStream = new FileOutputStream(tempFile);
// 将输入流中的数据复制到输出流(即临时文件)
byte[] buffer = new byte[2048];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
tempFilePath = tempFile.getAbsolutePath();
writeLog( "临时文件位置"+tempFilePath);
// 关闭输入流和输出流
inputStream.close();
outputStream.close();
}catch (Exception e){
e.printStackTrace();
writeLog( "创建本地文件异常"+e.getMessage());
throw new Exception("创建"+imageFileName+"文件异常"+e.getMessage());
}
//推送ESB服务器
String ftpPath = "";
try {
ftpPath = HgUtils.putFile(tempFilePath, requestId + File.separator + imageFileName);
} catch (FtpException e) {
e.printStackTrace();
writeLog( "传输ESBftp异常"+e.getMessage());
throw new Exception("传输ESBftp异常");
} catch (IOException e) {
e.printStackTrace();
writeLog( "传输ESBIO异常"+e.getMessage());
throw new Exception("传输ESBftp异常");
}
acsryItem.setAcsryNm(imageFileName);
acsryItem.setSavePath(ftpPath);
}
}
private String setMainForm(String requestId, String tablename, RecordSet rs ,TravelToEsbBean toEsbBean) {
rs.execute("select * from " + tablename + " where requestid = " + requestId);
String mainid = "";
String fj = "";
String spdfj = "";
String spwhscpdfwj = "";
//表单数据
if (rs.next()) {
mainid = rs.getString("id");
//OA差旅报销单单据编号
toEsbBean.setOaTrvlBnsExpnsAcctNo(rs.getString(Util.null2String("djbh")));
//经办人工号
toEsbBean.setOperatorNo(processString(Util.null2String(rs.getString("jbrgh"))));
//经办人姓名 id
toEsbBean.setOperatorName(Util.null2String(rs.getString("jbrxm")));
String lastname = new User(Util.getIntValue(toEsbBean.getOperatorName())).getLastname();
toEsbBean.setOperatorName(lastname);
//附件张数
toEsbBean.setAcsryNums(Util.null2String(rs.getString("fjzs")));
//报销金额
toEsbBean.setExpnsAmt(multiply100(Util.null2String(rs.getString("bxjedwf"))));
toEsbBean.setCostDeptCode((Util.null2String(rs.getString("cbzxbm"))));
toEsbBean.setCostDeptName((Util.null2String(rs.getString("cbzxmc"))));
//报销事由 Jsoup.parse(htmlContent).text()
String expnsRsn = Util.null2String(rs.getString("bxsy"));
String text = Jsoup.parse(expnsRsn).text();
toEsbBean.setExpnsRsn(text);
//备注
toEsbBean.setRemark(Util.null2String(rs.getString("bz")));
fj = Util.null2String(rs.getString("fj"));
spdfj = Util.null2String(rs.getString("spdfj"));
// spwhscpdfwj = Util.null2String(rs.getString("clspdpdffj"));
spwhscpdfwj = Util.null2String(rs.getString("clspdpdffj"));
// String formData = rs.getString("formData");
}
// 封装文件数组
//现在是id
List<String> fjids;
if(!StringUtil.isEmpty(fj)){
fjids = new ArrayList<>( Arrays.asList(fj.split(",")));
}else {
fjids = new ArrayList<>();
}
//
writeLog("fjids"+fjids);
try {
if (!StringUtil.isEmpty(spdfj)){
fjids.add(spdfj);
}
if (!StringUtil.isEmpty(spwhscpdfwj)){
fjids.add(spwhscpdfwj);
}
ArrayList<acsryItem> acsryArray = new ArrayList<>();
for (String fjid : fjids) {
acsryItem acsryItem = new acsryItem();
acsryItem.setAcsryNm(getimgid(fjid,rs));
acsryArray.add(acsryItem);
}
toEsbBean.setAcsryArray(acsryArray);
//重新设置下附件张数为数组长度
toEsbBean.setAcsryNums(acsryArray.size()+"");
}catch (Exception e){
e.printStackTrace();
writeLog("fjidsException"+e);
}
return mainid;
}
private void setFormDt1(String mainid, String tablename, RecordSet rs , TravelToEsbBean toEsbBean) {
rs.execute("select * from " + tablename + "_dt1 where mainid = " + mainid);
List<ExpenseItem> expenseArray = new ArrayList<>();
while (rs.next()) {
ExpenseItem expenseItem = new ExpenseItem();
// 支出类型
expenseItem.setExpndType(getpartyBuildCostCode(Util.getIntValue(rs.getString("zclx"),0)));
//不含税金额
expenseItem.setExclsvTaxAmt(multiply100(Util.null2String(rs.getString("bhsjedwf"))));
// //不含税金额
expenseItem.setTaxAmt(multiply100(Util.null2String(rs.getString("sedwf"))));
//价税合计金额
expenseItem.setPrcTotAmt(multiply100(Util.null2String(rs.getString("jshjjedwf"))));
//记账摘要 Jsoup.parse(expnsRsn).text()
String jzzy = Util.null2String(rs.getString("jzzy"));
String text = Jsoup.parse(jzzy).text();
expenseItem.setAcctingAbstct(text);
expenseArray.add(expenseItem);
}
toEsbBean.setExpndArray(expenseArray);
}
private void setFormDt2(String mainid, String tablename, RecordSet rs , TravelToEsbBean toEsbBean) {
rs.execute("select * from " + tablename + "_dt2 where mainid = " + mainid);
List<JourneyInfo> jrnyInfoArray = new ArrayList<>();
while (rs.next()) {
JourneyInfo journeyInfo = new JourneyInfo();
// 开始日期
journeyInfo.setStartDate(formatDate(Util.null2String(rs.getString("ksrq"))));
// 结束日期
journeyInfo.setEndDate(formatDate(Util.null2String(rs.getString("jsrq"))));
// 出差天数
journeyInfo.setBsnTrpDays(Util.null2String(rs.getString("ccts")));
//行程路线
journeyInfo.setJrnyPath(Util.null2String(rs.getString("hclx")));
//行程说明
journeyInfo.setJrnyExpln(Util.null2String(rs.getString("hcsm")));
//记账摘要
journeyInfo.setRemark(Util.null2String(rs.getString("bz")));
jrnyInfoArray.add(journeyInfo);
}
toEsbBean.setJrnyInfoArray(jrnyInfoArray);
}
//获取支出类型
private String getpartyBuildCostCode(int index){
if(index == 0){
return "FEE_BUILD";
}else if(index == 1){
return "BIZ_FEE";
}else if(index == 2){
return "PARTY_BUILD_EXPENSE";
}
return "";
}
public String getimgid(String docid, RecordSet rs){
String sql = "select docid,df.imagefileid imgid from docimagefile df left join imagefile imf on df.imagefileid = imf.imagefileid where DOCID = ?";
writeLog("getimgidsql"+sql+"===="+docid);
rs.executeQuery(sql,docid);
if (rs.next()){
writeLog("imgid"+Util.null2String(rs.getString("imgid")));
return Util.null2String(rs.getString("imgid"));
}
return "";
};
//生成流水号
public static String generateTimestamp() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date currentDate = new Date();
return dateFormat.format(currentDate);
}
public static String multiply100(String s) {
s = s.replace(",", ""); // 移除逗号
if (StringUtil.isEmpty(s)){
return "0";
}
BigDecimal value = new BigDecimal(s);
BigDecimal multipliedValue = value.multiply(new BigDecimal("100"));
int result = multipliedValue.intValue();
System.out.println(result); // 输出123456
return String.valueOf(result); // 输出123456
}
public static String formatDate(String input) {
// String input = "2023-09-20 19:29";
try {
SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// 使用SimpleDateFormat解析输入字符串
if (!input.contains(" ")){
datetimeFormat = new SimpleDateFormat("yyyy-MM-dd");
}
Date date = datetimeFormat.parse(input);
// 使用另一个SimpleDateFormat对象格式化Date为所需的输出格式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String output = dateFormat.format(date);
return output; // 输出: 2023-09-20
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static String processString(String input) {
// 检查字符串长度是否大于8
if (input.length() > 8) {
// 如果是,截取前八位
return input.substring(0, 8);
} else {
// 否则,返回原字符串
return input;
}
}
public static void main(String[] args) {
String imageFileName = "11.16天津-成都去程机票 (1).jpg";
int lastIndex = imageFileName.lastIndexOf('.');
String part1 = imageFileName.substring(0, lastIndex);
String part2 = imageFileName.substring(lastIndex + 1);
System.out.println(part1);
System.out.println(part2);
}
}

@ -4,10 +4,14 @@ import com.engine.custom.archives.service.PushArchivesCornService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import weaver.interfaces.schedule.BaseCronJob; import weaver.interfaces.schedule.BaseCronJob;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
/***
*
* @author rengp
* @date 2024/4/7
*/
@Slf4j @Slf4j
public class PushArchivesCorn extends BaseCronJob { public class PushArchivesCorn extends BaseCronJob {
public String filePath = "/opt/weaver/filesys/test"; public String filePath = "/opt/weaver/filesys/test";

@ -16,6 +16,7 @@ import java.nio.charset.StandardCharsets;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.StringUtil; import weaver.general.StringUtil;
import weaver.general.Util; import weaver.general.Util;
@ -76,8 +77,10 @@ public class PushArchivesCornService {
public void pushArchives(Map<String, String> param) { public void pushArchives(Map<String, String> param) {
log.info("PushArchivesCorn====Begin========{}", param); log.info("PushArchivesCorn====Begin========{}", param);
try { try {
ZipUtil zipUtil = new ZipUtil(); ZipUtil zipUtil = new ZipUtil();
Date date = getDate(); Date date = getDate();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
String format = dateFormat.format(date); String format = dateFormat.format(date);
SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@ -215,13 +218,16 @@ public class PushArchivesCornService {
}); });
//开始承办单 先获取主流程的承办单 //开始承办单 先获取主流程的承办单
List<String> requestDocid = generaRequestFormPdf(requestid); List<String> requestDocid = generaRequestFormPdf(requestid);
List<String> subRequestDocid = generaSubRequestFormPdf(requestid); // 1.去掉生成子流程承办单
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
Map<String, String> reqDocMap = getFileIdByDocId(String.join(",", requestDocid)); Map<String, String> reqDocMap = getFileIdByDocId(String.join(",", requestDocid));
Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid)); // 2.去掉生成子流程承办单
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap)); log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap)); //log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
docids.addAll(requestDocid); docids.addAll(requestDocid);
docids.addAll(subRequestDocid); // 3.去掉生成子流程承办单
// docids.addAll(subRequestDocid);
//附件 //附件
reqDocMap.forEach((docid, imageid) -> { reqDocMap.forEach((docid, imageid) -> {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
@ -249,34 +255,36 @@ public class PushArchivesCornService {
} }
}); });
//正文 //正文
i[0] = 1; i[0] = 1;
subReqDocMap.forEach((docid, imageid) -> { // 4.去掉生成子流程承办单
ImageFileManager imageFileManager = new ImageFileManager(); // subReqDocMap.forEach((docid, imageid) -> {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); // ImageFileManager imageFileManager = new ImageFileManager();
InputStream inputStream = imageFileManager.getInputStream(); // 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); // String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName());
log.info("子流程承办单路径:{}", imageFileName); // imageFileName = codeUtf8(imageFileName);
try { // log.info("子流程承办单路径:{}", imageFileName);
File file = saveInputStreamToFile(inputStream, imageFileName); // try {
String jsonStr = callApi(Url, file); // File file = saveInputStreamToFile(inputStream, imageFileName);
log.error("永中接口返回:{}", jsonStr); // String jsonStr = callApi(Url, file);
JSONObject result = JSONObject.parseObject(jsonStr); // log.error("永中接口返回:{}", jsonStr);
String errorcode = result.getString("errorcode"); // JSONObject result = JSONObject.parseObject(jsonStr);
if ("0".equals(errorcode)) { // String errorcode = result.getString("errorcode");
JSONObject data = result.getJSONObject("data"); // if ("0".equals(errorcode)) {
String destFileName = data.getString("destFileName"); // JSONObject data = result.getJSONObject("data");
String viewUrl = data.getString("viewUrl"); // String destFileName = data.getString("destFileName");
downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf"); // 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) { // i[0]++;
e.printStackTrace(); // } catch (IOException e) {
} // e.printStackTrace();
}); // }
// });
log.error(JSONObject.toJSONString(requestDocid)); log.error(JSONObject.toJSONString(requestDocid));
log.error(JSONObject.toJSONString(subRequestDocid)); // log.error(JSONObject.toJSONString(subRequestDocid));
for (String docid : docids) { for (String docid : docids) {
log.error("删除了" + docid); log.error("删除了" + docid);
deleteDocByid(docid); deleteDocByid(docid);
@ -474,7 +482,7 @@ public class PushArchivesCornService {
context.append(lwdwmc).append("|"); context.append(lwdwmc).append("|");
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限 String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
context.append(bgqx).append("|"); context.append(bgqx).append("|");
String lwrq = Util.null2String(requesData.get("bgqx")); //7 日期 -> 原发文日期 String lwrq = Util.null2String(requesData.get("lwrq")); //7 日期 -> 原发文日期
context.append(lwrq).append("|"); context.append(lwrq).append("|");
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数 String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
context.append(ys).append("|"); context.append(ys).append("|");
@ -857,11 +865,21 @@ public class PushArchivesCornService {
public static String getSignLog(String requestid, String dirName, String requestName) { public static String getSignLog(String requestid, String dirName, String requestName) {
List<String> subRequestIds = getSubRequestIds(requestid); List<String> subRequestIds = getSubRequestIds(requestid);
ArrayList<Map<String, Object>> lists = new ArrayList<>(); ArrayList<Map<String, Object>> lists = new ArrayList<>();
List<String> 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) { for (String reqid : subRequestIds) {
recordSet.executeQuery(getWFNameByReqId,reqid);
String wfName = "";
if (recordSet.next()){
wfName = recordSet.getString("WORKFLOWNAME");
}
HashMap<String, Object> params = new HashMap<>(); HashMap<String, Object> params = new HashMap<>();
params.put("requestid", reqid); params.put("requestid", reqid);
params.put("desremark", "all"); params.put("desremark", "all");
params.put("pageSize", "50"); params.put("pageSize", "999");
params.put("isfirst", "true"); params.put("isfirst", "true");
// params.put("request", request); // params.put("request", request);
Map<String, Object> data = getSignLogCmd(params, new User(1)); Map<String, Object> data = getSignLogCmd(params, new User(1));
@ -884,19 +902,49 @@ public class PushArchivesCornService {
Map value = (Map) entry.getValue(); Map value = (Map) entry.getValue();
List<Map<String, Object>> list = (List) value.get("list"); List<Map<String, Object>> list = (List) value.get("list");
String nodeid = Util.null2String(value.get("nodeid")) ;
if (autoInitNodeIds.contains(nodeid)){
continue;
}
for (Map<String, Object> item : list) { for (Map<String, Object> item : list) {
String operator = (String) item.get("operator"); String operator = (String) item.get("operator");
String operatorid = (String) item.get("operatorid"); String operatorid = (String) item.get("operatorid");
String operatortype = (String) item.get("operatortype"); String operatortype = (String) item.get("operatortype");
String operatedate = (String) item.get("operatedate"); String operatedate = (String) item.get("operatedate");
String receivedate = (String) item.get("receivedate");
String nodename = (String) value.get("nodename"); String nodename = (String) value.get("nodename");
String statuscode = (String) item.get("statuscode");
HashMap<String, String> itemMap = new HashMap<>(); HashMap<String, String> itemMap = new HashMap<>();
itemMap.put("operator", operator); itemMap.put("operator", operator);
itemMap.put("operatorid", operatorid); itemMap.put("operatorid", operatorid);
itemMap.put("operatortype", operatortype); itemMap.put("operatortype", operatortype);
itemMap.put("operatedate", operatedate); itemMap.put("operatedate", StringUtil.isEmpty(operatedate) ? receivedate : operatedate);
itemMap.put("nodename", nodename);
itemMap.put("nodename", nodename); itemMap.put("nodename", nodename);
itemMap.put("requestName", (String) value.get("requestName")); 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); results.add(itemMap);
} }
@ -905,7 +953,7 @@ public class PushArchivesCornService {
HashMap<String, Object> records = new HashMap<>(); HashMap<String, Object> records = new HashMap<>();
records.put("results",results); records.put("results",results);
String requestName1 = (String) data.get("requestName"); String requestName1 = (String) data.get("requestName");
records.put("requestName",requestName1); records.put("requestName","【"+wfName+"】-"+requestName1);
log.error("requestName1:{}", requestName1); log.error("requestName1:{}", requestName1);
log.error("records:{}", JSONObject.toJSONString(records)); log.error("records:{}", JSONObject.toJSONString(records));
lists.add(records); lists.add(records);
@ -1499,7 +1547,7 @@ public class PushArchivesCornService {
if (!tmpisremark.equals("s") && !tmpisremark.equals("c") && !tmpisremark.equals("r")) { if (!tmpisremark.equals("s") && !tmpisremark.equals("c") && !tmpisremark.equals("r")) {
_receivedate = Util.toScreen(tmpreceivedate, user.getLanguage()) + " " + Util.toScreen(tmpreceivetime, user.getLanguage()); _receivedate = Util.toScreen(tmpreceivedate, user.getLanguage()) + " " + Util.toScreen(tmpreceivetime, user.getLanguage());
} }
_operatedate = Util.toScreen(tmpreceivedate, user.getLanguage()) + " " + Util.toScreen(tmpreceivetime, user.getLanguage()); _operatedate = Util.toScreen(tmpoperatedate, user.getLanguage()) + " " + Util.toScreen(tmpoperatetime, user.getLanguage());
_intervel = Util.toScreen(tmpIntervel, user.getLanguage()); _intervel = Util.toScreen(tmpIntervel, user.getLanguage());
@ -1514,6 +1562,8 @@ public class PushArchivesCornService {
_statusmap.put("beagentname", _beagentname); _statusmap.put("beagentname", _beagentname);
_statusmap.put("nodetype", nodetype); _statusmap.put("nodetype", nodetype);
//所有节点 //所有节点
nodeallstatuslist.add(_statusmap); nodeallstatuslist.add(_statusmap);
//查看状态 1:未查看, 2:以查看, 3已提交 4:暂停, 5:撤销, 6:启用 7:已查阅 //查看状态 1:未查看, 2:以查看, 3已提交 4:暂停, 5:撤销, 6:启用 7:已查阅
@ -1714,4 +1764,28 @@ public class PushArchivesCornService {
System.out.println(s1); System.out.println(s1);
} }
} }
/**
*
* @param mainAndSubRequestId
* @return
*/
private static ArrayList<String> getAutoInitNodeIds(String mainAndSubRequestId) {
RecordSet recordSet = new RecordSet();
ArrayList<String> 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 nodeids;
}
} }

@ -140,6 +140,7 @@ public class RequestLogCusBiz {
mssqlTopflg = " top 100 percent "; mssqlTopflg = " top 100 percent ";
} }
String thisviewLogIds = getViewLogIds(viewLogIds, requestid, workflowid); String thisviewLogIds = getViewLogIds(viewLogIds, requestid, workflowid);
String autoInitNodeIds = getAutoInitNodeIds(mainAndSubRequestId);
String robotNodeid = getRobotNodeid(thisviewLogIds); String robotNodeid = getRobotNodeid(thisviewLogIds);
String selectfields = " nodeid,destnodeid,operatedate,operatetime,logtype,remark,isMobile,logid,operatortype,operator," + String selectfields = " nodeid,destnodeid,operatedate,operatetime,logtype,remark,isMobile,logid,operatortype,operator," +
"agenttype,agentorbyagentid,receivedPersonids,requestLogId,annexdocids,operatorDept,signdocids," + "agenttype,agentorbyagentid,receivedPersonids,requestLogId,annexdocids,operatorDept,signdocids," +
@ -155,8 +156,8 @@ public class RequestLogCusBiz {
} }
String sql = "select " + mssqlTopflg + selectfields + " from workflow_requestlog t1 " + String sql = "select " + mssqlTopflg + selectfields + " from workflow_requestlog t1 " +
" where t1.requestid in ( " + mainAndSubRequestId + ") and t1.logtype != '1' " ; " where t1.requestid in ( " + mainAndSubRequestId + ") and t1.logtype != '1' " +
// " and " + Util.getSubINClause(thisviewLogIds, "t1.nodeid", "in"); " and t1.nodeid not in (" + autoInitNodeIds + " )";
if (sqlwhere != null && !sqlwhere.equals("")) { if (sqlwhere != null && !sqlwhere.equals("")) {
sql = sql + sqlwhere; sql = sql + sqlwhere;
} }
@ -172,6 +173,30 @@ public class RequestLogCusBiz {
return sql; return sql;
} }
/**
*
* @param mainAndSubRequestId
* @return
*/
private static String getAutoInitNodeIds(String mainAndSubRequestId) {
RecordSet recordSet = new RecordSet();
ArrayList<String> 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);
}
private static String getMainOrSubRequest(int requestid, boolean isSubrequest) { private static String getMainOrSubRequest(int requestid, boolean isSubrequest) {
if (isSubrequest){ if (isSubrequest){
// RecordSet rs = new RecordSet(); // RecordSet rs = new RecordSet();

@ -275,12 +275,12 @@ public class LoadRequestLogDataCusCmd extends AbstractCommonCommand<Map<String,
start = System.currentTimeMillis(); start = System.currentTimeMillis();
} }
if (pgflag == null || pgflag.equals("")) { if (pgflag == null || pgflag.equals("")) {
log_loglist = wfLinkInfo.getRequestLog(requestid, workflowid, viewLogIds, orderby, sqlcondition); log_loglist = wfLinkInfo.getRequestLog(requestid, workflowid, viewLogIds, "asc", sqlcondition);
} else { } else {
//log_loglist = wfLinkInfo.getRequestLog(requestid, workflowid, viewLogIds, orderby, wfsignlddtcnt, sbfmaxrequestlogid, sqlwhere); //log_loglist = wfLinkInfo.getRequestLog(requestid, workflowid, viewLogIds, orderby, wfsignlddtcnt, sbfmaxrequestlogid, sqlwhere);
boolean isSubrequest = (boolean)params.get("isSubrequest"); boolean isSubrequest = (boolean)params.get("isSubrequest");
log_loglist = RequestLogCusBiz.getRequestLog(requestid,workflowid,viewLogIds,orderby,wfsignlddtcnt,pgnumber,sqlwhere,isSubrequest); log_loglist = RequestLogCusBiz.getRequestLog(requestid,workflowid,viewLogIds,"asc",wfsignlddtcnt,pgnumber,sqlwhere,isSubrequest);
if(RequestLogCusBiz.isEndLog(requestid,workflowid,viewLogIds,orderby,wfsignlddtcnt,pgnumber,sqlwhere)){///判断此次加载是否是最后一页 if(RequestLogCusBiz.isEndLog(requestid,workflowid,viewLogIds,"asc",wfsignlddtcnt,pgnumber,sqlwhere)){///判断此次加载是否是最后一页
resultDatas.put("isEnd", true); resultDatas.put("isEnd", true);
} }
} }

@ -30,9 +30,19 @@ public class CWGLSocketExecute extends BaseBean implements SocketExecute {
String sgntrOpn = Util.null2String(paramMap.get("sgntrOpn")); String sgntrOpn = Util.null2String(paramMap.get("sgntrOpn"));
sgntrOpn = apprvrName + "(" + apprvrNo + "):" + sgntrOpn; sgntrOpn = apprvrName + "(" + apprvrNo + "):" + sgntrOpn;
Map<String, String> resultMap = null; Map<String, String> resultMap = null;
String tableName = "";
int userid = 0; int userid = 0;
try { try {
resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, "formtable_main_281"); if(oaTrvlBnsExpnsAcctNo.startsWith("BTSQD")){
tableName = "formtable_main_281";
// resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, "formtable_main_281");
}else if(oaTrvlBnsExpnsAcctNo.startsWith("FHBTSQD")) {
tableName = "formtable_main_420";
// resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, "");
}else {
throw new Exception("未找到编号 '"+oaTrvlBnsExpnsAcctNo+"' 对应的表单");
};
resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, tableName);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return XMLUtils.CW2XML(paramMap, "1", e.getMessage()); return XMLUtils.CW2XML(paramMap, "1", e.getMessage());
@ -48,9 +58,9 @@ public class CWGLSocketExecute extends BaseBean implements SocketExecute {
if (requestid == 0) { if (requestid == 0) {
return XMLUtils.CW2XML(paramMap, "1", "流程未找到"); return XMLUtils.CW2XML(paramMap, "1", "流程未找到");
} }
if (userid == 0) { // if (userid == 0) {
return XMLUtils.CW2XML(paramMap, "1", "人员未找到"); // return XMLUtils.CW2XML(paramMap, "1", "人员未找到");
} // }
RequestService requestService = new RequestService(); RequestService requestService = new RequestService();
boolean istrue = false; boolean istrue = false;
if ("0".equals(flowStatus)) { if ("0".equals(flowStatus)) {
@ -69,7 +79,7 @@ public class CWGLSocketExecute extends BaseBean implements SocketExecute {
if (istrue) { if (istrue) {
try { try {
updateStatus(requestid, flowStatus); updateStatus(requestid, flowStatus);
String sqr = getsqrbyBH(oaTrvlBnsExpnsAcctNo, "formtable_main_281"); String sqr = getsqrbyBH(oaTrvlBnsExpnsAcctNo, tableName);
if("3".equals(flowStatus)){ if("3".equals(flowStatus)){
sendMsgForSuccess(sqr,oaTrvlBnsExpnsAcctNo,requestid); sendMsgForSuccess(sqr,oaTrvlBnsExpnsAcctNo,requestid);
} }
@ -122,6 +132,7 @@ public class CWGLSocketExecute extends BaseBean implements SocketExecute {
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
HashMap<String, String> resultMap = new HashMap<>(); HashMap<String, String> resultMap = new HashMap<>();
String sql = "select * from " + tableName + " where djbh = ?"; String sql = "select * from " + tableName + " where djbh = ?";
writeLog("getBeanByOAnumSql"+sql);
recordSet.executeQuery(sql, oaTrvlBnsExpnsAcctNo); recordSet.executeQuery(sql, oaTrvlBnsExpnsAcctNo);
if (recordSet.next()) { if (recordSet.next()) {
resultMap.put("id", Util.null2String(recordSet.getString("id"))); resultMap.put("id", Util.null2String(recordSet.getString("id")));

@ -0,0 +1,809 @@
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="java.io.*" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
<%@ page import="org.apache.http.impl.client.HttpClients" %>
<%@ page import="org.apache.http.client.methods.HttpPost" %>
<%@ page import="org.apache.http.entity.StringEntity" %>
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
<%@ page import="org.apache.http.HttpStatus" %>
<%@ page import="org.apache.http.HttpEntity" %>
<%@ page import="org.apache.http.util.EntityUtils" %>
<%@ page import="org.apache.http.client.ClientProtocolException" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="java.net.URL" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="org.apache.http.NameValuePair" %>
<%@ page import="org.apache.http.message.BasicNameValuePair" %>
<%@ page import="org.apache.http.client.entity.UrlEncodedFormEntity" %>
<%@ page import="weaver.rsa.security.RSA" %>
<%@ page import="java.security.interfaces.RSAPublicKey" %>
<%@ page import="java.security.KeyFactory" %>
<%@ page import="java.security.spec.X509EncodedKeySpec" %>
<%@ page import="javax.crypto.Cipher" %>
<%@ page import="org.apache.commons.codec.binary.Base64" %>
<%@ page import="java.nio.charset.StandardCharsets" %>
<%@ page import="org.apache.http.impl.client.HttpClientBuilder" %>
<%@ page import="org.apache.http.client.methods.HttpGet" %>
<%@ page import="com.engine.common.util.ParamUtil" %>
<%@ page import="java.time.format.DateTimeFormatter" %>
<%@ page import="java.time.LocalDateTime" %>
<%@ page import="java.time.temporal.ChronoUnit" %>
<%@ page import="okhttp3.*" %>
<%@ page import="javax.servlet.http.Cookie" %>
<%@ page import="weaver.file.Prop" %>
<%@ page import="com.alibaba.fastjson.JSONException" %>
<%@ page import="com.wbi.util.StringUtil" %>
<%@ page import="java.net.URLDecoder" %>
<%!
public String httpPostRequest(String param, String url, String token) {
BaseBean baseBean = new BaseBean();
String responseBody = "";
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
//设置请求体参数
StringEntity entity = new StringEntity(param, "utf-8");
baseBean.writeLog("entity-param->" + param);
baseBean.writeLog("entity-->" + entity);
entity.setContentEncoding("utf-8");
baseBean.writeLog("entity-utf-8->" + entity);
httpPost.setEntity(entity);
//设置请求头部
httpPost.setHeader("Content-Type", "application/json");
if (token != null && !"".equals(token)) {
httpPost.setHeader("Authorization", token);
}
//执行请求,返回请求响应
CloseableHttpResponse response = httpClient.execute(httpPost);
//请求返回状态码
int statusCode = response.getStatusLine().getStatusCode();
baseBean.writeLog("statusCode状态码->" + statusCode);
//请求成功
if (statusCode == HttpStatus.SC_OK && statusCode <= HttpStatus.SC_TEMPORARY_REDIRECT) {
//取出响应体
HttpEntity entity2 = response.getEntity();
//从响应体中解析出token
responseBody = EntityUtils.toString(entity2, "utf-8");
// jsonObject = JSONObject.parseObject(responseBody);
baseBean.writeLog("responseBody->" + responseBody);
// baseBean.writeLog("jsonObject->"+jsonObject);
//token = jsonObject.getString("access_token");
} else {
//请求失败
throw new ClientProtocolException("请求失败,响应码为:" + statusCode);
}
} catch (Exception e) {
e.printStackTrace();
}
return responseBody;
}
/**
* 发送http get请求
*/
public static String httpGet(String url, Map<String, String> headers, String encode) {
BaseBean bb = new BaseBean();
if (encode == null) {
encode = "utf-8";
}
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
String content = null;
//since 4.3 不再使用 DefaultHttpClient
try {
closeableHttpClient = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet(url);
//设置header
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpGet.setHeader(entry.getKey(), entry.getValue());
}
}
bb.writeLog("url=" + url + "header=" + headers + "encode=" + encode);
httpResponse = closeableHttpClient.execute(httpGet);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
* 向指定 URL 发送POST方法的请求
*
* @param url 发送请求的 URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public static String sendPost(String url, String param) {
BaseBean bb = new BaseBean();
String result = "";
PrintWriter out = null;
BufferedReader in = null;
HttpURLConnection connection = null;
try {
URL postUrl = new URL(url);
bb.writeLog("getUrl-->" + postUrl);
// 打开和URL之间的连接
connection = (HttpURLConnection) postUrl.openConnection();
// 在connect之前设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.setRequestProperty("Charsert", "UTF-8");
connection.setConnectTimeout(15000);
connection.setReadTimeout(60000);
// 发送POST请求必须设置如下两行参数要放在http正文内
connection.setDoOutput(true);
connection.setDoInput(true);
// 默认是 GET方式
connection.setRequestMethod("POST");
// Post 请求不使用缓存
connection.setUseCaches(false);
// 配置本次连接的Content-typeform表单是"application/x-www-form-urlencoded"json是"application/json"等
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.connect();
// 参数要放在http正文内
//1.获取URLConnection对象对应的输出流
out = new PrintWriter(connection.getOutputStream());
//2.中文有乱码的需要将PrintWriter改为如下
//out=new OutputStreamWriter(conn.getOutputStream(),"UTF-8")
out.print(param);
out.flush();
//也可以使用DataOutputStream
// DataOutputStream dos=new DataOutputStream(httpConn.getOutputStream());
// dos.writeBytes(param);
// dos.flush();
// dos.close();
// 定义BufferedReader输入流来读取URL的响应
if (connection.getResponseCode() == 200) {
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
}
} catch (Exception e) {
bb.writeLog("发送 POST 请求出现异常!" + e);
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
if (connection != null) {
//关闭连接
connection.disconnect();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return result;
}
/**
* 发送 http post 请求参数以form表单键值对的形式提交。
*/
public static String httpPostForm(String url, Map<String, String> params, Map<String, String> headers, String encode) {
BaseBean bb = new BaseBean();
if (encode == null) {
encode = "utf-8";
}
String content = null;
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
try {
closeableHttpClient = HttpClients.createDefault();
HttpPost httpost = new HttpPost(url);
//设置header
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpost.setHeader(entry.getKey(), entry.getValue());
}
}
bb.writeLog("url=" + url + "header=" + headers + "encode=" + encode);
bb.writeLog("params=" + params);
//组织请求参数
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
if (params != null && params.size() > 0) {
Set<String> keySet = params.keySet();
for (String key : keySet) {
paramList.add(new BasicNameValuePair(key, params.get(key)));
}
}
httpost.setEntity(new UrlEncodedFormEntity(paramList, encode));
httpResponse = closeableHttpClient.execute(httpost);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
* 公钥加密
*
* @param content 内容
* @param publicKey 公钥
* @return 加密后的密文
* @throws Exception 异常信息
*/
public static String encrypt(String content, String publicKey) throws Exception {
//base64编码的公钥
byte[] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(publicKey);
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
//RSA加密
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
return Base64.encodeBase64String(cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)));
}
public static String getPublicKey(Map<String, String> MachInfo) {
BaseBean bb = new BaseBean();
String publicKey = "";
String API_KEY = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "key"));
//请求获取publicKey接口
Map<String, String> headers = new HashMap<>();
String url = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "publicKeyUrl"));
headers.put("API_KEY", API_KEY);
headers.put("MACH_ID", MachInfo.get("deviceId"));
headers.put("MACH_TYPE", Util.null2String(MachInfo.get("clientType"), "0"));
headers.put("MACH_IP", MachInfo.get("param_ip"));
String msg = httpGet(url, headers, null);
bb.writeLog("===获取publickey返回值====" + msg);
try {
org.json.JSONObject resMsg = new org.json.JSONObject(msg);
bb.writeLog("===获取publickey返回值====" + resMsg);
if (resMsg.has("pubKey")) {
publicKey = Util.null2String(resMsg.get("pubKey").toString());
}
} catch (Exception e) {
e.getMessage();
}
return publicKey;
}
//获取TG
public static String getST(String tgt, String emobileUrl, Map<String, String> MachInfo) {
BaseBean bb = new BaseBean();
String ST = "";
String retMsg = "";
Map<String, String> params = new HashMap<>();//参数
Map<String, String> headers = new HashMap<>();//headers
String API_KEY = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "key"));
//请求获取TG接口
String url = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "stUrl"));
bb.writeLog("==获取TG==" + url);
//移动端首页地址
bb.writeLog("==移动端首页地址==" + emobileUrl);
//获取TGT
params = new HashMap<>();//参数
params.put("tgt", tgt);
params.put("service", emobileUrl);
bb.writeLog("==STparams==" + params);
headers = new HashMap<>();//headers
headers.put("API_KEY", API_KEY);
headers.put("MACH_ID", MachInfo.get("deviceId"));
headers.put("MACH_TYPE", Util.null2String(MachInfo.get("clientType"), "0"));
headers.put("MACH_IP", MachInfo.get("param_ip"));
try {
retMsg = httpPostForm(url, params, headers, null);
bb.writeLog("===获取ST返回值====" + retMsg);
org.json.JSONObject resMsg = new org.json.JSONObject(retMsg);
bb.writeLog("===获取ST返回值resMsg====" + resMsg);
if (resMsg.has("ST")) {
ST = Util.null2String(resMsg.get("ST").toString());
}
bb.writeLog("===获取ST====" + ST);
} catch (Exception e) {
throw new RuntimeException(e);
}
return retMsg;
}
public static String getSysUrl(String sysid) {
RecordSet rs = new RecordSet();
String url = "-1";
//查询建模
rs.executeQuery("select * from uf_otherSysInfo where id = ?", sysid);
if (rs.next()) {
url = Util.null2String(rs.getString("xtdz"));
} else {
return "-1";
}
url = url.trim();
if (!StringUtil.isBlank(url)) {
//判断是否带?号
if (url.indexOf("?") == -1) {
url = url + "?";
} else {
url = url + "&";
}
}
;
return url;
}
public static String getsysSSOurl(String sysid) {
RecordSet rs = new RecordSet();
String url = "-1";
//查询建模
rs.executeQuery("select * from uf_otherSysInfo where id = ?", sysid);
if (rs.next()) {
url = Util.null2String(rs.getString("hqdddz"));
} else {
return "-1";
}
new BaseBean().writeLog("hqdddz====" + url);
url = url.trim();
return url;
}
public static boolean isDifferenceGreaterThan(String timeStr2, int hours) {
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 解析字符串为LocalDateTime对象
// LocalDateTime time1 = LocalDateTime.parse(timeStr1, formatter);
LocalDateTime now = LocalDateTime.now();
LocalDateTime time2 = LocalDateTime.parse(timeStr2, formatter);
// 计算两个时间的差值(以小时为单位)
// long hoursDifference = ChronoUnit.HOURS.between(time1, time2);
long hoursDifference = ChronoUnit.SECONDS.between(now, time2);
System.out.println(hoursDifference);
// 检查差值是否大于给定的小时数
return Math.abs(hoursDifference) > (long) hours * 60 * 60;
}
public String getEMToken() {
try {
String sysurl = Prop.getPropValue("emsysinfo", "sysurl");
String corpid = Prop.getPropValue("emsysinfo", "corpid");
String corpsecret = Prop.getPropValue("emsysinfo", "corpsecret");
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(sysurl + "/emp/api/gettoken?corpid=" + corpid + "&corpsecret=" + corpsecret)
.get()
.build();
Response response = client.newCall(request).execute();
String responseStr = response.body().string();
JSONObject responseJson = JSONObject.parseObject(responseStr);
if ("0".equals(responseJson.get("errcode") + "")) {
return responseJson.getString("access_token");
} else {
return responseJson.getString("errmsg");
}
} catch (Exception e) {
return e.getMessage();
}
}
public String EMExt(String access_token, String jsonStr) {
OkHttpClient client = new OkHttpClient();
String sysurl = Prop.getPropValue("emsysinfo", "sysurl");
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, jsonStr);
Request request = new Request.Builder()
.url(sysurl + "/emp/api/integrate/func/offline?access_token=" + access_token)
.post(body)
.addHeader("content-type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
String responseStr = response.body().string();
JSONObject responseJson = JSONObject.parseObject(responseStr);
if ("0".equals(responseJson.get("errcode"))) {
return responseJson.getString("errmsg");
} else {
return responseJson.getString("errmsg");
}
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
%>
<%
BaseBean bb = new BaseBean();
bb.writeLog("进入消息单点跳转中中转页面jsp-->");
// 权限认证
User user = HrmUserVarify.getUser(request, response);
if (user == null) {
response.sendRedirect("/notice/noright.jsp");
return;
}
RecordSet rs = new RecordSet();
RSA rsa = new RSA();
Map<String, String> params = new HashMap<>();//参数
Map<String, String> headers = new HashMap<>();//headers
JSONArray array = new JSONArray();
List<String> decriptList = new ArrayList<>();
String ST = "";//获取ST
Map<String, Object> paramsMap = ParamUtil.request2Map(request);
String deviceId = Util.null2String(paramsMap.get("deviceId"));
String clientType = Util.null2String(paramsMap.get("clientType"));
if ("2".equals(clientType)) {
clientType = "0";
} else if ("3".equals(clientType)) {
clientType = "1";
}
String param_ip = Util.null2String(paramsMap.get("param_ip"));
new BaseBean().writeLog("paramsMap===>" + paramsMap);
new BaseBean().writeLog("deviceId===>" + deviceId);
new BaseBean().writeLog("clientType===>" + clientType);
HashMap<String, String> MachInfo = new HashMap<>();
MachInfo.put("deviceId", deviceId.isEmpty() ? "123" : deviceId);
MachInfo.put("clientType", clientType.isEmpty() ? "1" : clientType);
MachInfo.put("param_ip", param_ip.isEmpty() ? "127.0.0.1" : param_ip);
String sysid = (String) paramsMap.get("sysid");
if (StringUtil.isBlank(sysid)) {
out.print("sysid为空");
return;
}
// String sysUrl = getSysUrl(sysid);
String sysUrl = (String) paramsMap.get("sysUrl");
if ("-1".equals(sysUrl)) {
out.print("系统url为空");
return;
}
sysUrl = URLDecoder.decode(sysUrl, StandardCharsets.UTF_8.toString());
sysUrl = sysUrl.trim();
if (!StringUtil.isBlank(sysUrl)) {
//判断是否带?号
if (sysUrl.indexOf("?") == -1) {
sysUrl = sysUrl + "?";
} else {
sysUrl = sysUrl + "&";
}
}
String login_id = "";
String user_password = "";
int uid = user.getUID();
bb.writeLog("uid-->" + uid);
rs.executeQuery("select id,loginid,password,createtime from EmobileLoginDetail where id=?", uid);
if (rs.next()) {
login_id = Util.null2String(rs.getString("loginid"));
user_password = Util.null2String(rs.getString("password"));
}
bb.writeLog("login_id-->" + login_id);
bb.writeLog("user_password-->" + user_password);
//获取session
session = request.getSession(true);
String certified_token = Util.null2String(session.getAttribute("certified_token"));
String certified_token_expires = Util.null2String(session.getAttribute("certified_token_expires"));
bb.writeLog("获取sessionTGT==" + certified_token);
// //获取cookie
// Cookie[] cookies = request.getCookies();
// bb.writeLog("获取cookies==" + cookies);
// String idd = "";
// if (cookies != null) {
// for (Cookie cookie : cookies) {
// bb.writeLog("获取cookiesName==" + cookie.getName());
// if (cookie.getName().equals("loginidweaver")) {
// idd = cookie.getValue();
// bb.writeLog("获取idd==" + idd);
// }
// }
// }
//查询人员工号
RecordSet recordSet = new RecordSet();
String requestURI = request.getRequestURI();
bb.writeLog("请求路径=" + requestURI);
// Map<String, Object> useridMap = ParamUtil.request2Map(request);
// bb.writeLog("人员id=" + useridMap.get("userid"));
// recordSet.executeQuery("select WORKCODE from HRMRESOURCE where id=?", Util.null2String(useridMap.get("userid")));
// String workcode = "";
// if (recordSet.next()) {
// workcode = Util.null2String(recordSet.getString("WORKCODE"));
// }
// bb.writeLog("人员workcode=" + useridMap.get("workcode"));
//查询
String API_KEY = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "key"));//publicKey
String url = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "stUrl"));//获取ST的url
String cockpitUrl = getsysSSOurl(sysid);
String tgturl = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "tgtUrl"));//请求获取TGT地址
//获取ST带着下游系统
if (!StringUtil.isBlank(certified_token) && !isDifferenceGreaterThan(certified_token_expires, 4)) {
bb.writeLog("TGT未失效");
String responseInfo = getST(certified_token, cockpitUrl, MachInfo);
bb.writeLog("进入responseInfo-->" + responseInfo);
if (StringUtil.isBlank(responseInfo)) {
out.print("单点系统接口返回值为null");
return;
} else {
org.json.JSONObject stMsg = new org.json.JSONObject(responseInfo);
if (stMsg.has("ST")) {
ST = Util.null2String(stMsg.get("ST").toString());
} else {
try {
if (stMsg.has("errorCode") && "2009".equals(stMsg.getString("errorCode"))) {
response.sendRedirect("https://office.bankoftianjin.com/interface/transfer/mobile/noPermissons2.html");
} else if (stMsg.has("errorCode") && "2008".equals(stMsg.getString("errorCode"))) {
//----------------------------------TGT未找到---------------------------------------------
bb.writeLog("TGT未找到");
String TGT = "";
String passWord = "";
String retMsg = "";
decriptList.add(login_id);
decriptList.add(user_password);
List<String> resultList = rsa.decryptList(request, decriptList);
String loginId = resultList.get(0);
String userPassword = resultList.get(1);
String publicKey = getPublicKey(MachInfo);
passWord = encrypt(user_password, publicKey);
params = new HashMap<>();//参数
params.put("username", loginId);
params.put("password", passWord);
bb.writeLog("==STparams==" + params);
headers = new HashMap<>();//headers
headers.put("API_KEY", API_KEY);
headers.put("MACH_ID", MachInfo.get("deviceId"));
headers.put("MACH_TYPE", Util.null2String(MachInfo.get("clientType"), "0"));
headers.put("MACH_IP", MachInfo.get("param_ip"));
retMsg = httpPostForm(tgturl, params, headers, null);
bb.writeLog("===获取TGT返回值retMsg====" + retMsg);
org.json.JSONObject resMsg = new org.json.JSONObject(retMsg);
bb.writeLog("===获取TGT返回值====" + resMsg);
if (resMsg.has("TGT")) {
TGT = Util.null2String(resMsg.get("TGT").toString());
} else {
//密码不正确,执行强制退出
if ("2002".equals(resMsg.get("errorCode") + "")) {
out.print("<h3 style='font-size: 20px;'>您的单点系统密码已修改,请重新登录,将在3秒后退出</h3>");
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
JSONObject postBody = new JSONObject();
String sysid = Prop.getPropValue("emsysinfo", "sysid");
postBody.put("sysid", sysid);
postBody.put("userids", user.getUID());
postBody.put("offline_type", "1");
postBody.put("client_type", "1,2,3");
String errmsg = EMExt(getEMToken(), postBody.toJSONString());
}
});
thread.start();
return;
} else {
out.print(resMsg.get("message"));
return;
}
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
Date expiresDate = new Date(now.getTime() + (4 * 60 * 60 * 1000));
request.getSession(true).setAttribute("certified_token_expires", sdf.format(expiresDate));//记录toekn失效日期时间
request.getSession(true).setAttribute("certified_token", TGT);//记录toekn
responseInfo = getST(TGT, cockpitUrl, MachInfo);
if (StringUtil.isBlank(responseInfo)) {
out.print("单点系统接口返回值为null");
return;
} else {
org.json.JSONObject stMsgnew = new org.json.JSONObject(responseInfo);
if (stMsgnew.has("ST")) {
ST = Util.null2String(stMsgnew.get("ST").toString());
} else {
try {
if (stMsgnew.has("errorCode") && "2009".equals(stMsgnew.getString("errorCode"))) {
response.sendRedirect("https://office.bankoftianjin.com/interface/transfer/mobile/noPermissons2.html");
}
} catch (JSONException e) {
bb.writeLog(e);
}
out.print(Util.null2String(stMsgnew.getString("message")));
return;
}
String loginUrl = "";
String remuseUrl = sysUrl;
boolean isEm = Util.null2String(request.getHeader("user-agent")).indexOf("E-Mobile") > -1;
if (1 == 1) {
loginUrl = remuseUrl + "ticket=" + ST;
//loginUrl="http://123.151.115.199:8080/bi/PCFW?proc=1&action=viewer&hback=true&db=%E6%99%BA%E6%85%A7%E6%96%B9%E7%95%A5/%E5%89%8D%E7%BD%AE%E9%A1%B5.db&ticket="+ST;
}
bb.writeLog("loginUrl-->" + loginUrl);
response.sendRedirect(loginUrl);
}
//----------------------------------TGT未找到---------------------------------------------
} else {
try {
out.print(Util.null2String(stMsg.getString("message")));
} catch (org.json.JSONException e) {
e.printStackTrace();
}
}
} catch (JSONException e) {
bb.writeLog(e);
}
return;
}
String loginUrl = "";
// String remuseUrl = bb.getPropValue("tjbkremuse", "hbUrl");
String remuseUrl = sysUrl;
boolean isEm = Util.null2String(request.getHeader("user-agent")).indexOf("E-Mobile") > -1;
if (1 == 1) {
loginUrl = remuseUrl + "ticket=" + ST;
}
//loginUrl = "https://www.baidu.com/";
bb.writeLog("loginUrl-->" + loginUrl);
out.print("跳转路径-->" + loginUrl);
//out.print(loginUrl);
response.sendRedirect(loginUrl);
// request.getRequestDispatcher("loginUrl").forward(request,response);
// return;
}
} else {
bb.writeLog("TGT已失效");
String TGT = "";
String passWord = "";
String retMsg = "";
decriptList.add(login_id);
decriptList.add(user_password);
List<String> resultList = rsa.decryptList(request, decriptList);
String loginId = resultList.get(0);
String userPassword = resultList.get(1);
String publicKey = getPublicKey(MachInfo);
passWord = encrypt(user_password, publicKey);
params = new HashMap<>();//参数
params.put("username", loginId);
params.put("password", passWord);
bb.writeLog("==STparams==" + params);
headers = new HashMap<>();//headers
headers.put("API_KEY", API_KEY);
headers.put("MACH_ID", MachInfo.get("deviceId"));
headers.put("MACH_TYPE", Util.null2String(MachInfo.get("clientType"), "0"));
headers.put("MACH_IP", MachInfo.get("param_ip"));
retMsg = httpPostForm(tgturl, params, headers, null);
bb.writeLog("===获取TGT返回值retMsg====" + retMsg);
org.json.JSONObject resMsg = new org.json.JSONObject(retMsg);
bb.writeLog("===获取TGT返回值====" + resMsg);
if (resMsg.has("TGT")) {
TGT = Util.null2String(resMsg.get("TGT").toString());
} else {
//密码不正确,执行强制退出
if ("2002".equals(resMsg.get("errorCode") + "")) {
out.print("<h3 style='font-size: 20px;'>您的单点系统密码已修改,请重新登录,将在3秒后退出</h3>");
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
JSONObject postBody = new JSONObject();
String sysid = Prop.getPropValue("emsysinfo", "sysid");
postBody.put("sysid", sysid);
postBody.put("userids", user.getUID());
postBody.put("offline_type", "1");
postBody.put("client_type", "1,2,3");
String errmsg = EMExt(getEMToken(), postBody.toJSONString());
}
});
thread.start();
return;
} else {
out.print(resMsg.get("message"));
return;
}
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
Date expiresDate = new Date(now.getTime() + (4 * 60 * 60 * 1000));
request.getSession(true).setAttribute("certified_token_expires", sdf.format(expiresDate));//记录toekn失效日期时间
request.getSession(true).setAttribute("certified_token", TGT);//记录toekn
String responseInfo = getST(TGT, cockpitUrl, MachInfo);
if (StringUtil.isBlank(responseInfo)) {
out.print("单点系统接口返回值为null");
return;
} else {
org.json.JSONObject stMsg = new org.json.JSONObject(responseInfo);
if (stMsg.has("ST")) {
ST = Util.null2String(stMsg.get("ST").toString());
} else {
try {
if (stMsg.has("errorCode") && "2009".equals(stMsg.getString("errorCode"))) {
response.sendRedirect("https://office.bankoftianjin.com/interface/transfer/mobile/noPermissons2.html");
}
} catch (JSONException e) {
bb.writeLog(e);
}
out.print(Util.null2String(stMsg.getString("message")));
return;
}
String loginUrl = "";
String remuseUrl = sysUrl;
boolean isEm = Util.null2String(request.getHeader("user-agent")).indexOf("E-Mobile") > -1;
if (1 == 1) {
loginUrl = remuseUrl + "ticket=" + ST;
}
bb.writeLog("loginUrl-->" + loginUrl);
response.sendRedirect(loginUrl);
}
}
%>
 <script type="text/javascript">
 </script>

@ -110,7 +110,7 @@ public class LoginEMFilter implements Filter {
Date currentDate = new Date(); Date currentDate = new Date();
long difference = currentDate.getTime() - parsedDate.getTime(); long difference = currentDate.getTime() - parsedDate.getTime();
if (difference > 2 * 60 * 1000) { // 10分钟 = 10 * 60 * 1000 毫秒 if (difference > 5 * 60 * 1000) { // 10分钟 = 10 * 60 * 1000 毫秒
return true; return true;
} else { } else {
return false; return false;

Loading…
Cancel
Save