|
@@ -1,32 +1,53 @@
|
|
package com.nokia.financeapi.service.house;
|
|
package com.nokia.financeapi.service.house;
|
|
|
|
|
|
import com.nokia.financeapi.common.R;
|
|
import com.nokia.financeapi.common.R;
|
|
|
|
+import com.nokia.financeapi.dao.house.HouseReportDao;
|
|
import com.nokia.financeapi.pojo.dto.GetHouseReportDto;
|
|
import com.nokia.financeapi.pojo.dto.GetHouseReportDto;
|
|
|
|
+import com.nokia.financeapi.pojo.po.house.HouseReportsPo;
|
|
import com.nokia.financeapi.pojo.vo.GetHouseReportVo;
|
|
import com.nokia.financeapi.pojo.vo.GetHouseReportVo;
|
|
import com.nokia.financeapi.service.common.file.FileService;
|
|
import com.nokia.financeapi.service.common.file.FileService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class HouseReportService {
|
|
public class HouseReportService {
|
|
private final FileService fileService;
|
|
private final FileService fileService;
|
|
|
|
+ private final HouseReportDao houseReportDao;
|
|
|
|
|
|
- public HouseReportService(FileService fileService) {
|
|
|
|
|
|
+ public HouseReportService(FileService fileService, HouseReportDao houseReportDao) {
|
|
this.fileService = fileService;
|
|
this.fileService = fileService;
|
|
|
|
+ this.houseReportDao = houseReportDao;
|
|
}
|
|
}
|
|
|
|
|
|
public R<GetHouseReportVo> getReportWord(GetHouseReportDto dto) {
|
|
public R<GetHouseReportVo> getReportWord(GetHouseReportDto dto) {
|
|
- GetHouseReportVo vo = new GetHouseReportVo();
|
|
|
|
- String object = "oss/reports/house/202307.doc";
|
|
|
|
- String url = fileService.getDownloadUrl(object);
|
|
|
|
- vo.setUrl(url);
|
|
|
|
- return R.ok(vo);
|
|
|
|
|
|
+ dto.setFileType("word");
|
|
|
|
+ return getGetHouseReport(dto);
|
|
}
|
|
}
|
|
|
|
|
|
public R<GetHouseReportVo> getReportPdf(GetHouseReportDto dto) {
|
|
public R<GetHouseReportVo> getReportPdf(GetHouseReportDto dto) {
|
|
|
|
+ dto.setFileType("pdf");
|
|
|
|
+ return getGetHouseReport(dto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private R<GetHouseReportVo> getGetHouseReport(GetHouseReportDto dto) {
|
|
GetHouseReportVo vo = new GetHouseReportVo();
|
|
GetHouseReportVo vo = new GetHouseReportVo();
|
|
- String object = "oss/reports/house/202307.pdf";
|
|
|
|
- String url = fileService.getDownloadUrl(object);
|
|
|
|
- vo.setUrl(url);
|
|
|
|
|
|
+ vo.setUrl("");
|
|
|
|
+ String object = null;
|
|
|
|
+ if (dto.getEndDate() == null) {
|
|
|
|
+ HouseReportsPo po = houseReportDao.getLatest(dto);
|
|
|
|
+ if (po != null) {
|
|
|
|
+ object = po.getUrl();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ HouseReportsPo po = houseReportDao.getByDate(dto);
|
|
|
|
+ if (po != null) {
|
|
|
|
+ object = po.getUrl();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.hasText(object)) {
|
|
|
|
+ String url = fileService.getDownloadUrl(object);
|
|
|
|
+ vo.setUrl(url);
|
|
|
|
+ }
|
|
return R.ok(vo);
|
|
return R.ok(vo);
|
|
}
|
|
}
|
|
}
|
|
}
|