Преглед на файлове

页面设计后端

master
郑根木 преди 2 години
родител
ревизия
4dcde0330d
променени са 39 файла, в които са добавени 1332 реда и са изтрити 514 реда
  1. +5
    -0
      smtweb-framework/sw-framework-core/pom.xml
  2. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/AbstractCache.java
  3. +4
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java
  4. +5
    -2
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/DbEngine.java
  5. +25
    -4
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java
  6. +6
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/cache/EntityCache.java
  7. +4
    -3
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/config/DbEngineConfiguration.java
  8. +42
    -33
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/jdbc/JdbcEngine.java
  9. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractCompService.java
  10. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractDelHandler.java
  11. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractHandler.java
  12. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultDelHandler.java
  13. +30
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/SqlNamedPara.java
  14. +1
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/util/CommUtil.java
  15. +30
    -0
      smtweb-framework/sw-framework-core/src/test/java/cc/smtweb/framework/test/NamedJdbcTest.java
  16. +10
    -2
      smtweb-framework/sw-framework-core/src/test/java/cc/smtweb/framework/test/TestMain.java
  17. +0
    -60
      smtweb-framework/sw-framework-core/target/classes/config/app-config.yaml
  18. +0
    -111
      smtweb-framework/sw-framework-core/target/classes/config/demo.json
  19. +0
    -14
      smtweb-framework/sw-framework-core/target/classes/config/design_db.yaml
  20. +170
    -165
      smtweb-system/sw-system-bpm/pom.xml
  21. +120
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelForm.java
  22. +178
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  23. +87
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataSet.java
  24. +22
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetDynCond.java
  25. +9
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetEnumData.java
  26. +37
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java
  27. +20
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetFilter.java
  28. +9
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetSortField.java
  29. +22
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageInfo.java
  30. +0
    -81
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/modelcatalog/AspModelCatalogCardService.java
  31. +0
    -24
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/modelcatalog/AspModelCatalogListService.java
  32. +34
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/AbstractDynPageHandler.java
  33. +72
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageAddHandler.java
  34. +185
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageHelper.java
  35. +73
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageLoadHandler.java
  36. +42
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageService.java
  37. +35
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynRetBean.java
  38. +13
    -10
      smtweb-system/sw-system-bpm/src/test/java/cc/smtweb/system/bpm/test/BuildJavaBean.java
  39. +37
    -0
      smtweb-system/sw-system-bpm/src/test/java/cc/smtweb/system/bpm/test/ModelFormTest.java

+ 5
- 0
smtweb-framework/sw-framework-core/pom.xml Целия файл

@@ -148,6 +148,11 @@
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>


+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/AbstractCache.java Целия файл

@@ -42,7 +42,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache<

//数据加载状态
private short loadStatu = LS_NONE;
private Class<T> pTypeClass = null;
protected Class<T> pTypeClass = null;


private LoadingCache<String, T> cache;


+ 4
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java Целия файл

@@ -12,4 +12,8 @@ public interface SwConsts {
String SPLIT_CHAR = "-";
//默认根节点
String DEF_ROOT_ID = "-1";

//列表分页的页码和每页记录数
String PARAM_PAGE = "page";
String PARAM_ROWS = "rows";
}

+ 5
- 2
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/DbEngine.java Целия файл

@@ -9,6 +9,7 @@ import cc.smtweb.framework.core.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import java.sql.ResultSet;
import java.sql.SQLException;
@@ -31,8 +32,8 @@ public class DbEngine extends JdbcEngine {
return SpringUtil.getBean(DbEngine.class);
}

public DbEngine(JdbcTemplate jdbcTemplate, IdGenerator idGenerator, String type) {
super(jdbcTemplate, idGenerator, type);
public DbEngine(NamedParameterJdbcTemplate namedJdbcTemplate, IdGenerator idGenerator, String type) {
super(namedJdbcTemplate, idGenerator, type);
}

/**
@@ -274,4 +275,6 @@ public class DbEngine extends JdbcEngine {
}
return findDao((Class<T>) entities.get(0).getClass()).batchInsertEntity(entities, fields);
}


}

+ 25
- 4
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java Целия файл

@@ -4,6 +4,7 @@ import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.db.dao.AbstractEntityDao;
import cc.smtweb.framework.core.db.dao.EntityColumn;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.JdbcEngine;
import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.util.CommUtil;
@@ -224,6 +225,20 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
return jdbcEngine.update(sb.toString(), params);
}

private void setTableName(T bean) {
if (bean instanceof DefaultEntity) {
((DefaultEntity) bean).setTableName(this.tableName);
}
}

private void setTableName(List<T> list) {
if (!list.isEmpty() && list.get(0) instanceof DefaultEntity) {
for (T bean: list) {
((DefaultEntity) bean).setTableName(this.tableName);
}
}
}

/**
* 查询单行数据,返回bean
*/
@@ -238,7 +253,9 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
List<T> list = jdbcEngine.query(sb.toString(), type, id);

if (list != null && !list.isEmpty()) {
return list.get(0);
T bean = list.get(0);
setTableName(bean);
return bean;
}

return null;
@@ -279,7 +296,9 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
StringBuilder sb = new StringBuilder();
handleSelect(sb, fields);

return jdbcEngine.query(sb.toString(), type);
List<T> list = jdbcEngine.query(sb.toString(), type);
setTableName(list);
return list;
}

/**
@@ -292,7 +311,9 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
sb.append(" where ").append(sqlWhere);
}

return jdbcEngine.query(sb.toString(), type, params);
List<T> list = jdbcEngine.query(sb.toString(), type, params);
setTableName(list);
return list;
}


@@ -301,7 +322,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
String ss = "", sTitle = "";
List<Object> args = new ArrayList<>(fields.length + 1);
args.add(readId(bean));
for (String f: fields) {
for (String f : fields) {
if (StringUtils.isEmpty(f)) continue;
ss += " and " + f + "=?";
args.add(readValue(bean, f));


+ 6
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/cache/EntityCache.java Целия файл

@@ -8,6 +8,7 @@ import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.vo.ModelCache;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.controller.scan.BeanManager;
import cc.smtweb.framework.core.util.CommUtil;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.Scheduler;
@@ -26,6 +27,11 @@ public class EntityCache extends AbstractCache<DefaultEntity> {

public EntityCache(String tableName) {
this.tableName = tableName;
Class<DefaultEntity> clazz = (Class<DefaultEntity>)BeanManager.getInstance().getTableClass(tableName);
if (clazz != null) {
this.pTypeClass = clazz;
}

ModelTable table = ModelTableCache.getInstance().getByName(tableName);

ident = tableName;


+ 4
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/config/DbEngineConfiguration.java Целия файл

@@ -7,6 +7,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

/**
* 默认数据源
@@ -28,14 +29,14 @@ public class DbEngineConfiguration {

/**
* 产生数据库数据库访问对象 dbEngine
* @param jdbcTemplate Spring框架Jdbc,通过 spring.datasource 配置
* @param namedJdbcTemplate Spring框架Jdbc,通过 spring.datasource 配置
* @param idGenerator ID生成器对象,思想数据库ID生成
* @return dbEngine对象
*/
@Bean
@ConfigurationProperties(prefix = "smtweb.db.default")
public DbEngine dbEngine(JdbcTemplate jdbcTemplate, IdGenerator idGenerator) {
public DbEngine dbEngine(NamedParameterJdbcTemplate namedJdbcTemplate, IdGenerator idGenerator) {
System.out.println("create dbEngine=============");
return new DbEngine(jdbcTemplate, idGenerator, dbType);
return new DbEngine(namedJdbcTemplate, idGenerator, dbType);
}
}

