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 00000000..156a1dea --- /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 00000000..5f432694 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementVo.java @@ -0,0 +1,17 @@ +package com.bonus.sgzb.material.domain; + +import lombok.Data; + +/** + * @author 10488 + * 协议信息 + */ +@Data +public class AgreementVo { + + /** 协议ID*/ + private Integer agreementId; + + /** 协议编号*/ + private String agreementCode; +} 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 00000000..4e9e7328 --- /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 00000000..6d42b148 --- /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 00000000..b5f0b671 --- /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 00000000..4448430e --- /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 00000000..761aa423 --- /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 00000000..75fd3a31 --- /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 00000000..8f2b720a --- /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 00000000..061412e0 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SelectMapper.xml @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sgzb-ui/src/api/claimAndRefund/receive.js b/sgzb-ui/src/api/claimAndRefund/receive.js index 4e6233ad..ad3b6b4b 100644 --- a/sgzb-ui/src/api/claimAndRefund/receive.js +++ b/sgzb-ui/src/api/claimAndRefund/receive.js @@ -89,7 +89,7 @@ export function getLeaseAuditListAll(query) { // 获取 来往单位 列表 export function getUnitData(params = {}) { return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params, }) @@ -98,7 +98,7 @@ export function getUnitData(params = {}) { // 获取 工程 列表 export function getProData(params = {}) { return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params, }) @@ -116,7 +116,7 @@ export function getDeviceTypeTree(params = {}) { // 根据单位id和工程id 获取 协议id export function getAgreementInfoById(params = {}) { return request({ - url: '/system/select/getAgreementInfoById', + url: '/material/select/getAgreementInfoById', method: 'post', data: params, }) diff --git a/sgzb-ui/src/api/store/newBuy.js b/sgzb-ui/src/api/store/newBuy.js index caf740d2..c7d674e8 100644 --- a/sgzb-ui/src/api/store/newBuy.js +++ b/sgzb-ui/src/api/store/newBuy.js @@ -209,7 +209,7 @@ export function warehousingEntry(query) { // 配件所属上级树 export function getAccessoryTree(data) { return request({ - url: '/system/select/getAccessoryTree', + url: '/material/select/getAccessoryTree', method: 'post', data: data, }) diff --git a/sgzb-ui/src/api/store/poleConfig.js b/sgzb-ui/src/api/store/poleConfig.js index ab086075..1794f387 100644 --- a/sgzb-ui/src/api/store/poleConfig.js +++ b/sgzb-ui/src/api/store/poleConfig.js @@ -5,7 +5,7 @@ const addOrUpdateUrl = '/material/maWhole/addOrUpdate' // 添加 const selectListUrl = '/material/maWhole/selectList' // 查询首页 const selectListByIdUrl = '/material/maWhole/selectListById' // 查询详情 const deleteByIdUrl = '/material/maWhole/deleteById' // 删除 -const treeTypeUrl = '/system/select/getDeviceTypeTree' // 设备树 +const treeTypeUrl = '/material/select/getDeviceTypeTree' // 设备树 const selectListTreeUrl = '/material/maWhole/selectListTree' // 编辑查询 // 物品类型 选择配件 @@ -69,4 +69,4 @@ export function editRequest(data) { method: 'post', data, }) -} \ No newline at end of file +} diff --git a/sgzb-ui/src/api/store/putInStore.js b/sgzb-ui/src/api/store/putInStore.js index 96fb0922..060e1447 100644 --- a/sgzb-ui/src/api/store/putInStore.js +++ b/sgzb-ui/src/api/store/putInStore.js @@ -49,7 +49,7 @@ export function inputByType(data) { // 获取 设备树 export function getDeviceTypeTree(params = {}) { return request({ - url: '/system/select/getDeviceTypeTree', + url: '/material/select/getDeviceTypeTree', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/stquery/backRecord.js b/sgzb-ui/src/api/stquery/backRecord.js index 6c8c87af..1ecfa71b 100644 --- a/sgzb-ui/src/api/stquery/backRecord.js +++ b/sgzb-ui/src/api/stquery/backRecord.js @@ -22,7 +22,7 @@ export function exportList(params = {}){ // 获取 来往单位 列表 export function getUnitData(params = {}){ return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params }) @@ -31,7 +31,7 @@ export function getUnitData(params = {}){ // 获取 工程 列表 export function getProData(params = {}){ return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/stquery/deviceFixQuery.js b/sgzb-ui/src/api/stquery/deviceFixQuery.js index 3052be9f..e80f150f 100644 --- a/sgzb-ui/src/api/stquery/deviceFixQuery.js +++ b/sgzb-ui/src/api/stquery/deviceFixQuery.js @@ -22,7 +22,7 @@ export function exportList(params = {}){ // 获取 来往单位 列表 export function getUnitData(params = {}){ return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params }) @@ -31,7 +31,7 @@ export function getUnitData(params = {}){ // 获取 工程 列表 export function getProData(params = {}){ return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/stquery/deviceInStoreQuery.js b/sgzb-ui/src/api/stquery/deviceInStoreQuery.js index 8f755fce..56e02430 100644 --- a/sgzb-ui/src/api/stquery/deviceInStoreQuery.js +++ b/sgzb-ui/src/api/stquery/deviceInStoreQuery.js @@ -22,7 +22,7 @@ export function exportList(params = {}){ // 获取 来往单位 列表 export function getUnitData(params = {}){ return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params }) @@ -31,7 +31,7 @@ export function getUnitData(params = {}){ // 获取 工程 列表 export function getProData(params = {}){ return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/stquery/deviceScrapQuery.js b/sgzb-ui/src/api/stquery/deviceScrapQuery.js index 1244bc32..4757f349 100644 --- a/sgzb-ui/src/api/stquery/deviceScrapQuery.js +++ b/sgzb-ui/src/api/stquery/deviceScrapQuery.js @@ -22,7 +22,7 @@ export function exportList(params = {}){ // 获取 来往单位 列表 export function getUnitData(params = {}){ return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params }) @@ -31,7 +31,7 @@ export function getUnitData(params = {}){ // 获取 工程 列表 export function getProData(params = {}){ return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/stquery/deviceStatusRecord.js b/sgzb-ui/src/api/stquery/deviceStatusRecord.js index 3ba9ce15..2a5d4afb 100644 --- a/sgzb-ui/src/api/stquery/deviceStatusRecord.js +++ b/sgzb-ui/src/api/stquery/deviceStatusRecord.js @@ -22,7 +22,7 @@ export function exportList(params = {}){ // 获取 来往单位 列表 export function getUnitData(params = {}){ return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params }) @@ -31,7 +31,7 @@ export function getUnitData(params = {}){ // 获取 工程 列表 export function getProData(params = {}){ return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/stquery/projUsingRecord.js b/sgzb-ui/src/api/stquery/projUsingRecord.js index ef98c73c..e25a452b 100644 --- a/sgzb-ui/src/api/stquery/projUsingRecord.js +++ b/sgzb-ui/src/api/stquery/projUsingRecord.js @@ -4,7 +4,7 @@ import request from '@/utils/request' // 获取 来往单位 列表 export function getUnitData(params = {}){ return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params }) @@ -13,7 +13,7 @@ export function getUnitData(params = {}){ // 获取 工程 列表 export function getProData(params = {}){ return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/stquery/stquery.js b/sgzb-ui/src/api/stquery/stquery.js index 8645e8be..fe7fa6df 100644 --- a/sgzb-ui/src/api/stquery/stquery.js +++ b/sgzb-ui/src/api/stquery/stquery.js @@ -22,7 +22,7 @@ export function exportList(params = {}){ // 获取 来往单位 列表 export function getUnitData(params = {}){ return request({ - url: '/system/select/getUnitCbx', + url: '/material/select/getUnitCbx', method: 'post', data: params }) @@ -31,7 +31,7 @@ export function getUnitData(params = {}){ // 获取 工程 列表 export function getProData(params = {}){ return request({ - url: '/system/select/getSectionEngineeringCbx', + url: '/material/select/getSectionEngineeringCbx', method: 'post', data: params }) diff --git a/sgzb-ui/src/api/system/dept.js b/sgzb-ui/src/api/system/dept.js index d6a259e2..60527cd2 100644 --- a/sgzb-ui/src/api/system/dept.js +++ b/sgzb-ui/src/api/system/dept.js @@ -54,7 +54,7 @@ export function delDept(deptId) { // 上级获取 export function apiGetPartTree() { return request({ - url: '/system/select/getPartTree', + url: '/material/select/getPartTree', method: 'post', data:{} })