| | |
| | | import com.ruoyi.common.enums.ReportingStatusEnum; |
| | | import com.ruoyi.common.enums.UserTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.TbBasicData; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.system.dto.update.DeptFocusDTO; |
| | |
| | | import com.ruoyi.system.service.TbBasicDataService; |
| | | import com.ruoyi.system.service.TbDeptService; |
| | | import com.ruoyi.system.vo.DeptVO; |
| | | import java.io.InputStream; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.InputStream; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | Page<SysUser> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | Page<SysUser> userPage = sysUserService.lambdaQuery() |
| | | .eq(SysUser::getUserType, UserTypeEnum.DEPARTMENT.getCode()) |
| | | .like(StringUtils.isNotEmpty(query.getAreaName()), SysUser::getAreaName, query.getAreaName()) |
| | | .like(StringUtils.isNotEmpty(query.getUserName()), SysUser::getUserName, query.getUserName()) |
| | | .like(StringUtils.isNotEmpty(query.getPhone()), SysUser::getPhoneNumber, query.getPhone()) |
| | | .like(StringUtils.isNotEmpty(query.getAreaName()), SysUser::getAreaName, |
| | | query.getAreaName()) |
| | | .like(StringUtils.isNotEmpty(query.getUserName()), SysUser::getUserName, |
| | | query.getUserName()) |
| | | .like(StringUtils.isNotEmpty(query.getPhone()), SysUser::getPhoneNumber, |
| | | query.getPhone()) |
| | | .orderByDesc(SysUser::getCreateTime) |
| | | .page(page); |
| | | |
| | |
| | | //使用自定义校验规则 |
| | | importParams.setVerifyHandler(deptVerifyHandler); |
| | | InputStream inputStream = file.getInputStream(); |
| | | ExcelImportResult<DeptExcel> result = ExcelImportUtil.importExcelMore(inputStream, DeptExcel.class, importParams); |
| | | ExcelImportResult<DeptExcel> result = ExcelImportUtil.importExcelMore(inputStream, |
| | | DeptExcel.class, importParams); |
| | | inputStream.close(); |
| | | List<DeptExcel> list = result.getList(); |
| | | |
| | |
| | | } |
| | | List<String> strings = hasDuplicateAreaCode(list); |
| | | if (!CollectionUtils.isEmpty(strings)) { |
| | | throw new ServiceException(String.format("区划代码%s重复,请修改后重新导入", String.join(",", strings))); |
| | | throw new ServiceException( |
| | | String.format("区划代码%s重复,请修改后重新导入", String.join(",", strings))); |
| | | }else { |
| | | List<TbDept> tbDeptList = BeanUtils.copyList(list, TbDept.class); |
| | | this.remove(null); |
| | |
| | | |
| | | /** |
| | | * 校验区划代码是否重复 |
| | | * |
| | | * @param deptList 部门列表 |
| | | * @return 重复的区划代码 |
| | | */ |
| | |
| | | |
| | | @Override |
| | | public void focus(DeptFocusDTO dto) { |
| | | Optional<SysUser> sysUser = sysUserService.lambdaQuery().eq(SysUser::getUserId, dto.getUserId()).oneOpt(); |
| | | Optional<SysUser> sysUser = sysUserService.lambdaQuery() |
| | | .eq(SysUser::getUserId, dto.getUserId()).oneOpt(); |
| | | if (sysUser.isPresent()) { |
| | | sysUserService.lambdaUpdate() |
| | | .eq(SysUser::getUserId, dto.getUserId()) |
| | |
| | | //判断当前时间是否在季度初1-15号 |
| | | Instant instant = quarterStart.toInstant(); |
| | | LocalDate quarterStartLocalDate = instant.atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | LocalDate fifteenDaysLimit = quarterStartLocalDate.plusDays(15); |
| | | LocalDate fifteenDaysLimit = quarterStartLocalDate.plusDays(14); |
| | | LocalDate now = LocalDate.now(); |
| | | //如果当前时间不在规定范围内:季度初1-15号 |
| | | if (now.isAfter(quarterStartLocalDate) || now.isBefore(fifteenDaysLimit)) { |
| | | //查询所有的部门 |
| | | List<SysUser> list = sysUserService.lambdaQuery().eq(SysUser::getUserType, UserTypeEnum.DEPARTMENT.getCode()).list(); |
| | | Set<String> deptAreaCodeList = list.stream().map(SysUser::getAreaCode).collect(Collectors.toSet()); |
| | | List<SysUser> list = sysUserService.lambdaQuery() |
| | | .eq(SysUser::getUserType, UserTypeEnum.DEPARTMENT.getCode()).list(); |
| | | Set<String> deptAreaCodeList = list.stream().map(SysUser::getAreaCode) |
| | | .collect(Collectors.toSet()); |
| | | //查询当前季度填报了数据的部门 |
| | | List<TbBasicData> filledBasicData = tbBasicDataService.lambdaQuery().between(TbBasicData::getCreateTime, quarterStartLocalDate, fifteenDaysLimit) |
| | | List<TbBasicData> filledBasicData = tbBasicDataService.lambdaQuery() |
| | | .between(TbBasicData::getCreateTime, quarterStartLocalDate, fifteenDaysLimit) |
| | | .eq(TbBasicData::getStatus, ReportingStatusEnum.FILLED).list(); |
| | | Set<String> filledDeptCodes = filledBasicData.stream().map(TbBasicData::getDeptAreaCode).collect(Collectors.toSet()); |
| | | Set<String> filledDeptCodes = filledBasicData.stream().map(TbBasicData::getDeptAreaCode) |
| | | .collect(Collectors.toSet()); |
| | | if (!filledDeptCodes.containsAll(deptAreaCodeList)) { |
| | | return R.fail("有部门未上传季度数据"); |
| | | } |