护理单元表修改调整对应代码
This commit is contained in:
parent
b0261bc819
commit
545573e588
|
@ -1,147 +0,0 @@
|
||||||
package com.nu.modules.institution.controller;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
import com.nu.modules.institution.model.InstitutionAreaTreeModel;
|
|
||||||
import com.nu.modules.institution.service.IInstitutionAreaService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构表 前端控制器
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @Author: 曹磊 @Since: 2025-03-25
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/institutionArea")
|
|
||||||
@Slf4j
|
|
||||||
public class InstitutionAreaController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IInstitutionAreaService service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 异步查询机构list
|
|
||||||
* @param parentId 父节点 异步加载时传递
|
|
||||||
* @param primaryKey 主键字段(id或者orgCode)
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@RequestMapping(value = "/queryTreeSync", method = RequestMethod.GET)
|
|
||||||
public Result<List<InstitutionAreaTreeModel>> queryTreeSync(@RequestParam(name = "pid", required = false) String parentId, @RequestParam(name = "primaryKey", required = false) String primaryKey) {
|
|
||||||
Result<List<InstitutionAreaTreeModel>> result = new Result<>();
|
|
||||||
try {
|
|
||||||
List<InstitutionAreaTreeModel> list = service.queryTreeListByPid(parentId,primaryKey);
|
|
||||||
result.setResult(list);
|
|
||||||
result.setSuccess(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(),e);
|
|
||||||
result.setSuccess(false);
|
|
||||||
result.setMessage("查询失败");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加新数据 添加用户新建的机构对象数据,并保存到数据库
|
|
||||||
*
|
|
||||||
* @param InstitutionArea
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
||||||
public Result<InstitutionArea> add(@RequestBody InstitutionArea InstitutionArea, HttpServletRequest request) {
|
|
||||||
Result<InstitutionArea> result = new Result<InstitutionArea>();
|
|
||||||
String username = JwtUtil.getUserNameByToken(request);
|
|
||||||
try {
|
|
||||||
InstitutionArea.setCreateBy(username);
|
|
||||||
service.saveInstData(InstitutionArea, username);
|
|
||||||
result.success("添加成功!");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(),e);
|
|
||||||
result.error500("操作失败");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑数据 编辑机构的部分数据,并保存到数据库
|
|
||||||
*
|
|
||||||
* @param InstitutionArea
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
||||||
public Result<InstitutionArea> edit(@RequestBody InstitutionArea InstitutionArea, HttpServletRequest request) {
|
|
||||||
String username = JwtUtil.getUserNameByToken(request);
|
|
||||||
InstitutionArea.setUpdateBy(username);
|
|
||||||
Result<InstitutionArea> result = new Result<InstitutionArea>();
|
|
||||||
InstitutionArea InstitutionAreaEntity = service.getById(InstitutionArea.getId());
|
|
||||||
if (InstitutionAreaEntity == null) {
|
|
||||||
result.error500("未找到对应实体");
|
|
||||||
} else {
|
|
||||||
boolean ok = service.updateInstDataById(InstitutionArea, username);
|
|
||||||
if (ok) {
|
|
||||||
result.success("修改成功!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
* @param institutionArea
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping(value = "/delete")
|
|
||||||
public Result<String> delete(@RequestBody InstitutionArea institutionArea){
|
|
||||||
InstitutionArea entity = service.getById(institutionArea.getId());
|
|
||||||
if(entity==null) {
|
|
||||||
return Result.error("未找到对应实体");
|
|
||||||
}else {
|
|
||||||
return service.deleteInst(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构搜索功能方法,根据关键字模糊搜索相关机构
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param keyWord
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
|
|
||||||
public Result<List<InstitutionAreaTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) {
|
|
||||||
Result<List<InstitutionAreaTreeModel>> result = new Result<List<InstitutionAreaTreeModel>>();
|
|
||||||
List<InstitutionAreaTreeModel> treeList = this.service.searchByKeyWord(keyWord);
|
|
||||||
if (treeList == null || treeList.size() == 0) {
|
|
||||||
result.setSuccess(false);
|
|
||||||
result.setMessage("未查询匹配数据!");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result.setResult(treeList);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有子区域信息
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("queryChildrenByParentId")
|
|
||||||
public Result<List<InstitutionArea>> queryChildrenByParentId(@RequestParam(name = "pid", required = false) String parentId) {
|
|
||||||
Result<List<InstitutionArea>> result = new Result<>();
|
|
||||||
LambdaQueryWrapper<InstitutionArea> query = new LambdaQueryWrapper<InstitutionArea>();
|
|
||||||
query.orderByAsc(InstitutionArea::getInstName);
|
|
||||||
query.eq(InstitutionArea::getParentId,parentId);
|
|
||||||
List<InstitutionArea> ls = this.service.list(query);
|
|
||||||
result.setSuccess(true);
|
|
||||||
result.setResult(ls);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
package com.nu.modules.institution.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.jeecg.common.aspect.annotation.Dict;
|
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构区域表
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @Author 曹磊
|
|
||||||
* @Since 2025-03-25
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("nu_admin_institution_area")
|
|
||||||
public class InstitutionArea implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**ID*/
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
|
||||||
private String id;
|
|
||||||
/**父机构ID*/
|
|
||||||
private String parentId;
|
|
||||||
/**机构/部门名称*/
|
|
||||||
@Excel(name="机构/区域名称",width=15)
|
|
||||||
private String instName;
|
|
||||||
/**英文名*/
|
|
||||||
@Excel(name="英文名",width=15)
|
|
||||||
private String instNameEn;
|
|
||||||
/**缩写*/
|
|
||||||
private String instNameAbbr;
|
|
||||||
/**排序*/
|
|
||||||
@Excel(name="排序",width=15)
|
|
||||||
private Integer instOrder;
|
|
||||||
/**描述*/
|
|
||||||
@Excel(name="描述",width=15)
|
|
||||||
private String description;
|
|
||||||
/**机构类别 1=机构,2=区域*/
|
|
||||||
@Excel(name="机构区域类别",width=15,dicCode="inst_category")
|
|
||||||
private String orgCategory;
|
|
||||||
/**机构类型 1一级部门 2子部门*/
|
|
||||||
private String orgType;
|
|
||||||
/**机构编码*/
|
|
||||||
@Excel(name="机构编码",width=15)
|
|
||||||
private String orgCode;
|
|
||||||
/**手机号*/
|
|
||||||
@Excel(name="手机号",width=15)
|
|
||||||
private String mobile;
|
|
||||||
/**地址*/
|
|
||||||
@Excel(name="地址",width=15)
|
|
||||||
private String address;
|
|
||||||
/**状态(1启用,0不启用)*/
|
|
||||||
@Dict(dicCode = "depart_status")
|
|
||||||
private String status;
|
|
||||||
/**删除状态(0,正常,1已删除)*/
|
|
||||||
@Dict(dicCode = "del_flag")
|
|
||||||
private String delFlag;
|
|
||||||
/**创建人*/
|
|
||||||
private String createBy;
|
|
||||||
/**创建日期*/
|
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date createTime;
|
|
||||||
/**更新人*/
|
|
||||||
private String updateBy;
|
|
||||||
/**更新日期*/
|
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date updateTime;
|
|
||||||
/**租户ID*/
|
|
||||||
private Integer tenantId;
|
|
||||||
/**是否有叶子节点: 1是0否*/
|
|
||||||
private Integer izLeaf;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
package com.nu.modules.institution.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.apache.ibatis.annotations.Update;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构 Mapper 接口
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @Author: 曹磊
|
|
||||||
* @Since: 2025-03-25
|
|
||||||
*/
|
|
||||||
public interface InstitutionAreaMapper extends BaseMapper<InstitutionArea> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据parent_id查询下级区域
|
|
||||||
* @param parentId 父id
|
|
||||||
* @return List<InstitutionArea>
|
|
||||||
*/
|
|
||||||
List<InstitutionArea> queryTreeListByPid(@Param("parentId") String parentId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id下级区域数量
|
|
||||||
* @param parentId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Select("SELECT count(*) FROM nu_admin_institution_area where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}")
|
|
||||||
Integer queryCountByPid(@Param("parentId")String parentId);
|
|
||||||
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
|
||||||
@Select("SELECT * FROM nu_admin_institution_area where id = #{id,jdbcType=VARCHAR}")
|
|
||||||
InstitutionArea getInstById(@Param("id") String id);
|
|
||||||
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
|
||||||
List<InstitutionArea> getMaxCodeInst(@Param("page") Page<InstitutionArea> page, @Param("parentId") String parentId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改部门状态字段: 是否子节点
|
|
||||||
* @param id 部门id
|
|
||||||
* @param leaf 叶子节点
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
@Update("UPDATE nu_admin_institution_area SET iz_leaf=#{leaf} WHERE id = #{id}")
|
|
||||||
int setMainLeaf(@Param("id") String id, @Param("leaf") Integer leaf);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.nu.modules.institution.mapper.InstitutionAreaMapper">
|
|
||||||
|
|
||||||
<!--根据parent_id查询下级区域-->
|
|
||||||
<select id="queryTreeListByPid" parameterType="Object" resultType="com.nu.modules.institution.entity.InstitutionArea">
|
|
||||||
SELECT * FROM nu_admin_institution_area where del_flag = '0'
|
|
||||||
<choose>
|
|
||||||
<when test="parentId != null and parentId != ''">
|
|
||||||
AND parent_id = #{parentId,jdbcType=VARCHAR}
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
AND parent_id is null or parent_id=''
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
order by inst_order
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!--获取机构orgCode最大值的机构信息-->
|
|
||||||
<select id="getMaxCodeInst" resultType="com.nu.modules.institution.entity.InstitutionArea">
|
|
||||||
SELECT * FROM nu_admin_institution_area
|
|
||||||
WHERE
|
|
||||||
<choose>
|
|
||||||
<when test="parentId != null and parentId != ''">
|
|
||||||
parent_id = #{parentId}
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
parent_id IS NULL OR parent_id=''
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
ORDER BY org_code DESC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
|
|
@ -1,98 +0,0 @@
|
||||||
package com.nu.modules.institution.model;
|
|
||||||
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构表 封装树结构的机构的名称的实体类
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @Author Steve
|
|
||||||
* @Since 2019-01-22
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class InstitutionAreaIdModel implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 机构名称
|
|
||||||
*/
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
List<InstitutionAreaIdModel> children = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将SysDepartTreeModel的部分数据放在该对象当中
|
|
||||||
* @param treeModel
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public InstitutionAreaIdModel convert(InstitutionAreaTreeModel treeModel) {
|
|
||||||
this.key = treeModel.getId();
|
|
||||||
this.value = treeModel.getId();
|
|
||||||
this.title = treeModel.getInstName();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 该方法为用户机构的实现类所使用
|
|
||||||
* @param inst
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public InstitutionAreaIdModel convertByUserDepart(InstitutionArea inst) {
|
|
||||||
this.key = inst.getId();
|
|
||||||
this.value = inst.getId();
|
|
||||||
this.title = inst.getInstName();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InstitutionAreaIdModel> getChildren() {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChildren(List<InstitutionAreaIdModel> children) {
|
|
||||||
this.children = children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getSerialVersionUID() {
|
|
||||||
return serialVersionUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,357 +0,0 @@
|
||||||
package com.nu.modules.institution.model;
|
|
||||||
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构表 存储树结构数据的实体类
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @Author 曹磊
|
|
||||||
* @Since 2025-03-25
|
|
||||||
*/
|
|
||||||
public class InstitutionAreaTreeModel implements Serializable{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 对应InstitutionArea中的id字段,前端数据树中的key*/
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
/** 对应InstitutionArea中的id字段,前端数据树中的value*/
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
/** 对应inst_name字段,前端数据树中的title*/
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isLeaf;
|
|
||||||
// 以下所有字段均与InstitutionArea相同
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
private String parentId;
|
|
||||||
|
|
||||||
private String instName;
|
|
||||||
|
|
||||||
private String instNameEn;
|
|
||||||
|
|
||||||
private String instNameAbbr;
|
|
||||||
|
|
||||||
private Integer instOrder;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private String orgCategory;
|
|
||||||
|
|
||||||
private String orgType;
|
|
||||||
|
|
||||||
private String orgCode;
|
|
||||||
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
private String address;
|
|
||||||
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
//update-begin---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段部门负责人ids
|
|
||||||
/**部门负责人ids*/
|
|
||||||
private String directorUserIds;
|
|
||||||
//update-end---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段部门负责人ids
|
|
||||||
|
|
||||||
private List<InstitutionAreaTreeModel> children = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将InstitutionArea对象转换成InstitutionAreaTreeModel对象
|
|
||||||
* @param inst
|
|
||||||
*/
|
|
||||||
public InstitutionAreaTreeModel(InstitutionArea inst) {
|
|
||||||
this.key = inst.getId();
|
|
||||||
this.value = inst.getId();
|
|
||||||
this.title = inst.getInstName();
|
|
||||||
this.id = inst.getId();
|
|
||||||
this.parentId = inst.getParentId();
|
|
||||||
this.instName = inst.getInstName();
|
|
||||||
this.instNameEn = inst.getInstNameEn();
|
|
||||||
this.instNameAbbr = inst.getInstNameAbbr();
|
|
||||||
this.instOrder = inst.getInstOrder();
|
|
||||||
this.description = inst.getDescription();
|
|
||||||
this.orgCategory = inst.getOrgCategory();
|
|
||||||
this.orgType = inst.getOrgType();
|
|
||||||
this.orgCode = inst.getOrgCode();
|
|
||||||
this.mobile = inst.getMobile();
|
|
||||||
this.address = inst.getAddress();
|
|
||||||
this.status = inst.getStatus();
|
|
||||||
this.delFlag = inst.getDelFlag();
|
|
||||||
this.createBy = inst.getCreateBy();
|
|
||||||
this.createTime = inst.getCreateTime();
|
|
||||||
this.updateBy = inst.getUpdateBy();
|
|
||||||
this.updateTime = inst.getUpdateTime();
|
|
||||||
if(0 == inst.getIzLeaf()){
|
|
||||||
this.isLeaf = false;
|
|
||||||
}else{
|
|
||||||
this.isLeaf = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getIsLeaf() {
|
|
||||||
return isLeaf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsLeaf(boolean isleaf) {
|
|
||||||
this.isLeaf = isleaf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InstitutionAreaTreeModel> getChildren() {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChildren(List<InstitutionAreaTreeModel> children) {
|
|
||||||
if (children==null){
|
|
||||||
this.isLeaf=true;
|
|
||||||
}
|
|
||||||
this.children = children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParentId() {
|
|
||||||
return parentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentId(String parentId) {
|
|
||||||
this.parentId = parentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getSerialVersionUID() {
|
|
||||||
return serialVersionUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInstName() {
|
|
||||||
return instName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstName(String instName) {
|
|
||||||
this.instName = instName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrgCategory() {
|
|
||||||
return orgCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrgCategory(String orgCategory) {
|
|
||||||
this.orgCategory = orgCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrgType() {
|
|
||||||
return orgType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrgType(String orgType) {
|
|
||||||
this.orgType = orgType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrgCode() {
|
|
||||||
return orgCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrgCode(String orgCode) {
|
|
||||||
this.orgCode = orgCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMobile() {
|
|
||||||
return mobile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMobile(String mobile) {
|
|
||||||
this.mobile = mobile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddress() {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAddress(String address) {
|
|
||||||
this.address = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInstNameEn() {
|
|
||||||
return instNameEn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstNameEn(String instNameEn) {
|
|
||||||
this.instNameEn = instNameEn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInstNameAbbr() {
|
|
||||||
return instNameAbbr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstNameAbbr(String instNameAbbr) {
|
|
||||||
this.instNameAbbr = instNameAbbr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getInstOrder() {
|
|
||||||
return instOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstOrder(Integer instOrder) {
|
|
||||||
this.instOrder = instOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDelFlag() {
|
|
||||||
return delFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDelFlag(String delFlag) {
|
|
||||||
this.delFlag = delFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreateBy() {
|
|
||||||
return createBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateBy(String createBy) {
|
|
||||||
this.createBy = createBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreateTime() {
|
|
||||||
return createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateTime(Date createTime) {
|
|
||||||
this.createTime = createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUpdateBy() {
|
|
||||||
return updateBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdateBy(String updateBy) {
|
|
||||||
this.updateBy = updateBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getUpdateTime() {
|
|
||||||
return updateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdateTime(Date updateTime) {
|
|
||||||
this.updateTime = updateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InstitutionAreaTreeModel() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重写equals方法
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
InstitutionAreaTreeModel model = (InstitutionAreaTreeModel) o;
|
|
||||||
return Objects.equals(id, model.id) &&
|
|
||||||
Objects.equals(parentId, model.parentId) &&
|
|
||||||
Objects.equals(instName, model.instName) &&
|
|
||||||
Objects.equals(instNameEn, model.instNameEn) &&
|
|
||||||
Objects.equals(instNameAbbr, model.instNameAbbr) &&
|
|
||||||
Objects.equals(instOrder, model.instOrder) &&
|
|
||||||
Objects.equals(description, model.description) &&
|
|
||||||
Objects.equals(orgCategory, model.orgCategory) &&
|
|
||||||
Objects.equals(orgType, model.orgType) &&
|
|
||||||
Objects.equals(orgCode, model.orgCode) &&
|
|
||||||
Objects.equals(mobile, model.mobile) &&
|
|
||||||
Objects.equals(address, model.address) &&
|
|
||||||
Objects.equals(status, model.status) &&
|
|
||||||
Objects.equals(delFlag, model.delFlag) &&
|
|
||||||
Objects.equals(createBy, model.createBy) &&
|
|
||||||
Objects.equals(createTime, model.createTime) &&
|
|
||||||
Objects.equals(updateBy, model.updateBy) &&
|
|
||||||
Objects.equals(updateTime, model.updateTime) &&
|
|
||||||
Objects.equals(children, model.children);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重写hashCode方法
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
|
|
||||||
return Objects.hash(id, parentId, instName, instNameEn, instNameAbbr,
|
|
||||||
instOrder, description, orgCategory, orgType, orgCode, mobile, address,
|
|
||||||
status, delFlag, createBy, createTime, updateBy, updateTime,
|
|
||||||
children);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
package com.nu.modules.institution.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
import com.nu.modules.institution.model.InstitutionAreaTreeModel;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构表 服务实现类
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @Author 曹磊
|
|
||||||
* @Since 2025-03-25
|
|
||||||
*/
|
|
||||||
public interface IInstitutionAreaService extends IService<InstitutionArea>{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存部门数据
|
|
||||||
* @param InstitutionArea
|
|
||||||
* @param username 用户名
|
|
||||||
*/
|
|
||||||
void saveInstData(InstitutionArea InstitutionArea,String username);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新Inst数据
|
|
||||||
* @param InstitutionArea
|
|
||||||
* @param username 用户名
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Boolean updateInstDataById(InstitutionArea InstitutionArea,String username);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据关键字搜索相关的部门数据
|
|
||||||
* @param keyWord
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<InstitutionAreaTreeModel> searchByKeyWord(String keyWord);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据部门id删除并删除其可能存在的子级部门
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean delete(String id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取我的部门下级所有部门
|
|
||||||
* @param parentId 父id
|
|
||||||
* @param primaryKey 主键字段(id或者orgCode)
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<InstitutionAreaTreeModel> queryTreeListByPid(String parentId,String primaryKey);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id查询机构信息
|
|
||||||
* @param parentId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
IPage<InstitutionArea> getMaxCodeInst(Page<InstitutionArea> page, String parentId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除部门
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
Result<String> deleteInst(InstitutionArea institutionArea);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id查询部门信息
|
|
||||||
* @param parentId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
InstitutionArea getInstById(String parentId);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,201 +0,0 @@
|
||||||
package com.nu.modules.institution.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
import com.nu.modules.institution.mapper.InstitutionAreaMapper;
|
|
||||||
import com.nu.modules.institution.model.InstitutionAreaTreeModel;
|
|
||||||
import com.nu.modules.institution.service.IInstitutionAreaService;
|
|
||||||
import com.nu.modules.institution.utils.OrgCodeRule;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 机构表 服务实现类
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @Author 曹磊
|
|
||||||
* @Since 2025-03-25
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class InstitutionAreaServiceImpl extends ServiceImpl<InstitutionAreaMapper, InstitutionArea> implements IInstitutionAreaService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据parentId查询机构树
|
|
||||||
* @param parentId
|
|
||||||
* @param primaryKey 主键字段(id或者orgCode)
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<InstitutionAreaTreeModel> queryTreeListByPid(String parentId,String primaryKey) {
|
|
||||||
Consumer<LambdaQueryWrapper<InstitutionArea>> square = i -> {
|
|
||||||
if(oConvertUtils.isEmpty(parentId)){
|
|
||||||
i.and(q->q.isNull(true,InstitutionArea::getParentId).or().eq(true,InstitutionArea::getParentId,""));
|
|
||||||
}else{
|
|
||||||
i.eq(true,InstitutionArea::getParentId,parentId);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
LambdaQueryWrapper<InstitutionArea> lqw=new LambdaQueryWrapper<>();
|
|
||||||
lqw.eq(true,InstitutionArea::getDelFlag,CommonConstant.DEL_FLAG_0.toString());
|
|
||||||
lqw.func(square);
|
|
||||||
lqw.orderByAsc(InstitutionArea::getInstOrder);
|
|
||||||
List<InstitutionArea> list = list(lqw);
|
|
||||||
List<InstitutionAreaTreeModel> records = new ArrayList<>();
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
InstitutionArea inst = list.get(i);
|
|
||||||
InstitutionAreaTreeModel treeModel = new InstitutionAreaTreeModel(inst);
|
|
||||||
records.add(treeModel);
|
|
||||||
}
|
|
||||||
return records;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id查询机构信息
|
|
||||||
* @param parentId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public IPage<InstitutionArea> getMaxCodeInst(Page<InstitutionArea> page, String parentId) {
|
|
||||||
return page.setRecords(baseMapper.getMaxCodeInst(page,parentId));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* saveInstData 对应 add 保存用户在页面添加的新的机构对象数据
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void saveInstData(InstitutionArea institutionArea, String username) {
|
|
||||||
if (institutionArea != null && username != null) {
|
|
||||||
//给机构表加个是否有子节点------------
|
|
||||||
if (oConvertUtils.isEmpty(institutionArea.getParentId())) {
|
|
||||||
institutionArea.setParentId("");
|
|
||||||
}else{
|
|
||||||
//将父机构的设成不是叶子结点
|
|
||||||
baseMapper.setMainLeaf(institutionArea.getParentId(),CommonConstant.NOT_LEAF);
|
|
||||||
}
|
|
||||||
//给机构表加个是否有子节点------------
|
|
||||||
institutionArea.setId(IdWorker.getIdStr(institutionArea));
|
|
||||||
// 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
|
|
||||||
// 获取父级ID
|
|
||||||
String parentId = institutionArea.getParentId();
|
|
||||||
//begin--机构编码规则生成器做成公用配置
|
|
||||||
JSONObject formData = new JSONObject();
|
|
||||||
formData.put("parentId",parentId);
|
|
||||||
String[] codeArray = OrgCodeRule.getOrgCode(formData);
|
|
||||||
//end--机构编码规则生成器做成公用配置
|
|
||||||
institutionArea.setOrgCode(codeArray[0]);
|
|
||||||
String orgType = codeArray[1];
|
|
||||||
institutionArea.setOrgType(String.valueOf(orgType));
|
|
||||||
institutionArea.setCreateTime(new Date());
|
|
||||||
institutionArea.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
|
|
||||||
//新添加的机构是叶子节点
|
|
||||||
institutionArea.setIzLeaf(CommonConstant.IS_LEAF);
|
|
||||||
if (oConvertUtils.isEmpty(institutionArea.getOrgCategory())) {
|
|
||||||
if (oConvertUtils.isEmpty(institutionArea.getParentId())) {
|
|
||||||
institutionArea.setOrgCategory("1");
|
|
||||||
} else {
|
|
||||||
institutionArea.setOrgCategory("2");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.save(institutionArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateInstDataById 对应 edit 根据机构主键来更新对应的机构数据
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Boolean updateInstDataById(InstitutionArea institutionArea, String username) {
|
|
||||||
if (institutionArea != null && username != null) {
|
|
||||||
institutionArea.setUpdateTime(new Date());
|
|
||||||
institutionArea.setUpdateBy(username);
|
|
||||||
this.updateById(institutionArea);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 根据关键字搜索相关的机构数据
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<InstitutionAreaTreeModel> searchByKeyWord(String keyWord) {
|
|
||||||
LambdaQueryWrapper<InstitutionArea> query = new LambdaQueryWrapper<InstitutionArea>();
|
|
||||||
List<InstitutionAreaTreeModel> newList = new ArrayList<>();
|
|
||||||
query.like(InstitutionArea::getInstName, keyWord);
|
|
||||||
InstitutionAreaTreeModel model = new InstitutionAreaTreeModel();
|
|
||||||
List<InstitutionArea> instList = this.list(query);
|
|
||||||
if(instList.size() > 0) {
|
|
||||||
for(InstitutionArea inst : instList) {
|
|
||||||
model = new InstitutionAreaTreeModel(inst);
|
|
||||||
model.setChildren(null);
|
|
||||||
newList.add(model);
|
|
||||||
}
|
|
||||||
return newList;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InstitutionArea getInstById(String id) {
|
|
||||||
return baseMapper.getInstById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<String> deleteInst(InstitutionArea institutionArea) {
|
|
||||||
//判断是否有字节点
|
|
||||||
int childrenCount = baseMapper.queryCountByPid(institutionArea.getId());
|
|
||||||
if(childrenCount>0){
|
|
||||||
if(institutionArea.getOrgCategory().equals("1")){
|
|
||||||
return Result.error("此机构存在子区域,请将子区域全部删除后再来删除此机构!");
|
|
||||||
}else{
|
|
||||||
return Result.error("此区域存在子区域,请将子区域全部删除后再来删除此区域!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//删除机构设置父级的叶子结点
|
|
||||||
this.setIzLeaf(institutionArea.getId());
|
|
||||||
this.delete(institutionArea.getId());
|
|
||||||
return Result.OK("机构删除成功!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置父级节点是否存在叶子结点
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
private void setIzLeaf(String id) {
|
|
||||||
InstitutionArea inst = this.getInstById(id);
|
|
||||||
String parentId = inst.getParentId();
|
|
||||||
if(oConvertUtils.isNotEmpty(parentId)){
|
|
||||||
Long count = this.count(new QueryWrapper<InstitutionArea>().lambda().eq(InstitutionArea::getParentId, parentId));
|
|
||||||
if(count == 1){
|
|
||||||
//若父节点无其他子节点,则该父节点是叶子节点
|
|
||||||
baseMapper.setMainLeaf(parentId, CommonConstant.IS_LEAF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据机构id删除并且删除其可能存在的子级任何机构
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public boolean delete(String id) {
|
|
||||||
boolean ok = this.removeById(id);
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,180 +0,0 @@
|
||||||
package com.nu.modules.institution.utils;
|
|
||||||
|
|
||||||
import io.netty.util.internal.StringUtil;
|
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 流水号生成规则(按默认规则递增,数字从1-999开始递增,数字到999,递增字母;位数不够增加位数)
|
|
||||||
* A001
|
|
||||||
* A001A002
|
|
||||||
* @Author 曹磊
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FindOrgCodeUtil {
|
|
||||||
|
|
||||||
// 数字位数(默认生成3位的数字)
|
|
||||||
|
|
||||||
/**代表数字位数*/
|
|
||||||
private static final int NUM_LENGTH = 3;
|
|
||||||
|
|
||||||
public static final int ZHANWEI_LENGTH = 1+ NUM_LENGTH;
|
|
||||||
|
|
||||||
public static final char LETTER= 'Z';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据前一个code,获取同级下一个code
|
|
||||||
* 例如:当前最大code为A001A004,下一个code为:A001A005
|
|
||||||
*
|
|
||||||
* @param code
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static synchronized String getNextOrgCode(String code) {
|
|
||||||
String newcode = "";
|
|
||||||
if (oConvertUtils.isEmpty(code)) {
|
|
||||||
String zimu = "A";
|
|
||||||
String num = getStrNum(1);
|
|
||||||
newcode = zimu + num;
|
|
||||||
} else {
|
|
||||||
String beforeCode = code.substring(0, code.length() - 1- NUM_LENGTH);
|
|
||||||
String afterCode = code.substring(code.length() - 1 - NUM_LENGTH,code.length());
|
|
||||||
char afterCodeZimu = afterCode.substring(0, 1).charAt(0);
|
|
||||||
Integer afterCodeNum = Integer.parseInt(afterCode.substring(1));
|
|
||||||
|
|
||||||
String nextNum = "";
|
|
||||||
char nextZimu = 'A';
|
|
||||||
// 先判断数字等于999*,则计数从1重新开始,递增
|
|
||||||
if (afterCodeNum == getMaxNumByLength(NUM_LENGTH)) {
|
|
||||||
nextNum = getNextStrNum(0);
|
|
||||||
} else {
|
|
||||||
nextNum = getNextStrNum(afterCodeNum);
|
|
||||||
}
|
|
||||||
// 先判断数字等于999*,则字母从A重新开始,递增
|
|
||||||
if(afterCodeNum == getMaxNumByLength(NUM_LENGTH)) {
|
|
||||||
nextZimu = getNextZiMu(afterCodeZimu);
|
|
||||||
}else{
|
|
||||||
nextZimu = afterCodeZimu;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 例如Z99,下一个code就是Z99A01
|
|
||||||
if (LETTER == afterCodeZimu && getMaxNumByLength(NUM_LENGTH) == afterCodeNum) {
|
|
||||||
newcode = code + (nextZimu + nextNum);
|
|
||||||
} else {
|
|
||||||
newcode = beforeCode + (nextZimu + nextNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据父亲code,获取下级的下一个code
|
|
||||||
*
|
|
||||||
* 例如:父亲CODE:A001
|
|
||||||
* 当前CODE:A001B003
|
|
||||||
* 获取的code:A001B004
|
|
||||||
*
|
|
||||||
* @param parentCode 上级code
|
|
||||||
* @param localCode 同级code
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static synchronized String getSubOrgCode(String parentCode,String localCode) {
|
|
||||||
if(localCode!=null && localCode!=""){
|
|
||||||
|
|
||||||
return getNextOrgCode(localCode);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
parentCode = parentCode + "A"+ getNextStrNum(0);
|
|
||||||
}
|
|
||||||
return parentCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数字前面位数补零
|
|
||||||
*
|
|
||||||
* @param num
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static String getNextStrNum(int num) {
|
|
||||||
return getStrNum(getNextNum(num));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数字前面位数补零
|
|
||||||
*
|
|
||||||
* @param num
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static String getStrNum(int num) {
|
|
||||||
String s = String.format("%0" + NUM_LENGTH + "d", num);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递增获取下个数字
|
|
||||||
*
|
|
||||||
* @param num
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static int getNextNum(int num) {
|
|
||||||
num++;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递增获取下个字母
|
|
||||||
*
|
|
||||||
* @param zimu
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static char getNextZiMu(char zimu) {
|
|
||||||
if (zimu == LETTER) {
|
|
||||||
return 'A';
|
|
||||||
}
|
|
||||||
zimu++;
|
|
||||||
return zimu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据数字位数获取最大值
|
|
||||||
* @param length
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static int getMaxNumByLength(int length){
|
|
||||||
if(length==0){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
StringBuilder maxNum = new StringBuilder();
|
|
||||||
for (int i=0;i<length;i++){
|
|
||||||
maxNum.append("9");
|
|
||||||
}
|
|
||||||
return Integer.parseInt(maxNum.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] cutOrgCode(String code){
|
|
||||||
if(code==null || StringUtil.isNullOrEmpty(code)){
|
|
||||||
return null;
|
|
||||||
}else{
|
|
||||||
//获取标准长度为numLength+1,截取的数量为code.length/numLength+1
|
|
||||||
int c = code.length()/(NUM_LENGTH +1);
|
|
||||||
String[] cutcode = new String[c];
|
|
||||||
for(int i =0 ; i <c;i++){
|
|
||||||
cutcode[i] = code.substring(0,(i+1)*(NUM_LENGTH +1));
|
|
||||||
}
|
|
||||||
return cutcode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
|
||||||
// String s = getNextOrgCode("A001A002");
|
|
||||||
// System.out.println(s);
|
|
||||||
// char c1 = getNextZiMu('C');
|
|
||||||
// int n = getNextNum(8);
|
|
||||||
// String[] ss = cutOrgCode("C099A001B001");
|
|
||||||
// System.out.println(c1);
|
|
||||||
// System.out.println(n);
|
|
||||||
// for(int i=0;i<ss.length;i++){
|
|
||||||
// System.out.println(ss[i]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,108 +0,0 @@
|
||||||
package com.nu.modules.institution.utils;
|
|
||||||
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
import com.nu.modules.institution.model.InstitutionAreaIdModel;
|
|
||||||
import com.nu.modules.institution.model.InstitutionAreaTreeModel;
|
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <P>
|
|
||||||
* 对应机构的表,处理并查找树级数据
|
|
||||||
* <P>
|
|
||||||
*
|
|
||||||
* @Author: 曹磊
|
|
||||||
* @Date: 2025-03-25
|
|
||||||
*/
|
|
||||||
public class FindsInstChildrenUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queryTreeList的子方法 ====1=====
|
|
||||||
* 该方法是s将InstitutionArea类型的list集合转换成InstitutionAreaTreeModel类型的集合
|
|
||||||
*/
|
|
||||||
public static List<InstitutionAreaTreeModel> wrapTreeDataToTreeList(List<InstitutionArea> recordList) {
|
|
||||||
List<InstitutionAreaIdModel> idList = new ArrayList<InstitutionAreaIdModel>();
|
|
||||||
List<InstitutionAreaTreeModel> records = new ArrayList<>();
|
|
||||||
for (int i = 0; i < recordList.size(); i++) {
|
|
||||||
InstitutionArea inst = recordList.get(i);
|
|
||||||
records.add(new InstitutionAreaTreeModel(inst));
|
|
||||||
}
|
|
||||||
List<InstitutionAreaTreeModel> tree = findChildren(records, idList);
|
|
||||||
setEmptyChildrenAsNull(tree);
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取 InstitutionAreaIdModel
|
|
||||||
* @param recordList
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<InstitutionAreaIdModel> wrapTreeDataToInstIdTreeList(List<InstitutionArea> recordList) {
|
|
||||||
List<InstitutionAreaIdModel> idList = new ArrayList<InstitutionAreaIdModel>();
|
|
||||||
List<InstitutionAreaTreeModel> records = new ArrayList<>();
|
|
||||||
for (int i = 0; i < recordList.size(); i++) {
|
|
||||||
InstitutionArea inst = recordList.get(i);
|
|
||||||
records.add(new InstitutionAreaTreeModel(inst));
|
|
||||||
}
|
|
||||||
findChildren(records, idList);
|
|
||||||
return idList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queryTreeList的子方法 ====2=====
|
|
||||||
* 该方法是找到并封装顶级父类的节点到TreeList集合
|
|
||||||
*/
|
|
||||||
private static List<InstitutionAreaTreeModel> findChildren(List<InstitutionAreaTreeModel> recordList, List<InstitutionAreaIdModel> instIdList) {
|
|
||||||
List<InstitutionAreaTreeModel> treeList = new ArrayList<>();
|
|
||||||
for (int i = 0; i < recordList.size(); i++) {
|
|
||||||
InstitutionAreaTreeModel branch = recordList.get(i);
|
|
||||||
if (oConvertUtils.isEmpty(branch.getParentId())) {
|
|
||||||
treeList.add(branch);
|
|
||||||
InstitutionAreaIdModel InstitutionAreaIdModel = new InstitutionAreaIdModel().convert(branch);
|
|
||||||
instIdList.add(InstitutionAreaIdModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getGrandChildren(treeList,recordList,instIdList);
|
|
||||||
return treeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queryTreeList的子方法====3====
|
|
||||||
*该方法是找到顶级父类下的所有子节点集合并封装到TreeList集合
|
|
||||||
*/
|
|
||||||
private static void getGrandChildren(List<InstitutionAreaTreeModel> treeList,List<InstitutionAreaTreeModel> recordList,List<InstitutionAreaIdModel> idList) {
|
|
||||||
for (int i = 0; i < treeList.size(); i++) {
|
|
||||||
InstitutionAreaTreeModel model = treeList.get(i);
|
|
||||||
InstitutionAreaIdModel idModel = idList.get(i);
|
|
||||||
for (int i1 = 0; i1 < recordList.size(); i1++) {
|
|
||||||
InstitutionAreaTreeModel m = recordList.get(i1);
|
|
||||||
if (m.getParentId()!=null && m.getParentId().equals(model.getId())) {
|
|
||||||
model.getChildren().add(m);
|
|
||||||
InstitutionAreaIdModel dim = new InstitutionAreaIdModel().convert(m);
|
|
||||||
idModel.getChildren().add(dim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getGrandChildren(treeList.get(i).getChildren(), recordList, idList.get(i).getChildren());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queryTreeList的子方法 ====4====
|
|
||||||
* 该方法是将子节点为空的List集合设置为Null值
|
|
||||||
*/
|
|
||||||
private static void setEmptyChildrenAsNull(List<InstitutionAreaTreeModel> treeList) {
|
|
||||||
|
|
||||||
for (int i = 0; i < treeList.size(); i++) {
|
|
||||||
InstitutionAreaTreeModel model = treeList.get(i);
|
|
||||||
if (model.getChildren().size() == 0) {
|
|
||||||
model.setChildren(null);
|
|
||||||
model.setIsLeaf(true);
|
|
||||||
}else{
|
|
||||||
setEmptyChildrenAsNull(model.getChildren());
|
|
||||||
model.setIsLeaf(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
package com.nu.modules.institution.utils;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.nu.modules.institution.entity.InstitutionArea;
|
|
||||||
import com.nu.modules.institution.service.impl.InstitutionAreaServiceImpl;
|
|
||||||
import io.netty.util.internal.StringUtil;
|
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author scott
|
|
||||||
* @Date 2019/12/9 11:33
|
|
||||||
* @Description: 机构编码生成规则
|
|
||||||
*/
|
|
||||||
public class OrgCodeRule{
|
|
||||||
|
|
||||||
public static String[] getOrgCode(JSONObject params) {
|
|
||||||
InstitutionAreaServiceImpl institutionAreaService = (InstitutionAreaServiceImpl) SpringContextUtils.getBean("institutionAreaServiceImpl");
|
|
||||||
|
|
||||||
String[] strArray = new String[2];
|
|
||||||
//定义机构类型
|
|
||||||
String orgType = "";
|
|
||||||
// 定义新编码字符串
|
|
||||||
String newOrgCode = "";
|
|
||||||
// 定义旧编码字符串
|
|
||||||
String oldOrgCode = "";
|
|
||||||
String parentId = null;
|
|
||||||
Object obj = params.get("parentId");
|
|
||||||
if (obj != null) {
|
|
||||||
parentId = obj.toString();
|
|
||||||
}
|
|
||||||
//如果是最高级,则查询出同级的org_code, 调用工具类生成编码并返回
|
|
||||||
if (StringUtil.isNullOrEmpty(parentId)) {
|
|
||||||
// 线判断数据库中的表是否为空,空则直接返回初始编码
|
|
||||||
//获取最大值code的机构信息
|
|
||||||
Page<InstitutionArea> page = new Page<>(1,1);
|
|
||||||
IPage<InstitutionArea> pageList = institutionAreaService.getMaxCodeInst(page,"");
|
|
||||||
List<InstitutionArea> records = pageList.getRecords();
|
|
||||||
if (null==records || records.size()==0) {
|
|
||||||
strArray[0] = FindOrgCodeUtil.getNextOrgCode(null);
|
|
||||||
strArray[1] = "1";
|
|
||||||
return strArray;
|
|
||||||
} else {
|
|
||||||
InstitutionArea depart = records.get(0);
|
|
||||||
oldOrgCode = depart.getOrgCode();
|
|
||||||
orgType = depart.getOrgType();
|
|
||||||
newOrgCode = FindOrgCodeUtil.getNextOrgCode(oldOrgCode);
|
|
||||||
}
|
|
||||||
} else {//反之则查询出所有同级的机构,获取结果后有两种情况,有同级和没有同级
|
|
||||||
//获取自己机构最大值orgCode机构信息
|
|
||||||
Page<InstitutionArea> page = new Page<>(1,1);
|
|
||||||
IPage<InstitutionArea> pageList = institutionAreaService.getMaxCodeInst(page,parentId);
|
|
||||||
List<InstitutionArea> records = pageList.getRecords();
|
|
||||||
// 查询出父级机构
|
|
||||||
InstitutionArea depart = institutionAreaService.getInstById(parentId);
|
|
||||||
// 获取父级机构的Code
|
|
||||||
String parentCode = depart.getOrgCode();
|
|
||||||
// 根据父级机构类型算出当前机构的类型
|
|
||||||
orgType = String.valueOf(Integer.valueOf(depart.getOrgType()) + 1);
|
|
||||||
// 处理同级机构为null的情况
|
|
||||||
if (null == records || records.size()==0) {
|
|
||||||
// 直接生成当前的机构编码并返回
|
|
||||||
newOrgCode = FindOrgCodeUtil.getSubOrgCode(parentCode, null);
|
|
||||||
} else { //处理有同级机构的情况
|
|
||||||
// 获取同级机构的编码,利用工具类
|
|
||||||
String subCode = records.get(0).getOrgCode();
|
|
||||||
// 返回生成的当前机构编码
|
|
||||||
newOrgCode = FindOrgCodeUtil.getSubOrgCode(parentCode, subCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 返回最终封装了机构编码和机构类型的数组
|
|
||||||
strArray[0] = newOrgCode;
|
|
||||||
strArray[1] = orgType;
|
|
||||||
return strArray;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -133,7 +133,7 @@ public class CameraInfo implements Serializable {
|
||||||
private String topTime;
|
private String topTime;
|
||||||
/**护理单元*/
|
/**护理单元*/
|
||||||
@ApiModelProperty(value = "护理单元ID")
|
@ApiModelProperty(value = "护理单元ID")
|
||||||
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "nu_id")
|
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "id")
|
||||||
private String nuId;
|
private String nuId;
|
||||||
/**护理单元*/
|
/**护理单元*/
|
||||||
@ApiModelProperty(value = "护理单元")
|
@ApiModelProperty(value = "护理单元")
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
a.nu_id as nuId,
|
a.nu_id as nuId,
|
||||||
b.nu_name as nuName,
|
b.nu_name as nuName,
|
||||||
ifnull(c.multitrans,0) as multitrans
|
ifnull(c.multitrans,0) as multitrans
|
||||||
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.nu_id
|
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.id
|
||||||
left join nu_iot_tplink_camera_capability c on a.device_index = c.device_index
|
left join nu_iot_tplink_camera_capability c on a.device_index = c.device_index
|
||||||
<where>
|
<where>
|
||||||
<if test="params.deviceIndex != null and params.deviceIndex != ''">
|
<if test="params.deviceIndex != null and params.deviceIndex != ''">
|
||||||
|
@ -87,12 +87,12 @@
|
||||||
|
|
||||||
<select id="findNuPage" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
|
<select id="findNuPage" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
|
||||||
select
|
select
|
||||||
nu_id as nuId,
|
id as nuId,
|
||||||
nu_name as nuName
|
nu_name as nuName
|
||||||
from nu_base_info b
|
from nu_base_info b
|
||||||
<where>
|
<where>
|
||||||
<if test="params.nuId != null and params.nuId != ''">
|
<if test="params.nuId != null and params.nuId != ''">
|
||||||
AND b.nu_id = #{params.nuId}
|
AND b.id = #{params.nuId}
|
||||||
</if>
|
</if>
|
||||||
<if test="params.nuName != null and params.nuName != ''">
|
<if test="params.nuName != null and params.nuName != ''">
|
||||||
AND b.nu_name LIKE concat('%',#{params.nuName},'%')
|
AND b.nu_name LIKE concat('%',#{params.nuName},'%')
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
protocol as protocol,
|
protocol as protocol,
|
||||||
a.nu_id as nuId,
|
a.nu_id as nuId,
|
||||||
b.nu_name as nuName
|
b.nu_name as nuName
|
||||||
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.nu_id
|
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.id
|
||||||
where device_index = #{deviceIndex}
|
where device_index = #{deviceIndex}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue