package org.nl.acs.common;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.springframework.stereotype.Service;

/**
 * @author geng by
 * 输送机控制点-带扫描驱动
 *
 */
@Service("standard_conveyor_control_with_scanner")
public class StandardCoveyorControlWithScannerDevice extends AbstractDriverService {

    @Override
    public JSONObject getDeviceInfo(Device device) {
        StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver();
        JSONObject jo = super.getCommonDeviceInfo(standardCoveyorControlWithScannerDeviceDriver,0,0);
        jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError());
        jo.put("isError", standardCoveyorControlWithScannerDeviceDriver.getIserror());
        jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction());
        try {
            jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithScannerDeviceDriver.barcode()) ? "" : standardCoveyorControlWithScannerDeviceDriver.barcode());
        } catch (Exception e) {
            e.printStackTrace();
        }
        jo.put("message", StrUtil.equals(standardCoveyorControlWithScannerDeviceDriver.getMessage(), "null") ? "" : standardCoveyorControlWithScannerDeviceDriver.getMessage());
        jo.put("requestSucess", standardCoveyorControlWithScannerDeviceDriver.getRequireSucess().toString());
        jo.put("applySucess", standardCoveyorControlWithScannerDeviceDriver.getApplySucess().toString());
        return jo;
    }
}
