Commit 7975ed43 authored by tianbo's avatar tianbo

96333 redissionManager提交;

小程序机器人添加
parent 488a875d
......@@ -160,4 +160,7 @@ tzs.auth.user.photo=/public/common/userPic.png
tzs.WxApp.appId=wx48a1b1915b10d14b
tzs.WxApp.secret=ac4f4a9d3c97676badb70c19a2f37b16
tzs.WxApp.grant-type=authorization_code
\ No newline at end of file
tzs.WxApp.grant-type=authorization_code
amos.wechat.robot.user=we_robot
amos.wechat.robot.password=a1234567
\ No newline at end of file
......@@ -5,6 +5,7 @@ import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -13,39 +14,37 @@ import org.springframework.context.annotation.Configuration;
@Slf4j
public class RedissonManager {
//集群环境使用
// @Value("${spring.redis.cluster.nodes}")
// private String clusterNodes;
@Value("${spring.redis.cluster.nodes:default}")
private String clusterNodes;
//通用
@Value("${spring.redis.password}")
private String password;
//单机环境使用
@Value("${spring.redis.host}")
@Value("${spring.redis.host:default}")
private String host;
//单机环境使用
@Value("${spring.redis.port}")
@Value("${spring.redis.port:default}")
private String port;
@Bean
@ConditionalOnProperty(name = "spring.redis.mode", havingValue = "cluster")
public RedissonClient redissonClient() {
Config config = new Config();
config.useClusterServers()
.addNodeAddress(clusterNodes.split(","))
.setPassword(password);
return Redisson.create(config);
}
@Bean
public RedissonClient redissonClient() {
//集群环境使用
// log.info("clusterNodes{}",clusterNodes);
// log.info("password{}",password);
//
// Config config = new Config();
// config.useClusterServers()
// .addNodeAddress(clusterNodes.split(","))
// .setPassword(password);
// return Redisson.create(config);
//单机打包使用
@ConditionalOnProperty(name = "spring.redis.mode", havingValue = "singleton", matchIfMissing = true)
public RedissonClient redissonSingletonClient() {
// 单机打包使用
Config config = new Config();
config.useSingleServer().setAddress(host + ":" + port).setPassword(password);
return Redisson.create(config);
......
......@@ -10,17 +10,28 @@ import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.ymt.api.dto.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.UseUnitCreditCodeCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategoryData;
import com.yeejoin.amos.boot.module.ymt.api.entity.EsElevator;
import com.yeejoin.amos.boot.module.ymt.api.entity.SupervisoryCodeInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentCategoryEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryDataMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SupervisoryCodeInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.ymt.biz.dao.ESElavtorRepository;
import com.yeejoin.amos.boot.module.ymt.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.flc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.ymt.flc.api.feign.PrivilegeFeginService;
......@@ -43,7 +54,6 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
......@@ -62,10 +72,19 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
......@@ -1056,24 +1075,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//生成码
//集群模式使用
RLock lock = redissonClient.getLock(LOCK_KEY);
// lock.lock(); // 获取锁
// log.info("加锁成功");
// codeMap = categoryService.creatCode(city, county, equCategory, code96333, supervisionCode);
// log.info("生成码成功");
// lock.unlock(); // 释放锁
// log.info("释放锁");
// log.info("已生成对应监管码或96333电梯识别码");
//单机模式使用
boolean flag = false;
if (lock.tryLock(3, 100, TimeUnit.SECONDS)) {
codeMap = categoryService.creatCode(city, county, equCategory, code96333, supervisionCode);
log.info("已生成对应监管码或96333电梯识别码");
flag = true;
}
if(flag){
lock.unlock(); // 释放锁
log.info("释放锁");
}
lock.lock(); // 获取锁
log.info("加锁成功");
codeMap = categoryService.creatCode(city, county, equCategory, code96333, supervisionCode);
log.info("生成码成功");
lock.unlock(); // 释放锁
log.info("释放锁");
log.info("已生成对应监管码或96333电梯识别码");
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data");
supervisionMap.put("CODE96333", codeMap.get("code96333"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment