|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.gccloud.dataroom.core.module.manage.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.gccloud.common.permission.ApiPermission;
|
|
|
|
@ -13,6 +14,7 @@ import com.gccloud.dataroom.core.utils.DemoDataListener;
|
|
|
|
|
import com.gccloud.dataset.constant.DatasetConstant;
|
|
|
|
|
import com.gccloud.dataset.dto.DatasetDTO;
|
|
|
|
|
import com.gccloud.dataset.entity.DatasetEntity;
|
|
|
|
|
import com.gccloud.dataset.entity.config.BaseDataSetConfig;
|
|
|
|
|
import com.gccloud.dataset.service.IBaseDataSetService;
|
|
|
|
|
import com.gccloud.dataset.service.IDatasetLabelService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
@ -26,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author 17803
|
|
|
|
@ -46,33 +49,50 @@ public class NeUploadExcelController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IBaseDataSetService dataSetService;
|
|
|
|
|
|
|
|
|
|
@ApiOperation("新增Excel")
|
|
|
|
|
@PostMapping("/newAdd")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("上传Excel")
|
|
|
|
|
@PostMapping("/uploadExcel")
|
|
|
|
|
@ApiPermission(permissions = {DatasetConstant.Permission.Dataset.ADD})
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public R<String> newAdd(String datasetDTO, @RequestParam("file") @RequestPart MultipartFile file) throws IOException {
|
|
|
|
|
DatasetDTO datasetByJson = JSON.parseObject(datasetDTO, DatasetDTO.class);
|
|
|
|
|
// IBaseDataSetService dataSetService = dataSetServiceFactory.build(datasetByJson.getDatasetType());
|
|
|
|
|
String id = dataSetService.add(datasetByJson);
|
|
|
|
|
public R uploadExcel(@RequestParam("file") @RequestPart MultipartFile file,String userId) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//存储excel数据 根据id关联
|
|
|
|
|
String s = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
|
|
|
|
|
|
DemoDataListener demoDataListener = new DemoDataListener(neUploadExcelDao, userId, s);
|
|
|
|
|
|
|
|
|
|
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
|
|
|
|
|
EasyExcel.read(file.getInputStream(), StuUploadExcelUser.class,
|
|
|
|
|
new DemoDataListener(neUploadExcelDao, datasetByJson.getRemark(), id)).sheet().doRead();
|
|
|
|
|
new DemoDataListener(neUploadExcelDao, userId, s)).sheet().doRead();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.success(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("分页查询excel")
|
|
|
|
|
@GetMapping("/getExcelByPage")
|
|
|
|
|
@ApiPermission(permissions = {DatasetConstant.Permission.Dataset.ADD})
|
|
|
|
|
public R getExcelByPage(String userId,Integer index,Integer size,String value) throws IOException {
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<StuUploadExcelUser> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
wrapper.eq(StuUploadExcelUser::getModule,value);
|
|
|
|
|
IPage page = new Page(index,size);
|
|
|
|
|
neUploadExcelDao.selectPage(page, wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R<Object> objectR = new R<>(200,String.valueOf(page.getTotal()),page.getRecords());
|
|
|
|
|
|
|
|
|
|
// 保存与标签的关联关系
|
|
|
|
|
List<String> labelIds = datasetByJson.getLabelIds();
|
|
|
|
|
if (labelIds == null || labelIds.isEmpty()) {
|
|
|
|
|
return R.success(id);
|
|
|
|
|
}
|
|
|
|
|
datasetLabelService.addByDatasetId(id, labelIds);
|
|
|
|
|
|
|
|
|
|
return R.success(id);
|
|
|
|
|
return R.success(objectR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("新详情")
|
|
|
|
|
@GetMapping("/NewInfo")
|
|
|
|
|
@ApiPermission(permissions = {DatasetConstant.Permission.Dataset.VIEW})
|
|
|
|
@ -83,8 +103,20 @@ public class NeUploadExcelController {
|
|
|
|
|
DatasetEntityDTO datasetEntityDTO = new DatasetEntityDTO();
|
|
|
|
|
BeanUtils.copyProperties(datasetEntity,datasetEntityDTO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseDataSetConfig config = datasetEntity.getConfig();
|
|
|
|
|
|
|
|
|
|
String value = config.getParamsList().get(0).getValue();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<StuUploadExcelUser> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
wrapper.eq(StuUploadExcelUser::getModule,value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IPage page = new Page(index,size);
|
|
|
|
|
neUploadExcelDao.selectPage(page, null);
|
|
|
|
|
neUploadExcelDao.selectPage(page, wrapper);
|
|
|
|
|
|
|
|
|
|
datasetEntityDTO.setUploadExcelList(page.getRecords());
|
|
|
|
|
|
|
|
|
|