Przeglądaj źródła

驾驶舱数据 修改接口

master
PoffyZhang 1 rok temu
rodzic
commit
f00c16f2f7
2 zmienionych plików z 22 dodań i 19 usunięć
  1. +3
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/DashboardController.java
  2. +19
    -17
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/CockpitStatsManage.java

+ 3
- 2
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/DashboardController.java Wyświetl plik

@@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.UnknownHostException;
import java.util.List;

/**
* @author liuxinxin
@@ -85,8 +86,8 @@ public class DashboardController {

@PostMapping("cockpit-stats-save")
@ApiOperation("驾驶舱-统计数据接口 假数据保存")
public String statsSave(@RequestBody CockpitStatsSaveDTO save) {
cockpitStatsManage.save(save);
public String statsSave(@RequestBody List<CockpitStatsSaveDTO> saves) {
cockpitStatsManage.save(saves);
return "保存成功";
}
}

+ 19
- 17
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/CockpitStatsManage.java Wyświetl plik

@@ -65,26 +65,28 @@ public class CockpitStatsManage {
return convertCockpitStats.convertCockpitStats(cockpitStats,regionCode,year,aps);
}

public void save(CockpitStatsSaveDTO save) {
List<CockpitStats> cockpitStatsList = cockpitStatsService.list(Wrappers.lambdaUpdate(CockpitStats.class)
.eq(Objects.nonNull(save.getRegionCode()), CockpitStats::getRegionCode, save.getRegionCode())
.eq(Objects.nonNull(save.getYear()), CockpitStats::getYear, save.getYear()));
if(CollUtil.isNotEmpty(cockpitStatsList)){
for(CockpitStats cockpitStats : cockpitStatsList){
BeanUtil.copyProperties(save,cockpitStats, CopyOptions.create().ignoreNullValue());
cockpitStatsService.updateById(cockpitStats);
public void save(List<CockpitStatsSaveDTO> saves) {
for(CockpitStatsSaveDTO save : saves){
List<CockpitStats> cockpitStatsList = cockpitStatsService.list(Wrappers.lambdaUpdate(CockpitStats.class)
.eq(Objects.nonNull(save.getRegionCode()), CockpitStats::getRegionCode, save.getRegionCode())
.eq(Objects.nonNull(save.getYear()), CockpitStats::getYear, save.getYear()));
if(CollUtil.isNotEmpty(cockpitStatsList)){
for(CockpitStats cockpitStats : cockpitStatsList){
BeanUtil.copyProperties(save,cockpitStats, CopyOptions.create().ignoreNullValue());
cockpitStatsService.updateById(cockpitStats);
}
}
}

if(Objects.nonNull(save.getCockpitApplications())){
cockpitApplicationService.remove(Wrappers.lambdaQuery(CockpitApplication.class));
if(Objects.nonNull(save.getCockpitApplications())){
cockpitApplicationService.remove(Wrappers.lambdaQuery(CockpitApplication.class));

List<CockpitApplicationDTO> cockpitApplications = save.getCockpitApplications();
if(CollUtil.isNotEmpty(cockpitApplications)){
List<CockpitApplication> applications = cockpitApplications.stream()
.map(a -> BeanUtil.copyProperties(a,CockpitApplication.class))
.collect(Collectors.toList());
cockpitApplicationService.saveBatch(applications);
List<CockpitApplicationDTO> cockpitApplications = save.getCockpitApplications();
if(CollUtil.isNotEmpty(cockpitApplications)){
List<CockpitApplication> applications = cockpitApplications.stream()
.map(a -> BeanUtil.copyProperties(a,CockpitApplication.class))
.collect(Collectors.toList());
cockpitApplicationService.saveBatch(applications);
}
}
}
}


Ładowanie…
Anuluj
Zapisz