|
|
|
@ -21,6 +21,7 @@ import org.springframework.context.ApplicationContext; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
|
|
|
|
|
|
|
|
@ -176,14 +177,45 @@ public class EleProtocolStrategy implements ProtocolStrategy { |
|
|
|
public void analysisMeterOrder485(final String dataStr, final DeviceCodeParamEntity deviceCodeParam) { |
|
|
|
public void analysisMeterOrder485(final String dataStr, final DeviceCodeParamEntity deviceCodeParam) { |
|
|
|
// threadPoolService.execute(() -> {
|
|
|
|
// threadPoolService.execute(() -> {
|
|
|
|
Date date = new Date(); |
|
|
|
Date date = new Date(); |
|
|
|
String dateStr = sdf1.format(date); |
|
|
|
// 使用Calendar进行更安全的时间处理
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
|
|
|
|
cal.setTime(date); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:05:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 0); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:05:00", "00:10:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 5); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:10:00", "00:15:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 10); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:15:00", "00:20:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 15); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:20:00", "00:25:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 20); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:25:00", "00:30:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 25); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:30:00", "00:35:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 30); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:35:00", "00:40:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 35); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:40:00", "00:45:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 40); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:45:00", "00:50:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 45); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:50:00", "00:55:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 50); |
|
|
|
|
|
|
|
} else if (ExchangeStringUtil.isInDate(date, "00:55:00", "00:59:00")) { |
|
|
|
|
|
|
|
cal.set(Calendar.MINUTE, 55); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cal.set(Calendar.SECOND, 0); |
|
|
|
|
|
|
|
cal.set(Calendar.MILLISECOND, 0); |
|
|
|
|
|
|
|
date = cal.getTime(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
DataResultEntity dataResultEntity = new DataResultEntity(); |
|
|
|
DataResultEntity dataResultEntity = new DataResultEntity(); |
|
|
|
dataResultEntity.setDeviceAddr(deviceCodeParam.getDeviceAddr()); //通讯编号
|
|
|
|
dataResultEntity.setDeviceAddr(deviceCodeParam.getDeviceAddr()); //通讯编号
|
|
|
|
dataResultEntity.setDeviceType(deviceCodeParam.getDeviceType()); //类型
|
|
|
|
dataResultEntity.setDeviceType(deviceCodeParam.getDeviceType()); //类型
|
|
|
|
dataResultEntity.setProjectId(deviceCodeParam.getProjectId()); //所属项目
|
|
|
|
dataResultEntity.setProjectId(deviceCodeParam.getProjectId()); //所属项目
|
|
|
|
dataResultEntity.setCurValue(new BigDecimal(dataStr)); //当前读数
|
|
|
|
dataResultEntity.setCurValue(new BigDecimal(dataStr)); //当前读数
|
|
|
|
dataResultEntity.setCurDate(sdf1.parse(dateStr)); //当前日期
|
|
|
|
dataResultEntity.setCurDate(date); //当前日期
|
|
|
|
dataResultEntity.setGrade(deviceCodeParam.getGrade()); |
|
|
|
dataResultEntity.setGrade(deviceCodeParam.getGrade()); |
|
|
|
dataResultEntity.setRegisterAddr(deviceCodeParam.getRegisterAddr()); |
|
|
|
dataResultEntity.setRegisterAddr(deviceCodeParam.getRegisterAddr()); |
|
|
|
dataResultEntity.setRegisterName(deviceCodeParam.getRegisterName()); |
|
|
|
dataResultEntity.setRegisterName(deviceCodeParam.getRegisterName()); |
|
|
|
|