liujie
3 天以前 1affeef32cf30a1765ee749db0344258058b4e2e
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package com.ruoyi.other.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.Logical;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.other.api.domain.Region;
import com.ruoyi.other.api.domain.TSystemConfiguration;
import com.ruoyi.other.mapper.TScreenContentMapper;
import com.ruoyi.other.service.IRegionService;
import com.ruoyi.other.service.TScreenContentService;
import com.ruoyi.other.service.TSystemConfigurationService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
 
/**
 * @author zhibing.pu
 * @Date 2024/8/8 12:00
 */
@RestController
@RequestMapping("/region")
public class RegionController {
    
    @Resource
    private IRegionService regionService;
 
    @Resource
    private TSystemConfigurationService tSystemConfigurationService;
 
    @Resource
    private TScreenContentMapper screenContentMapper;
    
    
    
    @RequiresPermissions(value = {"/coupon", "/appUser/list", "/vipList", "/coupon/send"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping("/getRegion/{pid}")
    @ApiOperation(value = "获取省市区数据", tags = {"管理后台-站点管理"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "父级id,没有传0", name = "pid", required = true)
    })
    public AjaxResult<List<Region>> getRegion(@PathVariable Integer pid){
        List<Region> list = regionService.list(new LambdaQueryWrapper<Region>().eq(Region::getParentId, pid));
        return AjaxResult.success(list);
    }
 
    /**
     * 根据code获取对应名称
     * @return
     */
    @ResponseBody
    @GetMapping("/getRegionBuyCode/{code}")
    public R<Region> getRegionBuyCode(@PathVariable("code") String code){
        Region list = regionService.getOne(new LambdaQueryWrapper<Region>().eq(Region::getCode, code));
        return R.ok(list);
    }
 
    @ResponseBody
    @GetMapping("/getTSystemConfiguration")
    public R<List<TSystemConfiguration>> getTSystemConfiguration(){
        List<TSystemConfiguration> list = tSystemConfigurationService.list(new LambdaQueryWrapper<TSystemConfiguration>().in(TSystemConfiguration::getType, 4, 5));
        return R.ok(list);
    }
 
 
    @GetMapping(value = "/getCarDisCharge")
    @ResponseBody
    public R<BigDecimal> getCarDisCharge(){
        BigDecimal carDisCharge = screenContentMapper.getCarDisCharge(Arrays.asList(25,26));
        return R.ok(carDisCharge);
    }
 
    @PostMapping(value = "/getGreenElectricity")
    @ResponseBody
    public R<BigDecimal> getGreenElectricity(){
        BigDecimal greenElectricity = screenContentMapper.getGreenElectricity(Arrays.asList(26,25));
        return R.ok(greenElectricity);
    }
 
 
    @PostMapping(value = "/carportData")
    @ResponseBody
    public void carportData(String parkingPlace){
        String[] split = parkingPlace.split("_");
        Integer parkingPlace1 = Integer.parseInt(split[0]);
        Integer remainPlace = Integer.parseInt(split[1]);
        screenContentMapper.carportData(parkingPlace1,remainPlace);
    }
 
    @GetMapping(value = "/getCarportData")
    @ResponseBody
    public R<HashMap<String, Object>> getCarportData(){
        HashMap<String, Object> carportData = screenContentMapper.getCarportData();
        return R.ok(carportData);
    }
    @GetMapping(value = "/reset")
    @ResponseBody
    public void reset(@RequestParam("electricity") String electricity){
        TSystemConfiguration sysConfig = tSystemConfigurationService.getOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,5));
        sysConfig.setContent(electricity.split("_")[0]);
        tSystemConfigurationService.updateById(sysConfig);
 
        TSystemConfiguration sysConfig1 = tSystemConfigurationService.getOne(new LambdaQueryWrapper<TSystemConfiguration>()
                .eq(TSystemConfiguration::getType,4));
        sysConfig1.setContent(electricity.split("_")[1]);
        tSystemConfigurationService.updateById(sysConfig1);
    }
}