/* package com.thhy.screen.modules.biz.bigscreen.controller; import com.alibaba.fastjson.JSON; import com.thhy.general.common.BasicResult; import com.thhy.general.common.enums.ProListenType; import com.thhy.general.common.enums.TopicConstant; import com.thhy.general.config.GlobalConfig; import com.thhy.screen.modules.biz.bigscreen.entity.*; import com.thhy.screen.modules.biz.bigscreen.mapper.BigScreenMapper; import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; import org.apache.rocketmq.spring.core.RocketMQListener; import org.redisson.api.RBucket; import org.redisson.api.RedissonClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.websocket.Session; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArraySet; @Component @RocketMQMessageListener(topic = "prolistenexc",consumerGroup = TopicConstant.PROLISTENEXC_GROUP) public class ExecProListen implements RocketMQListener { @Autowired private RedissonClient redissonClient; @Autowired private GlobalConfig globalConfig; @Autowired private BigScreenMapper bigScreenMapper; private Logger logger = LoggerFactory.getLogger("ExecProListen"); @Override public void onMessage(String s) { logger.info("生产监控终端处理收到消息"+s); System.out.println("需要更新的模块"+s); CopyOnWriteArraySet SESSIONS = ProListenSocketServer.SESSIONS; SESSIONS.forEach(session ->{ try { List> mapList = getData(session,s); if (session.isOpen()) { session.getBasicRemote().sendText(JSON.toJSONString(BasicResult.success(mapList))); logger.info("成功推送消息到生产监控大屏"+session.getId()+"___"+session.getRequestURI().getHost()); } } catch (IOException e) { throw new RuntimeException(e); } }); } public List> getData(Session session,String dataType){ RBucket companyRBucket = redissonClient.getBucket(globalConfig.getKeyPrefix()+":ws:company:"+session.getId()); String companyId = companyRBucket.get(); List> mapList = new ArrayList<>(); Map map = new HashMap<>(); map.put("mod",dataType); if(dataType.equals(ProListenType.PIPEYEARMONTH)){ //管片年度和月度 Map map1 = new HashMap<>(); PipePlanActual pipePlanActual = bigScreenMapper.pipePlanActual(companyId); map1.put("mod",ProListenType.PIPEPLANACTUAL); map1.put("pipePlanActual",pipePlanActual); mapList.add(map1); Map map2 = new HashMap<>(); List pipeMonthPlanActuals = bigScreenMapper.pipeMonthPlanActual(companyId); map2.put("mod",ProListenType.PIPEMONTHPLANACTUAL); map2.put("pipeMonthPlanActual",pipeMonthPlanActuals); mapList.add(map2); return mapList; }else if(dataType.equals(ProListenType.MATERIALWEEKANDMONTHS)){ //原料消耗 周月 List materialWeekAndMonths = bigScreenMapper.materialWeekAndMonth(companyId); map.put("materialWeekAndMonths",materialWeekAndMonths); }else if (dataType.equals(ProListenType.PIPEPLANACTUAL)){ //年度生产计划和实际完成 PipePlanActual pipePlanActual = bigScreenMapper.pipePlanActual(companyId); map.put("pipePlanActual",pipePlanActual); }else if (dataType.equals(ProListenType.PIPEMONTHPLANACTUAL)){ //月度生产计划和实际完成 List pipeMonthPlanActuals = bigScreenMapper.pipeMonthPlanActual(companyId); map.put("pipeMonthPlanActual",pipeMonthPlanActuals); }else if (dataType.equals(ProListenType.WATERCULINFO)){ //水养池 List culInfoList = bigScreenMapper.WaterCulInfo(companyId); map.put("waterCulInfo",culInfoList); }else if (dataType.equals(ProListenType.REPOINFO)){ //堆场 List repoInfoList = bigScreenMapper.repoInfo(companyId); map.put("repoInfo",repoInfoList); }else if (dataType.equals(ProListenType.SENDINFO)){ //发运 Map map1 = new HashMap<>(); List sendInfoList = bigScreenMapper.sendInfo(companyId); map1.put("mod",ProListenType.SENDINFO); map1.put("sendInfo",sendInfoList); Map map2 = new HashMap<>(); List repoInfoList = bigScreenMapper.repoInfo(companyId); map2.put("mod",ProListenType.REPOINFO); map2.put("repoInfo",repoInfoList); mapList.add(map1); mapList.add(map2); return mapList; } mapList.add(map); return mapList; } } */