| | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.*; |
| | | import com.whyc.pojo.db_station.PowerInf; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | } |
| | | 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 setBaojiTeam(Integer id, Integer teamFalg) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("baoji_group_id",id); |
| | | wrapper.set("team_flag",teamFalg); |
| | | int bl=mapper.update(null,wrapper); |
| | | return new Response().set(1,bl>0,"修改包机组班组成功"); |
| | | /*设置包机组标记 |
| | | * ①将包机组设置成班组时,判断当前包机组内的电源是否在其他设置成班组的包机组内,若在则提示当前电源已在其他班组中。否则执行设置班组逻辑。 |
| | | * |
| | | * */ |
| | | public Response updateTeamFlag(Integer baoJiGroupId, Integer flag) { |
| | | 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,"当前包组下电源已存在班组中"); |
| | | } |
| | | } |
| | | } |
| | | 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,"设置完成"); |
| | | } |
| | | //删除包机组下的电源 |
| | | public void delPowerInBaoji(Integer pid) { |
| | | UpdateWrapper<BaojigroupPower> update = Wrappers.update(); |
| | | update.eq("power_id",pid); |
| | | bjPowermapper.delete(update); |
| | | } |
| | | |
| | | //删除包机组下的机房 |
| | | public void delStationInBaoji(Integer sid) { |
| | | UpdateWrapper<BaojigroupPower> update = Wrappers.update(); |
| | | update.eq("station_id",sid); |
| | | bjPowermapper.delete(update); |
| | | } |
| | | //查询机房所在的班组 |
| | | public String getGroupName(Integer powerId) { |
| | | String groupName = powerInfMapper.getGroupName(powerId); |
| | | if(groupName==null||groupName.length()<0){ |
| | | groupName="none"; |
| | | } |
| | | return groupName; |
| | | } |
| | | //查询所有的包机组名集合(班组) |
| | | public List<Baojigroup> getGroupList() { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("team_flag",1); |
| | | List<Baojigroup> list=mapper.selectList(wrapper); |
| | | return list; |
| | | } |
| | | } |