Browse Source

Merge remote-tracking branch 'remotes/origin/dev' into 市北生产

feature/teamB_zz_wgh
jianjun 3 years ago
parent
commit
3435fa4ab6
  1. 4
      epmet-commons/epmet-commons-tools/pom.xml
  2. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
  3. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/BarcodeUtils.java
  4. 36
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  5. 37
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

4
epmet-commons/epmet-commons-tools/pom.xml

@ -169,13 +169,13 @@
<dependency> <dependency>
<groupId>com.google.zxing</groupId> <groupId>com.google.zxing</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>3.3.2</version> <version>3.4.1</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase --> <!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
<dependency> <dependency>
<groupId>com.google.zxing</groupId> <groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId> <artifactId>javase</artifactId>
<version>3.3.2</version> <version>3.4.1</version>
</dependency> </dependency>
</dependencies> </dependencies>

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java

@ -440,4 +440,8 @@ public class RedisUtils {
public Long bitCount(String key, int start, int end) { public Long bitCount(String key, int start, int end) {
return redisTemplate.execute((RedisCallback<Long>) con -> con.bitCount(key.getBytes(), start, end)); return redisTemplate.execute((RedisCallback<Long>) con -> con.bitCount(key.getBytes(), start, end));
} }
public Long getTTL(String treeCacheKey) {
return redisTemplate.getExpire(treeCacheKey);
}
} }

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/BarcodeUtils.java

