薪酬模块生成工资条



主要运用easyUI 、 Hibernate 、Servlet 。

1.动态生成标签页,

?
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
$(function(){
     //创建打开新标签页
     $( ".easyui-linkbutton" ).click(function(){
         
         $( "#img" ).panel( 'close' );
         //获取组件的属性或内容
         var tab_title = $( this ).text(); //关键在this选择当前事件
         var tab_href = $( this ).attr( "title" );
         var dd =  $( this ).attr( "id" );
         //alert(tab_href);
         if ($( "#tt" ).tabs( "exists" ,tab_title))
             {
                 $( "#tt" ).tabs( "select" ,tab_title)
             }
         else if (dd== "dd" )
             {
             $( "#gz" ).dialog( 'open' );
             
             }
         else
             {
                 $( "#tt" ).tabs( 'add' ,{
                     title:tab_title,
                     closable: true ,
                     //href:tab_href
                     content: "<iframe frameborder='0' sarolling='auto' width='100%' height='100%'src='" + tab_href + "'></iframe>"
                 });
             }
         
     });
     
})

  这里主要是用inframe来获取href,避免多个标签页同时打开产生冲突。

 

2.然后就是生成工资条的弹窗,

这里是根据考勤表里的状态来获取月份的,(0表示未生成工资条)

注意下拉框是通过URL、valueFeild、textFeild 把value的值传递的,参考:省市区三级联动

3.点击生成按钮后,需要加载数据,需要一段时间,所以加了个进度条

?
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
<!-- 生成工资条弹窗 --> 
     
  <div class = "easyui-dialog" id= "gz" style= "width:400px; height:200px"
title= "生成工资条"
data-options="{
closed: true ,
modal: true ,
buttons:[{
text: '生成' ,
iconCls: 'icon-ok' ,
     handler:function(){
         $( '#form1' ).form( 'submit' ,{
         
             url: 'PayDateServlet' , //把定义的默认值是add的添加的方法传给Servlet然后判断
             onSubmit:function(){
             
             
                 var isValid = $( this ).form( 'validate' );
                 if (!isValid)
                 {
                     $.messager.show({
                         
                         title: '消息' ,
                         msg: '数据验证未通过'
                     });
                 }
                 else
                 {
                     //进度对话框
                     $.messager.progress(
                         {
                             title: '进度条' ,
                             msg: '工资加载中。。。' ,
                             text: '请稍后。。。' ,
                             interval: 1000
                         }      
                     
                     );
                 }
                 return isValid; //
             },
             success:function(data){
                 
             
                 var msg = eval( '(' + data + ')' ); //eval是js的方法
                 
             if (!msg.success)
                 {
                     alert(msg.message);
                 }
                 else
                 {
                  
                  $.messager.progress( 'close' );
                     $.messager.show({
                         
                         title: '消息' ,
                         msg: '数据验证通过,保存成功'
                     });
                     
                     $( '#gz' ).dialog( 'close' );
                     
                 }
             
             }
         });
     }
         
             
     
},
 
{
text: '取消' ,
iconCls: 'icon-cancel' ,
     handler:function(){$( '#gz' ).dialog( 'close' )},
}]
}"
>

  页面层

?
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html>
<head>
<meta charset= "UTF-8" >
<title>Insert title here</title>
<!-- 顺序不可以乱 -->
<!-- 1 .jQuery的js包 -->
<script type= "text/javascript" src= "jquery-easyui-1.4.4/jquery.min.js" ></script>
<!-- 2 .css资源 -->
<link  rel= "stylesheet" type= "text/css" href= "jquery-easyui-1.4.4/themes/default/easyui.css" >
<!-- 3 . 图标资源 -->
<link  rel= "stylesheet" type= "text/css" href= "jquery-easyui-1.4.4/themes/icon.css" >
<!-- 4 .easyui的js包 -->
<script type= "text/javascript" src= "jquery-easyui-1.4.4/jquery.easyui.min.js" ></script>
<!-- 5 .本地语言 -->
<script type= "text/javascript" src= "jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js" ></script>
 
<style type= "text/css" >
.caidan
{
    width:120px;
    height:40px;
    position:relative;
    float : left;
    margin-left: 40px;
    margin-top: 5px;
    color:white;
    text-align: center;
    line-height: 40px;
    font-size: 1 .2em;
}
.caidan:hover
{
background-color:# 595959 ;
border-radius: 3px;
}
</style>
 
 
<script type= "text/javascript" >
 
