|
@@ -5,6 +5,7 @@ import com.mixsmart.utils.ListUtils;
|
|
|
import com.mixsmart.utils.StringUtils;
|
|
|
import lombok.Data;
|
|
|
import org.springblade.business.feign.MileageClient;
|
|
|
+import org.springblade.common.utils.BaseUtils;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.manager.dto.ElementData;
|
|
|
import org.springblade.manager.dto.FormData;
|
|
@@ -26,13 +27,35 @@ import java.util.stream.Collectors;
|
|
|
public class FormulaMileage implements FormulaStrategy {
|
|
|
private FormData cur;
|
|
|
private final MileageClient mileageClient;
|
|
|
- public static final Pattern MILE_ARGS= Pattern.compile("(?<=MILE<)[^>]+(?=>)");
|
|
|
+ public static final Pattern MILE_ARGS= Pattern.compile("(?<=MILE\\()[^>]+(?=\\))");
|
|
|
+ public static final String ZH="桩号";
|
|
|
+ public static final String PW="偏位";
|
|
|
+ public static final String SJX="设计值X";
|
|
|
+ public static final String SJY="设计值Y";
|
|
|
+ public static final String SCX="实测值X";
|
|
|
+ public static final String SCY="实测值Y";
|
|
|
+ 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;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void execute(List<FormData> fds, Map<String,Object> constantMap) {
|
|
|
List<ElementData> eds = cur.getValues();
|
|
|
Map<String,String[]> mileages = getCoordinate(cur.getFormula().getFormula(),fds, Func.toLong(constantMap.get("contractId")));
|
|
|
if(ListUtils.isNotEmpty(eds)){
|
|
|
Matcher m= MILE_ARGS.matcher(cur.getCode());
|
|
|
+ String f= cur.getFormula().getFormula();
|
|
|
+ f=f.replace("MILE-","");
|
|
|
+ Map<String,String> keyMap = BaseUtils.string2Map(f);
|
|
|
+ if(keyMap.size()<MIN_ELE_SIZE){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String,FormData> mapFd=new HashMap<>(100);
|
|
|
+ keys.forEach(e->mapFd.put(e,fds.stream().filter(k->e.equals(k.getCode())).findFirst().orElseGet(null)));
|
|
|
+
|
|
|
if(m.find()){
|
|
|
String tmp =m.group();
|
|
|
tmp=tmp.replace("E[","").replace("]","");
|
|
@@ -51,7 +74,7 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
/*测点名称*/
|
|
|
List<ElementData> a = map.get(cp.get(0)).getValues();
|
|
|
/*编号*/
|
|
|
- List<ElementData> b = map.get(cp.get(2)).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);
|
|
@@ -59,10 +82,10 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
String k =ea.getValue().toString();
|
|
|
String jz=eb.getValue().toString();
|
|
|
String[] coordinate = mileages.get(k+"@"+jz);
|
|
|
- Map xyz = FormulaUtils.triangleSquare("-5,+5");
|
|
|
+ Map<String, Object> xyz = FormulaUtils.triangleSquare("-5,+5");
|
|
|
double dx = Double.parseDouble(xyz.get("X").toString());
|
|
|
double dy = Double.parseDouble(xyz.get("Y").toString());
|
|
|
- double dz = Double.parseDouble(xyz.get("Z").toString());
|
|
|
+ double ds = Double.parseDouble(xyz.get("Z").toString());
|
|
|
double scx= Double.parseDouble(coordinate[0]) + dx * 0.001;
|
|
|
double scy= Double.parseDouble(coordinate[1]) + dy * 0.001;
|
|
|
double sjx= Double.parseDouble(coordinate[0]);
|
|
@@ -70,25 +93,25 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
int index=ea.getIndex();
|
|
|
int groupId=ea.getGroupId();
|
|
|
/*实测x*/
|
|
|
- listFd.get(2).getValues().add(new ElementData(index,groupId,dx));
|
|
|
+ listFd.get(2).getValues().add(new ElementData(index,groupId,scx));
|
|
|
/*实测y*/
|
|
|
- listFd.get(3).getValues().add(new ElementData(index,groupId,dx));
|
|
|
+ listFd.get(3).getValues().add(new ElementData(index,groupId,scy));
|
|
|
/*设计x*/
|
|
|
- listFd.get(4).getValues().add(new ElementData(index,groupId,dx));
|
|
|
+ listFd.get(4).getValues().add(new ElementData(index,groupId,sjx));
|
|
|
/*设计x*/
|
|
|
- listFd.get(5).getValues().add(new ElementData(index,groupId,dx));
|
|
|
+ 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,dx));
|
|
|
+ listFd.get(7).getValues().add(new ElementData(index,groupId,dy));
|
|
|
/*设计ds*/
|
|
|
- listFd.get(8).getValues().add(new ElementData(index,groupId,dx));
|
|
|
+ listFd.get(8).getValues().add(new ElementData(index,groupId,ds));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
this.cur.getFormula().setFormula("");
|
|
|
}
|
|
|
- public static final Pattern MILE_P = Pattern.compile("(?<=MILE<)([^,]+),([^,]+)(?=,)");
|
|
|
+ public static final Pattern MILE_P = Pattern.compile("(?<=MILE\\()([^,]+),([^,]+)(?=,)");
|
|
|
|
|
|
public Map<String,String[]> getCoordinate(String tmp,List<FormData> fds,Long contractId){
|
|
|
Matcher mile=MILE_P.matcher(tmp);
|
|
@@ -129,6 +152,6 @@ public class FormulaMileage implements FormulaStrategy {
|
|
|
public boolean accept(FormData fd) {
|
|
|
this.cur=fd;
|
|
|
String f= fd.getFormula().getFormula();
|
|
|
- return StringUtils.isNotEmpty(f)&&f.startsWith("MILE<");
|
|
|
+ return StringUtils.isNotEmpty(f)&&f.startsWith("MILE-");
|
|
|
}
|
|
|
}
|