tangzy
2021-10-20 87204491aac135822f96f3fff297ddca400ea8c9
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.modules.mountainrain.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.modules.mountainrain.entity.Yucbig;
import org.springblade.modules.mountainrain.excel.BgrExcel;
import org.springblade.modules.mountainrain.excel.BgrImporter;
import org.springblade.modules.mountainrain.service.IBigriverService;
import org.springblade.modules.mountainrain.wrapper.BigriverWrapper;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.validation.Valid;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
 
/**
 *  控制器
 *
 * @author Blade
 * @since 2019-11-07
 */
@RestController
@AllArgsConstructor
@RequestMapping("/bigriver")
@Api(value = "", tags = "接口")
public class BigriverController extends BladeController {
 
    private IBigriverService iBigriverService;
 
    /**
    * 详情
    */
    @ApiLog("详情")
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "site")
    public R<Yucbig> detail(Yucbig yucbig) {
        Yucbig detail = iBigriverService.getOne(Condition.getQueryWrapper(yucbig));
        return R.data(BigriverWrapper.build().entityVO(detail));
    }
 
 
    /**
    * 新增
    */
    @ApiLog("新增")
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入site")
    public R save(@Valid @RequestBody Yucbig yucbig) {
        return R.status(iBigriverService.save(yucbig));
    }
 
    /**
    * 修改
    */
    @ApiLog("修改")
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入site")
    public R update(@Valid @RequestBody Yucbig yucbig) {
        return R.status(iBigriverService.updateById(yucbig));
    }
 
 
    /**
     * 大江大河预报数据导入
     */
    @PostMapping("import-bgr")
    public R importbgr(MultipartFile file) {
        BgrImporter bgrImporter = new BgrImporter(iBigriverService, false);
        ExcelUtil.save(file, bgrImporter, BgrExcel.class);
        return R.success("导入成功");
    }
 
    /**
     * 大江大河预警
     *
     * @return
     */
    @GetMapping("/selectbgriver")
    public R selectbgriver() {
        List<Map<String, Object>> selctsmriver = iBigriverService.selctbgriver();
        //预警数据
        List listyj = new ArrayList();
        //无预警数据
        List listzc = new ArrayList();
        for (int i = 0; i < selctsmriver.size(); i++) {
            //警戒水位
            String yjsw = selctsmriver.get(i).get("yjsw").toString();
            Double yjz = Double.parseDouble(yjsw);
            //水位
            String zs = selctsmriver.get(i).get("Z").toString();
            Double z = Double.parseDouble(zs);
            if (z > yjz) {
                listyj.add(selctsmriver.get(i));
            } else {
                listzc.add(selctsmriver.get(i));
            }
        }
        Map map = new HashMap();
        map.put("yj", listyj);
        map.put("zc", listzc);
        List list = new ArrayList();
        list.add(map);
        return R.data(list);
    }
 
}