居住信息代码移植

This commit is contained in:
张恒 2023-10-10 11:19:27 +08:00
parent 8082668114
commit 6811e9638b
8 changed files with 801 additions and 0 deletions

View File

@ -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<CommunityInfoVO> 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<CommunityInfoVO> list = communityInfoService.selectCommunityInfoList(communityInfo);
ExcelUtil<CommunityInfoVO> 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);
}
}

View File

@ -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();
}
}

View File

@ -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<CommunityInfo> communityInfoList;
}

View File

@ -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<CommunityInfoVO> selectCommunityInfoList(CommunityInfoVO communityInfo);
/**
* 新增居住社区信息
*
* @param communityInfo 居住社区信息
* @return 结果
*/
int insertCommunityInfoList(List<CommunityInfo> communityInfo);
/**
* 修改居住社区信息
*
* @param communityInfo 居住社区信息
* @return 结果
*/
int updateCommunityInfo(CommunityInfo communityInfo);
/**
* 批量删除居住社区信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteCommunityInfoByIds(Long[] ids);
}

View File

@ -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<CommunityInfoVO> selectCommunityInfoList(CommunityInfoVO communityInfo);
/**
* 新增居住社区信息
*
* @param communityInfo 居住社区信息
* @return 结果
*/
AjaxResult insertCommunityInfoList(List<CommunityInfo> 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);
}

View File

@ -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<CommunityInfoVO> selectCommunityInfoList(CommunityInfoVO communityInfo) {
List<CommunityInfoVO> communityInfoVOS = communityInfoMapper.selectCommunityInfoList(communityInfo);
List<String> areaCodeList = communityInfoVOS
.stream().filter(Objects::nonNull)
.map(CommunityInfoVO::getAreaCode)
.filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(areaCodeList)) {
return communityInfoVOS;
}
// 获取本护理站的区域信息
List<SysAreaVO> nurseStationAreaByList = sysAreaMapper.getNurseStationAreaByList(areaCodeList);
if (CollectionUtils.isEmpty(nurseStationAreaByList)) {
return communityInfoVOS;
}
//以护理站id进行分组将标签配置信息转为Map集合
Map<String, List<SysAreaVO>> 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> 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));
}
}

View File

@ -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<SysAreaVO> sysAreaVOList;
}

View File

@ -0,0 +1,234 @@
<?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.communityinfo.CommunityInfoMapper">
<resultMap type="CommunityInfo" id="CommunityInfoResult">
<result property="id" column="id"/>
<result property="areaCode" column="area_code"/>
<result property="communityCode" column="community_code"/>
<result property="communityName" column="community_name"/>
<result property="communityLongitude" column="community_longitude"/>
<result property="communityLatitude" column="community_latitude"/>
<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="selectCommunityInfoVo">
select id,
area_code,
community_code,
community_name,
community_longitude,
community_latitude,
create_by,
create_time,
update_by,
update_time
from community_info
</sql>
<select id="selectCommunityInfoListD" parameterType="CommunityInfo" resultMap="CommunityInfoResult">
<include refid="selectCommunityInfoVo"/>
<where>
<if test="areaCode != null and areaCode != ''">
and area_code = #{areaCode}
</if>
<if test="communityCode != null and communityCode != ''">
and community_code = #{communityCode}
</if>
<if test="communityName != null and communityName != ''">
and community_name like concat('%', #{communityName}, '%')
</if>
<if test="communityLongitude != null and communityLongitude != ''">
and community_longitude = #{communityLongitude}
</if>
<if test="communityLatitude != null and communityLatitude != ''">
and community_latitude = #{communityLatitude}
</if>
</where>
</select>
<select id="selectCommunityInfoByIdD" parameterType="Long"
resultMap="CommunityInfoResult">
<include refid="selectCommunityInfoVo"/>
where id = #{id}
</select>
<insert id="insertCommunityInfo" parameterType="CommunityInfo" useGeneratedKeys="true"
keyProperty="id">
insert into community_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaCode != null">area_code,
</if>
<if test="communityCode != null">community_code,
</if>
<if test="communityName != null">community_name,
</if>
<if test="communityLongitude != null">community_longitude,
</if>
<if test="communityLatitude != null">community_latitude,
</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="areaCode != null">#{areaCode},
</if>
<if test="communityCode != null">#{communityCode},
</if>
<if test="communityName != null">#{communityName},
</if>
<if test="communityLongitude != null">#{communityLongitude},
</if>
<if test="communityLatitude != null">#{communityLatitude},
</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="updateCommunityInfo" parameterType="CommunityInfo">
update community_info
<trim prefix="SET" suffixOverrides=",">
<if test="areaCode != null">area_code =
#{areaCode},
</if>
<if test="communityCode != null">community_code =
#{communityCode},
</if>
<if test="communityName != null">community_name =
#{communityName},
</if>
<if test="communityLongitude != null">community_longitude =
#{communityLongitude},
</if>
<if test="communityLatitude != null">community_latitude =
#{communityLatitude},
</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="deleteCommunityInfoById" parameterType="Long">
delete
from community_info
where id = #{id}
</delete>
<delete id="deleteCommunityInfoByIds" parameterType="String">
delete from community_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectCommunityInfoList"
resultType="com.xinelu.manage.vo.community.CommunityInfoVO">
select
ci.id,
ci.area_code,
ci.community_code,
ci.community_name,
ci.community_longitude,
ci.community_latitude,
ci.create_by,
ci.create_time,
ci.update_by,
ci.update_time,
sa.area_name
from community_info ci
INNER JOIN sys_area sa ON sa.area_code = ci.area_code
<where>
<if test="areaCode != null and areaCode != ''">
and ci.area_code = #{areaCode}
</if>
<if test="communityCode != null and communityCode != ''">
and ci.community_code = #{communityCode}
</if>
<if test="communityName != null and communityName != ''">
and ci.community_name like concat('%', #{communityName}, '%')
</if>
<if test="communityLongitude != null and communityLongitude != ''">
and ci.community_longitude = #{communityLongitude}
</if>
<if test="communityLatitude != null and communityLatitude != ''">
and ci.community_latitude = #{communityLatitude}
</if>
<if test="areaName!= null and communityLatitude != ''">
and sa.area_name like concat('%'#{areaName},'%')
</if>
</where>
ORDER BY ci.create_time DESC
</select>
<select id="selectCommunityInfoById" parameterType="Long"
resultType="com.xinelu.manage.vo.community.CommunityInfoVO">
select ci.id,
ci.area_code,
ci.community_code,
ci.community_name,
ci.community_longitude,
ci.community_latitude,
ci.create_by,
ci.create_time,
ci.update_by,
ci.update_time,
sa.area_name
from community_info ci
INNER JOIN sys_area sa ON sa.area_code = ci.area_code
where ci.id = #{id}
</select>
<insert id="insertCommunityInfoList" parameterType="java.util.List">
insert into community_info
(
area_code,
community_code,
community_name,
community_longitude,
community_latitude,
create_by,
create_time
)
VALUE
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.areaCode},
#{item.communityCode},
#{item.communityName},
#{item.communityLongitude},
#{item.communityLatitude},
#{item.createBy},
#{item.createTime}
)
</foreach>
</insert>
</mapper>