whycrzg
2021-02-02 086b0d677e761bb5d528e6f29232d663af6e83c7
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
package com.fgkj.services;
 
import com.fgkj.dto.*;
import com.fgkj.mapper.TestDaoFactory;
import com.fgkj.mapper.UtilityFactory;
import com.fgkj.mapper.impl.User_infMapper;
import com.fgkj.mapper.impl.User_task_changeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
import javax.annotation.Resource;
@Service
public class User_task_changeService {
 
    @Resource
    private User_task_changeMapper mapper;
    
    //4.1作业变更申请
    public ServiceModel add(User_task_change obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl= null;
        try {
            bl = mapper.add(obj);
        } catch (Exception e) {
            e.printStackTrace();
            model.setMsg("提交变更申请失败!");
            return model;
        }
        if(bl){
            model.setCode(1);
            model.setMsg("提交变更申请成功!");
        }
        else{
            model.setMsg("提交变更申请失败!");
        }
        return model;
        
    }
    //4.5作业变更查询(审批)
    public ServiceModel update(User_task_change obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl= null;
        try {
            bl = mapper.update(obj);
        } catch (Exception e) {
            e.printStackTrace();
            model.setMsg("作业审批失败!");
            return model;
        }
        if(bl){
            model.setCode(1);
            model.setMsg("作业审批成功!");
        }
        else{
            model.setMsg("作业审批失败!");
        }
        return model;    
    }
    //4.5作业变更查询(删除记录)
    public ServiceModel delete(User_task_change obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl=mapper.del(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("删除记录成功!");
        }
        else{
            model.setMsg("删除记录失败!");
        }
        return model;    
    }
 
 
 
    @Resource
    private UtilityFactoryService utilityFactoryService;
    //4.5作业变更查询
    public ServiceModel serchByCondition(Task_Batt_Test bmd) {
        ServiceModel model = new ServiceModel();
        //分页
        PageBean pageBean = bmd.getPageBean();
        PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true);
        List<Task_Batt_Test> list = mapper.serchByCondition(bmd);    //TODO 待测试,数据不足
        System.out.println("list.size() = " + list.size());
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
//                System.out.println("list = " + list.get(i));
//                System.out.println("getUsr_id = " + list.get(i).getUchange().getUsr_id());
                String Uname = utilityFactoryService.UidsToUnames(list.get(i).getUchange().getUsr_id().toString());
                list.get(i).getBinf().setStationName2(Uname);
 
//                String Cname = UtilityFactory.UidsToUnames(list.get(i).getUchange().getCopy_uids());
//                String Cname = userInfMapper.searchUnams(list.get(i).getUchange().getCopy_uids());
                String Cname = utilityFactoryService.UidsToUnames(list.get(i).getUchange().getCopy_uids());
                list.get(i).getBinf().setStationName3(Cname);
 
                String Aname = utilityFactoryService.UidsToUnames(list.get(i).getUchange().getAppoint_uid().toString());
                list.get(i).getBinf().setStationName4(Aname);
                //  System.out.println(Uname+"  "+Cname+"   "+Aname);
                String task_type = TestDaoFactory.getTaskType(list.get(i).getUchange().getTask_type_id());
                list.get(i).getBinf().setStationName5(task_type);
 
                String change_type = TestDaoFactory.getChangeType(list.get(i).getUchange().getChange_type_id());
                list.get(i).getBinf().setStationName6(change_type);
 
//                String Oname = UtilityFactory.UidsToUnames(list.get(i).getUchange().getOld_executor_ids());
                String Oname = utilityFactoryService.UidsToUnames(list.get(i).getUchange().getOld_executor_ids());
                list.get(i).getBinf().setStationName7(Oname);
 
//                String Nname = UtilityFactory.UidsToUnames(list.get(i).getUchange().getNew_executor_ids());
                String Nname = utilityFactoryService.UidsToUnames(list.get(i).getUchange().getNew_executor_ids());
                list.get(i).getBinf().setStationName8(Nname);
 
                String approve_res = TestDaoFactory.getApprove_res(list.get(i).getUchange().getTask_change_approve_res());
                list.get(i).getBinf().setStationName9(approve_res);
            }
        }
//        for (Task_Batt_Test t : list) {
//            System.out.println(t.getBinf());
//        }
        if (list != null && list.size() > 0) {
            PageInfo<Task_Batt_Test> pageInfo = new PageInfo<>(list);
            model.setCode(1);
            model.setData(pageInfo);
        }
        // System.out.println(model);
        return model;
    } 
 
    
    public ServiceModel searchAll(){
        ServiceModel model = new ServiceModel();
        List list=mapper.searchAll();
//        for (Object object : list) {
//            System.out.println(object);
//        }
        //System.out.println(list);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
        }
//      System.out.println(model);        
        return model;
    }
    
}