| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | IPage<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecordIPage = measuringInstrumentLedgerRecordMapper.listPage(page, measuringInstrumentLedgerRecord); |
| | | measuringInstrumentLedgerRecordIPage.getRecords().forEach(item -> { |
| | | LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>(); |
| | | salesLedgerFileWrapper.eq(CommonFile::getCommonId, item.getId()); |
| | | salesLedgerFileWrapper.eq(CommonFile::getCommonId, item.getId()) |
| | | .eq(CommonFile::getType, FileNameType.MEASURINGRecord.getValue()); |
| | | List<CommonFile> commonFiles = commonFileMapper.selectList(salesLedgerFileWrapper); |
| | | item.setCommonFiles(commonFiles); |
| | | }); |
| | |
| | | if(!measuringInstrumentLedgerRecord1.getValid().equals(measuringInstrumentLedgerRecord.getValid())){ |
| | | MeasuringInstrumentLedger measuringInstrumentLedger = measuringInstrumentLedgerMapper.selectById(measuringInstrumentLedgerRecord1.getMeasuringInstrumentLedgerId()); |
| | | if(measuringInstrumentLedger != null){ |
| | | measuringInstrumentLedger.setValid(measuringInstrumentLedgerRecord.getValid()); |
| | | measuringInstrumentLedger.setNextDate(new Date(measuringInstrumentLedger.getMostDate().getTime() + measuringInstrumentLedgerRecord.getValid() * 24 * 60 * 60 * 1000L)); |
| | | } |
| | | measuringInstrumentLedgerMapper.updateById(measuringInstrumentLedger); |
| | | } |
| | | // 删除附件 |
| | | LambdaQueryWrapper<CommonFile> delWrapper = new LambdaQueryWrapper<>(); |
| | | delWrapper.eq(CommonFile::getCommonId, measuringInstrumentLedgerRecord.getId()); |
| | | commonFileMapper.delete(delWrapper); |
| | | measuringInstrumentLedgerRecordMapper.updateById(measuringInstrumentLedgerRecord); |
| | | // 记录附件绑定 |
| | | migrateTempFilesToFormal(measuringInstrumentLedgerRecord.getId(), measuringInstrumentLedgerRecord.getTempFileIds(), FileNameType.MEASURINGRecord.getValue()); |
| | | return true; |
| | |
| | | |
| | | try { |
| | | // 执行文件迁移(使用原子操作确保安全性) |
| | | Files.move( |
| | | Paths.get(tempFile.getTempPath()), |
| | | formalFilePath, |
| | | StandardCopyOption.REPLACE_EXISTING, |
| | | StandardCopyOption.ATOMIC_MOVE |
| | | ); |
| | | // Files.move( |
| | | // Paths.get(tempFile.getTempPath()), |
| | | // formalFilePath, |
| | | // StandardCopyOption.REPLACE_EXISTING, |
| | | // StandardCopyOption.ATOMIC_MOVE |
| | | // ); |
| | | // 原子移动失败,使用复制+删除 |
| | | Files.copy(Paths.get(tempFile.getTempPath()), formalFilePath, StandardCopyOption.REPLACE_EXISTING); |
| | | Files.deleteIfExists(Paths.get(tempFile.getTempPath())); |
| | | log.info("文件迁移成功: {} -> {}", tempFile.getTempPath(), formalFilePath); |
| | | |
| | | // 更新文件记录(关联到业务ID) |