function getDate(date)
{
     //得到日期对象
     var d = new Date(date);
     //得到年  月  日
     var year = d.getFullYear();
     var month = (d.getMonth()+ 1 );
     var day = d.getDate();
     //拼装
     var rtn = year+ "-" +(month< 10 ? "0" +month : month) + "-" +(day< 10 ? "0" +day : day);
     return rtn;
}
 
$(function(){
     //创建打开新标签页
     $( ".easyui-linkbutton" ).click(function(){
         
         $( "#img" ).panel( 'close' );
         //获取组件的属性或内容
         var tab_title = $( this ).text(); //关键在this选择当前事件
         var tab_href = $( this ).attr( "title" );
         var dd =  $( this ).attr( "id" );
         //alert(tab_href);
         if ($( "#tt" ).tabs( "exists" ,tab_title))
             {
                 $( "#tt" ).tabs( "select" ,tab_title)
             }
         else if (dd== "dd" )
             {
             $( "#gz" ).dialog( 'open' );
             
             }
         else
             {
                 $( "#tt" ).tabs( 'add' ,{
                     title:tab_title,
                     closable: true ,
                     //href:tab_href
                     content: "<iframe frameborder='0' sarolling='auto' width='100%' height='100%'src='" + tab_href + "'></iframe>"
                 });
             }
         
     });
     
})
 
 
</script>
</head>
<body class = "easyui-layout" >
<div data-options= "region:'north',split:false" style= "height:152px;" >
 
     <div style= "width:100%;height:100px;margin-top:0px;" >
       <img alt= "" src= "images/head.jpg" width= "1360px" >
    </div>
    
    <div style= "background-color:#393755;width:100%;height:50px;margin-top:0px;" >
       <a href= "#" ><div class = "caidan" >人事管理模块</div></a>
       <a href= "#" ><div class = "caidan" >考勤管理模块</div></a>
       <a href= "#" ><div class = "caidan" >招聘管理模块</div></a>
       <a href= "#" ><div class = "caidan" >培训管理模块</div></a>
       <a href= "#" ><div class = "caidan" >薪酬管理模块</div></a>
    </div>
     
</div>  
         <div data-options= "region:'south',split:false" style= "height:50px;" ></div>  
         <!--  <div data-options= "region:'east',iconCls:'icon-reload',title:'工具',split:true" style= "width:100px;" ></div> --> 
  
  <!-- ********************菜单******************************** 8 -->  
         <div data-options= "region:'west',title:'菜单',split:false" style= "width:200px;" >
             
             <div id= "ac" class = "easyui-accordion" data-options= "fit:true" >
             
                 <div title= "查询工资" data-options= "selected:false" >
                     <a id= "" href= "#" class = "easyui-linkbutton" title= "SelectPay.html"
                     style= "width:100%" data-options= "iconCls:'icon-search'" >查询工资</a>
                     
                     <a id= "dd" href= "#" class = "easyui-linkbutton" title= ""
                     style= "width:100%" data-options= "iconCls:'icon-search'" >设置工资</a>
                 </div>
                 
                 <div  title= "税率标准" >
                     <a id= "" href= "#" class = "easyui-linkbutton"  title= "SelectRate.html"
                     style= "width:100%" data-options= "iconCls:'icon-search'" >查询税率</a>
                     
                     <a id= "" href= "#" class = "easyui-linkbutton" title= "ShezhiRate.html" style= "width:100%"
                     data-options= "iconCls:'icon-shezhi'" >设置税率</a>
                         
                     
                         
                 </div>
             
                 <div title= "奖惩标准" >
                     <a href= "#" title= "ShezhiDeal.html" class = "easyui-linkbutton" style= "width:100%"
                     data-options= "iconCls:'icon-shezhi'" >奖惩设置</a> 
                     <a href= "#" title= "SelectDeal.html" class = "easyui-linkbutton" style= "width:100%"
                     data-options= "iconCls:'icon-search'" >奖惩查询</a> 
                 </div>
                 
                 <div title= "工资标准" >
                 <a href= "#" title= "ShezhiRank.html" class = "easyui-linkbutton" style= "width:100%"
                 data-options= "iconCls:'icon-shezhi'" >工资标准设置</a> 
                 <a href= "#" title= "SelectRank.html" class = "easyui-linkbutton" style= "width:100%"
                 data-options= "iconCls:'icon-search'" >查询工资标准</a> 
                 </div>
                 
             </div>
         
         </div> 
      
      
         <div data-options= "region:'center',title:'主窗口'" style= "padding:5px;background:#eee;" >
         <div id= "img" class = "easyui-panel" ><img alt= "" src= "images/2.jpg" width= "100%" heigth= "440px" ></div>
             <div id= "tt" class = "easyui-tabs" data-options= "fit:true,justified:false" ></div>
         </div> 
 
         
     </div>
     
     
  <!-- 生成工资条弹窗 -->
     
  <div class = "easyui-dialog" id= "gz" style= "width:400px; height:200px"
