Browse Source

1、修改根据部门id获取子部门列表,原来获取的是分页列表,现在去掉分页;2、新增获取任务详情代码

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
2e7d7f2c37
11 changed files with 108 additions and 75 deletions
  1. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java
  2. +49
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryInspectionByIdCodeEnum.java
  3. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryInspectionPageListCodeEnum.java
  4. +8
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java
  5. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/QueryDeptChildPageListRequest.java
  6. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java
  7. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java
  8. +10
    -27
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryChildListService.java
  9. +7
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java
  10. +16
    -36
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionByIdService.java
  11. +9
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java View File

/** /**
* 根据id查询子部门列表 * 根据id查询子部门列表
*/ */
@GetMapping("/child/page/list/{id}")
public JsonResult getChildList(@RequestBody QueryDeptChildPageListRequest queryDeptChildPageListRequest) {
log.info("进入获取子部门分页列表列表接口, id:{}", queryDeptChildPageListRequest.getId());
return deptService.getChildPageList(queryDeptChildPageListRequest);
@GetMapping("/child/list/{id}")
public JsonResult getChildList(@PathVariable("id") String id) {
log.info("进入获取子部门分页列表列表接口, id:{}", id);
return deptService.getChildList(id);
} }


/** /**

+ 49
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryInspectionByIdCodeEnum.java View File

package com.tuoheng.admin.enums.code.inspection;

/**
* 查询巡检任务详情返回码
* 模块代码:23(公路管理)
* 接口代码:05 (查询巡检任务详情)
*
* @author wanjing
* @team tuoheng
* @date 2022-11-24
*/
public enum QueryInspectionByIdCodeEnum {

QUERY_IS_FAILED(1230500, "获取数据失败"),
INSPECTION_ID_IS_NULL(1230501, "任务id为空"),
INSPECTION_IS_NOT_EXIST(1230502, "任务不存在");

/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

QueryInspectionByIdCodeEnum(int code, String msg){
this.code = code;
this.msg = msg;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryInspectionPageListCodeEnum.java View File

/** /**
* 查询巡检任务分页列表返回码 * 查询巡检任务分页列表返回码
* 模块代码:23(公路管理) * 模块代码:23(公路管理)
* 接口代码:04 (根据部门id获取该部门下公路列表)
* 接口代码:04 (查询巡检任务分页列表)
* *
* @author wanjing * @author wanjing
* @team tuoheng * @team tuoheng

+ 8
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java View File

*/ */
List<String> selectAllChildListById(String id); List<String> selectAllChildListById(String id);


/**
* 通过部门idList,查找部门列表
*
* @param idList 部门id列表
* @return 结果
*/
List<Dept> selectListByIdList(List<String> idList);

/** /**
* 修改部门 * 修改部门
* *

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/QueryDeptChildPageListRequest.java View File

* @date 2022-11-22 * @date 2022-11-22
*/ */
@Data @Data
public class QueryDeptChildPageListRequest extends BaseQuery {
public class QueryDeptChildPageListRequest {


private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;



+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java View File

* @return 部门 * @return 部门
*/ */
@Override @Override
public JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest) {
return queryChildListService.getChildPageList(queryDeptChildPageListRequest);
public JsonResult getChildList(String id) {
return queryChildListService.getChildList(id);
} }
/** /**

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java View File

* *
* @return 部门集合 * @return 部门集合
*/ */
JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest);
JsonResult getChildList(String id);
/** /**

+ 10
- 27
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryChildListService.java View File

* *
* @return * @return
*/ */
public JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest) {
public JsonResult getChildList(String deptId) {
log.info("进入查询子部门列表业务"); log.info("进入查询子部门列表业务");
String tenantId = ShiroUtils.getTenantId();
String deptId = queryDeptChildPageListRequest.getId();

JsonResult result = this.check(tenantId, deptId);
JsonResult result = this.check(deptId);
if (0 != result.getCode()) { if (0 != result.getCode()) {
log.info("根据id查询子部门列表业务:校验失败:{}", result.getMsg()); log.info("根据id查询子部门列表业务:校验失败:{}", result.getMsg());
return result; return result;
} }

// 查询所有有效的子部门数据
IPage<Dept> page = new Page<>(queryDeptChildPageListRequest.getPage(), queryDeptChildPageListRequest.getLimit());
IPage<Dept> pageData = deptMapper.selectPage(page, Wrappers.<Dept>lambdaQuery()
.eq(Dept::getMark, 1)
.eq(Dept::getTenantId, tenantId)
.orderByDesc(Dept::getCreateTime));
List<Dept> deptList = pageData.getRecords();
List<Dept> list = new ArrayList<>();
for (Dept record : deptList) {
list.add(record);
}
pageData.setRecords(list);

if (CollectionUtil.isEmpty(deptList)) {
log.info("获取子部门列表为空");
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_LIST_IS_NULL.getCode(), QueryDeptChildListCodeEnum.DEPT_LIST_IS_NULL.getMsg());
List<String> deptIdList = deptMapper.selectAllChildListById(deptId);
if (CollectionUtil.isEmpty(deptIdList)) {
log.info("获取部门列表为空");
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getCode(), QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getMsg());
} }
return JsonResult.success(pageData);
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList);
return JsonResult.success(deptList);
} }


/** /**
* 检查参数 * 检查参数
* @param tenantId
*
* @param id * @param id
* @return * @return
*/ */
private JsonResult check(String tenantId, String id) {
private JsonResult check(String id) {
// 判断id是否为空 // 判断id是否为空
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getMsg()); return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getMsg());


