first commit

This commit is contained in:
2026-09-20 15:46:34 +08:00
parent 72fb5eae10
commit e558339dcc
3340 changed files with 671310 additions and 251 deletions
@@ -1,6 +1,5 @@
package io.v.nutz.base.utils;
import okhttp3.*;
import org.nutz.http.Header;
import org.nutz.http.Http;
import org.nutz.ioc.loader.annotation.Inject;
@@ -31,10 +30,10 @@ public class WxHttpUtil {
@Inject
private WxTokenUtil wxTokenUtil;
private final OkHttpClient okHttpClient = new OkHttpClient();
private final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private final MediaType formData = MediaType.parse("multipart/form-data");
private final NutMap jsonHeader = NutMap.NEW().setv("Content-Type", "application/json");
// private final OkHttpClient okHttpClient = new OkHttpClient();
// private final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// private final MediaType formData = MediaType.parse("multipart/form-data");
// private final NutMap jsonHeader = NutMap.NEW().setv("Content-Type", "application/json");
public String env = "unionpal-0ge58oan8d6fa30e";
@@ -63,22 +62,24 @@ public class WxHttpUtil {
Map<String, String> reqBody = new HashMap<>();
reqBody.put("env", this.env);
reqBody.put("query", query);
Header header = Header.create(jsonHeader);
org.nutz.http.Response response = Http.post3(queryUrl, Json.toJson(reqBody), header, 200000);
return Json.fromJson(NutMap.class, new InputStreamReader(response.getStream()));
// Header header = Header.create(jsonHeader);
// org.nutz.http.Response response = Http.post3(queryUrl, Json.toJson(reqBody), header, 200000);
// return Json.fromJson(NutMap.class, new InputStreamReader(response.getStream()));
return null;
}
public NutMap getCloudResult(String queryUrl, String name, Map<String, Object> reqBody) throws IOException {
String url = queryUrl.replace("ACCESS_TOKEN", wxTokenUtil.getWeAppAccesstoken())
.replace("ENV", this.env).replace("FUNCTION_NAME", name);
RequestBody b = RequestBody.create(Json.toJson(reqBody), JSON);
Request request = new Request.Builder()
.url(url)
.post(b)
.build();
Call call = okHttpClient.newCall(request);
Response response = call.execute();
return Json.fromJson(NutMap.class, Objects.requireNonNull(response.body()).string());
// String url = queryUrl.replace("ACCESS_TOKEN", wxTokenUtil.getWeAppAccesstoken())
// .replace("ENV", this.env).replace("FUNCTION_NAME", name);
// RequestBody b = RequestBody.create(Json.toJson(reqBody), JSON);
// Request request = new Request.Builder()
// .url(url)
// .post(b)
// .build();
// Call call = okHttpClient.newCall(request);
// Response response = call.execute();
// return Json.fromJson(NutMap.class, Objects.requireNonNull(response.body()).string());
return null;
}
/**
@@ -89,25 +90,26 @@ public class WxHttpUtil {
* @throws IOException
*/
public String getWxFileUrl(String fileid) throws IOException {
String url = this.downloadUrl.replace("ACCESS_TOKEN", wxTokenUtil.getWeAppAccesstoken());
Map mf = new HashMap<String, String>();
mf.put("fileid", fileid);
mf.put("max_age", 7200);
ArrayList<Map> fm = new ArrayList<>();
fm.add(mf);
Map reqbody = new HashMap<String, String>();
reqbody.put("env", this.env);
reqbody.put("file_list", fm);
Header header = Header.create(jsonHeader);
org.nutz.http.Response response = Http.post3(url, Json.toJson(reqbody), header, 200000);
NutMap map = Json.fromJson(NutMap.class, new InputStreamReader(response.getStream()));
if (map.getInt("errcode") == 0 && map.getString("errmsg").equals("ok")) {
NutMap res = map.getAsList("file_list", NutMap.class).get(0);
return res.getString("download_url");
} else {
log.error(map.getString("errmsg"));
return null;
}
// String url = this.downloadUrl.replace("ACCESS_TOKEN", wxTokenUtil.getWeAppAccesstoken());
// Map mf = new HashMap<String, String>();
// mf.put("fileid", fileid);
// mf.put("max_age", 7200);
// ArrayList<Map> fm = new ArrayList<>();
// fm.add(mf);
// Map reqbody = new HashMap<String, String>();
// reqbody.put("env", this.env);
// reqbody.put("file_list", fm);
// Header header = Header.create(jsonHeader);
// org.nutz.http.Response response = Http.post3(url, Json.toJson(reqbody), header, 200000);
// NutMap map = Json.fromJson(NutMap.class, new InputStreamReader(response.getStream()));
// if (map.getInt("errcode") == 0 && map.getString("errmsg").equals("ok")) {
// NutMap res = map.getAsList("file_list", NutMap.class).get(0);
// return res.getString("download_url");
// } else {
// log.error(map.getString("errmsg"));
// return null;
// }
return null;
}
/**
@@ -122,14 +124,15 @@ public class WxHttpUtil {
* @return
*/
public NutMap getUploadFile(String wxfilePath) throws Exception {
String Url = this.uploadUrl.replace("ACCESS_TOKEN", wxTokenUtil.getWeAppAccesstoken());
Map reqbody = new HashMap<String, String>();
reqbody.put("env", this.env);
reqbody.put("path", wxfilePath);
Header header = Header.create(jsonHeader);
org.nutz.http.Response response = Http.post3(Url, Json.toJson(reqbody), header, 200000);
NutMap map = Json.fromJson(NutMap.class, new InputStreamReader(response.getStream()));
return map;
// String Url = this.uploadUrl.replace("ACCESS_TOKEN", wxTokenUtil.getWeAppAccesstoken());
// Map reqbody = new HashMap<String, String>();
// reqbody.put("env", this.env);
// reqbody.put("path", wxfilePath);
// Header header = Header.create(jsonHeader);
// org.nutz.http.Response response = Http.post3(Url, Json.toJson(reqbody), header, 200000);
// NutMap map = Json.fromJson(NutMap.class, new InputStreamReader(response.getStream()));
// return map;
return null;
}
@@ -141,28 +144,29 @@ public class WxHttpUtil {
* @throws Exception
*/
public String uploadFile(NutMap map, TempFile file, String wxfilePath) throws Exception {
String url = map.getString("url");
String token = map.getString("token");
String authorization = map.getString("authorization");
String file_id = map.getString("file_id");
String cos_file_id = map.getString("cos_file_id");
RequestBody fb = RequestBody.create(file.getFile(), formData);
RequestBody b = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("key", wxfilePath)
.addFormDataPart("Signature", authorization)
.addFormDataPart("x-cos-security-token", token)
.addFormDataPart("x-cos-meta-fileid", cos_file_id)
.addFormDataPart("file", "filename", fb)
.build();
Request request = new Request.Builder()
.url(url)
.post(b)
.build();
Call call = okHttpClient.newCall(request);
Response response = call.execute();
//没有返回的内容 。。。怎么判断是否成功 难道去查?
return file_id;
// String url = map.getString("url");
// String token = map.getString("token");
// String authorization = map.getString("authorization");
// String file_id = map.getString("file_id");
// String cos_file_id = map.getString("cos_file_id");
// RequestBody fb = RequestBody.create(file.getFile(), formData);
// RequestBody b = new MultipartBody.Builder()
// .setType(MultipartBody.FORM)
// .addFormDataPart("key", wxfilePath)
// .addFormDataPart("Signature", authorization)
// .addFormDataPart("x-cos-security-token", token)
// .addFormDataPart("x-cos-meta-fileid", cos_file_id)
// .addFormDataPart("file", "filename", fb)
// .build();
//
// Request request = new Request.Builder()
// .url(url)
// .post(b)
// .build();
// Call call = okHttpClient.newCall(request);
// Response response = call.execute();
// //没有返回的内容 。。。怎么判断是否成功 难道去查?
// return file_id;
return null;
}
}
@@ -74,12 +74,12 @@ public class NutShiroProcessor extends AbstractProcessor {
//不需要认证授权的url
String[] authIgnoreUrlArr = Lang.array("/",
"/sso/login",
// "/platform/login",
"/platform/login",
"/platform/login(/doLogin|/logout|/captcha)",
"/platform/qywechat/.*",
"/platform/wechat/.*",
"/platform/home/(500|403|404|UnknownAccountError|LockedAccountError)",
// "/mobile/login",
"/mobile/login",
"/mobile/login/doLogin"
);
if (Arrays.stream(authIgnoreUrlArr).noneMatch(v -> Pattern.compile(v).matcher(requestURI).matches())) {
+14 -14
View File
@@ -1,26 +1,26 @@
nutz.application.name=union_hhu
server.port=8081
server.port=8080
server.host=0.0.0.0
jetty.contextPath=/
jetty.threadpool.idleTimeout=100000
jetty.threadpool.minThreads=10
jetty.threadpool.maxThreads=20000
jetty.page.403=/error/403.htmla
jetty.page.403=/error/403.html
jetty.page.404=/error/404.html
jetty.page.500=/error/500.html
#结合ftp使用,或用nginx代理ftp路径
jetty.staticPath=D://files
jetty.staticPath=D://filesu
#开发模式静态资源
jetty.staticPathLocal=
jetty.staticPathLocal=D:/gsProject/zhgh_hhu/src/main/resources/static
nutz.mvc.ignore=^(.+[.])(jsp|png|gif|jpg|js|css|jpeg|html|mp3|mp4|ico|svg)$
nutz.mvc.exclusions=/favicon/*,/assets/*,/druid/*,/upload/*
ftp.enabled=true
ftp.host=202.119.115.17
ftp.port=21
ftp.username=ftp_user
ftp.password=zhgh@17server
ftp.host=192.168.21.203
ftp.port=9090
ftp.username=ftpuser
ftp.password=123456
ftp.timeout=100
redis.host=202.119.115.17
redis.host=127.0.0.1
redis.port=6379
redis.timeout=2000
redis.max_redir=10
@@ -29,14 +29,14 @@ redis.maxTotal=850
redis.pool.maxTotal=900
redis.pool.maxIdle=500
redis.pool.minIdle=50
redis.password=dd3s
#redis.password=dd3s
#redis集群模式设置
#redis.mode=cluster
redis.mode=normal
#redis.nodes=192.168.6.31:6377,192.168.6.31:6378,192.168.6.28:6377,192.168.6.28:6378,192.168.6.34:6377,192.168.6.34:6378
jdbc.url=jdbc:mysql://202.119.115.17:3306/union?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
jdbc.url=jdbc:mysql://192.168.21.215:3306/union_hhu?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
jdbc.username=root
jdbc.password=zhgh@17server
jdbc.password=root
jdbc.validationQuery=select 1
jdbc.maxActive=900
jdbc.testWhileIdle=true
@@ -57,7 +57,7 @@ xsssql.ignore.urls=/platform/cms/content/article/addDo,/platform/sys/app/conf/ad
/platform/reimbursement/applyNew/doAdd,/platform/member/common/saveUser,\
/platform/sys/union/mange/unionPageData,/platform/fw/condolence/apply/doAdd
#环境 dev/prod
v.environment=prod
v.environment=dev
v.loginUrl=/sso/login
v.loginUrlMobile=/mobile/cas/login
#shiro.ini.path=shiro.ini
@@ -86,7 +86,7 @@ shiro.url.login=/platform
shiro.url.logout_redirect=/platform
shiro.url.unauth=/platform
#开发时设置本地路径,便于调试
beetl.RESOURCE.rootLocal=
beetl.RESOURCE.rootLocal=D:/gsProject/zhgh_hhu/src/main/resources/views/
beetl.RESOURCE.root=views/
beetl.DELIMITER_STATEMENT_START=<!--#
beetl.DELIMITER_STATEMENT_END=#-->
+174 -3
View File
@@ -1,10 +1,21 @@
package io.v.nutz;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.export.ExcelExportService;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.base.utils.MsgApi;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.data.model.UserSource;
import io.v.nutz.member.MemberMode;
import io.v.nutz.question.model.Question_issue;
import io.v.nutz.question.model.Question_wor;
import io.v.nutz.service.AsyncService;
import io.v.nutz.sickHelp.model.SickFundMember;
import io.v.nutz.sys.models.Sys_user;
@@ -13,6 +24,9 @@ import io.v.nutz.sys.models.User;
import io.v.nutz.sys.services.SysConfigService;
import io.v.nutz.sys.services.SysUserRoleService;
import io.v.nutz.sys.services.SysUserService;
import lombok.Data;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.apache.shiro.util.ByteSource;
import org.junit.Assert;
@@ -26,20 +40,28 @@ import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.integration.jedis.RedisService;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.trans.Trans;
import javax.servlet.ServletOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@@ -257,8 +279,157 @@ public class WebTestDemo extends Assert {
@Test
public void testMsgToken2() {
msgApi.sendMsg("1",List.of("18571562330"));
msgApi.sendMsg("1", List.of("18571562330"));
}
@Test
public void evalQuestion() {
String filePath = "C:\\Users\\jug\\Desktop\\新建文本文档.txt";
List<Question_issue> issues = new ArrayList<>();
Question_issue currentIssue = null;
try {
List<String> lines = Files.readAllLines(Paths.get(filePath));
for (String line : lines) {
line = line.trim();
if (line.isEmpty()) {
continue; // 跳过空行
}
// 检测题目
if (line.contains("[单选题]") || line.contains("【单选题】") || line.contains("[多选题]") || line.contains("【多选题】") || line.contains("[判断题]") || line.contains("【判断题】")) {
// 如果当前有题目,添加到列表中
if (currentIssue != null) {
issues.add(currentIssue);
}
// 创建新的题目
currentIssue = new Question_issue();
// 去除题目中的标签
String title = line.replaceAll("\\[单选题\\]", "").replaceAll("\\[多选题\\]", "")
.replaceAll("【单选题】", "").replaceAll("【多选题】", "")
.replaceAll("[判断题]", "").replaceAll("【判断题】", "");
// 去除序号
String[] patterns = {
"\\d+、", // 例如:1、
"\\d+\\.", // 例如:2.
"\\(\\d+\\)", // 例如:(3)
"第\\d+题" // 例如:第4题
};
for (String regex : patterns) {
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(title);
title = matcher.replaceAll("");
}
currentIssue.setIname(title);
currentIssue.setIisbd(true);
// 设置是否单选
if (line.contains("【单选题】") || line.contains("[单选题]")) {
currentIssue.setItx(1);
currentIssue.setIisdx(true);
} else if (line.contains("【多选题】") || line.contains("[多选题]")) {
currentIssue.setItx(1);
currentIssue.setIisdx(false);
} else if (line.contains("【判断题】") || line.contains("[判断题]")) {
currentIssue.setItx(3);
}
// 设置分数
currentIssue.setFraction(5);
// 初始化选项列表
currentIssue.setWors(new ArrayList<>());
} else {
// 处理选项
if (currentIssue != null && StrUtil.isNotBlank(line)) {
Question_wor wor = new Question_wor();
wor.setWtxt(line);
// 判断是否为正确答案
if (line.contains("(正确答案)") || line.contains("(正确答案)")) {
wor.setCorrect(true);
// 去除正确答案标记
wor.setWtxt(line.replace("(正确答案)", "").replace("(正确答案)", "").trim());
} else {
wor.setCorrect(false);
}
currentIssue.getWors().add(wor);
}
}
}
// 添加最后一题
if (currentIssue != null) {
issues.add(currentIssue);
}
// 输出解析结果
for (int i = 0; i < issues.size(); i++) {
issues.get(i).setIqid("7b44be22c6b042699779c9df5754a4da");
issues.get(i).setIpxbh(i + 1);
dao.insert(issues.get(i));
System.out.println(1);
List<Question_wor> wors = new ArrayList<>();
for (int i1 = 0; i1 < issues.get(i).getWors().size(); i1++) {
Question_wor wor = issues.get(i).getWors().get(i1);
wor.setWid(R.UU32());
wor.setWiid(issues.get(i).getIid());
wor.setWpxbh(i1 + 1);
wors.add(wor);
}
dao.insert(wors);
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void exportXlsx() throws IOException {
List<a> list = ExcelImportUtil.importExcel(new File("D:\\gooleDownload\\无标题.xlsx"), a.class, new ImportParams());
Map<String, List<a>> collect = list.stream().filter(v -> StrUtil.isNotBlank(v.getUnionname())).collect(Collectors.groupingBy(v -> v.getUnionname()));
ArrayList<ExcelExportEntity> entities = new ArrayList<>();
Workbook workbook = new XSSFWorkbook();
//每个分工会为一个sheet页
for (Map.Entry<String, List<a>> entry : collect.entrySet()) {
String sheetName = entry.getKey();
List<a> value = entry.getValue();
for (int i = 0; i < value.size(); i++) {
value.get(i).setNo(i + 1);
}
ExcelExportService service = new ExcelExportService();
ExportParams exportParams = new ExportParams();
exportParams.setTitle(sheetName);
exportParams.setSheetName(sheetName + "(" + value.size() + ")人");
exportParams.setType(ExcelType.XSSF);
// service.createSheetForMap(workbook, exportParams, entityList, value);
service.createSheet(workbook, exportParams, a.class, value);
}
FileOutputStream outputStream = new FileOutputStream("E:\\a.xlsx");
workbook.write(outputStream);
outputStream.close();
}
@Data
public static class a {
@Excel(name = "序号")
private Integer no;
@Excel(name = "工号", width = 20)
private String loginname;
@Excel(name = "姓名", width = 20)
private String username;
@Excel(name = "性别", width = 20)
private String sex;
@Excel(name = "出生年月", width = 20)
private String birthday;
@Excel(name = "在职状态", width = 20)
private String userState;
@Excel(name = "人员类型", width = 20)
private String personType;
@Excel(name = "单位", width = 20)
private String unitName;
@Excel(name = "分工会", width = 20)
private String unionname;
}
}