|
@@ -39,8 +39,8 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
public static final String DX="dx";
|
|
|
public static final String DY="dy";
|
|
|
public static final String DS="ds";
|
|
|
- public static final List<String> keys = new ArrayList<>(Arrays.asList(ZH,PW,SJX,SJY,SCX,SCY,DX,DY,DS));
|
|
|
- public static final int MIN_ELE_SIZE=9;
|
|
|
+ public static final List<String> KEYS = new ArrayList<>(Arrays.asList(ZH,PW,SJX,SJY,SCX,SCY,DX,DY,DS));
|
|
|
+ private List<String> relyList;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -50,10 +50,10 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
if(ListUtils.isNotEmpty(eds)&&!mileages.isEmpty()){
|
|
|
Matcher m= MILE_ARGS.matcher(cur.getFormula().getFormula());
|
|
|
if(m.find()){
|
|
|
- List<String> cp =cur.getFormula().getRelyList();
|
|
|
- Map<String,FormData> map = new LinkedHashMap<>();
|
|
|
+ this.relyList =cur.getFormula().getRelyList();
|
|
|
+ LinkedHashMap<String,FormData> map = new LinkedHashMap<>();
|
|
|
List<FormData> listFd = new ArrayList<>();
|
|
|
- cp.forEach(e->{
|
|
|
+ this.relyList.forEach(e->{
|
|
|
fds.forEach(k->{
|
|
|
if(e.equals(k.getCode())){
|
|
|
map.put(k.getCode(),k);
|
|
@@ -61,19 +61,19 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- if(listFd.size()<keys.size()){
|
|
|
+ if(listFd.size()<KEYS.size()){
|
|
|
return;
|
|
|
}
|
|
|
- /*测点名称*/
|
|
|
- List<ElementData> a = map.get(cp.get(0)).getValues();
|
|
|
- /*编号*/
|
|
|
- List<ElementData> b = map.get(cp.get(1)).getValues();
|
|
|
- int size=Math.min(a.size(),b.size());
|
|
|
- for(int i=0;i<size;i++){
|
|
|
- ElementData ea=a.get(i);
|
|
|
- ElementData eb=b.get(i);
|
|
|
- String k =ea.getValue().toString();
|
|
|
- String jz=eb.getValue().toString();
|
|
|
+ CompositeDataAccess cda = new CompositeDataAccess(map);
|
|
|
+ List<String> keys = KEYS.stream().skip(2).collect(Collectors.toList());
|
|
|
+ List<String> scale3=Arrays.asList(SJX,SJY,SCX,SCY);
|
|
|
+ while (cda.hasNext()){
|
|
|
+ LinkedHashMap<String,ElementData> row = cda.next();
|
|
|
+ /*桩号*/
|
|
|
+ ElementData ea=row.get(relyList.get(0));
|
|
|
+ /*偏距*/
|
|
|
+ String k = ea.stringValue();
|
|
|
+ String jz=row.get(relyList.get(1)).stringValue();
|
|
|
String[] coordinate = mileages.get(k+"@"+jz);
|
|
|
Map<String, Object> xyz = FormulaUtils.triangleSquare("-5,+5");
|
|
|
double dx = Double.parseDouble(xyz.get("X").toString());
|
|
@@ -83,22 +83,8 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
double scy= Double.parseDouble(coordinate[1]) + dy * 0.001;
|
|
|
double sjx= Double.parseDouble(coordinate[0]);
|
|
|
double sjy= Double.parseDouble(coordinate[1]);
|
|
|
- int index=ea.getIndex();
|
|
|
- int groupId=ea.getGroupId();
|
|
|
- /*实测x*/
|
|
|
- listFd.get(2).getValues().add(new ElementData(index,groupId,scx));
|
|
|
- /*实测y*/
|
|
|
- listFd.get(3).getValues().add(new ElementData(index,groupId,scy));
|
|
|
- /*设计x*/
|
|
|
- listFd.get(4).getValues().add(new ElementData(index,groupId,sjx));
|
|
|
- /*设计x*/
|
|
|
- listFd.get(5).getValues().add(new ElementData(index,groupId,sjy));
|
|
|
- /*设计dx*/
|
|
|
- listFd.get(6).getValues().add(new ElementData(index,groupId,dx));
|
|
|
- /*设计dy*/
|
|
|
- listFd.get(7).getValues().add(new ElementData(index,groupId,dy));
|
|
|
- /*设计ds*/
|
|
|
- listFd.get(8).getValues().add(new ElementData(index,groupId,ds));
|
|
|
+ List<Object> data = new ArrayList<>(Arrays.asList("占位","占位",sjx,sjy,scx,scy,dx,dy,ds));
|
|
|
+ this.write(row,data,keys,scale3);
|
|
|
}
|
|
|
listFd.forEach(e->e.setUpdate(1));
|
|
|
}
|
|
@@ -142,6 +128,44 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
return new HashMap<>(20);
|
|
|
}
|
|
|
|
|
|
+ public void write( LinkedHashMap<String,ElementData> row,List<Object>data,List<String> keys,List<String> scale3){
|
|
|
+ if(ListUtils.isNotEmpty(data)){
|
|
|
+ keys.forEach(k->{
|
|
|
+ ElementData elt = row.get(c(k));
|
|
|
+ /*这里只单纯写人内容,插入的其他属性在获取的时候已经准备好*/
|
|
|
+ if(elt.isEmpty()){
|
|
|
+ if(scale3.contains(k)){
|
|
|
+ elt.setValue(StringUtils.number2String(v(k,data),3));
|
|
|
+ }else{
|
|
|
+ elt.setValue(StringUtils.number2String(v(k,data),0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private String c(String name){
|
|
|
+ if(Func.isNotEmpty(name)&&Func.isNotEmpty(KEYS)){
|
|
|
+ int index= KEYS.indexOf(name);
|
|
|
+ if(index>=0){
|
|
|
+ return this.relyList.get(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Object v(String name,List<Object> data){
|
|
|
+ if(Func.isNotEmpty(name)&&ListUtils.isNotEmpty(data)){
|
|
|
+ int index= KEYS.indexOf(name);
|
|
|
+ if(index>=0){
|
|
|
+ return data.get(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public boolean accept(FormData fd) {
|
|
|
if(!fd.verify()){
|