From 21aa5f19e1a494998a66ba8fdd00571c938ce485 Mon Sep 17 00:00:00 2001 From: liuliang <401809302@qq.com> Date: Mon, 7 Apr 2025 10:17:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EmployeeInformationController.java | 33 +- .../service/EmployeeInformationService.java | 18 +- .../impl/EmployeeInformationServiceImpl.java | 319 ++++++++++++++---- 3 files changed, 289 insertions(+), 81 deletions(-) diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java index 81c5a92..521bbcc 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java @@ -2,6 +2,7 @@ package com.weaver.seconddev.jcl.organization.controller; import com.weaver.common.authority.annotation.WeaPermission; +import com.weaver.common.base.entity.result.WeaResult; import com.weaver.seconddev.jcl.common.web.EmployeeCommonController; import com.weaver.seconddev.jcl.organization.entity.Employee; import com.weaver.seconddev.jcl.organization.entity.PendingEmployee; @@ -77,16 +78,36 @@ public class EmployeeInformationController extends EmployeeCommonController { return actionMap; } /** - * 更新待入职员工共信息 + * 初始化同步字段 * @return */ @WeaPermission(publicPermission = true) - @Produces(MediaType.APPLICATION_JSON) @GetMapping("/synchronousField") - public Map synchronousField(){ + @ResponseBody + public WeaResult> synchronousField(){ Map actionMap = new HashMap<>(); - employeeInformationService.synchronousField(this.getCurrentUser()); + List errorMessage = employeeInformationService.synchronousField(this.getCurrentUser()); + if (errorMessage.size() > 0){ + return WeaResult.fail(errorMessage.toString(),true); + }else { + return WeaResult.success(actionMap); + } + } - return actionMap; + /** + * 将员工信息表同步给人力资源各个表 + * @return + */ + @WeaPermission(publicPermission = true) + @GetMapping("/synchronousFieldByEmployee") + @ResponseBody + public WeaResult> synchronousFieldByEmployee(){ + Map actionMap = new HashMap<>(); + List errorMessage = employeeInformationService.synchronousFieldByEmployee(this.getCurrentUser()); + if (errorMessage.size() > 0){ + return WeaResult.fail(errorMessage.toString(),true); + }else { + return WeaResult.success(actionMap); + } } -} +} \ No newline at end of file diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java index 47d19cd..f44fda4 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java @@ -10,13 +10,29 @@ import java.util.Map; public interface EmployeeInformationService { + /** + * 获得员工信息 + * @param employee + * @return + */ List> getInformation(Employee employee); + /** + * 获得待入职员工信息 + * @param employee + * @return + */ List> getPendingEmployment(Employee employee); void updatePendingEmploy(PendingEmployee pendingEmployee); - void synchronousField(SimpleEmployee employee); + /** + * 初始化同步 + * @param employee + */ + List synchronousField(SimpleEmployee employee); + + List synchronousFieldByEmployee(SimpleEmployee employee); /** * 获得字段信息 diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java index f2d3657..ca24f7e 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java @@ -105,7 +105,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic @Override public List> getPendingEmployment(Employee employee) { - String sql = "select * from uf_jcl_rzgl where delete_type<>'0' and ("; + String sql = "select * from uf_jcl_rzgl where delete_type ='0' and ("; List paramList = Lists.newArrayList(); if (employee.getMobile() != null && !"".equals(employee.getMobile())){ @@ -149,13 +149,19 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic } @Override - public void synchronousField(SimpleEmployee employee) { + public List synchronousField(SimpleEmployee employee) { String sql = "select form_id from form_table where table_name=? and delete_type='0'"; List paramList = Lists.newArrayList(); paramList.add(Constants.EMPLOYEE_INFORMATION); String employee_form_id = CommonUtils.null2String(databaseUtils.getSqlList(sql,paramList).get(0).get("form_id")); + + sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo'"; + List> personFormList = databaseUtils.getSqlList(sql); + Map personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString())); //基本信息自定义字段表 - String personCustomfieldFormid="1088177870727446575"; + String personCustomfieldFormid=personFormMap.get("hrm"); + //人力资源-个人信息自定义字段 + String personInfCustomFormid=personFormMap.get("hrm"); List formIdParamList = Lists.newArrayList(); @@ -164,18 +170,11 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic List> fieldGroupList = databaseUtils.getSqlList(sql,formIdParamList); Map fieldGroup = fieldGroupList.stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString())); formIdParamList.add(personCustomfieldFormid); -// sql = "select * from form_field where form_id in ("+String.join(",",formIdParamList)+") and delete_type='0'"; -// List> fieldList = databaseUtils.getSqlList(sql,formIdParamList); -// Map>> fieldGroupMapping = fieldList.stream().collect(Collectors.groupingBy(e->e.get("form_id").toString())); /** * 员工信息表所有字段 */ - FieldManageParam ownEntity = new FieldManageParam(); - ownEntity.setFormId(Long.valueOf(employee_form_id)); - ownEntity.setModule(ModuleSource.ebuilderform); - ownEntity.setNeedDataCount(true); - ownEntity.setNeedPanelField(true); + FieldManageParam ownEntity = getFieldManageParam(employee_form_id,ModuleSource.ebuilderform); List> employeeFieldList = getFieldList(ownEntity,employee); //员工信息主表-基本信息字段 List> mainFormBasicFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.BASIC_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList()); @@ -187,39 +186,33 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic /** * 人力资源-基本信息自定义字段 */ - FieldManageParam personCustomEntity = new FieldManageParam(); - personCustomEntity.setFormId(Long.valueOf(personCustomfieldFormid)); - personCustomEntity.setModule(ModuleSource.hrm); - personCustomEntity.setNeedDataCount(true); - personCustomEntity.setNeedPanelField(true); + FieldManageParam personCustomEntity = getFieldManageParam(personCustomfieldFormid,ModuleSource.hrm); + List> personCustomFieldList = getFieldList(personCustomEntity,employee); List> customFieldList = personCustomFieldList.stream().filter(e->!e.get("componentKey").equals("BaseField")).collect(Collectors.toList()); + //组装批量保存信息 + packageBatchSaveParam(personCustomFieldList,mainFormBasicFieldList,"-1"); + + /** + * 人力资源-个人信息自定义字段 + */ + FieldManageParam personInfCustomEntity = getFieldManageParam(personInfCustomFormid,ModuleSource.hruserinfo); + List> personInfCustomFieldList = getFieldList(personInfCustomEntity,employee); + List> infcustomFieldList = personInfCustomFieldList.stream().filter(e->!e.get("componentKey").equals("BaseField")).collect(Collectors.toList()); + //组装批量保存信息 + packageBatchSaveParam(personInfCustomFieldList,mainFormPersonFieldList,"-1"); + + + //组装员工信息 + packageBatchSaveParam(employeeFieldList,customFieldList,fieldGroup.get(Constants.BASIC_INFORMATION)); + packageBatchSaveParam(employeeFieldList,infcustomFieldList,fieldGroup.get(Constants.PERSONAL_INFORMATION)); + - for (Map customField:customFieldList){ - List> list = mainFormBasicFieldList.stream().filter(e->e.get("dataKey").equals(customField.get("dataKey"))).collect(Collectors.toList()); - if (list.size() == 0){ - customField.put("formId",employeeFieldList.get(0).get("formId")); - customField.put("formTableId",employeeFieldList.get(0).get("formTableId")); - customField.put("groupId",fieldGroup.get(Constants.BASIC_INFORMATION)); - customField.put("fieldId",idGeneratorService.generatorIds(1)[0]); - employeeFieldList.add(customField); - } - } - for (Map formBasicField:mainFormBasicFieldList){ - List> list = customFieldList.stream().filter(e->e.get("dataKey").equals(formBasicField.get("dataKey"))).collect(Collectors.toList()); - if (list.size() == 0){ - formBasicField.put("formId",personCustomFieldList.get(0).get("formId")); - formBasicField.put("formTableId",personCustomFieldList.get(0).get("formTableId")); - formBasicField.put("groupId","-1"); - formBasicField.put("fieldId",idGeneratorService.generatorIds(1)[0]); - personCustomFieldList.add(formBasicField); - } - } - Gson gson = new Gson(); log.error("employeeFieldList : [{}]",employeeFieldList); log.error("personCustomFieldList : [{}]",personCustomFieldList); + log.error("personInfCustomFieldList : [{}]",personInfCustomFieldList); /** * 批量保存 @@ -227,49 +220,108 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic //员工信息表 sql = "select b.id formtableid,a.* from sub_form a left join form_table b on a.id=b.form_id where a.form_id=?"; List> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(employee_form_id)); - FormFieldManageParam saveEmployeeEntity = new FormFieldManageParam(); - saveEmployeeEntity.setFormId(Long.valueOf(employee_form_id)); - saveEmployeeEntity.setModule(ModuleSource.ebuilderform); - saveEmployeeEntity.setJsonObjList(getJsonObjList(employeeFieldList)); - List forms = Lists.newArrayList(); - for (Map map:dataList){ - FormTableDto formTableDto = new FormTableDto(); - formTableDto.setDataCount(1); - formTableDto.setDataKey(map.get("data_key").toString()); - if (map.get("delete_type").equals("0")){ - formTableDto.setDelete(false); - formTableDto.setDeleteType(false); - }else { - formTableDto.setDelete(true); - formTableDto.setDeleteType(true); - } - formTableDto.setDescribe(map.get("describe").toString()); - formTableDto.setEditTable(true); - formTableDto.setFormTableId(Long.valueOf(map.get("formtableid").toString())); - formTableDto.setId(Long.valueOf(map.get("id").toString())); - formTableDto.setFormId(Long.valueOf(map.get("id").toString())); - formTableDto.setName(CommonUtils.null2String(map.get("title"))); - formTableDto.setTableName(map.get("data_key").toString()); - formTableDto.setTableType(FormTableType.MAIN); - formTableDto.setOrder(CommonUtils.null2String(map.get("show_order"))); - forms.add(formTableDto); + List errorMessage = Lists.newArrayList(); + WeaResult> result = batchSaveInformation(employee_form_id,employeeFieldList,dataList,ModuleSource.ebuilderform,null,null); + if (result.getCode() != 200){ + errorMessage.add(result.getMsg()); } - saveEmployeeEntity.setForms(forms); - WeaResult>result = batchSaveFormField(saveEmployeeEntity); - - log.error("save saveEmployeeEntity : [{}]",gson.toJson(result)); //保存人力资源-基本信息 - FormFieldManageParam savePersonCustomEntiy = new FormFieldManageParam(); - savePersonCustomEntiy.setFormId(Long.valueOf(personCustomfieldFormid)); - savePersonCustomEntiy.setModule(ModuleSource.hrm); - savePersonCustomEntiy.setJsonObjList(getJsonObjList(personCustomFieldList)); Map customParam = Maps.newHashMap(); customParam.put("formId",personCustomfieldFormid); - savePersonCustomEntiy.setCustomParam(customParam); - WeaResult> result2 = batchSaveFormField(savePersonCustomEntiy); - log.error("save PersonCustom : [{}]",gson.toJson(result2)); + WeaResult> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,null); + if (result2.getCode() != 200){ + errorMessage.add(result2.getMsg()); + } + //保存人力资源-个人信息 + Map customParam2 = Maps.newHashMap(); + customParam2.put("apiModule","hr"); + WeaResult> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,null); + if (result3.getCode() != 200){ + errorMessage.add(result3.getMsg()); + } + return errorMessage; + } + + + @Override + public List synchronousFieldByEmployee(SimpleEmployee employee) { + String sql = "select form_id from form_table where table_name=? and delete_type='0'"; + List paramList = Lists.newArrayList(); + paramList.add(Constants.EMPLOYEE_INFORMATION); + String employee_form_id = CommonUtils.null2String(databaseUtils.getSqlList(sql,paramList).get(0).get("form_id")); + + sql = "select id,module from FORM where (module='hrm' and ownership='personal') or module='hruserinfo'"; + List> personFormList = databaseUtils.getSqlList(sql); + Map personFormMap = personFormList.stream().collect(Collectors.toMap(e->e.get("module").toString(),e->e.get("id").toString())); + //基本信息自定义字段表 + String personCustomfieldFormid=personFormMap.get("hrm"); + //人力资源-个人信息自定义字段 + String personInfCustomFormid=personFormMap.get("hrm"); + + + List formIdParamList = Lists.newArrayList(); + formIdParamList.add(employee_form_id); + sql = "select id,group_name from form_field_group where form_id=? and delete_type='0'"; + List> fieldGroupList = databaseUtils.getSqlList(sql,formIdParamList); + Map fieldGroup = fieldGroupList.stream().collect(Collectors.toMap(e->e.get("group_name").toString(),e->e.get("id").toString())); + formIdParamList.add(personCustomfieldFormid); + + /** + * 员工信息表所有字段 + */ + FieldManageParam ownEntity = getFieldManageParam(employee_form_id,ModuleSource.ebuilderform); + List> employeeFieldList = getFieldList(ownEntity,employee); + //员工信息主表-基本信息字段 + List> mainFormBasicFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.BASIC_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList()); + //员工信息主表-账户信息字段 + List> mainFormAccountFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.ACCOUNT_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList()); + //员工信息主表-个人信息字段 + List> mainFormPersonFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.PERSONAL_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList()); + + /** + * 人力资源-基本信息自定义字段 + */ + FieldManageParam personCustomEntity = getFieldManageParam(personCustomfieldFormid,ModuleSource.hrm); + + List> personCustomFieldList = getFieldList(personCustomEntity,employee); + //组装批量保存信息 + List personCustomids = packageBatchSaveParamHaveDelete(personCustomFieldList,mainFormBasicFieldList,"-1"); + + /** + * 人力资源-个人信息自定义字段 + */ + FieldManageParam personInfCustomEntity = getFieldManageParam(personInfCustomFormid,ModuleSource.hruserinfo); + List> personInfCustomFieldList = getFieldList(personInfCustomEntity,employee); + //组装批量保存信息 + List personInfCustomIds = packageBatchSaveParamHaveDelete(personInfCustomFieldList,mainFormPersonFieldList,"-1"); + + + log.error("personCustomFieldList : [{}]",personCustomFieldList); + log.error("personInfCustomFieldList : [{}]",personInfCustomFieldList); + + /** + * 批量保存 + */ + List errorMessage = Lists.newArrayList(); + + + //保存人力资源-基本信息 + Map customParam = Maps.newHashMap(); + customParam.put("formId",personCustomfieldFormid); + WeaResult> result2 = batchSaveInformation(personCustomfieldFormid,personCustomFieldList,null,ModuleSource.hrm,customParam,personCustomids); + if (result2.getCode() != 200){ + errorMessage.add(result2.getMsg()); + } + //保存人力资源-个人信息 + Map customParam2 = Maps.newHashMap(); + customParam2.put("apiModule","hr"); + WeaResult> result3 = batchSaveInformation(personInfCustomFormid,personInfCustomFieldList,null,ModuleSource.hruserinfo,customParam2,personInfCustomIds); + if (result3.getCode() != 200){ + errorMessage.add(result3.getMsg()); + } + return errorMessage; } @Override @@ -283,6 +335,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic return (List>)resultMap.get("data"); } + /** * 批量保存 * @param entity @@ -300,4 +353,122 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic } return josnObjList; } + + public FieldManageParam getFieldManageParam(String formid,ModuleSource moduleSource){ + FieldManageParam entity = new FieldManageParam(); + entity.setFormId(Long.valueOf(formid)); + entity.setModule(moduleSource); + entity.setNeedDataCount(true); + entity.setNeedPanelField(true); + return entity; + } + + /** + * 组装批量保存参数 + * @param packageList + * @param conditionList + * @param groupId + */ + public void packageBatchSaveParam(List> packageList,List> conditionList,String groupId){ + for (Map customField:conditionList){ + List> list = packageList.stream().filter(e->e.get("dataKey").equals(customField.get("dataKey"))).collect(Collectors.toList()); + if (list.size() == 0){ + Map map = Maps.newHashMap(); + map.putAll(customField); + map.put("formId",packageList.get(0).get("formId")); + map.put("formTableId",packageList.get(0).get("formTableId")); + map.put("groupId",groupId); + map.put("fieldId",idGeneratorService.generatorIds(1)[0]); + if (map.get("options") != null && ((List>)map.get("options")).size() >0){ + List> options = (List>)map.get("options"); + for (Map option :options){ + option.put("selectionId",""); + } + } + packageList.add(map); + } + } + } + /** + * 组装批量保存参数 + * @param packageList + * @param conditionList + * @param groupId + */ + public List packageBatchSaveParamHaveDelete(List> packageList,List> conditionList,String groupId){ + for (Map customField:conditionList){ + List> list = packageList.stream().filter(e->e.get("dataKey").equals(customField.get("dataKey"))).collect(Collectors.toList()); + if (list.size() == 0){ + Map map = Maps.newHashMap(); + map.putAll(customField); + map.put("formId",packageList.get(0).get("formId")); + map.put("formTableId",packageList.get(0).get("formTableId")); + map.put("groupId",groupId); + map.put("fieldId",idGeneratorService.generatorIds(1)[0]); + if (map.get("options") != null && ((List>)map.get("options")).size() >0){ + List> options = (List>)map.get("options"); + for (Map option :options){ + option.put("selectionId",""); + } + } + packageList.add(map); + } + } + List ids = Lists.newArrayList(); + for (int i=0;i packageMap = packageList.get(i); + List> list = conditionList.stream().filter(e->e.get("dataKey").equals(packageMap.get("dataKey"))).collect(Collectors.toList()); + if (list.size() == 0){ + ids.add(Long.valueOf(packageMap.get("fieldId").toString())); + packageList.remove(i); + i--; + } + } + return ids; + } + + /** + * 批量保存 + * @return + */ + public WeaResult> batchSaveInformation(String formid,List> formFieldList,List> detailFormList,ModuleSource moduleSource,Map customParam,List ids){ + FormFieldManageParam saveEmployeeEntity = new FormFieldManageParam(); + saveEmployeeEntity.setFormId(Long.valueOf(formid)); + saveEmployeeEntity.setModule(moduleSource); + saveEmployeeEntity.setJsonObjList(getJsonObjList(formFieldList)); + List forms = Lists.newArrayList(); + if (detailFormList != null){ + for (Map map:detailFormList){ + FormTableDto formTableDto = new FormTableDto(); + formTableDto.setDataCount(1); + formTableDto.setDataKey(map.get("data_key").toString()); + if (map.get("delete_type").equals("0")){ + formTableDto.setDelete(false); + formTableDto.setDeleteType(false); + }else { + formTableDto.setDelete(true); + formTableDto.setDeleteType(true); + } + formTableDto.setDescribe(map.get("describe").toString()); + formTableDto.setEditTable(true); + formTableDto.setFormTableId(Long.valueOf(map.get("formtableid").toString())); + formTableDto.setId(Long.valueOf(map.get("id").toString())); + formTableDto.setFormId(Long.valueOf(map.get("id").toString())); + formTableDto.setName(CommonUtils.null2String(map.get("title"))); + formTableDto.setTableName(map.get("data_key").toString()); + formTableDto.setTableType(FormTableType.MAIN); + formTableDto.setOrder(CommonUtils.null2String(map.get("show_order"))); + forms.add(formTableDto); + } + } + saveEmployeeEntity.setIds(ids); + saveEmployeeEntity.setForms(forms); + saveEmployeeEntity.setCustomParam(customParam); + WeaResult>result = batchSaveFormField(saveEmployeeEntity); + Gson gson = new Gson(); + log.error("batchSaveInformation result :[{}]",gson.toJson(result)); + return result; + } + + }