whyclj
2019-10-29 1c0469e45346d464e0c5672ee68f9ecd4fb6be7c
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
package com.fgkj.actions;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Batt_Maint_Dealarm;
import com.fgkj.dto.Batt_User_Permit;
import com.fgkj.dto.Batt_maint_inf;
import com.fgkj.dto.Batt_maint_process;
import com.fgkj.dto.Batt_maintenance_inf;
import com.fgkj.dto.Batttestdata_inf;
import com.fgkj.dto.Page;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_inf;
import com.fgkj.services.Batt_maint_infService;
import com.google.gson.reflect.TypeToken;
import com.opensymphony.xwork2.ActionSupport;
import com.sun.xml.internal.ws.wsdl.writer.document.Service;
 
public class Batt_maint_infAction extends ActionSupport{
    private Batt_maint_infService service=new Batt_maint_infService();
    private Batt_maint_inf bmi;
    private Batt_Maint_Dealarm bd;
    private Batt_User_Permit bup;
    //private BattInf binf;
    private String result;
    private String json;
    
    //2.1电池故障维护记录查询
    public String serchMaint(){
        //System.out.println(bd);
        bd = ActionUtil.getGson("yyyy-MM-dd").fromJson(result, Batt_Maint_Dealarm.class);
        ServiceModel model=service.serchMaint(bd);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    
    // 2.2电池故障处理统计查询
    /*
     * maint_result存放统计方式 
     * fault_caption存放维护区 
     * master_check存放包机人 
     * remark存放品牌
     */
    public String serchByCondition(){
        //System.out.println(bup);
        bup= ActionUtil.getGson("yyyy-MM-dd").fromJson(result, Batt_User_Permit.class);
        List list=service.serchByCondition(bup);        
        result=ActionUtil.tojson(list);
        return SUCCESS;
    }
    
    //0.3查询所有的维护记录(只传page对象)
    public String search(){
        //System.out.println(bd+"$$$$$$$$$$");
        ServiceModel model=service.search();
        result=ActionUtil.tojson(model);
        //System.out.println("......................");
        return SUCCESS;
    }
    
    //0.4电池组故障率
    public String searchAll(){
        ServiceModel model=service.searchAll();
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    
    //0.4/0.8电池组故障率/维护率(最新)
    public String searchByStationName() {
        ServiceModel model=service.searchByStationName(bd);    
        
        result=ActionUtil.tojson(model);
        //System.out.println(result);
        return SUCCESS;
    }
    
    //根据电池组id查询电池的故障信息
    public String searchByBattgroupId(){
        bmi=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, Batt_maint_inf.class);
        ServiceModel model=service.searchByBattgroupId(bmi);
        //System.out.println(bmi);
        result=ActionUtil.tojson(model);
        //System.out.println(result);
        return SUCCESS;
    }
    
    //2.1 电池维护记录查询(编辑记录)
    public String update() {
        bmi=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, Batt_maint_inf.class);
        List<Batt_maint_process> process = ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(json, new TypeToken<List<Batt_maint_process>>(){}.getType());
        ServiceModel model=service.update(bmi,process);
        //System.out.println(bmi);
        result=ActionUtil.tojson(model);
        //System.out.println(result);
        return SUCCESS;
    }
    //2.1 电池维护记录查询(删除记录)
    public String delete() {
        bmi=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, Batt_maint_inf.class);
        ServiceModel model=service.delete(bmi);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    
    public void setBd(Batt_Maint_Dealarm bd) {
        this.bd = bd;
    }
 
    public Batt_Maint_Dealarm getBd() {
        return bd;
    }
 
    public String getResult() {
        return result;
    }
    
 
    public void setResult(String result) {
        this.result = result;
    }
 
    public Batt_User_Permit getBup() {
        return bup;
    }
 
    public void setBup(Batt_User_Permit bup) {
        this.bup = bup;
    }
 
    public Batt_maint_inf getBmi() {
        return bmi;
    }
 
    public void setBmi(Batt_maint_inf bmi) {
        this.bmi = bmi;
    }
 
    public void setJson(String json) {
        this.json = json;
    }
 
    public static void main(String[] args) throws ParseException {
        Batt_maint_infService us = new Batt_maint_infService();
        
        BattInf binf = new BattInf();
        
         binf.setStationName("");
         binf.setStationName1("");
         binf.setBattGroupName("");
         binf.setBattGroupName1(""); 
         binf.setBattProducer("");
         binf.setMonCapStd(100f); binf.setMonVolStd(12f);
         binf.setBattGroupId(0);
        binf.setStationName("");
        binf.setStationName1("");
        //binf.setBattGroupName("");
        binf.setBattGroupId(0);
        binf.setBattGroupName1("");
        binf.setBattProducer("");
        binf.setMonCapStd(0f);
        binf.setMonVolStd(0f);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2000-01-01");
        Date date2 = sdf.parse("2016-07-14");
        binf.setBattProductDate(ActionUtil.getSimpDate(date1));
        binf.setBattProductDate1(ActionUtil.getSimpDate(date2));
        binf.setBattInUseDate(ActionUtil.getSimpDate(date1));
        binf.setBattInUseDate1(ActionUtil.getSimpDate(date2));
 
        /*
          binf.getStationName1(), binf.getStationName(),
          binf.getBattGroupName(), binf.getBattProducer(),
          binf.getBattGroupName1(), binf.getBattProductDate(),
          binf.getBattProductDate1(), binf.getBattInUseDate(),
          binf.getBattInUseDate1(),uinf.getuName()
         */
 
        Batt_maintenance_inf minf = new Batt_maintenance_inf();
        minf.setRemark("100");
        minf.setMaintenance_time(ActionUtil.getSimpDate(date1));
        minf.setMaintenance_time1(ActionUtil.getSimpDate(date2));
 
        Batttestdata_inf tdata = new Batttestdata_inf();
        tdata.setTest_type(0);
        tdata.setRecord_time(ActionUtil.getSimpDate(date1));
        tdata.setRecord_time1(ActionUtil.getSimpDate(date2));
        
        User_inf uinf=new User_inf();
        uinf.setUName("0");
        
        Page p=new Page();
        p.setPageCurr(1);
        p.setPageSize(1);
        
        Batt_Maint_Dealarm bmd = new Batt_Maint_Dealarm();
        bmd.setBinf(binf);
        bmd.setMinf(minf);
        bmd.setTdata(tdata);
        bmd.setPage(p);
        bmd.setUinf(uinf);
        //List list=us.serchMaint(bmd);
        List list=us.serchByCondition(bmd);
        //System.out.println(list);
    }
    
}