diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java index fff594b..dca8694 100644 --- a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java @@ -1,19 +1,26 @@ package com.customization.youhong.taibao.trisubreq.impl; import aiyh.utils.Util; +import aiyh.utils.entity.ModelTableInfo; import aiyh.utils.excention.CustomerException; +import aiyh.utils.recordset.MapperBuilderSql; import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestEntity; import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataConfig; +import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataMapping; +import com.customization.youhong.taibao.trisubreq.impl.entity.WorkflowBaseDataEntity; import com.engine.core.cfg.annotation.ServiceDynamicProxy; import com.engine.core.impl.aop.AbstractServiceProxy; import com.engine.workflow.service.SubRequestService; import com.engine.workflow.service.impl.SubRequestServiceImpl; +import ebu7common.youhong.ai.bean.Builder; import org.apache.log4j.Logger; import weaver.workflow.request.DiffWfTriggerSetting; import weaver.workflow.request.SameWfTriggerSetting; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -44,14 +51,18 @@ public class TriSubRequestAfterInterceptImpl extends AbstractServiceProxy implem @Override public void triSubRequestAfter(int i) { + // 查询所有的子流程 List subRequestEntities = mapper.selectSubRequestByMainRequest(i); if (CollectionUtil.isEmpty(subRequestEntities)) { return; } - List subRequestToDataConfigs = mapper.selectConfig(); + String mainWorkflowId = mapper.selectWorkflowId(i); + // 查询配置信息 + List subRequestToDataConfigs = mapper.selectConfig(mainWorkflowId); if (CollectionUtil.isEmpty(subRequestToDataConfigs)) { return; } + // 按照流程类型分组,主要作用于不同流程的触发操作 Map collect = subRequestToDataConfigs .stream() .collect( @@ -59,20 +70,100 @@ public class TriSubRequestAfterInterceptImpl extends AbstractServiceProxy implem SubRequestToDataConfig::getWorkflowType, value -> value )); - - List> requestDataList = new ArrayList<>(); + // 查询出所有子流程的数据信息 + List requestDataList = new ArrayList<>(); for (SubRequestEntity subRequestEntity : subRequestEntities) { // 查询流程对应的配置信息 Map requestData = getRequestData(subRequestEntity); - requestDataList.add(requestData); + WorkflowBaseDataEntity build = Builder.builder(WorkflowBaseDataEntity::new) + .with(WorkflowBaseDataEntity::setRequestId, subRequestEntity.getRequestId()) + .with(WorkflowBaseDataEntity::setWorkflowId, subRequestEntity.getWorkflowId()) + .with(WorkflowBaseDataEntity::setData, requestData) + .build(); + requestDataList.add(build); } if (CollectionUtil.isEmpty(requestDataList)) { return; } + // 更具requestId转换map + Map requestDataMap = requestDataList.stream().collect(Collectors.toMap( + WorkflowBaseDataEntity::getRequestId, + value -> value + )); + // 查询主流程数据信息 Map mainRequestData = mapper.selectRequestBase(Util.null2String(i)); - + for (SubRequestEntity subRequestEntity : subRequestEntities) { + // 根据workflowId获取配置信息 + SubRequestToDataConfig subRequestToDataConfig = collect.get(subRequestEntity.getWorkflowId()); + WorkflowBaseDataEntity workflowBaseDataEntity = requestDataMap.get(subRequestEntity.getRequestId()); + Map data = workflowBaseDataEntity.getData(); + String conditionUpdate = subRequestToDataConfig.getConditionUpdate(); + ModelTableInfo modelTableInfo = subRequestToDataConfig.getModelTableInfo(); + String modelId = ""; + Map updateMap = null; + String id = ""; + // 没有更新条件,不需要更新数据信息 + if (StrUtil.isBlank(conditionUpdate)) { + modelId = mapper.selectModelId(conditionUpdate, modelTableInfo.getTableName(), mainRequestData, data); + id = modelId; + } + if (StrUtil.isNotBlank(modelId)) { + // 查询到数据,需要更新数据信息 + List updateMappings = subRequestToDataConfig.getUpdateMappings(); + updateMap = tidyUpData(updateMappings, mainRequestData, data); + } else { + // 没有数据,需要插入 + List mappings = subRequestToDataConfig.getMappings(); + updateMap = tidyUpData(mappings, mainRequestData, data); + int modeDataId = Util.getModeDataId(subRequestToDataConfig.getModelTable(), 1); + id = Util.null2String(modeDataId); + } + String updateSql = MapperBuilderSql.builderUpdateSql(subRequestToDataConfig.getModelTable(), updateMap); + updateSql += " where id = #{id}"; + updateMap.put("id", id); + boolean flag = mapper.updateModelData(updateSql, updateMap); + if (!flag) { + log.info("流程转数据数据信息更新失败!" + updateSql); + } else { + Util.rebuildModeDataShare(1, subRequestToDataConfig.getModelTable(), Integer.valueOf(id)); + } + } } + /** + *

整理数据

+ * + * @param mappings 字段映射关系 + * @param mainRequestData 主流程数据 + * @param data 子流程数据 + * @return 整理后数据 + */ + + private Map tidyUpData(List mappings, + Map mainRequestData, + Map data) { + Map result = new HashMap<>(mappings.size()); + for (SubRequestToDataMapping mapping : mappings) { + Integer dataSource = mapping.getDataSource(); + Object value = null; + if (dataSource == 0) { + // 主流程数据 + value = mainRequestData.get(mapping.getMainWorkflowField().getFieldName()); + } else { + // 子流程数据 + value = data.get(mapping.getWorkflowField().getFieldName()); + } + result.put(mapping.getModelField().getTableName(), value); + } + return result; + } + + /** + *

查询流程数据

+ * + * @param subRequestEntity 流程信息 + * @return 流程基本数据 + */ private Map getRequestData(SubRequestEntity subRequestEntity) { String tableName = subRequestEntity.getWorkflowTable(); Map requestData = mapper.selectWorkflowData(tableName, subRequestEntity.getRequestId()); diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java index 98580b6..7945016 100644 --- a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java @@ -52,10 +52,10 @@ public interface TriSubRequestAfterMapper { * * @return 配置表信息 */ - @Select("select * from uf_sub_wf_to_mode") + @Select("select * from uf_sub_wf_to_mode where workflow_type_1 = #{workflowId}") @Associations({ @Association( - property = "modelTableName", + property = "modelTableInfo", column = "model_table", select = "aiyh.utils.mapper.UtilMapper.selectModelTableInfo", id = @Id(value = Integer.class) @@ -66,9 +66,14 @@ public interface TriSubRequestAfterMapper { property = "mappings", column = "id", id = @Id(value = String.class, methodId = 1) + ), + @CollectionMapping( + property = "updateMappings", + column = "id", + id = @Id(value = String.class, methodId = 2) ) }) - List selectConfig(); + List selectConfig(@ParamMapper("workflowId") String workflowId); /** @@ -91,10 +96,46 @@ public interface TriSubRequestAfterMapper { column = "workflow_field", select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo", id = @Id(value = Integer.class) + ), + @Association( + property = "mainWorkflowField", + column = "main_workflow_field", + select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo", + id = @Id(value = Integer.class) ) }) List selectConfigDt(String mainId); + /** + *

查询明细表2信息

+ * + * @param mainId 主表id + * @return 明细表2数据 + */ + @CollectionMethod(value = 2, desc = "查询配置表明细2信息") + @Select("select * from uf_sub_wf_to_mode_dt2 where mainid = #{mainId}") + @Associations({ + @Association( + property = "modelField", + column = "model_field", + select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo", + id = @Id(value = Integer.class) + ), + @Association( + property = "workflowField", + column = "workflow_field", + select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo", + id = @Id(value = Integer.class) + ), + @Association( + property = "mainWorkflowField", + column = "main_workflow_field", + select = "aiyh.utils.mapper.UtilMapper.selectFieldInfo", + id = @Id(value = Integer.class) + ) + }) + List selectConfigDt2(String mainId); + /** *

查询流程数据

* @@ -113,4 +154,39 @@ public interface TriSubRequestAfterMapper { */ @Select("select * from workflow_requestbase where requestid = #{requestId}") Map selectRequestBase(@ParamMapper("requestId") String requestId); + + /** + *

查询建模数据id

+ * + * @param conditionUpdate 更新条件 + * @param tableName 表名称 + * @param mainRequestData 主流程数据 + * @param data 子流程数据 + * @return 流程数据 + */ + @Select("select * from $t{tableName} where $t{conditionUpdate}") + String selectModelId( + @ParamMapper("conditionUpdate") String conditionUpdate, + @ParamMapper("tableName") String tableName, + @ParamMapper("main") Map mainRequestData, + @ParamMapper("sub") Map data); + + + /** + *

更新建模

+ * + * @param updateSql 自定义sql + * @param updateMap 更新值 + */ + @Update(custom = true) + boolean updateModelData(@SqlString String updateSql, Map updateMap); + + /** + *

查询主流程流程id

+ * + * @param i 流程请求id + * @return 流程id + */ + @Select("select WORKFLOWID from workflow_requestbase where requestid = #{requestId}") + String selectWorkflowId(@ParamMapper("requestId") int i); } diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataConfig.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataConfig.java index 50be919..c95df11 100644 --- a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataConfig.java +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataConfig.java @@ -23,14 +23,21 @@ public class SubRequestToDataConfig { /** 流程 */ private String workflowType; + + /** 子流程 */ + private String workflowType1; /** 建模 */ private String modelTable; /** 更新条件 */ private String conditionUpdate; /** 建模表 */ - private ModelTableInfo modelTableName; + private ModelTableInfo modelTableInfo; + /** 插入字段映射 */ private List mappings; + /** 更新字段映射 */ + private List updateMappings; + } diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataMapping.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataMapping.java index 03260f4..8a7cd9c 100644 --- a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataMapping.java +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestToDataMapping.java @@ -26,4 +26,10 @@ public class SubRequestToDataMapping { private FieldViewInfo modelField; /** 流程字段 */ private FieldViewInfo workflowField; + + /** 主流程字段 */ + private FieldViewInfo mainWorkflowField; + + /** 数据来源 */ + private Integer dataSource; } diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/WorkflowBaseDataEntity.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/WorkflowBaseDataEntity.java new file mode 100644 index 0000000..b955e2c --- /dev/null +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/WorkflowBaseDataEntity.java @@ -0,0 +1,30 @@ +package com.customization.youhong.taibao.trisubreq.impl.entity; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + *

流程基本数据实体类

+ * + *

create: 2023/6/7 10:06

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class WorkflowBaseDataEntity { + + + /** 流程ID */ + private String workflowId; + + /** 请求id */ + private String requestId; + + /** 流程数据 */ + private Map data; +} diff --git a/src/main/java/weaver/youhong/ai/geerde/action/submitfirst/AutoSubmitFirstAction.java b/src/main/java/weaver/youhong/ai/geerde/action/submitfirst/AutoSubmitFirstAction.java index ded5743..4898627 100644 --- a/src/main/java/weaver/youhong/ai/geerde/action/submitfirst/AutoSubmitFirstAction.java +++ b/src/main/java/weaver/youhong/ai/geerde/action/submitfirst/AutoSubmitFirstAction.java @@ -9,6 +9,7 @@ import lombok.Setter; import lombok.ToString; import weaver.hrm.User; import weaver.soa.workflow.request.RequestInfo; +import weaver.soa.workflow.request.RequestService; import weaver.youhong.ai.geerde.action.submitfirst.mapper.AutoSubmitFirstMapper; import java.util.Arrays; @@ -77,6 +78,8 @@ public class AutoSubmitFirstAction extends SafeCusBaseAction { } int creatorId = requestInfo.getRequestManager().getCreater(); String finalNodesStr = nodesStr; + RequestService requestService = new RequestService(); + // requestService.setSubmitToNodeid(); Util.submitWorkflowThread(Integer.parseInt(requestId), creatorId, "", 60, flag -> { oneRequestLock.remove(requestId); diff --git a/src/main/java/weaver/youhong/ai/intellectualproperty/cusgetvalue/FileToBase64CusGetValue.java b/src/main/java/weaver/youhong/ai/intellectualproperty/cusgetvalue/FileToBase64CusGetValue.java index 3fd2b05..b3badd9 100644 --- a/src/main/java/weaver/youhong/ai/intellectualproperty/cusgetvalue/FileToBase64CusGetValue.java +++ b/src/main/java/weaver/youhong/ai/intellectualproperty/cusgetvalue/FileToBase64CusGetValue.java @@ -12,7 +12,9 @@ import weaver.youhong.ai.intellectualproperty.action.CaElectronicSignatureAction import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.Base64; +import java.util.List; import java.util.Map; +import java.util.Objects; /** *

自定义接口获取值

@@ -34,7 +36,11 @@ public class FileToBase64CusGetValue implements CusInterfaceGetValue { if (currentValue.split(",").length > 1) { throw new CustomerException("签章文件有且只能有一个文件!"); } - DocImageInfo docImageInfo = Util.selectImageInfoByDocId(currentValue); + List docImageInfoList = Util.selectImageInfoByDocIds(currentValue); + DocImageInfo docImageInfo = findMaxImageFileId(docImageInfoList); + if (Objects.isNull(docImageInfo)) { + throw new CustomerException("未找到实体文件数据!"); + } InputStream inputStream = ImageFileManager.getInputStreamById(docImageInfo.getImageFileId()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; @@ -51,4 +57,18 @@ public class FileToBase64CusGetValue implements CusInterfaceGetValue { throw new CustomerException("convert file to base64 fail!"); } } + + public DocImageInfo findMaxImageFileId(List list) { + DocImageInfo maxImageFileIdObj = null; + Integer maxImageFileId = null; + + for (DocImageInfo obj : list) { + if (maxImageFileId == null || obj.getImageFileId() > maxImageFileId) { + maxImageFileId = obj.getImageFileId(); + maxImageFileIdObj = obj; + } + } + + return maxImageFileIdObj; + } } diff --git a/view-mysql.sql b/view-mysql.sql index c8d6c41..c55b822 100644 --- a/view-mysql.sql +++ b/view-mysql.sql @@ -33,6 +33,56 @@ from workflow_billdetailtable bill join workflow_base base on base.formid = bill.billid; -- 流程和建模字段视图,更具流程和建模的billid可以查询流程和建模中的字段信息 +-- 初始化基础参数 +DROP TABLE IF EXISTS cus_workflow_base_field_assist; +CREATE TABLE cus_workflow_base_field_assist +( + id INT PRIMARY KEY, + fieldname VARCHAR(255) NOT NULL, + indexdesc VARCHAR(255) NOT NULL, + tablename VARCHAR(255) NOT NULL, + billid INT NOT NULL, + showtablename VARCHAR(255) NOT NULL, + fieldhtmltype VARCHAR(255) NOT NULL, + fieldtype INT NOT NULL +); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-999, 'requestname', '请求名称:requestname', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-998, 'creater', '创建人:creater', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-997, 'createdate', '创建日期:createdate', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-996, 'createtime', '创建时间:createtime', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-995, 'requestmark', '请求说明:requestmark', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-994, 'messagetype', '消息提醒:messagetype', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-993, 'mainrequestid', '主流程的请求id:mainrequestid', 'workflow_requestbase', 999, 'main table', '单行文本', + '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-992, 'ecology_pinyin_search', 'ecology_拼音_搜索:ecology_pinyin_search', 'workflow_requestbase', 999, + 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-991, 'requestnamenew', '带标题字段的请求标题:requestnamenew', 'workflow_requestbase', 999, 'main table', + '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-990, 'requestid', '请求id:requestid', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-989, 'workflowid', '工作流id:workflowid', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +-- 创建试图 create or replace view workflow_field_table_view as select wb.id, @@ -62,7 +112,10 @@ select wb.id, else '附件上传' end) fieldhtmltype, wb.FIELDHTMLTYPE fieldtype from workflow_billfield wb - left join htmllabelindex ht on wb.fieldlabel = ht.id; + left join htmllabelindex ht on wb.fieldlabel = ht.id +union all +select * +from cus_workflow_base_field_assist; -- 建模表信息视图 create @@ -73,6 +126,27 @@ from workflow_bill bill where bill.id < 0 and bill.tablename like 'uf%'; +-- 流程建模表信息 +CREATE +or replace VIEW workflow_mode_table_view +AS +select bill.ID id, + bill.TABLENAME tablename, + base.WORKFLOWNAME indexdesc, + 'workflow' tabletype +from ( + workflow_bill bill join workflow_base base on ((base.FORMID = bill.ID)) + ) +union all +select bill.ID id, + bill.TABLENAME tablename, + hti.INDEXDESC indexdesc, + 'mode' tabletype +from ( + workflow_bill bill left join htmllabelindex hti on ((hti.ID = bill.NAMELABEL)) + ) +where ((bill.ID < 0) and (bill.TABLENAME like 'uf%')); + -- 流程节点信息视图 create or replace view workflow_node_info_view as diff --git a/view-oracle.sql b/view-oracle.sql index 5684967..38f78cd 100644 --- a/view-oracle.sql +++ b/view-oracle.sql @@ -1,6 +1,6 @@ -- 流程类型视图,可用于数据集成或流览按钮 create - or replace view workflow_type_info_view as +or replace view workflow_type_info_view as select wb.id, wb.workflowname, wt.typename, @@ -8,39 +8,93 @@ select wb.id, (case when wb.version is null then 1 else wb.version end) version from workflow_base wb RIGHT JOIN workflow_type wt on wb.workflowtype = wt.id -/ + / -- 流程表单视图,用于流览按钮或数据集成,配置流程类型表可以用字段联动获取流程表表名 create - or replace view workflow_table_view as +or replace view workflow_table_view as select base.id, base.workflowname, base.formid, bill.tablename, - (case when base.version is null then 1 else base.version end) version + (case when base.version is null then 1 else base.version end) version from workflow_bill bill join workflow_base base on base.formid = bill.id -/ + / -- 流程明细表信息,可用流程主表查询对应的明细表信息,用于流览框 create - or replace view workflow_detail_table_view as +or replace view workflow_detail_table_view as select (bill.id || '-' || base.id) id, - bill.id bill_id, - base.id workflow_id, + bill.id bill_id, + base.id workflow_id, base.workflowname, - base.formid main_formid, + base.formid main_formid, bill.tablename from workflow_billdetailtable bill join workflow_base base on base.formid = bill.billid -/ + / -- 流程和建模字段视图,更具流程和建模的billid可以查询流程和建模中的字段信息 +-- 准备基础数据 + +BEGIN + -- 判断表是否存在 +FOR i IN (SELECT * FROM user_tables WHERE table_name = 'cus_workflow_base_field_assist') LOOP + -- 存在则删除表 + EXECUTE IMMEDIATE 'DROP TABLE cus_workflow_base_field_assist'; +END LOOP; + -- 不存在或删除成功后则创建表 +EXECUTE IMMEDIATE ' +CREATE TABLE cus_workflow_base_field_assist + (id NUMBER(10) PRIMARY KEY, fieldname VARCHAR2(255) NOT NULL, indexdesc VARCHAR2(255) NOT NULL, tablename VARCHAR2(255) NOT NULL, billid NUMBER(10) NOT NULL, showtablename VARCHAR2(255) NOT NULL, fieldhtmltype VARCHAR2(255) NOT NULL, fieldtype NUMBER(10) NOT NULL) +'; +END; +/ +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-999, 'requestname', '请求名称:requestname', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-998, 'creater', '创建人:creater', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-997, 'createdate', '创建日期:createdate', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-996, 'createtime', '创建时间:createtime', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-995, 'requestmark', '请求说明:requestmark', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-994, 'messagetype', '消息提醒:messagetype', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-993, 'mainrequestid', '主流程的请求id:mainrequestid', 'workflow_requestbase', 999, 'main table', '单行文本', + '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-992, 'ecology_pinyin_search', 'ecology_拼音_搜索:ecology_pinyin_search', 'workflow_requestbase', 999, + 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-991, 'requestnamenew', '带标题字段的请求标题:requestnamenew', 'workflow_requestbase', 999, 'main table', + '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-990, 'requestid', '请求id:requestid', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-989, 'workflowid', '工作流id:workflowid', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); + + +-- 创建试图 create - or replace view workflow_field_table_view as +or replace view workflow_field_table_view as select wb.id, wb.fieldname, - (ht.indexdesc || ':' || wb.fieldname) indexdesc, + (ht.indexdesc || ':' || wb.fieldname) indexdesc, ( case when wb.detailtable is null then (select distinct tablename from workflow_bill where id = wb.billid) @@ -48,38 +102,61 @@ select wb.id, then (select distinct tablename from workflow_bill where id = wb.billid) else wb.detailtable end - ) tablename, + ) tablename, billid, ( case when wb.detailtable = '' then 'main table' when wb.detailtable is null then 'main table' else wb.detailtable end - ) showtablename, + ) showtablename, (case when wb.fieldhtmltype = '1' then '单行文本框' when wb.FIELDHTMLTYPE = '2' then '多行文本框' when wb.FIELDHTMLTYPE = '3' then '流览框' when wb.FIELDHTMLTYPE = '4' then 'check框' when wb.FIELDHTMLTYPE = '5' then '选择框' - else '附件上传' end) fieldhtmltype + else '附件上传' end) fieldhtmltype from workflow_billfield wb left join htmllabelindex ht on wb.fieldlabel = ht.id -/ +union all +select * +from cus_workflow_base_field_assist / -- 建模表信息视图 create - or replace view mode_bill_info_view as +or replace view mode_bill_info_view as select bill.id, bill.tablename, hti.indexdesc from workflow_bill bill left join htmllabelindex hti on hti.id = bill.namelabel where bill.id < 0 and bill.tablename like 'uf%' -/ + / +-- 流程建模表信息 +CREATE +or replace VIEW workflow_mode_table_view +AS +select bill.ID id, + bill.TABLENAME tablename, + base.WORKFLOWNAME indexdesc, + 'workflow' tabletype +from ( + workflow_bill bill join workflow_base base on ((base.FORMID = bill.ID)) + ) +union all +select bill.ID id, + bill.TABLENAME tablename, + hti.INDEXDESC indexdesc, + 'mode' tabletype +from ( + workflow_bill bill left join htmllabelindex hti on ((hti.ID = bill.NAMELABEL)) + ) +where ((bill.ID < 0) and (bill.TABLENAME like 'uf%')) + / -- 流程节点信息视图 create - or replace view workflow_node_info_view as +or replace view workflow_node_info_view as select distinct nb.id, nb.nodename, (case when wb.version is null then 1 else wb.version end) version, @@ -87,4 +164,4 @@ select distinct nb.id, from workflow_nodebase nb left join workflow_flownode fn on nb.id = fn.nodeid left join workflow_base wb on wb.id = fn.workflowid -/ + / diff --git a/view-sql-server.sql b/view-sql-server.sql index 53de47a..df6e1a5 100644 --- a/view-sql-server.sql +++ b/view-sql-server.sql @@ -22,7 +22,7 @@ select base.id, base.workflowname, base.formid, bill.tablename, - (case when base.version is null then 1 else base.version end) version + (case when base.version is null then 1 else base.version end) version from workflow_bill bill join workflow_base base on base.formid = bill.id go @@ -41,7 +41,55 @@ from workflow_billdetailtable bill join workflow_base base on base.formid = bill.billid go -- 流程和建模字段视图,更具流程和建模的billid可以查询流程和建模中的字段信息 -if exists (select * from sysobjects where name = 'workflow_field_table_view') +-- 准备基础数据 + +DROP TABLE IF EXISTS cus_workflow_base_field_assist go +CREATE TABLE cus_workflow_base_field_assist +( + id INT PRIMARY KEY, + fieldname VARCHAR(255) NOT NULL, + indexdesc VARCHAR(255) NOT NULL, + tablename VARCHAR(255) NOT NULL, + billid INT NOT NULL, + showtablename VARCHAR(255) NOT NULL, + fieldhtmltype VARCHAR(255) NOT NULL, + fieldtype INT NOT NULL +)go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-999, 'requestname', '请求名称:requestname', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-998, 'creater', '创建人:creater', 'workflow_requestbase', 999, 'main table', '单行文本', '1'); +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-997, 'createdate', '创建日期:createdate', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-996, 'createtime', '创建时间:createtime', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-995, 'requestmark', '请求说明:requestmark', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-994, 'messagetype', '消息提醒:messagetype', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-993, 'mainrequestid', '主流程的请求id:mainrequestid', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-992, 'ecology_pinyin_search', 'ecology_拼音_搜索:ecology_pinyin_search', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-991, 'requestnamenew', '带标题字段的请求标题:requestnamenew', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-990, 'requestid', '请求id:requestid', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +INSERT INTO cus_workflow_base_field_assist(id, fieldname, indexdesc, tablename, billid, showtablename, fieldhtmltype, + fieldtype) +VALUES (-989, 'workflowid', '工作流id:workflowid', 'workflow_requestbase', 999, 'main table', '单行文本', '1') go +-- 创建试图 + if exists (select * from sysobjects where name = 'workflow_field_table_view') drop view workflow_field_table_view go create view workflow_field_table_view as @@ -71,7 +119,10 @@ select wb.id, when wb.FIELDHTMLTYPE = '5' then '选择框' else '附件上传' end) fieldhtmltype from workflow_billfield wb - left join htmllabelindex ht on wb.fieldlabel = ht.id go + left join htmllabelindex ht on wb.fieldlabel = ht.id +union all +select * +from cus_workflow_base_field_assist go -- 建模表信息视图 if exists (select * from sysobjects where name = 'mode_bill_info_view') @@ -84,6 +135,29 @@ from workflow_bill bill where bill.id < 0 and bill.tablename like 'uf%' go +-- 流程建模表信息 +if exists (select * from sysobjects where name = 'workflow_mode_table_view') +drop view workflow_field_table_view + go +CREATE VIEW workflow_mode_table_view +AS +select bill.ID id, + bill.TABLENAME tablename, + base.WORKFLOWNAME indexdesc, + 'workflow' tabletype +from ( + workflow_bill bill join workflow_base base on ((base.FORMID = bill.ID)) + ) +union all +select bill.ID id, + bill.TABLENAME tablename, + hti.INDEXDESC indexdesc, + 'mode' tabletype +from ( + workflow_bill bill left join htmllabelindex hti on ((hti.ID = bill.NAMELABEL)) + ) +where ((bill.ID < 0) and (bill.TABLENAME like 'uf%')) go + -- 流程节点信息视图 if exists (select * from sysobjects where name = 'workflow_node_info_view') drop view workflow_node_info_view