From d7e54f74cbe8006db2f6e14a78832d2e9644952b Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Mon, 19 Aug 2024 13:02:06 +0800 Subject: [PATCH] move select to material --- .../material/controller/SelectController.java | 126 ++++++++ .../sgzb/material/domain/AgreementVo.java | 20 ++ .../bonus/sgzb/material/domain/SelectDto.java | 32 ++ .../bonus/sgzb/material/domain/SelectVo.java | 16 + .../bonus/sgzb/material/domain/TreeNode.java | 41 +++ .../sgzb/material/mapper/SelectMapper.java | 193 ++++++++++++ .../sgzb/material/service/SelectService.java | 178 ++++++++++++ .../service/impl/SelectServiceImpl.java | 275 ++++++++++++++++++ .../bonus/sgzb/material/utils/TreeBuild.java | 79 +++++ .../mapper/material/SelectMapper.xml | 218 ++++++++++++++ .../system/controller/SelectController.java | 252 ++++++++-------- 11 files changed, 1304 insertions(+), 126 deletions(-) create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SelectController.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementVo.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectDto.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectVo.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeNode.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SelectMapper.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SelectService.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SelectServiceImpl.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/utils/TreeBuild.java create mode 100644 sgzb-modules/sgzb-material/src/main/resources/mapper/material/SelectMapper.xml diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SelectController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SelectController.java new file mode 100644 index 0000000..156a1de --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SelectController.java @@ -0,0 +1,126 @@ +package com.bonus.sgzb.material.controller; + +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.material.domain.SelectDto; +import com.bonus.sgzb.material.service.SelectService; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author 10488 + * 统一下拉选 + */ +@RestController +@RequestMapping("/select/") +public class SelectController { + + @Resource(name = "SelectService") + private SelectService service; + + @ApiOperation(value = "往来单位下拉选") + @PostMapping("getUnitCbx") + public AjaxResult getUnitData(@RequestBody SelectDto dto) { + return service.getUnitData(dto); + } + + @ApiOperation(value = "工程下拉选") + @PostMapping("getSectionEngineeringCbx") + public AjaxResult getProData(@RequestBody SelectDto dto) { + return service.getProData(dto); + } + + @ApiOperation(value = "机具类型下拉选") + @PostMapping("getMaTypeData") + public AjaxResult getMaTypeData(@RequestBody SelectDto dto){ + return service.getMaTypeData(dto); + } + + @ApiOperation(value = "数据字典下拉选") + @PostMapping("getDictByPidCbx") + public AjaxResult getDictByPidCbx(@RequestBody SelectDto dto){ + return service.getDictByPidCbx(dto); + } + + @ApiOperation(value = "单位树/归属部门/所属上级") + @PostMapping("getDeptTree") + public AjaxResult getDeptTree(@RequestBody SelectDto dto){ + return service.getDeptTree(dto); + } + + @ApiOperation(value = "岗位下拉选") + @PostMapping("getPostCbx") + public AjaxResult getPostCbx(@RequestBody SelectDto dto){ + return service.getPostCbx(dto); + } + + @ApiOperation(value = "角色下拉选") + @PostMapping("getRoleCbx") + public AjaxResult getRoleCbx(@RequestBody SelectDto dto){ + return service.getRoleCbx(dto); + } + + @ApiOperation(value = "单位类型下拉选") + @PostMapping("getUnitTypeCbx") + public AjaxResult getUnitTypeCbx(@RequestBody SelectDto dto){ + return service.getUnitTypeCbx(dto); + } + + @ApiOperation(value = "设备类型树") + @PostMapping("getDeviceTypeTree") + public AjaxResult getDeviceTypeTree(@RequestBody SelectDto dto){ + return service.getDeviceTypeTree(dto); + } + + @ApiOperation(value = "资产属性") + @PostMapping("getAssetAttributesCbx") + public AjaxResult getAssetAttributesCbx(@RequestBody SelectDto dto){ + return service.getAssetAttributesCbx(dto); + } + + @ApiOperation(value = "机具厂家") + @PostMapping("getDeviceFactoryCbx") + public AjaxResult getDeviceFactoryCbx(@RequestBody SelectDto dto){ + return service.getDeviceFactoryCbx(dto); + } + + @ApiOperation(value = "工程项目") + @PostMapping("getProCbx") + public AjaxResult getProCbx(@RequestBody SelectDto dto){ + return service.getProCbx(dto); + } + + @ApiOperation(value = "配件所属上级树") + @PostMapping("getAccessoryTree") + public AjaxResult getAccessoryTree(){ + return service.getAccessoryTree(); + } + + @ApiOperation(value = "配件所属上级树") + @PostMapping("getPartTree") + public AjaxResult getPartTree(@RequestBody SelectDto dto){ + return service.getPartTree(dto); + } + + @ApiOperation(value = "货架") + @PostMapping("getGoodsShelvesCbx") + public AjaxResult getGoodsShelvesCbx(@RequestBody SelectDto dto){ + return service.getGoodsShelvesCbx(dto); + } + + @ApiOperation(value = "用户/维修员/库管员/采购员") + @PostMapping("getUserByRoleIdCbx") + public AjaxResult getUserByRoleIdCbx(@RequestBody SelectDto dto){ + return service.getUserByRoleIdCbx(dto); + } + + @ApiOperation(value = "往来单位id和标段工程id获取协议信息") + @PostMapping("getAgreementInfoById") + public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto){ + return service.getAgreementInfoById(dto); + } +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementVo.java new file mode 100644 index 0000000..cb88fd9 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementVo.java @@ -0,0 +1,20 @@ +package com.bonus.sgzb.material.domain; + +import lombok.Data; + +/** + * @author 10488 + * 协议信息 + */ +@Data +public class AgreementVo { + + /** 协议ID*/ + private Integer agreementId; + + /** 协议编号*/ + private String agreementCode; + + /** 是否结算*/ + private String isSlt; +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectDto.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectDto.java new file mode 100644 index 0000000..4e9e732 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectDto.java @@ -0,0 +1,32 @@ +package com.bonus.sgzb.material.domain; + +import lombok.Data; + +/** + * @author 10488 + */ +@Data +public class SelectDto { + + /** 参数id*/ + private String id; + + /** 2.物品种类 3.设备类型 4.规格型号*/ + private String type; + + /** 字典表 父类值*/ + private String parentValue; + + /** 层级*/ + private String level; + + /** 角色权限字符串*/ + private String roleKey; + + /** 往来单位id*/ + private int unitId; + + /** 标段工程id*/ + private int projectId; + +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectVo.java new file mode 100644 index 0000000..6d42b14 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SelectVo.java @@ -0,0 +1,16 @@ +package com.bonus.sgzb.material.domain; + +import lombok.Data; + +/** + * @author 10488 + */ +@Data +public class SelectVo { + + /** id*/ + private long id; + + /** 名称*/ + private String name; +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeNode.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeNode.java new file mode 100644 index 0000000..b5f0b67 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeNode.java @@ -0,0 +1,41 @@ +package com.bonus.sgzb.material.domain; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author 10488 + * 下拉树-实体类 + */ +@Data +public class TreeNode { + + private long id; + + private String label; + + private long parentId; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private String level; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private String unitName; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private String companyId; + + private String code; + + private float num; + + private String modelCode; + + private String manageType; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children = new ArrayList<>(); +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SelectMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SelectMapper.java new file mode 100644 index 0000000..4448430 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SelectMapper.java @@ -0,0 +1,193 @@ +package com.bonus.sgzb.material.mapper; + +import com.bonus.sgzb.material.domain.AgreementVo; +import com.bonus.sgzb.material.domain.SelectDto; +import com.bonus.sgzb.material.domain.SelectVo; +import com.bonus.sgzb.material.domain.TreeNode; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author 10488 + * 统一下拉选 + */ +@Repository("SelectMapper") +public interface SelectMapper { + /** + * 往来单位下拉选 + * @param dto + * @return List + * @description 往来单位 + * @author cwchen + * @date 2023/12/20 14:23 + */ + List getUnitData(SelectDto dto); + + /** + * 工程下拉选 + * @param dto + * @return List + * @description 工程 + * @author cwchen + * @date 2023/12/20 15:05 + */ + List getProData(SelectDto dto); + + /** + * 机具类型下拉选 + * @param dto + * @return List + * @description 机具类型 + * @author cwchen + * @date 2023/12/20 16:02 + */ + List getMaTypeData(SelectDto dto); + + /** + * 数据字典下拉选 + * @param dto + * @return List + * @description 数据字典下拉选 + * @author cwchen + * @date 2023/12/20 16:23 + */ + List getDictByPidCbx(SelectDto dto); + + /** + * 单位树/归属部门/所属上级 + * @param dto + * @return List + * @description 单位树/归属部门/所属上级 + * @author cwchen + * @date 2023/12/20 17:10 + */ + List getDeptTree(SelectDto dto); + + /** + * 岗位下拉选 + * @param dto + * @return List + * @description 岗位下拉选 + * @author cwchen + * @date 2023/12/20 17:50 + */ + List getPostCbx(SelectDto dto); + + /** + * 角色下拉选 + * @param dto + * @return List + * @description 角色下拉选 + * @author cwchen + * @date 2023/12/20 17:56 + */ + List getRoleCbx(SelectDto dto); + + /** + * 单位类型下拉选 + * @param dto + * @return List + * @description 单位类型下拉选 + * @author cwchen + * @date 2023/12/20 18:01 + */ + List getUnitTypeCbx(SelectDto dto); + + /** + * 设备类型树 + * @param dto + * @return List + * @description 设备类型树 + * @author cwchen + * @date 2023/12/20 18:15 + */ + List getDeviceTypeTree(SelectDto dto); + + /** + * 资产属性 + * @param dto + * @return List + * @description 资产属性 + * @author cwchen + * @date 2023/12/20 19:48 + */ + List getAssetAttributesCbx(SelectDto dto); + + /** + * 机具厂家 + * @param dto + * @return List + * @description 机具厂家 + * @author cwchen + * @date 2023/12/20 19:57 + */ + List getDeviceFactoryCbx(SelectDto dto); + + /** + * 工程项目 + * @param dto + * @return List + * @description 工程项目 + * @author cwchen + * @date 2023/12/20 20:01 + */ + List getProCbx(SelectDto dto); + + /** + * 配件所属上级树 + * @param + * @return List + * @description 配件所属上级树 + * @author cwchen + * @date 2023/12/20 20:26 + */ + List getAccessoryTree(); + + /** + * 货架 + * @param dto + * @return List + * @description 货架 + * @author cwchen + * @date 2023/12/20 20:36 + */ + List getGoodsShelvesCbx(SelectDto dto); + + /** + * 用户/维修员/库管员/采购员-下拉选 + * @param dto + * @return List + * @description 用户/维修员/库管员/采购员-下拉选 + * @author cwchen + * @date 2023/12/20 20:54 + */ + List getUserByRoleIdCbxSelect(SelectDto dto); + + /** + * 用户/维修员/库管员/采购员-树 + * @param dto + * @return List + * @description 用户/维修员/库管员/采购员-树 + * @author cwchen + * @date 2023/12/20 21:02 + */ + List getUserByRoleIdCbxTree(SelectDto dto); + + /** + * 往来单位id和标段工程id获取协议信息 + * @param dto + * @return AgreementVo + * @description 往来单位id和标段工程id获取协议信息 + * @author cwchen + * @date 2023/12/21 10:53 + */ + List getAgreementInfoById(SelectDto dto); + + /** + * 配件所属上级树 + * @param dto + * @return List + */ + List getPartTree(SelectDto dto); +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SelectService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SelectService.java new file mode 100644 index 0000000..761aa42 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SelectService.java @@ -0,0 +1,178 @@ +package com.bonus.sgzb.material.service; + +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.material.domain.SelectDto; + +/** + * @author 10488 + * 统一下拉选 + */ +public interface SelectService { + + /** + * 往来单位 + * @param dto + * @return AjaxResult + * @description 往来单位 + * @author cwchen + * @date 2023/12/20 14:20 + */ + AjaxResult getUnitData(SelectDto dto); + + /** + * 工程 + * @param dto + * @return AjaxResult + * @description 工程 + * @author cwchen + * @date 2023/12/20 15:04 + */ + AjaxResult getProData(SelectDto dto); + + /** + * 机具类型 + * @param dto + * @return AjaxResult + * @description 机具类型 + * @author cwchen + * @date 2023/12/20 16:02 + */ + AjaxResult getMaTypeData(SelectDto dto); + + /** + * 数据字典下拉选 + * @param dto + * @return AjaxResult + * @description 数据字典下拉选 + * @author cwchen + * @date 2023/12/20 16:22 + */ + AjaxResult getDictByPidCbx(SelectDto dto); + + /** + * 单位树/归属部门/所属上级 + * @param dto + * @return AjaxResult + * @description 单位树/归属部门/所属上级 + * @author cwchen + * @date 2023/12/20 16:36 + */ + AjaxResult getDeptTree(SelectDto dto); + + /** + * 岗位下拉树 + * @param dto + * @return AjaxResult + * @description 岗位下拉树 + * @author cwchen + * @date 2023/12/20 17:45 + */ + AjaxResult getPostCbx(SelectDto dto); + + /** + * 角色下拉选 + * @param dto + * @return AjaxResult + * @description 角色下拉选 + * @author cwchen + * @date 2023/12/20 17:56 + */ + AjaxResult getRoleCbx(SelectDto dto); + + /** + * 单位类型下拉选 + * @param dto + * @return AjaxResult + * @description 单位类型下拉选 + * @author cwchen + * @date 2023/12/20 18:00 + */ + AjaxResult getUnitTypeCbx(SelectDto dto); + + /** + * 设备类型树 + * @param dto + * @return AjaxResult + * @description 设备类型树 + * @author cwchen + * @date 2023/12/20 18:14 + */ + AjaxResult getDeviceTypeTree(SelectDto dto); + + /** + * 资产属性 + * @param dto + * @return AjaxResult + * @description 资产属性 + * @author cwchen + * @date 2023/12/20 19:47 + */ + AjaxResult getAssetAttributesCbx(SelectDto dto); + + /** + * 机具厂家 + * @param dto + * @return AjaxResult + * @description 机具厂家 + * @author cwchen + * @date 2023/12/20 19:56 + */ + AjaxResult getDeviceFactoryCbx(SelectDto dto); + + /** + * 工程项目 + * @param dto + * @return AjaxResult + * @description 工程项目 + * @author cwchen + * @date 2023/12/20 20:01 + */ + AjaxResult getProCbx(SelectDto dto); + + /** + * 配件所属上级树 + * @param + * @return AjaxResult + * @description 配件所属上级树 + * @author cwchen + * @date 2023/12/20 20:25 + */ + AjaxResult getAccessoryTree(); + + /** + * 货架 + * @param dto + * @return AjaxResult + * @description 货架 + * @author cwchen + * @date 2023/12/20 20:36 + */ + AjaxResult getGoodsShelvesCbx(SelectDto dto); + + /** + * 用户/维修员/库管员/采购员 + * @param dto + * @return AjaxResult + * @description 用户/维修员/库管员/采购员 + * @author cwchen + * @date 2023/12/20 20:48 + */ + AjaxResult getUserByRoleIdCbx(SelectDto dto); + + /** + * 往来单位id和标段工程id获取协议信息 + * @param dto + * @return AjaxResult + * @description 往来单位id和标段工程id获取协议信息 + * @author cwchen + * @date 2023/12/21 10:47 + */ + AjaxResult getAgreementInfoById(SelectDto dto); + + /** + * 配件所属上级树 + * @param dto + * @return AjaxResult + */ + AjaxResult getPartTree(SelectDto dto); +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SelectServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SelectServiceImpl.java new file mode 100644 index 0000000..75fd3a3 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SelectServiceImpl.java @@ -0,0 +1,275 @@ +package com.bonus.sgzb.material.service.impl; + +import com.bonus.sgzb.common.core.utils.GlobalConstants; +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.material.domain.AgreementVo; +import com.bonus.sgzb.material.domain.SelectDto; +import com.bonus.sgzb.material.domain.SelectVo; +import com.bonus.sgzb.material.domain.TreeNode; +import com.bonus.sgzb.material.mapper.SelectMapper; +import com.bonus.sgzb.material.service.SelectService; +import com.bonus.sgzb.material.utils.TreeBuild; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @author 10488 + * 统一下拉选 + */ +@Service("SelectService") +@Slf4j +public class SelectServiceImpl implements SelectService { + + @Resource(name = "SelectMapper") + private SelectMapper mapper; + + @Override + public AjaxResult getUnitData(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getUnitData(dto); + } catch (Exception e) { + log.error("往来单位-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getProData(SelectDto dto) { + try { + List list = mapper.getProData(dto); + list.removeIf(item -> item == null); + return AjaxResult.success(list); + } catch (Exception e) { + log.error("工程-查询失败", e); + } + return AjaxResult.success(); + } + + @Override + public AjaxResult getMaTypeData(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getMaTypeData(dto); + } catch (Exception e) { + log.error("机具类型-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getDictByPidCbx(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getDictByPidCbx(dto); + } catch (Exception e) { + log.error("数据字典-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getDeptTree(SelectDto dto) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = mapper.getDeptTree(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("单位树/归属部门/所属上级-查询失败", e); + } + return AjaxResult.success(groupList); + } + + @Override + public AjaxResult getPostCbx(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getPostCbx(dto); + } catch (Exception e) { + log.error("岗位下拉选-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getRoleCbx(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getRoleCbx(dto); + } catch (Exception e) { + log.error("角色下拉选-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getUnitTypeCbx(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getUnitTypeCbx(dto); + } catch (Exception e) { + log.error("单位类型下拉选-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getDeviceTypeTree(SelectDto dto) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = mapper.getDeviceTypeTree(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("单位树/归属部门/所属上级-查询失败", e); + } + return AjaxResult.success(groupList); + } + + @Override + public AjaxResult getAssetAttributesCbx(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getAssetAttributesCbx(dto); + } catch (Exception e) { + log.error("资产属性-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getDeviceFactoryCbx(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getDeviceFactoryCbx(dto); + } catch (Exception e) { + log.error("机具厂家-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getProCbx(SelectDto dto) { + List list = new ArrayList<>(); + try { + list = mapper.getProCbx(dto); + } catch (Exception e) { + log.error("工程项目-查询失败", e); + } + return AjaxResult.success(list); + } + + @Override + public AjaxResult getAccessoryTree() { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = mapper.getAccessoryTree(); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("配件所属上级树-查询失败", e); + } + return AjaxResult.success(groupList); + } + + @Override + public AjaxResult getPartTree(SelectDto dto) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = mapper.getPartTree(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("配件所属上级树-查询失败", e); + } + return AjaxResult.success(groupList); + } + + @Override + public AjaxResult getGoodsShelvesCbx(SelectDto dto) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = mapper.getGoodsShelvesCbx(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("货架-查询失败", e); + } + return AjaxResult.success(groupList); + } + + @Override + public AjaxResult getUserByRoleIdCbx(SelectDto dto) { + try { + if (Objects.equals(GlobalConstants.STRING_1, dto.getType())) { + // 用户/维修员/库管员/采购员-下拉选 + List list = new ArrayList<>(); + list = mapper.getUserByRoleIdCbxSelect(dto); + return AjaxResult.success(list); + } else if (Objects.equals(GlobalConstants.STRING_2, dto.getType())) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + // 用户/维修员/库管员/采购员-树 + list = mapper.getUserByRoleIdCbxTree(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + return AjaxResult.success(groupList); + } + } catch (Exception e) { + log.error("用户/维修员/库管员/采购员-查询失败", e); + } + return AjaxResult.success(null); + } + + @Override + public AjaxResult getAgreementInfoById(SelectDto dto) { + AgreementVo vo = new AgreementVo(); + try { + List list = mapper.getAgreementInfoById(dto); + if (CollectionUtils.isNotEmpty(list)) { + vo = list.get(0); + } + } catch (Exception e) { + log.error("往来单位id和标段工程id获取协议信息", e); + } + return AjaxResult.success(vo); + } + + +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/utils/TreeBuild.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/utils/TreeBuild.java new file mode 100644 index 0000000..8f2b720 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/utils/TreeBuild.java @@ -0,0 +1,79 @@ +package com.bonus.sgzb.material.utils; + +import com.bonus.sgzb.material.domain.TreeNode; + +import java.util.ArrayList; +import java.util.List; + +/** + * BuildTree 构建树形结构 + * @author 10488 + */ +public class TreeBuild { + + public List nodeList = new ArrayList<>(); + + /** + * 构造方法 + * @param nodeList 将数据集合赋值给nodeList,即所有数据作为所有节点。 + */ + public TreeBuild(List nodeList){ + this.nodeList = nodeList; + } + + /** + * 获取需构建的所有根节点(顶级节点) "0" + * @return 所有根节点List集合 + */ + public List getRootNode(){ + // 保存所有根节点(所有根节点的数据) + List rootNodeList = new ArrayList<>(); + // treeNode:查询出的每一条数据(节点) + for (TreeNode treeNode : nodeList){ + // 判断当前节点是否为根节点,此处注意:若parentId类型是String,则要采用equals()方法判断。 + if (0 == treeNode.getParentId()) { + // 是,添加 + rootNodeList.add(treeNode); + } + } + return rootNodeList; + } + + /** + * 根据每一个顶级节点(根节点)进行构建树形结构 + * @return 构建整棵树 + */ + public List buildTree(){ + // treeNodes:保存一个顶级节点所构建出来的完整树形 + List treeNodes = new ArrayList(); + // getRootNode():获取所有的根节点 + for (TreeNode treeRootNode : getRootNode()) { + // 将顶级节点进行构建子树 + treeRootNode = buildChildTree(treeRootNode); + // 完成一个顶级节点所构建的树形,增加进来 + treeNodes.add(treeRootNode); + } + return treeNodes; + } + + /** + * 递归-----构建子树形结构 + * @param pNode 根节点(顶级节点) + * @return 整棵树 + */ + public TreeNode buildChildTree(TreeNode pNode){ + List childTree = new ArrayList(); + // nodeList:所有节点集合(所有数据) + for (TreeNode treeNode : nodeList) { + // 判断当前节点的父节点ID是否等于根节点的ID,即当前节点为其下的子节点 + if (treeNode.getParentId() == pNode.getId()) { + // 再递归进行判断当前节点的情况,调用自身方法 + childTree.add(buildChildTree(treeNode)); + } + } + // for循环结束,即节点下没有任何节点,树形构建结束,设置树结果 + pNode.setChildren(childTree); + return pNode; + } + +} diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SelectMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SelectMapper.xml new file mode 100644 index 0000000..b3f4991 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SelectMapper.xml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SelectController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SelectController.java index e70ae20..736c8f6 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SelectController.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SelectController.java @@ -1,126 +1,126 @@ -package com.bonus.sgzb.system.controller; - -import com.bonus.sgzb.common.core.web.domain.AjaxResult; -import com.bonus.sgzb.system.domain.SelectDto; -import com.bonus.sgzb.system.service.SelectService; -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -/** - * @author 10488 - * 统一下拉选 - */ -@RestController -@RequestMapping("/select/") -public class SelectController { - - @Resource(name = "SelectService") - private SelectService service; - - @ApiOperation(value = "往来单位下拉选") - @PostMapping("getUnitCbx") - public AjaxResult getUnitData(@RequestBody SelectDto dto) { - return service.getUnitData(dto); - } - - @ApiOperation(value = "工程下拉选") - @PostMapping("getSectionEngineeringCbx") - public AjaxResult getProData(@RequestBody SelectDto dto) { - return service.getProData(dto); - } - - @ApiOperation(value = "机具类型下拉选") - @PostMapping("getMaTypeData") - public AjaxResult getMaTypeData(@RequestBody SelectDto dto){ - return service.getMaTypeData(dto); - } - - @ApiOperation(value = "数据字典下拉选") - @PostMapping("getDictByPidCbx") - public AjaxResult getDictByPidCbx(@RequestBody SelectDto dto){ - return service.getDictByPidCbx(dto); - } - - @ApiOperation(value = "单位树/归属部门/所属上级") - @PostMapping("getDeptTree") - public AjaxResult getDeptTree(@RequestBody SelectDto dto){ - return service.getDeptTree(dto); - } - - @ApiOperation(value = "岗位下拉选") - @PostMapping("getPostCbx") - public AjaxResult getPostCbx(@RequestBody SelectDto dto){ - return service.getPostCbx(dto); - } - - @ApiOperation(value = "角色下拉选") - @PostMapping("getRoleCbx") - public AjaxResult getRoleCbx(@RequestBody SelectDto dto){ - return service.getRoleCbx(dto); - } - - @ApiOperation(value = "单位类型下拉选") - @PostMapping("getUnitTypeCbx") - public AjaxResult getUnitTypeCbx(@RequestBody SelectDto dto){ - return service.getUnitTypeCbx(dto); - } - - @ApiOperation(value = "设备类型树") - @PostMapping("getDeviceTypeTree") - public AjaxResult getDeviceTypeTree(@RequestBody SelectDto dto){ - return service.getDeviceTypeTree(dto); - } - - @ApiOperation(value = "资产属性") - @PostMapping("getAssetAttributesCbx") - public AjaxResult getAssetAttributesCbx(@RequestBody SelectDto dto){ - return service.getAssetAttributesCbx(dto); - } - - @ApiOperation(value = "机具厂家") - @PostMapping("getDeviceFactoryCbx") - public AjaxResult getDeviceFactoryCbx(@RequestBody SelectDto dto){ - return service.getDeviceFactoryCbx(dto); - } - - @ApiOperation(value = "工程项目") - @PostMapping("getProCbx") - public AjaxResult getProCbx(@RequestBody SelectDto dto){ - return service.getProCbx(dto); - } - - @ApiOperation(value = "配件所属上级树") - @PostMapping("getAccessoryTree") - public AjaxResult getAccessoryTree(){ - return service.getAccessoryTree(); - } - - @ApiOperation(value = "配件所属上级树") - @PostMapping("getPartTree") - public AjaxResult getPartTree(@RequestBody SelectDto dto){ - return service.getPartTree(dto); - } - - @ApiOperation(value = "货架") - @PostMapping("getGoodsShelvesCbx") - public AjaxResult getGoodsShelvesCbx(@RequestBody SelectDto dto){ - return service.getGoodsShelvesCbx(dto); - } - - @ApiOperation(value = "用户/维修员/库管员/采购员") - @PostMapping("getUserByRoleIdCbx") - public AjaxResult getUserByRoleIdCbx(@RequestBody SelectDto dto){ - return service.getUserByRoleIdCbx(dto); - } - - @ApiOperation(value = "往来单位id和标段工程id获取协议信息") - @PostMapping("getAgreementInfoById") - public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto){ - return service.getAgreementInfoById(dto); - } -} +//package com.bonus.sgzb.system.controller; +// +//import com.bonus.sgzb.common.core.web.domain.AjaxResult; +//import com.bonus.sgzb.system.domain.SelectDto; +//import com.bonus.sgzb.system.service.SelectService; +//import io.swagger.annotations.ApiOperation; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +// +//import javax.annotation.Resource; +// +///** +// * @author 10488 +// * 统一下拉选 +// */ +//@RestController +//@RequestMapping("/select/") +//public class SelectController { +// +// @Resource(name = "SelectService") +// private SelectService service; +// +// @ApiOperation(value = "往来单位下拉选") +// @PostMapping("getUnitCbx") +// public AjaxResult getUnitData(@RequestBody SelectDto dto) { +// return service.getUnitData(dto); +// } +// +// @ApiOperation(value = "工程下拉选") +// @PostMapping("getSectionEngineeringCbx") +// public AjaxResult getProData(@RequestBody SelectDto dto) { +// return service.getProData(dto); +// } +// +// @ApiOperation(value = "机具类型下拉选") +// @PostMapping("getMaTypeData") +// public AjaxResult getMaTypeData(@RequestBody SelectDto dto){ +// return service.getMaTypeData(dto); +// } +// +// @ApiOperation(value = "数据字典下拉选") +// @PostMapping("getDictByPidCbx") +// public AjaxResult getDictByPidCbx(@RequestBody SelectDto dto){ +// return service.getDictByPidCbx(dto); +// } +// +// @ApiOperation(value = "单位树/归属部门/所属上级") +// @PostMapping("getDeptTree") +// public AjaxResult getDeptTree(@RequestBody SelectDto dto){ +// return service.getDeptTree(dto); +// } +// +// @ApiOperation(value = "岗位下拉选") +// @PostMapping("getPostCbx") +// public AjaxResult getPostCbx(@RequestBody SelectDto dto){ +// return service.getPostCbx(dto); +// } +// +// @ApiOperation(value = "角色下拉选") +// @PostMapping("getRoleCbx") +// public AjaxResult getRoleCbx(@RequestBody SelectDto dto){ +// return service.getRoleCbx(dto); +// } +// +// @ApiOperation(value = "单位类型下拉选") +// @PostMapping("getUnitTypeCbx") +// public AjaxResult getUnitTypeCbx(@RequestBody SelectDto dto){ +// return service.getUnitTypeCbx(dto); +// } +// +// @ApiOperation(value = "设备类型树") +// @PostMapping("getDeviceTypeTree") +// public AjaxResult getDeviceTypeTree(@RequestBody SelectDto dto){ +// return service.getDeviceTypeTree(dto); +// } +// +// @ApiOperation(value = "资产属性") +// @PostMapping("getAssetAttributesCbx") +// public AjaxResult getAssetAttributesCbx(@RequestBody SelectDto dto){ +// return service.getAssetAttributesCbx(dto); +// } +// +// @ApiOperation(value = "机具厂家") +// @PostMapping("getDeviceFactoryCbx") +// public AjaxResult getDeviceFactoryCbx(@RequestBody SelectDto dto){ +// return service.getDeviceFactoryCbx(dto); +// } +// +// @ApiOperation(value = "工程项目") +// @PostMapping("getProCbx") +// public AjaxResult getProCbx(@RequestBody SelectDto dto){ +// return service.getProCbx(dto); +// } +// +// @ApiOperation(value = "配件所属上级树") +// @PostMapping("getAccessoryTree") +// public AjaxResult getAccessoryTree(){ +// return service.getAccessoryTree(); +// } +// +// @ApiOperation(value = "配件所属上级树") +// @PostMapping("getPartTree") +// public AjaxResult getPartTree(@RequestBody SelectDto dto){ +// return service.getPartTree(dto); +// } +// +// @ApiOperation(value = "货架") +// @PostMapping("getGoodsShelvesCbx") +// public AjaxResult getGoodsShelvesCbx(@RequestBody SelectDto dto){ +// return service.getGoodsShelvesCbx(dto); +// } +// +// @ApiOperation(value = "用户/维修员/库管员/采购员") +// @PostMapping("getUserByRoleIdCbx") +// public AjaxResult getUserByRoleIdCbx(@RequestBody SelectDto dto){ +// return service.getUserByRoleIdCbx(dto); +// } +// +// @ApiOperation(value = "往来单位id和标段工程id获取协议信息") +// @PostMapping("getAgreementInfoById") +// public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto){ +// return service.getAgreementInfoById(dto); +// } +//}