|
@@ -1218,7 +1218,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
tec.formDataMap.putAll(baseMap);*/
|
|
|
/*通用计算*/
|
|
|
generalCalc(tec);
|
|
|
- if (ExecuteType.INSPECTION.equals(tec.getExecuteType())|| ExecuteType.LOGINFO.equals(tec.getExecuteType()) ) {
|
|
|
+ if (ExecuteType.INSPECTION.equals(tec.getExecuteType())) {
|
|
|
if (tec.isNew) {
|
|
|
//TODO
|
|
|
} else {
|
|
@@ -1237,8 +1237,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
try {
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
tec.formDataList.forEach(e -> {
|
|
|
- if (e.executable() && e.getFormula().getFormula().contains(".weather(")) {
|
|
|
- String code = RegexUtil.findResult("(?<=weather\\(E\\[')[^']+(?='\\],WEATHER\\))", e.getFormula().getFormula());
|
|
|
+ if (e.executable() && (e.getFormula().getFormula().contains(".weather(") || e.getFormula().getFormula().contains(".maxtembydate("))) {
|
|
|
+ String code = RegexUtil.findResult("(?<=\\(E\\[')[^']+(?='\\],WEATHER\\))", e.getFormula().getFormula());
|
|
|
if (code != null) {
|
|
|
FormData formData = tec.getFormDataMap().get(code);
|
|
|
if (formData != null && !formData.empty()) {
|
|
@@ -1249,12 +1249,38 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
});
|
|
|
if (dateList.size() > 0) {
|
|
|
- List<Map<String, Object>> listMap = this.jdbcTemplate.queryForList(" select DATE(b.record_time) ds,b.weather from m_project_contract_area a join u_weather_info b on a.id=contract_area_id where a.contract_id=" + tec.getContractId() + " and DATE(b.record_time) in('" + dateList.stream().distinct().collect(Collectors.joining("','")) + "')");
|
|
|
+ List<Map<String, Object>> listMap = this.jdbcTemplate.queryForList(" select DATE(b.record_time) ds,b.weather,temp_high as maxtembydate,temp_low as mintembydate from m_project_contract_area a join u_weather_info b on a.id=contract_area_id where a.contract_id=" + tec.getContractId() + " and DATE(b.record_time) in('" + dateList.stream().distinct().collect(Collectors.joining("','")) + "')");
|
|
|
+ // 天气
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ //星期几
|
|
|
+ Map<String, String> map4 = new HashMap<>();
|
|
|
listMap.forEach(m -> {
|
|
|
- map.put(Func.toStr(m.get("ds")), Func.toStr(m.get("weather")));
|
|
|
+ String ds = Func.toStr(m.get("ds"));
|
|
|
+ map.put(ds, Func.toStr(m.get("weather")));
|
|
|
+ //将时间转化星期几
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
tec.constantMap.put("WEATHER", map);
|
|
|
+
|
|
|
+ // 最高气温
|
|
|
+ Map<String, String> map2 = new HashMap<>();
|
|
|
+ listMap.forEach(m -> {
|
|
|
+ map2.put(Func.toStr(m.get("ds")), Func.toStr(m.get("maxtembydate")));
|
|
|
+ });
|
|
|
+ tec.constantMap.put("MAXTEMBYDATE", map2);
|
|
|
+
|
|
|
+ // 最低气温
|
|
|
+ Map<String, String> map3 = new HashMap<>();
|
|
|
+ listMap.forEach(m -> {
|
|
|
+ map3.put(Func.toStr(m.get("ds")), Func.toStr(m.get("mintembydate")));
|
|
|
+ });
|
|
|
+ tec.constantMap.put("MINTEMBYDATE", map3);
|
|
|
+
|
|
|
+ //星期几
|
|
|
+ tec.constantMap.put("MINTEMBYDATE", map4 );
|
|
|
+
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -1271,7 +1297,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
checkTable = op.get().getInitTableName();
|
|
|
}
|
|
|
for (FormData fd : tec.formDataList) {
|
|
|
- if(fd.getCode().equals("m_20230423154304_1650042591250481152:key_42")){
|
|
|
+ if(fd.getCode().equals("_20240528110420_1795289980302524416:key_8")){
|
|
|
System.out.println("111");
|
|
|
}
|
|
|
if (fd.verify()) {
|
|
@@ -1315,6 +1341,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
} else {
|
|
|
putEle(f, ele, currentMap, fd);
|
|
|
+ //公式获取值
|
|
|
Object data = Expression.parse(formula.getFormula()).calculate(currentMap);
|
|
|
//如果有空串,也要加进data不然表格数据顺序会混乱
|
|
|
try {
|
|
@@ -1389,7 +1416,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ // 公式获取的数据 准备写入 准装 字段和值的关系
|
|
|
write(tec, fd, data);
|
|
|
}
|
|
|
/*错位计算偏移量重置*/
|