whycrzh
2021-01-19 3030b956b209ede9dc218d3c75b50bade8993f1b
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
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.text.ParseException;
import java.util.List;
 
import javax.annotation.Resource;
 
@RequestMapping("userTask")
@RestController
@Api
public class User_taskController{
    @Resource
    private User_taskService service;
 
    //添加作业
    @PostMapping("/")
    public ServiceModel add(@RequestBody User_task_param utparam,@RequestBody List<BattInf> addlist,
                            @RequestBody User_inf uinf) throws ParseException{
        ServiceModel model=new ServiceModel();
        if(uinf!=null){
            utparam.setTp_name(uinf.getuId().toString());
            model=service.add(addlist, utparam);
        }
        
        return model;
    }
    
    //4.1作业管理(修改作业名称,作业使能,作业开始时间,作业提醒次数,作业提醒时间,作业主管提醒使能,确认作业,完成作业,完成作业确认)
    @PutMapping("/")
    public ServiceModel update(@RequestBody User_task utask) {
          ServiceModel model=service.update(utask);
          
          return model;
      }
      
      //4.1删除指定的作业
    @DeleteMapping("/")
      public ServiceModel delete(@RequestBody User_task utask){
          ServiceModel model=service.delete(utask);
          
          return model;
      }
    
    //4.1作业管理查询user_task所有信息
    @GetMapping("byCondition")
    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
    @GetMapping("byInfo")
    public ServiceModel serchByInfo(@RequestBody User_task utask){
        ServiceModel model=service.serchByInfo(utask);
        
        return model;
    }
    
    //4.1查询符合条件的电池组信息
    @GetMapping("battGroup")
    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查询指定用户的作业信息
    @GetMapping("byUid")
    public ServiceModelOnce serchByUid(@RequestBody Task_Batt_Test tbt){
        User_inf user=(User_inf)ActionUtil.getSession().getAttribute("user");
//        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所有信息
    @GetMapping("byTask")
    public ServiceModel serchByTask(@RequestBody Task_Batt_Test tbt){
        ServiceModel model=service.serchByTask(tbt);
        
        return model;
    }
    //4.1根据维护区查询所有的电池组和对应的包机人(模板创建)和维护人员信息以及各类作业对应的电池组信息
    @GetMapping("byTemplate")
    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("byTemplate")
    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;
    }
 
}