perryhsu
2020-10-17 a543f4de1c91ef6f43aace92975c6cf28de23618
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
package com.fgkj.services;
 
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_inf;
import com.fgkj.dto.User_task_param;
import com.fgkj.mapper.impl.User_infMapper;
import com.fgkj.mapper.impl.User_task_paramMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Service
public class User_task_paramService {
 
    @Autowired
    private User_task_paramMapper mapper;
    @Autowired
    private User_infMapper userInfMapper;
    
    //4.2作业参数(新增作业参数)
    public ServiceModel add(Object obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl=mapper.add(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("添加成功!");
        }
        else{
            model.setMsg("添加失败!");
        }
        return model;
        
    }
    //4.2作业参数(修改操作/重命名操作)
    public ServiceModel update(Object obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl=mapper.update(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("修改成功!");
        }
        else{
            model.setMsg("修改失败!");
        }
        return model;    
    }
    
    //4.2作业参数(一次修改多个作业参数)
    public ServiceModel updatePro(Object obj){
        ServiceModel model = new ServiceModel();
        List<User_task_param> list=(List<User_task_param>) obj;
        ArrayList<String> sql_str = new ArrayList<String>();//存放所有的sql语句
        if(list!=null && list.size()>0){
            for(int i=0;i<list.size();i++){
                sql_str.add(mapper.updatePro(list.get(i)));
            }
        }
        //TODO perry待查
        boolean flag=true;
        //boolean flag= DateUtil.makeManualCommit(DBUtil.getConn(), sql_str);
        if(flag){
            model.setCode(1);
            model.setMsg("修改成功");
        }else{
            model.setCode(0);
            model.setMsg("修改失败");
        }
        return model;
    }
    
    //4.2作业参数(删除)
    public ServiceModel delete(Object obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl=mapper.del(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("删除成功!");
        }
        else{
            model.setMsg("删除失败!");
        }
        return model;    
    }
    //4.2根据参数id查基本参数和模板参数
        public ServiceModel serchByCondition(Object obj){
            ServiceModel model = new ServiceModel();
            User_inf uinf=new User_inf();
            List<User_task_param> list=mapper.serchByCondition(obj);
            for (int i=0;i<list.size();i++) {
                String uids=list.get(i).getTp_master_id();
                int uid=Integer.parseInt(uids);
                uinf.setUId(uid);
                List<User_inf> listu=userInfMapper.serchUname(uinf);
                if(listu.size()>0&&listu!=null){
                uids=listu.get(0).getUName();
                }
                list.get(i).setTp_master_id(uids);
            }
//            for(User_task_param u:list){
//                System.out.println(u);
//            }
            if(list!=null && list.size()>0){
                model.setCode(1);
                model.setData(list);
            }
            //System.out.println(model);        
            return model;
        } 
 
   
   //4.2查询所有参数种类
    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);
        }        
        return model;
    } 
    
}