Commit df34b26e by shun peng

fix: 通知单接口修改为post方式

parent 61b2aa0e
...@@ -17,7 +17,7 @@ public class AiChatMessageSendReqVO { ...@@ -17,7 +17,7 @@ public class AiChatMessageSendReqVO {
private Long conversationId; private Long conversationId;
@Schema(description = "聊天内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "帮我写个 Java 算法") @Schema(description = "聊天内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "帮我写个 Java 算法")
@NotEmpty(message = "聊天内容不能为空") // @NotEmpty(message = "聊天内容不能为空")
private String content; private String content;
@Schema(description = "是否携带上下文", example = "true") @Schema(description = "是否携带上下文", example = "true")
......
package cn.iocoder.yudao.module.ai.controller.admin.tongzhidan_demo; package cn.iocoder.yudao.module.ai.controller.admin.tongzhidan_demo;
import cn.iocoder.yudao.module.ai.dal.dataobject.tongzhidan_demo.CategoryDO;
import cn.iocoder.yudao.module.ai.service.aiappapikey.AiAppApiKeyService; import cn.iocoder.yudao.module.ai.service.aiappapikey.AiAppApiKeyService;
import jakarta.annotation.security.PermitAll; import jakarta.annotation.security.PermitAll;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -99,7 +100,7 @@ public class TognzhidanDemoController { ...@@ -99,7 +100,7 @@ public class TognzhidanDemoController {
BeanUtils.toBean(list, TognzhidanDemoRespVO.class)); BeanUtils.toBean(list, TognzhidanDemoRespVO.class));
} }
@GetMapping("/get-by") @PostMapping("/get-by")
@Operation(summary = "获得通知单业务场景模板") @Operation(summary = "获得通知单业务场景模板")
@PermitAll @PermitAll
public CommonResult<String> getInfoOrderTemp(@Valid @RequestBody TognzhidanDemoListReqVO demoNames, @RequestHeader("Authorization") String apiKey) { public CommonResult<String> getInfoOrderTemp(@Valid @RequestBody TognzhidanDemoListReqVO demoNames, @RequestHeader("Authorization") String apiKey) {
...@@ -114,12 +115,12 @@ public class TognzhidanDemoController { ...@@ -114,12 +115,12 @@ public class TognzhidanDemoController {
@GetMapping("/get-scene") @GetMapping("/get-scene")
@Operation(summary = "获得通知单业务场景名") @Operation(summary = "获得通知单业务场景名")
@PermitAll @PermitAll
public CommonResult<List<String>> getInfoOrderScene(@RequestHeader("Authorization") String apiKey) { public CommonResult<List<CategoryDO>> getInfoOrderScene(@RequestHeader("Authorization") String apiKey) {
String apiKey_ = appApiKeyService.getAppApiKeyByApi("/ai/tognzhidan-demo"); String apiKey_ = appApiKeyService.getAppApiKeyByApi("/ai/tognzhidan-demo");
if(!apiKey_.equals(apiKey)){ if(!apiKey_.equals(apiKey)){
return error(401, "密钥无效"); return error(401, "密钥无效");
} }
List<String> tognzhidanScene = tognzhidanDemoService.getScene(); List<CategoryDO> tognzhidanScene = tognzhidanDemoService.getScene();
return success(tognzhidanScene); return success(tognzhidanScene);
} }
......
package cn.iocoder.yudao.module.ai.dal.dataobject.tongzhidan_demo;
import java.util.ArrayList;
import java.util.List;
public class CategoryDO {
private String name;
private List<CategoryDO> children = new ArrayList<>();
public CategoryDO(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<CategoryDO> getChildren() {
return children;
}
public void setChildren(List<CategoryDO> children) {
this.children = children;
}
}
...@@ -10,8 +10,8 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; ...@@ -10,8 +10,8 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@TableName("tongzhidan_demo") @TableName("tongzhidan_demo_html")
@KeySequence("tongzhidan_demo_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @KeySequence("tongzhidan_demo_html_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
......
...@@ -28,9 +28,8 @@ public interface TognzhidanDemoMapper extends BaseMapperX<TognzhidanDemoDO> { ...@@ -28,9 +28,8 @@ public interface TognzhidanDemoMapper extends BaseMapperX<TognzhidanDemoDO> {
} }
// 根据业务场景名字查询业务场景模板字段 // 根据业务场景名字查询业务场景模板字段
// @Select("SELECT demo_context FROM tongzhidan_demo WHERE demo_name in #{demoName}")
List<String> selectDemoContextByDemoName(@Param("demoName") List<String> demoName); List<String> selectDemoContextByDemoName(@Param("demoName") List<String> demoName);
@Select("SELECT demo_name FROM tongzhidan_demo") @Select("SELECT demo_name FROM tongzhidan_demo_html")
List<String> selectDemoNameList(); List<String> selectDemoNameList();
} }
\ No newline at end of file
package cn.iocoder.yudao.module.ai.service.tongzhidan_demo; package cn.iocoder.yudao.module.ai.service.tongzhidan_demo;
import java.util.*; import java.util.*;
import cn.iocoder.yudao.module.ai.dal.dataobject.tongzhidan_demo.CategoryDO;
import jakarta.validation.*; import jakarta.validation.*;
import cn.iocoder.yudao.module.ai.controller.admin.tongzhidan_demo.vo.*; import cn.iocoder.yudao.module.ai.controller.admin.tongzhidan_demo.vo.*;
import cn.iocoder.yudao.module.ai.dal.dataobject.tongzhidan_demo.TognzhidanDemoDO; import cn.iocoder.yudao.module.ai.dal.dataobject.tongzhidan_demo.TognzhidanDemoDO;
...@@ -54,5 +56,5 @@ public interface TognzhidanDemoService { ...@@ -54,5 +56,5 @@ public interface TognzhidanDemoService {
String getByName(List<String> demoName); String getByName(List<String> demoName);
List<String> getScene(); List<CategoryDO> getScene();
} }
\ No newline at end of file
package cn.iocoder.yudao.module.ai.service.tongzhidan_demo; package cn.iocoder.yudao.module.ai.service.tongzhidan_demo;
import cn.iocoder.yudao.module.ai.dal.dataobject.tongzhidan_demo.CategoryDO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -78,9 +79,52 @@ public class TognzhidanDemoServiceImpl implements TognzhidanDemoService { ...@@ -78,9 +79,52 @@ public class TognzhidanDemoServiceImpl implements TognzhidanDemoService {
return String.join("", demoContextList); return String.join("", demoContextList);
} }
public String determineCategory(String task) {
if (task.contains("安装")) {
return "安装";
} else if (task.contains("安排")) {
return "安排";
} else if (task.contains("标注") || task.contains("标识") || task.contains("打印")) {
return "标注/标识";
} else if (task.contains("测量") || task.contains("测试") || task.contains("试验")) {
return "测量/测试";
} else if (task.contains("采购")) {
return "采购";
} else if (task.contains("加工") || task.contains("焊接") || task.contains("开孔") || task.contains("雕刻")) {
return "加工";
} else if (task.contains("报废") || task.contains("处理")) {
return "报废/处理";
} else if (task.contains("检验") || task.contains("检查")) {
return "检验/检查";
} else if (task.contains("更换") || task.contains("整改") || task.contains("维护") || task.contains("维修")) {
return "维护/维修";
} else {
return "其他";
}
}
@Override @Override
public List<String> getScene() { public List<CategoryDO> getScene() {
return tognzhidanDemoMapper.selectDemoNameList(); List<String> nameList = tognzhidanDemoMapper.selectDemoNameList();
// 对数据进行分类
Map<String, List<String>> categorizedData = new HashMap<>();
for (String name : nameList) {
String category = determineCategory(name); // 根据规则确定类别
categorizedData.computeIfAbsent(category, k -> new ArrayList<>()).add(name);
}
// 构建树状结构
List<CategoryDO> rootCategories = new ArrayList<>();
for (Map.Entry<String, List<String>> entry : categorizedData.entrySet()) {
CategoryDO root = new CategoryDO(entry.getKey());
for (String childName : entry.getValue()) {
root.getChildren().add(new CategoryDO(childName));
}
rootCategories.add(root);
}
return rootCategories;
// return tognzhidanDemoMapper.selectDemoNameList();
} }
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<!-- </select>--> <!-- </select>-->
<select id="selectDemoContextByDemoName" resultType="java.lang.String"> <select id="selectDemoContextByDemoName" resultType="java.lang.String">
SELECT demo_context SELECT demo_context
FROM tongzhidan_demo FROM tongzhidan_demo_html
WHERE demo_name IN WHERE demo_name IN
<foreach item="name" collection="demoName" open="(" separator="," close=")"> <foreach item="name" collection="demoName" open="(" separator="," close=")">
#{name} #{name}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment