This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.ApplyAttendanceChange;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceChangeDto;
|
||||
import jnpf.model.workflow.vo.ApplyAttendanceChangeVo;
|
||||
|
||||
/**
|
||||
* 打卡申请服务
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2023-12-11
|
||||
*/
|
||||
public interface ApplyAttendanceChangeService extends SuperService<ApplyAttendanceChange> {
|
||||
|
||||
/**
|
||||
* 查询审批记录
|
||||
* @param id 审批id
|
||||
* @return jnpf.model.workflow.vo.ApplyAttendanceChangeVo
|
||||
*/
|
||||
ApplyAttendanceChangeVo getApplyAttendanceChange(String id);
|
||||
|
||||
/**
|
||||
* 新增审批记录
|
||||
* @param entity 实体
|
||||
* @param applyAttendanceChangeDto 考勤变更dto
|
||||
*/
|
||||
void save(ApplyAttendanceChange entity, ApplyAttendanceChangeDto applyAttendanceChangeDto) throws Exception;
|
||||
|
||||
/**
|
||||
* 提交审批记录
|
||||
* @param id 审批id
|
||||
* @param entity 实体
|
||||
* @param applyAttendanceChangeDto 考勤变更dto
|
||||
*/
|
||||
void submit(String id, ApplyAttendanceChange entity, ApplyAttendanceChangeDto applyAttendanceChangeDto);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.ApplyAttendanceOutside;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceOutsideDto;
|
||||
import jnpf.model.workflow.vo.ApplyAttendanceOutsideVo;
|
||||
|
||||
/**
|
||||
* 外勤审批服务
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2023-12-13
|
||||
*/
|
||||
public interface ApplyAttendanceOutsideService extends SuperService<ApplyAttendanceOutside> {
|
||||
|
||||
/**
|
||||
* 查询外勤审批记录
|
||||
* @param id 审批id
|
||||
* @return jnpf.model.workflow.vo.ApplyAttendanceOutsideVo
|
||||
*/
|
||||
ApplyAttendanceOutsideVo getApplyAttendanceOutside(String id);
|
||||
|
||||
/**
|
||||
* 新建外勤审批申请
|
||||
* @param entity 外勤实体
|
||||
* @param applyAttendanceOutsideDto 外勤dto
|
||||
*/
|
||||
void save(ApplyAttendanceOutside entity, ApplyAttendanceOutsideDto applyAttendanceOutsideDto) throws Exception;
|
||||
|
||||
/**
|
||||
* 修改外勤审批申请
|
||||
* @param entity 外勤实体
|
||||
* @param applyAttendanceOutsideDto 外勤dto
|
||||
*/
|
||||
void submit(ApplyAttendanceOutside entity, ApplyAttendanceOutsideDto applyAttendanceOutsideDto);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.ApplyAttendanceRepair;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceRepairDto;
|
||||
import jnpf.model.workflow.vo.ApplyAttendanceRepairVo;
|
||||
|
||||
/**
|
||||
* 补卡审批服务
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2023-12-13
|
||||
*/
|
||||
public interface ApplyAttendanceRepairService extends SuperService<ApplyAttendanceRepair> {
|
||||
|
||||
/**
|
||||
* 查询补卡审批记录
|
||||
* @param id 审批id
|
||||
* @return jnpf.model.workflow.vo.ApplyAttendanceRepairVo
|
||||
*/
|
||||
ApplyAttendanceRepairVo getApplyAttendanceRepair(String id);
|
||||
|
||||
/**
|
||||
* 保存补卡审批记录
|
||||
* @param entity 补卡实体
|
||||
* @param applyAttendanceRepairDto 补卡审批dto
|
||||
* @throws Exception 异常抛出
|
||||
*/
|
||||
void save(ApplyAttendanceRepair entity, ApplyAttendanceRepairDto applyAttendanceRepairDto) throws Exception;
|
||||
|
||||
/**
|
||||
* 提交补卡审批记录
|
||||
* @param id 审批id
|
||||
* @param entity 补卡实体
|
||||
* @param applyAttendanceRepairDto 补卡审批dto
|
||||
*/
|
||||
void submit(String id, ApplyAttendanceRepair entity, ApplyAttendanceRepairDto applyAttendanceRepairDto);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.ApplyAttendanceViolation;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceViolationDto;
|
||||
|
||||
/**
|
||||
* 违规打卡审批服务
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2025-09-22
|
||||
*/
|
||||
public interface ApplyAttendanceViolationService extends SuperService<ApplyAttendanceViolation> {
|
||||
|
||||
/**
|
||||
* 新建违规打卡审批申请
|
||||
* @param applyAttendanceViolationDto 违规打卡dto
|
||||
*/
|
||||
void saveRecord(ApplyAttendanceViolationDto applyAttendanceViolationDto) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 审批图片服务
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2025-09-22
|
||||
*/
|
||||
public interface ApplyPicService {
|
||||
|
||||
/**
|
||||
* 获取图片数组
|
||||
* 前端给的值为[List<String>], 所以需要再转换
|
||||
* @param picUrlList 图片路径数组
|
||||
* @return java.util.List<java.lang.String>
|
||||
*/
|
||||
List<String> getPicList(List<String> picUrlList);
|
||||
|
||||
/**
|
||||
* 保存图片
|
||||
* @param taskId 任务id
|
||||
* @param urlList 图片列表
|
||||
*/
|
||||
void saveClockPic(String taskId, List<String> urlList);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.AttendanceBusinessTripApprove;
|
||||
import jnpf.model.workflow.dto.AttendanceBusinessTripApproveDto;
|
||||
import jnpf.model.workflow.dto.AttendanceBusinessTripApproveOaDto;
|
||||
import jnpf.model.workflow.vo.AttendanceBusinessTripApproveVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/14 18:33
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
public interface BusinessTripApproveService extends SuperService<AttendanceBusinessTripApprove> {
|
||||
|
||||
void save(String id, AttendanceBusinessTripApprove entity, AttendanceBusinessTripApproveDto dto);
|
||||
|
||||
|
||||
void submit(String id, AttendanceBusinessTripApprove entity, AttendanceBusinessTripApproveDto dto);
|
||||
|
||||
|
||||
AttendanceBusinessTripApproveVo getOne(String id);
|
||||
|
||||
/**
|
||||
* 批量获取出差申请记录
|
||||
*
|
||||
* @param groupIds 考勤组ID
|
||||
* @param ids 出差申请ID
|
||||
*/
|
||||
List<AttendanceBusinessTripApprove> getBatchByIds(List<String> groupIds, List<String> ids);
|
||||
|
||||
void saveForOa(AttendanceBusinessTripApproveOaDto approveOaDto);
|
||||
|
||||
void submitForOa(String id, AttendanceBusinessTripApproveOaDto approveOaDto);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
|
||||
/**
|
||||
* 工作流服务
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2024-08-19
|
||||
*/
|
||||
public interface FlowTaskService {
|
||||
|
||||
/**
|
||||
* 查询下一个节点审批信息
|
||||
* @param taskId 任务id
|
||||
* @param nodeId 节点id
|
||||
* @param tenantId 租户id
|
||||
* @param type 类型 0 :不需要校验userOperators对象审核通过时使用 其他:默认需要校验
|
||||
* @return jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo
|
||||
*/
|
||||
ApproverByTaskIdAndNodeIdVo getApproveInfo(String taskId, String nodeId, String tenantId, Integer type);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.AttendanceGoOutApprove;
|
||||
import jnpf.model.attendance.dto.GoOutApproveForOaDto;
|
||||
import jnpf.model.workflow.dto.AttendanceGoOutApproveDto;
|
||||
import jnpf.model.workflow.vo.AttendanceGoOutApproveVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/14 18:32
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
public interface GoOutApproveService extends SuperService<AttendanceGoOutApprove> {
|
||||
|
||||
void save(String id, AttendanceGoOutApprove entity, AttendanceGoOutApproveDto dto);
|
||||
|
||||
|
||||
void submit(String id, AttendanceGoOutApprove entity, AttendanceGoOutApproveDto dto);
|
||||
|
||||
|
||||
AttendanceGoOutApproveVo getOne(String id);
|
||||
|
||||
/**
|
||||
* 批量获取外出申请记录
|
||||
*
|
||||
* @param groupIds 考勤组ID
|
||||
* @param ids 申请记录ID
|
||||
* @return 外出申请记录 key=用户ID+考勤组ID
|
||||
*/
|
||||
List<AttendanceGoOutApprove> getBatchByIds(List<String> groupIds, List<String> ids);
|
||||
|
||||
void saveForOa(GoOutApproveForOaDto dto);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.AttendanceLeaveApprove;
|
||||
import jnpf.model.attendance.dto.LeaveApproveForOaDto;
|
||||
import jnpf.model.workflow.dto.AttendanceLeaveApproveDto;
|
||||
import jnpf.model.workflow.vo.AttendanceLeaveFlowApproveVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface LeaveApproveService extends SuperService<AttendanceLeaveApprove> {
|
||||
|
||||
/**
|
||||
* 新增审批记录
|
||||
*
|
||||
* @param id 审批id
|
||||
* @param entity 实体
|
||||
* @param attendanceLeaveApproveDto 请假dto
|
||||
*/
|
||||
void save(String id, AttendanceLeaveApprove entity, AttendanceLeaveApproveDto attendanceLeaveApproveDto);
|
||||
|
||||
/**
|
||||
* 提交审批记录
|
||||
*
|
||||
* @param id 审批id
|
||||
* @param entity 实体
|
||||
* @param attendanceLeaveApproveDto 请假dto
|
||||
*/
|
||||
void submit(String id, AttendanceLeaveApprove entity, AttendanceLeaveApproveDto attendanceLeaveApproveDto);
|
||||
|
||||
/**
|
||||
* 通过请假id获取请假详情
|
||||
*
|
||||
* @param id 请假id
|
||||
* @return jnpf.model.workflow.vo.AttendanceLeaveFlowApproveVo
|
||||
* @author hlp
|
||||
*/
|
||||
AttendanceLeaveFlowApproveVo getAttendanceLeave(String id);
|
||||
|
||||
void saveForOa(LeaveApproveForOaDto dto);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.PunishmentsApproval;
|
||||
import jnpf.model.workflow.dto.PunishmentsApprovalDto;
|
||||
import jnpf.model.workflow.vo.PunishmentsApprovalVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/24 10:43
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
public interface PunishmentsApprovalService extends SuperService<PunishmentsApproval> {
|
||||
void punishmentsApprove( String applyId, Integer status);
|
||||
|
||||
void savePunishments(String id, PunishmentsApproval entity, PunishmentsApprovalDto dto);
|
||||
|
||||
void submitPunishments(String id, PunishmentsApproval entity, PunishmentsApprovalDto dto);
|
||||
|
||||
PunishmentsApprovalVo getPunishments(String id);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.RewardApproval;
|
||||
import jnpf.model.workflow.dto.RewardApprovalDto;
|
||||
import jnpf.model.workflow.vo.AttendanceLeaveFlowApproveVo;
|
||||
import jnpf.model.workflow.vo.RewardApprovalVo;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/21 17:25
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
public interface RewardService extends SuperService<RewardApproval> {
|
||||
|
||||
|
||||
void saveReward(String id, RewardApproval entity, RewardApprovalDto dto);
|
||||
|
||||
|
||||
void submitReward(String id, RewardApproval entity, RewardApprovalDto dto);
|
||||
|
||||
|
||||
RewardApprovalVo getReward(String id);
|
||||
|
||||
void rewardApprove(String applyId, Integer status);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.SelfApprove;
|
||||
import jnpf.model.workflow.dto.SelfApproveDto;
|
||||
import jnpf.model.workflow.vo.SelfApproveVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SelfApproveService extends SuperService<SelfApprove> {
|
||||
|
||||
/**
|
||||
* 新增借调审批记录
|
||||
* @param id 审批id
|
||||
* @param entity 实体
|
||||
* @param selfApproveDto dto
|
||||
*/
|
||||
void save(String id, SelfApprove entity, SelfApproveDto selfApproveDto);
|
||||
|
||||
/**
|
||||
* 提交借调审批记录
|
||||
* @param id 借调审批id
|
||||
* @param entity 实体
|
||||
* @param selfApproveDto 借调审批dto
|
||||
*/
|
||||
void submit(String id, SelfApprove entity, SelfApproveDto selfApproveDto);
|
||||
|
||||
/**
|
||||
* 通过借调审批id获取借调审批详情
|
||||
* @param id 借调审批id
|
||||
* @return jnpf.model.workflow.vo.AttendanceLeaveFlowApproveVo
|
||||
* @author hlp
|
||||
*/
|
||||
SelfApproveVo getAttendanceLeave(String id);
|
||||
|
||||
/**
|
||||
* oa收拢保存借调
|
||||
* @param entity
|
||||
*/
|
||||
void saveForOa(SelfApprove entity, List<String> userIds);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package jnpf.workflow.service;
|
||||
|
||||
import jnpf.base.service.SuperService;
|
||||
import jnpf.entity.workflow.AttendanceWorkOvertimeApprove;
|
||||
import jnpf.model.workflow.dto.AttendanceWorkOvertimeApproveDto;
|
||||
import jnpf.model.workflow.vo.AttendanceWorkOvertimeApproveVo;
|
||||
|
||||
public interface WorkOvertimeApproveService extends SuperService<AttendanceWorkOvertimeApprove> {
|
||||
/**
|
||||
* 新增加班记录
|
||||
* @param id 审批id
|
||||
* @param entity 实体
|
||||
* @param attendanceWorkOvertimeApproveDto 请假dto
|
||||
*/
|
||||
void save(String id, AttendanceWorkOvertimeApprove entity, AttendanceWorkOvertimeApproveDto attendanceWorkOvertimeApproveDto);
|
||||
|
||||
/**
|
||||
* 提交加班审批记录
|
||||
* @param id 加班审批id
|
||||
* @param entity 实体
|
||||
* @param attendanceWorkOvertimeApproveDto 加班dto
|
||||
*/
|
||||
void submit(String id, AttendanceWorkOvertimeApprove entity, AttendanceWorkOvertimeApproveDto attendanceWorkOvertimeApproveDto);
|
||||
|
||||
/**
|
||||
* 通过加班id获取加班详情
|
||||
* @param id 加班id
|
||||
* @return jnpf.model.workflow.vo.AttendanceLeaveFlowApproveVo
|
||||
* @author hlp
|
||||
*/
|
||||
AttendanceWorkOvertimeApproveVo getAttendanceLeave(String id);
|
||||
|
||||
/**
|
||||
* oa收拢保存加班审批
|
||||
* @param entity
|
||||
*/
|
||||
void saveForOa(AttendanceWorkOvertimeApprove entity);
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.bean.ChangeConfig;
|
||||
import jnpf.attendance.mapper.AttendanceClockInResultMapper;
|
||||
import jnpf.attendance.service.AttendanceClockInResultService;
|
||||
import jnpf.attendance.service.AttendanceDailyRuleService;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.attendance.AttendanceClockInResult;
|
||||
import jnpf.entity.attendance.FtbAttendanceDailyRule;
|
||||
import jnpf.entity.workflow.ApplyAttendanceChange;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.enums.attendance.ClockInStatusEnum;
|
||||
import jnpf.exception.QueryException;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceChangeDto;
|
||||
import jnpf.model.workflow.vo.ApplyAttendanceChangeVo;
|
||||
import jnpf.permission.UserApi;
|
||||
import jnpf.permission.model.user.BaseUserInfoVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.ApplyAttendanceChangeMapper;
|
||||
import jnpf.workflow.service.ApplyAttendanceChangeService;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* 出勤变更
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2023-12-11
|
||||
*/
|
||||
@Service
|
||||
public class ApplyAttendanceChangeServiceImpl extends SuperServiceImpl<ApplyAttendanceChangeMapper, ApplyAttendanceChange> implements ApplyAttendanceChangeService {
|
||||
@Resource
|
||||
private AttendanceClockInResultService attendanceClockInResultService;
|
||||
@Resource
|
||||
private AttendanceDailyRuleService attendanceDailyRuleService;
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
@Autowired
|
||||
private UserApi userApi;
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
@Resource
|
||||
private ChangeConfig changeConfig;
|
||||
@Resource
|
||||
private AttendanceClockInResultMapper attendanceClockInResultMapper;
|
||||
|
||||
@Override
|
||||
public ApplyAttendanceChangeVo getApplyAttendanceChange(String id) {
|
||||
|
||||
ApplyAttendanceChange applyAttendanceChange = this.getById(id);
|
||||
return JsonUtil.getJsonToBean(applyAttendanceChange, ApplyAttendanceChangeVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ApplyAttendanceChange entity, ApplyAttendanceChangeDto applyAttendanceChangeDto) throws Exception {
|
||||
|
||||
int count = attendanceClockInResultMapper.getReplyingCount(applyAttendanceChangeDto.getClockInResultId());
|
||||
if (count > 0) {
|
||||
throw new QueryException("当前记录正在审批中,请审批结束后再重新执行操作");
|
||||
}
|
||||
//查询班次信息
|
||||
AttendanceClockInResult clockInResult = attendanceClockInResultService.lambdaQuery()
|
||||
.eq(AttendanceClockInResult::getId, applyAttendanceChangeDto.getClockInResultId())
|
||||
.eq(AttendanceClockInResult::getDeleteMark,0)
|
||||
.last("limit 1").one();
|
||||
if (null == clockInResult) {
|
||||
throw new QueryException("当天班次已变更,请重新发起!");
|
||||
}
|
||||
// 查询出勤规则
|
||||
FtbAttendanceDailyRule dailyRule = attendanceDailyRuleService.getById(clockInResult.getRuleId());
|
||||
if (null == dailyRule) {
|
||||
throw new QueryException("当天班次已变更,请重新发起!");
|
||||
}
|
||||
// 判定当前变更是否合法
|
||||
if (!applyAttendanceChangeDto.getChangeType().equals(ClockInStatusEnum.ROLLBACK.getValue())) {
|
||||
List<ClockInStatusEnum> clockInStatusEnums = changeConfig.getChangeMap().get(clockInResult.getClockInType()).get(ClockInStatusEnum.getClockInStatusEnum(clockInResult.getClockInStatus()));
|
||||
if (null == clockInStatusEnums || !clockInStatusEnums.contains(ClockInStatusEnum.getClockInStatusEnum(applyAttendanceChangeDto.getChangeType()))) {
|
||||
throw new Exception("无法变更为指定的状态");
|
||||
}
|
||||
}
|
||||
// 查询变更用户信息
|
||||
BaseUserInfoVo user = userApi.getUserInfoById(clockInResult.getUserId());
|
||||
entity.setChangeUserId(user.getUserId());
|
||||
entity.setChangeUserName(user.getUserName());
|
||||
entity.setApplyDate(new Date());
|
||||
// 变更结果为单个, 变更上班则将下班时间置空, 变更下班置空上班
|
||||
if (clockInResult.getClockInType().equals(ConstantUtil.ON_WORK)) {
|
||||
entity.setOnWorkTime(dailyRule.getInPoint());
|
||||
entity.setOffWorkTime(null);
|
||||
} else {
|
||||
entity.setOnWorkTime(null);
|
||||
entity.setOffWorkTime(dailyRule.getOutPoint());
|
||||
}
|
||||
entity.setId(applyAttendanceChangeDto.getTaskId());
|
||||
save(entity);
|
||||
updateClockInResult(entity.getId(), entity.getClockInResultId(), entity.getChangeType());
|
||||
//sendToIm(clockInResult.getClockInType(),entity, userProvider.get().getTenantId());
|
||||
}
|
||||
|
||||
private void updateClockInResult(String id, String clockInResultId, Integer changeType) {
|
||||
|
||||
AttendanceClockInResult clockInResult = attendanceClockInResultService.getById(clockInResultId);
|
||||
LambdaUpdateWrapper<AttendanceClockInResult> updateWrapper = new LambdaUpdateWrapper<AttendanceClockInResult>()
|
||||
.set(AttendanceClockInResult::getApplyType, ConstantUtil.APPLY_CHANGE)
|
||||
.set(AttendanceClockInResult::getApplyId, id)
|
||||
// .set(AttendanceClockInResult::getAbsenceLeader, userProvider.get().getUserId())
|
||||
.eq(AttendanceClockInResult::getDeleteMark, ConstantUtil.NUM_FALSE)
|
||||
.eq(AttendanceClockInResult::getId, clockInResult.getId());
|
||||
attendanceClockInResultService.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(String id, ApplyAttendanceChange entity, ApplyAttendanceChangeDto applyAttendanceChangeDto) {
|
||||
//查询班次信息
|
||||
AttendanceClockInResult clockInResult = attendanceClockInResultService.lambdaQuery()
|
||||
.eq(AttendanceClockInResult::getId, applyAttendanceChangeDto.getClockInResultId())
|
||||
.eq(AttendanceClockInResult::getDeleteMark,0)
|
||||
.last("limit 1").one();
|
||||
if (entity.getChangeType().equals(3) || entity.getChangeType().equals(4)) {
|
||||
if (clockInResult.getClockInType().equals(ConstantUtil.ON_WORK)) {
|
||||
entity.setOffWorkTime(null);
|
||||
} else {
|
||||
entity.setOnWorkTime(null);
|
||||
}
|
||||
}
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
//sendToIm(clockInResult.getClockInType(), entity, userProvider.get().getTenantId());
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
updateClockInResult(entity.getId(), entity.getClockInResultId(), entity.getChangeType());
|
||||
}
|
||||
|
||||
private void sendToIm(Integer clockInType, ApplyAttendanceChange entity, String tenantId) {
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.schedule(() -> {
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId, null);
|
||||
if (null == data) {
|
||||
return;
|
||||
}
|
||||
AttendanceApproveImVo approveIm = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
approveIm.setId(data.getTaskId());
|
||||
List<PartUserInfoVo> userList = userAntifreeze.getAllByIds(List.of(entity.getCreatorUserId()), tenantId);
|
||||
PartUserInfoVo userInfo = userList.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo(tenantId, AttendanceNoticeEnum.APPROVE);
|
||||
String content = "%s的【出勤变更】审批";
|
||||
String title = String.format(content, null != userInfo ? userInfo.getRealName() : "--");
|
||||
ApproveBaseImVo imDetail = new ApproveBaseImVo(title, ApprovalSettingTypeEnum.ACTION_RESULT.getCode(), entity.getChangeUserName(),
|
||||
getRuleTime(clockInType,entity), getResult(entity.getClockInResultId()), getChangeResult(entity.getChangeType()));
|
||||
data.getUserOperators().forEach(v -> {
|
||||
approveIm.setTaskId(v.getTaskOperatorId());
|
||||
approveImVo.setUserIds(List.of(v.getUserId()));
|
||||
String encode = FtbUtil.encodeJson(approveIm);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
imDetail.setUrl(url);
|
||||
approveImVo.setApproveBaseImVo(imDetail);
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
redisUtil.insert(ConstantUtil.APPROVE_NOTICE_CHANGE + approveIm.getId(), JSONUtil.toJsonStr(approveImVo));
|
||||
});
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
scheduler.shutdown();
|
||||
}
|
||||
|
||||
private String getChangeResult(Integer changeType) {
|
||||
|
||||
switch (changeType) {
|
||||
case 1:
|
||||
return "旷工";
|
||||
case 2:
|
||||
return "撤销旷工";
|
||||
case 3:
|
||||
return "正常";
|
||||
case 4:
|
||||
return "补卡";
|
||||
default:
|
||||
return "--";
|
||||
}
|
||||
}
|
||||
|
||||
private String getRuleTime(Integer clockInType, ApplyAttendanceChange entity) {
|
||||
switch (entity.getChangeType()) {
|
||||
case 1:
|
||||
case 2:
|
||||
return DateDetail.getDate2Str(entity.getOnWorkTime(), DateDetail.DF9) + "-" + DateDetail.getDate2Str(entity.getOffWorkTime(), DateDetail.DF10);
|
||||
case 3:
|
||||
case 4:
|
||||
return clockInType.equals(ConstantUtil.ON_WORK)? DateDetail.getDate2Str(entity.getOnWorkTime(), DateDetail.DF9):DateDetail.getDate2Str(entity.getOffWorkTime(), DateDetail.DF9);
|
||||
default:
|
||||
return "变更类型不正确";
|
||||
}
|
||||
}
|
||||
|
||||
private String getResult(String resultId) {
|
||||
|
||||
AttendanceClockInResult clockInResult = attendanceClockInResultService.getById(resultId);
|
||||
if (null != clockInResult.getAbsence() && clockInResult.getAbsence().equals(ConstantUtil.NUM_TRUE)) {
|
||||
return ClockInStatusEnum.ABSENCE.getDescription();
|
||||
} else {
|
||||
switch (clockInResult.getClockInStatus()) {
|
||||
case -1:
|
||||
return ClockInStatusEnum.NO_CLOCK.getDescription();
|
||||
case 1:
|
||||
return ClockInStatusEnum.NORMAL.getDescription();
|
||||
case 2:
|
||||
return ClockInStatusEnum.WORK_LATE.getDescription();
|
||||
case 3:
|
||||
return ClockInStatusEnum.HOME_EARLY.getDescription();
|
||||
default:
|
||||
return "--";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.service.AttendanceClockInPicService;
|
||||
import jnpf.attendance.service.AttendanceClockInService;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.UserInfo;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.attendance.AttendanceClockInPic;
|
||||
import jnpf.entity.workflow.ApplyAttendanceOutside;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceOutsideDto;
|
||||
import jnpf.model.workflow.vo.ApplyAttendanceOutsideVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.ApplyAttendanceOutsideMapper;
|
||||
import jnpf.workflow.service.ApplyAttendanceOutsideService;
|
||||
import jnpf.workflow.service.ApplyPicService;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 外勤审批服务实现
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2023-12-13
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ApplyAttendanceOutsideServiceImpl extends SuperServiceImpl<ApplyAttendanceOutsideMapper, ApplyAttendanceOutside> implements ApplyAttendanceOutsideService {
|
||||
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
@Resource
|
||||
private AttendanceClockInService attendanceClockInService;
|
||||
@Resource
|
||||
private ApplyPicService applyPicService;
|
||||
|
||||
@Override
|
||||
public ApplyAttendanceOutsideVo getApplyAttendanceOutside(String id) {
|
||||
|
||||
ApplyAttendanceOutside applyAttendanceOutside = this.getById(id);
|
||||
return JsonUtil.getJsonToBean(applyAttendanceOutside, ApplyAttendanceOutsideVo.class);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void save(ApplyAttendanceOutside entity, ApplyAttendanceOutsideDto applyAttendanceOutsideDto) throws Exception {
|
||||
log.error("发起外勤审批: {}", applyAttendanceOutsideDto.toString());
|
||||
//保存外勤打卡图片 picUrlList
|
||||
List<String> urlList = applyPicService.getPicList(applyAttendanceOutsideDto.getPicUrlList());
|
||||
if (!urlList.isEmpty()) {
|
||||
applyAttendanceOutsideDto.getPicUrlList().clear();
|
||||
applyAttendanceOutsideDto.getPicUrlList().addAll(urlList);
|
||||
}
|
||||
applyPicService.saveClockPic(applyAttendanceOutsideDto.getTaskId(), applyAttendanceOutsideDto.getPicUrlList());
|
||||
UserInfo userInfo = userProvider.get();
|
||||
entity.setApplyUser(userInfo.getUserId());
|
||||
entity.setApplyDate(DateDetail.getStr2DateTime(applyAttendanceOutsideDto.getApplyDateStr()));
|
||||
entity.setTenantId(userInfo.getTenantId());
|
||||
entity.setId(applyAttendanceOutsideDto.getTaskId());
|
||||
entity.setRemark(applyAttendanceOutsideDto.getRemark());
|
||||
save(entity);
|
||||
attendanceClockInService.outsideClockIn(applyAttendanceOutsideDto.getTaskId(), userInfo.getUserId(), applyAttendanceOutsideDto.getClockInId());
|
||||
}
|
||||
|
||||
private void sendToIm(ApplyAttendanceOutside entity, String tenantId) {
|
||||
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.schedule(() -> {
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId, null);
|
||||
if (null == data) {
|
||||
return;
|
||||
}
|
||||
AttendanceApproveImVo approveIm = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
approveIm.setId(data.getTaskId());
|
||||
List<PartUserInfoVo> userList = userAntifreeze.getAllByIds(List.of(entity.getApplyUserId()), tenantId);
|
||||
PartUserInfoVo userInfo = userList.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo(tenantId, AttendanceNoticeEnum.APPROVE);
|
||||
String content = "%s的【外勤】审批";
|
||||
String title = String.format(content, null != userInfo ? userInfo.getRealName() : "--");
|
||||
ApproveBaseImVo imDetail = new ApproveBaseImVo(title, ApprovalSettingTypeEnum.OUT.getCode(), entity.getCreatorTime(), entity.getAddress());
|
||||
data.getUserOperators().forEach(v -> {
|
||||
approveIm.setTaskId(v.getTaskOperatorId());
|
||||
approveImVo.setUserIds(List.of(v.getUserId()));
|
||||
String encode = FtbUtil.encodeJson(approveIm);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
imDetail.setUrl(url);
|
||||
approveImVo.setApproveBaseImVo(imDetail);
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
redisUtil.insert(ConstantUtil.APPROVE_NOTICE_OUTSIDE + approveIm.getId(), JSONUtil.toJsonStr(approveImVo));
|
||||
});
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
scheduler.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(ApplyAttendanceOutside entity, ApplyAttendanceOutsideDto applyAttendanceOutsideDto) {
|
||||
//保存外勤打卡图片
|
||||
applyPicService.saveClockPic(applyAttendanceOutsideDto.getTaskId(), applyAttendanceOutsideDto.getPicUrlList());
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(applyAttendanceOutsideDto.getTaskId());
|
||||
save(entity);
|
||||
//sendToIm(entity, userProvider.get().getTenantId());
|
||||
} else {
|
||||
entity.setId(applyAttendanceOutsideDto.getTaskId());
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.mapper.AttendanceClockInResultMapper;
|
||||
import jnpf.attendance.mapper.AttendanceDailyRuleMapper;
|
||||
import jnpf.attendance.service.AttendanceClockInResultService;
|
||||
import jnpf.attendance.service.AttendanceClockInService;
|
||||
import jnpf.attendance.service.AttendanceDayStatisticsService;
|
||||
import jnpf.attendance.service.AttendanceRepairService;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.UserInfo;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.attendance.AttendanceClockInResult;
|
||||
import jnpf.entity.attendance.AttendanceRepair;
|
||||
import jnpf.entity.attendance.FtbAttendanceDailyRule;
|
||||
import jnpf.entity.workflow.ApplyAttendanceRepair;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.enums.attendance.ClockInStatusEnum;
|
||||
import jnpf.exception.HandleException;
|
||||
import jnpf.exception.QueryException;
|
||||
import jnpf.model.attendance.vo.AttendanceRuleVo;
|
||||
import jnpf.model.attendance.vo.GroupRuleVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceRepairDto;
|
||||
import jnpf.model.workflow.vo.ApplyAttendanceRepairVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.ApplyAttendanceRepairMapper;
|
||||
import jnpf.workflow.service.ApplyAttendanceRepairService;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 补卡审批服务实现
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2023-12-13
|
||||
*/
|
||||
@Service
|
||||
public class ApplyAttendanceRepairServiceImpl extends SuperServiceImpl<ApplyAttendanceRepairMapper, ApplyAttendanceRepair> implements ApplyAttendanceRepairService {
|
||||
|
||||
@Resource
|
||||
private AttendanceClockInResultService attendanceClockInResultService;
|
||||
@Resource
|
||||
private AttendanceClockInResultMapper attendanceClockInResultMapper;
|
||||
@Resource
|
||||
private AttendanceClockInService attendanceClockInService;
|
||||
@Resource
|
||||
private AttendanceDayStatisticsService attendanceDayStatisticsService;
|
||||
@Resource
|
||||
private AttendanceDailyRuleMapper attendanceDailyRuleMapper;
|
||||
@Resource
|
||||
private AttendanceRepairService attendanceRepairService;
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
|
||||
@Override
|
||||
public ApplyAttendanceRepairVo getApplyAttendanceRepair(String id) {
|
||||
|
||||
ApplyAttendanceRepair applyAttendanceRepair = this.getById(id);
|
||||
return JsonUtil.getJsonToBean(applyAttendanceRepair, ApplyAttendanceRepairVo.class);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void save(ApplyAttendanceRepair entity, ApplyAttendanceRepairDto applyAttendanceRepairDto) throws Exception {
|
||||
|
||||
UserInfo userInfo = userProvider.get();
|
||||
// 提交前校验
|
||||
submitCheckRepair(entity.getClockInResultId());
|
||||
entity.setId(applyAttendanceRepairDto.getTaskId());
|
||||
entity.setApplyUser(userInfo.getUserId());
|
||||
entity.setApplyDate(new Date());
|
||||
entity.setTenantId(userInfo.getTenantId());
|
||||
setExtraValue(entity);
|
||||
save(entity);
|
||||
//sendToIm(entity, userInfo.getTenantId());
|
||||
// 表单信息
|
||||
/*if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
sendToIm(entity, userProvider.get().getTenantId());
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}*/
|
||||
}
|
||||
|
||||
private void submitCheckRepair(String clockInResultId) throws Exception {
|
||||
|
||||
// 判断当前出勤结果是否在进行别的审批
|
||||
int count = attendanceClockInResultMapper.getReplyingCount(clockInResultId);
|
||||
if (count > 0) {
|
||||
throw new QueryException("当前记录正在审批中,请审批结束后再重新执行操作");
|
||||
}
|
||||
AttendanceClockInResult clockInResult = attendanceClockInResultService.getById(clockInResultId);
|
||||
// 查询考勤规则
|
||||
AttendanceRuleVo rule = attendanceClockInService.getAttendanceRule(clockInResult.getRuleId());
|
||||
// 判定是否封账
|
||||
String monthDate = DateDetail.getDate2Str(rule.getDay(), DateDetail.DF15);
|
||||
Map<String, Boolean> map = attendanceDayStatisticsService.selectUserIsSeal(List.of(clockInResult.getUserId()), monthDate);
|
||||
if (map.get(clockInResult.getUserId())) {
|
||||
throw new HandleException(monthDate + "已封账,过去的考勤记录无法修改!");
|
||||
}
|
||||
// 用户补卡次数判定 (已使用次数 + 审批中的补卡)
|
||||
AttendanceRepair attendanceRepair = attendanceRepairService.getAttendanceRepair(rule.getUserId(), rule.getGroupId());
|
||||
String beginDate = String.format("%d-%02d-%02d", attendanceRepair.getGenerateYear(), attendanceRepair.getGenerateMonth(), attendanceRepair.getGenerateDay());
|
||||
String endDate = DateDetail.getDate2Str(attendanceRepair.getExpireDate(), DateDetail.DF);
|
||||
int applyCount = attendanceClockInResultMapper.selectRepairApplyCount(rule.getUserId(), rule.getGroupId(), beginDate, endDate);
|
||||
if (attendanceRepair.getRepairNum() - applyCount <= 0) {
|
||||
throw new QueryException("当前暂无补卡次数");
|
||||
}
|
||||
}
|
||||
|
||||
private void setExtraValue(ApplyAttendanceRepair entity) {
|
||||
// 根据打卡结果id查询打卡结果
|
||||
AttendanceClockInResult clockInResult = attendanceClockInResultService.getById(entity.getClockInResultId());
|
||||
LambdaUpdateWrapper<AttendanceClockInResult> updateWrapper = new LambdaUpdateWrapper<AttendanceClockInResult>()
|
||||
.eq(AttendanceClockInResult::getId, clockInResult.getId())
|
||||
.set(AttendanceClockInResult::getApplyType, ConstantUtil.APPLY_REPAIR)
|
||||
.set(AttendanceClockInResult::getApplyId, entity.getId());
|
||||
// .set(AttendanceClockInResult::getAbsenceLeader, userProvider.get().getUserId());
|
||||
attendanceClockInResultService.update(updateWrapper);
|
||||
// 查询出勤规则
|
||||
FtbAttendanceDailyRule dailyRule = attendanceDailyRuleMapper.selectById(clockInResult.getRuleId());
|
||||
Date date;
|
||||
if (clockInResult.getClockInType().equals(ConstantUtil.ON_WORK)) {
|
||||
date = dailyRule.getInPoint();
|
||||
} else {
|
||||
date = dailyRule.getOutPoint();
|
||||
}
|
||||
entity.setRepairDateStr(DateDetail.getDate2Str(date, DateDetail.DF));
|
||||
entity.setRepairTimeStr(DateDetail.getDate2Str(date, DateDetail.DF10));
|
||||
entity.setClockInStatus(clockInResult.getClockInStatus());
|
||||
entity.setAbsence(clockInResult.getAbsence());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(String id, ApplyAttendanceRepair entity, ApplyAttendanceRepairDto applyAttendanceRepairDto) {
|
||||
|
||||
setExtraValue(entity);
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
//sendToIm(entity, userProvider.get().getTenantId());
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendToIm(ApplyAttendanceRepair entity, String tenantId) {
|
||||
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.schedule(() -> {
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId,null);
|
||||
if (null == data) {
|
||||
return;
|
||||
}
|
||||
AttendanceApproveImVo approveIm = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
approveIm.setId(data.getTaskId());
|
||||
List<PartUserInfoVo> userList = userAntifreeze.getAllByIds(List.of(entity.getCreatorUserId()), tenantId);
|
||||
PartUserInfoVo userInfo = userList.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo(tenantId, AttendanceNoticeEnum.APPROVE);
|
||||
String content = "%s的【补卡】审批";
|
||||
String title = String.format(content, null != userInfo ? userInfo.getRealName() : "--");
|
||||
ApproveBaseImVo imDetail = new ApproveBaseImVo(title, ApprovalSettingTypeEnum.ROUTINE.getCode(), entity.getRepairDateStr() + " " + entity.getRepairTimeStr(), getResult(entity.getClockInStatus(), entity.getAbsence()));
|
||||
data.getUserOperators().forEach(v -> {
|
||||
approveIm.setTaskId(v.getTaskOperatorId());
|
||||
approveImVo.setUserIds(List.of(v.getUserId()));
|
||||
String encode = FtbUtil.encodeJson(approveIm);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
imDetail.setUrl(url);
|
||||
approveImVo.setApproveBaseImVo(imDetail);
|
||||
String key = ConstantUtil.APPROVE_NOTICE_REPAIR + approveIm.getId();
|
||||
redisUtil.insert(key, JSONUtil.toJsonStr(approveImVo));
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
});
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
scheduler.shutdown();
|
||||
}
|
||||
|
||||
private String getResult(Integer clockInStatus, Integer absence) {
|
||||
|
||||
if (null != absence && absence.equals(ConstantUtil.NUM_TRUE)) {
|
||||
return ClockInStatusEnum.ABSENCE.getDescription();
|
||||
} else {
|
||||
switch (clockInStatus) {
|
||||
case -1:
|
||||
return ClockInStatusEnum.NO_CLOCK.getDescription();
|
||||
case 2:
|
||||
return ClockInStatusEnum.WORK_LATE.getDescription();
|
||||
case 3:
|
||||
return ClockInStatusEnum.HOME_EARLY.getDescription();
|
||||
default:
|
||||
return "--";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import jnpf.attendance.service.AttendanceClockInService;
|
||||
import jnpf.base.UserInfo;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.entity.workflow.ApplyAttendanceViolation;
|
||||
import jnpf.enums.attendance.ApplyTypeEnum;
|
||||
import jnpf.model.attendance.dto.ClockInDto;
|
||||
import jnpf.model.workflow.dto.ApplyAttendanceViolationDto;
|
||||
import jnpf.util.ConstantUtil;
|
||||
import jnpf.util.DateDetail;
|
||||
import jnpf.util.JsonUtil;
|
||||
import jnpf.util.UserProvider;
|
||||
import jnpf.workflow.mapper.ApplyAttendanceViolationMapper;
|
||||
import jnpf.workflow.service.ApplyAttendanceViolationService;
|
||||
import jnpf.workflow.service.ApplyPicService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 违规打卡审批服务实现
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2025-09-22
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ApplyAttendanceViolationServiceImpl extends SuperServiceImpl<ApplyAttendanceViolationMapper, ApplyAttendanceViolation> implements ApplyAttendanceViolationService {
|
||||
|
||||
@Resource
|
||||
private ApplyPicService applyPicService;
|
||||
@Resource
|
||||
private AttendanceClockInService attendanceClockInService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveRecord(ApplyAttendanceViolationDto dto) throws Exception {
|
||||
|
||||
ApplyAttendanceViolation entity = JsonUtil.getJsonToBean(dto, ApplyAttendanceViolation.class);
|
||||
entity.setStatus(ConstantUtil.STATUS_PENDING_APPROVAL);
|
||||
log.error("发起异常打卡审批: 任务id: {}, 打卡类型: {}", dto.getTaskId(), dto.getClockInKind());
|
||||
//保存外勤打卡图片 picUrlList
|
||||
List<String> urlList = applyPicService.getPicList(dto.getPicUrlList());
|
||||
if (!urlList.isEmpty()) {
|
||||
dto.getPicUrlList().clear();
|
||||
dto.getPicUrlList().addAll(urlList);
|
||||
}
|
||||
applyPicService.saveClockPic(dto.getTaskId(), dto.getPicUrlList());
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
entity.setApplyUser(userInfo.getUserId());
|
||||
entity.setApplyDate(DateDetail.getStr2DateTime(dto.getApplyDateStr()));
|
||||
entity.setTenantId(userInfo.getTenantId());
|
||||
entity.setId(dto.getTaskId());
|
||||
entity.setRemark(dto.getRemark());
|
||||
ClockInDto clockInDto = new ClockInDto(dto.getDeviceType(), dto.getClockInKind(), dto.getTaskId(), ApplyTypeEnum.VIOLATION, dto.getAddress(), dto.getLng(), dto.getLat(), dto.getRemark());
|
||||
MutablePair<Integer, String> pair;
|
||||
if (StringUtils.isEmpty(dto.getClockInId())) {
|
||||
pair = attendanceClockInService.clockIn(clockInDto);
|
||||
} else {
|
||||
pair = attendanceClockInService.updateClockIn(dto.getClockInId(), clockInDto);
|
||||
}
|
||||
entity.setClockInResultId(pair.getRight());
|
||||
save(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import jnpf.attendance.service.AttendanceClockInPicService;
|
||||
import jnpf.entity.attendance.AttendanceClockInPic;
|
||||
import jnpf.util.FtbUtil;
|
||||
import jnpf.workflow.service.ApplyPicService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 审批图片服务实现
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2025-09-22
|
||||
*/
|
||||
@Service
|
||||
public class ApplyPicServiceImpl implements ApplyPicService {
|
||||
|
||||
@Resource
|
||||
private AttendanceClockInPicService attendanceClockInPicService;
|
||||
|
||||
@Override
|
||||
public List<String> getPicList(List<String> picUrlList) {
|
||||
|
||||
if (null != picUrlList && !picUrlList.isEmpty()) {
|
||||
String str = picUrlList.get(0);
|
||||
JSONArray array = new JSONArray(str);
|
||||
List<String> list = new ArrayList<>();
|
||||
array.forEach(v -> {
|
||||
JSONObject json = new JSONObject(v);
|
||||
Object o = json.get("previewUrl");
|
||||
if (null != o) {
|
||||
list.add(o.toString());
|
||||
}
|
||||
json.clear();
|
||||
});
|
||||
array.clear();
|
||||
return list;
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveClockPic(String taskId, List<String> urlList) {
|
||||
|
||||
if (CollUtil.isNotEmpty(urlList)) {
|
||||
List<AttendanceClockInPic> picUrlList = CollUtil.newArrayList();
|
||||
picUrlList.addAll(urlList.stream().map(item -> {
|
||||
AttendanceClockInPic clickInPic = AttendanceClockInPic.builder()
|
||||
.approvalCode(taskId)
|
||||
.picUrl(item)
|
||||
.build();
|
||||
clickInPic.setId(FtbUtil.getId());
|
||||
return clickInPic;
|
||||
}).collect(Collectors.toList()));
|
||||
attendanceClockInPicService.remove(new LambdaQueryWrapper<AttendanceClockInPic>().eq(AttendanceClockInPic::getApprovalCode, taskId));
|
||||
attendanceClockInPicService.saveBatch(picUrlList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.workflow.AttendanceBusinessTripApprove;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.AttendanceBusinessTripApproveDto;
|
||||
import jnpf.model.workflow.dto.AttendanceBusinessTripApproveOaDto;
|
||||
import jnpf.model.workflow.vo.AttendanceBusinessTripApproveVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.BusinessTripApproveMapper;
|
||||
import jnpf.workflow.service.BusinessTripApproveService;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/14 18:33
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BusinessTripApproveServiceImpl extends SuperServiceImpl<BusinessTripApproveMapper, AttendanceBusinessTripApprove> implements BusinessTripApproveService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
|
||||
|
||||
@Override
|
||||
public void save(String id, AttendanceBusinessTripApprove entity, AttendanceBusinessTripApproveDto dto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
String tenantId = userProvider.get().getTenantId();
|
||||
new Thread(()->{
|
||||
// 睡眠1秒,确保事务提交完成
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
businessSendIm(entity,tenantId);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void businessSendIm(AttendanceBusinessTripApprove entity,String tenantId) {
|
||||
// 张三的【出差】审批
|
||||
// 出发地:地点名称地点名称地点名称地点名称
|
||||
// 目的地:地点名称地点名称地点名称地点名称
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
// 查询第一节点审批人
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId,null);
|
||||
if (null != data) {
|
||||
AttendanceApproveImVo jsonToBean = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
jsonToBean.setId(data.getTaskId());
|
||||
List<PartUserInfoVo> allByIds = userAntifreeze.getAllByIds(CollUtil.newArrayList(entity.getUserId()), tenantId);
|
||||
PartUserInfoVo partUserInfoVo = allByIds.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo();
|
||||
approveImVo.setTenantId(tenantId);
|
||||
approveImVo.setAttendanceNoticeEnum(AttendanceNoticeEnum.APPROVE);
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
if (!Objects.isNull(partUserInfoVo)) {
|
||||
stringBuffer.append(partUserInfoVo.getRealName());
|
||||
}
|
||||
ApproveBaseImVo approveBaseImVo = new ApproveBaseImVo();
|
||||
approveBaseImVo.setType(ApprovalSettingTypeEnum.BUSINESS_TRIP.getCode());
|
||||
approveBaseImVo.setDestination(entity.getDestination());
|
||||
approveBaseImVo.setDeparture(entity.getDeparture());
|
||||
approveBaseImVo.setTitle(stringBuffer.append("的【出差】审批").toString());
|
||||
data.getUserOperators().forEach(v->{
|
||||
// 每个人的这个Id不同,所以轮询触发
|
||||
jsonToBean.setTaskId(v.getTaskOperatorId());
|
||||
// URL 拼接
|
||||
// String encode = Base64Util.encode(JSONUtil.toJsonStr(jsonToBean));
|
||||
String encode = FtbUtil.encodeJson(jsonToBean);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
approveImVo.setUserIds(CollUtil.newArrayList(v.getUserId()));
|
||||
approveBaseImVo.setUrl(url);
|
||||
approveImVo.setApproveBaseImVo(approveBaseImVo);
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(String id, AttendanceBusinessTripApprove entity, AttendanceBusinessTripApproveDto dto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
String tenantId = userProvider.get().getTenantId();
|
||||
new Thread(()->{
|
||||
// 睡眠1秒,确保事务提交完成
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
businessSendIm(entity,tenantId);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendanceBusinessTripApproveVo getOne(String id) {
|
||||
AttendanceBusinessTripApprove attendanceLeaveApprove = this.getById(id);
|
||||
return JsonUtil.getJsonToBean(attendanceLeaveApprove, AttendanceBusinessTripApproveVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttendanceBusinessTripApprove> getBatchByIds(List<String> groupIds, List<String> ids) {
|
||||
LambdaQueryWrapper<AttendanceBusinessTripApprove> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.in(AttendanceBusinessTripApprove::getId, ids);
|
||||
queryWrapper.in(CollUtil.isNotEmpty(groupIds), AttendanceBusinessTripApprove::getGroupId, groupIds);
|
||||
List<AttendanceBusinessTripApprove> list = this.list(queryWrapper);
|
||||
return CollUtil.isNotEmpty(list) ? list: new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForOa(AttendanceBusinessTripApproveOaDto approveOaDto) {
|
||||
AttendanceBusinessTripApprove entity = JsonUtil.getJsonToBean(approveOaDto, AttendanceBusinessTripApprove.class);
|
||||
// 计算两个时间戳之间的日期差
|
||||
|
||||
log.error("FoeOa开始存数据库出差了参数................: {}", entity);
|
||||
save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitForOa(String id, AttendanceBusinessTripApproveOaDto approveOaDto) {
|
||||
AttendanceBusinessTripApprove entity = JsonUtil.getJsonToBean(approveOaDto, AttendanceBusinessTripApprove.class);
|
||||
log.error("FoeOa开始x修改数据库出差了参数................: {}", entity);
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import jnpf.engine.FlowTaskApi;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 工作流服务实现
|
||||
*
|
||||
* @author yanwenfu
|
||||
* @create 2024-08-19
|
||||
*/
|
||||
@Service
|
||||
public class FlowTaskServiceImpl implements FlowTaskService {
|
||||
|
||||
@Resource
|
||||
private FlowTaskApi flowTaskApi;
|
||||
|
||||
@Override
|
||||
public ApproverByTaskIdAndNodeIdVo getApproveInfo(String taskId, String nodeId, String tenantId, Integer type) {
|
||||
|
||||
ApproverByTaskIdAndNodeIdVo vo = null;
|
||||
int index = 1;
|
||||
while (index <= 5) {
|
||||
try {
|
||||
index++;
|
||||
vo = flowTaskApi.getApproverByTaskIdAndNodeId(taskId, nodeId, tenantId).getData();
|
||||
if (null != type && type == 0 ){
|
||||
if (null != vo){
|
||||
break;
|
||||
}else {
|
||||
vo = null;
|
||||
Thread.sleep((long) index * 1000);
|
||||
}
|
||||
}else {
|
||||
if (null == vo || null == vo.getUserOperators() || vo.getUserOperators().isEmpty()) {
|
||||
vo = null;
|
||||
Thread.sleep((long) index * 1000);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.workflow.AttendanceGoOutApprove;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.model.attendance.dto.GoOutApproveForOaDto;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.AttendanceGoOutApproveDto;
|
||||
import jnpf.model.workflow.vo.AttendanceGoOutApproveVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.GoOutApproveMapper;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import jnpf.workflow.service.GoOutApproveService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/14 18:32
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class GoOutApproveServiceImpl extends SuperServiceImpl<GoOutApproveMapper, AttendanceGoOutApprove> implements GoOutApproveService {
|
||||
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
|
||||
@Override
|
||||
public void save(String id, AttendanceGoOutApprove entity, AttendanceGoOutApproveDto dto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
String tenantId = userProvider.get().getTenantId();
|
||||
new Thread(() -> {
|
||||
// 睡眠1秒,确保事务提交完成
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
goOutSendIm(entity, tenantId);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void goOutSendIm(AttendanceGoOutApprove entity, String tenantId) {
|
||||
//张三的【外出】审批
|
||||
//开始时间:2024年5月16日
|
||||
//结束时间:2024年5月17日
|
||||
//时长:2天
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
// 查询第一节点审批人
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId, null);
|
||||
if (null != data) {
|
||||
AttendanceApproveImVo jsonToBean = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
jsonToBean.setId(data.getTaskId());
|
||||
List<PartUserInfoVo> allByIds = userAntifreeze.getAllByIds(CollUtil.newArrayList(entity.getUserId()), tenantId);
|
||||
PartUserInfoVo partUserInfoVo = allByIds.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo();
|
||||
approveImVo.setTenantId(tenantId);
|
||||
approveImVo.setAttendanceNoticeEnum(AttendanceNoticeEnum.APPROVE);
|
||||
|
||||
ApproveBaseImVo approveBaseImVo = new ApproveBaseImVo();
|
||||
approveBaseImVo.setType(ApprovalSettingTypeEnum.GO_OUT.getCode());
|
||||
approveBaseImVo.setStartTime(entity.getStartTime());
|
||||
approveBaseImVo.setEndTime(entity.getEndTime());
|
||||
approveBaseImVo.setDuration(entity.getDayNum() + "天");
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
if (!Objects.isNull(partUserInfoVo)) {
|
||||
stringBuffer.append(partUserInfoVo.getRealName());
|
||||
}
|
||||
approveBaseImVo.setTitle(stringBuffer.append("的【外出】审批").toString());
|
||||
data.getUserOperators().forEach(v -> {
|
||||
// 每个人的这个Id不同,所以轮询触发
|
||||
jsonToBean.setTaskId(v.getTaskOperatorId());
|
||||
// URL 拼接
|
||||
// String encode = Base64Util.encode(JSONUtil.toJsonStr(jsonToBean));
|
||||
String encode = FtbUtil.encodeJson(jsonToBean);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
approveBaseImVo.setUrl(url);
|
||||
approveImVo.setUserIds(CollUtil.newArrayList(v.getUserId()));
|
||||
approveImVo.setApproveBaseImVo(approveBaseImVo);
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(String id, AttendanceGoOutApprove entity, AttendanceGoOutApproveDto dto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
String tenantId = userProvider.get().getTenantId();
|
||||
new Thread(() -> {
|
||||
// 睡眠1秒,确保事务提交完成
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
goOutSendIm(entity, tenantId);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendanceGoOutApproveVo getOne(String id) {
|
||||
AttendanceGoOutApprove attendanceLeaveApprove = this.getById(id);
|
||||
return JsonUtil.getJsonToBean(attendanceLeaveApprove, AttendanceGoOutApproveVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttendanceGoOutApprove> getBatchByIds(List<String> groupIds, List<String> ids) {
|
||||
LambdaQueryWrapper<AttendanceGoOutApprove> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.in(AttendanceGoOutApprove::getId, ids);
|
||||
queryWrapper.in(CollUtil.isNotEmpty(groupIds), AttendanceGoOutApprove::getGroupId, groupIds);
|
||||
List<AttendanceGoOutApprove> list = this.list(queryWrapper);
|
||||
return CollUtil.isNotEmpty(list) ? list : new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForOa(GoOutApproveForOaDto dto) {
|
||||
AttendanceGoOutApprove entity = JsonUtil.getJsonToBean(dto, AttendanceGoOutApprove.class);
|
||||
entity.setGroupId(dto.getGroupId());
|
||||
log.error("FoeOa开始存数据库出差了参数................: {}", entity);
|
||||
save(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.service.AttendanceDailyRuleService;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.attendance.ApplyParam;
|
||||
import jnpf.entity.workflow.AttendanceGoOutApprove;
|
||||
import jnpf.entity.workflow.AttendanceLeaveApprove;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.enums.attendance.AttendanceTypeEnum;
|
||||
import jnpf.exception.HandleException;
|
||||
import jnpf.model.attendance.dto.LeaveApproveForOaDto;
|
||||
import jnpf.model.attendance.vo.DailyRuleResultVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.AttendanceLeaveApproveDto;
|
||||
import jnpf.model.workflow.vo.AttendanceLeaveFlowApproveVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.AttendanceLeaveMapper;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import jnpf.workflow.service.LeaveApproveService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* describe
|
||||
*
|
||||
* @author HuangLinPan
|
||||
* @date 2023/12/11
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class LeaveApproveServiceImpl extends SuperServiceImpl<AttendanceLeaveMapper, AttendanceLeaveApprove> implements LeaveApproveService {
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Resource
|
||||
private AttendanceDailyRuleService attendanceDailyRuleService;
|
||||
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(String id, AttendanceLeaveApprove entity, AttendanceLeaveApproveDto attendanceLeaveApproveDto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
try {
|
||||
// 发送审批消息
|
||||
String tenantId = userProvider.get().getTenantId();
|
||||
new Thread(() -> {
|
||||
// 睡眠1秒,确保事务提交完成
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
leaveSendIm(entity, tenantId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
} catch (Exception e) {
|
||||
log.error("发送请假审批消息通知第一级审批人失败", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void leaveSendIm(AttendanceLeaveApprove entity, String tenantId) throws HandleException {
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
// 查询第一节点审批人
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId, null);
|
||||
if (null != data) {
|
||||
AttendanceApproveImVo jsonToBean = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
jsonToBean.setId(data.getTaskId());
|
||||
List<DailyRuleResultVo> dailyRuleResultVos = attendanceDailyRuleService.applyVerifyHandle(new ApplyParam(entity.getUserId(), entity.getStartTime(), entity.getEndTime(), AttendanceTypeEnum.LEAVE));
|
||||
// 实时获取申请时长
|
||||
BigDecimal hours = new BigDecimal("0");
|
||||
for (DailyRuleResultVo dailyRuleResultVo : dailyRuleResultVos) {
|
||||
hours = hours.add(dailyRuleResultVo.getDuration());
|
||||
}
|
||||
List<PartUserInfoVo> allByIds = userAntifreeze.getAllByIds(CollUtil.newArrayList(entity.getUserId()), tenantId);
|
||||
PartUserInfoVo partUserInfoVo = allByIds.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo();
|
||||
approveImVo.setTenantId(tenantId);
|
||||
approveImVo.setAttendanceNoticeEnum(AttendanceNoticeEnum.APPROVE);
|
||||
ApproveBaseImVo approveBaseImVo = new ApproveBaseImVo();
|
||||
approveBaseImVo.setType(ApprovalSettingTypeEnum.LEAVE.getCode());
|
||||
approveBaseImVo.setStartTime(entity.getStartTime());
|
||||
approveBaseImVo.setEndTime(entity.getEndTime());
|
||||
approveBaseImVo.setStartTimeType(entity.getStartTimeType());
|
||||
approveBaseImVo.setEndTimeType(entity.getEndTimeType());
|
||||
approveBaseImVo.setUnit(entity.getUnit());
|
||||
// 请假类型
|
||||
approveBaseImVo.setLeaveType(entity.getType());
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
if (!Objects.isNull(partUserInfoVo)) {
|
||||
stringBuffer.append(partUserInfoVo.getRealName());
|
||||
}
|
||||
approveBaseImVo.setTitle(stringBuffer.append("的【请假】审批").toString());
|
||||
data.getUserOperators().forEach(v -> {
|
||||
approveImVo.setUserIds(CollUtil.newArrayList(v.getUserId()));
|
||||
jsonToBean.setTaskId(v.getTaskOperatorId());
|
||||
// URL 拼接
|
||||
// String encode = Base64Util.encode(JSONUtil.toJsonStr(jsonToBean));
|
||||
String encode = FtbUtil.encodeJson(jsonToBean);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
approveBaseImVo.setUrl(url);
|
||||
approveImVo.setApproveBaseImVo(approveBaseImVo);
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(String id, AttendanceLeaveApprove entity, AttendanceLeaveApproveDto attendanceLeaveApproveDto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
try {
|
||||
// 发送审批消息
|
||||
String tenantId = userProvider.get().getTenantId();
|
||||
new Thread(() -> {
|
||||
// 睡眠1秒,确保事务提交完成
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
leaveSendIm(entity, tenantId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
} catch (Exception e) {
|
||||
log.error("发送请假审批消息通知第一级审批人失败", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendanceLeaveFlowApproveVo getAttendanceLeave(String id) {
|
||||
AttendanceLeaveApprove attendanceLeaveApprove = this.getById(id);
|
||||
AttendanceLeaveFlowApproveVo jsonToBean = JsonUtil.getJsonToBean(attendanceLeaveApprove, AttendanceLeaveFlowApproveVo.class);
|
||||
// 当审核未通过时动态取值
|
||||
// if (1 != jsonToBean.getStatus()){
|
||||
// 动态获取涉及班次/借调班次
|
||||
|
||||
// 实际使用余额/未抵扣余额/剩余余额(兑换券/抵扣劵)
|
||||
|
||||
|
||||
// }
|
||||
return jsonToBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForOa(LeaveApproveForOaDto dto) {
|
||||
AttendanceLeaveApprove entity = JsonUtil.getJsonToBean(dto, AttendanceLeaveApprove.class);
|
||||
entity.setUserId(JSONUtil.toList(dto.getApplyUser(), String.class).get(0));
|
||||
log.error("FoeOa开始存数据库请假参数................: {}", entity);
|
||||
save(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.entity.workflow.PunishmentsApproval;
|
||||
import jnpf.entity.workflow.RewardApproval;
|
||||
import jnpf.model.workflow.dto.PunishmentsApprovalDto;
|
||||
import jnpf.model.workflow.dto.UserSelfDto;
|
||||
import jnpf.model.workflow.vo.PunishmentsApprovalVo;
|
||||
import jnpf.model.workflow.vo.RewardApprovalVo;
|
||||
import jnpf.util.JsonUtil;
|
||||
import jnpf.util.StringUtil;
|
||||
import jnpf.workflow.mapper.PunishmentsApprovalMapper;
|
||||
import jnpf.workflow.service.PunishmentsApprovalService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.yaml.snakeyaml.events.Event;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/24 10:43
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
@Service
|
||||
public class PunishmentsApprovalServiceImpl extends SuperServiceImpl<PunishmentsApprovalMapper, PunishmentsApproval> implements PunishmentsApprovalService {
|
||||
|
||||
@Resource
|
||||
private PunishmentsApprovalMapper punishmentsApprovalMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void punishmentsApprove(String applyId, Integer status) {
|
||||
PunishmentsApproval punishmentsApproval = this.getById(applyId);
|
||||
punishmentsApproval.setStatus(status);
|
||||
if (1 == status){
|
||||
punishmentsApproval.setEffectiveDate(new Date());
|
||||
}
|
||||
updateById(punishmentsApproval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePunishments(String id, PunishmentsApproval entity, PunishmentsApprovalDto dto) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// 处理用户
|
||||
punishmentsApprovalMapper.saveUser(id,dto.getUserDtos());
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
punishmentsApprovalMapper.deleteUserById(id);
|
||||
// 处理用户
|
||||
punishmentsApprovalMapper.saveUser(entity.getId(),dto.getUserDtos());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitPunishments(String id, PunishmentsApproval entity, PunishmentsApprovalDto dto) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// 处理用户
|
||||
punishmentsApprovalMapper.saveUser(id,dto.getUserDtos());
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
punishmentsApprovalMapper.deleteUserById(id);
|
||||
// 处理用户
|
||||
punishmentsApprovalMapper.saveUser(entity.getId(),dto.getUserDtos());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PunishmentsApprovalVo getPunishments(String id) {
|
||||
PunishmentsApproval punishmentsApproval = this.getById(id);
|
||||
PunishmentsApprovalVo jsonToBean = JsonUtil.getJsonToBean(punishmentsApproval, PunishmentsApprovalVo.class);
|
||||
// 拼接用户
|
||||
if (null != jsonToBean){
|
||||
List<UserSelfDto> userSelfDtos = punishmentsApprovalMapper.getListById(id);
|
||||
jsonToBean.setUserDtos(userSelfDtos);
|
||||
}
|
||||
return jsonToBean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.entity.workflow.AttendanceLeaveApprove;
|
||||
import jnpf.entity.workflow.RewardApproval;
|
||||
import jnpf.model.workflow.dto.RewardApprovalDto;
|
||||
import jnpf.model.workflow.dto.UserSelfDto;
|
||||
import jnpf.model.workflow.vo.AttendanceLeaveFlowApproveVo;
|
||||
import jnpf.model.workflow.vo.RewardApprovalVo;
|
||||
import jnpf.util.JsonUtil;
|
||||
import jnpf.util.StringUtil;
|
||||
import jnpf.workflow.mapper.AttendanceLeaveMapper;
|
||||
import jnpf.workflow.mapper.RewardApprovalMapper;
|
||||
import jnpf.workflow.service.LeaveApproveService;
|
||||
import jnpf.workflow.service.RewardService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author huanglinpan
|
||||
* @Date 2024/5/21 17:25
|
||||
* @Version 1.0 (版本号)
|
||||
*/
|
||||
@Service
|
||||
public class RewardServiceImpl extends SuperServiceImpl<RewardApprovalMapper, RewardApproval> implements RewardService {
|
||||
|
||||
@Resource
|
||||
private RewardApprovalMapper rewardApprovalMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveReward(String id, RewardApproval entity, RewardApprovalDto dto) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// 处理用户
|
||||
rewardApprovalMapper.saveUser(id,dto.getUserDtos());
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
rewardApprovalMapper.deleteUserById(id);
|
||||
// 处理用户
|
||||
rewardApprovalMapper.saveUser(entity.getId(),dto.getUserDtos());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitReward(String id, RewardApproval entity, RewardApprovalDto dto) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// 处理用户
|
||||
rewardApprovalMapper.saveUser(id,dto.getUserDtos());
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
rewardApprovalMapper.deleteUserById(id);
|
||||
// 处理用户
|
||||
rewardApprovalMapper.saveUser(entity.getId(),dto.getUserDtos());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardApprovalVo getReward(String id) {
|
||||
RewardApproval rewardApproval = this.getById(id);
|
||||
RewardApprovalVo jsonToBean = JsonUtil.getJsonToBean(rewardApproval, RewardApprovalVo.class);
|
||||
// 拼接用户
|
||||
if (null != jsonToBean){
|
||||
List<UserSelfDto> userSelfDtos = rewardApprovalMapper.getListById(id);
|
||||
jsonToBean.setUserDtos(userSelfDtos);
|
||||
}
|
||||
return jsonToBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rewardApprove(String id, Integer status) {
|
||||
RewardApproval rewardApproval = this.getById(id);
|
||||
rewardApproval.setStatus(status);
|
||||
if (1 == status) {
|
||||
rewardApproval.setEffectiveDate(new Date());
|
||||
}
|
||||
//修改状态
|
||||
updateById(rewardApproval);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.service.AttendanceDailyRuleService;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.FlowTaskApi;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.workflow.SelfApprove;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.model.attendance.dto.WorkflowImQueryDto;
|
||||
import jnpf.model.attendance.vo.AttendanceSelfApproveVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.SelfApproveDto;
|
||||
import jnpf.model.workflow.dto.UserSelfDto;
|
||||
import jnpf.model.workflow.vo.SelfApproveVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.SelfApproveMapper;
|
||||
import jnpf.workflow.mapper.SelfApproveUserMapper;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import jnpf.workflow.service.SelfApproveService;
|
||||
import org.apache.logging.log4j.util.Base64Util;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* describe
|
||||
* 借调审批实现类
|
||||
* @author HuangLinPan
|
||||
* @date 2023/12/13
|
||||
*/
|
||||
@Service
|
||||
public class SelfApproveServiceImpl extends SuperServiceImpl<SelfApproveMapper, SelfApprove> implements SelfApproveService {
|
||||
|
||||
@Resource
|
||||
private SelfApproveUserMapper selfApproveUserMapper;
|
||||
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(String id, SelfApprove entity, SelfApproveDto selfApproveDto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// 保存对应的用户集合
|
||||
// selfApproveUserMapper.addList(selfApproveDto.getUserIds(),id);
|
||||
selfApproveUserMapper.addUserList(selfApproveDto.getUserSelfDtos(),id);
|
||||
// 发送消息
|
||||
// String tenantId = userProvider.get().getTenantId();
|
||||
// new Thread(()->{
|
||||
// // 睡眠1秒,确保事务提交完成
|
||||
// try {
|
||||
// Thread.sleep(1000);
|
||||
// secondedSendIm(entity,tenantId);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }).start();
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
// 删除以前绑定的用户集合
|
||||
selfApproveUserMapper.deleteById(id);
|
||||
// 保存对应的用户集合
|
||||
// selfApproveUserMapper.addList(selfApproveDto.getUserIds(),id);
|
||||
selfApproveUserMapper.addUserList(selfApproveDto.getUserSelfDtos(),id);
|
||||
}
|
||||
}
|
||||
|
||||
private void secondedSendIm(SelfApprove entity,String tenantId) {
|
||||
//张三的【借调】审批
|
||||
//借调开始时间:2024年5月16日 16:23
|
||||
//借调结束时间:2024年5月17日 09:00
|
||||
//借调考勤组:小露测试考勤组
|
||||
//被借调考勤组:小露验收考勤组
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
// 查询第一节点审批人
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId,null);
|
||||
if (null != data) {
|
||||
AttendanceApproveImVo jsonToBean = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
jsonToBean.setId(data.getTaskId());
|
||||
List<PartUserInfoVo> allByIds = userAntifreeze.getAllByIds(CollUtil.newArrayList(entity.getCreatorUserId()), tenantId);
|
||||
PartUserInfoVo partUserInfoVo = allByIds.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo();
|
||||
approveImVo.setTenantId(tenantId);
|
||||
approveImVo.setAttendanceNoticeEnum(AttendanceNoticeEnum.APPROVE);
|
||||
ApproveBaseImVo approveBaseImVo = new ApproveBaseImVo();
|
||||
approveBaseImVo.setType(ApprovalSettingTypeEnum.SECONDED.getCode());
|
||||
approveBaseImVo.setStartTime(entity.getStartTime());
|
||||
approveBaseImVo.setEndTime(entity.getEndTime());
|
||||
approveBaseImVo.setGroupName(entity.getGroupName());
|
||||
approveBaseImVo.setSecondedGroupName(entity.getSelfGroupName());
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
if (!Objects.isNull(partUserInfoVo)) {
|
||||
stringBuffer.append(partUserInfoVo.getRealName());
|
||||
}
|
||||
approveBaseImVo.setTitle(stringBuffer.append("的【借调】审批").toString());
|
||||
data.getUserOperators().forEach(v->{
|
||||
approveImVo.setUserIds(CollUtil.newArrayList(v.getUserId()));
|
||||
jsonToBean.setTaskId(v.getTaskOperatorId());
|
||||
// URL 拼接
|
||||
// String encode = Base64Util.encode(JSONUtil.toJsonStr(jsonToBean));
|
||||
String encode = FtbUtil.encodeJson(jsonToBean);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
approveBaseImVo.setUrl(url);
|
||||
approveImVo.setApproveBaseImVo(approveBaseImVo);
|
||||
// 发送消息
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(String id, SelfApprove entity, SelfApproveDto selfApproveDto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// 保存对应的用户集合
|
||||
// selfApproveUserMapper.addList(selfApproveDto.getUserIds(),id);
|
||||
selfApproveUserMapper.addUserList(selfApproveDto.getUserSelfDtos(),id);
|
||||
|
||||
// 发送消息
|
||||
// String tenantId = userProvider.get().getTenantId();
|
||||
// new Thread(()->{
|
||||
// // 睡眠1秒,确保事务提交完成
|
||||
// try {
|
||||
// Thread.sleep(1000);
|
||||
// secondedSendIm(entity,tenantId);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }).start();
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
// 删除以前绑定的用户集合
|
||||
selfApproveUserMapper.deleteById(id);
|
||||
// 保存对应的用户集合
|
||||
// selfApproveUserMapper.addList(selfApproveDto.getUserIds(),id);
|
||||
selfApproveUserMapper.addUserList(selfApproveDto.getUserSelfDtos(),id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelfApproveVo getAttendanceLeave(String id) {
|
||||
SelfApprove selfApprove = this.getById(id);
|
||||
SelfApproveVo jsonToBean = JsonUtil.getJsonToBean(selfApprove, SelfApproveVo.class);
|
||||
if (null != jsonToBean) {
|
||||
// 获取对应的用户集合
|
||||
List<UserSelfDto> userSelfDtos = selfApproveUserMapper.getListById(id);
|
||||
jsonToBean.setUserSelfDtos(userSelfDtos);
|
||||
// List<String> userIds = selfApproveUserMapper.getIdListById(id);
|
||||
// jsonToBean.setUserIds(userIds);
|
||||
}
|
||||
return jsonToBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForOa(SelfApprove entity,List<String> userIds) {
|
||||
save(entity);
|
||||
selfApproveUserMapper.addUserListForOa(userIds,entity.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package jnpf.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import jnpf.attendance.antifreeze.UserAntifreeze;
|
||||
import jnpf.attendance.service.handle.notice.AttendanceNoticeHandler;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.constants.AttendanceConstant;
|
||||
import jnpf.engine.vo.ApproverByTaskIdAndNodeIdVo;
|
||||
import jnpf.entity.workflow.AttendanceWorkOvertimeApprove;
|
||||
import jnpf.enums.attendance.ApprovalSettingTypeEnum;
|
||||
import jnpf.enums.attendance.AttendanceNoticeEnum;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveBaseImVo;
|
||||
import jnpf.model.attendance.vo.attendance.ApproveImVo;
|
||||
import jnpf.model.attendance.vo.attendance.AttendanceApproveImVo;
|
||||
import jnpf.model.workflow.dto.AttendanceWorkOvertimeApproveDto;
|
||||
import jnpf.model.workflow.vo.AttendanceWorkOvertimeApproveVo;
|
||||
import jnpf.permission.model.user.PartUserInfoVo;
|
||||
import jnpf.util.*;
|
||||
import jnpf.workflow.mapper.AttendanceWorkOvertimeApproveMapper;
|
||||
import jnpf.workflow.service.FlowTaskService;
|
||||
import jnpf.workflow.service.WorkOvertimeApproveService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* describe
|
||||
*
|
||||
* @author HuangLinPan
|
||||
* @date 2023/12/12
|
||||
*/
|
||||
@Service
|
||||
public class WorkOvertimeApproveServiceImpl extends SuperServiceImpl<AttendanceWorkOvertimeApproveMapper, AttendanceWorkOvertimeApprove> implements WorkOvertimeApproveService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserAntifreeze userAntifreeze;
|
||||
|
||||
@Resource
|
||||
private FlowTaskService flowTaskService;
|
||||
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Autowired
|
||||
private AttendanceNoticeHandler attendanceNoticeHandler;
|
||||
|
||||
@Resource
|
||||
private CustomTenantUtil customTenantUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(String id, AttendanceWorkOvertimeApprove entity, AttendanceWorkOvertimeApproveDto attendanceWorkOvertimeApproveDto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// String tenantId = userProvider.get().getTenantId();
|
||||
// new Thread(()->{
|
||||
// // 睡眠1秒,确保事务提交完成
|
||||
// try {
|
||||
// Thread.sleep(1000);
|
||||
// workSendIm(entity,tenantId);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }).start();
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void workSendIm(AttendanceWorkOvertimeApprove entity,String tenantId) {
|
||||
//张三的【加班】审批
|
||||
//选择日期:2024年5月16日
|
||||
//开始时间:22:00
|
||||
//结束时间:次日08:00
|
||||
customTenantUtil.checkOutTenant(tenantId);
|
||||
// 查询第一节点审批人
|
||||
ApproverByTaskIdAndNodeIdVo data = flowTaskService.getApproveInfo(entity.getId(), null, tenantId,null);
|
||||
if (null == data) {
|
||||
return;
|
||||
}
|
||||
AttendanceApproveImVo jsonToBean = JsonUtil.getJsonToBean(data, AttendanceApproveImVo.class);
|
||||
jsonToBean.setId(data.getTaskId());
|
||||
List<PartUserInfoVo> allByIds = userAntifreeze.getAllByIds(CollUtil.newArrayList(entity.getUserId()), tenantId);
|
||||
PartUserInfoVo partUserInfoVo = allByIds.stream().findFirst().orElse(null);
|
||||
// 组装消息
|
||||
ApproveImVo approveImVo = new ApproveImVo();
|
||||
approveImVo.setTenantId(tenantId);
|
||||
approveImVo.setAttendanceNoticeEnum(AttendanceNoticeEnum.APPROVE);
|
||||
ApproveBaseImVo approveBaseImVo = new ApproveBaseImVo();
|
||||
approveBaseImVo.setType(ApprovalSettingTypeEnum.OVERTIME.getCode());
|
||||
// approveBaseImVo.setSelectTime(entity.getWorkDay());
|
||||
approveBaseImVo.setStartTime(entity.getStartTime());
|
||||
approveBaseImVo.setEndTime(entity.getEndTime());
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
if (!Objects.isNull(partUserInfoVo)) {
|
||||
stringBuffer.append(partUserInfoVo.getRealName());
|
||||
}
|
||||
approveBaseImVo.setTitle(stringBuffer.append("的【加班】审批").toString());
|
||||
data.getUserOperators().forEach(v->{
|
||||
jsonToBean.setTaskId(v.getTaskOperatorId());
|
||||
approveImVo.setUserIds(CollUtil.newArrayList(v.getUserId()));
|
||||
// URL 拼接
|
||||
// String encode = Base64Util.encode(JSONUtil.toJsonStr(jsonToBean));
|
||||
String encode = FtbUtil.encodeJson(jsonToBean);
|
||||
String url = AttendanceConstant.APPROVE_URL + encode;
|
||||
approveBaseImVo.setUrl(url);
|
||||
approveImVo.setApproveBaseImVo(approveBaseImVo);
|
||||
attendanceNoticeHandler.send(approveImVo);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submit(String id, AttendanceWorkOvertimeApprove entity, AttendanceWorkOvertimeApproveDto attendanceWorkOvertimeApproveDto) {
|
||||
//表单信息
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(id);
|
||||
save(entity);
|
||||
// String tenantId = userProvider.get().getTenantId();
|
||||
// new Thread(()->{
|
||||
// // 睡眠1秒,确保事务提交完成
|
||||
// try {
|
||||
// Thread.sleep(1000);
|
||||
// workSendIm(entity,tenantId);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }).start();
|
||||
} else {
|
||||
entity.setId(id);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendanceWorkOvertimeApproveVo getAttendanceLeave(String id) {
|
||||
AttendanceWorkOvertimeApprove attendanceWorkOvertimeApprove = this.getById(id);
|
||||
AttendanceWorkOvertimeApproveVo jsonToBean = JsonUtil.getJsonToBean(attendanceWorkOvertimeApprove, AttendanceWorkOvertimeApproveVo.class);
|
||||
// 当审核未通过时动态取值
|
||||
// if (1 != jsonToBean.getStatus()){
|
||||
// 动态获取涉及班次/借调班次
|
||||
// }
|
||||
return jsonToBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForOa(AttendanceWorkOvertimeApprove entity) {
|
||||
save(entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user