|
@@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @Description: prediction_table
|
|
@@ -51,6 +53,11 @@ public class PredictionTableServiceImpl extends ServiceImpl<PredictionTableMappe
|
|
|
public PredictionInfo saveOrUpdateTable(PredictionTable predictionTable) {
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
PredictionInfo predictionInfo = predictionInfoMapper.selectById(predictionTable.getPredictionId());
|
|
|
+ List<PredictionColumns> columnsList = predictionColumnsMapper.selectList(new LambdaQueryWrapper<PredictionColumns>()
|
|
|
+ .eq(PredictionColumns::getPredictionId, predictionTable.getPredictionId()));
|
|
|
+ List<PredictionColumns> large = columnsList.stream().filter(col -> col.getColName().equals("大类")).toList();
|
|
|
+ List<PredictionColumns> small = columnsList.stream().filter(col -> col.getColName().equals("小类")).toList();
|
|
|
+ List<PredictionColumns> func = columnsList.stream().filter(col -> col.getColName().equals("预计方法")).toList();
|
|
|
PredictionTable table = predictionTableMapper.selectOne(new LambdaQueryWrapper<PredictionTable>()
|
|
|
.eq(PredictionTable::getPredictionId, predictionTable.getPredictionId())
|
|
|
.eq(PredictionTable::getStruId, predictionTable.getStruId())
|
|
@@ -61,6 +68,19 @@ public class PredictionTableServiceImpl extends ServiceImpl<PredictionTableMappe
|
|
|
table.setUpdateTime(new Date());
|
|
|
table.setVersionNo(table.getVersionNo()+1);
|
|
|
predictionTableMapper.updateById(table);
|
|
|
+
|
|
|
+ List<PredictionTable> predictionTables = predictionTableMapper.selectList(new LambdaQueryWrapper<PredictionTable>()
|
|
|
+ .eq(PredictionTable::getPredictionId, predictionTable.getPredictionId())
|
|
|
+ .eq(PredictionTable::getStruId, predictionTable.getStruId()));
|
|
|
+ predictionTables.forEach(tb -> {
|
|
|
+ if ((predictionTable.getColumnsId().equals(func.get(0).getId()) &&
|
|
|
+ (tb.getColumnsId().equals(large.get(0).getId()) || tb.getColumnsId().equals(small.get(0).getId()))) ||
|
|
|
+ (predictionTable.getColumnsId().equals(large.get(0).getId()) && tb.getColumnsId().equals(small.get(0).getId()))) {
|
|
|
+ predictionTableMapper.deleteById(tb.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
} else {
|
|
|
predictionTable.setCreateBy(sysUser.getUsername());
|
|
|
predictionTable.setCreateTime(new Date());
|