|
|
@@ -147,6 +147,43 @@ public class CommonService {
|
|
|
return offsetValue;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据偏移量,返回测量值
|
|
|
+ *
|
|
|
+ * @param value
|
|
|
+ * @param itemName
|
|
|
+ * @param deviceRelation
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal getValueByOffset(String value, String itemName, KwsDeviceReference deviceRelation) {
|
|
|
+ BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
+ if (DictItemEnum.ALTITUDE_Z.getValue().equals(itemName)) {
|
|
|
+ offsetValue = new BigDecimal(value).multiply(new BigDecimal(1000));
|
|
|
+ }
|
|
|
+ //BigDecimal subtract = new BigDecimal(value).subtract((deviceRelation == null ? new BigDecimal("0.00") : deviceRelation.getCurrentValue()));
|
|
|
+ if (DictItemEnum.LATITUDE_Y.getValue().equals(itemName)) {
|
|
|
+ offsetValue = new BigDecimal(value).divide(new BigDecimal(equatorial_circumference)).add(new BigDecimal(deviceRelation.getCurrentValue().toString()));
|
|
|
+ }
|
|
|
+ double angleInRadians = 0;
|
|
|
+ if (DictItemEnum.LONGITUDE_X.getValue().equals(itemName)) {
|
|
|
+ KwsDeviceReference deviceReference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceRelation.getDeviceId())
|
|
|
+ .eq(KwsDeviceReference::getType, NumberConstant.ONE)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
+ .eq(KwsDeviceReference::getItem, DictItemEnum.LATITUDE_Y.getValue())
|
|
|
+ );
|
|
|
+ if (deviceReference != null) {
|
|
|
+ angleInRadians = deviceReference.getCurrentValue().doubleValue();
|
|
|
+ }
|
|
|
+ double cosValue = Math.cos(angleInRadians);
|
|
|
+ BigDecimal doubleValue = new BigDecimal(value).multiply(new BigDecimal(360));//offset*360
|
|
|
+ BigDecimal offsetValue1 = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue));// L*cos(A)
|
|
|
+ BigDecimal xTmp = doubleValue.divide(offsetValue1, 9, BigDecimal.ROUND_HALF_UP);//除法
|
|
|
+ offsetValue = xTmp.add(new BigDecimal(deviceRelation.getCurrentValue().toString()));//加
|
|
|
+ }
|
|
|
+ return offsetValue;
|
|
|
+ }
|
|
|
+
|
|
|
public int insertLog(MessageLogEnum messageLogEnum, HeaderData headerData, Map<String, Object> logMap, Long operationBy) {
|
|
|
String content = com.sckw.core.utils.StringUtils.replaceTextVar(messageLogEnum.getContent(), logMap);
|
|
|
KwsLog log = new KwsLog();
|