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

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

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

public class ReadYWStatusCommandResponse extends ReadMemoryCommandResponse {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8088340048416088978L;
	
	private List<Boolean> ywbj; // 爆管液位报警状态

	public ReadYWStatusCommandResponse() {
		ywbj = new ArrayList<Boolean>();
	}

	public List<Boolean> getYwbj() {
		return ywbj;
	}

	public void setYwbj(List<Boolean> ywbj) {
		this.ywbj = ywbj;
	}

	@Override
	public void afterAction() {
		// 1将爆管液位浓度数据存入数据库
		PgYwDao ywDao = new PgYwDaoImpl();
		PgDeviceDao deviceDao = new PgDeviceDaoImpl();

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

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

}
