Commit 5d64406c authored by tianyiming's avatar tianyiming

一码通码生成重复问题修改

parent 430b48d6
......@@ -41,6 +41,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
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;
......@@ -48,6 +49,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
......@@ -262,10 +264,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
//生成码
Map<String, String> codeMap;
synchronized (EquipmentCategoryServiceImpl.class) {
codeMap = creatCode(city, county, equipCategory, null,null);
}
EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
Map<String, String> codeMap = categoryService.creatCode(city, county, equipCategory, null, null);
if (ObjectUtils.isEmpty(codeMap)) {
return new HashMap<>();
}
......@@ -283,7 +283,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
elevatorCode = EquipmentCategoryEnum.BF.getCode().equals(equInfoDto.getEquState()) ? null : codeMap.get("code96333");
List<CategoryOtherInfo> categoryOtherInfo = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("SUPERVISORY_CODE", supervisorCode));
if (categoryOtherInfo.size() > 0) {
// categoryOtherInfoMapper.updateCode(supervisorCode, equState);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisoryCodeInfo.getSupervisoryCode()));
} else {
supervisoryCodeInfo.setStatus(equState);
......@@ -482,7 +481,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/**
* 具体生成监管码和电梯96333识别码逻辑
*/
private synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333,String supervisionCode) {
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
public synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333,String supervisionCode) {
Map<String, String> resultMap = new HashMap<>();
StringBuilder supervisorCode = new StringBuilder();
StringBuilder elevatorCode = new StringBuilder();
......@@ -551,7 +551,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* @param county 行政区划区
* @return 监管码
*/
private String createSupervisorCode(String city, String county, String equipCategory) {
public String createSupervisorCode(String city, String county, String equipCategory) {
StringBuilder supervisorCode = new StringBuilder();
//生成监管码前缀
Map<String, Object> divisionMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), county);
......@@ -585,7 +585,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* @param county 行政区划区
* @return 96333电梯识别码
*/
private String createElevatorCode(String city, String county) {
public String createElevatorCode(String city, String county) {
StringBuilder elevatorCode = new StringBuilder();
//生成生成96333电梯码前缀
Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county);
......@@ -1034,8 +1034,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String county = String.valueOf(superviseMap.get("county"));
String equCategory = String.valueOf(superviseMap.get("equCategory"));
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
// EquipmentCategoryServiceImpl categoryService = SpringUtils.getBean(EquipmentCategoryServiceImpl.class);
//生成码
codeMap = creatCode(city, county, equCategory, code96333, supervisionCode);
codeMap = categoryService.creatCode(city, county, equCategory, code96333, supervisionCode);
log.info("已生成对应监管码或96333电梯识别码");
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data");
......@@ -1075,8 +1077,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
response.setStatus(HttpStatus.BAD_REQUEST.value());
return response;
} finally {
log.info("已生成对应监管码" + supervisionMap.get("SUPERVISORY_CODE"));
log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333"));
updateEquipmentCategoryData(unitCode,orgBranchCode);
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisoryCodeInfo.getSupervisoryCode()));
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisionMap.get("SUPERVISORY_CODE")));
}
return responseModel;
}
......
package com.yeejoin.amos.boot.module.tzs.biz.utils;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@Configuration
@ComponentScan("com.yeejoin.amos.boot.module.tzs.biz.service.impl")
@EnableAspectJAutoProxy(exposeProxy = true)//开启spring注解aop配置的支持
public class SpringConfiguration {
}
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