Commit 4441e203 authored by tianbo's avatar tianbo

修改一码通es初始化接口-优化

parent 40fca3f2
......@@ -3,7 +3,7 @@
<mapper namespace="com.yeejoin.amos.boot.module.tzs.api.mapper.SuperviseInfoMapper">
<update id="updateRecordBatch">
UPDATE idx_biz_jg_supervision_info SET "IS_NOT_ES" = 1 WHERE "RECORD" IN
UPDATE idx_biz_jg_use_info SET "IS_NOT_ES" = 1 WHERE "RECORD" IN
<foreach collection="recordList" separator="," item="record" open="(" close=")">
#{record}
</foreach>
......
package com.yeejoin.amos;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.amos.boot.module.tzs.biz.listener.*;
import com.yeejoin.amos.boot.module.tzs.biz.listener.AmosMqttListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.BaseEnterpriseMqTtlListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.CarcylUnitInspectMqTtlListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.FillingRecordSyncListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.PrivilegeCompanyDeleteListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.PrivilegeCompanyUpdateAddListener;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService;
import org.eclipse.paho.client.mqttv3.MqttException;
......
......@@ -801,11 +801,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
superviseInfoMapper.update(superviseInfo, new QueryWrapper<SuperviseInfo>().eq("RECORD", id));
ESEquipmentCategoryDto dto = JSON.parseObject(JSONObject.toJSONString(map), ESEquipmentCategoryDto.class);
Optional<ESEquipmentCategoryDto> data = esEquipmentCategory.findById(id);
dto.setREC_DATE(System.currentTimeMillis());
if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(id);
}
if (!ObjectUtils.isEmpty(dto)) {
dto.setREC_DATE(System.currentTimeMillis());
esEquipmentCategory.save(dto);
}
}
......@@ -891,6 +891,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
List<Map<String, Object>> mapList = bizJdbcTemplate.queryForList(selectSql);
page.setRecords(mapList);
page.setTotal(mapList.size());
return page;
}
......@@ -909,6 +910,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/
public void saveEs() {
long start = System.currentTimeMillis();
Map<String, Object> map = new HashMap<>();
map.put(TABLENAME, "idx_biz_view_jg_all");
Long counts = counts(map);
......@@ -917,10 +919,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (yushu > 0) {
times++;
}
long total = 0;
for (int i = 1; i <= times; i++) {
map.put("number", 1);
map.put("size", 1000);
Page<Map<String, Object>> page = getAll(map);
total = total + page.getTotal();
saveBatchEquipment2Es(page.getRecords());
// for (Map<String, Object> record : page.getRecords()) {
// if (ValidationUtil.isEmpty(record.get("IS_NOT_ES"))) {
......@@ -928,6 +932,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
// }
// }
}
long end = System.currentTimeMillis();
log.info("本次一码通同步设备数据:【" + total + "】条,耗时:" + (end - start) + " 毫秒");
}
public void saveBatchEquipment2Es(List<Map<String, Object>> equipList) {
......@@ -955,9 +961,17 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
recordList.add((String) e.get("SEQUENCE_NBR"));
}
long start = System.currentTimeMillis();
esEquipmentCategory.saveAll(esEquipDtoList);
long end = System.currentTimeMillis();
long cost = end - start;
System.out.println("批量存入es1000条数据耗时:" + cost);
long start1 = System.currentTimeMillis();
superviseInfoMapper.updateRecordBatch(recordList);
long end1 = System.currentTimeMillis();
long cost1 = end1 - start1;
System.out.println("批量更新1000条业务数据耗时:" + cost1);
}
/**
......
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