优化代码：
package com.simba.taobao.shield.helpers;

import com.alibaba.fastjson.JSON;
import com.alibaba.solar.jupiter.client.dto.outentity.OutEntityMessageDTO;
import com.taobao.item.domain.ItemDO;
import com.taobao.item.domain.ItemImageDO;
import com.taobao.item.domain.query.QueryItemOptionsDO;
import com.taobao.item.domain.result.ItemResultDO;
import com.taobao.item.service.client.ItemQueryServiceClient;
import com.taobao.simba.shield.api.common.FeatureKeys;
import com.taobao.simba.shield.sdk.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

/**
 * @Author: huafeng
 * @Email: <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
 * @Date:2023-04-07 11:23
 */
public class IcFactoryHelper {

    private static ItemQueryServiceClient itemQueryServiceClient;

    private static final Logger inDataLog = LoggerFactory.getLogger("shield_in_data");

    /**
     * 通过ic查到标题、主题、副图,取到后放字段里面
     * 添加宝贝subMessageType = 88
     * 宝贝变更subMessageType = 9（主图+副图)，34（标题）
     *
     * @param propertyMap
     * @param itemId
     */
    public static void fillItemTitleAndPicture(Map<String, String> propertyMap, Long itemId, Integer subMessageType) {
        if (itemId == null || subMessageType == null) {
            return;
        }
        ItemDO itemDO = getItemInfo(itemId);
        if (itemDO == null) {
            return;
        }
        //宝贝变更subMessageType = 34（标题）
        if (StringUtils.isNotBlank(itemDO.getTitle()) && OutEntityMessageDTO.MESSAGE_TYPE_ITEM_TITLE_CHANGE.equals(subMessageType)) {
            propertyMap.put(FeatureKeys.CMS_DESC_TEXT.getKey(), itemDO.getTitle());
        }
        //添加宝贝subMessageType = 23 or 宝贝变更subMessageType = 9（主图+副图)
        if (OutEntityMessageDTO.MESSAGE_TYPE_ITEM_IMAGE_CHANGE.equals(subMessageType) || OutEntityMessageDTO.MESSAGE_TYPE_FEED_REGISTER.equals(subMessageType)) {
            Set<String> imgs = getValidImages(itemDO);
            if (CollectionUtils.isNotEmpty(imgs)) {
                propertyMap.put(FeatureKeys.CMS_DESC_IMAGES.getKey(), JSON.toJSONString(imgs));
            }
        }
    }

    /**
     * 调用IC查询 获取商品信息
     *
     * @param itemId 宝贝ID
     * @return 商品信息
     */
    public static ItemDO getItemInfo(long itemId) {
        QueryItemOptionsDO options = new QueryItemOptionsDO();
        //需要查图片 但不需要查库存数量
        options.setIncludeImages(true);
        options.setIncludeQuantity(false);
        ItemResultDO itemResult;
        try {
            itemResult = itemQueryServiceClient.queryItemById(itemId, options);
        } catch (Exception e) {
            inDataLog.warn("itemQueryServiceClient.queryItemById hsf error:", e);
            return null;
        }
        if (itemResult != null && itemResult.isSuccess() && itemResult.getItem() != null) {
            return itemResult.getItem();
        }
        return null;
    }

    /**
     * 从itemDO里面提取主图和副图
     *
     * @param itemDO
     * @return
     */
    private static Set<String> getValidImages(ItemDO itemDO) {
        Set<String> images = new HashSet<>();
        if (StringUtils.isNotBlank(itemDO.getPictUrl())) {
            images.add(itemDO.getPictUrl());
        }
        if (CollectionUtils.isNotEmpty(itemDO.getCommonItemImageList())) {
            itemDO.getCommonItemImageList().stream()
                    .filter(itemImageDO -> itemImageDO.getImageUrl() != null && itemImageDO.getStatus() == 1)
                    .forEach(itemImageDO -> images.add(itemImageDO.getImageUrl()));
        }
        return images;
    }


    public void setItemQueryServiceClient(ItemQueryServiceClient itemQueryServiceClient) {
        IcFactoryHelper.itemQueryServiceClient = itemQueryServiceClient;
    }
}