EtlMvAttStBaseDataTask.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 lombok.extern.slf4j.Slf4j;
  11. import org.springblade.etl.entity.EtlMvAttStBaseEntity;
  12. import org.springblade.etl.service.IEtlMvAttStBaseService;
  13. import org.springblade.modules.baseinfo.stbase.entity.MvAttStBaseEntity;
  14. import org.springblade.modules.baseinfo.stbase.service.IMvAttStBaseService;
  15. import java.util.Date;
  16. import java.util.List;
  17. import java.util.concurrent.Callable;
  18. /***
  19. * Date:2022/5/22
  20. * Title: 测站基础数据
  21. * Description:
  22. * @author swp
  23. * @version 1.0
  24. * Remark:认为有必要的其他信息
  25. */
  26. @Slf4j
  27. public class EtlMvAttStBaseDataTask implements Callable<Integer> {
  28. private IEtlMvAttStBaseService etlMvAttStBaseService;
  29. private IMvAttStBaseService mvAttStBaseService;
  30. EtlMvAttStBaseDataTask(IEtlMvAttStBaseService etlMvAttStBaseService, IMvAttStBaseService mvAttStBaseService) {
  31. this.etlMvAttStBaseService = etlMvAttStBaseService;
  32. this.mvAttStBaseService = mvAttStBaseService;
  33. }
  34. @Override
  35. public Integer call() {
  36. try {
  37. log.info("测站数据抽取开始**************");
  38. List<EtlMvAttStBaseEntity> list = etlMvAttStBaseService.selectList();
  39. if (list != null && list.size() > 0) {
  40. for (int i = 0; i < list.size(); i++) {
  41. EtlMvAttStBaseEntity entity = list.get(i);
  42. LambdaQueryWrapper<MvAttStBaseEntity> dataWrapper = Wrappers.<MvAttStBaseEntity>query().lambda();
  43. dataWrapper.eq(MvAttStBaseEntity::getStCode, entity.getStCode());
  44. MvAttStBaseEntity baseEntity = mvAttStBaseService.getOne(dataWrapper);
  45. if (null == baseEntity) {
  46. baseEntity = new MvAttStBaseEntity();
  47. baseEntity.setCreateTime(new Date());
  48. baseEntity.setUpdateTime(new Date());
  49. baseEntity.setStatus(1);
  50. baseEntity.setIsDeleted(0);
  51. }
  52. baseEntity.setStCode(entity.getStCode());
  53. baseEntity.setStName(entity.getStName());
  54. baseEntity.setAdCode(entity.getAdCode());
  55. baseEntity.setAdName(entity.getAdName());
  56. baseEntity.setRvCode(entity.getRvCode());
  57. baseEntity.setRvName(entity.getRvName());
  58. baseEntity.setStLong(entity.getStLong());
  59. baseEntity.setStLat(entity.getStLat());
  60. baseEntity.setIsRain(entity.getIsRain());
  61. baseEntity.setIsRiver(entity.getIsRiver());
  62. baseEntity.setIsRes(entity.getIsRes());
  63. baseEntity.setRainStType(entity.getRainStType());
  64. baseEntity.setUpdateTime(new Date());
  65. mvAttStBaseService.saveOrUpdate(baseEntity);
  66. }
  67. }
  68. } catch (Exception e) {
  69. log.error("实时数据统计任务异常 {}", e.getMessage());
  70. }
  71. return 0;
  72. }
  73. }