mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
完善批次信息
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package cn.lihongjie.coal.empSalary.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.empSalaryBatch.entity.EmpSalaryBatchEntity;
|
||||
import cn.lihongjie.coal.employee.entity.EmployeeEntity;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@@ -13,6 +15,7 @@ import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@@ -25,8 +28,6 @@ public class EmpSalaryEntity extends OrgCommonEntity {
|
||||
private EmployeeEntity employee;
|
||||
|
||||
|
||||
@Comment("员工快照")
|
||||
private String employeeSnapshot;
|
||||
|
||||
private BigDecimal item0;
|
||||
private BigDecimal item1;
|
||||
@@ -87,6 +88,240 @@ public class EmpSalaryEntity extends OrgCommonEntity {
|
||||
private BigDecimal sfheji;
|
||||
|
||||
|
||||
/**
|
||||
* 出勤记录冗余字段
|
||||
*/
|
||||
|
||||
|
||||
@Comment("是否全勤")
|
||||
private Boolean fullAttendance;
|
||||
|
||||
|
||||
@Comment("是否满勤")
|
||||
private Boolean fullWork;
|
||||
|
||||
|
||||
|
||||
@Comment("应出勤天数")
|
||||
private Double shouldAttendanceDays;
|
||||
|
||||
|
||||
@Comment("实际出勤天数")
|
||||
private Double actualAttendanceDays;
|
||||
|
||||
|
||||
@Comment("加班天数")
|
||||
private Double overtimeDays;
|
||||
|
||||
|
||||
@Comment("请假天数")
|
||||
private Double leaveDays;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Comment("事假天数")
|
||||
private Double personalLeaveDays;
|
||||
|
||||
|
||||
@Comment("病假天数")
|
||||
private Double sickLeaveDays;
|
||||
|
||||
|
||||
@Comment("婚假天数")
|
||||
private Double marriageLeaveDays;
|
||||
|
||||
@Comment("产假天数")
|
||||
private Double maternityLeaveDays;
|
||||
|
||||
@Comment("陪产假天数")
|
||||
private Double paternityLeaveDays;
|
||||
|
||||
@Comment("丧假天数")
|
||||
private Double funeralLeaveDays;
|
||||
|
||||
@Comment("年假天数")
|
||||
private Double annualLeaveDays;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Comment("迟到次数")
|
||||
private Integer lateTimes;
|
||||
|
||||
@Comment("迟到分钟数")
|
||||
private Integer lateMinutes;
|
||||
|
||||
|
||||
@Comment("早退次数")
|
||||
private Integer earlyTimes;
|
||||
|
||||
@Comment("早退分钟数")
|
||||
private Integer earlyMinutes;
|
||||
|
||||
|
||||
@Comment("旷工次数")
|
||||
private Integer absenteeismTimes;
|
||||
|
||||
|
||||
/**
|
||||
* 员工信息冗余字段
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@Comment("性别")
|
||||
private String sex;
|
||||
|
||||
@Comment("性别-名称")
|
||||
@DictTranslate(dictKey = DictCode.SEX)
|
||||
private String sexName;
|
||||
|
||||
@Comment("民族")
|
||||
private String nation;
|
||||
|
||||
@Comment("民族-名称")
|
||||
@DictTranslate(dictKey = DictCode.NATION)
|
||||
private String nationName;
|
||||
|
||||
@Comment("婚姻状况")
|
||||
private String marriage;
|
||||
|
||||
@Comment("婚姻状况-名称")
|
||||
@DictTranslate(dictKey = DictCode.MARRIAGE)
|
||||
private String marriageName;
|
||||
|
||||
@Comment("入职时间")
|
||||
private LocalDate entryDate;
|
||||
|
||||
@Comment("身份证号")
|
||||
private String idCard;
|
||||
|
||||
@Comment("学历")
|
||||
private String education;
|
||||
|
||||
@Comment("学历-名称")
|
||||
@DictTranslate(dictKey = DictCode.EDUCATION)
|
||||
private String educationName;
|
||||
|
||||
@Comment("毕业学校")
|
||||
private String school;
|
||||
|
||||
@Comment("籍贯")
|
||||
private String nativePlace;
|
||||
|
||||
@Comment("住址")
|
||||
private String address;
|
||||
|
||||
@Comment("手机号")
|
||||
private String phone;
|
||||
|
||||
|
||||
|
||||
@Comment("部门")
|
||||
private String departmentId;
|
||||
|
||||
@Comment("部门")
|
||||
private String departmentCode;
|
||||
|
||||
|
||||
@Comment("部门")
|
||||
private String departmentName;
|
||||
|
||||
@Comment("岗位")
|
||||
private String jobPostId;
|
||||
|
||||
@Comment("岗位")
|
||||
private String jobPostCode;
|
||||
|
||||
|
||||
@Comment("岗位")
|
||||
private String jobPostName;
|
||||
|
||||
|
||||
@Comment("银行编码")
|
||||
private String bank;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.BANK)
|
||||
private String bankName;
|
||||
|
||||
@Comment("银行卡号")
|
||||
private String bankCardNumber;
|
||||
|
||||
@Comment("收款人姓名")
|
||||
private String bankCardName;
|
||||
|
||||
|
||||
|
||||
@Comment("离职时间")
|
||||
private LocalDate resignDate;
|
||||
|
||||
@Comment("离职原因")
|
||||
private String resignReason;
|
||||
|
||||
@Comment("员工状态")
|
||||
private String empStatus;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.EMP_STATUS)
|
||||
private String empStatusName;
|
||||
|
||||
|
||||
|
||||
@Comment("养老保险基数")
|
||||
private Double insurance1Base;
|
||||
@Comment("养老保险比例")
|
||||
private Double insurance1Percent;
|
||||
|
||||
|
||||
@Comment("医疗保险基数")
|
||||
private Double insurance2Base;
|
||||
@Comment("医疗保险比例")
|
||||
private Double insurance2Percent;
|
||||
|
||||
|
||||
|
||||
@Comment("失业保险基数")
|
||||
private Double insurance3Base;
|
||||
@Comment("失业保险比例")
|
||||
private Double insurance3Percent;
|
||||
|
||||
|
||||
|
||||
@Comment("工伤保险基数")
|
||||
private Double insurance4Base;
|
||||
@Comment("工伤保险比例")
|
||||
private Double insurance4Percent;
|
||||
|
||||
|
||||
|
||||
@Comment("生育保险基数")
|
||||
private Double insurance5Base;
|
||||
@Comment("生育保险比例")
|
||||
private Double insurance5Percent;
|
||||
|
||||
@Comment("住房公积金基数")
|
||||
private Double insurance6Base;
|
||||
@Comment("住房公积金比例")
|
||||
private Double insurance6Percent;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
@@ -21,6 +21,11 @@ public class EmpSalaryBatchEntity extends OrgCommonEntity {
|
||||
@Comment("批次号")
|
||||
private String batchNo;
|
||||
|
||||
|
||||
|
||||
@Comment("批次状态 0-未编辑 1-编辑中 2-已送审 3-已审核 4-已归档")
|
||||
private String batchStatus;
|
||||
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.lihongjie.coal.empSalaryBatch.service;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.common.Ctx;
|
||||
import cn.lihongjie.coal.empSalaryBatch.dto.CreateEmpSalaryBatchDto;
|
||||
import cn.lihongjie.coal.empSalaryBatch.dto.EmpSalaryBatchDto;
|
||||
import cn.lihongjie.coal.empSalaryBatch.dto.UpdateEmpSalaryBatchDto;
|
||||
@@ -11,16 +12,25 @@ import cn.lihongjie.coal.empSalaryBatch.mapper.EmpSalaryBatchMapper;
|
||||
import cn.lihongjie.coal.empSalaryBatch.repository.EmpSalaryBatchRepository;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
@@ -35,6 +45,23 @@ public class EmpSalaryBatchService
|
||||
public EmpSalaryBatchDto create(CreateEmpSalaryBatchDto request) {
|
||||
EmpSalaryBatchEntity entity = mapper.toEntity(request);
|
||||
|
||||
// 批次年月和批次号唯一
|
||||
if (this.repository.count(new Specification<EmpSalaryBatchEntity>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<EmpSalaryBatchEntity> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
|
||||
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.equal(root.get("batchYearMonth"), entity.getBatchYearMonth()),
|
||||
criteriaBuilder.equal(root.get("batchNo"), entity.getBatchNo()),
|
||||
criteriaBuilder.equal(root.get("organizationId"), Ctx.currentUser().getOrganizationId())
|
||||
);
|
||||
}
|
||||
}) > 0){
|
||||
throw new BizException("相同批次已经存在");
|
||||
}
|
||||
|
||||
entity.setBatchStatus("0");
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
@@ -44,6 +71,11 @@ public class EmpSalaryBatchService
|
||||
if (this.repository.containArchived(request.getId())){
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
|
||||
if (!StringUtils.equalsAny(entity.getBatchStatus(), "0")){
|
||||
throw new BizException("批次状态不是未编辑状态,无法编辑");
|
||||
}
|
||||
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
@@ -55,6 +87,14 @@ public class EmpSalaryBatchService
|
||||
if (this.repository.containArchived(request)){
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
|
||||
|
||||
this.repository.findAllById(request.getIds()).forEach(entity -> {
|
||||
|
||||
if (!Objects.equals(entity.getBatchStatus(), "0")){
|
||||
throw new BizException("批次状态不是未编辑状态,无法删除");
|
||||
}
|
||||
});
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user