package com.steering.mes.signature;

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

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.common.StringTool;
import com.steering.mes.zgmil.entity.MilPlanEntity3;
import com.steering.mes.zgmil.entity.QcmZgJugdeApplyEntity;

public class FrmScrapStoveApplyDescion extends DBCommon {

	/***
	 * 查询整炉废数据(轧管)
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject doQueryMata(ArrayList<String> parm) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmScrapStoveApplyDescion.doQueryMata");
		return this.getData(sql, new Object[] { parm.get(1), parm.get(0),
				parm.get(2) ,parm.get(1), parm.get(0),
				parm.get(2)});
	}

	/**
	 * 查询整炉废数据(炼钢)
	 * @param parm
	 * @return
	 */
	public CoreReturnObject doQueryMataLG(ArrayList<String> parm) {

		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmScrapStoveApplyDescion.doQueryMataLG");
		return this.getData(sql, new Object[] {  parm.get(0),parm.get(1),
				parm.get(2) });
	}
	/***
	 * 查询白条信息
	 * 
	 * @param parm
	 * @return
	 */
	public CoreReturnObject doQueryBTMata(ArrayList<String> parm) {
		String sql = CoreXmlSqlParsersFactory
				.getSql("FrmScrapStoveApplyDescion.doQueryBTMata");
		return this.getData(sql, new Object[] { parm.get(1), parm.get(0),
				parm.get(2) });
	}

	/***
	 * 查询整炉废、白条信息
	 * 
	 * @param jugeNo
	 * @return
	 */
	public CoreReturnObject doQueryQcmMata(ArrayList<String> parm) {
		return this.getDataBySqlID("FrmScrapStoveApplyDescion.doQueryQcmMata",
				new Object[] { parm.get(0), parm.get(2) });
	}
	
	/**
	 * 查询整炉废信息（炼钢)
	 * @param parm
	 * @return
	 */
	public CoreReturnObject doQueryQcmMataLG(ArrayList<String> parm) {
		return this.getDataBySqlID("FrmScrapStoveApplyDescion.doQueryQcmMataLG",
				new Object[] { parm.get(0), parm.get(2) });
	}

	/***
	 * 整炉废申请判定
	 * 
	 * @param milPlanTity
	 * @return
	 */
	public CoreReturnObject doDecisionScrap(ArrayList<String> parmList,
			String userName) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		Date now = new Date();
		/*SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat df = new SimpleDateFormat("yyyyMM");
		String systime = dateFormat.format(now);*/
		String yearMoth = ""; //改25号结转
		String jugdeApplyNo = "";// 判定单号
		String inputCount = "";// 投料支
		String inputWeight = "";// 投料吨

		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			for (String str : parmList) {
				MilPlanEntity3 milPtity = EntityTool.getEntityByJSONStr(str,
						MilPlanEntity3.class);
				QcmZgJugdeApplyEntity qcmTity = new QcmZgJugdeApplyEntity();
				yearMoth = StringTool.GetBalYear(now,StringTool.GetSupplyUnit(milPtity.getPlineCode())); //改25号结转
				String insertQcmZcSql = CoreXmlSqlParsersFactory
						.getSql("FrmScrapStoveApplyDescion.doDecisionScrap");
				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.jugdeApplyNo");// 生成判定单号
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPtity.getPlineCode());
				psta.setString(2, "801401");
				// psta.setString(3, milPtity.getPlineCode());
				rs = psta.executeQuery();
				if (rs.next()) {
					jugdeApplyNo = rs.getString("JUGDE_APPLY_CODE");
				}
				rs.close();
				psta.close();

