机构代码初始化

This commit is contained in:
zhangheng 2024-02-26 15:30:45 +08:00
parent 86245219ac
commit 1b56b32f63
15 changed files with 1474 additions and 0 deletions

View File

@ -133,4 +133,9 @@ public class Constants {
*/
public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache", "com.xinelu.common.utils.file"};
/**
* 机构类别编码前缀
*/
public static final String CATEGORY_CODE = "CC";
}

View File

@ -6,7 +6,10 @@ import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.Objects;
/**
* 时间工具类
@ -157,4 +160,45 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant());
}
/**
* 转换日期到字符串
*
* @param date LocalDate
* @param pattern 解析格式
* @return 日期字符串
* @Author jihan
*/
public static String formatDateToString(LocalDate date, String pattern) {
if (Objects.isNull(date)) {
throw new IllegalArgumentException("date time is null.");
}
return date.format(StringUtils.isNotBlank(pattern) ? DateTimeFormatter.ofPattern(pattern) : DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
/**
* 获取指定日期的结束时间
*
* @param date 指定日期,如果为null,默认为当天
* @return 结束日期
* @author jihan
*/
public static LocalDateTime end(LocalDate date) {
return LocalDateTime.of(null == date ? LocalDate.now() : date, LocalTime.MAX);
}
/**
* 计算两个时间的分钟差
*
* @param beginTime 开始时间
* @param endTime 结束时间可以为null, 如果为null则表示now
* @return 分钟差值
* @author jihan
*/
public static long differenceMinutes(LocalDateTime beginTime, LocalDateTime endTime) {
if (null == beginTime) {
throw new IllegalArgumentException("开始时间不能为空");
}
return ChronoUnit.MINUTES.between(beginTime, null == endTime ? LocalDateTime.now() : endTime);
}
}

View File

@ -0,0 +1,83 @@
package com.xinelu.common.utils.codes;
import com.xinelu.common.utils.DateUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.concurrent.TimeUnit;
/**
* @Description 编号工具类
* @Author 纪寒
* @Date 2022-08-02 18:13:55
* @Version 1.0
*/
@Component
public class GenerateSystemCodeUtil {
@Resource
private RedisTemplate<String, Object> redisTemplate;
/**
* 使用Redis生成唯一不重复的编码
*
* @param prefixCode 编号前缀
* @return 编号信息 MMdd
*/
public String generatePatientCode(String prefixCode) {
DecimalFormat df = new DecimalFormat("0000");
String dateFmt = DateUtils.formatDateToString(LocalDate.now(), "MMdd");
Long maxVal = redisTemplate.opsForValue().increment(prefixCode, 1);
//redis有效期开始时间
LocalDateTime now = LocalDateTime.now();
//redis有效期结束时间
LocalDateTime end = DateUtils.end(LocalDate.now());
redisTemplate.expire(prefixCode, DateUtils.differenceMinutes(now, end), TimeUnit.MINUTES);
return dateFmt + df.format(maxVal);
}
/**
* 使用Redis生成唯一不重复的编码
*
* @param prefixCode 编号前缀
* @return 编号信息 yyyyMMdd
*/
public String generateSystemCode(String prefixCode) {
DecimalFormat df = new DecimalFormat("0000");
String dateFmt = DateUtils.formatDateToString(LocalDate.now(), "yyyyMMdd");
Long maxVal = redisTemplate.opsForValue().increment(prefixCode, 1);
//redis有效期开始时间
LocalDateTime now = LocalDateTime.now();
//redis有效期结束时间
LocalDateTime end = DateUtils.end(LocalDate.now());
redisTemplate.expire(prefixCode, DateUtils.differenceMinutes(now, end), TimeUnit.MINUTES);
return dateFmt + df.format(maxVal);
}
/**
* 生成科室编码
*
* @param prefixCode 科室名称前缀
* @return 科室编码
*/
public String generateDepartCode(String prefixCode) {
DecimalFormat df = new DecimalFormat("00000");
String dateFmt = DateUtils.formatDateToString(LocalDate.now(), "yyyy");
Long maxVal = redisTemplate.opsForValue().increment(prefixCode, 1);
//redis有效期开始时间
LocalDateTime now = LocalDateTime.now();
//redis有效期结束时间
LocalDateTime end = DateUtils.end(LocalDate.now().plusYears(0).with(TemporalAdjusters.lastDayOfYear()));
redisTemplate.expire(prefixCode, DateUtils.differenceMinutes(now, end), TimeUnit.MINUTES);
return dateFmt + df.format(maxVal);
}
}

View File

@ -0,0 +1,99 @@
package com.xinelu.manage.controller.agency;
import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.agency.Agency;
import com.xinelu.manage.service.agency.IAgencyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 机构信息Controller
*
* @author xinelu
* @date 2024-02-26
*/
@RestController
@RequestMapping("/system/agency")
public class AgencyController extends BaseController {
@Resource
private IAgencyService agencyService;
/**
* 查询机构信息列表
*/
@PreAuthorize("@ss.hasPermi('system:agency:list')")
@GetMapping("/list")
public TableDataInfo list(Agency agency) {
startPage();
List<Agency> list = agencyService.selectAgencyList(agency);
return getDataTable(list);
}
/**
* 导出机构信息列表
*/
@PreAuthorize("@ss.hasPermi('system:agency:export')")
@Log(title = "机构信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Agency agency) {
List<Agency> list = agencyService.selectAgencyList(agency);
ExcelUtil<Agency> util = new ExcelUtil<Agency>(Agency.class);
util.exportExcel(response, list, "机构信息数据");
}
/**
* 获取机构信息详细信息
*/
@PreAuthorize("@ss.hasPermi('system:agency:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(agencyService.selectAgencyById(id));
}
/**
* 新增机构信息
*/
@PreAuthorize("@ss.hasPermi('system:agency:add')")
@Log(title = "机构信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Agency agency) {
return toAjax(agencyService.insertAgency(agency));
}
/**
* 修改机构信息
*/
@PreAuthorize("@ss.hasPermi('system:agency:edit')")
@Log(title = "机构信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Agency agency) {
return toAjax(agencyService.updateAgency(agency));
}
/**
* 删除机构信息
*/
@PreAuthorize("@ss.hasPermi('system:agency:remove')")
@Log(title = "机构信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(agencyService.deleteAgencyByIds(ids));
}
/**
* 查询机构信息列表 - 树图
*/
@GetMapping("/agencyList")
public AjaxResult agencyList() {
return AjaxResult.success(agencyService.agencyList());
}
}

View File

@ -0,0 +1,95 @@
package com.xinelu.manage.controller.agencycategory;
import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.agencycategory.AgencyCategory;
import com.xinelu.manage.service.agencycategory.IAgencyCategoryService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Objects;
/**
* 机构类别Controller
*
* @author xinelu
* @date 2024-02-26
*/
@RestController
@RequestMapping("/system/agencyCategory")
public class AgencyCategoryController extends BaseController {
@Resource
private IAgencyCategoryService agencyCategoryService;
/**
* 查询机构类别列表
*/
@PreAuthorize("@ss.hasPermi('system:agencyCategory:list')")
@GetMapping("/list")
public TableDataInfo list(AgencyCategory agencyCategory) {
startPage();
List<AgencyCategory> list = agencyCategoryService.selectAgencyCategoryList(agencyCategory);
return getDataTable(list);
}
/**
* 导出机构类别列表
*/
@PreAuthorize("@ss.hasPermi('system:agencyCategory:export')")
@Log(title = "机构类别", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AgencyCategory agencyCategory) {
List<AgencyCategory> list = agencyCategoryService.selectAgencyCategoryList(agencyCategory);
ExcelUtil<AgencyCategory> util = new ExcelUtil<AgencyCategory>(AgencyCategory.class);
util.exportExcel(response, list, "机构类别数据");
}
/**
* 获取机构类别详细信息
*/
@PreAuthorize("@ss.hasPermi('system:agencyCategory:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(agencyCategoryService.selectAgencyCategoryById(id));
}
/**
* 新增机构类别
*/
@PreAuthorize("@ss.hasPermi('system:agencyCategory:add')")
@Log(title = "机构类别", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AgencyCategory agencyCategory) {
if (Objects.isNull(agencyCategory)) {
return AjaxResult.success();
}
return toAjax(agencyCategoryService.insertAgencyCategory(agencyCategory));
}
/**
* 修改机构类别
*/
@PreAuthorize("@ss.hasPermi('system:agencyCategory:edit')")
@Log(title = "机构类别", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AgencyCategory agencyCategory) {
return toAjax(agencyCategoryService.updateAgencyCategory(agencyCategory));
}
/**
* 删除机构类别
*/
@PreAuthorize("@ss.hasPermi('system:agencyCategory:remove')")
@Log(title = "机构类别", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(agencyCategoryService.deleteAgencyCategoryByIds(ids));
}
}

View File

@ -0,0 +1,193 @@
package com.xinelu.manage.domain.agency;
import com.xinelu.common.annotation.Excel;
import com.xinelu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.ArrayList;
import java.util.List;
/**
* 机构信息对象 agency
*
* @author xinelu
* @date 2024-02-26
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "机构信息对象", description = "agency")
public class Agency extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private Long id;
/**
* 上级机构id
*/
@ApiModelProperty(value = "上级机构id")
@Excel(name = "上级机构id")
private Long parentId;
/**
* 所属机构类别id
*/
@ApiModelProperty(value = "所属机构类别id")
@Excel(name = "所属机构类别id")
private Long agencyCategoryId;
/**
* 所属机构类别名称
*/
@ApiModelProperty(value = "所属机构类别名称")
@Excel(name = "所属机构类别名称")
private String agencyCategoryName;
/**
* 所属行政区域编码
*/
@ApiModelProperty(value = "所属行政区域编码")
@Excel(name = "所属行政区域编码")
private String areaCode;
/**
* 所属行政区域名称
*/
@ApiModelProperty(value = "所属行政区域名称")
@Excel(name = "所属行政区域名称")
private String areaName;
/**
* 机构名称
*/
@ApiModelProperty(value = "机构名称")
@Excel(name = "机构名称")
private String agencyName;
/**
* 机构代码
*/
@ApiModelProperty(value = "机构代码")
@Excel(name = "机构代码")
private String agencyCode;
/**
* 机构简称
*/
@ApiModelProperty(value = "机构简称")
@Excel(name = "机构简称")
private String agencyAbbreviation;
/**
* 机构状态ON启用OFF禁用
*/
@ApiModelProperty(value = "机构状态ON启用OFF禁用")
@Excel(name = "机构状态ON启用OFF禁用")
private String agencyStatus;
/**
* 节点类型节点类型卫健委HEALTH_COMMISSION医保局MEDICAL_INSURANCE_BUREAU医院HOSPITAL院区CAMPUS药店PHARMACY科室DEPARTMENT病区WARD中国CHINA省份PROVINCE
*/
@ApiModelProperty(value = "节点类型节点类型卫健委HEALTH_COMMISSION医保局MEDICAL_INSURANCE_BUREAU医院HOSPITAL院区CAMPUS药店PHARMACY科室DEPARTMENT病区WARD中国CHINA省份PROVINCE")
@Excel(name = "节点类型节点类型卫健委HEALTH_COMMISSION医保局MEDICAL_INSURANCE_BUREAU医院HOSPITAL院区CAMPUS药店PHARMACY科室DEPARTMENT病区WARD中国CHINA省份PROVINCE")
private String nodeType;
/**
* 组织机构编码
*/
@ApiModelProperty(value = "组织机构编码")
@Excel(name = "组织机构编码")
private String orgAgencyCode;
/**
* 机构分类管理类别非营利性医疗机构NON_PROFIT_MEDICAL_AGENCY营利性医疗机构FOR_PROFIT_MEDICAL_AGENCY其他卫生机构OTHER_HEALTH_AGENCY
*/
@ApiModelProperty(value = "机构分类管理类别非营利性医疗机构NON_PROFIT_MEDICAL_AGENCY营利性医疗机构FOR_PROFIT_MEDICAL_AGENCY其他卫生机构OTHER_HEALTH_AGENCY")
@Excel(name = "机构分类管理类别非营利性医疗机构NON_PROFIT_MEDICAL_AGENCY营利性医疗机构FOR_PROFIT_MEDICAL_AGENCY其他卫生机构OTHER_HEALTH_AGENCY")
private String agencyCategoryManageLevel;
/**
* 机构联系人
*/
@ApiModelProperty(value = "机构联系人")
@Excel(name = "机构联系人")
private String agencyContacts;
/**
* 机构联系电话
*/
@ApiModelProperty(value = "机构联系电话")
@Excel(name = "机构联系电话")
private String agencyPhone;
/**
* 机构详细地址
*/
@ApiModelProperty(value = "机构详细地址")
@Excel(name = "机构详细地址")
private String agencyAddress;
/**
* 机构概述
*/
@ApiModelProperty(value = "机构概述")
@Excel(name = "机构概述")
private String agencyRemark;
/**
* 机构排序
*/
@ApiModelProperty(value = "机构排序")
@Excel(name = "机构排序")
private Integer agencySort;
private List<Agency> children = new ArrayList<Agency>();
public List<Agency> getChildren() {
return children;
}
public void setChildren(List<Agency> children) {
this.children = children;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("parentId", getParentId())
.append("agencyCategoryId", getAgencyCategoryId())
.append("agencyCategoryName", getAgencyCategoryName())
.append("areaCode", getAreaCode())
.append("areaName", getAreaName())
.append("agencyName", getAgencyName())
.append("agencyCode", getAgencyCode())
.append("agencyAbbreviation", getAgencyAbbreviation())
.append("agencyStatus", getAgencyStatus())
.append("nodeType", getNodeType())
.append("orgAgencyCode", getOrgAgencyCode())
.append("agencyCategoryManageLevel", getAgencyCategoryManageLevel())
.append("agencyContacts", getAgencyContacts())
.append("agencyPhone", getAgencyPhone())
.append("agencyAddress", getAgencyAddress())
.append("agencyRemark", getAgencyRemark())
.append("agencySort", getAgencySort())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,92 @@
package com.xinelu.manage.domain.agencycategory;
import com.xinelu.common.annotation.Excel;
import com.xinelu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 机构类别对象 agency_category
*
* @author xinelu
* @date 2024-02-26
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "机构类别对象", description = "agency_category")
public class AgencyCategory extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private Long id;
/**
* 父级类别id
*/
@ApiModelProperty(value = "父级类别id")
@Excel(name = "父级类别id")
private Long parentCategoryId;
/**
* 类别名称
*/
@ApiModelProperty(value = "类别名称")
@Excel(name = "类别名称")
private String categoryName;
/**
* 类别编码
*/
@ApiModelProperty(value = "类别编码")
@Excel(name = "类别编码")
private String categoryCode;
/**
* 类别等级1一级类型2二级类别3三级类别等
*/
@ApiModelProperty(value = "类别等级1一级类型2二级类别3三级类别等")
@Excel(name = "类别等级1一级类型2二级类别3三级类别等")
private Integer categoryLevel;
/**
* 类别排序
*/
@ApiModelProperty(value = "类别排序")
@Excel(name = "类别排序")
private Integer categorySort;
/**
* 类别概述
*/
@ApiModelProperty(value = "类别概述")
@Excel(name = "类别概述")
private String categoryRemark;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("parentCategoryId", getParentCategoryId())
.append("categoryName", getCategoryName())
.append("categoryCode", getCategoryCode())
.append("categoryLevel", getCategoryLevel())
.append("categorySort", getCategorySort())
.append("categoryRemark", getCategoryRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,63 @@
package com.xinelu.manage.mapper.agency;
import com.xinelu.manage.domain.agency.Agency;
import com.xinelu.manage.vo.agency.AgencyVO;
import java.util.List;
/**
* 机构信息Mapper接口
*
* @author xinelu
* @date 2024-02-26
*/
public interface AgencyMapper {
/**
* 查询机构信息
*
* @param id 机构信息主键
* @return 机构信息
*/
Agency selectAgencyById(Long id);
/**
* 查询机构信息列表
*
* @param agency 机构信息
* @return 机构信息集合
*/
List<Agency> selectAgencyList(Agency agency);
/**
* 新增机构信息
*
* @param agency 机构信息
* @return 结果
*/
int insertAgency(Agency agency);
/**
* 修改机构信息
*
* @param agency 机构信息
* @return 结果
*/
int updateAgency(Agency agency);
/**
* 删除机构信息
*
* @param id 机构信息主键
* @return 结果
*/
int deleteAgencyById(Long id);
/**
* 批量删除机构信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteAgencyByIds(Long[] ids);
}

View File

@ -0,0 +1,62 @@
package com.xinelu.manage.mapper.agencycategory;
import com.xinelu.manage.domain.agencycategory.AgencyCategory;
import java.util.List;
/**
* 机构类别Mapper接口
*
* @author xinelu
* @date 2024-02-26
*/
public interface AgencyCategoryMapper {
/**
* 查询机构类别
*
* @param id 机构类别主键
* @return 机构类别
*/
AgencyCategory selectAgencyCategoryById(Long id);
/**
* 查询机构类别列表
*
* @param agencyCategory 机构类别
* @return 机构类别集合
*/
List<AgencyCategory> selectAgencyCategoryList(AgencyCategory agencyCategory);
/**
* 新增机构类别
*
* @param agencyCategory 机构类别
* @return 结果
*/
int insertAgencyCategory(AgencyCategory agencyCategory);
/**
* 修改机构类别
*
* @param agencyCategory 机构类别
* @return 结果
*/
int updateAgencyCategory(AgencyCategory agencyCategory);
/**
* 删除机构类别
*
* @param id 机构类别主键
* @return 结果
*/
int deleteAgencyCategoryById(Long id);
/**
* 批量删除机构类别
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteAgencyCategoryByIds(Long[] ids);
}

View File

@ -0,0 +1,70 @@
package com.xinelu.manage.service.agency;
import com.xinelu.manage.domain.agency.Agency;
import com.xinelu.manage.vo.agency.AgencyVO;
import java.util.List;
/**
* 机构信息Service接口
*
* @author xinelu
* @date 2024-02-26
*/
public interface IAgencyService {
/**
* 查询机构信息
*
* @param id 机构信息主键
* @return 机构信息
*/
Agency selectAgencyById(Long id);
/**
* 查询机构信息列表
*
* @param agency 机构信息
* @return 机构信息集合
*/
List<Agency> selectAgencyList(Agency agency);
/**
* 新增机构信息
*
* @param agency 机构信息
* @return 结果
*/
int insertAgency(Agency agency);
/**
* 修改机构信息
*
* @param agency 机构信息
* @return 结果
*/
int updateAgency(Agency agency);
/**
* 批量删除机构信息
*
* @param ids 需要删除的机构信息主键集合
* @return 结果
*/
int deleteAgencyByIds(Long[] ids);
/**
* 删除机构信息信息
*
* @param id 机构信息主键
* @return 结果
*/
int deleteAgencyById(Long id);
/**
* 树图
*
* @return AgencyVO
*/
List<AgencyVO> agencyList();
}

View File

@ -0,0 +1,157 @@
package com.xinelu.manage.service.agency.impl;
import com.xinelu.common.utils.DateUtils;
import com.xinelu.common.utils.StringUtils;
import com.xinelu.manage.domain.agency.Agency;
import com.xinelu.manage.mapper.agency.AgencyMapper;
import com.xinelu.manage.service.agency.IAgencyService;
import com.xinelu.manage.vo.agency.AgencyVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
/**
* 机构信息Service业务层处理
*
* @author xinelu
* @date 2024-02-26
*/
@Service
public class AgencyServiceImpl implements IAgencyService {
@Resource
private AgencyMapper agencyMapper;
/**
* 查询机构信息
*
* @param id 机构信息主键
* @return 机构信息
*/
@Override
public Agency selectAgencyById(Long id) {
return agencyMapper.selectAgencyById(id);
}
/**
* 查询机构信息列表
*
* @param agency 机构信息
* @return 机构信息
*/
@Override
public List<Agency> selectAgencyList(Agency agency) {
return agencyMapper.selectAgencyList(agency);
}
/**
* 新增机构信息
*
* @param agency 机构信息
* @return 结果
*/
@Override
public int insertAgency(Agency agency) {
agency.setCreateTime(DateUtils.getNowDate());
return agencyMapper.insertAgency(agency);
}
/**
* 修改机构信息
*
* @param agency 机构信息
* @return 结果
*/
@Override
public int updateAgency(Agency agency) {
agency.setUpdateTime(DateUtils.getNowDate());
return agencyMapper.updateAgency(agency);
}
/**
* 批量删除机构信息
*
* @param ids 需要删除的机构信息主键
* @return 结果
*/
@Override
public int deleteAgencyByIds(Long[] ids) {
return agencyMapper.deleteAgencyByIds(ids);
}
/**
* 删除机构信息信息
*
* @param id 机构信息主键
* @return 结果
*/
@Override
public int deleteAgencyById(Long id) {
return agencyMapper.deleteAgencyById(id);
}
/**
* 树图
*
* @return AgencyVO
*/
@Override
public List<AgencyVO> agencyList() {
List<Agency> agencies = agencyMapper.selectAgencyList(null);
List<Agency> agencies1 = buildDeptTree(agencies);
return agencies1.stream().map(AgencyVO::new).collect(Collectors.toList());
}
public List<Agency> buildDeptTree(List<Agency> agencies) {
List<Agency> returnList = new ArrayList<Agency>();
List<Long> tempList = new ArrayList<Long>();
for (Agency agency : agencies) {
tempList.add(agency.getId());
}
for (Agency agency : agencies) {
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(agency.getParentId())) {
recursionFn(agencies, agency);
returnList.add(agency);
}
}
if (returnList.isEmpty()) {
returnList = agencies;
}
return returnList;
}
private void recursionFn(List<Agency> list, Agency t) {
// 得到子节点列表
List<Agency> childList = getChildList(list, t);
t.setChildren(childList);
for (Agency tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
}
private List<Agency> getChildList(List<Agency> list, Agency t) {
List<Agency> tlist = new ArrayList<Agency>();
Iterator<Agency> it = list.iterator();
while (it.hasNext()) {
Agency n = (Agency) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) {
tlist.add(n);
}
}
return tlist;
}
/**
* 判断是否有子节点
*/
private boolean hasChild(List<Agency> list, Agency t) {
return getChildList(list, t).size() > 0;
}
}

View File

@ -0,0 +1,62 @@
package com.xinelu.manage.service.agencycategory;
import com.xinelu.manage.domain.agencycategory.AgencyCategory;
import java.util.List;
/**
* 机构类别Service接口
*
* @author xinelu
* @date 2024-02-26
*/
public interface IAgencyCategoryService {
/**
* 查询机构类别
*
* @param id 机构类别主键
* @return 机构类别
*/
AgencyCategory selectAgencyCategoryById(Long id);
/**
* 查询机构类别列表
*
* @param agencyCategory 机构类别
* @return 机构类别集合
*/
List<AgencyCategory> selectAgencyCategoryList(AgencyCategory agencyCategory);
/**
* 新增机构类别
*
* @param agencyCategory 机构类别
* @return 结果
*/
int insertAgencyCategory(AgencyCategory agencyCategory);
/**
* 修改机构类别
*
* @param agencyCategory 机构类别
* @return 结果
*/
int updateAgencyCategory(AgencyCategory agencyCategory);
/**
* 批量删除机构类别
*
* @param ids 需要删除的机构类别主键集合
* @return 结果
*/
int deleteAgencyCategoryByIds(Long[] ids);
/**
* 删除机构类别信息
*
* @param id 机构类别主键
* @return 结果
*/
int deleteAgencyCategoryById(Long id);
}

View File

@ -0,0 +1,102 @@
package com.xinelu.manage.service.agencycategory.impl;
import com.xinelu.common.constant.Constants;
import com.xinelu.common.utils.DateUtils;
import com.xinelu.common.utils.SecurityUtils;
import com.xinelu.common.utils.codes.GenerateSystemCodeUtil;
import com.xinelu.manage.domain.agencycategory.AgencyCategory;
import com.xinelu.manage.mapper.agencycategory.AgencyCategoryMapper;
import com.xinelu.manage.service.agencycategory.IAgencyCategoryService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 机构类别Service业务层处理
*
* @author xinelu
* @date 2024-02-26
*/
@Service
public class AgencyCategoryServiceImpl implements IAgencyCategoryService {
@Resource
private AgencyCategoryMapper agencyCategoryMapper;
@Resource
private GenerateSystemCodeUtil generateSystemCodeUtil;
/**
* 查询机构类别
*
* @param id 机构类别主键
* @return 机构类别
*/
@Override
public AgencyCategory selectAgencyCategoryById(Long id) {
return agencyCategoryMapper.selectAgencyCategoryById(id);
}
/**
* 查询机构类别列表
*
* @param agencyCategory 机构类别
* @return 机构类别
*/
@Override
public List<AgencyCategory> selectAgencyCategoryList(AgencyCategory agencyCategory) {
return agencyCategoryMapper.selectAgencyCategoryList(agencyCategory);
}
/**
* 新增机构类别
*
* @param agencyCategory 机构类别
* @return 结果
*/
@Override
public int insertAgencyCategory(AgencyCategory agencyCategory) {
if (agencyCategory.getCategoryLevel().equals(1)) {
agencyCategory.setParentCategoryId(null);
}
agencyCategory.setCreateTime(DateUtils.getNowDate());
agencyCategory.setCreateBy(SecurityUtils.getUsername());
agencyCategory.setCategoryCode(Constants.CATEGORY_CODE + generateSystemCodeUtil.generateSystemCode(Constants.CATEGORY_CODE));
return agencyCategoryMapper.insertAgencyCategory(agencyCategory);
}
/**
* 修改机构类别
*
* @param agencyCategory 机构类别
* @return 结果
*/
@Override
public int updateAgencyCategory(AgencyCategory agencyCategory) {
agencyCategory.setUpdateTime(DateUtils.getNowDate());
agencyCategory.setUpdateBy(SecurityUtils.getUsername());
return agencyCategoryMapper.updateAgencyCategory(agencyCategory);
}
/**
* 批量删除机构类别
*
* @param ids 需要删除的机构类别主键
* @return 结果
*/
@Override
public int deleteAgencyCategoryByIds(Long[] ids) {
return agencyCategoryMapper.deleteAgencyCategoryByIds(ids);
}
/**
* 删除机构类别信息
*
* @param id 机构类别主键
* @return 结果
*/
@Override
public int deleteAgencyCategoryById(Long id) {
return agencyCategoryMapper.deleteAgencyCategoryById(id);
}
}

View File

@ -0,0 +1,75 @@
package com.xinelu.manage.vo.agency;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xinelu.common.core.domain.entity.SysMenu;
import com.xinelu.manage.domain.agency.Agency;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* 机构信息对象vo agency
*
* @author xinelu
* @date 2024-02-26
*/
public class AgencyVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 节点ID
*/
private Long id;
/**
* 节点名称
*/
private String label;
/**
* 子节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<AgencyVO> children;
public AgencyVO() {
}
public AgencyVO(Agency agency) {
this.id = agency.getId();
this.label = agency.getAgencyName();
this.children = agency.getChildren().stream().map(AgencyVO::new).collect(Collectors.toList());
}
public AgencyVO(SysMenu menu) {
this.id = menu.getMenuId();
this.label = menu.getMenuName();
this.children = menu.getChildren().stream().map(AgencyVO::new).collect(Collectors.toList());
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<AgencyVO> getChildren() {
return children;
}
public void setChildren(List<AgencyVO> children) {
this.children = children;
}
}

View File

@ -0,0 +1,272 @@
<?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.xinelu.manage.mapper.agency.AgencyMapper">
<resultMap type="Agency" id="AgencyResult">
<result property="id" column="id"/>
<result property="parentId" column="parent_id"/>
<result property="agencyCategoryId" column="agency_category_id"/>
<result property="agencyCategoryName" column="agency_category_name"/>
<result property="areaCode" column="area_code"/>
<result property="areaName" column="area_name"/>
<result property="agencyName" column="agency_name"/>
<result property="agencyCode" column="agency_code"/>
<result property="agencyAbbreviation" column="agency_abbreviation"/>
<result property="agencyStatus" column="agency_status"/>
<result property="nodeType" column="node_type"/>
<result property="orgAgencyCode" column="org_agency_code"/>
<result property="agencyCategoryManageLevel" column="agency_category_manage_level"/>
<result property="agencyContacts" column="agency_contacts"/>
<result property="agencyPhone" column="agency_phone"/>
<result property="agencyAddress" column="agency_address"/>
<result property="agencyRemark" column="agency_remark"/>
<result property="agencySort" column="agency_sort"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectAgencyVo">
select id, parent_id, agency_category_id, agency_category_name, area_code, area_name, agency_name, agency_code, agency_abbreviation, agency_status, node_type, org_agency_code, agency_category_manage_level, agency_contacts, agency_phone, agency_address, agency_remark, agency_sort, create_by, create_time, update_by, update_time from agency
</sql>
<select id="selectAgencyList" parameterType="Agency" resultMap="AgencyResult">
<include refid="selectAgencyVo"/>
<where>
<if test="parentId != null ">
and parent_id = #{parentId}
</if>
<if test="agencyCategoryId != null ">
and agency_category_id = #{agencyCategoryId}
</if>
<if test="agencyCategoryName != null and agencyCategoryName != ''">
and agency_category_name like concat('%', #{agencyCategoryName}, '%')
</if>
<if test="areaCode != null and areaCode != ''">
and area_code = #{areaCode}
</if>
<if test="areaName != null and areaName != ''">
and area_name like concat('%', #{areaName}, '%')
</if>
<if test="agencyName != null and agencyName != ''">
and agency_name like concat('%', #{agencyName}, '%')
</if>
<if test="agencyCode != null and agencyCode != ''">
and agency_code = #{agencyCode}
</if>
<if test="agencyAbbreviation != null and agencyAbbreviation != ''">
and agency_abbreviation = #{agencyAbbreviation}
</if>
<if test="agencyStatus != null and agencyStatus != ''">
and agency_status = #{agencyStatus}
</if>
<if test="nodeType != null and nodeType != ''">
and node_type = #{nodeType}
</if>
<if test="orgAgencyCode != null and orgAgencyCode != ''">
and org_agency_code = #{orgAgencyCode}
</if>
<if test="agencyCategoryManageLevel != null and agencyCategoryManageLevel != ''">
and agency_category_manage_level = #{agencyCategoryManageLevel}
</if>
<if test="agencyContacts != null and agencyContacts != ''">
and agency_contacts = #{agencyContacts}
</if>
<if test="agencyPhone != null and agencyPhone != ''">
and agency_phone = #{agencyPhone}
</if>
<if test="agencyAddress != null and agencyAddress != ''">
and agency_address = #{agencyAddress}
</if>
<if test="agencyRemark != null and agencyRemark != ''">
and agency_remark = #{agencyRemark}
</if>
<if test="agencySort != null ">
and agency_sort = #{agencySort}
</if>
</where>
</select>
<select id="selectAgencyById" parameterType="Long"
resultMap="AgencyResult">
<include refid="selectAgencyVo"/>
where id = #{id}
</select>
<insert id="insertAgency" parameterType="Agency" useGeneratedKeys="true"
keyProperty="id">
insert into agency
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,
</if>
<if test="agencyCategoryId != null">agency_category_id,
</if>
<if test="agencyCategoryName != null">agency_category_name,
</if>
<if test="areaCode != null">area_code,
</if>
<if test="areaName != null">area_name,
</if>
<if test="agencyName != null">agency_name,
</if>
<if test="agencyCode != null">agency_code,
</if>
<if test="agencyAbbreviation != null">agency_abbreviation,
</if>
<if test="agencyStatus != null">agency_status,
</if>
<if test="nodeType != null">node_type,
</if>
<if test="orgAgencyCode != null">org_agency_code,
</if>
<if test="agencyCategoryManageLevel != null">agency_category_manage_level,
</if>
<if test="agencyContacts != null">agency_contacts,
</if>
<if test="agencyPhone != null">agency_phone,
</if>
<if test="agencyAddress != null">agency_address,
</if>
<if test="agencyRemark != null">agency_remark,
</if>
<if test="agencySort != null">agency_sort,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},
</if>
<if test="agencyCategoryId != null">#{agencyCategoryId},
</if>
<if test="agencyCategoryName != null">#{agencyCategoryName},
</if>
<if test="areaCode != null">#{areaCode},
</if>
<if test="areaName != null">#{areaName},
</if>
<if test="agencyName != null">#{agencyName},
</if>
<if test="agencyCode != null">#{agencyCode},
</if>
<if test="agencyAbbreviation != null">#{agencyAbbreviation},
</if>
<if test="agencyStatus != null">#{agencyStatus},
</if>
<if test="nodeType != null">#{nodeType},
</if>
<if test="orgAgencyCode != null">#{orgAgencyCode},
</if>
<if test="agencyCategoryManageLevel != null">#{agencyCategoryManageLevel},
</if>
<if test="agencyContacts != null">#{agencyContacts},
</if>
<if test="agencyPhone != null">#{agencyPhone},
</if>
<if test="agencyAddress != null">#{agencyAddress},
</if>
<if test="agencyRemark != null">#{agencyRemark},
</if>
<if test="agencySort != null">#{agencySort},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
</trim>
</insert>
<update id="updateAgency" parameterType="Agency">
update agency
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id =
#{parentId},
</if>
<if test="agencyCategoryId != null">agency_category_id =
#{agencyCategoryId},
</if>
<if test="agencyCategoryName != null">agency_category_name =
#{agencyCategoryName},
</if>
<if test="areaCode != null">area_code =
#{areaCode},
</if>
<if test="areaName != null">area_name =
#{areaName},
</if>
<if test="agencyName != null">agency_name =
#{agencyName},
</if>
<if test="agencyCode != null">agency_code =
#{agencyCode},
</if>
<if test="agencyAbbreviation != null">agency_abbreviation =
#{agencyAbbreviation},
</if>
<if test="agencyStatus != null">agency_status =
#{agencyStatus},
</if>
<if test="nodeType != null">node_type =
#{nodeType},
</if>
<if test="orgAgencyCode != null">org_agency_code =
#{orgAgencyCode},
</if>
<if test="agencyCategoryManageLevel != null">agency_category_manage_level =
#{agencyCategoryManageLevel},
</if>
<if test="agencyContacts != null">agency_contacts =
#{agencyContacts},
</if>
<if test="agencyPhone != null">agency_phone =
#{agencyPhone},
</if>
<if test="agencyAddress != null">agency_address =
#{agencyAddress},
</if>
<if test="agencyRemark != null">agency_remark =
#{agencyRemark},
</if>
<if test="agencySort != null">agency_sort =
#{agencySort},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAgencyById" parameterType="Long">
delete from agency where id = #{id}
</delete>
<delete id="deleteAgencyByIds" parameterType="String">
delete from agency where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>