From 441f4fd8652a5d51c386d19eb27a7dbb2140b10b Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期六, 17 五月 2025 14:03:17 +0800 Subject: [PATCH] 查询机房,电源,电池组信息 --- src/main/java/com/whyc/controller/InfoContoller.java | 85 ++++++++ src/main/java/com/whyc/pojo/db_station/PowerInf.java | 2 src/main/java/com/whyc/mapper/PowerInfMapper.java | 2 src/main/java/com/whyc/service/PowerInfService.java | 28 +- src/main/java/com/whyc/pojo/db_station/BattInf.java | 2 src/main/java/com/whyc/controller/ConditionController.java | 56 +++++ src/main/resources/mapper/BattInfMapper.xml | 77 +++++++ src/main/java/com/whyc/controller/BattInfController.java | 16 src/main/java/com/whyc/mapper/StationInfMapper.java | 2 src/main/java/com/whyc/service/StationInfService.java | 6 src/main/java/com/whyc/service/BattInfService.java | 97 ++++++++- src/main/java/com/whyc/dto/InfoDto.java | 111 +++++++++++ src/main/resources/mapper/PowerInfMapper.xml | 12 + src/main/java/com/whyc/controller/PowerInfController.java | 7 src/main/java/com/whyc/factory/InfoFactory.java | 40 ++++ src/main/resources/mapper/StationInfMapper.xml | 13 + src/main/java/com/whyc/mapper/BattInfMapper.java | 19 + 17 files changed, 529 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/whyc/controller/BattInfController.java b/src/main/java/com/whyc/controller/BattInfController.java index 5eba3b6..45e05fd 100644 --- a/src/main/java/com/whyc/controller/BattInfController.java +++ b/src/main/java/com/whyc/controller/BattInfController.java @@ -20,15 +20,17 @@ private BattInfService service; - @ApiOperation(value = "璁惧娣诲姞鐢垫睜缁�") - @PostMapping("addBattInDev") + /*@ApiOperation(value = "璁惧娣诲姞鐢垫睜缁�") + @PostMapping("addBatt") public Response addBatt(@RequestBody BattInf binf){ - return service.addBatt(binf); + service.addBatt(binf); + return new Response().set(1,true); } @ApiOperation(value = "鏂板缓鐢垫睜缁勶紙鏂扮殑璁惧鏂扮殑鐢垫睜缁勶級") @PostMapping("addDev") public Response addDev(@RequestBody BattInf binf){ - return service.addDev(binf); + service.addDev(binf); + return new Response().set(1,true); } @ApiOperation(value = "鍒犻櫎鐢垫睜缁�") @@ -41,11 +43,11 @@ @PostMapping("updateBatt") public Response updateBatt(@RequestBody BattInf binf){ return service.updateBatt(binf); - } + }*/ - @ApiOperation(value = "鏌ヨ鐢垫睜缁�") + /* @ApiOperation(value = "鏌ヨ鐢垫睜缁�") @PostMapping("getBatt") public Response getBatt(@RequestBody BattDto dto){ return service.getBatt(dto); - } + }*/ } \ No newline at end of file diff --git a/src/main/java/com/whyc/controller/ConditionController.java b/src/main/java/com/whyc/controller/ConditionController.java index 50af51a..49efaae 100644 --- a/src/main/java/com/whyc/controller/ConditionController.java +++ b/src/main/java/com/whyc/controller/ConditionController.java @@ -3,6 +3,8 @@ import com.whyc.dto.Response; import com.whyc.pojo.db_user.User; import com.whyc.service.BaojigroupService; +import com.whyc.service.BattInfService; +import com.whyc.service.PowerInfService; import com.whyc.service.StationInfService; import com.whyc.util.ActionUtil; import io.swagger.annotations.Api; @@ -18,7 +20,13 @@ private StationInfService stationInfService; @Autowired + private PowerInfService powerInfService; + + @Autowired private BaojigroupService bjGroupService; + + @Autowired + private BattInfService binfService; @ApiOperation("鑾峰彇鎵�鏈夌殑鐪佷唤(涓嬫媺)") @GetMapping("getProviceByUid") @@ -56,6 +64,54 @@ return stationInfService.getPowerByUid(uinf.getId(),provice,city,country,stationName); } + @ApiOperation("鑾峰彇鐢靛帇绛夌骇(涓嬫媺)") + @GetMapping("getStationType") + public Response getStationTypeByUid() { + User uinf= ActionUtil.getUser(); + return stationInfService.getStationTypeByUid(uinf.getId()); + } + + @ApiOperation("鑾峰彇鐢垫睜鍝佺墝(涓嬫媺)") + @GetMapping("getProductByUid") + public Response getProductByUid() { + User uinf= ActionUtil.getUser(); + return binfService.getProductByUid(uinf.getId()); + } + + @ApiOperation("鑾峰彇鏍囩О鍗曚綋鐢靛帇(涓嬫媺)") + @GetMapping("getMonVolByUid") + public Response getMonVolByUid() { + User uinf= ActionUtil.getUser(); + return binfService.getMonVolByUid(uinf.getId()); + } + @ApiOperation("鑾峰彇鏍囩О瀹归噺(涓嬫媺)") + @GetMapping("getMonCapByUid") + public Response getMonCapByUid() { + User uinf= ActionUtil.getUser(); + return binfService.getMonCapByUid(uinf.getId()); + } + + @ApiOperation("鑾峰彇鏍囩О鍐呴樆(涓嬫媺)") + @GetMapping("getMonResByUid") + public Response getMonResByUid() { + User uinf= ActionUtil.getUser(); + return binfService.getMonResByUid(uinf.getId()); + } + + @ApiOperation("鑾峰彇璁惧鍨嬪彿(涓嬫媺)") + @GetMapping("getDevTypeByUid") + public Response getDevTypeByUid() { + User uinf= ActionUtil.getUser(); + return binfService.getDevTypeByUid(uinf.getId()); + } + + @ApiOperation("鑾峰彇鐢垫簮鍝佺墝(涓嬫媺)") + @GetMapping("getCompanyByUid") + public Response getCompanyByUid() { + User uinf= ActionUtil.getUser(); + return powerInfService.getCompanyByUid(uinf.getId()); + } + @ApiOperation(value = "褰撳墠鐢ㄦ埛鎵�鍦ㄥ寘鏈虹粍涓嬫墍鏈夌殑鐢ㄦ埛(涓嬫媺)") @GetMapping("getBaojiUserByUid") diff --git a/src/main/java/com/whyc/controller/InfoContoller.java b/src/main/java/com/whyc/controller/InfoContoller.java new file mode 100644 index 0000000..16b7ce9 --- /dev/null +++ b/src/main/java/com/whyc/controller/InfoContoller.java @@ -0,0 +1,85 @@ +package com.whyc.controller; + +import com.whyc.dto.BattDto; +import com.whyc.dto.InfoDto; +import com.whyc.dto.Response; +import com.whyc.factory.InfoFactory; +import com.whyc.pojo.db_station.BattInf; +import com.whyc.pojo.db_station.PowerInf; +import com.whyc.pojo.db_user.User; +import com.whyc.service.BaojigroupService; +import com.whyc.service.BattInfService; +import com.whyc.service.PowerInfService; +import com.whyc.util.ActionUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@Api(tags = "鏈烘埧锛岀數婧愶紝鐢垫睜缁勭鐞�") +@RequestMapping("condition") +public class InfoContoller { + + @Autowired + private PowerInfService pinfService; + + @Autowired + private BattInfService binfService; + + @Autowired(required = false) + private BaojigroupService bjService; + + @ApiOperation(value = "鏂板缓鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�") + @PostMapping("addInfo") + public Response addInfo(@RequestBody InfoDto info){ + //鍏堟牎楠屽綋鍓嶇敤鎴锋槸鍚﹀瓨鍦ㄥ寘鏈虹粍涓嶅瓨鍦ㄥ垯涓嶈娣诲姞鐢垫簮 + User user= ActionUtil.getUser(); + int flag=bjService.checkUserBaojiGroup(user.getId()); + String msg="娣诲姞鎴愬姛"; + boolean bl=true; + if(flag==0){ + bl=false; + msg="褰撳墠鐢ㄦ埛涓嶅瓨鍦ㄥ寘鏈虹粍"; + } + try { + PowerInf pinf=InfoFactory.infoToPower(info); + BattInf binf=InfoFactory.infoToBatt(info); + pinfService.addPower(pinf); + binf.setStationId(pinf.getStationId()); + binf.setPowerId(pinf.getPowerId()); + binfService.addDev(binf); + } catch (Exception e) { + e.printStackTrace(); + msg="娣诲姞澶辫触"; + bl=false; + } + return new Response().set(1,bl,msg); + } + + @ApiOperation(value = "璁惧涓嬫坊鍔犵數姹犵粍") + @PostMapping("addBatt") + public Response addBatt(@RequestBody BattInf binf){ + binfService.addBatt(binf); + return new Response().set(1,true); + } + + @ApiOperation(value = "鍒犻櫎鐢垫睜缁�") + @GetMapping("delBatt") + public Response delBatt(@RequestParam Integer stationId,@RequestParam Integer powerId,@RequestParam Integer battgroupId){ + return binfService.delBatt(stationId, powerId, battgroupId); + } + + /*@ApiOperation(value = "缂栬緫鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�") + @PostMapping("updateInfo") + public Response updateInfo(@RequestBody InfoDto info){ + PowerInf pinf=InfoFactory.infoToPower(info); + BattInf binf=InfoFactory.infoToBatt(info); + }*/ + + @ApiOperation(value = "鏌ヨ鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�") + @PostMapping("getInfo") + public Response getInfo(@RequestBody BattDto dto){ + return binfService.getInfo(dto); + } +} \ No newline at end of file diff --git a/src/main/java/com/whyc/controller/PowerInfController.java b/src/main/java/com/whyc/controller/PowerInfController.java index 74094b0..8305e2c 100644 --- a/src/main/java/com/whyc/controller/PowerInfController.java +++ b/src/main/java/com/whyc/controller/PowerInfController.java @@ -16,11 +16,12 @@ @Autowired private PowerInfService service; - +/* @ApiOperation(value = "娣诲姞鐢垫簮") @PostMapping("addPower") public Response addPower(@RequestBody PowerInf pinf){ - return service.addPower(pinf); + service.addPower(pinf); + return new Response().set(1,true,"娣诲姞鎴愬姛"); } @ApiOperation(value = "鍒犻櫎鐢垫簮") @@ -39,5 +40,5 @@ @PostMapping("getPower") public Response getPower(@RequestBody PowerDto dto){ return service.getPower(dto); - } + }*/ } \ No newline at end of file diff --git a/src/main/java/com/whyc/dto/InfoDto.java b/src/main/java/com/whyc/dto/InfoDto.java new file mode 100644 index 0000000..ad24c11 --- /dev/null +++ b/src/main/java/com/whyc/dto/InfoDto.java @@ -0,0 +1,111 @@ +package com.whyc.dto; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class InfoDto { + + @ApiModelProperty(value = "鏈烘埧Id") + private Integer stationId; + + @ApiModelProperty(value = "绔欑偣鍚嶇О") + private String stationName; + + @ApiModelProperty(value = "鐪�") + private String provice; + + @ApiModelProperty(value = "甯�") + private String city; + + @ApiModelProperty(value = "鍖哄幙") + private String country; + + @ApiModelProperty(value = "绔欑偣鐢靛帇绛夌骇[锛�35kv/110kv/220kv 瀛楃涓茬被鍨嬶級]") + private String stationType; + + @ApiModelProperty(value = "鏈烘埧鍚嶇О[鎷兼帴鍚庣殑]") + private String fullName; + + @ApiModelProperty(value = "缁忓害") + private Double longitude; + + @ApiModelProperty(value = "绾害") + private Double latitude; + + + @ApiModelProperty(value = "鐢垫簮id") + private Integer powerId; + + @ApiModelProperty(value = "鐢垫簮缂栧彿") + private Integer powerNum; + + @ApiModelProperty(value = "鐢垫簮鍚嶇О") + private String powerName; + + @ApiModelProperty(value = "鍘傚") + private String company; + + @ApiModelProperty(value = "鍨嬪彿") + private String powerModel; + + @ApiModelProperty(value = "鍗忚") + private String protocol; + + @ApiModelProperty(value = "鐢垫簮ip") + private String powerIp; + + + + @ApiModelProperty(value = "璁惧id") + private Integer devId; + + @ApiModelProperty(value = "璁惧ip") + private String devIp; + + @ApiModelProperty(value = "璁惧鍚嶇О") + private String devName; + + @ApiModelProperty(value = "璁惧绫诲瀷") + private String devType; + + @ApiModelProperty(value = "璁惧缂栧彿") + private Integer devNum; + + + @ApiModelProperty(value = "鐢垫睜缁刬d") + private Integer battgroupId; + + @ApiModelProperty(value = "鐢垫睜缁勫悕绉�") + private String battgroupName; + + @ApiModelProperty(value = "鐢垫睜缁勭紪鍙�") + private Integer battgroupNum; + + @ApiModelProperty(value = "鏍囩О鐢靛帇") + private Float monvolstd; + + @ApiModelProperty(value = "鏍囩О瀹归噺") + private Float moncapstd; + + @ApiModelProperty(value = "鏍囩О鍐呴樆") + private Float monresstd; + + @ApiModelProperty(value = "姣忕粍鍗曚綋涓暟") + private Float moncount; + + @ApiModelProperty(value = "鍝佺墝") + private String product; + + @ApiModelProperty(value = "鍨嬪彿") + private String battModel; + + @TableField(fill = FieldFill.INSERT) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") + private Date createTime; +} \ No newline at end of file diff --git a/src/main/java/com/whyc/factory/InfoFactory.java b/src/main/java/com/whyc/factory/InfoFactory.java new file mode 100644 index 0000000..8bec477 --- /dev/null +++ b/src/main/java/com/whyc/factory/InfoFactory.java @@ -0,0 +1,40 @@ +package com.whyc.factory; + +import com.whyc.dto.InfoDto; +import com.whyc.pojo.db_station.BattInf; +import com.whyc.pojo.db_station.PowerInf; +import com.whyc.pojo.db_station.StationInf; + +public class InfoFactory { + //灏唅nfo瀵硅薄杞负鐢垫簮瀵硅薄 + public static PowerInf infoToPower(InfoDto info) { + PowerInf pinf = new PowerInf(); + pinf.setCompany(info.getCompany()) + .setPowerModel(info.getPowerModel()) + .setProtocol(info.getProtocol()) + .setPowerIp(info.getPowerIp()); + StationInf sinf=new StationInf(); + sinf.setProvice(info.getProvice()) + .setCity(info.getCity()) + .setCountry(info.getCountry()) + .setStationName(info.getStationName()) + .setStationType(info.getStationType()) + .setLatitude(info.getLatitude()) + .setLongitude(info.getLongitude()); + pinf.setSinf(sinf); + return pinf; + } + //灏唅nfo瀵硅薄杞负鐢垫睜缁勫璞� + public static BattInf infoToBatt(InfoDto info) { + BattInf binf = new BattInf(); + binf.setDevIp(info.getDevIp()) + .setDevType(info.getDevType()) + .setMoncapstd(info.getMoncapstd()) + .setMoncount(info.getMoncount()) + .setMonresstd(info.getMonresstd()) + .setMonvolstd(info.getMonvolstd()) + .setProduct(info.getProduct()) + .setBattModel(info.getBattModel()); + return binf; + } +} \ No newline at end of file diff --git a/src/main/java/com/whyc/mapper/BattInfMapper.java b/src/main/java/com/whyc/mapper/BattInfMapper.java index 5d9f4ac..eb4497a 100644 --- a/src/main/java/com/whyc/mapper/BattInfMapper.java +++ b/src/main/java/com/whyc/mapper/BattInfMapper.java @@ -1,6 +1,7 @@ package com.whyc.mapper; import com.whyc.dto.BattDto; +import com.whyc.dto.InfoDto; import com.whyc.pojo.db_station.BattInf; import org.apache.ibatis.annotations.Param; @@ -11,10 +12,22 @@ Integer getMaxdevId(); //鑾峰彇瀵瑰簲鐨勭數姹犵粍id Integer getMaxBattGroupId(); - //鏌ヨ鐢垫睜 - List<BattInf> getBatt(BattDto dto); + //鏌ヨ鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭� + List<InfoDto> getInfo(BattDto dto); //妫�娴嬬數婧愪笅鏄惁瀛樺湪璁惧 Integer getMaxDevNum(@Param("powerId") Integer powerId); //妫�娴嬭澶囦笅鏄惁瀛樺湪鐢垫睜缁� - Integer getMaxBattgroupNum(@Param("devId")Integer devId); + Integer getMaxBattgroupNum(@Param("devId") Integer devId); + //鑾峰彇鐢垫睜鍝佺墝(涓嬫媺) + List<String> getProductByUid(@Param("devId") Integer uid); + //鑾峰彇鏍囩О鍗曚綋鐢靛帇(涓嬫媺) + List<String> getMonVolByUid(@Param("devId") Integer uid); + //鑾峰彇璁惧鍨嬪彿(涓嬫媺) + List<String> getDevTypeByUid(@Param("devId") Integer uid); + + //鑾峰彇鏍囩О瀹归噺(涓嬫媺) + List<String> getMonCapByUid(@Param("devId") Integer uid); + + //鑾峰彇鏍囩О鍐呴樆(涓嬫媺) + List<String> getMonResByUid(@Param("devId") Integer uid); } \ No newline at end of file diff --git a/src/main/java/com/whyc/mapper/PowerInfMapper.java b/src/main/java/com/whyc/mapper/PowerInfMapper.java index 05cb123..54e6d92 100644 --- a/src/main/java/com/whyc/mapper/PowerInfMapper.java +++ b/src/main/java/com/whyc/mapper/PowerInfMapper.java @@ -15,4 +15,6 @@ List<PowerInf> getPower(PowerDto dto); //鐢垫簮闇�瑕佺紪鍙凤紝powerNum缂栧彿锛岀數婧愬悕绉拌嚜鍔ㄧ敓鎴愰�氳鐢垫簮+powerNum int getMaxPowerNum(@Param("stationId") Integer stationId); + //鑾峰彇鐢垫簮鍝佺墝(涓嬫媺) + List<String> getCompanyByUid(Integer uid); } \ No newline at end of file diff --git a/src/main/java/com/whyc/mapper/StationInfMapper.java b/src/main/java/com/whyc/mapper/StationInfMapper.java index de5e7bb..5c9b4d1 100644 --- a/src/main/java/com/whyc/mapper/StationInfMapper.java +++ b/src/main/java/com/whyc/mapper/StationInfMapper.java @@ -22,4 +22,6 @@ List<StationInf> getStationByUid(@Param("uid") Integer uid,@Param("provice") String provice,@Param("city") String city,@Param("country") String country); //鑾峰彇绔欑偣涓嬬殑鐢垫簮(涓嬫媺) List<PowerInf> getPowerByUid(@Param("uid") Integer uid, @Param("provice") String provice, @Param("city") String city, @Param("country") String country, @Param("stationName") String stationName); + //鑾峰彇鐢靛帇绛夌骇(涓嬫媺) + List<String> getStationTypeByUid(@Param("uid") Integer uid); } \ No newline at end of file diff --git a/src/main/java/com/whyc/pojo/db_station/BattInf.java b/src/main/java/com/whyc/pojo/db_station/BattInf.java index e0d4596..b6688d8 100644 --- a/src/main/java/com/whyc/pojo/db_station/BattInf.java +++ b/src/main/java/com/whyc/pojo/db_station/BattInf.java @@ -78,7 +78,7 @@ private String product; @ApiModelProperty(value = "鍨嬪彿") - private String model; + private String battModel; @TableField(fill = FieldFill.INSERT) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") diff --git a/src/main/java/com/whyc/pojo/db_station/PowerInf.java b/src/main/java/com/whyc/pojo/db_station/PowerInf.java index a918f02..758a270 100644 --- a/src/main/java/com/whyc/pojo/db_station/PowerInf.java +++ b/src/main/java/com/whyc/pojo/db_station/PowerInf.java @@ -49,7 +49,7 @@ private String company; @ApiModelProperty(value = "鍨嬪彿") - private String model; + private String powerModel; @ApiModelProperty(value = "鍗忚") private String protocol; diff --git a/src/main/java/com/whyc/service/BattInfService.java b/src/main/java/com/whyc/service/BattInfService.java index da95a13..a4c0bd1 100644 --- a/src/main/java/com/whyc/service/BattInfService.java +++ b/src/main/java/com/whyc/service/BattInfService.java @@ -5,9 +5,12 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.dto.BattDto; +import com.whyc.dto.InfoDto; import com.whyc.dto.PowerDto; import com.whyc.dto.Response; import com.whyc.mapper.BattInfMapper; +import com.whyc.mapper.PowerInfMapper; +import com.whyc.mapper.StationInfMapper; import com.whyc.pojo.db_station.BattInf; import com.whyc.pojo.db_station.PowerInf; import com.whyc.pojo.db_station.StationInf; @@ -25,12 +28,18 @@ @Autowired(required = false) private BattInfMapper mapper; + @Autowired(required = false) + private PowerInfMapper pinfMapper; + + @Autowired(required = false) + private StationInfMapper sinfMapper; + /*鏂板缓鐢垫睜缁勶紙鏂扮殑璁惧鏂扮殑鐢垫睜缁勶級 * @param binf * 1.鍦ㄧ數婧愪笅鏂板缓璁惧锛岃褰曡澶囩紪鍙凤紝devNum,璁惧鍚嶇О涓鸿澶囩被鍨�+devNum */ @Transactional - public Response addDev(BattInf adddinf) { + public void addDev(BattInf adddinf) { //妫�娴嬬數婧愪笅鏄惁瀛樺湪璁惧 int devNum=mapper.getMaxDevNum(adddinf.getPowerId()); if(devNum==0){ @@ -59,11 +68,10 @@ adddinf.setBattgroupNum(1); adddinf.setCreateTime(new Date()); mapper.insert(adddinf); - return new Response().set(1, true, "鏂板缓鐢垫睜缁勶紙鏂扮殑璁惧鏂扮殑鐢垫睜缁勶級"); } //璁惧涓嬫坊鍔犵數姹犵粍 @Transactional - public Response addBatt(BattInf addbinf) { + public void addBatt(BattInf addbinf) { //鑾峰彇璁惧鐨勯�氱敤淇℃伅 QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("dev_id",addbinf.getDevId()); @@ -95,20 +103,55 @@ addbinf.setBattgroupNum(battgroupNum); addbinf.setCreateTime(new Date()); mapper.insert(addbinf); - return new Response().set(1, true, "璁惧涓嬫坊鍔犵數姹犵粍"); } - //鍒犻櫎鐢垫簮 - public Response delBatt(Integer bid) { + //鍒犻櫎鐢垫睜缁� + @Transactional + public Response delBatt(Integer stationId, Integer powerId,Integer battgroupId) { UpdateWrapper wrapper=new UpdateWrapper(); - wrapper.eq("battgroup_id",bid); + wrapper.eq("battgroup_id",battgroupId); mapper.delete(wrapper); + //妫�娴嬪鏋減owerId涓嬬數姹犵粍鍒犻櫎瀹屼簡,瑕佸皢鐢垫簮涔熷垹闄ゆ帀 + QueryWrapper wrapper1=new QueryWrapper(); + wrapper1.eq("power_id",powerId); + List<BattInf> binfList=mapper.selectList(wrapper1); + if(binfList==null){ + UpdateWrapper wrapper2=new UpdateWrapper(); + wrapper2.eq("power_id",powerId); + pinfMapper.delete(wrapper); + //鍐嶆娴嬪鏋滄満鎴夸笅鐢垫簮涔熷叏鍒犻櫎浜嗭紝瑕佸皢鏈烘埧涔熷垹闄� + QueryWrapper wrapper3=new QueryWrapper(); + wrapper3.eq("station_id",stationId); + List<PowerInf> pinfList=pinfMapper.selectList(wrapper3); + if(pinfList==null){ + UpdateWrapper wrapper4=new UpdateWrapper(); + wrapper4.eq("station_id",stationId); + sinfMapper.delete(wrapper4); + } + } return new Response().set(1,true); } - //淇敼鐢垫簮 + //淇敼鐢垫睜缁� public Response updateBatt(BattInf binf) { + UpdateWrapper wrapper1=new UpdateWrapper(); + wrapper1.eq("dev_id",binf.getDevId()); + if(binf.getDevIp()!=null){ + wrapper1.set("dev_ip",binf.getDevIp()); + } + if(binf.getDevName()!=null){ + wrapper1.set("dev_name",binf.getDevName()); + } UpdateWrapper wrapper=new UpdateWrapper(); wrapper.eq("battgroup_id",binf.getBattgroupId()); if(binf.getBattgroupName()!=null){ + //妫�娴嬭鏈烘埧涓嬭淇敼鐨勭數婧愬悕鏄惁绮楀湪 + QueryWrapper queryWrapper=new QueryWrapper(); + queryWrapper.eq("battgroup_name",binf.getBattgroupName()); + queryWrapper.eq("dev_id",binf.getDevId()); + queryWrapper.last("limit 1"); + BattInf juegeb=mapper.selectOne(queryWrapper); + if(juegeb!=null){ + return new Response().set(1,false,"璇ヨ澶囦笅宸插瓨鍦�"+binf.getBattgroupName()+"鐨勭數姹犵粍"); + } wrapper.set("battgroup_name",binf.getBattgroupName()); } if(binf.getMonvolstd()!=null){ @@ -126,18 +169,18 @@ if(binf.getMoncount()!=null){ wrapper.set("moncount",binf.getMoncount()); } - if(binf.getModel()!=null){ - wrapper.set("model",binf.getModel()); + if(binf.getBattModel()!=null){ + wrapper.set("batt_model",binf.getBattModel()); } mapper.update((BattInf) ActionUtil.objeNull,wrapper); return new Response().set(1,true); } - //鏌ヨ鐢垫睜 - public Response getBatt(BattDto dto) { + //鏌ヨ鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭� + public Response getInfo(BattDto dto) { User user= ActionUtil.getUser(); dto.setUid(user.getId()); PageHelper.startPage(dto.getPageNum(),dto.getPageSize()); - List<BattInf> list=mapper.getBatt(dto); + List<InfoDto> list=mapper.getInfo(dto); PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list!=null,pageInfo,"鏌ヨ鐢垫睜"); } @@ -147,4 +190,32 @@ wrapper.eq("power_id",pid); mapper.delete(wrapper); } + + //鑾峰彇鐢垫睜鍝佺墝(涓嬫媺) + public Response getProductByUid(Integer uid) { + List<String> list=mapper.getProductByUid(uid); + return new Response().setII(1,list.size()>0,list,"鑾峰彇鐢垫睜鍝佺墝(涓嬫媺)"); + } + //鑾峰彇鏍囩О鍗曚綋鐢靛帇(涓嬫媺) + public Response getMonVolByUid(Integer uid) { + List<String> list=mapper.getMonVolByUid(uid); + return new Response().setII(1,list.size()>0,list,"鑾峰彇鏍囩О鍗曚綋鐢靛帇(涓嬫媺)"); + } + + //鑾峰彇鏍囩О瀹归噺(涓嬫媺) + public Response getMonCapByUid(Integer uid) { + List<String> list=mapper.getMonCapByUid(uid); + return new Response().setII(1,list.size()>0,list,"鑾峰彇鏍囩О瀹归噺(涓嬫媺)"); + } + + //鑾峰彇鏍囩О鍐呴樆(涓嬫媺) + public Response getMonResByUid(Integer uid) { + List<String> list=mapper.getMonResByUid(uid); + return new Response().setII(1,list.size()>0,list,"鑾峰彇鏍囩О鍐呴樆(涓嬫媺)"); + } + //鑾峰彇璁惧鍨嬪彿(涓嬫媺) + public Response getDevTypeByUid(Integer uid) { + List<String> list=mapper.getDevTypeByUid(uid); + return new Response().setII(1,list.size()>0,list,"鑾峰彇璁惧鍨嬪彿(涓嬫媺)"); + } } \ No newline at end of file diff --git a/src/main/java/com/whyc/service/PowerInfService.java b/src/main/java/com/whyc/service/PowerInfService.java index feefddd..7fd1a9c 100644 --- a/src/main/java/com/whyc/service/PowerInfService.java +++ b/src/main/java/com/whyc/service/PowerInfService.java @@ -39,13 +39,7 @@ 3.鐢垫簮闇�瑕佺紪鍙凤紝powerNum缂栧彿锛岀數婧愬悕绉拌嚜鍔ㄧ敓鎴愰�氳鐢垫簮+powerNum */ @Transactional - public Response addPower(PowerInf addpinf) { - //鍏堟牎楠屽綋鍓嶇敤鎴锋槸鍚﹀瓨鍦ㄥ寘鏈虹粍涓嶅瓨鍦ㄥ垯涓嶈娣诲姞鐢垫簮 - User user= ActionUtil.getUser(); - int flag=bjService.checkUserBaojiGroup(user.getId()); - if(flag==0){ - return new Response().set(1,false,"褰撳墠鐢ㄦ埛涓嶅瓨鍦ㄥ寘鏈虹粍"); - } + public void addPower(PowerInf addpinf) { //鏈烘埧淇℃伅 StationInf addsinf= addpinf.getSinf(); //鍒ゆ柇娣诲姞閿佺殑鏃跺�欐満鎴挎槸涓嶆槸鏂版満鎴� @@ -91,7 +85,6 @@ } addpinf.setPowerId(powerId); mapper.insert(addpinf); - return new Response().set(1, true, "娣诲姞鐢垫簮"); } //鍒犻櫎鐢垫簮锛堝垹闄ゅ寘鏈虹粍涓嬭褰曪紝鍒犻櫎鐢垫簮涓嬬殑鐢垫睜缁勮澶囷級 @Transactional @@ -111,13 +104,22 @@ UpdateWrapper wrapper=new UpdateWrapper(); wrapper.eq("power_id",pinf.getPowerId()); if(pinf.getPowerName()!=null){ + //妫�娴嬭鏈烘埧涓嬭淇敼鐨勭數婧愬悕鏄惁绮楀湪 + QueryWrapper queryWrapper=new QueryWrapper(); + queryWrapper.eq("power_name",pinf.getPowerName()); + queryWrapper.eq("station_id",pinf.getStationId()); + queryWrapper.last("limit 1"); + PowerInf juegep=mapper.selectOne(queryWrapper); + if(juegep!=null){ + return new Response().set(1,false,"璇ユ満鎴夸笅宸插瓨鍦�"+pinf.getPowerName()+"鐨勭數婧�"); + } wrapper.set("power_name",pinf.getPowerName()); } if(pinf.getCompany()!=null){ wrapper.set("company",pinf.getCompany()); } - if(pinf.getModel()!=null){ - wrapper.set("model",pinf.getModel()); + if(pinf.getPowerModel()!=null){ + wrapper.set("power_model",pinf.getPowerModel()); } if(pinf.getProtocol()!=null){ wrapper.set("protocol",pinf.getProtocol()); @@ -137,5 +139,9 @@ PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list!=null,pageInfo,"鏌ヨ鐢垫簮"); } - + //鑾峰彇鐢垫簮鍝佺墝(涓嬫媺) + public Response getCompanyByUid(Integer uid) { + List<String> list=mapper.getCompanyByUid(uid); + return new Response().setII(1,list.size()>0,list,"鑾峰彇鐢垫簮鍝佺墝(涓嬫媺)"); + } } \ No newline at end of file diff --git a/src/main/java/com/whyc/service/StationInfService.java b/src/main/java/com/whyc/service/StationInfService.java index f36a249..5742b08 100644 --- a/src/main/java/com/whyc/service/StationInfService.java +++ b/src/main/java/com/whyc/service/StationInfService.java @@ -50,4 +50,10 @@ List<PowerInf> list=mapper.getPowerByUid(uid,provice,city,country,stationName); return new Response().setII(1,list.size()>0,list,"鑾峰彇绔欑偣涓嬬殑鐢垫簮(涓嬫媺)"); } + //鑾峰彇鐢靛帇绛夌骇(涓嬫媺) + public Response getStationTypeByUid(Integer uid) { + List<String> list=mapper.getStationTypeByUid(uid); + return new Response().setII(1,list.size()>0,list,"鑾峰彇鐢靛帇绛夌骇(涓嬫媺)"); + } + } \ No newline at end of file diff --git a/src/main/resources/mapper/BattInfMapper.xml b/src/main/resources/mapper/BattInfMapper.xml index ccb2acd..6775f47 100644 --- a/src/main/resources/mapper/BattInfMapper.xml +++ b/src/main/resources/mapper/BattInfMapper.xml @@ -15,11 +15,11 @@ select ifnull(max(battgroup_num),0) from db_station.tb_batt_inf where dev_id=#{devId}; </select> - <select id="getBatt" resultType="com.whyc.pojo.db_station.BattInf"> - select tb_batt_inf.*,tb_station_inf.station_name,tb_power_inf.power_name - from db_station.tb_power_inf,db_station.tb_station_inf,db_station.tb_batt_inf - where tb_batt_inf.station_id=tb_station_inf.station_id - and tb_batt_inf.power_id=tb_power_inf.power_id + <select id="getInfo" resultType="com.whyc.dto.InfoDto"> + SELECT * from db_station.tb_station_inf + LEFT JOIN db_station.tb_power_inf on tb_station_inf.station_id=tb_power_inf.station_id + LEFT JOIN db_station.tb_batt_inf on tb_batt_inf.station_id=tb_station_inf.station_id and tb_power_inf.power_id=tb_batt_inf.power_id + <where> <if test="provice!=null"> and tb_station_inf.provice=#{provice} </if> @@ -29,7 +29,7 @@ <if test="country!=null"> and tb_station_inf.country=#{country} </if> - <if test="stationName!=null"> + <!-- <if test="stationName!=null"> and tb_station_inf.station_name like concat('%',#{stationName},'%') </if> <if test="powerName!=null"> @@ -37,7 +37,7 @@ </if> <if test="battgroupName!=null"> and tb_batt_inf.battgroup_name like concat('%',#{battgroupName},'%') - </if> + </if>--> <if test="uid>100"> and tb_power_inf.power_id in( select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr @@ -45,6 +45,69 @@ and tb_baojigroup_usr.uid=#{uid} ) </if> + </where> + </select> + <select id="getProductByUid" resultType="java.lang.String"> + select distinct product from db_station.tb_batt_inf + <where> + <if test="uid>100"> + and tb_batt_inf.power_id in( + select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{uid} + ) + </if> + </where> + </select> + <select id="getMonVolByUid" resultType="java.lang.String"> + select distinct monvolstd from db_station.tb_batt_inf + <where> + <if test="uid>100"> + and tb_batt_inf.power_id in( + select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{uid} + ) + </if> + </where> + </select> + <select id="getDevTypeByUid" resultType="java.lang.String"> + select distinct dev_type from db_station.tb_batt_inf + <where> + <if test="uid>100"> + and tb_batt_inf.power_id in( + select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{uid} + ) + </if> + </where> + </select> + + <select id="getMonCapByUid" resultType="java.lang.String"> + select distinct moncapstd from db_station.tb_batt_inf + <where> + <if test="uid>100"> + and tb_batt_inf.power_id in( + select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{uid} + ) + </if> + </where> + </select> + + <select id="getMonResByUid" resultType="java.lang.String"> + select distinct monresstd from db_station.tb_batt_inf + <where> + <if test="uid>100"> + and tb_batt_inf.power_id in( + select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{uid} + ) + </if> + </where> </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/PowerInfMapper.xml b/src/main/resources/mapper/PowerInfMapper.xml index c8b6a79..60339c3 100644 --- a/src/main/resources/mapper/PowerInfMapper.xml +++ b/src/main/resources/mapper/PowerInfMapper.xml @@ -41,5 +41,17 @@ </if> </select> + <select id="getCompanyByUid" resultType="java.lang.String"> + select distinct company from db_station.tb_power_inf + <where> + <if test="uid>100"> + and tb_power_inf.power_id in( + select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{uid} + ) + </if> + </where> + </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/StationInfMapper.xml b/src/main/resources/mapper/StationInfMapper.xml index 775d9ee..5927691 100644 --- a/src/main/resources/mapper/StationInfMapper.xml +++ b/src/main/resources/mapper/StationInfMapper.xml @@ -156,4 +156,17 @@ </if> </where> </select> + <select id="getStationTypeByUid" resultType="java.lang.String"> + select distinct station_type from db_station.tb_station_inf + <where> + <if test="uid>100"> + and tb_station_inf.station_id in( + select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr + where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id + and tb_baojigroup_usr.uid=#{uid} + ) + </if> + </where> + </select> + </mapper> \ No newline at end of file -- Gitblit v1.9.1