This commit is contained in:
2024-08-17 16:34:01 +08:00
parent f37a265bd6
commit 64791a6c23
15 changed files with 870 additions and 96 deletions

View File

@@ -50,6 +50,13 @@
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-core -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>5.8.31</version>
</dependency>
<dependency>
<groupId>me.lemire.integercompression</groupId>
<artifactId>JavaFastPFOR</artifactId>

View File

@@ -12,6 +12,8 @@ import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
@Data
@Entity
@@ -93,8 +95,34 @@ public class EmpMonthAttendanceEntity extends OrgCommonEntity {
this.setDefaultVal();
}
public Map<String, Object> toCtxMap() {
Map<String, Object> map = new HashMap<>();
map.put("fullAttendance", fullAttendance);
map.put("fullWork", fullWork);
map.put("shouldAttendanceDays", shouldAttendanceDays);
map.put("actualAttendanceDays", actualAttendanceDays);
map.put("overtimeDays", overtimeDays);
map.put("leaveDays", leaveDays);
map.put("personalLeaveDays", personalLeaveDays);
map.put("sickLeaveDays", sickLeaveDays);
map.put("marriageLeaveDays", marriageLeaveDays);
map.put("maternityLeaveDays", maternityLeaveDays);
map.put("paternityLeaveDays", paternityLeaveDays);
map.put("funeralLeaveDays", funeralLeaveDays);
map.put("annualLeaveDays", annualLeaveDays);
map.put("lateTimes", lateTimes);
map.put("lateMinutes", lateMinutes);
map.put("earlyTimes", earlyTimes);
map.put("earlyMinutes", earlyMinutes);
map.put("absenteeismTimes", absenteeismTimes);
return map;
}
public void setDefaultVal() {
if (this.yearMonth != null) {
this.yearMonth = LocalDate.of(this.yearMonth.getYear(), this.yearMonth.getMonth(), 1);
}

View File

@@ -6,7 +6,7 @@ import java.math.BigDecimal;
import java.util.*;
@Data
public class RecalculatePreviewDto {
public class RecalculatePreviewDto implements SalaryItemData{
private BigDecimal item0;
@@ -65,4 +65,5 @@ public class RecalculatePreviewDto {
private BigDecimal kfheji;
private BigDecimal sfheji;
}

View File

@@ -0,0 +1,362 @@
package cn.lihongjie.coal.empSalary.dto;
import java.util.*;
public interface SalaryItemData {
java.math.BigDecimal getItem0();
void setItem0(java.math.BigDecimal item0);
java.math.BigDecimal getItem1();
void setItem1(java.math.BigDecimal item1);
java.math.BigDecimal getItem2();
void setItem2(java.math.BigDecimal item2);
java.math.BigDecimal getItem3();
void setItem3(java.math.BigDecimal item3);
java.math.BigDecimal getItem4();
void setItem4(java.math.BigDecimal item4);
java.math.BigDecimal getItem5();
void setItem5(java.math.BigDecimal item5);
java.math.BigDecimal getItem6();
void setItem6(java.math.BigDecimal item6);
java.math.BigDecimal getItem7();
void setItem7(java.math.BigDecimal item7);
java.math.BigDecimal getItem8();
void setItem8(java.math.BigDecimal item8);
java.math.BigDecimal getItem9();
void setItem9(java.math.BigDecimal item9);
java.math.BigDecimal getItem10();
void setItem10(java.math.BigDecimal item10);
java.math.BigDecimal getItem11();
void setItem11(java.math.BigDecimal item11);
java.math.BigDecimal getItem12();
void setItem12(java.math.BigDecimal item12);
java.math.BigDecimal getItem13();
void setItem13(java.math.BigDecimal item13);
java.math.BigDecimal getItem14();
void setItem14(java.math.BigDecimal item14);
java.math.BigDecimal getItem15();
void setItem15(java.math.BigDecimal item15);
java.math.BigDecimal getItem16();
void setItem16(java.math.BigDecimal item16);
java.math.BigDecimal getItem17();
void setItem17(java.math.BigDecimal item17);
java.math.BigDecimal getItem18();
void setItem18(java.math.BigDecimal item18);
java.math.BigDecimal getItem19();
void setItem19(java.math.BigDecimal item19);
java.math.BigDecimal getItem20();
void setItem20(java.math.BigDecimal item20);
java.math.BigDecimal getItem21();
void setItem21(java.math.BigDecimal item21);
java.math.BigDecimal getItem22();
void setItem22(java.math.BigDecimal item22);
java.math.BigDecimal getItem23();
void setItem23(java.math.BigDecimal item23);
java.math.BigDecimal getItem24();
void setItem24(java.math.BigDecimal item24);
java.math.BigDecimal getItem25();
void setItem25(java.math.BigDecimal item25);
java.math.BigDecimal getItem26();
void setItem26(java.math.BigDecimal item26);
java.math.BigDecimal getItem27();
void setItem27(java.math.BigDecimal item27);
java.math.BigDecimal getItem28();
void setItem28(java.math.BigDecimal item28);
java.math.BigDecimal getItem29();
void setItem29(java.math.BigDecimal item29);
java.math.BigDecimal getItem30();
void setItem30(java.math.BigDecimal item30);
java.math.BigDecimal getItem31();
void setItem31(java.math.BigDecimal item31);
java.math.BigDecimal getItem32();
void setItem32(java.math.BigDecimal item32);
java.math.BigDecimal getItem33();
void setItem33(java.math.BigDecimal item33);
java.math.BigDecimal getItem34();
void setItem34(java.math.BigDecimal item34);
java.math.BigDecimal getItem35();
void setItem35(java.math.BigDecimal item35);
java.math.BigDecimal getItem36();
void setItem36(java.math.BigDecimal item36);
java.math.BigDecimal getItem37();
void setItem37(java.math.BigDecimal item37);
java.math.BigDecimal getItem38();
void setItem38(java.math.BigDecimal item38);
java.math.BigDecimal getItem39();
void setItem39(java.math.BigDecimal item39);
java.math.BigDecimal getItem40();
void setItem40(java.math.BigDecimal item40);
java.math.BigDecimal getItem41();
void setItem41(java.math.BigDecimal item41);
java.math.BigDecimal getItem42();
void setItem42(java.math.BigDecimal item42);
java.math.BigDecimal getItem43();
void setItem43(java.math.BigDecimal item43);
java.math.BigDecimal getItem44();
void setItem44(java.math.BigDecimal item44);
java.math.BigDecimal getItem45();
void setItem45(java.math.BigDecimal item45);
java.math.BigDecimal getItem46();
void setItem46(java.math.BigDecimal item46);
java.math.BigDecimal getItem47();
void setItem47(java.math.BigDecimal item47);
java.math.BigDecimal getItem48();
void setItem48(java.math.BigDecimal item48);
java.math.BigDecimal getItem49();
void setItem49(java.math.BigDecimal item49);
java.math.BigDecimal getItem50();
void setItem50(java.math.BigDecimal item50);
java.math.BigDecimal getYfheji();
void setYfheji(java.math.BigDecimal yfheji);
java.math.BigDecimal getKfheji();
void setKfheji(java.math.BigDecimal kfheji);
java.math.BigDecimal getSfheji();
void setSfheji(java.math.BigDecimal sfheji);
default void overWriteSalaryItem(Map<String, Object> ctx) {
ctx.put("item0", this.getItem0());
ctx.put("item1", this.getItem1());
ctx.put("item2", this.getItem2());
ctx.put("item3", this.getItem3());
ctx.put("item4", this.getItem4());
ctx.put("item5", this.getItem5());
ctx.put("item6", this.getItem6());
ctx.put("item7", this.getItem7());
ctx.put("item8", this.getItem8());
ctx.put("item9", this.getItem9());
ctx.put("item10", this.getItem10());
ctx.put("item11", this.getItem11());
ctx.put("item12", this.getItem12());
ctx.put("item13", this.getItem13());
ctx.put("item14", this.getItem14());
ctx.put("item15", this.getItem15());
ctx.put("item16", this.getItem16());
ctx.put("item17", this.getItem17());
ctx.put("item18", this.getItem18());
ctx.put("item19", this.getItem19());
ctx.put("item20", this.getItem20());
ctx.put("item21", this.getItem21());
ctx.put("item22", this.getItem22());
ctx.put("item23", this.getItem23());
ctx.put("item24", this.getItem24());
ctx.put("item25", this.getItem25());
ctx.put("item26", this.getItem26());
ctx.put("item27", this.getItem27());
ctx.put("item28", this.getItem28());
ctx.put("item29", this.getItem29());
ctx.put("item30", this.getItem30());
ctx.put("item31", this.getItem31());
ctx.put("item32", this.getItem32());
ctx.put("item33", this.getItem33());
ctx.put("item34", this.getItem34());
ctx.put("item35", this.getItem35());
ctx.put("item36", this.getItem36());
ctx.put("item37", this.getItem37());
ctx.put("item38", this.getItem38());
ctx.put("item39", this.getItem39());
ctx.put("item40", this.getItem40());
ctx.put("item41", this.getItem41());
ctx.put("item42", this.getItem42());
ctx.put("item43", this.getItem43());
ctx.put("item44", this.getItem44());
ctx.put("item45", this.getItem45());
ctx.put("item46", this.getItem46());
ctx.put("item47", this.getItem47());
ctx.put("item48", this.getItem48());
ctx.put("item49", this.getItem49());
ctx.put("item50", this.getItem50());
ctx.put("yfheji", this.getYfheji());
ctx.put("kfheji", this.getKfheji());
ctx.put("sfheji", this.getSfheji());
}
default void updateItems(Map<String, Object> ctx) {
this.setItem0(getBigDeciaml(ctx, "item0"));
this.setItem1(getBigDeciaml(ctx, "item1"));
this.setItem2(getBigDeciaml(ctx, "item2"));
this.setItem3(getBigDeciaml(ctx, "item3"));
this.setItem4(getBigDeciaml(ctx, "item4"));
this.setItem5(getBigDeciaml(ctx, "item5"));
this.setItem6(getBigDeciaml(ctx, "item6"));
this.setItem7(getBigDeciaml(ctx, "item7"));
this.setItem8(getBigDeciaml(ctx, "item8"));
this.setItem9(getBigDeciaml(ctx, "item9"));
this.setItem10(getBigDeciaml(ctx, "item10"));
this.setItem11(getBigDeciaml(ctx, "item11"));
this.setItem12(getBigDeciaml(ctx, "item12"));
this.setItem13(getBigDeciaml(ctx, "item13"));
this.setItem14(getBigDeciaml(ctx, "item14"));
this.setItem15(getBigDeciaml(ctx, "item15"));
this.setItem16(getBigDeciaml(ctx, "item16"));
this.setItem17(getBigDeciaml(ctx, "item17"));
this.setItem18(getBigDeciaml(ctx, "item18"));
this.setItem19(getBigDeciaml(ctx, "item19"));
this.setItem20(getBigDeciaml(ctx, "item20"));
this.setItem21(getBigDeciaml(ctx, "item21"));
this.setItem22(getBigDeciaml(ctx, "item22"));
this.setItem23(getBigDeciaml(ctx, "item23"));
this.setItem24(getBigDeciaml(ctx, "item24"));
this.setItem25(getBigDeciaml(ctx, "item25"));
this.setItem26(getBigDeciaml(ctx, "item26"));
this.setItem27(getBigDeciaml(ctx, "item27"));
this.setItem28(getBigDeciaml(ctx, "item28"));
this.setItem29(getBigDeciaml(ctx, "item29"));
this.setItem30(getBigDeciaml(ctx, "item30"));
this.setItem31(getBigDeciaml(ctx, "item31"));
this.setItem32(getBigDeciaml(ctx, "item32"));
this.setItem33(getBigDeciaml(ctx, "item33"));
this.setItem34(getBigDeciaml(ctx, "item34"));
this.setItem35(getBigDeciaml(ctx, "item35"));
this.setItem36(getBigDeciaml(ctx, "item36"));
this.setItem37(getBigDeciaml(ctx, "item37"));
this.setItem38(getBigDeciaml(ctx, "item38"));
this.setItem39(getBigDeciaml(ctx, "item39"));
this.setItem40(getBigDeciaml(ctx, "item40"));
this.setItem41(getBigDeciaml(ctx, "item41"));
this.setItem42(getBigDeciaml(ctx, "item42"));
this.setItem43(getBigDeciaml(ctx, "item43"));
this.setItem44(getBigDeciaml(ctx, "item44"));
this.setItem45(getBigDeciaml(ctx, "item45"));
this.setItem46(getBigDeciaml(ctx, "item46"));
this.setItem47(getBigDeciaml(ctx, "item47"));
this.setItem48(getBigDeciaml(ctx, "item48"));
this.setItem49(getBigDeciaml(ctx, "item49"));
this.setItem50(getBigDeciaml(ctx, "item50"));
this.setYfheji(getBigDeciaml(ctx, "yfheji"));
this.setKfheji(getBigDeciaml(ctx, "kfheji"));
this.setSfheji(getBigDeciaml(ctx, "sfheji"));
}
default java.math.BigDecimal getBigDeciaml(Map<String, Object> ctx, String key) {
Object o = ctx.get(key);
if (o == null) {
return null;
}
if (o instanceof java.math.BigDecimal) {
return (java.math.BigDecimal) o;
}
if (o instanceof String) {
return new java.math.BigDecimal((String) o);
}
if (o instanceof Number) {
return java.math.BigDecimal.valueOf(((Number) o).doubleValue());
}
return (java.math.BigDecimal) o;
}
}

View File

@@ -11,8 +11,7 @@ import lombok.Data;
import java.math.BigDecimal;
@Data
public class UpdateEmpSalaryDto extends OrgCommonDto {
public class UpdateEmpSalaryDto extends OrgCommonDto implements SalaryItemData {
@ManyToOne
@NotNull
@@ -82,4 +81,5 @@ public class UpdateEmpSalaryDto extends OrgCommonDto {
private BigDecimal sfheji;
}

View File

@@ -3,6 +3,7 @@ package cn.lihongjie.coal.empSalary.entity;
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import cn.lihongjie.coal.common.DictCode;
import cn.lihongjie.coal.empMonthAttendance.entity.EmpMonthAttendanceEntity;
import cn.lihongjie.coal.empSalary.dto.SalaryItemData;
import cn.lihongjie.coal.empSalaryBatch.entity.EmpSalaryBatchEntity;
import cn.lihongjie.coal.employee.entity.EmployeeEntity;
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
@@ -18,11 +19,13 @@ import org.hibernate.annotations.Comment;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@Data
@Entity
public class EmpSalaryEntity extends OrgCommonEntity {
public class EmpSalaryEntity extends OrgCommonEntity implements SalaryItemData {
public static final Set<String> ITEM_KEYS =
Set.of(
@@ -442,4 +445,320 @@ public class EmpSalaryEntity extends OrgCommonEntity {
this.kfheji = salaryEntity.kfheji;
this.sfheji = salaryEntity.sfheji;
}
public Map<String, Object> toCtxMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("item0", this.item0);
map.put("item1", this.item1);
map.put("item2", this.item2);
map.put("item3", this.item3);
map.put("item4", this.item4);
map.put("item5", this.item5);
map.put("item6", this.item6);
map.put("item7", this.item7);
map.put("item8", this.item8);
map.put("item9", this.item9);
map.put("item10", this.item10);
map.put("item11", this.item11);
map.put("item12", this.item12);
map.put("item13", this.item13);
map.put("item14", this.item14);
map.put("item15", this.item15);
map.put("item16", this.item16);
map.put("item17", this.item17);
map.put("item18", this.item18);
map.put("item19", this.item19);
map.put("item20", this.item20);
map.put("item21", this.item21);
map.put("item22", this.item22);
map.put("item23", this.item23);
map.put("item24", this.item24);
map.put("item25", this.item25);
map.put("item26", this.item26);
map.put("item27", this.item27);
map.put("item28", this.item28);
map.put("item29", this.item29);
map.put("item30", this.item30);
map.put("item31", this.item31);
map.put("item32", this.item32);
map.put("item33", this.item33);
map.put("item34", this.item34);
map.put("item35", this.item35);
map.put("item36", this.item36);
map.put("item37", this.item37);
map.put("item38", this.item38);
map.put("item39", this.item39);
map.put("item40", this.item40);
map.put("item41", this.item41);
map.put("item42", this.item42);
map.put("item43", this.item43);
map.put("item44", this.item44);
map.put("item45", this.item45);
map.put("item46", this.item46);
map.put("item47", this.item47);
map.put("item48", this.item48);
map.put("item49", this.item49);
map.put("item50", this.item50);
map.put("yfheji", this.yfheji);
map.put("kfheji", this.kfheji);
map.put("sfheji", this.sfheji);
map.put("fullAttendance", this.fullAttendance);
map.put("fullWork", this.fullWork);
map.put("shouldAttendanceDays", this.shouldAttendanceDays);
map.put("actualAttendanceDays", this.actualAttendanceDays);
map.put("overtimeDays", this.overtimeDays);
map.put("leaveDays", this.leaveDays);
map.put("personalLeaveDays", this.personalLeaveDays);
map.put("sickLeaveDays", this.sickLeaveDays);
map.put("marriageLeaveDays", this.marriageLeaveDays);
map.put("maternityLeaveDays", this.maternityLeaveDays);
map.put("paternityLeaveDays", this.paternityLeaveDays);
map.put("funeralLeaveDays", this.funeralLeaveDays);
map.put("annualLeaveDays", this.annualLeaveDays);
map.put("lateTimes", this.lateTimes);
map.put("lateMinutes", this.lateMinutes);
map.put("earlyTimes", this.earlyTimes);
map.put("earlyMinutes", this.earlyMinutes);
map.put("absenteeismTimes", this.absenteeismTimes);
map.put("empName", this.empName);
map.put("empCode", this.empCode);
map.put("sex", this.sex);
map.put("sexName", this.sexName);
map.put("nation", this.nation);
map.put("nationName", this.nationName);
map.put("marriage", this.marriage);
map.put("marriageName", this.marriageName);
map.put("entryDate", this.entryDate);
map.put("idCard", this.idCard);
map.put("education", this.education);
map.put("educationName", this.educationName);
map.put("school", this.school);
map.put("nativePlace", this.nativePlace);
map.put("address", this.address);
map.put("phone", this.phone);
map.put("departmentId", this.departmentId);
map.put("departmentCode", this.departmentCode);
map.put("departmentName", this.departmentName);
map.put("jobPostId", this.jobPostId);
map.put("jobPostCode", this.jobPostCode);
map.put("jobPostName", this.jobPostName);
map.put("bank", this.bank);
map.put("bankName", this.bankName);
map.put("bankCardNumber", this.bankCardNumber);
map.put("bankCardName", this.bankCardName);
map.put("resignDate", this.resignDate);
map.put("resignReason", this.resignReason);
map.put("empStatus", this.empStatus);
map.put("empStatusName", this.empStatusName);
map.put("insurance1Base", this.insurance1Base);
map.put("insurance1Percent", this.insurance1Percent);
map.put("insurance2Base", this.insurance2Base);
map.put("insurance2Percent", this.insurance2Percent);
map.put("insurance3Base", this.insurance3Base);
map.put("insurance3Percent", this.insurance3Percent);
map.put("insurance4Base", this.insurance4Base);
map.put("insurance4Percent", this.insurance4Percent);
map.put("insurance5Base", this.insurance5Base);
map.put("insurance5Percent", this.insurance5Percent);
map.put("insurance6Base", this.insurance6Base);
map.put("insurance6Percent", this.insurance6Percent);
map.put("workAge", this.workAge);
map.put("age", this.age);
map.put("birthday", this.birthday);
map.put("batchYearMonth", this.batchYearMonth);
map.put("batchNo", this.batchNo);
return map;
}
public void updateFromCtxMap(Map<String, Object> ctx) {
SalaryItemData.super.updateItems(ctx);
this.fullAttendance = (Boolean) ctx.get("fullAttendance");
this.fullWork = (Boolean) ctx.get("fullWork");
this.shouldAttendanceDays = (Double) ctx.get("shouldAttendanceDays");
this.actualAttendanceDays = (Double) ctx.get("actualAttendanceDays");
this.overtimeDays = (Double) ctx.get("overtimeDays");
this.leaveDays = (Double) ctx.get("leaveDays");
this.personalLeaveDays = (Double) ctx.get("personalLeaveDays");
this.sickLeaveDays = (Double) ctx.get("sickLeaveDays");
this.marriageLeaveDays = (Double) ctx.get("marriageLeaveDays");
this.maternityLeaveDays = (Double) ctx.get("maternityLeaveDays");
this.paternityLeaveDays = (Double) ctx.get("paternityLeaveDays");
this.funeralLeaveDays = (Double) ctx.get("funeralLeaveDays");
this.annualLeaveDays = (Double) ctx.get("annualLeaveDays");
this.lateTimes = (Integer) ctx.get("lateTimes");
this.lateMinutes = (Integer) ctx.get("lateMinutes");
this.earlyTimes = (Integer) ctx.get("earlyTimes");
this.earlyMinutes = (Integer) ctx.get("earlyMinutes");
this.absenteeismTimes = (Integer) ctx.get("absenteeismTimes");
this.empName = (String) ctx.get("empName");
this.empCode = (String) ctx.get("empCode");
this.sex = (String) ctx.get("sex");
this.sexName = (String) ctx.get("sexName");
this.nation = (String) ctx.get("nation");
this.nationName = (String) ctx.get("nationName");
this.marriage = (String) ctx.get("marriage");
this.marriageName = (String) ctx.get("marriageName");
this.entryDate = (LocalDate) ctx.get("entryDate");
this.idCard = (String) ctx.get("idCard");
this.education = (String) ctx.get("education");
this.educationName = (String) ctx.get("educationName");
this.school = (String) ctx.get("school");
this.nativePlace = (String) ctx.get("nativePlace");
this.address = (String) ctx.get("address");
this.phone = (String) ctx.get("phone");
this.departmentId = (String) ctx.get("departmentId");
this.departmentCode = (String) ctx.get("departmentCode");
this.departmentName = (String) ctx.get("departmentName");
this.jobPostId = (String) ctx.get("jobPostId");
this.jobPostCode = (String) ctx.get("jobPostCode");
this.jobPostName = (String) ctx.get("jobPostName");
this.bank = (String) ctx.get("bank");
this.bankName = (String) ctx.get("bankName");
this.bankCardNumber = (String) ctx.get("bankCardNumber");
this.bankCardName = (String) ctx.get("bankCardName");
this.resignDate = (LocalDate) ctx.get("resignDate");
this.resignReason = (String) ctx.get("resignReason");
this.empStatus = (String) ctx.get("empStatus");
this.empStatusName = (String) ctx.get("empStatusName");
this.insurance1Base = (Double) ctx.get("insurance1Base");
this.insurance1Percent = (Double) ctx.get("insurance1Percent");
this.insurance2Base = (Double) ctx.get("insurance2Base");
this.insurance2Percent = (Double) ctx.get("insurance2Percent");
this.insurance3Base = (Double) ctx.get("insurance3Base");
this.insurance3Percent = (Double) ctx.get("insurance3Percent");
this.insurance4Base = (Double) ctx.get("insurance4Base");
this.insurance4Percent = (Double) ctx.get("insurance4Percent");
this.insurance5Base = (Double) ctx.get("insurance5Base");
this.insurance5Percent = (Double) ctx.get("insurance5Percent");
this.insurance6Base = (Double) ctx.get("insurance6Base");
this.insurance6Percent = (Double) ctx.get("insurance6Percent");
this.workAge = (Double) ctx.get("workAge");
this.age = (Double) ctx.get("age");
this.birthday = (LocalDate) ctx.get("birthday");
this.batchYearMonth = (LocalDate) ctx.get("batchYearMonth");
this.batchNo = (String) ctx.get("batchNo");
}
}

View File

@@ -1,5 +1,6 @@
package cn.lihongjie.coal.empSalary.service;
import cn.hutool.core.map.MapUtil;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
@@ -30,8 +31,6 @@ import groovy.lang.Binding;
import groovy.lang.GroovyClassLoader;
import groovy.lang.Script;
import io.vavr.control.Try;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
@@ -124,7 +123,8 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
EmpSalaryBatchEntity batch = batchService.get(dto.getBatchId());
assertBatchEditable(batch);
@Cleanup("unlock") RLock lock = redissonClient.getLock("batchModify." + batch.getId());
@Cleanup("unlock")
RLock lock = redissonClient.getLock("batchModify." + batch.getId());
boolean tryLock = lock.tryLock();
@@ -277,16 +277,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
RecalculatePreviewDto dto = new RecalculatePreviewDto();
for (String string : ctx.keySet()) {
if (EmpSalaryEntity.ITEM_KEYS.contains(string)) {
Object value = ctx.get(string);
ReflectUtils.writeField(
dto, string, conversionService.convert(value, BigDecimal.class));
}
}
dto.updateItems(ctx);
return dto;
}
@@ -345,7 +336,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
// 覆盖工资项目
overWriteSalaryItem(ctx, ReflectUtils.toMap(dto));
dto.overWriteSalaryItem(ctx);
scriptObj.setBinding(new Binding(Map.of("salary", ctx)));
@@ -423,9 +414,8 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
// 转化为工资数据
stopWatch.start("convertToSalary: " + employee.getName());
EmpSalaryEntity salaryEntity = ReflectUtils.fromMap(ctx, EmpSalaryEntity.class);
salary.update(salaryEntity);
salary.updateFromCtxMap(ctx);
stopWatch.stop();
}
@@ -568,7 +558,8 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
// 转化为工资数据
stopWatch.start("convertToSalary: " + employee.getName());
EmpSalaryEntity salaryEntity = ReflectUtils.fromMap(ctx, EmpSalaryEntity.class);
EmpSalaryEntity salaryEntity = new EmpSalaryEntity();
salaryEntity.updateFromCtxMap(ctx);
salaryEntity.setBatch(batch);
salaryEntity.setEmployee(em.getReference(EmployeeEntity.class, employee.getId()));
salaryEntity.setEmpMonthAttendance(attendance);
@@ -618,15 +609,11 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
*/
public Map<String, Object> buildPreviewCtx(UpdateEmpSalaryDto dto, EmpSalaryEntity entity) {
EmpSalaryDto salaryDto = this.mapper.toDto(entity);
Map<String, Object> ctxMap = entity.toCtxMap();
Map<String, Object> userInput = ReflectUtils.toMap(dto);
dto.overWriteSalaryItem(ctxMap);
Map<String, Object> ctx = ReflectUtils.toMap(salaryDto);
MapUtils.merge(userInput, ctx, EmpSalaryEntity.ITEM_KEYS);
return ctx;
return ctxMap;
}
public Map<String, Object> buildRecalculateCtx(EmpSalaryEntity entity) {
@@ -650,17 +637,14 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
return new HashMap<>();
}
EmpSalaryDto salary = empSalaryMapper.toDto(entity);
Map<String, Object> map = ReflectUtils.toMap(salary);
Map<String, Object> ctxMap = entity.toCtxMap();
if (onlyItems) {
return MapUtils.keepKey(map, EmpSalaryEntity.ITEM_KEYS);
return MapUtil.edit(
ctxMap, (e) -> EmpSalaryEntity.ITEM_KEYS.contains(e.getKey()) ? e : null);
} else {
removeCommonField(map);
return map;
return ctxMap;
}
}
@@ -670,14 +654,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
return new HashMap<>();
}
var attendance = empMonthAttendanceMapper.toDto2(empMonthAttendance);
Map<String, Object> map = ReflectUtils.toMap(attendance);
map.put("attendanceId", empMonthAttendance.getId());
removeCommonField(map);
return map;
return empMonthAttendance.toCtxMap();
}
private Map<String, Object> buildCtx(EmpSalaryBatchEntity batch) {
@@ -686,15 +663,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
return new HashMap<>();
}
var batchDto = empSalaryBatchMapper.toDto(batch);
Map<String, Object> batchMap = ReflectUtils.toMap(batchDto);
batchMap.put("batchId", batch.getId());
removeCommonField(batchMap);
return batchMap;
return batch.toCtxMap();
}
@Autowired EmpMonthAttendanceMapper empMonthAttendanceMapper;
@@ -718,21 +687,7 @@ public class EmpSalaryService extends BaseService<EmpSalaryEntity, EmpSalaryRepo
return new HashMap<>();
}
Map<String, Object> empMap = ReflectUtils.toMap(employee);
empMap.put("empId", employee.getId());
empMap.put("empName", employee.getName());
empMap.put("empCode", employee.getCode());
Try.run(() -> empMap.put("departmentId", employee.getDepartment().getId()));
Try.run(() -> empMap.put("departmentCode", employee.getDepartment().getCode()));
Try.run(() -> empMap.put("departmentName", employee.getDepartment().getName()));
Try.run(() -> empMap.put("jobPostId", employee.getJobPost().getId()));
Try.run(() -> empMap.put("jobPostCode", employee.getJobPost().getCode()));
Try.run(() -> empMap.put("jobPostName", employee.getJobPost().getName()));
removeCommonField(empMap);
return empMap;
return employee.toCtxMap();
}
private @NotNull Map<String, List<EmpMonthAttendanceEntity>> queryAttendanceMap(
@@ -823,18 +778,14 @@ select id from tmp1 where rk = 1
assertBatchEditable(batch);
@Cleanup("unlock") RLock lock = redissonClient.getLock("batchModify." + batch.getId());
@Cleanup("unlock")
RLock lock = redissonClient.getLock("batchModify." + batch.getId());
if (!lock.tryLock()) {
lock = null;
batchModifing(batch);
}
List<EmpSalaryItemEntity> items =
this.empSalaryItemService.getItems(batch.getOrganizationId());
@@ -859,12 +810,17 @@ select id from tmp1 where rk = 1
if (header.equals("身份证号") || header.equals("身份证")) {
object.put("idCard", value);
} else if (StringUtils.equalsAny("姓名","员工", "部门", "岗位")) {
} else if (StringUtils.equalsAny("姓名", "员工", "部门", "岗位")) {
// 忽略这些字段
} else if (itemMap.containsKey(header)) {
if (value == null || (value instanceof String && StringUtils.isBlank((String) value))){
return;
}
object.put(
itemMap.get(header).getCode(),
conversionService.convert(value, BigDecimal.class));

View File

@@ -10,6 +10,8 @@ import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
@Data
@Entity
@@ -56,4 +58,14 @@ public class EmpSalaryBatchEntity extends OrgCommonEntity {
super.preUpdate();
this.initName();
}
public Map<String, Object> toCtxMap() {
Map<String, Object> map = new HashMap<>();
map.put("batchYearMonth", batchYearMonth);
map.put("batchNo", batchNo);
map.put("batchId", getId());
map.put("batchStatus", batchStatus);
return map;
}
}

View File

@@ -41,6 +41,10 @@ public class CreateEmpSalaryItemDto extends OrgCommonDto {
@Comment("小数位处理方式 0-四舍五入 1-截断 2-进位")
private String decimalPlacesHandler;
@Comment("是否显示在列表")
private Boolean listShow;
@Comment("列表排序")
private Integer listSortKey;
}

View File

@@ -61,5 +61,9 @@ public class EmpSalaryItemDto extends OrgCommonDto {
@DictTranslate(dictKey = DictCode.EMP_SALARY_ITEM_DECIMALPLACESHANDLER)
private String decimalPlacesHandlerName;
@Comment("是否显示在列表")
private Boolean listShow;
@Comment("列表排序")
private Integer listSortKey;
}

View File

@@ -50,6 +50,10 @@ public class UpdateEmpSalaryItemDto extends OrgCommonDto {
@Comment("小数位处理方式 0-四舍五入 1-截断 2-进位")
private String decimalPlacesHandler;
@Comment("是否显示在列表")
private Boolean listShow;
@Comment("列表排序")
private Integer listSortKey;
}

View File

@@ -63,4 +63,12 @@ public class EmpSalaryItemEntity extends OrgCommonEntity {
@Comment("小数位处理方式 0-四舍五入 1-截断 2-进位")
private String decimalPlacesHandler;
@Comment("是否显示在列表")
private Boolean listShow;
@Comment("列表排序")
private Integer listSortKey;
}

View File

@@ -57,6 +57,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.YearMonth;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
@@ -207,7 +208,8 @@ public class EmpSalaryItemService
Float.class,
Double.class,
Long.class,
BigDecimal.class));
BigDecimal.class,
YearMonth.class));
}
});
}
@@ -445,9 +447,10 @@ public class EmpSalaryItemService
&& ObjectUtils.notEqual(oldName, newName)) {
if (StringUtils.isNotEmpty(item.getFormulaShow())
&& item.getFormulaShow().contains(oldName)) {
&& item.getFormulaShow().matches("\\b" + oldName + "\\b")) {
item.setFormulaShow(item.getFormulaShow().replace(oldName, newName));
item.setFormulaShow(
item.getFormulaShow().replaceAll("\\b" + oldName + "\\b", newName));
}
}
}
@@ -483,6 +486,9 @@ public class EmpSalaryItemService
String oldName = entity.getName();
String newName = request.getName();
if (!newName.matches("^[a-zA-Z0-9\\u4e00-\\u9fa5]+$")) {
throw new BizException("工资项目名称只能包含中文、英文、数字");
}
if (repository.count(
(Specification<EmpSalaryItemEntity>)
(root, query, criteriaBuilder) ->
@@ -569,6 +575,7 @@ public class EmpSalaryItemService
for (int i = 0; i < 50; i++) {
EmpSalaryItemEntity item = new EmpSalaryItemEntity();
item.setItemType("1");
item.setInputType("1");
item.setFormulaShow("");
@@ -581,7 +588,11 @@ public class EmpSalaryItemService
item.setRemarks("");
item.setSortKey(i);
item.setStatus(0);
item.setDecimalPlaces(2);
item.setDecimalPlacesHandler("0");
item.setShow(true);
item.setListShow(true);
item.setListSortKey(i);
repository.save(item);
}
@@ -597,6 +608,9 @@ public class EmpSalaryItemService
item.setCode("yfheji");
item.setRemarks("");
item.setSortKey(51);
item.setShow(true);
item.setListShow(true);
item.setListSortKey(51);
item.setStatus(1);
item.setSystemPreset(true);
@@ -614,6 +628,9 @@ public class EmpSalaryItemService
item2.setCode("kfheji");
item2.setRemarks("");
item2.setSortKey(52);
item2.setListSortKey(52);
item2.setShow(true);
item2.setListShow(true);
item2.setStatus(1);
item2.setSystemPreset(true);
@@ -631,6 +648,9 @@ public class EmpSalaryItemService
item3.setCode("sfheji");
item3.setRemarks("");
item3.setSortKey(53);
item3.setListSortKey(53);
item3.setShow(true);
item3.setListShow(true);
item3.setStatus(1);
item3.setSystemPreset(false);
@@ -732,8 +752,6 @@ public class EmpSalaryItemService
for (EmpSalaryItemEntity item : items) {
roundScript
.append("salary.")
.append(item.getCode())
@@ -779,9 +797,6 @@ public class EmpSalaryItemService
.append(" ?: 0")
.append(";\n");
continue;
}
@@ -814,11 +829,8 @@ public class EmpSalaryItemService
script.append("salary.")
.append(item.getCode())
.append(" = (")
.append(item.getFormula())
.append(item.getFormula().trim())
.append(") ?: 0 ;\n");
}
script.append("// 工资项目结束\n");
@@ -850,14 +862,9 @@ public class EmpSalaryItemService
return this.repository.computeCacheKey(organizationId);
}
public Script newScriptInstance(String organizationId) {
public Script newScriptInstance(String organizationId){
return groovyScriptManager.newInstance(computeCacheKey(organizationId), () -> genScript(organizationId));
return groovyScriptManager.newInstance(
computeCacheKey(organizationId), () -> genScript(organizationId));
}
}

