package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi.offlinesn;

import cn.estsh.i3plus.ext.mes.pcn.apiservice.model.MesCustSnOfflineModel;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.offlineprint.MesOfflinePrintServiceImpl;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Api(tags = "离线条码打印")
@RequestMapping(MesCommonConstant.MES_YANFEN + "/offline/print")
@Slf4j
public class MesWuhanOfflinePrintController {

    @Autowired
    private MesOfflinePrintServiceImpl mesOfflinePrintService;
    @PostMapping("/cust-sn")
    public ResultBean custSn(@RequestBody MesCustSnOfflineModel model) {

        Map<String, Object> custSnOfflineInfo = null;
        try {
            custSnOfflineInfo = mesOfflinePrintService.getCustSnOfflineInfo(model.getCustSn(), model.getTemplateCode(), model.getOrganizeCode());
        } catch (Exception e) {
          ResultBean.fail().setErrorMsg(e.getMessage());
        }
        return ResultBean.success("查询成功").setResultMap(custSnOfflineInfo);
    }
}
