MulService.java
4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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";
}
}