查询指定用户各功能使用情况
This commit is contained in:
@@ -5,21 +5,24 @@ import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.DesignMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
||||
import com.ai.da.model.vo.QuestionnaireVO;
|
||||
import com.ai.da.service.ConvenientInquiryService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Api(tags = "便利查询")
|
||||
@Slf4j
|
||||
@@ -81,4 +84,47 @@ public class ConvenientInquiryController {
|
||||
return Response.success(convenientInquiryService.getAllQuestionnaire());
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期新用户")
|
||||
@PostMapping("/recentNewUser")
|
||||
public Response<IPage<Account>> recentNewUser(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("userType") @RequestParam String userType,
|
||||
@ApiParam("pageNum") @RequestParam int pageNum,
|
||||
@ApiParam("size") @RequestParam int size){
|
||||
return Response.success(convenientInquiryService.recentNewUser(startTime, endTime, userType, pageNum, size));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期新用户图表数据")
|
||||
@PostMapping("/recentNewUserChart")
|
||||
public Response<Map<String, Object>> recentNewUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("userType") @RequestParam String userType){
|
||||
return Response.success(convenientInquiryService.recentNewUserChart(startTime, endTime, userType));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期活跃用户")
|
||||
@PostMapping("/recentActiveUser")
|
||||
public Response<IPage<Account>> recentActiveUser(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("pageNum") @RequestParam int pageNum,
|
||||
@ApiParam("size") @RequestParam int size){
|
||||
return Response.success(convenientInquiryService.recentActiveUser(startTime, endTime, pageNum, size));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期活跃用户图表数据")
|
||||
@PostMapping("/recentActiveUserChart")
|
||||
public Response<Integer> recentActiveUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime){
|
||||
return Response.success(convenientInquiryService.recentActiveUserChart(startTime, endTime));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户的各模块功能使用详情")
|
||||
@PostMapping("/getActiveUserFunc")
|
||||
public Response<Map<String, List<Object>>> getActiveUserFunc(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("userIdList") @RequestParam List<Long> userIdList){
|
||||
return Response.success(convenientInquiryService.getActiveUserFunc(startTime, endTime, userIdList));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,5 +3,10 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Generate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GenerateMapper extends CommonMapper<Generate> {
|
||||
|
||||
List<Map<String, Object>> getByTypeAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,10 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ToProductImageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ToProductImageResultMapper extends CommonMapper<ToProductImageResult> {
|
||||
|
||||
List<Map<String, Object>> getByTypeAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
|
||||
@@ -30,4 +30,12 @@ public interface AccountLoginLogService extends IService<AccountLoginLog> {
|
||||
*/
|
||||
List<AccountLoginLog> getByUserId(Long AccountId);
|
||||
|
||||
/**
|
||||
* 查询指定时间区间内的登录用户
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 登录用户id
|
||||
*/
|
||||
List<Long> getByDate(String startTime, String endTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
@@ -149,4 +150,11 @@ public interface AccountService extends IService<Account> {
|
||||
void toVisitor(Account account);
|
||||
|
||||
List<Long> setUserValidToDayEnd();
|
||||
|
||||
IPage<Account> getPageByDateAndUserType(String startTime, String endTime, Integer type, int pageNum, int size);
|
||||
|
||||
Map<String, Long> getByDateAndUserType(String startTime, String endTime, Integer type);
|
||||
|
||||
IPage<Account> getPageByIds(List<Long> ids, int pageNum, int size);
|
||||
List<Account> getByIds(List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.ChatRobot;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.model.dto.ChatFlushDTO;
|
||||
import com.ai.da.model.dto.ChatRobotLibraryDTO;
|
||||
import com.ai.da.model.dto.ChatSendDTO;
|
||||
import com.ai.da.model.vo.ChatRobotVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author aida
|
||||
@@ -15,7 +18,7 @@ import java.math.BigDecimal;
|
||||
* @description 对话机器人服务接口
|
||||
* @date 2023/7/25 16:42:18
|
||||
*/
|
||||
public interface ChatRobotService {
|
||||
public interface ChatRobotService extends IService<ChatRobot> {
|
||||
ChatRobotVO sendMessageToChatRobot(ChatSendDTO chatSendDTO);
|
||||
|
||||
String chatBufferFlush(ChatFlushDTO chatFlushDTO);
|
||||
@@ -23,4 +26,6 @@ public interface ChatRobotService {
|
||||
Library pictureLikeOrUnLike(ChatRobotLibraryDTO chatRobotLibraryDTO);
|
||||
|
||||
BigDecimal getBloodBars(Long userId);
|
||||
|
||||
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Questionnaire;
|
||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
||||
import com.ai.da.model.vo.QuestionnaireVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ConvenientInquiryService extends IService<Questionnaire> {
|
||||
|
||||
QuestionnaireFeedbackVO getQuestionnaireInfo();
|
||||
|
||||
List<QuestionnaireVO> getAllQuestionnaire();
|
||||
|
||||
IPage<Account> recentNewUser(String startTime, String endTime, String userType, int pageNum, int size);
|
||||
|
||||
Map<String, Object> recentNewUserChart(String startTime, String endTime, String userType);
|
||||
|
||||
IPage<Account> recentActiveUser(String startTime, String endTime, int pageNum, int count);
|
||||
|
||||
|
||||
int recentActiveUserChart(String startTime, String endTime);
|
||||
|
||||
Map<String, List<Object>> getActiveUserFunc(String startTime, String endTime, List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -58,4 +58,6 @@ public interface DesignItemService extends IService<DesignItem> {
|
||||
ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException;
|
||||
|
||||
List<DesignItem> selectDesignIdById(List<Long> designItemIdList);
|
||||
|
||||
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
||||
}
|
||||
|
||||
@@ -95,4 +95,6 @@ public interface DesignService extends IService<Design> {
|
||||
List<CollectionSketchVO> sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO);
|
||||
|
||||
List<String> getModel(List<Long> designItemIdList);
|
||||
|
||||
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.ai.da.model.vo.*;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GenerateService extends IService<Generate> {
|
||||
|
||||
@@ -38,4 +39,6 @@ public interface GenerateService extends IService<Generate> {
|
||||
void cancelGenerate(Long userId, List<String> uniqueId, String timeZone, String type);
|
||||
|
||||
void processRelightResult(String taskId, String url, String category);
|
||||
|
||||
List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
//import com.ai.da.common.utils.SendSmsUtil;
|
||||
|
||||
@@ -44,4 +45,14 @@ public class AccountLoginLogServiceImpl extends ServiceImpl<AccountLoginLogMappe
|
||||
queryWrapper.eq("account_id", AccountId);
|
||||
return accountLoginLogMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public List<Long> getByDate(String startTime, String endTime){
|
||||
QueryWrapper<AccountLoginLog> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("create_date", startTime).lt("create_date", endTime);
|
||||
queryWrapper.select("distinct account_id");
|
||||
|
||||
List<AccountLoginLog> accountLoginLogs = baseMapper.selectList(queryWrapper);
|
||||
return accountLoginLogs.stream().map(AccountLoginLog::getAccountId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,10 +47,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -1348,5 +1345,59 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
return ids;
|
||||
}
|
||||
|
||||
public IPage<Account> getPageByDateAndUserType(String startTime, String endTime, Integer type, int pageNum, int size){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
setTimeAndSystemUser(queryWrapper,startTime, endTime, type);
|
||||
|
||||
Page<Account> accountPage = new Page<>(pageNum, size);
|
||||
return baseMapper.selectPage(accountPage, queryWrapper);
|
||||
}
|
||||
|
||||
private void setTimeAndSystemUser(QueryWrapper<Account> queryWrapper, String startTime, String endTime, Integer type){
|
||||
queryWrapper.gt("create_date", startTime).lt("create_date",endTime);
|
||||
|
||||
if (!Objects.isNull(type)){
|
||||
switch (type){
|
||||
case 0:
|
||||
// 游客
|
||||
queryWrapper.eq("system_user", 0);
|
||||
case 1:
|
||||
// 试用用户
|
||||
queryWrapper.eq("system_user", 3).or().eq("system_user", 4);
|
||||
case 2:
|
||||
queryWrapper.eq("system_user", 1).or().eq("system_user", 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Long> getByDateAndUserType(String startTime, String endTime, Integer type){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
setTimeAndSystemUser(queryWrapper,startTime, endTime, type);
|
||||
queryWrapper.groupBy("system_user");
|
||||
|
||||
queryWrapper.select("system_user as type, count(id) as count");
|
||||
List<Map<String, Object>> maps = baseMapper.selectMaps(queryWrapper);
|
||||
return maps.stream()
|
||||
.collect(Collectors.toMap(
|
||||
map -> map.get("type").toString(),
|
||||
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
|
||||
}
|
||||
|
||||
public IPage<Account> getPageByIds(List<Long> ids, int pageNum, int size){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", ids);
|
||||
|
||||
return baseMapper.selectPage(new Page<>(pageNum, size), queryWrapper);
|
||||
}
|
||||
|
||||
public List<Account> getByIds(List<Long> ids){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", ids);
|
||||
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ai.da.common.enums.LibraryLevel1TypeEnum;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.common.utils.S3Util;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.LibraryMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
@@ -26,6 +27,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.minio.errors.MinioException;
|
||||
@@ -56,7 +58,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
public class ChatRobotServiceImpl extends ServiceImpl<ChatRobotMapper, ChatRobot> implements ChatRobotService {
|
||||
|
||||
// @Value("")
|
||||
String chatStreamUrl = "http://18.167.251.121:6789/api/chat_stream";
|
||||
@@ -382,4 +384,23 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
return "images/female/" + minioPath;
|
||||
}
|
||||
|
||||
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){
|
||||
QueryWrapper<ChatRobot> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("create_time", startTime)
|
||||
.lt("create_time", endTime)
|
||||
.select("count(id) as count");
|
||||
|
||||
if (!accountIds.isEmpty()){
|
||||
queryWrapper.in("user_id", accountIds);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> result = baseMapper.selectMaps(queryWrapper);
|
||||
if (result != null && !result.isEmpty()) {
|
||||
Object countObj = result.get(0).get("count");
|
||||
return (Long) countObj;
|
||||
}else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,22 +3,24 @@ package com.ai.da.service.impl;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.mapper.primary.QuestionnaireMapper;
|
||||
import com.ai.da.mapper.primary.ToProductImageResultMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Questionnaire;
|
||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
||||
import com.ai.da.model.vo.QuestionnaireVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import com.ai.da.service.ConvenientInquiryService;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMapper, Questionnaire> implements ConvenientInquiryService {
|
||||
@@ -26,6 +28,9 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
@Resource
|
||||
private AccountLoginLogService accountLoginLogService;
|
||||
|
||||
|
||||
public QuestionnaireFeedbackVO getQuestionnaireInfo() {
|
||||
String title = "AiDA_3.0 Feedback Survey--06/2024";
|
||||
@@ -181,26 +186,127 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
|
||||
/**
|
||||
* 近期新增用户
|
||||
*
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param userType 用户类型 visitor\trial\official
|
||||
* @return
|
||||
* @param endTime 结束时间
|
||||
* @param userType 用户类型 visitor\trial\official
|
||||
*/
|
||||
public List<Account> recentNewUser(String startTime, String endTime, String userType){
|
||||
return null;
|
||||
/*if (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime) && StringUtil.isNullOrEmpty(userType)){
|
||||
public IPage<Account> recentNewUser(String startTime, String endTime, String userType, int pageNum, int size) {
|
||||
if (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
return null;
|
||||
}
|
||||
Integer type = null;
|
||||
if (!StringUtil.isNullOrEmpty(userType)) {
|
||||
type = userType.equals("visitor") ? 0 : userType.equals("trial") ? 1 : 2;
|
||||
}
|
||||
|
||||
int type = userType.equals("visitor") ? 0 : userType.equals("trial") ? 1 : 2;
|
||||
return accountService.getByDateAndUserType(startTime, endTime, type);*/
|
||||
return accountService.getPageByDateAndUserType(startTime, endTime, type, pageNum, size);
|
||||
}
|
||||
|
||||
// 图表数据
|
||||
public Map<String, Object> recentNewUserChart(String startTime, String endTime, String userType) {
|
||||
if (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
return null;
|
||||
}
|
||||
Integer type = null;
|
||||
if (!StringUtil.isNullOrEmpty(userType)) {
|
||||
type = userType.equals("visitor") ? 0 : userType.equals("trial") ? 1 : 2;
|
||||
}
|
||||
|
||||
Map<String, Long> countMap = accountService.getByDateAndUserType(startTime, endTime, type);
|
||||
long type1 = countMap.get("1") == null ? 0L : countMap.get("1");
|
||||
long type2 = countMap.get("2") == null ? 0L : countMap.get("2");
|
||||
long type3 = countMap.get("3") == null ? 0L : countMap.get("3");
|
||||
long type4 = countMap.get("4") == null ? 0L : countMap.get("4");
|
||||
List<String> names = Arrays.asList("Visitor", "Trials", "Official");
|
||||
List<Long> values = Arrays.asList(countMap.get("0") == null ? 0L : countMap.get("0"),
|
||||
type3 + type4,
|
||||
type1 + type2);
|
||||
|
||||
HashMap<String, Object> resp = new HashMap<>();
|
||||
resp.put("names", names);
|
||||
resp.put("values", values);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
// 近期活跃用户
|
||||
public List<Account> recentActiveUser(String startTime, String endTime){
|
||||
return null;
|
||||
public IPage<Account> recentActiveUser(String startTime, String endTime, int pageNum, int size) {
|
||||
List<Long> accountIds = accountLoginLogService.getByDate(startTime, endTime);
|
||||
return accountService.getPageByIds(accountIds, pageNum, size);
|
||||
}
|
||||
|
||||
// 图表数据
|
||||
public int recentActiveUserChart(String startTime, String endTime) {
|
||||
List<Long> accountIds = accountLoginLogService.getByDate(startTime, endTime);
|
||||
return accountIds.size();
|
||||
}
|
||||
|
||||
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
@Resource
|
||||
private ToProductImageResultMapper toProductImageResultMapper;
|
||||
@Resource
|
||||
private DesignService designService;
|
||||
@Resource
|
||||
private DesignItemService designItemService;
|
||||
@Resource
|
||||
private ChatRobotService chatRobotService;
|
||||
|
||||
public Map<String, List<Object>> getActiveUserFunc(String startTime, String endTime, List<Long> ids) {
|
||||
// 必须指定时间区间
|
||||
if (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
return null;
|
||||
} else if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
endTime = LocalDateTime.now().format(formatter);
|
||||
}
|
||||
|
||||
// design
|
||||
Long designTimes = designService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
|
||||
// single design
|
||||
Long singleDesignTimes = designItemService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
|
||||
// generate -> MoodBoard\PrintBoard\SketchBoard
|
||||
List<Map<String, Object>> countGenerate = generateService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
// 使用Stream API和lambda表达式将数据合并到一个Map中
|
||||
Map<String, Long> countGenerateMerge = countGenerate.stream()
|
||||
.collect(Collectors.toMap(
|
||||
map -> (String) map.get("type"),
|
||||
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
|
||||
|
||||
// toProductImage\ReLight
|
||||
List<Map<String, Object>> countProduct = toProductImageResultMapper.getByTypeAndTime(startTime, endTime, ids);
|
||||
Map<String, Long> countProductMerge = countProduct.stream()
|
||||
.collect(Collectors.toMap(
|
||||
map -> (String) map.get("type"),
|
||||
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
|
||||
|
||||
// chatRobot
|
||||
Long chatTimes = chatRobotService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
|
||||
List<Object> names = Arrays.asList("Design", "SingleDesign", "MoodBoard", "PrintBoard", "SketchBoard", "Pattern", "Logo", "Slogan", "ToProductImage", "Relight", "ChatRobot");
|
||||
List<Object> values = Arrays.asList(designTimes, singleDesignTimes,
|
||||
countGenerateMerge.get("Moodboard") == null ? 0L : countGenerateMerge.get("Moodboard"),
|
||||
countGenerateMerge.get("Printboard") == null ? 0L : countGenerateMerge.get("Printboard"),
|
||||
countGenerateMerge.get("Sketchboard") == null ? 0L : countGenerateMerge.get("Sketchboard"),
|
||||
countGenerateMerge.get("Pattern") == null ? 0L : countGenerateMerge.get("Pattern"),
|
||||
countGenerateMerge.get("Logo") == null ? 0L : countGenerateMerge.get("Logo"),
|
||||
countGenerateMerge.get("Slogan") == null ? 0L : countGenerateMerge.get("Slogan"),
|
||||
countProductMerge.get("ToProductImage") == null ? 0L : countProductMerge.get("ToProductImage"),
|
||||
countProductMerge.get("Relight") == null ? 0L : countProductMerge.get("Relight"),
|
||||
chatTimes);
|
||||
|
||||
HashMap<String, List<Object>> resp = new HashMap<>();
|
||||
resp.put("names", names);
|
||||
resp.put("values", values);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -237,7 +237,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
// 执行积分扣除
|
||||
// ** 注:如果生成的图片都是空白 则不扣积分
|
||||
if (!status.equals("Invalid")){
|
||||
if (!status.equals("Invalid")) {
|
||||
String accountId = taskId.substring(taskId.lastIndexOf("-") + 1);
|
||||
String uuid = taskId.substring(0, taskId.substring(0, taskId.lastIndexOf("-")).lastIndexOf("-"));
|
||||
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), uuid);
|
||||
@@ -270,7 +270,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
Long accountId = Long.parseLong(taskId.substring(taskId.lastIndexOf("-") + 1));
|
||||
if (!status.equals("Invalid")){
|
||||
if (!status.equals("Invalid")) {
|
||||
// 4、扣除积分
|
||||
Boolean b = creditsService.taskCreditsDeduction(accountId, taskId);
|
||||
// 3、记录积分变更
|
||||
@@ -778,4 +778,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
return baseMapper.selectList(qw);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private GenerateMapper generateMapper;
|
||||
public List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList) {
|
||||
List<Map<String, Object>> byTypeAndTime = generateMapper.getByTypeAndTime(startTime, endTime, accountIdList);
|
||||
return byTypeAndTime;
|
||||
}
|
||||
}
|
||||
|
||||
46
src/main/resources/mapper/primary/GenerateMapper.xml
Normal file
46
src/main/resources/mapper/primary/GenerateMapper.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ai.da.mapper.primary.GenerateMapper">
|
||||
<select id="getByTypeAndTime" resultType="java.util.Map">
|
||||
-- 查询level1_type的记录
|
||||
SELECT
|
||||
level1_type as type,
|
||||
count(id) as count
|
||||
FROM
|
||||
t_generate
|
||||
WHERE
|
||||
level1_type IN ('Moodboard', 'Printboard', 'Sketchboard')
|
||||
AND create_date >= #{startTime}
|
||||
AND create_date <= #{endTime}
|
||||
<if test="accountIdList != null and accountIdList.size() > 0">
|
||||
AND account_id IN
|
||||
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY
|
||||
level1_type
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- 查询level2_type的记录
|
||||
SELECT
|
||||
level2_type as type,
|
||||
count(id) as count
|
||||
FROM
|
||||
t_generate
|
||||
WHERE
|
||||
level2_type IN ('Pattern', 'Logo', 'Slogan')
|
||||
AND create_date > #{startTime}
|
||||
AND create_date <= #{endTime}
|
||||
<if test="accountIdList != null and accountIdList.size() > 0">
|
||||
AND account_id IN
|
||||
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY
|
||||
level2_type;
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ai.da.mapper.primary.ToProductImageResultMapper">
|
||||
<select id="getByTypeAndTime" resultType="java.util.Map">
|
||||
select count(a.id) as count, a.result_type type
|
||||
from to_product_image_result as a
|
||||
left join t_user_like_group as b
|
||||
on a.user_like_group_id = b.id
|
||||
where a.create_time >= #{startTime}
|
||||
and a.create_time <= #{endTime}
|
||||
<if test="accountIdList != null and accountIdList.size() > 0">
|
||||
AND account_id IN
|
||||
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY type;
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user