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

import java.util.ArrayList;
import java.util.List;

import com.szpg.db.dao.PgDsDao;
import com.szpg.db.dao.PgDeviceDao;
import com.szpg.db.dao.impl.PgDsDaoImpl;
import com.szpg.db.dao.impl.PgDeviceDaoImpl;
import com.szpg.plc.message.response.ReadMemoryCommandResponse;
import com.szpg.util.TimeFormat;

public class ReadDSStatusCommandResponse extends ReadMemoryCommandResponse {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4047613496835657828L;
	
	private List<Boolean> dsbj; // 对射报警状态

	public ReadDSStatusCommandResponse() {
		dsbj = new ArrayList<Boolean>();
	}

	public List<Boolean> getDsbj() {
		return dsbj;
	}

	public void setDsbj(List<Boolean> dsbj) {
		this.dsbj = dsbj;
	}

	@Override
	public void afterAction() {
		// 1将对射报警数据存入数据库
		PgDsDao dsDao = new PgDsDaoImpl();
		PgDeviceDao deviceDao = new PgDeviceDaoImpl();

		List<Integer> ids = deviceDao.findDeviceIdByDestAndType(this.getMessageProducerId(), "DS");

		for (int i = 0; i < dsbj.size(); i++) {
			if (i < ids.size()) {
				dsDao.addSbjzRecord(dsbj.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), ids.get(i));
				
				// 有报警状态
				if (dsbj.get(i) == true) {
					// TODO
					// 1存入报警管理表
					
					
				}
			}
		}
	}

}
