mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
员工信息完善
This commit is contained in:
@@ -23,5 +23,5 @@ public interface CommonEntityMapper {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
public abstract class BaseService<
|
public abstract class BaseService<
|
||||||
Entity extends BaseEntity, Repository extends BaseRepository<Entity>> {
|
Entity extends BaseEntity, Repository extends BaseRepository<Entity>> {
|
||||||
@@ -58,12 +60,19 @@ public abstract class BaseService<
|
|||||||
if (ids == null){
|
if (ids == null){
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return dao.findAll(new Specification<Entity>() {
|
return dao.findAll(
|
||||||
@Override
|
new Specification<Entity>() {
|
||||||
public Predicate toPredicate(Root<Entity> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
|
@Override
|
||||||
return root.get("id").in(ids);
|
public Predicate toPredicate(
|
||||||
}
|
Root<Entity> root,
|
||||||
});
|
CriteriaQuery<?> query,
|
||||||
|
CriteriaBuilder criteriaBuilder) {
|
||||||
|
return root.get("id")
|
||||||
|
.in(
|
||||||
|
StreamSupport.stream(ids.spliterator(), false)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import jakarta.persistence.ElementCollection;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import org.hibernate.annotations.Comment;
|
import org.hibernate.annotations.Comment;
|
||||||
|
import org.hibernate.annotations.Formula;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -112,4 +113,23 @@ public class CreateEmployeeDto extends OrgCommonDto {
|
|||||||
private Double insurance6Base;
|
private Double insurance6Base;
|
||||||
@Comment("住房公积金比例")
|
@Comment("住房公积金比例")
|
||||||
private Double insurance6Percent;
|
private Double insurance6Percent;
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("离职时间")
|
||||||
|
private LocalDate resignDate;
|
||||||
|
|
||||||
|
@Comment("离职原因")
|
||||||
|
private String resignReason;
|
||||||
|
|
||||||
|
@Comment("员工状态")
|
||||||
|
private String empStatus;
|
||||||
|
|
||||||
|
@Formula(
|
||||||
|
"(select i.name\n"
|
||||||
|
+ "from t_dictionary d,\n"
|
||||||
|
+ " t_dictionary_item i\n"
|
||||||
|
+ "where d.id = i.dictionary_id\n"
|
||||||
|
+ " and d.code = 'emp.status'\n"
|
||||||
|
+ " and i.code = emp_status)")
|
||||||
|
private String empStatusName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import jakarta.persistence.ElementCollection;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import org.hibernate.annotations.Comment;
|
import org.hibernate.annotations.Comment;
|
||||||
|
import org.hibernate.annotations.Formula;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -114,4 +115,22 @@ public class UpdateEmployeeDto extends OrgCommonDto {
|
|||||||
@Comment("住房公积金比例")
|
@Comment("住房公积金比例")
|
||||||
private Double insurance6Percent;
|
private Double insurance6Percent;
|
||||||
|
|
||||||
|
@Comment("离职时间")
|
||||||
|
private LocalDate resignDate;
|
||||||
|
|
||||||
|
@Comment("离职原因")
|
||||||
|
private String resignReason;
|
||||||
|
|
||||||
|
@Comment("员工状态")
|
||||||
|
private String empStatus;
|
||||||
|
|
||||||
|
@Formula(
|
||||||
|
"(select i.name\n"
|
||||||
|
+ "from t_dictionary d,\n"
|
||||||
|
+ " t_dictionary_item i\n"
|
||||||
|
+ "where d.id = i.dictionary_id\n"
|
||||||
|
+ " and d.code = 'emp.status'\n"
|
||||||
|
+ " and i.code = emp_status)")
|
||||||
|
private String empStatusName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package cn.lihongjie.coal.employee.entity;
|
||||||
|
|
||||||
|
import cn.lihongjie.coal.file.entity.FileEntity;
|
||||||
|
|
||||||
|
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Embeddable;
|
||||||
|
import jakarta.persistence.Transient;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Comment;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Embeddable
|
||||||
|
public class EmpCarVO {
|
||||||
|
|
||||||
|
@Comment("车辆品牌")
|
||||||
|
private String brand;
|
||||||
|
@Comment("车辆型号")
|
||||||
|
private String model;
|
||||||
|
@Comment("颜色")
|
||||||
|
private String color;
|
||||||
|
|
||||||
|
@Comment("车牌号")
|
||||||
|
private String plateNo;
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("备注")
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
@Comment("关联附件")
|
||||||
|
@Column(columnDefinition = "text[]")
|
||||||
|
@Type(ListArrayType.class)
|
||||||
|
private List<String> fileIds;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private List<FileEntity> files;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
package cn.lihongjie.coal.employee.entity;
|
package cn.lihongjie.coal.employee.entity;
|
||||||
|
|
||||||
|
import cn.lihongjie.coal.file.entity.FileEntity;
|
||||||
|
|
||||||
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Embeddable;
|
import jakarta.persistence.Embeddable;
|
||||||
|
import jakarta.persistence.Transient;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -37,4 +40,9 @@ public class EmpCertVO {
|
|||||||
@Column(columnDefinition = "text[]")
|
@Column(columnDefinition = "text[]")
|
||||||
@Type(ListArrayType.class)
|
@Type(ListArrayType.class)
|
||||||
private List<String> fileIds;
|
private List<String> fileIds;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private List<FileEntity> files;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,12 @@ public class EmployeeEntity extends OrgCommonEntity {
|
|||||||
@Comment("员工证件信息")
|
@Comment("员工证件信息")
|
||||||
private List<EmpCertVO> certs;
|
private List<EmpCertVO> certs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ElementCollection
|
||||||
|
@Comment("员工车辆信息")
|
||||||
|
private List<EmpCarVO> cars;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* “五险”讲的是五种保险,包括养老保险、医疗保险、失业保险、工伤保险和生育保险。
|
* “五险”讲的是五种保险,包括养老保险、医疗保险、失业保险、工伤保险和生育保险。
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,4 +14,7 @@ import org.mapstruct.control.DeepClone;
|
|||||||
uses = {cn.lihongjie.coal.base.mapper.CommonMapper.class, cn.lihongjie.coal.base.mapper.CommonEntityMapper.class},
|
uses = {cn.lihongjie.coal.base.mapper.CommonMapper.class, cn.lihongjie.coal.base.mapper.CommonEntityMapper.class},
|
||||||
mappingControl = DeepClone.class)
|
mappingControl = DeepClone.class)
|
||||||
public interface EmployeeMapper
|
public interface EmployeeMapper
|
||||||
extends BaseMapper<EmployeeEntity, EmployeeDto, CreateEmployeeDto, UpdateEmployeeDto> {}
|
extends BaseMapper<EmployeeEntity, EmployeeDto, CreateEmployeeDto, UpdateEmployeeDto> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ import cn.lihongjie.coal.employee.dto.UpdateEmployeeDto;
|
|||||||
import cn.lihongjie.coal.employee.entity.EmployeeEntity;
|
import cn.lihongjie.coal.employee.entity.EmployeeEntity;
|
||||||
import cn.lihongjie.coal.employee.mapper.EmployeeMapper;
|
import cn.lihongjie.coal.employee.mapper.EmployeeMapper;
|
||||||
import cn.lihongjie.coal.employee.repository.EmployeeRepository;
|
import cn.lihongjie.coal.employee.repository.EmployeeRepository;
|
||||||
|
import cn.lihongjie.coal.file.service.FileService;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -51,10 +53,26 @@ class EmployeeService extends BaseService<EmployeeEntity, EmployeeRepository> {
|
|||||||
this.repository.deleteAllById(request.getIds());
|
this.repository.deleteAllById(request.getIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired FileService fileService;
|
||||||
|
|
||||||
public EmployeeDto getById(String id) {
|
public EmployeeDto getById(String id) {
|
||||||
EmployeeEntity entity = repository.get(id);
|
EmployeeEntity entity = repository.get(id);
|
||||||
|
|
||||||
return mapper.toDto(entity);
|
return toDto(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EmployeeDto toDto(EmployeeEntity entity) {
|
||||||
|
EmployeeDto dto = mapper.toDto(entity);
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getCerts())) {
|
||||||
|
dto.getCerts()
|
||||||
|
.forEach(
|
||||||
|
x -> {
|
||||||
|
if (CollectionUtils.isNotEmpty(x.getFileIds()))
|
||||||
|
x.setFiles(fileService.findAllByIds(x.getFileIds()));
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<EmployeeDto> list(CommonQuery query) {
|
public Page<EmployeeDto> list(CommonQuery query) {
|
||||||
@@ -66,6 +84,6 @@ class EmployeeService extends BaseService<EmployeeEntity, EmployeeRepository> {
|
|||||||
query.getPageSize(),
|
query.getPageSize(),
|
||||||
Sort.by(query.getOrders())));
|
Sort.by(query.getOrders())));
|
||||||
|
|
||||||
return page.map(this.mapper::toDto);
|
return page.map(this::toDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user