项目初始化创建

This commit is contained in:
2024-04-12 11:38:46 +08:00
commit 9eda320ed5
144 changed files with 9527 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
package com.seeyon.apps.src_dingding.util;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
* sql执行工具类
* 2021-06-08
* @author huangzhengguo
*
*/
public class BaseUtil {
PreparedStatement ps = null;
ResultSet res = null;
Connection conn =null;
/**
* sql查询工具
* @param sql sql语句
* @param params sql参数
* @return 结果集
*/
public ResultSet executeQuery(String sql, Object[] params)
{
conn = JdbcUtil.getConnection();
try {
ps = conn.prepareStatement(sql);
for(int i = 0; i < params.length; i++){
ps.setObject(i+1, params[i]);
}
res = ps.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return res;
}
/**
* sql更新工具
* @param sql
* @param params
* @return
*/
public int executeUpdate(String sql, Object[] params)
{
int res = 0;
conn = JdbcUtil.getConnection();
try {
ps = conn.prepareStatement(sql);
for(int i = 0; i < params.length; i++)
{
ps.setObject(i+1, params[i]);
}
res = ps.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return res;
}
public void close() {
release(res,null,conn,ps);
}
//定义一个释放资源的方法;
/*
* 定义一个方法: 释放资源: 直接将rs stmt conn 全部释放:
*/
public static void release(ResultSet rs ,Statement stmt , Connection conn,PreparedStatement ps){
if(rs!=null){
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs=null;
}
if(stmt!=null){
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
stmt=null;
}
if(conn!=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
conn=null;
}
if(ps!=null){
try {
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
ps=null;
}
}
}

View File

@@ -0,0 +1,127 @@
package com.seeyon.apps.src_dingding.util;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiGettokenRequest;
import com.dingtalk.api.response.OapiGettokenResponse;
import com.taobao.api.ApiException;
public class DingtalkUtil {
public String getToken() throws RuntimeException, ApiException, FileNotFoundException, IOException {
// DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
OapiGettokenRequest request = new OapiGettokenRequest();
request.setAppkey("dingtiefuskr6oycl5ah");
request.setAppsecret("5V_zIyAXU3Fx0yl20uxGotc3zIdrAXnKERat_ciEez0u3jqaVjosQhlflu5-83St");
request.setHttpMethod("GET");
OapiGettokenResponse response = client.execute(request);
JSONObject jsonObject = JSON.parseObject(response.getBody());
String token = jsonObject.getString("access_token");
return token;
}
/**
* 调用post接口
*
* @param str 调用接口传递的参数json
* @param urlStr 需要调用的url对应的参数文件中的编码
* @return
* @throws ApiException
* @throws RuntimeException
*/
public JSONObject doPost(String str, String urlStr) throws RuntimeException, ApiException {
HttpURLConnection connection = null;
InputStream is = null;
OutputStream os = null;
BufferedReader br = null;
String result = null;
try {
String token = getToken();
URL url = new URL(urlStr+"?access_token="+token);
// 通过远程url连接对象打开连接
connection = (HttpURLConnection) url.openConnection();
// 设置连接请求方式
connection.setRequestMethod("POST");
// 设置连接主机服务器超时时间15000毫秒
connection.setConnectTimeout(15000);
// 设置读取主机服务器返回数据超时时间60000毫秒
connection.setReadTimeout(60000);
// 默认值为false当向远程服务器传送数据/写数据时需要设置为true
connection.setDoOutput(true);
// 默认值为true当前向远程服务读取数据时设置为true该参数可有可无
connection.setDoInput(true);
// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
// connection.setRequestProperty("access_token", token);
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
// 通过连接对象获取一个输出流
os = connection.getOutputStream();
// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
if (!("".equals(str) || str == null)) {
os.write(str.getBytes("UTF-8"));
}
// 连接对象获取一个输入流,向远程读取
System.out.println(connection.getResponseCode());
if (connection.getResponseCode() == 200) {
is = connection.getInputStream();
// 对输入流对象进行包装:charset根据工作项目组的要求来设置
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer sbf = new StringBuffer();
String temp = null;
// 循环遍历一行一行读取数据
while ((temp = br.readLine()) != null) {
sbf.append(temp);
sbf.append("\r\n");
}
result = sbf.toString();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 关闭资源
if (null != br) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != os) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != is) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
// 断开与远程地址url的连接
connection.disconnect();
}
JSONObject json = JSONObject.parseObject(result);
return json;
}
}

View File

@@ -0,0 +1,111 @@
package com.seeyon.apps.src_dingding.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.seeyon.v3x.services.form.bean.RecordExport;
import com.seeyon.v3x.services.form.bean.SubordinateFormExport;
import com.seeyon.v3x.services.form.bean.ValueExport;
//创建无流程表单数据处理工具类
public class FormExportUtil {
/**
* 设置主表信息
* @param map 设置主表字段。Map<主表显示名称,主表数据>
* @return
*/
public List<ValueExport> setFormValue(Map<String, String> map){
// 创建返回值对象
List<ValueExport> valueExports = new ArrayList<ValueExport>();
ValueExport valueExport ;
// 获取参数信息(显示名称)
Set<String> keys = map.keySet();
if(keys.size()>0) {
// 对控件赋值
for (String key : keys) {
valueExport = new ValueExport();
valueExport.setDisplayName(key);
valueExport.setValue(map.get(key));
valueExports.add(valueExport);
}
}
return valueExports;
}
/**
* 设置从表信息
* @param lists 设置主表字段。List<Map<显示名称,数据值>>
*/
public List<SubordinateFormExport> setSubordinateFormValue(List<Map<String, String>> lists){
List<SubordinateFormExport> subordinateFormExports = new ArrayList<SubordinateFormExport>();
SubordinateFormExport subordinateFormExport = new SubordinateFormExport();
List<RecordExport> recordExports = new ArrayList<RecordExport>();
List<ValueExport> valueExports;
RecordExport recordExport;
for(int i = 0 ; i < lists.size() ; i++) {
recordExport = new RecordExport();
valueExports = setFormValue(lists.get(i));
recordExport.setRecord(valueExports);
recordExports.add(recordExport);
}
subordinateFormExport.setValues(recordExports);
subordinateFormExports.add(subordinateFormExport);
return subordinateFormExports;
}
/**
* 格式转换将{"id":1,"str1":"123","str2":"asd","str3":"qwe"},{"id":2,"str1":"123","str2":"asd","str3":"qwe"},{"id":3,"str1":"123","str2":"asd","str3":"qwe"},{"id":1,"str1":"123","str2":"asd","str3":"qwe"},{"id":2,"str1":"123","str2":"asd","str3":"qwe"},{"id":3,"str1":"123","str2":"asd","str3":"qwe"}]
有什么办法转换成
[{"id":1,"data":[{"id":1,"str1":"123","str2":"asd","str3":"qwe"},{"id":1,"str1":"123","str2":"asd","str3":"qwe"}]}{"id":2,"data":[{"id":2,"str1":"123","str2":"asd","str3":"qwe"},{"id":2,"str1":"123","str2":"asd","str3":"qwe"}]}{"id":3,"data":[{"id":3,"str1":"123","str2":"asd","str3":"qwe"},{"id":3,"str1":"123","str2":"asd","str3":"qwe"}]}]
* @param inputList
* @return
*/
public List<Map<String, Object>> transformData(JSONArray inputList) {
Map<String, List<Map<String, Object>>> groupedData = new HashMap<>();
for(int i = 0 ; i < inputList.size();i++) {
String userId = inputList.getJSONObject(i).getString("userId");
groupedData.computeIfAbsent(userId, k -> new ArrayList<>()).add(inputList.getJSONObject(i));
}
List<Map<String, Object>> result = new ArrayList<>();
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("userId", entry.getKey());
resultMap.put("data", entry.getValue());
result.add(resultMap);
}
return result;
}
public JSONArray dingdingTimeSequence (JSONArray datas){
for (int i = 0; i < datas.size() - 1; i++) {
for (int j = 0; j < datas.size() - i - 1; j++) {
String value1 = datas.getJSONObject(j).getString("baseCheckTime");
String value2 = datas.getJSONObject(j + 1).getString("baseCheckTime");
long long1 = Long.parseLong(value1);
long long2 = Long.parseLong(value2);
if (long1 > long2) {
JSONObject temp = datas.getJSONObject(j);
datas.set(j, datas.getJSONObject(j + 1));
datas.set(j + 1, temp);
}
}
}
return datas;
}
}

View File

@@ -0,0 +1,93 @@
package com.seeyon.apps.src_dingding.util;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import com.seeyon.apps.src_dingding.kit.PropKit;
/**
* jdbc工具类
* 2021-06-08
* @author huangzhengguo
*
*/
public class JdbcUtil {
private static String url;
private static String user;
private static String password;
static {
// 使用properties加载属性文件
// Properties prop = new Properties();
try {
// InputStream is = JdbcUtil.class.getClassLoader().getResourceAsStream("jdbc.properties");
// prop.load(is);
// 注册驱动(获取属性文件中的数据)
// String driverClassName = prop.getProperty("jdbc_driver");
System.out.println(PropKit.getProp(PropKit.JDBCDRIVER));
String driverClassName = PropKit.getProp(PropKit.JDBCDRIVER);
Class.forName(driverClassName);
// 获取属性文件中的url,username,password
// url = prop.getProperty("jdbc_url");
System.out.println(PropKit.getProp(PropKit.JDBCURL));
url = PropKit.getProp(PropKit.JDBCURL);
// user = prop.getProperty("jdbc_user");
System.out.println(PropKit.getProp(PropKit.JDBCUSER));
user = PropKit.getProp(PropKit.JDBCUSER);
// password = prop.getProperty("jdbc_password");
System.out.println(PropKit.getProp(PropKit.JDBCPASSWORD));
password = PropKit.getProp(PropKit.JDBCPASSWORD);
} catch (Exception e) {
e.printStackTrace();
}
}
// 获取数据库连接
public static Connection getConnection() {
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
// 释放资源
public static void close(Connection conn, Statement stat, ResultSet rs) {
close(conn, stat);
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
// 释放资源
public static void close(Connection conn, Statement stat) {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (stat != null) {
try {
stat.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,66 @@
package com.seeyon.apps.src_dingding.util;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
import com.seeyon.ctp.util.JDBCAgent;
public class TimeUtil {
private EnumManager enumManagerNew;
public EnumManager getEnumManager() {
if (this.enumManagerNew == null) {
this.enumManagerNew = ((EnumManager)AppContext.getBean("enumManagerNew"));
}
return enumManagerNew;
}
public void setEnumManagerNew(EnumManager enumManagerNew) {
this.enumManagerNew = enumManagerNew;
}
// 获取定时任务的同步频率
public String getTime() {
JDBCAgent agent = new JDBCAgent();
String time = "";
// String sqlString = "select field0001,field0002,field0003 from formmain_0067";
String sqlString = "select field0044,field0042,field0043 from formmain_1224";
try {
StringBuilder sql = new StringBuilder(sqlString);
List<Object> p = new ArrayList<Object>();
agent.execute(sql.toString(), p);
List<Map> list = agent.resultSetToList();
Map map = list.get(0);
Long enumid = Long.parseLong(map.get("field0044").toString());
String shi = map.get("field0042").toString();
String fen = map.get("field0043").toString();
String str = getEnumManager().getEnumItem(enumid).getValue();
if("0".equals(str)) {
time = "I-"+shi+","+fen;
}else {
time = "D-"+shi+","+fen;
}
} catch (BusinessException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}finally {
if (agent != null) {
agent.close();
}
}
return time;
}
}