diff --git a/epmet-cloud-generator/src/main/resources/application.yml b/epmet-cloud-generator/src/main/resources/application.yml index 0bd4a76f77..973eb74fe0 100644 --- a/epmet-cloud-generator/src/main/resources/application.yml +++ b/epmet-cloud-generator/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource #MySQL配置 driverClassName: com.mysql.jdbc.Driver - url: jdbc:mysql://192.168.1.140:3306/epmet_data_statistical?useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://118.190.150.119:43306/epmet_user?useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: root #oracle配置 diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index c551a68db1..7542899ad0 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -166,6 +166,17 @@ transmittable-thread-local 2.12.4 + + com.google.zxing + core + 3.3.2 + + + + com.google.zxing + javase + 3.3.2 + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/BarcodeUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/BarcodeUtils.java new file mode 100644 index 0000000000..ee5369b3af --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/BarcodeUtils.java @@ -0,0 +1,177 @@ +package com.epmet.commons.tools.utils; + +/** + * desc: + * + * @author: LiuJanJun + * @date: 2022/3/18 11:57 上午 + * @version: 1.0 + */ + + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.client.j2se.MatrixToImageConfig; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.CharacterSetECI; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; + +/** + * Author 程鹏 + * Date: 2021/08/27 16:01 + * Description:二维码生成工具类 + */ +public class BarcodeUtils { + /** + * 二维码颜色 默认是黑色 + */ + private static final Color QRCOLOR = Color.black; + /** + * 背景颜色 + */ + private static final Color BGWHITE = Color.white; + public static final int WIDTH = 360; + public static final int HEIGHT = 512; + public static final int MARGIN = 2; + public static final int FONTSIZE = 20; + + + /** + * // 二维码生成 + * + * @param contents 说明 + * @return BufferedImage + * @throws Exception + */ + public static BufferedImage drawQRImage(String pressText, String contents) throws Exception { + BufferedImage qRImage = null; + if (contents == null || "".equals(contents)) { + throw new Exception("content说明不能为空"); + } + // 二维码参数设置 + HashMap hints = new HashMap<>(); + hints.put(EncodeHintType.CHARACTER_SET, CharacterSetECI.UTF8); // 编码设置 + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); // 安全等级,最高h + hints.put(EncodeHintType.MARGIN, MARGIN); // 设置margin=0-10 + + // 二维码图片的生成 + BarcodeFormat format = BarcodeFormat.QR_CODE; + // 创建矩阵容器 + BitMatrix matrix = null; + try { + matrix = new MultiFormatWriter().encode(contents, format, WIDTH, HEIGHT, hints); + } catch (WriterException e) { + e.printStackTrace(); + } + + // 设置矩阵转为图片的参数 + MatrixToImageConfig toImageConfig = new MatrixToImageConfig(QRCOLOR.getRGB(), BGWHITE.getRGB()); + + // 矩阵转换图像 + qRImage = MatrixToImageWriter.toBufferedImage(matrix, toImageConfig); + return pressText(pressText, qRImage); + } + + /** + * @param pressText 二维码下方插入文字 + * @param image 需要添加文字的图片 + * @为图片添加文字 + */ + private static BufferedImage pressText(String pressText, BufferedImage image) throws Exception { + + BufferedImage outImage = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); + //计算文字开始的位置 + //x开始的位置:(图片宽度-字体大小*字的个数)/2 + int startX = (WIDTH - (FONTSIZE * pressText.length())) / 2; + //y开始的位置:图片高度-(图片高度-图片宽度)/2 + int startY = HEIGHT - (HEIGHT - WIDTH) / 2; + + int imageW = outImage.getWidth(); + int imageH = outImage.getHeight(); + Graphics2D g = outImage.createGraphics(); + g.drawImage(image, 0, 0, imageW, imageH, null); + g.setColor(QRCOLOR); + g.setFont(new Font("Noto Sans SC Light", Font.BOLD, FONTSIZE)); + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.setBackground(Color.white); +// 获取文字数量 按照字节展示 + int size = pressText.getBytes("GBK").length; +// 获取一行最多能容纳多少文字 按照文字字节展示 + int maxSize = (WIDTH / FONTSIZE - 2) * 2; + if (size > maxSize) { + int v = size % maxSize; + for (int a = 0; a < (size / maxSize); a++) { + String s = outStringByByte(pressText, maxSize); + g.drawString(s, (WIDTH - (FONTSIZE * (WIDTH / FONTSIZE - 2))) / 2, startY); + pressText = pressText.substring(s.length(), pressText.length()); + startY = startY + 30; + } + if (v != 0) { + g.drawString(pressText, (WIDTH - (FONTSIZE * v)) / 2, startY); + } + } else { + g.drawString(pressText, (WIDTH - ((pressText.getBytes("GBK").length) / 2) * FONTSIZE) / 2, startY); + } + + g.dispose(); + return outImage; + } + + + /** + * 保存二维码图片到本地 + * + * @param contents + * @throws Exception + */ + public static void createImg(String pressText, String contents, String filename, String filePath) throws Exception { + BufferedImage qRImageWithLogo = drawQRImage(pressText, contents); + // 写入返回 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ImageIO.write(qRImageWithLogo, "jpg", baos); + //图片类型 + String imageType = "jpg"; + //生成二维码存放文件 + File file = new File(filePath + filename + ".jpg"); + if (!file.exists()) { + file.mkdirs(); + } + ImageIO.write(qRImageWithLogo, imageType, file); + baos.close(); + } + + + private static String outStringByByte(String str, int len) throws IOException { + byte[] btf = str.getBytes("GBK"); + int count = 0; + + for (int j = len - 1; j >= 0; j--) { + if (btf[j] < 0) { + count++; + } else { + break; + } + } + + if (count % 2 == 0) { + return new String(btf, 0, len, "GBK"); + } else { + return new String(btf, 0, len - 1, "GBK"); + } + + } + + +} + diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index ee82177268..aeebe0f583 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -499,7 +499,12 @@ epmet: - /oper/customize/customerstartpage/homestartpage - /epmet/point/mqCallback/** - /tduck-api/** - + #居民信息采集:查询楼栋,单元,房屋,提交信息 + - /gov/org/icneighborhood/open/list + - /gov/org/icbuilding/buildingoption + - /gov/org/icbuildingunit/unitoption + - /gov/org/ichouse/houseoption + - /epmetuser/icresicollect/save # 外部应用认证,使用AccessToken等头进行认证 externalOpenUrls: - /data/report/** @@ -531,7 +536,6 @@ epmet: # 对外开放接口认证白名单 externalAuthUrlsWhiteList: - /epmet/ext/open-api/get-access-token - swaggerUrls: jwt: diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CreateQrCodeFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CreateQrCodeFormDTO.java new file mode 100644 index 0000000000..b209fccbf0 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CreateQrCodeFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.Group; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/3/18 15:43 + * @DESC + */ +@Data +public class CreateQrCodeFormDTO implements Serializable { + + private static final long serialVersionUID = -6801094057381407439L; + + public interface CreateQrCodeForm{} + + @NotBlank(message = "id不能为空",groups = CreateQrCodeForm.class) + private String id; + + /** + * community:社区,neighborHood:小区 + */ + @NotBlank(message = "type不能为空",groups = CreateQrCodeForm.class) + private String type; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java index fbeefeadf5..32eabb2ea6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java @@ -17,17 +17,17 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.dto.form.PageFormDTO; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; -import java.io.Serializable; @Data -public class IcNeighborHoodFormDTO implements Serializable { +public class IcNeighborHoodFormDTO extends PageFormDTO { private static final long serialVersionUID = 1L; @@ -102,4 +102,4 @@ public class IcNeighborHoodFormDTO implements Serializable { -} \ No newline at end of file +} diff --git a/epmet-module/gov-org/gov-org-server/Dockerfile b/epmet-module/gov-org/gov-org-server/Dockerfile index b4f5ecffbb..84c2478da5 100644 --- a/epmet-module/gov-org/gov-org-server/Dockerfile +++ b/epmet-module/gov-org/gov-org-server/Dockerfile @@ -5,6 +5,7 @@ RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo 'Asia/Shanghai' > /etc/timezone COPY ./target/*.jar ./gov-org.jar +COPY ./fonts/NotoSansSC-Light.otf /usr/share/fonts EXPOSE 8092 diff --git a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml index 0da84fc37e..0297930754 100644 --- a/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml +++ b/epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml @@ -15,4 +15,4 @@ services: resources: limits: cpus: '0.1' - memory: 300M \ No newline at end of file + memory: 300M diff --git a/epmet-module/gov-org/gov-org-server/fonts/NotoSansSC-Light.otf b/epmet-module/gov-org/gov-org-server/fonts/NotoSansSC-Light.otf new file mode 100644 index 0000000000..a1f02c6c62 Binary files /dev/null and b/epmet-module/gov-org/gov-org-server/fonts/NotoSansSC-Light.otf differ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index 363f7b7297..fa337b1fd2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -17,16 +17,24 @@ package com.epmet.controller; +import com.alibaba.fastjson.JSONObject; import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.RequirePermission; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.enums.RequirePermissionEnum; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.BarcodeUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.CustomerAgencyConstant; +import com.epmet.constant.OrgInfoConstant; import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; @@ -34,11 +42,28 @@ import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.send.SendMqMsgUtil; import com.epmet.service.AgencyService; import com.epmet.service.CustomerAgencyService; +import com.epmet.service.IcNeighborHoodService; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URLEncoder; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -59,6 +84,8 @@ public class AgencyController { private CustomerAgencyService customerAgencyService; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private IcNeighborHoodService neighborHoodService; /** * @param formDTO @@ -360,4 +387,67 @@ public class AgencyController { return new Result>().ok(agencyService.getSonAgencyId(orgId,type)); } -} \ No newline at end of file + /** + * Desc: 生成某类型下的二维码 + * @param formDTO + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + @PostMapping("create-qrcode") + public void createQrCode(@LoginUser TokenDto tokenDto, @RequestBody CreateQrCodeFormDTO formDTO, HttpServletResponse response){ + ValidatorUtils.validateEntity(formDTO, CreateQrCodeFormDTO.CreateQrCodeForm.class); + String id = formDTO.getId(); + String type = formDTO.getType(); + String name = ""; + try { + if (type.equals(OrgInfoConstant.COMMUNITY)){ + CustomerAgencyDTO customerAgencyDTO = customerAgencyService.get(id); + if (customerAgencyDTO == null){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"组织信息不存在"); + } + name = customerAgencyDTO.getOrganizationName(); + }else if (type.equals(OrgInfoConstant.NEIGHBOR_HOOD)){ + IcNeighborHoodDTO icNeighborHoodDTO = neighborHoodService.get(id); + if (icNeighborHoodDTO == null){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"小区信息不存在"); + } + name = icNeighborHoodDTO.getNeighborHoodName(); + } + //url组成:数字社区地址?小区id&用户id + //String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id; + String url = EnvEnum.getCurrentEnv().getUrl().replace("api/", StrConstant.EPMETY_STR) + .concat("epmet-oper-gov/#/caiji/") + .concat(id).concat("?") + .concat("name=").concat(URLEncoder.encode(name,StrConstant.UTF_8)).concat(StrConstant.AND_MARK) + .concat("customerId=").concat(tokenDto.getCustomerId()).concat(StrConstant.AND_MARK) + .concat("type=").concat(type).concat(StrConstant.AND_MARK) + .concat("userId=").concat(tokenDto.getUserId()) + .concat(StrConstant.AND_MARK).concat(String.valueOf(LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli())); + BufferedImage image = BarcodeUtils.drawQRImage(name, url); + //BufferedImage 转 InputStream + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); + ImageIO.write(image, "png", imageOutput); + InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); + long length = imageOutput.length(); + String fileName = name+".png"; + response.setContentType("application/octet-stream"); + response.setContentLength((int)length); + response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName, StrConstant.UTF_8)); + + //输出流 + byte[] bytes = new byte[1024]; + OutputStream outputStream = response.getOutputStream(); + long count = 0; + while(count < length){ + int len = inputStream.read(bytes, 0, 1024); + count +=len; + outputStream.write(bytes, 0, len); + } + outputStream.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index dadab70ce5..03bdf6050e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -19,20 +19,23 @@ package com.epmet.controller; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.OptionResultDTO; +import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.BarcodeUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; @@ -43,8 +46,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; -import java.io.InputStream; +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URLEncoder; import java.util.List; import java.util.Map; @@ -71,6 +78,12 @@ public class IcNeighborHoodController { return new Result>().ok(page); } + @PostMapping("open/list") + public Result> openList(@RequestBody IcNeighborHoodFormDTO params){ + PageData page = icNeighborHoodService.openPage(params); + return new Result>().ok(page); + } + @GetMapping("{id}") public Result get(@PathVariable("id") String id){ IcNeighborHoodDTO data = icNeighborHoodService.get(id); @@ -165,4 +178,51 @@ public class IcNeighborHoodController { return new Result(); } + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param id + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + @PostMapping("createQrCode/{id}") + public void getExistUserByHouseIds(@LoginUser TokenDto tokenDto, @PathVariable("id") String id, HttpServletResponse response){ + try { + IcNeighborHoodDTO icNeighborHoodDTO = icNeighborHoodService.get(id); + if (icNeighborHoodDTO == null){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"小区信息不存在"); + } + String neighborhoodName = icNeighborHoodDTO.getNeighborHoodName(); + //url组成:数字社区地址?小区id&用户id + //String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id; + String url = EnvEnum.getCurrentEnv().getUrl().replace("api/",StrConstant.EPMETY_STR) + .concat("epmet-oper-gov/#/caiji/") + .concat(id) + .concat(StrConstant.AND_MARK).concat("userId=").concat(tokenDto.getUserId()); + BufferedImage image = BarcodeUtils.drawQRImage(neighborhoodName, url); + //BufferedImage 转 InputStream + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); + ImageIO.write(image, "png", imageOutput); + InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); + long length = imageOutput.length(); + String fileName = neighborhoodName+".png"; + response.setContentType("application/octet-stream"); + response.setContentLength((int)length); + response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName, StrConstant.UTF_8)); + + //输出流 + byte[] bytes = new byte[1024]; + OutputStream outputStream = response.getOutputStream(); + long count = 0; + while(count < length){ + int len = inputStream.read(bytes, 0, 1024); + count +=len; + outputStream.write(bytes, 0, len); + } + outputStream.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index 1f32607a65..3dcfaba0da 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -23,12 +23,12 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcNeighborHoodDTO; import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.IcNeighborHoodEntity; import com.epmet.entity.IcNeighborHoodPropertyEntity; import com.epmet.entity.IcPropertyManagementEntity; -import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.InputStream; @@ -148,4 +148,11 @@ public interface IcNeighborHoodService extends BaseService void neighborHoodPropertyInsert(List entities); String orgGeneralImport(Collection errorRows, Class tClass) throws IOException; -} \ No newline at end of file + + /** + * desc:开发获取小区列表 分页或不分页 + * @param params + * @return + */ + PageData openPage(IcNeighborHoodFormDTO params); +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index f2b50748eb..331552e4a3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -48,6 +48,7 @@ import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcNeighborHoodDao; import com.epmet.dao.IcPropertyManagementDao; import com.epmet.dto.*; +import com.epmet.dto.form.IcNeighborHoodFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; @@ -61,6 +62,8 @@ import com.epmet.model.ImportNeighborHoodInfoListener; import com.epmet.model.NeighborHoodInfoModel; import com.epmet.redis.IcHouseRedis; import com.epmet.service.*; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; @@ -680,4 +683,25 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl openPage(IcNeighborHoodFormDTO params) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcNeighborHoodEntity::getAgencyId,params.getAgencyId()); + PageData result = null; + List list = null; + if (params.isPage()){ + Page objects = PageHelper.startPage(params.getPageNo(), params.getPageSize()).doSelectPage(() -> { + baseDao.selectList(wrapper); + }); + list = ConvertUtils.sourceToTarget(objects.getResult(),IcNeighborHoodDTO.class); + result = new PageData<>(list,objects.getTotal()); + return result; + } + + List listEntity = baseDao.selectList(wrapper); + list = ConvertUtils.sourceToTarget(listEntity,IcNeighborHoodDTO.class); + result = new PageData<>(list,list.size()); + return result; + } + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CollectListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CollectListFormDTO.java new file mode 100644 index 0000000000..ae5ec4bacb --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CollectListFormDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/3/18 19:00 + * @DESC + */ +@Data +public class CollectListFormDTO implements Serializable { + + private static final long serialVersionUID = 2106773724057183577L; + + public interface CollectListForm{} + + @NotNull(message = "pageNo不能为空", groups = CollectListForm.class) + private Integer pageNo; + + @NotNull(message = "pageSize不能为空", groups = CollectListForm.class) + private Integer pageSize; + + private String orgId; + private String neighborHoodId; + private String buildingId; + private String houseId; + private String address; + + /** + * 格式:yyyy-mm-dd + */ + private String startDate; + private String endDate; + + private String userId; + private String customerId; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectFormDTO.java new file mode 100644 index 0000000000..21f2244129 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectFormDTO.java @@ -0,0 +1,105 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * 收集居民信息入参 + */ +@Data +public class IcResiCollectFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + public interface InternalShowGroup extends CustomerClientShowGroup { + } + + public interface ExternalShowGroup extends CustomerClientShowGroup { + } + + /** + * 客户Id customer.id + */ + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + /** + * 内部:internal;外部:external + */ + @NotBlank(message = "兴德路社区:internal;其他社区:external", groups = AddUserInternalGroup.class) + private String origin; + + /** + * 网格ID_后端接口赋值 + */ + private String gridId; + + /** + * 组织Id_后端接口赋值 + */ + private String agencyId; + + /** + * 组织的pid_后端接口赋值 + */ + private String pids; + + /** + * 所属小区ID + */ + @NotBlank(message = "小区不能为空", groups = InternalShowGroup.class) + private String villageId; + + /** + * 所属楼宇Id + */ + @NotBlank(message = "楼栋不能为空", groups = InternalShowGroup.class) + private String buildId; + + /** + * 单元id + */ + @NotBlank(message = "单元不能为空", groups = InternalShowGroup.class) + private String unitId; + + /** + * 所属家庭Id + */ + @NotBlank(message = "家庭不能为空", groups = InternalShowGroup.class) + private String homeId; + + /** + * 详细地址 + */ + @NotBlank(message = "家庭地址不能为空", groups = {InternalShowGroup.class, ExternalShowGroup.class}) + private String address; + + /** + * 1自由0租住 + */ + @NotBlank(message = "房子属于自由还是组织?", groups = {InternalShowGroup.class, ExternalShowGroup.class}) + private String houseType; + + /** + * 户主姓名 + */ + @NotBlank(message = "户主姓名不能为空", groups = {InternalShowGroup.class, ExternalShowGroup.class}) + private String houseHolderName; + + /** + * 居住成员人数 + */ + @NotNull(message = "居住成员人数不能为空", groups = {InternalShowGroup.class, ExternalShowGroup.class}) + private Integer totalResi; + + @Valid + @NotEmpty(message = "成员信息不能为空", groups = {InternalShowGroup.class, ExternalShowGroup.class}) + private List memberList; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectMemFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectMemFormDTO.java new file mode 100644 index 0000000000..4490b9357c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiCollectMemFormDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Data +public class IcResiCollectMemFormDTO implements Serializable { + /** + * 客户Id customer.id + */ + private String customerId; + /** + * 居住成员1姓名 + */ + @NotBlank(message = "姓名不能为空", groups = {IcResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) + private String name; + + /** + * 居住成员1身份证号 + */ + @NotBlank(message = "身份证号不能为空", groups = {IcResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) + private String idNum; + + /** + * 居住成员1手机号 + */ + @NotBlank(message = "手机号不能为空", groups = {IcResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) + private String mobile; + + /** + * 居住成员1是否参加几轮全员核算检测,数字1-10 + */ + @NotBlank(message = "核算检测情况不能为空", groups = {IcResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) + private String heSuanCount; + + /** + * 居住成员1新冠疫苗接种情况;1:已全程接种;2:未全程接种;0未接种; + */ + @NotNull(message = "疫苗接种情况不能为空", groups = {IcResiCollectFormDTO.InternalShowGroup.class, IcResiCollectFormDTO.ExternalShowGroup.class}) + private Integer ymjz; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CollectListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CollectListResultDTO.java new file mode 100644 index 0000000000..9edcfa4d8d --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CollectListResultDTO.java @@ -0,0 +1,88 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/3/18 19:00 + * @DESC + */ +@Data +public class CollectListResultDTO implements Serializable { + + private static final long serialVersionUID = -6692672375850864451L; + + /** + * 户主姓名 + */ + private String houseHolderName; + + @JsonIgnore + private String id; + + /** + * 居住地址 + */ + private String address; + + /** + * 房屋类型,1:自有, 0:租住 + */ + private String houseType; + + /** + * 居住人数 + */ + private Integer totalResi; + + private List list; + + public CollectListResultDTO() { + this.houseHolderName = ""; + this.address = ""; + this.houseType = "0"; + this.totalResi = 0; + this.list = new ArrayList<>(); + } + + @Data + public static class CollectListMemberResultDTO{ + /** + * 成员名字 + */ + private String memberName; + + /** + * 成员身份证 + */ + private String memberIdNum; + + /** + * 成员电话 + */ + private String memberMobile; + + /** + * 核酸检测次数 + */ + private String heSuanCount; + + /** + * 疫苗是否全程接种,1:全程接种,2:未全程接种,3:为接种 + */ + private Integer ymjz; + + public CollectListMemberResultDTO() { + this.memberName = ""; + this.memberIdNum = ""; + this.memberMobile = ""; + this.heSuanCount = "0"; + this.ymjz = 0; + } + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectController.java new file mode 100644 index 0000000000..ed1227c01e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectController.java @@ -0,0 +1,71 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.CollectListFormDTO; +import com.epmet.dto.form.IcResiCollectFormDTO; +import com.epmet.dto.result.CollectListResultDTO; +import com.epmet.service.IcResiCollectService; +import org.springframework.beans.factory.annotation.Autowired; +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 java.util.List; + + +/** + * 居民信息采集表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-18 + */ +@RestController +@RequestMapping("icresicollect") +public class IcResiCollectController { + + @Autowired + private IcResiCollectService icResiCollectService; + + /** + * 居民信息采集_提交 + * + * @param formDTO + * @return + */ + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody IcResiCollectFormDTO formDTO) { + //效验数据 + ValidatorUtils.validateEntity(formDTO, IcResiCollectFormDTO.AddUserInternalGroup.class); + // 内部:internal;外部:external + if ("internal".equals(formDTO.getOrigin())) { + ValidatorUtils.validateEntity(formDTO, IcResiCollectFormDTO.InternalShowGroup.class); + } else if ("external".equals(formDTO.getOrigin())) { + ValidatorUtils.validateEntity(formDTO, IcResiCollectFormDTO.ExternalShowGroup.class); + } + icResiCollectService.save(formDTO); + return new Result(); + } + + /** + * Desc: 查询采集居民信息 + * @param formDTO + * @param tokenDto + * @author zxc + * @date 2022/3/18 19:23 + */ + @PostMapping("list") + public Result> getCollectList(@RequestBody CollectListFormDTO formDTO, @LoginUser TokenDto tokenDto){ + ValidatorUtils.validateEntity(formDTO,CollectListFormDTO.CollectListForm.class); + formDTO.setUserId(tokenDto.getUserId()); + formDTO.setCustomerId(tokenDto.getCustomerId()); + return new Result>().ok(icResiCollectService.getCollectList(formDTO)); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectDao.java new file mode 100644 index 0000000000..f70f0e04ff --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiCollectDao.java @@ -0,0 +1,36 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.CollectListFormDTO; +import com.epmet.dto.result.CollectListResultDTO; +import com.epmet.entity.IcResiCollectEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 居民信息采集表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-18 + */ +@Mapper +public interface IcResiCollectDao extends BaseDao { + + IcResiCollectEntity selectByAddress(String address); + + int updateRec(@Param("id") String id, + @Param("houseType") String houseType, + @Param("houseHolderName") String houseHolderName, + @Param("totalResi") Integer totalResi); + + /** + * Desc: 查询采集居民信息 + * @param formDTO + * @author zxc + * @date 2022/3/18 19:41 + */ + List getCollectList(CollectListFormDTO formDTO); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiMemberDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiMemberDao.java new file mode 100644 index 0000000000..e4748e01b2 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiMemberDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcResiMemberEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 居民信息成员表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-18 + */ +@Mapper +public interface IcResiMemberDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiCollectEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiCollectEntity.java new file mode 100644 index 0000000000..1123bca8b8 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiCollectEntity.java @@ -0,0 +1,86 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 居民信息采集表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-18 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_resi_collect") +public class IcResiCollectEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id customer.id + */ + private String customerId; + + /** + * 内部:internal;外部:external + */ + private String origin; + + /** + * 网格ID + */ + private String gridId; + + /** + * 组织Id + */ + private String agencyId; + + /** + * 组织的pids + */ + private String pids; + + /** + * 所属小区ID + */ + private String villageId; + + /** + * 所属楼宇Id + */ + private String buildId; + + /** + * 单元id + */ + private String unitId; + + /** + * 所属家庭Id + */ + private String homeId; + + /** + * 详细地址 + */ + private String address; + + /** + * 1自由0租住 + */ + private String houseType; + + /** + * 户主姓名 + */ + private String houseHolderName; + + /** + * 居住成员人数 + */ + private Integer totalResi; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiMemberEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiMemberEntity.java new file mode 100644 index 0000000000..399ce07822 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiMemberEntity.java @@ -0,0 +1,56 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 居民信息成员表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-18 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_resi_member") +public class IcResiMemberEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id customer.id + */ + private String customerId; + + /** + * ic_resi_colllect.id + */ + private String icResiCollectId; + + /** + * 居住成员1姓名 + */ + private String name; + + /** + * 居住成员1身份证号 + */ + private String idNum; + + /** + * 居住成员1手机号 + */ + private String mobile; + + /** + * 居住成员1是否参加几轮全员核算检测,数字1-10 + */ + private String heSuanCount; + + /** + * 居住成员1新冠疫苗接种情况;1:已全程接种;2:未全程接种;0未接种; + */ + private Integer ymjz; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiCollectService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiCollectService.java new file mode 100644 index 0000000000..4c0bca4fa5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiCollectService.java @@ -0,0 +1,39 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.CollectListFormDTO; +import com.epmet.dto.form.IcResiCollectFormDTO; +import com.epmet.dto.result.CollectListResultDTO; +import com.epmet.entity.IcResiCollectEntity; + +import java.util.List; + +/** + * 居民信息采集表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-18 + */ +public interface IcResiCollectService extends BaseService { + + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-03-18 + */ + void save(IcResiCollectFormDTO dto); + + /** + * Desc: 查询采集居民信息 + * @param formDTO + * @author zxc + * @date 2022/3/18 19:23 + */ + PageData getCollectList(CollectListFormDTO formDTO); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java new file mode 100644 index 0000000000..4037180bf0 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiCollectServiceImpl.java @@ -0,0 +1,138 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.IcResiCollectDao; +import com.epmet.dao.IcResiMemberDao; +import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.dto.form.CollectListFormDTO; +import com.epmet.dto.form.IcResiCollectFormDTO; +import com.epmet.dto.result.CollectListResultDTO; +import com.epmet.entity.IcResiCollectEntity; +import com.epmet.entity.IcResiMemberEntity; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.service.IcResiCollectService; +import org.apache.commons.collections4.MapUtils; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 居民信息采集表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-18 + */ +@Service +public class IcResiCollectServiceImpl extends BaseServiceImpl implements IcResiCollectService { + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; + @Autowired + private IcResiMemberDao icResiMemberDao; + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(IcResiCollectFormDTO formDTO) { + IcResiCollectEntity origin = baseDao.selectByAddress(formDTO.getAddress()); + if (null == origin) { + //插入主表、成员表 + IcResiCollectEntity insert = ConvertUtils.sourceToTarget(formDTO, IcResiCollectEntity.class); + if ("internal".equals(formDTO.getOrigin())) { + //根据小区id查询网格相关信息 + IcNeighborHoodDTO neighborHoodDTO = queryIcNeighborHood(formDTO.getVillageId()); + insert.setGridId(neighborHoodDTO.getGridId()); + insert.setAgencyId(neighborHoodDTO.getAgencyId()); + insert.setPids(neighborHoodDTO.getAgencyPids()); + } + baseDao.insert(insert); + List memberList = ConvertUtils.sourceToTarget(formDTO.getMemberList(), IcResiMemberEntity.class); + memberList.forEach(mem -> { + mem.setIcResiCollectId(insert.getId()); + icResiMemberDao.insert(mem); + }); + } else { + //更新主表 + baseDao.updateRec(origin.getId(), formDTO.getHouseType(), formDTO.getHouseHolderName(), formDTO.getTotalResi()); + List newMemberList = ConvertUtils.sourceToTarget(formDTO.getMemberList(), IcResiMemberEntity.class); + //查询之前录入的成员表 + Map memMap = queryOriginMem(origin.getId()); + saveOrUpdateMem(newMemberList, memMap,origin.getId()); + } + } + + /** + * Desc: 查询采集居民信息 + * @param formDTO + * @author zxc + * @date 2022/3/18 19:23 + */ + @Override + public PageData getCollectList(CollectListFormDTO formDTO) { + PageData result = new PageData<>(new ArrayList<>(), 0); + if (StringUtils.isBlank(formDTO.getOrgId()) && + StringUtils.isBlank(formDTO.getNeighborHoodId()) && + StringUtils.isBlank(formDTO.getBuildingId()) && + StringUtils.isBlank(formDTO.getHouseId()) && + StringUtils.isBlank(formDTO.getAddress()) && + StringUtils.isBlank(formDTO.getStartDate()) && + StringUtils.isBlank(formDTO.getEndDate()) ){ + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo){ + throw new EpmetException("查询人员信息失败"+formDTO.getUserId()); + } + formDTO.setOrgId(staffInfo.getAgencyId()); + } + PageInfo pageList = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.getCollectList(formDTO)); + result.setList(pageList.getList()); + result.setTotal(Integer.valueOf(String.valueOf(pageList.getTotal()))); + return result; + } + + + private IcNeighborHoodDTO queryIcNeighborHood(String villageId) { + Result res = govOrgOpenFeignClient.getIcNeighbordhoodById(villageId); + if (!res.success() || null == res.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "小区信息查询异常", "小区信息查询异常"); + } + return res.getData(); + } + + private Map queryOriginMem(String icResiCollectId) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcResiMemberEntity::getIcResiCollectId, icResiCollectId); + List originMemberList = icResiMemberDao.selectList(query); + Map memMap = originMemberList.stream().collect(Collectors.toMap(IcResiMemberEntity::getIdNum, Function.identity())); + return memMap; + } + + private void saveOrUpdateMem(List newMemberList, Map memMap, String originIcResiCollectId) { + for (IcResiMemberEntity entity : newMemberList) { + if (MapUtils.isNotEmpty(memMap) && memMap.containsKey(entity.getIdNum())) { + entity.setIcResiCollectId(originIcResiCollectId); + entity.setCustomerId(memMap.get(entity.getIdNum()).getCustomerId()); + entity.setId(memMap.get(entity.getIdNum()).getId()); + icResiMemberDao.updateById(entity); + continue; + } + //没有插入 + entity.setIcResiCollectId(originIcResiCollectId); + icResiMemberDao.insert(entity); + } + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.26__caiji_resi.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.26__caiji_resi.sql new file mode 100644 index 0000000000..e015975efa --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.26__caiji_resi.sql @@ -0,0 +1,42 @@ +CREATE TABLE `ic_resi_collect` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id customer.id', + `ORIGIN` varchar(32) NOT NULL COMMENT '内部:internal;外部:external。', + `GRID_ID` varchar(64) DEFAULT NULL COMMENT '网格ID', + `AGENCY_ID` varchar(64) DEFAULT NULL COMMENT '组织Id', + `PIDS` varchar(255) DEFAULT NULL COMMENT '组织的pids', + `VILLAGE_ID` varchar(64) DEFAULT NULL COMMENT '所属小区ID;', + `BUILD_ID` varchar(64) DEFAULT NULL COMMENT '所属楼宇Id', + `UNIT_ID` varchar(64) DEFAULT NULL COMMENT '单元id', + `HOME_ID` varchar(64) DEFAULT NULL COMMENT '所属家庭Id', + `ADDRESS` varchar(255) NOT NULL COMMENT '详细地址', + `HOUSE_TYPE` varchar(1) NOT NULL COMMENT '1自由0租住', + `HOUSE_HOLDER_NAME` varchar(32) NOT NULL COMMENT '户主姓名', + `TOTAL_RESI` int(11) NOT NULL COMMENT '居住成员人数', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民信息采集表'; + + +CREATE TABLE `ic_resi_member` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id customer.id', + `IC_RESI_COLLECT_ID` varchar(64) NOT NULL COMMENT 'ic_resi_colllect.id', + `NAME` varchar(32) NOT NULL COMMENT '居住成员1姓名', + `ID_NUM` varchar(32) NOT NULL COMMENT '居住成员1身份证号', + `MOBILE` varchar(32) NOT NULL COMMENT '居住成员1手机号', + `HE_SUAN_COUNT` varchar(32) NOT NULL COMMENT '居住成员1是否参加几轮全员核算检测,数字1-10', + `YMJZ` int(11) NOT NULL COMMENT '居住成员1新冠疫苗接种情况;1:已全程接种;2:未全程接种;0未接种;', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民信息成员表'; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectDao.xml new file mode 100644 index 0000000000..7f2c5a9a4d --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiCollectDao.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + UPDATE ic_resi_collect + SET UPDATED_TIME = NOW(), + HOUSE_TYPE = #{houseType}, + HOUSE_HOLDER_NAME = #{houseHolderName}, + TOTAL_RESI = #{totalResi} + WHERE + id = #{id} + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiMemberDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiMemberDao.xml new file mode 100644 index 0000000000..6423f7ecff --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiMemberDao.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file