Compare commits

...

2 Commits

Author SHA1 Message Date
furongxin
4829400ae2 feat(bpm): 添加我的出差申请列表功能
- 新增 getEvectionList 方法获取当前用户的出差申请列表
- 修改 selectEvectionList SQL 查询以排除已报销的出差申请
- 在前端添加我的出差申请列表接口和页面
-优化报销相关数据结构,增加业务表编号字段
- 修复流程实例创建时未配置岗位和部门的异常处理
2025-05-30 12:27:23 +08:00
furongxin
4131f6100d feat(smartfactory): 为员工导入功能添加银行卡信息并优化更新逻辑
- 在 StaffImportExcelVO 中添加银行名称和银行卡号字段
- 优化员工信息更新逻辑,增加对用户名和身份证号的校验
- 在员工导入时设置银行卡名称和银行卡号
- 改进员工信息匹配逻辑,支持模糊匹配用户名
2025-05-30 12:26:23 +08:00
17 changed files with 150 additions and 34 deletions

View File

@ -8,9 +8,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -34,8 +32,25 @@ public class BpmOAEvectionApiImpl implements BpmOAEvectionApi {
List<BpmOAEvectionDO> evectionOff = evectionService.getEvectionListByEndTime(now.minusDays(1));
Map<String, List<Long>> result = new HashMap<>();
result.put("on", evectionOn.stream().map(BpmOAEvectionDO::getUserId).distinct().collect(Collectors.toList()));
result.put("off", evectionOff.stream().map(BpmOAEvectionDO::getUserId).distinct().collect(Collectors.toList()));
result.put("on", evectionOn.stream().flatMap(item -> {
Set<Long> togetherUserIds = item.getTogetherUserIds();
List<Long> ids = new ArrayList<>();
ids.add(item.getUserId());
if (togetherUserIds != null) {
ids.addAll(togetherUserIds); // Set 转换为 List 并添加进去
}
return ids.stream();
}).distinct().collect(Collectors.toList()));
result.put("off", evectionOff.stream().flatMap(item -> {
Set<Long> togetherUserIds = item.getTogetherUserIds();
List<Long> ids = new ArrayList<>();
ids.add(item.getUserId());
if (togetherUserIds != null) {
ids.addAll(togetherUserIds); // Set 转换为 List 并添加进去
}
return ids.stream();
}).distinct().collect(Collectors.toList()));
return success(result);
}
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.controller.admin.oa;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.evection.BpmOAEvectionCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.evection.BpmOAEvectionRespVO;
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAEvectionConvert;
@ -65,6 +66,15 @@ public class BpmOAEvectionController {
return success(respVO);
}
@GetMapping("/get-list")
@Operation(summary = "获得我的出差申请")
public CommonResult<List<BpmOAEvectionRespVO>> getEvectionList() {
List<BpmOAEvectionDO> evections = evectionService.getEvectionList();
return success(BeanUtils.toBean(evections, BpmOAEvectionRespVO.class));
}
@GetMapping("/getByProcessInstanceId")
@Operation(summary = "获得出差申请")
@Parameter(name = "processInstanceId", description = "流程实例编号", required = true, example = "1024")

View File

