| | |
| | | /** |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | # __----~~~~~~~~~~~------___ |
| | | # . . ~~//====...... __--~ ~~ |
| | | # -. \_|// |||\\ ~~~~~~::::... /~ |
| | | # ___-==_ _-~o~ \/ ||| \\ _/~~- |
| | | # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ |
| | | # _-~~ .=~ | \\-_ '-~7 /- / || \ / |
| | | # .~ .~ | \\ -_ / /- / || \ / |
| | | # / ____ / | \\ ~-_/ /|- _/ .|| \ / |
| | | # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ |
| | | # ' ~-| /| |-~\~~ __--~~ |
| | | # |-~~-_/ | | ~\_ _-~ /\ |
| | | # / \ \__ \/~ \__ |
| | | # _--~ _/ | .-~~____--~-/ ~~==. |
| | | # ((->/~ '.|||' -_| ~~-/ , . _|| |
| | | # -_ ~\ ~~---l__i__i__i--~~_/ |
| | | # _-~-__ ~) \--______________--~~ |
| | | # //.-~~~-~_--~- |-------~~~~~~~~ |
| | | # //.-~~~--\ |
| | | # 神兽保佑 |
| | | # 永无BUG! |
| | | */ |
| | | package com.fengdu.gas.service; |
| | | |
| | | import com.fengdu.gas.common.*; |
| | | import com.fengdu.gas.common.enums.*; |
| | | import com.fengdu.gas.common.model.Tuple; |
| | | import com.fengdu.gas.common.util.*; |
| | | import com.fengdu.gas.entity.response.facility.FacilityCount; |
| | | import com.fengdu.gas.entity.response.facility.FacilityData; |
| | | import com.fengdu.gas.repository.impl.WaterFacilityParameterMapperImpl; |
| | | import com.fengdu.gas.repository.impl.WaterMonitoryPointMapperImpl; |
| | | import com.fengdu.gas.repository.po.WaterFacilityParameterPO; |
| | | import com.fengdu.gas.repository.po.WaterMonitoryPointPO; |
| | | import org.apache.commons.lang3.BooleanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import com.fengdu.gas.repository.impl.WaterFacilityMapperImpl; |
| | | import com.fengdu.gas.repository.po.WaterFacilityPO; |
| | | import com.fengdu.gas.entity.request.waterfacility.ReqCreateWaterFacility; |
| | |
| | | public class WaterFacilityService extends BaseService { |
| | | @Autowired |
| | | private WaterFacilityMapperImpl mapper; |
| | | @Autowired |
| | | private WaterFacilityParameterMapperImpl waterFacilityParameterMapper; |
| | | @Autowired |
| | | private WaterMonitoryPointMapperImpl waterMonitoryPointMapper; |
| | | |
| | | public ExecutedResult<Long> create(ReqCreateWaterFacility request) { |
| | | // 转换po |
| | | WaterFacilityPO item = WaterFacilityConvert.INSTANCE.toCreate(request); |
| | | WaterFacilityPO item = CopierUtil.mapTo(request, WaterFacilityPO.class); |
| | | // 设置状态 |
| | | //item.setStatus(EState.NORMAL.getValue()); |
| | | // 设置记录创建时间 |
| | |
| | | return ExecutedResult.success(result); |
| | | } |
| | | |
| | | // public ExecutedResult<String> stop(Long id) { |
| | | // // 验证记录是否存在 |
| | | // ExecutedResult<WaterFacilityPO> checkExists = this.check4Id(id); |
| | | // if (checkExists.isFailed()) { |
| | | // return ExecutedResult.failed(checkExists.getMsg()); |
| | | // } |
| | | // WaterFacilityPO item = new WaterFacilityPO(); |
| | | // item.setId(id); |
| | | // item.setStatus(EState.DISABLED.getValue()); |
| | | // |
| | | // int rowCount = mapper.updateById(item); |
| | | // if (rowCount != 1) { |
| | | // return ExecutedResult.failed("停用[设备信息]失败。"); |
| | | // } |
| | | // return ExecutedResult.success(); |
| | | // } |
| | | // |
| | | // public ExecutedResult<String> enable(Long id) { |
| | | // // 验证记录是否存在 |
| | | // ExecutedResult<WaterFacilityPO> checkExists = this.check4Id(id); |
| | | // if (checkExists.isFailed()) { |
| | | // return ExecutedResult.failed(checkExists.getMsg()); |
| | | // } |
| | | // WaterFacilityPO item = new WaterFacilityPO(); |
| | | // item.setId(id); |
| | | // item.setStatus(EState.NORMAL.getValue()); |
| | | // |
| | | // int rowCount = mapper.updateById(item); |
| | | // if (rowCount != 1) { |
| | | // return ExecutedResult.failed("启用[设备信息]失败。"); |
| | | // } |
| | | // return ExecutedResult.success(); |
| | | // } |
| | | // |
| | | // public ExecutedResult<String> setSort(ReqSetSort request) { |
| | | // // 验证记录是否存在 |
| | | // ExecutedResult<WaterFacilityPO> checkExists = this.check4Id(request.getId()); |
| | | // if (checkExists.isFailed()) { |
| | | // return ExecutedResult.failed(checkExists.getMsg()); |
| | | // } |
| | | // WaterFacilityPO item = new WaterFacilityPO(); |
| | | // item.setId(request.getId()); |
| | | // item.setSort(request.getSort()); |
| | | // |
| | | // int rowCount = mapper.updateById(item); |
| | | // if (rowCount != 1) { |
| | | // return ExecutedResult.failed("设置[设备信息]排序值失败。"); |
| | | // } |
| | | // return ExecutedResult.success(); |
| | | // } |
| | | // |
| | | // public ExecutedResult<String> listSetSort(ReqListSetSort request) { |
| | | // // id列表 |
| | | // List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList()); |
| | | // // 验证记录是否存在 |
| | | // ExecutedResult<List<WaterFacilityPO>> checkExists = this.check4Id(listId); |
| | | // if (checkExists.isFailed()) { |
| | | // return ExecutedResult.failed(checkExists.getMsg()); |
| | | // } |
| | | // |
| | | // List<WaterFacilityPO> listUpdate = request.getList().stream() |
| | | // .map(c -> { |
| | | // WaterFacilityPO item = new WaterFacilityPO(); |
| | | // item.setId(c.getId()); |
| | | // item.setSort(c.getSort()); |
| | | // return item; |
| | | // }) |
| | | // .collect(Collectors.toList()); |
| | | // Boolean result = mapper.modifyList(listUpdate); |
| | | // if (result) { |
| | | // return ExecutedResult.success(); |
| | | // } |
| | | // return ExecutedResult.failed("[设备信息]设置排序值失败"); |
| | | // } |
| | | // |
| | | // public ExecutedResult<String> remove(Long id) { |
| | | // Boolean result = mapper.deleteLogic(id); |
| | | // if (BooleanUtils.isFalse(result)) { |
| | | // return ExecutedResult.failed("删除[设备信息]失败。"); |
| | | // } |
| | | // return ExecutedResult.success(); |
| | | // } |
| | | // |
| | | // public ExecutedResult<String> removeList(List<Long> ids) { |
| | | // Boolean result = mapper.deleteLogic(ids); |
| | | // if (BooleanUtils.isFalse(result)) { |
| | | // return ExecutedResult.failed("删除[设备信息]失败。"); |
| | | // } |
| | | // return ExecutedResult.success(); |
| | | // } |
| | | public ExecutedResult<List<FacilityData>> getFacilityList() { |
| | | List<FacilityData> result = new ArrayList<>(); |
| | | List<WaterMonitoryPointPO> pointPOList = waterMonitoryPointMapper.getList(); |
| | | List<WaterFacilityPO> facilityPOList = mapper.getList(); |
| | | List<WaterFacilityParameterPO> parameterPOList = waterFacilityParameterMapper.getList(); |
| | | for (WaterFacilityPO facilityPO : facilityPOList) { |
| | | WaterMonitoryPointPO pointPO = pointPOList.stream().filter(item -> item.getId().equals(facilityPO.getPointId())).findFirst().orElse(null); |
| | | FacilityData data = new FacilityData(); |
| | | data.setPointId(facilityPO.getPointId()); |
| | | data.setPointName(facilityPO.getPointName()); |
| | | data.setLeft(pointPO.getLeftMargin()); |
| | | data.setTop(pointPO.getTopMargin()); |
| | | data.setFacilityId(facilityPO.getId()); |
| | | data.setFacilityName(facilityPO.getFacilityName()); |
| | | data.setFacilityState(EFacilityState.getByValue(facilityPO.getFacilityState()).getDesc()); |
| | | data.setFacilityFanState(EFacilityState.getByValue(facilityPO.getFacilityFanState()).getDesc()); |
| | | List<WaterFacilityParameterPO> poList = parameterPOList.stream().filter(item -> item.getFacilityId().equals(facilityPO.getId())).collect(Collectors.toList()); |
| | | if (ListUtil.isNotNullOrEmpty(poList)) { |
| | | //获取甲烷值 |
| | | String methaneValue = poList.stream().filter(item -> item.getColumnsCode().equals("JW001")).map(WaterFacilityParameterPO::getColumnValue).findFirst().orElse(null); |
| | | //获取硫化氢值 |
| | | String hyrothionValue = poList.stream().filter(item -> item.getColumnsCode().equals("LHQ001")).map(WaterFacilityParameterPO::getColumnValue).findFirst().orElse(null); |
| | | //获取温度 |
| | | String temperature = poList.stream().filter(item -> item.getColumnsCode().equals("WD001")).map(WaterFacilityParameterPO::getColumnValue).findFirst().orElse(null); |
| | | |
| | | if (StringUtil.isNotNullOrEmpty(methaneValue)) |
| | | data.setMethaneValue(new BigDecimal(methaneValue)); |
| | | if (StringUtil.isNotNullOrEmpty(hyrothionValue)) |
| | | data.setHyrothionValue(new BigDecimal(hyrothionValue)); |
| | | if (StringUtil.isNotNullOrEmpty(temperature)) |
| | | data.setTemperature(new BigDecimal(temperature)); |
| | | } |
| | | result.add(data); |
| | | } |
| | | return ExecutedResult.success(result); |
| | | } |
| | | public ExecutedResult<List<FacilityCount>> deviceCount(){ |
| | | List<FacilityCount> result = new ArrayList<>(); |
| | | List<WaterMonitoryPointPO> pointPOList = waterMonitoryPointMapper.getList(); |
| | | List<WaterFacilityPO> facilityPOList = mapper.getList(); |
| | | for(WaterMonitoryPointPO po:pointPOList){ |
| | | List<WaterFacilityPO> collect = facilityPOList.stream().filter(item -> item.getPointId().equals(po.getId())).collect(Collectors.toList()); |
| | | if(ListUtil.isNotNullOrEmpty(collect)&&collect.size()>0){ |
| | | FacilityCount count=new FacilityCount(); |
| | | count.setPointId(po.getId()); |
| | | count.setPointName(po.getPointName()); |
| | | count.setFacilityFanCount(collect.size()); |
| | | count.setMethaneCount(collect.size()); |
| | | count.setHyrothionCount(collect.size()); |
| | | count.setBoxCount(collect.size()); |
| | | int i = count.getFacilityFanCount() + count.getMethaneCount() + count.getHyrothionCount() + count.getBoxCount(); |
| | | count.setSumCount( i); |
| | | result.add(count); |
| | | } |
| | | } |
| | | return ExecutedResult.success(result); |
| | | } |
| | | |
| | | public ExecutedResult<List<WaterFacilityVO>> getList(List<Long> listId) { |
| | | List<WaterFacilityVO> result = new ArrayList<>(); |
| | |
| | | } |
| | | return ExecutedResult.success(exists); |
| | | } |
| | | |
| | | protected ExecutedResult<List<WaterFacilityPO>> check4Id(List<Long> listId) { |
| | | // 从数据库查找设备信息 |
| | | List<WaterFacilityPO> list = mapper.getList(listId); |
| | |
| | | } |
| | | } |
| | | return ExecutedResult.success(list); |
| | | }} |
| | | } |
| | | } |