whycxzp
2023-05-09 2dfa8e60eaff0373c76daa88f64c1409e70ea5e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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());
    }
 
}