whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
package com.fgkj.controller;
 
import com.fgkj.util.*;
 
import com.fgkj.dto.*;
import com.fgkj.services.User_taskService;
import com.google.gson.reflect.TypeToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.text.ParseException;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
@RequestMapping("userTask")
@RestController
@Api(tags = "userTask接口")
public class User_taskController{
    @Resource
    private User_taskService service;
 
 
//    ,@RequestBody User_task_param utparam,@RequestBody List<BattInf> addlist, @RequestBody User_inf uinf
    //添加作业
    @PostMapping("/")
    @ApiOperation(notes = "",value="添加作业TODO")
    public ServiceModel add(@RequestBody Map<String,Object> map) throws ParseException{
        ServiceModel model=new ServiceModel();
        try {
            User_task_param utparam = (User_task_param) map.get("utparam");    //TODO 参数未知
            List<BattInf> listbinf = (List<BattInf>) map.get("listbinf");
            User_inf uinf = (User_inf) map.get("uinf");
            if(uinf!=null){
                utparam.setTp_name(uinf.getuId().toString());
                model=service.add(listbinf, utparam);
            }
        } catch (ParseException e) {
            e.printStackTrace();
            model.setMsg("添加失败");
            return model;
        }
 
        return model;
    }
 
    //4.1作业管理(修改作业名称,作业使能,作业开始时间,作业提醒次数,作业提醒时间,作业主管提醒使能,确认作业,完成作业,完成作业确认)
    @PutMapping("/")
    @ApiOperation(notes = "修改作业名称,作业使能,作业开始时间,作业提醒次数,作业提醒时间,作业主管提醒使能,确认作业,完成作业,完成作业确认" +
            "{ \"task_id\": 1000009, \"task_name\": \"\", \"task_enabled\": 0, \"task_start_date\": \"2021-01-18 08:18:59\", \"task_notice_sum\": 0, \"task_notice_starttime\": \"2021-01-18 08:18:59\", \"task_notice_endtime\": \"2021-01-18 08:18:59\", \"task_confirm\": 0, \"task_confirm_date\": \"2021-01-18 08:18:59\", \"task_complete\": 0, \"task_complete_confirm\": 0, \"notice_master_enabled\": 0 }" +
            "",value="作业管理")
    public ServiceModel update(@RequestBody User_task utask) {
          ServiceModel model=service.update(utask);
          
          return model;
      }
      
      //4.1删除指定的作业
    @DeleteMapping("/")
    @ApiOperation(notes = "",value="删除指定的作业")
      public ServiceModel delete(@RequestParam Integer task_id,@RequestParam Integer task_type){
        User_task utask = new User_task();
        utask.setTask_id(task_id);
        utask.setTask_type(task_type);
          ServiceModel model=service.delete(utask);
          
          return model;
      }
 
    //4.1作业管理查询user_task所有信息
    @PostMapping("byCondition")
    @ApiOperation(notes = "{\n" +
            "  \"utask\": {\n" +
            "    \"task_type\": 1,\n" +
            "    \"task_create_date\": \"2001-01-25 08:19:35\",\n" +
            "    \"task_create_date1\": \"2021-01-25 08:19:35\",\n" +
            "    \"task_complete\": 1,\n" +
            "    \"task_complete_date\": \"2001-01-25 08:19:35\",\n" +
            "    \"task_complete_date1\": \"2021-01-25 08:19:35\"\n" +
            "  },\n" +
            "  \"utest\": {\n" +
            "    \"task_usr_ids\": \"1002\",\n" +
            "    \"task_exe_date\": \"2001-01-25 08:19:35\",\n" +
            "    \"task_exe_date1\": \"2021-01-25 08:19:35\"\n" +
            "  },\n" +
            "  \"ulist\": {\n" +
            "    \"uId\": 0\n" +
            "  },\n" +
            "  \"binf\": {\n" +
            "    \"stationName\": \"\",\n" +
            "    \"stationName1\": \"\",\n" +
            "    \"battGroupId\": 0,\n" +
            "    \"battGroupName1\": \"\",\n" +
            "    \"monCapStd\": 0.0,\n" +
            "    \"monVolStd\": 0.0,\n" +
            "    \"battProducer\": \"\"\n" +
            "  },\n" +
            "  \"ucheck\": {\n" +
            "    \"task_id\": 0,\n" +
            "    \"task_exe_date\": \"2021-01-25 08:19:35\",\n" +
            "    \"task_exe_date1\": \"2021-01-25 08:19:35\"\n" +
            "  },\n" +
            "  \"uinf\": {\n" +
            "    \"uId\": 1001\n" +
            "  }\n" +
            "}",value="作业管理查询user_task所有信息")
    public ServiceModel serchByCondition(@RequestBody Task_Batt_Test tbt){
        ServiceModel model=service.serchByCondition(tbt);
        
        //System.out.println(result);
        return model;
    }
    
