package com.ruoyi.ibs.task.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.file.ImageUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.ibs.customerselect.mapper.CustInfoBusinessMapper;
import com.ruoyi.ibs.list.domain.CustInfoBusiness;
import com.ruoyi.ibs.list.domain.CustInfoMerchant;
import com.ruoyi.ibs.list.domain.CustInfoRetail;
import com.ruoyi.ibs.list.domain.SysCampaign;
import com.ruoyi.ibs.list.mapper.CustInfoMerchantMapper;
import com.ruoyi.ibs.list.mapper.CustInfoRetailMapper;
import com.ruoyi.ibs.list.mapper.SysCampaignGroupCustomerMapper;
import com.ruoyi.ibs.list.mapper.SysCampaignMapper;
import com.ruoyi.ibs.task.domain.dto.*;
import com.ruoyi.ibs.task.domain.entity.*;
import com.ruoyi.ibs.task.domain.vo.SignInVO;
import com.ruoyi.ibs.task.domain.vo.VisitRecordListVO;
import com.ruoyi.ibs.task.domain.vo.VisitRecordVO;
import com.ruoyi.ibs.task.mapper.*;
import com.ruoyi.ibs.task.service.TaskVisitImageService;
import com.ruoyi.ibs.task.service.TaskVisitRecordService;
import com.ruoyi.ibs.task.service.VisitFeedbackService;
import com.ruoyi.system.domain.OssFileUploadDTO;
import com.ruoyi.system.enums.OssFileEnum;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.OssFileService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.geometry.Positions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @Author 吴凯程
 * @Date 2025/6/17
 **/
@Service
@Slf4j
public class TaskVisitRecordServiceImpl implements TaskVisitRecordService {

    @Resource
    private TaskVisitRecordMapper taskVisitRecordMapper;

    @Resource
    private OssFileService ossFileService;

    @Resource
    private TaskVisitImageMapper taskVisitImageMapper;

    @Resource
    private CustImageMapper custImageMapper;

    @Resource
    private TaskVisitSignMapper taskVisitSignMapper;

    @Resource
    private TaskVisitCustAddressMapper taskVisitCustAddressMapper;

    @Resource
    private VisitFeedbackService visitFeedbackService;

    @Resource
    private SysCampaignMapper sysCampaignMapper;

    @Resource
    private SysCampaignGroupCustomerMapper sysCampaignGroupCustomerMapper ;

    @Resource
    private CustInfoBusinessMapper custInfoBusinessMapper;

    @Resource
    private CustInfoRetailMapper custInfoRetailMapper;

    @Resource
    private CustInfoMerchantMapper custInfoMerchantMapper;

    @Resource
    private AppointmentMapper appointmentMapper;

    @Resource
    private ISysDeptService iSysDeptService ;
    @Resource
    private LowcodeVisstFeedbackModelMapper lowcodeVisstFeedbackModelMapper;

    @Resource
    private TaskVisitImageService taskVisitImageService;


    @Resource
    private RedisCache redisCache;

