| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.ServiceModel; |
| | | import com.whyc.dto.paramter.DateTimePar; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.service.BattInfService; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.HttpUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RequestMapping("battInf") |
| | | @RestController |
| | | @Api(tags = "电池信息") |
| | | @Api(tags = "数据管理-电池信息") |
| | | public class BattInfController { |
| | | |
| | | @Autowired |
| | | private BattInfService service; |
| | | |
| | | @GetMapping("/searchAllStationName1") |
| | | @ApiOperation("查询省") |
| | | @ApiOperation(tags = "在线监测-历史数据管理",value="查询省",notes = "原接口:BattInfAction!serchAllStationName1") |
| | | public Response searchAllStationName1(){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.searchAllStationName1(userInf.getUId().intValue()); |
| | |
| | | } |
| | | @GetMapping("/searchInform") |
| | | @ApiOperation(value = "电池组信息配置中查询所有的电池组信息") |
| | | public Response searchInform(@RequestParam(required = false)String stationName1,@RequestParam(required = false)String stationName2,@RequestParam(required = false)String stationName5,@RequestParam(required = false)String stationName3){ |
| | | public Response searchInform(@RequestParam int pageNum,@RequestParam int pageSize,@RequestParam(required = false)String stationName1,@RequestParam(required = false)String stationName2,@RequestParam(required = false)String stationName5,@RequestParam(required = false)String stationName3){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.searchInfo(userInf.getUId().intValue(),stationName1,stationName2,stationName5,stationName3); |
| | | return service.searchInfo(pageNum,pageSize,userInf.getUId().intValue(),stationName1,stationName2,stationName5,stationName3); |
| | | } |
| | | |
| | | |
| | |
| | | List<Battinf> stationList = service.getStationList(userInf.getUId().intValue()); |
| | | return new Response().set(1,stationList); |
| | | } |
| | | @GetMapping("/searchByBattProducer") |
| | | @ApiOperation(value = "获取所有电池品牌") |
| | | public Response getAllBattProducer(){ |
| | | return service.searchBattProducer(); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/add") |
| | | @PostMapping("/add") |
| | | @ApiOperation("新增电池组") |
| | | public Response addBattinf(@RequestBody Battinf battinf){ |
| | | UserInf userInf = (UserInf) ActionUtil.getUser(); |
| | | return service.add(battinf,userInf.getUId().intValue()); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @ApiOperation(value = "删除电池组") |
| | | public Response delete(@RequestParam Integer battgroupId){ |
| | | service.deleteByBattgroupId(battgroupId); |
| | | return new Response().setII(1,"删除成功"); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "更新电池组") |
| | | public Response update(@RequestBody Battinf battinf){ |
| | | return service.update(battinf); |
| | | } |
| | | |
| | | @PutMapping("/updateList") |
| | | @ApiOperation(value = "更新电池组List") |
| | | public Response updateList(@RequestBody List<Battinf> battinfs){ |
| | | return service.updateList(battinfs); |
| | | } |
| | | |
| | | |
| | | @PutMapping("/updatePubByDevId") |
| | | @ApiOperation(value = "根据设备id修改PublicKeyY值") |
| | | public Response updatePubByDevId(@RequestParam String publicKeyY,@RequestParam Integer deviceId){ |
| | | return service.updatePublicKeyByDevId(publicKeyY,deviceId); |
| | | } |
| | | |
| | | @PutMapping("/updateIP") |
| | | @ApiOperation(value = "更新电池组网关等信息",notes = "todo还需向设备发送相关指令和服务需重启") |
| | | public Response updateIp(@RequestBody Battinf battinf){ |
| | | //todo Fbs9100_setparamImpl().sendCmdToFBS9100Dev |
| | | //修改ip需要将61850的服务设为重启 |
| | | //todo process_survey |
| | | return service.updateIp(battinf); |
| | | } |
| | | @GetMapping("/findByBattGroupId") |
| | | @ApiOperation(value = "通过电池组id获取电池信息") |
| | | public Response findByBattGroupId(@RequestParam int battGroupId){ |
| | | return service.findByBattGroupId(battGroupId); |
| | | } |
| | | |
| | | |
| | | public Response searchNotInBattMapByUid(){ |
| | | UserInf user = ActionUtil.getUser(); |
| | | return service.searchNotInBattMapByUid(user.getUId().intValue()); |
| | | } |
| | | |
| | | @GetMapping("battGroupInfoByFBSDeviceId") |
| | | @ApiOperation(value = "查询电池组信息-通过设备Id") |
| | | public Response<List<Battinf>> getBattGroupInfoByFBSDeviceId(@RequestParam int fbsDeviceId){ |
| | | List<Battinf> battInfList = service.getBattGroupInfoByFBSDeviceId(fbsDeviceId); |
| | | return new Response<List<Battinf>>().set(1,battInfList); |
| | | } |
| | | |
| | | @GetMapping("/findUseYear") |
| | | @ApiOperation(value = "查询电池使用年限") |
| | | public Response findUseYear(){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | return service.findUseYear(userInf.getUId().intValue()); |
| | | } |
| | | @GetMapping("/findBattProducer") |
| | | @ApiOperation(value = "查询品牌数量") |
| | | public Response findBattProducer(){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | return service.findBattProducer(userInf.getUId().intValue()); |
| | | } |
| | | |
| | | @GetMapping("/findBattProducerInfoByProducerName") |
| | | @ApiOperation(value = "根据电池品牌查询站点及电池品牌基础信息") |
| | | public Response findBattProducerInfoByProducerName(@RequestParam String battProducer){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | return service.findBattProducerInfoByProducerName(battProducer,userInf.getUId().intValue()); |
| | | } |
| | | @GetMapping("/findBattProducerInfoByYearCode") |
| | | @ApiOperation(value = "根据电池使用年限查询站点及电池品牌基础信息",notes = "yearCode: ,1:3年以内 ,2:3-5年 ,3:5到7年 ,4:7年以上") |
| | | public Response findBattProducerInfoByYearCode(@RequestParam int yearCode){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | return service.findBattProducerInfoByYearCode(yearCode,userInf.getUId().intValue()); |
| | | } |
| | | |
| | | @PostMapping("/findBattProducerInfoByTime") |
| | | @ApiOperation(value = "根据电池使用时间段查询站点及电池品牌基础信息",notes = "") |
| | | public Response findBattProducerInfoByTime(@RequestBody DateTimePar dateTimePar){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | return service.findBattProducerInfoByTime(dateTimePar.getStartTime(),dateTimePar.getEndTime(),userInf.getUId().intValue()); |
| | | } |
| | | |
| | | @GetMapping("/findBattInfByStationId") |
| | | @ApiOperation("根据机房id获取电池信息") |
| | | public Response findBattInfByStationId(@RequestParam String stationId){ |
| | | return service.findBattInfoByStationId(stationId); |
| | | } |
| | | |
| | | @GetMapping("stationList8059") |
| | | @ApiOperation(tags = "在线监测-一体机导入记录",value = "站点列表") |
| | | public Response<List<Battinf>> getStationList8059(){ |
| | | Long uId = ActionUtil.getUser().getUId(); |
| | | List<Battinf> stationList = service.getStationList8059(uId); |
| | | return new Response<List<Battinf>>().set(1,stationList); |
| | | } |
| | | |
| | | @GetMapping("battInfByStationId") |
| | | @ApiOperation(tags = "在线监测-一体机导入记录",value = "站点下的电池组信息") |
| | | public Response findBattInfByStationId2(@RequestParam String stationId){ |
| | | return service.findBattInfoByStationId(stationId); |
| | | } |
| | | |
| | | @GetMapping("/searchByMonNum") |
| | | @ApiOperation(value = "根据电池组id查询不重复的单体编号") |
| | | public Response searchByMonNum(int battGroupId){ |
| | | return service.searchByMonNum(battGroupId); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getVideoAccessToken") |
| | | @ApiOperation(value = "获取机房内电池组对应视频的token令牌") |
| | | public Response getVideoAccessToken() { |
| | | String resultJson = HttpUtil.doPost(HttpUtil.VIDEO_URL, HttpUtil.VIDEO_REQUEST_BODY); |
| | | ServiceModel responseNew = ActionUtil.getGson().fromJson(resultJson, ServiceModel.class); |
| | | //ActionUtil.getApplication().setAttribute("videoToken",responseNew); |
| | | if(responseNew.getCode()==200){ |
| | | return new Response().set(1,((Map)responseNew.getData()).get("accessToken")); |
| | | }else{ |
| | | return new Response().setCode(0); |
| | | } |
| | | } |
| | | |
| | | //@GetMapping("/getVideoAccessToken") |
| | | //@ApiOperation(value = "获取机房内电池组对应视频的token令牌") |
| | | //public Response getVideoAccessToken1() { |
| | | // Response response = new Response(); |
| | | // String resultJson = HttpUtil.doPost(HttpUtil.VIDEO_URL, HttpUtil.VIDEO_REQUEST_BODY); |
| | | // try { |
| | | // Object resp = ActionUtil.getApplication().getAttribute("videoToken"); |
| | | // Integer code = ((ServiceModel)resp).getCode(); |
| | | // Map map = (Map) ((ServiceModel)resp).getData(); |
| | | // if(code==200){ |
| | | // String accessToken = (String) map.get("accessToken"); |
| | | // Double expireTime = (Double) map.get("expireTime"); |
| | | // long now = System.currentTimeMillis(); |
| | | // if(now>=(expireTime-1000*10)){ |
| | | // //重新获取accessToken并存入application |
| | | // //String resultJson = HttpUtil.doPost(HttpUtil.VIDEO_URL, HttpUtil.VIDEO_REQUEST_BODY); |
| | | // Response responseNew = ActionUtil.getGson().fromJson(resultJson, Response.class); |
| | | // ActionUtil.getApplication().setAttribute("videoToken",responseNew); |
| | | // if(responseNew.getCode()==200){ |
| | | // response.set(1,((Map)responseNew.getData()).get("accessToken")); |
| | | // }else{ |
| | | // response.setCode(0); |
| | | // } |
| | | // }else { |
| | | // response.set(1,accessToken); |
| | | // } |
| | | // }else { |
| | | // response.set(0); |
| | | // } |
| | | // }catch (Exception e){ |
| | | // |
| | | // response.set(0); |
| | | // } |
| | | // return response; |
| | | //} |
| | | @PostMapping("/uploadPicOfStation") |
| | | @ApiOperation("上传图片") |
| | | @ApiImplicitParam(name = "file", value = "上传的文件", dataTypeClass = MultipartFile.class, required = true,paramType = "form") |
| | | public Response uploadPicOfStation(@RequestPart("file") List<MultipartFile> file, @RequestParam String stationId){ |
| | | return service.uploadPicOfStation(file,stationId); |
| | | } |
| | | @PostMapping("/deletePic") |
| | | @ApiOperation("删除图片") |
| | | public Response deletePic(@RequestParam String stationId,@RequestParam List<String> fileNames){ |
| | | return service.deletePic(stationId,fileNames); |
| | | } |
| | | @PostMapping("/getStationPic") |
| | | @ApiOperation("获取站点图片") |
| | | public Response getStationPic(@RequestParam String stationId){ |
| | | return service.getStationPic(stationId); |
| | | } |
| | | |
| | | @GetMapping("getDeviceId") |
| | | @ApiOperation(value = "获取最大的设备id", notes = "旧:BattInfAction!getDeviceId") |
| | | public Response getDeviceId(@RequestParam Integer devId) { |
| | | return new Response().set(1,service.searchMaxDevId(devId)); |
| | | } |
| | | |
| | | @PutMapping("monCapWH") |
| | | @ApiModelProperty(value = "标称容量KWH修改",notes = "传入battGroupId和nomCapWH") |
| | | public Response updateMonCapWH(@RequestBody Battinf inf){ |
| | | return service.updateMonCapWH(inf); |
| | | } |
| | | |
| | | } |