feat(server): 添加工单管理功能
- 新增创建工单、更新工单状态和查询工单列表的接口
- 实现工单相关数据的数据库操作
- 添加定时任务检查工单状态变化
- 更新请求映射,支持新的工单管理接口
| | |
| | | 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);
|
| | |
|
| | | 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, stepid, org, deptname, dealtime, username, contactname, "
|
| | | + "contactphone, acceptuserid, acceptusername, acceptuseraccount, dealuserid, dealusername, "
|
| | | + "dealuseraccount, flowstatus, attachment, creator, createtime, isplan, originateid, "
|
| | | + "appointstarttime, appointendtime, parentid, relateids,is_notify"
|
| | | + ") 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"
|
| | | });
|
| | | }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();
|
| | |
| | | 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
|
| | | {
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smtaiserver.smtaiserver.scheduledTasks; |
| | | |
| | | import com.smtaiserver.smtaiserver.core.SMTAIServerApp; |
| | | import com.smtaiserver.smtaiserver.database.SMTDatabase; |
| | | 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.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 Logger _logger = LogManager.getLogger(checkForTicketStatusChanges.class); |
| | | |
| | | // ä¸ç§ä¸æ¬¡ |
| | | @Scheduled(cron = "0/1 * * * * ?") |
| | | public void checkForTicketStatusChanges() 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 * from work_order_list where is_notify =? and status_update_time > ?", |
| | | new Object[] {"N", time}); |
| | | _logger.info("æ¥è¯¢å°çæ°éï¼{}",dbRecords.getRowCount()); |
| | | dbRecords.getRecords().forEach(record -> {}); |
| | | |
| | | } 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
|
| | | {
|
| | |
| | | ]
|
| | | }
|
| | | ]
|
| | | },
|
| | | "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" : [
|
| | | ]
|
| | | }
|
| | | ]
|
| | | }
|
| | |
|
| | |
|
| | | } |