package com.whyc.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.BattInfMapper;
|
import com.whyc.pojo.Battinf;
|
import com.whyc.pojo.UserInf;
|
import com.whyc.service.A059StationInfService;
|
import com.whyc.service.BattInfService;
|
import com.whyc.util.ActionUtil;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
|
@RestController
|
@Api(tags = "配置信息-A059")
|
@RequestMapping("A059StationInf")
|
public class A059StationInfController {
|
@Resource
|
private A059StationInfService service;
|
@Resource
|
private BattInfService battInfService;
|
@Resource
|
private BattInfMapper battInfMapper;
|
|
@GetMapping("/getAll")
|
@ApiOperation("获取A059配置信息")
|
public Response getA059StationInfList(@RequestParam int pageNum, @RequestParam int pageSize, @RequestParam(required = false) String province, @RequestParam(required = false) String city, @RequestParam(required = false) String county, @RequestParam int stationType) {
|
return service.getA059StationInfListAndBattInf(pageNum, pageSize, province, city, county, stationType);
|
}
|
|
@PostMapping("/importBatt")
|
@ApiOperation("新增电池组并更新原先对应设备编号为0")
|
public Response addBattAndUpdateDevNum(@RequestBody Battinf battinf){
|
UserInf userInf = (UserInf) ActionUtil.getUser();
|
QueryWrapper<Battinf> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("dev_num",battinf.getDevNum());
|
List<Battinf> list = battInfMapper.selectList(queryWrapper);
|
for (Battinf batt:list) {
|
batt.setDevNum(0+"");
|
battInfMapper.updateById(batt);
|
}
|
return battInfService.add(battinf,userInf.getUId().intValue());
|
}
|
|
}
|