修复分页和编辑保存异常
This commit is contained in:
parent
33ad6d0b28
commit
66c2cea19e
|
@ -74,7 +74,10 @@ public class IndicatorController {
|
|||
setSuccess(result);
|
||||
|
||||
if(list != null){
|
||||
result.setData(list);
|
||||
HashMap<String, Object> hashMap =new HashMap<>();
|
||||
hashMap.put("data", list);
|
||||
hashMap.put("totalCount", result.getTotal());
|
||||
result.setData(hashMap);
|
||||
if(result.getTotal() == null){
|
||||
result.setTotal((long) list.size());
|
||||
}
|
||||
|
@ -459,21 +462,27 @@ public class IndicatorController {
|
|||
}
|
||||
|
||||
if(label_list != null && label_list.size()>0){
|
||||
boolean saveTmpFlag = false;
|
||||
for (int i = 0; i < label_list.size(); i++) {
|
||||
if(!updateFlag){
|
||||
if(i > 0 && i <(label_list.size())) {
|
||||
label_list.get(i).setParentId(label_list.get(i-1).getId());
|
||||
}
|
||||
label_list.get(i).setCreateTime(date);
|
||||
saveTmpFlag = true;
|
||||
}else {
|
||||
if (label_list.get(i).getId() == null) {
|
||||
log.error("-------- 保存指标异常, 更新指标时, 标签id不能为空" + label_list.get(i));
|
||||
throw new RuntimeException("更新指标时, 标签id不能为空" + label_list.get(i));
|
||||
// 新增指标
|
||||
if(i > 0 && i <(label_list.size())) {
|
||||
label_list.get(i).setParentId(label_list.get(i-1).getId());
|
||||
}
|
||||
label_list.get(i).setCreateTime(date);
|
||||
saveTmpFlag = true;
|
||||
} else {
|
||||
List<IndicatorLabel> I_L_list = indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId, indicator.getId()).list();
|
||||
boolean ILFlag = false;
|
||||
for (int j = 0; j < I_L_list.size(); j++) {
|
||||
if(label_list.get(i).getId() == I_L_list.get(j).getLabelId()){
|
||||
if (label_list.get(i).getId().equals(I_L_list.get(j).getLabelId())) {
|
||||
ILFlag = true;
|
||||
}
|
||||
}
|
||||
|
@ -484,6 +493,7 @@ public class IndicatorController {
|
|||
Label label = labelRepository.getById(label_list.get(i).getId());
|
||||
label_list.get(i).setParentId(label.getParentId());
|
||||
}
|
||||
}
|
||||
label_list.get(i).setTableName(tableName);
|
||||
label_list.get(i).setUpdateTime(date);
|
||||
if(i == label_list.size()-1){
|
||||
|
@ -493,7 +503,7 @@ public class IndicatorController {
|
|||
|
||||
System.out.println("___"+label_list.get(i).getId());
|
||||
if(label_flag){
|
||||
if(!updateFlag){
|
||||
if(!updateFlag || saveTmpFlag){
|
||||
IndicatorLabel indicator_label = new IndicatorLabel();
|
||||
indicator_label.setIndicatorId(indicator.getId());
|
||||
indicator_label.setLabelId(label_list.get(i).getId());
|
||||
|
@ -624,7 +634,7 @@ public class IndicatorController {
|
|||
public Result searchIndicator(@RequestBody Search search) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
Page<IndicatorVo> query = new Page(search.getCurrentPage(), search.getPageSize());
|
||||
Page<IndicatorVo> query = new Page(search.getCurrentPage()-1, search.getPageSize());
|
||||
Page<IndicatorVo> page = indicatorMapper.getIndicatorPage(query,search.getValue());
|
||||
for (IndicatorVo vo : page.getRecords()) {
|
||||
LambdaQueryChainWrapper<IndicatorLabel> wrapper = indicatorLabelRepository.lambdaQuery().eq(IndicatorLabel::getIndicatorId,vo.getId());
|
||||
|
@ -632,7 +642,7 @@ public class IndicatorController {
|
|||
for (IndicatorLabel indicatorLabel : wrapper.select(IndicatorLabel::getLabelId).list()) {
|
||||
list.add(indicatorLabel.getLabelId());
|
||||
}
|
||||
List<Label> labelList = labelMapper.selectBatchIds(list);
|
||||
List<Label> labelList = labelRepository.lambdaQuery().in(Label::getId,list).orderByAsc(Label::getLabelLevel).list();
|
||||
vo.setLableList(labelList);
|
||||
}
|
||||
result.setTotal(page.getTotal());
|
||||
|
|
Loading…
Reference in New Issue