title= "生成工资条"
data-options="{
closed: true ,
modal: true ,
buttons:[{
text: '生成' ,
iconCls: 'icon-ok' ,
     handler:function(){
         $( '#form1' ).form( 'submit' ,{
         
             url: 'PayDateServlet' , //把定义的默认值是add的添加的方法传给Servlet然后判断
             onSubmit:function(){
             
             
                 var isValid = $( this ).form( 'validate' );
                 if (!isValid)
                 {
                     $.messager.show({
                         
                         title: '消息' ,
                         msg: '数据验证未通过'
                     });
                 }
                 else
                 {
                     //进度对话框
                     $.messager.progress(
                         {
                             title: '进度条' ,
                             msg: '工资加载中。。。' ,
                             text: '请稍后。。。' ,
                             interval: 1000
                         }      
                     
                     );
                 }
                 return isValid; //
             },
             success:function(data){
                 
             
                 var msg = eval( '(' + data + ')' ); //eval是js的方法
                 
             if (!msg.success)
                 {
                     alert(msg.message);
                 }
                 else
                 {
                  
                  $.messager.progress( 'close' );
                     $.messager.show({
                         
                         title: '消息' ,
                         msg: '数据验证通过,保存成功'
                     });
                     
                     $( '#gz' ).dialog( 'close' );
                     
                 }
             
             }
         });
     }
         
             
     
},
 
{
text: '取消' ,
iconCls: 'icon-cancel' ,
     handler:function(){$( '#gz' ).dialog( 'close' )},
}]
}"
>
     <form action= "" id= "form1" method= "post" ><br><br>
        生成工资条:<input id= "date" class = "easyui-combobox" style= "width:100px"
      name= "date"
     data-options="
     url: 'PayServlet' ,
     valueField: 'payID' ,
     textField: 'payMonth' ,
     onSelect:function(r){$( '#date' ).combobox( 'setValue' ,r.payMonth.toString());}">
     </form>
</div>
     
 
      
</body>
</html>

  

获取下拉框月份的Servlet层

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         //转码
         request.setCharacterEncoding( "UTF-8" );
         response.setCharacterEncoding( "UTF-8" );
         response.setContentType( "text/html" );
         
         //调用底层查询表月份的集合
         SPayDAO sp = new SPayDAO();
         List<Object> lss = sp.getMonth();
         //System.out.println(lss);
         
         List<Month> ls = new ArrayList<Month>();
         for ( int i= 0 ;i<lss.size();i++)
         {
             Month m = new Month();
             m.setPayID(i);
             m.setPayMonth(lss.get(i).toString());
             ls.add(m);
         }
         String json = JSONArray.toJSONString(ls);
         response.getWriter().println(json);
     }

  提交from表单的select层

?
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
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         //转码
         request.setCharacterEncoding( "UTF-8" );
         response.setCharacterEncoding( "UTF-8" );
         response.setContentType( "text/html" );
         
         //接受月份
         String date = request.getParameter( "date" );
         
         
         System.out.println( "date=" +date);
         String msg = "{'success':true,'message':'保存成功'}" ;
         if (date != null )
         {
             try
             {
                 
                 SPayDAO sp = new SPayDAO();
                 sp.unite(date);
                 
             }
             catch (Exception e)
             {
                  msg = "{'success':false,'message':'访问失败'}" ;
             }
 
             response.getWriter().print(msg);
         }
         else
         {
              msg = "{'success':false,'message':'没有要生成的工资'}" ;
                 response.getWriter().print(msg);
         }
                 
     }

  DAO层

?
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
package com.hanqi.dao;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
 
import com.hanqi.entity.Basic;
import com.hanqi.entity.Deal;
import com.hanqi.entity.KqMonthkaoqin;
import com.hanqi.entity.Rank;
import com.hanqi.entity.Rate;
import com.hanqi.entity.SPay;
 
