1
81041
2019-06-20 ab3c4acf83f54f8449ca8664c4a2bb79bd30f297
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
package com.fgkj.dao;
 
import java.text.ParseException;
import java.util.Date;
import java.util.List;
 
import com.fgkj.actions.ActionUtil;
import com.fgkj.dao.impl.User_task_user_listImpl;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.User_task;
import com.fgkj.dto.User_task_batt_check;
import com.fgkj.dto.User_task_batt_test;
import com.fgkj.dto.User_task_param;
import com.fgkj.dto.User_task_user_list;
 
public class CreatClass {
    //构造默认的User_task对象<date为执行日期>
    public static User_task CreateUtask(Object obj1,Object obj2) throws ParseException{
        List<BattInf> list=(List) obj1;
        Date date=new Date(); //执行日期   
        if(list!=null&&list.size()>0){
            date=list.get(list.size()-1).getBattProductDate1();
            //System.out.println("date:"+date);
        }
        User_task_param uparam=(User_task_param) obj2;
        User_task utask=new User_task();//存放向User_task表中添加的对象
        //System.out.println(UtilityFactory.CreateTask());
        utask.setTask_id(UtilityFactory.CreateTask());
        utask.setTask_id_ex(UtilityFactory.CreateTask());
        utask.setTask_name(uparam.getTp_taskname()+"1"); 
        utask.setTask_type(uparam.getTp_tasktype());
        utask.setTask_enabled(uparam.getTp_task_enabled());
        utask.setTask_create_date(new Date());  //作业开始时间为当前时间
        //获取任务开始时间(默认时间为binf中的作业执行开始日期)
        utask.setTask_start_date(date);
        //System.out.println(date);
        //获取任务结束时间(默认时间为当执行年的最后一天)
        Date task_close_date=DAOHelper.sdf.parse(ActionUtil.getLastDayOfMonth(ActionUtil.getDateYear(date), 11));
        utask.setTask_close_date(task_close_date);
        
        //向utest/ucheck表中需要添加的个数
        int circle=0;  //每个电池组的根据类型获得的周期数
        int subtask_count=0;//每个电池组的task_count
        int dateRemain=0;//判断subtask_count用到
        for(int i=0;i<list.size();i++){
            Date battInUseDate=list.get(i).getBattInUseDate(); //电池组的使用时间用于判断新老电池
            if(uparam.getTp_tasktype()==0){        
                int judge=ActionUtil.judgeBatt(battInUseDate,date,uparam.getTp_task_battlife_var());//返回1为老电池;0为新电池
                if(judge==1){
                    circle=uparam.getTp_task_battold_test80_month();
                }else{
                    circle=uparam.getTp_task_battyong_test80_month();
                }
                dateRemain=(12-date.getMonth())%circle;
                if(dateRemain==0){
                    subtask_count+=(12-date.getMonth())/circle;
                }else{
                    subtask_count+=(12-date.getMonth())/circle+1;
                }
            }else if(uparam.getTp_tasktype()==1){
                int judge=ActionUtil.judgeBatt(battInUseDate,date,uparam.getTp_task_battlife_var());//返回1为老电池;0为新电池
                if(judge==1){
                    circle=uparam.getTp_task_battold_test40_month();
                }else{
                    circle=uparam.getTp_task_battyong_test40_month();
                }
                dateRemain=(12-date.getMonth())%circle;
                if(dateRemain==0){
                    subtask_count+=(12-date.getMonth())/circle;
                }else{
                    subtask_count+=(12-date.getMonth())/circle+1;
                }
            }else if(uparam.getTp_tasktype()==2){
                circle=uparam.getTp_task_batt_checkcircle_month();    
                dateRemain=(12-date.getMonth())%circle;
                if(dateRemain==0){
                    subtask_count+=(12-date.getMonth())/circle;
                }else{
                    subtask_count+=(12-date.getMonth())/circle+1;
                }
            }else if(uparam.getTp_tasktype()==3){
                circle=uparam.getTp_task_batt_lazhacircle_month();
                dateRemain=(12-date.getMonth())%circle;
                if(dateRemain==0){
                    subtask_count+=(12-date.getMonth())/circle;
                }else{
                    subtask_count+=(12-date.getMonth())/circle+1;
                }
            }
        }
        utask.setSubtask_count(subtask_count);//设置所有的个数
        utask.setTask_notice_sum(uparam.getTp_task_notice_count());
        //获取任务开始时间(默认时间为执行日期+开始时间段)
        Date task_notice_starttime=ActionUtil.getWorkDay(date,uparam.getTp_task_notice_starttime());
        utask.setTask_notice_starttime(task_notice_starttime);
        //获取任务结束时间(默认时间为执行日期+结束时间段)
        Date task_notice_endtime=ActionUtil.getWorkDay(date,uparam.getTp_task_notice_endtime());
        utask.setTask_notice_endtime(task_notice_endtime);
        
        utask.setTask_notice_timeinterval(uparam.getTp_task_notice_time_interval());
        utask.setTask_notice_count(0);//默认为0  <待验证>
        //获取最近提示时间(默认时间为执行日期加上一小时)
        utask.setTask_notice_latesttime(new Date());//默认为当前时间<待验证>
        
        utask.setTask_autoinc_day_count(uparam.getTp_autoinc_daycount());
        utask.setTask_delay_day_count(uparam.getTp_taskdelay_daycount());
        utask.setTask_pass_saturday(uparam.getTp_pass_saturday());
        utask.setTask_pass_sunday(uparam.getTp_pass_sunday());
        utask.setTask_pass_jiejiari(uparam.getTp_pass_jiejiari());
        utask.setTask_confirm(0);    //默认为0
        utask.setTask_confirm_date(new Date());//默认为当前时间
        utask.setTask_complete(0);    //默认为0        
        utask.setTask_complete_date(DAOHelper.sdf.parse("2015-09-01 00:00:00"));//默认完成时间                
        utask.setTask_complete_confirm(0);        //默认为0        
        utask.setTask_complete_confirm_date(DAOHelper.sdf.parse("2015-09-01 00:00:00"));//默认确认时间                
        utask.setNotice_master_enabled(uparam.getTp_notice_master_enabled());    //通知主管使能    
        utask.setNotice_master(0);//默认为0??????                
        utask.setNote("备注");
        
        return utask;
    }
 
