|
|
@@ -0,0 +1,112 @@
|
|
|
+package com.jeesite.modules.report.service;
|
|
|
+
|
|
|
+import com.jeesite.common.constant.Constants;
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
+import com.jeesite.common.service.CrudService;
|
|
|
+import com.jeesite.modules.file.entity.FileEntity;
|
|
|
+import com.jeesite.modules.file.entity.FileUpload;
|
|
|
+import com.jeesite.modules.file.utils.FileUploadUtils;
|
|
|
+import com.jeesite.modules.report.dao.WebsiteUserReportDao;
|
|
|
+import com.jeesite.modules.report.entity.WebsiteUserReport;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 发送网站用户报告Service
|
|
|
+ * @author gmj
|
|
|
+ * @version 2026-01-08
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class WebsiteUserReportService extends CrudService<WebsiteUserReportDao, WebsiteUserReport> {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取单条数据
|
|
|
+ * @param websiteUserReport
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public WebsiteUserReport get(WebsiteUserReport websiteUserReport) {
|
|
|
+ return super.get(websiteUserReport);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询分页数据
|
|
|
+ * @param websiteUserReport 查询条件
|
|
|
+ * @param websiteUserReport.page 分页对象
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<WebsiteUserReport> findPage(WebsiteUserReport websiteUserReport) {
|
|
|
+ int pageSize = websiteUserReport.getPageSize();
|
|
|
+ Page<WebsiteUserReport> page = super.findPage(websiteUserReport);
|
|
|
+ page.setList(page.getList().stream()
|
|
|
+ .map(w -> convertFile(w, w.getId(), Constants.websiteUserReport.WEBSITE_USER_REPORT_FILE))
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ long total = super.findCount(websiteUserReport);
|
|
|
+ long count = total / pageSize;
|
|
|
+ if(total % pageSize > 0){
|
|
|
+ count = count +1;
|
|
|
+ }
|
|
|
+ page.setCount(count);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ public WebsiteUserReport convertFile(WebsiteUserReport websiteUserReport, String bizKey, String bizType) {
|
|
|
+ List<FileUpload> list = FileUploadUtils.findFileUpload(bizKey, bizType);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ FileEntity fileEntity = list.get(0).getFileEntity();
|
|
|
+ if (fileEntity != null) {
|
|
|
+ websiteUserReport.setFileName(fileEntity.getFileId() + '.' + fileEntity.getFileExtension());
|
|
|
+ websiteUserReport.setFilePath(fileEntity.getFilePath());
|
|
|
+ websiteUserReport.setFileSize(fileEntity.getFileSize());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return websiteUserReport;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表数据
|
|
|
+ * @param websiteUserReport
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<WebsiteUserReport> findList(WebsiteUserReport websiteUserReport) {
|
|
|
+ return super.findList(websiteUserReport);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据(插入或更新)
|
|
|
+ * @param websiteUserReport
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void save(WebsiteUserReport websiteUserReport) {
|
|
|
+ super.save(websiteUserReport);
|
|
|
+ FileUploadUtils.saveFileUpload(websiteUserReport,websiteUserReport.getId(), Constants.websiteUserReport.WEBSITE_USER_REPORT_FILE);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新状态
|
|
|
+ * @param websiteUserReport
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void updateStatus(WebsiteUserReport websiteUserReport) {
|
|
|
+ super.updateStatus(websiteUserReport);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除数据
|
|
|
+ * @param websiteUserReport
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void delete(WebsiteUserReport websiteUserReport) {
|
|
|
+ super.delete(websiteUserReport);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|