修改用户数据库相关接口,

添加开放接口,自动同步新增账号学生信息,
master
whb 7 months ago
parent c0d3006986
commit b8f1213d7c

@ -23,7 +23,7 @@ public class TokenProvider {
private final static String SECRET = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAghgsx+OLLThi7c+/HgCaRla8n+/QLHt++uscoK22dMeaVa3WJvRb5C5qtHGzj9V74pI96JpxdWWCN3Zr1QtanQIDAQABAkB2fWRUD1jVMBVS+rPctLnPNPMKTRdzXGv0SC5D3tRfGZqdcfsmZg8hzBVndHxngmwZS73d+hPjofcdefDDnXq1AiEAz/r1AMF7fweN70mbKgBJuTja37puJMsH2Szwrvb5jlcCIQCgIaLZ5d9J7OomL0NwH8ghba/xgBEpKzErfGbFnTfeKwIgc8ptczFFV1DWZb2eJIEqinOr79l0jwl2YiQSD+cyw1sCIHqxCvv1Wx5jPgy/zeYNE+Q5DMP3Ii7u/x+Yk436JiI9AiEAio84hFm44YTUuV7YCYsbyvnCn/vtcAaqZlczbeHlP1I=";
private final static long EXP_TIME = 1000 * 60 * 60 * 4;
private final static String SECRET_ZHIYUN = "zy_yx_mnjy_fp76ckwuczzmb67w0a8x0";
private final static String SECRET_ZHIYUN = "zy_szyx_mnjy_fp76ckwuczzmb67w0a8x0";
private final static String CURRENT_TO_ZHIYUN = "jVzvfoZU_eFN0CJcFARg0K6DlzTLa7oMWB7lV_y2s7bkv2Bem0281wEwlJp5afhsmM-Ynwvh3mAUTpwblGEz1A";

@ -2,12 +2,9 @@ package com.sztzjy.marketing.controller.stu;
import cn.hutool.core.util.IdUtil;
import com.alibaba.excel.EasyExcel;
import com.sztzjy.marketing.annotation.AnonymousAccess;
import com.sztzjy.marketing.config.ThreadPoolConfig;
import com.sztzjy.marketing.entity.StuTableName;
import com.sztzjy.marketing.entity.StuTableNameExample;
import com.sztzjy.marketing.entity.StuUploadExcelUser;
import com.sztzjy.marketing.entity.StuUser;
import com.sztzjy.marketing.entity.dto.StuUserProfileDto;
import com.sztzjy.marketing.mapper.StuTableNameMapper;
import com.sztzjy.marketing.mapper.StuUploadExcelUserMapper;
@ -16,19 +13,16 @@ import com.sztzjy.marketing.util.ResultEntity;
import com.sztzjy.marketing.util.excel.DemoDataListener;
import com.sztzjy.marketing.util.file.IFileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.Async;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@ -93,7 +87,7 @@ public class StuUserProfileDatabaseController {
@PostMapping("/uploadExcel")
//@AnonymousAccess
@Transactional(rollbackFor = Exception.class)
public ResultEntity uploadExcel(@RequestPart @ApiParam("文件") MultipartFile file,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("."));

@ -135,8 +135,6 @@ public class UserController {
// jwtUser = TokenProvider.getJWTUserByZhiYun(TOKEN);
if (jwtUser == null) {
throw new UnAuthorizedException("token无效");
}

@ -21,7 +21,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
@ -94,7 +93,9 @@ public class SummaryOfGradesController {
//@AnonymousAccess
public ResultEntity setResultsOverviewWeight(@RequestBody TchGeneralViewWeightDTO generalViewWeightDTO) {
Boolean b = userService.insertByTchGeneralViewWeightDTO(generalViewWeightDTO);
userService.totalRank(generalViewWeightDTO.getSchoolId());
if (b == true) {
return new ResultEntity(HttpStatus.OK, "成绩总览权重设置成功");
}

@ -3,7 +3,6 @@ package com.sztzjy.marketing.service.impl;/**
* @date 2024-06-12 10:43
*/
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.marketing.config.Constant;
@ -13,17 +12,14 @@ import com.sztzjy.marketing.entity.dto.StuUserProfileDto;
import com.sztzjy.marketing.mapper.*;
import com.sztzjy.marketing.service.StuUserProfileDatabaseService;
import com.sztzjy.marketing.util.ResultEntity;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.util.CollectionUtils;
import java.rmi.ServerException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Service
@ -58,6 +54,15 @@ public class StuUserProfileDatabaseServiceImpl implements StuUserProfileDatabase
list.add("购物车数据表");
list.add("用户评论表");
list.add("RFM明细数据");
list.add("AARRR传播数据");
list.add("超市销售数据");
list.add("集团商品销售总表");
list.add("用户登录表");
list.add("用户留存分析");
list.add("用户粘性分析");
list.add("AARRR示例数据");
//用户属性表
StuSpendingLevelExample userAttributeExample = new StuSpendingLevelExample();
userAttributeExample.setOrderByClause("id asc");
@ -156,6 +161,24 @@ public class StuUserProfileDatabaseServiceImpl implements StuUserProfileDatabase
}
String[] list = {"RFM明细数据","AARRR传播数据","超市销售数据","集团商品销售总表","用户登录表","用户留存分析","用户粘性分析","AARRR示例数据"};
List<String> collect = Arrays.stream(list).collect(Collectors.toList());
if (collect.contains(tableName))
{
//开启分页
PageHelper.startPage(index, size);
StuUploadExcelUserExample uploadExcelUserExample = new StuUploadExcelUserExample();
uploadExcelUserExample.createCriteria().andUserIdEqualTo("999999999").andModuleEqualTo(tableName);
List<StuUploadExcelUser> stuUploadExcelUsers = uploadExcelUserMapper.selectByExample(uploadExcelUserExample);
if (!CollectionUtils.isEmpty(stuUploadExcelUsers))
{
return new ResultEntity<>(HttpStatus.OK, new PageInfo<>(stuUploadExcelUsers));
}
}
}

@ -3,16 +3,15 @@ package com.sztzjy.marketing.service.impl;/**
* @date 2024-05-07 9:58
*/
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.marketing.config.security.JwtUser;
import com.sztzjy.marketing.entity.*;
import com.sztzjy.marketing.entity.StuUser;
import com.sztzjy.marketing.entity.TchModuleWeith;
import com.sztzjy.marketing.entity.TchModuleWeithExample;
import com.sztzjy.marketing.entity.ZYUserInfo;
import com.sztzjy.marketing.mapper.StuUserMapper;
import com.sztzjy.marketing.mapper.TchModuleWeithMapper;
import com.sztzjy.marketing.service.StuUserService;
import com.sztzjy.marketing.util.PageUtil;
import com.sztzjy.marketing.util.TzApi;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -146,8 +145,6 @@ public class StuUserServiceImpl implements StuUserService {
stuUser.setTotalScore(BigDecimal.valueOf(0));
users.add(stuUser);
}
System.out.println("==========11111开始同步智云主平台用户数据11111==============="+System.currentTimeMillis());
for (StuUser user : users) {

@ -7,17 +7,12 @@ import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.util.ConverterUtils;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.fastjson.JSON;
import com.sztzjy.marketing.config.ThreadPoolConfig;
import com.sztzjy.marketing.entity.StuUploadExcelUser;
import com.sztzjy.marketing.mapper.StuUploadExcelUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.RunnableFuture;
// 有个很重要的点 DemoDataListener 不能被spring管理要每次读取excel都要new,然后里面用到spring可以构造方法传进去
@ -64,11 +59,11 @@ public class DemoDataListener implements ReadListener<StuUploadExcelUser> {
*/
@Override
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
log.info("解析到一条头数据:{}", JSON.toJSONString(headMap));
// log.info("解析到一条头数据:{}", JSON.toJSONString(headMap));
Map<Integer, String> integerStringMap = ConverterUtils.convertToStringMap(headMap, context);
log.info("转换解析到的一条头数据:{}", integerStringMap);
//log.info("转换解析到的一条头数据:{}", integerStringMap);
Set<Integer> integers = integerStringMap.keySet();
@ -150,6 +145,9 @@ public class DemoDataListener implements ReadListener<StuUploadExcelUser> {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (value.contains(",")){
value = value.replaceAll(",","");
}
try {
// 尝试将字符串转换为 int
int intValue = Integer.parseInt(value);

Loading…
Cancel
Save