|
@@ -3,6 +3,7 @@ package org.springblade.manager.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
+import cn.hutool.core.date.StopWatch;
|
|
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;
|
|
@@ -12,6 +13,7 @@ import com.jfireel.expression.Expression;
|
|
import com.mixsmart.utils.*;
|
|
import com.mixsmart.utils.*;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
+import org.jsoup.nodes.Document;
|
|
import org.springblade.common.utils.BaseUtils;
|
|
import org.springblade.common.utils.BaseUtils;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
@@ -33,7 +35,6 @@ import org.springblade.manager.vo.AppWbsTreeContractVO;
|
|
import org.springblade.manager.vo.CurrentNode;
|
|
import org.springblade.manager.vo.CurrentNode;
|
|
import org.springframework.context.annotation.Scope;
|
|
import org.springframework.context.annotation.Scope;
|
|
import org.springframework.context.annotation.ScopedProxyMode;
|
|
import org.springframework.context.annotation.ScopedProxyMode;
|
|
-import org.springframework.http.converter.json.MappingJacksonValue;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
@@ -77,12 +78,12 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
public static final Pattern AP=Pattern.compile("(E|WP)\\[([^]']+)]");
|
|
public static final Pattern AP=Pattern.compile("(E|WP)\\[([^]']+)]");
|
|
public static final String IF_REG= "(?<=T\\(com.mixsmart.utils.CustomFunction\\).ifelse\\()[^,]+(?=,)";
|
|
public static final String IF_REG= "(?<=T\\(com.mixsmart.utils.CustomFunction\\).ifelse\\()[^,]+(?=,)";
|
|
public static final String FC_REG="T\\(com.mixsmart.utils.CustomFunction\\)\\.";
|
|
public static final String FC_REG="T\\(com.mixsmart.utils.CustomFunction\\)\\.";
|
|
- public static final Pattern IF = Pattern.compile(IF_REG);
|
|
|
|
|
|
+ /*public static final Pattern IF = Pattern.compile(IF_REG);*/
|
|
public static final String ELE_CODE_REG= "(?<=E\\[)[^]]+(?=])";
|
|
public static final String ELE_CODE_REG= "(?<=E\\[)[^]]+(?=])";
|
|
public static final Pattern P = Pattern.compile(ELE_CODE_REG);
|
|
public static final Pattern P = Pattern.compile(ELE_CODE_REG);
|
|
- public static final Pattern P2= Pattern.compile("(?<=E\\[)[^];]+:[^];]+:[^];]+(?=])");
|
|
|
|
|
|
+ /*public static final Pattern P2= Pattern.compile("(?<=E\\[)[^];]+:[^];]+:[^];]+(?=])");*/
|
|
public final static String CTI="ContractInfo";
|
|
public final static String CTI="ContractInfo";
|
|
- public final static String PJI="ProjectInfo";
|
|
|
|
|
|
+ /*public final static String PJI="ProjectInfo";*/
|
|
/**元素标识*/
|
|
/**元素标识*/
|
|
public final static String E="E";
|
|
public final static String E="E";
|
|
/**公式参数*/
|
|
/**公式参数*/
|
|
@@ -91,7 +92,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
/**是否使用新流程*/
|
|
/**是否使用新流程*/
|
|
public final static boolean isNew=false;
|
|
public final static boolean isNew=false;
|
|
|
|
|
|
-
|
|
|
|
|
|
+ /**是否使用表单公式*/
|
|
|
|
+ public final static boolean isForm=true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -754,17 +756,23 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
try {
|
|
try {
|
|
Map<Boolean, List<FormData>> map = tec.formDataList.stream().collect(Collectors.partitioningBy(e -> Func.isNotEmpty(e.getFormula()) && e.getFormula().getFormula().contains("E[")));
|
|
Map<Boolean, List<FormData>> map = tec.formDataList.stream().collect(Collectors.partitioningBy(e -> Func.isNotEmpty(e.getFormula()) && e.getFormula().getFormula().contains("E[")));
|
|
tec.formDataList.clear();
|
|
tec.formDataList.clear();
|
|
- /*没有依赖的*/
|
|
|
|
- List<FormData> simple = map.get(false);
|
|
|
|
- if (CollectionUtil.isNotEmpty(simple)) {
|
|
|
|
- tec.formDataList.addAll(simple);
|
|
|
|
- }
|
|
|
|
/*有依赖的*/
|
|
/*有依赖的*/
|
|
List<FormData> rely = map.get(true);
|
|
List<FormData> rely = map.get(true);
|
|
if (CollectionUtil.isNotEmpty(rely)) {
|
|
if (CollectionUtil.isNotEmpty(rely)) {
|
|
sort(rely, ((rely.size() + 1) / 2) * rely.size());
|
|
sort(rely, ((rely.size() + 1) / 2) * rely.size());
|
|
tec.formDataList.addAll(rely);
|
|
tec.formDataList.addAll(rely);
|
|
}
|
|
}
|
|
|
|
+ /*没有依赖的*/
|
|
|
|
+ List<FormData> simple = map.get(false);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(simple)) {
|
|
|
|
+ for(FormData fd:simple){
|
|
|
|
+ if(fd.getCoordsList().size()==1&&fd.executable()&&fd.getFormula().getFormula().contains(WP)&&!fd.empty()){
|
|
|
|
+ fd.setFinished(true);
|
|
|
|
+ fd.setUpdate(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ tec.formDataList.addAll(simple);
|
|
|
|
+ }
|
|
/*初始化排序值,每个点间隔1000,方便插入*/
|
|
/*初始化排序值,每个点间隔1000,方便插入*/
|
|
AtomicInteger sort = new AtomicInteger();
|
|
AtomicInteger sort = new AtomicInteger();
|
|
tec.formDataList.forEach(e -> e.setSort(sort.getAndAdd(1000)));
|
|
tec.formDataList.forEach(e -> e.setSort(sort.getAndAdd(1000)));
|
|
@@ -887,10 +895,15 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
/*通用计算*/
|
|
/*通用计算*/
|
|
generalCalc();
|
|
generalCalc();
|
|
if(ExecuteType.INSPECTION.equals(tec.getExecuteType())) {
|
|
if(ExecuteType.INSPECTION.equals(tec.getExecuteType())) {
|
|
- /*汇总信息处理*/
|
|
|
|
- summaryCalc();
|
|
|
|
- /*附表的处理*/
|
|
|
|
- forSubTb();
|
|
|
|
|
|
+ if(isNew){
|
|
|
|
+ //TODO
|
|
|
|
+ }else{
|
|
|
|
+ /*汇总信息处理*/
|
|
|
|
+ summaryCalc();
|
|
|
|
+ /*附表的处理*/
|
|
|
|
+ forSubTb();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
@@ -1079,85 +1092,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
List<NodeTable> subTabList = this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("附表")).collect(Collectors.toList());
|
|
List<NodeTable> subTabList = this.tec.getTableAll().stream().filter(e -> e.getNodeName().contains("附表")).collect(Collectors.toList());
|
|
if (subTabList.size() == 0) {
|
|
if (subTabList.size() == 0) {
|
|
linkSub(subTabList);
|
|
linkSub(subTabList);
|
|
- /* boolean pd=tec.getTableAll().stream().anyMatch(e->e.getTableType().equals(5));
|
|
|
|
- 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().put(FormulaLog.SUB_TAB,"该项目没有挂有附表信息");
|
|
|
|
- } else {
|
|
|
|
- this.wbsTreePrivateService.addWbsTreeContractInfo(this.tec.getCurrentNode().getPkId().toString(), sub.getPKeyId().toString(), tec.getContractId());
|
|
|
|
- NodeTable one = this.tec.getTableAll().get(0);
|
|
|
|
- WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getParentId, one.getParentId()).eq(WbsTreeContract::getContractId,tec.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.getTableType().equals(1) || e.getTableType().equals(5)).map(NodeTable::getSort).max(Integer::compareTo).orElse(1000);
|
|
|
|
- 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()));
|
|
|
|
- *//*只需要挂载一张*//*
|
|
|
|
- NodeTable obj = BeanUtil.copy(wtc, NodeTable.class);
|
|
|
|
- tec.getTableAll().add(obj);
|
|
|
|
- subTabList.add(obj);
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
NodeTable first = subTabList.get(0);
|
|
NodeTable first = subTabList.get(0);
|
|
if (tec.getTableInfoList().stream().noneMatch(e -> StringUtils.isEquals(e.getPkeyId(), first.getPKeyId()))) {
|
|
if (tec.getTableInfoList().stream().noneMatch(e -> StringUtils.isEquals(e.getPkeyId(), first.getPKeyId()))) {
|
|
/*找不到附表表单数据,则从数据库加载*/
|
|
/*找不到附表表单数据,则从数据库加载*/
|
|
loadSubData(subTabList,first);
|
|
loadSubData(subTabList,first);
|
|
- /* JSONArray dataArray = new JSONArray();
|
|
|
|
- for (NodeTable data : subTabList) {
|
|
|
|
- *//*自动挂载附表情况下,装配TableInfo数据*//*
|
|
|
|
- R bussDataInfo = this.excelTabService.getBussDataInfo(data.getPKeyId(), 1);
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
|
- Map<String, Object> data1 = (Map<String, Object>) bussDataInfo.getData();
|
|
|
|
- data1.put("pkeyId",data.getPKeyId());
|
|
|
|
- dataArray.add(data1);
|
|
|
|
- }
|
|
|
|
- List<TableInfo> subTableInfo = this.excelTabService.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(), FormulaUtils.getElementCell(first.getHtmlUrl()));*//*
|
|
|
|
- tec.getCoordinateMap().computeIfAbsent(subTabList.get(0).getInitTableName(),k->FormulaUtils.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){
|
|
|
|
- String idStr =StringUtils.handleNull(e.get("fieldId"));
|
|
|
|
- if(Func.isNotEmpty(idStr)) {
|
|
|
|
- tmp.setId(Func.toLong(idStr));
|
|
|
|
- }
|
|
|
|
- tmp.setIsCurrentNodeElement(true);
|
|
|
|
- tec.formDataMap.put(tmp.getCode(),tmp);
|
|
|
|
- tec.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);
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
/*获取封装好的附表元素*/
|
|
/*获取封装好的附表元素*/
|
|
List<FormData> subTableFds=tec.formDataMap.values().stream().filter(e->StringUtils.isEquals(first.getInitTableName(),e.getTableName())).collect(Collectors.toList());
|
|
List<FormData> subTableFds=tec.formDataMap.values().stream().filter(e->StringUtils.isEquals(first.getInitTableName(),e.getTableName())).collect(Collectors.toList());
|
|
@@ -1186,21 +1125,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
/*把主表的表头表尾信息拷贝*/
|
|
/*把主表的表头表尾信息拷贝*/
|
|
headerFooterSub(subTableFds);
|
|
headerFooterSub(subTableFds);
|
|
- /* String mainTableName = tec.getTableAll().stream().filter(e -> e.getTableType().equals(1) || e.getTableType().equals(5)).map(NodeTable::getInitTableName).findFirst().orElse("");
|
|
|
|
- if(Func.isNotBlank(mainTableName)){
|
|
|
|
- List<FormData> sourceFds=tec.getFormDataMap().values().stream().filter(s->!s.empty()).filter(s->StringUtils.isEquals(s.getTableName(),mainTableName)).collect(Collectors.toList());
|
|
|
|
- Map<String,Object> copyMap= new HashMap<>();
|
|
|
|
- if(sourceFds.size()>0){
|
|
|
|
- sourceFds.forEach(d->{
|
|
|
|
- copyMap.put(d.getSimplifyName(),d.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).findAny().orElse(""));
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- subTableFds.stream().filter(s-> !SubTable.KEYS.contains(s.getEName().trim())).filter(s->copyMap.containsKey(s.getSimplifyName())).forEach(t->{
|
|
|
|
- Object val = copyMap.get(t.getSimplifyName());
|
|
|
|
- t.getValues().forEach(e->e.setValue(val));
|
|
|
|
- t.setUpdate(1);
|
|
|
|
- });
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -1314,12 +1238,12 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
public void summaryCalc(){
|
|
public void summaryCalc(){
|
|
try{
|
|
try{
|
|
if(tec.summary.size()>0){
|
|
if(tec.summary.size()>0){
|
|
- /**/
|
|
|
|
|
|
+ /*获取有实测值的检查项目*/
|
|
List<String> result=tec.checkItems.stream().filter(fdTmp->fdTmp.getValues().stream().map(ElementData::getValue).anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isNotEquals("/",e))).map(FormData::getEName).map(FormulaUtils::checkItemName).distinct().collect(Collectors.toList());
|
|
List<String> result=tec.checkItems.stream().filter(fdTmp->fdTmp.getValues().stream().map(ElementData::getValue).anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isNotEquals("/",e))).map(FormData::getEName).map(FormulaUtils::checkItemName).distinct().collect(Collectors.toList());
|
|
Optional<FormData> opk= tec.summary.stream().filter(FormData::executable).filter(f->StringUtils.isEquals(f.getFormula().getNumber(),CHECK_ITEMS)).findAny();
|
|
Optional<FormData> opk= tec.summary.stream().filter(FormData::executable).filter(f->StringUtils.isEquals(f.getFormula().getNumber(),CHECK_ITEMS)).findAny();
|
|
List<String> history=null;
|
|
List<String> history=null;
|
|
if(opk.isPresent()&&!opk.get().empty()){
|
|
if(opk.isPresent()&&!opk.get().empty()){
|
|
- /*假如已经存在内容,则需要筛选出手填部分*/
|
|
|
|
|
|
+ /*假如已经存内容,则需要筛选出手填部分*/
|
|
history= Arrays.asList(opk.get().getValues().get(0).stringValue().replaceAll("[\\s\\n]+","").split("[,、,]"));
|
|
history= Arrays.asList(opk.get().getValues().get(0).stringValue().replaceAll("[\\s\\n]+","").split("[,、,]"));
|
|
}
|
|
}
|
|
if(history!=null&&history.size()>0){
|
|
if(history!=null&&history.size()>0){
|
|
@@ -1327,7 +1251,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
List<String> customize=history.stream().filter(s->!itemAll.contains(s)).collect(Collectors.toList());
|
|
List<String> customize=history.stream().filter(s->!itemAll.contains(s)).collect(Collectors.toList());
|
|
result.addAll(customize);
|
|
result.addAll(customize);
|
|
}
|
|
}
|
|
|
|
+ /*检查内容*/
|
|
tec.constantMap.put(CHECK_ITEMS,result);
|
|
tec.constantMap.put(CHECK_ITEMS,result);
|
|
|
|
+ /*计算检查日期*/
|
|
tec.constantMap.put("CKD",tec.checkDate.stream().flatMap(k->k.getValues().stream()).map(ElementData::stringValue)
|
|
tec.constantMap.put("CKD",tec.checkDate.stream().flatMap(k->k.getValues().stream()).map(ElementData::stringValue)
|
|
.filter(StringUtils::isNotEmpty)
|
|
.filter(StringUtils::isNotEmpty)
|
|
.map(FormulaUtils::range2end)
|
|
.map(FormulaUtils::range2end)
|
|
@@ -1341,7 +1267,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
Object data = Expression.parse(e.getFormula().getFormula()).calculate(tec.constantMap);
|
|
Object data = Expression.parse(e.getFormula().getFormula()).calculate(tec.constantMap);
|
|
if(data!=null){
|
|
if(data!=null){
|
|
e.getFormula().setOutm(1);
|
|
e.getFormula().setOutm(1);
|
|
- FormulaUtils.write(e,data,false);
|
|
|
|
|
|
+ FormulaUtils.write(e,data);
|
|
e.setUpdate(1);
|
|
e.setUpdate(1);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -1537,15 +1463,61 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ public void copy2(FormData fd){
|
|
|
|
+ /*挑选最长的元素来决定需要增加的页数*/
|
|
|
|
+ if(fd.getAddPages()>20){
|
|
|
|
+ /*最大页数20*/
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ int pageAdd=fd.getAddPages();
|
|
|
|
+ /*增加表单页,删除实测值*/
|
|
|
|
+ LinkedList<NodeTable> nodeTableList=tec.getTableByName(fd.getTableName());
|
|
|
|
+ NodeTable source = nodeTableList.getLast();
|
|
|
|
+ WbsTreeContract origin = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,source.getPKeyId()));
|
|
|
|
+ if(origin!=null){
|
|
|
|
+ for(int i=0;i<pageAdd;i++){
|
|
|
|
+ /*复制表*/
|
|
|
|
+ WbsTreeContract target = new WbsTreeContract();
|
|
|
|
+ BeanUtil.copy(origin,target);
|
|
|
|
+ target.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
+ target.setCreateTime(new Date());
|
|
|
|
+ String nodeName = origin.getNodeName();
|
|
|
|
+ if (nodeName.contains("__")) {
|
|
|
|
+ String[] oldName = nodeName.split("__");
|
|
|
|
+ nodeName = oldName[0] + "__" + (Integer.parseInt(oldName[1]) + 1);
|
|
|
|
+ } else {
|
|
|
|
+ nodeName = nodeName + "__" + 1;
|
|
|
|
+ }
|
|
|
|
+ target.setNodeName(nodeName);
|
|
|
|
+ target.setIsCopeTab(2);
|
|
|
|
+ target.setIsTabPdf(1); // pdf 不能预览
|
|
|
|
+ target.setIsBussShow(1); // 是否隐藏表
|
|
|
|
+ target.setTabFileType(1);//没有上传附件
|
|
|
|
+ target.setPdfUrl("");
|
|
|
|
+ this.wbsTreeContractService.save(target);
|
|
|
|
+ Long pkeyId=origin.getPKeyId();
|
|
|
|
+ tec.getTableInfoList().stream().filter(o->StringUtils.isEquals(o.getPkeyId(),pkeyId)).findFirst().ifPresent(tb->{
|
|
|
|
+ /*表单数据复制*/
|
|
|
|
+ TableInfo tableInfo = new TableInfo();
|
|
|
|
+ BeanUtil.copy(tb,tableInfo);
|
|
|
|
+ tableInfo.setPkeyId(target.getPKeyId().toString());
|
|
|
|
+ tableInfo.setDataMap(new LinkedHashMap<>(tb.getDataMap()));
|
|
|
|
+ /*删除所有实测项目*/
|
|
|
|
+ List<FormData> fdsOfTable=tec.getTableNameFormDataMap().get(source.getInitTableName());
|
|
|
|
+ Set<String> removeKeySet=fdsOfTable.stream().filter(f->!f.empty()&&f.getCoordsList().size()>1).map(FormData::getKey).collect(Collectors.toSet());
|
|
|
|
+ for(String rk:removeKeySet){
|
|
|
|
+ tableInfo.getDataMap().remove(rk);
|
|
|
|
+ }
|
|
|
|
+ tableInfo.getDataMap().put("p_key_id",tableInfo.getPkeyId());
|
|
|
|
+ tec.getTableInfoList().add(tec.getTableInfoList().indexOf(tb)+1,tableInfo);
|
|
|
|
+ });
|
|
|
|
+ origin=target;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*复制最后一页只有一个单元格的存在内容的元素*/
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
-/*public List<ElementData> setScale(Integer scale,List<ElementData> data){
|
|
|
|
- if(scale==null){
|
|
|
|
- scale=StringUtils.getScale(data.stream().map(ElementData::getValue).filter(StringUtils::isDouble).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- Integer finalScale = scale;
|
|
|
|
- return data.stream().peek(e->{if(StringUtils.isDouble(e.getValue())){e.setValue(StringUtils.number2StringZero(e.getValue(),finalScale));}}).collect(Collectors.toList());
|
|
|
|
-}*/
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void format() {
|
|
public void format() {
|
|
@@ -1560,9 +1532,25 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/*检查超页情况*/
|
|
/*检查超页情况*/
|
|
- tec.formDataMap.values().stream().filter(e->e.getIsCurrentNodeElement()&&e.getUpdate()==1&&e.getAddPages()>0).sorted(Comparator.comparing(FormData::getAddPages).reversed())
|
|
|
|
- .collect(Collectors.groupingBy(FormData::getTableName,LinkedHashMap::new,Collectors.toList())).values()
|
|
|
|
- .forEach(l->copy(l.get(0)));
|
|
|
|
|
|
+ if(isNew){
|
|
|
|
+ tec.formDataMap.values().stream().filter(e->e.getIsCurrentSubmitElement()&&e.getUpdate()==1&&e.getAddPages()>0).sorted(Comparator.comparing(FormData::getAddPages).reversed())
|
|
|
|
+ .collect(Collectors.groupingBy(FormData::getTableName,LinkedHashMap::new,Collectors.toList())).values()
|
|
|
|
+ .forEach(l->copy2(l.get(0)));
|
|
|
|
+ /*表头表尾数据处理*/
|
|
|
|
+ tec.formDataMap.values().stream().filter(e->!e.empty()&&e.getIsCurrentSubmitElement()&&e.getUpdate()==1&&e.getCoordsList().size()==1).forEach(e->{
|
|
|
|
+ ElementData ed = e.getValues().get(0);
|
|
|
|
+ e.getValues().forEach(x->x.setValue(ed.getValue()));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ tec.formDataMap.values().stream().filter(e->e.getIsCurrentNodeElement()&&e.getUpdate()==1&&e.getAddPages()>0).sorted(Comparator.comparing(FormData::getAddPages).reversed())
|
|
|
|
+ .collect(Collectors.groupingBy(FormData::getTableName,LinkedHashMap::new,Collectors.toList())).values()
|
|
|
|
+ .forEach(l->copy(l.get(0)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1604,7 +1592,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else if(executeType.equals(ExecuteType.TESTING)){
|
|
}else if(executeType.equals(ExecuteType.TESTING)){
|
|
-
|
|
|
|
|
|
+ //TODO
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1987,32 +1975,19 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
if(f.contains("quantity")){
|
|
if(f.contains("quantity")){
|
|
/*聚合*/
|
|
/*聚合*/
|
|
- Matcher m = RegexUtils.matcher(FC_REG+"(quantity)\\(([^)]+)\\)",f);
|
|
|
|
|
|
+ /* Matcher m = RegexUtils.matcher(FC_REG+"(quantity)\\(([^)]+)\\)",f);
|
|
while (m.find()) {
|
|
while (m.find()) {
|
|
Object data=null;
|
|
Object data=null;
|
|
List<String> codeList = FormulaUtils.getCodeList(m.group(2));
|
|
List<String> codeList = FormulaUtils.getCodeList(m.group(2));
|
|
-// Map<String,List<Map<String,Object>>> textInfoMap= (Map<String, List<Map<String, Object>>>) tec.constantMap.getOrDefault(TEXT_INFO_MAP,new HashMap<>());
|
|
|
|
-// List<Map<String,Object>> tableColKeyVal= textInfoMap.get(codeList.get(0));
|
|
|
|
- /*表名+合同段+父节点*/
|
|
|
|
- String findStr="OP['"+fd.getTableName()+"']['"+fd.getKey()+"']['RG']";
|
|
|
|
- String rangeStr=StringUtils.handleNull(Expression.parse(findStr).calculate(tec.constantMap));
|
|
|
|
- //System.out.println("随机值参数:"+rangeStr);
|
|
|
|
- if(false){
|
|
|
|
- /* Optional<RangeInfo> op=tableColKeyVal.stream().map(map-> BeanUtil.toBean(JSON.parseObject(map.get("val").toString()),RangeInfo.class)).findFirst();
|
|
|
|
- if(op.isPresent()){
|
|
|
|
- RangeInfo d = op.get();
|
|
|
|
- d.build();
|
|
|
|
- data= d.getPassList().stream().mapToInt(Func::toInt).sum();
|
|
|
|
- }*/
|
|
|
|
- }else{
|
|
|
|
|
|
+ {
|
|
FormData dataFd=tec.formDataMap.get(codeList.get(0));
|
|
FormData dataFd=tec.formDataMap.get(codeList.get(0));
|
|
String designStr=codeList.get(1);
|
|
String designStr=codeList.get(1);
|
|
FormData designFd=tec.formDataMap.get(designStr);
|
|
FormData designFd=tec.formDataMap.get(designStr);
|
|
String devStr=StringUtils.isNotEmpty(formula.getDev())?formula.getDev():fd.getEAllowDeviation();
|
|
String devStr=StringUtils.isNotEmpty(formula.getDev())?formula.getDev():fd.getEAllowDeviation();
|
|
if(StringUtils.isEmpty(devStr)){
|
|
if(StringUtils.isEmpty(devStr)){
|
|
- /*数据库找不到的情况就读取Excel*/
|
|
|
|
|
|
+ *//*数据库找不到的情况就读取Excel*//*
|
|
if(tec.wkbMap.isEmpty()){
|
|
if(tec.wkbMap.isEmpty()){
|
|
- /*初始化*/
|
|
|
|
|
|
+ *//*初始化*//*
|
|
List<String> tableNames4Excel= tec.getFormDataList().stream().filter(FormData::executable).filter(e->e.info().contains("quantity")).map(FormData::getTableName).distinct().collect(Collectors.toList());
|
|
List<String> tableNames4Excel= tec.getFormDataList().stream().filter(FormData::executable).filter(e->e.info().contains("quantity")).map(FormData::getTableName).distinct().collect(Collectors.toList());
|
|
if(!tableNames4Excel.isEmpty()){
|
|
if(!tableNames4Excel.isEmpty()){
|
|
List<String> ids =tec.getTableAll().stream().filter(e->tableNames4Excel.contains(e.getInitTableName())).map(NodeTable::getPKeyId).map(String::valueOf).collect(Collectors.toList());
|
|
List<String> ids =tec.getTableAll().stream().filter(e->tableNames4Excel.contains(e.getInitTableName())).map(NodeTable::getPKeyId).map(String::valueOf).collect(Collectors.toList());
|
|
@@ -2078,7 +2053,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
devStr= Arrays.stream(devStr.replaceAll("^\\[|\\]$","").split(",")).map(s->map.getOrDefault(s,s)).map(StringUtils::handleNull).collect(Collectors.joining(","));
|
|
devStr= Arrays.stream(devStr.replaceAll("^\\[|\\]$","").split(",")).map(s->map.getOrDefault(s,s)).map(StringUtils::handleNull).collect(Collectors.joining(","));
|
|
}
|
|
}
|
|
- /*设计值可以是数值类型,或空(等效0)*/
|
|
|
|
|
|
+ *//*设计值可以是数值类型,或空(等效0)*//*
|
|
if(dataFd!=null){
|
|
if(dataFd!=null){
|
|
List<Object> values= dataFd.getRawValue();
|
|
List<Object> values= dataFd.getRawValue();
|
|
boolean nonNumeric=values.stream().filter(StringUtils::isNotEmpty).anyMatch(e->!StringUtils.isNumber(e));
|
|
boolean nonNumeric=values.stream().filter(StringUtils::isNotEmpty).anyMatch(e->!StringUtils.isNumber(e));
|
|
@@ -2086,7 +2061,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
data=values.stream().filter(StringUtils::isNotEmpty).count();
|
|
data=values.stream().filter(StringUtils::isNotEmpty).count();
|
|
}else if(designFd!=null){
|
|
}else if(designFd!=null){
|
|
if(dataFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNotEmpty)&&(designFd.getValues().size()>1||designFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isEmpty))){
|
|
if(dataFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNotEmpty)&&(designFd.getValues().size()>1||designFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isEmpty))){
|
|
- /*多少个设计值暂时默认全部合格,满足绝大部分结果*/
|
|
|
|
|
|
+ *//*多少个设计值暂时默认全部合格,满足绝大部分结果*//*
|
|
data=dataFd.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).count();
|
|
data=dataFd.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).count();
|
|
}else{
|
|
}else{
|
|
List<Object> result = CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),designFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),devStr,1 );
|
|
List<Object> result = CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),designFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),devStr,1 );
|
|
@@ -2101,7 +2076,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
f = f.replace(m.group(),putDataWithKey(BaseUtils.isNumber(data)?Double.parseDouble(data.toString()):data));
|
|
f = f.replace(m.group(),putDataWithKey(BaseUtils.isNumber(data)?Double.parseDouble(data.toString()):data));
|
|
}
|
|
}
|
|
fd.getFormula().setFormula(f);
|
|
fd.getFormula().setFormula(f);
|
|
- formula.setScale(1);
|
|
|
|
|
|
+ formula.setScale(1);*/
|
|
|
|
+ quantity(formula,fd,f);
|
|
}
|
|
}
|
|
formula.setFormula(f);
|
|
formula.setFormula(f);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -2110,6 +2086,112 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*合格率预处理*/
|
|
|
|
+ public void quantity( Formula formula,FormData fd,String f){
|
|
|
|
+ /*聚合*/
|
|
|
|
+ Matcher m = RegexUtils.matcher(FC_REG+"(quantity)\\(([^)]+)\\)",f);
|
|
|
|
+ while (m.find()) {
|
|
|
|
+ Object data=null;
|
|
|
|
+ List<String> codeList = FormulaUtils.getCodeList(m.group(2));
|
|
|
|
+ {
|
|
|
|
+ FormData dataFd=tec.formDataMap.get(codeList.get(0));
|
|
|
|
+ String designStr=codeList.get(1);
|
|
|
|
+ FormData designFd=tec.formDataMap.get(designStr);
|
|
|
|
+ String devStr=StringUtils.isNotEmpty(formula.getDev())?formula.getDev():fd.getEAllowDeviation();
|
|
|
|
+ if(StringUtils.isEmpty(devStr)){
|
|
|
|
+ /*数据库找不到的情况就读取Excel*/
|
|
|
|
+ if(tec.wkbMap.isEmpty()){
|
|
|
|
+ /*初始化*/
|
|
|
|
+ List<String> tableNames4Excel= tec.getFormDataList().stream().filter(FormData::executable).filter(e->e.info().contains("quantity")).map(FormData::getTableName).distinct().collect(Collectors.toList());
|
|
|
|
+ if(!tableNames4Excel.isEmpty()){
|
|
|
|
+ List<String> ids =tec.getTableAll().stream().filter(e->tableNames4Excel.contains(e.getInitTableName())).map(NodeTable::getPKeyId).map(String::valueOf).collect(Collectors.toList());
|
|
|
|
+ List<Map<String,Object>> listMaps= this.jdbcTemplate.queryForList("select a.p_key_id pkeyId,a.init_table_name tableName,b.file_url url from m_wbs_tree_contract a join m_excel_tab b on a.excel_id=b.id where a.p_key_id in("+String.join(",",ids)+")");
|
|
|
|
+ listMaps.forEach(mp->{
|
|
|
|
+ try {
|
|
|
|
+ Workbook wb = WorkbookFactory.create(Objects.requireNonNull(CommonUtil.getOSSInputStream(StringUtils.handleNull(mp.get("url")))));
|
|
|
|
+ tec.wkbMap.put(mp.get("pkeyId").toString(),wb);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Optional<NodeTable> nodeTableOp =tec.getTableAll().stream().filter(e->e.getInitTableName().equals(fd.getTableName())).findFirst();
|
|
|
|
+ if(nodeTableOp.isPresent()){
|
|
|
|
+ Workbook wb = tec.wkbMap.get(nodeTableOp.get().getPKeyId().toString());
|
|
|
|
+ if(wb!=null){
|
|
|
|
+ Cell deCell=null;
|
|
|
|
+ Sheet sheet = wb.getSheetAt(0);
|
|
|
|
+ outerLoop: for(int y=3;y<35;y++){
|
|
|
|
+ for(int x=0;x<35;x++){
|
|
|
|
+ Row row = sheet.getRow(y);
|
|
|
|
+ Cell cell= row.getCell(x);
|
|
|
|
+ String sv=StringUtils.handleNull(FormulaUtils.getValue(cell)).replaceAll("[^\u4e00-\u9fa5]+","");
|
|
|
|
+ if(sv.contains("规定")&&sv.contains("偏差")){
|
|
|
|
+ deCell=cell;
|
|
|
|
+ break outerLoop;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(deCell!=null) {
|
|
|
|
+ int min = 0;
|
|
|
|
+ Optional<Integer> op = fd.getCoordsList().stream().map(Coords::getY).distinct().min(Comparator.comparingInt(e -> e));
|
|
|
|
+ if (op.isPresent()) {
|
|
|
|
+ min = op.get();
|
|
|
|
+ }
|
|
|
|
+ Row row = sheet.getRow(min);
|
|
|
|
+ Cell cell = row.getCell(deCell.getColumnIndex());
|
|
|
|
+ devStr = FormulaUtils.getValue(cell).toString();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(CustomFunction.containsZH(devStr)||StringUtils.isEmpty(devStr)||StringUtils.handleNull(devStr).contains("/")){
|
|
|
|
+ devStr="±100000";
|
|
|
|
+ }
|
|
|
|
+ if(devStr.contains("E[")){
|
|
|
|
+ List<String> codes= getCodeByEl(devStr);
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
+ boolean isNull=false;
|
|
|
|
+ for (String c:codes){
|
|
|
|
+ FormData ffd= tec.getFormDataMap().get(c);
|
|
|
|
+ if(ffd.empty()){
|
|
|
|
+ isNull=true;
|
|
|
|
+ break;
|
|
|
|
+ } else{
|
|
|
|
+ map.put("E["+c+"]",ffd.getRawValue().stream().filter(StringUtils::isNotEmpty).findFirst().orElse(null)) ;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(isNull){
|
|
|
|
+ devStr="±100000";
|
|
|
|
+ }
|
|
|
|
+ devStr= Arrays.stream(devStr.replaceAll("^\\[|\\]$","").split(",")).map(s->map.getOrDefault(s,s)).map(StringUtils::handleNull).collect(Collectors.joining(","));
|
|
|
|
+ }
|
|
|
|
+ /*设计值可以是数值类型,或空(等效0)*/
|
|
|
|
+ if(dataFd!=null){
|
|
|
|
+ List<Object> values= dataFd.getRawValue();
|
|
|
|
+ boolean nonNumeric=values.stream().filter(StringUtils::isNotEmpty).anyMatch(e->!StringUtils.isNumber(e));
|
|
|
|
+ if(nonNumeric){
|
|
|
|
+ data=values.stream().filter(StringUtils::isNotEmpty).count();
|
|
|
|
+ }else if(designFd!=null){
|
|
|
|
+ if(dataFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNotEmpty)&&(designFd.getValues().size()>1||designFd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isEmpty))){
|
|
|
|
+ /*多少个设计值暂时默认全部合格,满足绝大部分结果*/
|
|
|
|
+ data=dataFd.getValues().stream().map(ElementData::getValue).filter(StringUtils::isNotEmpty).count();
|
|
|
|
+ }else{
|
|
|
|
+ List<Object> result = CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),designFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()),devStr,1 );
|
|
|
|
+ data=result.get(1);
|
|
|
|
+ }
|
|
|
|
+ }else if(BaseUtils.isNumber(designStr)) {
|
|
|
|
+ List<Object> result = CustomFunction.b445check(dataFd.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()), 0, devStr, 1);
|
|
|
|
+ data = result.get(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ f = f.replace(m.group(),putDataWithKey(BaseUtils.isNumber(data)?Double.parseDouble(data.toString()):data));
|
|
|
|
+ }
|
|
|
|
+ fd.getFormula().setFormula(f);
|
|
|
|
+ formula.setScale(1);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> createCurrentMap(String el){
|
|
public Map<String,Object> createCurrentMap(String el){
|
|
@@ -2219,7 +2301,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
public Map<String, FormData> createFormDataByCode(String codes) {
|
|
public Map<String, FormData> createFormDataByCode(String codes) {
|
|
if(Func.isNotBlank(codes)) {
|
|
if(Func.isNotBlank(codes)) {
|
|
List<String> codeList = Arrays.asList(codes.split(StringPool.COMMA));
|
|
List<String> codeList = Arrays.asList(codes.split(StringPool.COMMA));
|
|
- String tableNames = codeList.stream().map(e->e.split(StringPool.COLON)[0]).collect(Collectors.joining(","));
|
|
|
|
|
|
+ String tableNames = codeList.stream().map(e->e.split(StringPool.COLON)[0]).collect(Collectors.joining("','"));
|
|
/*select d.id,c.tab_ch_name tableChName,d.e_type eType,d.e_name eName,d.e_length eLength,d.e_allow_deviation eAllowDeviation,CONCAT(c.tab_en_name,':',d.e_key) code */
|
|
/*select d.id,c.tab_ch_name tableChName,d.e_type eType,d.e_name eName,d.e_length eLength,d.e_allow_deviation eAllowDeviation,CONCAT(c.tab_en_name,':',d.e_key) code */
|
|
List<FormData> fds =createFormDataByTableName(tableNames);
|
|
List<FormData> fds =createFormDataByTableName(tableNames);
|
|
if(fds!=null){
|
|
if(fds!=null){
|
|
@@ -2235,7 +2317,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
return this.getSqlList("select b.id, CONCAT(a.tab_en_name,':',b.e_key) code,a.tab_ch_name tableChName,b.e_name eName ,b.e_allow_deviation eAllowDeviation ,b.e_length eLength,c.dict_value eType " +
|
|
return this.getSqlList("select b.id, CONCAT(a.tab_en_name,':',b.e_key) code,a.tab_ch_name tableChName,b.e_name eName ,b.e_allow_deviation eAllowDeviation ,b.e_length eLength,c.dict_value eType " +
|
|
"from m_table_info a JOIN m_wbs_form_element b on a.id=b.f_id and b.is_deleted=0 " +
|
|
"from m_table_info a JOIN m_wbs_form_element b on a.id=b.f_id and b.is_deleted=0 " +
|
|
"LEFT JOIN (select dict_key, dict_value from blade_dict where code ='data_type' and parent_id > 0 and is_sealed = 0 and is_deleted = 0 )c on b.e_type=c.dict_key" +
|
|
"LEFT JOIN (select dict_key, dict_value from blade_dict where code ='data_type' and parent_id > 0 and is_sealed = 0 and is_deleted = 0 )c on b.e_type=c.dict_key" +
|
|
- " where a.tab_en_name in( "+ tableNames+")"
|
|
|
|
|
|
+ " where a.tab_en_name in('"+ tableNames+"')"
|
|
, FormData.class);
|
|
, FormData.class);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2254,10 +2336,126 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void paramFormula(WbsTreeContract wtc, Map<String, Object> dataMap, Document doc) {
|
|
|
|
+ try {
|
|
|
|
+ if(!isForm){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
|
+ stopWatch.start("表单公式");
|
|
|
|
+ /*获取当前表所有元素*/
|
|
|
|
+ List<FormData> fds=createFormDataByTableName(wtc.getInitTableName());
|
|
|
|
+ /*过滤掉已经存在内容的元素*/
|
|
|
|
+ Set<String> filterSet= dataMap.keySet().stream().map(s->s.split("__")[0]).collect(Collectors.toSet());
|
|
|
|
+ fds.removeIf(f->filterSet.contains(f.getKey()));
|
|
|
|
+ /*获取元素定位信息,过滤掉绑定单元格数量不为1的元素*/
|
|
|
|
+ Map<String,String> map = FormulaUtils.getElementCell(wtc.getHtmlUrl(),null,doc);
|
|
|
|
+ for(FormData fd:fds){
|
|
|
|
+ String coords= map.get(fd.getKey());
|
|
|
|
+ if(Func.isNotBlank(coords)){
|
|
|
|
+ fd.flushCoords(coords);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fds.removeIf(f->f.getCoordsList().size()!=1);
|
|
|
|
+ /*工序节点*/
|
|
|
|
+ WbsTreeContract node = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getId, wtc.getParentId()).eq(WbsTreeContract::getContractId,wtc.getContractId()));
|
|
|
|
+ /*项目节点*/
|
|
|
|
+ WbsTreePrivate wtp = this.wtpId(node.getPKeyId());
|
|
|
|
+ /*WBS*/
|
|
|
|
+ WbsTreePrivate publicWtp = this.getOriginWtp(wtp.getPKeyId());
|
|
|
|
+
|
|
|
|
+ Map<String,Object> result = new HashMap<>(100);
|
|
|
|
+ List<WbsParam> total = new ArrayList<>();
|
|
|
|
+ List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,publicWtp.getId()).eq(WbsParam::getType,1));
|
|
|
|
+ if(Func.isNotEmpty(wpsPublic)){
|
|
|
|
+ total.addAll(wpsPublic);
|
|
|
|
+ }
|
|
|
|
+ List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wtp.getPKeyId()).eq(WbsParam::getType,1));
|
|
|
|
+ if(Func.isNotEmpty(wpsPrivate)){
|
|
|
|
+ total.addAll(wpsPrivate);
|
|
|
|
+ }
|
|
|
|
+ if(CollectionUtil.isNotEmpty(total)){
|
|
|
|
+ /*同名参数私有覆盖公用*/
|
|
|
|
+ for(WbsParam p:total){
|
|
|
|
+ result.put(p.getK(),p.getV());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Map<Long,String> paramIdKeyMap= total.stream().collect(Collectors.toMap(WbsParam::getId,WbsParam::getK));
|
|
|
|
+ /*元素动态绑定*/
|
|
|
|
+ Map<String,Formula> formulaIdMap = this.wpService.formulaKeyMap(total.stream().map(WbsParam::getK).collect(Collectors.toList()));
|
|
|
|
+ /*获取已配置节点公式*/
|
|
|
|
+ if(Func.isNotEmpty(total)){
|
|
|
|
+ List<ElementFormulaMapping> mappingList = this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().in(ElementFormulaMapping::getParamId,total.stream().map(WbsParam::getId).collect(Collectors.toList())));
|
|
|
|
+ if(Func.isNotEmpty(mappingList)){
|
|
|
|
+ fds.forEach(e->{
|
|
|
|
+ mappingList.stream().filter(m->StringUtils.isEquals(m.getElementId(),e.getId())).findAny().ifPresent(d->{
|
|
|
|
+ String key = paramIdKeyMap.get(d.getParamId());
|
|
|
|
+ Formula formula=formulaIdMap.computeIfAbsent(key,k->this.getById(d.getFormulaId()));
|
|
|
|
+ if(formula!=null){
|
|
|
|
+ e.setFormulaId(formula.getId());
|
|
|
|
+ e.setFormula(formula);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*检查是否可以自动绑定参数公式*/
|
|
|
|
+ List<FormData> notFormulaFds=fds.stream().filter(f->f.getFormulaId()==null).collect(Collectors.toList());
|
|
|
|
+ if(notFormulaFds.size()>0){
|
|
|
|
+ notFormulaFds.forEach(e->{
|
|
|
|
+ /*暂时用参数名称是否包含元素名称作为匹配规则*/
|
|
|
|
+ total.stream().filter(p->e.getEName().contains(p.getName().replaceAll("【[\\u4E00-\\u9FFF]+】|\\s+",""))).findAny().ifPresent(d->{
|
|
|
|
+ Formula tf= formulaIdMap.get(d.getK());
|
|
|
|
+ if(tf!=null&&e.getId()!=null) {
|
|
|
|
+ e.setFormula(tf);
|
|
|
|
+ ElementFormulaMapping efm = new ElementFormulaMapping();
|
|
|
|
+ efm.setScope(FormulaBean.PARAM);
|
|
|
|
+ efm.setParamId(d.getId());
|
|
|
|
+ efm.setElementId(e.getId());
|
|
|
|
+ efm.setFormulaId(tf.getId());
|
|
|
|
+ this.elementFormulaMappingService.save(efm);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ /*执行结果放回数据集合*/
|
|
|
|
+ Map<String,Object> currentMap = new HashMap<>(30);
|
|
|
|
+ /*获取祖先联链*/
|
|
|
|
+ List<WbsTreeContract> nodes =this.wpService.tracing(node.getPKeyId());
|
|
|
|
+ currentMap.put(CHAIN,nodes.stream().map(e->StringUtils.isNotEmpty(e.getFullName())?e.getFullName():e.getNodeName()).collect(Collectors.toList()));
|
|
|
|
+ /*节点参数*/
|
|
|
|
+ currentMap.put(WP,result);
|
|
|
|
+ fds.forEach(fd->{
|
|
|
|
+ if(fd.executable()){
|
|
|
|
+ String tmp =fd.getFormula().getFormula().replaceAll("[\\s]+","");
|
|
|
|
+ tmp = tmp.replace(FC, CustomFunction.CLASS_CALL);
|
|
|
|
+ if(tmp.contains("WP[")){
|
|
|
|
+ Matcher am = AP.matcher(tmp);
|
|
|
|
+ while (am.find()){
|
|
|
|
+ tmp = tmp.replace(am.group(),am.group(1)+"['"+am.group(2)+"']");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Object data =Expression.parse(tmp).calculate(currentMap);
|
|
|
|
+ if(StringUtils.isNotEmpty(data)){
|
|
|
|
+ Coords coords=fd.getCoordsList().get(0);
|
|
|
|
+ /*计算结果放回结果集 */
|
|
|
|
+ dataMap.put(fd.getKey()+"__"+coords.getY()+"_"+coords.getX(),data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ stopWatch.stop();
|
|
|
|
+ long totalTime = stopWatch.getTotalTimeMillis();
|
|
|
|
+ StaticLog.info("表单公式执行用时:{}", totalTime);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|