| | |
| | | import java.util.LinkedHashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.apache.logging.log4j.LogManager;
|
| | | import org.apache.logging.log4j.Logger;
|
| | | import org.locationtech.proj4j.CRSFactory;
|
| | | import org.locationtech.proj4j.CoordinateReferenceSystem;
|
| | | import org.locationtech.proj4j.CoordinateTransform;
|
| | |
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | |
|
| | | import com.smtaiserver.smtaiserver.attach.SMTAIAttachMetricDef;
|
| | | import com.smtaiserver.smtaiserver.attach.SMTAIAttachTableDef;
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase;
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase.DBQueryNotify;
|
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase.DBRecord;
|
| | |
| | | import com.smtaiserver.smtaiserver.javaai.metrics.base.SMTMetricsDef;
|
| | | import com.smtaiserver.smtaiserver.javaai.querydetail.SMTAIQueryDetail;
|
| | | import com.smtaiserver.smtaiserver.javaai.qwen.SMTQwenAgentManager;
|
| | | import com.smtaiserver.smtaiserver.javaai.qwen.SMTQwenApp;
|
| | | import com.smtaiserver.smtaiserver.javaai.qwen.agent.SMTQwenAgent;
|
| | | import com.smtaiserver.smtaiserver.javaai.qwen.agent.SMTQwenAgentKnowlgFile;
|
| | | import com.smtservlet.util.Json;
|
| | |
| | | {
|
| | | @Value("${hswater.tables.global_config}")
|
| | | protected String _tableGlobalConfig;
|
| | | |
| | | private static Logger _logger = LogManager.getLogger(SMTQwenApp.class);
|
| | |
|
| | | public static String makeQueryStringAllRegExp(String str)
|
| | | {
|
| | |
| | | public CoordinateTransform[] getGisTransform() throws Exception
|
| | | {
|
| | | String gisProjParam = (String)SMTAIServerApp.getApp().getGlobalConfig("gis.proj.src", "+proj=longlat +datum=WGS84 +no_defs");
|
| | | String mapProjParam = (String)SMTAIServerApp.getApp().getGlobalConfig("gis.proj.tag");
|
| | | String mapProjParam = (String)SMTAIServerApp.getApp().getGlobalConfig("gis.proj.tag", "+proj=longlat +datum=WGS84 +no_defs");
|
| | |
|
| | | CRSFactory crsFactory = new CRSFactory();
|
| | | CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
|
| | |
| | |
|
| | | try
|
| | | {
|
| | | // 读取所有amis的agent
|
| | | db.querySQLNotify(
|
| | | String sql = |
| | | " SELECT agent_id,agent_type,agent_xml,clz_name,clz_arguments, group_type, agent_title, agent_group, agent_order,inner_call"
|
| | | + " FROM ai_agent_amis A"
|
| | | + " LEFT JOIN ai_scene_group G ON A.agent_group = G.group_id"
|
| | | + " WHERE " + (debugMode ? " agent_order > 0 OR is_debug='Y'" : "agent_order > 0 AND is_debug IS NULL")
|
| | | + " ORDER BY abs(agent_order)"
|
| | | , null,
|
| | | new DBQueryNotify() {
|
| | | ;
|
| | |
|
| | | // 读取所有amis的agent
|
| | | db.querySQLNotify(sql, null, new DBQueryNotify() {
|
| | | @Override
|
| | | public boolean onNextRecord(DBRecord rec) throws Exception
|
| | | {
|
| | | SMTQwenAgent agent = (SMTQwenAgent)Class.forName(rec.getString("clz_name")).newInstance();
|
| | | agent.initInstance(rec);
|
| | | manager.addAgent(agent);
|
| | | try
|
| | | {
|
| | | SMTQwenAgent agent = (SMTQwenAgent)Class.forName(rec.getString("clz_name")).newInstance();
|
| | | agent.initInstance(rec);
|
| | | manager.addAgent(agent);
|
| | | }
|
| | | catch(Exception ex)
|
| | | {
|
| | | _logger.fatal("load agent error and skip it : " + rec.getString("agent_id"), ex);
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | }
|
| | | return mapResult;
|
| | | }
|
| | | |
| | | @Cacheable(value="getAttachTableDefMap")
|
| | | public Map<String, SMTAIAttachTableDef> getAttachTableDefMap() throws Exception
|
| | | {
|
| | | Map<String, SMTAIAttachTableDef> mapResult = new HashMap<>();
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | try
|
| | | {
|
| | | DBRecords recs;
|
| | | |
| | | recs = db.querySQL("SELECT * FROM ai_attach_table", null);
|
| | | for(DBRecord rec : recs.getRecords())
|
| | | {
|
| | | SMTAIAttachTableDef attachTableDef = new SMTAIAttachTableDef(rec);
|
| | | mapResult.put(attachTableDef.getId(), attachTableDef);
|
| | | }
|
| | |
|
| | | }
|
| | | finally
|
| | | {
|
| | | db.close();
|
| | | }
|
| | | return mapResult; |
| | | }
|
| | | |
| | | @Cacheable(value="getAttachMetricDefMap")
|
| | | public Map<String, SMTAIAttachMetricDef> getAttachMetricDefMap() throws Exception
|
| | | {
|
| | | Map<String, SMTAIAttachMetricDef> mapResult = new HashMap<>();
|
| | | SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
|
| | | try
|
| | | {
|
| | | DBRecords recs;
|
| | | |
| | | recs = db.querySQL("SELECT * FROM ai_attach_metric", null);
|
| | | for(DBRecord rec : recs.getRecords())
|
| | | {
|
| | | SMTAIAttachMetricDef attachMetricDef = new SMTAIAttachMetricDef(rec);
|
| | | mapResult.put(attachMetricDef.getId(), attachMetricDef);
|
| | | }
|
| | |
|
| | | }
|
| | | finally
|
| | | {
|
| | | db.close();
|
| | | }
|
| | | return mapResult; |
| | | }
|
| | |
|
| | | }
|