81041
2019-10-31 2edd919b4ae7eb04a766ba034518ab420f4860f9
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
package com.fgkj.actions;
 
import java.lang.reflect.Type;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
 
import com.fgkj.dto.AllModel;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Batt_Maint_Dealarm;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.Task_Batt_Test;
import com.fgkj.dto.User;
import com.fgkj.dto.User_battgroup_baojigroup_usr;
import com.fgkj.dto.User_inf;
import com.fgkj.dto.User_permitgroup_data;
import com.fgkj.dto.User_task;
import com.fgkj.dto.User_task_batt_template;
import com.fgkj.dto.User_task_param;
import com.fgkj.services.User_taskService;
import com.google.gson.reflect.TypeToken;
import com.opensymphony.xwork2.ActionSupport;
import com.sun.xml.internal.ws.wsdl.writer.document.Service;
 
public class User_taskAction extends ActionSupport{
    private User_taskService service=new User_taskService();
    private User_task utask;
    private Task_Batt_Test tbt;
    private Batt_Maint_Dealarm bmd;
    private String param;
    private String result;
    
    //添加作业
    public String add() throws ParseException{
        User_task_param utparam=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(param, User_task_param.class);
        List<BattInf> addlist=ActionUtil.getGson("yyyy-MM-dd").fromJson(result, new TypeToken<List<BattInf>>(){}.getType());
        User_inf uinf=(User_inf)ActionUtil.getSession().getAttribute("user");
        ServiceModel model=new ServiceModel(); 
        if(uinf!=null){
            utparam.setTp_name(uinf.getUId().toString());
            model=service.add(addlist, utparam);
        }
        result=ActionUtil.tojson(model);
        //System.out.println(result);
        return SUCCESS;
    }
    
    //4.1作业管理(修改作业名称,作业使能,作业开始时间,作业提醒次数,作业提醒时间,作业主管提醒使能,确认作业,完成作业,完成作业确认)
      public String update() {
          //System.out.println(result);
          utask=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, User_task.class);
          ServiceModel model=service.update(utask);
          result=ActionUtil.tojson(model);
          return SUCCESS;
      }
      
      //4.1删除指定的作业
      public String delete(){
          utask=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, User_task.class);
          ServiceModel model=service.delete(utask);
          result=ActionUtil.tojson(model);
          return SUCCESS;
      }
    
    //4.1作业管理查询user_task所有信息
    public String serchByCondition(){
        //System.out.println(tbt);
        tbt = ActionUtil.getGson("yyyy-MM-dd").fromJson(result, Task_Batt_Test.class);
        ServiceModel model=service.serchByCondition(tbt);
        result=ActionUtil.tojson(model);
        //System.out.println(result);
        return SUCCESS;
    }
    
    //4.1根据task_id查询user_task_test/user_task_check
    public String serchByInfo(){
        ServiceModel model=service.serchByInfo(utask);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    
    //4.1查询符合条件的电池组信息
    public String serchBattgroup(){
        //System.out.println(bmd);
        List list=service.serchBattgroup(bmd);
        result=ActionUtil.tojson(list);
        //System.out.println(result);
        return SUCCESS;
    }
    
    //0.1查询指定用户的作业信息
    public String serchByUid(){
        User_inf user=(User_inf)ActionUtil.getSession().getAttribute("user"); 
        tbt = ActionUtil.getGson("yyyy-MM-dd").fromJson(result, Task_Batt_Test.class);
        //System.out.println(tbt);
        ServiceModel model=new ServiceModel();
        //System.out.println(user);
        //System.out.println(tbt);
        if(user!=null && tbt!=null){
            tbt.setUinf(user);
            model=service.serchByUid(tbt);
        }
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    
    //0.1作业管理查询user_task所有信息
    public String serchByTask(){
        tbt = ActionUtil.getGson("yyyy-MM-dd").fromJson(result, Task_Batt_Test.class);
        System.out.println(tbt);
        ServiceModel model=service.serchByTask(tbt);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    //4.1根据维护区查询所有的电池组和对应的包机人(模板创建)和维护人员信息以及各类作业对应的电池组信息
    public String serchBytemplate(){
        User_task_batt_template utbt=ActionUtil.getGson("yyyy-MM-dd").fromJson(result, User_task_batt_template.class);
        AllModel model=service.serchBytemplate(utbt);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    
      //4.1由模板添加作业(向utask,utest,ucheck中添加数据)
    public String addBytemplate(){
        AllModel allmodel=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(result, AllModel.class);
        User_inf uinf=(User_inf)ActionUtil.getSession().getAttribute("user");        
        //System.out.println(allmodel.getPmodel());
        allmodel.getAmodel().setData(ActionUtil.getObject(ActionUtil.tojson(allmodel.getAmodel().getData()), new TypeToken<List<BattInf>>(){}.getType()));
        allmodel.getSmodel().setData(ActionUtil.getObject(ActionUtil.tojson(allmodel.getSmodel().getData()), new TypeToken<List<BattInf>>(){}.getType()));
        allmodel.getRmodel().setData(ActionUtil.getObject(ActionUtil.tojson(allmodel.getRmodel().getData()), new TypeToken<List<BattInf>>(){}.getType()));
        allmodel.getUmodel().setData(ActionUtil.getObject(ActionUtil.tojson(allmodel.getUmodel().getData()), new TypeToken<List<BattInf>>(){}.getType()));
        allmodel.getPmodel().setData(ActionUtil.getObject(ActionUtil.tojson(allmodel.getPmodel().getData()),new TypeToken<List<User_task_param>>(){}.getType()));
        
        //System.out.println(allmodel.getPmodel());
        if(uinf!=null && allmodel!=null){
            allmodel.getPmodel().setMsg(uinf.getUId()+"");
        }
        ServiceModel model= new ServiceModel();
        try {
            model= service.addBytemplate(allmodel);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    
 
 
    public User_task getUtask() {
        return utask;
    }
 
    public void setUtask(User_task utask) {
        this.utask = utask;
    }
 
    public Task_Batt_Test getTbt() {
        return tbt;
    }
 
    public void setTbt(Task_Batt_Test tbt) {
        this.tbt = tbt;
    }
 
    public String getResult() {
        return result;
    }
 
    public void setResult(String result) {
        this.result = result;
    }
 
    public Batt_Maint_Dealarm getBmd() {
        return bmd;
    }
 
    public void setBmd(Batt_Maint_Dealarm bmd) {
        this.bmd = bmd;
    }
 
    public void setParam(String param) {
        this.param = param;
    }    
    
    
}