From f5680a8a16d80bdc2ee1f0295dbd6936d59180e7 Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Fri, 22 Dec 2023 03:54:27 +0000
Subject: [PATCH] 导出多余sheet页隐藏
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java | 331 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 281 insertions(+), 50 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
index 2a14cf4..4a0a7da 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -39,22 +39,25 @@
import me.zhengjie.modules.system.service.dto.*;
import me.zhengjie.modules.system.service.mapstruct.UserLoginMapper;
import me.zhengjie.modules.system.service.mapstruct.UserMapper;
-import me.zhengjie.modules.task.domain.TaskDaliy;
import me.zhengjie.modules.task.domain.TaskDaliyMongo;
import me.zhengjie.modules.task.domain.TaskMongo;
-import me.zhengjie.modules.task.domain.TaskUserMongo;
import me.zhengjie.modules.task.repository.TaskDaliyRepository;
import me.zhengjie.modules.task.service.TaskDaliyService;
import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria;
+import me.zhengjie.modules.treatment.domain.*;
+import me.zhengjie.modules.treatment.repository.*;
+import me.zhengjie.modules.treatment.rest.CmnInsuranceController;
import me.zhengjie.utils.*;
import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
@@ -110,8 +113,18 @@
private final SysCompanyRepository sysCompanyRepository;
private final TaskDaliyService taskDaliyService;
private final DeptRepository deptRepository;
+ private final MeritLevelRepository meritLevelRepository;
+ private final CmnLevelRepository cmnLevelRepository;
+ private final MeritWageRepository meritWageRepository;
+ private final CmnLevelRankRepository cmnLevelRankRepository;
+ private final CmnInsuranceRepository cmnInsuranceRepository;
private final MongoTemplate mongoTemplate;
+ private final UserLevelWageRepository userLevelWageRepository;
+ private final UserInsuranceRepository userInsuranceRepository;
+
+ @Autowired
+ private CacheManager cacheManager;
@Override
public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
@@ -224,6 +237,7 @@
/**
* 任务下的所有子级
+ *
* @param taskMongo
* @param containUserList
*/
@@ -381,12 +395,12 @@
if (resultList.isEmpty()) {
Map map = new HashMap();
map.put("name", taskName);
- if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")){
+ if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) {
map.put("value", taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
- }else {
+ } else {
map.put("value", taskDaliyMongo.getConsumedHours());
}
- map.put(taskDaliyMongo.getTaskUserMongo().getName(),taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
+ map.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
resultList.add(map);
continue;
}
@@ -396,13 +410,13 @@
for (Map map : resultList) {
ArrayList<Map> list = new ArrayList<>();
for (Object key : map.keySet()) {
- if (!key.equals("name") && !key.equals("value")){
+ if (!key.equals("name") && !key.equals("value")) {
Map innerMap = new HashMap();
- innerMap.put(key,map.get(key));
+ innerMap.put(key, map.get(key));
list.add(innerMap);
}
}
- map.put("list",list);
+ map.put("list", list);
}
return resultList;
}
@@ -414,7 +428,7 @@
User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
Role role = user1.getRoles().iterator().next();
//超管、总经理,痛苦哦经理查看全部
- if(Long.valueOf(role.getLevel()) == Constant.ROLE_LEVEL_SUPER || Long.valueOf(role.getLevel()) == Constant.ROLE_LEVEL_GENERAL){
+ if (Long.valueOf(role.getLevel()) == Constant.ROLE_LEVEL_SUPER || Long.valueOf(role.getLevel()) == Constant.ROLE_LEVEL_GENERAL) {
userList = userRepository.findAllByEnabled(true);
} else {
userList = userRepository.findByUserId(user1.getId());
@@ -435,21 +449,21 @@
Double value = (Double) map.get("value");
value += taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours();
map.put("value", value);
- map.put(taskDaliyMongo.getTaskUserMongo().getName(),taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
+ map.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
flag = true;
}
}
// 无
if (!flag) {
Map newMap = new HashMap();
- if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")){
+ if (taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) {
newMap.put("name", taskDaliyMongo.getTaskUserMongo().getTask().getName());
newMap.put("value", taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
- newMap.put(taskDaliyMongo.getTaskUserMongo().getName(),taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
- }else {
+ newMap.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
+ } else {
newMap.put("name", taskDaliyMongo.getTaskUserMongo().getTask().getName());
newMap.put("value", taskDaliyMongo.getConsumedHours());
- newMap.put(taskDaliyMongo.getTaskUserMongo().getName(),taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
+ newMap.put(taskDaliyMongo.getTaskUserMongo().getName(), taskDaliyMongo.getConsumedHours() > taskDaliyMongo.getTaskUserMongo().getPerformanceHours() ? taskDaliyMongo.getTaskUserMongo().getPerformanceHours() : taskDaliyMongo.getConsumedHours());
}
resultList.add(newMap);
}
@@ -467,6 +481,7 @@
@Override
@Cacheable(key = "'total'")
+// @CacheEvict(value = "total", allEntries = true)
@Transactional(rollbackFor = Exception.class)
public List<UserDto> queryAll(UserQueryCriteria criteria) {
criteria.setEnabled(true);
@@ -519,9 +534,12 @@
throw new EntityExistException(User.class, "phone", resources.getPhone());
}
redisUtils.del(CacheKey.TOTAL_USER);
+ redisUtils.del("user::AllUser");
userRepository.save(resources);
// 判断用户级别变更
checkUserLevel(resources.getId(), null, resources.getLevelId());
+ // 判断用户级别变更(新)
+ checkUserLevelNew(resources);
}
@Override
@@ -575,9 +593,12 @@
user.setLevelId(resources.getLevelId());
// 临时新用户级别ID
Long tempNewLevelId = user.getLevelId();
+ redisUtils.del("user::AllUser");
userRepository.save(user);
// 判断用户级别变更
checkUserLevel(user.getId(), tempOldLevelId, tempNewLevelId);
+// // 判断用户级别变更(新)
+// checkUserLevelNew(resources, tempOldLevelId, tempNewLevelId);
// 清除缓存
delCaches(user.getId(), user.getUsername());
}
@@ -923,18 +944,18 @@
// 查询日报表是否存在小于当前月填写的当前任务的日报
List<TaskDaliyMongo> taskDaliyMongoSm = mongoTemplate.find(Query.query(new Criteria("userId").is(SecurityUtils.getCurrentUserId()).and("old_task_id").is(taskDaliyMongo.getOld_task_id()).and("fillDate").lte(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime))).with(Sort.by(Sort.Direction.DESC, "fillDate")), TaskDaliyMongo.class);
//跨月
- if(taskDaliyMongoSm.size() > 0) {
+ if (taskDaliyMongoSm.size() > 0) {
Double horseValue1 = Double.valueOf(decimalFormat.format((taskDaliyMongoSm.get(0).getTaskProgress() / 100) * taskDaliyMongo.getTaskUserMongo().getPerformanceHours()));
horseValue1 = taskDaliyMongo.getTaskUserMongo().getPerformanceHours() - horseValue1;
completedWork += horseValue1;
- }else {
+ } else {
completedWork += taskDaliyMongo.getTaskUserMongo().getPerformanceHours();
}
}
}
// 非绩效
- for(TaskDaliyMongo taskDaliyMongo : daliyMongoList) {
+ for (TaskDaliyMongo taskDaliyMongo : daliyMongoList) {
//非绩效
if (!taskDaliyMongo.getTaskUserMongo().getPerformanceType().equals("1")) {
completedWork += taskDaliyMongo.getConsumedHours();
@@ -1073,14 +1094,15 @@
* @param newLevelId
*/
private void checkUserLevel(Long userId, Long oldLevelId, Long newLevelId) {
+ // 查询级别表
+ SysLevel sysLevel = sysLevelRepository.findById(newLevelId).orElseGet(SysLevel::new);
// 判断新旧用户级别ID是否相等
if (oldLevelId == null) {
- // 创建用户级别工资
+ // 创建用户级别工资(旧)
createSysUserLevelWage(userId, newLevelId);
- // 创建用户级别保险
+ // 创建用户级别保险(旧)
createSysUserLevelInsurance(userId, newLevelId);
- // 创建用户级别其他
- createSysUserLevelOther(userId, newLevelId);
+
} else if (oldLevelId != newLevelId) {
// 旧用户级别工资
SysUserLevelWage oldSysUserLevelWage = sysUserLevelWageRepository.findLastByUserId(userId);
@@ -1107,7 +1129,7 @@
// 保存
sysUserLevelWageRepository.save(oldSysUserLevelWage);
}
- // 创建用户级别工资
+ // 创建用户级别工资(旧)
createSysUserLevelWage(userId, newLevelId);
// 旧用户级别保险
SysUserLevelInsurance oldSysUserLevelInsurance = sysUserLevelInsuranceRepository.findLastByUserId(userId);
@@ -1134,7 +1156,7 @@
// 保存
sysUserLevelInsuranceRepository.save(oldSysUserLevelInsurance);
}
- // 创建用户级别保险
+ // 创建用户级别保险(旧)
createSysUserLevelInsurance(userId, newLevelId);
// 旧用户级别其他
SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId);
@@ -1161,15 +1183,246 @@
// 保存
sysUserLevelOtherRepository.save(oldSysUserLevelOther);
}
- // 创建用户级别其他
- createSysUserLevelOther(userId, newLevelId);
} else {
}
}
/**
- * 创建用户级别工资
+ * 判断用户级别变更
+ *
+ * @param resources
+ */
+ private void checkUserLevelNew(User resources) {
+ // 查询级别管理表
+ CmnLevel cmnLevel = cmnLevelRepository.findById(resources.getLevelId()).orElseGet(CmnLevel::new);
+ for (int i = 0; i < 2; i++) {
+ if (i == 1) {
+ // 创建第二条用户级别工资(新)
+ createNewSysUserLevelWage(resources, cmnLevel, EnumerationType.SECOND_ENUM);
+ // 创建第二条用户级别保险 (新)
+ createNewSysUserLevelInsurance(resources, EnumerationType.SECOND_ENUM);
+ } else {
+ // 创建第一条用户级别工资(新)
+ createNewSysUserLevelWage(resources, cmnLevel, EnumerationType.FIRST_ENUM);
+ // 创建第一条用户级别保险 (新)
+ createNewSysUserLevelInsurance(resources, EnumerationType.FIRST_ENUM);
+ }
+ }
+ // 创建用户级别其他(新)
+ createSysUserLevelOther(resources, cmnLevel);
+ }
+
+ /**
+ * 创建用户级别工资(新)
+ *
+ * @param resources
+ * @param cmnLevel
+ */
+ private void createNewSysUserLevelWage(User resources, CmnLevel cmnLevel, EnumerationType enumType) {
+ Calendar calendar = Calendar.getInstance();
+ // 用户级别工资
+ UserLevelWage userLevelWage = new UserLevelWage();
+ userLevelWage.setUserId(resources.getId());
+ userLevelWage.setLevel(cmnLevel.getId());
+ // 获取试用期结束的月初时间
+ Timestamp result1 = getConfirmationTime(resources);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+ String resultValue = sdf.format(result1);
+ if (enumType.equals(EnumerationType.FIRST_ENUM)) {
+ userLevelWage.setYearMonth(sdf.format(new Timestamp(calendar.getTimeInMillis())));
+ } else {
+ userLevelWage.setYearMonth(resultValue);
+ }
+ // 查询最小的等级
+ MeritLevel meritLevel = meritLevelRepository.findMinMeritStandardByLevelId(cmnLevel.getId());
+ userLevelWage.setRank(meritLevel.getId());
+ userLevelWage.setBasicWage(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(cmnLevel.getBasicWage().doubleValue() * 0.8) :cmnLevel.getBasicWage());
+ userLevelWage.setRankWage(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(cmnLevel.getRankWage().doubleValue() * 0.8) : cmnLevel.getRankWage());
+ userLevelWage.setPerformanceWage(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(cmnLevel.getPerformanceWage().doubleValue() * 0.8) : cmnLevel.getPerformanceWage());
+ // 查询绩效系数
+ CmnLevelRank cmnLevelRank = cmnLevelRankRepository.findbylevelSm(cmnLevel.getId());
+ userLevelWage.setPerformanceCoefficient(new BigDecimal(cmnLevelRank.getPerformanceCoefficient()));
+ // 保存
+ userLevelWageRepository.save(userLevelWage);
+ }
+
+ /**
+ * 创建用户级别保险 (新)
+ *
+ * @param resources
+ */
+ public void createNewSysUserLevelInsurance(User resources, EnumerationType enumType) {
+ Calendar calendar = Calendar.getInstance();
+ // 用户级别工资
+ UserInsurance userInsurance = new UserInsurance();
+ userInsurance.setUserId(resources.getId());
+ // 获取试用期结束的月初时间
+ Timestamp result = getConfirmationTime(resources);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+ String resultValue = sdf.format(result);
+ if (enumType.equals(EnumerationType.FIRST_ENUM)) {
+ userInsurance.setYearMonth(sdf.format(new Timestamp(calendar.getTimeInMillis())));
+ } else {
+ userInsurance.setYearMonth(resultValue);
+ }
+ // 根据选择的公司查询五险一金
+ CmnInsurance cmnInsurance = cmnInsuranceRepository.findByCompany(resources.getCompany()).orElseGet(CmnInsurance::new);
+ userInsurance.setAccumulationFund(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(0) : cmnInsurance.getAccumulationFund());
+ userInsurance.setAccumulationFundPersonal(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getAccumulationFundPersonal());
+ userInsurance.setAccumulationFundCompany(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getAccumulationFundCompany());
+ userInsurance.setRetirementInsurance(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(0) : cmnInsurance.getRetirementInsurance());
+ userInsurance.setRetirementInsurancePersonal(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getRetirementInsurancePersonal());
+ userInsurance.setRetirementInsuranceCompany(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getRetirementInsuranceCompany());
+ userInsurance.setMedicalInsurance(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(0) : cmnInsurance.getMedicalInsurance());
+ userInsurance.setMedicalInsurancePersonal(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getMedicalInsurancePersonal());
+ userInsurance.setMedicalInsuranceCompany(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getMedicalInsuranceCompany());
+ userInsurance.setUnemploymentInsurance(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(0) : cmnInsurance.getUnemploymentInsurance());
+ userInsurance.setUnemploymentInsurancePersonal(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getUnemploymentInsurancePersonal());
+ userInsurance.setUnemploymentInsuranceCompany(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getUnemploymentInsuranceCompany());
+ userInsurance.setBirthInsurance(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(0) : cmnInsurance.getBirthInsurance());
+ userInsurance.setBirthInsurancePersonal(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getBirthInsurancePersonal());
+ userInsurance.setBirthInsuranceCompany(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getBirthInsuranceCompany());
+ userInsurance.setEmploymentInsurance(enumType.equals(EnumerationType.FIRST_ENUM) ? new BigDecimal(0) : cmnInsurance.getEmploymentInsurance());
+ userInsurance.setEmploymentInsurancePersonal(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getEmploymentInsurancePersonal());
+ userInsurance.setEmploymentInsuranceCompany(enumType.equals(EnumerationType.FIRST_ENUM) ? new Double(0) : cmnInsurance.getEmploymentInsuranceCompany());
+ // 保存
+ userInsuranceRepository.save(userInsurance);
+ }
+
+ /**
+ * 创建用户级别其他(新)
+ * @param resources
+ * @param cmnLevel
+ */
+ private void createSysUserLevelOther(User resources, CmnLevel cmnLevel) {
+ SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM");
+ // 获取试用期结束的月初时间
+ Timestamp result = getConfirmationTime(resources);
+ // 获取实习期结束的年份
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(result);
+ int formalYear = calendar.get(Calendar.YEAR);
+ // 获取当前年份
+ int currentYear = Calendar.getInstance().get(Calendar.YEAR);
+
+// for (int i = 0; i < 2; i++) {
+// // 第一条记录
+// SysUserLevelOther sysUserLevelOther = new SysUserLevelOther();
+// sysUserLevelOther.setUserId(resources.getId());
+// sysUserLevelOther.setLevelId(cmnLevel.getId());
+// sysUserLevelOther.setPersonalPerformanceProportion(Double.valueOf(0));
+//
+// if (i == 1) {
+// // 计算剩余年假
+// Double annualLeave = getAnnualLeave(calendar);
+// sysUserLevelOther.setAnnualLeaveDays(annualLeave);
+// } else {
+// calendar.add(Calendar.YEAR, 1);
+// // 设置月份为一月
+// calendar.set(Calendar.MONTH, Calendar.JANUARY);
+// // 设置月份为一日
+// calendar.set(Calendar.DAY_OF_MONTH, 1);
+//
+// sysUserLevelOther.setAnnualLeaveDays(5.0);
+// }
+// // 年月
+// sysUserLevelOther.setYearMonth(sdf.format(calendar.getTime()));
+//
+//
+// sysUserLevelOtherRepository.save(sysUserLevelOther);
+// }
+
+ // 添加两条数据
+ for (int i = 0; i < 2; i++) {
+ if (i == 0) {
+ // 第一条记录
+ SysUserLevelOther sysUserLevelOther = new SysUserLevelOther();
+ sysUserLevelOther.setUserId(resources.getId());
+ sysUserLevelOther.setLevelId(cmnLevel.getId());
+ sysUserLevelOther.setPersonalPerformanceProportion(Double.valueOf(0));
+ // 计算剩余年假
+ Double annualLeave = getAnnualLeave(calendar);
+ sysUserLevelOther.setAnnualLeaveDays(annualLeave);
+ // 判断为今年设置为当前日期
+ if (formalYear == currentYear) {
+ sysUserLevelOther.setYearMonth(sdf.format(new Date()));
+ } else {
+ // 设置为明年转正日期
+ sysUserLevelOther.setYearMonth(sdf.format(calendar.getTime()));
+ }
+ sysUserLevelOtherRepository.save(sysUserLevelOther);
+ } else {
+ // 第二条记录
+ SysUserLevelOther sysUserLevelOther1 = new SysUserLevelOther();
+ sysUserLevelOther1.setUserId(resources.getId());
+ sysUserLevelOther1.setLevelId(cmnLevel.getId());
+ Calendar calendar1 = Calendar.getInstance();
+ calendar1.add(Calendar.YEAR, 1);
+ // 设置月份为一月
+ calendar1.set(Calendar.MONTH, Calendar.JANUARY);
+ calendar1.set(Calendar.DAY_OF_MONTH, 1);
+ sysUserLevelOther1.setPersonalPerformanceProportion(Double.valueOf(0));
+ sysUserLevelOther1.setAnnualLeaveDays(5.0);
+ // 判断实习期结束日期的年份不是今年,年份加1
+ if (formalYear != currentYear) {
+ // 在增加一年
+ calendar1.add(Calendar.YEAR, 1);
+ }
+ // 日期设置为 明年/后年 年初
+ sysUserLevelOther1.setYearMonth(sdf.format(calendar1.getTime()));
+ sysUserLevelOtherRepository.save(sysUserLevelOther1);
+ }
+ }
+ }
+
+ /**
+ * 获取转正的月初时间
+ *
+ * @return
+ */
+ private Timestamp getConfirmationTime(User resources) {
+ Calendar calendar = Calendar.getInstance();
+ // 获取 Calendar 对象所代表的时间
+ calendar.setTime(new Timestamp(calendar.getTimeInMillis()));
+ // 获取是一个月中的哪一天
+ int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
+ // 获取这个月有多少天
+ int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+ Timestamp result;
+ if (dayOfMonth <= daysInMonth / 2) {
+ // 实习时间为空默认三个月,用户是在前半个月加入的,算上本月获取两个月之后的日期
+ calendar.add(Calendar.MONTH, resources.getInternshipTime() == null ? 3 : resources.getInternshipTime());
+ } else {
+ // 用户是在后半个月加入的,不算本月获取三个月之后的日期
+ calendar.add(Calendar.MONTH, resources.getInternshipTime() == null ? 4 : resources.getInternshipTime() + 1);
+ }
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ result = new Timestamp(calendar.getTimeInMillis());
+ return result;
+ }
+
+ /**
+ * 获取年假
+ * @param calendar
+ * @return
+ */
+ private Double getAnnualLeave(Calendar calendar) {
+ // 转正的月份
+ int joinMonth = calendar.get(Calendar.MONTH);
+ Double annualLeave = 0.0;
+ int remainingMonths = 12 - joinMonth;
+ // 计算年假天数
+ annualLeave = (5.0 / 12) * remainingMonths;
+ BigDecimal big = new BigDecimal(annualLeave);
+ big = big.setScale(1, BigDecimal.ROUND_HALF_UP);
+ annualLeave = big.doubleValue();
+ return annualLeave;
+ }
+
+
+ /**
+ * 创建用户级别工资(旧)
*
* @param userId
* @param levelId
@@ -1191,7 +1444,7 @@
sysUserLevelWageRepository.save(sysUserLevelWage);
}
- // 创建用户级别保险
+ // 创建用户级别保险(旧)
private void createSysUserLevelInsurance(Long userId, Long levelId) {
// 级别
SysLevel sysLevel = sysLevelRepository.findById(levelId).orElseGet(SysLevel::new);
@@ -1221,26 +1474,4 @@
// 保存
sysUserLevelInsuranceRepository.save(sysUserLevelInsurance);
}
-
- /**
- * 创建用户级别其他
- *
- * @param userId
- * @param levelId
- */
- private void createSysUserLevelOther(Long userId, Long levelId) {
- // 级别
- SysLevel sysLevel = sysLevelRepository.findById(levelId).orElseGet(SysLevel::new);
- // 用户级别其他
- SysUserLevelOther sysUserLevelOther = new SysUserLevelOther();
- sysUserLevelOther.setUserId(userId);
- sysUserLevelOther.setLevelId(levelId);
- sysUserLevelOther.setStartDate(new Timestamp(new Date().getTime()));
- sysUserLevelOther.setPersonalPerformanceProportion(sysLevel.getPersonalPerformanceProportion());
- sysUserLevelOther.setAnnualLeaveDays(sysLevel.getAnnualLeaveDays());
- // 保存
- sysUserLevelOtherRepository.save(sysUserLevelOther);
- }
-
-
}
--
Gitblit v1.9.3