@ -52,6 +52,9 @@ public class BpmOAReimbursementCreateReqVO {
@Schema(description = "备用金差额", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private BigDecimal difference ;
@Schema(description = "业务表编号")
private Long objectId;
@Schema(description = "报销发票总数", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "报销发票总数不能为空")
private Integer totalQuantity ;

View File

@ -38,4 +38,7 @@ public class Reimbursement {
@Schema(description = "采购计划编号", example = "1")
private Long procureId;
@Schema(description = "业务表编号")
private Long objectId;
}

View File

@ -36,4 +36,7 @@ public class ReimbursementDTO {
@Schema(description = "采购计划编号", example = "1")
private Long procureId;
@Schema(description = "业务表编号")
private Long objectId;
}

View File

@ -68,4 +68,9 @@ public class BpmOAReimbursementItemDO extends BaseDO {
* 采购申请编号
*/
private Long procureId;
/**
* 业务表编号
*/
private Long objectId;
}

View File

@ -6,8 +6,10 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.evection.BpmOAEvection
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAEvectionDO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Arrays;
import java.util.List;
/**
* 出差申请 Mapper
@ -26,4 +28,6 @@ public interface BpmOAEvectionMapper extends BaseMapperX<BpmOAEvectionDO> {
.geIfPresent(BpmOAEvectionDO::getEndTime, createReqVO.getStartTime())
.in(BpmOAEvectionDO::getResult, Arrays.asList(BpmProcessInstanceResultEnum.PROCESS.getResult(), BpmProcessInstanceResultEnum.APPROVE.getResult())));
}
List<BpmOAEvectionDO> selectEvectionList(@Param("userId") Long userId);
}

View File

@ -54,4 +54,10 @@ public interface BpmOAEvectionService {
* @return 出差申请列表
*/
List<BpmOAEvectionDO> getEvectionListByEndTime(LocalDate date);
/**
* 获得我的出差申请列表
* @return 出差申请列表
*/
List<BpmOAEvectionDO> getEvectionList();
}

View File

@ -20,6 +20,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_EVECTION_IS_EXISTS;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_EVECTION_NOT_EXISTS;
@ -150,4 +151,10 @@ public class BpmOAEvectionServiceImpl extends BpmOABaseService implements BpmOAE
.eq(BpmOAEvectionDO::getResult, BpmProcessInstanceResultEnum.APPROVE.getResult())
.likeIfPresent(BpmOAEvectionDO::getEndTime, date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
}
@Override
public List<BpmOAEvectionDO> getEvectionList() {
return evectionMapper.selectEvectionList(getLoginUserId());
}
}

View File

@ -114,6 +114,7 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
processInstanceVariables.put("factoryType", factoryInfoDTO.getType());
}
processInstanceVariables.put("loanType", loan.getLoanType());
String processInstanceId = processInstanceService.createProcessInstance(userId,
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(loan.getId())));

View File

@ -276,9 +276,9 @@ public class BpmOAPaymentServiceImpl extends BpmOABaseService implements BpmOAPa
// 获取银行卡信息
BankRespDTO bankResp = bankApi.getBank(payment.getBankId()).getCheckedData();
// 设置银行卡信息
respVO.setBankName(bankResp.getBankName());
respVO.setBankNo(bankResp.getBankNo());
respVO.setNickname(bankResp.getNickname());
respVO.setBankName(bankResp != null ? bankResp.getBankName() : null);
respVO.setBankNo(bankResp != null ? bankResp.getBankNo() : null);
respVO.setNickname(bankResp != null ? bankResp.getNickname() : null);
}
}
return respVO;

View File

