zhangjinli 3 years ago
parent 5a8fd2f708
commit a070c8d4cd

@ -64,8 +64,10 @@ public class ScheduleController {
@Scheduled(cron = "0 0 0 * * ?")
@Transactional
public void videoEffect() {
// taskService.getMap()
Integer taskId = 1;
// 任务结束7天时自动结算积分
// videoService.videoEffectResult(taskId);
videoService.videoEffectResult(taskId);
}
// @Scheduled(cron = "0 0/1 * * * ? ")
// @Scheduled(cron = "0 0 0 1 1/1 ?")

@ -2,31 +2,31 @@ package com.zh.project0512.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
//import com.zh.project0512.service.IUserService;
import com.zh.project0512.mapper.QywxDepartmentGroupLinkMapper;
import com.zh.project0512.mapper.QywxDepartmentUserLinkMapper;
import com.zh.project0512.mapper.RankMapper;
import com.zh.project0512.model.Rank;
import com.zh.project0512.model.TaskTeachRefe;
import com.zh.project0512.model.Task;
import com.zh.project0512.model.dto.RankListDTO;
import com.zh.project0512.model.vo.RankListVo;
import com.zh.project0512.service.IQywxDepartmentGroupLinkService;
import com.zh.project0512.service.IRewardRuleService;
import com.zh.project0512.service.ITaskService;
import com.zh.project0512.service.IVideoService;
import com.zh.project0512.utils.AliyunOss;
import com.zh.project0512.utils.FileTypeUtil;
import com.zh.project0512.utils.JSONResult;
import com.zh.project0512.utils.result.HttpStatusEnum;
import com.zh.project0512.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -34,8 +34,6 @@ import ws.schild.jave.MultimediaObject;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
@ -159,7 +157,10 @@ public class UtilsController {
RankMapper rankMapper;
@Autowired
private IVideoService videoService;
@Autowired
private IRewardRuleService rewardRuleService;
@Autowired
private IQywxDepartmentGroupLinkService qywxDepartmentGroupLinkService;
@PostMapping("/test")
@ResponseBody
public Result test() {
@ -179,4 +180,46 @@ public class UtilsController {
return Result.success(rankUserList);
}
@Data
static class Param {
@Schema(title="接受任务部门列表")
private List<Integer> departmentList;
}
@Autowired
private QywxDepartmentGroupLinkMapper qywxDepartmentGroupLinkMapper;
@PostMapping("/test2")
@ResponseBody
public Result test2(@RequestBody Param param) {
List departmentIdList = qywxDepartmentGroupLinkService.departmentIdList(0,param.getDepartmentList());
// QueryWrapper<Task> qw = new QueryWrapper<>();
// LocalDateTime now = LocalDateTime.now().minusWeeks(1);
// String format = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// qw.eq("date_format(end, '%Y-%m-%d')", format);
// List<Task> taskList = taskService.list(qw);
// // 处理每个任务的传播值
//
// // 生成奖励流水并更新给用户积分
// for (Task t : taskList) {
// Integer taskId = t.getId();
// List<Map> videoEffectResult = videoService.videoEffectResult(taskId);
// List<Map> rewardRule = rewardRuleService.listByTemplateId(t.getRewardRuleTemplateId());
//
// System.out.println("videoEffectResult" + videoEffectResult);
// // 处理任务中每个用户的传播值
// for (Map m : videoEffectResult) {
// if (m.get("effectResultSum") != null && (Integer) m.get("effectResultSum") != 0) {
// int point = 0;
// int effectResultSum = (Integer) m.get("effectResultSum");
// // 根据传播值计算规则算出奖励
// for (Map r : rewardRule) {
// if (effectResultSum > (Integer) r.get("limitNum")) {
// point = (Integer) r.get("reward");
// }
// }
// }
// }
// }
return Result.success();
}
}

@ -116,7 +116,7 @@ public class TaskController {
}
List departmentGroupList = task.getDepartmentGroupList();
if (departmentGroupList != null && departmentGroupList.size() > 0) {
List departmentIdList = qywxDepartmentGroupLinkService.departmentIdList(departmentGroupList);
List departmentIdList = qywxDepartmentGroupLinkService.departmentIdList(null,departmentGroupList);
taskDepartmentService.addGroup(departmentIdList, id);
}
// 上传任务时同时上传素材
@ -127,7 +127,7 @@ public class TaskController {
for (FileUploadParamVo e : referenceUrlList) {
String url = e.getUrl();
if (url != null && e.getUrl().lastIndexOf(".") != -1) {
l.add(new Reference().setTitle(task.getTitle()).setCoverUrl(task.getCoverUrl()).setDuration(e.getDuration()).setCreatAt(LocalDateTime.now())
l.add(new Reference().setTitle(task.getTitle()).setCoverUrl(task.getCoverUrl()).setDuration(e.getDuration()).setCreatAt(LocalDateTime.now()).setUpdateAt(LocalDateTime.now())
.setFileUrl(url).setType(FileTypeUtil.getcontentTypeNum(url.substring(url.lastIndexOf(".")))));
// ta.add(new TopicActivity().setTitle(task.getTitle()).setCover(task.getCoverUrl()).setCreatAt(LocalDateTime.now())
// .setContent(e).setType(FileTypeUtil.getcontentTypeNum(e.substring(e.lastIndexOf(".")))));

@ -36,7 +36,8 @@ public interface QywxDepartmentGroupLinkMapper extends BaseMapper<QywxDepartment
" GROUP BY userName\n" +
" ORDER BY creatAt DESC")
List<Map> departmentList2(Integer groupId);
@Select("SELECT t1.departmentId\n" +
@Select("<script> "+
"SELECT t1.departmentId\n" +
"from qywxDepartmentGroupLink as t1\n" +
"LEFT JOIN qywxDepartmentGroup as t2 on t1.groupId = t2.id\n" +
"INNER JOIN qywxDepartment as t3 on t3.departmentId = t1.departmentId \n" +
@ -44,6 +45,7 @@ public interface QywxDepartmentGroupLinkMapper extends BaseMapper<QywxDepartment
"<foreach collection='groupIdList' index='index' item='item' open='(' separator=',' close=')'>" +
"#{item}" +
"</foreach>" +
"GROUP BY departmentId")
List<Integer> departmentIdList(List<Integer> groupIdList);
"GROUP BY departmentId" +
"</script>")
List<Integer> departmentIdList(Integer xxx, List<Integer> groupIdList);
}

@ -59,13 +59,7 @@ public interface VideoMapper extends BaseMapper<Video> {
"INNER JOIN task as t2 on t1.taskId = t2.id\n" +
"INNER JOIN user as t3 on t1.userId = t3.id\n" +
"WHERE taskId = #{taskId}\n" +
"<if test='ew != null'>" +
"<if test='ew.nonEmptyOfWhere'>" +
"AND " +
"</if> " +
"${ew.SqlSegment}" +
"</if> " +
"GROUP BY t1.userId \n" +
"ORDER BY effectResultSum DESC")
List<Map> videoEffectResult(int taskId, @Param("ew") Wrapper<Video> queryWrapper);
List<Map> videoEffectResult(int taskId);
}

@ -19,6 +19,6 @@ public interface IQywxDepartmentGroupLinkService extends IService<QywxDepartment
void groupAddDepartment(Integer groupId, List<Integer> departmentIdList, LocalDateTime creatAt);
List<Map> departmentList(Integer groupId);
List<Map> departmentList2(Integer groupId);
List<Integer> departmentIdList(List<Integer> groupIdList);
List<Integer> departmentIdList(Integer xxx,List groupIdList);
}

@ -26,5 +26,5 @@ public interface IVideoService extends IService<Video> {
void updStatusByTaskId(int taskId,LocalDateTime localDateTime);
IPage<Map> pageList(IPage iPage, @Param("ew") Wrapper<Video> queryWrapper);
JSONObject record(String openid);
List<Map> videoEffectResult(int taskId ,@Param("ew") Wrapper<Video> queryWrapper);
List<Map> videoEffectResult(int taskId );
}

@ -34,7 +34,7 @@ public class QywxDepartmentGroupLinkServiceImpl extends ServiceImpl<QywxDepartme
public List<Map> departmentList2(Integer groupId){
return qywxDepartmentGroupLinkMapper.departmentList2(groupId);
}
public List<Integer> departmentIdList(List<Integer> groupIdList){
return qywxDepartmentGroupLinkMapper.departmentIdList(groupIdList);
public List<Integer> departmentIdList(Integer xxx,List groupIdList){
return qywxDepartmentGroupLinkMapper.departmentIdList(xxx,groupIdList);
}
}

@ -45,7 +45,7 @@ public class VideoServiceImpl extends ServiceImpl<VideoMapper, Video> implements
public JSONObject record(String openid) {
return videoMapper.record(openid);
}
public List<Map> videoEffectResult(int taskId, @Param("ew") Wrapper<Video> queryWrapper){
return videoMapper.videoEffectResult(taskId, queryWrapper);
public List<Map> videoEffectResult(int taskId){
return videoMapper.videoEffectResult(taskId);
}
}

Loading…
Cancel
Save