From f1190bb43bee0d96f0ff671d75db8c65674039e0 Mon Sep 17 00:00:00 2001 From: mash Date: Tue, 3 Dec 2024 11:58:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PersonnelServiceImpl.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java index a6df69f..42cf4c5 100644 --- a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java +++ b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java @@ -271,19 +271,38 @@ public class PersonnelServiceImpl extends BaseService asList = Arrays.asList(ids.getIds()); - for (String s : asList) { - Personnel personnel = personnelMapper.selectOne(new LambdaQueryWrapper().eq(Personnel::getId, s).eq(Personnel::getAlterationSign, "1") - .eq(Personnel::getChangeAlterationSign, "1").in(Personnel::getAuditState, 1, 2).in(Personnel::getChangeAuditState, 1, 2)); + List idList = Arrays.asList(ids.getIds()); + + for (String id : idList) { + Personnel personnel = personnelMapper.selectOne(new LambdaQueryWrapper() + .eq(Personnel::getId, id) + .eq(Personnel::getAlterationSign, "1") + .eq(Personnel::getChangeAlterationSign, "1") + .in(Personnel::getAuditState, 1, 2) + .in(Personnel::getChangeAuditState, 1, 2)); + if (ObjectUtil.isNotEmpty(personnel)) { return AjaxResult.fail().msg("该人员有变更中或待审批数据,不能删除!"); } } - if (CollectionUtil.isEmpty(asList)) { + + if (CollectionUtil.isEmpty(idList)) { return AjaxResult.fail().msg("Id不能为空!"); } else { - int i = personnelMapper.deleteBatchIds(asList); - return i > 0 ? AjaxResult.ok().msg("删除成功!") : AjaxResult.fail().msg("删除失败!"); + List personnels = personnelMapper.selectBatchIds(idList); + + for (Personnel personnel : personnels) { + if ("退休".equals(personnel.getWorkState()) || "离职".equals(personnel.getWorkState())) { + CompanyName companyName = companyNameMapper.selectById(personnel.getCompanyName()); + if (companyName != null) { + companyName.setResidualNumber(companyName.getResidualNumber() - 1); + companyNameMapper.updateById(companyName); + } + } + } + + int deleteCount = personnelMapper.deleteBatchIds(idList); + return deleteCount > 0 ? AjaxResult.ok().msg("删除成功!") : AjaxResult.fail().msg("删除失败!"); } }