public class SPayDAO {
     
     Configuration  cfg = null ;
     ServiceRegistry  sr = null ;
      SessionFactory sf = null ;
      Session  se = null ;
     Transaction tr = null ;
     
     public SPayDAO() //注册服务
     {
         //1.加载配置文件
                 cfg = new Configuration().configure();
                 //2.注册服务
                  sr = new  StandardServiceRegistryBuilder()
                         .applySettings(cfg.getProperties()).build();
     }
     //初始化
     private void init()
     {
         try
         {
             sf= cfg.buildSessionFactory(sr);
         }
         catch (Exception e)
         {
             //1.加载配置文件
             cfg = new Configuration().configure();
             //2.注册服务
              sr = new  StandardServiceRegistryBuilder()
                     .applySettings(cfg.getProperties()).build();
             sf= cfg.buildSessionFactory(sr);
             
         }
         
         
         se = sf.openSession();
         tr = se.beginTransaction(); //启动事物
         
     }
     //提交和释放
     private void destroy()
     {
         try
         {
         tr.commit(); //提交事务
         
         }
         catch (Exception e)
         {
             //1.加载配置文件
             cfg = new Configuration().configure();
             //2.注册服务
              sr = new  StandardServiceRegistryBuilder()
                     .applySettings(cfg.getProperties()).build();
             sf= cfg.buildSessionFactory(sr);
             se = sf.openSession();
             tr = se.beginTransaction();
             tr.commit(); //提交事务
         }
         
         se.close();
         sf.close();
     }
     
     //联合查询
     public void unite(String date)
     {
          
          
         
         double zhengchang = getZhengchangJiaban();
          double zhoumo = getzhoumo();
          double jiaqi = getJiaqi();
          double  chidao = getChidao ();
          double zaotui =  getZaotui();
          double kuanggong = getKuanggong();
          List<Rate> rate = getRate();
          init();
          System.out.println( "uwef=" +date);
          List<KqMonthkaoqin> lb = se.createQuery( "from KqMonthkaoqin where zhuangtai= 0 and to_char(kaoqinmonth,'yyyy-MM')=?" )
                  .setString( 0 , date).list() ;
         
          System.out.println(lb);
          SPay sp = new SPay();
           for (KqMonthkaoqin k : lb)
           {
               sp.setPayid(date+k.getStaffid()); //获取并写入工资表的薪资编号
               
               sp.setYuangongid(k.getStaffid()); //获取员工id
               sp.setEmployeename(getName(k.getStaffid()));; //员工姓名
               //基本工资
              
               double jb = getSalary(Integer.parseInt(getLevels(k.getStaffid())));
               sp.setJibengongzi( jb);
             
               //加班总金额
               double zc = zhengchang*k.getJiaban();
               double zm = zhoumo*k.getZhoumojiaban();
               double jq = jiaqi*(k.getJiejiarijiaban());
               double z = zc+zm+jq ;
               sp.setJiaban(z);
                       
                       
               //请假
               sp.setQingjia(k.getQingjia());
               //迟到
               sp.setChidao(chidao*(k.getChidao()));
               //早退
               sp.setZaotui(zaotui*(k.getZaotui()));
               //旷工
               sp.setKuanggong(kuanggong*k.getKuanggong());
               //五险
               sp.setWuxian(jb* 0.1 );
               //公积金
               sp.setGongjijin(jb* 0.08 );
               //全勤
               if (k.getChidao()!= 0 || k.getZaotui() != 0 || k.getQingjia() != 0 ||k.getKuanggong() != 0 )
               {
                   sp.setQuanqin(getquanqin());
               }
               else
               {
                   sp.setQuanqin( 0 );
               }
               //应发工资
               double yingfa = jb+z-(jb* 0.1 +jb* 0.08 );
               sp.setYingfa(yingfa);
               
               
               //纳税
              double nashui = 0 ;
              //判断是否纳税
              if (yingfa-rate.get( 0 ).getStartpay()<= 0 )
             {
                 
             }
              else
              {
                  for ( int i= 0 ; i<rate.size();i++)
                  {
                      double qzd = rate.get(i).getStartpay();
                      double money = rate.get(i).getMoney();
                      double tax = rate.get(i).getTax();
                      double kouchu = rate.get(i).getKouchu();
                      if (yingfa-qzd<money)
                      {
                          nashui=((yingfa-qzd)*tax-kouchu);
                         
                          
                          System.out.println( "起征点=" +qzd);
                          System.out.println( "应纳税所得额=" +money);
                          System.out.println( "税率=" +tax);
                          System.out.println( "扣除数=" +kouchu);
                          break ;
                      }
                  }
                  
                  sp.setNashui(nashui);
              }
             //实发工资
               sp.setShifa((jb+z-(jb* 0.1 +jb* 0.08 ))-nashui);
              sp.setZhuangtai( '0' );
              sp.setHedui( '0' );
              
               getSave(sp);
               getzhuangtai(k.getId()); //调用更改考勤表状态的方法
           }
 
 
          destroy();
     
         
     }
     
