| | |
| | | package com.smtaiserver.smtaiserver.control;
|
| | |
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.File;
|
| | | import java.io.InputStream;
|
| | | import java.util.*;
|
| | | import java.util.Map.Entry;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.servlet.ModelAndView;
|
| | | import org.springframework.web.servlet.View;
|
| | | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
| | |
|
| | | import com.smtaiserver.smtaiserver.attach.SMTAIAttachMetricDef;
|
| | | import com.smtaiserver.smtaiserver.attach.SMTAIAttachTableDef;
|
| | | import com.smtaiserver.smtaiserver.attach.SMTAIAttachTableDef.SMTAIAttachTableColumn;
|
| | |
| | | import com.smtservlet.util.Json;
|
| | | import com.smtservlet.util.SMTJsonWriter;
|
| | | import com.smtservlet.util.SMTStatic;
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.File;
|
| | | import java.io.InputStream;
|
| | | import java.util.*;
|
| | | import java.util.Map.Entry;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.servlet.ModelAndView;
|
| | | import org.springframework.web.servlet.View;
|
| | | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
| | |
|
| | | public class SMTJavaAIControl
|
| | | {
|
| | |
| | |
|
| | | return tranReq.returnJson(jsonWr);
|
| | | }
|
| | | |
| | |
|
| | | public ModelAndView createOrder(SMTAIServerRequest tranReq) throws Exception {
|
| | | String title = tranReq.convParamToString("title", true);
|
| | | String wstypeid = tranReq.convParamToString("wstypeid", false);
|
| | | String wstypename = tranReq.convParamToString("wstypename", false);
|
| | | String urgencylevel = tranReq.convParamToString("urgencylevel", false);
|
| | | String shape = tranReq.convParamToString("shape", false);
|
| | | String deadline = tranReq.convParamToString("deadline", false);
|
| | | String stepstatus = tranReq.convParamToString("stepstatus", false);
|
| | | String originatetypetext = tranReq.convParamToString("originatetypetext", false);
|
| | | String content = tranReq.convParamToString("content", false);
|
| | | String address = tranReq.convParamToString("address", false);
|
| | | String stepid = tranReq.convParamToString("stepid", false);
|
| | | String org = tranReq.convParamToString("org", false);
|
| | | String deptname = tranReq.convParamToString("deptname", false);
|
| | | String dealtime = tranReq.convParamToString("dealtime", false);
|
| | | String username = tranReq.convParamToString("username", false);
|
| | | String contactname = tranReq.convParamToString("contactname", false);
|
| | | String contactphone = tranReq.convParamToString("contactphone", false);
|
| | | String acceptuserid = tranReq.convParamToString("acceptuserid", false);
|
| | | String acceptusername = tranReq.convParamToString("acceptusername", false);
|
| | | String acceptuseraccount = tranReq.convParamToString("acceptuseraccount", false);
|
| | | String dealuserid = tranReq.convParamToString("dealuserid", false);
|
| | | String dealusername = tranReq.convParamToString("dealusername", false);
|
| | | String dealuseraccount = tranReq.convParamToString("dealuseraccount", false);
|
| | | String flowstatus = tranReq.convParamToString("flowstatus", false);
|
| | | String attachment = tranReq.convParamToString("attachment", false);
|
| | | String creator = tranReq.convParamToString("creator", false);
|
| | | String createtime = tranReq.convParamToString("createtime", false);
|
| | | String isplan = tranReq.convParamToString("isplan", false);
|
| | | String originateid = tranReq.convParamToString("originateid", false);
|
| | | String appointstarttime = tranReq.convParamToString("appointstarttime", false);
|
| | | String appointendtime = tranReq.convParamToString("appointendtime", false);
|
| | | String parentid = tranReq.convParamToString("parentid", false);
|
| | | String relateids = tranReq.convParamToString("relateids", false);
|
| | | String oname = tranReq.convParamToString("oname", false);
|
| | | String otype = tranReq.convParamToString("otype", false);
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | try {
|
| | | db.executeSQL(
|
| | | "INSERT INTO work_order_list("
|
| | | + "order_id, title, wstypeid, wstypename, urgencylevel, shape, deadline, stepstatus, "
|
| | | + "originatetypetext, content, address, step_id, org, deptname, dealtime, username, contactname, "
|
| | | + "contactphone, acceptuserid, acceptusername, acceptuseraccount, dealuserid, dealusername, "
|
| | | + "dealuseraccount, flowstatus, attachment, creator, createtime, isplan, originateid, "
|
| | | + "appointstarttime, appointendtime, parentid, relateids,is_notify,oname,otype"
|
| | | + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)",
|
| | | new Object[] {
|
| | | SMTStatic.newUUID(),
|
| | | title,
|
| | | wstypeid,
|
| | | wstypename,
|
| | | urgencylevel,
|
| | | shape,
|
| | | deadline,
|
| | | stepstatus,
|
| | | originatetypetext,
|
| | | content,
|
| | | address,
|
| | | stepid,
|
| | | org,
|
| | | deptname,
|
| | | dealtime,
|
| | | username,
|
| | | contactname,
|
| | | contactphone,
|
| | | acceptuserid,
|
| | | acceptusername,
|
| | | acceptuseraccount,
|
| | | dealuserid,
|
| | | dealusername,
|
| | | dealuseraccount,
|
| | | flowstatus,
|
| | | attachment,
|
| | | creator,
|
| | | new Date(),
|
| | | isplan,
|
| | | originateid,
|
| | | appointstarttime,
|
| | | appointendtime,
|
| | | parentid,
|
| | | relateids,
|
| | | "N",
|
| | | oname,
|
| | | otype
|
| | | });
|
| | | } catch (Exception e) {
|
| | | throw new Exception("æ°æ®åºé误", e);
|
| | | }
|
| | |
|
| | | return tranReq.returnJsonState(true, null, null);
|
| | | }
|
| | |
|
| | | public ModelAndView updateOrderStatus(SMTAIServerRequest tranReq) throws Exception {
|
| | | String id = tranReq.convParamToString("id", true);
|
| | | Integer stepstatus = tranReq.convParamToInteger("stepstatus", true); // ç¶æä»£å·ï¼å¦å·²å®æ
|
| | |
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | try {
|
| | | db.executeSQL(
|
| | | "UPDATE work_order_list SET stepstatus = ? and status_update_time = ? WHERE id = ?",
|
| | | new Object[] {stepstatus, new Date(),id});
|
| | | } catch (Exception e) {
|
| | | throw new Exception("æ´æ°å·¥åç¶æå¤±è´¥", e);
|
| | | }
|
| | |
|
| | | return tranReq.returnJsonState(true, null, null);
|
| | | }
|
| | |
|
| | | public ModelAndView getOrderList(SMTAIServerRequest tranReq) throws Exception {
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | try {
|
| | | DBRecords recs = db.querySQL("SELECT * FROM work_order_list", null);
|
| | | if (recs.getRowCount() != 0) {
|
| | | SMTJsonWriter jsonWr = new SMTJsonWriter(false);
|
| | | jsonWr.beginArray("values"); // å¼å§ä¸ä¸ªæ°ç»ï¼key为 "values"
|
| | |
|
| | | for (DBRecord rec : recs.getRecords()) {
|
| | | jsonWr.beginMap(null); // æ¯æ¡è®°å½æ¯ä¸ä¸ªå¯¹è±¡
|
| | | for (String colName : rec.getColNames()) {
|
| | | jsonWr.addKeyValue(colName, rec.getString(colName)); // æ·»å æ¯ä¸ªå段
|
| | | }
|
| | | jsonWr.endMap(); // ç»æä¸ä¸ªå¯¹è±¡
|
| | | }
|
| | |
|
| | | jsonWr.endArray(); // ç»ææ°ç»
|
| | |
|
| | | return tranReq.returnJson(jsonWr); // è¿åæ´ä¸ªç»æ
|
| | |
|
| | | } else {
|
| | | return tranReq.returnJsonState(false, "æªæ¾å°å·¥å", null);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | throw new Exception("æ¥è¯¢å·¥å失败", e);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public ModelAndView disconnectBroadcastChat(SMTAIServerRequest tranReq) throws Exception
|
| | | {
|
| | | String userId = tranReq.getLoginUserId();
|
| | |
| | | Json jsonArgs = tranReq.convParamToJson("args", false);
|
| | | SMTQwenAgent agent = SMTAIServerApp.getApp().getQwenAgentManager().getAgentById(agentId);
|
| | |
|
| | | if(agent == null)
|
| | | throw new Exception("can't find agent : " + agentId);
|
| | | |
| | | SMTLLMConnect llm = SMTAIServerApp.getApp().allocLLMConnect(null);
|
| | |
|
| | | if(jsonArgs == null)
|
| | |
| | | import com.smtaiserver.smtaiserver.javaai.qwen.SMTQwenAgentManager;
|
| | | import com.smtaiserver.smtaiserver.javaai.qwen.SMTQwenApp;
|
| | | import com.smtaiserver.smtaiserver.javaai.sse.SMTSSEBroadcastChat;
|
| | | import com.smtaiserver.smtaiserver.web.SMTWebSocketHandler;
|
| | | import com.smtservlet.core.SMTApp;
|
| | | import com.smtservlet.core.SMTApp.SMTEhCacheManagerInitialize;
|
| | | import com.smtservlet.util.Json;
|
| | |
| | | import java.util.Set;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpSessionEvent;
|
| | | import net.sf.ehcache.Cache;
|
| | | import net.sf.ehcache.CacheManager;
|
| | |
| | | private static Pattern _patGlobalMacro = Pattern.compile("\\{\\{\\{([\\w\\.]+)\\}\\}\\}");
|
| | | private static Logger _logger = LogManager.getLogger(SMTQwenApp.class);
|
| | | private static Pattern _patIsNumber = Pattern.compile("^[1-9]\\d*$");
|
| | | |
| | | @Resource
|
| | | private SMTWebSocketHandler webSocketHandler;
|
| | | private static String[] _encacheIdList = {
|
| | | "GlobalConfig",
|
| | | "MetricsDefMap",
|
| | |
| | | return chat;
|
| | | }
|
| | | }
|
| | | |
| | | public void webSocketApp(String jsonString)
|
| | | {
|
| | | webSocketHandler.broadcast(jsonString);
|
| | | }
|
| | |
|
| | | public void setServiceEncache(SMTAIServerEncache serverEncache)
|
| | | {
|
| | | _serverEncache = serverEncache;
|
| | |
| | | package com.smtaiserver.smtaiserver.graph;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase;
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecord;
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecords;
|
| | | import com.smtservlet.util.Json;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | public class SMTAIGraphNode
|
| | | {
|
| | |
| | | import com.smtservlet.util.SMTJsonWriter;
|
| | | import com.smtservlet.util.SMTStatic;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map.Entry;
|
| | | import org.mozilla.javascript.Context;
|
| | |
| | | public String getGlobalConfig(String key, String defaultValue) throws Exception {
|
| | | String globalConfig = (String) SMTAIServerApp.getApp().getGlobalConfig(key, defaultValue);
|
| | | return globalConfig;
|
| | | }
|
| | | public String getNowDate() throws Exception {
|
| | | return SMTStatic.toString(new Date());
|
| | | }
|
| | | public String getUUID() throws Exception {
|
| | | return SMTStatic.newUUID();
|
| | | }
|
| | | public void webSocketBroadcast(NativeObject nativeObject) throws Exception {
|
| | | SMTJsonWriter jsonWr = new SMTJsonWriter(false);
|
| | | SMTAIServerApp.convJSToJsonWriter(nativeObject, jsonWr);
|
| | | SMTAIServerApp.getApp().webSocketApp(jsonWr.toString());
|
| | | }
|
| | |
|
| | | public Object getArg(String key)
|
| | |
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | return querySQL(db, sql, nvParams);
|
| | | }
|
| | | |
| | |
|
| | | public NativeArray querySQL(String dsId, String sql, NativeObject nvParams) throws Exception
|
| | | {
|
| | | SMTDatabase db = SMTAIServerApp.getApp().getDataSource(dsId).allocDatabase();
|
| | | return querySQL(db, sql, nvParams);
|
| | | }
|
| | |
|
| | | public int executeSQL(String sql, NativeObject nvParams) throws Exception
|
| | | {
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | return executeSQL(db, sql, nvParams);
|
| | | }
|
| | | |
| | | public int executeSQL(String dsId, String sql, NativeObject nvParams) throws Exception
|
| | | {
|
| | | SMTDatabase db = SMTAIServerApp.getApp().getDataSource(dsId).allocDatabase();
|
| | | return executeSQL(db, sql, nvParams);
|
| | | }
|
| | |
|
| | | |
| | | private int executeSQL(SMTDatabase db, String sql, NativeObject nvParams) throws Exception
|
| | | {
|
| | | List<Object> sqlParams = new ArrayList<>();
|
| | | try
|
| | | {
|
| | | // è§£æåºåå§sql
|
| | | String rawSQL = SMTStatic.stringFormat(sql, new SMTStatic.StringNamedNotify()
|
| | | {
|
| | | @Override
|
| | | public Object getNamedValue(String name, Object[] args) throws Exception |
| | | {
|
| | | char type;
|
| | | String value = SMTStatic.toString(SMTAIServerApp.getJSValue(nvParams, name));
|
| | | if(value.length() == 1)
|
| | | {
|
| | | type = value.charAt(0);
|
| | | value = "";
|
| | | }
|
| | | else
|
| | | {
|
| | | type = value.charAt(0);
|
| | | value = value.substring(1);
|
| | | |
| | | }
|
| | | |
| | | Object ovalue;
|
| | | |
| | | switch(type)
|
| | | {
|
| | | case 'N':
|
| | | ovalue = null;
|
| | | break;
|
| | | |
| | | case 'I':
|
| | | ovalue = SMTStatic.toInt(value);
|
| | | break;
|
| | | |
| | | case 'D':
|
| | | ovalue = SMTStatic.toDouble(value);
|
| | | break;
|
| | | |
| | | case 'L':
|
| | | ovalue = SMTStatic.toLong(value);
|
| | | break;
|
| | | |
| | | case 'T':
|
| | | ovalue = SMTStatic.toDate(value);
|
| | | break;
|
| | | |
| | | default:
|
| | | ovalue = value;
|
| | | break;
|
| | | }
|
| | | |
| | | sqlParams.add(ovalue);
|
| | | return "?";
|
| | | }
|
| | | });
|
| | | |
| | |
|
| | | // æ§è¡æ¥è¯¢
|
| | | int ret = db.executeSQL(rawSQL, sqlParams.toArray(new Object[sqlParams.size()]));
|
| | | |
| | | return ret;
|
| | | }
|
| | | finally
|
| | | {
|
| | | db.close();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | private NativeArray querySQL(SMTDatabase db, String sql, NativeObject nvParams) throws Exception
|
| | | {
|
| | | List<Object> sqlParams = new ArrayList<>();
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smtaiserver.smtaiserver.scheduledTasks; |
| | | |
| | | import com.smtaiserver.smtaiserver.core.SMTAIServerApp; |
| | | import com.smtaiserver.smtaiserver.core.SMTAIServerRequest; |
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase; |
| | | import com.smtaiserver.smtaiserver.javaai.llm.core.SMTLLMConnect; |
| | | import com.smtaiserver.smtaiserver.javaai.qwen.agent.SMTQwenAgent; |
| | | import com.smtaiserver.smtaiserver.web.SMTWebSocketHandler; |
| | | import com.smtservlet.util.Json; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import lombok.extern.log4j.Log4j2; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * è¿ä¸ªç±»æ¯ï¼ |
| | | * |
| | | * @author: adeng |
| | | * @date: 2025/4/17 17:03 |
| | | * @version: 1.0 |
| | | */ |
| | | @Log4j2 |
| | | @Component |
| | | public class checkForTicketStatusChanges { |
| | | private static final Logger _logger = LogManager.getLogger(checkForTicketStatusChanges.class); |
| | | |
| | | |
| | | @Scheduled(cron = "0/10 * * * * ?") // ä¸ç§ä¸æ¬¡ |
| | | public void execCheckForTicketStatusChanges() throws Exception { |
| | | _logger.info("start checkForTicketStatusChanges task"); |
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase(); |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(date); |
| | | cal.add(Calendar.MINUTE, -5); |
| | | Date time = cal.getTime(); |
| | | |
| | | try { |
| | | SMTDatabase.DBRecords dbRecords = |
| | | db.querySQL( |
| | | "select order_id from work_order_list where is_notify =? and status_update_time > ?", |
| | | new Object[] {"N", time}); |
| | | |
| | | _logger.info("æ¥è¯¢å°çæ°éï¼{}", dbRecords.getRowCount()); |
| | | for (SMTDatabase.DBRecord rec : dbRecords.getRecords()) |
| | | { |
| | | String agentId = "create_work_order"; |
| | | |
| | | Json jsonArgs = Json.object("question", "", "order_id", "aaaaa"); |
| | | |
| | | SMTQwenAgent agent = SMTAIServerApp.getApp().getQwenAgentManager().getAgentById(agentId); |
| | | if(agent == null) |
| | | throw new Exception("can't find agent : " + agentId); |
| | | SMTLLMConnect llm = SMTAIServerApp.getApp().allocLLMConnect(null); |
| | | |
| | | |
| | | SMTAIServerRequest _tranReq = new SMTAIServerRequest(); |
| | | agent.callAgents("/", jsonArgs, llm, "", _tranReq ); |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | _logger.error("checkForTicketStatusChanges error", e); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
| | | import org.springframework.boot.autoconfigure.SpringBootApplication;
|
| | | import org.springframework.context.annotation.ComponentScan;
|
| | | import org.springframework.scheduling.annotation.EnableScheduling;
|
| | |
|
| | | @SpringBootApplication
|
| | | @EnableAutoConfiguration
|
| | | @EnableScheduling
|
| | | @ComponentScan(basePackages = {"com.smtaiserver"})
|
| | | public class SMTAIServerWebApplication
|
| | | {
|
| | |
| | | package com.smtaiserver.smtaiserver.web;
|
| | |
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
| | | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
| | | import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
| | | import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
| | | import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
| | | import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
| | | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
| | | import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;
|
| | |
|
| | | @Configuration
|
| | | @EnableWebSocketMessageBroker
|
| | | public class SMTWebSocketConfig implements WebSocketMessageBrokerConfigurer
|
| | | @EnableWebSocket
|
| | | public class SMTWebSocketConfig implements WebSocketConfigurer
|
| | | {
|
| | | @Override
|
| | | public void configureMessageBroker(MessageBrokerRegistry config)
|
| | | {
|
| | | // è®¾ç½®æ¶æ¯ä»£ççåç¼ï¼å³å¦ææ¶æ¯çåç¼æ¯"/topic"ï¼å°±ä¼å°æ¶æ¯è½¬åç»æ¶æ¯ä»£çï¼brokerï¼
|
| | | // åç±æ¶æ¯ä»£çå°æ¶æ¯å¹¿æç»å½åè¿æ¥ç客æ·ç«¯
|
| | | config.enableSimpleBroker("/topic");
|
| | | // é
ç½®ä¸ä¸ªæå¤ä¸ªåç¼ï¼éè¿è¿äºåç¼è¿æ»¤åºéè¦è¢«æ³¨è§£æ¹æ³å¤ççæ¶æ¯
|
| | | // ä¾å¦"/app"åç¼çdestinationå¯ä»¥éè¿@MessageMappingæ³¨è§£çæ¹æ³å¤ç
|
| | | config.setApplicationDestinationPrefixes("/app");
|
| | |
|
| | |
|
| | | private final SMTWebSocketHandler webSocketHandler;
|
| | |
|
| | | public SMTWebSocketConfig(SMTWebSocketHandler webSocketHandler) {
|
| | | this.webSocketHandler = webSocketHandler;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void registerStompEndpoints(StompEndpointRegistry registry) {
|
| | | // å®ä¹ä¸ä¸ªåç¼ä¸º"/ws"çendpointï¼å¹¶å¼å¯sockjsæ¯æ
|
| | | // sockjså¯ä»¥è§£å³æµè§å¨å¯¹WebSocketçå
¼å®¹æ§é®é¢
|
| | | registry.addEndpoint("/ws").withSockJS();
|
| | | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
| | | registry.addHandler(webSocketHandler, "/ws")
|
| | | .addInterceptors(new HttpSessionHandshakeInterceptor())
|
| | | .setAllowedOrigins("*");
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smtaiserver.smtaiserver.web;
|
| | |
|
| | | import java.util.Collections;
|
| | | import java.util.HashSet;
|
| | | import java.util.Set;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.web.socket.CloseStatus;
|
| | | import org.springframework.web.socket.TextMessage;
|
| | | import org.springframework.web.socket.WebSocketSession;
|
| | | import org.springframework.web.socket.handler.TextWebSocketHandler;
|
| | |
|
| | | @Component
|
| | | public class SMTWebSocketHandler extends TextWebSocketHandler {
|
| | |
|
| | | private final Set<WebSocketSession> sessions = Collections.synchronizedSet(new HashSet<>());
|
| | |
|
| | | @Override
|
| | | public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
| | | sessions.add(session);
|
| | | System.out.println("Client connected: " + session.getId());
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
| | | String payload = message.getPayload();
|
| | | System.out.println("Received message from " + session.getId() + ": " + payload);
|
| | |
|
| | | // Broadcast message to all connected clients
|
| | | for (WebSocketSession s : sessions) {
|
| | | if (s.isOpen()) {
|
| | | s.sendMessage(new TextMessage(payload));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
| | | sessions.remove(session);
|
| | | System.out.println("Client disconnected: " + session.getId());
|
| | | }
|
| | |
|
| | | public void broadcast(String message) {
|
| | | synchronized (sessions) {
|
| | | for (WebSocketSession session : sessions) {
|
| | | if (session.isOpen()) {
|
| | | try {
|
| | | session.sendMessage(new TextMessage(message));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | ]
|
| | | }
|
| | | ]
|
| | | },
|
| | | "sys/create_order":{"map":{"class":"#SMTJavaAIControl", "method":"createOrder"}, "no_shrio":false,
|
| | | "swaggers":[
|
| | | { "tags" : ["å建工å"],
|
| | | "title" : "å建工å",
|
| | | "parameters" : [
|
| | | {"name": "title", "title": "æ é¢", "required": true},
|
| | | {"name": "wstypeid", "title": "ç±»åç¼å·", "required": false},
|
| | | {"name": "wstypename", "title": "ç±»ååç§°", "required": false},
|
| | | {"name": "urgencylevel", "title": "ç´§æ¥çº§å«", "required": false},
|
| | | {"name": "shape", "title": "æ´¾ååæ ", "required": false},
|
| | | {"name": "deadline", "title": "å¤çæ¶é", "required": false},
|
| | | {"name": "stepstatus", "title": "å·¥åè¿åº¦ç¶æ", "required": false},
|
| | | {"name": "originatetypetext", "title": "æ¥æºç±»å", "required": false},
|
| | | {"name": "content", "title": "å
容", "required": false},
|
| | | {"name": "address", "title": "å°å", "required": false},
|
| | | {"name": "stepid", "title": "å·¥åæ¥éª¤", "required": false},
|
| | | {"name": "org", "title": "æå±åå
¬å¸", "required": false},
|
| | | {"name": "deptname", "title": "å·¥åæå±é¨é¨åç§°", "required": false},
|
| | | {"name": "dealtime", "title": "å¤çæ¶é´", "required": false},
|
| | | {"name": "username", "title": "ç¨æ·åç§°", "required": false},
|
| | | {"name": "contactname", "title": "è系人", "required": false},
|
| | | {"name": "contactphone", "title": "èç³»çµè¯", "required": false},
|
| | | {"name": "acceptuserid", "title": "æ¥å人id", "required": false},
|
| | | {"name": "acceptusername", "title": "æ¥å人åç§°", "required": false},
|
| | | {"name": "acceptuseraccount", "title": "æ¥å人账å·", "required": false},
|
| | | {"name": "dealuserid", "title": "å¤ç人id", "required": false},
|
| | | {"name": "dealusername", "title": "å¤ç人åç§°", "required": false},
|
| | | {"name": "dealuseraccount", "title": "å¤ç人账å·", "required": false},
|
| | | {"name": "flowstatus", "title": "å·¥åç¶æ", "required": false},
|
| | | {"name": "attachment", "title": "éä»¶", "required": false},
|
| | | {"name": "creator", "title": "å建人", "required": false},
|
| | | {"name": "createtime", "title": "å建æ¶é´", "required": false},
|
| | | {"name": "isplan", "title": "æ¯å¦è®¡åå·¥å", "required": false},
|
| | | {"name": "originateid", "title": "æ¥æºç¼å·", "required": false},
|
| | | {"name": "appointstarttime", "title": "é¢çº¦å¼å§æ¶é´", "required": false},
|
| | | {"name": "appointendtime", "title": "é¢çº¦ç»ææ¶é´", "required": false},
|
| | | {"name": "parentid", "title": "ç¶çº§ç¼å·", "required": false},
|
| | | {"name": "relateids", "title": "å
³èç¼å·", "required": false}
|
| | | ]
|
| | | }
|
| | | ]
|
| | | },
|
| | | "sys/update_order_status":{
|
| | | "map":{"class":"#SMTJavaAIControl", "method":"updateOrderStatus"}, "no_shrio":false,
|
| | | "swaggers":[
|
| | | {
|
| | | "tags" : ["å·¥åæµè½¬"],
|
| | | "title" : "æ´æ°å·¥åç¶æ",
|
| | | "parameters" : [
|
| | | {"name": "id", "title": "å·¥åID", "required": true},
|
| | | {"name": "stepstatus", "title": "å·¥åç¶æä»£å·", "required": true}
|
| | | ]
|
| | | }
|
| | | ]
|
| | | },
|
| | | "sys/get_order_list":{
|
| | | "map":{"class":"#SMTJavaAIControl", "method":"getOrderList"}, "no_shrio":false,
|
| | | "swaggers":[
|
| | | {
|
| | | "tags" : ["æ¥è¯¢å·¥å"],
|
| | | "title" : "æ ¹æ®IDæ¥è¯¢å·¥å",
|
| | | "parameters" : [
|
| | | ]
|
| | | }
|
| | | ]
|
| | | }
|
| | |
|
| | |
|
| | | } |