陈昶聿
20 小时以前 a2dd5b42824eff9626d1f48e1561be85f17f6107
smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateScriptServiceImpl.java
@@ -16,6 +16,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static net.sf.jsqlparser.parser.feature.Feature.values;
@@ -157,25 +158,28 @@
                    }
                }
                itemCounts.forEach(itemCount ->{
                    if(ObjectUtils.isNotEmpty(count.getScriptid()) && ObjectUtils.isNotEmpty(itemCount.getScriptid())){
                        if(count.getScriptid().equals(itemCount.getScriptid())){
                            //放入统计信息
                            itemCount.setScriptContent(count.getScriptContent());
                            itemCount.setScriptType(count.getScriptType());
                            itemCount.setSubtaskType(count.getSubtaskType());
                            itemCount.setCompletedQuantity(count.getCompletedQuantity());
                            itemCount.setAllQuantity(count.getAllQuantity());
                            itemCount.setCompletedPercentage(count.getCompletedPercentage());
                            itemCount.setTemplateid(count.getTemplateid());
                            //计算选择比例
                            int chosenQuantity = ObjectUtils.isNotEmpty(itemCount.getChosenQuantity())?itemCount.getChosenQuantity():0;
                            int completedQuantity = itemCount.getCompletedQuantity();
                            if(ObjectUtils.isNotEmpty(completedQuantity) && completedQuantity != 0){
                                BigDecimal chosenPercentage = (new BigDecimal(chosenQuantity)).divide(new BigDecimal(completedQuantity), 2, RoundingMode.HALF_UP);
                                itemCount.setChosenPercentage(chosenPercentage.toString());
                            }
                            itemCountMap.put(itemCount.getOptionText(), itemCount);
                    //明细行已按“题目内容+任务类型”聚合,不能用 scriptid 匹配(同一道题在每个任务模板里的 scriptid 都不同)
                    boolean sameQuestion = ObjectUtils.isNotEmpty(count.getScriptContent())
                            && ObjectUtils.isNotEmpty(itemCount.getScriptContent())
                            && count.getScriptContent().equals(itemCount.getScriptContent())
                            && Objects.equals(count.getSubtaskType(), itemCount.getSubtaskType());
                    if(sameQuestion){
                        //放入统计信息
                        itemCount.setScriptContent(count.getScriptContent());
                        itemCount.setScriptType(count.getScriptType());
                        itemCount.setSubtaskType(count.getSubtaskType());
                        itemCount.setCompletedQuantity(count.getCompletedQuantity());
                        itemCount.setAllQuantity(count.getAllQuantity());
                        itemCount.setCompletedPercentage(count.getCompletedPercentage());
                        itemCount.setTemplateid(count.getTemplateid());
                        //计算选择比例
                        int chosenQuantity = ObjectUtils.isNotEmpty(itemCount.getChosenQuantity())?itemCount.getChosenQuantity():0;
                        int completedQuantity = itemCount.getCompletedQuantity();
                        if(ObjectUtils.isNotEmpty(completedQuantity) && completedQuantity != 0){
                            BigDecimal chosenPercentage = (new BigDecimal(chosenQuantity)).divide(new BigDecimal(completedQuantity), 2, RoundingMode.HALF_UP);
                            itemCount.setChosenPercentage(chosenPercentage.toString());
                        }
                        itemCountMap.put(itemCount.getOptionText(), itemCount);
                    }
                });
                List<ServiceSubtaskScriptCount> details = new ArrayList<>(itemCountMap.values());