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/feign/CommonAggFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonAggFeignClient.java index cb7146138d..abcc6fc90b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonAggFeignClient.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonAggFeignClient.java @@ -5,7 +5,6 @@ import com.epmet.commons.tools.feign.fallback.CommonAggFeignClientFallBackFactor import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache; import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache; -import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.Result; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PathVariable; @@ -39,15 +38,6 @@ public interface CommonAggFeignClient { @PostMapping("/data/aggregator/org/agency") Result getAgencyInfo(@RequestParam("agencyId")String agencyId); - /** - * @Description 查询网格信息 - * @param gridId - * @author zxc - * @date 2021/11/5 2:54 下午 - */ - @PostMapping("/data/aggregator/org/grid") - Result getGridInfo(@RequestParam("gridId")String gridId); - /** * 查询楼栋信息 * @param buildingId diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java index 8d6f5f1260..4aff62f235 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java @@ -5,7 +5,6 @@ import com.epmet.commons.tools.feign.CommonAggFeignClient; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache; import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache; -import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import org.springframework.stereotype.Component; @@ -29,11 +28,6 @@ public class CommonAggFeignClientFallback implements CommonAggFeignClient { return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "getAgencyInfo", agencyId); } - @Override - public Result getGridInfo(String gridId) { - return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "getGridInfo", gridId); - } - /** * 查询楼栋信息 * 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..555643e9e1 --- /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("微软雅黑", 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 598f8d7518..a5a7127cdd 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -499,7 +499,10 @@ epmet: - /oper/customize/customerstartpage/homestartpage - /epmet/point/mqCallback/** - /tduck-api/** - + #查询楼栋,单元,房屋 + - /gov/org/icbuilding/buildingoption + - /gov/org/icbuildingunit/unitoption + - /gov/org/ichouse/houseoption # 外部应用认证,使用AccessToken等头进行认证 externalOpenUrls: - /data/report/** @@ -531,7 +534,6 @@ epmet: # 对外开放接口认证白名单 externalAuthUrlsWhiteList: - /epmet/ext/open-api/get-access-token - swaggerUrls: jwt: diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java index 268330f03b..308a9113c9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java @@ -128,7 +128,7 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl w = new LambdaQueryWrapper<>(); w.eq(ScreenCustomerGridEntity::getGridId, grid.getId()); ScreenCustomerGridEntity e = new ScreenCustomerGridEntity(); - e.setDataEndTime(NumConstant.ONE_STR); + e.setDelFlag(NumConstant.ONE_STR); e.setUpdatedTime(new Date()); screenCustomerGridDao.update(e,w); // 此delete不更新 updatedTime 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..a482511982 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,6 +17,7 @@ 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; @@ -34,11 +35,20 @@ import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.send.SendMqMsgUtil; import com.epmet.service.AgencyService; import com.epmet.service.CustomerAgencyService; +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 java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -360,4 +370,48 @@ public class AgencyController { return new Result>().ok(agencyService.getSonAgencyId(orgId,type)); } -} \ No newline at end of file + @PostMapping("qr") + public void qr(){ + try { + write(); + } catch (IOException e) { + e.printStackTrace(); + } catch (WriterException e) { + e.printStackTrace(); + } + } + + public static void write() throws IOException, WriterException { + String filePath = "/Users/liujianjun/Downloads"; + String fileName = "qr.png"; +//二维码内容场景一:json数据 + JSONObject json = new JSONObject(); + json.put("baidu","http://www.baidu.com");//二维码一般就是存储链接 +// json.put("author", "lzz");//还可存储值(员工工号,员工姓名,年会二维码门票) + String content = json.toJSONString();//json 内容 +//二维码内容场景二:直接某个超链接 +// content="http://www.baidu.com";//直接某个超链接 + int width = 200; // 图像宽度 + int height = 200; // 图像高度 + String format = "png";// 图像类型 + Map hints = new HashMap(); + + hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); + BitMatrix bitMatrix = new MultiFormatWriter().encode(content, + BarcodeFormat.QR_CODE, width, height, hints);// 生成矩阵 + Path path = FileSystems.getDefault().getPath(filePath, fileName); + MatrixToImageWriter.writeToPath(bitMatrix, format, path);// 输出图像 + System.out.println("输出成功."); + } + + public static void main(String[] args) { + try { + write(); + } catch (IOException e) { + e.printStackTrace(); + } catch (WriterException 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 fe5722451e..5851ac9c31 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,18 +19,20 @@ 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.ImportInfoFormDTO; @@ -44,8 +46,12 @@ import org.springframework.transaction.annotation.Transactional; 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; @@ -166,4 +172,50 @@ 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(); + //String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id; + String url = EnvEnum.getCurrentEnv().getUrl().replace("api/",StrConstant.EPMETY_STR) + .concat("epmet-oper-gov/#/") + .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/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index b29dfbcdac..8190c9418d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -157,11 +157,20 @@ public interface EpmetUserFeignClient { Result getCustomerStaffList(List staffIdList); /** - * desc:删除审核中的徽章认证记录 + * desc:删除审核中的徽章认证记录-弃用网格是调用 * @param customerId * @param gridId * @return */ @PostMapping("/epmetuser/badge/deleteBadgeCertificateAuditing") Result deleteBadgeCertificateAuditing(@RequestParam("customerId") String customerId, @RequestParam("gridId") String gridId); + + /** + * desc:删除弃用网格的访问记录-弃用网格是调用 + * @param customerId + * @param gridId + * @return + */ + @PostMapping("/epmetuser/gridlatest/deleteGridLatestData") + Result deleteGridLatestData(@RequestParam("customerId") String customerId, @RequestParam("gridId") String gridId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 70bc8b7892..4594d36a60 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -96,4 +96,9 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { public Result deleteBadgeCertificateAuditing(String customerId, String gridId) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "deleteBadgeCertificateAuditing", customerId, gridId); } + + @Override + public Result deleteGridLatestData(String customerId, String gridId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "deleteGridLatestData", customerId, gridId); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index c337f989e3..70945c6fe1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -1046,7 +1046,11 @@ public class CustomerGridServiceImpl extends BaseServiceImpl gridLatestResult = epmetUserFeignClient.deleteGridLatestData(customerId,gridId); + if (gridLatestResult == null || !gridLatestResult.success()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"删除网格访问记录失败,请稍后重试"); + } //处理成功,隐藏网格 LambdaUpdateWrapper updateGrid=new LambdaUpdateWrapper<>(); updateGrid.set(CustomerGridEntity::getAbandonFlag,NumConstant.ONE); diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 426b4fbb0a..c3390d9cc9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -342,7 +342,6 @@ WHERE cg.del_flag = '0' AND ca.del_flag = '0' AND cg.SYNC_FLAG='1' - and cg.ABANDON_FLAG='0' AND cg.id IN #{id} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java index 37c56eeac9..eace8b90b0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java @@ -1,7 +1,9 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -218,11 +220,12 @@ public class BadgeController { } /** - * Desc: 查询网格下是否存在未审核的徽章,true:是,false:否 + * desc:删除审核中的徽章认证记录-弃用网格是调用 + * @param customerId * @param gridId - * @author zxc - * @date 2022/3/16 9:42 上午 + * @return */ + @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_DELETE) @PostMapping("deleteBadgeCertificateAuditing") public Result deleteBadgeCertificateAuditing(@RequestParam("customerId") String customerId,@RequestParam("gridId")String gridId){ return new Result().ok(badgeService.deleteBadgeCertificateAuditing(customerId,gridId)); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java index c470d793a9..b1b07c4e9e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java @@ -143,4 +143,15 @@ public class GridLatestController { return new Result().ok(gridLatestService.latestGridInfo(formDTO)); } + /** + * desc:删除弃用网格的访问记录-弃用网格是调用 + * @param customerId + * @param gridId + * @return + */ + @PostMapping("deleteGridLatestData") + public Result deleteGridLatestData(@RequestParam("customerId") String customerId,@RequestParam("gridId")String gridId){ + return new Result().ok(gridLatestService.deleteGridLatestData(customerId,gridId)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserRegGridChangeRecDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserRegGridChangeRecDao.java new file mode 100644 index 0000000000..c14ace1ab7 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserRegGridChangeRecDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.UserRegGridChangeRecEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户注册网格变更记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-17 + */ +@Mapper +public interface UserRegGridChangeRecDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserRegGridChangeRecEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserRegGridChangeRecEntity.java new file mode 100644 index 0000000000..262c79e608 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserRegGridChangeRecEntity.java @@ -0,0 +1,41 @@ +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-17 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("user_reg_grid_change_rec") +public class UserRegGridChangeRecEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 居民端用户id + */ + private String userId; + + /** + * 原始网格id + */ + private String originGridId; + + /** + * 当前所选择的注册网格 + */ + private String gridId; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java index b390d10a39..427e70f0a3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java @@ -122,18 +122,12 @@ public class IcResiImportDynamicExcelListener extends AnalysisEventListener> headers = icResiUserImportService.mergeMultiLevelHeadLabels(headList); - icResiUserImportService.printLog("invokeHeadMap_1_" + isPrimary); - // 清洗表头数据,通过items剔除,并且得到options abandonedHeaders = icResiUserImportService.removeAndGetOptionsFromHeaders(headers, formItemList); - icResiUserImportService.printLog("invokeHeadMap_2_" + isPrimary); - // 交换表头信息,以label连起来的string作为key,列号的列表作为value HashMap> combinedHeaders = icResiUserImportService.exchangeKeyAndValueOfHeaders(headers); - icResiUserImportService.printLog("invokeHeadMap_3_" + isPrimary); - // 得到客户配置item数据。<"兴趣爱好:兴趣特长", item对象> Map customizedLabelCompbinedItemsMap = formItemList.stream().collect( Collectors.toMap(formItem -> { @@ -147,11 +141,7 @@ public class IcResiImportDynamicExcelListener extends AnalysisEventListener formItem) ); - icResiUserImportService.printLog("invokeHeadMap_4_" + isPrimary); - itemIdAndColumnWrapper = icResiUserImportService.convertExcelHeaders2DBColumnWrappers(customizedLabelCompbinedItemsMap, combinedHeaders); - - icResiUserImportService.printLog("invokeHeadMap_5_" + isPrimary); } /** @@ -182,7 +172,6 @@ public class IcResiImportDynamicExcelListener extends AnalysisEventListener { * @Date 2020/8/3 **/ LatestGridInfoResultDTO latestGridInfo(LatestGridInfoFormDTO formDTO); + + /** + * desc:删除弃用网格的访问记录-弃用网格是调用 + * @param customerId + * @param gridId + * @return + */ + Integer deleteGridLatestData(String customerId, String gridId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java index 58f9383078..fabf993292 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java @@ -19,6 +19,7 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; @@ -36,7 +37,6 @@ import com.epmet.dto.result.CustomerUser4PointResultDTO; import com.epmet.dto.result.LatestGridInfoResultDTO; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.entity.GridLatestEntity; -import com.epmet.feign.EpmetHeartOpenFeignClient; import com.epmet.redis.UserBaseInfoRedis; import com.epmet.service.GridLatestService; import com.epmet.util.ModuleConstant; @@ -210,4 +210,13 @@ public class GridLatestServiceImpl extends BaseServiceImpl wrapper = new LambdaUpdateWrapper(); + wrapper.eq(GridLatestEntity::getCustomerId,customerId) + .eq(GridLatestEntity::getGridId,gridId) + .set(GridLatestEntity::getUpdatedTime,System.currentTimeMillis()); + return baseDao.delete(wrapper); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 182259a39f..883c72cf59 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -363,8 +363,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); - log.info("importIcResiBaseInfoFromExcel:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); - IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener(this, customerId, currentUserId, currUserAgencyId, currUserAgencyPids, true, tableName, formItemList, headRowNumber); EasyExcel.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); @@ -417,8 +415,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, String currUserAgencyPids, String currentUserId, String tableName) { - //this.printLog("persistIcResiBaseInfo"); - // 遍历每一行,将行内容转化为 for (Map row : dataRows) { @@ -549,8 +545,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); - log.info("persistIcResiExtraInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); - // 遍历每一行,将行内容转化为 for (Map row : dataRows) { @@ -1000,9 +994,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } List options = null; - - log.info("optionsUrl:{}, currUserAgencyId:{}", pureUri, currUserAgencyId); - //this.printLog("listRemoteOptions"); switch (pureUri) { case "/epmetuser/icresidemanddict/demandoption": options = getResultDataOrThrowsException(epmetUserOpenFeignClient.getDemandOptions(), ServiceConstant.EPMET_USER_SERVER, @@ -1043,9 +1034,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } nform.setGridId(gridId); - //this.printLog("listRemoteOptions#neighborhoodoption"); - log.info("neighborhoodoption:{},{}", currUserAgencyId, gridId); - options = getResultDataOrThrowsException(govOrgOpenFeignClient.getNeighborHoodOptions(nform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/sys/dict/data/education": @@ -1834,15 +1822,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } } - public void printLog(String positionPrefix) { - String app = EpmetRequestHolder.getHeader(AppClientConstant.APP); - String client = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); - String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); - String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); - - log.info("{}:: userId:{}, app:{}, client:{}, customerId:{}", positionPrefix, loginUserId, app, client, loginUserCustomerId); - } - @Override public Object testAsync() { IcNeighborHoodDTO nform = new IcNeighborHoodDTO(); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java index a6f88e5c0f..12380e64c2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java @@ -75,6 +75,9 @@ public class UserServiceImpl extends BaseServiceImpl implem private UserBadgeCertificateRecordDao userBadgeCertificateRecordDao; @Autowired private UserBaseInfoRedis userBaseInfoRedis; + @Autowired + private UserRegGridChangeRecDao UserRegGridChangeRecDao; + private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class); @@ -438,8 +441,9 @@ public class UserServiceImpl extends BaseServiceImpl implem @Override public void modifyRegGrid(ModifyRegGridFormDTO formDTO) { GridInfoCache newGridInfo= CustomerOrgRedis.getGridInfo(formDTO.getGridId()); - if (null == newGridInfo) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询当前网格信息异常", "服务器开小差了..."); + RegisterRelationEntity originReg=registerRelationDao.selectRegisteredGridIdByUserIdAndCustomerId(formDTO.getUserId(),formDTO.getCustomerId()); + if (null == newGridInfo || null == originReg) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询网格信息异常", "服务器开小差了..."); } //修改register_relation表 LambdaQueryWrapper originWrapper=new LambdaQueryWrapper(); @@ -467,18 +471,36 @@ public class UserServiceImpl extends BaseServiceImpl implem //2、修改历史徽章表 LambdaUpdateWrapper recUpdate=new LambdaUpdateWrapper<>(); - recUpdate.set(UserBadgeCertificateRecordEntity::getGridId,newGridInfo.getId()); + recUpdate.set(UserBadgeCertificateRecordEntity::getGridId,newGridInfo.getId()) + .set(UserBadgeCertificateRecordEntity::getUpdatedBy,formDTO.getUserId()) + .set(UserBadgeCertificateRecordEntity::getUpdatedTime,new Date()); recUpdate.eq(UserBadgeCertificateRecordEntity::getCustomerId,formDTO.getCustomerId()) .eq(UserBadgeCertificateRecordEntity::getUserId,formDTO.getUserId()); userBadgeCertificateRecordDao.update(null,recUpdate); LambdaUpdateWrapper badgeUpdate=new LambdaUpdateWrapper<>(); - badgeUpdate.set(ResiUserBadgeEntity::getGridId,newGridInfo.getId()); + badgeUpdate.set(ResiUserBadgeEntity::getGridId,newGridInfo.getId()) + .set(ResiUserBadgeEntity::getUpdatedBy,formDTO.getUserId()) + .set(ResiUserBadgeEntity::getUpdatedTime,new Date());; badgeUpdate.eq(ResiUserBadgeEntity::getCustomerId,formDTO.getCustomerId()) .eq(ResiUserBadgeEntity::getUserId,formDTO.getUserId()); resiUserBadgeDao.update(null,badgeUpdate); //3、修改支援者信息表 + modifyVolunteerGrid(formDTO,newGridInfo); + + //4、删除用户缓存信息 + userBaseInfoRedis.clearUserCache(Arrays.asList(formDTO.getUserId())); + //5、插入用户注册网格变更记录 + UserRegGridChangeRecEntity log=new UserRegGridChangeRecEntity(); + log.setCustomerId(formDTO.getCustomerId()); + log.setUserId(formDTO.getUserId()); + log.setOriginGridId(originReg.getGridId()); + log.setGridId(formDTO.getGridId()); + UserRegGridChangeRecDao.insert(log); + } + + private void modifyVolunteerGrid(ModifyRegGridFormDTO formDTO, GridInfoCache newGridInfo) { VolunteerInfoDTO volunteerInfoDTO=new VolunteerInfoDTO(); volunteerInfoDTO.setCustomerId(formDTO.getCustomerId()); volunteerInfoDTO.setUserId(formDTO.getUserId()); @@ -490,8 +512,6 @@ public class UserServiceImpl extends BaseServiceImpl implem if (!volunteerRes.success()) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:修改用户志愿者信息异常", "服务器开小差了..."); } - //4、删除用户缓存信息 - userBaseInfoRedis.clearUserCache(Arrays.asList(formDTO.getUserId())); } } diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.25__create_user_reg_grid_rec.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.25__create_user_reg_grid_rec.sql new file mode 100644 index 0000000000..85a0db8e18 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.25__create_user_reg_grid_rec.sql @@ -0,0 +1,14 @@ +CREATE TABLE `user_reg_grid_change_rec` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `USER_ID` varchar(64) NOT NULL COMMENT '居民端用户id', + `ORIGIN_GRID_ID` varchar(64) NOT NULL COMMENT '原始网格id', + `GRID_ID` varchar(64) NOT NULL COMMENT '当前所选择的注册网格', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 1删除;0未删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户注册网格变更记录表'; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml index 74c1691615..3ce51f018a 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml @@ -79,7 +79,7 @@ diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserRegGridChangeRecDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserRegGridChangeRecDao.xml new file mode 100644 index 0000000000..4fcd5c664e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserRegGridChangeRecDao.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file