Commit 4441e203 authored by tianbo's avatar tianbo

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

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