| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | PowerMapper powerMapper; |
| | | |
| | | |
| | | @Override |
| | | public Map<String, Object> selectAuxiliaryCorrectionHours(Page page, AuxiliaryCorrectionHoursDto auxiliaryCorrectionHoursDto) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Integer> ids = null; |
| | | List<Integer> ids = new ArrayList<>(); |
| | | map.put("head", PrintChina.printChina(AuxiliaryCorrectionHoursDto.class)); |
| | | //判断组长,组员,管理员权限 |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectAuxiliaryCorrectionHours"); |
| | |
| | | } else { |
| | | //是组长 |
| | | //查询组长下的组员 |
| | | List<User> users = userMapper.selectList(Wrappers.<User>lambdaQuery().like(User::getDepartLimsId, user.getDepartLimsId())); |
| | | List<User> users = userMapper.selectList(Wrappers.<User>lambdaQuery() |
| | | .like(User::getDepartLimsId, user.getDepartLimsId()) |
| | | .eq(User::getState, 1)); |
| | | if (ObjectUtils.isNotEmpty(users)) { |
| | | ids = users.stream().map(User::getId).distinct().collect(Collectors.toList()); |
| | | ids.addAll(users.stream().map(User::getId).distinct().collect(Collectors.toList())); |
| | | } |
| | | } |
| | | map.put("body", auxiliaryCorrectionHoursMapper.selectAuxiliaryCorrectionHours(page, QueryWrappers.queryWrappers(auxiliaryCorrectionHoursDto),ids)); |
| | | String departLims = auxiliaryCorrectionHoursDto.getDepartLims(); |
| | | auxiliaryCorrectionHoursDto.setDepartLims(null); |
| | | if (ObjectUtils.isNotEmpty(departLims)) { |
| | | //先模糊查询出来id |
| | | List<Integer> ides = auxiliaryCorrectionHoursMapper.selDepartLimsByName(departLims); |
| | | for (Integer ide : ides) { |
| | | List<User> users = userMapper.selectList(Wrappers.<User>lambdaQuery() |
| | | .like(User::getDepartLimsId, ide) |
| | | .eq(User::getState, 1)); |
| | | if (ObjectUtils.isNotEmpty(users)) { |
| | | ids.clear(); |
| | | ids.addAll(users.stream().map(User::getId).distinct().collect(Collectors.toList())); |
| | | } |
| | | } |
| | | } |
| | | map.put("body", auxiliaryCorrectionHoursMapper.selectAuxiliaryCorrectionHours(page, QueryWrappers.queryWrappers(auxiliaryCorrectionHoursDto).eq("month", auxiliaryCorrectionHoursDto.getMonth()), ids)); |
| | | return map; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | List<AuxiliaryCorrectionHours> auxiliaryCorrectionHoursList = new ArrayList<>(); |
| | | List<AuxiliaryCorrectionHours> auxiliaryCorrectionHoursList1 = new ArrayList<>(); |
| | | for (AuxiliaryCorrectionHoursDto auxiliaryCorrectionHoursDto : list) { |
| | | AuxiliaryCorrectionHours auxiliaryCorrectionHours = new AuxiliaryCorrectionHours(); |
| | | User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getName, auxiliaryCorrectionHoursDto.getName())); |
| | | if (ObjectUtils.isEmpty(user)){ |
| | | throw new RuntimeException("系统没有查到"+auxiliaryCorrectionHoursDto.getName()+"这个用户信息!"); |
| | | if (ObjectUtils.isEmpty(user)) { |
| | | throw new RuntimeException("系统没有查到" + auxiliaryCorrectionHoursDto.getName() + "这个用户信息!"); |
| | | } |
| | | BeanUtils.copyProperties(auxiliaryCorrectionHoursDto,auxiliaryCorrectionHours); |
| | | String regex = "\\d{4}-\\d{2}"; |
| | | if (Pattern.matches(regex,auxiliaryCorrectionHours.getMonth())) { |
| | | throw new RuntimeException(auxiliaryCorrectionHoursDto.getMonth() + "格式不正确,月份格式应为yyyy-MM"); |
| | | } |
| | | BeanUtils.copyProperties(auxiliaryCorrectionHoursDto, auxiliaryCorrectionHours); |
| | | auxiliaryCorrectionHours.setNameUser(user.getId()); |
| | | auxiliaryCorrectionHoursList.add(auxiliaryCorrectionHours); |
| | | AuxiliaryCorrectionHours auxiliaryCorrectionHours1 = auxiliaryCorrectionHoursMapper.selectOne(Wrappers.<AuxiliaryCorrectionHours>lambdaQuery() |
| | | .eq(AuxiliaryCorrectionHours::getNameUser, user.getId()) |
| | | .eq(AuxiliaryCorrectionHours::getType, auxiliaryCorrectionHours.getType()) |
| | | .eq(AuxiliaryCorrectionHours::getMonth, auxiliaryCorrectionHours.getMonth())); |
| | | if (ObjectUtils.isNotEmpty(auxiliaryCorrectionHours1)) { |
| | | auxiliaryCorrectionHoursList1.add(auxiliaryCorrectionHours); |
| | | } else { |
| | | auxiliaryCorrectionHoursList.add(auxiliaryCorrectionHours); |
| | | } |
| | | } |
| | | //批量新增 |
| | | saveBatch(auxiliaryCorrectionHoursList); |
| | | //批量修改 |
| | | updateBatchById(auxiliaryCorrectionHoursList1); |
| | | } |
| | | } |