| | |
| | | * 外来文件确认记录 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 芯导软件(江苏)有限公司 |
| | | * @author |
| | | * @since 2024-11-12 10:29:44 |
| | | */ |
| | | @Service |
| | |
| | | @Override |
| | | public IPage<ManageRecordVerify> pageManageRecordVerify(Page page, ManageRecordVerify manageRecordVerify) { |
| | | if (ObjectUtils.isEmpty(manageRecordVerify.getManageRecordTotalId())) { |
| | | //获取当前年份 |
| | | LocalDate currentDate = LocalDate.now(); |
| | | // 定义日期格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy"); |
| | | // 格式化当前日期 |
| | | String currentMonth = currentDate.format(formatter); |
| | | //查询历史 |
| | | ManageRecordTotal manageRecordTotal = manageRecordTotalMapper.selectOne(Wrappers.<ManageRecordTotal>lambdaQuery().eq(ManageRecordTotal::getYear, currentMonth)); |
| | | ManageRecordTotal manageRecordTotal = getCurrentYearRecord(); |
| | | if (ObjectUtils.isEmpty(manageRecordTotal)) { |
| | | return new Page<>(); |
| | | } |
| | | manageRecordVerify.setManageRecordTotalId(manageRecordTotal.getId()); |
| | | } |
| | | return manageRecordVerifyMapper.pageManageRecordVerify(page, QueryWrappers.queryWrappers(manageRecordVerify)); |
| | |
| | | |
| | | @Override |
| | | public int addManageRecordVerify(ManageRecordVerify manageRecordVerify) { |
| | | ManageRecordTotal manageRecordTotal = getOrCreateCurrentYearRecord(); |
| | | manageRecordVerify.setManageRecordTotalId(manageRecordTotal.getId()); |
| | | manageRecordVerifyMapper.insert(manageRecordVerify); |
| | | manageRecordTotal.setTotalNum(1 + manageRecordTotal.getTotalNum()); |
| | | return manageRecordTotalMapper.updateById(manageRecordTotal); |
| | | } |
| | | |
| | | private ManageRecordTotal getCurrentYearRecord() { |
| | | //获取当前年份 |
| | | LocalDate currentDate = LocalDate.now(); |
| | | // 定义日期格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy"); |
| | | // 格式化当前日期 |
| | | String currentMonth = currentDate.format(formatter); |
| | | ManageRecordTotal manageRecordTotal = manageRecordTotalMapper.selectOne(Wrappers.<ManageRecordTotal>lambdaQuery().eq(ManageRecordTotal::getYear, currentMonth)); |
| | | manageRecordVerify.setManageRecordTotalId(manageRecordTotal.getId()); |
| | | manageRecordVerifyMapper.insert(manageRecordVerify); |
| | | manageRecordTotal.setTotalNum(1 + manageRecordTotal.getTotalNum()); |
| | | return manageRecordTotalMapper.updateById(manageRecordTotal); |
| | | String currentYear = currentDate.format(formatter); |
| | | //查询历史 |
| | | return manageRecordTotalMapper.selectOne(Wrappers.<ManageRecordTotal>lambdaQuery().eq(ManageRecordTotal::getYear, currentYear)); |
| | | } |
| | | |
| | | private ManageRecordTotal getOrCreateCurrentYearRecord() { |
| | | ManageRecordTotal manageRecordTotal = getCurrentYearRecord(); |
| | | if (ObjectUtils.isEmpty(manageRecordTotal)) { |
| | | manageRecordTotal = new ManageRecordTotal(); |
| | | //获取当前年份 |
| | | LocalDate currentDate = LocalDate.now(); |
| | | // 定义日期格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy"); |
| | | // 格式化当前日期 |
| | | String currentYear = currentDate.format(formatter); |
| | | manageRecordTotal.setYear(currentYear); |
| | | manageRecordTotal.setTotalNum(0); |
| | | manageRecordTotalMapper.insert(manageRecordTotal); |
| | | } |
| | | return manageRecordTotal; |
| | | } |
| | | |
| | | @Override |
| | |
| | | public int exportManageRecordVerify(MultipartFile file) { |
| | | List<ManageRecordVerify> manageRecordVerifyList = new ArrayList<>(); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | //获取当前年份 |
| | | LocalDate currentDate = LocalDate.now(); |
| | | // 定义日期格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy"); |
| | | // 格式化当前日期 |
| | | String currentMonth = currentDate.format(formatter); |
| | | ManageRecordTotal manageRecordTotal = manageRecordTotalMapper.selectOne(Wrappers.<ManageRecordTotal>lambdaQuery().eq(ManageRecordTotal::getYear, currentMonth)); |
| | | ManageRecordTotal manageRecordTotal = getOrCreateCurrentYearRecord(); |
| | | try { |
| | | InputStream inputStream = file.getInputStream(); |
| | | XWPFDocument document = new XWPFDocument(inputStream); |
| | |
| | | for (int i = 1; i < rows.size(); i++) { // 从第二行开始,跳过表头 |
| | | XWPFTableRow row = rows.get(i); |
| | | if (row.getTableCells().size() != 8) { |
| | | System.out.println("行 " + (i + 1) + " 的列数不匹配,跳过该行"); |
| | | continue; |
| | | } |
| | | if (ObjectUtils.isNotEmpty(row.getCell(1).getText())) { |
| | |
| | | } |
| | | return 0; |
| | | } |
| | | } |
| | | } |