| | |
| | | } |
| | | //查询stationName是否存在 |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.like("station_name",stationName); |
| | | wrapper.eq("station_name",stationName); |
| | | int count=mapper.selectCount(wrapper); |
| | | if(count>0){ |
| | | bl=false; |
| | |
| | | //查询站点的机房是否存在stationId |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | stationId=mapper.selectIdByName(stationName); |
| | | if(stationId!=null||stationId!=0){ |
| | | if(stationId!=0){ |
| | | fileInfo.setStationId(String.valueOf(stationId)); |
| | | }else{ |
| | | fileInfo.setStationId(String.valueOf(stationIdMax+1)); |
| | | stationId=stationIdMax+1; |
| | | } |
| | | fileInfo.setFileId(String.valueOf(fileIdMax+1)); |
| | | count=infoMapper.insert(fileInfo); |
| | | //判断文件已经添加过则不再重复添加 |
| | | int flag=judgeFile(stationId,fileInfo.getFileUrl()); |
| | | if(flag>0){ |
| | | return new FileInfo(); |
| | | }else{ |
| | | count=infoMapper.insert(fileInfo); |
| | | } |
| | | //将解析出来的文件信息插入数据库 |
| | | FileParam fparam=fileInfo.getFileParam(); |
| | | //去除groupinfo |
| | |
| | | for(int i=0;i<battgroupInfoList.size();i++){ |
| | | BattgroupInfo battgroupInfo=battgroupInfoList.get(i); |
| | | battgroupInfo.setBattgroupId(String.valueOf(battGroupId+1+i)); |
| | | battgroupInfo.setStationId(String.valueOf(stationIdMax+1)); |
| | | battgroupInfo.setStationId(String.valueOf(stationId)); |
| | | battgroupInfo.setFileId(String.valueOf(fileIdMax+1)); |
| | | battgroupInfo.setBattgroupNum(fparam.getGroupNum()); |
| | | int groupCount=groupInfoMapper.insert(battgroupInfo); |
| | |
| | | } |
| | | } |
| | | if(count>0){ |
| | | if(stationId==0){ |
| | | //操作成功给台站赋予stationId |
| | | UpdateWrapper uwrapper=new UpdateWrapper(); |
| | | uwrapper.set("station_id",stationIdMax+1); |
| | | uwrapper.eq("station_name",stationName); |
| | | mapper.update(null,uwrapper); |
| | | } |
| | | //操作成功给台站赋予stationId |
| | | UpdateWrapper uwrapper=new UpdateWrapper(); |
| | | uwrapper.set("station_id",stationId); |
| | | uwrapper.eq("station_name",stationName); |
| | | mapper.update(null,uwrapper); |
| | | } |
| | | return fileInfo; |
| | | } |
| | | //判断文件已经添加过则不再重复添加 |
| | | public int judgeFile(int stationId,String fileUrl){ |
| | | int flag=0; |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("station_id",stationId); |
| | | wrapper.eq("file_url",fileUrl); |
| | | FileInfo fileInfo=infoMapper.selectOne(wrapper); |
| | | if(fileInfo!=null){ |
| | | flag=1; |
| | | } |
| | | return flag; |
| | | } |
| | | //编辑台站 |
| | | public Response updateStation(String stationName1, String stationName2, String stationName3, String updateStationName1, String updateStationName2, String updateStationName3) { |
| | | public Response updateStation(String stationName1, String stationName2, String stationName3, String updateName) { |
| | | String stationName=""; |
| | | String updateStationName=""; |
| | | int stationFlag=0; |
| | | if(stationName1!=null&&!stationName1.isEmpty()){ |
| | | stationName=stationName+stationName1; |
| | | stationFlag=1; |
| | | } |
| | | if(stationName2!=null&&!stationName2.isEmpty()){ |
| | | stationName=stationName+"-"+stationName2; |
| | | stationFlag=2; |
| | | } |
| | | if(stationName3!=null&&!stationName3.isEmpty()){ |
| | | stationName=stationName+"-"+stationName3; |
| | | stationFlag=3; |
| | | } |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | if(updateStationName1!=null&&!updateStationName1.isEmpty()){ |
| | | updateStationName=updateStationName+stationName1; |
| | | wrapper.set("station_name1",updateStationName1); |
| | | int flag=0; |
| | | if(stationFlag==1){ |
| | | //修改StationName1 |
| | | flag=mapper.updateStationName1(stationName1,updateName); |
| | | } |
| | | if(updateStationName2!=null&&!updateStationName2.isEmpty()){ |
| | | updateStationName=updateStationName+"-"+updateStationName2; |
| | | wrapper.set("station_name2",updateStationName2); |
| | | if(stationFlag==2){ |
| | | //修改StationName2 |
| | | flag=mapper.updateStationName2(stationName1,stationName2,updateName); |
| | | } |
| | | if(updateStationName3!=null&&!updateStationName3.isEmpty()){ |
| | | updateStationName=updateStationName+"-"+updateStationName3; |
| | | wrapper.set("station_name3",updateStationName3); |
| | | if(stationFlag==3){ |
| | | //修改StationName3 |
| | | flag=mapper.updateStationName3(stationName1,stationName2,stationName3,updateName); |
| | | } |
| | | wrapper.set("station_name",updateStationName); |
| | | wrapper.eq("station_name",stationName); |
| | | int flag=mapper.update(null,wrapper); |
| | | return new Response().set(1,flag>0,"修改操作"); |
| | | } |
| | | //删除台站 |
| | | @Transactional |
| | | public Response deleteStation(String stationName1, String stationName2, String stationName3) { |
| | | String stationName=""; |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | int stationFlag=0; |
| | | if(stationName1!=null&&!stationName1.isEmpty()){ |
| | | stationName=stationName+stationName1; |
| | | stationFlag=1; |
| | | } |
| | | if(stationName2!=null&&!stationName2.isEmpty()){ |
| | | stationName=stationName+"-"+stationName2; |
| | | stationFlag=2; |
| | | } |
| | | if(stationName3!=null&&!stationName3.isEmpty()){ |
| | | stationName=stationName+"-"+stationName3; |
| | | stationFlag=3; |
| | | } |
| | | wrapper.eq("station_name",stationName); |
| | | //1.先查出机房的id |
| | | Integer stationId=mapper.selectIdByName(stationName); |
| | | if(stationId==null||stationId==0){ |
| | | List<StationInfo> idStations=new ArrayList<>(); |
| | | if(stationFlag==1){ |
| | | //找出根节点是stationName1的所有机房id |
| | | idStations=mapper.selectIdByName1(stationName1); |
| | | } |
| | | if(stationFlag==2){ |
| | | //找出根节点是stationName1,stationName2的所有机房id |
| | | idStations=mapper.selectIdByName2(stationName1,stationName2); |
| | | } |
| | | if(stationFlag==3){ |
| | | //找出根节点是stationName1,stationName2,stationName3的所有机房id |
| | | idStations=mapper.selectIdByName3(stationName1,stationName2,stationName3); |
| | | } |
| | | if(idStations!=null&&idStations.size()>0){ |
| | | for (StationInfo stationInfo:idStations) { |
| | | String stationName=stationInfo.getStationName(); |
| | | Integer stationId=Integer.valueOf(stationInfo.getStationId()); |
| | | //3.删除所有文件数据 |
| | | dataMapper.deleteDataAndInfoByStationId(stationId); |
| | | //4.删除所有文件参数 |
| | | paramMapper.deleteParamByStationId(stationId); |
| | | //最终删除基站 |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("station_id",stationId); |
| | | wrapper.eq("station_name",stationName); |
| | | mapper.delete(wrapper); |
| | | } |
| | | return new Response().set(1,true,"删除成功"); |
| | | }else{ |
| | | return new Response().set(1,false,"机房不存在"); |
| | | }else { |
| | | //3.删除所有文件数据 |
| | | dataMapper.deleteDataAndInfoByStationId(stationId); |
| | | //4.删除所有文件参数 |
| | | paramMapper.deleteParamByStationId(stationId); |
| | | } |
| | | //最终删除基站 |
| | | int flag=mapper.delete(wrapper); |
| | | return new Response().set(1,flag>0,"删除成功"); |
| | | } |
| | | //移除台站下文件(单个文件) |
| | | @Transactional |
| | | public Response delFileFromStation(String stationName, String filePath) { |
| | | //1.先查出机房的id |
| | | Integer stationId=mapper.selectIdByName(stationName); |
| | | if(stationId==null||stationId==0){ |
| | | if(stationId==null){ |
| | | return new Response().set(1,false,"机房不存在"); |
| | | }else{ |
| | | }else if(stationId==0){ |
| | | return new Response().set(1,false,"机房下不存在文件"); |
| | | }else { |
| | | //2.查出文件对应的文件id |
| | | Integer fileId=infoMapper.selectFileId(stationId,filePath); |
| | | if(fileId==null||fileId==0){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | public StationInfo getByFileId(String fileId) { |
| | | return mapper.getByFileId(fileId); |
| | | } |
| | | } |