/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2020-02-17
 * 描述            ：小时能源实绩
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.tcp.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import market.Com.mapper.PbModelDbMapper;
import market.Com.pb.DoubleUtil;
import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Mes.Dev.mapper.TcpElectricitrcollectMapper;
import market.Mes.Dev.vo.TcpElectricitrcollect;
import market.tcp.mapper.RtdEnergyHourMapper;
import market.tcp.mapper.RtdPingzhengMapper;
import market.tcp.mapper.RtdSuanxiMapper;
import market.tcp.mapper.RtdTuihuoluMapper;
import market.tcp.service.RtdEnergyHourService;
import market.tcp.vo.RtdEnergyHour;
import market.tcp.vo.RtdPingzheng;
import market.tcp.vo.RtdSuanxi;
import market.tcp.vo.RtdTuihuolu;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hnshituo.basic.service.impl.BaseServiceImpl;
import com.hnshituo.basic.spring.remoting.annotation.RemoteService;

@Service("RtdEnergyHourService")
@RemoteService(path="RtdEnergyHourService")
public class RtdEnergyHourServiceImpl extends BaseServiceImpl<RtdEnergyHour,Object> implements RtdEnergyHourService {
	
	
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public void doInsertRtdHour() throws Exception{
		Date now = new Date();
		//删除当天的小时归集数据
		String wrk_date = new SimpleDateFormat("yyyy-MM-dd").format(now);
		//String wrk_date = "2021-10-03";
		String sql = "delete from rtd_energy_hour t where t.wrk_date = '"+wrk_date+"'";
		this.getMapper(PbModelDbMapper.class).doUpdateSql(sql);
		
		doInsertRtdHourByPingZheng(wrk_date);
		
		doInsertRtdHourByTuihuo(wrk_date);				
		
		doInsertRtdHourBySuanXi(wrk_date);
	}
	
