|
@@ -502,15 +502,14 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if(data instanceof List){
|
|
|
List<Object> values = (List<Object>) data;
|
|
|
if(values.size()>fd.getValues().size()){
|
|
|
- /*当生成的数据超过实际容量的时候,会自动合并到第一个单元格*/
|
|
|
- if(fd.getValues().size()==1){
|
|
|
+ /*当生成的数据超过实际容量的时候,会自动追加页数*/
|
|
|
+ if(fd.getCoordsList().size()==1){
|
|
|
fd.getValues().get(0).setValue(values.stream().map(StringUtils::handleNull).collect(Collectors.joining("、")));
|
|
|
}else{
|
|
|
- for(int n=0;n<fd.getValues().size()-1;n++){
|
|
|
+ copy(fd,values);
|
|
|
+ for(int n=0;n<fd.getValues().size();n++){
|
|
|
fd.getValues().get(n).setValue(values.get(n));
|
|
|
}
|
|
|
- /*元素存在多个单元格,写不下的数据在最后一个单元格合并*/
|
|
|
- fd.getValues().get(fd.getValues().size()-1).setValue(values.stream().skip(fd.getValues().size()-1).map(StringUtils::handleNull).collect(Collectors.joining("、")));
|
|
|
}
|
|
|
|
|
|
}else{
|
|
@@ -529,47 +528,53 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void copy(FormData fd){
|
|
|
+ /**加页增容*/
|
|
|
+ public void copy(FormData fd, List<Object> values){
|
|
|
WbsTreeContract origin = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,fd.getTableIds().get(fd.getTableIds().size()-1)));
|
|
|
if(origin!=null){
|
|
|
- /*复制表*/
|
|
|
- WbsTreeContract target = new WbsTreeContract();
|
|
|
- BeanUtil.copy(origin,target);
|
|
|
- target.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- this.wbsTreeContractService.saveOrUpdate(target);
|
|
|
- tec.getKeyMappers().stream().filter(e->e.getPkId().equals(origin.getPKeyId())).findFirst().ifPresent(d->{
|
|
|
- /*添加KeyMapper映射关系*/
|
|
|
- KeyMapper km = new KeyMapper();
|
|
|
- BeanUtil.copy(d,km);
|
|
|
- km.setPkId(target.getPKeyId());
|
|
|
- tec.getKeyMappers().add(km);
|
|
|
- tec.getTableInfoList().stream().filter(o->StringUtils.isEquals(o.getPkeyId(),origin.getPKeyId())).findFirst().ifPresent(tb->{
|
|
|
- /*表单数据复制*/
|
|
|
- TableInfo tableInfo = new TableInfo();
|
|
|
- BeanUtil.copy(tb,tableInfo);
|
|
|
- tableInfo.setDataMap(new LinkedHashMap<>());
|
|
|
- tec.getTableInfoList().add(tableInfo);
|
|
|
-
|
|
|
+ int pageSize = fd.getCoordsList().size();
|
|
|
+ int pageAdd=(int)Math.ceil((double)(values.size()-fd.getValues().size())/(double) pageSize);
|
|
|
+ for(int i=0;i<pageAdd;i++){
|
|
|
+ /*复制表*/
|
|
|
+ WbsTreeContract target = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(origin,target);
|
|
|
+ target.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ this.wbsTreeContractService.saveOrUpdate(target);
|
|
|
+ tec.getKeyMappers().stream().filter(e->e.getPkId().equals(origin.getPKeyId())).findFirst().ifPresent(d->{
|
|
|
+ /*添加KeyMapper映射关系*/
|
|
|
+ KeyMapper km = new KeyMapper();
|
|
|
+ BeanUtil.copy(d,km);
|
|
|
+ km.setPkId(target.getPKeyId());
|
|
|
+ tec.getKeyMappers().add(km);
|
|
|
+ tec.getTableInfoList().stream().filter(o->StringUtils.isEquals(o.getPkeyId(),origin.getPKeyId())).findFirst().ifPresent(tb->{
|
|
|
+ /*表单数据复制*/
|
|
|
+ TableInfo tableInfo = new TableInfo();
|
|
|
+ BeanUtil.copy(tb,tableInfo);
|
|
|
+ tableInfo.setDataMap(new LinkedHashMap<>());
|
|
|
+ tec.getTableInfoList().add(tec.getTableInfoList().indexOf(tb)+1,tableInfo);
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
+ enlarge(fd,pageAdd);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void enlarge(FormData fd,int size){
|
|
|
- int pageSize = fd.getCoordsList().size();
|
|
|
- int pageAdd=(int)Math.ceil((double)size/(double) pageSize);
|
|
|
- Map<String,List<KeyMapper>> kmMap = this.tec.getKeyMappers().stream().collect(Collectors.groupingBy(KeyMapper::getTableName));
|
|
|
- List<KeyMapper> kms = kmMap.get(fd.getTableName());
|
|
|
- kms.forEach(k->{
|
|
|
- FormData tmp = tec.getFormDataMap().get(k.getCode());
|
|
|
+ public void enlarge(FormData fd,int pageAdd){
|
|
|
+ List<FormData> targetList = tec.getFormDataMap().values().stream().filter(e->StringUtils.isEquals(fd.getTableName(),e.getTableName())).collect(Collectors.toList());
|
|
|
+ targetList.forEach(tmp->{
|
|
|
if(tmp!=null){
|
|
|
List<Coords> list = tmp.getCoordsList();
|
|
|
ElementData last = tmp.getValues().get(tmp.getValues().size()-1);
|
|
|
int index =last.getIndex();
|
|
|
int groupId=last.getGroupId();
|
|
|
+ Object data=null;
|
|
|
+ if(Formula.FULL.equals(tmp.getFormula().getOutm())){
|
|
|
+ data=tmp.getValues().get(tmp.getValues().size()-1);
|
|
|
+ }
|
|
|
for(int i=0;i<pageAdd;i++){
|
|
|
int finalIndex = index;
|
|
|
- tmp.getValues().addAll(list.stream().map(c-> new ElementData(finalIndex,groupId,null,c.getX(),c.getY())).collect(Collectors.toList()));
|
|
|
+ Object finalData = data;
|
|
|
+ tmp.getValues().addAll(list.stream().map(c-> new ElementData(finalIndex,groupId, finalData,c.getX(),c.getY())).collect(Collectors.toList()));
|
|
|
index++;
|
|
|
}
|
|
|
}
|
|
@@ -610,7 +615,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if(Func.isNotEmpty(listMap)){
|
|
|
/*当前节点的某个元素存在多种作用域的公式,作用域范围越小优先级越高*/
|
|
|
List<KeyMapper> list= listMap.stream().map(m->BeanUtil.toBean(m,KeyMapper.class)).collect(Collectors.toList());
|
|
|
- Set<KeyMapper> set = new HashSet<>(list.size()*2);
|
|
|
String nodeIdStr=nodeIds.stream().map(Object::toString).collect(Collectors.joining(StringPool.COMMA));
|
|
|
StringBuilder sb = new StringBuilder("select element_id elementId,formula_id formulaId,scope from m_element_formula_mapping where element_id in("+list.stream().map(KeyMapper::getFieldId).map(Func::toStr).collect(Collectors.joining(","))+") and is_deleted=0 ");
|
|
|
sb.append(" and ( scope<2 or (scope=2 and node_id in(").append(nodeIdStr).append(")) or (scope =10 and project_id = ").append(projectId).append(") or (scope=20 and project_id =").append(projectId).append(" and node_id in (").append(nodeIdStr).append(")))");
|
|
@@ -622,13 +626,12 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if(Func.isNotEmpty(tmp)){
|
|
|
tmp.stream().max(Comparator.comparing(oo->Func.toInt(oo.get("scope")))).ifPresent(d->{
|
|
|
e.setFormulaId(Func.toLong(d.get("formulaId")));
|
|
|
- set.add(e);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- if(set.size()>0){
|
|
|
- return new ArrayList<>(set);
|
|
|
+ if(list.size()>0){
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|
|
|
return Collections.emptyList();
|