    //构造默认的User_task_user_list对象
    public static User_task_user_list CreateUlist(Object obj,String id,int type){
        User_task utask=(User_task) obj;
        User_task_user_list ulist=new User_task_user_list();
        ulist.setTask_id(utask.getTask_id());
        //System.out.println(id);
        ulist.setUId(Integer.parseInt(id));//默认为admin(1001)
        ulist.setUsr_type(type);    //1:代表主管;2:代表指派人
        return ulist;
    }
 
    
    //构造默认的User_task_batt_check对象
    public static User_task_batt_check CreateUcheck(Object obj1,Object obj2,int monthOdd,int dayOdd) throws ParseException{
        User_task_batt_check ucheck=new User_task_batt_check();
        BattInf binf=(BattInf) obj1;
        Date date=binf.getBattProductDate1();
        User_task utask=(User_task) obj2;
        ucheck.setTask_id(utask.getTask_id());
        if(binf.getStationIp()!=null){
            ucheck.setTask_usr_ids(binf.getStationIp());//执行人
        }else{
            ucheck.setTask_usr_ids("0");//执行人
        }
        
        ucheck.setBattGroupId(binf.getBattGroupId());
        ucheck.setTask_enabled(1);//默认为1
        
        //获取任务开始时间(默认时间为当前月2号的0点)
        Date task_exe_date=DAOHelper.sdf.parse(ActionUtil.getDayTime(ActionUtil.getDateYear(date), ActionUtil.getDateMonth(date)+monthOdd-1,dayOdd,1));//2号的0点
        ucheck.setTask_exe_date(task_exe_date); 
        //获取任务结束时间(默认时间为当前月2号的23点)
        Date task_close_date=DAOHelper.sdf.parse(ActionUtil.getDayTime(ActionUtil.getDateYear(date), ActionUtil.getDateMonth(date)+monthOdd-1,dayOdd,4));//2号的23点
        ucheck.setTask_close_date(task_close_date);
        
        ucheck.setTest_complete(0);//默认为0
        ucheck.setTest_completetime(DAOHelper.sdf.parse("2015-09-01 00:00:00"));
        
        ucheck.setBatt_clean_done(0);
        ucheck.setBatt_clean_done_result("");
        ucheck.setBatt_clean_done_recheck(0);
        ucheck.setBatt_clean_done_recheck_result("");
        ucheck.setBatt_clean_done_recheck_check(0);
        ucheck.setBatt_clean_done_recheck_check_result("");
        
        
        ucheck.setBattvol_tempe_done(0);
        ucheck.setBattvol_tempe_done_result("");
        ucheck.setBattvol_tempe_done_recheck(0);
        ucheck.setBattvol_tempe_done_recheck_result("");
        ucheck.setBattvol_tempe_done_recheck_check(0);
        ucheck.setBattvol_tempe_done_recheck_check_result("");
    
        
        ucheck.setBattfault_check_done(0);
        ucheck.setBattfault_check_done_result("");
        ucheck.setBattfault_check_done_recheck(0);
        ucheck.setBattfault_check_done_recheck_result("");
        ucheck.setBattfault_check_done_recheck_check(0);
        ucheck.setBattfault_check_done_recheck_check_result("");
    
        return ucheck;
    }
    
