Compare commits

...

6 Commits

19 changed files with 153 additions and 77 deletions

View File

@ -4,11 +4,10 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.bpm.api.oa.vo.BpmOALeaveRpcVO;
import cn.iocoder.yudao.module.bpm.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@ -18,9 +17,9 @@ public interface BpmOALeaveApi {
String PREFIX = ApiConstants.PREFIX + "/oa/leave";
@GetMapping(PREFIX + "/leaveListByTime")
@Operation(summary = "根据时间获取请假列表")
@Parameter(name = "time", description = "时间格式yyyy-MM-dd", required = true, example = "2024-05-11")
CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByTime(@RequestParam(name = "time") String time);
@PostMapping(PREFIX + "/getLeaveListByIds")
@Operation(summary = "根据请假ids获取请假列表")
CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByIds(@RequestBody List<Long> ids);
}

View File

@ -1,29 +1,74 @@
package cn.iocoder.yudao.module.bpm.api.oa.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
public class BpmOALeaveRpcVO {
@Schema(description = "请假表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
/**
* 请假表单主键
*/
private Long id;
@Schema(description = "用户id")
/**
* 申请人的用户编号
* <p>
* 关联 AdminUserDO id 属性
*/
private Long userId;
@Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "开始时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
/**
* 假期设置id
*/
private Long holidaySettingId;
/**
* 原因
*/
private String reason;
/**
* 假期名称
*/
private String leaveName;
/**
* 开始时间
*/
private LocalDateTime startTime;
@Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "结束时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
/**
* 结束时间
*/
private LocalDateTime endTime;
@Schema(description = "请假类型-参见 bpm_oa_leave_type 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "请假类型不能为空")
private Integer type;
/**
* 请假时长单位根据请假最小单位来 按天or按半天 单位为天 按小时单位为小时
*/
private BigDecimal duration;
/**
* 开始时间额外字段 根据请假最小单位来 1按天则为空 2按半天则1为上午 2为下午 3按小时则 格式为 HH:mm
*/
private String startTimeExtraFields;
/**
* 结束时间额外字段 根据请假最小单位来 1按天则为空 2按半天则1为上午 2为下午 3按小时则 格式为 HH:mm
*/
private String endTimeExtraFields;
/**
* 请假最小单位 1按天 2按半天 3按小时
*/
private Integer minUnit;
/**
* 请假的结果
* <p>
* 枚举 {@link BpmProcessInstanceResultEnum}
* 考虑到简单所以直接复用了 BpmProcessInstanceResultEnum 枚举也可以自己定义一个枚举哈
*/
private Integer result;
/**
* 对应的流程编号
* <p>
* 关联 ProcessInstance id 属性
*/
private String processInstanceId;
}

View File

@ -24,9 +24,9 @@ public class BpmOALeaveApiImpl implements BpmOALeaveApi {
@Resource
private BpmOALeaveService leaveService;
@Override
public CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByTime(String time) {
return success(leaveService.getLeaveListByTime(time));
}
@Override
public CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByIds(List<Long> ids) {
return CommonResult.success(leaveService.getLeaveListByIds(ids));
}
}

View File

@ -29,10 +29,4 @@ public interface BpmOALeaveMapper extends BaseMapperX<BpmOALeaveDO> {
.orderByDesc(BpmOALeaveDO::getId));
}
/**
*
* @param time
* @return
*/
List<BpmOALeaveRpcVO> getLeaveListByTime(@Param("time") String time);
}

View File

@ -58,14 +58,6 @@ public interface BpmOALeaveService {
*/
PageResult<BpmOALeaveDO> getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO);
/**
* 根据时间获取请假列表
*
* @param time
* @return
*/
List<BpmOALeaveRpcVO> getLeaveListByTime(String time);
/**
* 获得指定请假申请
*
@ -82,4 +74,12 @@ public interface BpmOALeaveService {
* @return
*/
BigDecimal calculateAndVerifyTheNumberOfLeaveDays(Long loginUserId, CalculateAndVerifyLeaveDTO dto);
/**
* 根据请假ids获取请假列表
*
* @param ids
* @return
*/
List<BpmOALeaveRpcVO> getLeaveListByIds(List<Long> ids);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.bpm.service.oa;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.json.JSONUtil;
@ -524,10 +525,6 @@ public class BpmOALeaveServiceImpl extends BpmOABaseService implements BpmOALeav
return leaveMapper.selectPage(userId, pageReqVO);
}
@Override
public List<BpmOALeaveRpcVO> getLeaveListByTime(String time) {
return leaveMapper.getLeaveListByTime(time);
}
@Override
public BpmOALeaveDO getByProcessInstanceId(String processInstanceId) {
@ -545,4 +542,13 @@ public class BpmOALeaveServiceImpl extends BpmOABaseService implements BpmOALeav
this.builderLeaveTime(leave);
return this.calculateAndVerifyTheNumberOfLeaveDays(leave);
}
@Override
public List<BpmOALeaveRpcVO> getLeaveListByIds(List<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<BpmOALeaveDO> bpmOALeaveDOS = leaveMapper.selectBatchIds(ids);
return BeanUtil.copyToList(bpmOALeaveDOS, BpmOALeaveRpcVO.class);
}
}

