From 6811e9638b85f0eb3971aa95ae9373954c7a3a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=81=92?= <3226558941@qq.com> Date: Tue, 10 Oct 2023 11:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=85=E4=BD=8F=E4=BF=A1=E6=81=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=A7=BB=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../communityinfo/CommunityController.java | 122 +++++++++ .../domain/communityinfo/CommunityInfo.java | 93 +++++++ .../dto/community/CommunityInfoDTO.java | 23 ++ .../communityinfo/CommunityInfoMapper.java | 56 +++++ .../communityinfo/ICommunityInfoService.java | 72 ++++++ .../impl/CommunityInfoServiceImpl.java | 171 +++++++++++++ .../manage/vo/community/CommunityInfoVO.java | 30 +++ .../communityinfo/CommunityInfoMapper.xml | 234 ++++++++++++++++++ 8 files changed, 801 insertions(+) create mode 100644 xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/communityinfo/CommunityController.java create mode 100644 xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/communityinfo/CommunityInfo.java create mode 100644 xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/community/CommunityInfoDTO.java create mode 100644 xinelu-nurse-manage/src/main/java/com/xinelu/manage/mapper/communityinfo/CommunityInfoMapper.java create mode 100644 xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/ICommunityInfoService.java create mode 100644 xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/impl/CommunityInfoServiceImpl.java create mode 100644 xinelu-nurse-manage/src/main/java/com/xinelu/manage/vo/community/CommunityInfoVO.java create mode 100644 xinelu-nurse-manage/src/main/resources/mapper/manage/communityinfo/CommunityInfoMapper.xml diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/communityinfo/CommunityController.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/communityinfo/CommunityController.java new file mode 100644 index 0000000..296c344 --- /dev/null +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/communityinfo/CommunityController.java @@ -0,0 +1,122 @@ +package com.xinelu.manage.controller.communityinfo; + +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.custominterface.Insert; +import com.xinelu.common.custominterface.Update; +import com.xinelu.common.enums.BusinessType; +import com.xinelu.common.utils.poi.ExcelUtil; +import com.xinelu.manage.domain.communityinfo.CommunityInfo; +import com.xinelu.manage.dto.community.CommunityInfoDTO; +import com.xinelu.manage.service.communityinfo.ICommunityInfoService; +import com.xinelu.manage.vo.community.CommunityInfoVO; +import org.springframework.security.access.prepost.PreAuthorize; + +import org.springframework.validation.annotation.Validated; +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 xinyilu + * @date 2022-09-13 + */ +@RestController +@RequestMapping("/system/communityInfo") +public class CommunityController extends BaseController { + @Resource + private ICommunityInfoService communityInfoService; + + /** + * 查询居住社区信息列表 + */ + @PreAuthorize("@ss.hasPermi('system:communityInfo:list')") + @GetMapping("/list") + public TableDataInfo list(CommunityInfoVO communityInfo) { + startPage(); + List list = communityInfoService.selectCommunityInfoList(communityInfo); + return getDataTable(list); + } + + /** + * 导出居住社区信息列表 + */ + @PreAuthorize("@ss.hasPermi('system:communityInfo:export')") + @Log(title = "居住社区信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, CommunityInfoVO communityInfo) { + List list = communityInfoService.selectCommunityInfoList(communityInfo); + ExcelUtil util = new ExcelUtil<>(CommunityInfoVO.class); + util.exportExcel(response, list, "居住社区信息数据"); + } + + /** + * 获取居住社区信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:communityInfo:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(communityInfoService.selectCommunityInfoById(id)); + } + + /** + * 新增居住社区信息 + */ + @PreAuthorize("@ss.hasPermi('system:communityInfo:add')") + @Log(title = "居住社区信息", businessType = BusinessType.INSERT) + @PostMapping(value = "/add") + public AjaxResult add(@Validated(Insert.class) @RequestBody CommunityInfoDTO communityInfo) throws Exception { + return communityInfoService.insertCommunityInfoList(communityInfo.getCommunityInfoList()); + } + + /** + * 修改居住社区信息 + */ + @PreAuthorize("@ss.hasPermi('system:communityInfo:edit')") + @Log(title = "居住社区信息", businessType = BusinessType.UPDATE) + @PostMapping(value = "/edit") + public AjaxResult edit(@Validated(Update.class) @RequestBody CommunityInfo communityInfo) throws Exception { + return communityInfoService.updateCommunityInfo(communityInfo); + } + + /** + * 删除居住社区信息 + */ + @PreAuthorize("@ss.hasPermi('system:communityInfo:remove')") + @Log(title = "居住社区信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(communityInfoService.deleteCommunityInfoByIds(ids)); + } + + /** + * 查询省级区域信息信息 + * + * @return 省级区域信息集合 + */ + @GetMapping("/getFirstLevelInfo") + public AjaxResult getFirstLevelInfo() { + return communityInfoService.getProvinceAreaInfo(); + } + + /** + * 根据父级id + * + * @param parentId 父级id + * @return 所属下级区域信息集合 + */ + @GetMapping("/getSecondaryLevelInfo") + public AjaxResult getSecondaryLevelInfo(Long parentId) { + if (Objects.isNull(parentId)) { + return AjaxResult.error("上级区域id不能为空"); + } + return communityInfoService.getSubordinateAreaInfo(parentId); + } +} \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/communityinfo/CommunityInfo.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/communityinfo/CommunityInfo.java new file mode 100644 index 0000000..0ee0cd4 --- /dev/null +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/domain/communityinfo/CommunityInfo.java @@ -0,0 +1,93 @@ +package com.xinelu.manage.domain.communityinfo; + +import com.xinelu.common.annotation.Excel; +import com.xinelu.common.core.domain.BaseDomain; +import com.xinelu.common.custominterface.Insert; +import com.xinelu.common.custominterface.Update; +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 javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 居住社区信息对象 community_info + * + * @author xinyilu + * @date 2022-09-13 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "居住社区信息对象", description = "community_info") +public class CommunityInfo extends BaseDomain implements Serializable { + private static final long serialVersionUID = -1144563330958336472L; + /** + * 主键id + */ + @NotNull(message = "居住社区id不能为空", groups = {Update.class}) + private Long id; + + /** + * 所属区域编码 + */ + @NotNull(message = "所属区域编码不能为空", groups = {Insert.class, Update.class}) + @ApiModelProperty(value = "所属区域编码") + @Excel(name = "所属区域编码") + private String areaCode; + + /** + * 社区编码 + */ + @ApiModelProperty(value = "社区编码") + @Excel(name = "社区编码") + private String communityCode; + + /** + * 社区名称 + */ + @NotBlank(message = "社区名称", groups = {Insert.class, Update.class}) + @ApiModelProperty(value = "社区名称") + @Excel(name = "社区名称") + private String communityName; + + /** + * 社区经度 + */ + + @ApiModelProperty(value = "社区经度") + @Excel(name = "社区经度") + private String communityLongitude; + + /** + * 社区纬度 + */ + @ApiModelProperty(value = "社区纬度") + @Excel(name = "社区纬度") + private String communityLatitude; + + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("areaCode", getAreaCode()) + .append("communityCode", getCommunityCode()) + .append("communityName", getCommunityName()) + .append("communityLongitude", getCommunityLongitude()) + .append("communityLatitude", getCommunityLatitude()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/community/CommunityInfoDTO.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/community/CommunityInfoDTO.java new file mode 100644 index 0000000..06a1297 --- /dev/null +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/dto/community/CommunityInfoDTO.java @@ -0,0 +1,23 @@ +package com.xinelu.manage.dto.community; + +import com.xinelu.manage.domain.communityinfo.CommunityInfo; +import lombok.Data; + +import javax.validation.Valid; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 居住社区接收集合 + * @Author zhangheng + * @Date 2022-09-09 + */ +@Data +public class CommunityInfoDTO implements Serializable { + private static final long serialVersionUID = -8215685222114894288L; + /** + * 信息集合 + */ + @Valid + private List communityInfoList; +} \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/mapper/communityinfo/CommunityInfoMapper.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/mapper/communityinfo/CommunityInfoMapper.java new file mode 100644 index 0000000..3dda8e0 --- /dev/null +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/mapper/communityinfo/CommunityInfoMapper.java @@ -0,0 +1,56 @@ +package com.xinelu.manage.mapper.communityinfo; + + +import com.xinelu.manage.domain.communityinfo.CommunityInfo; +import com.xinelu.manage.vo.community.CommunityInfoVO; + +import java.util.List; + + +/** + * 居住社区信息Mapper接口 + * + * @author xinyilu + * @date 2022-09-13 + */ +public interface CommunityInfoMapper { + /** + * 查询居住社区信息 + * + * @param id 居住社区信息主键 + * @return 居住社区信息 + */ + CommunityInfoVO selectCommunityInfoById(Long id); + + /** + * 查询居住社区信息列表 + * + * @param communityInfo 居住社区信息 + * @return 居住社区信息集合 + */ + List selectCommunityInfoList(CommunityInfoVO communityInfo); + + /** + * 新增居住社区信息 + * + * @param communityInfo 居住社区信息 + * @return 结果 + */ + int insertCommunityInfoList(List communityInfo); + + /** + * 修改居住社区信息 + * + * @param communityInfo 居住社区信息 + * @return 结果 + */ + int updateCommunityInfo(CommunityInfo communityInfo); + + /** + * 批量删除居住社区信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteCommunityInfoByIds(Long[] ids); +} \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/ICommunityInfoService.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/ICommunityInfoService.java new file mode 100644 index 0000000..ebbb89e --- /dev/null +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/ICommunityInfoService.java @@ -0,0 +1,72 @@ +package com.xinelu.manage.service.communityinfo; + + +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.manage.domain.communityinfo.CommunityInfo; +import com.xinelu.manage.vo.community.CommunityInfoVO; + +import java.util.List; + + +/** + * 居住社区信息Service接口 + * + * @author xinyilu + * @date 2022-09-13 + */ +public interface ICommunityInfoService { + /** + * 查询居住社区信息 + * + * @param id 居住社区信息主键 + * @return 居住社区信息 + */ + CommunityInfoVO selectCommunityInfoById(Long id); + + /** + * 查询居住社区信息列表 + * + * @param communityInfo 居住社区信息 + * @return 居住社区信息集合 + */ + List selectCommunityInfoList(CommunityInfoVO communityInfo); + + /** + * 新增居住社区信息 + * + * @param communityInfo 居住社区信息 + * @return 结果 + */ + AjaxResult insertCommunityInfoList(List communityInfo) throws Exception; + + /** + * 修改居住社区信息 + * + * @param communityInfo 居住社区信息 + * @return 结果 + */ + AjaxResult updateCommunityInfo(CommunityInfo communityInfo) throws Exception; + + /** + * 批量删除居住社区信息 + * + * @param ids 需要删除的居住社区信息主键集合 + * @return 结果 + */ + int deleteCommunityInfoByIds(Long[] ids); + + /** + * 查询省级区域信息信息 + * + * @return 省级区域信息集合 + */ + AjaxResult getProvinceAreaInfo(); + + /** + * 根据父id查询其下属区域信息 + * + * @param parentId 父级区域id + * @return 下属区域信息集合 + */ + AjaxResult getSubordinateAreaInfo(Long parentId); +} \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/impl/CommunityInfoServiceImpl.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/impl/CommunityInfoServiceImpl.java new file mode 100644 index 0000000..d85e030 --- /dev/null +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/communityinfo/impl/CommunityInfoServiceImpl.java @@ -0,0 +1,171 @@ +package com.xinelu.manage.service.communityinfo.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.SecurityUtils; +import com.xinelu.common.utils.codes.GenerateSystemCodeUtil; +import com.xinelu.manage.domain.communityinfo.CommunityInfo; +import com.xinelu.manage.domain.sysarea.SysArea; +import com.xinelu.manage.mapper.communityinfo.CommunityInfoMapper; +import com.xinelu.manage.mapper.sysarea.SysAreaMapper; +import com.xinelu.manage.service.communityinfo.ICommunityInfoService; +import com.xinelu.manage.vo.community.CommunityInfoVO; +import com.xinelu.manage.vo.sysarea.SysAreaVO; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * 居住社区信息Service业务层处理 + * + * @author xinyilu + * @date 2022-09-13 + */ +@Service +public class CommunityInfoServiceImpl implements ICommunityInfoService { + + @Resource + private CommunityInfoMapper communityInfoMapper; + + @Resource + private SysAreaMapper sysAreaMapper; + + @Resource + private GenerateSystemCodeUtil generateSystemCodeUtil; + + /** + * 查询居住社区信息 + * + * @param id 居住社区信息主键 + * @return 居住社区信息 + */ + @Override + public CommunityInfoVO selectCommunityInfoById(Long id) { + return communityInfoMapper.selectCommunityInfoById(id); + } + + /** + * 查询居住社区信息列表 + * + * @param communityInfo 居住社区信息 + * @return 居住社区信息 + */ + @Override + public List selectCommunityInfoList(CommunityInfoVO communityInfo) { + List communityInfoVOS = communityInfoMapper.selectCommunityInfoList(communityInfo); + List areaCodeList = communityInfoVOS + .stream().filter(Objects::nonNull) + .map(CommunityInfoVO::getAreaCode) + .filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()); + + if (CollectionUtils.isEmpty(areaCodeList)) { + return communityInfoVOS; + } + // 获取本护理站的区域信息 + List nurseStationAreaByList = sysAreaMapper.getNurseStationAreaByList(areaCodeList); + if (CollectionUtils.isEmpty(nurseStationAreaByList)) { + return communityInfoVOS; + } + //以护理站id进行分组将标签配置信息转为Map集合 + Map> nurseStationAreaMap = nurseStationAreaByList.stream() + .filter(Objects::nonNull) + .filter(item -> Objects.nonNull(item.getStreetCode())) + .collect(Collectors.groupingBy(SysAreaVO::getStreetCode)); + communityInfoVOS.forEach(item -> + item.setSysAreaVOList(nurseStationAreaMap.getOrDefault(Objects.isNull(item.getAreaCode()) ? 0L : item.getAreaCode(), Lists.newArrayList()))); + return communityInfoVOS; + } + + /** + * 新增居住社区信息 + * + * @param communityInfo 居住社区信息 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult insertCommunityInfoList(List communityInfo) throws Exception { + if (CollectionUtils.isEmpty(communityInfo)) { + return AjaxResult.error("请添加数据"); + } + //插如数据 + for (CommunityInfo community : communityInfo) { + community.setCreateTime(LocalDateTime.now()); + community.setCreateBy(SecurityUtils.getUsername()); + //编号生成 + community.setCommunityCode(Constants.COMMUNITY_CODE + + generateSystemCodeUtil.generateSystemCode(Constants.COMMUNITY_CODE)); + } + //批量新增 + int infoList = communityInfoMapper.insertCommunityInfoList(communityInfo); + if (infoList <= 0) { + throw new ServiceException("新增居住社区信息失败,请联系管理员!"); + } + return AjaxResult.success(); + } + + /** + * 修改居住社区信息 + * + * @param communityInfo 居住社区信息 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult updateCommunityInfo(CommunityInfo communityInfo) throws Exception { + communityInfo.setUpdateTime(LocalDateTime.now()); + communityInfo.setUpdateBy(SecurityUtils.getUsername()); + int updateCommunityInfo = communityInfoMapper.updateCommunityInfo(communityInfo); + if (updateCommunityInfo <= 0) { + throw new ServiceException("修改居住社区信息失败,请联系管理员!"); + } + return AjaxResult.success(); + } + + /** + * 批量删除居住社区信息 + * + * @param ids 需要删除的居住社区信息主键 + * @return 结果 + */ + @Override + public int deleteCommunityInfoByIds(Long[] ids) { + return communityInfoMapper.deleteCommunityInfoByIds(ids); + } + + /** + * 查询省级区域信息信息 + * + * @return 省级区域信息集合 + */ + @Override + public AjaxResult getProvinceAreaInfo() { + SysArea area = new SysArea(); + area.setAreaLevel(1); + return AjaxResult.success(sysAreaMapper.selectSysAreaList(area)); + } + + /** + * 根据父id查询其下属区域信息 + * + * @param parentId 父级区域id + * @return 下属区域信息集合 + */ + @Override + public AjaxResult getSubordinateAreaInfo(Long parentId) { + SysArea area = new SysArea(); + area.setParentId(parentId); + return AjaxResult.success(sysAreaMapper.selectSysAreaList(area)); + } +} \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/vo/community/CommunityInfoVO.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/vo/community/CommunityInfoVO.java new file mode 100644 index 0000000..6d7a476 --- /dev/null +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/vo/community/CommunityInfoVO.java @@ -0,0 +1,30 @@ +package com.xinelu.manage.vo.community; + +import com.xinelu.manage.domain.communityinfo.CommunityInfo; +import com.xinelu.manage.vo.sysarea.SysAreaVO; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 居住社区传输实体类 + * @Author zhangheng + * @Date 2022-09-09 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class CommunityInfoVO extends CommunityInfo implements Serializable { + private static final long serialVersionUID = -236808776108105744L; + /** + * 区域名称 + */ + private String areaName; + + /** + * 护理站区域集合 + */ + List sysAreaVOList; + +} \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/resources/mapper/manage/communityinfo/CommunityInfoMapper.xml b/xinelu-nurse-manage/src/main/resources/mapper/manage/communityinfo/CommunityInfoMapper.xml new file mode 100644 index 0000000..d3eb0a7 --- /dev/null +++ b/xinelu-nurse-manage/src/main/resources/mapper/manage/communityinfo/CommunityInfoMapper.xml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + select id, + area_code, + community_code, + community_name, + community_longitude, + community_latitude, + create_by, + create_time, + update_by, + update_time + from community_info + + + + + + + + insert into community_info + + area_code, + + community_code, + + community_name, + + community_longitude, + + community_latitude, + + create_by, + + create_time, + + update_by, + + update_time, + + + + #{areaCode}, + + #{communityCode}, + + #{communityName}, + + #{communityLongitude}, + + #{communityLatitude}, + + #{createBy}, + + #{createTime}, + + #{updateBy}, + + #{updateTime}, + + + + + + update community_info + + area_code = + #{areaCode}, + + community_code = + #{communityCode}, + + community_name = + #{communityName}, + + community_longitude = + #{communityLongitude}, + + community_latitude = + #{communityLatitude}, + + create_by = + #{createBy}, + + create_time = + #{createTime}, + + update_by = + #{updateBy}, + + update_time = + #{updateTime}, + + + where id = #{id} + + + + delete + from community_info + where id = #{id} + + + + delete from community_info where id in + + #{id} + + + + + + + + + insert into community_info + ( + area_code, + community_code, + community_name, + community_longitude, + community_latitude, + create_by, + create_time + ) + VALUE + + ( + #{item.areaCode}, + #{item.communityCode}, + #{item.communityName}, + #{item.communityLongitude}, + #{item.communityLatitude}, + #{item.createBy}, + #{item.createTime} + ) + + + \ No newline at end of file