|
|
|
@ -3,16 +3,23 @@ package com.zh.project0512.serviceImpl;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.zh.project0512.mapper.ReferenceMapper;
|
|
|
|
|
import com.zh.project0512.model.Reference;
|
|
|
|
|
import com.zh.project0512.model.Task;
|
|
|
|
|
import com.zh.project0512.mapper.TaskMapper;
|
|
|
|
|
import com.zh.project0512.service.ITaskService;
|
|
|
|
|
import com.zh.project0512.model.TaskTeachRefe;
|
|
|
|
|
import com.zh.project0512.model.TeachingRefe;
|
|
|
|
|
import com.zh.project0512.model.vo.FileUploadParamVo;
|
|
|
|
|
import com.zh.project0512.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.zh.project0512.utils.FileTypeUtil;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -28,26 +35,99 @@ import java.util.Map;
|
|
|
|
|
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private TaskMapper taskMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IReferenceService referenceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ITaskReferenceService taskReferenceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ITeachingRefeService teachingRefeService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ITaskTeachRefeService taskTeachRefeService;
|
|
|
|
|
|
|
|
|
|
public void add(Task task) {
|
|
|
|
|
taskMapper.add(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IPage<Integer> idList(IPage iPage, String openid, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper) {
|
|
|
|
|
return taskMapper.idList(iPage, openid, tagIdList, brandIdList, queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map> list(String openid, List<Integer> list, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper) {
|
|
|
|
|
return taskMapper.list(openid, list, tagIdList, brandIdList, queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task detailById(String openid, int id) {
|
|
|
|
|
return taskMapper.detailById(openid, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JSONObject taskEffect(@Param("ew") Wrapper<Task> queryWrapper) {
|
|
|
|
|
return taskMapper.taskEffect(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map> taskEffectData(@Param("ew") Wrapper<Task> queryWrapper) {
|
|
|
|
|
return taskMapper.taskEffectData(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map> taskDepartment(int taskId) {
|
|
|
|
|
return taskMapper.taskDepartment(taskId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传任务时同时上传素材
|
|
|
|
|
public Boolean upReferenceInTask(Task task, List<Integer> referenceList, List<FileUploadParamVo> referenceUrlList) {
|
|
|
|
|
List<Integer> reference = new ArrayList<>();
|
|
|
|
|
if (referenceList != null && referenceList.size() > 0) {
|
|
|
|
|
for (Integer e : referenceList) {
|
|
|
|
|
reference.add(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 上传任务时同时上传素材
|
|
|
|
|
if (referenceUrlList != null && referenceUrlList.size() > 0) {
|
|
|
|
|
List<Reference> l = new ArrayList<>();
|
|
|
|
|
// List<TopicActivity> ta = new ArrayList<>();
|
|
|
|
|
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()).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(".")))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (l.size() > 0) {
|
|
|
|
|
referenceService.saveBatch(l);
|
|
|
|
|
// topicActivityService.saveBatch(ta);
|
|
|
|
|
for (Reference r : l) {
|
|
|
|
|
referenceList.add(r.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (reference.size() > 0) {
|
|
|
|
|
taskReferenceService.addGroup(reference, task.getId());
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传任务的通用教程
|
|
|
|
|
public Boolean upTeachRefeInTask(Task task,List<Integer> teachRefeList, List<FileUploadParamVo> teachRefeUrlList) {
|
|
|
|
|
List<TaskTeachRefe> l2 = new ArrayList<>();
|
|
|
|
|
if (teachRefeList != null && teachRefeList.size() > 0) {
|
|
|
|
|
List<TeachingRefe> teachingRefes = (List<TeachingRefe>) teachingRefeService.listByIds(teachRefeList);
|
|
|
|
|
for (TeachingRefe e : teachingRefes) {
|
|
|
|
|
l2.add((new TaskTeachRefe().setTaskId(task.getId()).setCreatAt(LocalDateTime.now())
|
|
|
|
|
.setFileUrl(e.getFileUrl()).setType(FileTypeUtil.getcontentTypeNum(e.getFileUrl().substring(e.getFileUrl().lastIndexOf("."))))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (
|
|
|
|
|
FileUploadParamVo e : teachRefeUrlList) {
|
|
|
|
|
String url = e.getUrl();
|
|
|
|
|
if (url != null && url.lastIndexOf(".") != -1) {
|
|
|
|
|
l2.add(new TaskTeachRefe().setTaskId(task.getId()).setCreatAt(LocalDateTime.now()).setDuration(e.getDuration())
|
|
|
|
|
.setFileUrl(url).setType(FileTypeUtil.getcontentTypeNum(url.substring(url.lastIndexOf(".")))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (l2.size() > 0) {
|
|
|
|
|
taskTeachRefeService.saveBatch(l2);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|