package com.sw.mes.fb.checkout.controller;

import com.alibaba.excel.EasyExcelFactory;
import com.sw.mes.base.factory.material.entity.MaterialModel;
import com.sw.mes.base.factory.material.service.MaterialModelService;
import com.sw.mes.base.global.GlobalSwitch;
import com.sw.mes.base.global.SwitchConfig;
import com.sw.mes.core.api.system.YbFeignClients;
import com.sw.mes.core.context.BaseContextHandler;
import com.sw.mes.core.dto.PieceCheckDto;
import com.sw.mes.core.dto.mes.pc.fb.FbCheckOutDataDto;
import com.sw.mes.core.dto.mes.pc.yb.YbInspectDataDto;
import com.sw.mes.core.entity.FbCheckOutData;
import com.sw.mes.core.enums.SectionIndexRangeEnum;
import com.sw.mes.core.response.ResponsePage;
import com.sw.mes.core.response.Result;
import com.sw.mes.core.response.ResultGenerator;
import com.sw.mes.core.utils.*;
import com.sw.mes.fb.checkout.dao.RecutDetailDao;
import com.sw.mes.fb.checkout.dto.ExportFbCheckOutDataDto;
import com.sw.mes.fb.checkout.dto.ImportGrade;
import com.sw.mes.fb.checkout.dto.MatchOrder;
import com.sw.mes.fb.checkout.entity.OperateCheckOutDataLog;
import com.sw.mes.fb.checkout.service.FbCheckOutDataService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

import static com.sw.mes.base.global.GlobalSwitchNamespace.NAMESPACE_COMMON_SWITCH;


/**
 * @Author
 * @Description：
 * @Date: Create in
 * @Modified By:
 */
@RestController
@RequestMapping("/ZhxxOperateCheckOutData")
@Slf4j
@Api(description = "方棒检验数据库接口")
public class FbCheckOutDataController {
    @Autowired
    ModelMapper modelMapper;

    @Autowired
    private FbCheckOutDataService fbCheckOutDataService;

    @Autowired
    private YbFeignClients ybFeignClients;

    @Autowired
    private RecutDetailDao recutDetailDao;

    @Autowired
    private MaterialModelService materialModelService;

    @ApiOperation(value = "分页查询方棒检验数据库列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "rows", value = "行数", dataType = "integer", paramType = "query"), @ApiImplicitParam(name = "page", value = "页码", dataType = "integer", paramType = "query"), @ApiImplicitParam(name = "search_LIKE_ybSectionNo", value = "圆棒编号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_LIKE_fbSectionNo", value = "方棒编号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_EQ_checkUserName", value = "检验人员", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_LIKE_sectionNo", value = "晶棒编号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_GTE_checkTime", value = "检验开始时间", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_LTE_checkTime", value = "检验结束时间", dataType = "String", paramType = "query"),})
    @GetMapping("/listByPage")
    public Result<ResponsePage<FbCheckOutDataDto>> listByPage(ServletRequest request, @ApiIgnore RequestPage requestPage) {
        Specification<FbCheckOutData> specification = DynamicSpecifications.bySearchFilter(request, FbCheckOutData.class);
        Page<FbCheckOutData> page = fbCheckOutDataService.findByExample(specification, PageUtil.createPageable(requestPage));
        Integer userId = BaseContextHandler.getUserID();
        SwitchConfig config = GlobalSwitch.switchConfig(NAMESPACE_COMMON_SWITCH, "edit", false);
        HashMap<String, String> materialCache = new HashMap<>();

        List<FbCheckOutDataDto> dtos = page.getContent().stream().map(entity -> {
            FbCheckOutDataDto newDto = toLazyDto(entity);
            if (null != entity.getMaterialCode()) {
                if (materialCache.containsKey(entity.getMaterialCode())) {
                    newDto.setMaterialName(materialCache.get(entity.getMaterialNumber()));
                } else {
                    MaterialModel materialModel = materialModelService.findByCode(entity.getMaterialNumber());
                    if (null != materialModel) {
                        newDto.setMaterialName(materialModel.getName());
                        materialCache.put(entity.getMaterialNumber(), materialModel.getName());
                    }
                }
            }
            if (config != null && config.isEnable() && userIdSet(config.getValue()).contains(userId)) {
                newDto.setEdit(true);
            }
            return newDto;
        }).collect(Collectors.toList());
        ResponsePage responsePage = new ResponsePage(dtos, page.getTotalElements());
        return ResultGenerator.success(responsePage);
    }

    private Set<Integer> userIdSet(String value) {
        if (StringUtils.isEmpty(value)) {
            return Collections.emptySet();
        }
        return Arrays.stream(value.split(",")).map(Integer::parseInt).collect(Collectors.toSet());

    }

    @ApiOperation(value = "创建方棒检验数据库")
    @PostMapping("/matchOrder")
    public Result matchOrder(@RequestBody @Valid @ApiParam(value = "方棒匹配订单接口") MatchOrder matchOrder, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
        }
        if (matchOrder.getIds().isEmpty()) {
            return ResultGenerator.success("至少选择一个编号");
        }
        if (matchOrder.getIds().size() > 100) {
            return ResultGenerator.success("每次最多只能选择100个编号");
        }
        for (Integer id : matchOrder.getIds()) {

        }
        return ResultGenerator.success();
    }

