|  |  | @ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |  |  |  | import com.baomidou.mybatisplus.core.toolkit.IdWorker; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |  |  |  | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.google.api.client.util.Sleeper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.google.common.collect.Lists; |  |  |  | import com.google.common.collect.Lists; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.hnac.hzims.equipment.EquipmentContants; |  |  |  | import com.hnac.hzims.equipment.EquipmentContants; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.hnac.hzims.equipment.entity.*; |  |  |  | import com.hnac.hzims.equipment.entity.*; | 
			
		
	
	
		
		
			
				
					|  |  | @ -21,6 +22,7 @@ import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; |  |  |  | import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; |  |  |  | import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; |  |  |  | import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.apache.commons.collections4.MapUtils; |  |  |  | import org.apache.commons.collections4.MapUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springblade.core.log.exception.ServiceException; |  |  |  | import org.springblade.core.log.exception.ServiceException; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springblade.core.mp.base.BaseServiceImpl; |  |  |  | import org.springblade.core.mp.base.BaseServiceImpl; | 
			
		
	
	
		
		
			
				
					|  |  | @ -38,6 +40,7 @@ import org.springframework.util.Assert; | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.validation.Valid; |  |  |  | import javax.validation.Valid; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.*; |  |  |  | import java.util.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.stream.Collectors; |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.util.stream.Stream; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /** |  |  |  | /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  * 服务实现类 |  |  |  |  * 服务实现类 | 
			
		
	
	
		
		
			
				
					|  |  | @ -45,6 +48,7 @@ import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					
					|  |  |  |  * @author Chill |  |  |  |  * @author Chill | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | @Service |  |  |  | @Service | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | @Slf4j | 
			
		
	
		
		
			
				
					
					|  |  |  | public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntity> implements IEmInfoService { |  |  |  | public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntity> implements IEmInfoService { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	@Autowired |  |  |  | 	@Autowired | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private IEmParamService paramService; |  |  |  | 	private IEmParamService paramService; | 
			
		
	
	
		
		
			
				
					|  |  | @ -77,6 +81,11 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit | 
			
		
	
		
		
			
				
					
					|  |  |  | 	@Value("${hzims.equipment.emInfo.code-prefix}") |  |  |  | 	@Value("${hzims.equipment.emInfo.code-prefix}") | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public String emInfoCodePrefix; |  |  |  | 	public String emInfoCodePrefix; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	/** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * 10站点为一组数据 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	private static final Integer MAX_SEND = 3; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	@Override |  |  |  | 	@Override | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public R<EmInfoEntity> getEmInfoByCode(String emCode) { |  |  |  | 	public R<EmInfoEntity> getEmInfoByCode(String emCode) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		EmInfoNoScopeMapper mapper = SpringUtil.getBean("emInfoNoScopeMapper"); |  |  |  | 		EmInfoNoScopeMapper mapper = SpringUtil.getBean("emInfoNoScopeMapper"); | 
			
		
	
	
		
		
			
				
					|  |  | @ -417,29 +426,38 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit | 
			
		
	
		
		
			
				
					
					|  |  |  | 	@Override |  |  |  | 	@Override | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public void loadEmInfo() { |  |  |  | 	public void loadEmInfo() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		// 查询所有首页展示/状态非删除设备
 |  |  |  | 		// 查询所有首页展示/状态非删除设备
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<EminfoAndEmParamVo> list = this.baseMapper.selectEminfoAndEmParamVoList(); |  |  |  | 		List<EminfoAndEmParamVo> devices = this.baseMapper.selectEminfoAndEmParamVoList(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		// 查询所有设备(ct、pt、installedCapacity)配置参数
 |  |  |  | 		// 查询所有设备(ct、pt、installedCapacity)配置参数
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<EmParamEntity> paramList = this.paramService.getParamByParamNameGenerate(); |  |  |  | 		List<EmParamEntity> paramList = this.paramService.getParamByParamNameGenerate(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		// 获取设备监测点
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		// 获取设备监测点位:未配置监测点位不进行统计设备
 |  |  |  | 		// 获取设备监测点位:未配置监测点位不进行统计设备
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		List<MultiAnalyzeCodePO> multiAnalyzeCodePOList = list.stream().map(o->{ |  |  |  | 		List<MultiAnalyzeCodePO> multiAnalyzeCodePOList = devices.stream().map(o->{ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); |  |  |  | 			MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			multiAnalyzeCodePO.setDeviceCode(o.getEmCode()); |  |  |  | 			multiAnalyzeCodePO.setDeviceCode(o.getEmCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			multiAnalyzeCodePO.setSignages(HomePageConstant.SIGNAGES); |  |  |  | 			multiAnalyzeCodePO.setSignages(HomePageConstant.SIGNAGES); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return multiAnalyzeCodePO; |  |  |  | 			return multiAnalyzeCodePO; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		}).collect(Collectors.toList()); |  |  |  | 		}).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		R<List<AnalyzeCodeBySignagesVO>> result = searchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); |  |  |  | 		// 切割
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		int limit = countStep(multiAnalyzeCodePOList.size()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		List<List<MultiAnalyzeCodePO>> lists = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> multiAnalyzeCodePOList.stream().skip((long) a * MAX_SEND).limit(MAX_SEND).parallel().collect(Collectors.toList())).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		// 接收数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		List<AnalyzeCodeBySignagesVO> analys = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		lists.forEach(list->{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			R<List<AnalyzeCodeBySignagesVO>> result = searchClient.getAnalyzeCodeBySignages(list); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |  |  |  | 			if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ | 
			
		
	
		
		
			
				
					
					|  |  |  | 				return; |  |  |  | 				return; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			analys.addAll(result.getData()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		}); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		// 设备遍历
 |  |  |  | 		// 设备遍历
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		list.forEach(item->{ |  |  |  | 		devices.forEach(item->{ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			item.setRideCount(1); |  |  |  | 			item.setRideCount(1); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			item.setInstalledCapacity(0.0); |  |  |  | 			item.setInstalledCapacity(0.0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			List<AnalyzeCodeBySignagesVO> signages = analys.stream().filter(o-> item.getEmCode().equals(o.getDeviceCode()) && !StringUtil.isEmpty(o.getSignage()) && !StringUtil.isEmpty(o.getRealId())).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if(CollectionUtil.isEmpty(signages)){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				return; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  | 			// list -> map
 |  |  |  | 			// list -> map
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 			item.setPoint(result.getData().stream().filter(o-> item.getEmCode().equals(o.getDeviceCode()) && StringUtil.isNotBlank(o.getSignage()) && StringUtil.isNotBlank(o.getRealId())). |  |  |  | 			item.setPoint(signages.stream().collect(Collectors.toMap(AnalyzeCodeBySignagesVO::getSignage,AnalyzeCodeBySignagesVO::getRealId))); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 				collect(Collectors.toMap(AnalyzeCodeBySignagesVO::getSignage,AnalyzeCodeBySignagesVO::getRealId))); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			// 寻找设备配置参数
 |  |  |  | 			// 寻找设备配置参数
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 			List<EmParamEntity> itemParamList = paramList.stream().filter(o->item.getId().equals(o.getInfoId())).collect(Collectors.toList()); |  |  |  | 			List<EmParamEntity> itemParamList = paramList.stream().filter(o->item.getId().equals(o.getInfoId())).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			if(CollectionUtil.isNotEmpty(itemParamList)){ |  |  |  | 			if(CollectionUtil.isNotEmpty(itemParamList)){ | 
			
		
	
	
		
		
			
				
					|  |  | @ -456,6 +474,8 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit | 
			
		
	
		
		
			
				
					
					|  |  |  | 						case "installedCapacity": |  |  |  | 						case "installedCapacity": | 
			
		
	
		
		
			
				
					
					|  |  |  | 							item.setInstalledCapacity(Double.valueOf(param.getParamValue())); |  |  |  | 							item.setInstalledCapacity(Double.valueOf(param.getParamValue())); | 
			
		
	
		
		
			
				
					
					|  |  |  | 							break; |  |  |  | 							break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						default: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							break; | 
			
		
	
		
		
			
				
					
					|  |  |  | 					} |  |  |  | 					} | 
			
		
	
		
		
			
				
					
					|  |  |  | 				} |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  | 				// 设置ct * pt
 |  |  |  | 				// 设置ct * pt
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -465,7 +485,14 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		}); |  |  |  | 		}); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		// 设置缓存
 |  |  |  | 		// 设置缓存
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		redisTemplate.opsForValue().set(em_info_list_path, JSONObject.toJSONString(list.stream().filter(o-> Math.abs(o.getInstalledCapacity()) > 0  || MapUtils.isNotEmpty(o.getPoint())).collect(Collectors.toList()))); |  |  |  | 		redisTemplate.opsForValue().set(em_info_list_path, JSONObject.toJSONString(devices.stream().filter(o-> Math.abs(o.getInstalledCapacity()) > 0  || MapUtils.isNotEmpty(o.getPoint())).collect(Collectors.toList()))); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	/** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 * 计算切分次数 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	private static Integer countStep(Integer size) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		return (size + MAX_SEND - 1) / MAX_SEND; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private void validEmInfo(EmInfoAddVo em_info) { |  |  |  | 	private void validEmInfo(EmInfoAddVo em_info) { | 
			
		
	
	
		
		
			
				
					|  |  | 
 |