Browse Source

提交获取任务分页列表代码

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
a8d96bf1be
8 changed files with 97 additions and 41 deletions
  1. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  2. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/AddInspectionRequest.java
  3. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/QueryInspectionPageListRequest.java
  4. +73
    -25
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java
  5. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/ExecuteHandle.java
  6. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/LiveHandle.java
  7. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/ResubmitHandle.java
  8. +7
    -6
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java View File

* 查询巡检任务分页列表 * 查询巡检任务分页列表
*/ */
@GetMapping("/page/list") @GetMapping("/page/list")
public JsonResult list(QueryInspectionPageListRequest request) {
log.info("进入查询巡检任务分页列表");
public JsonResult list(@RequestBody QueryInspectionPageListRequest request) {
log.info("进入查询巡检任务分页列表接口");
return iInspectionService.selectPageList(request); return iInspectionService.selectPageList(request);
} }



+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/AddInspectionRequest.java View File

private String sectionName; private String sectionName;


/** /**
* 是否实时,1:实时 2:离线 默认:null
* 是否直播,1:实时 2:离线 默认:null
*/ */
private Integer isLive; private Integer isLive;



+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspection/QueryInspectionPageListRequest.java View File

import com.tuoheng.common.core.common.BaseQuery; import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data; import lombok.Data;


import java.util.List;

/** /**
* 查询巡检任务请求实体 * 查询巡检任务请求实体
* *
*/ */
private String deptId; private String deptId;


/**
* 部门及子部门Id列表
*/
private List<String> deptIdList;

} }

+ 73
- 25
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java View File

package com.tuoheng.admin.service.inspection.query; package com.tuoheng.admin.service.inspection.query;


import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.conver.InspectionConverMapper; import com.tuoheng.admin.conver.InspectionConverMapper;
import com.tuoheng.admin.entity.Dept; import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.InspectionTypeEnum;
import com.tuoheng.admin.enums.UserTypeEnum; import com.tuoheng.admin.enums.UserTypeEnum;
import com.tuoheng.admin.enums.code.inspection.AddInspectionCodeEnum;
import com.tuoheng.admin.enums.code.dept.QueryDeptChildListCodeEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.InspectionFileMapper; import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.utils.ShiroUtils; import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.admin.vo.InspectionVo; import com.tuoheng.admin.vo.InspectionVo;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.List; import java.util.List;


