Explorar el Código

Merge branch 'develop' of http://192.168.11.14:51037/gitadmin/tuoheng_freeway into feature_v1.0

tags/v1.0.0^2
chengwang hace 1 año
padre
commit
60b3cf776a
Se han modificado 24 ficheros con 620 adiciones y 16 borrados
  1. +17
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java
  2. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoadInformationController.java
  3. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/SectionController.java
  4. +50
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/QueryDeptChildListCodeEnum.java
  5. +2
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/QueryDeptInfoCodeEnum.java
  6. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/QueryDeptTreeListCodeEnum.java
  7. +50
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/road/QueryRoadListByDeptIdCodeEnum.java
  8. +50
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/section/QuerySectionListByDeptIdCodeEnum.java
  9. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java
  10. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/EditDeptRequest.java
  11. +27
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/QueryDeptChildPageListRequest.java
  12. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/ISectionService.java
  13. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/RoadInformationService.java
  14. +16
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java
  15. +10
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java
  16. +95
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryChildListService.java
  17. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryDeptInfoService.java
  18. +3
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryListTreeService.java
  19. +14
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/RoadInformationServiceImpl.java
  20. +13
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/SectionServiceImpl.java
  21. +110
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/road/query/QueryRoadListByDeptIdService.java
  22. +116
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/query/QuerySectionListByDeptIdService.java
  23. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/DeptTreeVo.java
  24. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml

+ 17
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/DeptController.java Ver fichero

@@ -1,13 +1,17 @@
package com.tuoheng.admin.controller;

