whycrzg
2021-02-03 f3e160c4c6690232da3258adb42c1f702cd8bb07
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
package com.fgkj.controller;
 
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Batt_electricity;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_log;
import com.fgkj.mapper.UinfDaoFactory;
import com.fgkj.services.Batt_electricityService;
import com.fgkj.services.User_logService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@RequestMapping("battElectricity")
@RestController
@Api(tags = "battElectricity接口")
public class Batt_electricityController{
 
    @Resource
    private Batt_electricityService service;
    @Resource
    private User_logService uservice;
 
    @PostMapping("/")
    @ApiOperation(notes = "{ \"dev_id\": 12112, \"dev_name\": \"91000012\", \"dev_recordtime\": \"2020-12-28 08:18:11\", \"dev_electricity_CM\": 0.0, \"dev_electricity_CT\": 0.0, \"dev_electricity_CU\": 0.0, \"note\": \"test\" }",value="新增")
    public ServiceModel add(@RequestBody Batt_electricity be){
        // Batt_electricity be = getGson().fromJson(json, Batt_electricity.class);
        ServiceModel model = service.add(be);
        if (model.getCode().equals(1)){
            String msg="添加对"+be.getDev_name()+"设备的记录";
            User_log ulog= UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
            uservice.add(ulog);//将用户的操作记录下来
        }
        return model;
    }
 
    @PutMapping("/")
    @ApiOperation(notes = "{ \"num\": 39284, \"dev_id\": 0, \"dev_name\": \"\", \"dev_recordtime\": \"2020-12-29 08:21:43\", \"dev_electricity_CM\": 0.0, \"dev_electricity_CT\": 0.0, \"dev_electricity_CU\": 0.0, \"note\": \"uu\" }",value="修改")
    public ServiceModel update(@RequestBody Batt_electricity be){
        // Batt_electricity be = getGson().fromJson(json, Batt_electricity.class);
        ServiceModel model  = service.update(be);
 
        return model;
    }
    @DeleteMapping("/")
    @ApiOperation(notes = "",value="删除")
    public ServiceModel del(@RequestParam Integer num) {
        Batt_electricity be = new Batt_electricity();
        be.setNum(num);
        ServiceModel model = service.del(be);
 
        return model;
    }
    @GetMapping("all")
    @ApiOperation(notes = "",value="all")
    public ServiceModel searchAll(){
        ServiceModel model = service.searchAll();
 
        return model;
    }
    
    
    //10.1根据设备id连battinf和batt_devdischarge表      查询电度
    /*
     * 记录时间放在battinf的battproducer
     * 统计方式放在battinf  的signalname  中       1 - 月       2-季度    3-年份
     * */
    @PostMapping("byCondition")
    @ApiOperation(notes = "根据设备id连battinf和batt_devdischarge表 ",value="查询电度")
    public List serchByCondition(@ApiParam(value = "设备id 42010007" ,required = true)@RequestParam String stationId, @ApiParam(value = "生产日期 格式2016/12/29 08:21:43" ,required = true)@RequestParam Date battProductDate,@ApiParam(value = "生产日期" ,required = true)@RequestParam Date battProductDate1){
        BattInf binf = new BattInf();
        binf.setStationId(stationId);
        binf.setBattProductDate(battProductDate);
        binf.setBattProductDate1(battProductDate1);
        List list = service.serchByCondition(binf);
        //System.out.println(result);
        return list;
    }
    
    //9.1机房主控中用电量的统计的折线图
    @PostMapping("byInfo")
    @ApiOperation(notes = "",value="机房主控中用电量的统计的折线图")
    public ServiceModel  serchByInfo(@ApiParam(value = "设备id 42010007" ,required = true)@RequestParam String stationId, @ApiParam(value = "生产日期 格式2016/12/29 08:21:43" ,required = true)@RequestParam Date battProductDate,@ApiParam(value = "生产日期" ,required = true)@RequestParam Date battProductDate1){
        BattInf binf = new BattInf();
        binf.setStationId(stationId);
        binf.setBattProductDate(battProductDate);
        binf.setBattProductDate1(battProductDate1);
        //System.out.println(binf);
        ServiceModel model = service.serchByInfo(binf);
 
        return model;
    }
    
 
    
    
}