diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java index 155cbf6..21a624d 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java @@ -23,12 +23,15 @@ import com.hxhq.common.core.web.domain.AjaxResult; import com.hxhq.common.core.web.page.TableDataInfo; import com.hxhq.common.redis.service.RedisService; import com.hxhq.common.security.utils.SecurityUtils; +import com.hxhq.system.api.domain.SysDept; +import com.hxhq.system.service.ISysDeptService; import com.hxhq.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** @@ -70,6 +73,8 @@ public class PublicController extends BaseController { public ICellService cellService; @Autowired public IBacteriaService bacteriaService; + @Autowired + public ISysDeptService sysDeptService; /** @@ -281,4 +286,19 @@ public class PublicController extends BaseController { List list = bacteriaService.queryStudyList(form); return getDataTable(list); } + + /** + * 冰箱列表 + * @return + */ + @GetMapping("/fridgeList") + public TableDataInfo getFridgeList(YqSearchForm form) { + List superiorAndSubordinate = sysDeptService.getSuperiorAndSubordinate(SecurityUtils.getLoginUser().getSysUser().getDeptId()); + List deptIdList = superiorAndSubordinate.stream().map(SysDept::getDeptId).collect(Collectors.toList()); + form.setDeptIdList(deptIdList); + startPage(); + form.setFridge(NormalEnum.yes.getValue()); + List list = yqService.queryList(form); + return getDataTable(list); + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Yq.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Yq.java index a97a92c..4a62739 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Yq.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Yq.java @@ -84,6 +84,16 @@ public class Yq extends MpBaseEntity { @Compare(name = "温层") private String wc; + /** 是否是冰箱 1-否 10-是 */ + private Integer fridge; + + public Integer getFridge() { + return fridge; + } + + public void setFridge(Integer fridge) { + this.fridge = fridge; + } public void setMc(String mc) { this.mc = mc; diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqForm.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqForm.java index 47f9fbd..ff96358 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqForm.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqForm.java @@ -72,6 +72,8 @@ public class YqForm { @Length(max = 500, message = "备注不能超过500字") private String remark; + /** 是否是冰箱 1-否 10-是 */ + private Integer fridge; /** 签名人密码 */ @NotNull(message = "请输入签名人密码") @@ -174,4 +176,12 @@ public class YqForm { public void setBmId(Long bmId) { this.bmId = bmId; } + + public Integer getFridge() { + return fridge; + } + + public void setFridge(Integer fridge) { + this.fridge = fridge; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqSearchForm.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqSearchForm.java index 3c002e0..a9e8163 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqSearchForm.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/yq/YqSearchForm.java @@ -1,5 +1,7 @@ package com.hxhq.business.form.yq; +import java.util.List; + /** 仪器列表搜索 * @author 15881*/ public class YqSearchForm { @@ -22,6 +24,27 @@ public class YqSearchForm { /** 部门名称 */ private String bmMc; + /** 是否是冰箱 1-否 10-是 */ + private Integer fridge; + + private List deptIdList; + + public List getDeptIdList() { + return deptIdList; + } + + public void setDeptIdList(List deptIdList) { + this.deptIdList = deptIdList; + } + + public Integer getFridge() { + return fridge; + } + + public void setFridge(Integer fridge) { + this.fridge = fridge; + } + public String getBmMc() { return bmMc; } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqServiceImpl.java index 55e5bc8..9bf13fc 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/YqServiceImpl.java @@ -8,6 +8,7 @@ import java.util.Map; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hxhq.business.domain.MjyJcgj; @@ -74,6 +75,12 @@ public class YqServiceImpl extends ServiceImpl implements IYqServi if(StringUtils.isNotEmpty(form.getBmMc())) { queryWrapper.like("d.dept_name", form.getBmMc()); } + if(form.getFridge() != null) { + queryWrapper.eq("y.fridge", form.getFridge()); + } + if(CollectionUtils.isNotEmpty(form.getDeptIdList())) { + queryWrapper.in("y.bm_id", form.getDeptIdList()); + } queryWrapper.orderByDesc("y.id"); return baseMapper.queryList(queryWrapper); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysDeptMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysDeptMapper.java index dda23f7..46a7bc4 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysDeptMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysDeptMapper.java @@ -45,6 +45,13 @@ public interface SysDeptMapper public List selectChildrenDeptById(Long deptId); /** + * 根据id数组查询部门 + * @param deptIdList + * @return + */ + public List selectDeptByIdList(@Param("deptIdList") List deptIdList); + + /** * 根据ID查询所有子部门(正常状态) * * @param deptId 部门ID diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysDeptService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysDeptService.java index a080788..d9c194c 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysDeptService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysDeptService.java @@ -121,4 +121,11 @@ public interface ISysDeptService * @return 结果 */ public int deleteDeptById(Long deptId); + + /** + * 获取上下级部门列表 + * @param deptId + * @return + */ + public List getSuperiorAndSubordinate(Long deptId); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java index 08d04fb..5494b24 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java @@ -1,13 +1,17 @@ package com.hxhq.system.service.impl; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; +import cn.hutool.core.util.ArrayUtil; +import com.hxhq.business.enums.dept.DeptTypeEnum; import com.hxhq.system.domain.vo.TreeSelect; import com.hxhq.system.mapper.SysDeptMapper; import com.hxhq.system.mapper.SysRoleMapper; +import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hxhq.common.core.constant.UserConstants; @@ -294,6 +298,34 @@ public class SysDeptServiceImpl implements ISysDeptService return deptMapper.deleteDeptById(deptId); } + @Override + public List getSuperiorAndSubordinate(Long deptId) { + List result = new ArrayList<>(); + SysDept sysDept = deptMapper.selectDeptById(deptId); + if(sysDept.getType() == DeptTypeEnum.dept.getValue()) { + // 当前组织如果是部门,则不需要寻找上级 + result.add(sysDept); + } else { + // 若当前组织不是部门类型,则需要寻找上级的部门 + String ancestors = sysDept.getAncestors(); + String[] parentIdList = ancestors.split(","); + List parentDeptList = deptMapper.selectDeptByIdList(Arrays.stream(parentIdList) + .map(Long::parseLong) + .collect(Collectors.toList())); + for (SysDept dept : parentDeptList) { + if(dept.getType() == DeptTypeEnum.dept.getValue()) { + result.add(dept); + break; + } + } + } + + // 查询所有子部门 + List childrenDeptList = deptMapper.selectChildrenDeptById(deptId); + result.addAll(childrenDeptList); + return result; + } + /** * 递归列表 */ diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml index cdceab0..183923a 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -88,8 +88,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 - - + + + insert into sys_dept( dept_id, parent_id,