开始关闭数据库连接

This commit is contained in:
zhal 2023-10-17 08:39:31 +08:00
parent a7cfe16dc7
commit f859fccff8
2 changed files with 67 additions and 79 deletions

View File

@ -61,7 +61,7 @@ public class TaskController {
@Mapping("com.yili_pal_portal_open")
public String openPALConsole(String code) throws Exception {
ResponseObject ro = ResponseObject.newOkResponse();
Connection open = DBSql.open();
String userid = "";
@ -81,7 +81,7 @@ public class TaskController {
//System.out.println("userid》》》》》》》》》》"+json.getString("employeenumber"));
userid = json.getString("employeenumber");
try {
setUserLog("", userid, "1");
setUserLog("", userid, "1",open);
} catch (Exception e) {
}
}
@ -99,7 +99,7 @@ public class TaskController {
String portal_url = "https://bpm.yili.com:8088" + "/portal/r/or?cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1&sid=" + sessionId + "&oauthName=oauthLogin&code=" + code;
//ro.put("new_url",url);
DBSql.close(open);
return portal_url;
}
@ -111,11 +111,10 @@ public class TaskController {
* @param userid
* @param logType
*/
public void setUserLog(String processInstId, String userid, String logType) {
Connection open = DBSql.open();
public void setUserLog(String processInstId, String userid, String logType,Connection conn) {
System.err.println("用户登录记录存入日志========>" + userid + "_类型:" + logType);
if (UtilString.isNotEmpty(userid)) {
try {
//待阅更新已读记录
if ("3".equals(logType)) {
String dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
@ -138,14 +137,14 @@ public class TaskController {
String sqly = "SELECT PROCESSID,USER_ID,USERDEP,READTIMES,DATAID,TITLE,SENDTYPE,READSTATE,READCOUNT,ID FROM BO_ACT_DATAID WHERE PROCESSID='" + processInstId + "' AND USER_ID='"+userid+"' ";
RowMap mapsy = DBSql.getMap(open,sqly);
RowMap mapsy = DBSql.getMap(conn,sqly);
if (null != mapsy && !mapsy.isEmpty()) {
String alsqly = "SELECT USER_ID FROM BO_ACT_ALREADY_DATAID WHERE PROCESSID='" + processInstId + "' AND USER_ID='"+userid+"' ";
RowMap alsqlyMap = DBSql.getMap(open,alsqly);
RowMap alsqlyMap = DBSql.getMap(conn,alsqly);
if(alsqlyMap==null){
String sql = "insert into BO_ACT_ALREADY_DATAID (ID,PROCESSID,USER_ID,READTIMES,DATAID,TITLE,READSTATE) values ('%s', '%s', '%s', '%s', '%s', '%s','%s')";
String id = UUIDGener.getUUID();
int update = DBSql.update(open,String.format(sql, id, mapsy.getString("PROCESSID"), mapsy.getString("USER_ID"), dateTime, mapsy.getString("DATAID"),mapsy.getString("TITLE"),mapsy.getString("READSTATE")));
int update = DBSql.update(conn,String.format(sql, id, mapsy.getString("PROCESSID"), mapsy.getString("USER_ID"), dateTime, mapsy.getString("DATAID"),mapsy.getString("TITLE"),mapsy.getString("READSTATE")));
/* ProcessInstance boProcessInstance = SDK.getProcessAPI()
.createBOProcessInstance("obj_1a2207bf57eb4ed982ed24b9ed80e260", "admin", "OA已阅日志");
@ -162,7 +161,7 @@ public class TaskController {
if(update!=0){
System.out.println("count==========="+update);
String sql1 = "DELETE FROM BO_ACT_DATAID WHERE PROCESSID='"+processInstId+"'AND USER_ID='"+userid+"'";
DBSql.update(open,sql1);
DBSql.update(conn,sql1);
//SDK.getBOAPI().remove("BO_ACT_DATAID",mapsy.getString("ID"));
}
@ -184,12 +183,6 @@ public class TaskController {
bo.set("LOGTYPE", Integer.valueOf(logType));
SDK.getBOAPI().createDataBO("BO_EU_USER_LOGIN_LOG", bo, UserContext.fromUID("admin"));
DBSql.close(open);
} catch (Exception e) {
DBSql.close(open);
e.printStackTrace();
}
}
}
@ -203,11 +196,12 @@ public class TaskController {
*/
@Mapping("com.yili_form_page_open")
public String openFormPage(UserContext me, RequestParams params) {
Connection conn = DBSql.open();
//System.out.println("进入表单了===========");
//System.out.println("参数输出==========="+params.asMap());
//打开待办时记录日志
try {
setUserLog("", me.getUID(), "2");
setUserLog("", me.getUID(), "2",conn);
} catch (Exception e) {
}
String sessionId = me.getSessionId();
@ -262,6 +256,7 @@ public class TaskController {
//System.err.println("单点登录页面链接--->"+formURL);
//return portalUrl+"/r"+formURL.substring(1);
////System.out.println("输出表单==========="+formPage);
DBSql.close(conn);
return formPage;
}
@ -329,7 +324,7 @@ public class TaskController {
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("PUBLISHFILEID") + "'" + ") ORDER BY FILENAME ASC";
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
String methodId = DBSql.getString(conn,"select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("PUBLISHFILEID") + "'");
if (UtilString.isNotEmpty(methodId)) {
if (methodId.equals("control.policy")) {
@ -449,7 +444,7 @@ public class TaskController {
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("STOPFILEID") + "'" + ") ORDER BY FILENAME ASC";
String methodId = DBSql
.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
.getString(conn,"select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("STOPFILEID") + "'");
if (UtilString.isNotEmpty(methodId)) {
if (methodId.equals("control.policy")) {
@ -566,7 +561,7 @@ public class TaskController {
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.get("CHANGEDFILEIDNEW") + "'" + ") ORDER BY FILENAME ASC";
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
String methodId = DBSql.getString(conn,"select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("CHANGEDFILEIDNEW") + "'");
if (UtilString.isNotEmpty(methodId)) {
if (methodId.equals("control.policy")) {
@ -690,15 +685,42 @@ public class TaskController {
// jsonObject);
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
.addQuery("OPTIONTYPE IS NOT NULL", null).detail();
List<BO> bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).list();
if (bo_act_dataid.size() > 0) {
BO bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).detail();
if (bo_act_dataid!=null) {
System.out.println("查询未读数据=============" + processInstId + "USER_ID=========" + usercode);
for (BO bo : bo_act_dataid) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "read");
jsonObject.put("status", "1");
jsonObject.put("dataid", bo_act_dataid.getString("DATAID"));
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
+ " </web:service>" + " </soapenv:Body>" + "</soapenv:Envelope>";
HttpClient client = new HttpClient();
int timeout = 10000;
String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
UtilUrl uc=new UtilUrl();
String s = uc.doPostSoap(readurl, xmlStr, "");
System.err.println(instanceById.getTitle() + "OA待阅PC端阅读返回=======>" + s);
String nums = DBSql.getString(conn,
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
if (UtilString.isNotEmpty(nums)) {
Integer read_num = Integer.valueOf(nums);
read_num += 1;
DBSql.update(conn,"update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
+ processInstId + "'");
}
} else {
BO actAlreadyDataid = SDK.getBOAPI().query("BO_ACT_ALREADY_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).detail();
if(actAlreadyDataid!=null){
System.out.println("查询已读数据=============" + processInstId + "USER_ID=========" + usercode);
JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "read");
jsonObject.put("status", "1");
jsonObject.put("dataid", bo.getString("DATAID"));
jsonObject.put("dataid", actAlreadyDataid.getString("DATAID"));
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
@ -709,51 +731,21 @@ public class TaskController {
UtilUrl uc=new UtilUrl();
String s = uc.doPostSoap(readurl, xmlStr, "");
System.err.println(instanceById.getTitle() + "OA待阅PC端阅读返回=======>" + s);
String nums = DBSql.getString(
String nums = DBSql.getString(conn,
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
if (UtilString.isNotEmpty(nums)) {
Integer read_num = Integer.valueOf(nums);
read_num += 1;
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
DBSql.update(conn,"update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
+ processInstId + "'");
}
}
} else {
List<BO> actAlreadyDataid = SDK.getBOAPI().query("BO_ACT_ALREADY_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).list();
if (actAlreadyDataid.size() > 0) {
System.out.println("查询已读数据=============" + processInstId + "USER_ID=========" + usercode);
for (BO bo : actAlreadyDataid) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "read");
jsonObject.put("status", "1");
jsonObject.put("dataid", bo.getString("DATAID"));
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
+ " </web:service>" + " </soapenv:Body>" + "</soapenv:Envelope>";
HttpClient client = new HttpClient();
int timeout = 10000;
String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
UtilUrl uc=new UtilUrl();
String s = uc.doPostSoap(readurl, xmlStr, "");
System.err.println(instanceById.getTitle() + "OA待阅PC端阅读返回=======>" + s);
String nums = DBSql.getString(
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
if (UtilString.isNotEmpty(nums)) {
Integer read_num = Integer.valueOf(nums);
read_num += 1;
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
+ processInstId + "'");
}
}
}
}
// 用户打开阅览界面日志
setUserLog(processInstId, me.getUID(), "3");
//setUserLog(processInstId, me.getUID(), "3");
long have_time = System.currentTimeMillis();
@ -919,7 +911,7 @@ public class TaskController {
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("PUBLISHFILEID") + "'" + ") ORDER BY FILENAME ASC";
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
String methodId = DBSql.getString(conn,"select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("PUBLISHFILEID") + "'");
if (UtilString.isNotEmpty(methodId)) {
if (methodId.equals("control.policy")) {
@ -1105,7 +1097,7 @@ public class TaskController {
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("STOPFILEID") + "'" + ") ORDER BY FILENAME ASC";
String methodId = DBSql
.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
.getString(conn,"select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("STOPFILEID") + "'");
if (UtilString.isNotEmpty(methodId)) {
if (methodId.equals("control.policy")) {
@ -1281,7 +1273,7 @@ public class TaskController {
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("CHANGEDFILEIDNEW") + "'" + ") ORDER BY FILENAME ASC";
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
String methodId = DBSql.getString(conn,"select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
+ bo.getString("CHANGEDFILEIDNEW") + "'");
if (UtilString.isNotEmpty(methodId)) {
if (methodId.equals("control.policy")) {
@ -1399,14 +1391,13 @@ public class TaskController {
String mobileurl = portalUrl + "/r/or?cmd=com.yili_process_page_phone&processInstId=" + processInstId
+ "&taskInstId=" + taskInstId;
HttpClientUtils httpClientUtil = new HttpClientUtils();
List<BO> bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).list();
if (bo_act_dataid.size() > 0) {
for (BO bo : bo_act_dataid) {
BO bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).detail();
if (bo_act_dataid!=null) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("status", "1");
jsonObject.put("action", "read");
jsonObject.put("dataid", bo.getString("DATAID"));
jsonObject.put("dataid", bo_act_dataid.getString("DATAID"));
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
@ -1416,25 +1407,23 @@ public class TaskController {
UtilUrl uc=new UtilUrl();
String s = uc.doPostSoap(readurl, xmlStr, "");
//System.err.println(instanceById.getTitle()+"_OA待阅移动端阅读返回=======>"+s);
String nums = DBSql.getString(
String nums = DBSql.getString(conn,
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
if (UtilString.isNotEmpty(nums)) {
Integer read_num = Integer.valueOf(nums);
read_num += 1;
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
DBSql.update(conn,"update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
+ processInstId + "'");
}
}
} else {
List<BO> alreadyDataid = SDK.getBOAPI().query("BO_ACT_ALREADY_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).list();
if (alreadyDataid.size() > 0) {
for (BO bo : alreadyDataid) {
BO alreadyDataid = SDK.getBOAPI().query("BO_ACT_ALREADY_DATAID").addQuery("PROCESSID=", processInstId)
.addQuery("USER_ID=", usercode).detail();
if (alreadyDataid!=null) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("status", "1");
jsonObject.put("action", "read");
jsonObject.put("dataid", bo.getString("DATAID"));
jsonObject.put("dataid", alreadyDataid.getString("DATAID"));
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
@ -1444,21 +1433,20 @@ public class TaskController {
UtilUrl uc=new UtilUrl();
String s = uc.doPostSoap(readurl, xmlStr, "");
System.err.println(instanceById.getTitle() + "_OA待阅移动端阅读返回=======>" + s);
String nums = DBSql.getString(
String nums = DBSql.getString(conn,
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
if (UtilString.isNotEmpty(nums)) {
Integer read_num = Integer.valueOf(nums);
read_num += 1;
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
DBSql.update(conn,"update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
+ processInstId + "'");
}
}
}
}
System.out.println("插入待阅日志开始========================");
// 用户打开阅览界面日志
setUserLog(processInstId, me.getUID(), "3");
//setUserLog(processInstId, me.getUID(), "3");
System.out.println("插入待阅日志结束========================");
/*
* JSONObject jsonObject = new JSONObject(); SimpleDateFormat sdf = new

View File

@ -669,7 +669,7 @@ public class UpfileWeb extends ActionWeb {
}
}
/**
* 压缩附件下载功能