DataTransRepLiquidTask.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.hb.proj.gather.process;
  2. import org.apache.commons.lang3.StringUtils;
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import com.hb.proj.gather.model.LiquidPO;
  6. import com.hb.proj.gather.rep.GatherDataRepService;
  7. import com.hb.proj.gather.rep.WellConfigService;
  8. import com.hb.xframework.util.ApplicationContextUtils;
  9. public class DataTransRepLiquidTask implements Runnable {
  10. private final static Logger logger = LoggerFactory.getLogger(DataTransRepLiquidTask.class);
  11. private LiquidPO po;
  12. public DataTransRepLiquidTask(LiquidPO po) {
  13. this.po=po;
  14. }
  15. @Override
  16. public void run() {
  17. logger.info("开始动液面数据转换处理{}",po.getDevSerial());
  18. try {
  19. WellConfigService configService=ApplicationContextUtils.getBean("wellConfigService", WellConfigService.class);
  20. String wellId=configService.getWellIdByDev(po.getDevSerial());
  21. if(StringUtils.isBlank(wellId)) {
  22. logger.warn("动液面设备{}未找到对应井,取消入库",po.getDevSerial());
  23. return;
  24. }
  25. po.setWellId(wellId);
  26. GatherDataRepService repService=ApplicationContextUtils.getBean("gatherDataRepService", GatherDataRepService.class);
  27. repService.save(po);
  28. logger.info("动液面数据入库完成{}",po.getDevSerial());
  29. }
  30. catch(Exception e) {
  31. e.printStackTrace();
  32. logger.error("动液面数据转换、入库任务执行出现异常:{}",e.getMessage());
  33. }
  34. }
  35. }