    //构造默认的User_task_batt_test对象
    public static User_task_batt_test CreateUtest(Object obj1,Object obj2,int monthOdd,int dayOdd) throws ParseException{
        User_task_batt_test utest=new User_task_batt_test();
        BattInf binf=(BattInf) obj1;
        Date date=binf.getBattProductDate1();//执行日期
        User_task utask=(User_task) obj2;
        
        utest.setTask_id(utask.getTask_id());
        if(binf.getStationIp()!=null){
            utest.setTask_usr_ids(binf.getStationIp());//执行人
        }else{
            utest.setTask_usr_ids("0");
        }
        
        utest.setBattGroupId(binf.getBattGroupId());
        utest.setTask_enabled(1);//默认为1
        
        //获取任务开始时间(默认时间为当前月的第一天)
        Date task_exe_date=DAOHelper.sdf.parse(ActionUtil.getDayTime(ActionUtil.getDateYear(date), ActionUtil.getDateMonth(date)+monthOdd-1,dayOdd,1));
        utest.setTask_exe_date(task_exe_date); 
        //获取任务结束时间(默认时间为当前月的最后一天)
        Date task_close_date=DAOHelper.sdf.parse(ActionUtil.getDayTime(ActionUtil.getDateYear(date), ActionUtil.getDateMonth(date)+monthOdd-1,dayOdd,4));
        utest.setTask_close_date(task_close_date);
        
        
        //获取提醒开始时间(默认时间为当前月的工作的起始时间)
        Date task_notice_starttime=DAOHelper.sdf.parse(ActionUtil.getDayTime(ActionUtil.getDateYear(new Date()), ActionUtil.getDateMonth(new Date())-1,ActionUtil.getDateday(new Date()),2));
        utest.setTask_notice_starttime(task_notice_starttime);
        //获取提醒结束时间(默认时间为当前月的工作的起始时间)
        Date task_notice_endtime=DAOHelper.sdf.parse(ActionUtil.getDayTime(ActionUtil.getDateYear(new Date()), ActionUtil.getDateMonth(new Date())-1,ActionUtil.getDateday(new Date()),3));
        utest.setTask_notice_endtime(task_notice_endtime);
        
        utest.setTask_notice_count(0);
        utest.setTask_notice_latesttime(new Date());
        
        utest.setTask_notice_master(0);
        utest.setTest_complete(0);
        utest.setTest_completetime(DAOHelper.sdf.parse("2015-09-01 00:00:00"));
        utest.setTest_starttime(DAOHelper.sdf.parse("2015-09-01 00:00:00"));
        utest.setTest_record_count_id(0);
        utest.setNote("");
        return utest;
    }
}