This commit is contained in:
aikai 2024-09-12 21:39:34 +08:00
commit 8c6bfd1ef5
4 changed files with 92 additions and 2 deletions

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.bpm.api.oa;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.bpm.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
import java.util.Map;
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 流程实例")
public interface BpmOAGoOutApi {
String PREFIX = ApiConstants.PREFIX + "/oa/goOut";
@GetMapping(PREFIX + "/getGoOutByTime")
@Operation(summary = "获取当日以及昨日外出的用户编号")
CommonResult<Map<String, List<Long>>> getLeaveListByTime();
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.bpm.api.oa;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAGoOutDO;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAGoOutService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
/**
* Flowable 流程实例 Api 实现类
*
* @author jason
*/
@RestController
@Validated
public class BpmOAGoOutApiImpl implements BpmOAGoOutApi{
@Resource
private BpmOAGoOutService goOutService;
@Override
public CommonResult<Map<String, List<Long>>> getLeaveListByTime() {
// 定义格式化模式
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));
Map<String, List<Long>> result = new HashMap<>();
result.put("now", convertList(goOutNow, BpmOAGoOutDO::getUserId));
result.put("yesterday", convertList(goOutYesterday, BpmOAGoOutDO::getUserId));
return success(result);
}
}

View File

@ -3,6 +3,9 @@ package cn.iocoder.yudao.module.bpm.service.oa;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.goOut.BpmOAGoOutCreateReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAGoOutDO;
import java.time.LocalDate;
import java.util.List;
public interface BpmOAGoOutService {
/**
@ -34,4 +37,11 @@ public interface BpmOAGoOutService {
* @return 外出申请
*/
BpmOAGoOutDO getGoOut(Long id);
/**
* 获得指定开始时间的外出申请
* @param time 时间
* @return 外出申请
*/
List<BpmOAGoOutDO> getGoOutByStartTime(String time);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.service.oa;
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.module.bpm.controller.admin.upload.UploadUserFile;
@ -15,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -79,8 +81,11 @@ public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOu
uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ;
}
// 发起外出申请后设置外勤打卡权限
userApi.updateFieldwork(getLoginUserId(), 1);
// 发起外出申请后判断是否是当天的外出
if (goOut.getStartTime().toLocalDate().isEqual(LocalDate.now())) {
// 设置外勤打卡权限
userApi.updateFieldwork(getLoginUserId(), 1);
}
return goOut.getId();
}
@ -115,6 +120,13 @@ public class BpmOAGoOutServiceImpl extends BpmOABaseService implements BpmOAGoOu
return goOutMapper.selectById(id);
}
@Override
public List<BpmOAGoOutDO> getGoOutByStartTime(String time) {
return goOutMapper.selectList(new LambdaQueryWrapperX<BpmOAGoOutDO>()
.likeIfPresent(BpmOAGoOutDO::getStartTime, time));
}
private void validateLeaveExists(Long id) {
if (goOutMapper.selectById(id) == null) {
throw exception(OA_GOOut_NOT_EXISTS);