// 判断部门是否存在 // 判断部门是否存在
Integer count = deptMapper.selectCount(new LambdaQueryWrapper<Dept>() Integer count = deptMapper.selectCount(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, id) .eq(Dept::getId, id)
.eq(Dept::getMark, 1)); .eq(Dept::getMark, 1));
if (count <= 0) { if (count <= 0) {

+ 7
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java View File

import com.tuoheng.admin.service.inspection.add.AddInspectionService; import com.tuoheng.admin.service.inspection.add.AddInspectionService;
import com.tuoheng.admin.service.inspection.delete.DeleteInspectionService; import com.tuoheng.admin.service.inspection.delete.DeleteInspectionService;


import com.tuoheng.admin.service.inspection.query.QueryInspectionByIdService;
import com.tuoheng.admin.service.inspection.query.QueryInspectionListService; import com.tuoheng.admin.service.inspection.query.QueryInspectionListService;
import com.tuoheng.admin.service.inspection.query.QueryInspectionPageListService; import com.tuoheng.admin.service.inspection.query.QueryInspectionPageListService;
import com.tuoheng.admin.service.inspection.query.QueryVideoService; import com.tuoheng.admin.service.inspection.query.QueryVideoService;
@Slf4j @Slf4j
@Service @Service
public class InspectionServiceImpl implements IInspectionService { public class InspectionServiceImpl implements IInspectionService {

@Autowired @Autowired
private InspectionMapper inspectionMapper; private InspectionMapper inspectionMapper;


@Autowired @Autowired
private QueryInspectionPageListService queryInspectionPageListService; private QueryInspectionPageListService queryInspectionPageListService;


@Autowired
private QueryInspectionByIdService queryInspectionByIdService;

@Autowired @Autowired
private AddInspectionService addinspectionService; private AddInspectionService addinspectionService;


} }


/** /**
* 查询巡检任务
* 查询巡检任务详情
* *
* @param id 巡检任务id * @param id 巡检任务id
* @return 巡检任务 * @return 巡检任务
*/ */
@Override @Override
public JsonResult selectOneById(String id) { public JsonResult selectOneById(String id) {

return JsonResult.success();
return queryInspectionByIdService.getInfo(id);
} }


/** /**

+ 16
- 36
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionByIdService.java View File



import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionFile; import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.enums.InspectionFileStatusEnum; import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionByIdCodeEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; 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;


public JsonResult getInfo(String id) { public JsonResult getInfo(String id) {
log.info("进入查询巡检任务详情业务"); log.info("进入查询巡检任务详情业务");

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

JsonResult result = this.check(tenantId, id);
JsonResult result = this.check(id);
if (0 != result.getCode()) { if (0 != result.getCode()) {
log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg()); log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg());
return result; return result;
} }


Integer confirmedProblemCount = 0;
Integer discoverProblemCount = 0;

List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper<InspectionFile>()
.eq(InspectionFile::getTenantId, tenantId)
.eq(InspectionFile::getInspectionId,id)
.eq(InspectionFile::getMark, 1));

if (CollectionUtil.isEmpty(inspectionFileList)) {
discoverProblemCount = inspectionFileList.size();
for (InspectionFile inspectionFile : inspectionFileList) {
if (InspectionFileStatusEnum.CONFIRMED.getCode() == inspectionFile.getStatus()) {
confirmedProblemCount++;
}
}
}
Inspection inspection = (Inspection) result.getData();


// inspectionVo.setConfirmedProblemCount(confirmedProblemCount);
// inspectionVo.setDiscoverProblemCount(discoverProblemCount);
return JsonResult.success(); return JsonResult.success();
} }


/** /**
* 检查参数 * 检查参数
* @param tenantId
* @param id * @param id
* @return * @return
*/ */
private JsonResult check(String tenantId, String id) {
// 判断部门id是否为空
private JsonResult check(String id) {
// 判断任务id是否为空
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryInspectionPageListCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryInspectionPageListCodeEnum.DEPT_ID_IS_NULL.getMsg());
return JsonResult.error(QueryInspectionByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
} }


// // 判断部门是否存在
// Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
// .eq(Dept::getTenantId, tenantId)
// .eq(Dept::getId, queryInspectionRequest.getDeptId())
// .eq(Dept::getMark, 1));
// if (null == dept) {
// return JsonResult.error(QueryInspectionPageListCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryInspectionPageListCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
// }
return JsonResult.success();
// 判断任务是否存在
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getId, id)
.eq(Inspection::getMark, 1));
if (null == inspection) {
return JsonResult.error(QueryInspectionByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryInspectionByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(inspection);
} }


} }

+ 9
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml View File

join th_dept u2 on find_in_set(u2.id, convert(u1.p_ids using utf8) collate utf8_unicode_ci) join th_dept u2 on find_in_set(u2.id, convert(u1.p_ids using utf8) collate utf8_unicode_ci)
</select> </select>


<select id="selectListByIdList" parameterType="list" resultMap="DeptResult">
select <include refid="Base_Column_List"/>
from th_dept
where mark = 1 and id in
<foreach collection="list" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>

<update id="update" parameterType="com.tuoheng.admin.entity.Dept"> <update id="update" parameterType="com.tuoheng.admin.entity.Dept">
update th_dept update th_dept
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">

Loading…
Cancel
Save