    //4.1根据task_id查询user_task_test/user_task_check
    @PostMapping("byInfo")
    @ApiOperation(notes = "",value="task_id查询user_task_test/user_task_check")
    public ServiceModel serchByInfo(@RequestParam Integer task_id,@RequestParam Integer task_type){
        User_task utask = new User_task();
        utask.setTask_id(task_id);
        utask.setTask_type(task_type);
        ServiceModel model=service.serchByInfo(utask);
        
        return model;
    }
    
    //4.1查询符合条件的电池组信息
    @PostMapping("battGroup")
    @ApiOperation(notes = "{\n" +
            "  \"binf\": {\n" +
            "    \"stationName\": \"\",\n" +
            "    \"stationName1\": \"\",\n" +
            "    \"battGroupId\": 0,\n" +
            "    \"battGroupName1\": \"电池组1\",\n" +
            "    \"battProductDate\": \"1901-01-18 08:18:59\",\n" +
            "    \"battProductDate1\": \"2021-01-18 08:18:59\",\n" +
            "    \"battInUseDate\": \"1901-01-18 08:18:59\",\n" +
            "    \"battInUseDate1\": \"2021-01-18 08:18:59\",\n" +
            "    \"monVolStd\": 0.0,\n" +
            "    \"monCapStd\": 0.0\n" +
            "\n" +
            "\n" +
            "  },\n" +
            "  \"mainf\": {\n" +
            "    \"maint_done_time\": \"1901-01-18 08:18:59\",\n" +
            "    \"maint_done_time1\": \"2021-01-18 08:18:59\"\n" +
            "  },\n" +
            "  \"uinf\": {\n" +
            "    \"uName\": \"\"\n" +
            "  },\n" +
            "  \"tdata\": {\n" +
            "    \"test_type\": 0,\n" +
            "    \"record_time\": \"1901-01-18 08:18:59\",\n" +
            "    \"record_time1\": \"2021-01-18 08:18:59\"\n" +
            "  }\n" +
            "}",value="查询符合条件的电池组信息")
    public ServiceModel serchBattgroup(@RequestBody Batt_Maint_Dealarm bmd){
        ServiceModel model = new ServiceModel();
 
        List list=service.serchBattgroup(bmd);
        if (list.size()>0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    
    //0.1查询指定用户的作业信息
    @PostMapping("byUid")
    @ApiOperation(notes = "{\n" +
            "  \"utask\": {\n" +
            "    \"task_type\": 0,\n" +
            "    \"task_close_date\": \"2006-12-30 13:26:38\",\n" +
            "    \"task_close_date1\": \"2021-01-19 13:26:38\",\n" +
            "    \"task_complete\": 1\n" +
            "  },\n" +
            "  \"uinf\": {\n" +
            "    \"uId\": 1001\n" +
            "  },\n" +
            "  \"pageBean\": {\n" +
            "    \"pageSize\":12,\n" +
            "    \"pageNum\": 0\n" +
            "  }\n" +
            "}",value="查询指定用户的作业信息")
    public ServiceModelOnce serchByUid(@RequestBody Task_Batt_Test tbt){
        User_inf user=(User_inf)ActionUtil.getUser();
//        User_inf user= new User_inf();
//        user.setuId(1001);
        ServiceModelOnce model=new ServiceModelOnce();
        if(user!=null && tbt!=null){
            tbt.setUinf(user);
            model=service.serchByUid(tbt);
        }
        
        return model;
    }
    
    //0.1作业管理查询user_task所有信息
    @PostMapping("byTask")
    @ApiOperation(notes = "task_type==2 " +
            "{\n" +
            "  \"utask\": {\n" +
            "    \"task_type\": 2,\n" +
            "    \"task_complete\": 1,\n" +
            "    \"task_complete_date\": \"2000-01-20 11:48:46\",\n" +
            "    \"task_complete_date1\": \"2031-01-20 11:48:46\"\n" +
            "  },\n" +
            "  \"binf\": {\n" +
            "    \"stationName\": \"\",\n" +
            "    \"stationName1\": \"\",\n" +
            "    \"battGroupId\": 1000003\n" +
            "  },\n" +
            "  \"ucheck\": {\n" +
            "    \"task_exe_date\": \"2001-01-20 11:48:46\",\n" +
            "    \"task_exe_date1\": \"2021-01-20 11:48:46\"\n" +
            "  },\n" +
            "    \"pageBean\": {\n" +
            "    \"pageSize\": 1,\n" +
            "    \"pageNum\": 0\n" +
            "    }\n" +
            "}" +
            "-------------------------" +
            "task_type!=2 " +
            "{\n" +
            "  \"utask\": {\n" +
            "    \"task_type\": 1,\n" +
            "    \"task_complete\": 1,\n" +
            "    \"task_complete_date\": \"2000-01-20 11:48:46\",\n" +
            "    \"task_complete_date1\": \"2031-01-20 11:48:46\"\n" +
            "  },\n" +
            "  \"utest\": {\n" +
            "    \"task_usr_ids\": \"\",\n" +
            "    \"task_exe_date\": \"2001-01-20 11:48:46\",\n" +
            "    \"task_exe_date1\": \"2031-01-20 11:48:46\"\n" +
            "  },\n" +
            "  \"binf\": {\n" +
            "    \"stationName\": \"太原市\",\n" +
            "    \"stationName1\": \"\",\n" +
            "    \"battGroupId\": 1000003\n" +
            "  },\n" +
            "    \"pageBean\": {\n" +
            "    \"pageSize\": 6,\n" +
            "    \"pageNum\": 0\n" +
            "    }\n" +
            "}",value="作业管理查询user_task所有信息")
    public ServiceModel serchByTask(@RequestBody Task_Batt_Test tbt){
        ServiceModel model=service.serchByTask(tbt);
        
        return model;
    }
    //4.1根据维护区查询所有的电池组和对应的包机人(模板创建)和维护人员信息以及各类作业对应的电池组信息
    @PostMapping("serchBytemplate")
    @ApiOperation(notes = "",value="TODO 维护区查询所有的电池组和对应的包机人(模板创建)和维护人员信息以及各类作业对应的电池组信息")
    public ServiceModel serchBytemplate(@RequestBody User_task_batt_template utbt){
        ServiceModel model=new ServiceModel();
 
        AllModel allModel=service.serchBytemplate(utbt);
 
        model.setCode(1);
        model.setData(allModel);
        return model;
    }
    
      //4.1由模板添加作业(向utask,utest,ucheck中添加数据)
    @PostMapping("addBytemplate")
    @ApiOperation(notes = "",value="TODO由模板添加作业(向utask,utest,ucheck中添加数据)")
    public ServiceModel addBytemplate(@RequestBody AllModel allmodel){
        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) {
            e.printStackTrace();
        }
        
        return model;
    }
 
}