package com.ld.igds.io.notify.impl; import com.ld.igds.m.service.InoutCommonService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.ld.igds.constant.BizType; import com.ld.igds.inout.InoutConstant; import com.ld.igds.io.dto.WeightDto; import com.ld.igds.io.notify.NotifyWeightService; import com.ld.igds.util.ContextUtil; import com.ld.igds.websocket.WebSocketPacket; import com.ld.igds.websocket.WebSocketServer; /** * @author: andy.jia * @description: * @version: * @data:2020年3月13日 */ @Slf4j @Component(NotifyWeightService.BEAN_ID) public class NotifyWeightServiceImpl implements NotifyWeightService { @Autowired private WebSocketServer socketServer; @Autowired private InoutCommonService inoutManagerService; @SuppressWarnings("static-access") @Override public void notify(WeightDto response) { if(null == response.getCompanyId()){ response.setCompanyId(ContextUtil.getDefaultCompanyId()); } WebSocketPacket packet = new WebSocketPacket(); packet.setBizTag(InoutConstant.PROGRESS_WEIGHT_TAG); packet.setBizType(response.getBizType()); packet.setCompanyId(response.getCompanyId()); packet.setBizId("WEIGH"); packet.setData(response); //通知入库 packet.setBizType(BizType.INOUT_IN.getCode()); socketServer.sendByBizTag(packet); //通知出庫 packet.setBizType(BizType.INOUT_OUT.getCode()); socketServer.sendByBizTag(packet); log.debug("向前端发送地磅信息={}", packet.toString()); } @Override public void onCreate(String address, Integer port) { inoutManagerService.updateInoutConfStatus(address, port, InoutConstant.MAC_STATUS_NORMAL); } @Override public void onDestroy(String address, Integer port) { inoutManagerService.updateInoutConfStatus(address, port, InoutConstant.MAC_STATUS_NO_SIGNAL); } }