|
@@ -7,9 +7,8 @@ import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.project.VRdemo.domain.*;
|
|
|
import com.ruoyi.project.VRdemo.mapper.DataExcelMapper;
|
|
|
-import com.ruoyi.project.VRdemo.service.INoticeDataService;
|
|
|
-import com.ruoyi.project.VRdemo.service.IPressService;
|
|
|
-import com.ruoyi.project.VRdemo.service.IStudyDataService;
|
|
|
+import com.ruoyi.project.VRdemo.service.*;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -43,8 +42,16 @@ public class DataIoController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private IStudyDataService studyDataService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IPressService pressService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IThesisService thesisService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IResearchService researchService;
|
|
|
+
|
|
|
// 应用导出数据
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,company')")
|
|
|
@GetMapping("/export/app")
|
|
@@ -82,7 +89,7 @@ public class DataIoController extends BaseController {
|
|
|
EasyExcel.write(response.getOutputStream(), ImportApp.class).sheet("Sheet1").doWrite(dataList);
|
|
|
}
|
|
|
|
|
|
- // 活动预告导出数据
|
|
|
+ // 活动预告导出数据
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
|
|
|
@GetMapping("/export/noticeData")
|
|
|
public void exNoticeData(HttpServletResponse response) throws IOException {
|
|
@@ -108,7 +115,7 @@ public class DataIoController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- // 活动预告导入数据
|
|
|
+ // 活动预告导入数据
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
|
|
|
@PostMapping("/import/notice")
|
|
|
public AjaxResult imNoticeData(MultipartFile file, boolean updateSupport) throws IOException {
|
|
@@ -121,7 +128,7 @@ public class DataIoController extends BaseController {
|
|
|
return success(message);
|
|
|
}
|
|
|
|
|
|
- // 活动预告下载模板
|
|
|
+ // 活动预告下载模板
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
|
|
|
@PostMapping("/importTemplate/notice")
|
|
|
public void imNoticeTemplate(HttpServletResponse response) throws IOException {
|
|
@@ -129,7 +136,7 @@ public class DataIoController extends BaseController {
|
|
|
EasyExcel.write(response.getOutputStream(), NoticeImData.class).sheet("Sheet1").doWrite(dataList);
|
|
|
}
|
|
|
|
|
|
- // 研究导出数据
|
|
|
+ // 研究导出数据
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
|
|
|
@GetMapping("/export/studydata")
|
|
|
public void exStudyData(HttpServletResponse response) throws IOException {
|
|
@@ -169,7 +176,7 @@ public class DataIoController extends BaseController {
|
|
|
EasyExcel.write(response.getOutputStream(), StudyExData.class).registerWriteHandler(new CustomCellWriteWeightConfig()).sheet("Sheet1").doWrite(dataList);
|
|
|
}
|
|
|
|
|
|
- // 研究导入数据
|
|
|
+ // 研究导入数据
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,company,xmg')")
|
|
|
@PostMapping("/import/study")
|
|
|
public AjaxResult imStudyData(MultipartFile file, boolean updateSupport) throws IOException {
|
|
@@ -212,4 +219,51 @@ public class DataIoController extends BaseController {
|
|
|
// 返回成功响应,携带导入结果信息
|
|
|
return AjaxResult.success(message);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入Thesis数据
|
|
|
+ */
|
|
|
+// @PreAuthorize("@ss.hasAnyRoles('admin,company')")
|
|
|
+ @Anonymous
|
|
|
+ @PostMapping("/import/thesis")
|
|
|
+ public AjaxResult importThesisData(MultipartFile file, boolean updateSupport) throws IOException {
|
|
|
+ // 初始化监听器以处理导入逻辑
|
|
|
+ ThesisImportListener dataImportListener = new ThesisImportListener(DataExcelMapper);
|
|
|
+
|
|
|
+ // 使用EasyExcel读取Excel文件内容
|
|
|
+ EasyExcel.read(file.getInputStream(), Thesis.class, dataImportListener)
|
|
|
+ .sheet() // 默认读取第一个sheet
|
|
|
+ .headRowNumber(1) // 指定表头所在行数
|
|
|
+ .doRead(); // 执行读取操作
|
|
|
+
|
|
|
+ // 调用服务层方法进行数据导入处理
|
|
|
+ String message = thesisService.importThesis(dataImportListener.getDataList(), updateSupport);
|
|
|
+
|
|
|
+ // 返回成功响应,携带导入结果信息
|
|
|
+ return AjaxResult.success(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入research数据
|
|
|
+ */
|
|
|
+// @PreAuthorize("@ss.hasAnyRoles('admin,company')")
|
|
|
+ @Anonymous
|
|
|
+ @PostMapping("/import/research")
|
|
|
+ public AjaxResult importResearchData(MultipartFile file, boolean updateSupport) throws IOException {
|
|
|
+ // 初始化监听器以处理导入逻辑
|
|
|
+ ResearchImportListener dataImportListener = new ResearchImportListener(DataExcelMapper);
|
|
|
+
|
|
|
+ // 使用EasyExcel读取Excel文件内容
|
|
|
+ EasyExcel.read(file.getInputStream(), Research.class, dataImportListener)
|
|
|
+ .sheet() // 默认读取第一个sheet
|
|
|
+ .headRowNumber(1) // 指定表头所在行数
|
|
|
+ .doRead(); // 执行读取操作
|
|
|
+
|
|
|
+ // 调用服务层方法进行数据导入处理
|
|
|
+ String message = researchService.importResearch(dataImportListener.getDataList(), updateSupport);
|
|
|
+
|
|
|
+ // 返回成功响应,携带导入结果信息
|
|
|
+ return AjaxResult.success(message);
|
|
|
+ }
|
|
|
+
|
|
|
}
|