/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.gpsboot.service.paln.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.gpsboot.common.system.FileTableEnum;
import com.tofly.gpsboot.mapper.plan.HydrantrecordMapper;
import com.tofly.gpsboot.service.comm.IFileInfoService;
import com.tofly.gpsboot.service.paln.HydrantrecordService;
import com.tofly.pojo.plan.Hydrantrecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


/**
 * 消防栓记录上报表
 *
 * @author admin
 * @date Fri Sep 10 00:00:00 CST 2021
 */
@Service("hydrantrecordService")
public class HydrantrecordServiceImpl extends ServiceImpl<HydrantrecordMapper, Hydrantrecord> implements HydrantrecordService {

    @Value("${xrty.ftp.hydrantrecord}")
    private String hydrantRecordPath;
    @Autowired
    private IFileInfoService iFileInfoService;
    @Override
    public boolean savaHydrantRecordInfo(List<MultipartFile> fileList, Hydrantrecord hydrantrecord) {
        // 判断当前是否有文件,则存入返回文件id
        if (null != fileList && fileList.size() > 0) {
            StringBuilder fileIdList = iFileInfoService.saveFileList(fileList, hydrantRecordPath, FileTableEnum.TF_YWPN_HYDRANTRECORD_W.getTableName());
            // 根据文件id反射填充对象
            hydrantrecord.setFileIds(fileIdList.toString());
        }
        // 对象入库
       return this.save(hydrantrecord);
    }
}