View File

@ -9,15 +9,4 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getLeaveListByTime" resultType="cn.iocoder.yudao.module.bpm.api.oa.vo.BpmOALeaveRpcVO">
SELECT
*
FROM
bpm_oa_leave
<where>
result = 2
AND DATE_FORMAT( end_time, '%Y-%m-%d' ) &gt;= #{time}
AND DATE_FORMAT( start_time, '%Y-%m-%d') &lt;= #{time}
</where>
</select>
</mapper>

View File

@ -161,7 +161,9 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
AdminUserPageApiDTO userPageReqVO = new AdminUserPageApiDTO();
userPageReqVO.setPageNo(pageReqVO.getPageNo());
userPageReqVO.setPageSize(pageReqVO.getPageSize());
PageResult<AdminUserApiVO> pageResult = adminUserApi.getUserPage(userPageReqVO).getCheckedData();
// -- 这里固定查询销售的
userPageReqVO.setRoleCode("sale");
PageResult<AdminUserApiVO> pageResult = adminUserApi.getUserBringDeptPage(userPageReqVO).getCheckedData();
PageResult<UserAchieveRespVO> pageResult1 = BeanUtils.toBean(pageResult, UserAchieveRespVO.class);
List<Long> typeIds = new ArrayList<>();
for (UserAchieveRespVO vo : pageResult1.getList()) {

View File

@ -116,4 +116,8 @@ public interface AdminUserApi {
@GetMapping(PREFIX + "/getUserListBySubordinateIds")
@Operation(summary = "获取当前部门以及下级部门所有人员(负责人)")
CommonResult<List<Long>> getUserListBySubordinateIds(@RequestParam(name = "adminId") Long adminId);
@PostMapping(PREFIX + "/getUserBringDeptPage")
@Operation(summary = "获取用户分页列表通过条件")
CommonResult<PageResult<AdminUserApiVO>> getUserBringDeptPage(@RequestBody AdminUserPageApiDTO userPageReqVO);
}

View File

@ -40,4 +40,7 @@ public class AdminUserPageApiDTO extends PageParam {
@Schema(description = "考勤组ids", example = "1024")
private List<Long> groupIds;
@Schema(description = "角色code", example = "1")
private String roleCode;
}

View File

@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.template.vo.MsgData;
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
@ -33,20 +32,26 @@ public class SubscribeMessageSendApiImpl implements SubscribeMessageSendApi {
@Resource
private SocialClientService socialClientService;
@SneakyThrows
@Override
public CommonResult<Long> sendMaMsg(SubscribeMessageReqDTO reqDTO) {
//发送审批结果通知
socialClientService.getWxMaService(reqDTO.getSocialType()).getMsgService().sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
try {
//发送审批结果通知
socialClientService.getWxMaService(reqDTO.getSocialType()).getMsgService().sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
} catch (Exception e) {
log.error("发送小程序订阅消息失败:{}", e.getMessage());
}
return success(1L);
}
@Override
@SneakyThrows
public CommonResult<Long> sendMpMsg(SubscribeMessageReqDTO reqDTO) {
// -- 公众号 点击 跳转 小程序 - 需要获取到小程序appId
// 判断是否需要跳转小程序 - 通过
socialClientService.getWxMpService().getTemplateMsgService().sendTemplateMsg(initWxMpSubscribeMessage(reqDTO));
try {
socialClientService.getWxMpService().getTemplateMsgService().sendTemplateMsg(initWxMpSubscribeMessage(reqDTO));
} catch (Exception e) {
log.error("发送公众号消息失败:{}", e.getMessage());
}
return success(1L);
}

View File

@ -145,4 +145,13 @@ public class AdminUserApiImpl implements AdminUserApi {
return success(ids);
}
@Override
public CommonResult<PageResult<AdminUserApiVO>> getUserBringDeptPage(AdminUserPageApiDTO dto) {
PageResult<AdminUserApiVO> vo = new PageResult<>();
UserPageReqVO userPageReqVO = BeanUtil.copyProperties(dto, UserPageReqVO.class);
PageResult<AdminUserDO> pageResult = userService.getUserBringDeptPage(userPageReqVO);
BeanUtil.copyProperties(pageResult, vo);
return success(vo);
}
}

View File

@ -45,4 +45,7 @@ public class UserPageReqVO extends PageParam {
@Schema(description = "考勤组ids", example = "1024")
private List<Long> groupIds;
@Schema(description = "角色编码", example = "1024")
private String roleCode;
}

View File

@ -11,6 +11,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, FactoryInfoApi.class, BpmModelApi.class, BpmOAGoOutApi.class, BpmOAEntryApi.class, ConfigApi.class,
BpmOAEvectionApi.class, BpmOAReplacementCardApi.class, BpmOARefundApi.class})
BpmOAEvectionApi.class, BpmOAReplacementCardApi.class, BpmOARefundApi.class, BpmOALeaveApi.class})
public class RpcConfiguration {
}

