diff --git a/postdischarge-admin/src/main/resources/template/机构信息导入表.xlsx b/postdischarge-admin/src/main/resources/template/机构信息导入表.xlsx new file mode 100644 index 00000000..8bb9aadd Binary files /dev/null and b/postdischarge-admin/src/main/resources/template/机构信息导入表.xlsx differ diff --git a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java index 9c63c487..4424712d 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java @@ -134,8 +134,23 @@ 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"}; + /** + * Excel文件格式后缀 + */ + public static final String XLSX = "xlsx"; + + /** + * Excel文件格式后缀 + */ + public static final String XLS = "xls"; + /** * 机构类别编码前缀 */ public static final String CATEGORY_CODE = "CC"; + + /** + * 机构信息导入标识 + */ + public static final String AGENCY = "agency"; } diff --git a/postdischarge-common/src/main/java/com/xinelu/common/utils/regex/RegexUtil.java b/postdischarge-common/src/main/java/com/xinelu/common/utils/regex/RegexUtil.java new file mode 100644 index 00000000..f49c51bf --- /dev/null +++ b/postdischarge-common/src/main/java/com/xinelu/common/utils/regex/RegexUtil.java @@ -0,0 +1,63 @@ +package com.xinelu.common.utils.regex; + +import com.xinelu.common.exception.ServiceException; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.regex.Pattern; + +/** + * @Description 正则表达式工具类 + * @Author 纪寒 + * @Date 2022-08-24 13:58:48 + * @Version 1.0 + */ +@Component +public class RegexUtil { + + /** + * 校验手机号码 + * + * @param phone 手机号码 + * @return 校验结果 + */ + public boolean regexPhone(String phone) { + if (StringUtils.isBlank(phone)) { + throw new ServiceException("手机号码不能为空!"); + } + //校验手机号 + String regex = "^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[2567]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\\d{8})$"; + return Pattern.matches(regex, phone); + } + + /** + * 校验身份证号码 + * + * @param cardNo 身份证号码 + * @return 校验结果 + */ + public boolean regexCardNo(String cardNo) { + if (StringUtils.isBlank(cardNo)) { + throw new ServiceException("身份证号不能为空!"); + } + //校验身份证号码 + String regex = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|" + + "(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)"; + return Pattern.matches(regex, cardNo); + } + + /** + * 校验座机手机号码 + * + * @param seatNumber 座机手机号码 + * @return 校验结果 + */ + public boolean regexSeatNumber(String seatNumber) { + if (StringUtils.isBlank(seatNumber)) { + throw new ServiceException("手机号码不能为空!"); + } + //校验座机手机号 + String regex = "^(([0-9]{4,13}))"; + return Pattern.matches(regex, seatNumber); + } +} \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/agency/AgencyController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/agency/AgencyController.java index f282e77d..31361061 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/agency/AgencyController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/agency/AgencyController.java @@ -1,6 +1,7 @@ package com.xinelu.manage.controller.agency; import com.xinelu.common.annotation.Log; +import com.xinelu.common.constant.Constants; import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.page.TableDataInfo; @@ -8,12 +9,15 @@ 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.apache.commons.lang3.StringUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.util.List; +import java.util.Objects; /** * 机构信息Controller @@ -96,4 +100,29 @@ public class AgencyController extends BaseController { public AjaxResult agencyList() { return AjaxResult.success(agencyService.agencyList()); } + + /** + * 导入机构信息 + * + * @param file 模板文件 + * @return 导入结果 + * @throws Exception 异常信息 + */ + @PreAuthorize("@ss.hasPermi('system:agency:importStationInfo')") + @Log(title = "导入机构信息", businessType = BusinessType.IMPORT) + @PostMapping("/insertAgencyImportList") + public AjaxResult insertAgencyImportList(MultipartFile file) throws Exception { + //判断excel里面是否有数据/文件格式 + if (Objects.isNull(file) || StringUtils.isBlank(file.getOriginalFilename())) { + return AjaxResult.error("请选择需要导入的文件!"); + } + // 获取文件名 + String orgName = file.getOriginalFilename(); + if (!orgName.endsWith(Constants.XLSX) && !orgName.endsWith(Constants.XLS)) { + return AjaxResult.error("导入文件格式不正确,请导入xlsx或xls格式的文件!"); + } + ExcelUtil util = new ExcelUtil<>(Agency.class); + List list = util.importExcel(file.getInputStream()); + return agencyService.insertAgencyImportList(list); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/importdownload/ImportDownloadController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/importdownload/ImportDownloadController.java new file mode 100644 index 00000000..f5790d87 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/importdownload/ImportDownloadController.java @@ -0,0 +1,56 @@ +package com.xinelu.manage.controller.importdownload; + +import com.xinelu.common.constant.Constants; +import com.xinelu.common.exception.ServiceException; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.ResourceUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.Objects; + +/** + * 导入与下载Controller + * + * @author zh + * @date 2024-02-26 + */ + +@RestController +@RequestMapping("/system/importDownload") +public class ImportDownloadController { + + /** + * 下载导入模板 + * + * @param fileType 文件类型 + * @param res http请求 + **/ + @RequestMapping("downloadTemplate") + public void download(@RequestParam(value = "fileType") String fileType, HttpServletResponse res) throws IOException { + if (StringUtils.isBlank(fileType)) { + throw new ServiceException("请选择文件类型!"); + } + File file = null; + if (fileType.equals(Constants.AGENCY)) { + file = ResourceUtils.getFile("classpath:template/机构信息导入表.xlsx"); + } + if (Objects.isNull(file)) { + throw new ServiceException("下载导入模板文件失败,请联系管理员!"); + } + res.setCharacterEncoding("UTF-8"); + res.setHeader("Content-Disposition", "inline;filename=" + fileType + ".txt"); + res.setContentType("text/plain;UTF-8"); + ServletOutputStream os = res.getOutputStream(); + byte[] bytes = FileUtils.readFileToByteArray(file); + os.write(bytes); + os.flush(); + os.close(); + } +} \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agency/Agency.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agency/Agency.java index 91a4ab42..28933814 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agency/Agency.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agency/Agency.java @@ -11,9 +11,6 @@ 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 * @@ -37,14 +34,14 @@ public class Agency extends BaseEntity { * 上级机构id */ @ApiModelProperty(value = "上级机构id") - @Excel(name = "上级机构id") + @Excel(name = "上级机构") private Long parentId; /** * 所属机构类别id */ @ApiModelProperty(value = "所属机构类别id") - @Excel(name = "所属机构类别id") + @Excel(name = "所属机构类别") private Long agencyCategoryId; /** @@ -100,7 +97,7 @@ public class Agency extends BaseEntity { * 节点类型,节点类型,卫健委: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") + @Excel(name = "节点类型") private String nodeType; /** @@ -114,7 +111,7 @@ public class Agency extends BaseEntity { * 机构分类管理类别,非营利性医疗机构: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") + @Excel(name = "机构分类管理类别") private String agencyCategoryManageLevel; /** @@ -152,17 +149,6 @@ public class Agency extends BaseEntity { @Excel(name = "机构排序") private Integer agencySort; - private List children = new ArrayList(); - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agencycategory/AgencyCategory.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agencycategory/AgencyCategory.java index 86e53c8f..f99265d1 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agencycategory/AgencyCategory.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/agencycategory/AgencyCategory.java @@ -11,9 +11,6 @@ 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_category * @@ -75,18 +72,6 @@ public class AgencyCategory extends BaseEntity { @Excel(name = "类别概述") private String categoryRemark; - - private List children = new ArrayList(); - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agency/AgencyMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agency/AgencyMapper.java index 499e16b9..dae202aa 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agency/AgencyMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agency/AgencyMapper.java @@ -2,6 +2,7 @@ package com.xinelu.manage.mapper.agency; import com.xinelu.manage.domain.agency.Agency; import com.xinelu.manage.vo.agency.AgencyVO; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -37,6 +38,14 @@ public interface AgencyMapper { */ List selectAgencyList(Agency agency); + /** + * 查询机构信息列表 + * + * @param agency 机构信息 + * @return 机构信息集合 + */ + List selectAgencyVOList(Agency agency); + /** * 新增机构信息 * @@ -68,4 +77,20 @@ public interface AgencyMapper { * @return 结果 */ int deleteAgencyByIds(Long[] ids); + + /** + * 查询所有的机构信息 + * + * @param agencyNames 机构信息集合 + * @return 列表集合信息 + */ + List getAllAgencyInfo(@Param("agencyNames") List agencyNames); + + /** + * 机构信息导入 + * + * @param agencyList 机构信息 + * @return int + **/ + int insertAgencyImportList(List agencyList); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agencycategory/AgencyCategoryMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agencycategory/AgencyCategoryMapper.java index ba0ab704..567d57af 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agencycategory/AgencyCategoryMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/agencycategory/AgencyCategoryMapper.java @@ -1,6 +1,7 @@ package com.xinelu.manage.mapper.agencycategory; import com.xinelu.manage.domain.agencycategory.AgencyCategory; +import com.xinelu.manage.vo.agencycategory.AgencyCategoryVO; import java.util.List; @@ -28,6 +29,14 @@ public interface AgencyCategoryMapper { */ List selectAgencyCategoryList(AgencyCategory agencyCategory); + /** + * 查询机构类别列表 + * + * @param agencyCategory 机构类别 + * @return 机构类别集合 + */ + List selectAgencyCategoryVOList(AgencyCategory agencyCategory); + /** * 新增机构类别 * diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/IAgencyService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/IAgencyService.java index d56e556c..f7d27b97 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/IAgencyService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/IAgencyService.java @@ -1,7 +1,9 @@ package com.xinelu.manage.service.agency; +import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.manage.domain.agency.Agency; import com.xinelu.manage.vo.agency.AgencyTreeVO; +import com.xinelu.manage.vo.agency.AgencyVO; import java.util.List; @@ -19,7 +21,7 @@ public interface IAgencyService { * @param id 机构信息主键 * @return 机构信息 */ - Agency selectAgencyById(Long id); + AgencyVO selectAgencyById(Long id); /** * 查询机构信息列表 @@ -67,4 +69,13 @@ public interface IAgencyService { * @return AgencyVO */ List agencyList(); + + + /** + * 机构信息导入 + * + * @param agencyList 机构信息 + * @return int + **/ + AjaxResult insertAgencyImportList(List agencyList); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/impl/AgencyServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/impl/AgencyServiceImpl.java index 4247fa3e..073b76f6 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/impl/AgencyServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agency/impl/AgencyServiceImpl.java @@ -1,15 +1,27 @@ package com.xinelu.manage.service.agency.impl; +import com.xinelu.common.constant.Constants; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.DateUtils; +import com.xinelu.common.utils.SecurityUtils; import com.xinelu.common.utils.StringUtils; +import com.xinelu.common.utils.bean.BeanUtils; +import com.xinelu.common.utils.codes.GenerateSystemCodeUtil; +import com.xinelu.common.utils.regex.RegexUtil; 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.AgencyTreeVO; +import com.xinelu.manage.vo.agency.AgencyVO; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -25,6 +37,10 @@ import java.util.stream.Collectors; public class AgencyServiceImpl implements IAgencyService { @Resource private AgencyMapper agencyMapper; + @Resource + private RegexUtil regexUtil; + @Resource + private GenerateSystemCodeUtil generateSystemCodeUtil; /** * 查询机构信息 @@ -33,8 +49,8 @@ public class AgencyServiceImpl implements IAgencyService { * @return 机构信息 */ @Override - public Agency selectAgencyById(Long id) { - return agencyMapper.selectAgencyById(id); + public AgencyVO selectAgencyById(Long id) { + return agencyMapper.selectAgencyVOById(id); } /** @@ -101,18 +117,65 @@ public class AgencyServiceImpl implements IAgencyService { */ @Override public List agencyList() { - List agencies = agencyMapper.selectAgencyList(null); - List agenciesTree = buildDeptTree(agencies); + List agencies = agencyMapper.selectAgencyVOList(null); + for (AgencyVO agency : agencies) { + agency.setValue(agency.getId().toString()); + } + List agenciesTree = buildDeptTree(agencies); return agenciesTree.stream().map(AgencyTreeVO::new).collect(Collectors.toList()); } - public List buildDeptTree(List agencies) { - List returnList = new ArrayList(); + /** + * 机构信息导入 + * + * @param agencyList 机构信息 + * @return 导入结果 + **/ + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult insertAgencyImportList(List agencyList) { + //判断添加的数据是否为空 + if (CollectionUtils.isEmpty(agencyList)) { + return AjaxResult.error("请添加机构导入信息!"); + } + //根据护理站名称做去除处理 + List importDataList = agencyList.stream().filter(item -> StringUtils.isNotBlank(item.getAgencyName())).distinct().collect(Collectors.toList()); + //校验联系电话格式是否正确 + Agency agency = importDataList.stream().filter(item -> StringUtils.isNotBlank(item.getAgencyPhone())).filter(item -> BooleanUtils.isFalse(regexUtil.regexPhone(item.getAgencyPhone()))).findFirst().orElse(new Agency()); + if (StringUtils.isNotBlank(agency.getAgencyPhone())) { + return AjaxResult.error("当前机构联系电话:" + agency.getAgencyPhone() + " 格式不正确,请重新录入!"); + } + List agencyNames = importDataList.stream().filter(item -> StringUtils.isNotBlank(item.getAgencyName())).map(Agency::getAgencyName).distinct().collect(Collectors.toList()); + //根据名称查询护理站基本信息 + List allNurseStationInfo = agencyMapper.getAllAgencyInfo(agencyNames); + //做差集,去除数据库中已经存在的护理站信息 + List subtractList = new ArrayList<>(CollectionUtils.subtract(importDataList, allNurseStationInfo)); + if (CollectionUtils.isEmpty(subtractList)) { + return AjaxResult.success(); + } + List saveAgencyList = new ArrayList<>(); + for (Agency item : subtractList) { + item.setCreateBy(SecurityUtils.getUsername()); + item.setCreateTime(new Date()); + item.setAgencyCode(Constants.CATEGORY_CODE + generateSystemCodeUtil.generateSystemCode(Constants.CATEGORY_CODE)); + Agency nurseStations = new Agency(); + BeanUtils.copyProperties(item, nurseStations); + saveAgencyList.add(nurseStations); + } + int insertCount = agencyMapper.insertAgencyImportList(saveAgencyList); + if (insertCount <= 0) { + throw new ServiceException("导入护理站信息失败,请联系管理员!"); + } + return AjaxResult.success(); + } + + public List buildDeptTree(List agencies) { + List returnList = new ArrayList(); List tempList = new ArrayList(); - for (Agency agency : agencies) { + for (AgencyVO agency : agencies) { tempList.add(agency.getId()); } - for (Agency agency : agencies) { + for (AgencyVO agency : agencies) { // 如果是顶级节点, 遍历该父节点的所有子节点 if (!tempList.contains(agency.getParentId())) { recursionFn(agencies, agency); @@ -125,22 +188,22 @@ public class AgencyServiceImpl implements IAgencyService { return returnList; } - private void recursionFn(List list, Agency t) { + private void recursionFn(List list, AgencyVO t) { // 得到子节点列表 - List childList = getChildList(list, t); + List childList = getChildList(list, t); t.setChildren(childList); - for (Agency tChild : childList) { + for (AgencyVO tChild : childList) { if (hasChild(list, tChild)) { recursionFn(list, tChild); } } } - private List getChildList(List list, Agency t) { - List tlist = new ArrayList(); - Iterator it = list.iterator(); + private List getChildList(List list, AgencyVO t) { + List tlist = new ArrayList(); + Iterator it = list.iterator(); while (it.hasNext()) { - Agency n = (Agency) it.next(); + AgencyVO n = (AgencyVO) it.next(); if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) { tlist.add(n); } @@ -151,7 +214,7 @@ public class AgencyServiceImpl implements IAgencyService { /** * 判断是否有子节点 */ - private boolean hasChild(List list, Agency t) { + private boolean hasChild(List list, AgencyVO t) { return getChildList(list, t).size() > 0; } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/IAgencyCategoryService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/IAgencyCategoryService.java index 6433b6b6..356cd00f 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/IAgencyCategoryService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/IAgencyCategoryService.java @@ -2,7 +2,7 @@ package com.xinelu.manage.service.agencycategory; import com.xinelu.manage.domain.agencycategory.AgencyCategory; -import com.xinelu.manage.vo.agencycategory.AgencyCategoryVO; +import com.xinelu.manage.vo.agencycategory.AgencyCategoryTreeVO; import java.util.List; @@ -66,5 +66,5 @@ public interface IAgencyCategoryService { * * @return AgencyVO */ - List agencyCategoryList(); + List agencyCategoryList(); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/impl/AgencyCategoryServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/impl/AgencyCategoryServiceImpl.java index 988b47ac..23af9515 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/impl/AgencyCategoryServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/agencycategory/impl/AgencyCategoryServiceImpl.java @@ -8,6 +8,7 @@ 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 com.xinelu.manage.vo.agencycategory.AgencyCategoryTreeVO; import com.xinelu.manage.vo.agencycategory.AgencyCategoryVO; import org.springframework.stereotype.Service; @@ -111,19 +112,19 @@ public class AgencyCategoryServiceImpl implements IAgencyCategoryService { * @return AgencyCategoryVO */ @Override - public List agencyCategoryList() { - List agencyCategoryList = agencyCategoryMapper.selectAgencyCategoryList(null); - List agencyTree = buildDeptTree(agencyCategoryList); - return agencyTree.stream().map(AgencyCategoryVO::new).collect(Collectors.toList()); + public List agencyCategoryList() { + List agencyCategoryList = agencyCategoryMapper.selectAgencyCategoryVOList(null); + List agencyTree = buildDeptTree(agencyCategoryList); + return agencyTree.stream().map(AgencyCategoryTreeVO::new).collect(Collectors.toList()); } - public List buildDeptTree(List agencyCategoryList) { - List returnList = new ArrayList(); + public List buildDeptTree(List agencyCategoryList) { + List returnList = new ArrayList(); List tempList = new ArrayList(); - for (AgencyCategory agencyCategory : agencyCategoryList) { + for (AgencyCategoryVO agencyCategory : agencyCategoryList) { tempList.add(agencyCategory.getId()); } - for (AgencyCategory agencyCategory : agencyCategoryList) { + for (AgencyCategoryVO agencyCategory : agencyCategoryList) { // 如果是顶级节点, 遍历该父节点的所有子节点 if (!tempList.contains(agencyCategory.getParentCategoryId())) { recursionFn(agencyCategoryList, agencyCategory); @@ -136,22 +137,22 @@ public class AgencyCategoryServiceImpl implements IAgencyCategoryService { return returnList; } - private void recursionFn(List list, AgencyCategory t) { + private void recursionFn(List list, AgencyCategoryVO t) { // 得到子节点列表 - List childList = getChildList(list, t); + List childList = getChildList(list, t); t.setChildren(childList); - for (AgencyCategory tChild : childList) { + for (AgencyCategoryVO tChild : childList) { if (hasChild(list, tChild)) { recursionFn(list, tChild); } } } - private List getChildList(List list, AgencyCategory t) { - List tlist = new ArrayList(); - Iterator it = list.iterator(); + private List getChildList(List list, AgencyCategoryVO t) { + List tlist = new ArrayList(); + Iterator it = list.iterator(); while (it.hasNext()) { - AgencyCategory n = (AgencyCategory) it.next(); + AgencyCategoryVO n = (AgencyCategoryVO) it.next(); if (StringUtils.isNotNull(n.getParentCategoryId()) && n.getParentCategoryId().longValue() == t.getId().longValue()) { tlist.add(n); } @@ -162,7 +163,7 @@ public class AgencyCategoryServiceImpl implements IAgencyCategoryService { /** * 判断是否有子节点 */ - private boolean hasChild(List list, AgencyCategory t) { + private boolean hasChild(List list, AgencyCategoryVO t) { return getChildList(list, t).size() > 0; } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/importdownload/ImportDownloadService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/importdownload/ImportDownloadService.java new file mode 100644 index 00000000..36a3c76f --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/importdownload/ImportDownloadService.java @@ -0,0 +1,10 @@ +package com.xinelu.manage.service.importdownload; + +/** + * 导入Service接口 + * + * @author xinelu + * @date 2024-02-26 + */ +public interface ImportDownloadService { +} \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/importdownload/impl/ImportDownloadServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/importdownload/impl/ImportDownloadServiceImpl.java new file mode 100644 index 00000000..4a519aca --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/importdownload/impl/ImportDownloadServiceImpl.java @@ -0,0 +1,15 @@ +package com.xinelu.manage.service.importdownload.impl; + + +import com.xinelu.manage.service.importdownload.ImportDownloadService; +import org.springframework.stereotype.Service; + +/** + * 导入Service业务层处理 + * + * @author xinelu + * @date 2024-02-26 + */ +@Service +public class ImportDownloadServiceImpl implements ImportDownloadService { +} \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyTreeVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyTreeVO.java index 48dd031f..a1aa51f5 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyTreeVO.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyTreeVO.java @@ -1,8 +1,6 @@ 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; @@ -27,6 +25,11 @@ public class AgencyTreeVO implements Serializable { */ private String label; + /** + * 节点名称 + */ + private String value; + /** * 子节点 */ @@ -37,18 +40,13 @@ public class AgencyTreeVO implements Serializable { } - public AgencyTreeVO(Agency agency) { + public AgencyTreeVO(AgencyVO agency) { this.id = agency.getId(); this.label = agency.getAgencyName(); + this.value = agency.getValue(); this.children = agency.getChildren().stream().map(AgencyTreeVO::new).collect(Collectors.toList()); } - public AgencyTreeVO(SysMenu menu) { - this.id = menu.getMenuId(); - this.label = menu.getMenuName(); - this.children = menu.getChildren().stream().map(AgencyTreeVO::new).collect(Collectors.toList()); - } - public Long getId() { return id; } @@ -65,6 +63,14 @@ public class AgencyTreeVO implements Serializable { this.label = label; } + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + public List getChildren() { return children; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyVO.java index 8098626f..010a5e19 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyVO.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agency/AgencyVO.java @@ -1,6 +1,11 @@ package com.xinelu.manage.vo.agency; import com.xinelu.manage.domain.agency.Agency; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.ArrayList; +import java.util.List; /** * 机构树图信息对象vo agency @@ -8,8 +13,25 @@ import com.xinelu.manage.domain.agency.Agency; * @author xinelu * @date 2024-02-26 */ + +@EqualsAndHashCode(callSuper = true) +@Data public class AgencyVO extends Agency { - private String a; + /** + * 上级机构 + */ + private String parentAgencyName; + private String value; + + private List children = new ArrayList(); + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agencycategory/AgencyCategoryTreeVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agencycategory/AgencyCategoryTreeVO.java new file mode 100644 index 00000000..af1224ae --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agencycategory/AgencyCategoryTreeVO.java @@ -0,0 +1,69 @@ +package com.xinelu.manage.vo.agencycategory; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +public class AgencyCategoryTreeVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 节点ID + */ + private Long id; + + /** + * 节点名称 + */ + private String label; + + private String value; + + /** + * 子节点 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public AgencyCategoryTreeVO(AgencyCategoryVO agencyCategory) { + this.id = agencyCategory.getId(); + this.label = agencyCategory.getCategoryName(); + this.value = agencyCategory.getValue(); + this.children = agencyCategory.getChildren().stream().map(AgencyCategoryTreeVO::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 String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } +} \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agencycategory/AgencyCategoryVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agencycategory/AgencyCategoryVO.java index 19a21e37..b4062f1f 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agencycategory/AgencyCategoryVO.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/agencycategory/AgencyCategoryVO.java @@ -1,43 +1,25 @@ package com.xinelu.manage.vo.agencycategory; -import com.fasterxml.jackson.annotation.JsonInclude; import com.xinelu.manage.domain.agencycategory.AgencyCategory; +import lombok.Data; +import lombok.EqualsAndHashCode; -import java.io.Serializable; +import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; -public class AgencyCategoryVO implements Serializable { +@EqualsAndHashCode(callSuper = true) +@Data +public class AgencyCategoryVO extends AgencyCategory { - private static final long serialVersionUID = 1L; + private String value; - /** - * 节点ID - */ - private Long id; + private List children = new ArrayList(); - /** - * 节点名称 - */ - private String label; - - /** - * 子节点 - */ - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List children; - - public AgencyCategoryVO(AgencyCategory agencyCategory) { - this.id = agencyCategory.getId(); - this.label = agencyCategory.getCategoryName(); - this.children = agencyCategory.getChildren().stream().map(AgencyCategoryVO::new).collect(Collectors.toList()); + public List getChildren() { + return children; } - public Long getId() { - return id; + public void setChildren(List children) { + this.children = children; } - - public void setId(Long id) { - this.id = id; - } -} \ No newline at end of file +} diff --git a/postdischarge-manage/src/main/resources/mapper/manage/agency/AgencyMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/agency/AgencyMapper.xml index a396d67e..ded4c9b9 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/agency/AgencyMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/agency/AgencyMapper.xml @@ -5,32 +5,54 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - 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 + 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 + + + insert into agency - 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, - + 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, + - #{parentId}, - - #{agencyCategoryId}, - - #{agencyCategoryName}, - - #{areaCode}, - - #{areaName}, - - #{agencyName}, - - #{agencyCode}, - - #{agencyAbbreviation}, - - #{agencyStatus}, - - #{nodeType}, - - #{orgAgencyCode}, - - #{agencyCategoryManageLevel}, - - #{agencyContacts}, - - #{agencyPhone}, - - #{agencyAddress}, - - #{agencyRemark}, - - #{agencySort}, - - #{createBy}, - - #{createTime}, - - #{updateBy}, - - #{updateTime}, - + #{parentId}, + + #{agencyCategoryId}, + + #{agencyCategoryName}, + + #{areaCode}, + + #{areaName}, + + #{agencyName}, + + #{agencyCode}, + + #{agencyAbbreviation}, + + #{agencyStatus}, + + #{nodeType}, + + #{orgAgencyCode}, + + #{agencyCategoryManageLevel}, + + #{agencyContacts}, + + #{agencyPhone}, + + #{agencyAddress}, + + #{agencyRemark}, + + #{agencySort}, + + #{createBy}, + + #{createTime}, + + #{updateBy}, + + #{updateTime}, + update agency - parent_id = - #{parentId}, - - agency_category_id = - #{agencyCategoryId}, - - agency_category_name = - #{agencyCategoryName}, - - area_code = - #{areaCode}, - - area_name = - #{areaName}, - - agency_name = - #{agencyName}, - - agency_code = - #{agencyCode}, - - agency_abbreviation = - #{agencyAbbreviation}, - - agency_status = - #{agencyStatus}, - - node_type = - #{nodeType}, - - org_agency_code = - #{orgAgencyCode}, - - agency_category_manage_level = - #{agencyCategoryManageLevel}, - - agency_contacts = - #{agencyContacts}, - - agency_phone = - #{agencyPhone}, - - agency_address = - #{agencyAddress}, - - agency_remark = - #{agencyRemark}, - - agency_sort = - #{agencySort}, - - create_by = - #{createBy}, - - create_time = - #{createTime}, - - update_by = - #{updateBy}, - - update_time = - #{updateTime}, - + parent_id = + #{parentId}, + + agency_category_id = + #{agencyCategoryId}, + + agency_category_name = + #{agencyCategoryName}, + + area_code = + #{areaCode}, + + area_name = + #{areaName}, + + agency_name = + #{agencyName}, + + agency_code = + #{agencyCode}, + + agency_abbreviation = + #{agencyAbbreviation}, + + agency_status = + #{agencyStatus}, + + node_type = + #{nodeType}, + + org_agency_code = + #{orgAgencyCode}, + + agency_category_manage_level = + #{agencyCategoryManageLevel}, + + agency_contacts = + #{agencyContacts}, + + agency_phone = + #{agencyPhone}, + + agency_address = + #{agencyAddress}, + + agency_remark = + #{agencyRemark}, + + agency_sort = + #{agencySort}, + + create_by = + #{createBy}, + + create_time = + #{createTime}, + + update_by = + #{updateBy}, + + update_time = + #{updateTime}, + where id = #{id} - delete from agency where id = #{id} + delete + from agency + where id = #{id} @@ -293,4 +321,82 @@ #{id} + + + + + insert into agency( + select + 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 + ) values + + ( + #{Agency.parentId}, + #{Agency.agencyCategoryId}, + #{Agency.agencyCategoryName}, + #{Agency.areaCode}, + #{Agency.areaName}, + #{Agency.agencyName}, + #{Agency.agencyCode}, + #{Agency.agencyAbbreviation}, + #{Agency.agencyStatus}, + #{Agency.nodeType}, + #{Agency.orgAgencyCode}, + #{Agency.agencyCategoryManageLevel}, + #{Agency.agencyContacts}, + #{Agency.agencyPhone}, + #{Agency.agencyAddress}, + #{Agency.agencyRemark}, + #{Agency.agencySort} + ) + + \ No newline at end of file diff --git a/postdischarge-manage/src/main/resources/mapper/manage/agencycategory/AgencyCategoryMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/agencycategory/AgencyCategoryMapper.xml index 946bf6e5..1c3e5876 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/agencycategory/AgencyCategoryMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/agencycategory/AgencyCategoryMapper.xml @@ -57,6 +57,10 @@ + +