|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
package com.sztzjy.marketing.controller.stu;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.sztzjy.marketing.annotation.AnonymousAccess;
|
|
|
|
|
import com.sztzjy.marketing.entity.StuTableName;
|
|
|
|
|
import com.sztzjy.marketing.entity.StuTableNameExample;
|
|
|
|
|
import com.sztzjy.marketing.entity.StuUploadExcelUser;
|
|
|
|
@ -9,6 +12,7 @@ import com.sztzjy.marketing.entity.dto.StuUserProfileDto;
|
|
|
|
|
import com.sztzjy.marketing.mapper.StuTableNameMapper;
|
|
|
|
|
import com.sztzjy.marketing.mapper.StuUploadExcelUserMapper;
|
|
|
|
|
import com.sztzjy.marketing.service.StuUserProfileDatabaseService;
|
|
|
|
|
import com.sztzjy.marketing.util.HttpUtils;
|
|
|
|
|
import com.sztzjy.marketing.util.ResultEntity;
|
|
|
|
|
import com.sztzjy.marketing.util.excel.DemoDataListener;
|
|
|
|
|
import com.sztzjy.marketing.util.file.IFileUtil;
|
|
|
|
@ -52,57 +56,55 @@ public class StuUserProfileDatabaseController {
|
|
|
|
|
@GetMapping("/getBaseInfo")
|
|
|
|
|
//@AnonymousAccess
|
|
|
|
|
@ApiOperation("用户数据基本信息")
|
|
|
|
|
public ResultEntity<StuUserProfileDto> getBaseInfo(String userId){
|
|
|
|
|
public ResultEntity<StuUserProfileDto> getBaseInfo(String userId) {
|
|
|
|
|
return userProfileDatabaseService.getBaseInfo(userId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getBaseInfoBySelect")
|
|
|
|
|
//@AnonymousAccess
|
|
|
|
|
@ApiOperation("条件查询用户表信息")
|
|
|
|
|
public ResultEntity getBaseInfoBySelect( @ApiParam("用户ID")String userId,
|
|
|
|
|
public ResultEntity getBaseInfoBySelect(@ApiParam("用户ID") String userId,
|
|
|
|
|
@ApiParam("表名") @RequestParam(required = false) String tableName,
|
|
|
|
|
@RequestParam(required = false) @ApiParam("自建表名") String selfTableName,
|
|
|
|
|
@ApiParam("页码") Integer index,@ApiParam("每页展示数量") Integer size){
|
|
|
|
|
@ApiParam("页码") Integer index, @ApiParam("每页展示数量") Integer size) {
|
|
|
|
|
|
|
|
|
|
return userProfileDatabaseService.getBaseInfoBySelect(userId,tableName,selfTableName,index,size);
|
|
|
|
|
return userProfileDatabaseService.getBaseInfoBySelect(userId, tableName, selfTableName, index, size);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/selfExcelBaseInfo")
|
|
|
|
|
//@AnonymousAccess
|
|
|
|
|
@ApiOperation("自荐表数据下拉框")
|
|
|
|
|
public ResultEntity selfExcelBaseInfo( @ApiParam("用户ID")String userId){
|
|
|
|
|
public ResultEntity selfExcelBaseInfo(@ApiParam("用户ID") String userId) {
|
|
|
|
|
|
|
|
|
|
return userProfileDatabaseService.selfExcelBaseInfo(userId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导入外部Excel格式的数据
|
|
|
|
|
@ApiOperation("外部excel上传")
|
|
|
|
|
@PostMapping("/uploadExcel")
|
|
|
|
|
//@AnonymousAccess
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public ResultEntity uploadExcel(@RequestPart @ApiParam("文件") MultipartFile file,@RequestParam(required = false) String userId) throws IOException {
|
|
|
|
|
public ResultEntity uploadExcel(@RequestPart @ApiParam("文件") MultipartFile file, @RequestParam(required = false) String userId) throws IOException {
|
|
|
|
|
//读取文件内容 批量导入excel中 以文件名区分\
|
|
|
|
|
|
|
|
|
|
String fileName = file.getOriginalFilename().substring(0,file.getOriginalFilename().lastIndexOf("."));
|
|
|
|
|
String fileName = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf("."));
|
|
|
|
|
|
|
|
|
|
//导入之前判断是否重复导入
|
|
|
|
|
StuTableNameExample stuTableNameExample = new StuTableNameExample();
|
|
|
|
|
stuTableNameExample.createCriteria().andUserIdEqualTo(userId).andTableNameEqualTo(fileName);
|
|
|
|
|
List<StuTableName> stuTableNames = stuTableNameMapper.selectByExample(stuTableNameExample);
|
|
|
|
|
if (!CollectionUtils.isEmpty(stuTableNames)){
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK,"文件已存在!");
|
|
|
|
|
if (!CollectionUtils.isEmpty(stuTableNames)) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "文件已存在!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
|
|
|
|
|
EasyExcel.read(file.getInputStream(), StuUploadExcelUser.class,new DemoDataListener(stuUploadExcelUserMapper,userId,fileName)).sheet().doRead();
|
|
|
|
|
EasyExcel.read(file.getInputStream(), StuUploadExcelUser.class, new DemoDataListener(stuUploadExcelUserMapper, userId, fileName)).sheet().doRead();
|
|
|
|
|
|
|
|
|
|
StuTableName tableName = new StuTableName();
|
|
|
|
|
tableName.setUserId(userId);
|
|
|
|
@ -112,10 +114,35 @@ public class StuUserProfileDatabaseController {
|
|
|
|
|
stuTableNameMapper.insertSelective(tableName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK,"上传成功");
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "上传成功");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("外部excel上传")
|
|
|
|
|
@PostMapping("/readInfo")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity readInfo(String text, String userId) throws IOException {
|
|
|
|
|
|
|
|
|
|
String url = "http://wbdsj.sztzjy.com/prod-api/makesoft/report/sentiment";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject entries = HttpUtils.sendPost(url, text, null, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String str = entries.getStr("respString");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将字符串解析为JSONObject
|
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(str);
|
|
|
|
|
|
|
|
|
|
// 获取 data 字段的值
|
|
|
|
|
String data = jsonObject.getStr("data");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "成功", data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|