@ -25,7 +25,6 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.module.system.api.bank.dto.BankRespDTO;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@ -101,6 +100,7 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
@Override
@Transactional(rollbackFor = Exception.class)
public Long createReimbursement(Long userId, BpmOAReimbursementCreateReqVO createReqVO) {
BpmOAReimbursementDO reimbursement = BpmOAReimbursementConvert.INSTANCE.convert(createReqVO).setUserId(userId)
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
@ -120,6 +120,8 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
createDO.forEach(item -> item.setReimbursementId(reimbursement.getId()));
reimbursementItemMapper.insertBatch(createDO);
// 同步更新
// 发起 BPM 流程
Map<String, Object> processInstanceVariables = new HashMap<>();
String processInstanceId = processInstanceApi.createProcessInstance(userId,

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAEvectionMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectEvectionList" resultType="cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAEvectionDO">
SELECT
a.*
FROM
bpm_oa_evection a
WHERE
a.id NOT IN (
SELECT
c.object_id
FROM
bpm_oa_reimbursement b,
bpm_oa_reimbursement_item c
WHERE
b.user_id = #{userId}
AND b.deleted = 0
AND b.id = c.reimbursement_id
AND b.result IN ( 1, 2 )
AND c.type = 1
AND c.object_id IS NOT NULL
)
AND a.user_id = #{userId}
AND a.deleted = 0
ORDER BY
a.create_time DESC
</select>
</mapper>

View File

@ -78,15 +78,23 @@
<if test="pageReqVO.userId != null">
AND a.user_id = #{pageReqVO.userId}
</if>
<if test="pageReqVO.factoryId != null">
AND b.dept_id = #{pageReqVO.factoryId}
</if>
<if test="pageReqVO.type != null">
AND b.type = #{pageReqVO.type}
</if>
<if test="pageReqVO.costSection != null">
AND b.cost_section = #{pageReqVO.costSection}
</if>
AND EXISTS (
SELECT
1
FROM
bpm_oa_expenses_item b
WHERE
b.expenses_id = a.id
<if test="pageReqVO.factoryId != null">
AND b.dept_id = #{pageReqVO.factoryId}
</if>
<if test="pageReqVO.type != null">
AND b.type = #{pageReqVO.type}
</if>
<if test="pageReqVO.costSection != null">
AND b.cost_section = #{pageReqVO.costSection}
</if>
)
<if test="pageReqVO.payeeName != null">
AND ub.nickname LIKE CONCAT('%', #{pageReqVO.payeeName}, '%')
</if>

View File

@ -41,6 +41,12 @@ public class StaffImportExcelVO {
@IdCard
private String idCard;
@ExcelProperty("银行名称")
private String bankName;
@ExcelProperty("银行卡号")
private String bankNo;
@ExcelProperty("薪资")
private BigDecimal salary;
}

View File

@ -68,21 +68,22 @@ public class StaffServiceImpl implements StaffService {
@Override
public void updateStaff(StaffSaveReqVO updateReqVO) {
if (staffMapper.selectById(updateReqVO.getId()) == null) {
StaffDO staff = staffMapper.selectById(updateReqVO.getId());
if (staff == null) {
throw exception(STAFF_NOT_EXISTS);
}
// 校验用户名身份证号是否已经存在
Long cunt = staffMapper.selectCount(new LambdaQueryWrapperX<StaffDO>()
.neIfPresent(StaffDO::getId, updateReqVO.getId())
.eqIfPresent(StaffDO::getIdCard, updateReqVO.getIdCard()));
if (cunt > 0) {
throw exception(USER_USERNAME_EXISTS);
if (!staff.getIdCard().equals(updateReqVO.getIdCard()) || !staff.getNickName().equals(updateReqVO.getNickName())) {
// 校验用户名身份证号是否已经存在
Long cunt = staffMapper.selectCount(new LambdaQueryWrapperX<StaffDO>()
.neIfPresent(StaffDO::getId, updateReqVO.getId())
.eqIfPresent(StaffDO::getIdCard, updateReqVO.getIdCard())
.eqIfPresent(StaffDO::getNickName, updateReqVO.getNickName()));
if (cunt > 0) {
throw exception(USER_USERNAME_EXISTS);
}
}
// 身份证号是否已经存在
validateUserForCreate(null, null, null, updateReqVO.getIdCard());
// 更新
StaffDO updateObj = BeanUtils.toBean(updateReqVO, StaffDO.class);
staffMapper.updateById(updateObj);
@ -201,6 +202,9 @@ public class StaffServiceImpl implements StaffService {
//设置 性别年龄
updateUser.setSex(idCardDO.getSex());
updateUser.setAge(idCardDO.getAge());
// 设置银行卡名称 银行卡号
updateUser.setBankName(importUser.getBankName());
updateUser.setBankNo(importUser.getBankNo());
//设置部门ID
if (StrUtil.isNotEmpty(importUser.getFactoryName())) {
@ -226,12 +230,14 @@ public class StaffServiceImpl implements StaffService {
if (updateSupport) {
StaffDO staffDO = staffMapper.selectOne(new LambdaQueryWrapperX<StaffDO>()
.eqIfPresent(StaffDO::getIdCard, importUser.getIdCard())
.eqIfPresent(StaffDO::getNickName, importUser.getNickName()));
.likeIfPresent(StaffDO::getNickName, importUser.getNickName()));
updateUser.setId(staffDO.getId());
staffMapper.updateById(updateUser);
respVO.getUpdateUsernames().add(importUser.getNickName());
return;
if (staffDO != null) {
updateUser.setId(staffDO.getId());
staffMapper.updateById(updateUser);
respVO.getUpdateUsernames().add(importUser.getNickName());
return;
}
}
// 插入用户