| | |
| | | |
| | | 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.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | |
| | | @Resource |
| | | private BatttestdataInfService testInfService; |
| | | |
| | | //查询最大的自增标识同一机房的标识 |
| | | public int getMaxTogetherFlag() { |
| | | int togetherFlag = mapper.getMaxTogetherFlag(); |
| | | return togetherFlag; |
| | | } |
| | | |
| | | //根据statidonId去查同一机房的标识 |
| | | public int getTogetherFlag(String stationIdTogether) { |
| | | int togetherFlag = mapper.getTogetherFlag(stationIdTogether); |
| | | return togetherFlag; |
| | | } |
| | | |
| | | //根据stationId和togetherFlag查询另外相同的机房 |
| | | public Response getTogetherFlagStationInf(String stationId, int togetherFlag) { |
| | | QueryWrapper wrapper = Wrappers.query(); |
| | | wrapper.eq("together_flag", togetherFlag); |
| | | wrapper.ne("stationId", stationId); |
| | | wrapper.last("limit 1"); |
| | | StationInf sinf = mapper.selectOne(wrapper); |
| | | return new Response().setII(1, sinf != null ? true : false, sinf, "根据stationId和togetherFlag查询另外相同的机房"); |
| | | } |
| | | |
| | | //插入站点 |
| | | @Transactional |
| | | public Response insertStation(StationInf stationInf) { |
| | | String stationId = stationInf.getStationId(); |
| | | String stationIdTogether = stationInf.getStationIdTogether(); |
| | | int togetherFlag = 0; |
| | | if (stationId == null || stationId.isEmpty()) { |
| | | stationId = String.valueOf(Integer.valueOf(getMaxStationId()) + 1); |
| | | stationInf.setStationId(stationId); |
| | | } |
| | | if (stationIdTogether == null || stationIdTogether.isEmpty()) { |
| | | togetherFlag = mapper.getMaxTogetherFlag() + 1; |
| | | } else { |
| | | //1.先验证同一机房结点信息和电压等级是否一样,若不一样则不允许添加 |
| | | QueryWrapper wrapper = Wrappers.query(); |
| | | wrapper.ne("stationId", stationIdTogether); |
| | | wrapper.last("limit 1"); |
| | | StationInf sinf = mapper.selectOne(wrapper); |
| | | if (stationInf.getNodeStation() != sinf.getNodeStation()) { |
| | | return new Response().set(1, false, "设置同一站点时,两站点节点属性不一致"); |
| | | } |
| | | if (!stationInf.getStationType().equals(sinf.getStationType())) { |
| | | return new Response().set(1, false, "设置同一站点时,两站点电压等级属性不一致"); |
| | | } |
| | | //2.相同设置同一站点 |
| | | togetherFlag = mapper.getTogetherFlag(stationIdTogether); |
| | | } |
| | | stationInf.setTogetherFlag(togetherFlag); |
| | | int flag = mapper.insert(stationInf); |
| | | //往map表插入 |
| | | BattMapInformation mapInfo = new BattMapInformation(); |
| | |
| | | mapInfo.setLatitude(stationInf.getStationLatitude()); |
| | | mapInfo.setStationName3(stationInf.getStationName3()); |
| | | mapMapper.insert(mapInfo); |
| | | return new Response().set(1, flag > 0, "插入站点"); |
| | | return new Response().set(1, flag > 0, flag > 0 ? "插入站点成功" : "插入站点失败"); |
| | | } |
| | | |
| | | //编辑机房名 |
| | | @Transactional |
| | | public Response updateName(String stationName, String stationName1, String stationName2, String stationName3, String stationName4, String stationName5, String stationId) { |
| | | public Response updateName(String stationName, String stationName1, String stationName2, String stationName3, String stationName4, String stationName5 |
| | | , String stationIdTogether, String stationId) { |
| | | UpdateWrapper wrapper = new UpdateWrapper(); |
| | | wrapper.eq("stationId", stationId); |
| | | UpdateWrapper sinfWrapper = new UpdateWrapper(); |
| | | sinfWrapper.eq("stationId", stationId); |
| | | if (stationName != null && !stationName.isEmpty()) { |
| | | wrapper.set("stationName", stationName); |
| | | sinfWrapper.set("stationName", stationName); |
| | | } |
| | | if (stationName1 != null && !stationName1.isEmpty()) { |
| | | wrapper.set("stationName1", stationName1); |
| | | sinfWrapper.set("stationName1", stationName1); |
| | | } |
| | | if (stationName2 != null && !stationName2.isEmpty()) { |
| | | wrapper.set("stationName2", stationName2); |
| | | sinfWrapper.set("stationName2", stationName2); |
| | | } |
| | | if (stationName3 != null && !stationName3.isEmpty()) { |
| | | wrapper.set("stationName3", stationName3); |
| | | sinfWrapper.set("stationName3", stationName3); |
| | | } |
| | | if (stationName4 != null && !stationName4.isEmpty()) { |
| | | wrapper.set("stationName4", stationName4); |
| | | sinfWrapper.set("stationName4", stationName4); |
| | | } |
| | | if (stationName5 != null && !stationName5.isEmpty()) { |
| | | wrapper.set("stationName5", stationName5); |
| | | sinfWrapper.set("stationName5", stationName5); |
| | | } |
| | | int flag = mapper.update(null, wrapper); |
| | | if (stationIdTogether != null && !stationIdTogether.isEmpty()) { |
| | | //1.先验证同一机房结点信息和电压等级是否一样,若不一样则不允许添加 |
| | | QueryWrapper wrapperZj = new QueryWrapper(); |
| | | QueryWrapper wrapperGl = new QueryWrapper(); |
| | | wrapperZj.eq("stationId", stationId); |
| | | wrapperGl.eq("stationId", stationIdTogether); |
| | | wrapper.last("limit 1"); |
| | | StationInf sinfZj = mapper.selectOne(wrapperZj); |
| | | StationInf sinfGl = mapper.selectOne(wrapperGl); |
| | | if (sinfZj.getNodeStation() != sinfGl.getNodeStation()) { |
| | | return new Response().set(1, false, "设置同一站点时,两站点节点属性不一致"); |
| | | } |
| | | if (!sinfZj.getStationType().equals(sinfGl.getStationType())) { |
| | | return new Response().set(1, false, "设置同一站点时,两站点电压等级属性不一致"); |
| | | } |
| | | if (sinfZj.getStationLongitude() != sinfGl.getStationLongitude()) { |
| | | return new Response().set(1, false, "设置同一站点时,两站点地址的经度属性不一致"); |
| | | } |
| | | if (sinfZj.getStationLatitude() != sinfGl.getStationLatitude()) { |
| | | return new Response().set(1, false, "设置同一站点时,两站点地址的维度属性不一致"); |
| | | } |
| | | if (!sinfZj.getStationAddr().equals(sinfGl.getStationAddr())) { |
| | | return new Response().set(1, false, "设置同一站点时,两站点详细地址属性不一致"); |
| | | } |
| | | int togetherFlag = mapper.getTogetherFlag(stationIdTogether); |
| | | sinfWrapper.set("together_flag", togetherFlag); |
| | | } else { |
| | | int togetherFlag = mapper.getMaxTogetherFlag() + 1; |
| | | sinfWrapper.set("together_flag", togetherFlag); |
| | | } |
| | | int flag = mapper.update(null, sinfWrapper); |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("stationId", stationId); |
| | | List listB = binfMapper.selectList(queryWrapper); |
| | |
| | | if (listP != null && listP.size() > 0) { |
| | | pinfMapper.update(null, wrapper); |
| | | } |
| | | return new Response().set(1, flag > 0, "编辑机房名"); |
| | | return new Response().set(1, flag > 0, flag > 0 ? "编辑机房名成功" : "编辑机房名失败"); |
| | | } |
| | | |
| | | //编辑站点 |
| | | @Transactional |
| | | public Response updateStation(String nodeStation, String stationType |
| | | , String stationLongitude, String stationLatitude |
| | | , String stationAddr, String stationId) { |
| | | , String stationAddr, int togetherFlag, String stationId) { |
| | | int nofla = 0; |
| | | int stlag = 0; |
| | | int lofla = 0; |
| | |
| | | //往map表插入 |
| | | BattMapInformation mapInfo = new BattMapInformation(); |
| | | UpdateWrapper wrapper = new UpdateWrapper(); |
| | | UpdateWrapper wrapperEx = new UpdateWrapper(); |
| | | UpdateWrapper infwrapper = new UpdateWrapper(); |
| | | UpdateWrapper infwrapperEx = new UpdateWrapper(); |
| | | UpdateWrapper mapwrapper = new UpdateWrapper(); |
| | | UpdateWrapper mapwrapperEx = new UpdateWrapper(); |
| | | wrapper.eq("stationId", stationId); |
| | | infwrapper.eq("stationId", stationId); |
| | | mapwrapper.eq("stationId", stationId); |
| | | //根据togetherFlag和stationId查询相同机房 |
| | | QueryWrapper togetWapper = Wrappers.query(); |
| | | togetWapper.eq("together_flag", togetherFlag); |
| | | togetWapper.ne("stationId", stationId); |
| | | togetWapper.last("limit 1"); |
| | | StationInf sinfEx = mapper.selectOne(togetWapper); |
| | | |
| | | if (nodeStation != null && !nodeStation.isEmpty()) { |
| | | nofla = 1; |
| | | wrapper.set("nodeStation", nodeStation); |
| | | infwrapper.set("nodeStation", nodeStation); |
| | | wrapperEx.set("nodeStation", nodeStation); |
| | | infwrapperEx.set("nodeStation", nodeStation); |
| | | } |
| | | if (stationType != null && !stationType.isEmpty()) { |
| | | stlag = 1; |
| | | wrapper.set("stationType", stationType); |
| | | infwrapper.set("stationType", stationType); |
| | | wrapperEx.set("stationType", stationType); |
| | | infwrapperEx.set("stationType", stationType); |
| | | } |
| | | if (stationLongitude != null && !stationLongitude.isEmpty()) { |
| | | lofla = 1; |
| | | mapInfo.setLongitude(Double.parseDouble(stationLongitude)); |
| | | wrapper.set("stationLongitude", stationLongitude); |
| | | wrapperEx.set("stationLongitude", stationLongitude); |
| | | mapwrapper.set("longitude", stationLongitude); |
| | | mapwrapperEx.set("longitude", stationLongitude); |
| | | |
| | | } |
| | | if (stationLatitude != null && !stationLatitude.isEmpty()) { |
| | | lafla = 1; |
| | | mapInfo.setLatitude(Double.parseDouble(stationLatitude)); |
| | | wrapper.set("stationLatitude", stationLatitude); |
| | | wrapperEx.set("stationLatitude", stationLatitude); |
| | | mapwrapper.set("latitude", stationLatitude); |
| | | mapwrapperEx.set("latitude", stationLatitude); |
| | | } |
| | | if (stationAddr != null && !stationAddr.isEmpty()) { |
| | | addfla = 1; |
| | | mapInfo.setAddress(stationAddr); |
| | | wrapper.set("stationAddr", stationAddr); |
| | | wrapperEx.set("stationAddr", stationAddr); |
| | | mapwrapper.set("address", stationAddr); |
| | | mapwrapperEx.set("address", stationAddr); |
| | | } else { |
| | | mapInfo.setAddress(""); |
| | | } |
| | |
| | | List list = binfMapper.selectList(qwrapper); |
| | | if (list.size() > 0) { |
| | | binfMapper.update(null, infwrapper); |
| | | } |
| | | //修改相同机房 |
| | | if (sinfEx != null) { |
| | | wrapperEx.eq("stationId", sinfEx.getStationId()); |
| | | infwrapperEx.eq("stationId", sinfEx.getStationId()); |
| | | mapper.update(null, wrapperEx); |
| | | binfMapper.update(null, infwrapperEx); |
| | | } |
| | | } |
| | | if (lofla > 0 || lafla > 0 || addfla > 0) { |
| | |
| | | mapInfo.setStationName(sinf.getStationName()); |
| | | mapInfo.setStationName3(sinf.getStationName3()); |
| | | mapMapper.insert(mapInfo); |
| | | } |
| | | //修改相同机房 |
| | | if (sinfEx != null) { |
| | | QueryWrapper mwrapperEx = new QueryWrapper(); |
| | | mwrapperEx.eq("stationId", sinfEx.getStationId()); |
| | | List listEx = mapMapper.selectList(mwrapperEx); |
| | | if (listEx.size() > 0) { |
| | | mapMapper.update(null, mapwrapperEx); |
| | | } else { |
| | | //插入map |
| | | mapInfo.setStationId(sinfEx.getStationId()); |
| | | mapInfo.setStationName(sinfEx.getStationName()); |
| | | mapInfo.setStationName3(sinfEx.getStationName3()); |
| | | mapMapper.insert(mapInfo); |
| | | } |
| | | } |
| | | } |
| | | return new Response().set(1, flag > 0, "编辑站点"); |
| | |
| | | } |
| | | map.put("data", list); |
| | | //站点统计 |
| | | List<StationInf> stationInfList = mapper.getStationInfList(userId); |
| | | //List<StationInf> stationInfList = mapper.getStationInfList(userId); |
| | | List<StationInf> stationInfList = mapper.getSateAnalysis(userId);//和homeAdmin相同 |
| | | //110kv/35kv/... |
| | | Map<String, Object> kvMap = new HashMap(); |
| | | Map<String, List<StationInf>> stationTypeMap = stationInfList.stream().filter(stationInf -> !stationInf.getStationType().equals("")).collect(Collectors.groupingBy(StationInf::getStationType)); |
| | |
| | | List<String> list = mapper.searStationType(); |
| | | return new Response().setII(1, list.size() > 0 ? true : false, list, "查询所有的站点电压等级"); |
| | | } |
| | | |
| | | //添加关联时下拉显示 |
| | | public Response getTogetherStations(String stationName1, String stationName2, String stationName5) { |
| | | List<StationInf> list = mapper.getTogetherStations(stationName1, stationName2, stationName5); |
| | | return new Response().set(1, list, "查询成功"); |
| | | } |
| | | } |