巡检权限
This commit is contained in:
parent
304159b895
commit
e9672899ec
@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.checking.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.execption.OpenPromptException;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
||||
@ -87,43 +89,52 @@ public class CheckingPointInfoServiceImpl extends ServiceImpl<CheckingPointInfoM
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(CheckingPointInfo checkingPointInfo) {
|
||||
log.info("CheckingPointInfoServiceImpl#add param:{}", checkingPointInfo);
|
||||
Long checkingPointId = checkingPointInfo.getCheckingPointId();
|
||||
public void add(CheckingPointInfo info) {
|
||||
log.info("CheckingPointInfoServiceImpl#add param:{}", info);
|
||||
Long checkingPointId = info.getCheckingPointId();
|
||||
CheckingPoint old = checkingPointService.getById(checkingPointId);
|
||||
if (old == null) {
|
||||
log.error("CheckingPointInfoServiceImpl#add 当前打卡测点不存在!打卡信息为:{}", checkingPointInfo);
|
||||
log.error("CheckingPointInfoServiceImpl#add 当前打卡测点不存在!打卡信息为:{}", info);
|
||||
throw new NullPointerException("当前打卡测点不存在!");
|
||||
}
|
||||
// 异常添加异常信息
|
||||
if (checkingPointInfo.getStatus() == PointStatusEnum.ABNORMAL.getId()) {
|
||||
checkingPointAlarmService.save(new CheckingPointAlarm(checkingPointId, checkingPointInfo.getAlarmDetails(), checkingPointInfo.getAlarmImage()));
|
||||
if (info.getStatus() == PointStatusEnum.ABNORMAL.getId()) {
|
||||
checkingPointAlarmService.save(new CheckingPointAlarm(checkingPointId, info.getAlarmDetails(), info.getAlarmImage()));
|
||||
}
|
||||
CheckingPoint checkingPoint = checkingPointMapper.selectById(checkingPointInfo.getCheckingPointId());
|
||||
CheckingPoint checkingPoint = checkingPointMapper.selectById(info.getCheckingPointId());
|
||||
|
||||
String noticeUserIds;
|
||||
if (checkingPointInfo.getXzCheckingRouteTaskId() != null) {
|
||||
checkDuplicateAndPointExist(checkingPointInfo);
|
||||
checkingPointInfoMapper.insert(checkingPointInfo);
|
||||
if (info.getXzCheckingRouteTaskId() != null) {
|
||||
checkDuplicateAndPointExist(info);
|
||||
checkingPointInfoMapper.insert(info);
|
||||
|
||||
String xzCheckingRouteTaskId = String.valueOf(info.getXzCheckingRouteTaskId());
|
||||
XzCheckingRouteTask task = xzCheckingRouteTaskService.queryById(xzCheckingRouteTaskId);
|
||||
noticeUserIds = task.getXzCheckingRoute().getNoticeUserIds();
|
||||
|
||||
// 判断用户是否存在于检查人员id列表
|
||||
boolean userFlag = CharSequenceUtil.split(task.getXzCheckingRoute().getInspectUserIds(), ",").contains(String.valueOf(info.getCheckingPointUserId()));
|
||||
if (!userFlag) {
|
||||
throw new OpenAlertException("当前用户不具备巡检权限!");
|
||||
}
|
||||
|
||||
//更新任务-检查人员信息
|
||||
String xzCheckingRouteTaskId = String.valueOf(checkingPointInfo.getXzCheckingRouteTaskId());
|
||||
ProjectSnQO qo = new ProjectSnQO();
|
||||
qo.setXzCheckingRouteTaskId(xzCheckingRouteTaskId);
|
||||
List<CheckingPoint> checkingPoints = checkingPointService.selectCheckingPointList(qo);
|
||||
int allSize = checkingPoints.size();
|
||||
int normalSize = checkingPoints.stream().filter(checkingPoint1 -> checkingPoint1.getInspectStatus() == 1).collect(Collectors.toList()).size();
|
||||
int abnormalSize = checkingPoints.stream().filter(checkingPoint1 -> checkingPoint1.getInspectStatus() == 2).collect(Collectors.toList()).size();
|
||||
int isInspect = allSize == (normalSize + abnormalSize) ? 1 : 0;
|
||||
xzCheckingRouteTaskMapper.update(null, new LambdaUpdateWrapper<XzCheckingRouteTask>()
|
||||
.set(XzCheckingRouteTask::getIsInspect, 1)
|
||||
.set(XzCheckingRouteTask::getCheckingPointNum, checkingPoints.size())
|
||||
.set(XzCheckingRouteTask::getNormalCheckingPointNum, checkingPoints.stream().filter(checkingPoint1 -> checkingPoint1.getInspectStatus() == 1).collect(Collectors.toList()).size())
|
||||
.set(XzCheckingRouteTask::getAbnormalCheckingPointNum, checkingPoints.stream().filter(checkingPoint1 -> checkingPoint1.getInspectStatus() == 2).collect(Collectors.toList()).size())
|
||||
.set(XzCheckingRouteTask::getIsInspect, isInspect)
|
||||
.set(XzCheckingRouteTask::getCheckingPointNum, allSize)
|
||||
.set(XzCheckingRouteTask::getNormalCheckingPointNum, normalSize)
|
||||
.set(XzCheckingRouteTask::getAbnormalCheckingPointNum, abnormalSize)
|
||||
.eq(XzCheckingRouteTask::getId, xzCheckingRouteTaskId)
|
||||
);
|
||||
|
||||
XzCheckingRouteTask task = xzCheckingRouteTaskService.queryById(xzCheckingRouteTaskId);
|
||||
noticeUserIds = task.getXzCheckingRoute().getNoticeUserIds();
|
||||
} else {
|
||||
checkingPointInfoMapper.insert(checkingPointInfo);
|
||||
checkingPointInfoMapper.insert(info);
|
||||
noticeUserIds = checkingPoint.getInspectUserIds();
|
||||
}
|
||||
|
||||
@ -133,7 +144,7 @@ public class CheckingPointInfoServiceImpl extends ServiceImpl<CheckingPointInfoM
|
||||
SystemUser systemUser = systemUserMapper.selectById(userId);
|
||||
noticeService.addUserNotice(Long.valueOf(userId),
|
||||
String.format("新增巡检点记录,巡检点名称为%s,巡检位置为%s,巡检时间为%s,巡检人员为%s,巡检状态为%s,请注意。",
|
||||
checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(checkingPoint.getCreateDate()), systemUser.getRealName(), getStatus(checkingPointInfo.getStatus())),
|
||||
checkingPoint.getCheckingPointName(), checkingPoint.getPosition(), DateUtil.formatDateTime(checkingPoint.getCreateDate()), systemUser.getRealName(), getStatus(info.getStatus())),
|
||||
"巡检点记录新增", "19");
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,11 +65,6 @@ public class CheckingPointServiceImpl extends ServiceImpl<CheckingPointMapper, C
|
||||
if (checkingPoint == null) {
|
||||
throw new OpenAlertException("该巡检点不存在");
|
||||
}
|
||||
// 判断用户是否存在于检查人员id列表
|
||||
boolean userFlag = CharSequenceUtil.split(checkingPoint.getInspectUserIds(), ",").contains(String.valueOf(userId));
|
||||
if (!userFlag) {
|
||||
throw new OpenPromptException("当前用户不具备巡检权限!", false);
|
||||
}
|
||||
if (checkingPoint.getStandArea() == null || checkingPoint.getLongitude() == null || checkingPoint.getLatitude() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user