import com.alibaba.fastjson.JSON;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.request.dept.EditDeptRequest;
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest;
import com.tuoheng.admin.service.dept.IDeptService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
* 部门前端控制器
*
@@ -24,7 +28,7 @@ public class DeptController {
private IDeptService deptService;

/**
* 查询部门列表
* 查询部门树形列表
*/
@GetMapping("/list/tree")
public JsonResult getListTree() {
@@ -32,6 +36,15 @@ public class DeptController {
return deptService.getListTree();
}

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

/**
* 获取部门详细信息
*/
@@ -54,8 +67,10 @@ public class DeptController {
* 修改部门
*/
@PutMapping
public JsonResult update(@RequestBody EditDeptRequest oldEditDeptRequest, @RequestBody EditDeptRequest newEditDeptRequest) {
public JsonResult update(@RequestBody Map<String, Object> param) {
log.info("进入修改部门接口");
EditDeptRequest oldEditDeptRequest = JSON.parseObject(JSON.toJSONString(param.get("oldEditDeptRequest")), EditDeptRequest.class);
EditDeptRequest newEditDeptRequest = JSON.parseObject(JSON.toJSONString(param.get("newEditDeptRequest")), EditDeptRequest.class);
return deptService.update(oldEditDeptRequest, newEditDeptRequest);
}


+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoadInformationController.java Ver fichero

@@ -38,6 +38,16 @@ public class RoadInformationController {
return roadInformationService.getListInfo(query);
}

/**
* 根据部门id获取该部门下公路信息列表
* @param deptId
* @return
*/
@GetMapping("/list/by/dept/{deptId}")
public JsonResult getListByDeptId(@PathVariable("deptId") String deptId){
return roadInformationService.getListByDeptId(deptId);
}

/**
* 公路新增
* @param entity

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/SectionController.java Ver fichero

@@ -38,6 +38,16 @@ public class SectionController {
return sectionService.getListInfo(query);
}

/**
* 根据部门id获取该部门下路段信息列表
* @param deptId
* @return
*/
@GetMapping("/list/by/dept/{deptId}")
public JsonResult getListByDeptId(@PathVariable("deptId") String deptId){
return sectionService.getListByDeptId(deptId);
}

/**
* 根据id获取路段详情
* @param sectionId

+ 50
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/QueryDeptChildListCodeEnum.java Ver fichero

@@ -0,0 +1,50 @@
package com.tuoheng.admin.enums.dept;

/**
* 获取子部门列表返回码
* 模块代码:20(部门管理)
* 接口代码:06 (获取子部门列表)
*
* @author wanjing
* @team tuoheng
* @date 2022-11-22
*/
public enum QueryDeptChildListCodeEnum {

DEPT_LIST_IS_FAILED(1200600, "获取子部门列表失败"),
DEPT_ID_IS_NULL(1200601, "部门id为空"),
DEPT_IS_NOT_EXIST(1200602, "部门不存在"),
DEPT_LIST_IS_NULL(1200603, "子部门列表为空");

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

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

QueryDeptChildListCodeEnum(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;
}

}

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/DeptInfoCodeEnum.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/QueryDeptInfoCodeEnum.java Ver fichero

@@ -9,9 +9,8 @@ package com.tuoheng.admin.enums.dept;
* @team tuoheng
* @date 2022-11-20
*/
public enum DeptInfoCodeEnum {
public enum QueryDeptInfoCodeEnum {

// 部门列表为空
DEPT_ID_IS_NULL(1200201, "部门id为空"),
DEPT_IS_NOT_EXIST(1200202, "部门不存在");

@@ -25,7 +24,7 @@ public enum DeptInfoCodeEnum {
*/
private String msg;

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

tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/DeptTreeCodeListEnum.java → tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/dept/QueryDeptTreeListCodeEnum.java Ver fichero

@@ -9,9 +9,9 @@ package com.tuoheng.admin.enums.dept;
* @team tuoheng
* @date 2022-11-20
*/
public enum DeptTreeCodeListEnum {
public enum QueryDeptTreeListCodeEnum {

DEPT_LIST_NULL(1200101, "部门列表为空");
DEPT_LIST_IS_NULL(1200101, "部门列表为空");

/**
* 错误码
@@ -23,7 +23,7 @@ public enum DeptTreeCodeListEnum {
*/
private String msg;

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

+ 50
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/road/QueryRoadListByDeptIdCodeEnum.java Ver fichero

@@ -0,0 +1,50 @@
package com.tuoheng.admin.enums.road;

/**
* 根据部门id获取该部门下公路列表返回码
* 模块代码:21(公路管理)
* 接口代码:03 (根据部门id获取该部门下公路列表)
*
* @author wanjing
* @team tuoheng
* @date 2022-11-20
*/
public enum QueryRoadListByDeptIdCodeEnum {

QUERY_IS_FAILED(1210300, "获取数据失败"),
DEPT_ID_IS_NULL(1210301, "部门id为空"),
DEPT_IS_NOT_EXIST(1210302, "部门不存在"),
ROAD_LIST_IS_NULL(1210303, "公路列表为空");

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

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

QueryRoadListByDeptIdCodeEnum(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;
}

}

+ 50
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/section/QuerySectionListByDeptIdCodeEnum.java Ver fichero

@@ -0,0 +1,50 @@
package com.tuoheng.admin.enums.section;

/**
* 根据部门id获取该部门下公路列表返回码
* 模块代码:22(路段管理)
* 接口代码:03 (根据部门id获取该部门下公路列表)
*
* @author wanjing
* @team tuoheng
* @date 2022-11-20
*/
public enum QuerySectionListByDeptIdCodeEnum {

QUERY_IS_FAILED(1220300, "获取数据失败"),
DEPT_ID_IS_NULL(1220201, "部门id为空"),
DEPT_IS_NOT_EXIST(1220202, "部门不存在"),
SECTION_LIST_IS_NULL(1220203, "路段列表为空");;

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

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

QuerySectionListByDeptIdCodeEnum(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;
}

}

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/DeptMapper.java Ver fichero

@@ -14,6 +14,8 @@ import java.util.List;
*/
public interface DeptMapper extends BaseMapper<Dept> {

List<String> selectAllChildListById(String id);

/**
* 修改部门
*

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/EditDeptRequest.java Ver fichero

@@ -40,5 +40,4 @@ public class EditDeptRequest {
*/
private List<RoadSectionDto> roadSectionDtoList;


}

+ 27
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/dept/QueryDeptChildPageListRequest.java Ver fichero

@@ -0,0 +1,27 @@
package com.tuoheng.admin.request.dept;

import com.tuoheng.admin.dto.RoadSectionDto;
import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
* 根据部门id查询子部门列表请求参数
*
* @author wanjing
* @team tuoheng
* @date 2022-11-22
*/
@Data
public class QueryDeptChildPageListRequest extends BaseQuery {

private static final long serialVersionUID = 1L;

/**
* 部门id
*/
private String id;

}

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/ISectionService.java Ver fichero

@@ -14,6 +14,8 @@ public interface ISectionService extends IBaseService<Section> {

JsonResult getListInfo(SectionQuery query);

JsonResult getListByDeptId(String deptId);

JsonResult editInfo(Section entity);

JsonResult getSectionInfo(String sectionId);

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/RoadInformationService.java Ver fichero

@@ -15,6 +15,8 @@ public interface RoadInformationService extends IBaseService<RoadInformation> {

JsonResult getListInfo(RoadInformationQuery query);

JsonResult getListByDeptId(String deptId);

JsonResult editInfo(RoadInformation entity);

// JsonResult deleteRoadByIds(String[] ids);

+ 16
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/DeptServiceImpl.java Ver fichero

@@ -4,8 +4,10 @@ import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.request.dept.EditDeptRequest;
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest;
import com.tuoheng.admin.service.dept.add.AddDeptService;
import com.tuoheng.admin.service.dept.delete.DeleteDeptService;
import com.tuoheng.admin.service.dept.query.QueryChildListService;
import com.tuoheng.admin.service.dept.query.QueryDeptInfoService;
import com.tuoheng.admin.service.dept.query.QueryListTreeService;
import com.tuoheng.admin.service.dept.update.UpdateDeptService;
@@ -31,6 +33,9 @@ public class DeptServiceImpl implements IDeptService {
@Autowired
private QueryListTreeService queryListTreeService;
@Autowired
private QueryChildListService queryChildListService;
@Autowired
private QueryDeptInfoService queryDeptInfoService;
@@ -44,7 +49,7 @@ public class DeptServiceImpl implements IDeptService {
private DeleteDeptService deleteDeptService;
/**
* 查询部门列表
* 查询部门树形列表
*
* @return 部门
*/
@@ -53,6 +58,16 @@ public class DeptServiceImpl implements IDeptService {
return queryListTreeService.getListTree();
}
/**
* 根据id查询子部门列表
*
* @return 部门
*/
@Override
public JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest) {
return queryChildListService.getChildPageList(queryDeptChildPageListRequest);
}
/**
* 查询部门
*

+ 10
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/IDeptService.java Ver fichero

@@ -3,6 +3,7 @@ package com.tuoheng.admin.service.dept;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.request.dept.AddDeptRequest;
import com.tuoheng.admin.request.dept.EditDeptRequest;
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest;
import com.tuoheng.common.core.utils.JsonResult;
import java.util.List;
@@ -25,12 +26,20 @@ public interface IDeptService {
JsonResult getDeptInfo(String id);
/**
* 查询部门列表
* 查询部门树形列表
*
* @return 部门集合
*/
JsonResult getListTree();
/**
* 根据id查询子部门列表
*
* @return 部门集合
*/
JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest);
/**
* 新增部门
*

+ 95
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryChildListService.java Ver fichero

@@ -0,0 +1,95 @@
package com.tuoheng.admin.service.dept.query;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.enums.dept.QueryDeptChildListCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* 根据id查询子部门列表业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-11-22
*/
@Slf4j
@Service
public class QueryChildListService {

@Autowired
private DeptMapper deptMapper;

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

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

return JsonResult.success(pageData);
}

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

// 判断部门是否存在
Integer count = deptMapper.selectCount(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, id)
.eq(Dept::getMark, 1));
if (count <= 0) {
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryDeptChildListCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
}
return JsonResult.success();
}
}

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryDeptInfoService.java Ver fichero

@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.conver.DeptConverMapper;
import com.tuoheng.admin.dto.RoadSectionDto;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.dept.DeptInfoCodeEnum;
import com.tuoheng.admin.enums.dept.QueryDeptInfoCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.admin.vo.DeptInfoVo;
@@ -98,7 +98,7 @@ public class QueryDeptInfoService {
*/
private JsonResult check(String tenantId, String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(DeptInfoCodeEnum.DEPT_ID_IS_NULL.getCode(), DeptInfoCodeEnum.DEPT_ID_IS_NULL.getMsg());
return JsonResult.error(QueryDeptInfoCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryDeptInfoCodeEnum.DEPT_ID_IS_NULL.getMsg());
}

// 判断部门是否存在
@@ -107,7 +107,7 @@ public class QueryDeptInfoService {
.eq(Dept::getId, id)
.eq(Dept::getMark, 1));
if (null == dept) {
return JsonResult.error(DeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getCode(), DeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
return JsonResult.error(QueryDeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryDeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(dept);
}

+ 3
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/dept/query/QueryListTreeService.java Ver fichero

@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.conver.DeptConverMapper;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.enums.dept.DeptTreeCodeListEnum;
import com.tuoheng.admin.enums.dept.QueryDeptTreeListCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.vo.DeptTreeVo;
import com.tuoheng.common.core.utils.JsonResult;
@@ -45,7 +45,7 @@ public class QueryListTreeService {

if (CollectionUtil.isEmpty(deptList)) {
log.info("获取部门列表为空");
return JsonResult.error(DeptTreeCodeListEnum.DEPT_LIST_NULL.getCode(), DeptTreeCodeListEnum.DEPT_LIST_NULL.getMsg());
return JsonResult.error(QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getCode(), QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getMsg());
}

List<DeptTreeVo> deptTreeVoListTmp = DeptConverMapper.INSTANCE.deptListToDeptVoList(deptList);
@@ -60,6 +60,7 @@ public class QueryListTreeService {
deptTreeVoList.add(deptTreeVo);
} else {
DeptTreeVo parent = deptVoMap.get(child.getPid());
deptTreeVo.setPName(parent.getName());
parent.getChildren().add(child);
}
}

+ 14
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/RoadInformationServiceImpl.java Ver fichero

@@ -13,6 +13,7 @@ import com.tuoheng.admin.mapper.RoadInformationMapper;
import com.tuoheng.admin.mapper.SectionMapper;
import com.tuoheng.admin.query.RoadInformationQuery;
import com.tuoheng.admin.service.RoadInformationService;
import com.tuoheng.admin.service.road.query.QueryRoadListByDeptIdService;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.utils.DateUtils;
@@ -38,6 +39,9 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM
@Autowired
private SectionMapper sectionMapper;

@Autowired
private QueryRoadListByDeptIdService queryRoadListByDeptIdService;

@Override
public JsonResult queryPage(RoadInformationQuery query) {
if (query.getLimit() == null && query.getPage() == null) {
@@ -78,6 +82,16 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM
return JsonResult.success(list);
}

/**
* 根据部门id获取该部门下公路列表
* @param deptId
* @return
*/
@Override
public JsonResult getListByDeptId(String deptId) {
return queryRoadListByDeptIdService.getRoadList(deptId);
}

@Override
public JsonResult editInfo(RoadInformation entity) {
// User user = (User) ThreadLocalUtil.get();

+ 13
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/SectionServiceImpl.java Ver fichero

@@ -14,6 +14,7 @@ import com.tuoheng.admin.mapper.SectionDeptMapper;
import com.tuoheng.admin.mapper.SectionMapper;
import com.tuoheng.admin.query.SectionQuery;
import com.tuoheng.admin.service.ISectionService;
import com.tuoheng.admin.service.section.query.QuerySectionListByDeptIdService;
import com.tuoheng.admin.vo.SectionInfoVo;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
@@ -45,6 +46,8 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section>
@Autowired
private SectionDeptMapper sectionDeptMapper;

@Autowired
private QuerySectionListByDeptIdService querySectionListByDeptIdService;

@Override
public JsonResult queryPage(SectionQuery query) {
@@ -94,6 +97,16 @@ public class SectionServiceImpl extends BaseServiceImpl<SectionMapper, Section>
return JsonResult.success(list);
}

/**
* 根据部门id获取该部门下路段信息列表
* @param deptId
* @return
*/
@Override
public JsonResult getListByDeptId(String deptId) {
return querySectionListByDeptIdService.getRoadList(deptId);
}

@Override
public JsonResult editInfo(Section entity) {
// User user = (User) ThreadLocalUtil.get();

+ 110
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/road/query/QueryRoadListByDeptIdService.java Ver fichero

@@ -0,0 +1,110 @@
package com.tuoheng.admin.service.road.query;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Dept;
import com.tuoheng.admin.entity.RoadDept;
import com.tuoheng.admin.entity.RoadInformation;
import com.tuoheng.admin.enums.dept.QueryDeptChildListCodeEnum;
import com.tuoheng.admin.enums.road.QueryRoadListByDeptIdCodeEnum;
import com.tuoheng.admin.mapper.DeptMapper;
import com.tuoheng.admin.mapper.RoadDeptMapper;
import com.tuoheng.admin.mapper.RoadInformationMapper;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 根据部门Id查询公路列表业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-11-22
*/
@Slf4j
@Service
public class QueryRoadListByDeptIdService {

@Autowired
private DeptMapper deptMapper;

@Autowired
private RoadInformationMapper roadInformationMapper;

@Autowired
private RoadDeptMapper roadDeptMapper;

public JsonResult getRoadList(String deptId) {
log.info("进入根据部门Id查询公路列表业务");
String tenantId = ShiroUtils.getTenantId();

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

// 获取该部门下公路列表
List<RoadInformation> roadInformationList = this.getRoadInformationList(tenantId, deptId);
if (CollectionUtil.isEmpty(roadInformationList)) {
log.info("根据部门Id查询公路列表业务:公路信息为空");
return JsonResult.error(QueryRoadListByDeptIdCodeEnum.ROAD_LIST_IS_NULL.getCode(), QueryRoadListByDeptIdCodeEnum.ROAD_LIST_IS_NULL.getMsg());
}
return JsonResult.success(roadInformationList);
}

/**
* 检查参数
*
* @param tenantId
* @param id
* @return
*/
private JsonResult check(String tenantId, String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryRoadListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryRoadListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getMsg());
}

// 判断部门是否存在
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, id)
.eq(Dept::getMark, 1));
if (null == dept) {
return JsonResult.error(QueryRoadListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryRoadListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(dept);
}

/**
* 查询该部门下公路信息列表
*
* @param tenantId
* @param id
* @return
*/
private List<RoadInformation> getRoadInformationList(String tenantId, String id) {
List<RoadDept> roadDeptList = roadDeptMapper.selectList(new LambdaQueryWrapper<RoadDept>()
.eq(RoadDept::getTenantId, tenantId)
.eq(RoadDept::getDeptId, id));
if (CollectionUtil.isEmpty(roadDeptList)) {
return null;
}
List<String> roadIdList = roadDeptList.stream().map(o -> o.getRoadId()).collect(Collectors.toList());
Map<String, Object> map = new HashMap<>();
map.put("tenantId", tenantId);
map.put("roadIdList", roadIdList);
List<RoadInformation> roadInformationList = roadInformationMapper.getListByMap(map);
return roadInformationList;
}

}

+ 116
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/section/query/QuerySectionListByDeptIdService.java Ver fichero

@@ -0,0 +1,116 @@
package com.tuoheng.admin.service.section.query;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.conver.DeptConverMapper;
import com.tuoheng.admin.dto.RoadSectionDto;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.road.QueryRoadListByDeptIdCodeEnum;
import com.tuoheng.admin.enums.section.QuerySectionListByDeptIdCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.ShiroUtils;
import com.tuoheng.admin.vo.DeptInfoVo;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 根据部门Id查询路段列表业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2022-11-22
*/
@Slf4j
@Service
public class QuerySectionListByDeptIdService {

@Autowired
private DeptMapper deptMapper;

@Autowired
private RoadInformationMapper roadInformationMapper;

@Autowired
private SectionMapper sectionMapper;

@Autowired
private RoadDeptMapper roadDeptMapper;

@Autowired
private SectionDeptMapper sectionDeptMapper;

public JsonResult getRoadList(String id) {
log.info("进入根据部门Id查询路段列表业务");
String tenantId = ShiroUtils.getTenantId();

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

// 获取该部门下路段列表
List<Section> sectionList = this.getSectionList(tenantId, id);
if (CollectionUtil.isEmpty(sectionList)) {
log.info("根据部门Id查询路段列表业务:路段信息为空");
return JsonResult.error(QuerySectionListByDeptIdCodeEnum.SECTION_LIST_IS_NULL.getCode(), QuerySectionListByDeptIdCodeEnum.SECTION_LIST_IS_NULL.getMsg());
}

return JsonResult.success(sectionList);
}

/**
* 检查参数
*
* @param tenantId
* @param id
* @return
*/
private JsonResult check(String tenantId, String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(QuerySectionListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getCode(), QuerySectionListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getMsg());
}

// 判断部门是否存在
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getTenantId, tenantId)
.eq(Dept::getId, id)
.eq(Dept::getMark, 1));
if (null == dept) {
return JsonResult.error(QuerySectionListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QuerySectionListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(dept);
}

/**
* 查询该部门下路段信息列表
*
* @param tenantId
* @param id
* @return
*/
private List<Section> getSectionList(String tenantId, String id) {
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(new LambdaQueryWrapper<SectionDept>()
.eq(SectionDept::getTenantId, tenantId)
.eq(SectionDept::getDeptId, id));
if (CollectionUtil.isEmpty(sectionDeptList)) {
return null;
}
List<String> sectionIdList = sectionDeptList.stream().map(o -> o.getSectionId()).collect(Collectors.toList());
Map<String, Object> map = new HashMap<>();
map.put("tenantId", tenantId);
map.put("sectionIdList", sectionIdList);
List<Section> sectionList = sectionMapper.getListByMap(map);
return sectionList;
}
}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/DeptTreeVo.java Ver fichero

@@ -37,6 +37,11 @@ public class DeptTreeVo {
*/
private String pid;

/**
* 上级部门名称
*/
private String pname;

/**
* 子部门
*/

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/DeptMapper.xml Ver fichero

@@ -25,6 +25,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
id, tenant_id, name, code, fullname, type, pid, sort, note, create_user, create_time, update_user, update_time, mark
</sql>

<select id="selectAllChildListById" parameterType="String" resultType="java.lang.String">
SELECT id
FROM(
SELECT @ids AS p_ids, (SELECT @ids := GROUP_CONCAT(id) FROM th_dept WHERE FIND_IN_SET(pid, CONVERT(@ids USING utf8) COLLATE utf8_unicode_ci)) AS c_ids, @l := @l+1 AS LEVEL
FROM th_dept, (SELECT @ids := #{id}, @l := 0 ) b
WHERE @ids IS NOT NULL
) u1
JOIN th_dept u2 ON FIND_IN_SET(u2.id, CONVERT(u1.p_ids USING utf8) COLLATE utf8_unicode_ci)
</select>

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

Cargando…
Cancelar
Guardar