|
|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.mongodb.MongoClientSettings;
|
|
|
import com.yingyangfly.common.domain.BaseEntity;
|
|
|
import com.yingyangfly.common.dto.ResultResponse;
|
|
|
import com.yingyangfly.common.utils.DateUtils;
|
|
|
@@ -26,10 +27,14 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import com.yingyangfly.core.service.*;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.bson.Document;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.aggregation.*;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -49,37 +54,40 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class GameTaskServiceImpl extends ServiceImpl<GameTaskMapper, GameTask> implements GameTaskService {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private GameTaskMapper gameTaskMapper;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
ReviewTaskService reviewTaskService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private GameMapper gameMapper;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private GameTaskDetailMapper gameTaskDetailMapper;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
GameService gameService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
GameTaskDetailService gameTaskDetailService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
TreatmentService treatmentService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
AppUserService appUserService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private AppUserMapper appUserMapper;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private TokenUtil tokenUtil;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private GamePlayRecordService gamePlayRecordService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MsgWarnService msgWarnService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MentalEnergyDetailRecordMapper mentalEnergyDetailRecordMapper;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MentalEnergyDetailMapper mentalEnergyDetailMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MongoTemplate mongoTemplate;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public GameTask findMyCurrentTask(String time, Long userId,String status) {
|
|
|
@@ -427,27 +435,19 @@ public class GameTaskServiceImpl extends ServiceImpl<GameTaskMapper, GameTask> i
|
|
|
gameTaskDetailWrapper.like("create_time", date + "%");
|
|
|
List<GameTaskDetail> gameTaskDetails = gameTaskDetailMapper.selectList(gameTaskDetailWrapper);
|
|
|
|
|
|
+ Set<String> upSet = new HashSet<>();
|
|
|
+ Set<String> downSet = new HashSet<>();
|
|
|
|
|
|
- String up = "";
|
|
|
- String down = "";
|
|
|
for (GameTaskDetail gameTaskDetail : gameTaskDetails) {
|
|
|
if (gameTaskDetail.getStatus().equals("1")) {//如果未完成,放到下降里
|
|
|
- if (StringUtils.isNotBlank(down)) {
|
|
|
- down += "、" + GameTypeEnums.getInfo(gameTaskDetail.getGameType());
|
|
|
- } else {
|
|
|
- down += GameTypeEnums.getInfo(gameTaskDetail.getGameType());
|
|
|
- }
|
|
|
+ downSet.add(GameTypeEnums.getInfo(gameTaskDetail.getGameType()));
|
|
|
} else {//否则放到成功里
|
|
|
- if (StringUtils.isNotBlank(up)) {
|
|
|
- up += "、" + GameTypeEnums.getInfo(gameTaskDetail.getGameType());
|
|
|
- } else {
|
|
|
- up += GameTypeEnums.getInfo(gameTaskDetail.getGameType());
|
|
|
- }
|
|
|
+ upSet.add(GameTypeEnums.getInfo(gameTaskDetail.getGameType()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- map.put("up", up);
|
|
|
- map.put("down", down);
|
|
|
+ map.put("up", String.join("、",upSet));
|
|
|
+ map.put("down", String.join("、",downSet));
|
|
|
|
|
|
return map;
|
|
|
}
|
|
|
@@ -673,15 +673,42 @@ public class GameTaskServiceImpl extends ServiceImpl<GameTaskMapper, GameTask> i
|
|
|
}
|
|
|
|
|
|
|
|
|
- QueryWrapper<GameTaskDetail> gameTaskDetailWrapper = new QueryWrapper();
|
|
|
- gameTaskDetailWrapper.select(" sum(play_time) as gameDuration,DATE_FORMAT(create_time, '%Y-%m-%d') as time ");
|
|
|
- gameTaskDetailWrapper.eq("user_id", userId);
|
|
|
- gameTaskDetailWrapper.groupBy("time");
|
|
|
+// QueryWrapper<GameTaskDetail> gameTaskDetailWrapper = new QueryWrapper();
|
|
|
+// gameTaskDetailWrapper.select(" sum(play_time) as gameDuration,DATE_FORMAT(create_time, '%Y-%m-%d') as time ");
|
|
|
+// gameTaskDetailWrapper.eq("user_id", userId);
|
|
|
+// gameTaskDetailWrapper.groupBy("time");
|
|
|
+//
|
|
|
+// List<Map<String, Object>> gameTaskDetailMap = gameTaskDetailMapper.selectMaps(gameTaskDetailWrapper);
|
|
|
+
|
|
|
+ Criteria criteria = Criteria.where("user_id").is(Long.parseLong(userId)).and("play_class").is("B");
|
|
|
+ String groupExpr = "%Y-%m-%d";
|
|
|
+
|
|
|
+ AggregationExpression dateExpression = DateOperators.DateToString
|
|
|
+ .dateOf("create_time")
|
|
|
+ .toString(groupExpr);
|
|
|
+
|
|
|
+ ProjectionOperation projectionOperation = Aggregation.project()
|
|
|
+ .andExclude("_id")
|
|
|
+ .and(dateExpression).as("date")
|
|
|
+ .and("user_id").as("user_id")
|
|
|
+ .and("duration").as("duration");
|
|
|
+
|
|
|
+ GroupOperation groupOperation = Aggregation.group("date")
|
|
|
+ .sum("duration").as("gameDuration")
|
|
|
+ .first("user_id").as("user_id")
|
|
|
+ .first("date").as("time");
|
|
|
+
|
|
|
+
|
|
|
+ Aggregation aggregation = Aggregation.newAggregation(Aggregation.match(criteria),projectionOperation,
|
|
|
+ groupOperation);
|
|
|
+
|
|
|
+ AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, "game_play_record", Map.class);
|
|
|
+
|
|
|
+ List<Map> gameTaskDetailMap = result.getMappedResults();
|
|
|
|
|
|
- List<Map<String, Object>> gameTaskDetailMap = gameTaskDetailMapper.selectMaps(gameTaskDetailWrapper);
|
|
|
for (Map<String, Object> stringObjectMap : gameTaskDetailMap) {
|
|
|
- BigDecimal gameDuration = stringObjectMap.get("gameDuration") == null?new BigDecimal(0):(BigDecimal) stringObjectMap.get("gameDuration");
|
|
|
- map.put((String) stringObjectMap.get("time"), String.valueOf(gameDuration.intValue()));
|
|
|
+// BigDecimal gameDuration = stringObjectMap.get("gameDuration") == null?new BigDecimal(0):(BigDecimal) stringObjectMap.get("gameDuration");
|
|
|
+ map.put((String) stringObjectMap.get("time"), String.valueOf(stringObjectMap.get("gameDuration")));
|
|
|
}
|
|
|
for (String s : day) {
|
|
|
TreeMap<String, Object> m = new TreeMap<>();
|