@ -95,7 +95,7 @@ public class BarcodeUtils {
//x开始的位置:(图片宽度-字体大小*字的个数)/2 //x开始的位置:(图片宽度-字体大小*字的个数)/2
int startX = (WIDTH - (FONTSIZE * pressText.length())) / 2; int startX = (WIDTH - (FONTSIZE * pressText.length())) / 2;
//y开始的位置:图片高度-(图片高度-图片宽度)/2 //y开始的位置:图片高度-(图片高度-图片宽度)/2
int startY = HEIGHT - (HEIGHT - WIDTH) / 2; int startY = HEIGHT - (HEIGHT - WIDTH) / 2+ FONTSIZE;
int imageW = outImage.getWidth(); int imageW = outImage.getWidth();
int imageH = outImage.getHeight(); int imageH = outImage.getHeight();
@ -115,7 +115,7 @@ public class BarcodeUtils {
String s = outStringByByte(pressText, maxSize); String s = outStringByByte(pressText, maxSize);
g.drawString(s, (WIDTH - (FONTSIZE * (WIDTH / FONTSIZE - 2))) / 2, startY); g.drawString(s, (WIDTH - (FONTSIZE * (WIDTH / FONTSIZE - 2))) / 2, startY);
pressText = pressText.substring(s.length(), pressText.length()); pressText = pressText.substring(s.length(), pressText.length());
startY = startY + 30; startY = startY + 35;
} }
if (v != 0) { if (v != 0) {
g.drawString(pressText, (WIDTH - (FONTSIZE * v)) / 2, startY); g.drawString(pressText, (WIDTH - (FONTSIZE * v)) / 2, startY);

36
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -12,8 +12,11 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.form.DingTextBriefNessFormDTO; import com.epmet.commons.tools.dto.form.DingTextBriefNessFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
@ -60,6 +63,7 @@ import java.io.OutputStream;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -95,6 +99,10 @@ public class GovOrgServiceImpl implements GovOrgService {
private EvaluationIndexService evaluationIndexService; private EvaluationIndexService evaluationIndexService;
@Autowired @Autowired
private IcBuildingDao icBuildingDao; private IcBuildingDao icBuildingDao;
@Autowired
private RedisUtils redisUtils;
@Autowired
private ExecutorService executorService;
/** /**
* @param staffId * @param staffId
@ -583,12 +591,34 @@ public class GovOrgServiceImpl implements GovOrgService {
@Override @Override
public List<OrgTreeResultDTO> getAgencyTree(TokenDto tokenDto, SubOrgFormDTO formDTO) { public List<OrgTreeResultDTO> getAgencyTree(TokenDto tokenDto, SubOrgFormDTO formDTO) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
if (staffInfo == null || StringUtils.isBlank(staffInfo.getAgencyId())){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"工作人员所属组织不存在");
}
String agencyId = staffInfo.getAgencyId();
String client = formDTO.getClient();
//组织缓存key
String treeCacheKey = RedisKeys.getOrgTreeCacheKey(agencyId).concat(StrConstant.COLON).concat(client);
Long expiryTime = redisUtils.getTTL(treeCacheKey);
List<OrgTreeResultDTO> orgTreeResultDTOS = (List<OrgTreeResultDTO>) redisUtils.get(treeCacheKey);
//如果接近过期或已经过期且缓存数据不为空 则异步查询
if ((expiryTime == null || expiryTime <= NumConstant.ONE_THOUSAND) && CollectionUtils.isNotEmpty(orgTreeResultDTOS)) {
executorService.submit(() -> {
List<OrgTreeResultDTO> list = buildTempOrgTree(agencyId, client);
redisUtils.set(treeCacheKey, list, RedisUtils.HOUR_FOUR_EXPIRE);
});
} else if (CollectionUtils.isEmpty(orgTreeResultDTOS)){
orgTreeResultDTOS = buildTempOrgTree(staffInfo.getAgencyId(), formDTO.getClient());
redisUtils.set(treeCacheKey, orgTreeResultDTOS, RedisUtils.HOUR_FOUR_EXPIRE);
}
return orgTreeResultDTOS;
}
private List<OrgTreeResultDTO> buildTempOrgTree(String agencyId, String client){
List<OrgTreeResultDTO> list = new ArrayList<>(); List<OrgTreeResultDTO> list = new ArrayList<>();
if ("resi".equals(formDTO.getClient())) { if ("resi".equals(client)) {
list.add(customerAgencyDao.getResiOrgTree(staffInfo.getAgencyId())); list.add(customerAgencyDao.getResiOrgTree(agencyId));
return list; return list;
} }
list.add(customerAgencyDao.getOrgTree(staffInfo.getAgencyId())); list.add(customerAgencyDao.getOrgTree(agencyId));
return list; return list;
} }

37
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

@ -17,7 +17,6 @@
package com.epmet.controller; package com.epmet.controller;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.annotation.RequirePermission;
@ -43,12 +42,7 @@ import com.epmet.send.SendMqMsgUtil;
import com.epmet.service.AgencyService; import com.epmet.service.AgencyService;
import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerAgencyService;
import com.epmet.service.IcNeighborHoodService; import com.epmet.service.IcNeighborHoodService;
import com.google.zxing.BarcodeFormat; import org.apache.commons.io.FileUtils;
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.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -58,10 +52,11 @@ import javax.imageio.ImageIO;
import javax.imageio.stream.ImageOutputStream; import javax.imageio.stream.ImageOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.HashMap; import java.util.HashMap;
@ -415,7 +410,9 @@ public class AgencyController {
} }
//url组成:数字社区地址?小区id&用户id //url组成:数字社区地址?小区id&用户id
//String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id; //String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id;
String url = EnvEnum.getCurrentEnv().getUrl().replace("api/", StrConstant.EPMETY_STR) String url = EnvEnum.getCurrentEnv().getUrl()
.replace("cloud","open")
.replace("api/", StrConstant.EPMETY_STR)
.concat("epmet-oper-gov/#/caiji/") .concat("epmet-oper-gov/#/caiji/")
.concat(id).concat("?") .concat(id).concat("?")
.concat("name=").concat(URLEncoder.encode(name,StrConstant.UTF_8)).concat(StrConstant.AND_MARK) .concat("name=").concat(URLEncoder.encode(name,StrConstant.UTF_8)).concat(StrConstant.AND_MARK)
@ -450,4 +447,22 @@ public class AgencyController {
} }
} }
public static void main(String[] args) {
try {
BufferedImage image = BarcodeUtils.drawQRImage("小崽子社区中国国歌过过过过过所多对方水电费是的发生的", "https://epmet-cloud.elinkservice.cn/epmet-oper-gov/#/caiji/b058eb82d65d922fec9dc84f0348fc6a?name=%E5%B0%8F%E5%AF%A8%E5%AD%90%E7%A4%BE%E5%8C%BA&customerId=3fdd0380deff5b30f45376cdf995d1c1&type=community&userId=72d331139a5012b6bba18b40029a2755&123123123111");
//BufferedImage image = BarcodeUtils.drawQRImage("小崽子社区", "erId=72d331139a5012b6bba18b40029a2755&123123123111");
//BufferedImage image2 = BarcodeUtils.getQRCode("小崽子社区", "https://epmet-cloud.elinkservice.cn/epmet-oper-gov/#/caiji/b058eb82d65d922fec9dc84f0348fc6a?name=%E5%B0%8F%E5%AF%A8%E5%AD%90%E7%A4%BE%E5%8C%BA&customerId=3fdd0380deff5b30f45376cdf995d1c1&type=community&userId=72d331139a5012b6bba18b40029a2755&123123123111");
//BufferedImage 转 InputStream
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream);
ImageIO.write(image, "png", imageOutput);
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
String s = "/Users/liujianjun/Downloads/t.png";
File file= new File(s);
FileUtils.copyInputStreamToFile(inputStream, file);
} catch (Exception e) {
e.printStackTrace();
}
}
} }

Loading…
Cancel
Save