@@ -52,31 +52,24 @@ public class ModelProcService extends AbstractCompService { | |||
} | |||
//加载工作流的列表字段 | |||
public R loadProcInstFields(@SwBody SwMap params, UserSession us) { | |||
ModelTable table = ModelTableCache.getInstance().getByName(ProcInst.ENTITY_NAME); | |||
if (table == null) return R.error("没有找到表定义信息(table=" + ProcInst.ENTITY_NAME + ")!"); | |||
public R loadFlowListFields (@SwBody SwMap params, UserSession us) { | |||
List<SwMap> ret = new ArrayList<>(); | |||
for (ModelField field : table.getFields()) { | |||
SwMap col = new SwMap(2); | |||
ModelFormHelper.buildFieldInfo(table, field, col); | |||
ret.add(col); | |||
} | |||
ModelFormHelper.buildTableFields(ret, ProcInst.ENTITY_NAME); | |||
return R.success(ret); | |||
} | |||
public R loadFlowCardFields(@SwBody SwMap params, UserSession us) { | |||
List<SwMap> ret = new ArrayList<>(); | |||
ModelFormHelper.buildTableFields(ret, ProcInst.ENTITY_NAME); | |||
ret.add(buildField("selTaskId", SwEnum.DataType.ID.value, "选中任务")); | |||
return R.success(ret); | |||
} | |||
//加载审批意见的列表字段 | |||
public R loadCommentFields(@SwBody SwMap params, UserSession us) { | |||
ModelTable table = ModelTableCache.getInstance().getByName(Comment.ENTITY_NAME); | |||
if (table == null) return R.error("没有找到表定义信息(table=" + Comment.ENTITY_NAME + ")!"); | |||
List<SwMap> ret = new ArrayList<>(); | |||
for (ModelField field : table.getFields()) { | |||
SwMap col = new SwMap(2); | |||
ModelFormHelper.buildFieldInfo(table, field, col); | |||
ret.add(col); | |||
} | |||
ModelFormHelper.buildTableFields(ret, Comment.ENTITY_NAME); | |||
ret.add(buildField("cmt_act_code", SwEnum.DataType.CODE.value, "活动编号")); | |||
ret.add(buildField("cmt_act_text", SwEnum.DataType.NAME.value, "活动名称")); | |||
return R.success(ret); | |||
@@ -1,11 +1,13 @@ | |||
package cc.smtweb.system.bpm.web.design.form; | |||
import cc.smtweb.framework.core.common.R; | |||
import cc.smtweb.framework.core.common.SwEnum; | |||
import cc.smtweb.framework.core.common.SwMap; | |||
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 cc.smtweb.framework.core.exception.BizException; | |||
import cc.smtweb.framework.core.exception.SwException; | |||
import cc.smtweb.framework.core.mvc.variable.SwVariableFactory; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.framework.core.util.JsonUtil; | |||
@@ -18,6 +20,7 @@ import cc.smtweb.system.bpm.util.IdeaUtil; | |||
import cc.smtweb.system.bpm.web.design.db.ModelCatalogCache; | |||
import cc.smtweb.system.bpm.web.design.db.ModelProjectCache; | |||
import cc.smtweb.system.bpm.web.design.form.define.*; | |||
import cc.smtweb.system.bpm.web.engine.flow.entity.Comment; | |||
import com.fasterxml.jackson.core.JsonProcessingException; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -513,6 +516,17 @@ public class ModelFormHelper { | |||
} | |||
} | |||
public static void buildTableFields(List<SwMap> ret, String tableName) { | |||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||
if (table == null) throw new SwException("没有找到表定义信息(table=" + tableName + ")!"); | |||
for (ModelField field : table.getFields()) { | |||
SwMap col = new SwMap(2); | |||
ModelFormHelper.buildFieldInfo(table, field, col); | |||
ret.add(col); | |||
} | |||
} | |||
/** | |||
* 页面设计时,返回的字段信息,带控件 | |||
* | |||
@@ -52,6 +52,9 @@ public class FlowInstance { | |||
private FlowListener listener; | |||
//提交驳回等之后的,属于我的新任务 | |||
private Task nextMyTask; | |||
public static FlowInstance createById(UserSession us, FlowListener listener, long billId, long taskId) { | |||
FlowInstance flowInstance = new FlowInstance(listener, us); | |||
flowInstance.load(billId, taskId); | |||
@@ -261,9 +264,13 @@ public class FlowInstance { | |||
for (Task act : list) { | |||
//如果办理人是当前用户,则置此任务为当前任务 | |||
//我办理中的任务:非待办,且是我的任务 | |||
if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && FlowHelper.isMyWaitedTask(act.getId(), us.getUserId())) { | |||
//我的待办任务,设下值,为后面的按钮判断减轻负担 | |||
act.setHandler(us.getUserId()); | |||
if (act.getId() == actInst.getId()) { | |||
act = actInst; | |||
if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && FlowHelper.isMyWaitedTask(act.getId(), us.getUserId())) { | |||
//我的待办任务,设下值,为后面的按钮判断减轻负担 | |||
act.setHandler(us.getUserId()); | |||
} | |||
} | |||
//如果当前任务为待办理,那么要找其前置任务,作为活动任务,方便取回 | |||
if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && !act.isReject() && !act.isRetake()) { | |||
@@ -318,6 +325,7 @@ public class FlowInstance { | |||
* 返回页面前的设置 | |||
*/ | |||
public void setPageRetExtra(SwMap ret) { | |||
procInst.setSelTaskId(actInst.getId()); | |||
SwMap extra = ret.computeMapIfAbsent("extra", k -> new SwMap()); | |||
List<Task> listTask = adjustTasks(); | |||
@@ -527,13 +535,8 @@ public class FlowInstance { | |||
actInst.setStatu(FlowConst.ActivityStatu.SUBMIT.value); | |||
actInst.setRetake(false); | |||
if (listInsertTask.size() > 0) { | |||
procInst.setTaskId(listInsertTask.get(0).getEntityId()); | |||
procInst.setActName(listInsertTask.get(0).getActName()); | |||
} else { | |||
procInst.setTaskId(actInst.getEntityId()); | |||
procInst.setActName(actInst.getActName()); | |||
} | |||
procInst.setTaskId(listInsertTask.get(0).getEntityId()); | |||
procInst.setActName(listInsertTask.get(0).getActName()); | |||
if (new_acts.size() == 1 && new_acts.get(0).getType() == FlowConst.ActivityType.END.value) { | |||
procInst.setStatu(FlowConst.InstanceStatu.FINISH.value); | |||
@@ -543,7 +546,6 @@ public class FlowInstance { | |||
} | |||
//保存入库 | |||
if (!listInsertTask.isEmpty()) { | |||
getTaskDao().batchInsertEntity(listInsertTask); | |||
getCandidateDao().batchInsertEntity(listInsertCand); | |||
getTaskRelDao().batchInsertEntity(listTaskRel); | |||
@@ -551,13 +553,16 @@ public class FlowInstance { | |||
if (!listTaskComment.isEmpty()) { | |||
getCommentDao().batchInsertEntity(listTaskComment); | |||
} | |||
} | |||
getTaskDao().updateEntity(actInst); | |||
getProcInstDao().updateEntity(procInst); | |||
updateComment(comment, FlowConst.Button.SUBMIT.value); | |||
buildBillLog(FlowConst.Button.SUBMIT.value, comment, actInst, listInsertTask); | |||
listener.afterSubmit(actInst, listInsertTask); | |||
//设置当前步骤 | |||
actInst = nextMyTask != null ? nextMyTask : listInsertTask.get(0); | |||
} | |||
/** | |||
@@ -645,6 +650,9 @@ public class FlowInstance { | |||
} | |||
for (Long user_id : listHander) { | |||
// if (act.getHandler().getIgnore() && user_id == submit_user) continue; | |||
if (nextMyTask == null && user_id == us.getUserId()) { | |||
nextMyTask = task; | |||
} | |||
Candidate cand = new Candidate(); | |||
cand.init(); | |||
cand.setEntityId(DbEngine.getInstance().nextId()); | |||
@@ -678,34 +686,7 @@ public class FlowInstance { | |||
} | |||
Activity activityEntity = procDef.getProcInfo().findActivity(actInst.getActId()); | |||
EntityDao<Task> taskDao = getTaskDao(); | |||
if (activityEntity.getType() == FlowConst.ActivityType.END.value) {//从结束取回 | |||
List<Task> new_acts = provider.findBeforeTasks(actInst.getId()); | |||
Task old_act = (Task) actInst.clone(); | |||
old_act.setEntityId(actInst.getEntityId()); | |||
actInst = new_acts.get(0); | |||
actInst.setHandler(user_id); | |||
actInst.setStartTime(DateUtil.nowDateTimeLong()); | |||
actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); | |||
if (actInst.isMake()) { | |||
actInst.setHandler(user_id); | |||
} | |||
procInst.setTaskId(actInst.getEntityId()); | |||
procInst.setActName(actInst.getActName()); | |||
procInst.setStatu(actInst.isMake() ? FlowConst.InstanceStatu.BEGIN.value: FlowConst.InstanceStatu.RUNING.value); | |||
taskDao.updateEntity(actInst); | |||
taskDao.deleteEntity(old_act); | |||
getTaskRelDao().deleteEntity("where trl_src_task_id=?", old_act.getId()); | |||
getProcInstDao().updateEntity(procInst); | |||
getCommentDao().deleteEntity("where cmt_tsk_id=?", old_act.getId()); | |||
new_acts.clear(); | |||
new_acts.add(old_act); | |||
buildBillLog(FlowConst.Button.RETAKE.value, "TODO", actInst, new_acts); | |||
listener.afterRetake(actInst, new_acts); | |||
// comp.transCallback(FlowConst.Button.RETAKE.value, actInst, new_acts); | |||
} else { | |||
List<Task> new_acts = provider.findAfterTasks(actInst.getId()); | |||
for (Task act : new_acts) { | |||
@@ -733,7 +714,6 @@ public class FlowInstance { | |||
updateComment(null, FlowConst.Button.RETAKE.value); | |||
buildBillLog(FlowConst.Button.RETAKE.value, "TODO", actInst, new_acts); | |||
listener.afterRetake(actInst, new_acts); | |||
} | |||
} | |||
/** | |||
@@ -766,6 +746,7 @@ public class FlowInstance { | |||
//待新增任务候选人 | |||
List<Candidate> listInsertCand = new ArrayList<>(); | |||
nextMyTask = null; | |||
//校验完毕,接下来干活。 | |||
//并发考虑:找到此任务的前置任务,创建对应的新任务,原流程其他未办理任务删除,办理中及已提交的,置为 | |||
for (String dstTaskId : dstTasks) { | |||
@@ -777,31 +758,30 @@ public class FlowInstance { | |||
buildRejectTask(toTask, listInsertTask, listInsertCand, listTaskRel, listTaskComment); | |||
} | |||
actInst.setStatu(FlowConst.ActivityStatu.REJECT.value); | |||
if (listInsertTask.size() > 0) { | |||
procInst.setTaskId(listInsertTask.get(0).getEntityId()); | |||
procInst.setActName(listInsertTask.get(0).getActName()); | |||
} else { | |||
procInst.setTaskId(actInst.getEntityId()); | |||
procInst.setActName(actInst.getActName()); | |||
} | |||
procInst.setTaskId(listInsertTask.get(0).getEntityId()); | |||
procInst.setActName(listInsertTask.get(0).getActName()); | |||
//先停止其他待办或办理中的任务 | |||
FlowHelper.stopTask(procInst.getId(), actInst.getId()); | |||
//保存入库 | |||
if (!listInsertTask.isEmpty()) { | |||
getTaskDao().batchInsertEntity(listInsertTask); | |||
getCandidateDao().batchInsertEntity(listInsertCand); | |||
getTaskRelDao().batchInsertEntity(listTaskRel); | |||
if (!listTaskComment.isEmpty()) { | |||
getCommentDao().batchInsertEntity(listTaskComment); | |||
} | |||
getTaskDao().batchInsertEntity(listInsertTask); | |||
getCandidateDao().batchInsertEntity(listInsertCand); | |||
getTaskRelDao().batchInsertEntity(listTaskRel); | |||
if (!listTaskComment.isEmpty()) { | |||
getCommentDao().batchInsertEntity(listTaskComment); | |||
} | |||
getTaskDao().updateEntity(actInst); | |||
getProcInstDao().updateEntity(procInst); | |||
updateComment(comment, FlowConst.Button.REJECT.value); | |||
buildBillLog(FlowConst.Button.SUBMIT.value, comment, actInst, listInsertTask); | |||
listener.afterSubmit(actInst, listInsertTask); | |||
actInst = nextMyTask != null ? nextMyTask: listInsertTask.get(0); | |||
} | |||
private void buildRejectTask(Task oldTask, List<Task> listInsertTask, List<Candidate> listInsertCand, List<TaskRel> listTaskRel, List<Comment> listTaskComment) { | |||
@@ -826,7 +806,9 @@ public class FlowInstance { | |||
cand.setPriId(task.getPriId()); | |||
cand.setTskId(task.getId()); | |||
cand.setUserId(oldTask.getHandler()); | |||
if (nextMyTask == null && task.getHandler() == us.getUserId()) { | |||
nextMyTask = task; | |||
} | |||
listInsertCand.add(cand); | |||
//创建新的审批意见 | |||
@@ -232,4 +232,11 @@ public class ProcInst extends DefaultEntity { | |||
public void setUrl(String pri_url) { | |||
put("pri_url", pri_url); | |||
} | |||
/** | |||
* 当前选择的任务 | |||
*/ | |||
public void setSelTaskId(long selTaskId) { | |||
put("selTaskId", selTaskId); | |||
} | |||
} |
@@ -28,9 +28,10 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad | |||
bean.setEntityId(flowInstance.getProcInst().getId()); | |||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | |||
flowInstance.setPageRetExtra(ret); | |||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | |||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | |||
flowInstance.setPageRetExtra(ret); | |||
} | |||
@Override | |||
@@ -47,9 +48,9 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad | |||
//加载流程信息 | |||
flowInstance = FlowInstance.createById(us, this, id, taskId); | |||
flowInstance.setPageRetExtra(ret); | |||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | |||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); | |||
flowInstance.setPageRetExtra(ret); | |||
afterLoad(ret, bean); | |||
return R.success(ret); | |||
} | |||
@@ -55,9 +55,9 @@ public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSave | |||
@Override | |||
protected void afterSave(SwMap ret, T bean) { | |||
super.afterSave(ret, bean); | |||
flowInstance.setPageRetExtra(ret); | |||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | |||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | |||
flowInstance.setPageRetExtra(ret); | |||
} | |||
//单据编号,新增保存时调用 | |||
@@ -34,9 +34,10 @@ public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHa | |||
private SwMap buildRetData() { | |||
SwMap ret = new SwMap(); | |||
ret.put(LCSingleHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean)); | |||
flowInstance.setPageRetExtra(ret); | |||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | |||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | |||
flowInstance.setPageRetExtra(ret); | |||
return ret; | |||
} | |||
@@ -50,7 +50,7 @@ public class AuthService { | |||
UserSession userSession = null; | |||
try { | |||
if ("admin".equals(loginPO.getUsername())) { | |||
userSession = new UserSession(1); | |||
userSession = UserSession.createSys(); | |||
// user=new User(); | |||
// return new UserSession(1); | |||
} else { | |||
@@ -87,6 +87,8 @@ public class AuthService { | |||
loginAckVO.setDesc(user.getSign()); | |||
loginAckVO.setToken(sessionManager.login(userSession)); | |||
loginAckVO.setUserLevel(user.getLevel() + ""); | |||
loginAckVO.setUserNicky(user.getNicky()); | |||
loginAckVO.setUserTel(user.getTel()); | |||
data.put("user", loginAckVO); | |||
data.put("token", loginAckVO.getToken()); | |||
data.put("isOk", true); | |||
@@ -12,4 +12,6 @@ public class LoginAckVO { | |||
private String desc; | |||
private String token; | |||
private String userLevel; //102100内部用户/102101外部用户/102102公众用户 | |||
private String userNicky; | |||
private String userTel; | |||
} |
@@ -106,7 +106,7 @@ | |||
"size": "default", | |||
"hideLabel": true, | |||
"dataset": "flow", | |||
"field": "pri_task_id" | |||
"field": "selTaskId" | |||
}, | |||
"events": { | |||
"on-change": "onTaskChange" | |||
@@ -85,7 +85,66 @@ | |||
}, | |||
"events": {} | |||
} | |||
<#if field_has_next>,</#if> | |||
<#if field_has_next> | |||
<#if (param.masterCol lte 1 )> | |||
<#if (field.desc != "")> | |||
,{ | |||
"id": "id${newId()}", | |||
"type": "fx-label", | |||
"props": { | |||
"label": "${field.desc}", | |||
"labelWidth": 0, | |||
"affixError": true, | |||
"labelAlign": "left" | |||
} | |||
} | |||
,{ | |||
"id": "id${newId()}", | |||
"type": "fx-placeholder", | |||
"props": { | |||
"label": "占位" | |||
}, | |||
"layout": { | |||
"row": 1 | |||
} | |||
} | |||
<#else> | |||
,{ | |||
"id": "id${newId()}", | |||
"type": "fx-placeholder", | |||
"props": { | |||
"label": "占位" | |||
}, | |||
"layout": { | |||
"row": 1 | |||
} | |||
} | |||
,{ | |||
"id": "id${newId()}", | |||
"type": "fx-placeholder", | |||
"props": { | |||
"label": "占位" | |||
}, | |||
"layout": { | |||
"row": 1 | |||
} | |||
} | |||
</#if> | |||
</#if> | |||
<#if (param.masterCol = 2 && ((field_index+1) % 2 = 0 ) )> | |||
,{ | |||
"id": "id${newId()}", | |||
"type": "fx-placeholder", | |||
"props": { | |||
"label": "占位" | |||
}, | |||
"layout": { | |||
"row": 1 | |||
} | |||
} | |||
</#if> | |||
, | |||
</#if> | |||
</#list> | |||
] | |||
}, | |||
@@ -278,23 +278,6 @@ public class DbEngine extends JdbcEngine { | |||
if (entities == null || entities.isEmpty()) { | |||
return null; | |||
} | |||
return findDao((Class<T>) entities.get(0).getClass()).batchInsertEntity(entities, null); | |||
return findDao((Class<T>) entities.get(0).getClass()).batchInsertEntity(entities); | |||
} | |||
/** | |||
* 批量插入单行数据 | |||
* | |||
* @param entities PO对象列表 | |||
* @param fields 逗号分隔的字段列表 | |||
* @param <T> 实体类型 | |||
* @return 更新数量 | |||
*/ | |||
public <T> int[] batchInsertEntity(List<T> entities, String fields) { | |||
if (entities == null || entities.isEmpty()) { | |||
return null; | |||
} | |||
return findDao((Class<T>) entities.get(0).getClass()).batchInsertEntity(entities, fields); | |||
} | |||
} |
@@ -139,40 +139,18 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||
* 批量插入单行数据 | |||
* | |||
* @param entities PO对象列表 | |||
* @return 更新数量 | |||
*/ | |||
public int[] batchInsertEntity(Collection<T> entities) { | |||
return batchInsertEntity(entities, null); | |||
} | |||
/** | |||
* 批量插入单行数据 | |||
* | |||
* @param entities PO对象列表 | |||
* @param fields 逗号分隔的字段列表 | |||
* @return 更新数量 | |||
*/ | |||
public int[] batchInsertEntity(Collection<T> entities, String fields) { | |||
public int[] batchInsertEntity(Collection<T> entities) { | |||
StringBuilder sql = new StringBuilder(); | |||
sql.append("insert into ").append(modelTable.getSchemaTableName()).append("("); | |||
List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value); | |||
List<EntityColumn> insertColumns = new ArrayList<>(this.columns.size()); | |||
if (listFields == null) { | |||
for (EntityColumn column : this.columns.values()) { | |||
sql.append(column.getField().getName()).append(","); | |||
insertColumns.add(column); | |||
} | |||
} else { | |||
for (String name : listFields) { | |||
EntityColumn column = this.columns.get(name.trim()); | |||
sql.append(column.getField().getName()).append(","); | |||
insertColumns.add(column); | |||
} | |||
for (EntityColumn column : this.columns.values()) { | |||
sql.append(column.getField().getName()).append(","); | |||
insertColumns.add(column); | |||
} | |||
sql.setCharAt(sql.length() - 1, ')'); | |||