Commit 22979784 authored by tianyiming's avatar tianyiming

气瓶基本信息同步es修改

parent 16caeba5
...@@ -87,4 +87,6 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> { ...@@ -87,4 +87,6 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
Integer getInfoTotal(); Integer getInfoTotal();
void updateEsCylinderInfoStatus(@Param("ids")List<String> ids);
} }
...@@ -338,4 +338,11 @@ ...@@ -338,4 +338,11 @@
where ci.is_not_es IS NULL where ci.is_not_es IS NULL
AND region_code is not null AND region_code is not null
</select> </select>
<update id="updateEsCylinderInfoStatus">
UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN
<foreach collection="ids" separator="," item="id" open="(" close=")">
#{id}
</foreach>
</update>
</mapper> </mapper>
...@@ -567,7 +567,7 @@ public class CylinderInfoController extends BaseController { ...@@ -567,7 +567,7 @@ public class CylinderInfoController extends BaseController {
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/saveCyinderInfo") @GetMapping(value = "/saveCyinderInfo")
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息存入es", notes = "气瓶基本信息存入es") @ApiOperation(httpMethod = "GET", value = "气瓶基本信息存入es", notes = "气瓶基本信息存入es")
public void saveCyinderInfo() { public void saveCyinderInfo() {
...@@ -584,30 +584,27 @@ public class CylinderInfoController extends BaseController { ...@@ -584,30 +584,27 @@ public class CylinderInfoController extends BaseController {
return; return;
} }
for (int i = 0; i <= times; i++) { for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(i); cylinderInfoPage.setCurrent(0);
cylinderInfoPage.setSize(1000); cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage); cylinderInfoPage = cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) { if (!ObjectUtils.isEmpty(cylinderInfoPage) && !ObjectUtils.isEmpty(cylinderInfoPage.getRecords())) {
cylinderInfoServiceImpl.saveCylinderInfo2ES(cylinderInfoPage.getRecords()); cylinderInfoServiceImpl.saveCylinderInfo2ES(cylinderInfoPage.getRecords());
} }
// for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) {
// cylinderInfoServiceImpl.saveCylinderInfoToES(ci);
// }
} }
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/getCyinderInfo") @GetMapping(value = "/getCyinderInfo")
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息存入es入口", notes = "气瓶基本信息存入es入口") @ApiOperation(httpMethod = "GET", value = "气瓶基本信息存入es入口", notes = "气瓶基本信息存入es入口")
public Page<CylinderInfoDto> getCyinderInfo() { public ResponseModel getCyinderInfo() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>(); Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
cylinderInfoPage.setCurrent(1); cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000); cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage); cylinderInfoPage = cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage);
for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) { if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
cylinderInfoServiceImpl.saveCylinderInfoToES(ci); cylinderInfoServiceImpl.saveCylinderInfo2ES(cylinderInfoPage.getRecords());
} }
return cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage); return ResponseHelper.buildResponse(true);
} }
...@@ -661,10 +658,6 @@ public class CylinderInfoController extends BaseController { ...@@ -661,10 +658,6 @@ public class CylinderInfoController extends BaseController {
for (int i = 0; i <= times; i++) { for (int i = 0; i <= times; i++) {
recordDtoPage.setCurrent(1); recordDtoPage.setCurrent(1);
recordDtoPage.setSize(1000); recordDtoPage.setSize(1000);
// CylinderFillingRecordDto cylinderFillingRecordDto = new CylinderFillingRecordDto();
// if (StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) {
// cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF");
// }
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordServiceImpl.getCyinderFillingRecord(recordDtoPage); Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordServiceImpl.getCyinderFillingRecord(recordDtoPage);
if (!ObjectUtils.isEmpty(cyinderFillingRecord)) { if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cylinderFillingRecordServiceImpl.saveCylinderFillingRecord2ES(cyinderFillingRecord.getRecords()); cylinderFillingRecordServiceImpl.saveCylinderFillingRecord2ES(cyinderFillingRecord.getRecords());
......
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.cylinder.api.dto.WarningMsgDto; import com.yeejoin.amos.boot.module.cylinder.api.dto.WarningMsgDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto; import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto;
...@@ -40,6 +41,7 @@ import org.springframework.scheduling.annotation.Scheduled; ...@@ -40,6 +41,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
...@@ -746,18 +748,17 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -746,18 +748,17 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@SchedulerLock(name = "cylinderInfoToESTask", lockAtMostFor = "PT6H") @SchedulerLock(name = "cylinderInfoToESTask", lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES() { public void setTimeSaveCylinderInfoToES() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>(); Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage); Integer count = getInfoTotal();
Long count = cyinderInfoList.getCurrent(); Integer times = 0;
Long times = 0L;
if (count != 0) { if (count != 0) {
times = count / 1000; times = count / 1000;
Long last = count % 1000; int last = count % 1000;
if (last > 0) { if (last > 0) {
times++; times++;
} }
} }
for (int i = 0; i <= times; i++) { for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1); cylinderInfoPage.setCurrent(0);
cylinderInfoPage.setSize(1000); cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage); cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) { if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
...@@ -772,19 +773,27 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -772,19 +773,27 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Override @Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) { public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>(); List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>(); List<String> ids = Lists.newArrayList();
for (CylinderInfoDto record : records) { for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto(); ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record, esCylinderInfo); BeanUtils.copyProperties(record, esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo); esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo(); ids.add(String.valueOf(record.getSequenceNbr()));
BeanUtils.copyProperties(record, cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
} }
StopWatch stopWatch = new StopWatch();
stopWatch.start();
esCylinderInfoRepository.saveAll(esCylinderInfoDto); esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList); stopWatch.stop();
if (log.isInfoEnabled()) {
log.info("批量存入es耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
cylinderInfoMapper.updateEsCylinderInfoStatus(ids);
stopWatch1.stop();
if (log.isInfoEnabled()) {
log.info("批量更新业务数据耗时:{} 秒", stopWatch1.getTotalTimeSeconds());
}
} }
@Override @Override
......
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