	/**
	 * 平整获取小时数据
	 */
	public void doInsertRtdHourByPingZheng(String wrk_date){
		String sql = "select to_number(to_char(t.systime,'HH24')) hour, max(t.systime) systime, "
				+ " max(t.guolvqi_steam_f_acc) guolvqi_steam_f_acc, max(t.mogun_air_f_acc) mogun_air_f_acc,"
				+ " max(t.pingzheng_air_f_acc) pingzheng_air_f_acc, max(t.pingzheng_steam_f_acc) pingzheng_steam_f_acc,"
				+ " max(t.tuoyan_water_f_acc) tuoyan_water_f_acc, max(t.zhaji_air_f_acc) zhaji_air_f_acc,"
				+ " max(t.zhaji_steam_f_acc) zhaji_steam_f_acc, max(t.zhajituoyan_water_f_acc) zhajituoyan_water_f_acc "
				+ " from rtd_pingzheng t "
				+ " where to_char(t.systime, 'yyyy-MM-dd') = '"+wrk_date+"' "
				+ " group by to_char(t.systime,'HH24') "
				+ " order by to_char(t.systime,'HH24')";
		List<RtdPingzheng> pzList = this.getMapper(RtdEnergyHourMapper.class).doQueryRtdPingzhengHour(sql);
		if (CollectionUtils.isEmpty(pzList)) {
			return;
		}
		for (RtdPingzheng ePz : pzList) {
			long i = ePz.getHour();
			//获取开始数据
			RtdPingzheng sPz = null;
			if (i == 0) {
				//获取今天之前最后的一条采集数据
				String condition = "to_char(systime,'yyyy-MM-dd') < '"+wrk_date+"'";
				List<RtdPingzheng> pList = this.getMapper(RtdPingzhengMapper.class).findWithCondition(null, condition, "systime desc", 0, 1);
				if (CollectionUtils.isNotEmpty(pList)) {					
					sPz = pList.get(0);
				}
			}else {	
				//sPz = pzList.get(pzList.indexOf(ePz)-1);
				sPz = pzList.get((int) (i-1));
			}
			//平整过滤器蒸汽流量
			RtdEnergyHour rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			Double check_value = ePz.getGuolvqi_steam_f_acc()-sPz.getGuolvqi_steam_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("平整过滤器蒸汽流量");
			rtdEnergyHour.setItem_name("平整过滤器蒸汽流量");
			rtdEnergyHour.setMch_code("M0007");
			rtdEnergyHour.setStart_time(sPz.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sPz.getGuolvqi_steam_f_acc());
			rtdEnergyHour.setEnd_value(ePz.getGuolvqi_steam_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());//采集结束时间				
			rtdEnergyHour.setShijianduan(ePz.getHour());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);	
			
			//平整压缩空气流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=ePz.getPingzheng_air_f_acc()-sPz.getPingzheng_air_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(ePz.getPingzheng_air_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());
			rtdEnergyHour.setItem_code("平整压缩空气流量");
			rtdEnergyHour.setItem_name("平整压缩空气流量");
			rtdEnergyHour.setMch_code("M0007");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sPz.getSystime());
			rtdEnergyHour.setStart_value(sPz.getPingzheng_air_f_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}				
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//平整压缩蒸汽流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=ePz.getPingzheng_steam_f_acc()-sPz.getPingzheng_steam_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(ePz.getPingzheng_steam_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());
			rtdEnergyHour.setItem_code("平整压缩蒸汽流量");
			rtdEnergyHour.setItem_name("平整压缩蒸汽流量");
			rtdEnergyHour.setMch_code("M0007");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sPz.getSystime());
			rtdEnergyHour.setStart_value(sPz.getPingzheng_steam_f_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//平整脱盐水流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=ePz.getTuoyan_water_f_acc()-sPz.getTuoyan_water_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(ePz.getTuoyan_water_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());
			rtdEnergyHour.setItem_code("平整脱盐水流量");
			rtdEnergyHour.setItem_name("平整脱盐水流量");
			rtdEnergyHour.setMch_code("M0007");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sPz.getSystime());
			rtdEnergyHour.setStart_value(sPz.getTuoyan_water_f_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//磨辊间压缩空气流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=ePz.getMogun_air_f_acc()-sPz.getMogun_air_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setStart_time(sPz.getSystime());
			rtdEnergyHour.setStart_value(sPz.getMogun_air_f_acc());
			rtdEnergyHour.setEnd_value(ePz.getMogun_air_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());
			rtdEnergyHour.setItem_code("磨辊间压缩空气流量");
			rtdEnergyHour.setItem_name("磨辊间压缩空气流量");
			rtdEnergyHour.setMch_code("M0008");
			rtdEnergyHour.setShijianduan(i);
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//轧机压缩空气流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=ePz.getZhaji_air_f_acc()-sPz.getZhaji_air_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(ePz.getZhaji_air_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());
			rtdEnergyHour.setItem_code("轧机压缩空气流量");
			rtdEnergyHour.setItem_name("轧机压缩空气流量");
			rtdEnergyHour.setMch_code("M0008");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sPz.getSystime());
			rtdEnergyHour.setStart_value(sPz.getZhaji_air_f_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//轧机压缩蒸汽流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=ePz.getZhaji_steam_f_acc()-sPz.getZhaji_steam_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(ePz.getZhaji_steam_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());
			rtdEnergyHour.setItem_code("轧机压缩蒸汽流量");
			rtdEnergyHour.setItem_name("轧机压缩蒸汽流量");
			rtdEnergyHour.setMch_code("M0008");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sPz.getSystime());
			rtdEnergyHour.setStart_value(sPz.getZhaji_steam_f_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//轧机脱盐水流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=ePz.getZhajituoyan_water_f_acc()-sPz.getZhajituoyan_water_f_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(ePz.getZhajituoyan_water_f_acc());
			rtdEnergyHour.setEnd_time(ePz.getSystime());
			rtdEnergyHour.setItem_code("轧机脱盐水流量");
			rtdEnergyHour.setItem_name("轧机脱盐水流量");
			rtdEnergyHour.setMch_code("M0008");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sPz.getSystime());
			rtdEnergyHour.setStart_value(sPz.getZhajituoyan_water_f_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
		}
	}
	
	/**
	 * 退火获取小时数据
	 */
	public void doInsertRtdHourByTuihuo(String wrk_date){
		String sql = "select to_number(to_char(t.create_time,'HH24')) hour,max(t.create_time) create_time,"
				+ " max(t.cog_acc) cog_acc,max(t.bs_h2_acc) bs_h2_acc,max(t.bs_n2_acc) bs_n2_acc,"
				+ " max(t.ebn_h2_acc) ebn_h2_acc,max(t.ebn_n2_acc) ebn_n2_acc,"
				+ " max(t.water_cyc) water_cyc,max(t.water_new) water_new "
				+ " from rtd_tuihuolu t "
				+ " where to_char(t.create_time, 'yyyy-MM-dd') = '"+wrk_date+"' "
				+ " group by to_char(t.create_time,'HH24') "
				+ " order by to_char(t.create_time,'HH24')";
		List<RtdTuihuolu> thList = this.getMapper(RtdEnergyHourMapper.class).doQueryRtdTuiHuoHour(sql);
		if (CollectionUtils.isEmpty(thList)) {
			return;
		}		
		for (RtdTuihuolu eTh : thList) {
			long i = eTh.getHour();
			//获取开始数据
			RtdTuihuolu sTh = null;
			if (i == 0) {
				//获取今天之前最后的一条采集数据
				String condition = "to_char(create_time,'yyyy-MM-dd') < '"+wrk_date+"'";
				List<RtdTuihuolu> pList = this.getMapper(RtdTuihuoluMapper.class).findWithCondition(null, condition, "create_time desc", 0, 1);
				if (CollectionUtils.isNotEmpty(pList)) {					
					sTh = pList.get(0);
				}
			}else {
				sTh = thList.get((int) (i-1));
			}
			
			RtdEnergyHour rtdEnergyHour=new RtdEnergyHour();
			//宝信H2累计
			Double check_value=eTh.getBs_h2_acc()-sTh.getBs_h2_acc();
			rtdEnergyHour.setWrk_date(wrk_date);
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(eTh.getBs_h2_acc());
			rtdEnergyHour.setEnd_time(eTh.getCreate_time());
			rtdEnergyHour.setItem_code("宝信H2");
			rtdEnergyHour.setItem_name("宝信H2");
			rtdEnergyHour.setMch_code("M0005");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sTh.getCreate_time());
			rtdEnergyHour.setStart_value(sTh.getBs_h2_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//宝信 N2
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=eTh.getBs_n2_acc()-sTh.getBs_n2_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(eTh.getBs_n2_acc());
			rtdEnergyHour.setEnd_time(eTh.getCreate_time());
			rtdEnergyHour.setItem_code("宝信 N2");
			rtdEnergyHour.setItem_name("宝信 N2");
			rtdEnergyHour.setMch_code("M0005");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sTh.getCreate_time());
			rtdEnergyHour.setStart_value(sTh.getBs_n2_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
		  
			
			//焦气累计
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=eTh.getCog_acc()-sTh.getCog_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(eTh.getCog_acc());
			rtdEnergyHour.setEnd_time(eTh.getCreate_time());
			rtdEnergyHour.setItem_code("焦气");
			rtdEnergyHour.setItem_name("焦气");
			rtdEnergyHour.setMch_code("M0005");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sTh.getCreate_time());
			rtdEnergyHour.setStart_value(sTh.getCog_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//EBN H2累计
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=eTh.getEbn_h2_acc()-sTh.getEbn_h2_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(eTh.getEbn_h2_acc());
			rtdEnergyHour.setEnd_time(eTh.getCreate_time());
			rtdEnergyHour.setItem_code("EBN H2");
			rtdEnergyHour.setItem_name("EBN H2");
			rtdEnergyHour.setMch_code("M0005");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sTh.getCreate_time());
			rtdEnergyHour.setStart_value(sTh.getEbn_h2_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			
			//EBN N2累计
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=eTh.getEbn_n2_acc()-sTh.getEbn_n2_acc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(eTh.getEbn_n2_acc());
			rtdEnergyHour.setEnd_time(eTh.getCreate_time());
			rtdEnergyHour.setItem_code("EBN N2");
			rtdEnergyHour.setItem_name("EBN N2");
			rtdEnergyHour.setMch_code("M0005");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sTh.getCreate_time());
			rtdEnergyHour.setStart_value(sTh.getEbn_n2_acc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);			
			
			//循环水
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=eTh.getWater_cyc()-sTh.getWater_cyc();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(eTh.getWater_cyc());
			rtdEnergyHour.setEnd_time(eTh.getCreate_time());
			rtdEnergyHour.setItem_code("循环水");
			rtdEnergyHour.setItem_name("循环水");
			rtdEnergyHour.setMch_code("M0005");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sTh.getCreate_time());
			rtdEnergyHour.setStart_value(sTh.getWater_cyc());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);				
			
			//补水
			rtdEnergyHour=new RtdEnergyHour();
			if (i == 21 && "2021-04-23".equals(wrk_date)) {
				System.out.println("出bug了");
			}
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value=eTh.getWater_new()-sTh.getWater_new();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setEnd_value(eTh.getWater_new());
			rtdEnergyHour.setEnd_time(eTh.getCreate_time());
			rtdEnergyHour.setItem_code("补水");
			rtdEnergyHour.setItem_name("补水");
			rtdEnergyHour.setMch_code("M0005");
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setStart_time(sTh.getCreate_time());
			rtdEnergyHour.setStart_value(sTh.getWater_new());
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("1");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
		}
	}
	
	/**
	 * 酸洗获取小时数据
	 */
	public void doInsertRtdHourBySuanXi(String wrk_date){
		
		String sql = "select to_number(to_char(t.systime,'HH24')) hour,max(t.systime) systime,"
				+ " max(t.fs_a) fs_a, max(t.qdyskq_a) qdyskq_a,max(t.tys_a) tys_a,"
				+ " max(t.xfs_a) xfs_a,max(t.xs_a) xs_a,max(t.yskq_a) yskq_a,"
				+ " max(t.zq_a) zq_a,max(t.zss_a) zss_a "
				+ " from rtd_suanxi t "
				+ " where to_char(t.systime, 'yyyy-MM-dd') = '"+wrk_date+"' "
				+ " group by to_char(t.systime,'HH24') "
				+ " order by to_char(t.systime,'HH24')";
		List<RtdSuanxi> sxList = this.getMapper(RtdEnergyHourMapper.class).doQueryRtdSuanxiHour(sql);
		if (CollectionUtils.isEmpty(sxList)) {
			return;
		}
		
		for (RtdSuanxi eSx : sxList) {
			long i = eSx.getHour();
			//获取开始数据
			RtdSuanxi sSx = null;
			if (i == 0) {
				//获取今天之前最后的一条采集数据
				String condition = "to_char(systime,'yyyy-MM-dd') < '"+wrk_date+"'";
				List<RtdSuanxi> sList = this.getMapper(RtdSuanxiMapper.class).findWithCondition(null, condition, "systime desc", 0, 1);
				if (CollectionUtils.isNotEmpty(sList)) {					
					sSx = sList.get(0);
				}
			}else {
				sSx = sxList.get((int) (i-1));
			}
			
			//废水累积
			RtdEnergyHour rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			Double check_value = eSx.getFs_a()-sSx.getFs_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("废酸流量");
			rtdEnergyHour.setItem_name("废酸流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getFs_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getFs_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//夜
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//气动压缩空气
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = eSx.getQdyskq_a()-sSx.getQdyskq_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("气动压缩空气流量");
			rtdEnergyHour.setItem_name("气动压缩空气流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getQdyskq_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getQdyskq_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//酸洗脱盐水
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = eSx.getTys_a()-sSx.getTys_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("脱盐水流量");
			rtdEnergyHour.setItem_name("脱盐水流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getTys_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getTys_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//循环水
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = eSx.getXfs_a()-sSx.getXfs_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("循环水流量");
			rtdEnergyHour.setItem_name("循环水流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getXfs_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getXfs_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//新酸
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = eSx.getXs_a()-sSx.getXs_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("新酸流量");
			rtdEnergyHour.setItem_name("新酸流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getXs_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getXs_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//酸洗压缩空气
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = eSx.getYskq_a()-sSx.getYskq_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("压缩空气流量");
			rtdEnergyHour.setItem_name("压缩空气流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getYskq_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getYskq_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//酸洗蒸汽
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = eSx.getZq_a()-sSx.getZq_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("蒸汽流量");
			rtdEnergyHour.setItem_name("蒸汽流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getZq_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getZq_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//酸洗再生酸
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = eSx.getZss_a()-sSx.getZss_a();
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("再生酸流量");
			rtdEnergyHour.setItem_name("再生酸流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getZss_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getZss_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
			//酸洗线循环水累积流量
			rtdEnergyHour=new RtdEnergyHour();
			rtdEnergyHour.setWrk_date(wrk_date);
			check_value = (eSx.getSxxxfs_a()==null?0d:eSx.getSxxxfs_a())-(sSx.getSxxxfs_a()==null?0d:sSx.getSxxxfs_a());
			rtdEnergyHour.setCheck_value(DoubleUtil.round(check_value, 2));
			rtdEnergyHour.setItem_code("酸洗线循环水累积流量");
			rtdEnergyHour.setItem_name("酸洗线循环水累积流量");
			rtdEnergyHour.setMch_code("M0010");
			rtdEnergyHour.setStart_time(sSx.getSystime());//采集开始时间
			rtdEnergyHour.setStart_value(sSx.getSxxxfs_a());
			rtdEnergyHour.setEnd_time(eSx.getSystime());//采集结束时间				
			rtdEnergyHour.setEnd_value(eSx.getSxxxfs_a());
			rtdEnergyHour.setShijianduan(i);
			rtdEnergyHour.setPrd_line("酸洗");//产线
			if(i>=0 && i<8){
				rtdEnergyHour.setWrk_ord("1");//晚班
			}else if(i>=8 && i<16){
				rtdEnergyHour.setWrk_ord("2");//早班
			}else if(i>=16 && i<24){
				rtdEnergyHour.setWrk_ord("3");//中班
			}
			this.getMapper(RtdEnergyHourMapper.class).insert(rtdEnergyHour);
			
		}
	}
	
	@SuppressWarnings("rawtypes")
	public ResultModel doQuaryTcpEle(CommonPage<TcpElectricitrcollect> cp){
		ResultModel rm = new ResultModel();
		String wrk_date = cp.getMemo2();//时间2020-03-20
		String mch_code = cp.getMemo1();//机组 M0001
		List<HashMap> hmList = new ArrayList<>();
		if ("M0001".equals(mch_code)) {//4mm
			hmList = this.getMapper(TcpElectricitrcollectMapper.class).doQuaryTcpElemm(mch_code,
					wrk_date+" 00:00:00",//当日0点
					wrk_date+" 23:59:59",//当日的24点
					wrk_date.substring(0, 7)+"-01 00:00:00","0006");//当月的0点
		}else if ("M0002".equals(mch_code)) {//12mm
			hmList = this.getMapper(TcpElectricitrcollectMapper.class).doQuaryTcpElemm(mch_code,
					wrk_date+" 00:00:00",//当日0点
					wrk_date+" 23:59:59",//当日的24点
					wrk_date.substring(0, 7)+"-01 00:00:00","0001");//当月的0点
		}else if ("M0003".equals(mch_code)) {//3mm
			hmList = this.getMapper(TcpElectricitrcollectMapper.class).doQuaryTcpElemm(mch_code,
					wrk_date+" 00:00:00",//当日0点
					wrk_date+" 23:59:59",//当日的24点
					wrk_date.substring(0, 7)+"-01 00:00:00","0005");//当月的0点
		}else if ("M0004".equals(mch_code)) {//退火
			hmList = this.getMapper(TcpElectricitrcollectMapper.class).doQuaryTcpEleTh(mch_code,
					wrk_date+" 00:00:00",//当日0点
					wrk_date+" 23:59:59",//当日的24点
					wrk_date.substring(0, 7)+"-01 00:00:00");//当月的0点
		}else if ("M0007".equals(mch_code)) {//平整
			hmList = this.getMapper(TcpElectricitrcollectMapper.class).doQuaryTcpElePz(mch_code,
					wrk_date+" 00:00:00",//当日0点
					wrk_date+" 23:59:59",//当日的24点
					wrk_date.substring(0, 7)+"-01 00:00:00");//当月的0点
		}else if ("M0008".equals(mch_code)) {//轧机
			hmList = this.getMapper(TcpElectricitrcollectMapper.class).doQuaryTcpEleZj(mch_code,
					wrk_date+" 00:00:00",//当日0点
					wrk_date+" 23:59:59",//当日的24点
					wrk_date.substring(0, 7)+"-01 00:00:00");//当月的0点
		}else if ("M0010".equals(mch_code)) {//酸洗
			hmList = this.getMapper(TcpElectricitrcollectMapper.class).doQuaryTcpEleSx(mch_code,
					wrk_date+" 00:00:00",//当日0点
					wrk_date+" 23:59:59",//当日的24点
					wrk_date.substring(0, 7)+"-01 00:00:00");//当月的0点
		}
		
				
		rm.setData(hmList);
		rm.setState("200");
		return rm;
	}

	public ResultModel doRtdSetZero(CommonPage<RtdEnergyHour> cp){
		String wrk_date = cp.getMemo1();
		ResultModel rm = new ResultModel();
		//1.获取退火最大值
		RtdTuihuolu th = this.getMapper(RtdEnergyHourMapper.class).doQueryMaxRtdTuihuolu(wrk_date);
		
		//2.获取平整轧机最大值
		RtdPingzheng pz = this.getMapper(RtdEnergyHourMapper.class).doQueryMaxRtdPingzheng(wrk_date);
		
		//3.获取酸洗最大值
		RtdSuanxi sx = this.getMapper(RtdEnergyHourMapper.class).doQueryMaxRtdSuanxi(wrk_date);
		
		//处理清零导致数据为负数的问题
		String condition = "wrk_date = '"+wrk_date+"' and check_value < 0";
		List<RtdEnergyHour> rehList = this.getMapper(RtdEnergyHourMapper.class).findWithCondition(null, condition, "shijianduan", 0, 0);
		if (CollectionUtils.isNotEmpty(rehList)) {
			for (RtdEnergyHour reh : rehList) {
				if ("废酸流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getFs_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("气动压缩空气流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getQdyskq_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("脱盐水流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getTys_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("脱盐水流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getTys_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("循环水流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getXfs_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("新酸流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getXs_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("压缩空气流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getYskq_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("蒸汽流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getZq_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("再生酸流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - sx.getZss_a(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("磨辊间压缩空气流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getMogun_air_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("平整压缩空气流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getPingzheng_air_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("平整压缩蒸汽流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getPingzheng_steam_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("平整过滤器蒸汽流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getGuolvqi_steam_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("平整脱盐水流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getTuoyan_water_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("轧机压缩空气流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getZhaji_air_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("轧机压缩蒸汽流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getZhaji_steam_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("轧机脱盐水流量".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - pz.getZhajituoyan_water_f_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("宝信H2".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - th.getBs_h2_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("宝信 N2".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - th.getBs_n2_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("焦气".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - th.getCog_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("EBN H2".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - th.getEbn_h2_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("EBN N2".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - th.getEbn_n2_acc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("循环水".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - th.getWater_cyc(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}else if ("补水".equals(reh.getItem_name())) {
					reh.setStart_value(DoubleUtil.round(reh.getStart_value() - th.getWater_new(), 2));
					reh.setCheck_value(DoubleUtil.round(reh.getEnd_value() - reh.getStart_value(), 2));
					this.getMapper(RtdEnergyHourMapper.class).doRtdSetZero(reh);
					continue;
				}
			}
		}
		rm.setState("200");
		rm.setMsgInfo("清零成功");
		return rm;
	}


}
