package com.fzzy.protocol.fzzy.analysis; import com.fzzy.api.Constant; import com.fzzy.api.data.ApiCommonDevice; import com.fzzy.gateway.GatewayUtils; import com.fzzy.gateway.entity.GatewayDevice; import com.fzzy.gateway.service.GatewayDeviceService; import com.fzzy.protocol.fzzy.builder.ObjectCommandBuilder; import com.fzzy.protocol.fzzy.builder.SimpleCommandBuilder; import com.fzzy.protocol.fzzy.cmd.BaseRemoteImpl; import com.fzzy.protocol.fzzy.data.ReMessage; import com.fzzy.protocol.fzzy.data.SendMessage; import com.fzzy.protocol.fzzy.resp.Response1001; import com.fzzy.protocol.fzzy.server.ServerUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.Date; /** * 系统类协议解析 */ @Slf4j @Component(AnalysisSystem.BEAN_ID) public class AnalysisSystem extends BaseRemoteImpl { public static final String BEAN_ID = "fzzy.analysisSystem"; @Resource private GatewayDeviceService gatewayDeviceService; public void analysis1001(ReMessage reMessage) { //获取到登陆信息,执行设备信息整理 ApiCommonDevice device = Constant.getCommonDeviceCache(reMessage.getSn()); if (null == device) { device = new ApiCommonDevice(); } device.setIp(reMessage.getIp()); device.setPort(reMessage.getPort()); device.setSn(reMessage.getSn()); device.setId(reMessage.getIedId()); device.setOnlineTime(new Date()); device.setCode("SUCCESS"); Constant.updateCache(device); //更新设备在线 gatewayDeviceService.onlineByCommonDevice(device); //返回当前系统时间 Response1001 response = new Response1001(); response.setTime(DateFormatUtils.format(new Date(), "yyyyMMddHHmmss")); ObjectCommandBuilder commandBuilder = ObjectCommandBuilder.getInstance(); SendMessage message = commandBuilder.buildMessage(reMessage, ServerUtils.FUNCTION_1001, response); send(message); log.info("控制柜----->>>平台,控制柜登陆解析完成-报文-{}", reMessage); } public void analysis1003(ReMessage reMessage, ApiCommonDevice ser) { } public void analysis1004(ReMessage reMessage, ApiCommonDevice ser) { } public void analysis1005(ReMessage reMessage, ApiCommonDevice ser) { //直接返回 SimpleCommandBuilder commandBuilder = SimpleCommandBuilder.getInstance(); SendMessage message = commandBuilder.buildMessage(ser, ServerUtils.FUNCTION_1005); send(message); } public void analysis1006(ReMessage reMessage, ApiCommonDevice ser) { //TODO } public void analysis1007(ReMessage reMessage, ApiCommonDevice ser) { log.info("控制柜----->>>平台:控制柜仓库状态信息同步完成-控制柜={}", ser.getIp()); } public void analysis1008(ReMessage message, ApiCommonDevice ser) { } public void analysis1009(ReMessage message, ApiCommonDevice ser) { } public void analysis1010(ReMessage reMessage, ApiCommonDevice ser) { log.info("控制柜----->>>平台:控制柜仓库配置信息同步完成-控制柜={}", ser.getIp()); } }