|
|
|
@ -2,21 +2,38 @@ package com.weaver.seconddev.jcl.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.weaver.common.base.entity.result.WeaResult;
|
|
|
|
|
import com.weaver.common.form.dto.form.FormTableDto;
|
|
|
|
|
import com.weaver.common.form.fieldmanage.service.FormFieldManageService;
|
|
|
|
|
import com.weaver.common.form.metadata.ModuleSource;
|
|
|
|
|
import com.weaver.common.form.param.FieldManageParam;
|
|
|
|
|
import com.weaver.common.form.physical.enums.FormTableType;
|
|
|
|
|
import com.weaver.common.form.service.IdGeneratorService;
|
|
|
|
|
import com.weaver.form.controller.FormBaseController;
|
|
|
|
|
import com.weaver.form.controller.manage.FormFieldManageController;
|
|
|
|
|
import com.weaver.form.entity.FormFieldManageParam;
|
|
|
|
|
import com.weaver.seconddev.jcl.common.service.CommonService;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.entity.Employee;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.entity.PendingEmployee;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.service.EmployeeInformationService;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.util.CommonUtils;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.util.Constants;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
|
|
|
|
|
import com.weaver.teams.domain.user.SimpleEmployee;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 员工信息管理
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class EmployeeInformationServiceImpl implements EmployeeInformationService {
|
|
|
|
|
|
|
|
|
@ -24,12 +41,15 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
private DatabaseUtils databaseUtils;
|
|
|
|
|
@Autowired
|
|
|
|
|
private CommonService commonService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IdGeneratorService idGeneratorService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private FormFieldManageController fieldManageController;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getInformation(Employee employee) {
|
|
|
|
|
|
|
|
|
|
String sql = "select * from uf_jcl_employee_information where (delete_type is null or delete_type=false) and (";
|
|
|
|
|
String sql = "select * from uf_jcl_employee_information where delete_type='0' and (";
|
|
|
|
|
List<String> paramList = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
if (employee.getMobile() != null && !"".equals(employee.getMobile())){
|
|
|
|
@ -56,7 +76,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
String ygzt = CommonUtils.null2String(userMap.get("personnel_status"));
|
|
|
|
|
if (ygzt.equals("5")){
|
|
|
|
|
//离职
|
|
|
|
|
sql = "select zhgzr,lzqbm from uf_jcl_lzxxjl where glyg=? and (delete_type is null or delete_type<>'1') ";
|
|
|
|
|
sql = "select zhgzr,lzqbm from uf_jcl_lzxxjl where glyg=? and delete_type='0' ";
|
|
|
|
|
List<Map<String, Object>> resignList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(userMap.get("id").toString()));
|
|
|
|
|
if (resignList.size() > 0){
|
|
|
|
|
userMap.put("zhgzr",resignList.get(0).get("zhgzr"));
|
|
|
|
@ -64,7 +84,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
ssbm = CommonUtils.null2String(resignList.get(0).get("lzqbm"));
|
|
|
|
|
}else if (ygzt.equals("6")){
|
|
|
|
|
//退休
|
|
|
|
|
sql = "select zhgzr,txqbm from uf_jcl_txxxjl where glyg=? and (delete_type is null or delete_type<>'1') ";
|
|
|
|
|
sql = "select zhgzr,txqbm from uf_jcl_txxxjl where glyg=? and delete_type='0' ";
|
|
|
|
|
List<Map<String, Object>> retireList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(userMap.get("id").toString()));
|
|
|
|
|
if (retireList.size() > 0){
|
|
|
|
|
userMap.put("zhgzr",retireList.get(0).get("zhgzr"));
|
|
|
|
@ -85,7 +105,7 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getPendingEmployment(Employee employee) {
|
|
|
|
|
String sql = "select * from uf_jcl_rzgl where (delete_type is null or delete_type<>'1') and (";
|
|
|
|
|
String sql = "select * from uf_jcl_rzgl where delete_type<>'0' and (";
|
|
|
|
|
List<String> paramList = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
if (employee.getMobile() != null && !"".equals(employee.getMobile())){
|
|
|
|
@ -127,4 +147,157 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|
|
|
|
param.put("condition",condition);
|
|
|
|
|
commonService.updateCommon(param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void synchronousField(SimpleEmployee employee) {
|
|
|
|
|
String sql = "select form_id from form_table where table_name=? and delete_type='0'";
|
|
|
|
|
List<String> paramList = Lists.newArrayList();
|
|
|
|
|
paramList.add(Constants.EMPLOYEE_INFORMATION);
|
|
|
|
|
String employee_form_id = CommonUtils.null2String(databaseUtils.getSqlList(sql,paramList).get(0).get("form_id"));
|
|
|
|
|
//基本信息自定义字段表
|
|
|
|
|
String personCustomfieldFormid="1088177870727446575";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> 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<Map<String, Object>> fieldGroupList = databaseUtils.getSqlList(sql,formIdParamList);
|
|
|
|
|
Map<String,String> 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<Map<String, Object>> fieldList = databaseUtils.getSqlList(sql,formIdParamList);
|
|
|
|
|
// Map<String,List<Map<String, Object>>> 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);
|
|
|
|
|
List<Map<Object, Object>> employeeFieldList = getFieldList(ownEntity,employee);
|
|
|
|
|
//员工信息主表-基本信息字段
|
|
|
|
|
List<Map<Object, Object>> mainFormBasicFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.BASIC_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList());
|
|
|
|
|
//员工信息主表-账户信息字段
|
|
|
|
|
List<Map<Object, Object>> mainFormAccountFieldList = employeeFieldList.stream().filter(e->fieldGroup.get(Constants.ACCOUNT_INFORMATION).equals(e.get("groupId")) && "".equals(CommonUtils.null2String(e.get("subFormId")))).collect(Collectors.toList());
|
|
|
|
|
//员工信息主表-个人信息字段
|
|
|
|
|
List<Map<Object, Object>> 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 = new FieldManageParam();
|
|
|
|
|
personCustomEntity.setFormId(Long.valueOf(personCustomfieldFormid));
|
|
|
|
|
personCustomEntity.setModule(ModuleSource.hrm);
|
|
|
|
|
personCustomEntity.setNeedDataCount(true);
|
|
|
|
|
personCustomEntity.setNeedPanelField(true);
|
|
|
|
|
|
|
|
|
|
List<Map<Object, Object>> personCustomFieldList = getFieldList(personCustomEntity,employee);
|
|
|
|
|
List<Map<Object, Object>> customFieldList = personCustomFieldList.stream().filter(e->!e.get("componentKey").equals("BaseField")).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
for (Map<Object, Object> customField:customFieldList){
|
|
|
|
|
List<Map<Object, Object>> 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<Object, Object> formBasicField:mainFormBasicFieldList){
|
|
|
|
|
List<Map<Object, Object>> 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);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量保存
|
|
|
|
|
*/
|
|
|
|
|
//员工信息表
|
|
|
|
|
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<Map<String, Object>> 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<FormTableDto> forms = Lists.newArrayList();
|
|
|
|
|
for (Map<String, Object> 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);
|
|
|
|
|
}
|
|
|
|
|
saveEmployeeEntity.setForms(forms);
|
|
|
|
|
WeaResult<Map<String, Object>>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<String, Object> customParam = Maps.newHashMap();
|
|
|
|
|
customParam.put("formId",personCustomfieldFormid);
|
|
|
|
|
savePersonCustomEntiy.setCustomParam(customParam);
|
|
|
|
|
WeaResult<Map<String, Object>> result2 = batchSaveFormField(savePersonCustomEntiy);
|
|
|
|
|
log.error("save PersonCustom : [{}]",gson.toJson(result2));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<Object, Object>> getFieldList(FieldManageParam entity,SimpleEmployee employee) {
|
|
|
|
|
|
|
|
|
|
// List<Map<Object, Object>> fieldList = (CommonUtils.getRealService(module.name(), "FormFieldManageService", FormFieldManageService.class)).getFormFieldJsonByFormId(entity, employee);
|
|
|
|
|
WeaResult<Map<String, Object>> result = fieldManageController.getFormFieldList(entity);
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
log.error("getFieldList :[{}]",gson.toJson(result));
|
|
|
|
|
Map<String, Object> resultMap = result.getData();
|
|
|
|
|
return (List<Map<Object, Object>>)resultMap.get("data");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量保存
|
|
|
|
|
* @param entity
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public WeaResult<Map<String, Object>> batchSaveFormField(FormFieldManageParam entity) {
|
|
|
|
|
return fieldManageController.batchSaveFormField(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getJsonObjList(List<Map<Object, Object>> list){
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
List<String> josnObjList = Lists.newArrayList();
|
|
|
|
|
for (Map<Object, Object> map:list){
|
|
|
|
|
josnObjList.add(gson.toJson(map));
|
|
|
|
|
}
|
|
|
|
|
return josnObjList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|