| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | //删除电池组 |
| | | @Transactional |
| | | public Response delBatt(Integer stationId, Integer powerId,Integer battgroupId) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("battgroup_id",battgroupId); |
| | | mapper.delete(wrapper); |
| | | //检测如果powerId下电池组删除完了,要将电源也删除掉 |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.eq("power_id",powerId); |
| | | List<BattInf> binfList=mapper.selectList(wrapper1); |
| | | if(binfList==null){ |
| | | List<BattInf> binfList=new ArrayList<>(); |
| | | if(battgroupId!=null){ |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("battgroup_id",battgroupId); |
| | | mapper.delete(wrapper); |
| | | //检测如果powerId下电池组删除完了,要将电源也删除掉 |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.eq("power_id",powerId); |
| | | binfList=mapper.selectList(wrapper1); |
| | | } |
| | | if(binfList==null||binfList.size()==0){ |
| | | UpdateWrapper wrapper2=new UpdateWrapper(); |
| | | wrapper2.eq("power_id",powerId); |
| | | pinfMapper.delete(wrapper); |
| | | pinfMapper.delete(wrapper2); |
| | | //删除所有包机组下的电源 |
| | | bjService.delPowerInBaoji(powerId); |
| | | //再检测如果机房下电源也全删除了,要将机房也删除 |
| | | QueryWrapper wrapper3=new QueryWrapper(); |
| | | wrapper3.eq("station_id",stationId); |
| | | List<PowerInf> pinfList=pinfMapper.selectList(wrapper3); |
| | | if(pinfList==null){ |
| | | if(pinfList==null||pinfList.size()==0){ |
| | | UpdateWrapper wrapper4=new UpdateWrapper(); |
| | | wrapper4.eq("station_id",stationId); |
| | | sinfMapper.delete(wrapper4); |
| | |
| | | wrapper1.set("latitude",sinf.getLatitude()); |
| | | } |
| | | wrapper1.eq("station_id",sinf.getStationId()); |
| | | sinfMapper.update((StationInf) ActionUtil.objeNull,wrapper1); |
| | | |
| | | //再修改电源信息 |
| | | UpdateWrapper wrapper2=new UpdateWrapper(); |
| | | if(pinf.getCompany()!=null){ |
| | |
| | | //检测该机房下要修改的电源名是否存在 |
| | | QueryWrapper queryWrapper=new QueryWrapper(); |
| | | queryWrapper.eq("power_name",pinf.getPowerName()); |
| | | queryWrapper.eq("station_id",pinf.getStationId()); |
| | | queryWrapper.eq("station_id",sinf.getStationId()); |
| | | queryWrapper.last("limit 1"); |
| | | PowerInf juegep=pinfMapper.selectOne(queryWrapper); |
| | | if(juegep!=null){ |
| | |
| | | wrapper2.set("power_name",pinf.getPowerName()); |
| | | } |
| | | wrapper2.eq("power_id",pinf.getPowerId()); |
| | | pinfMapper.update((PowerInf) ActionUtil.objeNull,wrapper2); |
| | | |
| | | //最后修改设备信息 |
| | | BattInf binf=InfoFactory.infoToBatt(info); |
| | | UpdateWrapper wrapper3=new UpdateWrapper(); |
| | | if(binf.getDevIp()!=null){ |
| | | wrapper3.set("dev_ip",binf.getDevIp()); |
| | | } |
| | | if(binf.getDevName()!=null){ |
| | | //检测该电源下修改的设备名是否存在 |
| | | QueryWrapper queryWrapper1=new QueryWrapper(); |
| | | queryWrapper1.eq("dev_name",binf.getDevName()); |
| | | queryWrapper1.eq("power_id",pinf.getPowerId()); |
| | | queryWrapper1.last("limit 1"); |
| | | BattInf jueged=mapper.selectOne(queryWrapper1); |
| | | if(jueged!=null){ |
| | | return new Response().set(1,false,"该电源下已存在"+binf.getDevName()+"的设备"); |
| | | if(binf.getDevId()!=null) { |
| | | UpdateWrapper wrapper3 = new UpdateWrapper(); |
| | | if (binf.getDevIp() != null) { |
| | | wrapper3.set("dev_ip", binf.getDevIp()); |
| | | } |
| | | wrapper3.set("dev_name",binf.getDevName()); |
| | | } |
| | | if(binf.getDevType()!=null){ |
| | | wrapper3.set("dev_type",binf.getDevType()); |
| | | } |
| | | wrapper3.eq("dev_id",binf.getDevId()); |
| | | mapper.update((BattInf) ActionUtil.objeNull,wrapper3); |
| | | if (binf.getDevName() != null) { |
| | | //检测该电源下修改的设备名是否存在 |
| | | QueryWrapper queryWrapper1 = new QueryWrapper(); |
| | | queryWrapper1.eq("dev_name", binf.getDevName()); |
| | | queryWrapper1.eq("power_id", pinf.getPowerId()); |
| | | queryWrapper1.last("limit 1"); |
| | | BattInf jueged = mapper.selectOne(queryWrapper1); |
| | | if (jueged != null) { |
| | | return new Response().set(1, false, "该电源下已存在" + binf.getDevName() + "的设备"); |
| | | } |
| | | wrapper3.set("dev_name", binf.getDevName()); |
| | | } |
| | | /*if(binf.getDevType()!=null){ |
| | | wrapper3.set("dev_type",binf.getDevType()); |
| | | }*/ |
| | | wrapper3.eq("dev_id", binf.getDevId()); |
| | | |
| | | //修改电池组信息 |
| | | UpdateWrapper wrapper4=new UpdateWrapper(); |
| | | 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()+"的电池组"); |
| | | //修改电池组信息 |
| | | UpdateWrapper wrapper4 = new UpdateWrapper(); |
| | | 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() + "的电池组"); |
| | | } |
| | | wrapper4.set("battgroup_name", binf.getBattgroupName()); |
| | | } |
| | | wrapper4.set("battgroup_name",binf.getBattgroupName()); |
| | | if (binf.getMonvolstd() != null) { |
| | | wrapper4.set("monvolstd", binf.getMonvolstd()); |
| | | } |
| | | if (binf.getMoncapstd() != null) { |
| | | wrapper4.set("moncapstd", binf.getMoncapstd()); |
| | | } |
| | | if (binf.getMonresstd() != null) { |
| | | wrapper4.set("monresstd", binf.getMonresstd()); |
| | | } |
| | | if (binf.getProduct() != null) { |
| | | wrapper4.set("product", binf.getProduct()); |
| | | } |
| | | if (binf.getMoncount() != null) { |
| | | wrapper4.set("moncount", binf.getMoncount()); |
| | | } |
| | | if (binf.getBattModel() != null) { |
| | | wrapper4.set("batt_model", binf.getBattModel()); |
| | | } |
| | | wrapper4.eq("battgroup_id", binf.getBattgroupId()); |
| | | mapper.update((BattInf) ActionUtil.objeNull,wrapper3); |
| | | mapper.update((BattInf) ActionUtil.objeNull,wrapper4); |
| | | } |
| | | if(binf.getMonvolstd()!=null){ |
| | | wrapper4.set("monvolstd",binf.getMonvolstd()); |
| | | } |
| | | if(binf.getMoncapstd()!=null){ |
| | | wrapper4.set("moncapstd",binf.getMoncapstd()); |
| | | } |
| | | if(binf.getMonresstd()!=null){ |
| | | wrapper4.set("monresstd",binf.getMonresstd()); |
| | | } |
| | | if(binf.getProduct()!=null){ |
| | | wrapper4.set("product",binf.getProduct()); |
| | | } |
| | | if(binf.getMoncount()!=null){ |
| | | wrapper4.set("moncount",binf.getMoncount()); |
| | | } |
| | | if(binf.getBattModel()!=null){ |
| | | wrapper4.set("batt_model",binf.getBattModel()); |
| | | } |
| | | wrapper4.eq("battgroup_id",binf.getBattgroupId()); |
| | | mapper.update((BattInf) ActionUtil.objeNull,wrapper4); |
| | | return new Response().set(1,true); |
| | | sinfMapper.update((StationInf) ActionUtil.objeNull,wrapper1); |
| | | pinfMapper.update((PowerInf) ActionUtil.objeNull,wrapper2); |
| | | return new Response().set(1,true,"修改信息成功"); |
| | | } |
| | | /*//修改电池组 |
| | | public Response updateBatt(BattInf binf) { |