    /**
     * @param taskVisitRecordDTO
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public synchronized SignInVO addTaskVisitRecord(TaskVisitRecordDTO taskVisitRecordDTO) {
        String recordId = taskVisitRecordDTO.getRecordId();
        TaskVisitRecord taskVisitRecord;
        boolean newRecordFlag = Objects.isNull(recordId);
        SysCampaign sysCampaign   = sysCampaignMapper.selectSysCampaignByCampaignId(taskVisitRecordDTO.getCampaignId());
        if (newRecordFlag){
            recordId = IdUtils.fastSimpleUUID();
            taskVisitRecord = new TaskVisitRecord();
            BeanUtils.copyProperties(taskVisitRecordDTO, taskVisitRecord);
            taskVisitRecord.setId(recordId);

            //判断是否是预约走访任务
            if(Objects.isNull(sysCampaign)){
                taskVisitRecord.setVisitType("预约走访任务");
                taskVisitRecord.setCampaignName("预约走访任务");
                taskVisitRecord.setFeedbackTemplateId("-1");
                String custType = taskVisitRecordDTO.getCustType();
                taskVisitRecord.setCustType(custType);
                if (custType.equals("0")) {
                    taskVisitRecord.setFeedbackType("0");
                } else {
                    taskVisitRecord.setFeedbackType("1");
                }
                AppointmentInfo appointmentInfo = new AppointmentInfo();
                appointmentInfo.setId(taskVisitRecordDTO.getAppointmentId());
                appointmentInfo.setSignFlag("1");
                appointmentInfo.setRecordId(recordId);
                appointmentMapper.updateAppointment(appointmentInfo);
            }else {
                taskVisitRecord.setVisitType(sysCampaign.getVisitType());
                taskVisitRecord.setCampaignName(sysCampaign.getCampaignName());
                taskVisitRecord.setCustType(sysCampaign.getCustType());
                taskVisitRecord.setFeedbackTemplateId(sysCampaign.getRelatedModelId());
                if (sysCampaign.getRelatedModelId().equals("-1")) {
                    if (sysCampaign.getCustType().equals("0")) {
                        taskVisitRecord.setFeedbackType("0");
                    } else {
                        taskVisitRecord.setFeedbackType("1");
                    }
                } else {
                    taskVisitRecord.setFeedbackType("2");
                }
            }
            taskVisitRecord.setUserId(SecurityUtils.getUserId());
            taskVisitRecord.setUserName(SecurityUtils.getUsername());
            taskVisitRecord.setNickName(SecurityUtils.getLoginUser().getUser().getNickName());
        }else{
            taskVisitRecord = taskVisitRecordMapper.selectById(recordId);
            if (Objects.isNull(taskVisitRecord)){
                throw new ServiceException("走访记录不存在");
            }
            if (Objects.nonNull(taskVisitRecord.getSignId())){
                throw new ServiceException("走访记录已签到，禁止重复签到");
            }
        }
        TaskVisitSign taskVisitSign = new TaskVisitSign();
        BeanUtils.copyProperties(taskVisitRecordDTO, taskVisitSign);
        taskVisitSign.setId(IdUtils.fastSimpleUUID());
        taskVisitSign.setRecordId(recordId);
        taskVisitSignMapper.insert(taskVisitSign);

        taskVisitRecord.setSignId(taskVisitSign.getId());
        taskVisitRecord.setLatestSign(taskVisitSign.getId());
        if (newRecordFlag){
            taskVisitRecordMapper.insert(taskVisitRecord);
        }else {
            taskVisitRecordMapper.updateById(taskVisitRecord);
        }

        if (taskVisitRecordDTO.getImageList() != null && !taskVisitRecordDTO.getImageList().isEmpty()){
            ArrayList<String> msgList = new ArrayList<>();
            msgList.add(taskVisitRecordDTO.getSignInAddress());
            msgList.add(taskVisitRecordDTO.getSignInTime().toString());
            uploadImagesToOss(recordId, "0", taskVisitRecordDTO.getImageList(), msgList, SecurityUtils.getUsername());
        }


        if(Objects.nonNull(sysCampaign)){
        //   如果是协作任务，更新任务所属客户经理 \ 网点字段
            if(sysCampaign.getCooperate()){
                sysCampaignGroupCustomerMapper.updateUserIdByCampaignId(sysCampaign.getCampaignId(),taskVisitRecordDTO.getCustId(), SecurityUtils.getUserId(),SecurityUtils.getDeptId());
            }
        }
        SignInVO signInVO = new SignInVO();
        BeanUtils.copyProperties(taskVisitRecord, signInVO);
        signInVO.setRecordId(recordId);
        return signInVO;
    }

    /**
     * 处理远程走访任务的签到逻辑，包括新增或更新走访记录、插入签到信息、上传图片等操作。
     *
     * @param taskRemoteVisitDTO 远程走访任务数据传输对象，包含走访相关信息
     * @return 返回操作结果提示信息："非实地走访签到成功"
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public SignInVO addRemoteVisitRecord(TaskRemoteVisitDTO taskRemoteVisitDTO) {

        String recordId = taskRemoteVisitDTO.getRecordId();
        TaskVisitRecord taskVisitRecord;
        boolean newRecordFlag = Objects.isNull(recordId);
        SysCampaign sysCampaign = sysCampaignMapper.selectSysCampaignByCampaignId(taskRemoteVisitDTO.getCampaignId());

        // 如果是新增记录，则初始化走访记录并设置相关信息
        if (newRecordFlag){
            recordId = IdUtils.fastSimpleUUID();
            taskVisitRecord = new TaskVisitRecord();
            BeanUtils.copyProperties(taskRemoteVisitDTO, taskVisitRecord);
            taskVisitRecord.setId(recordId);

            // 判断是否是预约走访任务
            if(Objects.isNull(sysCampaign)){
                taskVisitRecord.setVisitType("预约走访任务");
                taskVisitRecord.setCampaignName("预约走访任务");
                taskVisitRecord.setFeedbackTemplateId("-1");
                String custType = taskRemoteVisitDTO.getCustType();
                taskVisitRecord.setCustType(custType);
                if (custType.equals("0")) {
                    taskVisitRecord.setFeedbackType("0");
                } else {
                    taskVisitRecord.setFeedbackType("1");
                }

                // 更新预约信息状态为已签到
                AppointmentInfo appointmentInfo = new AppointmentInfo();
                appointmentInfo.setId(taskRemoteVisitDTO.getAppointmentId());
                appointmentInfo.setSignFlag("1");
                appointmentInfo.setRecordId(recordId);
                appointmentMapper.updateAppointment(appointmentInfo);
            }else {
                taskVisitRecord.setVisitType(sysCampaign.getVisitType());
                taskVisitRecord.setCampaignName(sysCampaign.getCampaignName());
                taskVisitRecord.setCustType(sysCampaign.getCustType());
                taskVisitRecord.setFeedbackTemplateId(sysCampaign.getRelatedModelId());

                // 根据模板ID和客户类型设置反馈类型
                if (sysCampaign.getRelatedModelId().equals("-1")) {
                    if (sysCampaign.getCustType().equals("0")) {
                        taskVisitRecord.setFeedbackType("0");
                    } else {
                        taskVisitRecord.setFeedbackType("1");
                    }
                } else {
                    taskVisitRecord.setFeedbackType("2");
                }
            }

            // 设置当前用户相关信息
            taskVisitRecord.setUserId(SecurityUtils.getUserId());
            taskVisitRecord.setUserName(SecurityUtils.getUsername());
            taskVisitRecord.setNickName(SecurityUtils.getLoginUser().getUser().getNickName());
        }else{
            // 如果是已有记录，则从数据库查询该记录
            taskVisitRecord = taskVisitRecordMapper.selectById(recordId);
            if (Objects.isNull(taskVisitRecord)){
                throw new ServiceException("走访记录不存在");
            }
            if (Objects.nonNull(taskVisitRecord.getSignId())){
                throw new ServiceException("走访记录已签到，无法进行非实地走访");
            }
        }

        // 创建并保存签到信息
        TaskVisitSign taskVisitSign = new TaskVisitSign();
        taskVisitSign.setId(IdUtils.fastSimpleUUID());
        taskVisitSign.setRecordId(recordId);
        taskVisitSign.setSignInTime(taskRemoteVisitDTO.getSignInTime());
        taskVisitSign.setSignOutTime(taskRemoteVisitDTO.getSignInTime());
        taskVisitSign.setSignOutRemark(taskRemoteVisitDTO.getSignOutRemark());
        taskVisitSignMapper.insert(taskVisitSign);

        // 更新走访记录中的最新签到ID
        taskVisitRecord.setLatestSign(taskVisitSign.getId());
        if (newRecordFlag){
            taskVisitRecordMapper.insert(taskVisitRecord);
        }else {
            taskVisitRecordMapper.updateById(taskVisitRecord);
        }

        // 如果有图片列表，则上传图片至OSS
        if (taskRemoteVisitDTO.getImageList() != null && !taskRemoteVisitDTO.getImageList().isEmpty()){
            ArrayList<String> msgList = new ArrayList<>();
            msgList.add(SecurityUtils.getUsername());
            msgList.add(taskRemoteVisitDTO.getSignInTime().toString());
            uploadImagesToOss(recordId, "0", taskRemoteVisitDTO.getImageList(), msgList, SecurityUtils.getUsername());
        }

        // 如果是协作任务，更新任务所属客户经理和网点信息
        if(Objects.nonNull(sysCampaign)){
            if(sysCampaign.getCooperate()){
                sysCampaignGroupCustomerMapper.updateUserIdByCampaignId(sysCampaign.getCampaignId(),taskRemoteVisitDTO.getCustId(), SecurityUtils.getUserId(),SecurityUtils.getDeptId());
            }
        }

        SignInVO signInVO = new SignInVO();
        BeanUtils.copyProperties(taskVisitRecord, signInVO);
        signInVO.setRecordId(recordId);
        return signInVO;
    }

    /**
     * @param signOutDTO
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public synchronized String updateTaskVisitRecord(SignOutDTO signOutDTO) {
        TaskVisitRecord taskVisitRecord = taskVisitRecordMapper.selectById(signOutDTO.getRecordId());
        if (Objects.isNull(taskVisitRecord)){
            throw new ServiceException("走访记录不存在");
        }
        if (Objects.isNull(taskVisitRecord.getSignId())){
            throw new ServiceException("签到记录不存在或未签到");
        }
        TaskVisitSign taskVisitSign = taskVisitSignMapper.selectById(taskVisitRecord.getSignId());
        if (Objects.isNull(taskVisitSign)){
            throw new ServiceException("签到记录不存在或未签到");
        }
        Instant instantIn = taskVisitSign.getSignInTime().toInstant();
        Instant instantNow = new Date().toInstant();

        List<SysDictData> sysDictTypeArrayList = new ArrayList<SysDictData>(redisCache.getCacheObject("sys_dict:sign_out_duration"));
        if(!sysDictTypeArrayList.isEmpty()){
            List<SysDictData> collect = sysDictTypeArrayList.stream().filter(e -> e.getDictLabel().equalsIgnoreCase(String.valueOf(SecurityUtils.getDeptId() / 1000))).collect(Collectors.toList());
            if(!collect.isEmpty()){
                Integer time = Integer.valueOf(collect.get(0).getDictValue());
                if(time  > Duration.between(instantIn, instantNow).toMinutes()) {
                    throw new ServiceException("签到、签退时间必须大于"+ time  +"分钟");
                }
            }
        }


        BeanUtils.copyProperties(signOutDTO, taskVisitSign);
        taskVisitSignMapper.updateById(taskVisitSign);

        double timeDiff = (taskVisitSign.getSignOutTime().getTime() - taskVisitSign.getSignInTime().getTime()) / 3600000.0;
        if (Objects.isNull(taskVisitRecord.getDuration())){
            taskVisitRecord.setDuration(timeDiff);
        }else{
            taskVisitRecord.setDuration(taskVisitRecord.getDuration() + timeDiff);
        }
        taskVisitRecord.setSignId(null);
        taskVisitRecordMapper.updateById(taskVisitRecord);

        if (signOutDTO.getImageList() != null && !signOutDTO.getImageList().isEmpty()){
            ArrayList<String> msgList = new ArrayList<>();
            msgList.add(SecurityUtils.getUsername());
            msgList.add(signOutDTO.getSignOutTime().toString());
            uploadImagesToOss(taskVisitRecord.getId(), "1", signOutDTO.getImageList(), msgList, SecurityUtils.getUsername());
        }

        if (Objects.nonNull(signOutDTO.getAppointmentId()) && signOutDTO.getAppointmentId() != -1){
            AppointmentInfo appointmentInfo = new AppointmentInfo();
            appointmentInfo.setId(signOutDTO.getAppointmentId());
            appointmentInfo.setSignFlag("0");
            appointmentMapper.updateAppointment(appointmentInfo);
        }

        return "走访任务签退成功";
    }

    /**
     * @param taskVisitCustAddressDTO
     * @return
     */
    @Override
    public String addCustAddress(TaskVisitCustAddressDTO taskVisitCustAddressDTO) {
        LambdaQueryWrapper<TaskVisitCustAddress> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TaskVisitCustAddress::getCustId, taskVisitCustAddressDTO.getCustId())
                .eq(TaskVisitCustAddress::getUserName, SecurityUtils.getUsername());
        TaskVisitCustAddress taskVisitCustAddress = taskVisitCustAddressMapper.selectOne(queryWrapper);
        if (Objects.isNull(taskVisitCustAddress)){
            taskVisitCustAddress = new TaskVisitCustAddress();
            BeanUtils.copyProperties(taskVisitCustAddressDTO, taskVisitCustAddress);
            taskVisitCustAddress.setUserName(SecurityUtils.getUsername());
            taskVisitCustAddressMapper.insert(taskVisitCustAddress);
        }else {
            BeanUtils.copyProperties(taskVisitCustAddressDTO, taskVisitCustAddress);
            taskVisitCustAddressMapper.updateById(taskVisitCustAddress);
        }
        return "客户地址采集成功";
    }

    /**
     * @param recordId
     * @return
     */
    @Override
    public TaskVisitSign getCurrentSign(String recordId) {
        TaskVisitRecord taskVisitRecord = taskVisitRecordMapper.selectById(recordId);
        if (Objects.nonNull(taskVisitRecord) && Objects.nonNull(taskVisitRecord.getSignId())) {
            return taskVisitSignMapper.selectById(taskVisitRecord.getSignId());
        }
        return null;
    }

    /**
     * @param custId
     * @return
     */
    @Override
    public List<VisitRecordListVO> getVisitRecordList(String custId) {
        return taskVisitRecordMapper.getVisitRecordList(custId, SecurityUtils.getHeadId());
    }

    /**
     * @return
     */
    @Override
    public List<VisitRecordListVO> getVisitRecordListByUserName(TaskRecordDTO taskRecordDTO) {
        taskRecordDTO.setUserName(SecurityUtils.getUsername());
        taskRecordDTO.setPost(SecurityUtils.userRoleHeadOrBranch());
        taskRecordDTO.setDeptId(SecurityUtils.getDeptId());
        return taskVisitRecordMapper.getVisitRecordListByUserName(taskRecordDTO);
    }

    /**
     * @param recordId
     * @return
     */
    @Override
    @SneakyThrows
    public VisitRecordVO getVisitRecord(String recordId) {
        VisitRecordVO visitRecord = taskVisitRecordMapper.getVisitRecord(recordId);
        if (Objects.isNull(visitRecord)){
            throw new ServiceException("走访记录不存在");
        }
        LambdaQueryWrapper<TaskVisitSign> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TaskVisitSign::getRecordId, recordId).orderByDesc(TaskVisitSign::getSignInTime);
        List<TaskVisitSign> taskVisitSigns = taskVisitSignMapper.selectList(queryWrapper);
        visitRecord.setSignList(taskVisitSigns);

        LambdaQueryWrapper<TaskVisitImage> imageQueryWrapper = new LambdaQueryWrapper<>();
        imageQueryWrapper.eq(TaskVisitImage::getRecordId, recordId);
        List<TaskVisitImage> taskVisitImages = taskVisitImageMapper.selectList(imageQueryWrapper);
        if (Objects.nonNull(taskVisitImages) && !taskVisitImages.isEmpty()) {
            List<String> imageList = new ArrayList<>();
            for (TaskVisitImage taskVisitImage : taskVisitImages) {
                MultipartFile fileFromOss = ossFileService.getFileFromOss(taskVisitImage.getFileId());
                imageList.add(ImageUtils.multiplePartFileToBase64(fileFromOss));
            }
            visitRecord.setImageList(imageList);
        }
        if (Objects.nonNull(visitRecord.getFeedbackId())){
            visitRecord.setFeedback(visitFeedbackService.getFeedback(visitRecord.getFeedbackType(), visitRecord.getFeedbackId()));
        }

        if("0".equalsIgnoreCase(visitRecord.getCustType())){
            CustInfoRetail custInfoRetail = custInfoRetailMapper.selectCustInfoRetailByCustId(visitRecord.getCustId());
            visitRecord.setIndustry(custInfoRetail.getBelongBusi());
        }
        if("1".equalsIgnoreCase(visitRecord.getCustType())){
            CustInfoMerchant custInfoMerchant = custInfoMerchantMapper.selectCustInfoMerchatByCustId(visitRecord.getCustId());
            visitRecord.setIndustry(custInfoMerchant.getIndustry());
        }
        if("2".equalsIgnoreCase(visitRecord.getCustType())){
            CustInfoBusiness custInfoBusiness = custInfoBusinessMapper.selectCustInfoBusinessByCustId(visitRecord.getCustId());
            visitRecord.setIndustry(custInfoBusiness.getIndustry());
        }

        return visitRecord;
    }

    private void uploadImagesToOss(String recordId, String signType, List<MultipartFile> imageList, List<String> msgList, String userName) {
        imageList.forEach(image -> {
            OssFileUploadDTO ossFileUploadDTO = new OssFileUploadDTO();
            MultipartFile compressImage = ImageUtils.compressPictureForScale(image, 512);
            MultipartFile file = ImageUtils.addMultilineTextWatermark(compressImage, msgList, Positions.CENTER, 0.7f);
            ossFileUploadDTO.setFile(file);
            ossFileUploadDTO.setOssFileEnum(OssFileEnum.VISIT_IMAGE);
            ossFileUploadDTO.setUserName(userName);
            String uuid = ossFileService.uploadFileToOss(ossFileUploadDTO);

            TaskVisitImage taskVisitImage = new TaskVisitImage();
            taskVisitImage.setFileId(uuid);
            taskVisitImage.setRecordId(recordId);
            taskVisitImage.setSignType(signType);
            taskVisitImage.setCreateTime(new Date());
            taskVisitImageMapper.insert(taskVisitImage);

        });
        log.info("上传图片到OSS成功");
    }

        public void uploadCustImagesToOss(List<MultipartFile> imageList,String custId) {
        //先删除已有的照片
            List<CustImage> list = custImageMapper.selectList(new LambdaQueryWrapper<CustImage>().eq(CustImage::getCustId,custId));
            for (CustImage custImage:list
                 ) {
                custImageMapper.delete(new LambdaQueryWrapper<CustImage>().eq(CustImage::getFileId,custImage.getFileId()));
                ossFileService.deleteFileFromOss(custImage.getFileId());
            }
            if (imageList==null || imageList.size()==0){
                log.info("本次未上传图片");
                return;
            }
//            List<MultipartFile> fileList = new ArrayList<>();
//            for (int i = imageList.size()-1; i >=0 ; i--) {
//                fileList.add(imageList.get(i));
//            }
            //上传新照片---------20250730图片排序有问题
            imageList.forEach(image -> {
            OssFileUploadDTO ossFileUploadDTO = new OssFileUploadDTO();
            MultipartFile compressImage = ImageUtils.compressPictureForScale(image, 512);
            ossFileUploadDTO.setFile(compressImage);
            ossFileUploadDTO.setOssFileEnum(OssFileEnum.CUST_IMAGE);
            ossFileUploadDTO.setUserName(SecurityUtils.getUsername());
            String uuid = ossFileService.uploadFileToOss(ossFileUploadDTO);

            CustImage custImage = new CustImage();
            custImage.setFileId(uuid);
            custImage.setCustId(custId);
            custImage.setCreateTime(new Date());
            custImageMapper.insert(custImage);

        });
        log.info("上传图片到OSS成功");
    }

    public List<String> downloadCustImagesToOss(String custId) {
        List<String> imageList = new ArrayList<>();
        List<CustImage> list = custImageMapper.selectList(new LambdaQueryWrapper<CustImage>().eq(CustImage::getCustId,custId).eq(CustImage::getIsDelete,"0"));
        for (CustImage custImage:list
             ) {
            MultipartFile fileFromOss = ossFileService.getFileFromOss(custImage.getFileId());
            imageList.add(ImageUtils.multiplePartFileToBase64(fileFromOss));
        }
       return imageList;
    }

}
