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

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

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

public class ReadHSValueCommandResponse extends ReadMemoryCommandResponse {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3546717876436310153L;
	
	private List<Float> hsnd; //硫化氢浓度值
	private List<Float> hsldbjz; //硫化氢联动报警值
	
	public ReadHSValueCommandResponse() {
		hsnd = new ArrayList<Float>();
		hsldbjz = new ArrayList<Float>();
	}

	public List<Float> getHsnd() {
		return hsnd;
	}

	public void setHsnd(List<Float> hsnd) {
		this.hsnd = hsnd;
	}

	public List<Float> getHsldbjz() {
		return hsldbjz;
	}

	public void setHsldbjz(List<Float> hsldbjz) {
		this.hsldbjz = hsldbjz;
	}

	@Override
	public void afterAction() {
		// 1将硫化氢浓度数据存入数据库
		PgHSDao hsDao = new PgHSDaoImpl();
		PgDeviceDao deviceDao = new PgDeviceDaoImpl();
		
		List<Integer> ids = deviceDao.findDeviceIdByDestAndType(this.getMessageProducerId(), "HS");
		
		for (int i = 0; i < hsnd.size(); i++) {
			if (i < ids.size()) {
				hsDao.addPblzRecord(hsnd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), ids.get(i));
			}
		}
	}

}
