75 lines
2.5 KiB
Java
75 lines
2.5 KiB
Java
|
|
package com.gunshi.project.xyt.service;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||
|
|
import com.gunshi.project.xyt.mapper.AssessObjectMapper;
|
||
|
|
import com.gunshi.project.xyt.model.AssessObject;
|
||
|
|
import com.gunshi.project.xyt.model.AssessTeam;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
import org.springframework.transaction.annotation.Transactional;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 描述: 考核对象
|
||
|
|
* author: xusan
|
||
|
|
* date: 2024-09-05 14:19:30
|
||
|
|
*/
|
||
|
|
@Service
|
||
|
|
@Slf4j
|
||
|
|
@Transactional(rollbackFor = Exception.class)
|
||
|
|
public class AssessObjectService extends ServiceImpl<AssessObjectMapper, AssessObject>
|
||
|
|
{
|
||
|
|
@Autowired
|
||
|
|
private AssessTeamService assessTeamService;
|
||
|
|
|
||
|
|
public void saveObject(List<AssessObject> assessObjects,List<AssessTeam> assessTeams, Long taskId) {
|
||
|
|
List<AssessTeam> teams = new ArrayList<>();
|
||
|
|
assessObjects.stream().forEach(o->{
|
||
|
|
long objectId = IdWorker.getId();
|
||
|
|
o.setId(objectId);
|
||
|
|
o.setTaskId(taskId);
|
||
|
|
o.setStatus(0);
|
||
|
|
assessTeams.stream().forEach(t->{
|
||
|
|
t.setId(IdWorker.getId());
|
||
|
|
t.setTaskId(taskId);
|
||
|
|
t.setObjectId(objectId);
|
||
|
|
t.setStatus(0);
|
||
|
|
});
|
||
|
|
teams.addAll(assessTeams);
|
||
|
|
});
|
||
|
|
this.saveBatch(assessObjects);
|
||
|
|
assessTeamService.saveBatch(teams);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void delObject(Long taskId) {
|
||
|
|
assessTeamService.remove(new QueryWrapper<AssessTeam>().eq("task_id",taskId));
|
||
|
|
this.remove(new QueryWrapper<AssessObject>().eq("task_id",taskId));
|
||
|
|
}
|
||
|
|
|
||
|
|
public void updateObject(List<AssessObject> assessObjects,List<AssessTeam> assessTeams, Long taskId) {
|
||
|
|
this.delObject(taskId);
|
||
|
|
this.saveObject(assessObjects,assessTeams,taskId);
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<AssessObject> getObject(Long taskId) {
|
||
|
|
List<AssessObject> list = this.list(new QueryWrapper<AssessObject>().eq("task_id",taskId));
|
||
|
|
return list;
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<AssessTeam> getTeam(Long taskId) {
|
||
|
|
List<AssessTeam> list = assessTeamService.list(new QueryWrapper<AssessTeam>().eq("task_id",taskId));
|
||
|
|
return list;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void updateTeams(List<AssessTeam> teams) {
|
||
|
|
assessTeamService.updateBatchById(teams);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|