package org.springnewfiber.dataadapter.ziguang.yl.dto; import com.google.common.collect.Maps; import lombok.Data; import org.springnewfiber.dataadapter.entity.MqNodeData; import org.springnewfiber.dataadapter.entity.PtReceiveBaseModel; import java.math.BigDecimal; import java.util.Date; import java.util.Map; /** * @program: newfiber-data-adapter * @description: 雨量dto * @author: djt * @create: 2022-01-19 09:38 **/ @Data public class YlDto { //站码 private String STCD; //站名 private String STNM; //降雨量 private Float DRP; // 常规水位 private Float MAXDRP; // 行政区划 private Float DSNM; // 最新监测时间啊 YYYY-MM-DD HH:mm:ss private Date TM; // 纬度 private Float LGTD; // 纬度 private Float LTTD; //序列 private String RR; private String BZ; private Float p1; private Float p3; private Float p6; private Float p12; private Float p24; private BigDecimal countPt=BigDecimal.ZERO; public static String one = "p1"; public static String Three = "p3"; public static String six = "p6"; public static String twelve = "p12"; public static String day = "p24"; public static String pt = "pt"; public static PtReceiveBaseModel convert(YlDto dto) { PtReceiveBaseModel model = new PtReceiveBaseModel(); model.setSt(dto.getSTCD()); model.setTt(dto.getTM()); model.setUt(new Date()); model.setSn(""); Map<String, MqNodeData> dataMap = Maps.newHashMap(); MqNodeData data = new MqNodeData(); data.setKey("drp"); data.setValue(dto.getDRP()); data.setSn("drp"); if (dto.getP1() != null) { MqNodeData p1 = new MqNodeData(); p1.setKey(YlDto.one); p1.setValue(dto.getP1()); p1.setSn(YlDto.one); dataMap.put(YlDto.one, p1); } if (dto.getP3() != null) { MqNodeData p1 = new MqNodeData(); p1.setKey(YlDto.Three); p1.setValue(dto.getP3()); p1.setSn(YlDto.Three); dataMap.put(YlDto.Three, p1); } if (dto.getP6() != null) { MqNodeData p1 = new MqNodeData(); p1.setKey(YlDto.six); p1.setValue(dto.getP6()); p1.setSn(YlDto.six); dataMap.put(YlDto.six, p1); } if (dto.getP12() != null) { MqNodeData p1 = new MqNodeData(); p1.setKey(YlDto.twelve); p1.setValue(dto.getP12()); p1.setSn(YlDto.twelve); dataMap.put(YlDto.twelve, p1); } if (dto.getP24() != null) { MqNodeData p1 = new MqNodeData(); p1.setKey(YlDto.day); p1.setValue(dto.getP24()); p1.setSn(YlDto.day); dataMap.put(YlDto.day, p1); } if (dto.getCountPt() != null) { MqNodeData p1 = new MqNodeData(); p1.setKey(YlDto.pt); p1.setValue(dto.getCountPt()); p1.setSn(YlDto.pt); dataMap.put(YlDto.pt, p1); } dataMap.put("drp", data); model.setDataMap(dataMap); return model; } /** * 累计count * * @param size * @param dto * @param countBig */ public void setCountBig(int size, YlDto dto, BigDecimal countBig) { if (size == 60 / 5) { dto.setP1(countBig.floatValue()); } else if (size == 60 * 3 / 5) { dto.setP3(countBig.floatValue()); } else if (size == 60 * 6 / 5) { dto.setP6(countBig.floatValue()); } else if (size == 60 * 12 / 5) { dto.setP12(countBig.floatValue()); } else if (size == 60 * 24 / 5) { dto.setP24(countBig.floatValue()); } } }