				sql = CoreXmlSqlParsersFactory
						.getSql("FrmScrapStoveApplyDescion.SelectScrapInput");// 查询投料支吨
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPtity.getJudgeStoveNo().replaceFirst("-.*", ""));
				rs = psta.executeQuery();
				if (rs.next()) {
					inputCount = rs.getString("INPUT_COUNT");
					inputWeight = rs.getString("INPUT_WEIGHT");
				}
				rs.close();
				psta.close();

				qcmTity.setJugdeApplyCode(jugdeApplyNo);
				qcmTity.setJudgeStoveNo(milPtity.getJudgeStoveNo().replaceAll("-.*", ""));
				qcmTity.setJudgeStoveNoSeq(milPtity.getJudgeStoveNo());
				qcmTity.setProducname(milPtity.getVarieties());
				qcmTity.setSteelname(milPtity.getSteelname());
				qcmTity.setSpecName(milPtity.getPipeSize().replace("*", "x"));
				qcmTity.setModelDesc(milPtity.getBuckleType());
				qcmTity.setStdStyleDesc(milPtity.getStdStyleDesc());
				qcmTity.setPlineCode(milPtity.getPlineCode());
				if (milPtity.getPlineCode().equals("C008")) {
					qcmTity.setBelongCode("002001016003");
					qcmTity.setBelongName("250机组");
					qcmTity.setBelongCodeJugde("002001016003");
					qcmTity.setBelongNameJugde("250机组");
					qcmTity.setPlineName("250机组");
				} else if (milPtity.getPlineCode().equals("C009")) {
					qcmTity.setBelongCode("002001016002");
					qcmTity.setBelongName("258机组");
					qcmTity.setBelongCodeJugde("002001016002");
					qcmTity.setBelongNameJugde("258机组");
					qcmTity.setPlineName("258机组");

				} else if (milPtity.getPlineCode().equals("C010")) {
					qcmTity.setBelongCode("002001017003");
					qcmTity.setBelongName("168机组");
					qcmTity.setBelongCodeJugde("002001017003");
					qcmTity.setBelongNameJugde("168机组");
					qcmTity.setPlineName("168机组");
				} else if (milPtity.getPlineCode().equals("C017")) {
					qcmTity.setBelongCode("002001018003");
					qcmTity.setBelongName("460机组");
					qcmTity.setBelongCodeJugde("002001018003");
					qcmTity.setBelongNameJugde("460机组");
					qcmTity.setPlineName("460机组");
				}else if (milPtity.getPlineCode().equals("C072")) {
					qcmTity.setBelongCode("002023018001");
					qcmTity.setBelongName("天淮508机组");
					qcmTity.setBelongCodeJugde("002023018001");
					qcmTity.setBelongNameJugde("天淮508机组");
					qcmTity.setPlineName("天淮508机组");
				}
				qcmTity.setValidflag("20");
				qcmTity.setActCount("0");
				qcmTity.setActTheoryWeight("0");
				qcmTity.setInputCount(inputCount);
				qcmTity.setInputWeight(inputWeight);
				qcmTity.setOutputCount(inputCount);
				qcmTity.setOutputWeight(inputWeight);
				qcmTity.setIsAllScrap("1");
				qcmTity.setApplyName(userName);
				qcmTity.setTarget(milPtity.getTarget());
				qcmTity.setCrafNo(milPtity.getImpProcess());
				qcmTity.setProOrderId(milPtity.getProPlanId());
				qcmTity.setGxPlanNo(milPtity.getGxPlanNo());
				qcmTity.setBalYearMonth(yearMoth);
				qcmTity.setProcessStatus(milPtity.getProcessStatus());
				qcmTity.setBatchNo("001");
				qcmTity.setBatchGroudNo("001");
				qcmTity.setLotNo(milPtity.getLotNo());
				qcmTity.setProOrderNo(milPtity.getContractNo());
				qcmTity.setGradename(milPtity.getGradename());
				qcmTity.setStdName(milPtity.getRollStandrad());
				qcmTity.setApplyFlag("0");
				qcmTity.setJudgeResultCode("40740705");
				qcmTity.setJudgeResult("废品");
				qcmTity.setJudgeMaker(userName);


				insertQcmZcSql = EntityTool.fillSqlByEntity(insertQcmZcSql,
						qcmTity);
				psta = connection.prepareStatement(insertQcmZcSql);
				psta.executeUpdate();
				psta.close();

				String updateProcess = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.insertMilProcess");// 更新进程表mil_processes数据
				PreparedStatement updateMilProcess = connection
						.prepareStatement(updateProcess);

				// 更新进程表mil_processes数据
				updateMilProcess.setString(1, milPtity.getJudgeStoveNo());
				updateMilProcess.setString(2, milPtity.getLotNo());
				updateMilProcess.setString(3, milPtity.getPlineCode());
				updateMilProcess.setString(4, milPtity.getProPlanId());
				updateMilProcess.setString(5, milPtity.getGxPlanNo());
				updateMilProcess.addBatch();
				updateMilProcess.executeBatch();

				String updatePlanStatus = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.updatePlanStatus");// 更新炉计划状态
				PreparedStatement updatePlanStatusPst = connection
						.prepareStatement(updatePlanStatus);
				updatePlanStatusPst.setString(1, "40"); // 关闭炉计划
				updatePlanStatusPst.setString(2, milPtity.getProPlanId());
				updatePlanStatusPst.setString(3, milPtity.getGxPlanNo());
				updatePlanStatusPst.setString(4, milPtity.getJudgeStoveNo());
				updatePlanStatusPst.addBatch();
				updatePlanStatusPst.executeBatch();
			}
			cro.setV_errMsg("送判成功!");
			connection.commit();

		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 撤销整炉废
	 * 
	 * @param qcmTity
	 * @return
	 */
	public CoreReturnObject cancelScrapMata(String qcmTity) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务
			QcmZgJugdeApplyEntity qcmEntity = EntityTool.getEntityByJSONStr(
					qcmTity, QcmZgJugdeApplyEntity.class);
			if (qcmEntity.getIsAllScrap().equals("白条")) {
				qcmEntity.setIsAllScrap("2");
			} else if (qcmEntity.getIsAllScrap().equals("整炉废")) {
				qcmEntity.setIsAllScrap("1");
			}
			String deleteScrapSql = CoreXmlSqlParsersFactory
					.getSql("FrmScrapStoveApplyDescion.cancelScrapMata");
			deleteScrapSql = EntityTool.fillSqlByEntity(deleteScrapSql,
					qcmEntity);
			psta = connection.prepareStatement(deleteScrapSql);
			psta.executeUpdate();
			psta.close();

			if (qcmEntity.getIsAllScrap().equals("2")) {
				qcmEntity
						.setJugdeApplyCode("B" + qcmEntity.getJugdeApplyCode());
				String deleteScrapSqlS = CoreXmlSqlParsersFactory
						.getSql("FrmScrapStoveApplyDescion.cancelScrapMata");
				deleteScrapSqlS = EntityTool.fillSqlByEntity(deleteScrapSqlS,
						qcmEntity);
				psta = connection.prepareStatement(deleteScrapSqlS);
				psta.executeUpdate();
				psta.close();

				String updateProcess = CoreXmlSqlParsersFactory
						.getSql("FrmInOnlineStore.insertMilProcess");// 更新进程表mil_processes数据
				PreparedStatement updateMilProcess = connection
						.prepareStatement(updateProcess);

				// 更新进程表mil_processes数据
				updateMilProcess.setString(1, qcmEntity.getJudgeStoveNo());
				updateMilProcess.setString(2, qcmEntity.getLotNo());
				updateMilProcess.setString(3, qcmEntity.getPlineCode());
				updateMilProcess.setString(4, qcmEntity.getProOrderId());
				updateMilProcess.setString(5, qcmEntity.getGxPlanNo());
				updateMilProcess.addBatch();
				updateMilProcess.executeBatch();

			}
			cro.setV_errMsg("撤销成功!");
			connection.commit();

		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/***
	 * 打白条判定
	 * 
	 * @param milPlanTity
	 * @return
	 */
	public CoreReturnObject insertWhiteBank(ArrayList<String> parmList,
			String userName) {
		CoreReturnObject cro = new CoreReturnObject();
		Connection connection = this.getDao(CoreConstantData.sysbeanstr)
				.getConnection();
		String sql = "";
		PreparedStatement psta = null;
		ResultSet rs = null;
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat df = new SimpleDateFormat("yyyyMM");
		String systime = dateFormat.format(now);
		// String yearMoth = df.format(now);
		String yearMoth = "";
		String yearMothB = "";
		String jugdeApplyNo = "";// 判定单号
		int scapCount = 0;// 所有废品支吨
		int inputCount = 0;// 投料支
		double inputWeight = 0.000;// 投料吨
		int sawCutNum = 0;// 分切数
		int count = 0;
		try {
			connection.setAutoCommit(false); // 取消自动提交事务

			QcmZgJugdeApplyEntity qcmTity = new QcmZgJugdeApplyEntity();
			String insertQcmZcSql = CoreXmlSqlParsersFactory
					.getSql("FrmScrapStoveApplyDescion.doDecisionScrap");// 本月正
			String insertQcmZcBSql = CoreXmlSqlParsersFactory
					.getSql("FrmScrapStoveApplyDescion.doDecisionScrap");// 下月负

			for (String str : parmList) {
				MilPlanEntity3 milPtity = EntityTool.getEntityByJSONStr(str,
						MilPlanEntity3.class);
				sql = CoreXmlSqlParsersFactory
						.getSql("insertWhiteBank.selectInstore");// 查询是否下线点结炉
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPtity.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					count = Integer.parseInt(rs.getString("ACOUNT"));
				}
				rs.close();
				psta.close();
				if (count > 0) {

				} else {
					cro.setV_errMsg("下线点未结炉,不允许打白条!");
					return cro;
				}

				sql = CoreXmlSqlParsersFactory
						.getSql("FrmScrapStoveApplyDescion.selectMaxBalYearMoth");// 查询最大结转年月
				psta = connection.prepareStatement(sql);
				rs = psta.executeQuery();
				if (rs.next()) {
					yearMoth = rs.getString("BAL_YEAR_MONTH");
					yearMothB = rs.getString("B_BAL_YEAR_MONTH");
				}
				rs.close();
				psta.close();

				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.jugdeApplyNo");// 生成判定单号
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPtity.getPlineCode());
				psta.setString(2, "801401");
				// psta.setString(3, milPtity.getPlineCode());
				rs = psta.executeQuery();
				if (rs.next()) {
					jugdeApplyNo = rs.getString("JUGDE_APPLY_CODE");
				}
				rs.close();
				psta.close();

				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.SelectPlanSaw");// 查询分切数
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPtity.getJudgeStoveNo());
				rs = psta.executeQuery();
				if (rs.next()) {
					sawCutNum = Integer.parseInt(rs.getString("SAW_NUM"));
				}
				rs.close();
				psta.close();

				sql = CoreXmlSqlParsersFactory
						.getSql("doDecision.SelectScrapCount");// 查询所有废品支
				sql = EntityTool.fillSqlByEntity(sql, milPtity);
				psta = connection.prepareStatement(sql);
				rs = psta.executeQuery();
				if (rs.next()) {
					scapCount = Integer.parseInt(rs.getString("ACT_COUNT"));
				}
				rs.close();
				psta.close();

				ArrayList<String> matNoList = new ArrayList<String>();
				sql = CoreXmlSqlParsersFactory
						.getSql("FrmScrapStoveApplyDescion.SelectScrapInput1");// 查询投料支吨
				psta = connection.prepareStatement(sql);
				psta.setString(1, milPtity.getJudgeStoveNo());
				psta.setString(2, String.valueOf(Math.ceil((Integer
						.parseInt(milPtity.getActCount()) + scapCount)
						/ sawCutNum)));
				rs = psta.executeQuery();
				while (rs.next()) {
					matNoList.add(rs.getString("M_MAT_NO"));
				}
				rs.close();
				psta.close();

				inputCount = matNoList.size();
				for (int j = 0; j < matNoList.size(); j++) {
					sql = CoreXmlSqlParsersFactory
							.getSql("doDecision.SelectPortWgt");// 查询判定支+废品支

					psta = connection.prepareStatement(sql);
					psta.setString(1, matNoList.get(j));
					psta.setString(2, milPtity.getJudgeStoveNo());
					rs = psta.executeQuery();
					if (rs.next()) {
						inputWeight = inputWeight
								+ Double.parseDouble(rs
										.getString("INPUT_WEIGHT"));
					}
					rs.close();
					psta.close();
				}

				qcmTity.setJugdeApplyCode(jugdeApplyNo);
				qcmTity.setJudgeStoveNo(milPtity.getJudgeStoveNo().replaceAll("-.*", ""));
				qcmTity.setProducname(milPtity.getVarieties());
				qcmTity.setSteelname(milPtity.getSteelname());
				qcmTity.setSpecName(milPtity.getPipeSize().replace("*", "x"));
				qcmTity.setModelDesc(milPtity.getBuckleType());
				qcmTity.setStdStyleDesc(milPtity.getStdStyleDesc());
				qcmTity.setPlineCode(milPtity.getPlineCode());
				if (milPtity.getPlineCode().equals("C008")) {
					qcmTity.setBelongCode("002001016003");
					qcmTity.setBelongName("250机组");
					qcmTity.setBelongCodeJugde("002001016003");
					qcmTity.setBelongNameJugde("250机组");
					qcmTity.setPlineName("250机组");
				} else if (milPtity.getPlineCode().equals("C009")) {
					qcmTity.setBelongCode("002001016002");
					qcmTity.setBelongName("258机组");
					qcmTity.setBelongCodeJugde("002001016002");
					qcmTity.setBelongNameJugde("258机组");
					qcmTity.setPlineName("258机组");

				} else if (milPtity.getPlineCode().equals("C010")) {
					qcmTity.setBelongCode("002001017003");
					qcmTity.setBelongName("168机组");
					qcmTity.setBelongCodeJugde("002001017003");
					qcmTity.setBelongNameJugde("168机组");
					qcmTity.setPlineName("168机组");
				} else if (milPtity.getPlineCode().equals("C017")) {
					qcmTity.setBelongCode("002001018003");
					qcmTity.setBelongName("460机组");
					qcmTity.setBelongCodeJugde("002001018003");
					qcmTity.setBelongNameJugde("460机组");
					qcmTity.setPlineName("460机组");
				}
				qcmTity.setValidflag("20");
				qcmTity.setActCount(milPtity.getActCount());
				qcmTity.setActWeight(milPtity.getActWeight());
				qcmTity.setActTheoryWeight(milPtity.getActWeight());
				qcmTity.setInputCount(String.valueOf(Math.ceil(Double
						.parseDouble((milPtity.getActCount()))
						/ sawCutNum)));
				qcmTity.setInputWeight(milPtity.getInputWeight());
				qcmTity.setOutputCount(String.valueOf(Math.ceil(Double
						.parseDouble((milPtity.getActCount()))
						/ sawCutNum)));
				qcmTity.setOutputWeight(milPtity.getInputWeight());
				qcmTity.setIsAllScrap("2");
				qcmTity.setApplyName(userName);
				qcmTity.setTarget(milPtity.getTarget());
				qcmTity.setCrafNo(milPtity.getImpProcess());
				qcmTity.setProOrderId(milPtity.getProPlanId());
				qcmTity.setGxPlanNo(milPtity.getGxPlanNo());
				qcmTity.setBalYearMonth(yearMoth);
				qcmTity.setProcessStatus(milPtity.getProcessStatus());
				qcmTity.setBatchNo("001");
				qcmTity.setBatchGroudNo("001");
				qcmTity.setLotNo(milPtity.getLotNo());
				qcmTity.setProOrderNo(milPtity.getContractNo());
				qcmTity.setGradename(milPtity.getGradename());
				qcmTity.setStdName(milPtity.getRollStandrad());
				qcmTity.setApplyFlag("0");
				qcmTity.setJudgeResultCode("40740701");
				qcmTity.setJudgeResult("合格");
				qcmTity.setJudgeMaker(userName);
				if(qcmTity.getTarget().equals("A"))
				{
					qcmTity.setJudgeTolresultCode("40740701");
					qcmTity.setJudgeTolresult("合格");
					qcmTity.setJudgeTolmark(userName);
					qcmTity.setJudgeTolresultTime(systime);
				}else
				{
					qcmTity.setJudgeTolresultCode("40740701");
					qcmTity.setJudgeTolresult("合格");
					qcmTity.setJudgeTolmark(userName);
					qcmTity.setJudgeTolresultTime("");
				}

				insertQcmZcSql = EntityTool.fillSqlByEntity(insertQcmZcSql,
						qcmTity);
				psta = connection.prepareStatement(insertQcmZcSql);
				psta.executeUpdate();

				psta.close();

				qcmTity.setJugdeApplyCode("B" + jugdeApplyNo);
				qcmTity.setActCount("-" + milPtity.getActCount());
				qcmTity.setActWeight("-" + milPtity.getActWeight());
				qcmTity.setActTheoryWeight("-" + milPtity.getActWeight());
				qcmTity.setInputCount("-"
						+ String.valueOf(Math.ceil(Double.parseDouble((milPtity
								.getActCount()))
								/ sawCutNum)));
				qcmTity.setInputWeight("-"
						+ String.valueOf(milPtity.getInputWeight()));
				qcmTity.setOutputCount("-"
						+ String.valueOf(Math.ceil(Double.parseDouble((milPtity
								.getActCount()))
								/ sawCutNum)));
				qcmTity.setOutputWeight("-"
						+ String.valueOf(milPtity.getInputWeight()));
				qcmTity.setBalYearMonth(getBalYearMoth(yearMothB));

				insertQcmZcBSql = EntityTool.fillSqlByEntity(insertQcmZcBSql,
						qcmTity);
				psta = connection.prepareStatement(insertQcmZcBSql);
				psta.executeUpdate();

				psta.close();

			}

			cro.setV_errMsg("送判成功!");
			connection.commit();

		} catch (SQLException e) {
			System.out.println(e.getMessage());
			if (connection != null) {
				try {
					connection.rollback(); // 回滚事务
				} catch (Exception e2) {
				}
			}
		} finally {
			try {
				if (connection != null && !connection.isClosed()) {
					connection.close();
				}
			} catch (Exception e2) {
			}
		}
		return cro;
	}

	/**
	 * 生成最大年月下一年月
	 * 
	 * @param yearMoth
	 * @return
	 */
	private String getBalYearMoth(String yearMoth) {
		String year = "";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
		SimpleDateFormat sdfS = new SimpleDateFormat("yyyyMM");
		try {
			Date date = sdf.parse(yearMoth);
			Calendar calender = Calendar.getInstance();
			calender.setTime(date);
			calender.add(Calendar.MONTH, 1);
			year = sdfS.format(calender.getTime());
		} catch (ParseException e) {
			e.printStackTrace();
		}

		return year;

	}
}
