Ver Fonte

Merge remote-tracking branch 'origin/master_feat_ysy_20250929' into master_feat_ysy_20250929

wjj há 8 horas atrás
pai
commit
0b2cf2a75c

+ 3 - 0
fs-service/src/main/java/com/fs/handwrite/domain/HandwriteCollection.java

@@ -50,6 +50,9 @@ public class HandwriteCollection implements Serializable
     @Excel(name = "订单号")
     private String orderCode;
 
+    /** 商品 */
+    @Excel(name = "商品")
+    private String productName;//这是非数据库字段!!!!!
 
     /** 手写信息采集表url */
     @Excel(name = "手写信息采集表图片链接")

+ 74 - 6
fs-service/src/main/java/com/fs/handwrite/service/impl/HandwriteCollectionServiceImpl.java

@@ -1,5 +1,7 @@
 package com.fs.handwrite.service.impl;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
@@ -15,7 +17,10 @@ import com.fs.his.param.CollectionOrcParam;
 import com.fs.his.service.IFsOrcAiRecordService;
 import com.fs.his.vo.CollectionOrcVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
+import com.fs.hisStore.mapper.FsStoreOrderItemScrmMapper;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import com.fs.qw.vo.FsStoreOrderScrmIdVo;
 import com.google.gson.Gson;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -26,9 +31,7 @@ import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -47,12 +50,18 @@ public class HandwriteCollectionServiceImpl implements IHandwriteCollectionServi
     @Autowired
     private FsStoreOrderScrmMapper storeOrderScrmMapper;
 
+    @Autowired
+    private FsStoreOrderItemScrmMapper itemScrmMapper;
+
     @Autowired
     private ChatService chatService;
 
     @Autowired
     private IFsOrcAiRecordService orcAiRecordService;
 
+    @Autowired
+    private ObjectMapper objectMapper;
+
     @Override
     public HandwriteCollection selectHandwriteCollectionById(Integer id)
     {
@@ -60,9 +69,68 @@ public class HandwriteCollectionServiceImpl implements IHandwriteCollectionServi
     }
 
     @Override
-    public List<HandwriteCollection> selectHandwriteCollectionList(HandwriteCollection handwriteCollection)
-    {
-        return handwriteCollectionMapper.selectHandwriteCollectionList(handwriteCollection);
+    public List<HandwriteCollection> selectHandwriteCollectionList(HandwriteCollection handwriteCollection) {
+        List<HandwriteCollection> handwriteCollections = handwriteCollectionMapper.selectHandwriteCollectionList(handwriteCollection);
+        if (CollectionUtils.isEmpty(handwriteCollections)) {
+            return Collections.emptyList();
+        }
+
+        // 1. 获取所有手写采集ID
+        List<Long> handwriteCollectionIds = handwriteCollections.stream()
+                .map(HandwriteCollection::getId)
+                .collect(Collectors.toList());
+
+        // 2. 查出关联的订单信息
+        List<FsStoreOrderScrmIdVo> orderScrmList = storeOrderScrmMapper.selectIdListByHandleCollectionIds(handwriteCollectionIds);
+        if (CollectionUtils.isEmpty(orderScrmList)) {
+            return handwriteCollections;
+        }
+
+        // 3. 构建 Map:Key = handle_collection_id, Value = order_id
+        Map<Long, Long> collectionToOrderMap = orderScrmList.stream()
+                .filter(o -> o.getHandleCollectionId() != null && o.getId() != null)
+                .collect(Collectors.toMap(
+                        FsStoreOrderScrmIdVo::getHandleCollectionId,
+                        FsStoreOrderScrmIdVo::getId,
+                        (v1, v2) -> v1
+                ));
+
+        // 4. 获取所有订单ID,并查出订单商品明细
+        List<Long> orderScrmIds = new ArrayList<>(collectionToOrderMap.values());
+        List<FsStoreOrderItemVO> fsStoreOrderItemVOS = itemScrmMapper.selectByOrderIds(orderScrmIds);
+
+        // 5. 解析 JSON 提取商品名称
+        for (FsStoreOrderItemVO item : fsStoreOrderItemVOS) {
+            if (StringUtils.isNotBlank(item.getJsonInfo())) {
+                try {
+                    JsonNode jsonNode = objectMapper.readTree(item.getJsonInfo());
+                    String productName = jsonNode.has("productName") ? jsonNode.get("productName").asText() : null;
+                    item.setProductName(productName);
+                } catch (Exception e) {
+                    log.error("解析商品JSON失败, itemId: {}", item.getItemId(), e);
+                }
+            }
+        }
+
+        // 6. 【核心】按订单ID分组,并将商品名称用逗号拼接
+        // Key: orderId, Value: "商品A,商品B"
+        Map<Long, String> orderProductMap = fsStoreOrderItemVOS.stream()
+                .filter(item -> item.getOrderId() != null && StringUtils.isNotBlank(item.getProductName()))
+                .collect(Collectors.groupingBy(
+                        FsStoreOrderItemVO::getOrderId,
+                        Collectors.mapping(FsStoreOrderItemVO::getProductName, Collectors.joining(","))
+                ));
+
+        // 7. 将拼接好的商品名称回填到 HandwriteCollection 中
+        for (HandwriteCollection collection : handwriteCollections) {
+            Long orderId = collectionToOrderMap.get(collection.getId());
+            if (orderId != null) {
+                String productNames = orderProductMap.get(orderId);
+                collection.setProductName(productNames); // 如果没有商品,设为 null
+            }
+        }
+
+        return handwriteCollections;
     }
 
     @Override

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -20,6 +20,7 @@ import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.ReportScrm;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.vo.*;
+import com.fs.qw.vo.FsStoreOrderScrmIdVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -1250,4 +1251,9 @@ public interface FsStoreOrderScrmMapper
      * 根据订单号批量修改关联的手写信息采集为NULL
      * */
     int updateStoreOrderScrmHandIdIsNullByOrderCodeList(@Param("orderCodeList")List<String> orderCodeList);
+
+    /**
+     * 根据手写信息采集id查询订单列表信息
+     * */
+    List<FsStoreOrderScrmIdVo> selectIdListByHandleCollectionIds(@Param("handwriteCollectionIds") List<Long> handwriteCollectionIds);
 }

