refactor(bpm): 优化外出申请查询逻辑
- 将获取前一天外出申请的逻辑改为获取前一天结束的外出申请 - 新增 getGoOutByEndTime 方法用于获取指定结束时间的外出申请 - 更新 FieldworkJob 中的逻辑,根据外出结束时间来关闭外勤打卡权限
This commit is contained in:
parent
34a6b6d4cd
commit
53bf2a584e
@ -35,7 +35,7 @@ public class BpmOAGoOutApiImpl implements BpmOAGoOutApi{
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
List<BpmOAGoOutDO> goOutNow = goOutService.getGoOutByStartTime(LocalDate.now().format(formatter));
|
||||
List<BpmOAGoOutDO> goOutYesterday = goOutService.getGoOutByStartTime(LocalDate.now().minusDays(1).format(formatter));
|
||||
List<BpmOAGoOutDO> goOutYesterday = goOutService.getGoOutByEndTime(LocalDate.now().minusDays(1).format(formatter));
|
||||
|
||||
Map<String, List<Long>> result = new HashMap<>();
|
||||
result.put("now", convertList(goOutNow, BpmOAGoOutDO::getUserId));
|
||||
|
@ -44,4 +44,11 @@ public interface BpmOAGoOutService {
|
||||
* @return 外出申请
|
||||
*/
|
||||
List<BpmOAGoOutDO> getGoOutByStartTime(String time);
|
||||
|
||||
/**
|
||||
* 获得指定结束时间的外出申请
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
List<BpmOAGoOutDO> getGoOutByEndTime(String time);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.goOut.BpmOAGoOutCreateReqVO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAGoOutConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAGoOutDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAGoOutMapper;
|
||||
@ -17,7 +17,10 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@ -27,11 +30,10 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_GOOut_NOT_
|
||||
* OA 外出申请 Service 实现类
|
||||
*
|
||||
* @author 符溶馨
|
||||
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOutService{
|
||||
public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOutService {
|
||||
|
||||
/**
|
||||
* OA 外出对应的流程定义 KEY
|
||||
@ -73,10 +75,10 @@ public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOu
|
||||
historyProcessInstanceService.createHistoryProcessInstance(processInstanceId, createReqVO.getProcessInstanceId());
|
||||
}
|
||||
|
||||
List<UploadUserFile> fileItems = createReqVO.getFileItems() ;
|
||||
List<UploadUserFile> fileItems = createReqVO.getFileItems();
|
||||
//这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id
|
||||
if (fileItems != null && !fileItems.isEmpty()) {
|
||||
uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ;
|
||||
uploadBpmFileProcessInstanceId(processInstanceId, fileItems);
|
||||
}
|
||||
|
||||
// 发起外出申请后,判断是否是当天的外出
|
||||
@ -124,6 +126,12 @@ public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOu
|
||||
.likeIfPresent(BpmOAGoOutDO::getStartTime, time));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BpmOAGoOutDO> getGoOutByEndTime(String time) {
|
||||
return goOutMapper.selectList(new LambdaQueryWrapperX<BpmOAGoOutDO>()
|
||||
.likeIfPresent(BpmOAGoOutDO::getEndTime, time));
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (goOutMapper.selectById(id) == null) {
|
||||
throw exception(OA_GOOut_NOT_EXISTS);
|
||||
|
@ -40,13 +40,12 @@ public class FieldworkJob {
|
||||
|
||||
// 外勤打卡权限变更
|
||||
try {
|
||||
|
||||
// 获取用户编号
|
||||
Map<String, List<Long>> goOutList = goOutApi.getLeaveListByTime().getCheckedData();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(goOutList.get("yesterday"))) {
|
||||
|
||||
// 将昨日外出的用户,关闭外勤打卡权限
|
||||
// 将昨日外出结束的用户,关闭外勤打卡权限
|
||||
adminUserMapper.update(new AdminUserDO().setFieldworkFlag(0).setFieldworkType(0),
|
||||
new LambdaQueryWrapper<AdminUserDO>()
|
||||
.in(AdminUserDO::getId, goOutList.get("yesterday"))
|
||||
@ -55,7 +54,7 @@ public class FieldworkJob {
|
||||
|
||||
if (CollectionUtil.isNotEmpty(goOutList.get("now"))) {
|
||||
|
||||
// 讲需要当天外出的用户,设置外勤打卡权限
|
||||
// 讲需要当天外出开始的用户,设置外勤打卡权限
|
||||
adminUserMapper.update(new AdminUserDO().setFieldworkFlag(1).setFieldworkType(2),
|
||||
new LambdaQueryWrapper<AdminUserDO>()
|
||||
.in(AdminUserDO::getId, goOutList.get("now"))
|
||||
@ -104,4 +103,4 @@ public class FieldworkJob {
|
||||
log.info(ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user