Commit 03b7857a authored by 韩桐桐's avatar 韩桐桐

fix(ymt):删除冗余方法

parent fe6a4e27
......@@ -58,5 +58,4 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> {
*/
List<KV> selectSupervisorCodeMaxValue();
List<String> selectData();
}
......@@ -188,79 +188,4 @@
LIMIT 1
</select>
<select id="selectData" resultType="java.lang.String">
SELECT
distinct equ_id
FROM
(
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_change_registration_name_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_change_registration_reform_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_change_registration_transfer_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_change_registration_unit_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_enable_disable_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_equip_transfer_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_installation_notice_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_maintain_notice_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_maintenance_contract_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_reform_notice_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_scrap_cancel_eq" UNION ALL
SELECT
equ_id,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_transfer_notice_eq" UNION ALL
SELECT
equ_id ,
rec_date
FROM
"amos_tzs_biz"."tzs_jg_use_registration_eq" UNION ALL
( SELECT "RECORD" AS equ_id, rec_date FROM "amos_tzs_biz"."idx_biz_jg_other_info" WHERE ( "CLAIM_STATUS" IS NULL OR "CLAIM_STATUS" = '' ) AND "RECORD" LIKE'________-____-____-____-____________' )
)
WHERE
"REC_DATE" >= '2024-02-26 00:00:00'
</select>
</mapper>
......@@ -422,14 +422,6 @@ public class EquipmentCategoryController extends BaseController {
return ResponseHelper.buildResponse("success");
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "updateEquipmentCategoryToEs")
@ApiOperation(httpMethod = "GET", value = "jg数据更新至es", notes = "jg数据更新至es")
public ResponseModel<String> updateEquipmentCategoryToEs() {
equipmentCategoryServiceImpl.updateEs();
return ResponseHelper.buildResponse("success");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
......@@ -26,9 +25,6 @@ import com.yeejoin.amos.boot.module.ymt.api.service.IGenerateCodeService;
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.dao.EsEntity;
import com.yeejoin.amos.boot.module.ymt.biz.dao.JgAll;
import com.yeejoin.amos.boot.module.ymt.biz.utils.ElasticSearchUtil;
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;
......@@ -94,242 +90,221 @@ import static com.alibaba.fastjson.JSON.toJSONString;
@Slf4j
public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryDto, EquipmentCategory, EquipmentCategoryMapper> implements IEquipmentCategoryService {
// 一码通码自动生成
final static String CREATE = "1";
// 一码通码手动输入
final static String NOT_CREATE = "0";
@Autowired
ESEquipmentCategory esEquipmentCategory;
private static final String TABLENAME = "tableName";
// 管辖机构redis缓存key
private static final String REGULATOR_UNIT_TREE = "REGULATOR_UNIT_TREE";
// 行政区划redis缓存key
private static final String PROVINCE = "PROVINCE";
private static final String CITY = "CITY";
private static final String REGION = "REGION";
private static final String STREET = "STREET";
// 行政区划level
private static final String PROVINCE_LEVEL = "1";
private static final String CITY_LEVEL = "2";
private static final String REGION_LEVEL = "3";
private static final String STREET_LEVEL = "4";
// 西安行政区划code
private static final String XIAN = "610100";
// 咸阳行政区划code
private static final String XIAN_YANG = "610400";
// 判断行政区划查询市还是区
private static final String END_CODE = "0000";
// 判断行政区划查询街道
private static final String STREET_END_CODE = "00";
// 一码通使用信息表单id
private static final String use_info_form_id = "1627903393253056514";
// 一码通监督管理表单id
private static final String supervision_form_id = "1627903532906602497";
// 一码通设计制造表单页id
private static final String design_from_id = "1627897116087050241";
// 一码通检验检测表单页id
private static final String inspection_form_id = "1636282043618848769";
// 一码通施工信息表单页id
private static final String construction_form_id = "1636347672031948801";
// 一码通维保信息表单页id
private static final String maintenance_form_id = "1636347684057018369";
// 一码通注册登记表单页-电梯id
private static final String dt_register_from_id = "1637431088563384322";
// 一码通注册登记表单页-起重机械id
private static final String qzjx_register_from_id = "1635115308320583681";
// 一码通注册登记表单页-锅炉id
private static final String gl_register_from_id = "1631125178945662977";
// 一码通注册登记表单页-游乐设施id
private static final String ylss_register_from_id = "1631125167914643457";
// 一码通注册登记表单页-客运索道id
private static final String kysd_register_from_id = "1631125158229995521";
// 一码通注册登记表单页-压力管道id
private static final String ylgd_register_from_id = "1631125206695178241";
// 一码通注册登记表单页-压力容器id
private static final String ylrq_register_from_id = "1631125198260432897";
// 一码通注册登记表单页-厂车id
private static final String cc_register_from_id = "1631125079347720193";
// 主要零部件
private static final String main_parts = "mainParts";
// 主要零部件
private static final String protection_devices = "ProtectionDevices";
// 一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
// 一码通判断是否复制
private static final String IS_COPY = "isCopy";
// 一码通生成码分布式锁key
private final static String LOCK_KEY = "RESOURCE_KEY";
// 一码通checkCode分布式锁key
private final static String CHECK_CODE_LOCK_KEY = "CHECK_CODE_KEY";
// 一码通checkCode中96333码redis key
private final static String CHECK_CODE_CODE96333 = "CODE96333_";
// 一码通checkCode中设备代码redis key
private final static String CHECK_CODE_EQU_CODE = "EQU_CODE_";
// 一码通checkCode中使用登记证编号redis key
private final static String CHECK_CODE_USE_ORG_CODE = "USE_ORG_CODE_";
// 管辖机构
private static final String REGULATOR_UNIT = "监管机构";
/**
* levlel=company,是企业,如果不是都是监管单位,
* * 在接口中查询当前登录人所属单位是监管单位还是企业。
* * 如果为监管单位添加监管机构查询参数(ORG_BRANCH_CODE);
* * 如果为企业添加使用单位查询参数(USE_UNIT_CREDIT_CODE)
*/
private static final String LEVEL = "company";
private static final String EQUSTATE = "EQU_STATE";
private static final String USEPLACE = "USE_PLACE";
@Autowired
private SuperviseInfoMapper superviseInfoMapper;
ESEquipmentCategory esEquipmentCategory;
@Autowired
EquipmentCategoryMapper equipmentCategoryMapper;
@Value("classpath:/json/equipCategory.json")
private Resource equipCategory;
@Autowired
private JdbcTemplate bizJdbcTemplate;
@Autowired
CategoryOtherInfoMapper categoryOtherInfoMapper;
@Autowired
SupervisoryCodeInfoMapper supervisoryCodeInfoMapper;
@Autowired
SuperviseInfoService superviseInfoService;
@Autowired
EquipmentCategoryDataMapper equipmentCategoryDataMapper;
@Autowired
EquipmentCategoryDataServiceImpl equipmentCategoryDataService;
@Autowired
IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
IdxBizJgSupervisionInfoServiceImpl idxBizJgSupervisionInfoService;
@Autowired
IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService;
@Autowired
IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
@Autowired
IdxBizJgDesignInfoServiceImpl idxBizJgDesignInfoService;
@Autowired
IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
IdxBizJgFactoryInfoMapper idxBizJgFactoryInfoMapper;
@Autowired
IdxBizJgInspectionDetectionInfoServiceImpl idxBizJgInspectionDetectionInfoService;
@Autowired
IdxBizJgConstructionInfoServiceImpl idxBizJgConstructionInfoService;
@Autowired
IdxBizJgMaintenanceRecordInfoServiceImpl idxBizJgMaintenanceRecordInfoService;
@Autowired
IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
IdxBizJgTechParamsElevatorServiceImpl idxBizJgTechParamsElevatorService;
@Autowired
IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper;
@Autowired
IdxBizJgTechParamsVehicleServiceImpl idxBizJgTechParamsVehicleService;
@Autowired
IdxBizJgTechParamsVehicleMapper idxBizJgTechParamsVehicleMapper;
@Autowired
IdxBizJgTechParamsRopewayServiceImpl idxBizJgTechParamsRopewayService;
@Autowired
IdxBizJgTechParamsRopewayMapper idxBizJgTechParamsRopewayMapper;
@Autowired
IdxBizJgTechParamsRidesServiceImpl idxBizJgTechParamsRidesService;
@Autowired
IdxBizJgTechParamsRidesMapper idxBizJgTechParamsRidesMapper;
@Autowired
IdxBizJgTechParamsBoilerServiceImpl idxBizJgTechParamsBoilerService;
@Autowired
IdxBizJgTechParamsBoilerMapper idxBizJgTechParamsBoilerMapper;
@Autowired
IdxBizJgTechParamsVesselServiceImpl idxBizJgTechParamsVesselService;
@Autowired
IdxBizJgTechParamsVesselMapper idxBizJgTechParamsVesselMapper;
@Autowired
IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineService;
@Autowired
IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper;
@Autowired
IdxBizJgTechParamsLiftingServiceImpl idxBizJgTechParamsLiftingService;
@Autowired
IdxBizJgTechParamsLiftingMapper idxBizJgTechParamsLiftingMapper;
@Autowired
IdxBizJgMainPartsServiceImpl idxBizJgMainPartsService;
@Autowired
IdxBizJgMainPartsMapper idxBizJgMainPartsMapper;
@Autowired
IdxBizJgProtectionDevicesServiceImpl idxBizJgProtectionDevicesService;
@Autowired
IdxBizJgProtectionDevicesMapper idxBizJgProtectionDevicesMapper;
@Autowired
PrivilegeFeginService privilegeFeginService;
@Autowired
IdxFeignService idxFeignService;
@Autowired
IGenerateCodeService generateCodeService;
@Autowired
private ElasticSearchUtil elasticSearchUtil;
RestHighLevelClient restHighLevelClient;
@Autowired
private static final String TABLENAME = "tableName";
RedissonClient redissonClient;
@Autowired
private SuperviseInfoMapper superviseInfoMapper;
@Value("classpath:/json/equipCategory.json")
private Resource equipCategory;
@Autowired
private JdbcTemplate bizJdbcTemplate;
@Autowired
private ESElavtorRepository esElavtorRepository;
@Value("${regulator.unit.code}")
private String code;
@Autowired
private RedisUtils redisUtils;
//管辖机构redis缓存key
private static final String REGULATOR_UNIT_TREE = "REGULATOR_UNIT_TREE";
//行政区划redis缓存key
private static final String PROVINCE = "PROVINCE";
private static final String CITY = "CITY";
private static final String REGION = "REGION";
private static final String STREET = "STREET";
//行政区划level
private static final String PROVINCE_LEVEL = "1";
private static final String CITY_LEVEL = "2";
private static final String REGION_LEVEL = "3";
private static final String STREET_LEVEL = "4";
//西安行政区划code
private static final String XIAN = "610100";
//咸阳行政区划code
private static final String XIAN_YANG = "610400";
//判断行政区划查询市还是区
private static final String END_CODE = "0000";
//判断行政区划查询街道
private static final String STREET_END_CODE = "00";
// 一码通使用信息表单id
private static final String use_info_form_id = "1627903393253056514";
// 一码通监督管理表单id
private static final String supervision_form_id = "1627903532906602497";
// 一码通设计制造表单页id
private static final String design_from_id = "1627897116087050241";
// 一码通检验检测表单页id
private static final String inspection_form_id = "1636282043618848769";
// 一码通施工信息表单页id
private static final String construction_form_id = "1636347672031948801";
// 一码通维保信息表单页id
private static final String maintenance_form_id = "1636347684057018369";
// 一码通注册登记表单页-电梯id
private static final String dt_register_from_id = "1637431088563384322";
// 一码通注册登记表单页-起重机械id
private static final String qzjx_register_from_id = "1635115308320583681";
// 一码通注册登记表单页-锅炉id
private static final String gl_register_from_id = "1631125178945662977";
// 一码通注册登记表单页-游乐设施id
private static final String ylss_register_from_id = "1631125167914643457";
// 一码通注册登记表单页-客运索道id
private static final String kysd_register_from_id = "1631125158229995521";
// 一码通注册登记表单页-压力管道id
private static final String ylgd_register_from_id = "1631125206695178241";
// 一码通注册登记表单页-压力容器id
private static final String ylrq_register_from_id = "1631125198260432897";
// 一码通注册登记表单页-厂车id
private static final String cc_register_from_id = "1631125079347720193";
// 主要零部件
private static final String main_parts = "mainParts";
// 主要零部件
private static final String protection_devices = "ProtectionDevices";
//一码通码自动生成
final static String CREATE = "1";
//一码通码手动输入
final static String NOT_CREATE = "0";
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
//一码通判断是否复制
private static final String IS_COPY = "isCopy";
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
RedissonClient redissonClient;
//一码通生成码分布式锁key
private final static String LOCK_KEY = "RESOURCE_KEY";
//一码通checkCode分布式锁key
private final static String CHECK_CODE_LOCK_KEY = "CHECK_CODE_KEY";
//一码通checkCode中96333码redis key
private final static String CHECK_CODE_CODE96333 = "CODE96333_";
//一码通checkCode中设备代码redis key
private final static String CHECK_CODE_EQU_CODE = "EQU_CODE_";
//一码通checkCode中使用登记证编号redis key
private final static String CHECK_CODE_USE_ORG_CODE = "USE_ORG_CODE_";
//管辖机构
private static final String REGULATOR_UNIT = "监管机构";
//一码通checkCode中redis key过期时间
// 一码通checkCode中redis key过期时间
private long time = 300l;
private ExecutorService threadPool = Executors.newCachedThreadPool();
/**
* 获取两个List的不同元素
*
* @param list1
* @param list2
* @return
*/
private static List<Integer> getDiffrent(List<Integer> list1, List<Integer> list2) {
List<Integer> diff = new ArrayList<Integer>();
Map<Integer, Integer> map = new HashMap<Integer, Integer>(list1.size());
for (Integer integer : list1) {
map.put(integer, 1);
}
for (Integer integer : list2) {
if (map.get(integer) != null) {
map.put(integer, 2);
continue;
}
}
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
if (entry.getValue() == 1) {
diff.add(entry.getKey());
}
}
// 对集合进行排序
Collections.sort(diff);
return diff;
}
/**
* 分页查询
*/
public Page<EquipmentCategoryDto> queryForEquipmentCategoryPage(Page<EquipmentCategoryDto> page) {
......@@ -454,16 +429,16 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
public Map<String, String> createSupervisorCode(Map<String, Object> map) {
String city, county, equipCategory, isNotXiXian;
//获取对应行政区划
// 获取对应行政区划
city = String.valueOf(map.get("cityCode"));
county = String.valueOf(map.get("countyCode"));
//获取对应设备分类
// 获取对应设备分类
equipCategory = String.valueOf(map.get("equCategory"));
if ("null".equals(equipCategory) || "null".equals(city) || "null".equals(county)) {
throw new BadRequest("请求参数不全,请查看参数中是否携带 cityCode、countyCode、equCategory 三个参数及对应值");
}
isNotXiXian = "null".equals(String.valueOf(map.get("isXiXian"))) ? "0" : "1";
//生成码
// 生成码
EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
Map<String, String> codeMap = creatCode(isNotXiXian, city, county, equipCategory, "null", "null");
if (ObjectUtils.isEmpty(codeMap)) {
......@@ -475,7 +450,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
public List<LinkedHashMap> getTree() {
List<LinkedHashMap> result = (List<LinkedHashMap>) redisUtils.get(REGULATOR_UNIT_TREE);
//判断redis是否存在管辖机构树
// 判断redis是否存在管辖机构树
return !ObjectUtils.isEmpty(result) ? result : creatTree();
}
......@@ -483,14 +458,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
public List<LinkedHashMap> creatTree() {
FeignClientResult tree = privilegeFeginService.tree(RequestContext.getToken(), RequestContext.getAppKey(), RequestContext.getProduct());
List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult();
List<LinkedHashMap> treeData = deleteTreeData(result,REGULATOR_UNIT);
List<LinkedHashMap> treeData = deleteTreeData(result, REGULATOR_UNIT);
List<LinkedHashMap> supervisionTree = treeData.stream().filter(e -> code.equals(e.get("orgCode"))).collect(Collectors.toList());
List<LinkedHashMap> resultTree = updateNullChildren(supervisionTree);
redisUtils.set(REGULATOR_UNIT_TREE, resultTree);
return resultTree;
}
private List<LinkedHashMap> deleteTreeData(List<LinkedHashMap> result,String companyType) {
private List<LinkedHashMap> deleteTreeData(List<LinkedHashMap> result, String companyType) {
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
......@@ -499,7 +474,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
it.remove();
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
deleteTreeData((List<LinkedHashMap>) e.get("children"),companyType);
deleteTreeData((List<LinkedHashMap>) e.get("children"), companyType);
}
}
return result;
......@@ -515,7 +490,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//将管辖机构树中children为[]的修改为null
// 将管辖机构树中children为[]的修改为null
if (e.get("children") != null) {
if (((List<LinkedHashMap>) e.get("children")).size() == 0) {
e.put("children", null);
......@@ -538,7 +513,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//删除使用单位
// 删除使用单位
if ("company".equals(e.get("level"))) {
it.remove();
}
......@@ -556,7 +531,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return result;
}
@Override
public List<LinkedHashMap> getRegion(String level, String parentId) {
List<LinkedHashMap> list = new ArrayList<>();
......@@ -565,7 +539,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return ObjectUtils.isEmpty(list) ? getProvinceList(level) : list;
} else if (!ObjectUtils.isEmpty(parentId)) {
String regionCode = parentId.split("_")[0];
//regionCode不是以00结尾查询街道,以0000结果查询市、否则查询区
// regionCode不是以00结尾查询街道,以0000结果查询市、否则查询区
if (!regionCode.endsWith(STREET_END_CODE)) {
list = ObjectUtils.isEmpty(redisUtils.get(STREET)) ? getProvinceList(STREET_LEVEL) : (List<LinkedHashMap>) redisUtils.get(STREET);
} else if (regionCode.endsWith(END_CODE)) {
......@@ -690,7 +664,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* 具体生成监管码和电梯96333识别码逻辑
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public synchronized Map<String, String> creatCode(String isNotXiXian, String city, String county, String equipCategory, String code96333, String supervisionCode) {
public synchronized Map<String, String> creatCode(String isNotXiXian, String city, String county, String equipCategory, String code96333, String supervisionCode) {
RLock lock = redissonClient.getLock(LOCK_KEY);
Map<String, String> resultMap = null;
try {
......@@ -701,9 +675,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
StringBuilder elevatorCode = new StringBuilder();
CategoryOtherInfo categoryOtherInfo = new CategoryOtherInfo();
String prefix;
//判断是否需要生成96333电梯码
// 判断是否需要生成96333电梯码
if (equipCategory.startsWith("3") && (((XIAN.equals(city) || XIAN_YANG.equals(city)) && "1".equals(isNotXiXian)) || !XIAN.equals(city))) {
//判断数据是否携带96333电梯码,携带则使用,不携带则生成
// 判断数据是否携带96333电梯码,携带则使用,不携带则生成
if ("null".equals(code96333)) {
if (((XIAN.equals(city) || XIAN_YANG.equals(city)) && "1".equals(isNotXiXian))) {
prefix = EquipmentCategoryEnum.XXCSM.getValue();
......@@ -711,9 +685,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Map<String, Object> elevatorMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), county);
prefix = ObjectUtils.isEmpty(elevatorMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQHDT.getCode(), city).get("code").toString() : elevatorMap.get("code").toString();
}
//查询未使用的电梯码
// 查询未使用的电梯码
categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode());
//如果存在未使用的电梯码则启用未使用的否则创建
// 如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? generateCodeService.createElevatorCode("96333_" + prefix) : categoryOtherInfo.getCode();
if (!ObjectUtils.isEmpty(categoryOtherInfo)) {
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333", categoryOtherInfo.getCode()));
......@@ -725,7 +699,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
resultMap.put("creatStatus", NOT_CREATE);
}
}
//判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成
// 判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成
if ("null".equals(supervisionCode)) {
String supervisor = createSupervisorCode(isNotXiXian, city, county, equipCategory);
supervisorCode.append(supervisor);
......@@ -739,7 +713,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
log.info("生成码成功");
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionCode));
//将生成的码添加到码表中,码的使用状态为初始状态
// 将生成的码添加到码表中,码的使用状态为初始状态
String equState = EquipmentCategoryEnum.CSZT.getCode();
supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode));
supervisoryCodeInfo.setCreateStatus(resultMap.get("creatStatus"));
......@@ -752,14 +726,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisoryCodeInfoMapper.update(selectOne,
new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", selectOne.getSupervisoryCode()));
}
//使用UUID生成一个record,多表关联关系用
// 使用UUID生成一个record,多表关联关系用
resultMap.put("superviseCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
resultMap.put("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString());
resultMap.put("qrCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
} catch (Exception e) {
throw new RuntimeException(e);
}
finally {
} finally {
lock.unlock(); // 释放锁
log.info("释放锁");
}
......@@ -783,18 +756,18 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (((XIAN.equals(city) || XIAN_YANG.equals(city)) && "1".equals(isNotXiXian))) {
division = "X";
} else {
//生成监管码前缀
// 生成监管码前缀
Map<String, Object> divisionMap = equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), county);
division = ObjectUtils.isEmpty(divisionMap) ? equipmentCategoryMapper.getAdministrativeDivision(EquipmentCategoryEnum.XZQH.getCode(), city).get("code").toString() : divisionMap.get("code").toString();
}
//supervisorCode.append(division).append(equipCategory).append("-");
// supervisorCode.append(division).append(equipCategory).append("-");
supervisorCode.append(division).append(equipCategory);
return generateCodeService.createSupervisoryCode(String.valueOf(supervisorCode));
//获取行政区划区县、市是否存在历史监管码
//CategoryOtherInfo supervisor = categoryOtherInfoMapper.selectSupervisorCode(supervisorCode.toString());
//生成对应监管码
//if (!ObjectUtils.isEmpty(supervisor) && supervisor.getSupervisoryCode() != null) {
// 获取行政区划区县、市是否存在历史监管码
// CategoryOtherInfo supervisor = categoryOtherInfoMapper.selectSupervisorCode(supervisorCode.toString());
// 生成对应监管码
// if (!ObjectUtils.isEmpty(supervisor) && supervisor.getSupervisoryCode() != null) {
// //获取补零位长度
// String supervisoryCode = supervisor.getSupervisoryCode().substring(6);
// long num = Long.valueOf(supervisoryCode) + 1;
......@@ -809,7 +782,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//} else {
// supervisorCode.append(EquipmentCategoryEnum.JGM.getCode());
//}
//return supervisorCode.toString();
// return supervisorCode.toString();
}
/**
......@@ -821,14 +794,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Deprecated
public String createElevatorCode(String prefix) {
StringBuilder elevatorCode = new StringBuilder();
//生成生成96333电梯码前缀
// 生成生成96333电梯码前缀
elevatorCode.append(prefix);
String initCode = elevatorCode + EquipmentCategoryEnum.getValue.get(elevatorCode.toString());
CategoryOtherInfo initSupervisoryCode = categoryOtherInfoMapper.queryInitCode(initCode); // 查询是否已经生成过初始值
if (ValidationUtil.isEmpty(initSupervisoryCode)) {
elevatorCode.append(EquipmentCategoryEnum.getValue.get(prefix));
} else {
//获取行政区划区县、市是否存在历史96333电梯码
// 获取行政区划区县、市是否存在历史96333电梯码
CategoryOtherInfo elevatorOtherInfo = categoryOtherInfoMapper.selectElevatorCode(elevatorCode.toString(), null);
if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) {
StopWatch stopWatch = new StopWatch();
......@@ -844,7 +817,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
elevatorCode.setLength(0);
elevatorCode.append(resultList.get(0));
} else {
//获取补零位长度
// 获取补零位长度
String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
long num = Long.parseLong(elevatorCode1) + 1;
int numLength = String.valueOf(num).length();
......@@ -864,36 +837,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
/**
* 获取两个List的不同元素
*
* @param list1
* @param list2
* @return
*/
private static List<Integer> getDiffrent(List<Integer> list1, List<Integer> list2) {
List<Integer> diff = new ArrayList<Integer>();
Map<Integer, Integer> map = new HashMap<Integer, Integer>(list1.size());
for (Integer integer : list1) {
map.put(integer, 1);
}
for (Integer integer : list2) {
if (map.get(integer) != null) {
map.put(integer, 2);
continue;
}
}
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
if (entry.getValue() == 1) {
diff.add(entry.getKey());
}
}
// 对集合进行排序
Collections.sort(diff);
return diff;
}
/**
* 获取当前登录人单位类型
*
* @return
......@@ -916,7 +859,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return objectList;
}
@Override
public Map<String, Map<String, Object>> getFormRecordById(Map<String, Object> map) {
// ResponseModel<Map<String, Map<String, Object>>> responseModel = idxFeignService.getFormRecordById(map);
......@@ -1235,16 +1177,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return page;
}
/**
* levlel=company,是企业,如果不是都是监管单位,
* * 在接口中查询当前登录人所属单位是监管单位还是企业。
* * 如果为监管单位添加监管机构查询参数(ORG_BRANCH_CODE);
* * 如果为企业添加使用单位查询参数(USE_UNIT_CREDIT_CODE)
*/
private static final String LEVEL = "company";
private static final String EQUSTATE = "EQU_STATE";
private static final String USEPLACE = "USE_PLACE";
public Page<Map<String, Object>> getTable(Map<String, Object> map) {
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
......@@ -1267,12 +1199,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ValidationUtil.isEmpty(level)) {
Page<Map<String, Object>> m = new Page<>();
if (LEVEL.equals(level)) {
//企业
// 企业
map.put("USE_UNIT_CREDIT_CODE", companyCode);
m = this.getPage(map);
map.remove("USE_UNIT_CREDIT_CODE");
} else {
//监管单位
// 监管单位
map.put("ORG_BRANCH_CODE", code);
m = this.getPage(map);
map.remove("ORG_BRANCH_CODE");
......@@ -1290,7 +1222,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
objectPage.setSize(Long.valueOf(map.get("size").toString()));
objectPage.setCurrent(Long.valueOf(map.get("number").toString()));
model.setResult(objectPage);
//设备状态码对应枚举值
// 设备状态码对应枚举值
List<Map<String, Object>> records = model.getResult().getRecords();
List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, Object> record : records) {
......@@ -1343,10 +1275,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String companyCode = object.getString("companyCode");
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
// 企业
dto.setUSE_UNIT_CREDIT_CODE(companyCode);
} else {
//监管单位
// 监管单位
dto.setORG_BRANCH_CODE(orgCode);
}
List<EquipExportVo> equipExportData = equipmentCategoryMapper.getEquipExportData(dto);
......@@ -1371,10 +1303,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ValidationUtil.isEmpty(level)) {
Page<EquipExportVo> equipExportVoPage = new Page<>(pageNum, size);
if (LEVEL.equals(level)) {
//企业
// 企业
dto.setUSE_UNIT_CREDIT_CODE(companyCode);
} else {
//监管单位
// 监管单位
dto.setORG_BRANCH_CODE(orgCode);
}
Page<EquipExportVo> equipExportData = equipmentCategoryMapper.exportImageZip(equipExportVoPage, dto);
......@@ -1442,7 +1374,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
esElevator.setSequenceNbr(recordList.toString());
esElevatorList.add(esElevator);
}
//删除监管码表数据
// 删除监管码表数据
List<String> superviseCodeList = superviseInfoMapper.selectSuperviseCodeList(records);
List<Map<String, Object>> unitCodeAndOrgBranchCodeList = superviseInfoMapper.selectUnitCodeList(records);
List<String> unitCodeList = new ArrayList<>();
......@@ -1455,11 +1387,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(superviseCodeList)) {
supervisoryCodeInfoMapper.updateStatus(superviseCodeList);
}
//删除es中elev中的相关数据
// 删除es中elev中的相关数据
esElavtorRepository.deleteAll(esElevatorList);
//删除涉及的19张表的数据
// 删除涉及的19张表的数据
superviseInfoMapper.deleteDataAll(records);
//删除es中的数据
// 删除es中的数据
esEquipmentCategory.deleteAll(list);
return records;
}
......@@ -1509,7 +1441,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String claimStatus = String.valueOf(superviseMap.get("claimStatus"));
String operateType = String.valueOf(superviseMap.get("operateType"));
String isCopy = String.valueOf(useInfoFrom.get("isCopy"));
//生成码
// 生成码
Map<String, String> codeMap = new HashMap<>();
if (EquipmentCategoryEnum.YRL.getName().equals(claimStatus)) {
log.info("准备生成监管码或96333电梯识别码");
......@@ -1517,9 +1449,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String county = String.valueOf(superviseMap.get("county"));
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
EquipmentCategoryServiceImpl categoryService = (EquipmentCategoryServiceImpl) AopContext.currentProxy();
//生成码
// 生成码
codeMap = categoryService.creatCode(isNotXiXian, city, county, equCategory, code96333, supervisionCode);
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
// 删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data");
supervisionMap.put("CODE96333", codeMap.get("code96333"));
supervisionMap.put("SUPERVISORY_CODE", codeMap.get("superviseCode"));
......@@ -1535,7 +1467,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisionMap.put("CODE96333", "null".equals(code96333) ? null : code96333);
map.put(supervision_form_id, supervisionMap);
supervisoryCodeInfo.setCode96333("null".equals(code96333) ? null : code96333);
//根据操作状态判断是调用新增还是修改接口
// 根据操作状态判断是调用新增还是修改接口
record = batchSubmitOrUpdate(map, registerForm, alias, isCopy, operateType, claimStatus);
} else {
record = batchSubmitOrUpdate(map, registerForm, alias, isCopy, operateType, claimStatus);
......@@ -1610,7 +1542,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.YSY.getCode());
if (category.startsWith("3")) {
if ("null".equals(map.get("code"))) {
//code96333 = createElevatorCode("31");
// code96333 = createElevatorCode("31");
code96333 = generateCodeService.createElevatorCode("96333_31");
supervisoryCodeInfo.setCreateStatus(CREATE);
} else {
......@@ -1619,7 +1551,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
supervisoryCodeInfo.setCode96333(code96333);
//更新至码表
// 更新至码表
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
CategoryOtherInfo categoryOtherInfo = new CategoryOtherInfo();
categoryOtherInfo.setCode(code96333);
......@@ -1678,7 +1610,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
idxBizJgUseInfoService.saveOrUpdate(useInfo);
//监督管理信息
// 监督管理信息
LinkedHashMap supervisionForm = (LinkedHashMap) map.get(supervision_form_id);
IdxBizJgSupervisionInfo supervisionInfo = JSON.parseObject(JSON.toJSONString(supervisionForm), IdxBizJgSupervisionInfo.class);
supervisionInfo.setRecord(record);
......@@ -1696,7 +1628,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
idxBizJgOtherInfoService.saveOrUpdate(idxBizJgOtherInfo);
}
//设计制造信息
// 设计制造信息
LinkedHashMap designForm = (LinkedHashMap) map.get(design_from_id);
IdxBizJgDesignInfo designInfo = JSON.parseObject(JSON.toJSONString(designForm), IdxBizJgDesignInfo.class);
designInfo.setRecord(record);
......@@ -1712,7 +1644,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
idxBizJgFactoryInfoService.saveOrUpdate(factoryInfo);
}
//检验检测信息
// 检验检测信息
LinkedHashMap inspectionForm = (LinkedHashMap) map.get(inspection_form_id);
List inspectionList = (ArrayList) inspectionForm.get("subForm_pbim1pfid8");
List<IdxBizJgInspectionDetectionInfo> detectionInfoList = new ArrayList<>();
......@@ -1727,7 +1659,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
idxBizJgInspectionDetectionInfoService.saveOrUpdateBatch(detectionInfoList);
}
//施工信息
// 施工信息
LinkedHashMap constructionForm = (LinkedHashMap) map.get(construction_form_id);
List constructionlist = (ArrayList) constructionForm.get("subForm_b2x2wmcy2s");
if (!ObjectUtils.isEmpty(constructionlist)) {
......@@ -1742,11 +1674,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
idxBizJgConstructionInfoService.saveOrUpdateBatch(constructionInfoList);
}
//八大类技术参数实体填充
// 八大类技术参数实体填充
List<IdxBizJgMainParts> mainPartsList = new ArrayList<>();
List<IdxBizJgProtectionDevices> protectionDevicesList = new ArrayList<>();
if (EquipmentTypeEnum.DT.getCode().equals(alias)) {
//维保备案信息
// 维保备案信息
LinkedHashMap maintenanceForm = (LinkedHashMap) map.get(maintenance_form_id);
List subFormMaintenanceList = (ArrayList) maintenanceForm.get("subForm_6i16fox27e");
if (!ObjectUtils.isEmpty(subFormMaintenanceList)) {
......@@ -1760,7 +1692,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
idxBizJgMaintenanceRecordInfoService.saveOrUpdateBatch(maintenanceList);
}
//技术参数
// 技术参数
IdxBizJgTechParamsElevator elevator = JSON.parseObject(JSON.toJSONString(registerForm), IdxBizJgTechParamsElevator.class);
if (!ObjectUtils.isEmpty(elevator)) {
elevator.setRecord(record);
......@@ -1942,7 +1874,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return page;
}
//查询总条数
// 查询总条数
public Long counts(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空");
......@@ -1979,21 +1911,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
log.info("本次一码通同步设备数据:【" + total + "】条,耗时:" + (end - start) + " 毫秒");
}
public void updateEs() {
List<String> list = categoryOtherInfoMapper.selectData();
List<List<String>> allDataList = Lists.partition(list, 100);
for (List<String> tempDataList : allDataList) {
if (CollectionUtils.isNotEmpty(tempDataList)) {
List<EsEntity<JgAll>> batchList = new ArrayList<>(tempDataList.size());
tempDataList.forEach(item -> batchList.add(new EsEntity<>(item, new JgAll("jg"))));
elasticSearchUtil.updateBatch("idx_biz_view_jg_all", batchList);
}
}
log.info("idx_biz_view_jg_all 旧数据:"+list);
log.info("idx_biz_view_jg_all 旧数据size:"+list.size());
}
public void saveBatchEquipment2Es(List<Map<String, Object>> equipList) {
List<ESEquipmentCategoryDto> esEquipDtoList = Lists.newArrayList();
List<String> recordList = Lists.newArrayList();
......@@ -2048,11 +1965,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//通用匹配规则,条件构建
// 通用匹配规则,条件构建
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
// 企业
map.put("USE_UNIT_CREDIT_CODE", companyCode);
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
......@@ -2072,12 +1989,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return result;
}
} else {
//监管单位
// 监管单位
map.put("ORG_BRANCH_CODE", code);
}
}
}
//SEQUENCE_NBR
// SEQUENCE_NBR
if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("SEQUENCE_NBR"));
......@@ -2204,7 +2121,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return result;
}
//es统计总记录数
// es统计总记录数
public Long getCount(String indexs, RestHighLevelClient esClient) {
Long totle = 0L;
SearchRequest searchRequest = new SearchRequest(indexs);
......@@ -2476,31 +2393,31 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Map<String, Object> childMap = entry.getValue();
if (!childMap.isEmpty()) {
ESEquipmentCategoryDto oldData = null;
//获取Es中旧的数据
// 获取Es中旧的数据
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
if (!ObjectUtils.isEmpty(optional)) {
oldData = optional.get();
oldUscUnitCreditCode = oldData.getUSC_UNIT_CREDIT_CODE();
oldUscUnitName = oldData.getUSC_UNIT_NAME();
}
//获取Es中新的参数
// 获取Es中新的参数
ESEquipmentCategoryDto newData = JSON.parseObject(toJSONString(childMap), ESEquipmentCategoryDto.class);
String newUscUnitCreditCode = newData.getUSC_UNIT_CREDIT_CODE();
String newUscUnitName = newData.getUSC_UNIT_NAME();
//删除Es中旧的数据
// 删除Es中旧的数据
if (!ObjectUtils.isEmpty(oldData)) {
esEquipmentCategory.deleteById(record);
//整合新旧数据
// 整合新旧数据
Bean.copyExistPropertis(newData, oldData);
//处理施工单位信息[去重]
if(!ValidationUtil.isEmpty(newUscUnitCreditCode)){
// 处理施工单位信息[去重]
if (!ValidationUtil.isEmpty(newUscUnitCreditCode)) {
if (!ValidationUtil.isEmpty(oldUscUnitCreditCode)) {
if(!oldUscUnitCreditCode.contains(newUscUnitCreditCode)){
if (!oldUscUnitCreditCode.contains(newUscUnitCreditCode)) {
oldData.setUSC_UNIT_CREDIT_CODE(oldUscUnitCreditCode + "," + newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(oldUscUnitName + "," + newUscUnitName);
}
}else {
} else {
oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(newUscUnitName);
}
......@@ -2511,7 +2428,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
oldData.setREC_DATE(System.currentTimeMillis());
ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData);
//组装返回数据
// 组装返回数据
resultMap.put(record, saveData);
}
}
......
package com.yeejoin.amos.boot.module.ymt.biz.utils;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.module.ymt.biz.dao.EsEntity;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author LiuLin
* @date 2023年08月08日 16:30
*/
@Slf4j
@Component
public class ElasticSearchUtil {
private static final long SCROLL_TIMEOUT = 180000;
private static final int SIZE = 1000;
@Autowired
private RestHighLevelClient restHighLevelClient;
/**
* Description: 批量修改数据
*
* @param index index
* @param list 更新列表
* @author LiuLin
*/
public <T> void updateBatch(String index, List<EsEntity<T>> list) {
BulkRequest request = new BulkRequest();
list.forEach(item -> request.add(new UpdateRequest(index, item.getId())
.doc(JSON.toJSONString(item.getData()), XContentType.JSON)));
try {
restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
list.forEach(s -> log.info("===========索引:【{}】,主键:【{}】修改成功", index, s.getId()));
} catch (Exception e) {
log.error("索引:[{}]", index, e);
}
}
}
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