|
|
|
|
@ -7,11 +7,13 @@ import com.sztzjy.linkCommerce.entity.SchoolClass;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.TaskAllocation;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.TaskAllocationExample;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.TeachingClassStudent;
|
|
|
|
|
import com.sztzjy.linkCommerce.entity.dto.TaskPublication;
|
|
|
|
|
import com.sztzjy.linkCommerce.mapper.SchoolClassMapper;
|
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TaskAllocationMapper;
|
|
|
|
|
import com.sztzjy.linkCommerce.mapper.TeachingClassStudentMapper;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.SchoolDefaultTaskService;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.StudentTeachingClassResolver;
|
|
|
|
|
import com.sztzjy.linkCommerce.service.TrainingTaskService;
|
|
|
|
|
import com.sztzjy.linkCommerce.util.ResultEntity;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
@ -23,7 +25,10 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
@Api(tags = "任务分配相关")
|
|
|
|
|
@ -40,6 +45,31 @@ public class TaskAllocationController {
|
|
|
|
|
SchoolDefaultTaskService schoolDefaultTaskService;
|
|
|
|
|
@Autowired(required = false)
|
|
|
|
|
StudentTeachingClassResolver studentTeachingClassResolver;
|
|
|
|
|
@Autowired(required = false)
|
|
|
|
|
TrainingTaskService trainingTaskService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/selectTaskPublicationByClassId")
|
|
|
|
|
@ApiOperation("查询教学班实训任务发布配置")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity<TaskPublication> selectTaskPublicationByClassId(@RequestParam String classId) {
|
|
|
|
|
TaskPublication publication = new TaskPublication();
|
|
|
|
|
TaskAllocationExample example = new TaskAllocationExample();
|
|
|
|
|
example.createCriteria().andClassIdEqualTo(classId);
|
|
|
|
|
example.setOrderByClause("sort asc");
|
|
|
|
|
List<TaskAllocation> rows = taskAllocationMapper.selectByExample(example);
|
|
|
|
|
Set<String> taskKeys = new LinkedHashSet<>();
|
|
|
|
|
if (rows != null) {
|
|
|
|
|
for (TaskAllocation row : rows) {
|
|
|
|
|
if (TaskAllocation.PUBLICATION_MARKER.equals(row.getModule())) {
|
|
|
|
|
publication.setConfigured(true);
|
|
|
|
|
} else if (row.getDisabledStatus() == null || row.getDisabledStatus() == 0) {
|
|
|
|
|
taskKeys.add(row.getModule());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
publication.setTaskKeys(new ArrayList<>(taskKeys));
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "查询成功", publication);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/selectTaskAllocationByClassId")
|
|
|
|
|
@ApiOperation("根据班级ID查询任务分配")
|
|
|
|
|
@ -106,15 +136,43 @@ public class TaskAllocationController {
|
|
|
|
|
|| !userId.equals(schoolClass.getCreatedBy())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "只能分配自己创建教学班的任务");
|
|
|
|
|
}
|
|
|
|
|
if (taskAllocationList == null) {
|
|
|
|
|
taskAllocationList = Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
Set<String> taskKeys = new LinkedHashSet<>();
|
|
|
|
|
for (TaskAllocation allocation : taskAllocationList) {
|
|
|
|
|
if (allocation == null || TaskAllocation.PUBLICATION_MARKER.equals(allocation.getModule())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String taskKey = allocation.getModule() == null ? null : allocation.getModule().trim();
|
|
|
|
|
if (taskKey != null && !taskKey.isEmpty()
|
|
|
|
|
&& (trainingTaskService == null || trainingTaskService.getByTaskKey(taskKey) != null)) {
|
|
|
|
|
taskKeys.add(taskKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskAllocationExample taskAllocationExample = new TaskAllocationExample();
|
|
|
|
|
taskAllocationExample.createCriteria().andClassIdEqualTo(classId);
|
|
|
|
|
taskAllocationMapper.deleteByExample(taskAllocationExample);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < taskAllocationList.size(); i++) {
|
|
|
|
|
TaskAllocation taskAllocation = taskAllocationList.get(i);
|
|
|
|
|
TaskAllocation marker = new TaskAllocation();
|
|
|
|
|
marker.setId(UUID.randomUUID().toString());
|
|
|
|
|
marker.setClassId(classId);
|
|
|
|
|
marker.setSchoolId(schoolClass.getSchoolId());
|
|
|
|
|
marker.setModule(TaskAllocation.PUBLICATION_MARKER);
|
|
|
|
|
marker.setDisabledStatus((byte) 1);
|
|
|
|
|
marker.setSort(0);
|
|
|
|
|
taskAllocationMapper.insert(marker);
|
|
|
|
|
|
|
|
|
|
int sort = 1;
|
|
|
|
|
for (String taskKey : taskKeys) {
|
|
|
|
|
TaskAllocation taskAllocation = new TaskAllocation();
|
|
|
|
|
taskAllocation.setId(UUID.randomUUID().toString());
|
|
|
|
|
taskAllocation.setClassId(classId);
|
|
|
|
|
taskAllocation.setSchoolId(schoolId);
|
|
|
|
|
taskAllocation.setSchoolId(schoolClass.getSchoolId());
|
|
|
|
|
taskAllocation.setModule(taskKey);
|
|
|
|
|
taskAllocation.setDisabledStatus((byte) 0);
|
|
|
|
|
taskAllocation.setSort(sort++);
|
|
|
|
|
taskAllocationMapper.insert(taskAllocation);
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "修改成功");
|
|
|
|
|
|