星瀚HR——人员附表集成原创
3人赞赏了该文章
1,024次浏览
未经作者许可,禁止转载编辑于2023年06月29日 19:06:42
前言:本文旨在指引二开如何封装入参
背景:上游系统通过中间表,往人员附表(比如教育经历表)同步数据
接口:统一调用【HRPIPersonGenericServiceHelper methodName: saveBatch】,此接口出入参文档不在社区公开提供,需联系星瀚HR标品开发团队。
新增
关键入参
id Long ORM.create().genLongId("hrpi实体元数据编码")方法获取 person Long 此员工的自然人ID employee Long 若附表为企业人附表为必填;否则不填 其他业务字段根据需求设置
以【教育经历】为例
// 新增推荐写法 List<Map<String, Object>> datas = new ArrayList(); Map<String, Object> entity = new HashMap(); HRBaseServiceHelper helper = new HRBaseServiceHelper("hrpi_pereduexp"); DynamicObject eduExp = helper.generateEmptyDynamicObject(); Long id = ORM.create().genLongId("hrpi_pereduexp"); eduExp.set("id", id); eduExp.set("person", 1484316452860248064L); // 此员工的自然人ID eduExp.set("ishighestdegree", 0); eduExp.set("admissiondate", HRDateTimeUtils.parseDate("2017-09-01")); eduExp.set("gradutiondate", HRDateTimeUtils.parseDate("2021-07-11")); eduExp.set("graduateschool", 1386846885406462976L); eduExp.set("education", 1030); // 组装参数调用人员通用接口 DynamicObjectCollection hisDyns = new DynamicObjectCollection(); hisDyns.add(eduExp); entity.put("hisDyns", hisDyns); datas.add(entity); Map<String, Object> paramMap = new HashMap(16); paramMap.put("data", datas); paramMap.put("caller", "initialize"); paramMap.put("mustAllSuccess", true); Long eventId = ORM.create().genLongId("hrpi_event"); paramMap.put(HRPIGenericConstants.PARAM_EVENTID, eventId); // 调用IHRPIPersonGenericService. saveBatch Map<String, Object> result = HRPIPersonGenericServiceHelper.saveBatch(paramMap);
修改
关键入参
id Long ORM.create().genLongId("hrpi实体元数据编码")方法获取 boid Long 从【id关系映射表】获取到已有数据的id person Long 此员工的自然人ID 以【教育经历】为例
// 修改推荐写法 List<Map<String, Object>> datas = new ArrayList(); Map<String, Object> entity = new HashMap(); HRBaseServiceHelper helper = new HRBaseServiceHelper("hrpi_pereduexp"); Long oldId = 1500588176912398336L; // 从【id关系映射表】获取到已有数据的id // 先从目标库查出数据 DynamicObject eduExp= helper.loadDynamicObject(new QFilter[]{new QFilter("id", QFilter.equals, oldId)}); Long id1 = ORM.create().genLongId("hrpi_pereduexp"); // 将load出的eduExp的字段复制到empty DynamicObject empty = helper.generateEmptyDynamicObject(); HRDynamicObjectUtils.copy(eduExp, empty); empty.set("id", id1); empty.set("person", 1484316452860248064L); // 此员工的自然人ID empty.set("boid", oldId ); // 设为已有数据ID empty.set("ishighestdegree", 0); empty.set("admissiondate", HRDateTimeUtils.parseDate("2017-09-01")); empty.set("gradutiondate", HRDateTimeUtils.parseDate("2021-07-11")); empty.set("graduateschool", 1386846885406462976L); empty.set("education", 1030); // 组装参数调用人员通用接口 DynamicObjectCollection hisDyns = new DynamicObjectCollection(); hisDyns.add(empty); entity.put("hisDyns", hisDyns); datas.add(entity); Map<String, Object> paramMap = new HashMap(16); paramMap.put("data", datas); paramMap.put("caller", "initialize"); paramMap.put("mustAllSuccess", true); Long eventId = ORM.create().genLongId("hrpi_event"); paramMap.put(HRPIGenericConstants.PARAM_EVENTID, eventId); // 调用IHRPIPersonGenericService. saveBatch Map<String, Object> result = HRPIPersonGenericServiceHelper.saveBatch(paramMap);
删除(慎用)
删除某个自然人下所有教育经历
Long personId = 1480526618027029504L; HRBaseServiceHelper helper = new HRBaseServiceHelper("hrpi_pereduexp"); //person_id为教育经历表上的自然人ID字段 helper.deleteByFilter(new QFilter[]{new QFilter("person_id", QFilter.in, Arrays.asList(personId))});
推荐阅读