Browse Source

驾驶舱数据 修改接口

tags/24080901
PoffyZhang 1 year ago
parent
commit
f00c16f2f7
2 changed files with 22 additions and 19 deletions
  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 View File

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


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


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

+ 19
- 17
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/CockpitStatsManage.java View File

@@ -65,26 +65,28 @@ public class CockpitStatsManage {
return convertCockpitStats.convertCockpitStats(cockpitStats,regionCode,year,aps); 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);
}
} }
} }
} }


Loading…
Cancel
Save