+ 4 - 1
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemVO.java

@@ -32,9 +32,12 @@ public class FsStoreOrderItemVO  implements Serializable
     private Long productAttrValueId;
 
     /** $column.columnComment */
-    @Excel(name = "商品ID")
+    @Excel(name = "商品信息")
     private String jsonInfo;
 
+    /** 商品名称(非数据库字段,用于内存解析) */
+    private String productName;
+
     /** $column.columnComment */
     @Excel(name = "商品ID")
     private Long num;

+ 14 - 0
fs-service/src/main/java/com/fs/qw/vo/FsStoreOrderScrmIdVo.java

@@ -0,0 +1,14 @@
+package com.fs.qw.vo;
+
+import lombok.Data;
+
+@Data
+public class FsStoreOrderScrmIdVo {
+    /** 订单ID */
+    private Long id;
+
+    /**
+     * 手写信息采集表id(fs_handwrite_collection的主键)
+     * */
+    private Long handleCollectionId;
+}

+ 8 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -1189,4 +1189,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         order by o.create_time desc
     </select>
+
+    <select id="selectIdListByHandleCollectionIds" resultType="com.fs.qw.vo.FsStoreOrderScrmIdVo">
+    select id,handle_collection_id from fs_store_order_scrm where handle_collection_id in
+    <foreach collection="handwriteCollectionIds" index="index" item="item" open="(" separator="," close=")">
+        #{item}
+    </foreach>
+</select>
+
 </mapper>

+ 9 - 0
fs-service/src/main/resources/mapper/qw/FsCompanyCustomerMapper.xml

@@ -93,6 +93,15 @@
         <if test="completeStatus != null">
             and complete_status = #{completeStatus}
         </if>
+        <if test="kdzlAddWechatStatus != null">
+            and kdzl_add_wechat_status = #{kdzlAddWechatStatus}
+        </if>
+        <if test="kdzlMakeStatus != null">
+            and kdzl_make_status = #{kdzlMakeStatus}
+        </if>
+        <if test="kdzlCallStatus != null and kdzlCallStatus != ''">
+            and kdzl_call_status like concat('%', #{kdzlCallStatus}, '%')
+        </if>
         <!-- 动态排序 -->
         <choose>
             <when test="sortField != null and sortField != '' and sortOrder != null and sortOrder != ''">