     //提交保存SPay
     public void  getSave(SPay spay)
     {
         init();
           se.save(spay);
          destroy();
     }
     //改变考勤表的状态
     public void getzhuangtai(String id)
     {
         init();
         KqMonthkaoqin kaoqin = (KqMonthkaoqin)se.get(KqMonthkaoqin. class , id);
         kaoqin.setZhuangtai( 1 );
         destroy();
     }
     //查询Rate税率表
     public List<Rate> getRate()
     {
         init();
         List<Rate> rtn = new ArrayList<Rate>();
         rtn=se.createQuery( "from Rate order by money asc" ).list();
         destroy();
         return rtn;
     }
     
     
     
     //查询考勤表里状态是0 的月份
     public List<Object> getMonth()
     {
         init();
         List<Object> li = new ArrayList<Object>();
         li = se.createQuery( "select distinct to_char(kaoqinmonth,'yyyy-MM') from KqMonthkaoqin where zhuangtai='0' " ).list();
         
          destroy();
         return li;
         
     }
     
     //根据考勤表的员工id查询员工表的姓名
     public String getName(String yuangongid)
     {
         init();
         String rtn = "" ;
         List<Object> li = new ArrayList<Object>();
          li = se.createQuery( "select name from Basic where yuangongid = ? " )
           .setString( 0 , yuangongid)
         .list() ;
         
         if (li.size()> 0 )
         {
             rtn = li.get( 0 ).toString();
         }
          
         destroy();
         
         
         destroy();
         return rtn;
         
     }
 
     //根据员工编号查询员工等级
     public String getLevels(String yuangongid)
     {
         init();
         String rtn = "" ;
         List<Object> li = new ArrayList<Object>();
          li = se.createQuery( "select jibie from Basic where yuangongid = ? and zhuangtai = '在职'" )
           .setString( 0 , yuangongid)
         .list() ;
         
         if (li.size()> 0 )
         {
             rtn = li.get( 0 ).toString();
         }
          
         destroy();
         
          return rtn;
         
     }
 
     //根据等级查询员工基本工资
     public int getSalary( int levels)
     {
         init();
         int rtn = 0 ;
         
         List<Object> li = new ArrayList<Object>();
         li = se.createQuery( "select salary from Rank where levels = ?" )
                 .setLong( 0 , levels).list();
         if (li.size()> 0 )
         {
             rtn = Integer.parseInt(li.get( 0 ).toString());  
         }
         
         destroy();
         return rtn;
         
     }
     //查询全勤奖励
     public int getquanqin()
     {
         int rtn = 0 ;
         
         init();
         
         List<Object> li = new ArrayList<Object>();
         
         li = se.createQuery( "select quanqin from Deal where state='1'" )
                 .list();
         System.out.println( "list.size = " + li.size());
         if (li.size()> 0 )
         {
             rtn = (Integer.parseInt(li.get( 0 ).toString()));
         }
         
         destroy();
         return rtn;
     }
//获取Deal表的正常加班单价
public int getZhengchangJiaban()
{
     int rtn = 0 ;
     
     init();
     
     List<Object> li = new ArrayList<Object>();
     //查询启用状态下正常加班的金额
     li = se.createQuery( "select zhengban from Deal where state='1'" )
             .list();
     if (li.size()> 0 )
     {
         rtn = (Integer.parseInt(li.get( 0 ).toString()));
     }
     
     destroy();
     return rtn;
     
}
//获取周末加班单价
public int getzhoumo()
{
     int rtn = 0 ;
     
     init();
     
     List<Object> li = new ArrayList<Object>();
     //查询启用状态下周末加班的金额
     li = se.createQuery( "select zhouban from Deal where state='1'" )
             .list();
     if (li.size()> 0 )
     {
         rtn = (Integer.parseInt(li.get( 0 ).toString()));
     }
     
     destroy();
     return rtn;
     
}
 