View File

@ -15,9 +15,11 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.distance.GeoUtil;
import cn.iocoder.yudao.module.bpm.api.oa.BpmOALeaveApi;
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAReplacementCardApi;
import cn.iocoder.yudao.module.bpm.api.oa.vo.BpmOALeaveRpcVO;
import cn.iocoder.yudao.module.system.api.attendance.dto.AttendanceTimeRangeInfoDTO;
import cn.iocoder.yudao.module.system.api.attendance.vo.AttendanceTimeRangeInfoVO;
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAReplacementCardApi;
import cn.iocoder.yudao.module.system.controller.admin.attendance.dto.*;
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.punchrecord.vo.AttendancePunchRecordSaveReqVO;
@ -28,7 +30,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.A
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.punchrecord.AttendancePunchRecordDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.attendance.group.AttendanceGroupMapper;
import cn.iocoder.yudao.module.system.dal.mysql.attendance.punchrecord.AttendancePunchRecordMapper;
@ -117,7 +118,8 @@ public class AttendanceServiceImpl implements AttendanceService {
@Resource
private BpmOAReplacementCardApi replacementCardApi;
@Resource
private BpmOALeaveApi leaveApi;
// 定义一些常量以提高代码的可读性和可维护性
/**
@ -1224,9 +1226,11 @@ public class AttendanceServiceImpl implements AttendanceService {
List<List<String>> data = new ArrayList<>();
// -- 根据部门分组 - 根据考勤组分组
Map<Long, List<AttendancePunchRecordDO>> userPunchMap = list.stream().collect(Collectors.groupingBy(AttendancePunchRecordDO::getUserId));
List<DictDataDO> bpmOaLeaveType = dictDataService.getDictDataList(CommonStatusEnum.ENABLE.getStatus(), "bpm_oa_leave_type");
//根据字典值分组
Map<String, String> leaveTypeMap = bpmOaLeaveType.stream().collect(Collectors.toMap(DictDataDO::getValue, DictDataDO::getLabel));
// 获取到这段时间请假的Ids
List<Long> leaveIds = list.stream().map(AttendancePunchRecordDO::getLeaveId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
List<BpmOALeaveRpcVO> leaveRpcVOS = leaveApi.getLeaveListByIds(leaveIds).getCheckedData();
Map<Long, String> leaveTypeMap = leaveRpcVOS.stream().collect(Collectors.toMap(BpmOALeaveRpcVO::getId, BpmOALeaveRpcVO::getLeaveName));
//
// -- 先计算下要循环几次 - 一个用户一个部门一个考勤组一个班次一个日期 最大的打卡次数 -
Map<String, List<AttendancePunchRecordDO>> map = list.stream().collect(Collectors.groupingBy(
a -> a.getUserId() + "_"
@ -1275,7 +1279,7 @@ public class AttendanceServiceImpl implements AttendanceService {
for (Map.Entry<Long, List<AttendancePunchRecordDO>> groupShiftItemEntry : workMap.entrySet()) {
for (AttendancePunchRecordDO attendancePunchRecordDO : groupShiftItemEntry.getValue()) {
row.add(attendancePunchRecordDO.getPunchTime() == null ? "/" : attendancePunchRecordDO.getPunchTime().format(Constants.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
String statusStr = attendancePunchRecordDO.getStatus().equals(AttendanceOnTheDayDTO.ASK_FOR_LEAVE) ? "请假-" + leaveTypeMap.get(attendancePunchRecordDO.getLeaveType()) : this.statusToStr(attendancePunchRecordDO.getStatus());
String statusStr = attendancePunchRecordDO.getStatus().equals(AttendanceOnTheDayDTO.ASK_FOR_LEAVE) ? "请假-" + leaveTypeMap.get(attendancePunchRecordDO.getLeaveId()) : this.statusToStr(attendancePunchRecordDO.getStatus());
row.add(statusStr);
}
}

View File

@ -21,7 +21,7 @@ public interface AdminOauthUserOtherInfoService {
*/
void checkInsert(Long userId, String appId, String openId, Integer socialType);
AdminOauthUserOtherInfoDO getByCondition(Long userId, String appId, String openId, Integer socialType);
AdminOauthUserOtherInfoDO getByCondition(Long userId, Integer socialType);
/**
* 通过社交类型+用户状态获取用户社交信息

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.service.auth;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.module.system.dal.dataobject.auth.AdminOauthUserOtherInfoDO;
import cn.iocoder.yudao.module.system.dal.mysql.auth.AdminOauthUserOtherInfoMapper;
import cn.iocoder.yudao.module.system.service.auth.dto.AdminOauthUserOtherInfoDTO;
@ -8,6 +9,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
/**
@ -24,22 +26,24 @@ public class AdminOauthUserOtherInfoServiceImpl implements AdminOauthUserOtherIn
@Override
public void checkInsert(Long userId, String appId, String openId, Integer socialType) {
AdminOauthUserOtherInfoDO adminOauthUserOtherInfoDOS = this.getByCondition(userId, appId, openId, socialType);
AdminOauthUserOtherInfoDO adminOauthUserOtherInfoDOS = this.getByCondition(userId, socialType);
if (adminOauthUserOtherInfoDOS == null) {
adminOauthUserOtherInfoMapper.insert(new AdminOauthUserOtherInfoDO()
.setUserId(userId)
.setAppId(appId)
.setOpenId(openId)
.setSocialType(socialType));
} else {
if (!adminOauthUserOtherInfoDOS.getOpenId().equals(openId)) {
adminOauthUserOtherInfoMapper.updateById(adminOauthUserOtherInfoDOS.setOpenId(openId));
}
}
}
@Override
public AdminOauthUserOtherInfoDO getByCondition(Long userId, String appId, String openId, Integer socialType) {
public AdminOauthUserOtherInfoDO getByCondition(Long userId, Integer socialType) {
return adminOauthUserOtherInfoMapper.selectOne(new LambdaQueryWrapper<AdminOauthUserOtherInfoDO>()
.eq(AdminOauthUserOtherInfoDO::getUserId, userId)
.eq(AdminOauthUserOtherInfoDO::getAppId, appId)
.eq(AdminOauthUserOtherInfoDO::getOpenId, openId)
.eq(AdminOauthUserOtherInfoDO::getSocialType, socialType));
}

View File

@ -50,7 +50,7 @@
#{deptId}
</foreach>
</if>
<if test="dto.userIds != null and dto.userIds() > 0">
<if test="dto.userIds != null and dto.userIds.size() > 0">
and b.id in
<foreach collection="dto.userIds" item="userId" open="(" close=")" separator=",">
#{userId}

View File

@ -129,6 +129,10 @@
<if test="vo.groupIds != null and vo.groupIds.size() > 0">
left join kq_attendance_group_user c on a.id = c.user_id
</if>
<if test="vo.roleCode != null and vo.roleCode != ''">
left join system_user_role as d on a.id = d.user_id AND d.deleted = 0
left join system_role as e on d.role_id = e.id AND e.deleted = 0
</if>
<where>
a.deleted = 0
and a.user_type = 1
@ -166,6 +170,9 @@
#{groupId}
</foreach>
</if>
<if test="vo.roleCode != null and vo.roleCode != ''">
and e.code = #{vo.roleCode}
</if>
</where>
</select>
<select id="selectListByCondition"
@ -201,4 +208,6 @@
</if>
</where>
</select>
</mapper>