集成设计器数据流程、流程设计器可以暴露接口触发

集成设计器数据流程暴露接口触发

需求:在集成设计器配置的连接器、数据流程链接到外部接口,需要可以有一个管理页面,统一管理这些集成配置。比如对接多个医院的挂号系统,希望可以配置好数据流程之后,能够在已经实现的开放接口上,动态的调用集成平台配置的数据流程。

连接器暴露接口触发

  1. 设计连接器资源配置模型。使用业务ID+接口唯一标识+连接器实现连接器资源和业务唯一。

    @Model.model(EipConnectorResourceSetting.MODEL_MODEL)
    @Model(displayName = "连接器资源配置", summary = "连接器资源配置")
    @Model.Advanced(unique = {"hospitalId, interfaceUnique"})
    public class EipConnectorResourceSetting extends IdModel {
    
    public static final String MODEL_MODEL = "hr.simple.EipConnectorResourceSetting";
    
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "医院", required = true)
    @Field.Relation(relationFields = {"hospitalId"}, referenceFields = {"id"})
    private Hospital hospital;
    
    @Field.Integer
    @Field(displayName = "医院ID", invisible = true)
    private Long hospitalId;
    
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.String
    @Field(displayName = "接口唯一标识", required = true)
    private String interfaceUnique;
    
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.many2one
    @Field(displayName = "连接器", required = true)
    @Field.Relation(relationFields = {"connectorId"}, referenceFields = {"id"})
    private EipConnector connector;
    
    @Field.Integer
    @Field(displayName = "连接器ID", invisible = true)
    private Long connectorId;
    
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.many2one
    @Field(displayName = "连接器接口", required = true)
    @Field.Relation(relationFields = {"integrationInterfaceId"}, referenceFields = {"id"}, domain = "connectorId==${activeRecord.connector.id}")
    private EipConnectorResource connectorResource;
    
    @Field.Integer
    @Field(displayName = "连接器接口ID", invisible = true)
    private Long connectorResourceId;
    }
  2. 开放接口定义,文档参考:https://doc.oinone.top/oio4/9326.html
    外部平台调用开放接口,实现动态调用连接器资源

    @Model.model(HospitalSection.MODEL_MODEL)
    @Model(displayName = "医院科室", summary = "医院科室")
    public class HospitalSection extends IdModel {
    
    public static final String MODEL_MODEL = "net.example.HospitalSection";
    
    @Field(displayName = "科室Code", required = true)
    private String deptCode;
    
    @Field(displayName = "科室名称", required = true)
    private String deptName;
    
    @Field(displayName = "科室描述")
    private String deptDesc;
    }
    @Slf4j
    @Fun
    @Component
    public class TestOpenService {
    
    @Resource
    private TestCommonService testCommonService;
    
    @Function
    @Open(name = "获取科室", path = "test/gainSections")
    @Open.Advanced(httpMethod = "POST")
    public OpenEipResult<List<HospitalSection>> gainSections(IEipContext<SuperMap> context, ExtendedExchange exchange) {
        return new OpenEipResult<>(testCommonService.gainSections(context));
    }
    }
    @Slf4j
    @Component
    public class TestCommonService {
    
    @Resource
    private CustomWorkflowService customWorkflowService;
    
    /**
     * 获取科室
     *
     * @param context 请求上下文
     * @return 科室集合
     */
    public List<HospitalSection> gainSections(IEipContext<SuperMap> context) {
        EipResult<SuperMap> gainSections = executeEipConnector(context, "gainSections");
        if (gainSections.getSuccess()) {
            if (gainSections.getContext().getInterfaceContext().get("DepartmentList")!=null) {
                return JSON.parseArray(JSON.toJSONString(gainSections.getContext().getInterfaceContext().get("DepartmentList")),
                        HospitalSection.class);
    
            }
        }
        String errorCode = gainSections.getErrorCode();
        String errorMessage = gainSections.getErrorMessage();
        // Object result = gainSections.getResult();
        return new ArrayList<>();
    }
        /**
     * 根据请求参数中医院id和参数key-value、接口标识获取连接器
     *
     * @param context         请求上下文
     * @param interfaceUnique 接口标识
     * @return 连接器
     */
    private EipResult<SuperMap> executeEipConnector(IEipContext<SuperMap> context, String interfaceUnique) {
        String hospitalId = Optional.ofNullable(String.valueOf(context.getInterfaceContext().getIteration("hospitalId"))).orElse("");
        String parameterValue = Optional.ofNullable(String.valueOf(context.getInterfaceContext().getIteration("parameterValue"))).orElse("");
        //step1. 获取连接器模型
        EipConnectorResourceSetting interfaceSetting = new EipConnectorResourceSetting()
                .setHospitalId(Long.valueOf(hospitalId)).setInterfaceUnique(interfaceUnique).queryOne();
        if (interfaceSetting == null) {
            throw PamirsException.construct(ExpEnumerate.SYSTEM_ERROR).appendMsg("连接器模型未找到").errThrow();
        }
        //step2. 获取连接器接口
        interfaceSetting.fieldQuery(EipConnectorResourceSetting::getConnectorResource);
        EipConnectorResource connectorResource = interfaceSetting.getConnectorResource();
        if (connectorResource == null) {
            throw PamirsException.construct(ExpEnumerate.SYSTEM_ERROR).appendMsg("连接器接口未找到").errThrow();
        }
        //3. 执行连接器获取结果
        Map<String, Object> params = new HashMap<>();
        params.put("wxValue1", parameterValue);
        return EipExecutor.newInstance().call(connectorResource.getInterfaceName(), params);
    }

数据流程暴露接口触发

  1. 设计数据流程配置模型。使用业务ID+接口唯一标识+连接器实现数据流程配置和业务唯一。

    @Model.model(EipOpenDataflowSetting.MODEL_MODEL)
    @Model(displayName = "数据流程配置", summary = "数据流程配置")
    @Model.Advanced(unique = {"hospitalId,interfaceUnique"})
    public class EipOpenDataflowSetting extends IdModel {
    
    public static final String MODEL_MODEL = "hr.simple.EipOpenDataflowSetting";
    
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "医院", required = true)
    @Field.Relation(relationFields = {"hospitalId"}, referenceFields = {"id"})
    private Hospital hospital;
    
    @Field.Integer
    @Field(displayName = "医院ID", invisible = true)
    private Long hospitalId;
    
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.String
    @Field(displayName = "接口唯一标识", required = true)
    private String interfaceUnique;
    
    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.many2one
    @Field(displayName = "数据流程", required = true)
    @Field.Relation(relationFields = {"dataflowId"}, referenceFields = {"id"})
    private DataflowDesigner dataflow;
    
    @Field.Integer
    @Field(displayName = "数据流程编码", invisible = true)
    private Long dataflowId;
    
    @Field.String
    @Field.Related(related = {"dataflow", "code"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "数据流程编码", store = NullableBoolEnum.TRUE)
    private String dataflowCode;
    }
  2. 开放接口定义。

    @Fun(RegisterOpenService.FUN_NAMESPACE)
    public interface RegisterOpenService {
    
    String FUN_NAMESPACE = "net.example.RegisterService";
    
    @Function
    RegisterOrder queryById(Long hospitalId, Long memberId);
    }
    @Slf4j
    @Fun(RegisterOpenService.FUN_NAMESPACE)
    @Component
    public class RegisterOpenServiceImpl implements RegisterOpenService {
    
    @Autowired
    private CustomWorkflowService customWorkflowService;
    
    /**
     * 开放接口:把自己的开放出去供外部调用(如:小程序调用)
     *
     * 文档参考:https://doc.oinone.top/oio4/9326.html
     *
     * 1、接口访问URL地址:http://127.0.0.1:8195/openapi/pamirs/register/queryById 端口根据yml配置进行修改
     * 2、参数默认是map格式,构造为IEipContext对象
     */
    @Function
    @Open(name = "根据ID查询挂号流水", path = "register/queryById")
    @Open.Advanced(
            httpMethod = "GET"
    )
    public OpenEipResult<RegisterOrder> queryById4Open(IEipContext<SuperMap> context, ExtendedExchange exchange) {
        String memberId = Optional.ofNullable(String.valueOf(context.getInterfaceContext().getIteration("id"))).orElse("0");
        String hospitalId = Optional.ofNullable(String.valueOf(context.getInterfaceContext().getIteration("hospitalId"))).orElse("0");
        // 开发接口的内部具体实现
        RegisterOrder register = queryById(Long.valueOf(hospitalId), Long.valueOf(memberId));
        if (register!=null) {
            return new OpenEipResult<>(register);
        } else {
            throw PamirsException.construct(EipExpEnumerate.SYSTEM_ERROR).appendMsg("根据ID "+ memberId +"查询挂号流水").errThrow();
        }
    }
    
    @Override
    @Function
    public RegisterOrder queryById(Long hospitalId, Long memberId) {
        // step1、业务前置逻辑、参数校验等
        // step2、构造请求数据、或者通过BD获取数据(这里先进行Mock)
        RegisterOrder register = new RegisterOrder();
        register.setHospitalId("719331903102009889");
        register.setSectionId("1");
        register.setDoctorId("1");
        register.setSourceId("1");
        register.setPatienterName("zhangsan");
        register.setPatienterIdCard("123444");
        // 配置表,医院 + 接口功能 == >> 流程编码。   ****** 实际项目这些基础数据需要缓存,如果Caffeine/Redis*********
        EipOpenDataflowSetting dataflowSetting = new EipOpenDataflowSetting().setHospitalId(hospitalId).setInterfaceUnique("theWeather").queryOne();
        if (dataflowSetting !=  null) {
            // step3、调用数据流程
            WorkflowDefinition workflowDefinition = customWorkflowService.queryWorkflowDefinition(dataflowSetting.getDataflowCode());
            if (workflowDefinition != null) {
                // 分支1:调用数据流程
                Map<String, Object> result = customWorkflowService.startWorkflow(workflowDefinition, register);
                log.info("调用数据流程返回:" + result);
    
                // 根据返回处理业务逻辑
            }
        } else {
            // 分支2:异常处理,或者没有数据流程实现执行默认逻辑
        }
    
        // Step4 业务后置逻辑,数据操作、其他service的调用之类
        return register;
    }
    }
    @Slf4j
    @Component
    public class CustomWorkflowService {
    
    public WorkflowDefinition queryWorkflowDefinition(String workflowCode) {
        return new WorkflowDefinition().queryOneByWrapper(
                Pops.<WorkflowDefinition>lambdaQuery()
                        .from(WorkflowDefinition.MODEL_MODEL)
                        .eq(WorkflowDefinition::getWorkflowCode, workflowCode)
                        .eq(WorkflowDefinition::getActive, 1)
        );
    }
    
    /**
     * 触发⼯作流实例
     */
    public Map<String, Object> startWorkflow(WorkflowDefinition workflowDefinition, IdModel modelData) {
        Map<String, Object> result = new HashMap<>();
        if (null == workflowDefinition) {
            // 流程没有运⾏实例
            return result;
        }
        String model = Models.api().getModel(modelData);
        //⼯作流上下⽂
        WorkflowDataContext wdc = new WorkflowDataContext();
        wdc.setDataType(WorkflowVariationTypeEnum.ADD);
        wdc.setModel(model);
        wdc.setWorkflowDefinitionDefinition(workflowDefinition.parseContent());
        wdc.setWorkflowDefinition(workflowDefinition);
        wdc.setWorkflowDefinitionId(workflowDefinition.getId());
        IdModel copyData = KryoUtils.get().copy(modelData);
        // ⼿动触发创建的动作流,将操作⼈设置为当前用户,作为流程的发起⼈
        copyData.setCreateUid(PamirsSession.getUserId());
        copyData.setWriteUid(PamirsSession.getUserId());
        String jsonData = JsonUtils.toJSONString(copyData.get_d());
        //触发工作流 新增时触发-onCreateManual 更新时触发-onUpdateManual
        Fun.run(WorkflowModelTriggerFunction.FUN_NAMESPACE, "onCreateManualSync", wdc, "1", jsonData);
    
        // 处理返回结果
        Long workflowInstanceId = (Long) wdc.getDataMap().get(WorkflowConstant.WORKFLOW_INSTANCE_ID);
        if (workflowInstanceId !=null) {
            WorkflowInstance workflowInstance = new WorkflowInstance().setId(workflowInstanceId).queryById();
            WorkflowContext workflowContext = workflowInstance.fetchWorkflowContext();
            result = (HashMap)workflowContext.get(ParamNode.PARAM_PREFIX);
        }
    
        return result;
    }
    
    public Map<String,Object> startCreatOrderWorkflow(WorkflowDefinition workflowDefinition, IdModel modelData){
        Map<String, Object> result = new HashMap<>();
        if (null == workflowDefinition) {
            // 流程没有运⾏实例
            return result;
        }
        String model = Models.api().getModel(modelData);
        //⼯作流上下⽂
        WorkflowDataContext wdc = new WorkflowDataContext();
        wdc.setDataType(WorkflowVariationTypeEnum.ADD);
        wdc.setModel(model);
        wdc.setWorkflowDefinitionDefinition(workflowDefinition.parseContent());
        wdc.setWorkflowDefinition(workflowDefinition);
        wdc.setWorkflowDefinitionId(workflowDefinition.getId());
        IdModel copyData = KryoUtils.get().copy(modelData);
        // ⼿动触发创建的动作流,将操作⼈设置为当前用户,作为流程的发起⼈
        copyData.setCreateUid(PamirsSession.getUserId());
        copyData.setWriteUid(PamirsSession.getUserId());
        String jsonData = JsonUtils.toJSONString(copyData.get_d());
        //触发⼯作流 新增时触发-onCreateManual 更新时触发-onUpdateManual
        Fun.run(WorkflowModelTriggerFunction.FUN_NAMESPACE, "onCreateManualSync", wdc, "1", jsonData);
    
        // 处理返回结果
        Long workflowInstanceId = (Long) wdc.getDataMap().get(WorkflowConstant.WORKFLOW_INSTANCE_ID);
        if (workflowInstanceId !=null) {
            WorkflowInstance workflowInstance = new WorkflowInstance().setId(workflowInstanceId).queryById();
            WorkflowContext workflowContext = workflowInstance.fetchWorkflowContext();
            result = (HashMap)workflowContext.get(ParamNode.PARAM_PREFIX);
        }
    
        return result;
    }
    }

Oinone社区 作者:yexiu原创文章,如若转载,请注明出处:https://doc.oinone.top/dai-ma-shi-jian/20972.html

访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验

(0)
yexiu的头像yexiu数式员工
上一篇 2025年4月17日 pm8:52
下一篇 2025年4月21日 pm3:53

相关推荐

  • 同一行操作跳转到不同的视图(动态表单)

    背景 实际项目中,存在这样的场景:同一列表中的数据是泛化的数据集合,即数据来源于不同的模型;行操作需要根据来源去向不同的目标页。 如下图,「提报」操作需根据「报表类型」去向不同的表单。 并支持目标弹窗标题和弹框大小的配置。 解决思路 每行记录需要跳转到不同的模型不同视图,增加一个配置页面用于维护源模型和目标模型的调整动作关系; 返回数据的时候,同时返回自定义的动作。 前端自定义实现如上面图例中的「填报」,从返回数据中获取ViewAction并做对应的跳转。 具体步骤 [后端] 建立模型和视图的关系设置的模型 1、创建 模型和视图的关系设置的模型,用于配置列表模型和各记录即目标模型的视图关系 import pro.shushi.oinone.examples.simple.api.proxy.system.SimpleModel; import pro.shushi.oinone.examples.simple.api.proxy.system.SimpleModule; import pro.shushi.pamirs.boot.base.enmu.ActionTargetEnum; import pro.shushi.pamirs.boot.base.model.View; import pro.shushi.pamirs.meta.annotation.Field; import pro.shushi.pamirs.meta.annotation.Model; import pro.shushi.pamirs.meta.base.IdModel; import pro.shushi.pamirs.meta.enmu.ViewTypeEnum; /** * 模型和视图的关系设置 * ModelRelViewSetting */ @Model.model(ModelRelViewSetting.MODEL_MODEL) @Model(displayName = "模型和视图的关系设置", summary = "模型和视图的关系设置") @Model.Advanced(unique = {"oModel,model,target,viewType,viewName"}) public class ModelRelViewSetting extends IdModel { public static final String MODEL_MODEL = "examples.custom.ModelRelViewSetting"; @Field.many2one @Field(displayName = "模块") @Field.Relation(relationFields = {"module"}, referenceFields = {"module"}) private SimpleModule moduleDef; @Field.String @Field(displayName = "模块编码", invisible = true) private String module; @Field.many2one @Field(displayName = "源模型") @Field.Relation(relationFields = {"oModel"}, referenceFields = {"model"}) private SimpleModel originModel; @Field.String @Field(displayName = "源模型编码", invisible = true) private String oModel; @Field.many2one @Field(displayName = "目标模型") @Field.Relation(relationFields = {"model"}, referenceFields = {"model"}) private SimpleModel targetModel; @Field.String @Field(displayName = "目标模型编码", invisible = true) private String model; @Field.Enum @Field(displayName = "视图类型") private ViewTypeEnum viewType; @Field.Enum @Field(displayName = "打开方式", required = true) private ActionTargetEnum target; @Field.String @Field(displayName = "动作名称", invisible = true) private String name; @Field.many2one @Field.Relation(relationFields = {"model", "viewName"}, referenceFields = {"model", "name"}, domain = "systemSource=='UI'") @Field(displayName = "绑定页面", summary = "绑定页面") private View view; @Field.String @Field(displayName = "视图/页面", invisible…

    2025年2月19日
    42900
  • 复杂Excel模版定义

    模版示例: Demo Excel样例 代码示例: @Model.model(TestApply.MODEL_MODEL) @Model(displayName = "测试申请") public class TestApply extends IdModel { public static final String MODEL_MODEL = "top.TestApply"; @Field.String @Field(displayName = "发件人") private String addresser; @Field.String @Field(displayName = "委托单位") private String entrustedUnit; @Field.String @Field(displayName = "付款单位") private String payer; @Field.String @Field(displayName = "付款单位地址") private String paymentUnitAdd; } 模版: package pro.shushi.pamirs.top.core.temp; import org.springframework.stereotype.Component; import pro.shushi.pamirs.file.api.builder.SheetDefinitionBuilder; import pro.shushi.pamirs.file.api.builder.WorkbookDefinitionBuilder; import pro.shushi.pamirs.file.api.enmu.ExcelAnalysisTypeEnum; import pro.shushi.pamirs.file.api.enmu.ExcelDirectionEnum; import pro.shushi.pamirs.file.api.enmu.ExcelHorizontalAlignmentEnum; import pro.shushi.pamirs.file.api.model.ExcelWorkbookDefinition; import pro.shushi.pamirs.file.api.util.ExcelHelper; import pro.shushi.pamirs.file.api.util.ExcelTemplateInit; import pro.shushi.pamirs.top.api.model.TestApply; import java.util.Collections; import java.util.List; @Component public class DemoTemplate implements ExcelTemplateInit { public static final String TEMPLATE_NAME = "DemoTemplate"; @Override public List<ExcelWorkbookDefinition> generator() { WorkbookDefinitionBuilder builder = WorkbookDefinitionBuilder.newInstance(TestApply.MODEL_MODEL, TEMPLATE_NAME) .setDisplayName("测试Demo"); DemoTemplate.createSheet(builder); return Collections.singletonList(builder.build()); } private static void createSheet(WorkbookDefinitionBuilder builder) { SheetDefinitionBuilder sheetBuilder = builder.createSheet().setName("测试Demo"); buildBasicInfo(sheetBuilder); } private static void buildBasicInfo(SheetDefinitionBuilder builder) { //A1:D8:表示表头占的单元格数,范围必须大于实际表头行 BlockDefinitionBuilder mergeRange = builder.createBlock(TestApply.MODEL_MODEL, ExcelAnalysisTypeEnum.FIXED_HEADER, ExcelDirectionEnum.HORIZONTAL, "A1:D8") //预设行 .setPresetNumber(10) //合并哪几个单元格 .createMergeRange("A1:D1") .createMergeRange("A2:D2") .createMergeRange("A3:D3") .createMergeRange("A4:A6") .createMergeRange("B4:B6") .createMergeRange("C4:C6") .createMergeRange("D4:D5"); //createHeader创建行,createCell创建单元格,setField指定解析字段,setIsConfig指定为true标记该行是需要解析的值 mergeRange.createHeader().setStyleBuilder(ExcelHelper.createDefaultStyle()).setIsConfig(Boolean.TRUE) .createCell().setField("addresser").setStyleBuilder(ExcelHelper.createDefaultStyle().setWidth(6000)).and() .createCell().setField("entrustedUnit").and() .createCell().setField("payer").and() .createCell().setField("paymentUnitAdd").and() .and() .createHeader().setStyleBuilder(ExcelHelper.createDefaultStyle(typeface -> typeface.setBold(Boolean.TRUE)).setHorizontalAlignment(ExcelHorizontalAlignmentEnum.CENTER)) .createCell().setValue("Demo").and() .createCell().and() .createCell().and() .createCell().and() .and() //由于该行合并为一个单元格,所以其他可以不设置value .createHeader().setStyleBuilder(ExcelHelper.createDefaultStyle(typeface -> typeface.setBold(Boolean.TRUE)).setHorizontalAlignment(ExcelHorizontalAlignmentEnum.CENTER)) .createCell().setValue("生效金额").and() .createCell().and() .createCell().and() .createCell().and() .and() .createHeader().setStyleBuilder(ExcelHelper.createDefaultStyle(typeface -> typeface.setBold(Boolean.TRUE)).setHorizontalAlignment(ExcelHorizontalAlignmentEnum.RIGHT)) .createCell().setValue("金额单位:元").and() .createCell().and() .createCell().and() .createCell().and() .and() //easyExcel解析不了空行,所以这里写上值。由于上面使用createMergeRange把单元格合并了,并且D列有分割,这里填上每个单元格的值,把合并的单元格填为一样的。 .createHeader().setStyleBuilder(ExcelHelper.createDefaultStyle(typeface -> typeface.setBold(Boolean.TRUE)).setHorizontalAlignment(ExcelHorizontalAlignmentEnum.CENTER)) .createCell().setValue("发件人").and() .createCell().setValue("委托单位").and()…

    2024年11月18日
    1.8K00
  • 部分模型不动态修改表结构(由单独DDL处理)

    需求描述 实际项目中, 存在部分模型不动态修改表结构,由单独DDL脚本处理,常见的场景有: 已存在库和表中使用Oinone进行功能开发,此时对于已经存在的表对应的模型不允许改表结构 其他情况不希望动态改变表结构的情况 实现步骤 新建NODDL的基础模型 模型公共字段 公共字段说明:使用Oinone进行开发时,业务模型需继承基础IdModel(或者由IdModel衍生出的子类),这些基础模型有createDate(创建时间)、writeDate(更新时间)、createUid(创建人ID)和writeUid(更新人ID)等公共字段;实际表中公共字段可能与Oinone有所不同。 实现方式 方式1:公共属性字段用平台提供的createDate、writeDate、createUid和writeUid,通过指定column与表中的实际字段对应.【推荐】该方式,公共字段的处理可以继续使用平台的默认赋值处理方式; 方式2:继承平台的时候,把公共字段排除掉(配置unInheritedFields),然后自行加通用字段:排除字段:@Model.Advanced(type= ModelTypeEnum.ABSTRACT, ordering = "createAt DESC, id DESC", unInheritedFields = {"createUid","writeUid","createDate","writeDate"})【不推荐】该方式,公共字段的赋值逻辑需要自行处理,略显复杂; 实现方式举例 下面的示例以方式1举例;假设表的基础字段分别是:createAt、updateAt、createId和updateId 与平台的不同. 不自动DDL的抽象模型示例 import pro.shushi.pamirs.meta.annotation.Field; import pro.shushi.pamirs.meta.annotation.Model; import pro.shushi.pamirs.meta.base.IdModel; import pro.shushi.pamirs.meta.enmu.FieldStrategyEnum; import pro.shushi.pamirs.meta.enmu.ModelTypeEnum; import java.util.Date; /** * 假设表的基础字段分别是:createAt、updateAt、createId和updateId 与平台的不同 */ @Model.model(BaseNoDdlModel.MODEL_MODEL) @Model(displayName = "不自动DDL的抽象模型") @Model.Advanced(type= ModelTypeEnum.ABSTRACT, ordering = "createAt DESC, id DESC") public abstract class BaseNoDdlModel extends IdModel { public static final String MODEL_MODEL = "hr.std.BaseNoDdlModel"; // 如果原表的主键的列名不是ID的情况,这里可以定义column指定ID属性对应的列名 /** @Field.PrimaryKey @Field(displayName = "主键ID") @Field.Advanced(column = "XLH") private Long id; **/ // 下面这几个字段按实际项目中的情况来增加,包括字段名 @Field.Advanced(columnDefinition = "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP", column = "createAt", insertStrategy = FieldStrategyEnum.NEVER, updateStrategy = FieldStrategyEnum.NEVER, batchStrategy = FieldStrategyEnum.NEVER) @Field(displayName = "创建时间", priority = 200) private Date createDate; @Field.Advanced(columnDefinition = "DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", column = "updateAt", batchStrategy = FieldStrategyEnum.NEVER) @Field(displayName = "更新时间", priority = 210) private Date writeDate; @Field.Advanced(column = "createId") @Field(displayName = "创建人ID", priority = 220, invisible = true) private Long createUid; @Field.Advanced(column = "updateId") @Field(displayName = "更新人ID", priority = 230, invisible = true) private Long writeUid; } 不需动态DDL的业务模型,业务模型继承BaseNoDdlModel。 其他业务模型如果有相同的需求类似的做法 /** * 测试合同表 */ @Model.model(InspectionInfo.MODEL_MODEL) @Model(displayName = "合同", labelFields…

    2025年2月22日
    61000
  • 工作流:通过业务数据操作工作流程(催办、撤销等)

    一、抽象模型,需要操作流程的模型继承此模型 定义流程相关的一些信息在模型中;如果直接定义在存储模型中,下面这些字段都是显示的指定为非存储字段。更好的建议:1、如果有多个业务模型有这类需要,则可以把这些字段抽取到抽象模型中2、如果仅有一个业务模型需要,则可以放到代理模型中 /** * 定义流程相关的一些信息在模型中 */ @Model.model(DemoBaseAbstractModel.MODEL_MODEL) @Model(displayName = "抽象模型") @Model.Advanced(type= ModelTypeEnum.ABSTRACT) public abstract class DemoBaseAbstractModel extends IdModel { public static final String MODEL_MODEL = "hr.simple.DemoBaseAbstractModel"; // 流程相关 @Field.Integer @Field(displayName = "工作流用户任务ID", summary = "业务数据列表中审核流程使用", invisible = true, store = NullableBoolEnum.FALSE) private Long workflowUserTaskId; @Field.Integer @Field(displayName = "流程实例ID", summary = "业务数据列表中催办使用", invisible = true, store = NullableBoolEnum.FALSE) private Long instanceId; @Field.String @UxForm.FieldWidget(@UxWidget(invisible = "true")) @UxDetail.FieldWidget(@UxWidget(invisible = "true")) @Field(displayName = "当前流程节点", store = NullableBoolEnum.FALSE) private String currentFlowNode; @Field.Boolean @Field(displayName = "能否催办", invisible = true, defaultValue = "false", store = NullableBoolEnum.FALSE) private Boolean canUrge; // 审批状态控制申请单是否可以被发起流程、能否编辑等控制 @Field.Enum @Field(displayName = "审批状态", defaultValue = "NC") @UxForm.FieldWidget(@UxWidget(invisible = "true")) private ApprovalStatusEnum approvalStatus; } @Dict(dictionary = ApprovalStatusEnum.dictionary, displayName = "审批状态") public enum ApprovalStatusEnum implements IEnum<String> { NC("NC", "待提交", "待提交"), PENDING("PENDING", "已提交", "已提交,待审批"), APPROVED("APPROVED", "已批准", "已批准"), REJECTED("REJECTED", "已拒绝", "已拒绝"); public static final String dictionary = "land.enums.LandApprovalStatusEnum"; private final String value; private final String displayName; private final String help; ApprovalStatusEnum(String value, String displayName, String help) { this.value = value; this.displayName = displayName; this.help = help; } public String getValue() { return value; } public String getDisplayName() { return…

    2025年6月26日
    23600
  • 对字段进行加密存储

    需求: 模型字段上使用 pro.shushi.pamirs.user.api.crypto.annotation.EncryptField 注解模型动作上使用 pro.shushi.pamirs.user.api.crypto.annotation.NeedDecrypt 注解 示例: 对需要加密的字段添加@EncryptField注解 @Model.model(Student.MODEL_MODEL) @Model(displayName = "学生", summary = "学生") public class Student extends IdModel { public static final String MODEL_MODEL = "top.Student"; @Field(displayName = "学生名字") @Field.String private String studentName; @Field(displayName = "学生ID") @Field.Integer private Long studentId; @Field(displayName = "学生卡号") @Field.String @EncryptField private String studentCard; } 对函数添加@NeedDecrypt注解 @Action.Advanced(name = FunctionConstants.create, managed = true)//默认取的是方法名 @Action(displayName = "确定", summary = "添加", bindingType = ViewTypeEnum.FORM) @Function(name = FunctionConstants.create)//默认取的是方法名 @Function.fun(FunctionConstants.create)//默认取的是方法名 @NeedDecrypt public Student create(Student data) { String studentCard = data.getStudentCard(); if (studentCard != null) { //自定义加密方法 data.setStudentCard(StudentEncoder.encode(studentCard)); } return data.create(); }

    2024年10月10日
    79900

Leave a Reply

登录后才能评论