|
|
@@ -37,6 +37,7 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -181,10 +182,13 @@ public class CommonService {
|
|
|
angleInRadians = deviceReference.getCurrentValue().doubleValue();
|
|
|
}
|
|
|
double cosValue = Math.cos(Math.toRadians(angleInRadians));;
|
|
|
- double doubleValue = subtract.divide(new BigDecimal("360"), 11, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ double doubleValue = subtract.divide(new BigDecimal("360"), 18, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
}
|
|
|
- return offsetValue;
|
|
|
+ double number = offsetValue.doubleValue();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
+ String result = decimalFormat.format(number);
|
|
|
+ return new BigDecimal(result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -198,7 +202,7 @@ public class CommonService {
|
|
|
public BigDecimal computeOriginalOffset(String value, String itemName, KwsDeviceReference deviceRelation) {
|
|
|
BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
if (DictItemEnum.ALTITUDE_Z.getValue().equals(itemName)) {
|
|
|
- offsetValue = new BigDecimal(value).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
+ offsetValue = new BigDecimal(value).divide(new BigDecimal(1000), 18, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
BigDecimal subtract = new BigDecimal(value).subtract((deviceRelation == null ? new BigDecimal("0.00") : deviceRelation.getOriginalValue()));
|
|
|
if (DictItemEnum.LATITUDE_Y.getValue().equals(itemName)) {
|
|
|
@@ -216,7 +220,7 @@ public class CommonService {
|
|
|
angleInRadians = deviceReference.getOriginalValue().doubleValue();
|
|
|
}
|
|
|
double cosValue = Math.cos(Math.toRadians(angleInRadians));
|
|
|
- double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ double doubleValue = subtract.divide(new BigDecimal("360"), 18, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
}
|
|
|
return offsetValue;
|
|
|
@@ -231,14 +235,19 @@ public class CommonService {
|
|
|
* @param deviceRelation
|
|
|
* @return
|
|
|
*/
|
|
|
- public BigDecimal getValueByOffset(String value, String itemName, KwsDeviceReference deviceRelation) {
|
|
|
+ public BigDecimal getValueByOffset(String value, String itemName, KwsDeviceReference deviceRelation,String snCode) {
|
|
|
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()));
|
|
|
+ SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, DictItemEnum.LATITUDE_Y.getValue());
|
|
|
+ String currentY = "0";
|
|
|
+ if (!Objects.isNull(slopeData)) {
|
|
|
+ currentY = slopeData.getVal();
|
|
|
+ }
|
|
|
+ offsetValue = new BigDecimal(currentY).subtract(new BigDecimal(value).divide(new BigDecimal(LATITUDE_REFERENCE), 18, BigDecimal.ROUND_HALF_UP));
|
|
|
}
|
|
|
double angleInRadians = 0;
|
|
|
if (DictItemEnum.LONGITUDE_X.getValue().equals(itemName)) {
|
|
|
@@ -254,8 +263,13 @@ public class CommonService {
|
|
|
double cosValue = Math.cos(Math.toRadians(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()));//加
|
|
|
+ BigDecimal xTmp = doubleValue.divide(offsetValue1, 18, BigDecimal.ROUND_HALF_UP);
|
|
|
+ SlopeData slopeData = slopeDataMapper.selectListByLine(snCode, DictItemEnum.LONGITUDE_X.getValue());
|
|
|
+ String currentX = "0";
|
|
|
+ if (!Objects.isNull(slopeData)) {
|
|
|
+ currentX = slopeData.getVal();
|
|
|
+ }
|
|
|
+ offsetValue = new BigDecimal(currentX).subtract(xTmp);//
|
|
|
}
|
|
|
return offsetValue;
|
|
|
}
|
|
|
@@ -287,7 +301,7 @@ public class CommonService {
|
|
|
double angleInRadians = Double.parseDouble(y.get(1).getVal());
|
|
|
double cosValue =Math.cos(Math.toRadians(angleInRadians));
|
|
|
|
|
|
- double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ double doubleValue = subtract.divide(new BigDecimal("360"), 18, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
}
|
|
|
if (DictItemEnum.LATITUDE_Y.getValue().equals(inter.getPartNames())) {
|
|
|
@@ -353,7 +367,7 @@ public class CommonService {
|
|
|
if (y.size() > 0) {
|
|
|
double angleInRadians = Double.parseDouble(y.get(0).getVal());
|
|
|
double cosValue = Math.cos(Math.toRadians(angleInRadians));
|
|
|
- double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ double doubleValue = subtract.divide(new BigDecimal("360"), 18, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
}
|
|
|
}
|