package com.szpg.plc.message.response.write;

import com.szpg.db.dao.PgDeviceDao;
import com.szpg.db.dao.impl.PgDeviceDaoImpl;
import com.szpg.plc.message.response.WriteMemoryCommandResponse;
import org.apache.log4j.Logger;

public class SetZmOnBitCommandResponse extends WriteMemoryCommandResponse {

    private final Logger logger = Logger.getLogger(this.getClass().getName());

    private PgDeviceDao deviceDao = new PgDeviceDaoImpl();

    @Override
    public void afterAction() {
        if (this.isSuccess() == true) {
            // 更新设备状态 开
            int deviceId = deviceDao.findDeviceIdByCode(this.getDestinationId());
            if (deviceId > 0) {
                deviceDao.updateDeviceStatus(deviceId, "照明开启");
            }

            logger.info("[" + this.getAcucode() + "]打开照明成功");
        }
    }
}
