!15 修改test

Merge pull request !15 from new_new_new/feature/20260506-branch
This commit is contained in:
new_new_new
2026-05-06 00:57:12 +00:00
committed by Gitee
38 changed files with 1039 additions and 719 deletions
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>jeecg-boot-module</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>${jeecgProjectVersion}</version>
</parent>
<artifactId>jeecg-module-flow</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-local-api</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-module-bpm-flowable</artifactId>
<version>3.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-biz</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,17 @@
package org.jeecg;
//TIP 要<b>运行</b>代码,请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
public static void main(String[] args) {
//TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
// 查看 IntelliJ IDEA 建议如何修正。
System.out.printf("Hello and welcome!");
for (int i = 1; i <= 5; i++) {
//TIP 按 <shortcut actionId="Debug"/> 开始调试代码。我们已经设置了一个 <icon src="AllIcons.Debugger.Db_set_breakpoint"/> 断点
// 但您始终可以通过按 <shortcut actionId="ToggleLineBreakpoint"/> 添加更多断点。
System.out.println("i = " + i);
}
}
}
@@ -0,0 +1,33 @@
package org.jeecg.xispeak;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "flow-biz")
public class XiSpeakConfig {
/**
* 对应 yml 中的 xi-speak 节点
* Spring 会自动将中划线命名映射为驼峰命名
*/
private XiSpeakProperties xiSpeak;
@Data
public static class XiSpeakProperties {
/** 对应 bg-dept-id */
private String bgDeptId;
/** 对应 ld-role-id */
private String ldRoleId;
/** 对应 need-sdw-approve-code */
private String needSdwApproveCode;
/** 对应 json-data-key */
private String jsonDataKey;
/** 对应 impl-dept-key */
private String implDeptKey;
/** 对应impl-dept-collection-used*/
private String implDeptCollectionUsedKey;
}
}
@@ -0,0 +1,129 @@
package org.jeecg.xispeak;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.util.StringUtils;
import org.flowable.engine.RuntimeService;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Component("xiSpeakFlow")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class XiSpeakFlow {
private final XiSpeakConfig xiSpeakConfig;
private final ISysBaseAPI iSysBaseAPI;
private final RuntimeService runtimeService;
public List<String> getBgDeptLdUserIdList() {
// 1. 安全获取配置,防止 NPE
XiSpeakConfig.XiSpeakProperties props = xiSpeakConfig.getXiSpeak();
if (props == null || !StringUtils.hasText(props.getBgDeptId())) {
log.error("流程配置缺失: [flow-biz.xi-speak.bg-dept-id] 未在 YAML 中定义");
return Collections.emptyList();
}
// 2. 调用接口获取数据
log.info("正在查询部门: {} 下的角色: {} 的用户列表", props.getBgDeptId(), props.getLdRoleId());
List<String> userList = iSysBaseAPI.getUsersListByDeptIdAndRoleIdLocalApi(
props.getBgDeptId(),
props.getLdRoleId()
);
log.info("查询到的用户为: {}", userList);
return userList;
}
public Integer getNeedSdwApproval(Object jsonData) {
XiSpeakConfig.XiSpeakProperties props = xiSpeakConfig.getXiSpeak();
if (jsonData == null || org.apache.commons.lang.StringUtils.isBlank(props.getNeedSdwApproveCode())) {
return 0;
}
String codeName = props.getNeedSdwApproveCode();
if (org.apache.commons.lang.StringUtils.isBlank(codeName)) return 0;
try {
JSONObject data;
if (jsonData instanceof JSONObject) {
data = (JSONObject) jsonData;
} else if (jsonData instanceof String) {
if (org.apache.commons.lang.StringUtils.isBlank((String) jsonData)) {
return 0;
}
data = JSONObject.parseObject((String) jsonData);
} else {
data = JSONObject.parseObject(JSONObject.toJSONString(jsonData));
}
log.info("needSdwApproval结果为{}", data.getInteger(codeName));
return data == null ? 0 : data.getInteger(codeName);
} catch (Exception e) {
log.warn("getJsondata parse failed, codeName={}, jsonData={}", codeName, jsonData, e);
return 0;
}
}
public List<String> getImplDeptLdsList(String deptId) {
return iSysBaseAPI.getUsersListByDeptIdAndRoleIdLocalApi(deptId, xiSpeakConfig.getXiSpeak().getLdRoleId());
}
public int getListSize(String jsonData){
if (org.apache.commons.lang3.StringUtils.isEmpty(jsonData)) {
return 0;
}
return Math.toIntExact(Arrays.stream(jsonData.split(","))
.map(String::trim)
.filter(org.apache.commons.lang3.StringUtils::isNotEmpty)
.count());
}
// List<String> getImplDeptWorker(String JG_LOCAL_PROCESS_ID,String deptId){
// runtimeService.get
// }
public Integer getImplDeptNums(String jsonData) {
String codeName = xiSpeakConfig.getXiSpeak().getImplDeptKey();
if (jsonData == null || org.apache.commons.lang.StringUtils.isEmpty(codeName)) {
return 0;
}
// 1. 统一转成 JSONObject
JSONObject json;
json = JSON.parseObject((String) jsonData);
if (json == null || !json.containsKey(codeName)) {
return 0;
}
// 2. 获取原始对象进行兼容性处理
Object value = json.get(codeName);
if (value == null) {
return 0;
}
List<String> resultList = new ArrayList<>();
if (value instanceof Collection) {
// 情况 A: 本身就是集合/JSON数组
resultList.addAll(json.getJSONArray(codeName).toJavaList(String.class));
} else if (value instanceof String) {
// 情况 B: 是逗号分隔的字符串 "ID1,ID2,ID3"
String str = (String) value;
if (org.apache.commons.lang.StringUtils.isNotEmpty(str)) {
// 使用 split 拆分,并过滤掉空格和空字符串
String[] split = str.split(",");
for (String s : split) {
if (org.apache.commons.lang.StringUtils.isNotEmpty(s.trim())) {
resultList.add(s.trim());
}
}
}
}
return resultList.size();
}
}
@@ -0,0 +1,118 @@
package org.jeecg.modules.extbpm.listener.execution;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.extbpm.process.common.expression.FlowNodeExpression;
import lombok.RequiredArgsConstructor;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.extbpm.process.common.WorkFlowGlobals;
import org.jeecg.xispeak.XiSpeakConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Component("AfterSDWApproveHqListener")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class AfterSDWApproveHqListener implements ExecutionListener {
private static final long serialVersionUID = 1L;
private final FlowNodeExpression flowNodeExpression;
@Autowired
private RuntimeService runtimeService;
private final XiSpeakConfig xiSpeakConfig;
@Override
public void notify(DelegateExecution execution) {
XiSpeakConfig.XiSpeakProperties props = xiSpeakConfig.getXiSpeak();
//RuntimeService runtimeService = SpringContextUtils.getBean(RuntimeService.class);
String mainProcessId = (String)execution.getProcessInstanceId();
String url = (String)execution.getVariable(WorkFlowGlobals.BPM_FORM_CONTENT_URL);
// 打印主流程里所有的变量名,看看有没有 json_data
Map<String, Object> variables = runtimeService.getVariables(execution.getRootProcessInstanceId());
log.info("主流程中的所有变量名: " + variables.keySet());
// 打印当前执行流的所有变量名
log.info("当前执行流的所有变量名: " + execution.getVariables().keySet());
String bizTitle = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_BIZ_TITLE);
if(org.apache.commons.lang.StringUtil.isEmpty(url)) {
url = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_FORM_CONTENT_URL);
String mobileUrl = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_FORM_CONTENT_URL_MOBILE);
execution.setVariable(WorkFlowGlobals.BPM_FORM_CONTENT_URL, url);
execution.setVariable(WorkFlowGlobals.BPM_FORM_CONTENT_URL_MOBILE, mobileUrl);
}
// 1. 获取主流程中的 json_data 对象(可能是 String 或 JSONObject
Object jsonDataObj = (String)runtimeService.getVariable(mainProcessId,props.getJsonDataKey());
if (oConvertUtils.isNotEmpty(jsonDataObj)) {
String json_data = jsonDataObj.toString();
try {
// 2. 调用表达式解析工具获取特定字段的字符串内容
String jsonStr = flowNodeExpression.getJsondatastring(json_data, props.getImplDeptKey());
// 3. 只有当字段存在且内容不为空时,才进行解析
if (oConvertUtils.isNotEmpty(jsonStr)) {
List<String> deptIds = Arrays.stream(jsonStr.split(","))
.map(String::trim) // 去掉可能存在的空格
.filter(s -> !s.isEmpty()) // 过滤掉空字符串
.collect(Collectors.toList());
if (deptIds != null && !deptIds.isEmpty()) {
// 4. 将提取出的 List 存入子流程变量(供多实例 Collection 使用)
execution.setVariable( props.getImplDeptKey(), deptIds);
log.info("子流程变量 deptIdList 注入成功: " + deptIds);
}
}
} catch (Exception e) {
log.error("解析 JSON 字段 pending_depts_id 失败: ", e);
}
}
//获取主表数据id
String businessKey = (String)runtimeService.getVariable(mainProcessId, WorkFlowGlobals.BPM_DATA_ID);
//获取主表的设计表单数据ID
String BPM_DES_DATA_ID = oConvertUtils.getString(runtimeService.getVariable(mainProcessId, WorkFlowGlobals.BPM_DES_DATA_ID));
//获取主表表名
String tableName = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_FORM_KEY);
execution.setVariable(WorkFlowGlobals.BPM_FORM_KEY, tableName);
//--update--begin------author:scott-----date:20210512-----for:出差借款子流程,加载表单数据为空问题---------
//log.info("----------传入子流程的数据ID--------------: "+execution.getVariable(WorkFlowGlobals.DATA_ID));
if(oConvertUtils.isNotEmpty(execution.getVariable(WorkFlowGlobals.DATA_ID))){
execution.setVariable(WorkFlowGlobals.BPM_DATA_ID, execution.getVariable(WorkFlowGlobals.DATA_ID));
//如果是设计器表单,则还需要设置设计表单数据ID
if(oConvertUtils.isNotEmpty(BPM_DES_DATA_ID)){
execution.setVariable(WorkFlowGlobals.BPM_DES_DATA_ID, execution.getVariable(WorkFlowGlobals.DATA_ID));
}
}else{
//未传入id值,则获取主表数据id给子流程【online表单需要】
execution.setVariable(WorkFlowGlobals.BPM_DATA_ID, businessKey);
//如果是设计器表单,则还需要设置设计表单数据ID
if(oConvertUtils.isNotEmpty(BPM_DES_DATA_ID)){
execution.setVariable(WorkFlowGlobals.BPM_DES_DATA_ID, BPM_DES_DATA_ID);
}
}
//--update--end------author:scott-----date:20210512-----for:出差借款子流程,加载表单数据为空问题---------
//子流程实例set业务号和主流程保持一致
runtimeService.updateBusinessKey(execution.getProcessInstanceId(), businessKey);
}
}
@@ -0,0 +1,8 @@
flow-biz:
xi-speak:
bg-dept-id: "2044677604785229826"
ld-role-id: "2044680793306591234"
need-sdw-approve-code: "needSdwApproval"
json-data-key: "json_data"
impl-dept-key: "implDept"
impl-dept-collection-used-key: "impl_dept_id"
@@ -0,0 +1,117 @@
package org.jeecg.modules.extbpm.listener.execution;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtil;
import org.jeecg.modules.extbpm.process.common.expression.FlowNodeExpression;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.extbpm.process.common.WorkFlowGlobals;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Component("embeddedSubProcessHqStartListener")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class EmbeddedSubProcessHqStartListener implements ExecutionListener {
private static final long serialVersionUID = 1L;
private final FlowNodeExpression flowNodeExpression;
@Autowired
private RuntimeService runtimeService;
@Override
public void notify(DelegateExecution execution) {
//RuntimeService runtimeService = SpringContextUtils.getBean(RuntimeService.class);
String mainProcessId = (String)execution.getProcessInstanceId();
String url = (String)execution.getVariable(WorkFlowGlobals.BPM_FORM_CONTENT_URL);
// 打印主流程里所有的变量名,看看有没有 json_data
Map<String, Object> variables = runtimeService.getVariables(execution.getRootProcessInstanceId());
log.info("主流程中的所有变量名: " + variables.keySet());
// 打印当前执行流的所有变量名
log.info("当前执行流的所有变量名: " + execution.getVariables().keySet());
String bizTitle = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_BIZ_TITLE);
if(org.apache.commons.lang.StringUtil.isEmpty(url)) {
url = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_FORM_CONTENT_URL);
String mobileUrl = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_FORM_CONTENT_URL_MOBILE);
execution.setVariable(WorkFlowGlobals.BPM_FORM_CONTENT_URL, url);
execution.setVariable(WorkFlowGlobals.BPM_FORM_CONTENT_URL_MOBILE, mobileUrl);
}
// 1. 获取主流程中的 json_data 对象(可能是 String 或 JSONObject
Object jsonDataObj = (String)runtimeService.getVariable(mainProcessId,"json_data");
if (oConvertUtils.isNotEmpty(jsonDataObj)) {
String json_data = jsonDataObj.toString();
try {
// 2. 调用表达式解析工具获取特定字段的字符串内容
String jsonStr = flowNodeExpression.getJsondatastring(json_data, "implDept");
// 3. 只有当字段存在且内容不为空时,才进行解析
if (oConvertUtils.isNotEmpty(jsonStr)) {
List<String> deptIds = Arrays.stream(jsonStr.split(","))
.map(String::trim) // 去掉可能存在的空格
.filter(s -> !s.isEmpty()) // 过滤掉空字符串
.collect(Collectors.toList());
if (deptIds != null && !deptIds.isEmpty()) {
// 4. 将提取出的 List 存入子流程变量(供多实例 Collection 使用)
execution.setVariable("pending_depts_id", deptIds);
log.info("子流程变量 deptIdList 注入成功: " + deptIds);
}
}
} catch (Exception e) {
log.error("解析 JSON 字段 pending_depts_id 失败: ", e);
}
}
//获取主表数据id
String businessKey = (String)runtimeService.getVariable(mainProcessId, WorkFlowGlobals.BPM_DATA_ID);
//获取主表的设计表单数据ID
String BPM_DES_DATA_ID = oConvertUtils.getString(runtimeService.getVariable(mainProcessId, WorkFlowGlobals.BPM_DES_DATA_ID));
//获取主表表名
String tableName = (String)runtimeService.getVariable(mainProcessId,WorkFlowGlobals.BPM_FORM_KEY);
execution.setVariable(WorkFlowGlobals.BPM_FORM_KEY, tableName);
//--update--begin------author:scott-----date:20210512-----for:出差借款子流程,加载表单数据为空问题---------
//log.info("----------传入子流程的数据ID--------------: "+execution.getVariable(WorkFlowGlobals.DATA_ID));
if(oConvertUtils.isNotEmpty(execution.getVariable(WorkFlowGlobals.DATA_ID))){
execution.setVariable(WorkFlowGlobals.BPM_DATA_ID, execution.getVariable(WorkFlowGlobals.DATA_ID));
//如果是设计器表单,则还需要设置设计表单数据ID
if(oConvertUtils.isNotEmpty(BPM_DES_DATA_ID)){
execution.setVariable(WorkFlowGlobals.BPM_DES_DATA_ID, execution.getVariable(WorkFlowGlobals.DATA_ID));
}
}else{
//未传入id值,则获取主表数据id给子流程【online表单需要】
execution.setVariable(WorkFlowGlobals.BPM_DATA_ID, businessKey);
//如果是设计器表单,则还需要设置设计表单数据ID
if(oConvertUtils.isNotEmpty(BPM_DES_DATA_ID)){
execution.setVariable(WorkFlowGlobals.BPM_DES_DATA_ID, BPM_DES_DATA_ID);
}
}
//--update--end------author:scott-----date:20210512-----for:出差借款子流程,加载表单数据为空问题---------
//子流程实例set业务号和主流程保持一致
runtimeService.updateBusinessKey(execution.getProcessInstanceId(), businessKey);
}
}
@@ -0,0 +1,61 @@
package org.jeecg.modules.extbpm.listener.execution;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.jeecg.modules.extbpm.process.common.WorkFlowGlobals;
import org.jeecg.modules.extbpm.process.common.expression.FlowNodeExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Slf4j
@Component("subProcessSelectUserListener")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class SubProcessSelectUserListener implements ExecutionListener {
private final FlowNodeExpression flowNodeExpression;
@Autowired
private RuntimeService runtimeService;
@Override
public void notify(DelegateExecution execution) {
String mainProcessId = (String) execution.getProcessInstanceId();
String url = (String)execution.getVariable(WorkFlowGlobals.BPM_FORM_CONTENT_URL);
// 打印主流程里所有的变量名,看看有没有 json_data
Map<String, Object> variables = runtimeService.getVariables(execution.getRootProcessInstanceId());
log.info("主流程中的所有变量名: " + variables.keySet());
// 打印当前执行流的所有变量名
log.info("当前执行流的所有变量名: " + execution.getVariables().keySet());
// 1. 获取原生组件选中的处理人 (假设 Key 为 assigneeUserIdList)
Object selectedValue = execution.getVariable("assigneeUserIdList");
List<String> list = new ArrayList<>();
if (selectedValue instanceof String) {
// 如果是逗号分隔的字符串,拆分
list = Arrays.asList(((String) selectedValue).split(","));
} else if (selectedValue instanceof List) {
list = (List<String>) selectedValue;
}
// 2. 如果没选人,给个默认值防止报错,或者抛出业务异常
if (list.isEmpty()) {
throw new RuntimeException("请选择下一步处理人!");
}
// 3. 关键:将这个 List 存入局部变量,供下一节点的 Multi-instance 读取
// 使用 setVariableLocal 确保并行子流程互不干扰
execution.setVariableLocal("internal_collection", list);
}
}
@@ -201,4 +201,10 @@ public final class WorkFlowGlobals {
* 流程信号启动类型:按钮触发
*/
public static String START_BUTTON_EVENT = "buttonEvent";
/**
* 用于加载json_data字段的键名
*/
public static String JSON_DATA = "json_data";
public static String PENDING_DEPTS_ID = "pending_depts_id";
}
@@ -1,6 +1,7 @@
package org.jeecg.modules.extbpm.process.common.expression;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -75,6 +76,144 @@ public class FlowNodeExpression {
}
}
/**
* 根据字段名称在json_data内查询对应list或set的长度
* ${flowNodeExpression.getJsonDataSizeByCodeName(json_data,"pending_depts_id")}
*
* @param jsonData
* @param codeName
* @return
*/
public Integer getJsonDataSizeByCodeNameStr(Object jsonData, String codeName){
if (jsonData == null || StringUtils.isEmpty(codeName)) {
return 0;
}
// 1. 统一转成 JSONObject
JSONObject json;
if (jsonData instanceof String) {
json = JSON.parseObject((String) jsonData);
} else if (jsonData instanceof JSONObject) {
json = (JSONObject) jsonData;
} else {
return 0;
}
if (json == null || !json.containsKey(codeName)) {
return 0;
}
// 2. 获取原始对象进行兼容性处理
Object value = json.get(codeName);
if (value == null) {
return 0;
}
List<String> resultList = new ArrayList<>();
if (value instanceof Collection) {
// 情况 A: 本身就是集合/JSON数组
resultList.addAll(json.getJSONArray(codeName).toJavaList(String.class));
} else if (value instanceof String) {
// 情况 B: 是逗号分隔的字符串 "ID1,ID2,ID3"
String str = (String) value;
if (StringUtils.isNotEmpty(str)) {
// 使用 split 拆分,并过滤掉空格和空字符串
String[] split = str.split(",");
for (String s : split) {
if (StringUtils.isNotEmpty(s.trim())) {
resultList.add(s.trim());
}
}
}
}
return resultList.size();
}
/**
* 根据字段名称在json_data内查询对应list或set的长度
* ${flowNodeExpression.getJsonDataSizeByCodeName(json_data,"pending_depts_id")}
*
* @param jsonData
* @param codeName
* @return
*/
public Integer getJsonDataSizeByCodeNameObj(Object jsonData, String codeName){
if (jsonData == null || StringUtils.isEmpty(codeName)) {
return 0;
}
// 1. 统一转成 JSONObject
JSONObject json;
if (jsonData instanceof String) {
json = JSON.parseObject((String) jsonData);
} else if (jsonData instanceof JSONObject) {
json = (JSONObject) jsonData;
} else {
return 0;
}
if (json == null || !json.containsKey(codeName)) {
return 0;
}
// 2. 获取原始对象进行兼容性处理
Object value = json.get(codeName);
if (value == null) {
return 0;
}
List<String> resultList = new ArrayList<>();
if (value instanceof Collection) {
// 情况 A: 本身就是集合/JSON数组
resultList.addAll(json.getJSONArray(codeName).toJavaList(String.class));
} else if (value instanceof String) {
// 情况 B: 是逗号分隔的字符串 "ID1,ID2,ID3"
String str = (String) value;
if (StringUtils.isNotEmpty(str)) {
// 使用 split 拆分,并过滤掉空格和空字符串
String[] split = str.split(",");
for (String s : split) {
if (StringUtils.isNotEmpty(s.trim())) {
resultList.add(s.trim());
}
}
}
}
return resultList.size();
}
/**
* 优雅地从 JSON 对象中提取 List
*/
private List<String> getListFromJsonByCodeName(JSONObject json, String key) {
if (json == null || !json.containsKey(key)) {
return Collections.emptyList();
}
Object value = json.get(key);
if (value == null) {
return Collections.emptyList();
}
// 如果本身就是 JSONArrayCollection 子类)
if (value instanceof Collection) {
return ((JSONArray) value).toJavaList(String.class);
}
// 如果是逗号分隔的字符串
if (value instanceof String && StringUtils.isNotBlank((String) value)) {
return Arrays.stream(((String) value).split(","))
.map(String::trim)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toList());
}
return Collections.emptyList();
}
/**
* 根据字段名称取json_data查询对应业务表单的数据
* ${flowNodeExpression.getJsondatastring(jsonData,'supDeptleaderid')}
@@ -87,6 +226,18 @@ public class FlowNodeExpression {
return ISysBaseAPI.getUsersListByJsonLocalAPI(jsonData, deptKeyName, roleId);
}
/**
* 根据部门id角色id获取用户列表
* ${flowNodeExpression.getUsersListByDeptIdAndRoleId(deptId,roleId)}
*
* @param deptId
* @param roleId
* @return roleId
*/
public List<String> getUsersListByDeptIdAndRoleId(String deptId, String roleId) {
return sysbase.getUsersListByDeptIdAndRoleIdLocalApi(deptId, roleId);
}
/**
* 查找上一级部门负责人
* ${flowNodeExpression.getLevel1DepartLeaders(applyUserId)}
@@ -0,0 +1,17 @@
package org.jeecg;
//TIP 要<b>运行</b>代码,请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
public static void main(String[] args) {
//TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
// 查看 IntelliJ IDEA 建议如何修正。
System.out.printf("Hello and welcome!");
for (int i = 1; i <= 5; i++) {
//TIP 按 <shortcut actionId="Debug"/> 开始调试代码。我们已经设置了一个 <icon src="AllIcons.Debugger.Db_set_breakpoint"/> 断点
// 但您始终可以通过按 <shortcut actionId="ToggleLineBreakpoint"/> 添加更多断点。
System.out.println("i = " + i);
}
}
}
@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatter;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -0,0 +1,168 @@
package org.jeecg.modules.bg.xispeak.controller.feedback;
import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
import org.jeecg.modules.bg.xispeak.service.IBgXiSpeakFeedbackService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Tag(name="习总书记重要讲话反馈表")
@RestController
@RequestMapping("/bg/xispeak/bgXiSpeak")
@Slf4j
public class BgXiSpeakFeedbackController extends JeecgController<BgXiSpeakFeedback, IBgXiSpeakFeedbackService> {
@Autowired
private IBgXiSpeakFeedbackService bgXiSpeakFeedbackService;
/**
* 分页列表查询
*
* @param bgXiSpeakFeedback
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@Operation(summary="习总书记重要讲话反馈表-分页列表查询")
@GetMapping(value = "/listBgXiSpeakFeedbackByMainId")
public Result<IPage<BgXiSpeakFeedback>> queryPageList(BgXiSpeakFeedback bgXiSpeakFeedback,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<BgXiSpeakFeedback> queryWrapper = QueryGenerator.initQueryWrapper(bgXiSpeakFeedback, req.getParameterMap());
Page<BgXiSpeakFeedback> page = new Page<BgXiSpeakFeedback>(pageNo, pageSize);
IPage<BgXiSpeakFeedback> pageList = bgXiSpeakFeedbackService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param bgXiSpeakFeedback
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-添加")
@Operation(summary="习总书记重要讲话反馈表-添加")
@PostMapping(value = "/addBgXiSpeakFeedback")
public Result<String> add(@RequestBody BgXiSpeakFeedback bgXiSpeakFeedback) {
bgXiSpeakFeedbackService.save(bgXiSpeakFeedback);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param bgXiSpeakFeedback
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-编辑")
@Operation(summary="习总书记重要讲话反馈表-编辑")
@PostMapping(value = "/editBgXiSpeakFeedback")
public Result<String> edit(@RequestBody BgXiSpeakFeedback bgXiSpeakFeedback) {
bgXiSpeakFeedbackService.updateById(bgXiSpeakFeedback);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-通过id删除")
@Operation(summary="习总书记重要讲话反馈表-通过id删除")
@DeleteMapping(value = "/deleteBgXiSpeakFeedback")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
bgXiSpeakFeedbackService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-批量删除")
@Operation(summary="习总书记重要讲话反馈表-批量删除")
@DeleteMapping(value = "/deleteBatchBgXiSpeakFeedback")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.bgXiSpeakFeedbackService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@Operation(summary="习总书记重要讲话反馈表-通过id查询")
@GetMapping(value = "/queryBgXiSpeakFeedbackById")
public Result<BgXiSpeakFeedback> queryById(@RequestParam(name="id",required=true) String id) {
BgXiSpeakFeedback bgXiSpeakFeedback = bgXiSpeakFeedbackService.getById(id);
if(bgXiSpeakFeedback==null) {
return Result.error("未找到对应数据");
}
return Result.OK(bgXiSpeakFeedback);
}
/**
* 导出excel
*
* @param request
* @param bgXiSpeakFeedback
*/
@RequestMapping(value = "/exportBgXiSpeakFeedback")
public ModelAndView exportXls(HttpServletRequest request, BgXiSpeakFeedback bgXiSpeakFeedback) {
return super.exportXls(request, bgXiSpeakFeedback, BgXiSpeakFeedback.class, "习总书记重要讲话反馈表");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importBgXiSpeakFeedback", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
return super.importExcel(request, response, BgXiSpeakFeedback.class);
}
}
@@ -157,4 +157,12 @@ public class BgXiSpeak implements Serializable {
@Excel(name = "督办次数", width = 15)
@Schema(description = "督办次数")
private java.lang.Integer supervisionCount;
/**dw领导userId字段*/
@Excel(name = "领导userId字段", width = 15)
@Schema(description = "领导userId字段")
private java.lang.String sdwLeaderList;
/**dw领导userId字段*/
@Excel(name = "是否需要sdw审批", width = 15)
@Schema(description = "是否需要sdw审批")
private java.lang.Integer needSdwApproval;
}
@@ -0,0 +1,84 @@
package org.jeecg.modules.bg.xispeak.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Data
@TableName("bg_xi_speak_feedback")
@Schema(description="习总书记重要讲话反馈表")
public class BgXiSpeakFeedback implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private java.lang.String id;
/**创建人*/
@Schema(description = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private java.util.Date createTime;
/**更新人*/
@Schema(description = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private java.util.Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private java.lang.String sysOrgCode;
/**反馈部门id*/
@Excel(name = "反馈部门id", width = 15)
@Schema(description = "反馈部门id")
private java.lang.String responDeptid;
/**反馈部门名称*/
@Excel(name = "反馈部门名称", width = 15)
@Schema(description = "反馈部门名称")
private java.lang.String responDeptname;
/**反馈人id*/
@Excel(name = "反馈人id", width = 15)
@Schema(description = "反馈人id")
private java.lang.String responPersonid;
/**反馈人姓名*/
@Excel(name = "反馈人姓名", width = 15)
@Schema(description = "反馈人姓名")
private java.lang.String responPersonname;
/**反馈时间*/
@Excel(name = "反馈时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "反馈时间")
private java.util.Date responTime;
/**落实情况*/
@Excel(name = "落实情况", width = 15)
@Schema(description = "落实情况")
private java.lang.String implStatus;
/**完成状态*/
@Excel(name = "完成状态", width = 15)
@Schema(description = "完成状态")
private java.lang.String completionStatus;
/**外键*/
@Excel(name = "外键", width = 15)
@Schema(description = "外键")
private java.lang.String mainId;
}
@@ -0,0 +1,16 @@
package org.jeecg.modules.bg.xispeak.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Mapper
public interface BgXiSpeakFeedbackMapper extends BaseMapper<BgXiSpeakFeedback> {
}
@@ -0,0 +1,14 @@
package org.jeecg.modules.bg.xispeak.service;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
public interface IBgXiSpeakFeedbackService extends IService<BgXiSpeakFeedback> {
}
@@ -0,0 +1,19 @@
package org.jeecg.modules.bg.xispeak.service.impl;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
import org.jeecg.modules.bg.xispeak.mapper.BgXiSpeakFeedbackMapper;
import org.jeecg.modules.bg.xispeak.service.IBgXiSpeakFeedbackService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Service
public class BgXiSpeakFeedbackServiceImpl extends ServiceImpl<BgXiSpeakFeedbackMapper, BgXiSpeakFeedback> implements IBgXiSpeakFeedbackService {
}
@@ -7,7 +7,6 @@ import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatterFeedback;
import org.jeecg.modules.demo.bgpartymatter.mapper.BgPartymatterFeedbackMapper;
import org.jeecg.modules.demo.bgpartymatter.mapper.BgPartymatterMapper;
import org.jeecg.modules.demo.bgpartymatter.service.IBgPartymatterService;
import org.jeecg.modules.test.mapper.TestSonTableMapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -1,270 +0,0 @@
package org.jeecg.modules.test.controller;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.vo.LoginUser;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.entity.TestMainTable;
import org.jeecg.modules.test.vo.TestMainTablePage;
import org.jeecg.modules.test.service.ITestMainTableService;
import org.jeecg.modules.test.service.ITestSonTableService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Tag(name="test")
@RestController
@RequestMapping("/test/testMainTable")
@Slf4j
public class TestMainTableController {
@Autowired
private ITestMainTableService testMainTableService;
@Autowired
private ITestSonTableService testSonTableService;
/**
* 分页列表查询
*
* @param testMainTable
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "test-分页列表查询")
@Operation(summary="test-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<TestMainTable>> queryPageList(TestMainTable testMainTable,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<TestMainTable> queryWrapper = QueryGenerator.initQueryWrapper(testMainTable, req.getParameterMap());
Page<TestMainTable> page = new Page<TestMainTable>(pageNo, pageSize);
IPage<TestMainTable> pageList = testMainTableService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param testMainTablePage
* @return
*/
@AutoLog(value = "test-添加")
@Operation(summary="test-添加")
@RequiresPermissions("test:test_main_table:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody TestMainTablePage testMainTablePage) {
TestMainTable testMainTable = new TestMainTable();
BeanUtils.copyProperties(testMainTablePage, testMainTable);
testMainTableService.saveMain(testMainTable, testMainTablePage.getTestSonTableList());
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param testMainTablePage
* @return
*/
@AutoLog(value = "test-编辑")
@Operation(summary="test-编辑")
@RequiresPermissions("test:test_main_table:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody TestMainTablePage testMainTablePage) {
TestMainTable testMainTable = new TestMainTable();
BeanUtils.copyProperties(testMainTablePage, testMainTable);
TestMainTable testMainTableEntity = testMainTableService.getById(testMainTable.getId());
if(testMainTableEntity==null) {
return Result.error("未找到对应数据");
}
testMainTableService.updateMain(testMainTable, testMainTablePage.getTestSonTableList());
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "test-通过id删除")
@Operation(summary="test-通过id删除")
@RequiresPermissions("test:test_main_table:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
testMainTableService.delMain(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "test-批量删除")
@Operation(summary="test-批量删除")
@RequiresPermissions("test:test_main_table:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.testMainTableService.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "test-通过id查询")
@Operation(summary="test-通过id查询")
@GetMapping(value = "/queryById")
public Result<TestMainTable> queryById(@RequestParam(name="id",required=true) String id) {
TestMainTable testMainTable = testMainTableService.getById(id);
if(testMainTable==null) {
return Result.error("未找到对应数据");
}
return Result.OK(testMainTable);
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "test通过主表ID查询")
@Operation(summary="test主表ID查询")
@GetMapping(value = "/queryTestSonTableByMainId")
public Result<List<TestSonTable>> queryTestSonTableListByMainId(@RequestParam(name="id",required=true) String id) {
List<TestSonTable> testSonTableList = testSonTableService.selectByMainId(id);
return Result.OK(testSonTableList);
}
/**
* 导出excel
*
* @param request
* @param testMainTable
*/
@RequiresPermissions("test:test_main_table:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, TestMainTable testMainTable) {
// Step.1 组装查询条件查询数据
QueryWrapper<TestMainTable> queryWrapper = QueryGenerator.initQueryWrapper(testMainTable, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//配置选中数据查询条件
String selections = request.getParameter("selections");
if(oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
queryWrapper.in("id",selectionList);
}
//Step.2 获取导出数据
List<TestMainTable> testMainTableList = testMainTableService.list(queryWrapper);
// Step.3 组装pageList
List<TestMainTablePage> pageList = new ArrayList<TestMainTablePage>();
for (TestMainTable main : testMainTableList) {
TestMainTablePage vo = new TestMainTablePage();
BeanUtils.copyProperties(main, vo);
List<TestSonTable> testSonTableList = testSonTableService.selectByMainId(main.getId());
vo.setTestSonTableList(testSonTableList);
pageList.add(vo);
}
// Step.4 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "test列表");
mv.addObject(NormalExcelConstants.CLASS, TestMainTablePage.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("test数据", "导出人:"+sysUser.getRealname(), "test"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("test:test_main_table:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<TestMainTablePage> list = ExcelImportUtil.importExcel(file.getInputStream(), TestMainTablePage.class, params);
for (TestMainTablePage page : list) {
TestMainTable po = new TestMainTable();
BeanUtils.copyProperties(page, po);
testMainTableService.saveMain(po, page.getTestSonTableList());
}
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.OK("文件导入失败!");
}
}
@@ -1,65 +0,0 @@
package org.jeecg.modules.test.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Schema(description="test")
@Data
@TableName("test_main_table")
public class TestMainTable implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**创建人*/
@Schema(description = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人*/
@Schema(description = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private String sysOrgCode;
/**a字段*/
@Excel(name = "a字段", width = 15)
@Schema(description = "a字段")
private String fieldA;
/**b字段*/
@Excel(name = "b字段", width = 15)
@Schema(description = "b字段")
private String fieldB;
@TableLogic(value = "0", delval = "1")
private int delFlag = 0;
}
@@ -1,62 +0,0 @@
package org.jeecg.modules.test.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.util.Date;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.UnsupportedEncodingException;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Schema(description="test")
@Data
@TableName("test_son_table")
public class TestSonTable implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**创建人*/
@Schema(description = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人*/
@Schema(description = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private String sysOrgCode;
/**字段c*/
@Excel(name = "字段c", width = 15)
@Schema(description = "字段c")
private String fieldC;
/**主表id*/
@Schema(description = "主表id")
private String mainTableId;
@TableLogic(value = "0", delval = "1")
private int delFlag = 0;
}
@@ -1,17 +0,0 @@
package org.jeecg.modules.test.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.test.entity.TestMainTable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface TestMainTableMapper extends BaseMapper<TestMainTable> {
}
@@ -1,31 +0,0 @@
package org.jeecg.modules.test.mapper;
import java.util.List;
import org.jeecg.modules.test.entity.TestSonTable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface TestSonTableMapper extends BaseMapper<TestSonTable> {
/**
* 通过主表id删除子表数据
*
* @param mainId 主表id
* @return boolean
*/
public boolean deleteByMainId(@Param("mainId") String mainId);
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<TestSonTable>
*/
public List<TestSonTable> selectByMainId(@Param("mainId") String mainId);
}
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.test.mapper.TestMainTableMapper">
</mapper>
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.test.mapper.TestSonTableMapper">
<delete id="deleteByMainId" parameterType="java.lang.String">
DELETE
FROM test_son_table
WHERE
main_table_id = #{mainId} </delete>
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.test.entity.TestSonTable">
SELECT *
FROM test_son_table
WHERE
main_table_id = #{mainId} </select>
</mapper>
@@ -1,48 +0,0 @@
package org.jeecg.modules.test.service;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.entity.TestMainTable;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface ITestMainTableService extends IService<TestMainTable> {
/**
* 添加一对多
*
* @param testMainTable
* @param testSonTableList
*/
public void saveMain(TestMainTable testMainTable,List<TestSonTable> testSonTableList) ;
/**
* 修改一对多
*
* @param testMainTable
* @param testSonTableList
*/
public void updateMain(TestMainTable testMainTable,List<TestSonTable> testSonTableList);
/**
* 删除一对多
*
* @param id
*/
public void delMain (String id);
/**
* 批量删除一对多
*
* @param idList
*/
public void delBatchMain (Collection<? extends Serializable> idList);
}
@@ -1,22 +0,0 @@
package org.jeecg.modules.test.service;
import org.jeecg.modules.test.entity.TestSonTable;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface ITestSonTableService extends IService<TestSonTable> {
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<TestSonTable>
*/
public List<TestSonTable> selectByMainId(String mainId);
}
@@ -1,83 +0,0 @@
package org.jeecg.modules.test.service.impl;
import org.jeecg.common.aspect.annotation.CascadeDelete;
import org.jeecg.common.aspect.annotation.SonTable;
import org.jeecg.modules.test.entity.TestMainTable;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.mapper.TestSonTableMapper;
import org.jeecg.modules.test.mapper.TestMainTableMapper;
import org.jeecg.modules.test.service.ITestMainTableService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;
import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Service
public class TestMainTableServiceImpl extends ServiceImpl<TestMainTableMapper, TestMainTable> implements ITestMainTableService {
@Autowired
private TestMainTableMapper testMainTableMapper;
@Autowired
private TestSonTableMapper testSonTableMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMain(TestMainTable testMainTable, List<TestSonTable> testSonTableList) {
testMainTableMapper.insert(testMainTable);
if(testSonTableList!=null && testSonTableList.size()>0) {
for(TestSonTable entity:testSonTableList) {
//外键设置
entity.setMainTableId(testMainTable.getId());
testSonTableMapper.insert(entity);
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMain(TestMainTable testMainTable,List<TestSonTable> testSonTableList) {
testMainTableMapper.updateById(testMainTable);
//1.先删除子表数据
testSonTableMapper.deleteByMainId(testMainTable.getId());
//2.子表数据重新插入
if(testSonTableList!=null && testSonTableList.size()>0) {
for(TestSonTable entity:testSonTableList) {
//外键设置
entity.setMainTableId(testMainTable.getId());
testSonTableMapper.insert(entity);
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@CascadeDelete(sons = {
// 配置子表1:Mapper类 + 子表中关联主表的字段名
@SonTable(mapper = TestSonTableMapper.class, joinColumn = "main_table_id"),
})
public void delMain(String id) {
testMainTableMapper.deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delBatchMain(Collection<? extends Serializable> idList) {
for(Serializable id:idList) {
testSonTableMapper.deleteByMainId(id.toString());
testMainTableMapper.deleteById(id);
}
}
}
@@ -1,27 +0,0 @@
package org.jeecg.modules.test.service.impl;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.mapper.TestSonTableMapper;
import org.jeecg.modules.test.service.ITestSonTableService;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Service
public class TestSonTableServiceImpl extends ServiceImpl<TestSonTableMapper, TestSonTable> implements ITestSonTableService {
@Autowired
private TestSonTableMapper testSonTableMapper;
@Override
public List<TestSonTable> selectByMainId(String mainId) {
return testSonTableMapper.selectByMainId(mainId);
}
}
@@ -1,64 +0,0 @@
package org.jeecg.modules.test.vo;
import java.util.List;
import org.jeecg.modules.test.entity.TestMainTable;
import org.jeecg.modules.test.entity.TestSonTable;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelEntity;
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Data
@Schema(description="test")
public class TestMainTablePage {
/**主键*/
@Schema(description = "主键")
private String id;
/**创建人*/
@Schema(description = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人*/
@Schema(description = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private String sysOrgCode;
/**a字段*/
@Excel(name = "a字段", width = 15)
@Schema(description = "a字段")
private String fieldA;
/**b字段*/
@Excel(name = "b字段", width = 15)
@Schema(description = "b字段")
private String fieldB;
@ExcelCollection(name="test")
@Schema(description = "test")
private List<TestSonTable> testSonTableList;
}
@@ -564,4 +564,6 @@ public interface ISysBaseAPI extends CommonAPI {
String updateBusinessId(String businessId, List<String> deliverablesList);
List<String> getUsersListByJsonLocalAPI(Object jsonData, String deptKeyName, String roleId);
List<String> getUsersListByDeptIdAndRoleIdLocalApi(String deptId, String roleId);
}
@@ -545,10 +545,10 @@ public class SysUserController {
*/
@RequestMapping(value = "/queryUserByDeptAndROle", method = RequestMethod.GET)
@Operation(summary = "根据角色ID,部门ID以及用户密级查询当前用户列表", description = "原生用户查询逻辑加上密级筛选以及角色筛选") // 2. 接口描述
public Result<List<SysUser>> queryUserByDeptAndROle(DeptRoleVO deptRoleVO
public Result<List<String>> queryUserByDeptAndROle(DeptRoleVO deptRoleVO
) {
try {
List<SysUser> sysUserList = sysUserService.queryUserByDeptAndROle(
List<String> sysUserList = sysUserService.queryUserByDeptAndROle(
deptRoleVO.getDeptId(),
deptRoleVO.getRoleId(),
deptRoleVO.getSecretLevel()
@@ -495,5 +495,5 @@ public interface ISysUserService extends IService<SysUser> {
*/
void updatePasswordNotBindPhone(String oldPassword, String password, String username);
List<SysUser> queryUserByDeptAndROle(@NotBlank(message = "deptId不为空") String deptId, @NotBlank(message = "角色id不为空") String roleId, @NotBlank(message = "secretLevel不为空") Integer secretLevel);
List<String> queryUserByDeptAndROle(@NotBlank(message = "deptId不为空") String deptId, @NotBlank(message = "角色id不为空") String roleId, @NotBlank(message = "secretLevel不为空") Integer secretLevel);
}
@@ -2100,6 +2100,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return "";
}
@Override
public List<String> getUsersListByJsonLocalAPI(Object jsonData, String deptKeyName, String roleId) {
if (jsonData == null || StringUtils.isEmpty(deptKeyName) || StringUtils.isEmpty(roleId)) {
return Collections.emptyList();
@@ -2126,7 +2127,21 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return Collections.emptyList();
}
List<SysUser> sysUserList = sysUserService.queryUserByDeptAndROle(
List<String> sysUserList = sysUserService.queryUserByDeptAndROle(
deptId,
roleId,
UserSecretLevel.SECRET_LEVEL_NONE
);
return Optional.ofNullable(sysUserList)
.orElse(Collections.emptyList())
.stream()
.collect(Collectors.toList());
}
@Override
public List<String> getUsersListByDeptIdAndRoleIdLocalApi(String deptId, String roleId){
List<String> sysUserList = sysUserService.queryUserByDeptAndROle(
deptId,
roleId,
UserSecretLevel.SECRET_LEVEL_NONE
@@ -2135,7 +2150,6 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return Optional.ofNullable(sysUserList)
.orElse(Collections.emptyList())
.stream()
.map(SysUser::getUsername)
.collect(Collectors.toList());
}
}
@@ -2416,7 +2416,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
@Override
public List<SysUser> queryUserByDeptAndROle(@NotBlank(message = "deptId不为空") String deptId, @NotBlank(message = "角色id不为空") String roleId, @NotBlank(message = "secretLevel不为空") Integer secretLevel){
return sysUserMapper.queryUserByDeptAndROle(deptId,roleId,secretLevel);
public List<String> queryUserByDeptAndROle(@NotBlank(message = "deptId不为空") String deptId, @NotBlank(message = "角色id不为空") String roleId, @NotBlank(message = "secretLevel不为空") Integer secretLevel){
return sysUserMapper.queryUserByDeptAndROle(deptId,roleId,secretLevel).stream().map(SysUser::getUsername).collect(Collectors.toList()) ;
}
}
@@ -27,6 +27,10 @@
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-supervision</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-flow</artifactId>
</dependency>
<!-- flyway 数据库自动升级 -->
<dependency>
@@ -40,6 +40,9 @@ public class JeecgSystemApplication extends SpringBootServletInitializer {
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
// 检查是否有 xiSpeakFlow 这个 Bean
boolean exists = application.containsBean("xiSpeakFlow");
System.out.println("★★★ xiSpeakFlow 是否加载成功: " + exists);
}
}