|
|
@@ -79,6 +79,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.*;
|
|
|
@@ -1245,8 +1246,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(")) {
|
|
|
- String code = RegexUtil.findResult("(?<=weather\\(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()) {
|
|
|
@@ -1257,12 +1271,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 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 -> {
|
|
|
- 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")));
|
|
|
+ //将时间转化星期几
|
|
|
+ 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);
|
|
|
+ tec.constantMap.put("MAXTEMBYDATE", map2);
|
|
|
+ tec.constantMap.put("MINTEMBYDATE", map3);
|
|
|
+ tec.constantMap.put("WEEKBYDATE", map4);
|
|
|
+ tec.constantMap.put("MAXMINBYDATE", map5);
|
|
|
+ tec.constantMap.put("WEATHERTEM", map6);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -1279,7 +1332,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()) {
|
|
|
@@ -1549,6 +1602,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
} else {
|
|
|
putEle(f, ele, currentMap, fd);
|
|
|
+ //公式获取值
|
|
|
Object data = Expression.parse(formula.getFormula()).calculate(currentMap);
|
|
|
//如果有空串,也要加进data不然表格数据顺序会混乱
|
|
|
try {
|
|
|
@@ -1623,7 +1677,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ // 公式获取的数据 准备写入 准装 字段和值的关系
|
|
|
write(tec, fd, data);
|
|
|
}
|
|
|
/*错位计算偏移量重置*/
|
|
|
@@ -6151,6 +6205,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if(Objects.equals("≠",s1)){
|
|
|
s1 = "!=";
|
|
|
}
|
|
|
+ if(Objects.equals("=",s1)){
|
|
|
+ s1 = "==";
|
|
|
+ }
|
|
|
if(Objects.equals("<",s1)){
|
|
|
s1 = "<";
|
|
|
}
|
|
|
@@ -6284,8 +6341,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
/*设计值可以是数值类型,或空(等效0)*/
|
|
|
if (dataFd != null) {
|
|
|
List<Object> values = dataFd.getRawValue();
|
|
|
- /*保留小数位,去除*/
|
|
|
- values = values.stream().map(e -> StringUtils.number2StringZero(e,8)).collect(Collectors.toList());
|
|
|
//boolean nonNumeric = values.stream().filter(StringUtils::isNotEmpty).anyMatch(e -> !StringUtils.isNumber(e));
|
|
|
boolean nonNumeric = values.stream()
|
|
|
.filter(StringUtils::isNotEmpty)
|
|
|
@@ -6672,7 +6727,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public R<Object> evaluate(Long pkeyId) {
|
|
|
+ public R evaluate(Long pkeyId) {
|
|
|
if (StringUtils.isNumber(pkeyId)) {
|
|
|
/*节点信息*/
|
|
|
WtcEva wtcEva = this.getSqlOne(
|
|
|
@@ -6726,7 +6781,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
xm.setName(name);
|
|
|
xm.setSubItem(info.getTitle());
|
|
|
|
|
|
- if(name.contains("△")){
|
|
|
+ if(name.contains("△")||name.contains("Δ")){
|
|
|
xm.setWeight(2);
|
|
|
}else{
|
|
|
xm.setWeight(1);
|
|
|
@@ -6936,7 +6991,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- return R.data("暂无数据");
|
|
|
+ return R.fail("暂无数据");
|
|
|
}
|
|
|
}
|
|
|
return R.fail("无数据");
|
|
|
@@ -7008,6 +7063,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
return remap;
|
|
|
}
|
|
|
+
|
|
|
public Map<String, String> getWtpParent(String meterType, String projectId) {
|
|
|
Map<String, Object> map = this.jdbcTemplate.queryForMap("select id,wbs_id wbsId,CONCAT(ancestors_p_id,',',p_key_id) path from m_wbs_tree_private a where a.node_name=? and a.project_id=?", meterType, projectId);
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
@@ -7939,5 +7995,5 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
return wbsTreeContract;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|