|
@@ -874,36 +874,40 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
/**汇总处理*/
|
|
/**汇总处理*/
|
|
public void summaryCalc(){
|
|
public void summaryCalc(){
|
|
- if(this.summary.size()>0){
|
|
|
|
- /**/
|
|
|
|
- List<String> result=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.toList());
|
|
|
|
- Optional<FormData> opk= this.summary.stream().filter(FormData::executable).filter(f->StringUtils.isEquals(f.getFormula().getNumber(),CHECK_ITEMS)).findAny();
|
|
|
|
- List<String> history=null;
|
|
|
|
- if(opk.isPresent()&&!opk.get().empty()){
|
|
|
|
- /*假如已经存在内容,则需要筛选出手填部分*/
|
|
|
|
- history= Arrays.asList(opk.get().getValues().get(0).stringValue().replaceAll("[\\s\\n]+","").split("[,、,]"));
|
|
|
|
- }
|
|
|
|
- if(history!=null&&history.size()>0){
|
|
|
|
- List<String> itemAll=this.checkItems.stream().map(FormData::getEName).map(FormulaUtils::parseItemName).distinct().collect(Collectors.toList());
|
|
|
|
- List<String> customize=history.stream().filter(s->!itemAll.contains(s)).collect(Collectors.toList());
|
|
|
|
- result.addAll(customize);
|
|
|
|
- }
|
|
|
|
- this.constantMap.put(CHECK_ITEMS,result);
|
|
|
|
- this.constantMap.put("CKD",this.checkDate.stream().flatMap(k->k.getValues().stream()).map(ElementData::stringValue).filter(StringUtils::isNotEmpty).reduce((a, b) -> Comparator.<DateTime>reverseOrder().compare(new DateTime(a), new DateTime(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);
|
|
|
|
|
|
+ try{
|
|
|
|
+ if(this.summary.size()>0){
|
|
|
|
+ /**/
|
|
|
|
+ List<String> result=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.toList());
|
|
|
|
+ Optional<FormData> opk= this.summary.stream().filter(FormData::executable).filter(f->StringUtils.isEquals(f.getFormula().getNumber(),CHECK_ITEMS)).findAny();
|
|
|
|
+ List<String> history=null;
|
|
|
|
+ if(opk.isPresent()&&!opk.get().empty()){
|
|
|
|
+ /*假如已经存在内容,则需要筛选出手填部分*/
|
|
|
|
+ history= Arrays.asList(opk.get().getValues().get(0).stringValue().replaceAll("[\\s\\n]+","").split("[,、,]"));
|
|
}
|
|
}
|
|
- });
|
|
|
|
- /*分项汇总*/
|
|
|
|
- doForDataBlock();
|
|
|
|
|
|
+ if(history!=null&&history.size()>0){
|
|
|
|
+ List<String> itemAll=this.checkItems.stream().map(FormData::getEName).map(FormulaUtils::parseItemName).distinct().collect(Collectors.toList());
|
|
|
|
+ List<String> customize=history.stream().filter(s->!itemAll.contains(s)).collect(Collectors.toList());
|
|
|
|
+ result.addAll(customize);
|
|
|
|
+ }
|
|
|
|
+ this.constantMap.put(CHECK_ITEMS,result);
|
|
|
|
+ this.constantMap.put("CKD",this.checkDate.stream().flatMap(k->k.getValues().stream()).map(ElementData::stringValue).filter(StringUtils::isNotEmpty).reduce((a, b) -> Comparator.<DateTime>reverseOrder().compare(new DateTime(a), new DateTime(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);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ /*分项汇总*/
|
|
|
|
+ doForDataBlock();
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|