【组织单位】代码优化

This commit is contained in:
weizhiqiang 2022-06-25 11:51:19 +08:00
parent 15c0b43dc7
commit 28e49e4f52
9 changed files with 692 additions and 674 deletions

View file

@ -556,7 +556,7 @@ public class FileConsoleServiceImpl implements FileConsoleService {
public void editUploadOfficeFileById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
int status = Integer.parseInt(map.get("status").toString());
//当我们关闭编辑窗口后十秒钟左右onlyoffice会将它存储的我们的编辑后的文件此时status = 2
// 当我们关闭编辑窗口后十秒钟左右onlyoffice会将它存储的我们的编辑后的文件此时status = 2
if (status == 2 || status == 3) {//MustSave, Corrupted
map.put("key", map.get("key").toString().split("-")[0]);
URL url = new URL(map.get("url").toString());//新文件地址

View file

@ -19,12 +19,10 @@ import com.skyeye.eve.service.CompanyDepartmentService;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @ClassName: CompanyDepartmentController
* @Description: 部门管理控制类
* @author: skyeye云系列--卫志强
* @date: 2022/4/8 19:40
*
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@ -43,7 +41,7 @@ public class CompanyDepartmentController {
* @throws Exception
*/
@RequestMapping("/post/CompanyDepartmentController/queryCompanyDepartmentList")
public void queryCompanyDepartmentList(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyDepartmentList(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.queryCompanyDepartmentList(inputObject, outputObject);
}
@ -55,7 +53,7 @@ public class CompanyDepartmentController {
* @throws Exception
*/
@RequestMapping("/post/CompanyDepartmentController/insertCompanyDepartmentMation")
public void insertCompanyDepartmentMation(InputObject inputObject, OutputObject outputObject) throws Exception{
public void insertCompanyDepartmentMation(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.insertCompanyDepartmentMation(inputObject, outputObject);
}
@ -67,7 +65,7 @@ public class CompanyDepartmentController {
* @throws Exception
*/
@RequestMapping("/post/CompanyDepartmentController/deleteCompanyDepartmentMationById")
public void deleteCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception{
public void deleteCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.deleteCompanyDepartmentMationById(inputObject, outputObject);
}
@ -79,7 +77,7 @@ public class CompanyDepartmentController {
* @throws Exception
*/
@RequestMapping("/post/CompanyDepartmentController/queryCompanyDepartmentMationToEditById")
public void queryCompanyDepartmentMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyDepartmentMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.queryCompanyDepartmentMationToEditById(inputObject, outputObject);
}
@ -91,7 +89,7 @@ public class CompanyDepartmentController {
* @throws Exception
*/
@RequestMapping("/post/CompanyDepartmentController/editCompanyDepartmentMationById")
public void editCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception{
public void editCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.editCompanyDepartmentMationById(inputObject, outputObject);
}
@ -103,7 +101,7 @@ public class CompanyDepartmentController {
* @throws Exception
*/
@RequestMapping("/post/CompanyDepartmentController/queryCompanyDepartmentListTreeByCompanyId")
public void queryCompanyDepartmentListTreeByCompanyId(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyDepartmentListTreeByCompanyId(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.queryCompanyDepartmentListTreeByCompanyId(inputObject, outputObject);
}
@ -115,7 +113,7 @@ public class CompanyDepartmentController {
* @throws Exception
*/
@RequestMapping("/post/CompanyDepartmentController/queryCompanyDepartmentListByCompanyIdToSelect")
public void queryCompanyDepartmentListByCompanyIdToSelect(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyDepartmentListByCompanyIdToSelect(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.queryCompanyDepartmentListByCompanyIdToSelect(inputObject, outputObject);
}
@ -142,7 +140,7 @@ public class CompanyDepartmentController {
@ApiImplicitParams({
@ApiImplicitParam(id = "ids", name = "ids", value = "部门ids逗号隔开", required = "required")})
@RequestMapping("/post/CompanyDepartmentController/queryCompanyDepartmentListByIds")
public void queryCompanyDepartmentListByIds(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyDepartmentListByIds(InputObject inputObject, OutputObject outputObject) throws Exception {
companyDepartmentService.queryCompanyDepartmentListByIds(inputObject, outputObject);
}

View file

@ -30,7 +30,7 @@ public class CompanyJobController {
* @throws Exception
*/
@RequestMapping("/post/CompanyJobController/queryCompanyJobList")
public void queryCompanyJobList(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyJobList(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.queryCompanyJobList(inputObject, outputObject);
}
@ -42,7 +42,7 @@ public class CompanyJobController {
* @throws Exception
*/
@RequestMapping("/post/CompanyJobController/insertCompanyJobMation")
public void insertCompanyJobMation(InputObject inputObject, OutputObject outputObject) throws Exception{
public void insertCompanyJobMation(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.insertCompanyJobMation(inputObject, outputObject);
}
@ -54,7 +54,7 @@ public class CompanyJobController {
* @throws Exception
*/
@RequestMapping("/post/CompanyJobController/deleteCompanyJobMationById")
public void deleteCompanyJobMationById(InputObject inputObject, OutputObject outputObject) throws Exception{
public void deleteCompanyJobMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.deleteCompanyJobMationById(inputObject, outputObject);
}
@ -66,7 +66,7 @@ public class CompanyJobController {
* @throws Exception
*/
@RequestMapping("/post/CompanyJobController/queryCompanyJobMationToEditById")
public void queryCompanyJobMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyJobMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.queryCompanyJobMationToEditById(inputObject, outputObject);
}
@ -78,7 +78,7 @@ public class CompanyJobController {
* @throws Exception
*/
@RequestMapping("/post/CompanyJobController/editCompanyJobMationById")
public void editCompanyJobMationById(InputObject inputObject, OutputObject outputObject) throws Exception{
public void editCompanyJobMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.editCompanyJobMationById(inputObject, outputObject);
}
@ -90,7 +90,7 @@ public class CompanyJobController {
* @throws Exception
*/
@RequestMapping("/post/CompanyJobController/queryCompanyJobListTreeByDepartmentId")
public void queryCompanyJobListTreeByDepartmentId(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyJobListTreeByDepartmentId(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.queryCompanyJobListTreeByDepartmentId(inputObject, outputObject);
}
@ -105,7 +105,7 @@ public class CompanyJobController {
@ApiImplicitParams({
@ApiImplicitParam(id = "departmentId", name = "departmentId", value = "部门id")})
@RequestMapping("/post/CompanyJobController/queryCompanyJobListByToSelect")
public void queryCompanyJobListByToSelect(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyJobListByToSelect(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.queryCompanyJobListByToSelect(inputObject, outputObject);
}
@ -117,7 +117,7 @@ public class CompanyJobController {
* @throws Exception
*/
@RequestMapping("/post/CompanyJobController/queryCompanyJobSimpleListByToSelect")
public void queryCompanyJobSimpleListByToSelect(InputObject inputObject, OutputObject outputObject) throws Exception{
public void queryCompanyJobSimpleListByToSelect(InputObject inputObject, OutputObject outputObject) throws Exception {
companyJobService.queryCompanyJobSimpleListByToSelect(inputObject, outputObject);
}

View file

@ -9,6 +9,7 @@ import com.github.pagehelper.PageHelper;
import com.skyeye.common.constans.OrganizationConstants;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.DataCommonUtil;
import com.skyeye.common.util.DateUtil;
import com.skyeye.common.util.ToolUtil;
import com.skyeye.eve.dao.CompanyDepartmentDao;
@ -16,6 +17,7 @@ import com.skyeye.eve.service.CompanyDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Arrays;
@ -23,17 +25,15 @@ import java.util.List;
import java.util.Map;
/**
*
* @ClassName: CompanyDepartmentServiceImpl
* @Description: 公司部门信息管理服务类
* @author: skyeye云系列--卫志强
* @date: 2021/7/6 22:56
*
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Service
public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
public class CompanyDepartmentServiceImpl implements CompanyDepartmentService {
@Autowired
private CompanyDepartmentDao companyDepartmentDao;
@ -66,18 +66,16 @@ public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
* @throws Exception
*/
@Override
@Transactional(value="transactionManager")
@Transactional(value = "transactionManager")
public void insertCompanyDepartmentMation(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = companyDepartmentDao.queryCompanyDepartmentMationByName(map);
if(bean == null){
Map<String, Object> user = inputObject.getLogParams();
map.put("id", ToolUtil.getSurFaceId());
map.put("createId", user.get("id"));
if (ObjectUtils.isEmpty(bean)) {
String userId = inputObject.getLogParams().get("id").toString();
DataCommonUtil.setCommonData(map, userId);
map.put("pId", "0");
map.put("createTime", DateUtil.getTimeAndToString());
companyDepartmentDao.insertCompanyDepartmentMation(map);
}else{
} else {
outputObject.setreturnMessage("该公司部门名称已存在.");
}
}
@ -90,18 +88,18 @@ public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
* @throws Exception
*/
@Override
@Transactional(value="transactionManager")
@Transactional(value = "transactionManager")
public void deleteCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = companyDepartmentDao.queryCompanyDepartmentUserMationById(map);
if(Integer.parseInt(bean.get("childsNum").toString()) == 0){//判断是否有员工
if (Integer.parseInt(bean.get("childsNum").toString()) == 0) {//判断是否有员工
bean = companyDepartmentDao.queryCompanyJobNumMationById(map);
if(Integer.parseInt(bean.get("companyJobNum").toString()) == 0){//判断是否有职位
if (Integer.parseInt(bean.get("companyJobNum").toString()) == 0) {//判断是否有职位
companyDepartmentDao.deleteCompanyDepartmentMationById(map);
}else{
} else {
outputObject.setreturnMessage("该部门下存在职位,无法直接删除。");
}
}else{
} else {
outputObject.setreturnMessage("该部门下存在员工,无法直接删除。");
}
}
@ -130,13 +128,13 @@ public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
* @throws Exception
*/
@Override
@Transactional(value="transactionManager")
@Transactional(value = "transactionManager")
public void editCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = companyDepartmentDao.queryCompanyDepartmentMationByNameAndId(map);
if(bean == null){
if (bean == null) {
companyDepartmentDao.editCompanyDepartmentMationById(map);
}else{
} else {
outputObject.setreturnMessage("该公司部门名称已存在.");
}
}
@ -153,7 +151,7 @@ public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
Map<String, Object> map = inputObject.getParams();
List<Map<String, Object>> beans = companyDepartmentDao.queryCompanyDepartmentListTreeByCompanyId(map);
beans = ToolUtil.listToTree(beans, "id", "parentId", "children");
if(!beans.isEmpty()){
if (!beans.isEmpty()) {
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}
@ -170,7 +168,7 @@ public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
public void queryCompanyDepartmentListByCompanyIdToSelect(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
List<Map<String, Object>> beans = companyDepartmentDao.queryCompanyDepartmentListByCompanyIdToSelect(map);
if(!beans.isEmpty()){
if (!beans.isEmpty()) {
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}
@ -204,11 +202,11 @@ public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
Map<String, Object> map = inputObject.getParams();
List<String> idsList = Arrays.asList(map.get("ids").toString().split(","));
List<Map<String, Object>> beans = new ArrayList<>();
if(!idsList.isEmpty()){
if (!idsList.isEmpty()) {
beans = companyDepartmentDao.queryCompanyDepartmentListByIds(idsList);
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}else{
} else {
outputObject.setBeans(beans);
}
}

View file

@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.List;
@ -48,7 +49,7 @@ public class AnnualLeaveStatisticsQuartz {
@Autowired
private SysQuartzRunHistoryService sysQuartzRunHistoryService;
private static enum YearLimits{
private static enum YearLimits {
ONE_YEAR(0, 1, "1"), // 1年以下
ONE_THREE_YEAR(1, 3, "2"), // 1年 ~ 3年
THREE_FIVE_YEAR(3, 5, "3"), // 3年 ~ 5年
@ -87,14 +88,14 @@ public class AnnualLeaveStatisticsQuartz {
public void annualLeaveStatistics() throws Exception {
String historyId = sysQuartzRunHistoryService.startSysQuartzRun(QUARTZ_ID);
LOGGER.info("annualLeaveStatistics start.");
try{
try {
// 1.获取年假信息
List<Map<String, Object>> yearHolidaysMation = getSystemYearHolidaysMation();
// 2.获取所有在职状态的员工列表, 见习试用退休离职员工不计入计算
List<Map<String, Object>> userStaff = sysEveUserStaffDao.queryAllSysUserStaffListByState(Arrays.asList(new Integer[]{1}));
// 获取当前年月日
String nowDate = DateUtil.getYmdTimeAndToString();
for(Map<String, Object> staff : userStaff) {
for (Map<String, Object> staff : userStaff) {
String staffId = staff.get("id").toString();
// 员工当前剩余年假
String annualLeave = staff.get("annualLeave").toString();
@ -104,7 +105,7 @@ public class AnnualLeaveStatisticsQuartz {
int differDays = DateUtil.getDistanceDay(workTime, nowDate);
String differYear = getDifferYear(differDays);
Map<String, Object> yearMation = getConcertWithYearMation(Integer.parseInt(differYear), yearHolidaysMation);
if(yearMation != null && !yearMation.isEmpty()){
if (!ObjectUtils.isEmpty(yearMation)) {
String yearHour = yearMation.get("yearHour").toString();
// 获取每个季度应该相加的年假小时
String quarterYearHour = CalculationUtil.divide(yearHour, "4", 2);
@ -114,7 +115,7 @@ public class AnnualLeaveStatisticsQuartz {
sysEveUserStaffDao.editSysUserStaffAnnualLeaveById(staffId, annualLeave, DateUtil.getTimeAndToString());
}
}
} catch (Exception e){
} catch (Exception e) {
sysQuartzRunHistoryService.endSysQuartzRun(historyId, SysQuartzRunHistory.State.START_ERROR.getState());
LOGGER.warn("AnnualLeaveStatisticsQuartz error.", e);
}
@ -124,13 +125,14 @@ public class AnnualLeaveStatisticsQuartz {
/**
* 筛选已工作年份应该获取的年假信息
*
* @param differYear 已工作年份
* @param yearHolidaysMation 年假信息
* @return
*/
private Map<String, Object> getConcertWithYearMation(int differYear, List<Map<String, Object>> yearHolidaysMation){
for (YearLimits q : YearLimits.values()){
if(q.getMin() <= differYear && differYear < q.getMax()){
private Map<String, Object> getConcertWithYearMation(int differYear, List<Map<String, Object>> yearHolidaysMation) {
for (YearLimits q : YearLimits.values()) {
if (q.getMin() <= differYear && differYear < q.getMax()) {
List<Map<String, Object>> fillterMation = yearHolidaysMation.stream()
.filter(bean -> bean.get("yearType").toString().equals(q.getYearType()))
.collect(Collectors.toList());
@ -152,7 +154,7 @@ public class AnnualLeaveStatisticsQuartz {
*/
private String getDifferYear(int differDays) throws IllegalAccessException {
String year = CalculationUtil.divide(String.valueOf(differDays), "365", 2);
if(ToolUtil.isBlank(year)){
if (ToolUtil.isBlank(year)) {
return "0";
}
return year.split("\\.")[0];

View file

@ -69,9 +69,9 @@ public class CalcStaffWaitPayWages {
public void handler() throws Exception {
String historyId = sysQuartzRunHistoryService.startSysQuartzRun(QUARTZ_ID);
log.info("定时统计员工待结算薪资的数据定时任务开始执行");
try{
try {
calcWaitWages();
} catch (Exception e){
} catch (Exception e) {
sysQuartzRunHistoryService.endSysQuartzRun(historyId, SysQuartzRunHistory.State.START_ERROR.getState());
log.warn("CalcStaffWaitPayWages error.", e);
}
@ -104,19 +104,19 @@ public class CalcStaffWaitPayWages {
private String getAllOverTimeMoneyThisMonth(List<Map<String, Object>> overTimeList, String hourWages) throws Exception {
String allOverTimeHourThisMonth = "0";
for(Map<String, Object> bean: overTimeList) {
for (Map<String, Object> bean : overTimeList) {
// 加班工时
String overtimeHour = bean.get("overtimeHour").toString();
// 结算类型
int overtimeSettlementType = Integer.parseInt(bean.get("overtimeSettlementType").toString());
String money = "0";
if(overtimeSettlementType == 1){
if (overtimeSettlementType == 1) {
// 单倍薪资结算
money = CalculationUtil.multiply(2, overtimeHour, hourWages, "1");
} else if(overtimeSettlementType == 2){
} else if (overtimeSettlementType == 2) {
// 1.5倍薪资结算
money = CalculationUtil.multiply(2, overtimeHour, hourWages, "1.5");
} else if(overtimeSettlementType == 3){
} else if (overtimeSettlementType == 3) {
// 双倍薪资结算
money = CalculationUtil.multiply(2, overtimeHour, hourWages, "2");
}
@ -162,7 +162,7 @@ public class CalcStaffWaitPayWages {
}
private List<Map<String, Object>> getPointMonthCheckWorkTime(Map<String, List<Map<String, Object>>> cache, String pointMonthDate) throws Exception {
if(cache.containsKey(pointMonthDate)){
if (cache.containsKey(pointMonthDate)) {
return cache.get(pointMonthDate);
}
// 所有的考勤班次信息

View file

@ -60,19 +60,19 @@ public class StaffWagesPaymentQuartz {
public void staffWagesPayment() throws Exception {
String historyId = sysQuartzRunHistoryService.startSysQuartzRun(QUARTZ_ID);
LOGGER.info("staff wagesPayment month is start");
try{
try {
// 获取上个月的年月
String lastMonthDate = DateUtil.getLastMonthDate();
while (true){
while (true) {
// 获取一条未发放的员工薪资信息
Map<String, Object> staffWages = wagesPaymentHistoryDao.queryWaitPaymentStaffHistory(lastMonthDate, getStaffIdsFromRedis());
// 如果已经没有要发放薪资的员工则停止统计
if(staffWages == null){
if (staffWages == null) {
break;
}
String staffId = staffWages.get("staffId").toString();
// 判断该员工的薪资发放是否在处理中如果在处理中则进行下一条
if(isInWagesPaymentRedisMation(staffId)){
if (isInWagesPaymentRedisMation(staffId)) {
continue;
}
try {
@ -80,7 +80,7 @@ public class StaffWagesPaymentQuartz {
addStaffIdInWagesPaymentRedisMation(staffId);
// 开始发放
paymentStaffWages(staffWages, lastMonthDate);
} catch (Exception e){
} catch (Exception e) {
LOGGER.warn("deal with staff failed, staffId is {}", staffId, e);
break;
} finally {
@ -89,7 +89,7 @@ public class StaffWagesPaymentQuartz {
}
}
deleteWagesPaymentRedisMation();
} catch (Exception e){
} catch (Exception e) {
sysQuartzRunHistoryService.endSysQuartzRun(historyId, SysQuartzRunHistory.State.START_ERROR.getState());
LOGGER.warn("StaffWagesPaymentQuartz error.", e);
}
@ -108,8 +108,6 @@ public class StaffWagesPaymentQuartz {
// 这里处理薪资发放的信息
wagesPaymentHistoryDao.editToPaymentByStaffAndPayMonth(staffId, lastMonthDate);
}
@ -118,7 +116,7 @@ public class StaffWagesPaymentQuartz {
*
* @param staffIds 员工ids
*/
private void setToRedis(List<String> staffIds){
private void setToRedis(List<String> staffIds) {
// 默认存储时间为六个小时
jedisClient.set(IN_WAGES_PAYMENT_STAFF_REDIS_KEY, JSONUtil.toJsonStr(staffIds), 60 * 60 * 6);
}
@ -128,7 +126,7 @@ public class StaffWagesPaymentQuartz {
*
* @param staffId 员工id
*/
private void removeStaffIdInWagesPaymentRedisMation(String staffId){
private void removeStaffIdInWagesPaymentRedisMation(String staffId) {
List<String> staffIds = getStaffIdsFromRedis();
staffIds = staffIds.stream().filter(str -> !staffId.equals(str)).collect(Collectors.toList());
setToRedis(staffIds);
@ -139,7 +137,7 @@ public class StaffWagesPaymentQuartz {
*
* @param staffId 员工id
*/
private void addStaffIdInWagesPaymentRedisMation(String staffId){
private void addStaffIdInWagesPaymentRedisMation(String staffId) {
List<String> staffIds = getStaffIdsFromRedis();
staffIds.add(staffId);
setToRedis(staffIds);
@ -151,18 +149,18 @@ public class StaffWagesPaymentQuartz {
* @param staffId 员工id
* @return true处理中false未在处理
*/
private boolean isInWagesPaymentRedisMation(String staffId){
private boolean isInWagesPaymentRedisMation(String staffId) {
List<String> staffIds = getStaffIdsFromRedis();
return staffIds.contains(staffId);
}
private void deleteWagesPaymentRedisMation(){
private void deleteWagesPaymentRedisMation() {
jedisClient.del(IN_WAGES_PAYMENT_STAFF_REDIS_KEY);
}
private List<String> getStaffIdsFromRedis(){
private List<String> getStaffIdsFromRedis() {
List<String> staffIds = new ArrayList<>();
if(jedisClient.exists(IN_WAGES_PAYMENT_STAFF_REDIS_KEY)){
if (jedisClient.exists(IN_WAGES_PAYMENT_STAFF_REDIS_KEY)) {
staffIds = JSONUtil.toList(JSONUtil.parseArray(jedisClient.get(IN_WAGES_PAYMENT_STAFF_REDIS_KEY)), null);
}
return staffIds;

View file

@ -26,12 +26,10 @@ import java.util.*;
import java.util.stream.Collectors;
/**
*
* @ClassName: StaffWagesQuartz
* @Description: 定时统计上个月员工的薪资情况
* @author: skyeye云系列--卫志强
* @date: 2021/4/5 18:28
*
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目
*/
@ -81,16 +79,18 @@ public class StaffWagesQuartz {
@Autowired
private SysQuartzRunHistoryService sysQuartzRunHistoryService;
public enum AbnormalCheckworkType{
public enum AbnormalCheckworkType {
ABNORMAL_LEAVEEARLY("leaveEarly", "早退"),
ABNORMAL_LATE("late", "迟到"),
ABNORMAL_MINER("miner", "旷工");
private String key;
private String name;
AbnormalCheckworkType(String key, String name){
AbnormalCheckworkType(String key, String name) {
this.key = key;
this.name = name;
}
public String getKey() {
return key;
}
@ -109,7 +109,7 @@ public class StaffWagesQuartz {
@Scheduled(cron = "0 0 2 10 * ?")
public void statisticsStaffWages() throws Exception {
String historyId = sysQuartzRunHistoryService.startSysQuartzRun(QUARTZ_ID);
try{
try {
// 获取上个月的年月
String lastMonthDate = DateUtil.getLastMonthDate();
LOGGER.info("statistics staff wages month is {}", lastMonthDate);
@ -124,16 +124,16 @@ public class StaffWagesQuartz {
// 所有的考勤班次信息
List<Map<String, Object>> workTime =
ExecuteFeignClient.get(() -> checkWorkTimeService.getAllCheckWorkTime(lastMonthDate)).getRows();
while (true){
while (true) {
// 获取一条未生成薪资的员工数据
Map<String, Object> staff = wagesStaffMationDao.queryNoWagesLastMonthByLastMonthDate(lastMonthDate, getStaffIdsFromRedis());
// 如果已经没有要统计薪资的员工则停止统计
if(staff == null){
if (staff == null) {
break;
}
String staffId = staff.get("id").toString();
// 判断该员工的薪资统计是否在处理中如果在处理中则进行下一条
if(isInStatisticsRedisMation(staffId)){
if (isInStatisticsRedisMation(staffId)) {
continue;
}
try {
@ -143,7 +143,7 @@ public class StaffWagesQuartz {
calcStaffWages(staff, wagesModelMation, socialSecurityFund, systemFoundationSettings, workTime, lastMonthDate, taxRate);
// 将指定员工月度清零的薪资字段设置为0
wagesStaffMationDao.editStaffMonthlyClearingWagesByStaffId(staffId);
} catch (Exception e){
} catch (Exception e) {
LOGGER.warn("deal with staff failed, staffId is {}", staffId, e);
break;
} finally {
@ -152,7 +152,7 @@ public class StaffWagesQuartz {
}
}
deleteStatisticsRedisMation();
} catch (Exception e){
} catch (Exception e) {
sysQuartzRunHistoryService.endSysQuartzRun(historyId, SysQuartzRunHistory.State.START_ERROR.getState());
LOGGER.warn("StaffWagesQuartz error.", e);
}
@ -270,7 +270,7 @@ public class StaffWagesQuartz {
wagesPaymentHistoryDao.insertWagesPaymentHistoryMation(map);
}
public static List<Map<String, Object>> removeDuplicateUser(List<Map<String, Object>> beans){
public static List<Map<String, Object>> removeDuplicateUser(List<Map<String, Object>> beans) {
Set<Map<String, Object>> set = new TreeSet<>((bean1, bean2) -> bean1.get("modelId").toString().compareTo(bean2.get("modelId").toString()));
set.addAll(beans);
return new ArrayList<>(set);
@ -284,23 +284,23 @@ public class StaffWagesQuartz {
* @param modelIds 员工拥有的模板的模型id
* @return
*/
private List<Map<String, Object>> getWagesJson(List<Map<String, Object>> staffModelField, Map<String, String> staffModelFieldMap, List<String> modelIds){
private List<Map<String, Object>> getWagesJson(List<Map<String, Object>> staffModelField, Map<String, String> staffModelFieldMap, List<String> modelIds) {
List<Map<String, Object>> beans = new ArrayList<>();
if(modelIds != null || !modelIds.isEmpty()){
for(Map<String, Object> model: staffModelField){
if (modelIds != null || !modelIds.isEmpty()) {
for (Map<String, Object> model : staffModelField) {
Map<String, Object> bean = new HashMap<>();
bean.put("name", model.get("title"));
bean.put("modelId", model.get("modelId"));
List<Map<String, Object>> childFields = new ArrayList<>();
List<Map<String, Object>> fields = (List<Map<String, Object>>) model.get("fieldList");
for(Map<String, Object> field: fields){
for (Map<String, Object> field : fields) {
Map<String, Object> childField = new HashMap<>();
childField.put("name", field.get("nameCn"));
String formula = field.get("formula").toString();
String key = field.get("fieldKey").toString();
if(ToolUtil.isBlank(formula)){
if (ToolUtil.isBlank(formula)) {
childField.put("moneyValue", staffModelFieldMap.get(key));
}else{
} else {
childField.put("moneyValue", ReflexUtil.convertToCode(formula, staffModelFieldMap));
}
childField.put("key", key);
@ -325,7 +325,7 @@ public class StaffWagesQuartz {
* @param staffModelFieldMap 薪资数据
* @return
*/
private List<Map<String, Object>> getSocialSecurityFundWagesJson(Map<String, String> staffModelFieldMap){
private List<Map<String, Object>> getSocialSecurityFundWagesJson(Map<String, String> staffModelFieldMap) {
List<Map<String, Object>> beans = new ArrayList<>();
Map<String, Object> bean = new HashMap<>();
bean.put("name", "社保公积金");
@ -355,7 +355,7 @@ public class StaffWagesQuartz {
* @param staffModelFieldMap 薪资数据
* @return
*/
private List<Map<String, Object>> getTaxRateWagesJson(Map<String, String> staffModelFieldMap){
private List<Map<String, Object>> getTaxRateWagesJson(Map<String, String> staffModelFieldMap) {
List<Map<String, Object>> beans = new ArrayList<>();
Map<String, Object> bean = new HashMap<>();
bean.put("name", "个人缴税");
@ -392,7 +392,7 @@ public class StaffWagesQuartz {
}).collect(Collectors.toList());
// 缴纳的税额
String taxRateMoney = "0";
if(staffTaxRate != null && !staffTaxRate.isEmpty()){
if (staffTaxRate != null && !staffTaxRate.isEmpty()) {
taxRateMoney = CalculationUtil.multiply(monthlyStandardRealMoney,
CalculationUtil.divide(getMonthRate(lastMonthDate, staffTaxRate), "100", 2), 4);
}
@ -413,19 +413,43 @@ public class StaffWagesQuartz {
Map<String, Object> taxRate = staffTaxRate.get(0);
String month = lastMonthDate.split("-")[1];
String key = "";
switch (month){
case "01": key = "janRate"; break;
case "02": key = "febRate"; break;
case "03": key = "marRate"; break;
case "04": key = "aprRate"; break;
case "05": key = "mayRate"; break;
case "06": key = "junRate"; break;
case "07": key = "julRate"; break;
case "08": key = "augRate"; break;
case "09": key = "septRate"; break;
case "10": key = "octRate"; break;
case "11": key = "novRate"; break;
case "12": key = "decRate"; break;
switch (month) {
case "01":
key = "janRate";
break;
case "02":
key = "febRate";
break;
case "03":
key = "marRate";
break;
case "04":
key = "aprRate";
break;
case "05":
key = "mayRate";
break;
case "06":
key = "junRate";
break;
case "07":
key = "julRate";
break;
case "08":
key = "augRate";
break;
case "09":
key = "septRate";
break;
case "10":
key = "octRate";
break;
case "11":
key = "novRate";
break;
case "12":
key = "decRate";
break;
}
return taxRate.get(key).toString();
}
@ -488,7 +512,7 @@ public class StaffWagesQuartz {
staffModelFieldMap.get(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_HOUR.getKey()), 2);
// 销假要退还给员工的钱
String cancleLeaveMoney = "0";
for(Map<String, Object> bean : cancleLeaveTime){
for (Map<String, Object> bean : cancleLeaveTime) {
// 销假的时长分钟
String cancelMinute = DateUtil.getDistanceMinuteByHMS(bean.get("cancelStartTime").toString(), bean.get("cancelEndTime").toString());
String cancelHourTime = CalculationUtil.divide(cancelMinute, "60", 2);
@ -541,16 +565,16 @@ public class StaffWagesQuartz {
*/
private String calcMoney(List<String> minute, List<Map<String, Object>> abnormalTypes, Map<String, String> staffModelFieldMap,
String key) throws Exception {
if(abnormalTypes != null && !abnormalTypes.isEmpty()){
if (abnormalTypes != null && !abnormalTypes.isEmpty()) {
Map<String, Object> abnormalType = abnormalTypes.get(0);
// 扣费类型 1.按次扣费 2.按时间扣费
String abnormal = abnormalType.get("abnormal").toString();
if("1".equals(abnormal)){
if ("1".equals(abnormal)) {
// 次数
String num = staffModelFieldMap.get(key);
// 次数*扣款金额保留四位小数
return CalculationUtil.multiply(num, abnormalType.get("abnormalMoney").toString(), 4);
}else if("2".equals(abnormal)){
} else if ("2".equals(abnormal)) {
// 与默认的一样(按时间扣费)
}
}
@ -559,7 +583,7 @@ public class StaffWagesQuartz {
staffModelFieldMap.get(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.MONTHLY_STANDARD_SALARY.getKey()),
staffModelFieldMap.get(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_HOUR.getKey()), 4);
String resultMoney = "0";
for(String str: minute){
for (String str : minute) {
resultMoney = CalculationUtil.add(
resultMoney,
CalculationUtil.multiply(2, CalculationUtil.divide(str, "60", 2), hourWages), 4);
@ -575,16 +599,16 @@ public class StaffWagesQuartz {
* @return
*/
private String calcMinerMoney(List<Map<String, Object>> abnormalTypes, Map<String, String> staffModelFieldMap) throws Exception {
if(abnormalTypes != null && !abnormalTypes.isEmpty()){
if (abnormalTypes != null && !abnormalTypes.isEmpty()) {
Map<String, Object> abnormalType = abnormalTypes.get(0);
// 扣费类型 1.按次扣费 2.按时间扣费
String abnormal = abnormalType.get("abnormal").toString();
if("1".equals(abnormal)){
if ("1".equals(abnormal)) {
// 缺勤次数
String num = staffModelFieldMap.get(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_DUTY_NUM.getKey());
// 次数*扣款金额保留四位小数
return CalculationUtil.multiply(num, abnormalType.get("abnormalMoney").toString(), 4);
}else if("2".equals(abnormal)){
} else if ("2".equals(abnormal)) {
// 与默认的一样(按时间扣费)
}
}
@ -627,19 +651,19 @@ public class StaffWagesQuartz {
for (Map.Entry<String, List<Map<String, Object>>> entry : leaveTimeGroupType.entrySet()) {
String leaveType = entry.getKey();
List<Map<String, Object>> holidays = holidaysTypeJson.stream().filter(bean -> leaveType.equals(bean.get("holidayNo").toString())).collect(Collectors.toList());
for(Map<String, Object> bean : entry.getValue()){
for (Map<String, Object> bean : entry.getValue()) {
// 请假的时长分钟
String leaveMinuteTime = DateUtil.getDistanceMinuteByHMS(bean.get("leaveStartTime").toString(), bean.get("leaveEndTime").toString());
// 请假的时长小时
String leaveHourTime = CalculationUtil.divide(leaveMinuteTime, "60", 2);
allLeaveHourTime = CalculationUtil.add(allLeaveHourTime, leaveHourTime, 2);
if(holidays != null && !holidays.isEmpty()){
if (holidays != null && !holidays.isEmpty()) {
// 该扣薪规则存在获取扣钱百分比
String percentage = CalculationUtil.divide(holidays.get(0).get("offPercentageMoney").toString(), "100", 4);
allLeaveHourMoney = CalculationUtil.add(
allLeaveHourMoney,
CalculationUtil.multiply(4, leaveHourTime, hourWages, percentage), 4);
}else{
} else {
allLeaveHourMoney = CalculationUtil.add(
allLeaveHourMoney,
CalculationUtil.multiply(leaveHourTime, hourWages, 4), 4);
@ -673,10 +697,10 @@ public class StaffWagesQuartz {
List<Map<String, Object>> workTimes = staffWorkTime.stream()
.filter(item -> bean.get("timeId").toString().equals(item.get("timeId").toString()))
.collect(Collectors.toList());
if(workTimes != null && !workTimes.isEmpty()){
if (workTimes != null && !workTimes.isEmpty()) {
Map<String, Object> workTime = workTimes.get(0);
// 全勤以及工时不足的都算为实际出勤
if("1".equals(state) || "3".equals(state)){
if ("1".equals(state) || "3".equals(state)) {
lastMonthRealNum++;
String time = DateUtil.getDistanceMinuteByHMS(bean.get("clockIn").toString(), bean.get("clockOut").toString());
lastMonthRealHour = CalculationUtil.add(lastMonthRealHour, time, 2);
@ -684,12 +708,12 @@ public class StaffWagesQuartz {
DateUtil.getDistanceMinuteByHMS(workTime.get("startTime").toString(), workTime.get("endTime").toString()), 2);
}
// 迟到
if("2".equals(bean.get("clockInState").toString())){
if ("2".equals(bean.get("clockInState").toString())) {
lastMonthLateNum++;
lateMinute.add(DateUtil.getDistanceMinuteByHMS(bean.get("clockIn").toString(), workTime.get("startTime").toString()));
}
// 早退
if("2".equals(bean.get("clockOutState").toString())){
if ("2".equals(bean.get("clockOutState").toString())) {
lastMonthEarlyNum++;
earlyMinute.add(DateUtil.getDistanceMinuteByHMS(bean.get("clockOut").toString(), workTime.get("endTime").toString()));
}
@ -737,11 +761,11 @@ public class StaffWagesQuartz {
return (companyId.equals(objectId) || departmentId.equals(objectId)
|| staffId.equals(objectId));
}).collect(Collectors.toList());
if(applyThisUserStaffSocialSecurityFund != null && !applyThisUserStaffSocialSecurityFund.isEmpty()) {
if (applyThisUserStaffSocialSecurityFund != null && !applyThisUserStaffSocialSecurityFund.isEmpty()) {
// 因为根据公司id部门id员工id会找到多个信息所以筛选值sortNo最大那个社保公积金
Optional<Map<String, Object>> applyThisUserStaff = applyThisUserStaffSocialSecurityFund.stream()
.max(Comparator.comparingInt(bean -> Integer.parseInt(bean.get("sortNo").toString())));
if(applyThisUserStaff != null && applyThisUserStaff.isPresent()) {
if (applyThisUserStaff != null && applyThisUserStaff.isPresent()) {
Map<String, Object> staffSocialSecurityFund = applyThisUserStaff.get();
// 养老保险
String insuranceEndowment = CalculationUtil.multiply(staffSocialSecurityFund.get("insuranceEndowmentBase").toString(),
@ -790,7 +814,7 @@ public class StaffWagesQuartz {
return (companyId.equals(objectId) || departmentId.equals(objectId)
|| staffId.equals(objectId));
}).map(p -> p.get("modelId").toString()).collect(Collectors.toList());
if(modelIds == null || modelIds.isEmpty()){
if (modelIds == null || modelIds.isEmpty()) {
return new ArrayList<>();
}
// 获取薪资要素字段以及对应的值
@ -830,7 +854,7 @@ public class StaffWagesQuartz {
* @throws Exception
*/
private List<Map<String, Object>> getWagesModel(String lastMonthDate) throws Exception {
try{
try {
// 获取所有启用中的薪资模板适用对象关系
List<Map<String, Object>> applicableObjects = wagesModelApplicableObjectsDao.queryAllEanbleWagesModelApplicableObjects(lastMonthDate);
applicableObjects.forEach(bean -> {
@ -847,7 +871,7 @@ public class StaffWagesQuartz {
}));
});
return applicableObjects;
} catch (Exception e){
} catch (Exception e) {
LOGGER.warn("get wages model mation failed", e);
} finally {
LOGGER.info("remove StaffWagesQuartz -> getWagesModel local cache");
@ -861,7 +885,7 @@ public class StaffWagesQuartz {
*
* @param staffIds 员工ids
*/
private void setToRedis(List<String> staffIds){
private void setToRedis(List<String> staffIds) {
// 默认存储时间为六个小时
jedisClient.set(IN_STATISTICS_STAFF_REDIS_KEY, JSONUtil.toJsonStr(staffIds), 60 * 60 * 6);
}
@ -871,7 +895,7 @@ public class StaffWagesQuartz {
*
* @param staffId 员工id
*/
private void removeStaffIdInStatisticsRedisMation(String staffId){
private void removeStaffIdInStatisticsRedisMation(String staffId) {
List<String> staffIds = getStaffIdsFromRedis();
staffIds = staffIds.stream().filter(str -> !staffId.equals(str)).collect(Collectors.toList());
setToRedis(staffIds);
@ -882,7 +906,7 @@ public class StaffWagesQuartz {
*
* @param staffId 员工id
*/
private void addStaffIdInStatisticsRedisMation(String staffId){
private void addStaffIdInStatisticsRedisMation(String staffId) {
List<String> staffIds = getStaffIdsFromRedis();
staffIds.add(staffId);
setToRedis(staffIds);
@ -894,18 +918,18 @@ public class StaffWagesQuartz {
* @param staffId 员工id
* @return true处理中false未在处理
*/
private boolean isInStatisticsRedisMation(String staffId){
private boolean isInStatisticsRedisMation(String staffId) {
List<String> staffIds = getStaffIdsFromRedis();
return staffIds.contains(staffId);
}
private void deleteStatisticsRedisMation(){
private void deleteStatisticsRedisMation() {
jedisClient.del(IN_STATISTICS_STAFF_REDIS_KEY);
}
private List<String> getStaffIdsFromRedis(){
private List<String> getStaffIdsFromRedis() {
List<String> staffIds = new ArrayList<>();
if(jedisClient.exists(IN_STATISTICS_STAFF_REDIS_KEY)){
if (jedisClient.exists(IN_STATISTICS_STAFF_REDIS_KEY)) {
staffIds = JSONUtil.toList(JSONUtil.parseArray(jedisClient.get(IN_STATISTICS_STAFF_REDIS_KEY)), null);
}
return staffIds;

View file

@ -19,12 +19,10 @@ import org.springframework.stereotype.Component;
import java.io.File;
/**
*
* @ClassName: TemporaryFileDeleteQuartz
* @Description: 定时删除临时的云压缩文件
* @author: skyeye云系列--卫志强
* @date: 2021/6/14 11:11
*
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@ -51,21 +49,21 @@ public class TemporaryFileDeleteQuartz {
*
* @throws Exception
*/
@Scheduled(cron="0 0 23 * * ?")
@Scheduled(cron = "0 0 23 * * ?")
public void deleteTemporaryFile() throws Exception {
String historyId = sysQuartzRunHistoryService.startSysQuartzRun(QUARTZ_ID);
log.info("TemporaryFileDeleteQuartz start");
try{
try {
// 临时文件存储路径
String basePath = tPath + "\\upload\\fileconsole\\temporaryfile\\";
File pack = new File(basePath);
if(!pack.isDirectory()){
if (!pack.isDirectory()) {
// 创建目录
pack.mkdirs();
}
// 读取指定路径下的文件名和目录名
getAllFileByRecursion(pack.listFiles());
} catch (Exception e){
} catch (Exception e) {
sysQuartzRunHistoryService.endSysQuartzRun(historyId, SysQuartzRunHistory.State.START_ERROR.getState());
log.warn("TemporaryFileDeleteQuartz error.", e);
}
@ -73,17 +71,17 @@ public class TemporaryFileDeleteQuartz {
sysQuartzRunHistoryService.endSysQuartzRun(historyId, SysQuartzRunHistory.State.START_SUCCESS.getState());
}
public void getAllFileByRecursion(File[] fileList) throws Exception{
public void getAllFileByRecursion(File[] fileList) throws Exception {
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isFile()) {
// 如果是文件,获取文件最后的修改时间
String upTime = DateUtil.getDateStr(fileList[i].lastModified());
// 获取当前时间和文件最后修改时间的时间差多少分钟
long time = DateUtil.getDistanceMinute(upTime, DateUtil.getTimeAndToString());
if(time > DAY_MINUTE_TIME){
if (time > DAY_MINUTE_TIME) {
fileList[i].delete();
}
}else{
} else {
//如果是文件夹
getAllFileByRecursion(fileList[i].listFiles());
}