EtlGroundDataTask.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Copyright
  3. * All right reserved.
  4. * 项目名称:
  5. * 创建日期:2022/5/22
  6. */
  7. package org.springblade.etl;
  8. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  9. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  10. import org.springblade.etl.dto.EtlGroundDataDTO;
  11. import org.springblade.etl.entity.EtlGroundDataEntity;
  12. import org.springblade.etl.service.IEtlGroundDataService;
  13. import org.springblade.modules.business.data.entity.RtuDataGroundEntity;
  14. import org.springblade.modules.business.data.service.IRtuDataGroundService;
  15. import java.util.Date;
  16. import java.util.List;
  17. /***
  18. * Date:2022/5/22
  19. * Title: 墒情同步
  20. * Description:
  21. * @author swp
  22. * @version 1.0
  23. * Remark:认为有必要的其他信息
  24. */
  25. public class EtlGroundDataTask {
  26. public static RtuDataGroundEntity dataSync(EtlGroundDataDTO etlGroundDataDTO, IEtlGroundDataService etlGroundDataService, IRtuDataGroundService rtuDataGroundService) {
  27. List<EtlGroundDataEntity> groundDataEntityList = etlGroundDataService.selectLastList(etlGroundDataDTO);
  28. if (null != groundDataEntityList && groundDataEntityList.size() > 0) {
  29. EtlGroundDataEntity entity = groundDataEntityList.get(0);
  30. LambdaQueryWrapper<RtuDataGroundEntity> dataWrapper = Wrappers.<RtuDataGroundEntity>query().lambda();
  31. dataWrapper.eq(RtuDataGroundEntity::getRtuCode, entity.getRtuCode());
  32. dataWrapper.eq(RtuDataGroundEntity::getIsDeleted, 0);
  33. RtuDataGroundEntity groundDataEntity = rtuDataGroundService.getOne(dataWrapper);
  34. if (null == groundDataEntity) {
  35. groundDataEntity = new RtuDataGroundEntity();
  36. groundDataEntity.setRtuCode(entity.getRtuCode());
  37. groundDataEntity.setCreateTime(new Date());
  38. groundDataEntity.setUpdateTime(new Date());
  39. groundDataEntity.setStatus(1);
  40. groundDataEntity.setIsDeleted(0);
  41. }
  42. groundDataEntity.setSlm10(entity.getMoco10cm());
  43. groundDataEntity.setSlm20(entity.getMoco20cm());
  44. groundDataEntity.setSlm30(entity.getMoco30cm());
  45. groundDataEntity.setSlm40(entity.getMoco40cm());
  46. groundDataEntity.setSlm50(entity.getMoco50cm());
  47. groundDataEntity.setSlm60(entity.getMoco60cm());
  48. groundDataEntity.setSlm80(entity.getMoco80cm());
  49. groundDataEntity.setSlm100(entity.getMoco100cm());
  50. groundDataEntity.setSrlslm(entity.getSurfMoco());
  51. groundDataEntity.setVtavslm(entity.getVertAverMoco());
  52. groundDataEntity.setTm(entity.getTm());
  53. rtuDataGroundService.saveOrUpdate(groundDataEntity);
  54. return groundDataEntity;
  55. }
  56. return null;
  57. }
  58. }