|
|
@@ -0,0 +1,98 @@ |
|
|
|
package com.tuoheng.admin.service.inspection.query.handle; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.tuoheng.admin.entity.Dept; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.enums.*; |
|
|
|
import com.tuoheng.admin.enums.code.inspection.EditInspectionCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.UserMapper; |
|
|
|
import com.tuoheng.admin.vo.inspection.InspectionVo; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service("editHandle") |
|
|
|
public class EditHandle implements GenerateInspectionFieldHander { |
|
|
|
|
|
|
|
private GenerateInspectionFieldHander handler; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void setNextHandler(GenerateInspectionFieldHander handler) { |
|
|
|
this.handler = handler; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 判断是否有编辑权限 |
|
|
|
* 1、机场任务: |
|
|
|
* 1)、只有本部门管理员(上上级部门管理员不可编辑)和创建用户才能编辑; |
|
|
|
* 2)、待执行任务,执行后不可编辑; |
|
|
|
* 3)、编辑信息包括,任务地点,路段,巡检机场,巡检路线,巡检时间,执行时间 |
|
|
|
* 2、飞手任务不能编辑。 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param user |
|
|
|
* @param dept |
|
|
|
* @param inspectionVo |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void handler(User user, Dept dept, InspectionVo inspectionVo) { |
|
|
|
// log.info("处理编辑字段"); |
|
|
|
if (InspectionTypeEnum.AIRPORT.getCode() != inspectionVo.getInspectionType()) { |
|
|
|
if (null != handler) { |
|
|
|
handler.handler(user, dept, inspectionVo); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
if (InspectionStatusEnum.WAIT_FLIGHT.getCode() != inspectionVo.getStatus()) { |
|
|
|
// 待执行任务 |
|
|
|
if (null != handler) { |
|
|
|
handler.handler(user, dept, inspectionVo); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
if (InspectionExecutionStatusEnum.EXECUTED.getCode() == inspectionVo.getExecutionStatus()) { |
|
|
|
// 执行后不可编辑 |
|
|
|
if (null != handler) { |
|
|
|
handler.handler(user, dept, inspectionVo); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
if (user.getId().equals(inspectionVo.getCreateUser())) { |
|
|
|
// 自己创建的任务 |
|
|
|
inspectionVo.setEdit(true); |
|
|
|
} else { |
|
|
|
// 非本人创建,判断该用户是不是该部门管理员 |
|
|
|
// 本部门主管编辑本部门任务 |
|
|
|
// 查询部门管理员,若是部门管理员可修改,非部门管理员不能修改 |
|
|
|
User userTmp = userMapper.selectOne(new LambdaQueryWrapper<User>() |
|
|
|
.eq(User::getDeptId, user.getDeptId()) |
|
|
|
.eq(User::getRoleId, RoleEnum.ADMIN.getCode()) |
|
|
|
.eq(User::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if (ObjectUtil.isNull(userTmp)) { |
|
|
|
if (null != handler) { |
|
|
|
handler.handler(user, dept, inspectionVo); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!user.getId().equals(userTmp.getId())) { |
|
|
|
if (null != handler) { |
|
|
|
handler.handler(user, dept, inspectionVo); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
inspectionVo.setEdit(true); |
|
|
|
} |
|
|
|
|
|
|
|
if (null != handler) { |
|
|
|
handler.handler(user, dept, inspectionVo); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |