/** * Copyright * All right reserved. * 项目名称: * 创建日期:2022/5/22 */ package org.springblade.etl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.springblade.etl.dto.EtlGroundDataDTO; import org.springblade.etl.entity.EtlGroundDataEntity; import org.springblade.etl.service.IEtlGroundDataService; import org.springblade.modules.business.data.entity.RtuDataGroundEntity; import org.springblade.modules.business.data.service.IRtuDataGroundService; import java.util.Date; import java.util.List; /*** * Date:2022/5/22 * Title: 墒情同步 * Description: * @author swp * @version 1.0 * Remark:认为有必要的其他信息 */ public class EtlGroundDataTask { public static RtuDataGroundEntity dataSync(EtlGroundDataDTO etlGroundDataDTO, IEtlGroundDataService etlGroundDataService, IRtuDataGroundService rtuDataGroundService) { List groundDataEntityList = etlGroundDataService.selectLastList(etlGroundDataDTO); if (null != groundDataEntityList && groundDataEntityList.size() > 0) { EtlGroundDataEntity entity = groundDataEntityList.get(0); LambdaQueryWrapper dataWrapper = Wrappers.query().lambda(); dataWrapper.eq(RtuDataGroundEntity::getRtuCode, entity.getRtuCode()); dataWrapper.eq(RtuDataGroundEntity::getIsDeleted, 0); RtuDataGroundEntity groundDataEntity = rtuDataGroundService.getOne(dataWrapper); if (null == groundDataEntity) { groundDataEntity = new RtuDataGroundEntity(); groundDataEntity.setRtuCode(entity.getRtuCode()); groundDataEntity.setCreateTime(new Date()); groundDataEntity.setUpdateTime(new Date()); groundDataEntity.setStatus(1); groundDataEntity.setIsDeleted(0); } groundDataEntity.setSlm10(entity.getMoco10cm()); groundDataEntity.setSlm20(entity.getMoco20cm()); groundDataEntity.setSlm30(entity.getMoco30cm()); groundDataEntity.setSlm40(entity.getMoco40cm()); groundDataEntity.setSlm50(entity.getMoco50cm()); groundDataEntity.setSlm60(entity.getMoco60cm()); groundDataEntity.setSlm80(entity.getMoco80cm()); groundDataEntity.setSlm100(entity.getMoco100cm()); groundDataEntity.setSrlslm(entity.getSurfMoco()); groundDataEntity.setVtavslm(entity.getVertAverMoco()); groundDataEntity.setTm(entity.getTm()); rtuDataGroundService.saveOrUpdate(groundDataEntity); return groundDataEntity; } return null; } }