whyclj
2020-07-22 a5729100cb1eaa3584b3a194e46e1b8b52b3ed1a
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
package com.fgkj.services;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
import com.fgkj.actions.ActionUtil;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dao.TestDaoFactory;
import com.fgkj.dao.UtilityFactory;
import com.fgkj.db.DBUtil;
import com.fgkj.db.IDatabaseName;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Page;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.Task_Batt_Test;
import com.fgkj.dto.User_task_change;
 
public class User_task_changeService {
    private ServiceModel model;
    private BaseDAO dao;
    public User_task_changeService() {
        model=new ServiceModel();
        dao=BaseDAOFactory.getBaseDAO(BaseDAO.USER_TASK_CHANGE);
    }
    
    //4.1作业变更申请
    public ServiceModel add(Object obj) {
        Boolean bl=dao.add(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("提交变更申请成功!");
        }
        else{
            model.setMsg("提交变更申请失败!");
        }
        return model;
        
    }
    //4.5作业变更查询(审批)
    public ServiceModel update(Object obj) {
        Boolean bl=dao.update(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("作业审批成功!");
        }
        else{
            model.setMsg("作业审批失败!");
        }
        return model;    
    }
    //4.5作业变更查询(删除记录)
    public ServiceModel delete(Object obj) {
        Boolean bl=dao.del(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("删除记录成功!");
        }
        else{
            model.setMsg("删除记录失败!");
        }
        return model;    
    }
    //4.5作业变更查询
    public ServiceModel serchByCondition(Object obj){
        List<Task_Batt_Test> list=dao.serchByCondition(obj);
        if(list!=null&&list.size()>0){
        for(int i=0;i<list.size();i++){
            
            String Uname=UtilityFactory.UidsToUnames(list.get(i).getUchange().getUsr_id().toString());
            list.get(i).getBinf().setStationName2(Uname);
            
            String Cname=UtilityFactory.UidsToUnames(list.get(i).getUchange().getCopy_uids());
            list.get(i).getBinf().setStationName3(Cname);
            
            String Aname=UtilityFactory.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());
            list.get(i).getBinf().setStationName7(Oname);
            
            String Nname=UtilityFactory.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){
            model.setCode(1);
            model.setData(list);
        }
         // System.out.println(model);        
        return model;
    } 
 
    
    public ServiceModel searchAll(){
        List list=dao.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;
    } 
    public static void main(String[] args) throws ParseException {
        User_task_changeService uservice=new User_task_changeService();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2000-01-01");
        Date date2 = sdf.parse("2020-01-01");
        
        BattInf binf = new BattInf();
        binf.setStationName("");
        binf.setStationName1("");
        binf.setBattGroupId(0);
        binf.setBattGroupName1("");
        binf.setBattProducer("");
        binf.setMonCapStd(0f);
        binf.setMonVolStd(0f);
        
        User_task_change uchange=new User_task_change();
        uchange.setTask_type_id(100);                //作业类型  100:全部
        uchange.setChange_type_id(100);                //作业变更类型
        uchange.setUsr_id(0);                        //作业变更申请人
        uchange.setTask_change_approve_res(100);    //变更审批状态
        uchange.setChange_ask_time(ActionUtil.getSimpDate(date1));
        uchange.setChange_ask_time1(ActionUtil.getSimpDate(date2));
        
        Page page=new Page();
        page.setPageCurr(1);
        page.setPageSize(10);
        
        Task_Batt_Test tbt=new Task_Batt_Test();
        tbt.setBinf(binf);
        tbt.setUchange(uchange);
        tbt.setPage(page);
        
        uservice.serchByCondition(tbt);
    }
}