/** /**
* 查询巡检任务分页列表业务层处理
* 查询巡检任务分页列表业务层处理
* *
* @author wanjing * @author wanjing
* @team tuoheng * @team tuoheng
problemCountHandle.setNextHandler(resubmitHandle); problemCountHandle.setNextHandler(resubmitHandle);
} }


public JsonResult getPageList(QueryInspectionPageListRequest queryInspectionRequest) {
public JsonResult getPageList(QueryInspectionPageListRequest request) {
log.info("进入查询巡检任务分页列表业务"); log.info("进入查询巡检任务分页列表业务");


String userId = ShiroUtils.getUserId(); String userId = ShiroUtils.getUserId();
String tenantId = ShiroUtils.getTenantId(); String tenantId = ShiroUtils.getTenantId();


JsonResult result = this.check(tenantId, queryInspectionRequest);
JsonResult result = this.check(tenantId, request);
if (0 != result.getCode()) { if (0 != result.getCode()) {
log.info("进入查询巡检任务分页列表业务:校验失败:{}", result.getMsg()); log.info("进入查询巡检任务分页列表业务:校验失败:{}", result.getMsg());
return result; return result;
.eq(Dept::getId, user.getDeptId()) .eq(Dept::getId, user.getDeptId())
.eq(Dept::getMark, 1)); .eq(Dept::getMark, 1));


IPage<Inspection> pageData = null;
if (UserTypeEnum.SUPER_ADMIN.getCode() == user.getType()) { if (UserTypeEnum.SUPER_ADMIN.getCode() == user.getType()) {
pageData = this.getAllList(request);
} else if (UserTypeEnum.ADMIN.getCode() == user.getType()) { } else if (UserTypeEnum.ADMIN.getCode() == user.getType()) {
pageData = this.getListByDept(request);
} else if (UserTypeEnum.ORDINARY_USER.getCode() == user.getType()) { } else if (UserTypeEnum.ORDINARY_USER.getCode() == user.getType()) {
pageData = this.getListByDept(request);
} }


// if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() == queryInspectionRequest.getInspectionType()) {
// queryInspectionRequest.setAirportId(0);
// queryInspectionRequest.setInspectionLine(0);
// }

// 获取本部门及子孙部门id列表
List<String> deptIdList = deptMapper.selectAllChildListById(queryInspectionRequest.getDeptId());

// 设置分页参数
IPage<Inspection> page = new Page<>(queryInspectionRequest.getPage(), queryInspectionRequest.getLimit());

// 查询结果
IPage<Inspection> pageData = inspectionMapper.selectPageList(page, queryInspectionRequest);

List<Inspection> inspectionList = pageData.getRecords();
if (null == pageData || pageData.getTotal() == 0) {
log.info("获取任务分页列表为空");
return JsonResult.error(QueryInspectionPageListCodeEnum.QUERY_IS_FAILED.getCode(), QueryInspectionPageListCodeEnum.QUERY_IS_FAILED.getMsg());
}


List<InspectionVo> inspectionVoList = buildIspectionVoList(user, dept, inspectionList);
// 构造返回结果对象
List<InspectionVo> inspectionVoList = buildIspectionVoList(user, dept, pageData.getRecords());


// 重写返回结果对象
IPage<InspectionVo> inspectionVoPageData = new Page<>();
inspectionVoPageData.setPages(pageData.getPages());
inspectionVoPageData.setCurrent(pageData.getCurrent());
inspectionVoPageData.setSize(pageData.getSize());
inspectionVoPageData.setTotal(pageData.getTotal());
inspectionVoPageData.setRecords(inspectionVoList);


return JsonResult.success(inspectionVoList);
return JsonResult.success(inspectionVoPageData);
} }


/** /**
* 检查参数 * 检查参数
*
* @param tenantId * @param tenantId
* @param queryInspectionRequest * @param queryInspectionRequest
* @return * @return
return JsonResult.success(); return JsonResult.success();
} }


/**
* 超级管理员可查全部的任务
*
* @param request
* @return
*/
private IPage<Inspection> getAllList(QueryInspectionPageListRequest request) {
// 设置分页参数
IPage<Inspection> page = new Page<>(request.getPage(), request.getLimit());
// 查询结果
IPage<Inspection> pageData = inspectionMapper.selectPageList(page, request);
return pageData;
}

/**
* 管理员和普通用户可查本部门及子部门的任务
* 1)、如果前端检索条件,传了部门Id,则根据deptId来查
* 2)、如果前端检索条件,部门Id为空,则表示查本部门及子部门的任务
*
* @param request
* @return
*/
private IPage<Inspection> getListByDept(QueryInspectionPageListRequest request) {
// 获取本部门及子孙部门id列表
if (StringUtils.isEmpty(request.getDeptId())) {
List<String> deptIdList = deptMapper.selectAllChildListById(request.getDeptId());
request.setDeptIdList(deptIdList);
}

// 设置分页参数
IPage<Inspection> page = new Page<>(request.getPage(), request.getLimit());
// 查询结果
IPage<Inspection> pageData = inspectionMapper.selectPageList(page, request);
return pageData;
}