+ 42
- 33
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/jdbc/JdbcEngine.java Целия файл

@@ -12,6 +12,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
@@ -33,13 +34,15 @@ public class JdbcEngine {

private Map<Thread, JdbcTrans> mapThreadTrans = new ConcurrentHashMap<>();
private JdbcTemplate jdbcTemplate;
private NamedParameterJdbcTemplate namedJdbcTemplate;
private DataSourceTransactionManager dataSourceTransactionManager;
private IdGenerator idGenerator;

protected String type;

public JdbcEngine(JdbcTemplate jdbcTemplate, IdGenerator idGenerator, String type) {
this.jdbcTemplate = jdbcTemplate;
public JdbcEngine(NamedParameterJdbcTemplate namedJdbcTemplate, IdGenerator idGenerator, String type) {
this.namedJdbcTemplate = namedJdbcTemplate;
this.jdbcTemplate = namedJdbcTemplate.getJdbcTemplate();
this.dataSourceTransactionManager = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
this.idGenerator = idGenerator;
this.type = type;
@@ -105,13 +108,6 @@ public class JdbcEngine {
}

/**
* 翻页查询
*/
public <T> List<T> pagedQuery(String sql, RowMapper<T> rowMapper, int start, int limit, Object... params) {
return jdbcTemplate.query(sql + " LIMIT " + start + "," + limit, rowMapper, params);
}

/**
* 执行更新SQL
*/
public int update(String sql) {
@@ -126,27 +122,6 @@ public class JdbcEngine {
}

/**
* 执行更新语句直到无更新数据或者达到最大修改记录数
*
* @param sql 需要执行的SQL语句
* @param limit 每次更新的条数
* @param count 最大更新次数
* @param params 执行参数
* @return 返回更新的数据数量
*/
public int pagedUpdate(String sql, int limit, int count, Object... params) {
int result = 0;
for (int i = 0, ret = 1; i < count && ret > 0; i++) {
ret = jdbcTemplate.update(sql + " LIMIT " + limit, params);
if (ret > 0) {
result += ret;
}
}

return result;
}

/**
* 查询字符list
*
* @param sql 查询SQL
@@ -452,13 +427,40 @@ public class JdbcEngine {
return jdbcTemplate.query(sql, createRowMapper(type), params);
}


/*================以下为具名参数方法================================================*/
public <T> T queryEntityN(String sql, Map<String, ?> params, Class<T> type) {
List<T> list = queryN(sql, params, type);

if (list != null && !list.isEmpty()) {
return list.get(0);
}

return null;
}

public <T> List<T> queryN(String sql, Map<String, ?> params, Class<T> type) {
return namedJdbcTemplate.query(sql, params, createRowMapper(type));
}

/**
* 翻页查询
* 执行更新SQL
*/
public <T> List<T> pagedQuery(String sql, Class<T> type, int start, int limit) {
return jdbcTemplate.query(sql + " LIMIT " + start + "," + limit, createRowMapper(type));
public int updateN(String sql, Map<String, ?> params) {
return namedJdbcTemplate.update(sql, params);
}

public int[] batchUpdateN(String sql, List<Map<String, Object>> params) {
return namedJdbcTemplate.batchUpdate(sql, (Map<String, Object>[])params.toArray());
}

/**
* 翻页查询
*/
public <T> List<T> pagedQueryN(String sql, Class<T> type, int start, int limit, Map<String, ?> params) {
return queryN(sql + " LIMIT " + start + "," + limit, params, type);
}
/*=================以上为具名参数方法==================================================*/
public boolean isExists(String sql, Object... params) {
return jdbcTemplate.queryForObject(sql + " LIMIT 0, 1", int.class, params) > 0;
}
@@ -485,4 +487,11 @@ public class JdbcEngine {
public <T> List<T> pagedQuery(String sql, Class<T> type, int start, int limit, Object... params) {
return jdbcTemplate.query(sql + " LIMIT " + start + "," + limit, createRowMapper(type), params);
}

/**
* 翻页查询
*/
public <T> List<T> pagedQuery(String sql, RowMapper<T> rowMapper, int start, int limit, Object... params) {
return jdbcTemplate.query(sql + " LIMIT " + start + "," + limit, rowMapper, params);
}
}

+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractCompService.java Целия файл

@@ -29,7 +29,7 @@ public abstract class AbstractCompService {
return handler;
}

private R pageHandler(SwMap params, UserSession us, String type) {
protected R pageHandler(SwMap params, UserSession us, String type) {
try {
IHandler handler = getHandler(params, us, type);
return handler.doWork();


+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractDelHandler.java Целия файл

@@ -11,7 +11,7 @@ import lombok.extern.slf4j.Slf4j;
* 保存
*/
@Slf4j
public abstract class AbstractDelHandler<T> extends AbstractHandler<T>{
public abstract class AbstractDelHandler extends AbstractHandler{
protected long id;

@Override


+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractHandler.java Целия файл

@@ -7,7 +7,7 @@ import cc.smtweb.framework.core.session.UserSession;
/**
* Created by Akmm at 2022/3/2 19:44
*/
public abstract class AbstractHandler<T> implements IHandler {
public abstract class AbstractHandler implements IHandler {
protected SwMap params;
protected UserSession us;



+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultDelHandler.java Целия файл

@@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils;
* Created by Akmm at 2022/3/2 19:52
* 默认实体实现
*/
public class DefaultDelHandler<T extends DefaultEntity> extends AbstractDelHandler<T> {
public class DefaultDelHandler<T extends DefaultEntity> extends AbstractDelHandler {
protected String tableName;

public DefaultDelHandler(String tableName) {


+ 30
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/SqlNamedPara.java Целия файл

@@ -0,0 +1,30 @@
package cc.smtweb.framework.core.mvc.service;

import cc.smtweb.framework.core.SwMap;
import org.apache.commons.lang3.ArrayUtils;

import java.util.HashMap;
import java.util.Map;

//一个sql及其参数,具名参数
public class SqlNamedPara {
public String sql = "";
public SwMap paras = new SwMap();
//页码,从1开始;为0,则不需要分页
public int page = 0;
//每页记录数
public int rows = 20;

public SqlNamedPara(String sql) {
this.sql = sql;
}

public SqlNamedPara(String sql, SwMap paras) {
this.sql = sql;
this.paras = paras;
}

public void addParas(String name, Object value) {
paras.put(name, value);
}
}

+ 1
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/util/CommUtil.java Целия файл

@@ -105,4 +105,5 @@ public class CommUtil {
public static int chineseCompare(String s1, String s2) {
return chineseCollator.compare(s1, s2);
}

}

+ 30
- 0
smtweb-framework/sw-framework-core/src/test/java/cc/smtweb/framework/test/NamedJdbcTest.java Целия файл

@@ -0,0 +1,30 @@
package cc.smtweb.framework.test;

import cc.smtweb.framework.core.CoreApplication;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/4/24 14:58
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = CoreApplication.class)
public class NamedJdbcTest {
@Test
public void testSelect() {
List<DefaultEntity> list = DbEngine.getInstance().query("select * from asp_model_project", DefaultEntity.class);
System.out.println(list.size());
Map<String, Object> params = new HashMap<>();
params.put("id", 1);
list = DbEngine.getInstance().queryN("select * from asp_model_project where prj_id=:id", params, DefaultEntity.class);
System.out.println(list.size());
}
}

+ 10
- 2
smtweb-framework/sw-framework-core/src/test/java/cc/smtweb/framework/test/TestMain.java Целия файл

@@ -1,6 +1,12 @@
package cc.smtweb.framework.test;

import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.util.JsonUtil;

import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2021/12/25 22:21
@@ -8,8 +14,10 @@ import cc.smtweb.framework.core.db.vo.ModelTable;
public class TestMain {

public static void main(String[] args) {
ModelTable table = new ModelTable();
List<DefaultEntity> list = DbEngine.getInstance().query("select * from asp_model_project", DefaultEntity.class);
System.out.println(list.size());
/*ModelTable table = new ModelTable();
table.setId(1);
table.setContent("{\"fields\":[{\"name\":\"db_id\",\"fieldType\":\"ID\",\"dataType\":\"ID\",\"null\":\"1\",\"default\":\"-1\",\"title\":\"ID\"},{\"name\":\"db_prj_id\",\"fieldType\":\"\",\"dataType\":\"ID\",\"null\":\"1\",\"default\":\"-1\",\"title\":\"ID\",\"link\":\"asp_model_project\"},{\"name\":\"db_name\",\"fieldType\":\"CODE\",\"dataType\":\"CODE\",\"null\":\"0\",\"default\":\"\",\"title\":\"库名\",\"link\":\"\",\"editor\":\"\"},{\"name\":\"db_title\",\"fieldType\":\"NAME\",\"dataType\":\"NAME\",\"null\":\"0\",\"default\":\"\",\"title\":\"中文名\",\"link\":\"\",\"editor\":\"\"},{\"name\":\"db_status\",\"fieldType\":\"\",\"dataType\":\"BOOL\",\"null\":\"1\",\"default\":\"0\",\"title\":\"启用状态\",\"link\":\"\",\"editor\":\"\"},{\"name\":\"db_version\",\"fieldType\":\"\",\"dataType\":\"INT-4\",\"null\":\"1\",\"default\":\"0\",\"title\":\"版本\",\"link\":\"\",\"editor\":\"\"},{\"name\":\"db_create_uid\",\"fieldType\":\"\",\"dataType\":\"ID\",\"null\":\"1\",\"default\":\"-1\",\"title\":\"创建人\",\"link\":\"\",\"editor\":\"\"},{\"name\":\"db_update_uid\",\"fieldType\":\"\",\"dataType\":\"ID\",\"null\":\"1\",\"default\":\"-1\",\"title\":\"最后更新人\",\"link\":\"\",\"editor\":\"\"},{\"name\":\"db_create_at\",\"fieldType\":\"\",\"dataType\":\"DATETIME\",\"null\":\"1\",\"default\":\"-1\",\"title\":\"创建时间\",\"link\":\"\",\"editor\":\"\"},{\"name\":\"db_update_at\",\"fieldType\":\"\",\"dataType\":\"DATETIME\",\"null\":\"1\",\"default\":\"-1\",\"title\":\"最后更新时间\",\"link\":\"\",\"editor\":\"\"}],\"indexes\":[{\"name\":\"pk\",\"fields\":\"db_id\",\"type\":\"P\"}],\"caches\":[{\"name\":\"n\",\"title\":\"按库名\",\"fields\":\"db_name\",\"type\":\"M\"},{\"name\":\"prj\",\"title\":\"按项目\",\"fields\":\"db_prj_id\",\"type\":\"L\"}]}");
table.setContent(s);*/
}
}

+ 0
- 60
smtweb-framework/sw-framework-core/target/classes/config/app-config.yaml Целия файл

@@ -1,60 +0,0 @@
smtweb:
machine-id: 1
file:
local-path: /data/files/smart/
host: http://127.0.0.1
url: ${smtweb.file.host}:${server.port}${server.servlet.context-path}/${smtweb.file.local-path}
db:
default:
rule:
prefix: _smt_
replace: smt_
server:
port: 8888
servlet:
context-path: /
logging:
level:
root: INFO
cc.smtweb: DEBUG
spring:
# 设置服务名
application:
name: smtweb_core
main:
allow-bean-definition-overriding: true
mvc:
static-path-pattern: /static/**
redis:
host: 127.0.0.1
port: 6379
password:
database: 0
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/sw_user?useUnicode=true&characterEncoding=utf-8&useTimezone=true&serverTimezone=CTT&allowMultiQueries=true&useSSL=false
username: root
password: 1681860
servlet:
multipart:
max-file-size: 104857600000
max-request-size: 10485760000000
profiles:
include: role
cache:
type: caffeine
cache-names:
- core
caffeine:
spec: maximumSize=1024,expireAfterWrite=2h
park:
secret:
key: null
# key: cmVmb3JtZXJyZWZvcm1lcg==
swagger:
name: smtweb-core
version: 2.0
enabled: true




+ 0
- 111
smtweb-framework/sw-framework-core/target/classes/config/demo.json Целия файл

@@ -1,111 +0,0 @@
{
"fields": [
{
"name": "mc_id",
"fieldType": "1",
"dataType": "ID",
"null": "1",
"default": "-1",
"title": "ID"
},
{
"name": "mc_parent_id",
"fieldType": "4",
"dataType": "ID",
"null": "1",
"default": "-1",
"title": "ID",
"link": "2"
},
{
"name": "mc_prj_id",
"fieldType": "",
"dataType": "ID",
"null": "1",
"default": "-1",
"title": "ID",
"link": "1"
},
{
"name": "mc_code",
"fieldType": "2",
"dataType": "CODE",
"null": "0",
"default": "",
"title": "编码",
"link": "",
"editor": ""
},
{
"name": "mc_name",
"fieldType": "3",
"dataType": "NAME",
"null": "0",
"default": "",
"title": "编码",
"link": "",
"editor": ""
},
{
"name": "mc_create_uid",
"fieldType": "7",
"dataType": "ID",
"null": "1",
"default": "-1",
"title": "创建人",
"link": "",
"editor": ""
},
{
"name": "mc_update_uid",
"fieldType": "9",
"dataType": "ID",
"null": "1",
"default": "-1",
"title": "最后更新人",
"link": "",
"editor": ""
},
{
"name": "mc_create_at",
"fieldType": "8",
"dataType": "DATETIME",
"null": "1",
"default": "-1",
"title": "创建时间",
"link": "",
"editor": ""
},
{
"name": "mc_update_at",
"fieldType": "10",
"dataType": "DATETIME",
"null": "1",
"default": "-1",
"title": "最后更新时间",
"link": "",
"editor": ""
}
],
"indexes": [
{
"name": "pk",
"fields": "mc_id",
"type": "P"
}
],
"caches": [
{
"name": "pr",
"title": "按树型",
"fields": "mc_parent_id",
"type": "L"
},
{
"name": "prj",
"title": "按项目",
"fields": "mc_prj_id,mc_parent_id",
"type": "L"
}
]
}

+ 0
- 14
smtweb-framework/sw-framework-core/target/classes/config/design_db.yaml Целия файл

@@ -1,14 +0,0 @@
design:
data-type:
- {type: "id", name: "ID", sql-type: "bigint", java-type: "long", widget: "fz-field-long", defaultValue: "0"}
- {type: "code", name: "编码", sql-type: "varchar", java-type: "string", data-length: 32, widget: "fz-field-string", defaultValue: ""}
- {type: "name", name: "名字", sql-type: "varchar", java-type: "string", data-length: 100, widget: "fz-field-string", defaultValue: ""}
- {type: "remark", name: "备注", sql-type: "varchar", data-length: 255, java-type: "string", widget: "fz-field-string", defaultValue: ""}
- {type: "text", name: "大文本", sql-type: "text", java-type: "string", widget: "fz-field-string", defaultValue: ""}
- {type: "currency", name: "货币", sql-type: "bigint", java-type: "long", widget: "fz-field-long", defaultValue: "0"}
- {type: "datetime", name: "时间日期", sql-type: "bigint", java-type: "long", widget: "fz-field-datetime", defaultValue: "0"}
- {type: "date", name: "日期", sql-type: "int", java-type: "int", widget: "fz-field-date", defaultValue: "0"}
- {type: "time", name: "时间", sql-type: "int", java-type: "int", widget: "fz-field-time", defaultValue: "0"}
- {type: "int", name: "整型", sql-type: "int", java-type: "int", widget: "fz-field-int", defaultValue: "0"}
- {type: "smallint", name: "短整型", sql-type: "smallint", java-type: "short", widget: "fz-field-int", defaultValue: "0"}
- {type: "bool", name: "布尔型", sql-type: "tinyint", java-type: "boolean", widget: "fz-field-bool", defaultValue: "0"}

+ 170
- 165
smtweb-system/sw-system-bpm/pom.xml Целия файл

@@ -2,175 +2,180 @@
<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>
<modelVersion>4.0.0</modelVersion>

<artifactId>sw-system-bpm</artifactId>
<groupId>cc.smtweb</groupId>
<version>2.2.2-SNAPSHOT</version>
<artifactId>sw-system-bpm</artifactId>
<groupId>cc.smtweb</groupId>
<version>2.2.2-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cc.smtweb</groupId>
<artifactId>sw-framework-auth</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cc.smtweb</groupId>
<artifactId>sw-framework-file</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.jodah/typetools -->
<!-- <dependency>-->
<!-- <groupId>net.jodah</groupId>-->
<!-- <artifactId>typetools</artifactId>-->
<!-- <version>0.6.3</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<!-- <dependency>-->
<!-- <groupId>org.assertj</groupId>-->
<!-- <artifactId>assertj-core</artifactId>-->
<!-- <version>3.16.0</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.7.RELEASE</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cc.smtweb</groupId>
<artifactId>sw-framework-auth</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cc.smtweb</groupId>
<artifactId>sw-framework-file</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.jodah/typetools -->
<!-- <dependency>-->
<!-- <groupId>net.jodah</groupId>-->
<!-- <artifactId>typetools</artifactId>-->
<!-- <version>0.6.3</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<!-- <dependency>-->
<!-- <groupId>org.assertj</groupId>-->
<!-- <artifactId>assertj-core</artifactId>-->
<!-- <version>3.16.0</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!--<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.7.RELEASE</version>
<scope>test</scope>
</dependency>-->
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- 打 springboot 完整包 -->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <version>2.1.5.RELEASE</version>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- 用于生成source.jar包的plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 用于生成jar包的plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>config/application.yaml</exclude>
<exclude>config/application-dev.yaml</exclude>
<exclude>config/application-prod.yaml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<build>
<plugins>
<!-- 打 springboot 完整包 -->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <version>2.1.5.RELEASE</version>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- 用于生成source.jar包的plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 用于生成jar包的plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>config/application.yaml</exclude>
<exclude>config/application-dev.yaml</exclude>
<exclude>config/application-prod.yaml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://47.92.149.153:7000/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://47.92.149.153:7000/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://47.92.149.153:7000/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://47.92.149.153:7000/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>

+ 120
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelForm.java Целия файл

@@ -0,0 +1,120 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.annotation.SwTable;
import cc.smtweb.framework.core.db.impl.DefaultEntity;

/**
* Created by Akmm at 2022/4/15 17:26
*/
@SwTable("ASP_MODEL_FORM")
public class ModelForm extends DefaultEntity {
public static final String ENTITY_NAME = "ASP_MODEL_FORM";

public ModelForm() {
super(ENTITY_NAME);
}

public long getId() {
return getLong("mf_id");
}

public void setId(long mfId) {
put("mf_id", mfId);
}

public long getPrjId() {
return getLong("mf_prj_id");
}

public void setPrjId(long mfPrjId) {
put("mf_prj_id", mfPrjId);
}

public long getMcId() {
return getLong("mf_mc_id");
}

public void setMcId(long mfMcId) {
put("mf_mc_id", mfMcId);
}

public String getName() {
return getStr("mf_name");
}

public void setName(String mfName) {
put("mf_name", mfName);
}

public String getTitle() {
return getStr("mf_title");
}

public void setTitle(String mfTitle) {
put("mf_title", mfTitle);
}

public int getType() {
return getInt("mf_type");
}

public void setType(int mfType) {
put("mf_type", mfType);
}

public String getService() {
return getStr("mf_service");
}

public void setService(String mfService) {
put("mf_service", mfService);
}

public String getContent() {
return getStr("mf_content");
}

public void setContent(String mfContent) {
put("mf_content", mfContent);
}

public long getCreateUid() {
return getLong("mf_create_uid");
}

public void setCreateUid(long mfCreateUid) {
put("mf_create_uid", mfCreateUid);
}

public long getUpdateUid() {
return getLong("mf_update_uid");
}

public void setUpdateUid(long mfUpdateUid) {
put("mf_update_uid", mfUpdateUid);
}

public long getCreateAt() {
return getLong("mf_create_at");
}

public void setCreateAt(long mfCreateAt) {
put("mf_create_at", mfCreateAt);
}

public long getUpdateAt() {
return getLong("mf_update_at");
}

public void setUpdateAt(long mfUpdateAt) {
put("mf_update_at", mfUpdateAt);
}

public String getRemark() {
return getStr("mf_remark");
}

public void setRemark(String mfRemark) {
put("mf_remark", mfRemark);
}
}

+ 178
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java Целия файл

@@ -0,0 +1,178 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.MapUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetDynCond;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetField;
import cc.smtweb.system.bpm.web.design.form.define.PageInfo;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.PropertyWriter;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/4/20 18:45
* 辅助类
*/
public class ModelFormHelper {
/**
* 从缓存获取Form对象
* @param formId
* @return
*/
public static ModelForm getFromCache(long formId) {
AbstractCache<ModelForm> cache = CacheManager.getIntance().getCache(ModelForm.ENTITY_NAME);
if (cache == null) return null;
return cache.get(formId);
}

/**
* 根据json字符串解析对象
* @param jsonStr
* @return
*/
public static PageInfo parsePageInfo(String jsonStr) {
if (StringUtils.isEmpty(jsonStr)) return null;
return JsonUtil.parse(jsonStr, PageInfo.class);
}

public static PageInfo parsePageInfo(long formId) {
ModelForm form = getFromCache(formId);
if (form == null) return null;
return parsePageInfo(form.getContent());
}

/**
* 页面传回的content,加工处理成待保存的json串
* 主要处理内容:
* 1、model的一些maxlen、默认值等信息,如果和数据库一致,则去掉
* 2、db中的只保留表、字段和别名
* @param jsonStr
* @return
*/
public static String buildSaveJson(String jsonStr) throws Exception {
PageInfo pageInfo = parsePageInfo(jsonStr);
resetDataset(pageInfo);
for (Map<String, Object> model: pageInfo.model) {
Map<String, Object> props = (Map<String, Object>)model.get("props");
buildSaveModelFields(pageInfo, props, true);
buildSaveModelFields(pageInfo, props, false);
}
return encodeSaveJson(pageInfo);
}

//处理model的fields和filters
private static void buildSaveModelFields(PageInfo pageInfo, Map<String, Object> props, boolean isField) {
String db = (String)props.get("db");
//没有配置db,配置有误,不处理
if (StringUtils.isEmpty(db)) throw new SwException("model未配置数据集db,无法解析!");
PageDataSet pds = pageInfo.findDataSet(db);
String key = isField ? "fields":"filters";
List<Map<String, Object>> fields = (List<Map<String, Object>>)props.get(key);
if (fields == null || fields.isEmpty()) return;
for (Map<String, Object> fi: fields) {
Map<String, Object> field = (Map<String, Object>)fi.get("props");
if (field == null) throw new SwException("model[" + db + "]." + key + "未配置props,无法解析!");

String fn = (String)field.get("field");
if (StringUtils.isEmpty(fn)) throw new SwException("model[" + db + "]." + key + "未配置字段名field,无法解析!");
PageDatasetField pdf = isField ? pds.getField(fn) : pds.getFilter(fn);
if (pdf == null) throw new SwException("model[" + db + "]." + key + "未找到定义的数据集字段(" + fn + "),无法解析!");

//必填字段
if (pdf.isNotNull() == MapUtil.readBool(field, "required")) {
field.remove("required");
}

if (MapUtil.readInt(field,"maxlength") == SwEnum.DataType.instance.getByValue(pdf.dataType).dataLength) {
field.remove("maxlength");
}
}
}

//将db中field按表定义重置一下
public static void resetDataset(PageInfo pageInfo) {
for (PageDataSet ds: pageInfo.db) {
ds.resetFields();
}
}

//构建成需要保存的字符串
private static String encodeSaveJson(PageInfo pageInfo) throws JsonProcessingException {
//todo
ObjectMapper mapper = new ObjectMapper();
FilterProvider filters = new SimpleFilterProvider().addFilter("datasetField", new SimpleBeanPropertyFilter(){
private final String includes = "name,label,field,table";
@Override
protected boolean include(PropertyWriter writer) {
return includes.contains(writer.getName());
}
}).addFilter("datasetFilter", new SimpleBeanPropertyFilter(){
private final String includes = ",name,label,field,table,dataType,type,linkDb,linkField,value";
@Override
protected boolean include(PropertyWriter writer) {
return includes.contains(","+ writer.getName());
}
});
return mapper.writer(filters).writeValueAsString(pageInfo);
}

/**
* 根据数据库存储的信息,加工处理成页面要的,与buildsave逆向
* @param jsonStr
* @return
*/
public static String buildReqJson(String jsonStr) {
PageInfo pageInfo = parsePageInfo(jsonStr);
resetDataset(pageInfo);
for (Map<String, Object> model: pageInfo.model) {
Map<String, Object> props = (Map<String, Object>)model.get("props");
buildReqModelFields(pageInfo, props, true);
buildReqModelFields(pageInfo, props, false);
}
return JsonUtil.encodeString(pageInfo);
}

//处理model的fields和filters
private static void buildReqModelFields(PageInfo pageInfo, Map<String, Object> props, boolean isField) {
String db = (String)props.get("db");
//没有配置db,配置有误,不处理
if (StringUtils.isEmpty(db)) return;
PageDataSet pds = pageInfo.findDataSet(db);
String key = isField ? "fields":"filters";
List<Map<String, Object>> fields = (List<Map<String, Object>>)props.get(key);
if (fields == null || fields.isEmpty()) return;
for (Map<String, Object> fi: fields) {
Map<String, Object> field = (Map<String, Object>)fi.get("props");
if (field == null) continue;

String fn = (String)field.get("field");
if (StringUtils.isEmpty(fn)) continue;
PageDatasetField pdf = isField ? pds.getField(fn) : pds.getFilter(fn);
if (pdf == null) continue;

//必填字段
if (!field.containsKey("required")) {
field.put("required", pdf.isNotNull());
}

if (!field.containsKey("maxlength")) {
field.put("maxlength", SwEnum.DataType.instance.getByValue(pdf.dataType).dataLength);
}
}
}
}

+ 87
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataSet.java Целия файл

@@ -0,0 +1,87 @@
package cc.smtweb.system.bpm.web.design.form.define;

import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelTable;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/4/18 14:20
* 数据集定义
*/
public class PageDataSet {
//名称
public String name;
//中文名
public String label;
//类别:list-列表;form-表单;editList-编辑列表;tree
public String type;
//主表
public long masterTable;
//list的自定义sql,仅列表支持,select fields from tables [condition] group by xxx order by xxx
public String sql;
//固定条件,如f1='a' and f2=:p1
public String fixedCond;
//select的字段
public List<PageDatasetField> fields;
public List<PageDatasetFilter> filters;
public List<PageDatasetEnumData> data;
public PageDatasetDynCond dynCond;
public List<PageDatasetSortField> sortFields;

private Map<String, PageDatasetField> mapField;
private Map<String, PageDatasetFilter> mapFilter;

public PageDatasetField getField(String name) {
if (mapField == null) resetFields();
return mapField.get(name);
}

public PageDatasetFilter getFilter(String name) {
if (mapFilter == null) resetFields();
return mapFilter.get(name);
}

/**
* 重置丰富字段信息
*/
public void resetFields() {
mapField = new HashMap<>();
resetFields(mapField, fields);
mapFilter = new HashMap<>();
resetFields(mapFilter, filters);
for (PageDatasetFilter filter: filters) {
if (StringUtils.isEmpty(filter.sqlName)) {
filter.sqlName = filter.field;
}
}
}

private <T extends PageDatasetField> void resetFields(Map<String, T> map, List<T> list) {
ModelTableCache cache = ModelTableCache.getInstance();
ModelTable table = null;
for (T field: list) {
map.put(field.name, field);
if (field.table <= 0 || StringUtils.isEmpty(field.field)) continue;
if (table == null || table.getId() != field.table) {
table = cache.get(field.table);
}
if (table == null) throw new SwException("未找到表的定义信息(id=" + field.table + ")");
ModelField mf = table.findField(field.field);
if (mf == null) throw new SwException("未找到表字段的定义信息(" + table.getName() + "." + field.field + ")");
field.dataType = mf.getDataType();
field.editor = mf.getEditor();
field.fieldType = mf.getFieldType();
field.notNull = mf.getNotNull();
field.label = mf.getTitle();
field.link = mf.getLink();
field.remark = mf.getRemark();
}
}
}

+ 22
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetDynCond.java Целия файл

@@ -0,0 +1,22 @@
package cc.smtweb.system.bpm.web.design.form.define;

import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
* Created by Akmm at 2022/4/20 18:15
*/ //动态条件,一颗二叉树
public class PageDatasetDynCond {
public String param;
public String opt;
public List<PageDatasetDynCond> children;

public boolean isEmpty() {
return StringUtils.isEmpty(param) && StringUtils.isEmpty(opt);
}

public boolean isOpt() {
return StringUtils.isEmpty(param);
}
}

+ 9
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetEnumData.java Целия файл

@@ -0,0 +1,9 @@
package cc.smtweb.system.bpm.web.design.form.define;

/**
* Created by Akmm at 2022/4/20 18:15
*/ //简单枚举combo的数据
public class PageDatasetEnumData {
public String value;
public String label;
}

+ 37
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java Целия файл

@@ -0,0 +1,37 @@
package cc.smtweb.system.bpm.web.design.form.define;

import com.fasterxml.jackson.annotation.JsonFilter;

/**
* Created by Akmm at 2022/4/20 18:15
*/ //字段要素
@JsonFilter("datasetField")
public class PageDatasetField {
//表
public long table;
//字段
public String field;
//有别名取别名,无别名同字段名
public String name;
public String label;

public String remark;
//字段类型,如编码字段,参见FieldTypeDef
public int fieldType;
/**
* 数据类型,参见DataType
*/
public String dataType;
/**
* '禁止为空'
*/
public int notNull;
//外键关联表
public String link;
//控件类型:TEXT/TextArea/NUMBER/COMBO
public String editor;

public boolean isNotNull() {
return notNull == 1;
}
}

+ 20
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetFilter.java Целия файл

@@ -0,0 +1,20 @@
package cc.smtweb.system.bpm.web.design.form.define;

import com.fasterxml.jackson.annotation.JsonFilter;

/**
* Created by Akmm at 2022/4/20 18:15
*/ //过滤条件信息
@JsonFilter("datasetFilter")
public class PageDatasetFilter extends PageDatasetField {
//param-参数/link/const
public String type;
//sql中的查询字段名,可能带前缀
public String sqlName;
//type为link时,关联的数据集及字段
public String linkDb;
public String linkField;
//type为const时,常量值
public String value;
public boolean required;
}

+ 9
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetSortField.java Целия файл

@@ -0,0 +1,9 @@
package cc.smtweb.system.bpm.web.design.form.define;

/**
* Created by Akmm at 2022/4/20 18:16
*/
public class PageDatasetSortField {
public String field;
public String type;
}

+ 22
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageInfo.java Целия файл

@@ -0,0 +1,22 @@
package cc.smtweb.system.bpm.web.design.form.define;

import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/4/20 15:39
*/
public class PageInfo {
public List<Map<String, Object>> form;
public List<Map<String, Object>> model;
public Map<String, Object> option;
public Map<String, Object> extra;
public List<PageDataSet> db;

public PageDataSet findDataSet(String name) {
for (PageDataSet pds: db) {
if (name.equalsIgnoreCase(pds.name)) return pds;
}
return null;
}
}

+ 0
- 81
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/modelcatalog/AspModelCatalogCardService.java Целия файл

@@ -1,81 +0,0 @@
package cc.smtweb.system.bpm.web.design.modelcatalog;

import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwParam;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.system.bpm.engine.entity.AspModelCatalogPO;
import org.apache.commons.lang3.StringUtils;

@SwService
public class AspModelCatalogCardService {
@SwParam
private DbEngine dbEngine;

public R load(@SwParam("id") long id, UserSession us) {
String sql = "select mc_id, mc_parent_id, mc_code, mc_site_id, mc_name, mc_create_time, mc_last_time from sw_bpm.asp_model_catalog" +
" where mc_id=? and mc_site_id=?";
AspModelCatalogPO po = dbEngine.queryEntity(sql, AspModelCatalogPO.class, id, us.getSiteId());
return R.success(po);
}

public R save(@SwBody AspModelCatalogPO po, UserSession us) {
if (StringUtils.isBlank(po.getMcName())) {
return R.error("必须填写项目名称");
}

if (StringUtils.isBlank(po.getMcModule())) {
return R.error("必须填写模块名");
}

Long oldId = dbEngine.queryLong("select mc_id from sw_bpm.asp_model_catalog where mc_module=? and mc_id<>?",
po.getMcModule(), po.getMcId() == null ? 0 : po.getMcId());
if (oldId != null) {
return R.error("模块名有重复");
}

po.setMcLastTime(DateUtil.nowDateTimeLong());
if (po.getMcId() == null || po.getMcId() == 0L) {
po.setMcId(dbEngine.nextId());

SqlBuilder.createInsert("sw_bpm.asp_model_catalog")
.add("mc_id", po.getMcId())
.add("mc_name", po.getMcName())
.add("mc_module", po.getMcModule())
.add("mc_site_id", us.getSiteId())
.add("mc_create_time", po.getMcLastTime())
.add("mc_last_time", po.getMcLastTime())
.update(dbEngine);

return R.success(po.getMcId());
} else {
SqlBuilder.createUpdate("sw_bpm.asp_model_catalog")
.add("mc_name", po.getMcName())
.add("mc_module", po.getMcModule())
.add("mc_last_time", po.getMcLastTime())
.addWhere("mc_id", po.getMcId())
.addWhere("mc_site_id", us.getSiteId())
.update(dbEngine);

return R.success();
}
}

public R delete(@SwBody AspModelCatalogPO modelPo, UserSession us) {
Long id = dbEngine.queryLong("select model_id from sw_bpm.asp_model where model_mc_id=? limit 1", modelPo.getMcId());
if (id != null) {
return R.error("已有页面存在,不允许删除项目");
}

String sql = "delete from sw_bpm.asp_model_catalog where mc_id=? and mc_site_id=?";
if (dbEngine.update(sql, modelPo.getMcId(), us.getSiteId()) > 0) {
return R.success();
}

return R.error("删除失败");
}
}

+ 0
- 24
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/modelcatalog/AspModelCatalogListService.java Целия файл

@@ -1,24 +0,0 @@
package cc.smtweb.system.bpm.web.design.modelcatalog;

import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.annotation.SwParam;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.engine.entity.AspModelCatalogPO;

import java.util.List;

@SwService
public class AspModelCatalogListService {
@SwParam
private DbEngine dbEngine;

public R list(UserSession us) {
String sql = "select mc_id, mc_parent_id, mc_code, mc_site_id, mc_name, mc_module, mc_create_time, mc_last_time from sw_bpm.asp_model_catalog" +
" where mc_site_id=?";
List<AspModelCatalogPO> list = dbEngine.query(sql, AspModelCatalogPO.class, us.getSiteId());

return R.success(list);
}
}

+ 34
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/AbstractDynPageHandler.java Целия файл

@@ -0,0 +1,34 @@
package cc.smtweb.system.bpm.web.engine;

import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageInfo;

import java.util.HashMap;
import java.util.Map;

/**
* Created by Akmm at 2022/4/21 17:53
*/
public abstract class AbstractDynPageHandler extends AbstractHandler {
//页面定义id
protected long pageId;
protected PageInfo pageInfo;

@Override
public void init(SwMap params, UserSession us) {
super.init(params, us);
pageId = params.readLong("pageId");

pageInfo = ModelFormHelper.parsePageInfo(pageId);
if (pageInfo == null) throw new SwException("没有找到页面定义数据!");
ModelFormHelper.resetDataset(pageInfo);
}
}

+ 72
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageAddHandler.java Целия файл

@@ -0,0 +1,72 @@
package cc.smtweb.system.bpm.web.engine;

import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/4/21 17:53
* 新增操作,初始化定义的数据集
*/
public class DynPageAddHandler extends AbstractDynPageHandler {
//数据集
private String dbName;
//过滤条件
private Map<String, Object> filter = new HashMap<>();

//对应的数据集定义
private PageDataSet pageDataSet;

@Override
public R doWork() throws Exception {
dbName = params.readString("dataset");
filter = (Map<String, Object>)params.get("filter");

pageDataSet = pageInfo.findDataSet(dbName);
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!");

DynRetBean bean = null;
if (SwEnum.DatasetType.LISTR.value.equals(pageDataSet.type)) {//列表类
bean = DynRetBean.createList(loadList());
} else if (SwEnum.DatasetType.TREE.value.equals(pageDataSet.type)) {//列表类
// return new DynRetBean(loadTree());
} else {
bean = DynRetBean.createBean(loadOne());
}

return R.success(bean);
}

/**
* 返回单个对象
* @return
*/
private SwMap loadOne() {
SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter);
return DbEngine.getInstance().queryEntityN(sqlPara.sql, sqlPara.paras, SwMap.class);
}

/**
* 返回list
* @return
*/
private SwListData loadList() {
SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter);
List<SwMap> list;
if (sqlPara.page > 0 && sqlPara.rows > 0) {
list = DbEngine.getInstance().pagedQueryN(sqlPara.sql, SwMap.class, (sqlPara.page - 1) * sqlPara.rows, sqlPara.rows, sqlPara.paras);
} else {
list = DbEngine.getInstance().queryN(sqlPara.sql, sqlPara.paras, SwMap.class);
}
return SwListData.create(list, sqlPara.rows);
}
}

+ 185
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageHelper.java Целия файл

@@ -0,0 +1,185 @@
package cc.smtweb.system.bpm.web.engine;

import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;
import cc.smtweb.framework.core.mvc.service.SqlPara;
import cc.smtweb.framework.core.util.MapUtil;
import cc.smtweb.system.bpm.web.design.form.define.*;
import javafx.scene.control.Tab;
import org.apache.commons.lang3.StringUtils;

import java.util.*;

/**
* Created by Akmm at 2022/4/23 10:01
*/
public class DynPageHelper {

/**
* 构建select fields from table
*
* @param dataSet
* @return
*/
public static SqlNamedPara buildSelectSql(PageDataSet dataSet, Map<String, Object> params) {
StringBuilder sql = new StringBuilder(512);
sql.append(buildSelFieldsSql(dataSet));

SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params);
if (StringUtils.isNotEmpty(sqlNamedPara.sql)) {
sql.append(" where ").append(sqlNamedPara.sql);
}
if (dataSet.sortFields != null) {
String s = "";
for (PageDatasetSortField sf : dataSet.sortFields) {
s += "," + sf.field + " " + sf.type;
}
if (StringUtils.isNotEmpty(s)) {
sql.append(" order by ").append(s.substring(1));
}
}
sqlNamedPara.sql = sql.toString();
sqlNamedPara.page = MapUtil.readInt(params, SwConsts.PARAM_PAGE);
sqlNamedPara.rows = MapUtil.readInt(params, SwConsts.PARAM_ROWS);
return sqlNamedPara;
}

private static String buildSelFieldsSql(PageDataSet dataSet) {
StringBuilder sql = new StringBuilder(512);
//主表
ModelTable masterTable = ModelTableCache.getInstance().get(dataSet.masterTable);
//非查询列表,或sql为空,则自己组装select sql
if (!SwEnum.DatasetType.LISTR.equals(dataSet.type) || StringUtils.isEmpty(dataSet.sql)) {
sql.append("select ");
for (PageDatasetField field : dataSet.fields) {
sql.append(field.field);
//加别名
if (!field.field.equalsIgnoreCase(field.name)) {
sql.append(" ").append(field.name);
}
sql.append(",");
}
sql.setCharAt(sql.length() - 1, ' ');
sql.append(" from ").append(masterTable.getName());
return sql.toString();
} else {
return dataSet.sql;
}
}

/**
* 构建where条件:组合固定和动态条件
*
* @param dataSet
* @param params
* @return
*/
public static SqlNamedPara buildWhereSql(PageDataSet dataSet, Map<String, Object> params) {
StringBuilder sql = new StringBuilder(512);
SwMap args = new SwMap();

if (StringUtils.isNotEmpty(dataSet.fixedCond)) {
sql.append("(").append(dataSet.fixedCond).append(")");
}
//记录归属于固定条件的filter,最后设置参数
Set<String> setFixedFilter = new HashSet<>();
for (PageDatasetFilter filter: dataSet.filters) {
setFixedFilter.add(filter.name);
}
if (!dataSet.dynCond.isEmpty()) {
String s = buildDynCondSql(dataSet, dataSet.dynCond, params, args, setFixedFilter);
if (StringUtils.isNotEmpty(s)) {
if (sql.length() > 0) sql.append(" and ");
sql.append(s);
}
}
for (String s: setFixedFilter) {
args.put(s, params.get(s));
}
return new SqlNamedPara(sql.toString(), args);
}

public static String buildDynCondSql(PageDataSet dataSet, PageDatasetDynCond dynCond, Map<String, Object> params, SwMap args, Set<String> setFixedFilter) {
if (dynCond.isOpt()) {//是and/or
StringBuilder sql = new StringBuilder(256);
boolean b = false;
//递归调用
for (PageDatasetDynCond dc : dynCond.children) {
String s = buildDynCondSql(dataSet, dc, params, args, setFixedFilter);
if (StringUtils.isEmpty(s)) continue;

if (b) sql.append(" ").append(dynCond.opt).append(" ");
sql.append(s);
b = true;
}
return "(" + sql.toString() + ")";
}

boolean isNameSelf = setFixedFilter.contains(dynCond.param);
setFixedFilter.remove(dynCond.param);

PageDatasetFilter filter = dataSet.getFilter(dynCond.param);
if (filter == null) throw new SwException("没有找到filter(" + dynCond.param + ")!");

Object value = null;
if (SwEnum.FilterType.CONST.value.equals(filter.type)) {
value = filter.value;
//todo 有变量的情况需要处理
} else {
value = params.get(filter.name);
}
if (value == null || StringUtils.isEmpty(value.toString())) {
if (filter.required) {
throw new SwException("过滤条件不能为空(" + dynCond.param + ")!");
}
return null;
}
IBuilderExpr builder = getBuilder(dynCond.opt);
String ns = isNameSelf ? filter.name : filter.name + "_" + dynCond.hashCode();
return builder.build(dynCond.opt, filter.sqlName, ns, value, args);
}


private static Map<String, IBuilderExpr> mapBuilder;
private static IBuilderExpr baseBuilder;

static {
baseBuilder = (opt, field, name, value, args) -> {
args.put(name, value);
return field + " " + opt + " :" + name;
};
mapBuilder = new HashMap<>();
mapBuilder.put(SwEnum.OptType.LIKE.value, (opt, field, name, value, args) -> {
args.put(name, "%" + value + "%");
return field + " like :" + name;
});

mapBuilder.put(SwEnum.OptType.PLIKE.value, (opt, field, name, value, args) -> {
args.put(name, value + "%");
return field + " like :" + name;
});

mapBuilder.put(SwEnum.OptType.BT.value, (opt, field, name, value, args) -> {
String[] ss = value.toString().split(",");
if (ss.length != 2) throw new SwException("介于条件,参数值个数错误!");
args.put(name + "_1", ss[0]);
args.put(name + "_2", ss[1]);
return "(" + field + ">=:" + name + "_1 and " + field + "<=:" + name + "_2)";
});
}

private static IBuilderExpr getBuilder(String opt) {
IBuilderExpr builder = mapBuilder.get(opt);
return builder != null ? builder : baseBuilder;
}

interface IBuilderExpr {
String build(String opt, String field, String name, Object value, Map<String, Object> args);
}

}

+ 73
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageLoadHandler.java Целия файл

@@ -0,0 +1,73 @@
package cc.smtweb.system.bpm.web.engine;

import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.SwException;
import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.mvc.service.*;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageInfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/4/21 17:53
*/
public class DynPageLoadHandler extends AbstractDynPageHandler {
//数据集
private String dbName;
//过滤条件
private Map<String, Object> filter = new HashMap<>();

//对应的数据集定义
private PageDataSet pageDataSet;

@Override
public R doWork() throws Exception {
dbName = params.readString("dataset");
filter = (Map<String, Object>)params.get("filter");

pageDataSet = pageInfo.findDataSet(dbName);
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!");

DynRetBean bean = null;
if (SwEnum.DatasetType.LISTR.value.equals(pageDataSet.type)) {//列表类
bean = DynRetBean.createList(loadList());
} else if (SwEnum.DatasetType.TREE.value.equals(pageDataSet.type)) {//列表类
// return new DynRetBean(loadTree());
} else {
bean = DynRetBean.createBean(loadOne());
}

return R.success(bean);
}

/**
* 返回单个对象
* @return
*/
private SwMap loadOne() {
SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter);
return DbEngine.getInstance().queryEntityN(sqlPara.sql, sqlPara.paras, SwMap.class);
}

/**
* 返回list
* @return
*/
private SwListData loadList() {
SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter);
List<SwMap> list;
if (sqlPara.page > 0 && sqlPara.rows > 0) {
list = DbEngine.getInstance().pagedQueryN(sqlPara.sql, SwMap.class, (sqlPara.page - 1) * sqlPara.rows, sqlPara.rows, sqlPara.paras);
} else {
list = DbEngine.getInstance().queryN(sqlPara.sql, sqlPara.paras, SwMap.class);
}
return SwListData.create(list, sqlPara.rows);
}
}

+ 42
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynPageService.java Целия файл

@@ -0,0 +1,42 @@
package cc.smtweb.system.bpm.web.engine;

import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.db.vo.ModelCatalog;
import cc.smtweb.framework.core.mvc.service.*;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.design.table.ModelCatalogTreeHandler;

/**
* Created by Akmm at 2022/4/21 17:43
* 动态页面引擎
*/
@SwService
public class DynPageService extends AbstractCompService {
public final static String TYPE_ADD = "add";
@Override
protected IHandler createHandler(String type) {
switch (type) {
case TYPE_ADD:
return new DefaultLoadHandler<ModelCatalog>(ModelCatalog.ENTITY_NAME);
case TYPE_LOAD:
return new DynPageLoadHandler();
case TYPE_SAVE:
return new DefaultSaveHandler<>(ModelCatalog.ENTITY_NAME);
case TYPE_DEL:
return new DefaultDelHandler<>(ModelCatalog.ENTITY_NAME);
case TYPE_LIST:
return new DefaultListHandler<>(ModelCatalog.ENTITY_NAME);
case TYPE_TREE:
return new ModelCatalogTreeHandler();
}
return null;
}

//树,换爹
public R add(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_SAVE);
}
}

+ 35
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/DynRetBean.java Целия файл

@@ -0,0 +1,35 @@
package cc.smtweb.system.bpm.web.engine;

import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.mvc.service.SwListData;

import java.util.Map;

/**
* Created by Akmm at 2022/4/21 19:26
* 动态页面加载
*/
public class DynRetBean {
//单个表单
private SwMap form = null;
//列表返回
private SwListData list = null;

public static DynRetBean createBean(SwMap form) {
DynRetBean bean = new DynRetBean();
bean.form = form;
return bean;
}

public static DynRetBean createList(SwListData list) {
DynRetBean bean = new DynRetBean();
bean.list = list;
return bean;
}
/*
public static DynRetBean createTree(SwListData list) {
DynRetBean bean = new DynRetBean();
bean.list = list;
return bean;
}*/
}

+ 13
- 10
smtweb-system/sw-system-bpm/src/test/java/cc/smtweb/system/bpm/test/BuildJavaBean.java Целия файл

@@ -11,16 +11,19 @@ import org.junit.Test;
public class BuildJavaBean {
@Test
public void buildBean() {
String str = "`db_id` bigint(20) NOT NULL,\n" +
" `db_prj_id` bigint(20) DEFAULT NULL,\n" +
" `db_name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '添加上所有父节节点key,就构成模型唯一key',\n" +
" `db_title` varchar(200) COLLATE utf8_unicode_ci NOT NULL COMMENT '名称',\n" +
" `db_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态:0 启用,1 禁用',\n" +
" `db_version` int(11) NOT NULL DEFAULT '0' COMMENT '版本',\n" +
" `db_create_uid` bigint(20) DEFAULT NULL,\n" +
" `db_update_uid` bigint(20) DEFAULT NULL,\n" +
" `db_create_at` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',\n" +
" `db_update_at` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',\n";
String str = "`mf_id` bigint(20) NOT NULL,\n" +
" `mf_prj_id` bigint(20) NOT NULL DEFAULT '-1',\n" +
" `mf_mc_id` bigint(20) DEFAULT NULL COMMENT '-1',\n" +
" `mf_name` varchar(32) COLLATE utf8_unicode_ci DEFAULT '名称',\n" +
" `mf_title` varchar(200) COLLATE utf8_unicode_ci NOT NULL COMMENT '标题',\n" +
" `mf_type` int(4) DEFAULT '0',\n" +
" `mf_service` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '服务名',\n" +
" `mf_content` text COLLATE utf8_unicode_ci COMMENT '详细信息',\n" +
" `mf_create_uid` bigint(20) DEFAULT NULL,\n" +
" `mf_update_uid` bigint(20) DEFAULT NULL,\n" +
" `mf_create_at` bigint(20) NOT NULL DEFAULT '0',\n" +
" `mf_update_at` bigint(20) NOT NULL DEFAULT '0',\n" +
" `mf_remark` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '备注',\n";
String[] ss = str.split("\n");
for (String s: ss) {
String[] s0 = s.trim().split(" ");


+ 37
- 0
smtweb-system/sw-system-bpm/src/test/java/cc/smtweb/system/bpm/test/ModelFormTest.java Целия файл

@@ -0,0 +1,37 @@
package cc.smtweb.system.bpm.test;

import cc.smtweb.framework.core.CoreApplication;
import cc.smtweb.framework.core.R;
import cc.smtweb.framework.core.SwMap;
import cc.smtweb.framework.core.annotation.SwParam;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.SpringUtil;
import cc.smtweb.system.bpm.spring.BpmApplication;
import cc.smtweb.system.bpm.web.engine.DynPageService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;

/**
* Created by Akmm at 2022/4/26 9:46
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = BpmApplication.class)
public class ModelFormTest {
@Test
public void testLoad() {
SwMap params = new SwMap();
params.put("pageId", 1);
params.put("dataset", "modelProject");
Map<String, Object> filter = new HashMap<>();
filter.put("prj_name", "测试");
params.put("filter", filter);
DynPageService service = new DynPageService();
R r = service.load(params, null);
System.out.println(r.readSuccess());
}
}

Зареждане…
Отказ
Запис