From 2fcfbcefee1a6ad5b51e23223ebe77093b847c3a Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Thu, 30 Oct 2025 14:45:53 +0800
Subject: [PATCH] feat(ai):优化对话流初始化逻辑 - 调整对话记录查询顺序,确保获取最新进行中的对话 - 在对话不存在时创建新对话并初始化问题 - 若对话已存在,则查询最近的对话项作为标题来源 - 修复可能因查询顺序导致的标题加载异常问题
---
src/main/java/cc/mrbird/febs/mall/controller/clothes/AdminClothesTypeController.java | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 398 insertions(+), 11 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/controller/clothes/AdminClothesTypeController.java b/src/main/java/cc/mrbird/febs/mall/controller/clothes/AdminClothesTypeController.java
index 7d18b56..2b1bb00 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/clothes/AdminClothesTypeController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/clothes/AdminClothesTypeController.java
@@ -4,24 +4,38 @@
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
+import cc.mrbird.febs.common.enumerates.ClothesOrderStatusEnum;
import cc.mrbird.febs.common.enumerates.OrderDeliveryStateEnum;
import cc.mrbird.febs.common.enumerates.OrderStatusEnum;
+import cc.mrbird.febs.common.exception.FebsException;
+import cc.mrbird.febs.common.utils.AppContants;
+import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.common.utils.excl.ExcelSheetPO;
import cc.mrbird.febs.common.utils.excl.ExcelUtil;
import cc.mrbird.febs.common.utils.excl.ExcelVersion;
import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil;
+import cc.mrbird.febs.mall.controller.order.ViewMallOrderController;
+import cc.mrbird.febs.mall.dto.AdminHappyActivityCategoryDto;
import cc.mrbird.febs.mall.dto.DeliverGoodsDto;
-import cc.mrbird.febs.mall.dto.clothes.AdminClothesDeliverGoodsDto;
-import cc.mrbird.febs.mall.dto.clothes.AdminClothesOrderListDto;
-import cc.mrbird.febs.mall.dto.clothes.AdminClothesRefundOrderDto;
-import cc.mrbird.febs.mall.dto.clothes.AdminClothesTypeInfoDto;
+import cc.mrbird.febs.mall.dto.activity.AdminCategoryAddDto;
+import cc.mrbird.febs.mall.dto.activity.AdminCategoryUpdateDto;
+import cc.mrbird.febs.mall.dto.clothes.*;
import cc.mrbird.febs.mall.entity.*;
+import cc.mrbird.febs.mall.mapper.ClothesOrderMapper;
+import cc.mrbird.febs.mall.mapper.ClothesTypeMapper;
import cc.mrbird.febs.mall.service.ClothesTypeService;
+import cc.mrbird.febs.mall.vo.clothes.AdminClothesPrintLocationVo;
+import cc.mrbird.febs.mall.vo.clothes.AdminClothesPrintMemberStatureVo;
+import cc.mrbird.febs.mall.vo.clothes.AdminClothesPrintOrderVo;
+import cc.mrbird.febs.mall.vo.clothes.AdminClothesPrintPatternVo;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSON;
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
@@ -35,11 +49,10 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.math.BigDecimal;
import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
@Slf4j
@Validated
@@ -49,6 +62,254 @@
public class AdminClothesTypeController extends BaseController {
private final ClothesTypeService clothesTypeService;
+ private final ClothesOrderMapper clothesOrderMapper;
+ private final ClothesTypeMapper clothesTypeMapper;
+ private final RedisUtils redisUtils;
+
+ /**
+ * 分类列表
+ * @return
+ */
+ @GetMapping("groupList")
+ public FebsResponse groupList(AdminClothesSocialCategoryDto dto, QueryRequest request) {
+
+ Map<String, Object> data = getDataTable(clothesTypeService.getGroupList(dto, request));
+ return new FebsResponse().success().data(data);
+ }
+ /**
+ * 分类-新增
+ */
+ @PostMapping("addGroup")
+ @ControllerEndpoint(operation = "分类-新增", exceptionMessage = "操作失败")
+ public FebsResponse addGroup(@RequestBody @Valid AdminClothesCategoryAddDto dto) {
+
+ return clothesTypeService.addGroup(dto);
+ }
+
+ /**
+ * 分类-删除
+ */
+ @GetMapping("groupDelete/{id}")
+ @ControllerEndpoint(operation = "选项-删除", exceptionMessage = "操作失败")
+ public FebsResponse groupDelete(@NotNull(message = "{required}") @PathVariable Long id) {
+
+ return clothesTypeService.groupDelete(id);
+ }
+
+ /**
+ * 分类-更新
+ */
+ @PostMapping("groupUpdate")
+ @ControllerEndpoint(operation = "分类-更新", exceptionMessage = "操作失败")
+ public FebsResponse groupUpdate(@RequestBody @Valid AdminClothesCategoryUpdateDto dto) {
+
+ return clothesTypeService.groupUpdate(dto);
+ }
+ /**
+ * 分类-开启
+ */
+ @GetMapping("groupState/{id}/{type}")
+ @ControllerEndpoint(operation = "分类-开启", exceptionMessage = "操作失败")
+ public FebsResponse groupState(
+ @NotNull(message = "{required}") @PathVariable Long id,
+ @NotNull(message = "{required}") @PathVariable Integer type) {
+
+ return clothesTypeService.groupState(id,type);
+ }
+
+ /**
+ * 社区列表
+ *
+ * @param dto
+ * @param request
+ * @return
+ */
+ @GetMapping("socialList")
+ public FebsResponse socialList(AdminClothesSocialListDto dto, QueryRequest request) {
+ String startTime = dto.getStartTime();
+ String endTime = dto.getEndTime();
+ if(StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)){
+ DateTime dateStartTime= DateUtil.parseDate(startTime);
+ DateTime dateEndTime = DateUtil.parseDate(endTime);
+ int compare = DateUtil.compare(dateStartTime, dateEndTime);
+ if(compare >= 0){
+ return new FebsResponse().fail().message("请输入正确的开始时间和结束时间");
+ }
+ }
+ Map<String, Object> data = getDataTable(clothesTypeService.getSocialListInPage(dto, request));
+ return new FebsResponse().success().data(data);
+ }
+
+
+
+ /**
+ * 社区列表-评论列表
+ */
+ @GetMapping("socialComment")
+ public FebsResponse socialComment(ClothesSocialComment dto, QueryRequest request, Integer parentId) {
+ String existToken = redisUtils.getString(AppContants.SOCIAL_COMMENT);
+ long socialId = Long.parseLong(existToken);
+ dto.setSocialId(socialId);
+ Map<String, Object> data = getDataTable(clothesTypeService.socialComment(dto,request));
+ return new FebsResponse().success().data(data);
+ }
+
+
+ /**
+ * 社区-新增
+ */
+ @PostMapping("socialAdd")
+ @ControllerEndpoint(operation = "新增", exceptionMessage = "操作失败")
+ public FebsResponse socialAdd(@RequestBody ClothesSocial dto) {
+
+ return clothesTypeService.socialAdd(dto);
+ }
+
+
+ /**
+ * 社区-更新
+ */
+ @PostMapping("socialUpdate")
+ @ControllerEndpoint(operation = "社区-更新", exceptionMessage = "操作失败")
+ public FebsResponse socialUpdate(@RequestBody ClothesSocial dto) {
+
+ return clothesTypeService.socialUpdate(dto);
+ }
+
+
+ /**
+ * 社区-灵感
+ */
+ @PostMapping("socialMuseUpdate")
+ @ControllerEndpoint(operation = "社区-灵感", exceptionMessage = "操作失败")
+ public FebsResponse socialMuseUpdate(@RequestBody ClothesSocialMuse dto) {
+
+ return clothesTypeService.socialMuseUpdate(dto);
+ }
+
+ /**
+ * 社区获取设计类型-工艺
+ * @return
+ */
+ @GetMapping(value = "/allArt/{typeId}")
+ public FebsResponse allArt(@NotNull(message = "{required}") @PathVariable Long typeId) {
+
+ return new FebsResponse().success().data(clothesTypeService.allArt(typeId));
+ }
+
+ /**
+ * 社区获取设计类型-尺码
+ * @return
+ */
+ @GetMapping(value = "/allSize/{typeId}")
+ public FebsResponse allSize(@NotNull(message = "{required}") @PathVariable Long typeId) {
+
+ return new FebsResponse().success().data(clothesTypeService.allSize(typeId));
+ }
+
+ /**
+ * 社区获取设计类型-位置
+ * @return
+ */
+ @GetMapping(value = "/allLocation/{typeId}")
+ public FebsResponse allLocation(@NotNull(message = "{required}") @PathVariable Long typeId) {
+
+ return new FebsResponse().success().data(clothesTypeService.allLocation(typeId));
+ }
+
+ /**
+ * 社区获取设计类型-图案
+ * @return
+ */
+ @GetMapping(value = "/allPattern/{typeId}")
+ public FebsResponse allPattern(@NotNull(message = "{required}") @PathVariable Long typeId) {
+
+ return new FebsResponse().success().data(clothesTypeService.allPattern(typeId));
+ }
+
+ /**
+ * 社区获取设计类型-布料
+ * @return
+ */
+ @GetMapping(value = "/allCloth/{typeId}")
+ public FebsResponse allCloth(@NotNull(message = "{required}") @PathVariable Long typeId) {
+
+ return new FebsResponse().success().data(clothesTypeService.allCloth(typeId));
+ }
+
+ /**
+ * 社区获取设计类型
+ * @return
+ */
+ @GetMapping(value = "/allType")
+ public FebsResponse allType() {
+
+ return new FebsResponse().success().data(clothesTypeService.allType());
+ }
+
+ /**
+ * 社区获取分类
+ * @return
+ */
+ @GetMapping(value = "/allGroup")
+ public FebsResponse allGroup() {
+
+ return new FebsResponse().success().data(clothesTypeService.allGroup());
+ }
+
+ /**
+ * 社区-开启
+ */
+ @GetMapping("socialState/{id}/{state}")
+ @ControllerEndpoint(operation = "社区-开启", exceptionMessage = "操作失败")
+ public FebsResponse socialState(@NotNull(message = "{required}") @PathVariable Long id,
+ @NotNull(message = "{required}") @PathVariable Integer state) {
+
+ return clothesTypeService.socialState(id,state);
+ }
+
+ /**
+ * 社区-开启评论
+ */
+ @GetMapping("commentStateSwitch/{id}/{state}")
+ @ControllerEndpoint(operation = "社区-开启评论", exceptionMessage = "操作失败")
+ public FebsResponse commentStateSwitch(@NotNull(message = "{required}") @PathVariable Long id,
+ @NotNull(message = "{required}") @PathVariable Integer state) {
+
+ return clothesTypeService.commentStateSwitch(id,state);
+ }
+
+ /**
+ * 社区-评论-是否展示
+ */
+ @GetMapping("showStateSwitch/{id}/{state}")
+ @ControllerEndpoint(operation = "社区-评论-是否展示", exceptionMessage = "操作失败")
+ public FebsResponse showStateSwitch(@NotNull(message = "{required}") @PathVariable Long id,
+ @NotNull(message = "{required}") @PathVariable Integer state) {
+
+ return clothesTypeService.showStateSwitch(id,state);
+ }
+
+ /**
+ * 社区-推荐首页
+ */
+ @GetMapping("socialHotState/{id}/{state}")
+ @ControllerEndpoint(operation = "社区-开启", exceptionMessage = "操作失败")
+ public FebsResponse socialHotState(@NotNull(message = "{required}") @PathVariable Long id,
+ @NotNull(message = "{required}") @PathVariable Integer state) {
+
+ return clothesTypeService.socialHotState(id,state);
+ }
+
+ /**
+ * 社区-删除
+ */
+ @GetMapping("socialDelete/{id}")
+ @ControllerEndpoint(operation = "社区-删除", exceptionMessage = "删除失败")
+ public FebsResponse socialDelete(@NotNull(message = "{required}") @PathVariable Long id) {
+
+ return clothesTypeService.socialDelete(id);
+ }
/**
* 订单列表
@@ -86,6 +347,77 @@
/**
* 订单列表-修改物流编号
*/
+ @GetMapping("printOrder/{id}")
+ @ControllerEndpoint(operation = "订单列表-修改物流编号", exceptionMessage = "操作失败")
+ public FebsResponse printOrder(@NotNull(message = "{required}") @PathVariable Long id) {
+ AdminClothesPrintOrderDto dto = new AdminClothesPrintOrderDto();
+ dto.setId(id);
+ return clothesTypeService.printOrder(dto);
+ }
+
+ public static void main(String[] args) {
+ AdminClothesPrintOrderVo vo = new AdminClothesPrintOrderVo();
+ vo.setOrderNo("20201201");
+ vo.setTypeName("T恤");
+ vo.setTypeFront("https://excoin.oss-cn-hangzhou.aliyuncs.com/clothes/1752740706568ab67808fb49940a7930b9e0ab0793238.png");
+ vo.setTypeBack("https://excoin.oss-cn-hangzhou.aliyuncs.com/clothes/1752740734639227e7f5a0f3a4de097a2785305bff825.png");
+ vo.setClothName("棉");
+ vo.setClothCode("TX");
+ vo.setSizeName("XL");
+ vo.setSizeCode("XL");
+ vo.setArtName("印花");
+ vo.setArtCode("C");
+ List<AdminClothesPrintPatternVo> patterns = new ArrayList<>();
+ AdminClothesPrintPatternVo pattern = new AdminClothesPrintPatternVo();
+ pattern.setPatternName("胸口");
+ pattern.setPatternCode("front-one");
+ pattern.setPatternText("胸口");
+ pattern.setPatternImage("https://excoin.oss-cn-hangzhou.aliyuncs.com/clothes/17527407868773d1ad92c4c2e454396a6fc051c2219bc.png");
+ patterns.add(pattern);
+
+ AdminClothesPrintPatternVo pattern1 = new AdminClothesPrintPatternVo();
+ pattern1.setPatternName("左下");
+ pattern1.setPatternCode("front-two");
+ pattern1.setPatternText("左下");
+ pattern1.setPatternImage("https://excoin.oss-cn-hangzhou.aliyuncs.com/clothes/17527407868773d1ad92c4c2e454396a6fc051c2219bc.png");
+ patterns.add(pattern1);
+ AdminClothesPrintPatternVo pattern2 = new AdminClothesPrintPatternVo();
+ pattern2.setPatternName("袖口");
+ pattern2.setPatternCode("front-three");
+ pattern2.setPatternText("袖口");
+ pattern2.setPatternImage("https://excoin.oss-cn-hangzhou.aliyuncs.com/clothes/17527407868773d1ad92c4c2e454396a6fc051c2219bc.png");
+ patterns.add(pattern2);
+ vo.setPatterns( patterns);
+
+ List<AdminClothesPrintLocationVo> locations = new ArrayList<>();
+ AdminClothesPrintLocationVo location = new AdminClothesPrintLocationVo();
+ location.setLocationName("后背");
+ location.setLocationCode("back-one");
+ location.setLocationText("后背");
+ location.setLocationImage("https://excoin.oss-cn-hangzhou.aliyuncs.com/clothes/17527407868773d1ad92c4c2e454396a6fc051c2219bc.png");
+ locations.add(location);
+ vo.setLocations(locations);
+
+ AdminClothesPrintMemberStatureVo adminClothesPrintMemberStatureVo = new AdminClothesPrintMemberStatureVo();
+ adminClothesPrintMemberStatureVo.setName("会员身高");
+ adminClothesPrintMemberStatureVo.setHeightLine(new BigDecimal("170"));
+ adminClothesPrintMemberStatureVo.setBustLine(new BigDecimal("90"));
+ adminClothesPrintMemberStatureVo.setWaistLine(new BigDecimal("80"));
+ adminClothesPrintMemberStatureVo.setWideLine(new BigDecimal("100"));
+ adminClothesPrintMemberStatureVo.setHipLine(new BigDecimal("100"));
+ vo.setMemberStature(adminClothesPrintMemberStatureVo);
+
+
+ //将vo转换成json字符串
+ JSON parse = JSONUtil.parse(vo);
+ System.out.println(parse.toString());
+
+
+ }
+
+ /**
+ * 订单列表-修改物流编号
+ */
@PostMapping("deliverGoodsUpdate")
@ControllerEndpoint(operation = "订单列表-修改物流编号", exceptionMessage = "操作失败")
public FebsResponse deliverGoodsUpdate(@Valid AdminClothesDeliverGoodsDto dto) {
@@ -116,9 +448,13 @@
return new FebsResponse().success();
}
- @GetMapping("exportOrderList/{ids}")
+ @GetMapping("exportOrderList")
@ControllerEndpoint(operation = "订单列表", exceptionMessage = "导出失败")
- public FebsResponse exportOrderList(@NotBlank(message = "{required}") @PathVariable String ids, HttpServletResponse response) throws IOException {
+ public FebsResponse exportOrderList(ClothesOrder clothesOrder, HttpServletResponse response) throws IOException {
+ if(ObjectUtil.isNull(clothesOrder.getIds())){
+ throw new FebsException("请选择要导出的订单");
+ }
+ String ids = clothesOrder.getIds();
List<String> List = StrUtil.splitTrim(ids, ",");
if(CollUtil.isNotEmpty( List)){
ArrayList<Long> orderIds = new ArrayList<>();
@@ -128,7 +464,58 @@
}
if(CollUtil.isNotEmpty(orderIds)){
- clothesTypeService.exportOrderList(orderIds,response);
+ List<ExcelSheetPO> res = new ArrayList<>();
+
+ ExcelSheetPO orderSheet = new ExcelSheetPO();
+ String title = "订单列表";
+ orderSheet.setSheetName(title);
+ orderSheet.setTitle(title);
+ String[] header = {"订单ID", "订单编号", "收货姓名", "收货电话", "收货地址", "商品详情", "备注", "物流单号", "物流公司", "物流公司码"};
+ orderSheet.setHeaders(header);
+
+ QueryRequest request = new QueryRequest();
+ request.setPageNum(1);
+ request.setPageSize(9999);
+ List<ClothesOrder> dataList = clothesOrderMapper.selectList(
+ Wrappers.lambdaQuery(ClothesOrder.class)
+ .in(ClothesOrder::getId, orderIds)
+ .eq(ClothesOrder::getDelFlag, 0)
+ .eq(ClothesOrder::getStatus, ClothesOrderStatusEnum.WAIT_SHIPPING.getValue()));
+ Map<Long, ClothesType> longClothesTypeHashMap = new HashMap<>();
+ if(CollUtil.isNotEmpty(dataList)){
+ Set<Long> typeIds = dataList.stream().map(ClothesOrder::getTypeId).collect(Collectors.toSet());
+ List<ClothesType> clothesTypes = clothesTypeMapper.selectList(
+ Wrappers.lambdaQuery(ClothesType.class)
+ .in(ClothesType::getId, typeIds)
+ );
+ if(CollUtil.isNotEmpty(clothesTypes)){
+ //stream操作clothesTypes,返回一个HashMap<Long, ClothesType>, key为clothesType.id, value为clothesType
+ longClothesTypeHashMap = clothesTypes.stream().collect(Collectors.toMap(ClothesType::getId, clothesType -> clothesType));
+ }
+ }
+
+ List<List<Object>> list = new ArrayList<>();
+
+ if (dataList.size() > 0) {
+ for (ClothesOrder item : dataList) {
+ List<Object> temp = new ArrayList<>();
+ temp.add(item.getId());
+ temp.add(item.getOrderNo());
+ temp.add(item.getName());
+ temp.add(item.getPhone());
+ temp.add(item.getAddress());
+ temp.add(longClothesTypeHashMap.get(item.getTypeId()).getName());
+ temp.add(item.getRemark());
+ list.add(temp);
+ }
+ }
+ orderSheet.setDataList(list);
+ res.add(orderSheet);
+ response = ResponseHeadUtil.setExcelHead(response);
+ response.setHeader("Content-Disposition",
+ "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), "yyyyMMDDHHmmss") + ".xlsx".trim(), "UTF-8"));
+ OutputStream os = response.getOutputStream();
+ ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true);
}
}
return null;
--
Gitblit v1.9.1