package com.steering.mes.signature;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import org.omg.CORBA.OBJECT_NOT_EXIST;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;

import com.steering.comm.db.DBCommon;
import com.steering.common.EntityTool;
import com.steering.mes.zgmil.entity.MatZcMEntity;
import com.steering.mes.zgmil.entity.StlControlLogEntity;

/**
 * 炼钢调度日志
 * 
 * @author Administrator
 * 
 */
public class FrmStlControlLog extends DBCommon {
	/***
	 * 查询炼钢日志表
	 * 
	 * @param parm
	 * @param plineCode
	 * @param startTim
	 *            当天
	 * @param endTim
	 *            前一天
	 * @return
	 */
	public CoreReturnObject doQueryPlan(String startTim, String endTim,
			String bc, String bz, String plineCode, String conFalg) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryPlan");
		sql += " AND T.PRO_TYPE = '1' AND T.PROC_DATE BETWEEN  '" + startTim
				+ "' AND '" + endTim + "'";
		if (!plineCode.equals("")) {
			sql += "  AND T.EF_PLINE_CODE ='" + plineCode + "'";
		}
		if (!conFalg.equals("")) {
			sql += " AND T.CONFIRM_FLAG ='" + conFalg + "'";
		}
		sql += " ORDER BY T.LOGS_BEG,T.LOGS_END ASC";
		return this.getData(sql);
	}

	/**
	 * 停机查询（按炉号）
	 * 
	 * @param stoveNo
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryPlan2(String stoveNo, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryPlan");
		sql += " AND T.PRO_TYPE = '2' AND T.STOVE_NO = '" + stoveNo + "'";
		if (!plineCode.equals("")) {
			sql += "  AND T.EF_PLINE_CODE ='" + plineCode + "'";
		}
		sql += " ORDER BY T.LOGS_BEG,T.LOGS_END ASC";
		return this.getData(sql);
	}
	
	/**
	 * 停机查询
	 * @param startTim
	 * @param endTim
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryPlan3(String startTim, String endTim, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryPlan");
		sql += " AND T.PRO_TYPE = '2' AND T.PROC_DATE BETWEEN  '" + startTim
		+ "' AND '" + endTim + "'";
		if (!plineCode.equals("")) {
			sql += "  AND T.EF_PLINE_CODE ='" + plineCode + "'";
		}
		sql += " ORDER BY T.EF_PLINE_CODE,T.LOGS_BEG,T.LOGS_END ASC";
		return this.getData(sql);
	}
	
	/**
	 * 调度数据汇总
	 * @param startTim
	 * @param endTim
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryPlanCollect(String startTim, String endTim, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryPlanCollect");
		String sql1 = "  AND T1.PROC_DATE BETWEEN  '" + startTim
		+ "' AND '" + endTim + "'";
		String sql2 = "  AND T.PROC_DATE BETWEEN  '" + startTim
		+ "' AND '" + endTim + "'";
		if (!plineCode.equals("")) {
			sql1 += "  AND T1.EF_PLINE_CODE ='" + plineCode + "'";
			sql2 += "  AND T.EF_PLINE_CODE ='" + plineCode + "'";
		}
		sql = sql.replace("#SOMETHING1#", sql1).replace("#SOMETHING2#", sql2);
		return this.getData(sql);
	}

	/***
	 * 查询炼钢日志表停机记录
	 * 
	 * @param parm
	 * @param plineCode
	 * @param startTim
	 * @param endTim
	 * @return
	 */
	public CoreReturnObject doStopQuery(String startTim, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doStopQuery");
		if (!startTim.equals("")) {
			sql += " AND T.PROC_DATE='" + startTim + "'";
		}
		if (!plineCode.equals("")) {
			sql += "  AND T.PLINE_CODE ='" + plineCode + "'";
		}
		sql += " ORDER BY T.LOGS_BEG ASC";
		return this.getData(sql);
	}

	/***
	 * 查询调度生产运行停机时间
	 * 
	 * @param parm
	 * @param plineCode
	 * @param startTim
	 * @param endTim
	 * @return
	 */
	public CoreReturnObject doMinutesQuery(String startTim, String days) {
		String sql = "";
		try {

			// = CoreXmlSqlParsersFactory
			// .getSql("FrmStlControlLog.doMinutesQuery");
			int day = Integer.parseInt(days);
			sql += "SELECT";
			for (int i = 0; i < day; i++) {
				SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
				Date strat;
				String systime = "";

				strat = dateFormat.parse(startTim + String.valueOf(i + 1));
				systime = dateFormat.format(strat);
				String dayd = "DAY" + String.valueOf(i + 1);
				sql += "  (SELECT NVL(SUM(CEIL((TO_DATE(T.LOGS_END, 'YYYY-MM-DD HH24:MI') - "
						+ "TO_DATE(T.LOGS_BEG, 'YYYY-MM-DD HH24:MI')) * 24*60)),0) SUMMINUTES "
						+ "FROM MIL_CONTROL_LOG T WHERE T.PROC_DATE = '"
						+ systime
						+ "'"
						+ " AND T.PLINE_CODE = T1.PLINE_CODE "
						+ " AND T.CONFIRM_FLAG = '1'  "
						+ " AND T.PRO_TYPE = '2') " + dayd + ",";
			}
			sql += " (SELECT T2.PLINE_NAME FROM COM_BASE_PLINE T2 "
					+ " WHERE T2.PLINE_CODE = T1.PLINE_CODE  "
					+ " AND T2.VALIDFLAG = '1') PLINE_NAME";
			sql += " FROM MIL_CONTROL_LOG T1  WHERE T1.BAL_YEAR_MONTH = '"
					+ startTim + "' "
					+ " AND T1.CONFIRM_FLAG = '1'  GROUP BY T1.PLINE_CODE";

			sql += " ORDER BY PLINE_NAME ASC";
		} catch (ParseException e) {
			e.printStackTrace();
		}

		return this.getData(sql);
	}

	/***
	 * 查询生产详情
	 * 
	 * @param startTim
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryPlanPro(String startTim, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryPlanPro");
		if (!startTim.equals("")) {
			sql += "  AND T.PROC_DATE = '" + startTim + "'";
		}
		if (!plineCode.equals("")) {
			sql += "  AND T.EF_PLINE_CODE ='" + plineCode + "'";
		}
		sql += " ORDER BY T.LOGS_BEG,T.LOGS_END ASC";
		return this.getData(sql);
	}

	/***
	 * 查询月生产详情
	 * 
	 * @param startTim
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doMonthQueryPlanPro(String startTim,
			String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryPlanPro");
		if (!startTim.equals("")) {
			sql += "  AND T.BAL_YEAR_MONTH = '" + startTim + "'";
		}
		if (!plineCode.equals("")) {
			sql += "  AND T.EF_PLINE_CODE ='" + plineCode + "'";
		}
		sql += " ORDER BY T.LOGS_BEG,T.LOGS_END ASC";
		return this.getData(sql);
	}

	/***
	 * 统计生产班实绩
	 * 
	 * @param parm
	 * @param plineCode
	 * @param startTim
	 * @param endTim
	 * @return
	 */
	public CoreReturnObject doQueryActual(String startTim, String bc,
			String plineCode) {
		String sql = "";
		sql = CoreXmlSqlParsersFactory.getSql("FrmStlControlLog.doQueryActual");
		return this.getData(sql, new Object[] { startTim, bc, startTim, bc,
				plineCode, startTim, bc, plineCode, startTim, bc, plineCode,
				startTim, bc, plineCode, startTim, bc, plineCode });
	}

	/***
	 * 统计生产日实绩
	 * 
	 * @param parm
	 * @param plineCode
	 * @param startTim
	 * @param endTim
	 * @return
	 */
	public CoreReturnObject doQueryDayActual(String startTim, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryDayActual");
		return this.getData(sql, new Object[] { startTim, startTim, plineCode,
				startTim, plineCode, startTim, plineCode, startTim, plineCode,
				startTim, plineCode });
	}

	/***
	 * 统计生产月实绩
	 * 
	 * @param parm
	 * @param plineCode
	 * @param startTim
	 * @param endTim
	 * @return
	 */
	public CoreReturnObject doQueryMonthActual(String startTim, String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryMonthActual");
		return this.getData(sql, new Object[] { startTim, startTim, plineCode,
				startTim, plineCode, startTim, plineCode, startTim, plineCode,
				startTim, plineCode });
	}

	/**
	 * 查询停机分类
	 * 
	 * @param sortCode
	 * @return
	 */
	public CoreReturnObject getComBaseInfo(String sortCode) {
		return this.getDataBySqlID("FrmStlControlLog.getComBaseInfo",
				new Object[] { sortCode });
	}

	/***
	 * 新增炼钢日志
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject addMilControlLog(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String addsql2 = "";
			String addsql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.addMilControlLog");// 新增日志

			for (String str : parm) {
				StlControlLogEntity matZcTity = EntityTool.getEntityByJSONStr(
						str, StlControlLogEntity.class);
				addsql2 = EntityTool.fillSqlByEntity(addsql, matZcTity);
				PreparedStatement pstaControl = connection
						.prepareStatement(addsql2);
				pstaControl.addBatch();
				pstaControl.executeBatch();
				pstaControl.close();
			}
			cro.setV_errMsg("新增成功!");
			connection.commit();
		} catch (Exception e) {
			cro.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 一键处理新增炼钢日志
	 * 
	 * @param parm
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public CoreReturnObject oneKeyProcesMilControlLog(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String addsql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.OneKeyProcesMilControlLog");// 一键处理新增炼钢日志
			PreparedStatement pstaControl = connection.prepareStatement(addsql);
			for (int i = 0; i < parm.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) parm.get(i);
				String stratime = list.get(0);
				String endtime = list.get(1);
				String name = list.get(2);
				String bc = list.get(3);
				String bz = list.get(4);

				pstaControl.setObject(1, stratime);
				pstaControl.setObject(2, endtime);
				pstaControl.setObject(3, systime);
				pstaControl.setObject(4, name);
				pstaControl.setObject(5, bc);
				pstaControl.setObject(6, bz);
				pstaControl.setObject(7, list.get(5));
				pstaControl.setObject(8, "2");
				pstaControl.setObject(9, "500603");
				pstaControl.setObject(10, "50060302");
				pstaControl.setObject(11, "5006030201");
				pstaControl.setObject(12, list.get(6));
				pstaControl.addBatch();
			}
			pstaControl.executeBatch();
			pstaControl.close();

			// 修改MIL_CONTROL_LOG :Proc_Date
			String updateSql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.UpdataPROCDATE");
			PreparedStatement ps = connection.prepareStatement(updateSql);
			ps.executeUpdate();
			ps.close();

			cro.setV_errMsg("一键处理成功!");
			connection.commit();
		} catch (Exception e) {
			cro.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 一键处理修改炼钢日志
	 * 
	 * @param parm
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public CoreReturnObject oneKeyUpdateMilControlLog(ArrayList<Object> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		// Date now = new Date();
		// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		// String systime = dateFormat.format(now);
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String addsql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.OneKeyUpdateMilControlLog");// 一键处理修改炼钢日志
			PreparedStatement pstaControl = connection.prepareStatement(addsql);
			for (int i = 0; i < parm.size(); i++) {
				ArrayList<String> list = (ArrayList<String>) parm.get(i);
				// String stratime = list.get(0);
				String endtime = list.get(2);
				// String name = list.get(3);
				// String bc = list.get(4);
				// String bz = list.get(5);
				//               
				pstaControl.setObject(1, endtime);
				pstaControl.setObject(2, list.get(7));
				pstaControl.addBatch();
			}
			pstaControl.executeBatch();

			cro.setV_errMsg("一键处理成功!");
			connection.commit();
		} catch (Exception e) {
			cro.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/**
	 * 修改调度日志维护第一条数据时间
	 * 
	 * @param logsEnd
	 * @param ControlId
	 * @return
	 */
	public CoreReturnObject updateOneDate(String logsEnd, String ControlId) {
		String sql = "";
		sql = "UPDATE STL_CONTROL_LOG T SET T.LOGS_BEG = '" + logsEnd
				+ "' WHERE T.CONTROL_ID = '" + ControlId + "'";
		return this.setData(sql);
	}

	/***
	 * 修改调度日志
	 * 
	 * @param parm
	 * @param stationId
	 * @param colGroup
	 * @param colOrder
	 * @return
	 */
	public CoreReturnObject updateMilControlLog(ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmm");
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateSql2 = "";
			String updateSql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.updateControlLog");// 修改调度日志
			for (String str : parm) {
				StlControlLogEntity matZcTity = EntityTool.getEntityByJSONStr(
						str, StlControlLogEntity.class);
				updateSql2 = EntityTool.fillSqlByEntity(updateSql, matZcTity);
				PreparedStatement updatePsta = connection
						.prepareStatement(updateSql2);
				updatePsta.addBatch();
				updatePsta.executeBatch();
				updatePsta.close();
			}
			cro.setV_errMsg("修改成功!");
			connection.commit();
		} catch (Exception e) {
			cro.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 删除停机调度日志
	 * 
	 * @param parm
	 * @param stationId
	 * @param colGroup
	 * @param colOrder
	 * @return
	 */
	public CoreReturnObject deleteMilControlLog(
			ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateSql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.DeleteControlLog");// 删除调度日志
			PreparedStatement updatePsta = connection
					.prepareStatement(updateSql);
			for (String str : parm) {
				StlControlLogEntity matZcTity = EntityTool.getEntityByJSONStr(
						str, StlControlLogEntity.class);
				updatePsta.setObject(1, matZcTity.getControlId());
				updatePsta.addBatch();
			}
			updatePsta.executeBatch();
			cro.setV_errMsg("删除成功!");
			connection.commit();
		} catch (Exception e) {
			cro.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 确认
	 * 
	 * @param parm
	 * @param count
	 * @param list1
	 * @return
	 */
	public CoreReturnObject confirmMilControlLog(
			ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateSql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.confirmMilControlLog");// 修改确认
			PreparedStatement updatePsta = connection
					.prepareStatement(updateSql);

			String updatePLN_ORDER_ZG_S = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.updatePlnOrder"); // 修改PLN_ORDER_ZG_S表数据
			PreparedStatement updatePlnOrder = connection
					.prepareStatement(updatePLN_ORDER_ZG_S);

			for (String str : parm) {
				StlControlLogEntity matZcTity = EntityTool.getEntityByJSONStr(
						str, StlControlLogEntity.class);
				updatePsta.setObject(1, matZcTity.getConfirmName());
				updatePsta.setObject(2, matZcTity.getStoveNo());
				updatePsta.setObject(3, matZcTity.getPlineCode());
				updatePsta.setObject(4, matZcTity.getEfPlineCode());
				updatePsta.addBatch();
			}

			updatePsta.executeBatch();
			// updatePlnOrder.executeBatch();

			cro.setV_errMsg("确认成功!");
			connection.commit();
		} catch (Exception e) {
			cro.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 取消确认
	 * 
	 * @param parm
	 * @param count
	 * @param list1
	 * @return
	 */
	public CoreReturnObject upConfirmMilControlLog(
			ArrayList<String> parm) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			String updateSql = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.UpConfirmMilControlLog");// 取消确认
			PreparedStatement updatePsta = connection
					.prepareStatement(updateSql);

			String updatePLN_ORDER_ZG_S = CoreXmlSqlParsersFactory
					.getSql("FrmStlControlLog.updatePlnOrderBack"); // 取消确认时，修改PLN_ORDER_ZG_S表数据
			PreparedStatement updatePlnOrder = connection
					.prepareStatement(updatePLN_ORDER_ZG_S);

			for (String str : parm) {
				StlControlLogEntity matZcTity = EntityTool.getEntityByJSONStr(
						str, StlControlLogEntity.class);
				updatePsta.setObject(1, matZcTity.getStoveNo());
				updatePsta.setObject(2, matZcTity.getPlineCode());
				updatePsta.setObject(3, matZcTity.getEfPlineCode());
				updatePsta.addBatch();
			}
			// updatePlnOrder.executeBatch();
			updatePsta.executeBatch();

			cro.setV_errMsg("取消确认成功!");
			connection.commit();
		} catch (Exception e) {
			cro.setV_errMsg(e.getMessage());
			if (connection != null) {
				try {
					cro.setV_errMsg(e.getMessage());
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/**
	 * 获取修改后的时间
	 * 
	 * @param beginTime
	 * @param day
	 * @param hours
	 * @param minutes
	 * @return
	 */
	public static Date dateAddSecond(Date beginTime, int day, int hours,
			int minutes) {
		Calendar rightNow = Calendar.getInstance();
		rightNow.setTime(beginTime);
		rightNow.add(Calendar.DAY_OF_YEAR, day);
		rightNow.add(Calendar.HOUR, hours);
		rightNow.add(Calendar.MINUTE, minutes);
		Date dt = rightNow.getTime();
		return dt;
	}

	/**
	 * 两个时间相差距离多少天多少小时多少分
	 * 
	 * @param str1
	 *            时间参数 1 格式：1990-01-01 12:00
	 * @param str2
	 *            时间参数 2 格式：2009-01-01 12:00
	 * @return long[] 返回值为：{天, 时, 分}
	 */
	public static long[] getDistanceTimes(String str1, String str2) {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		Date one;
		Date two;
		long day = 0;
		long hour = 0;
		long min = 0;
		// long sec = 0;
		try {
			one = df.parse(str1);
			two = df.parse(str2);
			long time1 = one.getTime();
			long time2 = two.getTime();
			long diff;
			// if (time1 < time2) {
			// diff = time2 - time1;
			// }
			// else {
			diff = time2 - time1;
			// }
			day = diff / (24 * 60 * 60 * 1000);
			hour = (diff / (60 * 60 * 1000) - day * 24);
			min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60);
			// sec = (diff/1000-day*24*60*60-hour*60*60-min*60);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		long[] times = { day, hour, min };
		return times;
	}

	/**
	 * 查询产线
	 * 
	 * @param plineCode
	 * @return
	 */
	public CoreReturnObject doQueryPlineName(String plineCode) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmStlControlLog.doQueryPlineName");
		return this.getData(sql, new Object[] { plineCode });
	}

}
