| | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.BattInfAndEnduranceDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattInfMapper; |
| | | import com.whyc.mapper.BattinfUpdateRecordMapper; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.BattinfUpdateRecord; |
| | | import com.whyc.pojo.PowerInf; |
| | | import com.whyc.pojo.StationInf; |
| | | import com.whyc.mapper.*; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | |
| | | private ProcessSurveyService processSurveyService; |
| | | @Autowired |
| | | private BatttestdataInfService testInfService; |
| | | |
| | | @Autowired(required = false) |
| | | private StationInfMapper sinfMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private BaoJiGroupBattGroupMapper bjBattMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private DevalarmDataMapper devAlmMapper; |
| | | |
| | | public int searchMaxBattgroupId_zj() { |
| | | Integer id = battInfMapper.getMaxBattGroupId_zj(); |
| | |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | public Response searchStationNameInGroup2(Integer uId,String stationName1){ |
| | | List<Battinf> list = battInfMapper.getStationNameInGroup2(uId,stationName1); |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | @Transactional |
| | | public Response add(Battinf battinf,Integer userId){ |
| | | int battGroupId = searchMaxBattgroupId_zj();//BattinfGroupFactory.searchMaxBattgroupId(); |
| | |
| | | station.setStationName3(battinf.getStationName3()); |
| | | station.setStationName4(battinf.getStationName4()); |
| | | station.setStationName5(battinf.getStationName5()); |
| | | station.setTogetherFlag(sinfMapper.getMaxTogetherFlag()); |
| | | stationInfService.insertStation(station); |
| | | |
| | | battinf.setStationId(stationId); |
| | | battinf.setFBSDeviceId((long) dev_id); |
| | | } |
| | |
| | | public void deleteByBattgroupId(Integer battgroupId){ |
| | | QueryWrapper<Battinf> wrapper = new QueryWrapper<Battinf>().eq("battgroupId",battgroupId); |
| | | battInfMapper.delete(wrapper); |
| | | //删除包机组下电池组 |
| | | QueryWrapper<BaojiGroupBattGroup> bjWrapper = new QueryWrapper<BaojiGroupBattGroup>().eq("battgroupId",battgroupId); |
| | | bjBattMapper.delete(bjWrapper); |
| | | //删除电池组后操作 |
| | | doAfterBattGroupChange(battgroupId); |
| | | } |
| | | |
| | |
| | | |
| | | public List<Battinf> getBattGroupInfoByFBSDeviceId(int fbsDeviceId) { |
| | | QueryWrapper<Battinf> queryWrapper = Wrappers.query(); |
| | | queryWrapper.select("BattGroupId","BattGroupName").eq("FBSDeviceId",fbsDeviceId); |
| | | queryWrapper.select("BattGroupId","stationName1","stationName2","stationName3","stationName4","stationName5","BattGroupName","GroupIndexInFBSDevice","MonVolStd","MonCapStd","MonResStd","MonSerStd","MonTmpStd").eq("FBSDeviceId",fbsDeviceId); |
| | | return battInfMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | |
| | | int yearAboveSeven = 0; |
| | | List<Integer> list = battInfMapper.findUseYear(uId); |
| | | //查询1年内~7年内,7年以上,含头不含尾 |
| | | map.put("1年内", (int) list.stream().filter(item -> item <= 1).count()); |
| | | map.put("2年内", (int) list.stream().filter(item -> item <= 2).count()); |
| | | map.put("3年内", (int) list.stream().filter(item -> item <= 3).count()); |
| | | map.put("4年内", (int) list.stream().filter(item -> item <= 4).count()); |
| | | map.put("5年内", (int) list.stream().filter(item -> item <= 5).count()); |
| | | map.put("6年内", (int) list.stream().filter(item -> item <= 6).count()); |
| | | map.put("7年内", (int) list.stream().filter(item -> item <= 7).count()); |
| | | map.put("7年以上", (int) list.stream().filter(item -> item > 7).count()); |
| | | map.put("1年内", (int) list.stream().filter(item -> item <1).count()); |
| | | map.put("2年内", (int) list.stream().filter(item -> item < 2).count()); |
| | | map.put("3年内", (int) list.stream().filter(item -> item < 3).count()); |
| | | map.put("4年内", (int) list.stream().filter(item -> item < 4).count()); |
| | | map.put("5年内", (int) list.stream().filter(item -> item < 5).count()); |
| | | map.put("6年内", (int) list.stream().filter(item -> item < 6).count()); |
| | | map.put("7年内", (int) list.stream().filter(item -> item < 7).count()); |
| | | map.put("7年以上", (int) list.stream().filter(item -> item >= 7).count()); |
| | | |
| | | /*for (int year:list){ |
| | | if(year<3){ |
| | |
| | | //取出电池组信息构建excel文件的名称 |
| | | public String serchExcelName(int battGroupId) { |
| | | Battinf binf = battInfMapper.serchExcelName(battGroupId); |
| | | String excelName = binf.getStationName1() + "-" + binf.getStationName2() + "-" + binf.getStationName5() + "-" + binf.getStationName3() + "-" + ActionUtil.sdfwithOutday.format(binf.getBattProductDate()).replace("_", "-") + "-" + (int) ((float) binf.getMonCapStd()) + "AH" + "-" + binf.getBattGroupName(); |
| | | //String excelName = binf.getStationName1() + "-" + binf.getStationName2() + "-" + binf.getStationName5() + "-" + binf.getStationName3() + "-" + ActionUtil.sdfwithOutday.format(binf.getBattProductDate()).replace("_", "-") + "-" + (int) ((float) binf.getMonCapStd()) + "AH" + "-" + binf.getBattGroupName(); |
| | | String excelName = binf.getStationName1() + "-" + binf.getStationName2() + "-" + binf.getStationName5() + "-" + binf.getStationName3()+ "-" + binf.getStationName4() |
| | | + "-" + ThreadLocalUtil.format(binf.getBattProductDate(),2).replace("_", "-") + "-" + (int) ((float) binf.getMonCapStd()) + "AH" + "-" + binf.getBattGroupName(); |
| | | return excelName; |
| | | } |
| | | |
| | |
| | | public String serchExcelNameA059(int battGroupId, String stateFlag) { |
| | | Battinf binf = battInfMapper.serchExcelName(battGroupId); |
| | | //导出格式:内蒙古自治区-鄂尔多斯市-东胜区-中心局-理士400AH1组-2022-04-21-第1次放电 |
| | | String excelName = binf.getStationName1() + "-" + binf.getStationName2() + "-" + binf.getStationName5() + "-" + binf.getStationName3() + "-" + |
| | | String excelName = binf.getStationName1() + "-" + binf.getStationName2() + "-" + binf.getStationName5() + "-" + binf.getStationName3() + "-" + binf.getStationName4() + "-" + |
| | | binf.getBattProducer() + binf.getMonCapStd() + "AH" + (binf.getGroupIndexInFBSDevice() + 1) + "组" + "-" + stateFlag; |
| | | return excelName; |
| | | } |
| | | |
| | | |
| | | public Response uploadPicOfStation(List<MultipartFile> file, String stationId) { |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | stationId = ActionUtil.filterFileName(stationId); |
| | | String fileDirName = ""; |
| | | int configType = Integer.parseInt(environment.getProperty("configFile.type")); |
| | | ApplicationHome applicationHome = new ApplicationHome(getClass()); |
| | |
| | | fileDirName = jarFile.toString(); |
| | | } |
| | | boolean deleted = false; |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | stationId = ActionUtil.filterFileName(stationId); |
| | | String root=fileDirName+"/fg_photo/stationsrc/"+ stationId + "/"; |
| | | for (int i = 0; i < fileNames.size(); i++) { |
| | | File file = new File(root+fileNames.get(i)); |
| | | String fileName = fileNames.get(i); |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | fileName = ActionUtil.filterFileName(fileName); |
| | | File file = new File(root+ fileName); |
| | | if (file.exists()&&file.isFile()){ |
| | | deleted = file.delete(); |
| | | }else { |
| | |
| | | |
| | | |
| | | public Response getStationPic(String stationId){ |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | stationId = ActionUtil.filterFileName(stationId); |
| | | String fileDirName = ""; |
| | | int configType = Integer.parseInt(environment.getProperty("configFile.type")); |
| | | ApplicationHome applicationHome = new ApplicationHome(getClass()); |
| | |
| | | |
| | | public Battinf getBattGroupInfoByBattGroupId(int battGroupId) { |
| | | QueryWrapper<Battinf> queryWrapper = Wrappers.query(); |
| | | queryWrapper.select("MonVolStd", "MonCount", "cellShowType","NomCapWH","NomCapAH").eq("BattGroupId", battGroupId); |
| | | queryWrapper.select("MonVolStd", "MonCount", "cellShowType","NomCapWH","NomCapAH","acdc_secuity_flag","Load_curr").eq("BattGroupId", battGroupId); |
| | | return battInfMapper.selectOne(queryWrapper); |
| | | } |
| | | |
| | |
| | | Float nomCapAH = nomCapWH*1000/53.5f; |
| | | UpdateWrapper<Battinf> update = Wrappers.update(); |
| | | update.set("NomCapWH",nomCapWH).set("NomCapAH",nomCapAH).eq("battGroupId",inf.getBattGroupId()); |
| | | battInfMapper.update(null,update); |
| | | battInfMapper.update((Battinf) ActionUtil.objeNull,update); |
| | | return new Response().setII(1,"修改完成"); |
| | | } |
| | | |
| | | /** |
| | | * 获取电池,设备,电源,机房站点 计数/管理元首页:基础资源信息 |
| | | * |
| | | * 设备的数量统计和设备状态的统计,逻辑是不同的,数据库筛选的时候条件逻辑必定是不同的: TODO |
| | | * 通常情况下,设备数量统计,要排除掉一个设备两个id的一拖二情况; |
| | | * 而设备状态统计,只需要区分一个设备的字段,一个设备有多条记录也是正常合理的,通过状态优先级覆盖来定义整个设备的状态 |
| | | * |
| | | * @param userId |
| | | * @return |
| | |
| | | int powerNum = powerInfService.getNum(userId); |
| | | List<StationInf> stationInfList = stationInfService.getStationInfList(userId); |
| | | int stationNum = stationInfService.getStation(userId); |
| | | int hrDisNum = testInfService.getHrQuarter(userId); |
| | | int hrDisNum = testInfService.getHrQuarterZC(userId); |
| | | map.put("battGroupCount", battGroupCount); |
| | | map.put("devCount", devCount); |
| | | map.put("powerNum", powerNum); |
| | | map.put("stationNum",stationNum); |
| | | map.put("stationInfList",stationInfList); |
| | | map.put("checkCapNum",hrDisNum); |
| | | return new Response().setII(1,true, map,null); |
| | | return new Response().setII(1,true, map,""); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | public Response getDevCountMapForSZ(int userId) { |
| | | try { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | int battGroupCount = battInfMapper.getBattGroupNum(userId); |
| | | //电池单体总数 |
| | | int battGroupMonCount = battInfMapper.getBattGroupMonNum(userId); |
| | | int devCount = battInfMapper.getDevNum(userId); |
| | | int powerNum = powerInfService.getNum(userId); |
| | | List<StationInf> stationInfList = stationInfService.getStationInfList(userId); |
| | | int stationNum = stationInfService.getStation(userId); |
| | | int hrDisNum = testInfService.getHrQuarterZC(userId); |
| | | map.put("battGroupCount", battGroupCount); |
| | | map.put("battGroupMonCount", battGroupMonCount); |
| | | map.put("devCount", devCount); |
| | | map.put("powerNum", powerNum); |
| | | map.put("stationNum",stationNum); |
| | | map.put("stationInfList",stationInfList); |
| | | map.put("checkCapNum",hrDisNum); |
| | | return new Response().setII(1,true, map,""); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | //山西晋源特定接口 |
| | | public Response getDevCountMapJY() { |
| | | try { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | int battGroupCount = battInfMapper.getBattGroupNumJY(); |
| | | int devCount = battInfMapper.getDevNumJY(); |
| | | int powerNum = powerInfService.getNumJY(); |
| | | List<StationInf> stationInfList = stationInfService.getStationInfListJY(); |
| | | int stationNum = stationInfService.getStationJY(); |
| | | int hrDisNum = testInfService.getHrQuarterZCJY(); |
| | | map.put("battGroupCount", battGroupCount); |
| | | map.put("devCount", devCount); |
| | | map.put("powerNum", powerNum); |
| | | map.put("stationNum",stationNum); |
| | | map.put("stationInfList",stationInfList); |
| | | map.put("checkCapNum",hrDisNum); |
| | | return new Response().setII(1,true, map,""); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | //大屏 |
| | | public List<Battinf> getBattGroupList(int userId) { |
| | | return battInfMapper.getBattGroupList(userId); |
| | | } |
| | | //山西晋源特定接口 |
| | | public List<Battinf> getBattGroupListJY() { |
| | | return battInfMapper.getBattGroupListJY(); |
| | | } |
| | | |
| | | //管理员首页:基础资源信息 |
| | |
| | | //int battStationNum = battInfMapper.geStationCount(userId); |
| | | //总机房 |
| | | int stationNum = stationInfService.getStation(userId); |
| | | //设备数 |
| | | int deviceNum = battInfMapper.getDevNum(userId); |
| | | /*本年度已核容放电电池组(testdate_inf中test_type=3,test_startType=3) |
| | | int hrDisNum = testInfService.getHrQuarter(userId); |
| | | * 修改为:领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: |
| | |
| | | map.put("powerNum", powerNum);//电源 |
| | | map.put("stationNum", stationNum);//总机房 |
| | | map.put("hrDisNum", hrDisNum);//本年度核容放电电池组 |
| | | map.put("deviceNum", deviceNum);//本年度核容放电电池组 |
| | | return new Response().setII(1, true, map, "基础资源信息"); |
| | | } catch (Exception e) { |
| | | return new Response<>().set(1, false, "发生异常:" + e.getCause()); |
| | |
| | | List<String> list = battInfMapper.searchMonVol(); |
| | | return new Response().setII(1, list.size() > 0 ? true : false, list, "查询标称电压类别"); |
| | | } |
| | | |
| | | //根据设备id查询电池组id(取第一个) |
| | | public Response searchBattGroupIdByDevId(int devId) { |
| | | String battGroupId = battInfMapper.searchBattGroupIdByDevId(devId); |
| | | return new Response().setII(1, battGroupId != null, battGroupId != null ? battGroupId : "0", "返回电池组id"); |
| | | } |
| | | |
| | | public String getStationIdByBattGroupId(Integer battGroupId) { |
| | | QueryWrapper<Battinf> query = Wrappers.query(); |
| | | query.eq("BattGroupId",battGroupId).last(" limit 1"); |
| | | return battInfMapper.selectOne(query).getStationId(); |
| | | } |
| | | |
| | | public String getStationIdByDeviceId(Integer deviceId) { |
| | | QueryWrapper<Battinf> query = Wrappers.query(); |
| | | query.eq("FBSDeviceId",deviceId).last(" limit 1"); |
| | | return battInfMapper.selectOne(query).getStationId(); |
| | | } |
| | | //天一电厂获取用户管理的电池组实时数据 |
| | | public Response selectTydc3DRealTimeInfo(Long uId) { |
| | | List<Battinf> list=battInfMapper.selectTydc3DRealTimeInfo(uId); |
| | | return new Response().setII(1,list!=null,list,"用户管理的电池组实时数据"); |
| | | } |
| | | |
| | | public List<String> getStationIds() { |
| | | QueryWrapper<Battinf> query = Wrappers.query(); |
| | | query.select("distinct StationId as StationId"); |
| | | List<Battinf> battinfs = battInfMapper.selectList(query); |
| | | return battinfs.stream().map(Battinf::getStationId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public List<Battinf> getBattListByStatoinId(String stationId) { |
| | | QueryWrapper<Battinf> query = Wrappers.query(); |
| | | query.eq("StationId",stationId); |
| | | return battInfMapper.selectList(query); |
| | | } |
| | | //取第一组电池信息 |
| | | public Response getPowerHr6159(int devId) { |
| | | QueryWrapper<Battinf> query = Wrappers.query(); |
| | | query.eq("FBSDeviceId",devId).last(" limit 1").orderByAsc("battGroupId"); |
| | | Battinf binf=battInfMapper.selectOne(query); |
| | | return new Response().setII(1,binf!=null,binf,"取第一组电池信息"); |
| | | } |
| | | //keyid绑定设备id |
| | | public Response setKeyIdWithDeviceId(Integer devId, String keyId) { |
| | | //1.检测是否存在keyid的设备 |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("KeyID",keyId); |
| | | wrapper.last(" limit 1"); |
| | | Battinf binf=battInfMapper.selectOne(wrapper); |
| | | int flag=0; |
| | | if(binf!=null){ |
| | | //查询devId对应设备的ip |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.eq("FBSDeviceId",devId); |
| | | wrapper1.last(" limit 1"); |
| | | Battinf binf1=battInfMapper.selectOne(wrapper1); |
| | | if(binf.getFBSDeviceIp().equals(binf1.getFBSDeviceIp())){ |
| | | flag=1; |
| | | }else{ |
| | | flag=0; |
| | | } |
| | | }else{ |
| | | flag=1; |
| | | } |
| | | if(flag==1){ |
| | | UpdateWrapper updateWrapper=new UpdateWrapper(); |
| | | updateWrapper.set("KeyID",keyId); |
| | | updateWrapper.eq("FBSDeviceId",devId); |
| | | battInfMapper.update((Battinf) ActionUtil.objeNull,updateWrapper); |
| | | return new Response().set(1,true,"keyid绑定设备id"); |
| | | }else { |
| | | return new Response().set(1,false,"改ukey已绑定"); |
| | | } |
| | | } |
| | | //插入初始数据 |
| | | public void setDefalut( Map<String,Object> map){ |
| | | Map<String,Object> mapNum=new HashMap<>(); |
| | | mapNum.put("stionNum",0); |
| | | mapNum.put("devNum",0); |
| | | mapNum.put("battNum",0); |
| | | map.put("3",mapNum); |
| | | map.put("5",mapNum); |
| | | map.put("6",mapNum); |
| | | map.put("7",mapNum); |
| | | map.put("8",mapNum); |
| | | } |
| | | //1统计机房个数,设备个数,电池组个数(苏州地铁) |
| | | public Response getAllInfInSz2(Integer userId) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | //setDefalut(map); |
| | | Map<String,Object> allmap=new HashMap<>(); |
| | | int stionNum=0; |
| | | int devNum=0; |
| | | int battNum=0; |
| | | try { |
| | | //查询battinf表中所有电池组信息 |
| | | List<Battinf> list=battInfMapper.getAllInfInSz2(userId); |
| | | Map<String, List<Battinf>> ListMap = list.stream().collect(Collectors.groupingBy(Battinf::getStationName9)); |
| | | for (String stationName9 : ListMap.keySet()) { |
| | | Map<String, Object> battInfoMap = new HashMap<>(); |
| | | battInfoMap.put("stionNum",0); |
| | | battInfoMap.put("devNum",0); |
| | | battInfoMap.put("battNum",0); |
| | | List<Battinf> name9List=ListMap.get(stationName9); |
| | | Map<String, List<Battinf>> stationMap = name9List.stream().collect(Collectors.groupingBy(Battinf::getStationId)); |
| | | battInfoMap.put("stionNum",stationMap.size()); |
| | | stionNum+=stationMap.size(); |
| | | Map<Long, List<Battinf>> devMap = name9List.stream().collect(Collectors.groupingBy(Battinf::getFBSDeviceId)); |
| | | battInfoMap.put("devNum",devMap.size()); |
| | | devNum+=devMap.size(); |
| | | Map<Integer, List<Battinf>> battMap = name9List.stream().collect(Collectors.groupingBy(Battinf::getBattGroupId)); |
| | | battInfoMap.put("battNum",battMap.size()); |
| | | map.put(stationName9,battInfoMap); |
| | | battNum+=battMap.size(); |
| | | } |
| | | allmap.put("stionNum",stionNum); |
| | | allmap.put("devNum",devNum); |
| | | allmap.put("battNum",battNum); |
| | | map.put("allmap",allmap); |
| | | return new Response<>().setII(1,true,map,""); |
| | | } catch (Exception e) { |
| | | return new Response<>().set(1,false,""); |
| | | } |
| | | |
| | | } |
| | | //4.中间地图 |
| | | public Response getAllStationInSz2(Integer userId) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | try { |
| | | //查询battinf表中所有机房信息 |
| | | List<Battinf> list=battInfMapper.getAllStationInSz2(userId); |
| | | Map<String, List<Battinf>> ListMap = list.stream().collect(Collectors.groupingBy(Battinf::getStationName9)); |
| | | for (String stationName9 : ListMap.keySet()) { |
| | | List<Battinf> name9List=ListMap.get(stationName9); |
| | | for (Battinf binf:name9List) { |
| | | //判断机房下的设备告警是否都存在通讯告警 119020 |
| | | int flag=devAlmMapper.judgeCommErr(binf.getStationId(),119020); |
| | | if(flag>0){ |
| | | binf.setNote("0"); |
| | | }else{ |
| | | binf.setNote("1"); |
| | | } |
| | | } |
| | | map.put(stationName9,name9List); |
| | | } |
| | | return new Response<>().setII(1,true,map,""); |
| | | } catch (Exception e) { |
| | | return new Response<>().set(1,false,""); |
| | | } |
| | | } |
| | | } |