View File

@@ -6,6 +6,8 @@ import cn.lihongjie.coal.department.dto.DepartmentDto;
import cn.lihongjie.coal.jobPost.dto.JobPostDto;
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
import io.vavr.control.Try;
import jakarta.persistence.ManyToOne;
import lombok.Data;
@@ -13,6 +15,8 @@ import lombok.Data;
import org.hibernate.annotations.Comment;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
@Data
public class EmployeeCalculateDto extends OrgCommonDto {
@@ -138,4 +142,62 @@ public class EmployeeCalculateDto extends OrgCommonDto {
@Comment("出生日期")
private LocalDate birthday;
public Map<String, Object> toCtxMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("sex", this.sex);
map.put("sexName", this.sexName);
map.put("nation", this.nation);
map.put("nationName", this.nationName);
map.put("marriage", this.marriage);
map.put("marriageName", this.marriageName);
map.put("entryDate", this.entryDate);
map.put("idCard", this.idCard);
map.put("education", this.education);
map.put("educationName", this.educationName);
map.put("school", this.school);
map.put("nativePlace", this.nativePlace);
map.put("address", this.address);
map.put("phone", this.phone);
// map.put("department", this.department);
// map.put("jobPost", this.jobPost);
map.put("bank", this.bank);
map.put("bankName", this.bankName);
map.put("bankCardNumber", this.bankCardNumber);
map.put("bankCardName", this.bankCardName);
map.put("resignDate", this.resignDate);
map.put("resignReason", this.resignReason);
map.put("empStatus", this.empStatus);
map.put("empStatusName", this.empStatusName);
map.put("insurance1Base", this.insurance1Base);
map.put("insurance1Percent", this.insurance1Percent);
map.put("insurance2Base", this.insurance2Base);
map.put("insurance2Percent", this.insurance2Percent);
map.put("insurance3Base", this.insurance3Base);
map.put("insurance3Percent", this.insurance3Percent);
map.put("insurance4Base", this.insurance4Base);
map.put("insurance4Percent", this.insurance4Percent);
map.put("insurance5Base", this.insurance5Base);
map.put("insurance5Percent", this.insurance5Percent);
map.put("insurance6Base", this.insurance6Base);
map.put("insurance6Percent", this.insurance6Percent);
map.put("workAge", this.workAge);
map.put("age", this.age);
map.put("birthday", this.birthday);
map.put("empId", this.getId());
map.put("empName", this.getName());
map.put("empCode", this.getCode());
Try.run(() -> map.put("departmentId", this.getDepartment().getId()));
Try.run(() -> map.put("departmentCode", this.getDepartment().getCode()));
Try.run(() -> map.put("departmentName", this.getDepartment().getName()));
Try.run(() -> map.put("jobPostId", this.getJobPost().getId()));
Try.run(() -> map.put("jobPostCode", this.getJobPost().getCode()));
Try.run(() -> map.put("jobPostName", this.getJobPost().getName()));
return map;
}
}

View File

@@ -179,7 +179,7 @@ public class EmployeeEntity extends OrgCommonEntity {
throw new BizException(this.getName() + " 入职时间不能为空");
}
long monthDiff = ChronoUnit.MONTHS.between(LocalDate.now(), entryDate);
long monthDiff = ChronoUnit.MONTHS.between(entryDate, LocalDate.now());
if (monthDiff < 0) {
throw new BizException(this.getName() + " 入职时间不能大于当前时间");