tjx
2025-10-30 f2b62569198d9afd1604a1617ab1e0a3e11f74bf
src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java
@@ -1,6 +1,7 @@
package com.gs.xiaomi;
import cn.hutool.crypto.digest.DigestUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gs.xiaomi.dto.BCS101Request;
@@ -10,6 +11,7 @@
import com.gs.xiaomi.entity.DeliveryMain;
import com.gs.xiaomi.entity.SnListItem;
import com.gs.xiaomi.service.BCS101ApiService;
import com.gs.xiaomi.service.BCS101Service;
import com.gs.xiaomi.service.DeliveryMainService;
import com.gs.xiaomi.service.SnListItemService;
import com.gs.xiaomi.service.Xm104Service;
@@ -36,6 +38,9 @@
    @Autowired
    private SnListItemService snListItemService;
    @Autowired
    private BCS101Service bcs101Service;
    @Test
    void contextLoads() throws Exception {
@@ -101,15 +106,15 @@
                        // 转换DTO为Entity,并设置关联信息
                        List<SnListItem> entityList = SnListItemConverter.toEntityList(
                            snList,
                            s.getId(),      // deliveryMainId - 送货单主表ID
                            s.getZzasn()    // zzasn - 送货单号
                                snList,
                                s.getId(),      // deliveryMainId - 送货单主表ID
                                s.getZzasn()    // zzasn - 送货单号
                        );
                        // 先删除该送货单已有的SN数据(避免重复)
                        snListItemService.lambdaUpdate()
                            .eq(SnListItem::getZzasn, s.getZzasn())
                            .remove();
                                .eq(SnListItem::getZzasn, s.getZzasn())
                                .remove();
                        // 批量保存到数据库
                        boolean saved = snListItemService.saveBatch(entityList);
@@ -131,4 +136,16 @@
            }
        });
    }
    /**
     * 测试BCS101数据同步 - 使用BCS101Service
     * @param asn 送货单号
     * @throws Exception 异常
     */
    @Test
    void testGetBCS101() throws Exception {
        // 直接调用BCS101Service进行数据同步
        bcs101Service.syncBCS101DataByAsn("9316702418");
    }
}