MulService.java 4.8 KB
package com.service.bkyld;

import java.text.DecimalFormat;

import com.dao.bkyld.YLDDataBase;
import com.dao.dbutil.DataBase;
import com.vo.YLDDataManage;
import com.vo.YLD_mul;
import com.vo.YLD_outline_DataManage;
import com.vo.yld_Sound;

/**
 * 
 * @ClassName: MulService
 * @Description: TODO(得到SHDataManage类型,通过date找到标准算出超标倍数写入SHDataManage返回)
 * @author zhengwei
 * @date 2014-3-3 上午10:54:07
 * @version 1.0
 */
public class MulService extends DataBase {
	private static DecimalFormat format = new DecimalFormat("0.00");

	public YLDDataManage putMUL(YLDDataManage data) {
		YLD_mul mul = new YLDDataBase().getMUL1(data.getDate());
		if(data.getA_outcod().equals("--")||data.getA_outcod().equals("-100")){
			data.setA_outcod("--");
			data.setA_outcod_mul("--");
		}else{
			data.setA_outcod_mul(getmul(Double.parseDouble(data.getA_outcod()), mul.getOut_cod()));
		}
		String date = data.getDate();
		String month = date.split(" ")[0].split("-")[1];
		if (month.equals("12") || month.equals("01") || month.equals("02")
				|| month.equals("03"))
			if(data.getA_outnh4n().equals("--")||data.getA_outnh4n().equals("-100")){
				data.setA_outnh4n("--");
				data.setA_outnh4n_mul("--");
			}else{
				data.setA_outnh4n_mul(getmul(Double.parseDouble(data.getA_outnh4n()),
						mul.getOut_nh4n_1()));
			}
		else
			if(data.getA_outnh4n().equals("--")||data.getA_outnh4n().equals("-100")){
				data.setA_outnh4n("--");
				data.setA_outnh4n_mul("--");
			}else{
				data.setA_outnh4n_mul(getmul(Double.parseDouble(data.getA_outnh4n()),
						mul.getOut_nh4n_2()));
			}
		if(data.getA_outph().equals("--")||data.getA_outph().equals("-100")){
			data.setA_outph("--");
			data.setA_outph_mul("--");
		}else{
			data.setA_outph_mul(getPHmul(Double.parseDouble(data.getA_outph()), mul.getOut_max_ph(),
					mul.getOut_min_ph()));
		}
		new YLDDataBase().updateData(data);
		
		return data;
	}
	public YLD_outline_DataManage putMUL(YLD_outline_DataManage data) {
		data.setA_tp_mul(getmul(data.getA_tp(), "1.0"));
		data.setA_tn_mul(getmul(data.getA_tn(), "20"));
		data.setA_ss_mul(getmul(data.getA_ss(), "20"));
		data.setA_shxyl_mul(getmul(data.getA_shxyl(), "20"));
		data.setA_dzwy_mul(getmul(data.getA_dzwy(), "3"));
		data.setA_syl_mul(getmul(data.getA_syl(), "3"));
		data.setA_ylzbmhxj_mul(getmul(data.getA_ylzbmhxj(), "1"));
		data.setA_sd_mul(getmul(data.getA_sd(), "30"));
		data.setA_fdcjq_mul(getmul(data.getA_fdcjq(), "10000"));
		data.setA_tcd_mul(getmul(data.getA_tcd(), "0.01"));
		data.setA_tcr_mul(getmul(data.getA_tcr(), "0.1"));
		data.setA_ljg_mul(getmul(data.getA_ljg(), "0.05"));
		data.setA_tas_mul(getmul(data.getA_tas(), "0.1"));
		data.setA_tpb_mul(getmul(data.getA_tpb(), "0.1"));
		data.setA_yjg_mul(getmul(data.getA_yjg(), "0"));
		data.setA_jjg_mul(getmul(data.getA_jjg(), "0"));
		new YLDDataBase().updateData(data);
		return data;
	}
	public yld_Sound putMUL(yld_Sound data) {
		data.setSound_n_mul(getmul(data.getSound_n(), "55"));
		data.setSound_s_mul(getmul(data.getSound_s(), "55"));
		data.setSound_w_mul(getmul(data.getSound_w(), "55"));
		data.setSound_e_mul(getmul(data.getSound_e(), "55"));
		data.setSound_n_night_mul(getmul(data.getSound_n_night(), "45"));
		data.setSound_s_night_mul(getmul(data.getSound_s_night(), "45"));
		data.setSound_w_night_mul(getmul(data.getSound_w_night(), "45"));
		data.setSound_e_night_mul(getmul(data.getSound_e_night(), "45"));
		new YLDDataBase();
		YLDDataBase.updataSound2(data);
		return data;
	}
	public static String putMUL2(yld_Sound data) {
		data.setSound_n_mul(getmul(data.getSound_n(), "55"));
		data.setSound_s_mul(getmul(data.getSound_s(), "55"));
		data.setSound_w_mul(getmul(data.getSound_w(), "55"));
		data.setSound_e_mul(getmul(data.getSound_e(), "55"));
		data.setSound_n_night_mul(getmul(data.getSound_n_night(), "45"));
		data.setSound_s_night_mul(getmul(data.getSound_s_night(), "45"));
		data.setSound_w_night_mul(getmul(data.getSound_w_night(), "45"));
		data.setSound_e_night_mul(getmul(data.getSound_e_night(), "45"));
		String sqlString  =  YLDDataBase.updataSound2(data);
		return sqlString;
	}
	private static String getmul(double value, String mul) {
		// double v = Double.valueOf(value);
		double m = Double.valueOf(mul);
		if (m == 0) {
			if (value <= 0)
				return "0";
			else
				return String.valueOf(value);
		} else {
			double re = (value - m) / m;
			if (re <= 0)
				return "0";
			else
				return format.format(re);
		}
	}

	private String getPHmul(double value, String max, String min) {
		// double v = Double.valueOf(value);
		double ma = Double.valueOf(max);
		double mi = Double.valueOf(min);
		if (value > ma)
			return format.format((value - ma) / ma);
		else if (value < mi)
			return format.format((mi - value) / mi);
		else
			return "0";
	}
}