    @ApiOperation(value = "导出方棒检验数据库")
    @ApiImplicitParams({@ApiImplicitParam(name = "search_LIKE_ybSectionNo", value = "圆棒编号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_LIKE_fbSectionNo", value = "方棒编号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_EQ_checkUserName", value = "检验人员", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_LIKE_sectionNo", value = "晶棒编号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_GTE_checkTime", value = "检验开始时间", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "search_LTE_checkTime", value = "检验结束时间", dataType = "String", paramType = "query"),})
    @GetMapping("/export")
    public void export(ServletRequest request, @ApiIgnore RequestPage requestPage, HttpServletResponse response) {
        try {
            Specification<FbCheckOutData> specification = DynamicSpecifications.bySearchFilter(request, FbCheckOutData.class);
            List<FbCheckOutData> list = fbCheckOutDataService.findByExampleSort(specification, null);
            List<MaterialModel> materialModelList = materialModelService.findAll();
            Map<String, List<MaterialModel>> listMap = materialModelList.stream().collect(Collectors.groupingBy(MaterialModel::getCode));
            List<ExportFbCheckOutDataDto> dtos = list.stream().map(entity -> {
                        ExportFbCheckOutDataDto exportFbCheckOutDataDto = toLazyExportDto(entity);
                        if (null != exportFbCheckOutDataDto.getMaterialCode()) {
                            List<MaterialModel> materialModelList1 = listMap.get(exportFbCheckOutDataDto.getMaterialCode());
                            MaterialModel materialModel = materialModelList1.get(0);
                            if (Objects.nonNull(materialModel)) {
                                exportFbCheckOutDataDto.setMaterialName(materialModel.getName());
                            }
                        }
                        return exportFbCheckOutDataDto;
                    }
            ).collect(Collectors.toList());
            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            response.setCharacterEncoding("utf-8");
            String fileName = URLEncoder.encode("方棒检验数据库", String.valueOf(StandardCharsets.UTF_8)).replaceAll("\\+", "%20");
            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
            EasyExcelFactory.write(response.getOutputStream(), ExportFbCheckOutDataDto.class)
                    .sheet("方棒检验数据库")
                    .doWrite(dtos);
        } catch (Exception e) {
            throw new RuntimeException("方棒拼棒记录导出失败，错误信息：" + e.getMessage());
        }
    }

    @ApiOperation(value = "获取所有方棒检验数据库")
    @GetMapping("/listAll")
    public Result<List<FbCheckOutDataDto>> listAll(ServletRequest request) {
        Specification<FbCheckOutData> specification = DynamicSpecifications.bySearchFilter(request, FbCheckOutData.class);
        List<FbCheckOutData> fbCheckOutData = fbCheckOutDataService.findByExampleSort(specification, null);
        List<FbCheckOutDataDto> fbCheckOutDataDtos = fbCheckOutData.stream().map(fbCheckOutData2 -> toLazyDto(fbCheckOutData2)).collect(Collectors.toList());
        return ResultGenerator.success(fbCheckOutDataDtos);
    }

    @ApiOperation(value = "方棒检验数据库详细信息")
    @GetMapping("/{id}")
    public Result<FbCheckOutDataDto> get(@PathVariable @ApiParam(value = "ZhxxOperateCheckOutDataid") Long id) {
        FbCheckOutData fbCheckOutData = fbCheckOutDataService.get(id);
        if (null == fbCheckOutData) return ResultGenerator.fail("该方棒检验信息不存在");
        FbCheckOutDataDto newFbCheckOutDataDto = toEagerDto(fbCheckOutData);
        MaterialModel materialModel = materialModelService.findByCode(fbCheckOutData.getMaterialCode());
        if (Objects.nonNull(materialModel)) {
            newFbCheckOutDataDto.setMaterialName(materialModel.getName());
        }
        return ResultGenerator.success();
    }


    @ApiOperation(value = "方棒检验数据库详细信息")
    @GetMapping("/edit/{id}")
    public Result<FbCheckOutDataDto> editGet(@PathVariable @ApiParam(value = "ZhxxOperateCheckOutDataid") Long id) {
        FbCheckOutData fbCheckOutData = fbCheckOutDataService.get(id);
        //根据方棒的晶段号，获取圆棒的编号
        String ybSectionNo = fbCheckOutData.getYbSectionNo();
        Result<YbInspectDataDto> inspectDataById = ybFeignClients.accordSquareGetInspect(ybSectionNo);
        if (inspectDataById.getCode().equals(200) && null != inspectDataById.getData()) {
            YbInspectDataDto ybInspectDataDto = inspectDataById.getData();
            //T电阻率
            fbCheckOutData.setTResistivity(ybInspectDataDto.getTResistivity() != null ? ybInspectDataDto.getTResistivity() : new BigDecimal(0));
            //W电阻率
            fbCheckOutData.setWResistivity(ybInspectDataDto.getWResistivity() != null ? ybInspectDataDto.getWResistivity() : new BigDecimal(0));
            //T寿命
            fbCheckOutData.setTCarrierLifetime(ybInspectDataDto.getTCentreLife() != null ? ybInspectDataDto.getTCentreLife() : new BigDecimal(0));
            //W寿命
            fbCheckOutData.setWCarrierLifetime(ybInspectDataDto.getWCentreLife() != null ? ybInspectDataDto.getWCentreLife() : new BigDecimal(0));
            //T氧含量中心
            fbCheckOutData.setTOxygenContent(ybInspectDataDto.getOxygenContentHead() != null ? ybInspectDataDto.getOxygenContentHead() : new BigDecimal(0));
            //W氧含量中心
            fbCheckOutData.setWOxygenContent(ybInspectDataDto.getOxygenContentTail() != null ? ybInspectDataDto.getOxygenContentTail() : new BigDecimal(0));
            //T碳含量中心
            fbCheckOutData.setTCarbonContent(ybInspectDataDto.getCarbonContentHead() != null ? ybInspectDataDto.getCarbonContentHead() : new BigDecimal(0));
            //W碳含量中心
            fbCheckOutData.setWCarbonContent(ybInspectDataDto.getCarbonContentTail() != null ? ybInspectDataDto.getCarbonContentTail() : new BigDecimal(0));
            //A电阻率均值
            fbCheckOutData.setMeanResistivityA(ybInspectDataDto.getMeanResistivityA() != null ? ybInspectDataDto.getMeanResistivityA() : new BigDecimal(0));
            //B电阻率均值
            fbCheckOutData.setMeanResistivityB(ybInspectDataDto.getMeanResistivityB() != null ? ybInspectDataDto.getMeanResistivityB() : new BigDecimal(0));
            //A少子寿命均值
            fbCheckOutData.setMeanCarrierLifetimeA(ybInspectDataDto.getMeanCarrierLifetimeA() != null ? ybInspectDataDto.getMeanCarrierLifetimeA() : new BigDecimal(0));
            //B少子寿命均值
            fbCheckOutData.setMeanCarrierLifetimeB(ybInspectDataDto.getMeanCarrierLifetimeB() != null ? ybInspectDataDto.getMeanCarrierLifetimeB() : new BigDecimal(0));
        }
        if (null == fbCheckOutData) return ResultGenerator.fail("该方棒检验信息不存在");
        return ResultGenerator.success(toEagerDto(fbCheckOutData));
    }

    /**
     * 单行修改
     *
     * @param dto
     * @param bindingResult
     * @return
     */
    @ApiOperation(value = "更新方棒检验数据库")
    @PostMapping("/update/line")
    public Result updateLine(@RequestBody @Valid @ApiParam(value = "ZhxxOperateCheckOutData") FbCheckOutDataDto dto, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
        if (dto.getId() == null) return ResultGenerator.fail("id不能为空");
        FbCheckOutData entity = fbCheckOutDataService.get(dto.getId());
        if (entity == null) return ResultGenerator.fail("原信息不存在");
        try {
            FbCheckOutData entityfromFto = fromDto(dto);
            BeanUtils.copyProperties(entityfromFto, entity, BeanUtil.getIgnoreProperties(entityfromFto, null, null));
            fbCheckOutDataService.saveOrUpdate(entity);
            return ResultGenerator.success();
        } catch (Exception e) {
            return ResultGenerator.fail(e.getMessage());
        }
    }


    @ApiOperation(value = "接收MCS的编号查询检验数据")
    @PostMapping("/bySectionList")
    public Result<List<FbCheckOutData>> getData(@RequestBody List<String> sectionNos) {
        List<FbCheckOutData> checkOutDataByFbSectionNoIns = new ArrayList<>();
        if (null != sectionNos && sectionNos.size() > 0) {
            checkOutDataByFbSectionNoIns = fbCheckOutDataService.findCheckOutDataByFbSectionNoIns(sectionNos);
            if (null == checkOutDataByFbSectionNoIns) {
                return ResultGenerator.fail("检验数据不存在");
            }
        }
        return ResultGenerator.success(checkOutDataByFbSectionNoIns);
    }

    @ApiOperation(value = "创建方棒检验数据库")
    @PostMapping("/create")
    public Result create(@RequestBody @Valid @ApiParam(value = "ZhxxOperateCheckOutData对象") FbCheckOutDataDto fbCheckOutDataDto, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
        }
        FbCheckOutData fbCheckOutData = fromDto(fbCheckOutDataDto);
        fbCheckOutDataService.saveOrUpdate(fbCheckOutData);
        return ResultGenerator.success();
    }

    @ApiOperation(value = "更新方棒检验数据库")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid @ApiParam(value = "ZhxxOperateCheckOutData") FbCheckOutDataDto dto, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
        if (dto.getId() == null) return ResultGenerator.fail("id不能为空");
        FbCheckOutData entity = fbCheckOutDataService.get(dto.getId());
        if (entity == null) return ResultGenerator.fail("原信息不存在");
        try {
            FbCheckOutData entityfromFto = fromDto(dto);
            BeanUtils.copyProperties(entityfromFto, entity, BeanUtil.getIgnoreProperties(entityfromFto, null, null));
            fbCheckOutDataService.saveOrUpdate(entity);
            return ResultGenerator.success();
        } catch (Exception e) {
            return ResultGenerator.fail(e.getMessage());
        }
    }

    @ApiOperation(value = "删除方棒检验数据库")
    @PostMapping("/delete")
    public Result remove(@ApiParam(value = "id集合,逗号分隔,如2,4", type = "query") @RequestParam Long[] ids) {
        for (Long id : ids) {
            fbCheckOutDataService.delete(id);
        }
        return ResultGenerator.success();
    }


    @ApiOperation(value = "根据单晶编号查询")
    @GetMapping("/findDataByFbSectionNo")
    Result findDataByFbSectionNo(@RequestParam String fbSectionNo) {
        return ResultGenerator.success(fbCheckOutDataService.findDataByFbSectionNo(fbSectionNo));
    }

    @ApiOperation(value = "根据单晶编号模糊查询")
    @GetMapping("/findDataByLikeFbSectionNo")
    Result findDataByLikeFbSectionNo(@RequestParam String fbSectionNo) {
        return ResultGenerator.success(fbCheckOutDataService.findDataByLikeFbSectionNo(fbSectionNo));
    }


    @ApiOperation(value = "根据单晶编号集合查询")
    @GetMapping("/findDataByFbSectionNoList")
    Result findDataByFbSectionNoList(@RequestParam List<String> fbSectionNos) {
        return ResultGenerator.success(fbCheckOutDataService.findCheckOutDataByFbSectionNoIns(fbSectionNos));
    }

    @ApiOperation(value = "根据单晶编号查询拼棒组合编号")
    @GetMapping("/getSectionComposeBySectionNo")
    Result getSectionComposeBySectionNo(@RequestParam(value = "方棒编号") String fbSectionNo) {
        String sectionCompose = fbCheckOutDataService.getSectionComposeBySectionNo(fbSectionNo);
        return ResultGenerator.success(sectionCompose);
    }

    @ApiOperation(value = "根据工单号以及反切标识获取总重量")
    @GetMapping("/findSumWeightByOrderNoAndBackCut")
    Result findSumWeightByOrderNoAndBackCut(@RequestParam(value = "工单号") String orderNo, @RequestParam(value = "反切标识") int backCut) {
        String sumWeight = fbCheckOutDataService.findSumWeightByOrderNoAndBackCut(orderNo,backCut);
        return ResultGenerator.success(sumWeight);
    }


    /**
     * 晶段编号、规格、产品等级、实验等级
     *
     * @param file
     */
    @ApiOperation(value = "导入")
    @PostMapping("/import")
    public Result importGrade(MultipartFile file) {
        Object objList = EasyExcelUtils.readExcel(file, new ImportGrade(), 1, 1);
        if (objList != null) {
            List<ImportGrade> importGrades = (List<ImportGrade>) objList;
            StringBuilder failMessage = new StringBuilder();
            int successCount = 0, failCount = 0;
            for (ImportGrade importGrade : importGrades) {
                FbCheckOutData fbCheckOutData = fbCheckOutDataService.findDataByFbSectionNo(importGrade.getFbSectionNo());
                try {
                    if (fbCheckOutData != null) {
                        OperateCheckOutDataLog operateCheckOutDataLog = new OperateCheckOutDataLog();
                        BeanUtils.copyProperties(fbCheckOutData, operateCheckOutDataLog, BeanUtil.getIgnoreProperties(fbCheckOutData, "id", null));
                        operateCheckOutDataLog.setOperateTime(new Date());
                        operateCheckOutDataLog.setOperator(BaseContextHandler.getUsername());
                        operateCheckOutDataLog.setOperateType(1);
                        operateCheckOutDataLog.setRemarks(BaseContextHandler.getUsername() + "导入评级，数据变动");
                        BeanUtils.copyProperties(importGrade, fbCheckOutData);
                        fbCheckOutDataService.saveAndLog(fbCheckOutData, operateCheckOutDataLog);
                        successCount++;
                    } else {
                        failMessage.append(importGrade).append("导入失败【 检验信息不存在 】\\n");
                        failCount++;
                    }
                } catch (Exception e) {
                    failCount++;
                    failMessage.append(importGrade.getFbSectionNo()).append("导入失败【").append(e.getMessage()).append("】；\\n");
                }
                successCount++;
            }
            if (successCount > 0) {
                return ResultGenerator.success("共【" + successCount + failCount + "】条，成功【" + successCount + "】条；\\n"
                        + "失败【" + failCount + "】：" + failMessage);
            } else {
                return ResultGenerator.fail("共【" + successCount + failCount + "】条，全部失败：" + failMessage);
            }
        } else {
            return ResultGenerator.fail("导入数据为空");
        }
    }

    public FbCheckOutDataDto toLazyDto(FbCheckOutData entity) {
        FbCheckOutDataDto dto = modelMapper.map(entity, FbCheckOutDataDto.class);
        String fromMark = dto.getYbSectionNo().substring(SectionIndexRangeEnum.基地追溯产品类型.getBeginIndex(), SectionIndexRangeEnum.基地追溯产品类型.getEndIndex());
        if (fromMark.matches("[A-Z]+")) {
            dto.setCrystalNo(dto.getYbSectionNo().substring(SectionIndexRangeEnum.毛棒范围.getBeginIndex(), SectionIndexRangeEnum.毛棒范围.getEndIndex()));
        } else {
            dto.setCrystalNo(dto.getYbSectionNo().substring(0, 12));
        }
        return dto;
    }

    public ExportFbCheckOutDataDto toLazyExportDto(FbCheckOutData entity) {
        ExportFbCheckOutDataDto dto = modelMapper.map(entity, ExportFbCheckOutDataDto.class);
        if (null != entity.getBackCut() && entity.getBackCut() == 1) {
            dto.setBackCut("是");
        } else {
            dto.setBackCut("否");
        }
        if (null != entity.getOutGoing() && entity.getOutGoing() == 1) {
            dto.setOutGoing("是");
        } else {
            dto.setOutGoing("否");
        }
        if (null != entity.getAppearanceBackCut()&&entity.getAppearanceBackCut()==1){
            dto.setAppearanceBackCut("是");
        } else {
            dto.setAppearanceBackCut("否");
        }
        return dto;
    }


    @ApiOperation(value = "更新方棒样片数据")
    @PostMapping("/updatePieceCheckData")
    public Result updatePieceCheckData(@RequestBody @Valid @ApiParam(value = "样片检验数据对象") PieceCheckDto pieceCheckDto, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return ResultGenerator.fail(bindingResult.getFieldError().getDefaultMessage());
        }
        fbCheckOutDataService.updatePieceCheckData(pieceCheckDto);
        return ResultGenerator.success();
    }

    @ApiOperation(value = "返切更新检验返切状态")
    @PostMapping("/updateBackCutByFbSectionNo")
    public Result updateBackCutByFbSectionNo(@RequestParam String fbSectionNo,@RequestParam Integer backCut) {
        if (StringUtils.isBlank(fbSectionNo)){
            return ResultGenerator.fail("单晶编号为空！");
        }
        try {
            fbCheckOutDataService.updateBackCutByFbSectionNo(fbSectionNo,backCut);
        }catch (Exception e){
            log.info(e.getMessage());
            return ResultGenerator.fail(e.getMessage());
        }

        return ResultGenerator.success();
    }

    public FbCheckOutDataDto toEagerDto(FbCheckOutData entity) {
        return modelMapper.map(entity, FbCheckOutDataDto.class);
    }

    public FbCheckOutData fromDto(FbCheckOutDataDto dto) {
        return modelMapper.map(dto, FbCheckOutData.class);
    }


}
