修改状态

This commit is contained in:
mash 2024-12-03 11:58:16 +08:00
parent 825674398f
commit f1190bb43b
1 changed files with 26 additions and 7 deletions

View File

@ -271,19 +271,38 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult deleteByIds(PersonnelDeleteRequest ids) {
List<String> asList = Arrays.asList(ids.getIds());
for (String s : asList) {
Personnel personnel = personnelMapper.selectOne(new LambdaQueryWrapper<Personnel>().eq(Personnel::getId, s).eq(Personnel::getAlterationSign, "1")
.eq(Personnel::getChangeAlterationSign, "1").in(Personnel::getAuditState, 1, 2).in(Personnel::getChangeAuditState, 1, 2));
List<String> idList = Arrays.asList(ids.getIds());
for (String id : idList) {
Personnel personnel = personnelMapper.selectOne(new LambdaQueryWrapper<Personnel>()
.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<Personnel> 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("删除失败!");
}
}