|
@@ -15,9 +15,11 @@ import com.platform.dao.bean.MyPage;
|
|
|
import com.platform.dao.dto.fill.FillGatherTaskDTO;
|
|
|
import com.platform.dao.dto.fill.FillGatherTaskDetailDTO;
|
|
|
import com.platform.dao.entity.fill.*;
|
|
|
+import com.platform.dao.entity.upms.SysRole;
|
|
|
import com.platform.dao.entity.upms.SysUser;
|
|
|
import com.platform.dao.enums.*;
|
|
|
import com.platform.dao.mapper.fill.*;
|
|
|
+import com.platform.dao.mapper.upms.SysRoleMapper;
|
|
|
import com.platform.dao.mapper.upms.SysUserMapper;
|
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
|
import com.platform.dao.vo.SysRoleVO;
|
|
@@ -55,6 +57,7 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
|
|
|
private final FillGatherTaskDetailMapper fillGatherTaskDetailMapper;
|
|
|
private final SysUserMapper sysUserMapper;
|
|
|
private final FillUpdateRecordMapper fillUpdateRecordMapper;
|
|
|
+ private final SysRoleMapper sysRoleMapper;
|
|
|
|
|
|
private void deleteDetails(List<String> detailIds){
|
|
|
for(int i=0;i<detailIds.size();i++){
|
|
@@ -71,10 +74,30 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
|
|
|
FillGatherTask task = new FillGatherTask();
|
|
|
task.setId(dto.getId());
|
|
|
if (dto.getIsAdd()==0){
|
|
|
- //删除
|
|
|
- task.setTotalNum(task1.getTotalNum()-dto.getDetailIds().size());
|
|
|
- task.setWaitNum(task1.getTotalNum()-dto.getDetailIds().size());
|
|
|
- deleteDetails(dto.getDetailIds());
|
|
|
+ UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
+ SysRole sysRole = new SysRole();
|
|
|
+ sysRole.setRoleName("调度人员");
|
|
|
+ SysRole role = sysRoleMapper.selectOne(sysRole);
|
|
|
+ if (userInfo.getSuperAdmin()==1){
|
|
|
+ task.setTotalNum(task1.getTotalNum()-dto.getDetailIds().size());
|
|
|
+ task.setWaitNum(task1.getTotalNum()-dto.getDetailIds().size());
|
|
|
+ deleteDetails(dto.getDetailIds());
|
|
|
+ }else if (userInfo.getRoleCodes().size()>0){
|
|
|
+ for (int i = 0;i<userInfo.getRoleCodes().size();i++){
|
|
|
+ if (userInfo.getRoleCodes().get(i).equals(role.getRoleCode())){
|
|
|
+ //删除
|
|
|
+ task.setTotalNum(task1.getTotalNum()-dto.getDetailIds().size());
|
|
|
+ task.setWaitNum(task1.getTotalNum()-dto.getDetailIds().size());
|
|
|
+ deleteDetails(dto.getDetailIds());
|
|
|
+ break;
|
|
|
+ }else if (i==userInfo.getRoleCodes().size()-1){
|
|
|
+ throw new DeniedException("对不起,只有调度人员可以删除巡检任务!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new DeniedException("对不起,只有调度人员可以删除巡检任务!");
|
|
|
+ }
|
|
|
+
|
|
|
}else if (dto.getIsAdd()==1){
|
|
|
List<FillGatherTaskDetailVO> detailVOS = fillGatherTaskDetailMapper.selectVOByTaskId(task1.getId());
|
|
|
StringBuffer sb = new StringBuffer();
|
|
@@ -107,10 +130,42 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
|
|
|
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
- Weekend<FillGatherTask> weekend = new Weekend<>(FillGatherTask.class);
|
|
|
- WeekendCriteria<FillGatherTask, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
- weekendCriteria.andIn(FillGatherTask::getId, ids);
|
|
|
- mapper.deleteByExample(weekend);
|
|
|
+ UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
+ SysRole sysRole = new SysRole();
|
|
|
+ sysRole.setRoleName("调度人员");
|
|
|
+ SysRole role = sysRoleMapper.selectOne(sysRole);
|
|
|
+ if (userInfo.getSuperAdmin()==1){
|
|
|
+ Weekend<FillGatherTask> weekend = new Weekend<>(FillGatherTask.class);
|
|
|
+ WeekendCriteria<FillGatherTask, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andIn(FillGatherTask::getId, ids);
|
|
|
+ for (String id:ids){
|
|
|
+ FillGatherTaskDetail detail = new FillGatherTaskDetail();
|
|
|
+ detail.setTaskId(id);
|
|
|
+ fillGatherTaskDetailMapper.delete(detail);
|
|
|
+ }
|
|
|
+ mapper.deleteByExample(weekend);
|
|
|
+ }else if (userInfo.getRoleCodes().size()>0){
|
|
|
+ for (int i = 0;i<userInfo.getRoleCodes().size();i++){
|
|
|
+ if (userInfo.getRoleCodes().get(i).equals(role.getRoleCode())){
|
|
|
+ Weekend<FillGatherTask> weekend = new Weekend<>(FillGatherTask.class);
|
|
|
+ WeekendCriteria<FillGatherTask, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andIn(FillGatherTask::getId, ids);
|
|
|
+ for (String id:ids){
|
|
|
+ FillGatherTaskDetail detail = new FillGatherTaskDetail();
|
|
|
+ detail.setTaskId(id);
|
|
|
+ fillGatherTaskDetailMapper.delete(detail);
|
|
|
+ }
|
|
|
+ mapper.deleteByExample(weekend);
|
|
|
+ break;
|
|
|
+ }else if (i==userInfo.getRoleCodes().size()-1){
|
|
|
+ throw new DeniedException("对不起,只有调度人员可以删除巡检任务!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new DeniedException("对不起,只有调度人员可以删除巡检任务!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return 1;
|
|
|
}
|
|
|
|