package com.iailab.module.model.utils;
|
|
import com.iailab.common.constant.BusinessConstant;
|
import com.iailab.module.infra.api.config.ConfigApi;
|
import com.iailab.module.model.enums.ModelResultEnum;
|
import com.iailab.module.websocket.server.WebSocketServer;
|
import lombok.extern.slf4j.Slf4j;
|
import javax.annotation.Resource;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2023年11月26日 12:58:00
|
*/
|
@Slf4j
|
@Component
|
public class DcsUtils {
|
|
@Resource
|
private ConfigApi configApi;
|
|
@Resource
|
private WebSocketServer webSocketServer;
|
|
|
private String IS_TIP = "isTip";
|
|
private String DEV_Y = "y";
|
|
public void sendTips(Map<String, Object> data, String modelName) {
|
if (!data.containsKey(BusinessConstant.MODELE_RESULT_STATUS)) {
|
return;
|
}
|
Integer code = Integer.parseInt(data.get(BusinessConstant.MODELE_RESULT_STATUS).toString());
|
if (BusinessConstant.MODELE_RESULT_STATUS_200.equals(code)) {
|
return;
|
}
|
String isTip = configApi.queryConfigByCode(IS_TIP);
|
if (!DEV_Y.equals(isTip)) {
|
return;
|
}
|
StringBuilder sb = new StringBuilder();
|
sb.append(modelName);
|
sb.append(":");
|
sb.append(ModelResultEnum.getEumByCode(code).getDesc());
|
webSocketServer.onMessage(sb.toString());
|
|
}
|
}
|