|
|
@@ -78,6 +78,7 @@ import java.io.*;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
@@ -1237,8 +1238,21 @@ 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(") || e.getFormula().getFormula().contains(".maxtembydate("))) {
|
|
|
- String code = RegexUtil.findResult("(?<=\\(E\\[')[^']+(?='\\],WEATHER\\))", e.getFormula().getFormula());
|
|
|
+ if (e.executable() && (e.getFormula().getFormula().contains(".weather(") //天气
|
|
|
+ || e.getFormula().getFormula().contains(".maxtembydate(") // 最大气温
|
|
|
+ || e.getFormula().getFormula().contains(".mintembydate(") // 最小气温
|
|
|
+ || e.getFormula().getFormula().contains(".maxminbydate(") //最大最小气温
|
|
|
+ || e.getFormula().getFormula().contains(".weathertem(") // 气温/天气
|
|
|
+ || e.getFormula().getFormula().contains(".weekbydate(") // 日期计算周几
|
|
|
+ )) {
|
|
|
+ String tyepData[] = new String[]{"WEATHER","MAXTEMBYDATE","MINTEMBYDATE","MAXMINBYDATE","WEATHERTEM","WEEKBYDATE"};
|
|
|
+ String code ="";
|
|
|
+ for (int i=0;i<tyepData.length;i++){
|
|
|
+ code = RegexUtil.findResult("(?<=\\(E\\[')[^']+(?='\\],"+tyepData[i]+"\\))", e.getFormula().getFormula());
|
|
|
+ if (code != null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (code != null) {
|
|
|
FormData formData = tec.getFormDataMap().get(code);
|
|
|
if (formData != null && !formData.empty()) {
|
|
|
@@ -1249,38 +1263,51 @@ 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,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("','")) + "')");
|
|
|
+ List<Map<String, Object>> listMap = this.jdbcTemplate.queryForList(" select DATE(b.record_time) ds,b.weather,temp_high as maxtembydate,temp_low as mintembydate,CONCAT_WS('~',temp_low,temp_high) as maxminbydate,CONCAT(b.weather,'、',temp_low,'℃~',temp_high,'℃') as weathertem 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> map2 = new HashMap<>();
|
|
|
+ //最低气温
|
|
|
+ Map<String, String> map3 = new HashMap<>();
|
|
|
//星期几
|
|
|
Map<String, String> map4 = new HashMap<>();
|
|
|
+ //最高最低气温
|
|
|
+ Map<String, String> map5 = new HashMap<>();
|
|
|
+ //气温 天气
|
|
|
+ Map<String, String> map6 = new HashMap<>();
|
|
|
listMap.forEach(m -> {
|
|
|
String ds = Func.toStr(m.get("ds"));
|
|
|
map.put(ds, Func.toStr(m.get("weather")));
|
|
|
//将时间转化星期几
|
|
|
+ if (StringUtils.isNotEmpty(ds)) {
|
|
|
+ Date datetime = null;
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ try {
|
|
|
+ datetime = dateFormat.parse(ds);
|
|
|
+ }catch (Exception e){
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+ String[] weekDays = {"日", "一", "二", "三", "四", "五", "六"};
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(datetime);
|
|
|
+ String week = weekDays[calendar.get(Calendar.DAY_OF_WEEK) - 1];
|
|
|
+ map4.put(ds, week);
|
|
|
+ }else {
|
|
|
+ map4.put(ds, "");
|
|
|
+ }
|
|
|
+ map2.put(ds, Func.toStr(m.get("maxtembydate")));
|
|
|
+ map3.put(ds, Func.toStr(m.get("mintembydate")));
|
|
|
+ map5.put(ds, Func.toStr(m.get("maxminbydate")));
|
|
|
+ map6.put(ds, Func.toStr(m.get("weathertem")));
|
|
|
});
|
|
|
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 );
|
|
|
-
|
|
|
+ tec.constantMap.put("WEEKBYDATE", map4);
|
|
|
+ tec.constantMap.put("MAXMINBYDATE", map5);
|
|
|
+ tec.constantMap.put("WEATHERTEM", map6);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|