Parcourir la source

工作流

master
郑根木 il y a 2 ans
Parent
révision
f8f613b945
5 fichiers modifiés avec 31 ajouts et 4 suppressions
  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 Voir le fichier

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

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


+ 7
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java Voir le fichier

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

EntityDao dao = DbEngine.getInstance().findDao(tableName);
@@ -144,16 +147,17 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
} else {
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() {
@Override
public void work() {
EntityDao dao = DbEngine.getInstance().findDao(tableName);
listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean);
dao.updateEntity(bean, fieldParentCode.getName());
dao.updateEntity(bean, fieldParentId.getName());
}

@Override


+ 14
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java Voir le fichier

@@ -88,6 +88,20 @@ public class TreeHelper<T extends DefaultEntity> {
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) {
List<T> list = new ArrayList<>();
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 Voir le fichier

@@ -15,5 +15,6 @@ public class ModelTableSaveHanlder extends DefaultSaveHandler<ModelTable> {
protected void readFromPage() {
super.readFromPage();
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 Voir le fichier

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

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

Chargement…
Annuler
Enregistrer