|
@@ -31,12 +31,11 @@ import static org.springblade.manager.formula.TurnPoint.*;
|
|
|
*/
|
|
|
@Component
|
|
|
@Data
|
|
|
-@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
|
|
public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
public static final String TURN_REG = "(?<=T\\(com.mixsmart.utils.CustomFunction\\).TURNPOINT\\()([^)]+)(?=\\))";
|
|
|
- private FormData cur;
|
|
|
+// private FormData cur;
|
|
|
static final List<String> KEYS;
|
|
|
- private List<String> args;
|
|
|
+// private List<String> args;
|
|
|
/**从节点参数获取G8偏差范围的公式脚本*/
|
|
|
static final String F_DEV="WP['g8pcfw']";
|
|
|
|
|
@@ -45,12 +44,13 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void execute(TableElementConverter tec) {
|
|
|
+ public void execute(FormData cur,TableElementConverter tec) {
|
|
|
cur.setFinished(Boolean.TRUE);
|
|
|
LinkedHashMap<String, FormData> dataSourceMap = new LinkedHashMap<>();
|
|
|
String funArgs = ReUtil.getGroup1(TURN_REG, cur.getFormula().getFormula());
|
|
|
+ List<String> args=new ArrayList<>();
|
|
|
if (StringUtils.isNotEmpty(funArgs)) {
|
|
|
- this.args = new ArrayList<>(Arrays.asList(funArgs.split(",")));
|
|
|
+ args = new ArrayList<>(Arrays.asList(funArgs.split(",")));
|
|
|
args = args.stream().map(k -> k.replaceAll("[(E\\[)'\\]]", "")).collect(Collectors.toList());
|
|
|
}
|
|
|
if (Func.isNotEmpty(args)) {
|
|
@@ -67,10 +67,10 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
/*用来映射元素*/
|
|
|
LinkedHashMap<String, String> configMap = new LinkedHashMap<>(KEYS.size() * 2);
|
|
|
for (int i = 0; i < KEYS.size(); i++) {
|
|
|
- configMap.put(KEYS.get(i), this.args.get(i));
|
|
|
+ configMap.put(KEYS.get(i), args.get(i));
|
|
|
}
|
|
|
/*原始数据转ListMap*/
|
|
|
- List<Map<String, Object>> tableData=listMaps( tec, dataSourceMap,configMap);
|
|
|
+ List<Map<String, Object>> tableData=listMaps( cur,tec, dataSourceMap,configMap,args);
|
|
|
/*数据分组*/
|
|
|
List<List<Map<String, Object>>> total = group(tableData);
|
|
|
/* 分组计算*/
|
|
@@ -78,7 +78,7 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
/*附加属性如:顶面和底面高程判断*/
|
|
|
forG8(result.stream().flatMap(Collection::stream).collect(Collectors.toList()), (Map<String, Object>)tec.getConstantMap().computeIfAbsent("G8", k -> new HashMap<>()),tec);
|
|
|
/*插值分页*/
|
|
|
- List<Object> data = paginate(result,configMap);
|
|
|
+ List<Object> data = paginate(cur,result,configMap);
|
|
|
/*数据回写*/
|
|
|
write(data,dataSourceMap,configMap.size());
|
|
|
|
|
@@ -86,7 +86,7 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<Object> paginate( List<List<TurnPoint>> result,LinkedHashMap<String, String> configMap){
|
|
|
+ public List<Object> paginate( FormData cur,List<List<TurnPoint>> result,LinkedHashMap<String, String> configMap){
|
|
|
int rowSize= cur.getCoordsList().size();
|
|
|
List<Object> data = new ArrayList<>();
|
|
|
for(List<TurnPoint> turnPoints:result){
|
|
@@ -99,7 +99,7 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
- private List<Map<String, Object>> listMaps(TableElementConverter tec,LinkedHashMap<String, FormData> dataSourceMap,LinkedHashMap<String, String> configMap){
|
|
|
+ private List<Map<String, Object>> listMaps(FormData cur,TableElementConverter tec,LinkedHashMap<String, FormData> dataSourceMap,LinkedHashMap<String, String> configMap,List<String> args){
|
|
|
CompositeDataAccess cda = new CompositeDataAccess(dataSourceMap);
|
|
|
List<Map<String, Object>> tableData = new ArrayList<>();
|
|
|
List<Long> tableInfoIds = tec.getKeyMappers().stream().filter(k -> k.getTableName().equals(cur.getTableName())).map(KeyMapper::getPkId).distinct().collect(Collectors.toList());
|
|
@@ -107,7 +107,7 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
LinkedHashMap<String, ElementData> map = cda.next();
|
|
|
Map<String, Object> tmp = new HashMap<>(16);
|
|
|
KEYS.forEach(k -> {
|
|
|
- ElementData ed = map.get(c(k));
|
|
|
+ ElementData ed = map.get(c(k,args));
|
|
|
tmp.put(configMap.get(k), ed.stringValue());
|
|
|
/*V判断*/
|
|
|
if (CD.equals(k)) {
|
|
@@ -228,8 +228,8 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private String c(String name) {
|
|
|
- if (Func.isNotEmpty(name) && Func.isNotEmpty(this.args)) {
|
|
|
+ private String c(String name,List<String> args) {
|
|
|
+ if (Func.isNotEmpty(name) && Func.isNotEmpty(args)) {
|
|
|
int index = KEYS.indexOf(name);
|
|
|
if (index < args.size()) {
|
|
|
return args.get(index);
|
|
@@ -240,7 +240,6 @@ public class FormulaTurnPoint implements FormulaStrategy {
|
|
|
|
|
|
@Override
|
|
|
public boolean accept(FormData fd) {
|
|
|
- this.cur = fd;
|
|
|
Formula f = fd.getFormula();
|
|
|
return StringUtils.isEquals(f.getNumber(), "TURN_POINT");
|
|
|
}
|