     //获取节假日加班
     public int getJiaqi()
     {
         int rtn = 0 ;
         
         init();
         
         List<Object> li = new ArrayList<Object>();
         //查询启用状态下节假日加班的金额
         li = se.createQuery( "select jieban from Deal where state='1'" )
                 .list();
         if (li.size()> 0 )
         {
             rtn = (Integer.parseInt(li.get( 0 ).toString()));
         }
         
         destroy();
         return rtn;
     }
     
     //获取迟到金额
     
     public int getChidao ()
     {
 
         int rtn = 0 ;
         
         init();
         
         List<Object> li = new ArrayList<Object>();
         //查询启用状态下迟到一次的金额
         li = se.createQuery( "select chidao from Deal where state='1'" )
                 .list();
         if (li.size()> 0 )
         {
             rtn = (Integer.parseInt(li.get( 0 ).toString()));
         }
         
         destroy();
         return rtn;
     }
     
     //获取早退
     public int getZaotui()
     {
         int rtn = 0 ;
         
         init();
         
         List<Object> li = new ArrayList<Object>();
         //查询启用状态下迟到一次的金额
         li = se.createQuery( "select zaotui from Deal where state='1'" )
                 .list();
         if (li.size()> 0 )
         {
             rtn = (Integer.parseInt(li.get( 0 ).toString()));
         }
         
         destroy();
         return rtn;
     }
     
     //获取旷工
     public int getKuanggong()
     {
         int rtn = 0 ;
         
         init();
         
         List<Object> li = new ArrayList<Object>();
         //查询启用状态下旷工一次的金额
         li = se.createQuery( "select kuanggong from Deal where state='1'" )
                 .list();
         if (li.size()> 0 )
         {
             rtn = (Integer.parseInt(li.get( 0 ).toString()));
         }
         
         destroy();
         return rtn;
     }
     
     
     
     //获取分页数据集合列表
         public List<SPay> getPageList( int page , int rows,String sort,Map<String,String> where)
         {
             init();
             //创建基础HQL语句
             String sql = "from SPay where 1=1" ;
             
             //判断传递的的参数
             String yuangongid =  where.get( "yuangongid_s" );
             
             if (yuangongid != null && !yuangongid.equals( "" ))
             {
                 sql += " and yuangongid " ;
             }
             //排序
                     
             if (sort != null && !sort.equals( "" ))
                 {
                     sql += " order by " + sort;
                 }
             
             //得到HQL
             //并判断查询条件
             Query q = se.createQuery(sql);
             
             if (yuangongid != null && !yuangongid.equals( "" ) )
             {
             
                 q.setString( "yuangongid" , yuangongid); //引号的内容必须跟上面引号后的别名一致
             }
             System.out.println( "yuangongid=" +yuangongid);
             
              List<SPay> rtn = new ArrayList<SPay>();
              rtn = q.setMaxResults(rows) //每页行数
                      .setFirstResult((page- 1 )*rows).list(); //其实页码
 
              destroy();
             return rtn;
         }
         
         
         
         
         
         
         
         //获取数据条数
         public int getTotal(Map<String,String> where)
         {
             int rtn= 0 ;
             init();
             
             //创建基础HQL语句
             String sql = "select count(1) from  SPay where 1=1" ;
             
             //判断传递的的参数
             String yuangongid_s =  where.get( "yuangongid_s" );
             if (yuangongid_s != null && !yuangongid_s.equals( "" ))
             {
                 sql += " and yuangongid  )" ; //and前面加空格
             }
             
             //得到HQL
             //并判断查询条件
             Query q = se.createQuery(sql);
                     
             if (yuangongid_s != null && !yuangongid_s.equals( "" ) )
             {
                 
                 q.setString( "yuangongid" , yuangongid_s);
                 //引号的内容必须跟上面引号后的别名一致
                 
             }
             
             
             //获取Query对对象,定义集合并实例化
             List<Object> lo = q.list();
             
             if (lo != null && lo.size() > 0 )
             {
                 rtn = Integer.parseInt(lo.get( 0 ).toString()); //转换成int并赋值
             }
             
              destroy();
             
             
             return rtn;
         }
}

  DAO层主要是围绕着联合查询这个方法来的,通过给中小方法,获取其他表的数据,生成工资表SPay中的各个字段,然后添加,也就是一个添加的过程。

这个项目所遇到的一些问题:代码优化,逻辑还不够严谨。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值