|
@@ -15,6 +15,7 @@ import org.apache.poi.ss.usermodel.*;
|
|
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;
|
|
|
|
+import org.springblade.core.mp.base.BaseEntity;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.utils.*;
|
|
import org.springblade.core.tool.utils.*;
|
|
@@ -1364,6 +1365,38 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void formulaInto(List<FormData> curFormDatas, String projectId, String nodeId, ExecuteType executeType) {
|
|
|
|
+ if(executeType.equals(ExecuteType.INSPECTION)){
|
|
|
|
+ WbsTreePrivate wtp =wtpId(Long.parseLong(nodeId));
|
|
|
|
+ /*项目级*/
|
|
|
|
+ Long nodeIdPrivate= wtp.getId();
|
|
|
|
+ WbsTreePrivate origin =getOriginWtp(wtp.getPKeyId());
|
|
|
|
+ String wbsId =StringUtils.handleNull(origin.getPKeyId());
|
|
|
|
+ /*Wbs对应的节点*/
|
|
|
|
+ Long nodeIdWbs=origin.getId();
|
|
|
|
+ List<Map<String,Object>> efMap= this.jdbcTemplate.queryForList("select element_id elementId,formula_id formulaId,scope " +
|
|
|
|
+ "from m_element_formula_mapping " +
|
|
|
|
+ "where element_id in(" + curFormDatas.stream().map(FormData::getId).map(Func::toStr).collect(Collectors.joining(",")) + ") " +
|
|
|
|
+ "and is_deleted=0 " + " and (scope=0 or (scope=1 and wbs_id="+wbsId+") or(scope=2 and wbs_id="+wbsId+" and node_id="+nodeIdWbs+")or (scope =10 and project_id = " + projectId + ") or (scope=20 and project_id =" + projectId + " and node_id=" +nodeIdPrivate +"))");
|
|
|
|
+ setFormula2(curFormDatas,efMap);
|
|
|
|
+ /*节点参数公式*/
|
|
|
|
+ setParamsFormula2( wtp.getPKeyId(),origin.getId(),curFormDatas);
|
|
|
|
+ List<Long> formulaIds = curFormDatas.stream().map(FormData::getFormulaId).distinct().collect(Collectors.toList());
|
|
|
|
+ if(formulaIds.size()>0) {
|
|
|
|
+ List<Formula> formulaList = this.listByIds(formulaIds);
|
|
|
|
+ if (formulaList.size() > 0) {
|
|
|
|
+ Map<Long, Formula> idMap = formulaList.stream().collect(Collectors.toMap(Formula::getId, f -> f, (p, n) -> n));
|
|
|
|
+ for (FormData fd : curFormDatas) {
|
|
|
|
+ fd.setFormula(idMap.get(fd.getFormulaId()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else if(executeType.equals(ExecuteType.TESTING)){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public WbsTreePrivate getOriginWtp(Long pkeyId) {
|
|
public WbsTreePrivate getOriginWtp(Long pkeyId) {
|
|
WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId,pkeyId));
|
|
WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId,pkeyId));
|
|
@@ -1480,7 +1513,31 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ private void setParamsFormula2(Long privatePkeyId,Long wbsNodeId, List<FormData> list){
|
|
|
|
+ if(StringUtils.isNotEmpty(privatePkeyId,wbsNodeId)){
|
|
|
|
+ List<WbsParam> total = new ArrayList<>();
|
|
|
|
+ List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wbsNodeId));
|
|
|
|
+ /*同时获取WBS和 项目级的节点参数,如果存在同名则项目级覆盖WBS*/
|
|
|
|
+ if(Func.isNotEmpty(wpsPublic)){
|
|
|
|
+ total.addAll(wpsPublic);
|
|
|
|
+ }
|
|
|
|
+ List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,privatePkeyId));
|
|
|
|
+ if(Func.isNotEmpty(wpsPrivate)){
|
|
|
|
+ total.addAll(wpsPrivate);
|
|
|
|
+ }
|
|
|
|
+ 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)){
|
|
|
|
+ list.forEach(e->{
|
|
|
|
+ mappingList.stream().filter(m->StringUtils.isEquals(m.getElementId(),e.getId())).findAny().ifPresent(d-> e.setFormulaId(d.getFormulaId()));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
private List<KeyMapper> listForPrivate(List<Long> ids,String projectId,String nodeId){
|
|
private List<KeyMapper> listForPrivate(List<Long> ids,String projectId,String nodeId){
|
|
/**/
|
|
/**/
|
|
List<Map<String,Object>> listMap = listMap(ids,ExecuteType.TESTING);
|
|
List<Map<String,Object>> listMap = listMap(ids,ExecuteType.TESTING);
|
|
@@ -1522,6 +1579,19 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ private void setFormula2(List<FormData> list,List<Map<String,Object>> efMap){
|
|
|
|
+ if(Func.isNotEmpty(efMap)){
|
|
|
|
+ Map<Long,List<Map<String,Object>>> efGroup= efMap.stream().collect(Collectors.groupingBy(e->Func.toLong(e.get("elementId"))));
|
|
|
|
+ list.forEach(e->{
|
|
|
|
+ List<Map<String,Object>> tmp = efGroup.get(e.getId());
|
|
|
|
+ if(Func.isNotEmpty(tmp)){
|
|
|
|
+ tmp.stream().max(Comparator.comparing(oo->Func.toInt(oo.get("scope")))).ifPresent(d->{
|
|
|
|
+ e.setFormulaId(Func.toLong(d.get("formulaId")));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<Formula> getFormulaList(List<KeyMapper> keyMapperList) {
|
|
public List<Formula> getFormulaList(List<KeyMapper> keyMapperList) {
|
|
@@ -1537,42 +1607,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-/* public List<Object> slice(List<LocalVariable> local,String formula){
|
|
|
|
- int min =0;
|
|
|
|
- List<Object> result = new ArrayList<>();
|
|
|
|
- try {
|
|
|
|
- pretreatment(local,formula);
|
|
|
|
- List<Object> r= local.stream().map(e-> {
|
|
|
|
- *//*所有依赖元素的内容必须非空才进行计算,否则返回空值*//*
|
|
|
|
- return e.hasEmptyElementValue()?"": Expression.parse(e.getFormula()).calculate(e.getCurrentMap());
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- if(CollectionUtil.isNotEmpty(r)&&r.stream().anyMatch(StringUtils::isNotEmpty)){
|
|
|
|
- result.addAll(r);
|
|
|
|
- }
|
|
|
|
- }catch (Exception e){
|
|
|
|
- StaticLog.error("公式:{},执行出错",formula);
|
|
|
|
- }
|
|
|
|
- return result;
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
-/* public void pretreatment(List<LocalVariable> local,String formula){
|
|
|
|
- formula=StringUtils.removeMultiSpace(formula);
|
|
|
|
- if(formula.contains("LIST")){
|
|
|
|
- Matcher m=RegexUtils.matcher("\\(([^)]*)\\)/LIST",formula);
|
|
|
|
- while (m.find()){
|
|
|
|
- List<String> codes=FormulaUtils.getCodeList(m.group(1).replaceAll("[+-]",","));
|
|
|
|
- local=local.stream().peek(e->{
|
|
|
|
- @SuppressWarnings("unckecked")
|
|
|
|
- Map<String,Object> map = (Map<String, Object>) e.getCurrentMap().getOrDefault(E,new HashMap<>());
|
|
|
|
- int listSize=(int)codes.stream().filter(c->StringUtils.isNotEmpty(map.get(c))).count();
|
|
|
|
- if(listSize<=0||listSize>codes.size()){
|
|
|
|
- listSize=codes.size();
|
|
|
|
- }
|
|
|
|
- map.put("LIST",listSize);
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
|
|
|
|
|
|
|
|
public static void sort( List<FormData> list,int n){
|
|
public static void sort( List<FormData> list,int n){
|
|
@@ -1918,16 +1952,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /*从方法参数中获取全部code*/
|
|
|
|
-/* public List<String> getCodeList(String param){
|
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
|
- if(StringUtils.isNotEmpty(param)){
|
|
|
|
- Arrays.stream(param.split(",")).forEach(s->{
|
|
|
|
- list.add(s.replaceAll("[E\\[\\]']",""));
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
- }*/
|
|
|
|
|
|
+
|
|
|
|
|
|
public List<String> getCodeByEl(String el){
|
|
public List<String> getCodeByEl(String el){
|
|
List<String> l = new ArrayList<>();
|
|
List<String> l = new ArrayList<>();
|