[新增]导入特殊人群信息,导入小区,导入楼栋和网格信息
| | |
| | | <artifactId>commons-codec</artifactId> |
| | | <version>1.9</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>5.6.7</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.esotericsoftware</groupId> |
| | | <artifactId>reflectasm</artifactId> |
| | | <version>1.11.9</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | |
New file |
| | |
| | | package com.panzhihua.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 婚姻状况 |
| | | * |
| | | * @author huanghongfa |
| | | */ |
| | | @Getter |
| | | public enum KeyPersonLabelEnum |
| | | { |
| | | XD(1, "吸毒人员"), |
| | | ZJ(2, "重精人员"), |
| | | XJ(3, "邪教人员"), |
| | | QT(4, "其他重点人员"); |
| | | |
| | | private final Integer code; |
| | | private final String name; |
| | | |
| | | KeyPersonLabelEnum(Integer code, String name) |
| | | { |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | |
| | | public static int getCodeByName(String name) { |
| | | for (KeyPersonLabelEnum item : KeyPersonLabelEnum.values()) { |
| | | if (item.name.equals(name)) { |
| | | return item.getCode(); |
| | | } |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | public static String getCnDescByName(Integer code) { |
| | | for (KeyPersonLabelEnum item : KeyPersonLabelEnum.values()) { |
| | | if (item.code.equals(code)) { |
| | | return item.getName(); |
| | | } |
| | | } |
| | | return "其他"; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.google.common.collect.Lists; |
| | | import com.panzhihua.common.enums.*; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngBuildingExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationImportErrorVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationServeExcelVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.*; |
| | | import com.panzhihua.common.service.grid.GridService; |
| | | import com.panzhihua.common.utlis.ListUtils; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Slf4j |
| | | public class ComMngBuildingExcelListen extends AnalysisEventListener<Map<Integer, String>> { |
| | | |
| | | private CommunityService communityService; |
| | | |
| | | private GridService gridService; |
| | | |
| | | private Long communityId; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param headMap |
| | | * @param context |
| | | */ |
| | |
| | | vo.setVillageName(oneData.get(4)); |
| | | vo.setDoorNo(oneData.get(5)); |
| | | vo.setName(oneData.get(6)); |
| | | |
| | | vo.setGridName(oneData.get(15)); |
| | | vo.setGridId(oneData.get(15)); |
| | | try{ |
| | | vo.setUnitTotal(oneData.get(7)==null?0:Integer.valueOf(oneData.get(7))); |
| | | }catch (Exception e){ |
| | |
| | | |
| | | } |
| | | vo.setRemark(oneData.get(14)); |
| | | vo.setGrid(oneData.get(15)); |
| | | vo.setGridId(oneData.get(15)); |
| | | voList.add(vo); |
| | | } |
| | | |
| | |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngVillageServeExcelVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | private CommunityService communityService; |
| | | |
| | | private Long communityId; |
| | | private LoginUserInfoVO loginUserInfo ; |
| | | |
| | | public ComMngVillageServeExcelListen(CommunityService communityService, Long communityId) { |
| | | public ComMngVillageServeExcelListen(CommunityService communityService, LoginUserInfoVO loginUserInfo) { |
| | | this.communityService = communityService; |
| | | this.communityId = communityId; |
| | | this.loginUserInfo = loginUserInfo; |
| | | } |
| | | |
| | | |
| | |
| | | // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM |
| | | if (list.size() >= BATCH_COUNT) { |
| | | log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | R r = communityService.listSaveVillageServeExcelVO(list, this.communityId); |
| | | list.forEach(villageServe->{ |
| | | villageServe.setVillageId(Snowflake.getId()); |
| | | villageServe.setCreateAt(new Date()); |
| | | }); |
| | | R r = communityService.listSaveVillageServeExcelVO(list, loginUserInfo.getCommunityId()); |
| | | if (!R.isOk(r)) { |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | //确保最后遗留的数据保存在数据库中 |
| | | R r = this.communityService.listSaveVillageServeExcelVO(list, this.communityId); |
| | | list.forEach(villageServe->{ |
| | | villageServe.setVillageId(Snowflake.getId()); |
| | | villageServe.setCreateAt(new Date()); |
| | | }); |
| | | R r = this.communityService.listSaveVillageServeExcelVO(list, loginUserInfo.getCommunityId()); |
| | | if (!R.isOk(r)) { |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
New file |
| | |
| | | package com.panzhihua.common.model.dtos.community; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 实有人口DTO |
| | | */ |
| | | @Data |
| | | public class ComMngPopulationTagCardNoDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 身份证 |
| | | */ |
| | | @ApiModelProperty(value="身份证") |
| | | private String cardNo; |
| | | |
| | | /** |
| | | * 标签字符串(多个以,隔开) |
| | | */ |
| | | @ApiModelProperty(value="标签字符串") |
| | | private String label; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.common.model.dtos.community; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * Description 重点人员信息 |
| | | * ClassName KeyPersonInfo |
| | | * |
| | | * @author manailin |
| | | */ |
| | | @Data |
| | | public class KeyPersonInfoDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 街道id |
| | | */ |
| | | private Long streetId; |
| | | /** |
| | | * 姓名 |
| | | */ |
| | | @ExcelProperty(value = "姓名" ,index = 2) |
| | | private String name; |
| | | /** |
| | | * 性别(取字典表国家编码) |
| | | */ |
| | | private String sex; |
| | | /** |
| | | * 性别名称 |
| | | */ |
| | | @ExcelProperty(value = "性别名称" ,index = 3) |
| | | private String sexName; |
| | | /** |
| | | * 身份证号码 |
| | | */ |
| | | @ExcelProperty(value = "身份证号码" ,index = 4) |
| | | private String cardNo; |
| | | /** |
| | | * 联系方式 |
| | | */ |
| | | @ExcelProperty(value = "联系方式" ,index = 5) |
| | | private String phone; |
| | | /** |
| | | * 民族 |
| | | */ |
| | | @ExcelProperty(value = "民族" ,index = 6) |
| | | private String nation; |
| | | /** |
| | | * 户口所在地 |
| | | */ |
| | | @ExcelProperty(value = "户口所在地" ,index = 7) |
| | | private String censusRegister; |
| | | /** |
| | | * 居住地址 |
| | | */ |
| | | @ExcelProperty(value = "居住地址" ,index = 8) |
| | | private String address; |
| | | /** |
| | | * 地址精度纬度信息(逗号隔开) |
| | | */ |
| | | @ExcelProperty(value = "地址精度纬度信息(逗号隔开)" ,index = 9) |
| | | private String visiterAddressLatLng; |
| | | /** |
| | | * 人员类型1吸毒2严重精神障碍3刑释人员4社区矫正人员 |
| | | */ |
| | | @ExcelProperty(value = "人员类型1吸毒2严重精神障碍3刑释人员4社区矫正人员" ,index = 10) |
| | | private Integer visiterType; |
| | | /** |
| | | * (法轮功类填写)基本情况 |
| | | */ |
| | | private String basicInfo; |
| | | /** |
| | | * 是否有效 |
| | | */ |
| | | @ExcelProperty(value = "是否有效" ,index = 11) |
| | | private Boolean invalid; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注" ,index = 12) |
| | | private String note; |
| | | /** |
| | | * 文化程度(取字典表国家编码)) |
| | | */ |
| | | @ExcelProperty(value = "文化程度" ,index = 13) |
| | | private String cultureLevel; |
| | | /** |
| | | * 经济状态 |
| | | */ |
| | | @ExcelProperty(value = "经济状态" ,index = 14) |
| | | private String economicLevel; |
| | | /** |
| | | * 修改人 |
| | | */ |
| | | private Long updateBy; |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateAt; |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | private Long createBy; |
| | | /** |
| | | * (精神类人群填写)目前诊断 |
| | | */ |
| | | @ExcelProperty(value = "目前诊断" ,index = 18) |
| | | private String diagnose; |
| | | /** |
| | | * 上报提交时间 |
| | | */ |
| | | private Date submitDate; |
| | | /** |
| | | * (精神类人群填写)监护人名称 |
| | | */ |
| | | @ExcelProperty(value = "监护人名称" ,index = 20) |
| | | private String guardian; |
| | | /** |
| | | * (精神类人群填写)监护人电话 |
| | | */ |
| | | @ExcelProperty(value = "监护人电话" ,index = 21) |
| | | private String guardianPhone; |
| | | /** |
| | | * (精神类人群填写)监护人关系 |
| | | */ |
| | | @ExcelProperty(value = "监护人关系" ,index = 22) |
| | | private String guardianRelation; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createAt; |
| | | /** |
| | | * 社区id |
| | | */ |
| | | |
| | | private Long actId; |
| | | /** |
| | | * 小区id(实有房屋id) |
| | | */ |
| | | |
| | | private Long villageId; |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | |
| | | private Long userId; |
| | | |
| | | } |
| | |
| | | private String remark; |
| | | |
| | | @ExcelProperty(value = "网格划分", index = 15) |
| | | private String grid; |
| | | private String gridId; |
| | | |
| | | private String gridName; |
| | | } |
| | |
| | | @Data |
| | | public class ComMngVillageServeExcelVO implements Serializable { |
| | | /** |
| | | * villageId |
| | | */ |
| | | private Long villageId; |
| | | /** |
| | | * 服务分类 |
| | | */ |
| | | @ExcelProperty(value = "街路巷" ,index = 0) |
| | |
| | | |
| | | @ExcelProperty(value = "小区(组)" ,index = 2) |
| | | private String groupAt; |
| | | /** |
| | | * 小区类型(1.城镇 2.农村 3.未知) |
| | | */ |
| | | @ExcelProperty(value = "小区(组)" ,index = 3) |
| | | private Integer type; |
| | | /**如果是城镇小区填写楼栋数量 */ |
| | | @ExcelProperty(value = "小区(组)" ,index = 4) |
| | | private Integer buildSum; |
| | | /**(城镇)建筑年代*/ |
| | | @ExcelProperty(value = "小区(组)" ,index = 5) |
| | | private Date buildYear; |
| | | /**(城镇)建筑类型*/ |
| | | @ExcelProperty(value = "小区(组)" ,index = 6) |
| | | private Long buildType; |
| | | /**(城镇)是否存在物业公司*/ |
| | | @ExcelProperty(value = "小区(组)" ,index = 7) |
| | | private String property; |
| | | /**(城镇)开发商*/ |
| | | @ExcelProperty(value = "小区(组)" ,index = 8) |
| | | private String developers; |
| | | /**(城镇)小区总共居民数量/这户一共住了几口人*/ |
| | | @ExcelProperty(value = "小区(组)" ,index = 9) |
| | | private Integer userSum; |
| | | private Date createAt; |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/building/batchSave") |
| | | R listSaveBuildingExcelVO(@RequestBody List<ComMngBuildingExcelVO> newVoList,@RequestParam("communityId") Long communityId,@RequestParam("streetId")Long streetId); |
| | | |
| | | /** |
| | | * description 批量保存重点人群人员信息 |
| | | * |
| | | * @param list 重点人群信息 |
| | | * @return R 保存结果 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @PostMapping("/key_person/batch/save") |
| | | R saveBatchKeyPerson(@RequestBody List<KeyPersonInfoDTO> list); |
| | | } |
New file |
| | |
| | | package com.panzhihua.common.utlis; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.esotericsoftware.reflectasm.MethodAccess; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Modifier; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | |
| | | /** |
| | | * 通用情况拷贝 |
| | | * |
| | | * @author tkq |
| | | * @date 14:36 2019/4/10 |
| | | */ |
| | | @Slf4j |
| | | public class CopyUtil { |
| | | private static final Logger logger = LoggerFactory.getLogger(CopyUtil.class); |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | private static Map<Class, MethodAccess> methodMap = new ConcurrentHashMap<>(); |
| | | |
| | | private static Map<String, Integer> methodIndexMap = new ConcurrentHashMap<>(); |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | private static Map<Class, List<String>> fieldMap = new ConcurrentHashMap<>(); |
| | | |
| | | private CopyUtil() { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * <p>对数组进行拷贝 </p> |
| | | * |
| | | * @author tkq |
| | | * @date 2018年12月19日 |
| | | */ |
| | | public static <T> List<T> copyList(List<?> desc, Class<T> targetClass) { |
| | | if (desc == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | if (desc.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | //创建返回对象 |
| | | List<T> targetList = new ArrayList<>(desc.size()); |
| | | for (Object des : desc) { |
| | | if (null != des) { |
| | | try { |
| | | T newInstance = targetClass.newInstance(); |
| | | copyProperties(des, newInstance); |
| | | targetList.add(newInstance); |
| | | } catch (InstantiationException | IllegalAccessException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | | return targetList; |
| | | } |
| | | |
| | | /** |
| | | * <p>对数组进行拷贝 </p> |
| | | * |
| | | * @author manailin |
| | | * @date 2018年12月19日 |
| | | */ |
| | | public static <T> List<T> beanCopyList(List<?> desc, Class<T> targetClass) { |
| | | if (desc == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | if (desc.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | //创建返回对象 |
| | | List<T> targetList = new ArrayList<>(desc.size()); |
| | | for (Object des : desc) { |
| | | if (null != des) { |
| | | try { |
| | | T newInstance = targetClass.newInstance(); |
| | | BeanUtil.copyProperties(des, newInstance); |
| | | targetList.add(newInstance); |
| | | } catch (InstantiationException | IllegalAccessException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | | return targetList; |
| | | } |
| | | |
| | | /** |
| | | * @Title: |
| | | * @Description: 根据目标对象类型进行拷贝 |
| | | * @author tkq |
| | | * @date:2019/1/2 |
| | | * @Copyright: 2018 All rights reserved. 注意:禁止外泄以及用于其他的商业目 |
| | | */ |
| | | public static <T> T copyPropertiesByClass(Object desc, Class<T> targetClass) { |
| | | if (desc != null) { |
| | | try { |
| | | T newInstance = targetClass.newInstance(); |
| | | copyProperties(desc, newInstance); |
| | | return newInstance; |
| | | } catch (Exception e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 进行复制方法 |
| | | * |
| | | * @param dataSource 源目标对象 |
| | | * @param target 目标对象 |
| | | * @author tkq |
| | | * @date 14:37 2019-11-13 |
| | | */ |
| | | public static void copyProperties(Object dataSource, Object target) { |
| | | if (target == null) { |
| | | return; |
| | | } |
| | | if (dataSource == null) { |
| | | return; |
| | | } |
| | | MethodAccess descMethodAccess = methodMap.get(target.getClass()); |
| | | if (descMethodAccess == null) { |
| | | descMethodAccess = cache(target); |
| | | } |
| | | MethodAccess orgiMethodAccess = methodMap.get(dataSource.getClass()); |
| | | if (orgiMethodAccess == null) { |
| | | orgiMethodAccess = cache(dataSource); |
| | | } |
| | | |
| | | List<String> fieldList = fieldMap.get(dataSource.getClass()); |
| | | for (String field : fieldList) { |
| | | String getKey = dataSource.getClass().getName() + "." + "get" + field; |
| | | String setkey = target.getClass().getName() + "." + "set" + field; |
| | | Integer setIndex = methodIndexMap.get(setkey); |
| | | if (setIndex != null) { |
| | | int getIndex = methodIndexMap.get(getKey); |
| | | // 参数一需要反射的对象 |
| | | // 参数二class.getDeclaredMethods 对应方法的index |
| | | // 参数对三象集合 |
| | | try { |
| | | descMethodAccess.invoke(target, setIndex.intValue(), orgiMethodAccess.invoke(dataSource, getIndex)); |
| | | } catch (Exception e) { |
| | | log.info("field:" + field); |
| | | throw e; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 单例模式 |
| | | * |
| | | * @param object 实体对象 |
| | | * @return MethodAccess |
| | | * @author tkq |
| | | * @date 14:36 2019/4/10 |
| | | */ |
| | | private static MethodAccess cache(Object object) { |
| | | Class<?> name = object.getClass(); |
| | | synchronized (name) { |
| | | MethodAccess methodAccess = MethodAccess.get(name); |
| | | Class<?> className = object.getClass(); |
| | | Set<Field> fields =new HashSet<>(); |
| | | for(;className != Object.class ; className = className.getSuperclass()) { |
| | | fields.addAll(Arrays.asList(className.getDeclaredFields())); |
| | | } |
| | | List<String> fieldList = new ArrayList<>(fields.size()); |
| | | for (Field field : fields) { |
| | | // 是否是私有的,是否是静态的 |
| | | if (Modifier.isPrivate(field.getModifiers()) && !Modifier.isStatic(field.getModifiers())) { |
| | | // 非公共私有变量 |
| | | // 获取属性名称 |
| | | String fieldName = StringUtils.capitalize(field.getName()); |
| | | // 获取get方法的下标 |
| | | int getIndex = methodAccess.getIndex("get" + fieldName); |
| | | // 获取set方法的下标 |
| | | int setIndex = methodAccess.getIndex("set" + fieldName); |
| | | // 将类名get方法名,方法下标注册到map中 |
| | | methodIndexMap.put(object.getClass().getName() + "." + "get" + fieldName, getIndex); |
| | | // 将类名set方法名,方法下标注册到map中 |
| | | methodIndexMap.put(object.getClass().getName() + "." + "set" + fieldName, setIndex); |
| | | // 将属性名称放入集合里 |
| | | fieldList.add(fieldName); |
| | | } |
| | | } |
| | | // 将类名,属性名称注册到map中 |
| | | fieldMap.put(name, fieldList); |
| | | methodMap.put(name, methodAccess); |
| | | return methodAccess; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 复制属性 |
| | | * @param source 源数据 |
| | | * @param targetClass 目标对象类型 |
| | | * @return |
| | | * @author weifei |
| | | * @date 2020/8/20 10:38 |
| | | */ |
| | | public static <T,K> K copyProperties(T source,Class<K> targetClass){ |
| | | if(source == null || targetClass == null){ |
| | | return null; |
| | | } |
| | | //创建对象 |
| | | try { |
| | | K k = targetClass.newInstance(); |
| | | //复制对象 |
| | | BeanUtils.copyProperties(source,k); |
| | | return k; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 复制属性 |
| | | * @param source 源数据 |
| | | * @param targetClass 目标对象类型 |
| | | * @return |
| | | * @author weifei |
| | | * @date 2020/12/16 10:12 |
| | | */ |
| | | public static <T,K> List<K> copyProperties(List<T> source,Class<K> targetClass){ |
| | | if(source == null || targetClass == null){ |
| | | return null; |
| | | } |
| | | List<K> returnValue = new ArrayList<>(); |
| | | try { |
| | | source.forEach(s -> { |
| | | K k = copyProperties(s, targetClass); |
| | | if(k != null){ |
| | | returnValue.add(k); |
| | | } |
| | | }); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | return returnValue; |
| | | } |
| | | |
| | | /** |
| | | * @description 深度复制对象 |
| | | * @param source 元数据 |
| | | * @param targetClass 目标对象类型 |
| | | * @return |
| | | * @author weifei |
| | | * @date 2021/3/1 14:21 |
| | | */ |
| | | public static <T,K> K deepCopyObject(T source,Class<K> targetClass){ |
| | | if(source == null || targetClass == null){ |
| | | return null; |
| | | } |
| | | return JSONObject.parseObject(JSONObject.toJSONBytes(source),targetClass); |
| | | } |
| | | |
| | | /** |
| | | * @description 深度复制list对象 |
| | | * @param source 元数据 |
| | | * @param targetClass 目标对象类型 |
| | | * @return |
| | | * @author weifei |
| | | * @date 2021/3/1 14:26 |
| | | */ |
| | | public static <T,K> List<K> deepCopyListObject(List<T> source,Class<K> targetClass){ |
| | | if(source == null || targetClass == null){ |
| | | return null; |
| | | } |
| | | return JSONObject.parseArray(JSONObject.toJSONString(source),targetClass); |
| | | } |
| | | } |
New file |
| | |
| | | package com.panzhihua.common.utlis; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.*; |
| | | |
| | | |
| | | /** |
| | | * @author manailin |
| | | */ |
| | | @Data |
| | | public class ValidableList<E> implements List<E> { |
| | | |
| | | @Valid |
| | | private List<E> list = new LinkedList<>(); |
| | | |
| | | @Override |
| | | public int size() { |
| | | return list.size(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isEmpty() { |
| | | return list.isEmpty(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean contains(Object o) { |
| | | return list.contains(o); |
| | | } |
| | | |
| | | @Override |
| | | public Iterator<E> iterator() { |
| | | return list.iterator(); |
| | | } |
| | | |
| | | @Override |
| | | public Object[] toArray() { |
| | | return list.toArray(); |
| | | } |
| | | |
| | | @Override |
| | | public <T> T[] toArray(T[] a) { |
| | | return list.toArray(a); |
| | | } |
| | | |
| | | @Override |
| | | public boolean add(E e) { |
| | | return list.add(e); |
| | | } |
| | | |
| | | @Override |
| | | public boolean remove(Object o) { |
| | | return list.remove(o); |
| | | } |
| | | |
| | | @Override |
| | | public boolean containsAll(Collection<?> c) { |
| | | return list.containsAll(c); |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAll(Collection<? extends E> c) { |
| | | return list.addAll(c); |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAll(int index, Collection<? extends E> c) { |
| | | return list.addAll(index, c); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeAll(Collection<?> c) { |
| | | return list.removeAll(c); |
| | | } |
| | | |
| | | @Override |
| | | public boolean retainAll(Collection<?> c) { |
| | | return list.retainAll(c); |
| | | } |
| | | |
| | | @Override |
| | | public void clear() { |
| | | list.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public E get(int index) { |
| | | return list.get(index); |
| | | } |
| | | |
| | | @Override |
| | | public E set(int index, E element) { |
| | | return list.set(index, element); |
| | | } |
| | | |
| | | @Override |
| | | public void add(int index, E element) { |
| | | list.add(index, element); |
| | | } |
| | | |
| | | @Override |
| | | public E remove(int index) { |
| | | return list.remove(index); |
| | | } |
| | | |
| | | @Override |
| | | public int indexOf(Object o) { |
| | | return list.indexOf(o); |
| | | } |
| | | |
| | | @Override |
| | | public int lastIndexOf(Object o) { |
| | | return list.lastIndexOf(o); |
| | | } |
| | | |
| | | @Override |
| | | public ListIterator<E> listIterator() { |
| | | return list.listIterator(); |
| | | } |
| | | |
| | | @Override |
| | | public ListIterator<E> listIterator(int index) { |
| | | return list.listIterator(index); |
| | | } |
| | | |
| | | @Override |
| | | public List<E> subList(int fromIndex, int toIndex) { |
| | | return list.subList(fromIndex, toIndex); |
| | | } |
| | | } |
| | | |
| | |
| | | InputStream inputStream; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | long communityId = 45L; |
| | | long communityId = 2L; |
| | | ComMngBuildingExcelListen comMngBuildingExcelListen = new ComMngBuildingExcelListen(communityService, communityId); |
| | | EasyExcel.read(inputStream, null, comMngBuildingExcelListen).sheet().doRead(); |
| | | } catch (IOException e) { |
New file |
| | |
| | | package com.panzhihua.community_backstage.api; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.community.KeyPersonInfoDTO; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.community_backstage.listen.KeyPersonInfoExcelListen; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 特殊人群管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | @Slf4j |
| | | @Api(tags = {"特殊人群管理API"}) |
| | | @RestController |
| | | @RequestMapping("/") |
| | | public class MainMemberApi extends BaseController { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | /** |
| | | * description 批量保存重点人群人员信息 |
| | | * |
| | | * @param file 重点人群信息 |
| | | * @return R 保存结果 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @PostMapping(value = "mainMember/import", consumes = "multipart/*", headers = "content-type=multipart/form-date") |
| | | public R importExcl(@RequestParam MultipartFile file, HttpServletRequest request) { |
| | | String fileName = file.getOriginalFilename(); //获取文件名 |
| | | log.info("传入文件名字【{}】", fileName); |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | // LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(); |
| | | loginUserInfo.setUserId(2323L); |
| | | loginUserInfo.setCommunityId(888L); |
| | | EasyExcel.read(inputStream, KeyPersonInfoDTO.class, new KeyPersonInfoExcelListen(communityService, loginUserInfo)).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = file.getInputStream(); |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | ComMngVillageServeExcelListen comMngVillageServeExcelListen = new ComMngVillageServeExcelListen(communityService, loginUserInfo.getCommunityId()); |
| | | // LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(); |
| | | loginUserInfo.setUserId(2323L); |
| | | loginUserInfo.setCommunityId(2L); |
| | | ComMngVillageServeExcelListen comMngVillageServeExcelListen = new ComMngVillageServeExcelListen(communityService, loginUserInfo); |
| | | EasyExcel.read(inputStream, ComMngVillageServeExcelVO.class, comMngVillageServeExcelListen).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | log.error("导入模板失败【{}】", e.getMessage()); |
New file |
| | |
| | | package com.panzhihua.community_backstage.listen; |
| | | |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.exceptions.PartyBuildingMemberException; |
| | | import com.panzhihua.common.model.dtos.community.KeyPersonInfoDTO; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | | * @description: 特殊人群入监听 |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2020-11-30 15:12 |
| | | **/ |
| | | @Slf4j |
| | | public class KeyPersonInfoExcelListen extends AnalysisEventListener<KeyPersonInfoDTO> { |
| | | |
| | | @Resource |
| | | private CommunityService communityService; |
| | | |
| | | private LoginUserInfoVO loginUserInfo; |
| | | |
| | | public KeyPersonInfoExcelListen(CommunityService communityService, LoginUserInfoVO loginUserInfo) { |
| | | this.communityService = communityService; |
| | | this.loginUserInfo = loginUserInfo; |
| | | } |
| | | |
| | | |
| | | private static final int BATCH_COUNT = 5000; |
| | | private List<KeyPersonInfoDTO> list = new ArrayList<>(); |
| | | |
| | | @Override |
| | | public void invoke(KeyPersonInfoDTO keyPersonInfoDTO, AnalysisContext analysisContext) { |
| | | list.add(keyPersonInfoDTO); |
| | | // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM |
| | | if (list.size() >= BATCH_COUNT) { |
| | | log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | list.forEach(keyPersonInfo -> { |
| | | keyPersonInfo.setId(Snowflake.getId()); |
| | | keyPersonInfo.setActId(loginUserInfo.getCommunityId()); |
| | | keyPersonInfo.setCreateBy(loginUserInfo.getUserId()); |
| | | keyPersonInfo.setCreateAt(new Date()); |
| | | keyPersonInfo.setUpdateBy(loginUserInfo.getUserId()); |
| | | keyPersonInfo.setUpdateAt(new Date()); |
| | | }); |
| | | R r = this.communityService.saveBatchKeyPerson(list); |
| | | if (!R.isOk(r)) { |
| | | throw new PartyBuildingMemberException(r.getMsg()); |
| | | } |
| | | list.clear(); //清空list |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | list.forEach(keyPersonInfo -> { |
| | | keyPersonInfo.setId(Snowflake.getId()); |
| | | keyPersonInfo.setActId(loginUserInfo.getCommunityId()); |
| | | keyPersonInfo.setCreateBy(loginUserInfo.getUserId()); |
| | | keyPersonInfo.setCreateAt(new Date()); |
| | | keyPersonInfo.setUpdateBy(loginUserInfo.getUserId()); |
| | | keyPersonInfo.setUpdateAt(new Date()); |
| | | }); |
| | | R r = this.communityService.saveBatchKeyPerson(list);//确保最后遗留的数据保存在数据库中 |
| | | if (!R.isOk(r)) { |
| | | throw new PartyBuildingMemberException(r.getMsg()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.panzhihua.common.model.vos.user.UserElectronicFileVO; |
| | | import com.panzhihua.common.validated.AddGroup; |
| | | import com.panzhihua.service_community.service.*; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | |
| | | /** |
| | | * 小程序用户车辆登记 |
| | | * |
| | | * @param comCvtBusinessDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 小程序用户车辆列表 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台车辆管理列表 |
| | | * |
| | | * @param pageComMngCarDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台添加修改车辆 |
| | | * |
| | | * @param comMngCarSaveDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台删除车辆 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | public R deleteComMngCar(@RequestParam(value = "id") Long id) { |
| | | return comMngCarService.deleteComMngCar(id); |
| | | } |
| | | |
| | | /** |
| | | * 社区后台导入车辆 |
| | | * |
| | | * @param list 车辆列表 |
| | | * @param communityId 社区编号 |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 社区后台实有单位管理列表 |
| | | * |
| | | * @param pageComMngRealCompanyDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台添加修改实有单位 |
| | | * |
| | | * @param comMngRealCompanyVO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台删除实有单位 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | public R belongsComMngRealCompany(@RequestBody ComMngRealCompanyBelongsDTO comMngRealCompanyBelongsDTO) { |
| | | return comMngRealCompanyService.belongsComMngRealCompany(comMngRealCompanyBelongsDTO); |
| | | } |
| | | |
| | | /** |
| | | * 社区后台导入实有单位 |
| | | * |
| | | * @param list 车实有单位列表 |
| | | * @param communityId 社区编号 |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 导出实有单位 |
| | | * |
| | | * @param exportRealCompanyExcelDTO 实有单位导出查询参数 |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台实有资产管理列表 |
| | | * |
| | | * @param pageComMngRealAssetsDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台添加修改实有资产 |
| | | * |
| | | * @param comMngRealAssetsVO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台删除实有资产 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台导入实有资产 |
| | | * |
| | | * @param list 车实有资产列表 |
| | | * @param communityId 社区编号 |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 导出实有资产 |
| | | * |
| | | * @param exportRealAssetsExcelDTO 实有资产导出查询参数 |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询所有省份 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/province") |
| | |
| | | |
| | | /** |
| | | * 查询省份下所有的城市 |
| | | * |
| | | * @param provinceAdcode |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询城市下所有的区县 |
| | | * |
| | | * @param cityAdcode |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询特定省下所有区域 tree结构 |
| | | * |
| | | * @param provinceAdcode |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台实有人口管理列表 |
| | | * |
| | | * @param comMngPopulationVO 查询参数 |
| | | * @return 实有人口分页查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 社区后台导入实有人口 |
| | | * |
| | | * @param list 数据 |
| | | * @param communityId 社区编号 |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 确认导入实有人口(有则更新,无则新建) |
| | | * |
| | | * @param list 用户信息 |
| | | * @param communityId 社区id |
| | | * @return 导入结果 |
| | |
| | | |
| | | /** |
| | | * 根据实有人口id查询详情 |
| | | * |
| | | * @param populationId 实有人口id |
| | | * @return 实有人口详情查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询实有人口电子档信息 |
| | | * |
| | | * @param populationId 实有人口id |
| | | * @return 实有人口电子档信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据实有人口id修改标签列表 |
| | | * |
| | | * @param populationTagDTO 请求参数 |
| | | * @return 修改结果 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据实有人口身份证修改标签列表 |
| | | * |
| | | * @param comMngPopulationTagCardNoDTO 请求参数 |
| | | * @return 修改结果 |
| | | */ |
| | | @PostMapping("/cardNo/population/editTag") |
| | | public R editTagPopulationByCardNo(@RequestBody ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO) { |
| | | return comMngPopulationService.editTagPopulationByCardNo(comMngPopulationTagCardNoDTO); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除实有人口 |
| | | * |
| | | * @param Ids 删除id集合 |
| | | * @return 删除结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据社区id查询所有实有人口 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据id集合查询实有人口 |
| | | * |
| | | * @param Ids 实有人口id集合 |
| | | * @return 查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 编辑实有人口 |
| | | * |
| | | * @param populationEditDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 分页查询特殊群体 |
| | | * |
| | | * @param pageInputUserDTO 请求参数 |
| | | * @return 特殊群体列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除特殊群体人员 |
| | | * |
| | | * @param id 特殊群体id |
| | | * @return 删除结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 编辑实有人口_电子档案 |
| | | * |
| | | * @param userElectronicFileVO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 实有人口统计 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询房屋级联菜单 |
| | | * |
| | | * @param cascadeHouseDTO 请求参数 |
| | | * @return 菜单列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 分页查询房屋列表 |
| | | * |
| | | * @param populationHouseAdminDTO 请求参数 |
| | | * @return 房屋列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据id查询实有房屋信息 |
| | | * |
| | | * @param houseId 房屋id |
| | | * @return 房屋信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 编辑实有房屋信息 |
| | | * |
| | | * @param houseEditAdminDTO 请求参数 |
| | | * @return 编辑结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据房屋id列表删除房屋信息 |
| | | * |
| | | * @param Ids 请求参数 |
| | | * @return 删除结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 实有房屋统计 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据社区id查询社区所有省市区 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 社区所在省市区 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 统计社区内小区数量 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计小区数量 |
| | | */ |
New file |
| | |
| | | package com.panzhihua.service_community.api; |
| | | |
| | | import com.panzhihua.common.model.dtos.community.KeyPersonInfoDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.utlis.CopyUtil; |
| | | import com.panzhihua.common.utlis.ValidableList; |
| | | import com.panzhihua.service_community.model.dos.KeyPersonInfoDO; |
| | | import com.panzhihua.service_community.service.KeyPersonInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 特殊人群管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/") |
| | | public class MainMemberApi { |
| | | |
| | | @Resource |
| | | private KeyPersonInfoService keyPersonInfoService; |
| | | |
| | | /** |
| | | * description 批量保存重点人群人员信息 |
| | | * |
| | | * @param list 重点人群信息 |
| | | * @return R 保存结果 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @PostMapping("/key_person/batch/save") |
| | | public R BatchSave(@RequestBody @Valid ValidableList<KeyPersonInfoDTO> list, @ApiIgnore BindingResult results) { |
| | | if (results.hasErrors()) { |
| | | return R.fail(results.getFieldError().getDefaultMessage()); |
| | | } |
| | | return keyPersonInfoService.saveBatchKeyPerson(list); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.service_community.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.panzhihua.service_community.model.dos.GridBuildRelationDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 特殊人群管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | @Mapper |
| | | public interface GridBuildRelationDAO extends BaseMapper<GridBuildRelationDO> { |
| | | } |
New file |
| | |
| | | package com.panzhihua.service_community.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.panzhihua.common.model.dtos.community.KeyPersonInfoDTO; |
| | | import com.panzhihua.service_community.model.dos.ComActActPrizeDO; |
| | | import com.panzhihua.service_community.model.dos.KeyPersonInfoDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 特殊人群管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | @Mapper |
| | | public interface KeyPersonInfoDAO extends BaseMapper<KeyPersonInfoDO> { |
| | | } |
| | |
| | | */ |
| | | private String contactsPhone; |
| | | |
| | | /**社区总人口*/ |
| | | private Integer totalUser; |
| | | /**社区书记-用户ID*/ |
| | | private Long managerId; |
| | | /**社区书记_名称*/ |
| | | private String managerName; |
| | | /**社区介绍*/ |
| | | private String introduce; |
| | | /**层次递归字段(省>市>区县>街道>社区)*/ |
| | | private String path; |
| | | /** |
| | | * 超管账号 |
| | | */ |
| | |
| | | */ |
| | | private String remark; |
| | | |
| | | private Long gridId; |
| | | |
| | | private String gridId; |
| | | } |
| | |
| | | /** |
| | | * villageId |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | @TableId(value = "village_id",type = IdType.INPUT) |
| | | private Long villageId; |
| | | /** |
| | | * 街路巷 |
| | |
| | | */ |
| | | private Integer type; |
| | | |
| | | /** |
| | | * 小区地址 |
| | | */ |
| | | /**(城镇)小区名字*/ |
| | | private String name; |
| | | /**如果是城镇小区填写楼栋数量 */ |
| | | private Integer buildSum; |
| | | /**(城镇)建筑年代*/ |
| | | private Date buildYear; |
| | | /**(城镇)建筑类型*/ |
| | | private Long buildType; |
| | | /**(城镇)是否存在物业公司*/ |
| | | private String property; |
| | | /**(城镇)开发商*/ |
| | | private String developers; |
| | | /**(城镇)小区总共居民数量/这户一共住了几口人*/ |
| | | private Integer userSum; |
| | | /**图片*/ |
| | | private String villageImages; |
| | | /**地址*/ |
| | | private String address; |
| | | /**层次递归字段(省>市>区县>街道>社区>小区)*/ |
| | | private String path; |
| | | /**经度*/ |
| | | private String lng; |
| | | /**维度*/ |
| | | private String lat; |
| | | |
| | | /** |
| | | * 更新时间 |
New file |
| | |
| | | package com.panzhihua.service_community.model.dos; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * Description 网格和建筑或楼栋关联表 |
| | | * ClassName GridBuildRelation |
| | | * @author manailin |
| | | */ |
| | | @Data |
| | | @TableName(value = "event_grid_building_relation") |
| | | public class GridBuildRelationDO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | /**主键*/ |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private Long id; |
| | | /**网格所属街道*/ |
| | | private Long gridStreetId; |
| | | /**网格所属社区ID*/ |
| | | private Long gridCommunityId; |
| | | /**网格ID*/ |
| | | private Long gridId; |
| | | /**网格名称*/ |
| | | private String gridName; |
| | | /**小区类型(1.城镇 2.农村 3.未知)*/ |
| | | private Integer type; |
| | | /**小区表ID*/ |
| | | private Long villageId; |
| | | /**楼栋ID*/ |
| | | private Long buildId; |
| | | private String buildName; |
| | | /**创建人*/ |
| | | private Long createBy; |
| | | /**创建时间*/ |
| | | private Date createAt; |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.service_community.model.dos; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * Description 重点人员信息 |
| | | * ClassName KeyPersonInfo |
| | | * |
| | | * @author manailin |
| | | */ |
| | | @Data |
| | | @TableName("com_key_person_info") |
| | | public class KeyPersonInfoDO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private Long id; |
| | | /** |
| | | * 街道id |
| | | */ |
| | | private Long streetId; |
| | | /** |
| | | * 姓名 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 性别(取字典表国家编码) |
| | | */ |
| | | private String sex; |
| | | /** |
| | | * 性别名称 |
| | | */ |
| | | private String sexName; |
| | | /** |
| | | * 身份证号码 |
| | | */ |
| | | private String cardNo; |
| | | /** |
| | | * 联系方式 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 民族 |
| | | */ |
| | | private String nation; |
| | | /** |
| | | * 户口所在地 |
| | | */ |
| | | private String censusRegister; |
| | | /** |
| | | * 居住地址 |
| | | */ |
| | | private String address; |
| | | /** |
| | | * 地址精度纬度信息(逗号隔开) |
| | | */ |
| | | private String visiterAddressLatLng; |
| | | /** |
| | | * 人员类型1吸毒2严重精神障碍3刑释人员4社区矫正人员 |
| | | */ |
| | | private Integer visiterType; |
| | | /** |
| | | * (法轮功类填写)基本情况 |
| | | */ |
| | | private String basicInfo; |
| | | /** |
| | | * 是否有效 |
| | | */ |
| | | private Boolean invalid; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String note; |
| | | /** |
| | | * 文化程度(取字典表国家编码)) |
| | | */ |
| | | private String cultureLevel; |
| | | /** |
| | | * 经济状态 |
| | | */ |
| | | private String economicLevel; |
| | | /** |
| | | * 修改人 |
| | | */ |
| | | private Long updateBy; |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateAt; |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | private Long createBy; |
| | | /** |
| | | * (精神类人群填写)目前诊断 |
| | | */ |
| | | private String diagnose; |
| | | /** |
| | | * 上报提交时间 |
| | | */ |
| | | private Date submitDate; |
| | | /** |
| | | * (精神类人群填写)监护人名称 |
| | | */ |
| | | private String guardian; |
| | | /** |
| | | * (精神类人群填写)监护人电话 |
| | | */ |
| | | private String guardianPhone; |
| | | /** |
| | | * (精神类人群填写)监护人关系 |
| | | */ |
| | | private String guardianRelation; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createAt; |
| | | /** |
| | | * 社区id |
| | | */ |
| | | |
| | | private Long actId; |
| | | /** |
| | | * 小区id(实有房屋id) |
| | | */ |
| | | |
| | | private Long villageId; |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | |
| | | private Long userId; |
| | | |
| | | } |
| | |
| | | |
| | | import com.panzhihua.common.model.dtos.community.ComMngPopulationDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComMngPopulationEditDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComMngPopulationTagCardNoDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComMngPopulationTagDTO; |
| | | import com.panzhihua.common.model.dtos.user.PageInputUserDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationServeExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationVO; |
| | | import com.panzhihua.common.model.vos.community.EditComMngPopulationVO; |
| | | import com.panzhihua.common.model.vos.user.UserElectronicFileVO; |
| | | import com.panzhihua.service_community.model.dos.ComMngPopulationDO; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | public interface ComMngPopulationService { |
| | | /** |
| | | * 新增实有人口 |
| | | * |
| | | * @param comMngPopulationVO 实有人口信息 |
| | | * @return 新增结果 |
| | | */ |
| | | R addPopulation(ComMngPopulationVO comMngPopulationVO); |
| | | |
| | | /** |
| | | * 编辑实有人口 |
| | | * |
| | | * @param comMngPopulationVO 编辑内容 |
| | | * @return 编辑结果 |
| | | */ |
| | | R putPopulation(ComMngPopulationVO comMngPopulationVO); |
| | | |
| | | /** |
| | | * 查询实有人口 |
| | | * |
| | | * @param comMngPopulationVO 请求参数 |
| | | * @return 实有人口集合 |
| | | */ |
| | | R listPopulation(ComMngPopulationDTO comMngPopulationVO); |
| | | |
| | | /** |
| | | * 实有人口详情 |
| | | * |
| | | * @param populationId 实有人口id |
| | | * @return 实有人口详情 |
| | | */ |
| | | R detailPopulation(Long populationId); |
| | | |
| | | /** |
| | | * 分页查询实有人口 |
| | | * |
| | | * @param comMngPopulationVO 查询参数 |
| | | * @return 分页集合 |
| | | */ |
| | | R pagePopulation(ComMngPopulationDTO comMngPopulationVO); |
| | | |
| | | /** |
| | | * 查询平台所有的实有人口 |
| | | * |
| | | * @return 实有人口集合 按照创建顺序倒序排列 |
| | | */ |
| | | R listPopulationAll(); |
| | | |
| | | /** |
| | | * 删除实有人口 |
| | | * |
| | | * @param populationId 实有人口id |
| | | * @return 删除结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 导入实有人口 |
| | | * |
| | | * @param list |
| | | * @param communityId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 确认导入实有人口(有则更新,无则新建) |
| | | * |
| | | * @param list 用户信息 |
| | | * @param communityId 社区id |
| | | * @return 导入结果 |
| | | */ |
| | | R listSavePopulationConfirm(List<ComMngPopulationServeExcelVO> list, Long communityId); |
| | | |
| | | /** |
| | | * 根据实有人口id修改用户标签 |
| | | * |
| | | * @param populationTagDTO 请求参数 |
| | | * @return 修改结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据社区id查询所有实有人口 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据id集合查询实有人口 |
| | | * |
| | | * @param Ids 实有人口id集合 |
| | | * @return 查询结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 编辑实有人口 |
| | | * |
| | | * @param populationEditDTO |
| | | * @param communityId |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 分页查询特殊群体 |
| | | * |
| | | * @param pageInputUserDTO 请求参数 |
| | | * @return 特殊群体列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除特殊群体人员 |
| | | * |
| | | * @param id 特殊群体id |
| | | * @return 删除结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询实有人口电子档信息 |
| | | * |
| | | * @param populationId 实有人口id |
| | | * @return 实有人口电子档信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 编辑电子档案 |
| | | * |
| | | * @param userElectronicFileVO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 实有人口统计 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | */ |
| | | R getPopulationTotalByAdmin(Long communityId); |
| | | |
| | | /** |
| | | * description 根据身份证信息修改用户标签信息 |
| | | * |
| | | * @param comMngPopulationTagCardNoDTO 查询对象 |
| | | * @return ComMngPopulationDO 实有人口信息 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | R editTagPopulationByCardNo(ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO); |
| | | |
| | | /** |
| | | * description 根据身份证信息从实有人口表查询对应信息 |
| | | * |
| | | * @param cardNo 身份证号码 |
| | | * @return ComMngPopulationDO 实有人口信息 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | ComMngPopulationDO getPopulationByCardNo(String cardNo); |
| | | } |
New file |
| | |
| | | package com.panzhihua.service_community.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.service_community.model.dos.GridBuildRelationDO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 网格和小区楼栋和建筑的关系表管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | public interface GridBuildRelationService extends IService<GridBuildRelationDO> { |
| | | |
| | | /** |
| | | * description 批量保存网格和小区楼栋和建筑的关系 |
| | | * |
| | | * @param keyList 网格和小区楼栋和建筑的关系信息 |
| | | * @return R 保存结果 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | R saveBatchGridBuildRelation(List<GridBuildRelationDO> keyList); |
| | | } |
New file |
| | |
| | | package com.panzhihua.service_community.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.panzhihua.common.model.dtos.community.KeyPersonInfoDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.service_community.model.dos.KeyPersonInfoDO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 特殊人群管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | public interface KeyPersonInfoService extends IService<KeyPersonInfoDO> { |
| | | |
| | | /** |
| | | * description 批量保存重点人群人员信息 |
| | | * |
| | | * @param keyList 重点人群信息 |
| | | * @return R 保存结果 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | R saveBatchKeyPerson(List<KeyPersonInfoDTO> keyList); |
| | | } |
| | |
| | | import com.google.common.collect.Lists; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngBuildingExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationImportErrorVO; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComActVillageDAO; |
| | | import com.panzhihua.service_community.dao.ComMngBuildingDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngBuildingDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngVillageDO; |
| | | import com.panzhihua.service_community.model.dos.GridBuildRelationDO; |
| | | import com.panzhihua.service_community.service.ComActBuildingService; |
| | | import com.panzhihua.service_community.service.GridBuildRelationService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author xyh |
| | |
| | | private ComActVillageDAO comActVillageDAO; |
| | | @Resource |
| | | private ComActDAO comActDAO; |
| | | @Resource |
| | | private GridBuildRelationService gridBuildRelationService; |
| | | |
| | | @Override |
| | | public R batchSaveBuilding(List<ComMngBuildingExcelVO> newVoList, Long communityId, Long streetId) { |
| | | ArrayList<ComMngBuildingDO> list = Lists.newArrayList(); |
| | | List<GridBuildRelationDO> keyList = new ArrayList<>(); |
| | | for(ComMngBuildingExcelVO vo:newVoList){ |
| | | |
| | | ComMngVillageDO comMngVillageDO = comActVillageDAO.selectOne(new QueryWrapper<ComMngVillageDO>().eq("alley",vo.getAlley()).eq("house_num",vo.getDoorNo()).eq("community_id",communityId)); |
| | |
| | | StringBuilder path = new StringBuilder(); |
| | | path.append(vo.getAlley()).append(">").append(actDO.getName()).append(vo.getVillageName()).append(">").append(vo.getName()); |
| | | comMngBuildingDO.setPath(path.toString()); |
| | | comMngBuildingDO.setGridId(null); |
| | | comMngBuildingDO.setGridId(vo.getGridId()); |
| | | list.add(comMngBuildingDO); |
| | | GridBuildRelationDO gridBuildRelation = getGridBuildRelationDO(communityId, streetId, vo, comMngBuildingDO); |
| | | keyList.add(gridBuildRelation); |
| | | } |
| | | |
| | | gridBuildRelationService.saveBatchGridBuildRelation(keyList); |
| | | this.saveBatch(list); |
| | | return R.ok(); |
| | | } |
| | | |
| | | public GridBuildRelationDO getGridBuildRelationDO(Long communityId, Long streetId, ComMngBuildingExcelVO vo, ComMngBuildingDO comMngBuildingDO) { |
| | | GridBuildRelationDO gridBuildRelation = new GridBuildRelationDO(); |
| | | gridBuildRelation.setId(Snowflake.getId()); |
| | | gridBuildRelation.setBuildId(comMngBuildingDO.getId()); |
| | | gridBuildRelation.setBuildName(comMngBuildingDO.getPath()); |
| | | gridBuildRelation.setVillageId(comMngBuildingDO.getVillageId()); |
| | | gridBuildRelation.setGridCommunityId(communityId); |
| | | gridBuildRelation.setGridStreetId(streetId); |
| | | if (vo.getGridId() != null) { |
| | | gridBuildRelation.setGridId(Long.valueOf(vo.getGridId())); |
| | | } |
| | | gridBuildRelation.setGridName(vo.getGridName()); |
| | | gridBuildRelation.setType(1); |
| | | gridBuildRelation.setCreateAt(new Date()); |
| | | return gridBuildRelation; |
| | | } |
| | | } |
| | |
| | | return R.ok(this.baseMapper.getPopulationTotalByAdmin(communityId)); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | // List<ComMngPopulationHouseUserDO> distinctClass = populationHouseUserDOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getPopulId() + ";" + o.getHouseId() + ";" + o.getId() + ";" + o.getRelation()))), ArrayList::new)); |
| | | @Override |
| | | public R editTagPopulationByCardNo(ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO) { |
| | | ComMngPopulationDO comMngPopulationDO = getPopulationByCardNo(comMngPopulationTagCardNoDTO.getCardNo()); |
| | | if (comMngPopulationDO == null) { |
| | | return R.fail("未查询到人口记录"); |
| | | } |
| | | ComMngPopulationDO comMngPopulation = new ComMngPopulationDO(); |
| | | if(comMngPopulationDO.getLabel()!=null) { |
| | | if(!comMngPopulationDO.getLabel().contains(comMngPopulationTagCardNoDTO.getLabel())) { |
| | | comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel().concat(",").concat(comMngPopulationDO.getLabel())); |
| | | } |
| | | }else{ |
| | | comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel()); |
| | | } |
| | | comMngPopulation.setCardNo(null); |
| | | comMngPopulation.setId(comMngPopulationDO.getId()); |
| | | int nub = populationDAO.updateById(comMngPopulation); |
| | | if (nub < 1) { |
| | | return R.fail(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public ComMngPopulationDO getPopulationByCardNo(String cardNo) { |
| | | try { |
| | | String aesCardNo = AESUtil.encrypt128(cardNo, aesKey); |
| | | return baseMapper.selectOne( |
| | | new QueryWrapper<ComMngPopulationDO>() |
| | | .eq("card_no",aesCardNo) |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("根据身份证查询业务-加密证件信息出错"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | BeanUtils.copyProperties(vo, comMngVillageDO); |
| | | comMngVillageDO.setCommunityId(comActDO.getCommunityId()); |
| | | comMngVillageDO.setStreetId(comActDO.getStreetId()); |
| | | StringBuilder path = new StringBuilder(); |
| | | path.append(vo.getAlley()).append(">").append(vo.getHouseNum()).append(">").append(vo.getGroupAt()); |
| | | comMngVillageDO.setPath(path.toString()); |
| | | comMngVillageDO.setUpdateAt(new Date()); |
| | | comMngVillageDOS.add(comMngVillageDO); |
| | | }); |
| | | this.saveBatch(comMngVillageDOS); |
New file |
| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.service_community.dao.GridBuildRelationDAO; |
| | | import com.panzhihua.service_community.model.dos.GridBuildRelationDO; |
| | | import com.panzhihua.service_community.service.GridBuildRelationService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 特殊人群管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | @Service |
| | | public class GridBuildRelationServiceImpl extends ServiceImpl<GridBuildRelationDAO, GridBuildRelationDO> implements GridBuildRelationService { |
| | | |
| | | /** |
| | | * description 批量保存重点人群人员信息 |
| | | * 处理逻辑:同一个人的信息可以被多个社区重复录入 |
| | | * 一个人的信息如果被同一个社区重复导入。以最新的导入数据为准。将之前的数据进行更新操作。 |
| | | * |
| | | * @param keyList 重点人群信息 |
| | | * @return R 保存结果 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R saveBatchGridBuildRelation(List<GridBuildRelationDO> keyList) { |
| | | keyList.forEach(keyPersonInfoDTO -> { |
| | | GridBuildRelationDO dbKeyPerson = checkExistFromDb(keyPersonInfoDTO); |
| | | if (dbKeyPerson != null) { |
| | | //已经存在数据,进行数据更新操作 |
| | | GridBuildRelationDO keyPersonInfoDO = new GridBuildRelationDO(); |
| | | BeanUtils.copyProperties(keyPersonInfoDTO, keyPersonInfoDO); |
| | | keyPersonInfoDO.setId(dbKeyPerson.getId()); |
| | | updateById(keyPersonInfoDO); |
| | | } else { |
| | | GridBuildRelationDO keyPersonInfoDO = new GridBuildRelationDO(); |
| | | BeanUtils.copyProperties(keyPersonInfoDTO, keyPersonInfoDO); |
| | | save(keyPersonInfoDO); |
| | | } |
| | | }); |
| | | return R.ok(); |
| | | } |
| | | |
| | | private GridBuildRelationDO checkExistFromDb(GridBuildRelationDO gridBuildRelationDO) { |
| | | return baseMapper.selectOne( |
| | | new QueryWrapper<GridBuildRelationDO>() |
| | | .eq("grid_community_id", gridBuildRelationDO.getGridCommunityId()) |
| | | .eq("grid_id", gridBuildRelationDO.getGridId()) |
| | | .eq("village_id", gridBuildRelationDO.getVillageId()) |
| | | .eq("build_id", gridBuildRelationDO.getBuildId()) |
| | | ); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.enums.KeyPersonLabelEnum; |
| | | import com.panzhihua.common.model.dtos.community.ComMngPopulationTagCardNoDTO; |
| | | import com.panzhihua.common.model.dtos.community.KeyPersonInfoDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.service_community.dao.KeyPersonInfoDAO; |
| | | import com.panzhihua.service_community.model.dos.KeyPersonInfoDO; |
| | | import com.panzhihua.service_community.service.ComMngPopulationService; |
| | | import com.panzhihua.service_community.service.KeyPersonInfoService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * program 攀枝花智慧社区项目 |
| | | * description 特殊人群管理API |
| | | * |
| | | * @author manailin |
| | | * Date 2021-01-22 15:30 |
| | | **/ |
| | | @Service |
| | | public class KeyPersonInfoServiceImpl extends ServiceImpl<KeyPersonInfoDAO, KeyPersonInfoDO> implements KeyPersonInfoService { |
| | | |
| | | @Resource |
| | | private ComMngPopulationService comMngPopulationService; |
| | | |
| | | /** |
| | | * description 批量保存重点人群人员信息 |
| | | * 处理逻辑:同一个人的信息可以被多个社区重复录入 |
| | | * 一个人的信息如果被同一个社区重复导入。以最新的导入数据为准。将之前的数据进行更新操作。 |
| | | * |
| | | * @param list 重点人群信息 |
| | | * @return R 保存结果 |
| | | * @author manailin |
| | | * @date 2021/6/10 17:00 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R saveBatchKeyPerson(List<KeyPersonInfoDTO> list) { |
| | | list.forEach(keyPersonInfoDTO -> { |
| | | KeyPersonInfoDO dbKeyPerson = checkExistFromDb(keyPersonInfoDTO); |
| | | if (dbKeyPerson != null) { |
| | | //已经存在数据,进行数据更新操作 |
| | | KeyPersonInfoDO keyPersonInfoDO = new KeyPersonInfoDO(); |
| | | BeanUtils.copyProperties(keyPersonInfoDTO, keyPersonInfoDO); |
| | | keyPersonInfoDO.setId(dbKeyPerson.getId()); |
| | | ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO = new ComMngPopulationTagCardNoDTO(); |
| | | comMngPopulationTagCardNoDTO.setCardNo(dbKeyPerson.getCardNo()); |
| | | comMngPopulationTagCardNoDTO.setLabel(calculateLabel(dbKeyPerson)); |
| | | comMngPopulationService.editTagPopulationByCardNo(comMngPopulationTagCardNoDTO); |
| | | updateById(keyPersonInfoDO); |
| | | } else { |
| | | KeyPersonInfoDO keyPersonInfoDO = new KeyPersonInfoDO(); |
| | | BeanUtils.copyProperties(keyPersonInfoDTO, keyPersonInfoDO); |
| | | save(keyPersonInfoDO); |
| | | } |
| | | }); |
| | | return R.ok(); |
| | | } |
| | | |
| | | private String calculateLabel(KeyPersonInfoDO dbKeyPerson) { |
| | | switch (dbKeyPerson.getVisiterType()) { |
| | | case 1: |
| | | return KeyPersonLabelEnum.XD.getName(); |
| | | case 2: |
| | | return KeyPersonLabelEnum.ZJ.getName(); |
| | | |
| | | case 3: |
| | | return KeyPersonLabelEnum.XJ.getName(); |
| | | |
| | | case 4: |
| | | return KeyPersonLabelEnum.QT.getName(); |
| | | default: |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | private KeyPersonInfoDO checkExistFromDb(KeyPersonInfoDTO keyPersonInfoDTO) { |
| | | return baseMapper.selectOne( |
| | | new QueryWrapper<KeyPersonInfoDO>() |
| | | .eq("act_id", keyPersonInfoDTO.getActId()) |
| | | .eq("card_no", keyPersonInfoDTO.getCardNo()) |
| | | .eq("visiter_type", keyPersonInfoDTO.getVisiterType()) |
| | | ); |
| | | } |
| | | } |