|
@@ -1,6 +1,7 @@
|
|
package org.springblade.manager.service.impl;
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.util.HashUtil;
|
|
import cn.hutool.core.util.HashUtil;
|
|
import cn.hutool.log.StaticLog;
|
|
import cn.hutool.log.StaticLog;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -73,6 +74,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
private Map<String,FormData> formDataMap;
|
|
private Map<String,FormData> formDataMap;
|
|
private Map<String,Map<String,Object>> tableDataMaps;
|
|
private Map<String,Map<String,Object>> tableDataMaps;
|
|
|
|
|
|
|
|
+ private List<FormData> checkItems;
|
|
|
|
+ private List<FormData> checkDate;
|
|
|
|
+ private List<FormData> summary;
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
public final static String WP="WP";
|
|
public final static String WP="WP";
|
|
@@ -109,6 +114,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public IFormulaService init() {
|
|
public IFormulaService init() {
|
|
|
|
+ this.checkItems= new ArrayList<>();
|
|
|
|
+ this.checkDate= new ArrayList<>();
|
|
|
|
+ this.summary = new ArrayList<>();
|
|
this.tableDataMaps=this.tec.getTableDataMaps();
|
|
this.tableDataMaps=this.tec.getTableDataMaps();
|
|
this.formDataMap=this.tec.getFormDataMap();
|
|
this.formDataMap=this.tec.getFormDataMap();
|
|
List<FormData> list =this.tec.getFds();
|
|
List<FormData> list =this.tec.getFds();
|
|
@@ -145,16 +153,16 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
this.constantMap.put("tableNames",tableList.stream().filter(e->StringUtils.isEquals(e.getIsBussShow(),1)).map(WbsTreeContract::getNodeName).collect(Collectors.toList()));
|
|
this.constantMap.put("tableNames",tableList.stream().filter(e->StringUtils.isEquals(e.getIsBussShow(),1)).map(WbsTreeContract::getNodeName).collect(Collectors.toList()));
|
|
/*检查是否有跨节点数据*/
|
|
/*检查是否有跨节点数据*/
|
|
/*获取type=1的检验单或者type=4的监表*/
|
|
/*获取type=1的检验单或者type=4的监表*/
|
|
- List<Map<String,Object>> inspectionElementMaps = new ArrayList<>();
|
|
|
|
- Optional<AppWbsTreeContractVO> wop=tableList.stream().filter(e->e.getNodeName().contains("检验单")).findAny();
|
|
|
|
- if(wop.isPresent()){
|
|
|
|
- /*检验单或者监表的*/
|
|
|
|
- inspectionElementMaps= this.jdbcTemplate.queryForList(" select c.e_name name ,b.tab_en_name tableName,c.e_key ekey from m_wbs_tree_contract a join m_table_info b on a.init_table_name=b.tab_en_name join m_wbs_form_element c on c.f_id= b.id where a.p_key_id=" + wop.get().getPKeyId());
|
|
|
|
- }
|
|
|
|
|
|
+// List<Map<String,Object>> inspectionElementMaps = new ArrayList<>();
|
|
|
|
+// Optional<AppWbsTreeContractVO> wop=tableList.stream().filter(e->e.getNodeName().contains("检验单")).findAny();
|
|
|
|
+// if(wop.isPresent()){
|
|
|
|
+// /*检验单或者监表的*/
|
|
|
|
+// inspectionElementMaps= this.jdbcTemplate.queryForList(" select c.e_name name ,b.tab_en_name tableName,c.e_key ekey from m_wbs_tree_contract a join m_table_info b on a.init_table_name=b.tab_en_name join m_wbs_form_element c on c.f_id= b.id where a.p_key_id=" + wop.get().getPKeyId());
|
|
|
|
+// }
|
|
List<String> missingList = new ArrayList<>();
|
|
List<String> missingList = new ArrayList<>();
|
|
- List<Map<String, Object>> finalInspectionElementMaps = inspectionElementMaps;
|
|
|
|
- List<String> cki =new ArrayList<>();
|
|
|
|
- AtomicReference<String> ckd= new AtomicReference<>("");
|
|
|
|
|
|
+// List<Map<String, Object>> finalInspectionElementMaps = inspectionElementMaps;
|
|
|
|
+// List<String> cki =new ArrayList<>();
|
|
|
|
+// AtomicReference<String> ckd= new AtomicReference<>("");
|
|
this.formDataList.forEach(fd->{
|
|
this.formDataList.forEach(fd->{
|
|
if(fd.executable()){
|
|
if(fd.executable()){
|
|
relyParse(fd.getFormula());
|
|
relyParse(fd.getFormula());
|
|
@@ -167,31 +175,31 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- if(StringUtils.isEquals("CKI",f.getNumber())){
|
|
|
|
- finalInspectionElementMaps.forEach(m->{
|
|
|
|
- String name = StringUtils.handleNull(m.get("name"));
|
|
|
|
- if(name.contains("实测值")&&name.contains("偏差值")){
|
|
|
|
- String ekey = StringUtils.handleNull(m.get("tableName"))+":"+StringUtils.handleNull(m.get("ekey"));
|
|
|
|
- cki.add(ekey);
|
|
|
|
- if(this.formDataMap.values().stream().map(FormData::getCode).noneMatch(k->StringUtils.isEquals(k,ekey))){
|
|
|
|
- missingList.add(ekey);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- f.setFormula("CKI");
|
|
|
|
- }else if(StringUtils.isEquals("CKD",f.getNumber())){
|
|
|
|
- finalInspectionElementMaps.forEach(m->{
|
|
|
|
- String name = StringUtils.handleNull(m.get("name"));
|
|
|
|
- if(name.contains("检验日期")){
|
|
|
|
- String ekey = StringUtils.handleNull(m.get("tableName"))+":"+StringUtils.handleNull(m.get("ekey"));
|
|
|
|
- ckd.set(ekey);
|
|
|
|
- if(!this.formDataMap.containsKey(ekey)&&this.formDataMap.values().stream().map(FormData::getCode).noneMatch(k->StringUtils.isEquals(k,ekey))){
|
|
|
|
- missingList.add(ekey);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- f.setFormula("CKD");
|
|
|
|
- }
|
|
|
|
|
|
+// if(StringUtils.isEquals("CKI",f.getNumber())){
|
|
|
|
+// finalInspectionElementMaps.forEach(m->{
|
|
|
|
+// String name = StringUtils.handleNull(m.get("name"));
|
|
|
|
+// if(name.contains("实测值")&&name.contains("偏差值")){
|
|
|
|
+// String ekey = StringUtils.handleNull(m.get("tableName"))+":"+StringUtils.handleNull(m.get("ekey"));
|
|
|
|
+// cki.add(ekey);
|
|
|
|
+// if(this.formDataMap.values().stream().map(FormData::getCode).noneMatch(k->StringUtils.isEquals(k,ekey))){
|
|
|
|
+// missingList.add(ekey);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// f.setFormula("CKI");
|
|
|
|
+// }else if(StringUtils.isEquals("CKD",f.getNumber())){
|
|
|
|
+// finalInspectionElementMaps.forEach(m->{
|
|
|
|
+// String name = StringUtils.handleNull(m.get("name"));
|
|
|
|
+// if(name.contains("检验日期")){
|
|
|
|
+// String ekey = StringUtils.handleNull(m.get("tableName"))+":"+StringUtils.handleNull(m.get("ekey"));
|
|
|
|
+// ckd.set(ekey);
|
|
|
|
+// if(!this.formDataMap.containsKey(ekey)&&this.formDataMap.values().stream().map(FormData::getCode).noneMatch(k->StringUtils.isEquals(k,ekey))){
|
|
|
|
+// missingList.add(ekey);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// f.setFormula("CKD");
|
|
|
|
+// }
|
|
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -200,26 +208,26 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
if(Func.isNotEmpty(missingList)){
|
|
if(Func.isNotEmpty(missingList)){
|
|
this.tec.getLog().append("【没有能加载的跨节点数据:").append(missingList.stream().map(e->e.replaceAll("'","")).collect(Collectors.joining(","))).append("】");
|
|
this.tec.getLog().append("【没有能加载的跨节点数据:").append(missingList.stream().map(e->e.replaceAll("'","")).collect(Collectors.joining(","))).append("】");
|
|
}
|
|
}
|
|
- if(Func.isNotEmpty(cki)){
|
|
|
|
- /*检验内容*/
|
|
|
|
- List<String> sb = new ArrayList<>();
|
|
|
|
- for(String s:cki){
|
|
|
|
- FormData fdTmp=this.formDataMap.get(s);
|
|
|
|
- if(fdTmp!=null&&fdTmp.getValues().stream().map(ElementData::getValue).anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isNotEquals("/",e))){
|
|
|
|
- sb.add(FormulaUtils.parseItemName(fdTmp.getEName()));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(sb.size()>0){
|
|
|
|
- this.constantMap.put(CHECK_ITEMS,sb.stream().distinct().filter(StringUtils::isNotEmpty).collect(Collectors.joining(",")));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(Func.isNotBlank(ckd.get())){
|
|
|
|
- /*检验时间*/
|
|
|
|
- FormData fdTmp = this.formDataMap.get(ckd.get());
|
|
|
|
- if(fdTmp!=null){
|
|
|
|
- this.constantMap.put("CKD",fdTmp.getValues().stream().map(ElementData::stringValue).collect(Collectors.joining(",")));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// if(Func.isNotEmpty(cki)){
|
|
|
|
+// /*检验内容*/
|
|
|
|
+// List<String> sb = new ArrayList<>();
|
|
|
|
+// for(String s:cki){
|
|
|
|
+// FormData fdTmp=this.formDataMap.get(s);
|
|
|
|
+// if(fdTmp!=null&&fdTmp.getValues().stream().map(ElementData::getValue).anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isNotEquals("/",e))){
|
|
|
|
+// sb.add(FormulaUtils.parseItemName(fdTmp.getEName()));
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if(sb.size()>0){
|
|
|
|
+// this.constantMap.put(CHECK_ITEMS,sb.stream().distinct().filter(StringUtils::isNotEmpty).collect(Collectors.joining(",")));
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if(Func.isNotBlank(ckd.get())){
|
|
|
|
+// /*检验时间*/
|
|
|
|
+// FormData fdTmp = this.formDataMap.get(ckd.get());
|
|
|
|
+// if(fdTmp!=null){
|
|
|
|
+// this.constantMap.put("CKD",fdTmp.getValues().stream().map(ElementData::stringValue).collect(Collectors.joining(",")));
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
|
|
/*实测值参数*/
|
|
/*实测值参数*/
|
|
List<Map<String,Object>> textInfoMap= this.jdbcTemplate.queryForList("SELECT b.tab_id pkId,b.col_name val ,CONCAT(a.init_table_name,':',b.col_key)code from m_wbs_tree_contract a inner join m_textdict_info b on a.p_key_id=b.tab_id " +
|
|
List<Map<String,Object>> textInfoMap= this.jdbcTemplate.queryForList("SELECT b.tab_id pkId,b.col_name val ,CONCAT(a.init_table_name,':',b.col_key)code from m_wbs_tree_contract a inner join m_textdict_info b on a.p_key_id=b.tab_id " +
|
|
@@ -433,9 +441,45 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
/*初始化排序值,每个点间隔1000,方便插入*/
|
|
/*初始化排序值,每个点间隔1000,方便插入*/
|
|
AtomicInteger sort= new AtomicInteger();
|
|
AtomicInteger sort= new AtomicInteger();
|
|
this.formDataList.forEach(e->e.setSort(sort.getAndAdd(1000)));
|
|
this.formDataList.forEach(e->e.setSort(sort.getAndAdd(1000)));
|
|
|
|
+ /*汇总阶段执行的公式*/
|
|
|
|
+ summaryPre();
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*汇总阶段执行的公式*/
|
|
|
|
+ public void summaryPre(){
|
|
|
|
+ this.formDataList.stream().filter(e->StringUtils.isEquals("CKI",e.getFormula().getNumber())||StringUtils.isEquals("CKD",e.getFormula().getNumber())).forEach(t->this.summary.add(t));
|
|
|
|
+ this.formDataList.removeAll(this.summary);
|
|
|
|
+ /*监表的处理*/
|
|
|
|
+ Optional<AppWbsTreeContractVO> aop=tec.getTableAll().stream().filter(e->e.getNodeName().contains("A15")).findAny();
|
|
|
|
+ if(aop.isPresent()){
|
|
|
|
+ /*存在监表,则需要收集检查项目和检查时间等元素*/
|
|
|
|
+ Optional<AppWbsTreeContractVO> wop=tec.getTableAll().stream().filter(e->e.getNodeName().contains("检验单")||e.getNodeName().contains("检验表")).findAny();
|
|
|
|
+ if(wop.isPresent()){
|
|
|
|
+ /*存在检验表*/
|
|
|
|
+ tec.getKeyMappers().stream().filter(e->StringUtils.isEquals(wop.get().getInitTableName(),e.getTableName())&&this.formDataMap.containsKey(e.getCode())).forEach(k->{
|
|
|
|
+ if(k.getEName().contains("实测值")&&k.getEName().contains("偏差值")){
|
|
|
|
+ this.checkItems.add(this.formDataMap.get(k.getCode()));
|
|
|
|
+ }else if(k.getEName().contains("检验日期")){
|
|
|
|
+ this.checkDate.add(this.formDataMap.get(k.getCode()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ /*不存在检验表的的情况则获取记录表*/
|
|
|
|
+ List<String> recordTable=tec.getTableAll().stream().filter(e->StringUtils.isEquals(2,e.getTableType())).map(AppWbsTreeContractVO::getInitTableName).distinct().collect(Collectors.toList());
|
|
|
|
+ tec.getKeyMappers().stream().filter(k->recordTable.contains(k.getTableName())).map(k->k.getCode()+"@"+k.getEName()).distinct().forEach(k->{
|
|
|
|
+ String[] ka=k.split("@");
|
|
|
|
+ if(ka[1].contains("实测值")){
|
|
|
|
+ this.checkItems.add(this.formDataMap.get(ka[0]));
|
|
|
|
+ }else if(ka[1].contains("日期")||ka[1].contains("年月日")){
|
|
|
|
+ this.checkDate.add(this.formDataMap.get(ka[0]));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public IFormulaService pre() {
|
|
public IFormulaService pre() {
|
|
if(CollectionUtil.isNotEmpty(this.formDataList)){
|
|
if(CollectionUtil.isNotEmpty(this.formDataList)){
|
|
@@ -497,6 +541,17 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public IFormulaService calculate() {
|
|
public IFormulaService calculate() {
|
|
|
|
+ /*通用计算*/
|
|
|
|
+ generalCalc();
|
|
|
|
+ /*汇总信息处理*/
|
|
|
|
+ summaryCalc();
|
|
|
|
+ /*附表的处理*/
|
|
|
|
+ forSubTb();
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**通用计算*/
|
|
|
|
+ public void generalCalc(){
|
|
for(FormData fd:this.formDataList){
|
|
for(FormData fd:this.formDataList){
|
|
if(fd.verify()){
|
|
if(fd.verify()){
|
|
Formula formula =fd.getFormula();
|
|
Formula formula =fd.getFormula();
|
|
@@ -521,16 +576,16 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
if(fd.getCoordsList().size()>1&&f.split("[/+\\-*]").length>1){
|
|
if(fd.getCoordsList().size()>1&&f.split("[/+\\-*]").length>1){
|
|
LinkedHashMap<String,FormData> fdMap =new LinkedHashMap<>();
|
|
LinkedHashMap<String,FormData> fdMap =new LinkedHashMap<>();
|
|
- Optional<FormData> tto= ele.stream().max(Comparator.comparingInt(fe->fe.getValues().size()));
|
|
|
|
- Optional<FormData> tts= ele.stream().min(Comparator.comparingInt(fe->fe.getValues().size()));
|
|
|
|
- if(tto.isPresent()&&tts.isPresent()){
|
|
|
|
- if(tto.get().getValues().size()!=tts.get().getValues().size()){
|
|
|
|
- int baseLength=tto.get().getValues().size();
|
|
|
|
- ele.forEach(e->{
|
|
|
|
- e.setStep(baseLength/e.getValues().size());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Optional<FormData> tto= ele.stream().max(Comparator.comparingInt(fe->fe.getValues().size()));
|
|
|
|
+ Optional<FormData> tts= ele.stream().min(Comparator.comparingInt(fe->fe.getValues().size()));
|
|
|
|
+ if(tto.isPresent()&&tts.isPresent()){
|
|
|
|
+ if(tto.get().getValues().size()!=tts.get().getValues().size()){
|
|
|
|
+ int baseLength=tto.get().getValues().size();
|
|
|
|
+ ele.forEach(e->{
|
|
|
|
+ e.setStep(baseLength/e.getValues().size());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
ele.forEach(e->{
|
|
ele.forEach(e->{
|
|
fdMap.put(e.getCode(),e);
|
|
fdMap.put(e.getCode(),e);
|
|
});
|
|
});
|
|
@@ -577,129 +632,147 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
fd.setUpdate(1);
|
|
fd.setUpdate(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-/*###############################附表的处理##################################*/
|
|
|
|
- if(true) {//临时开关,稳定后移除
|
|
|
|
- try {
|
|
|
|
- /*检验单附表处理*/
|
|
|
|
- List<FormData> inspectionList = new ArrayList<>();
|
|
|
|
- this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("检验单") || e.getNodeName().contains("评定表")).forEach(e -> {
|
|
|
|
- /*获取所有挂在表里的元素映射关系*/
|
|
|
|
- this.tec.getKeyMappers().stream().filter(p -> p.getPkId().equals(e.getPKeyId())).forEach(k -> {
|
|
|
|
- /*元素长度筛选超页的元素*/
|
|
|
|
- List<FormData> target = this.formDataMap.values().stream().filter(f -> f.getCode().equals(k.getCode()) && f.getAddPages() > 0).collect(Collectors.toList());
|
|
|
|
- if (Func.isNotEmpty(target)) {
|
|
|
|
- inspectionList.addAll(target);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+ /**附表处理*/
|
|
|
|
+ public void forSubTb(){
|
|
|
|
+ try {
|
|
|
|
+ /*检验单附表处理*/
|
|
|
|
+ List<FormData> inspectionList = new ArrayList<>();
|
|
|
|
+ this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("检验单") || e.getNodeName().contains("评定表")).forEach(e -> {
|
|
|
|
+ /*获取所有挂在表里的元素映射关系*/
|
|
|
|
+ this.tec.getKeyMappers().stream().filter(p -> p.getPkId().equals(e.getPKeyId())).forEach(k -> {
|
|
|
|
+ /*元素长度筛选超页的元素*/
|
|
|
|
+ List<FormData> target = this.formDataMap.values().stream().filter(f -> f.getCode().equals(k.getCode()) && f.getAddPages() > 0).collect(Collectors.toList());
|
|
|
|
+ if (Func.isNotEmpty(target)) {
|
|
|
|
+ inspectionList.addAll(target);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- if (Func.isNotEmpty(inspectionList)) {
|
|
|
|
- /*检查是否存在附表,不存在挂载*/
|
|
|
|
- List<AppWbsTreeContractVO> subTabList = this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("附表")).collect(Collectors.toList());
|
|
|
|
- if (subTabList.size() == 0) {
|
|
|
|
- boolean pd=tec.getTableAll().stream().anyMatch(e->e.getNodeName().contains("评定表"));
|
|
|
|
- WbsTreePrivate sub = wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().and(e->e.eq(WbsTreePrivate::getNodeName, pd?"质量检验评定表(附表)":"质量检验表(附表)").or().eq(WbsTreePrivate::getFullName, pd?"质量检验评定表(附表)":"质量检验表(附表)")).eq(WbsTreePrivate::getProjectId, tec.getProjectId()).eq(WbsTreePrivate::getIsLinkTable,2));
|
|
|
|
- if (sub == null) {
|
|
|
|
- this.tec.getLog().append("该项目没有挂有附表信息");
|
|
|
|
- } else {
|
|
|
|
- this.wbsTreePrivateService.addWbsTreeContractInfo(this.tec.getCurrentNode().getPkId().toString(), sub.getPKeyId().toString(), tec.getContractId());
|
|
|
|
- AppWbsTreeContractVO one = this.tec.getTableAll().get(0);
|
|
|
|
- WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getParentId, one.getParentId()).eq(WbsTreeContract::getContractId,one.getContractId()).eq(WbsTreeContract::getWbsId, one.getWbsId()).and(e->e.eq(WbsTreeContract::getNodeName, pd?"质量检验评定表(附表)":"质量检验表(附表)").or().eq(WbsTreeContract::getFullName, pd?"质量检验评定表(附表)":"质量检验表(附表)")));
|
|
|
|
- if (wtc != null) {
|
|
|
|
- /*附表的顺序在检验单或者评定表之后*/
|
|
|
|
- int sort=this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("检验单") || e.getNodeName().contains("评定表")).map(AppWbsTreeContractVO::getSort).max(Integer::compareTo).orElse(30);
|
|
|
|
- this.wbsTreeContractService.update(Wrappers.<WbsTreeContract>lambdaUpdate()
|
|
|
|
- .set(WbsTreeContract::getSort,sort).set(WbsTreeContract::getContractType,-1).set(WbsTreeContract::getAncestors,one.getAncestors())
|
|
|
|
- .set(WbsTreeContract::getIsCopeTab,2)
|
|
|
|
- .eq(WbsTreeContract::getPKeyId,wtc.getPKeyId()));
|
|
|
|
- /*只需要挂载一张*/
|
|
|
|
- AppWbsTreeContractVO obj = BeanUtil.copy(wtc, AppWbsTreeContractVO.class);
|
|
|
|
- this.tec.getTableAll().add(obj);
|
|
|
|
- subTabList.add(obj);
|
|
|
|
- }
|
|
|
|
|
|
+ });
|
|
|
|
+ if (Func.isNotEmpty(inspectionList)) {
|
|
|
|
+ /*检查是否存在附表,不存在挂载*/
|
|
|
|
+ List<AppWbsTreeContractVO> subTabList = this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("附表")).collect(Collectors.toList());
|
|
|
|
+ if (subTabList.size() == 0) {
|
|
|
|
+ boolean pd=tec.getTableAll().stream().anyMatch(e->e.getNodeName().contains("评定表"));
|
|
|
|
+ WbsTreePrivate sub = wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().and(e->e.eq(WbsTreePrivate::getNodeName, pd?"质量检验评定表(附表)":"质量检验表(附表)").or().eq(WbsTreePrivate::getFullName, pd?"质量检验评定表(附表)":"质量检验表(附表)")).eq(WbsTreePrivate::getProjectId, tec.getProjectId()).eq(WbsTreePrivate::getIsLinkTable,2));
|
|
|
|
+ if (sub == null) {
|
|
|
|
+ this.tec.getLog().append("该项目没有挂有附表信息");
|
|
|
|
+ } else {
|
|
|
|
+ this.wbsTreePrivateService.addWbsTreeContractInfo(this.tec.getCurrentNode().getPkId().toString(), sub.getPKeyId().toString(), tec.getContractId());
|
|
|
|
+ AppWbsTreeContractVO one = this.tec.getTableAll().get(0);
|
|
|
|
+ WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getParentId, one.getParentId()).eq(WbsTreeContract::getContractId,one.getContractId()).eq(WbsTreeContract::getWbsId, one.getWbsId()).and(e->e.eq(WbsTreeContract::getNodeName, pd?"质量检验评定表(附表)":"质量检验表(附表)").or().eq(WbsTreeContract::getFullName, pd?"质量检验评定表(附表)":"质量检验表(附表)")));
|
|
|
|
+ if (wtc != null) {
|
|
|
|
+ /*附表的顺序在检验单或者评定表之后*/
|
|
|
|
+ int sort=this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("检验单") || e.getNodeName().contains("评定表")).map(AppWbsTreeContractVO::getSort).max(Integer::compareTo).orElse(30);
|
|
|
|
+ this.wbsTreeContractService.update(Wrappers.<WbsTreeContract>lambdaUpdate()
|
|
|
|
+ .set(WbsTreeContract::getSort,sort).set(WbsTreeContract::getContractType,-1).set(WbsTreeContract::getAncestors,one.getAncestors())
|
|
|
|
+ .set(WbsTreeContract::getIsCopeTab,2)
|
|
|
|
+ .eq(WbsTreeContract::getPKeyId,wtc.getPKeyId()));
|
|
|
|
+ /*只需要挂载一张*/
|
|
|
|
+ AppWbsTreeContractVO obj = BeanUtil.copy(wtc, AppWbsTreeContractVO.class);
|
|
|
|
+ this.tec.getTableAll().add(obj);
|
|
|
|
+ subTabList.add(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- AppWbsTreeContractVO first = subTabList.get(0);
|
|
|
|
- if (tec.getTableInfoList().stream().noneMatch(e -> StringUtils.isEquals(e.getPkeyId(), first.getPKeyId()))) {
|
|
|
|
- /*找不到附表表单数据,则从数据库加载*/
|
|
|
|
- JSONArray dataArray = new JSONArray();
|
|
|
|
- for (WbsTreeContract data : subTabList) {
|
|
|
|
- /*自动挂载附表情况下,装配TableInfo数据*/
|
|
|
|
- R bussDataInfo = this.getBussDataInfo(data.getPKeyId(), 1);
|
|
|
|
- Map<String, Object> data1 = (Map<String, Object>) bussDataInfo.getData();
|
|
|
|
- data1.put("pkeyId",data.getPKeyId());
|
|
|
|
- dataArray.add(data1);
|
|
|
|
- }
|
|
|
|
- List<TableInfo> subTableInfo = FormulaUtils.getTableInfoList(dataArray);
|
|
|
|
- TableInfo example = tec.getTableInfoList().get(0);
|
|
|
|
- subTableInfo.forEach(e -> {
|
|
|
|
- e.setToBeUpdated(true);
|
|
|
|
- e.setBusinessId(null);
|
|
|
|
- e.setContractId(example.getContractId());
|
|
|
|
- e.setClassify(example.getClassify());
|
|
|
|
- e.setProjectId(example.getProjectId());
|
|
|
|
- e.setGroupId(example.getGroupId());
|
|
|
|
|
|
+ }
|
|
|
|
+ AppWbsTreeContractVO first = subTabList.get(0);
|
|
|
|
+ if (tec.getTableInfoList().stream().noneMatch(e -> StringUtils.isEquals(e.getPkeyId(), first.getPKeyId()))) {
|
|
|
|
+ /*找不到附表表单数据,则从数据库加载*/
|
|
|
|
+ JSONArray dataArray = new JSONArray();
|
|
|
|
+ for (WbsTreeContract data : subTabList) {
|
|
|
|
+ /*自动挂载附表情况下,装配TableInfo数据*/
|
|
|
|
+ R bussDataInfo = this.getBussDataInfo(data.getPKeyId(), 1);
|
|
|
|
+ Map<String, Object> data1 = (Map<String, Object>) bussDataInfo.getData();
|
|
|
|
+ data1.put("pkeyId",data.getPKeyId());
|
|
|
|
+ dataArray.add(data1);
|
|
|
|
+ }
|
|
|
|
+ List<TableInfo> subTableInfo = FormulaUtils.getTableInfoList(dataArray);
|
|
|
|
+ TableInfo example = tec.getTableInfoList().get(0);
|
|
|
|
+ subTableInfo.forEach(e -> {
|
|
|
|
+ e.setToBeUpdated(true);
|
|
|
|
+ e.setBusinessId(null);
|
|
|
|
+ e.setContractId(example.getContractId());
|
|
|
|
+ e.setClassify(example.getClassify());
|
|
|
|
+ e.setProjectId(example.getProjectId());
|
|
|
|
+ e.setGroupId(example.getGroupId());
|
|
|
|
+ });
|
|
|
|
+ tec.getTableInfoList().addAll(subTableInfo);
|
|
|
|
+ /*获取附表元素定位集*/
|
|
|
|
+ tec.getCoordinateMap().put(subTabList.get(0).getInitTableName(), CustomFunction.getElementCell(first.getHtmlUrl()));
|
|
|
|
+ /*附表元素关键信息*/
|
|
|
|
+ List<Map<String, Object>> elementMaps = this.jdbcTemplate.queryForList("select b.e_name ename , CONCAT(a.tab_en_name,':',b.e_key) code , b.e_key ekey ,b.id fieldId,a.tab_en_name tableName from m_table_info a join m_wbs_form_element b on a.id = b.f_id where a.tab_en_name='" + first.getInitTableName() + "' and b.is_deleted=0 ");
|
|
|
|
+ if (Func.isNotEmpty(elementMaps)) {
|
|
|
|
+ elementMaps.forEach(e->{
|
|
|
|
+ /*装配元素*/
|
|
|
|
+ String values=subTableInfo.stream().map(TableInfo::getDataMap).map(m->m.get(StringUtils.handleNull(e.get("ekey")))).filter(StringUtils::isNotEmpty).collect(Collectors.joining(";;"));
|
|
|
|
+ FormData tmp= createFormDataFast(StringUtils.handleNull(e.get("ename")),StringUtils.handleNull(e.get("code")),values);
|
|
|
|
+ if(tmp!=null){
|
|
|
|
+ this.formDataMap.put(tmp.getCode(),tmp);
|
|
|
|
+ this.formDataList.add(tmp);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- tec.getTableInfoList().addAll(subTableInfo);
|
|
|
|
- /*获取附表元素定位集*/
|
|
|
|
- tec.getCoordinateMap().put(subTabList.get(0).getInitTableName(), CustomFunction.getElementCell(first.getHtmlUrl()));
|
|
|
|
- /*附表元素关键信息*/
|
|
|
|
- List<Map<String, Object>> elementMaps = this.jdbcTemplate.queryForList("select b.e_name ename , CONCAT(a.tab_en_name,':',b.e_key) code , b.e_key ekey ,b.id fieldId,a.tab_en_name tableName from m_table_info a join m_wbs_form_element b on a.id = b.f_id where a.tab_en_name='" + first.getInitTableName() + "' and b.is_deleted=0 ");
|
|
|
|
- if (Func.isNotEmpty(elementMaps)) {
|
|
|
|
|
|
+ /*生成元素映射关系*/
|
|
|
|
+ subTabList.forEach(s->{
|
|
elementMaps.forEach(e->{
|
|
elementMaps.forEach(e->{
|
|
- /*装配元素*/
|
|
|
|
- String values=subTableInfo.stream().map(TableInfo::getDataMap).map(m->m.get(StringUtils.handleNull(e.get("ekey")))).filter(StringUtils::isNotEmpty).collect(Collectors.joining(";;"));
|
|
|
|
- FormData tmp= createFormDataFast(StringUtils.handleNull(e.get("ename")),StringUtils.handleNull(e.get("code")),values);
|
|
|
|
- if(tmp!=null){
|
|
|
|
- this.formDataMap.put(tmp.getCode(),tmp);
|
|
|
|
- this.formDataList.add(tmp);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- /*生成元素映射关系*/
|
|
|
|
- subTabList.forEach(s->{
|
|
|
|
- elementMaps.forEach(e->{
|
|
|
|
- KeyMapper km = new KeyMapper();
|
|
|
|
- km.setPkId(s.getPKeyId());
|
|
|
|
- km.setField(StringUtils.handleNull(e.get("ekey")));
|
|
|
|
- km.setFieldId(Func.toLong(e.get("fieldId")));
|
|
|
|
- km.setTableName(StringUtils.handleNull(e.get("tableName")));
|
|
|
|
- this.tec.getKeyMappers().add(km);
|
|
|
|
- });
|
|
|
|
|
|
+ KeyMapper km = new KeyMapper();
|
|
|
|
+ km.setPkId(s.getPKeyId());
|
|
|
|
+ km.setField(StringUtils.handleNull(e.get("ekey")));
|
|
|
|
+ km.setFieldId(Func.toLong(e.get("fieldId")));
|
|
|
|
+ km.setTableName(StringUtils.handleNull(e.get("tableName")));
|
|
|
|
+ this.tec.getKeyMappers().add(km);
|
|
});
|
|
});
|
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- /*获取封装好的附表元素*/
|
|
|
|
- List<FormData> subTableFds=this.formDataMap.values().stream().filter(e->StringUtils.isEquals(first.getInitTableName(),e.getTableName())).collect(Collectors.toList());
|
|
|
|
- /*初始化附表对象*/
|
|
|
|
- SubTable sta=new SubTable(subTableFds);
|
|
|
|
- /*根据行号排序*/
|
|
|
|
- inspectionList.sort(Comparator.comparingInt(e->e.getCoordsList().get(0).getY()));
|
|
|
|
- inspectionList.forEach(f -> {
|
|
|
|
- /*检验单或者评定表存的超页数据汇总到附表对象*/
|
|
|
|
- List<ElementData> overList = f.getValues().stream().skip(f.getCoordsList().size()).collect(Collectors.toList());
|
|
|
|
- f.setValues(f.getValues().stream().limit(f.getCoordsList().size()).collect(Collectors.toList()));
|
|
|
|
- f.setAddPages(0);
|
|
|
|
- String itemName=FormulaUtils.parseItemName(f.getEName());
|
|
|
|
- String key=itemName.trim();
|
|
|
|
- /*同项目*/
|
|
|
|
- Optional<FormData> designFdOp= this.formDataMap.values().stream().filter(o->o.getTableName().equals(f.getTableName())&&StringUtils.isEquals(itemName,FormulaUtils.parseItemName(o.getEName()))&&o.getEName().contains("设计值")&&!o.getEName().contains("判定")).findAny();
|
|
|
|
- if(designFdOp.isPresent()){
|
|
|
|
- key+="@"+designFdOp.get().getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).findAny().orElse("");
|
|
|
|
- }
|
|
|
|
- sta.put(key,setScale(2,overList));
|
|
|
|
- });
|
|
|
|
- if(sta.checked()){
|
|
|
|
- /*把附表数据刷入对应的附表元素对象*/
|
|
|
|
- sta.flush();
|
|
|
|
|
|
+ }
|
|
|
|
+ /*获取封装好的附表元素*/
|
|
|
|
+ List<FormData> subTableFds=this.formDataMap.values().stream().filter(e->StringUtils.isEquals(first.getInitTableName(),e.getTableName())).collect(Collectors.toList());
|
|
|
|
+ /*初始化附表对象*/
|
|
|
|
+ SubTable sta=new SubTable(subTableFds);
|
|
|
|
+ /*根据行号排序*/
|
|
|
|
+ inspectionList.sort(Comparator.comparingInt(e->e.getCoordsList().get(0).getY()));
|
|
|
|
+ inspectionList.forEach(f -> {
|
|
|
|
+ /*检验单或者评定表存的超页数据汇总到附表对象*/
|
|
|
|
+ List<ElementData> overList = f.getValues().stream().skip(f.getCoordsList().size()).collect(Collectors.toList());
|
|
|
|
+ f.setValues(f.getValues().stream().limit(f.getCoordsList().size()).collect(Collectors.toList()));
|
|
|
|
+ f.setAddPages(0);
|
|
|
|
+ String itemName=FormulaUtils.parseItemName(f.getEName());
|
|
|
|
+ String key=itemName.trim();
|
|
|
|
+ /*同项目*/
|
|
|
|
+ Optional<FormData> designFdOp= this.formDataMap.values().stream().filter(o->o.getTableName().equals(f.getTableName())&&StringUtils.isEquals(itemName,FormulaUtils.parseItemName(o.getEName()))&&o.getEName().contains("设计值")&&!o.getEName().contains("判定")).findAny();
|
|
|
|
+ if(designFdOp.isPresent()){
|
|
|
|
+ key+="@"+designFdOp.get().getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).findAny().orElse("");
|
|
}
|
|
}
|
|
|
|
+ sta.put(key,setScale(2,overList));
|
|
|
|
+ });
|
|
|
|
+ if(sta.checked()){
|
|
|
|
+ /*把附表数据刷入对应的附表元素对象*/
|
|
|
|
+ sta.flush();
|
|
}
|
|
}
|
|
- } catch (Exception e) {
|
|
|
|
- this.tec.getLog().append("【").append("附表异常").append("】");
|
|
|
|
- e.printStackTrace();
|
|
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ this.tec.getLog().append("【").append("附表异常").append("】");
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /**汇总处理*/
|
|
|
|
+ public void summaryCalc(){
|
|
|
|
+ if(this.summary.size()>0){
|
|
|
|
+ /**/
|
|
|
|
+ this.constantMap.put(CHECK_ITEMS,this.checkItems.stream().filter(fdTmp->fdTmp.getValues().stream().map(ElementData::getValue).anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isNotEquals("/",e))).map(FormData::getEName).map(FormulaUtils::parseItemName).distinct().collect(Collectors.joining(",")));
|
|
|
|
+ this.constantMap.put("CKD",this.checkDate.stream().flatMap(k->k.getValues().stream()).map(ElementData::stringValue).map(DateTime::new).reduce((a, b) -> Comparator.<DateTime>reverseOrder().compare(a, b) <= 0 ? a : b).orElse(null));
|
|
|
|
+ this.summary.forEach(e->{
|
|
|
|
+ /*处理脚本*/
|
|
|
|
+ e.getFormula().setFormula(e.getFormula().getNumber());
|
|
|
|
+ });
|
|
|
|
+ this.summary.forEach(e->{
|
|
|
|
+ /*执行公式*/
|
|
|
|
+ Object data = Expression.parse(e.getFormula().getFormula()).calculate(this.constantMap);
|
|
|
|
+ if(data!=null){
|
|
|
|
+ FormulaUtils.write(e,data,false);
|
|
|
|
+ e.setUpdate(1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- return this;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void write(FormData fd,Object data){
|
|
public void write(FormData fd,Object data){
|
|
@@ -709,6 +782,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
/**加页增容*/
|
|
/**加页增容*/
|
|
public void copy(FormData fd){
|
|
public void copy(FormData fd){
|
|
|
|
+ if(fd.getAddPages()>20){
|
|
|
|
+ /*最大页数20*/
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
int pageAdd=fd.getAddPages();
|
|
int pageAdd=fd.getAddPages();
|
|
LinkedHashMap<String,List<KeyMapper>> tabs = this.tec.getKeyMappers().stream().collect(Collectors.groupingBy(KeyMapper::getCode,LinkedHashMap::new,Collectors.toList()));
|
|
LinkedHashMap<String,List<KeyMapper>> tabs = this.tec.getKeyMappers().stream().collect(Collectors.groupingBy(KeyMapper::getCode,LinkedHashMap::new,Collectors.toList()));
|
|
List<KeyMapper> kms = tabs.get(fd.getCode());
|
|
List<KeyMapper> kms = tabs.get(fd.getCode());
|