| | |
| | | } |
| | | return new Response().setII(1,baojiList!=null,baojiList,"查询包机组及包机组对应的用户和对应机房和锁"); |
| | | } |
| | | //包机组添加机房和锁|移除机房和锁 |
| | | //包机组添加机房和电源|移除机房和电源 |
| | | //②)将电源添加到班组包机组中时需检查该电源是否在其他包机组中存在,若存在则提示当前电源已在其他班组(可提示存在的班组名称)中存在,若不存在则执行添加逻辑。 |
| | | @Transactional |
| | | public void updateStationAndLockList(List<BaojigroupPower> BaojigroupPowerList, int operationFlag) { |
| | | public Response updateStationAndLockList(List<BaojigroupPower> BaojigroupPowerList, int operationFlag) { |
| | | if(operationFlag==1){ |
| | | bjPowermapper.insertBatchSomeColumn(BaojigroupPowerList); |
| | | List<BaojigroupPower> addList=new ArrayList<>(); |
| | | List<BaojigroupPower> unaddList=new ArrayList<>(); |
| | | for (BaojigroupPower bjp:BaojigroupPowerList) { |
| | | //检测否在其他包机组中存在,若存在则提示当前电源已在其他班组(可提示存在的班组名称)中存在 |
| | | int flag=checkPowerIsInBanzu(bjp.getPowerId()); |
| | | if(flag==1){ |
| | | unaddList.add(bjp); |
| | | return new Response().setII(1,false,unaddList,"存在电源已添加过班组"); |
| | | } |
| | | } |
| | | bjPowermapper.insertBatchSomeColumn(addList); |
| | | return new Response().set(1, true,"添加成功"); |
| | | |
| | | }else{ |
| | | bjPowermapper.deleteStationAndLockList(BaojigroupPowerList); |
| | | return new Response().set(1,true,"移除成功"); |
| | | } |
| | | } |
| | | //检测否在其他包机组中存在,若存在则提示当前电源已在其他班组(可提示存在的班组名称)中存在 |
| | | private int checkPowerIsInBanzu(Integer powerId) { |
| | | int flag=0; |
| | | List<BaojigroupPower> List=bjPowermapper.checkPower(powerId); |
| | | if(List!=null&&List.size()>0){ |
| | | List<Integer> flagList=List.stream().map(BaojigroupPower::getTeamFlag).collect(Collectors.toList()); |
| | | if (flagList != null && flagList.contains(1)) { |
| | | flag=1; |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | //包机组添加用户|移除用户 |
| | | @Transactional |
| | | public void updateUserList(List<BaojigroupUsr> baoJiGroupUserList, int operationFlag) { |
| | |
| | | List<BaojigroupUsr> list=bjUsrmapper.selectList(wrapper); |
| | | return list.size()>0?1:0 ; |
| | | } |
| | | //设置包机组标记 |
| | | /*设置包机组标记 |
| | | * ①将包机组设置成班组时,判断当前包机组内的电源是否在其他设置成班组的包机组内,若在则提示当前电源已在其他班组中。否则执行设置班组逻辑。 |
| | | * |
| | | * */ |
| | | public Response updateTeamFlag(Integer baoJiGroupId, Integer flag) { |
| | | if(flag==1) { |
| | | //查询要设置的包机组的站点 |
| | | QueryWrapper<BaojigroupPower> query = Wrappers.query(); |
| | | query.select("baoji_group_id", "station_id").eq("baoji_group_id", baoJiGroupId); |
| | | List<BaojigroupPower> stationIdList = bjPowermapper.selectList(query); |
| | | stationIdList = stationIdList.stream().distinct().collect(Collectors.toList()); |
| | | //查询其他的组,包含的所有站点 |
| | | List<BaojigroupPower> stationIdListWithDischargePlanFlag = bjPowermapper.getStationIdListWithDischargePlanFlag(); |
| | | stationIdListWithDischargePlanFlag = stationIdListWithDischargePlanFlag.stream().distinct().collect(Collectors.toList()); |
| | | List<BaojigroupPower> repeatedStationIdList = new LinkedList<>(); |
| | | for (int i = 0; i < stationIdList.size(); i++) { |
| | | BaojigroupPower baojiGroupBattGroup = stationIdList.get(i); |
| | | for (int j = 0; j < stationIdListWithDischargePlanFlag.size(); j++) { |
| | | BaojigroupPower baojiGroupBattGroupWithFlag = stationIdListWithDischargePlanFlag.get(j); |
| | | if (baojiGroupBattGroupWithFlag.getStationId().equals(baojiGroupBattGroup.getStationId())) { |
| | | repeatedStationIdList.add(baojiGroupBattGroupWithFlag); |
| | | break; |
| | | } |
| | | if(flag==1){ |
| | | //1检测当前包机组下的电源是否在其他包机组中存在,则查看该包机组是否为班组 |
| | | List<BaojigroupPower> powerList=bjPowermapper.checkPwrIsInBanzu(baoJiGroupId); |
| | | //2.若存在一条则返回,若不存在修改为班组 |
| | | if(powerList!=null&&powerList.size()>0){ |
| | | List<Integer> flagList=powerList.stream().map(BaojigroupPower::getTeamFlag).collect(Collectors.toList()); |
| | | if (flagList != null && flagList.contains(1)) { |
| | | return new Response().set(1,false,"当前包组下电源已存在班组中"); |
| | | } |
| | | } |
| | | //查询重复站点的信息 |
| | | if (repeatedStationIdList.size() > 0) { |
| | | return new Response().setII(1, false, repeatedStationIdList, "设置失败"); |
| | | } |
| | | } |
| | | UpdateWrapper<Baojigroup> update = Wrappers.update(); |
| | | update.set("team_flag",flag).eq("baoji_group_id",baoJiGroupId); |
| | | mapper.update((Baojigroup) ActionUtil.objeNull,update); |
| | | UpdateWrapper wrapper = new UpdateWrapper(); |
| | | wrapper.set("team_flag",flag); |
| | | wrapper.eq("baoji_group_id",baoJiGroupId); |
| | | mapper.update(null,wrapper); |
| | | return new Response().set(1,true,"设置完成"); |
| | | } |
| | | //删除包机组下的电源 |