Commit a0c171ba authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs' of http://39.98.45.134:8090/moa/amos-boot-biz into develop_tzs

# Conflicts: # amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/service/impl/EquipmentCategoryServiceImpl.java
parents bcc0ebf2 e5e39d15
......@@ -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,40 @@ 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() {
//集群环境使用
// log.info("clusterNodes{}",clusterNodes);
// log.info("password{}",password);
//
// Config config = new Config();
// config.useClusterServers()
// .addNodeAddress(clusterNodes.split(","))
// .setPassword(password);
// return Redisson.create(config);
//单机打包使用
log.info("clusterNodes{}",clusterNodes);
log.info("password{}",password);
Config config = new Config();
config.useClusterServers()
.addNodeAddress(clusterNodes.split(","))
.setPassword(password);
return Redisson.create(config);
}
@Bean
@ConditionalOnProperty(name = "spring.redis.mode", havingValue = "singleton")
public RedissonClient redissonSingletonClient() {
// 单机打包使用
Config config = new Config();
config.useSingleServer().setAddress(host + ":" + port).setPassword(password);
return Redisson.create(config);
......
package com.yeejoin.amos.boot.module.ymt.biz.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -12,7 +11,6 @@ import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
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.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.enums.ImageSizeEnums;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
......@@ -20,14 +18,21 @@ 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.service.impl.EquipmentCategoryServiceImpl;
import com.yeejoin.amos.boot.module.ymt.biz.utils.ImageUtils;
import com.yeejoin.amos.component.robot.BadRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -35,8 +40,16 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.stream.Collectors;
/**
......@@ -264,7 +277,13 @@ public class EquipmentCategoryController extends BaseController {
return ResponseHelper.buildResponse(equipmentCategoryService.submit(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/test/lock")
@ApiOperation(httpMethod = "GET", value = "一码通八大类设备数据操作接口", notes = "一码通八大类设备数据操作接口")
public ResponseModel<Object> lockTest() {
equipmentCategoryServiceImpl.lockTest();
return ResponseHelper.buildResponse("OK~");
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
......
......@@ -11,7 +11,10 @@ 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.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.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;
......@@ -19,7 +22,6 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
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.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.biz.permission.PermissionOfUser;
import com.yeejoin.amos.boot.module.ymt.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.flc.api.feign.IdxFeignService;
......@@ -42,7 +44,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;
......@@ -64,7 +65,6 @@ import java.text.SimpleDateFormat;
import java.util.*;
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;
......@@ -161,7 +161,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private static final String COPY_KEY = "stashType";
@Autowired
RestHighLevelClient restHighLevelClient;
RestHighLevelClient restHighLevelClient;
private static String USE_CODE = "use_code";
......@@ -428,11 +428,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String useOrgCode = (String) obj.get("USE_ORG_CODE");
String record = (String) obj.get("id");
Map<String, Long> map = categoryOtherInfoMapper.checkCode(type, code96333, equCode, useOrgCode, record);
if(map.containsKey("equCode") && map.get("equCode") > 0){
if (map.containsKey("equCode") && map.get("equCode") > 0) {
result = "设备代码重复,请确认数据是否输入正确,或联系管辖机构处理。";
} else if (map.containsKey("useOrgCode") && map.get("useOrgCode") > 0){
} else if (map.containsKey("useOrgCode") && map.get("useOrgCode") > 0) {
result = "使用登记证编号重复,请确认数据是否输入正确,或联系管辖机构处理。";
} else if (map.containsKey("code") && map.get("code") > 0){
} else if (map.containsKey("code") && map.get("code") > 0) {
result = "96333码重复,请确认数据是否输入正确,或联系管辖机构处理。";
}
return result;
......@@ -900,12 +900,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
list.add(equipmentCategoryData);
}
}
if (!ObjectUtils.isEmpty(unitCodes) && !ObjectUtils.isEmpty(orgBranchCodes) ) {
if (!ObjectUtils.isEmpty(unitCodes) && !ObjectUtils.isEmpty(orgBranchCodes)) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>()
.in("unit_code", unitCodes)
.in("org_branch_code",orgBranchCodes));
.in("org_branch_code", orgBranchCodes));
}
if (!ObjectUtils.isEmpty(unitCodes) && ObjectUtils.isEmpty(orgBranchCodes) ) {
if (!ObjectUtils.isEmpty(unitCodes) && ObjectUtils.isEmpty(orgBranchCodes)) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>()
.in("unit_code", unitCodes));
}
......@@ -1050,24 +1050,24 @@ 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电梯识别码");
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("释放锁");
}
// boolean flag = false;
// if (lock.tryLock(3, 5, TimeUnit.SECONDS)) {
// codeMap = categoryService.creatCode(city, county, equCategory, code96333, supervisionCode);
// log.info("已生成对应监管码或96333电梯识别码");
// flag = true;
// }
// if(flag){
// lock.unlock(); // 释放锁
// log.info("释放锁");
// }
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data");
supervisionMap.put("CODE96333", codeMap.get("code96333"));
......@@ -1080,7 +1080,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
//根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit( null, map) :
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, map) :
idxFeignService.batchUpdate(null, map);
stopWatch1.stop();
if (log.isInfoEnabled()) {
......@@ -1106,7 +1106,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
StopWatch stopWatch4 = new StopWatch();
stopWatch4.start();
if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) {
log.info("responseModel.getResult().toString()->>>>>>>>>>>>>> {}",responseModel.getResult());
log.info("responseModel.getResult().toString()->>>>>>>>>>>>>> {}", responseModel.getResult());
checkEsData(String.valueOf(responseModel.getResult()));
}
stopWatch4.stop();
......@@ -1417,4 +1417,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
return totle;
}
public void lockTest() {
RLock rLock = redissonClient.getLock(LOCK_KEY);
rLock.lock();
System.out.println("redissonClient ====> ");
rLock.unlock();
}
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.mode=singleton
## emqx properties:
emqx.clean-session=false
......
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