Browse Source

工作流

master
郑根木 2 years ago
parent
commit
f8f613b945
5 changed files with 31 additions and 4 deletions
  1. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/CacheManager.java
  2. +7
    -3
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java
  3. +14
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java
  4. +1
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/table/ModelTableSaveHanlder.java
  5. +8
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowService.java

+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/CacheManager.java View File

@@ -30,7 +30,7 @@ public class CacheManager {
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2); private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2);


public AbstractCache getCache(String ident) { public AbstractCache getCache(String ident) {
final AbstractCache cache = cacheMap.get(ident);
final AbstractCache cache = cacheMap.get(ident.toUpperCase());
if (cache != null && cache.isNotInited()) { if (cache != null && cache.isNotInited()) {
cache.init(); cache.init();
} }


+ 7
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java View File

@@ -70,6 +70,9 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
if (field.isNotNull() && StringUtils.isEmpty(bean.getStr(field.getName()))) { if (field.isNotNull() && StringUtils.isEmpty(bean.getStr(field.getName()))) {
throw new SwException(field.getTitle() + "不能为空!"); throw new SwException(field.getTitle() + "不能为空!");
} }
if (field.getFieldType() == SwEnum.FieldType.PARENT_ID.value) {
TreeHelper.getTreeHelper(tableName).checkParent(bean);
}
} }


EntityDao dao = DbEngine.getInstance().findDao(tableName); EntityDao dao = DbEngine.getInstance().findDao(tableName);
@@ -144,16 +147,17 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
} else { } else {
bean = loadComp(id); bean = loadComp(id);
} }
TreeHelper.getTreeHelper(tableName).checkParent(bean);
//不考虑没有级次码等情况,这个在表设计时校验 //不考虑没有级次码等情况,这个在表设计时校验
ModelField fieldParentCode = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value);
ModelField fieldParentId = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value);


bean.put(fieldParentCode.getName(), parentId);
bean.put(fieldParentId.getName(), parentId);
DbEngine.getInstance().doTrans(new AbsDbWorker() { DbEngine.getInstance().doTrans(new AbsDbWorker() {
@Override @Override
public void work() { public void work() {
EntityDao dao = DbEngine.getInstance().findDao(tableName); EntityDao dao = DbEngine.getInstance().findDao(tableName);
listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean);
dao.updateEntity(bean, fieldParentCode.getName());
dao.updateEntity(bean, fieldParentId.getName());
} }


@Override @Override


+ 14
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java View File

@@ -88,6 +88,20 @@ public class TreeHelper<T extends DefaultEntity> {
return list; return list;
} }


public void checkParent(T bean) {
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return;
if (!table.isNeedCache()) throw new SwException("请定义为需要缓存!");
long pId = getParentId(bean);
if (bean.getEntityId() == pId) throw new SwException("上级节点不能为自己!");
if (pId <= 0) return;
T parent = cache.get(pId);
if (parent == null) return;
String plevelcode = SwConsts.SPLIT_CHAR + parent.getStr(fieldLevelCode) + SwConsts.SPLIT_CHAR;
if (plevelcode.contains(SwConsts.SPLIT_CHAR + bean.getEntityId() + SwConsts.SPLIT_CHAR)) {
throw new SwException("上级节点不能为自己的下级!");
}
}

public List<T> resetTreeLevel(T bean) { public List<T> resetTreeLevel(T bean) {
List<T> list = new ArrayList<>(); List<T> list = new ArrayList<>();
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return list; if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return list;


+ 1
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/table/ModelTableSaveHanlder.java View File

@@ -15,5 +15,6 @@ public class ModelTableSaveHanlder extends DefaultSaveHandler<ModelTable> {
protected void readFromPage() { protected void readFromPage() {
super.readFromPage(); super.readFromPage();
bean.setContent(bean.getContent()); bean.setContent(bean.getContent());
bean.setName(bean.getName().toUpperCase());
} }
} }

+ 8
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowService.java View File

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

/**
* Created by Akmm at 2022/5/24 14:21
* 工作流
*/
public class FlowService {
}

Loading…
Cancel
Save