/**
* 1)、查找已确认问题数、发现问题数字段
* 2)、判断是否有操作权限:立即执行、直播、回放、问题详情、问题核实、重新提交
*
* @param user
* @param dept
* @param inspectionList
* @return
*/
private List<InspectionVo> buildIspectionVoList(User user, Dept dept, List<Inspection> inspectionList) { private List<InspectionVo> buildIspectionVoList(User user, Dept dept, List<Inspection> inspectionList) {
List<InspectionVo> inspectionVoList = InspectionConverMapper.INSTANCE.fromInspectionListToInspectionVoList(inspectionList); List<InspectionVo> inspectionVoList = InspectionConverMapper.INSTANCE.fromInspectionListToInspectionVoList(inspectionList);
for (InspectionVo inspectionVo : inspectionVoList) { for (InspectionVo inspectionVo : inspectionVoList) {

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/ExecuteHandle.java View File

if (InspectionStatusEnum.WAIT_FLIGHT.getCode() != inspectionVo.getStatus()) { if (InspectionStatusEnum.WAIT_FLIGHT.getCode() != inspectionVo.getStatus()) {
if (null != handler) { if (null != handler) {
handler.handler(user, dept, inspectionVo); handler.handler(user, dept, inspectionVo);
return;
} }
return;
} }


if (InspectionTypeEnum.AIRPORT.getCode() != inspectionVo.getInspectionType()) { if (InspectionTypeEnum.AIRPORT.getCode() != inspectionVo.getInspectionType()) {
if (null != handler) { if (null != handler) {
handler.handler(user, dept, inspectionVo); handler.handler(user, dept, inspectionVo);
return;
} }
return;
} }


if (UserTypeEnum.ADMIN.getCode() == user.getType()) { if (UserTypeEnum.ADMIN.getCode() == user.getType()) {

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/LiveHandle.java View File

if (InspectionStatusEnum.IN_FLIGHT.getCode() != inspectionVo.getStatus()) { if (InspectionStatusEnum.IN_FLIGHT.getCode() != inspectionVo.getStatus()) {
if (null != handler) { if (null != handler) {
handler.handler(user, dept, inspectionVo); handler.handler(user, dept, inspectionVo);
return;
} }
return;
} }
if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() != inspectionVo.getInspectionType()) { if (InspectionTypeEnum.MABNNEDFLIGHT.getCode() != inspectionVo.getInspectionType()) {
if (null != handler) { if (null != handler) {
handler.handler(user, dept, inspectionVo); handler.handler(user, dept, inspectionVo);
return;
} }
return;
} }


if (1 == inspectionVo.getIsLive()) {
if (null != inspectionVo.getIsLive() && 1 == inspectionVo.getIsLive()) {
inspectionVo.setLive(true); inspectionVo.setLive(true);
} }



+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/handle/ResubmitHandle.java View File

if (InspectionStatusEnum.FLIGHT_FAILED.getCode() != inspectionVo.getStatus()) { if (InspectionStatusEnum.FLIGHT_FAILED.getCode() != inspectionVo.getStatus()) {
if (null != handler) { if (null != handler) {
handler.handler(user, dept, inspectionVo); handler.handler(user, dept, inspectionVo);
return;
} }
return;
} }
if (InspectionTypeEnum.AIRPORT.getCode() != inspectionVo.getInspectionType()) { if (InspectionTypeEnum.AIRPORT.getCode() != inspectionVo.getInspectionType()) {
if (null != handler) { if (null != handler) {
handler.handler(user, dept,inspectionVo); handler.handler(user, dept,inspectionVo);
return;
} }
return;
} }
inspectionVo.setResubmit(true); inspectionVo.setResubmit(true);
if (null != handler) { if (null != handler) {

+ 7
- 6
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml View File

<if test="request.type != null and request.type != 0"> and type = #{request.type} </if> <if test="request.type != null and request.type != 0"> and type = #{request.type} </if>
<if test="request.status != null and request.status != 0"> and status = #{request.status} </if> <if test="request.status != null and request.status != 0"> and status = #{request.status} </if>
<if test="request.inspectionType != null and request.inspectionType != 0"> and inspection_type = #{request.inspectionType} </if> <if test="request.inspectionType != null and request.inspectionType != 0"> and inspection_type = #{request.inspectionType} </if>
<!-- <if test="request.name != null and request.name != ''">-->
<!-- and dept_id in-->
<!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
<!-- #{id}-->
<!-- </foreach>-->
<!-- </if>-->
<if test="request.deptId != null and request.deptId != ''"> and dept_id = #{request.deptId} </if>
<if test="request.deptIdList != null and request.deptIdList.size() > 0">
and dept_id in
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
</where> </where>
</select> </select>



Loading…
Cancel
Save