162 lines
4.5 KiB
Plaintext
162 lines
4.5 KiB
Plaintext
package com.sercurityControl.proteam.service.impl;
|
|
|
|
import com.securityControl.common.core.utils.StringUtils;
|
|
import com.securityControl.common.core.web.domain.AjaxResult;
|
|
import com.sercurityControl.proteam.domain.ClassData;
|
|
import com.sercurityControl.proteam.domain.UserCheck;
|
|
import com.sercurityControl.proteam.mapper.AllocationMapper;
|
|
import com.sercurityControl.proteam.mapper.TeamMapper;
|
|
import com.sercurityControl.proteam.service.AllocationService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author bonus
|
|
* @data 2023/4/17 13:22
|
|
* @description 人员分配
|
|
*/
|
|
@Slf4j
|
|
@Service
|
|
public class AllocationServiceImpl implements AllocationService {
|
|
|
|
@Autowired
|
|
private AllocationMapper mapper;
|
|
|
|
/**
|
|
* 查询人员分配
|
|
*
|
|
* @param entity 条件
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<UserCheck> getList(UserCheck entity) {
|
|
return mapper.getList(entity);
|
|
}
|
|
|
|
/**
|
|
* 查询今日任务
|
|
*
|
|
* @param entity 条件
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<ClassData> getClass(ClassData entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getClass(entity);
|
|
}
|
|
|
|
/**
|
|
* 任务移除
|
|
*
|
|
* @param entity 条件
|
|
* @return 条数
|
|
*/
|
|
@Override
|
|
public AjaxResult delData(UserCheck entity) {
|
|
try {
|
|
Integer integer = mapper.delData(entity);
|
|
if (integer > 0) {
|
|
return AjaxResult.success("移除成功");
|
|
} else {
|
|
return AjaxResult.error("移除失败");
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return AjaxResult.error("移除失败");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public AjaxResult delAll(UserCheck entity) {
|
|
try {
|
|
Integer integer = mapper.delAll(entity);
|
|
if (integer > 0) {
|
|
return AjaxResult.success("移除成功");
|
|
} else {
|
|
return AjaxResult.error("移除失败");
|
|
}
|
|
} catch (Exception e) {
|
|
log.error(e.toString(),e);
|
|
return AjaxResult.error("移除失败");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 添加任务
|
|
*
|
|
* @param params 条件
|
|
* @return 条数
|
|
*/
|
|
@Override
|
|
public AjaxResult insertData(String params, String userId,String quality) {
|
|
UserCheck userCheck=new UserCheck();
|
|
String qualityUser;
|
|
if("1".equals(quality)){
|
|
//质量
|
|
qualityUser="QU";
|
|
}else{
|
|
qualityUser="AU";
|
|
}
|
|
//安全
|
|
userCheck.setQuality(qualityUser);
|
|
List<String> list = new ArrayList<>();
|
|
if (StringUtils.isNotBlank(params)) {
|
|
String[] arr = params.split(",");
|
|
list = Arrays.asList(arr);
|
|
}
|
|
try {
|
|
for (String classId : list) {
|
|
//对数据进行删除
|
|
userCheck.setClassId(classId);
|
|
//删除已分配的数据
|
|
mapper.delTypeData(userCheck);
|
|
mapper.insertNewData(classId, userId,qualityUser);
|
|
}
|
|
return AjaxResult.success("添加成功");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return AjaxResult.error("添加失败");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 查询今日任务
|
|
*
|
|
* @param entity 条件
|
|
* @return 集合
|
|
*/
|
|
@Override
|
|
public List<ClassData> getClassData(ClassData entity) {
|
|
if (StringUtils.isNotBlank(entity.getOrg())) {
|
|
String[] arr = entity.getOrg().split(",");
|
|
List<String> list = Arrays.asList(arr);
|
|
entity.setOrgList(list);
|
|
}
|
|
return mapper.getClassData(entity);
|
|
}
|
|
|
|
@Override
|
|
public AjaxResult updateUserInformation(String userId, String type, String value) {
|
|
try{
|
|
int num= mapper.updateUserInformation(userId,type,value);
|
|
if(1==num){
|
|
return AjaxResult.success("修改成功");
|
|
}
|
|
}catch (Exception e){
|
|
log.error(e.toString(),e);
|
|
}
|
|
return AjaxResult.error("修改失败");
|
|
}
|
|
|
|
}
|