Commit 1b4ae83a88c6b05abce3c367f733ef9a494846d7
1 parent
66b96aa4
人机材修改
Showing
1 changed file
with
29 additions
and
2 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/personalcost/PersonalCostServiceImpl.java
| 1 | 1 | package com.zteits.urbanops.module.garden.service.personalcost; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 3 | 5 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 4 | 6 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 7 | +import com.zteits.urbanops.module.garden.controller.admin.costfee.vo.TeamBizdomainRelVo; | |
| 5 | 8 | import com.zteits.urbanops.module.garden.controller.admin.personalcost.vo.PersonalCostPageReqVO; |
| 6 | 9 | import com.zteits.urbanops.module.garden.controller.admin.personalcost.vo.PersonalCostSaveReqVO; |
| 7 | 10 | import com.zteits.urbanops.module.garden.dal.dataobject.personalcost.PersonalCostDO; |
| 8 | 11 | import com.zteits.urbanops.module.garden.dal.mysql.personalcost.PersonalCostMapper; |
| 9 | -import com.zteits.urbanops.module.garden.controller.admin.costfee.vo.TeamBizdomainRelVo; | |
| 10 | - | |
| 11 | 12 | import com.zteits.urbanops.module.system.api.dept.DeptApi; |
| 12 | 13 | import jakarta.annotation.Resource; |
| 13 | 14 | import org.springframework.stereotype.Service; |
| 14 | 15 | import org.springframework.transaction.annotation.Transactional; |
| 16 | +import org.springframework.util.CollectionUtils; | |
| 15 | 17 | import org.springframework.validation.annotation.Validated; |
| 16 | 18 | |
| 17 | 19 | import java.util.List; |
| 18 | 20 | import java.util.stream.Collectors; |
| 19 | 21 | |
| 22 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | |
| 20 | 23 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 24 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; | |
| 21 | 25 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PERSONAL_COST_NOT_EXISTS; |
| 22 | 26 | |
| 23 | 27 | /** |
| ... | ... | @@ -44,6 +48,29 @@ public class PersonalCostServiceImpl implements PersonalCostService { |
| 44 | 48 | .map(TeamBizdomainRelVo::getTeamId) |
| 45 | 49 | .collect(Collectors.toList()); |
| 46 | 50 | personalCost.setDeptId(deptIds); |
| 51 | + if (CollectionUtils.isEmpty(deptIds)) { | |
| 52 | + throw exception0(BAD_REQUEST.getCode(), "部门ID集合不能为空"); | |
| 53 | + } | |
| 54 | + LambdaQueryWrapper<PersonalCostDO> queryWrapper = Wrappers.lambdaQuery(); | |
| 55 | + queryWrapper.eq(PersonalCostDO::getSalaryMonth, createReqVO.getSalaryMonth()); | |
| 56 | + queryWrapper.eq(PersonalCostDO::getName, createReqVO.getName()); | |
| 57 | + queryWrapper.eq(PersonalCostDO::getCompanyId, createReqVO.getCompanyId()); | |
| 58 | + List<PersonalCostDO> existingList = personalCostMapper.selectList(queryWrapper); | |
| 59 | + if(!CollectionUtils.isEmpty(existingList)) { | |
| 60 | + for (PersonalCostDO existing : existingList) { | |
| 61 | + List<Long> existingDeptList = existing.getDeptId(); | |
| 62 | + if (CollectionUtils.isEmpty(existingDeptList)) { | |
| 63 | + continue; | |
| 64 | + } | |
| 65 | + boolean isDuplicate = deptIds.stream() | |
| 66 | + .anyMatch(existingDeptList::contains); | |
| 67 | + | |
| 68 | + if (isDuplicate) { | |
| 69 | + String userName = createReqVO.getName(); | |
| 70 | + throw exception0(BAD_REQUEST.getCode(), "人员" + userName + "费用已录入"); | |
| 71 | + } | |
| 72 | + } | |
| 73 | + } | |
| 47 | 74 | personalCostMapper.insert(personalCost); |
| 48 | 75 | // 返回 |
| 49 | 76 | return personalCost.getId(); | ... | ... |