我的JAVA

我的门户
随笔 - 5, 文章 - 0, 评论 - 2, 引用 - 0
数据加载中……

BO

  1 /*
  2  * 创建日期 2006-12-22
  3  *
  4  * TODO 要更改此生成的文件的模板,请转至
  5  * 窗口 - 首选项 - Java - 代码样式 - 代码模板
  6   */

  7 package  com.sinotrans.uploadfileportlet;
  8
  9 import  java.io.BufferedReader;
 10 import  java.io.File;
 11 import  java.io.FileInputStream;
 12 import  java.io.IOException;
 13 import  java.io.InputStreamReader;
 14 import  java.sql.Connection;
 15 import  java.sql.SQLException;
 16 import  java.sql.Statement;
 17 import  java.text.NumberFormat;
 18 import  java.text.SimpleDateFormat;
 19 import  java.util.ArrayList;
 20 import  java.util.Date;
 21 import  java.util.Iterator;
 22 import  java.util.List;
 23 import  java.util.Locale;
 24
 25 import  javax.naming.Context;
 26 import  javax.naming.InitialContext;
 27 import  javax.naming.NamingException;
 28 import  javax.portlet.ActionRequest;
 29 import  javax.sql.DataSource;
 30
 31 import  org.apache.commons.fileupload.FileItem;
 32 import  org.apache.commons.fileupload.FileUpload;
 33 import  org.apache.commons.fileupload.FileUploadException;
 34 import  org.apache.commons.fileupload.RequestContext;
 35 import  org.apache.commons.fileupload.disk.DiskFileItemFactory;
 36 import  org.apache.commons.fileupload.portlet.PortletFileUpload;
 37 import  org.apache.commons.fileupload.portlet.PortletRequestContext;
 38 import  org.apache.poi.hssf.usermodel.HSSFCell;
 39 import  org.apache.poi.hssf.usermodel.HSSFRow;
 40 import  org.apache.poi.hssf.usermodel.HSSFSheet;
 41 import  org.apache.poi.hssf.usermodel.HSSFWorkbook;
 42
 43 /**
 44  *  @author  Administrator
 45  * 
 46  * TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
 47   */

 48 public   class  BO  {
 49
 50      private  String message  =   " 未知 " ;
 51
 52      private  String uploadFileName  =   "" ;
 53     
 54      private  PaySlip[] pays;
 55
 56      private   long  uploadFileSize  =   0 ;
 57
 58      private   final   static  String TEMP_FILE_PATH  =   " uploadFile.tmp " ;
 59     
 60      private   final   static  String ATTACHMENT_PATH  =   " attachments " ;
 61
 62      private   final   static   long  FILE_MAX_SIZE  =   2L   *   1024   *   1024 ;
 63
 64      private   final   static   int  THRESHOLD_SIZE  =   4   *   1024 ;
 65
 66      private   final   static  String ENCODING  =   " GBK " ;
 67     
 68      private   final   static  String DS_JNDI  =   " jdbc/payslip " ;
 69     
 70      private   final   static  String SCHEMA_NAME  =   " SPOR " ;
 71
 72      /**
 73      * 构造函数,初始化上传目录和临时目录
 74       */

 75      public  BO()  {
 76         File att  =   new  File(ATTACHMENT_PATH);
 77          if  ( ! att.exists())  {
 78             att.mkdirs();
 79         }

 80         File tmp  =   new  File(TEMP_FILE_PATH);
 81          if  ( ! tmp.exists())  {
 82             tmp.mkdirs();
 83         }

 84     }

 85     
 86      /**
 87      * 处理文件上传的请求
 88      * 
 89      *  @param  req
 90      *  @return
 91       */

 92      public   boolean  doProcess(ActionRequest req)  {
 93          boolean  uploadFile  =  doUploadFile(req);
 94          boolean  parseFile  =  doParseFile(uploadFile);
 95          boolean  opDB  =  doOperateDB(parseFile);
 96          return  uploadFile  &&  parseFile  &&  opDB;
 97     }

 98
 99      /**
100      *  @return  返回 message。
101       */

102      public  String getMessage()  {
103          return  message;
104     }

105
106      /**
107      *  @param  message
108      *            要设置的 message。
109       */

110      public   void  setMessage(String message)  {
111          this .message  =  message;
112     }

113
114      /**
115      * 处理文件上传
116      * 
117      *  @param  req
118      *  @return
119       */

120      private   boolean  doUploadFile(ActionRequest req)  {
121
122         RequestContext ctx  =   new  PortletRequestContext(req);
123
124          if  (FileUpload.isMultipartContent(ctx))  {
125
126             DiskFileItemFactory factory  =   new  DiskFileItemFactory();
127             factory.setRepository( new  File(TEMP_FILE_PATH));
128             factory.setSizeThreshold(THRESHOLD_SIZE);
129
130             PortletFileUpload upload  =   new  PortletFileUpload(factory);
131             upload.setHeaderEncoding(ENCODING);
132             upload.setSizeMax(FILE_MAX_SIZE);
133
134             List items  =   null ;
135              try   {
136                 items  =  upload.parseRequest(req);
137             }
  catch  (FileUploadException e)  {
138                 e.printStackTrace();
139                 setMessage( " 上传文件时出现错误。 "   +  e.getMessage());
140                  return   false ;
141             }

142              for  (Iterator iter  =  items.iterator(); iter.hasNext();)  {
143                 FileItem item  =  (FileItem) iter.next();
144                  if  (UploadFilePortletPortlet.FORM_FILE.equals(item.getFieldName()))  {
145                     uploadFileName  =  item.getName();
146                      if  (uploadFileName.length()  ==   0 {
147                         setMessage( " 上传文件时出现错误:文件名为空。 " );
148                          return   false ;
149                     }

150                     uploadFileName  =  uploadFileName.substring(uploadFileName.lastIndexOf( " \\ " ) + 1 );
151                     uploadFileSize  =  item.getSize();
152                      try   {
153                         item.write( new  File(ATTACHMENT_PATH, uploadFileName));
154                     }
  catch  (Exception e)  {
155                         e.printStackTrace();
156                         setMessage( " 上传文件时出现错误:文件不能保存。 "   +  e.getMessage());
157                          return   false ;
158                     }

159                 }

160             }

161
162         }
  else   {
163             setMessage( " 上传文件时出现错误:请求的表单编码不是\ " multipart / form - data\ " " );
164              return   false ;
165         }

166
167          return   true ;
168     }

169
170      /**
171      * 处理文件解析
172      * 
173      *  @return
174       */

175      private   boolean  doParseFile( boolean  preFlag)  {
176         
177          if  ( ! preFlag)  {
178              return   false ;
179         }

180
181          boolean  flag  =   false ;
182
183          if  (uploadFileSize  ==   0 {
184             setMessage( " 解析文件时错误:上传的文件“<B> "   +  uploadFileName  +   " </B>”大小为零。 " );
185              return   false ;
186         }

187
188          if  (uploadFileName.toLowerCase().endsWith( " .csv " ))  {
189             flag  =  doParseCsvFile();
190         }
  else   if  (uploadFileName.toLowerCase().endsWith( " .xls " ))  {
191             flag  =  doParseXlsFile();
192         }
  else   {
193             setMessage( " 解析文件时错误:上传的文件“<B> "   +  uploadFileName  +   " </B>”不是CSV或XLS文件。 " );
194              return   false ;
195         }

196
197          return  flag;
198     }

199     
200      /**
201      * 处理CSV文件解析
202      * 
203      *  @return
204       */

205      private   boolean  doParseCsvFile()  {
206
207         File file  =   new  File(ATTACHMENT_PATH, uploadFileName);
208          if  ( ! file.exists())  {
209             setMessage( " 解析CSV文件时错误:找不到文件“<B> "   +  uploadFileName  +   " </B>”。 " );
210              return   false ;
211         }

212
213         List list  =   new  ArrayList();
214          try   {
215             BufferedReader r  =   new  BufferedReader( new  InputStreamReader( new  FileInputStream(file),  " gb2312 " ));
216              for  (String line  =   null ; (line  =  r.readLine())  !=   null ;)  {
217                 String[] data  =  line.split( " , " );
218                  if  (data.length  >=   45   &&  data[ 0 ].length() <= 3 {
219                      int  index  =   0 ;
220                     PaySlip _pay  =   new  PaySlip();
221                      try   {
222                         _pay.id  =  Integer.parseInt(data[index ++ ].trim());
223                         _pay.dept  =  data[index ++ ].trim(); 
224                         _pay.name  =  data[index ++ ].trim();
225                         _pay.stationPay  =  doParse2Double(data[index ++ ]);
226                         _pay.pkiScore  =  doParse2Double(data[index ++ ]);
227                         _pay.staffPfScore  =  doParse2Double(data[index ++ ]);
228                         _pay.finalPfScore  =  doParse2Double(data[index ++ ]);
229                         _pay.pfPay  =  doParse2Double(data[index ++ ]);
230                         _pay.overtimePay  =  doParse2Double(data[index ++ ]);
231                         _pay.teaFee  =  doParse2Double(data[index ++ ]);
232                         _pay.festivalFee  =  doParse2Double(data[index ++ ]);
233                         _pay.nightAllw  =  doParse2Double(data[index ++ ]);
234                         _pay.areaAllw  =  doParse2Double(data[index ++ ]);
235                         _pay.otherAllw  =  doParse2Double(data[index ++ ]);
236                         _pay.semiYearPrize  =  doParse2Double(data[index ++ ]);
237                         _pay.finalYearPrize  =  doParse2Double(data[index ++ ]);
238                         _pay.bounty  =  doParse2Double(data[index ++ ]);
239                         _pay.reFund  =  doParse2Double(data[index ++ ]);
240                         _pay.attFund  =  doParse2Double(data[index ++ ]);
241                         _pay.all_1  =  doParse2Double(data[index ++ ]);
242                         _pay.agednessIns  =  doParse2Double(data[index ++ ]);
243                         _pay.medicalIns  =  doParse2Double(data[index ++ ]);
244                         _pay.idlenessIns  =  doParse2Double(data[index ++ ]);
245                         _pay.housingFund  =  doParse2Double(data[index ++ ]);
246                         _pay.allSubtract  =  doParse2Double(data[index ++ ]);
247                         _pay.all_2  =  doParse2Double(data[index ++ ]);
248                         _pay.staffTax  =  doParse2Double(data[index ++ ]);
249                         _pay.foodFee  =  doParse2Double(data[index ++ ]);
250                         _pay.amerce  =  doParse2Double(data[index ++ ]);
251                         _pay.otherSubs  =  doParse2Double(data[index ++ ]);
252                         _pay.realPay  =  data[index ++ ].trim();
253                          if  (_pay.realPay.startsWith( " \ "" ) && data[index].trim().endsWith( " \ "" ))  {
254                             _pay.realPay  =  _pay.realPay.substring( 1 ).trim()  +   " , "   +  data[index].substring( 0 , data[index].length() - 1 ).trim();
255                             index ++ ;
256                         }

257                         _pay.bankAccount  =  data[index ++ ].trim();
258                         _pay.payDate  =  data[index ++ ].trim();
259                         index ++ ;     //  跳过空列
260                         _pay.coAgednessIns  =  doParse2Double(data[index ++ ]);
261                         _pay.coMedicalIns  =  doParse2Double(data[index ++ ]);
262                         _pay.coIdlenessIns  =  doParse2Double(data[index ++ ]);
263                         _pay.coInjureIns  =  doParse2Double(data[index ++ ]);
264                         _pay.coBearingIns  =  doParse2Double(data[index ++ ]);
265                         _pay.coReMedicalIns  =  doParse2Double(data[index ++ ]);
266                         _pay.coHousingFund  =  doParse2Double(data[index ++ ]);
267                         _pay.coDisease  =  doParse2Double(data[index ++ ]);
268                         _pay.coAll  =  data[index ++ ].trim();
269                          if  (_pay.coAll.startsWith( " \ "" ) && data[index].trim().endsWith( " \ "" ))  {
270                             _pay.coAll  =  _pay.coAll.substring( 1 ).trim()  +   " , "   +  data[index].substring( 0 , data[index].length() - 1 ).trim();
271                             index ++ ;
272                         }

273                         index ++ ;     //  跳过空列
274                         _pay.staffCost  =  doParse2Double(data[index ++ ]);
275                     }
  catch  (NumberFormatException e)  {
276                         e.printStackTrace();
277                         setMessage( " 解析CSV文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中数字项包含非数字内容。 "   +  e.getMessage());
278                          return   false ;
279                     }

280
281                      if  (_pay.dept.length()  ==   0 {
282                         setMessage( " 解析CSV文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少所属部门信息。 " );
283                          return   false ;
284                     }

285                      if  (_pay.name.length()  ==   0 {
286                         setMessage( " 解析CSV文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少姓名信息。 " );
287                          return   false ;
288                     }

289                      if  (_pay.bankAccount.length()  ==   0 {
290                         setMessage( " 解析CSV文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少银行帐号信息。 " );
291                          return   false ;
292                     }

293                      if  (_pay.payDate.length()  ==   0 {
294                         setMessage( " 解析CSV文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少工资年月信息。 " );
295                          return   false ;
296                     }

297                     list.add(_pay);
298                 }

299             }

300             r.close();
301         }
  catch  (IOException e)  {
302             e.printStackTrace();
303             setMessage( " 解析CSV文件时错误:解析文件“<B> "   +  uploadFileName  +   " </B>”时发生IO异常。 "   +  e.getMessage());
304              return   false ;
305         }

306         pays  =  (PaySlip[]) list.toArray( new  PaySlip[ 0 ]);
307          if  (pays.length  ==   0 {
308             setMessage( " 解析CSV文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少工资记录。 " );
309              return   false ;
310         }

311         
312          return   true ;
313     }

314     
315      /**
316      * 处理XLS文件解析
317      * 
318      *  @return
319       */

320      private   boolean  doParseXlsFile()  {
321
322         File file  =   new  File(ATTACHMENT_PATH, uploadFileName);
323          if  ( ! file.exists())  {
324             setMessage( " 解析XLS文件时错误:找不到文件“<B> "   +  uploadFileName  +   " </B>”。 " );
325              return   false ;
326         }

327         
328         List list  =   new  ArrayList();
329          try   {
330             HSSFWorkbook workbook  =   new  HSSFWorkbook( new  FileInputStream(file));
331             HSSFSheet sheet  =  workbook.getSheetAt( 0 );
332             HSSFRow row  =   null ;
333              for  ( int  i  =   3 ; (row  =  sheet.getRow(i))  !=   null ; i ++ {
334                  short  index  =   0 ;
335                 PaySlip _pay  =   new  PaySlip();
336                  try   {
337                     _pay.id  =  Integer.parseInt(doParseXlsCell(row.getCell(index ++ ), " INTEGER " ));
338                     _pay.dept  =  doParseXlsCell(row.getCell(index ++ ), null );
339                     _pay.name  =  doParseXlsCell(row.getCell(index ++ ), null );
340                     _pay.stationPay  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
341                     _pay.pkiScore  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
342                     _pay.staffPfScore  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
343                     _pay.finalPfScore  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
344                     _pay.pfPay  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
345                     _pay.overtimePay  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
346                     _pay.teaFee  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
347                     _pay.festivalFee  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
348                     _pay.nightAllw  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
349                     _pay.areaAllw  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
350                     _pay.otherAllw  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
351                     _pay.semiYearPrize  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
352                     _pay.finalYearPrize  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
353                     _pay.bounty  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
354                     _pay.reFund  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
355                     _pay.attFund  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
356                     _pay.all_1  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
357                     _pay.agednessIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
358                     _pay.medicalIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
359                     _pay.idlenessIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
360                     _pay.housingFund  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
361                     _pay.allSubtract  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
362                     _pay.all_2  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
363                     _pay.staffTax  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
364                     _pay.foodFee  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
365                     _pay.amerce  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
366                     _pay.otherSubs  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
367                     _pay.realPay  =  doParseXlsCell(row.getCell(index ++ ), " MONEY " );
368                     _pay.bankAccount  =  doParseXlsCell(row.getCell(index ++ ), " INTEGER " );
369                     _pay.payDate  =  doParseXlsCell(row.getCell(index ++ ), " DATE " );
370                     index ++ ;     //  跳过空列
371                     _pay.coAgednessIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
372                     _pay.coMedicalIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
373                     _pay.coIdlenessIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
374                     _pay.coInjureIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
375                     _pay.coBearingIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
376                     _pay.coReMedicalIns  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
377                     _pay.coHousingFund  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
378                     _pay.coDisease  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
379                     _pay.coAll  =  doParseXlsCell(row.getCell(index ++ ), " MONEY " );
380                     index ++ ;     //  跳过空列
381                     _pay.staffCost  =  doParse2Double(doParseXlsCell(row.getCell(index ++ ), null ));
382                 }
  catch  (NumberFormatException e)  {
383                     e.printStackTrace();
384                     setMessage( " 解析XLS文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中数字项包含非数字内容。 "   +  e.getMessage());
385                      return   false ;
386                 }

387
388                  if  (_pay.dept.length()  ==   0 {
389                     setMessage( " 解析XLS文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少所属部门信息。 " );
390                      return   false ;
391                 }

392                  if  (_pay.name.length()  ==   0 {
393                     setMessage( " 解析XLS文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少姓名信息。 " );
394                      return   false ;
395                 }

396                  if  (_pay.bankAccount.length()  ==   0 {
397                     setMessage( " 解析XLS文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少银行帐号信息。 " );
398                      return   false ;
399                 }

400                  if  (_pay.payDate.length()  ==   0 {
401                     setMessage( " 解析XLS文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少工资年月信息。 " );
402                      return   false ;
403                 }

404                 list.add(_pay);
405             }

406         }
  catch  (IOException e)  {
407             e.printStackTrace();
408             setMessage( " 解析XLS文件时错误:解析文件“<B> "   +  uploadFileName  +   " </B>”时发生IO异常。 "   +  e.getMessage());
409              return   false ;
410         }

411         pays  =  (PaySlip[]) list.toArray( new  PaySlip[ 0 ]);
412          if  (pays.length  ==   0 {
413             setMessage( " 解析XLS文件时错误:文件“<B> "   +  uploadFileName  +   " </B>”中缺少工资记录。 " );
414              return   false ;
415         }

416         
417          return   true ;
418     }

419     
420      /**
421      * 将字符串转换成数字
422      * 
423      *  @param  num
424      *  @return
425      *  @throws  NumberFormatException
426       */

427      private   double  doParse2Double(String num)  throws  NumberFormatException  {
428         num  =  num.trim();
429          if  (num.length()  ==   0 {
430              return   0.0 ;
431         }
  else   {
432              return  Double.parseDouble(num);
433         }

434     }

435     
436      /**
437      * 将XLS单元格内容转换成字符串
438      * 
439      *  @param  cell
440      *  @param  format
441      *  @return
442       */

443      private  String doParseXlsCell(HSSFCell cell, String format)  {
444          if  (cell  ==   null {
445              return   "" ;
446         }
  else   if  (cell.getCellType()  ==  HSSFCell.CELL_TYPE_STRING)  {
447              return  cell.getStringCellValue().trim();
448         }
  else   if  (cell.getCellType()  ==  HSSFCell.CELL_TYPE_NUMERIC)  {
449              double  value  =  cell.getNumericCellValue();
450              if  (format  ==   null {
451                  return  String.valueOf(value);
452             }
  else   if  (format.equals( " MONEY " ))  {
453                  return  NumberFormat.getCurrencyInstance(Locale.CHINESE).format(value);
454             }
  else   if  (format.equals( " INTEGER " ))  {
455                 NumberFormat nFormat  =  NumberFormat.getIntegerInstance();
456                 nFormat.setGroupingUsed( false );
457                  return  nFormat.format(value);
458             }
  else   if  (format.equals( " DATE " ))  {
459                 value  =  (value  -   25567 *   24   *   60   *   60   *   1000 ;
460                  return   new  SimpleDateFormat( " yyyy'年'MM'月' " ).format( new  Date(( long ) value));
461             }

462         }

463          return   "" ;
464     }

465
466      /**
467      * 操作数据库
468      * 
469      *  @param  preFlag
470      *  @return
471       */

472      private   boolean  doOperateDB( boolean  preFlag)  {
473         
474          if  ( ! preFlag)  {
475              return   false ;
476         }

477
478         Context ctx  =   null ;
479         DataSource ds  =   null ;
480         Connection con  =   null ;
481         
482          try   {
483             ctx  =   new  InitialContext();
484             ds  =  (DataSource) ctx.lookup(DS_JNDI);
485         }
  catch  (NamingException e)  {
486             e.printStackTrace();
487             setMessage( " 保存数据错误:查找数据源异常。 "   +  e.getMessage());
488              return   false ;
489         }

490         
491          try   {
492             con  =  ds.getConnection();
493             
494             con.setAutoCommit( false );
495             Statement stm  =  con.createStatement();
496
497              for  ( int  i  =   0 ; i  <  pays.length; i ++ {
498                 String delSQL  =   " delete from  "   +  SCHEMA_NAME  +   " .PaySlip where name=' "   +  pays[i].name  +   " ' and payDate=' "   +  pays[i].payDate  +   " ' " ;
499                 String insSQL  =   " insert into  "   +  SCHEMA_NAME  +   " .PaySlip values ( "   +
500                          ""   +  pays[i].id  +   " , "   +
501                          " ' "   +  pays[i].dept  +   " ', "   +
502                          " ' "   +  pays[i].name  +   " ', "   +
503                          ""   +  pays[i].stationPay  +   " , "   +
504                          ""   +  pays[i].pkiScore  +   " , "   +
505                          ""   +  pays[i].staffPfScore  +   " , "   +
506                          ""   +  pays[i].finalPfScore  +   " , "   +
507                          ""   +  pays[i].pfPay  +   " , "   +
508                          ""   +  pays[i].overtimePay  +   " , "   +
509                          ""   +  pays[i].teaFee  +   " , "   +
510                          ""   +  pays[i].festivalFee  +   " , "   +
511                          ""   +  pays[i].nightAllw  +   " , "   +
512                          ""   +  pays[i].areaAllw  +   " , "   +
513                          ""   +  pays[i].otherAllw  +   " , "   +
514                          ""   +  pays[i].semiYearPrize  +   " , "   +
515                          ""   +  pays[i].finalYearPrize  +   " , "   +
516                          ""   +  pays[i].bounty  +   " , "   +
517                          ""   +  pays[i].reFund  +   " , "   +
518                          ""   +  pays[i].attFund  +   " , "   +
519                          ""   +  pays[i].all_1  +   " , "   +
520                          ""   +  pays[i].agednessIns  +   " , "   +
521                          ""   +  pays[i].medicalIns  +   " , "   +
522                          ""   +  pays[i].idlenessIns  +   " , "   +
523                          ""   +  pays[i].housingFund  +   " , "   +
524                          ""   +  pays[i].allSubtract  +   " , "   +
525                          ""   +  pays[i].all_2  +   " , "   +
526                          ""   +  pays[i].staffTax  +   " , "   +
527                          ""   +  pays[i].foodFee  +   " , "   +
528                          ""   +  pays[i].amerce  +   " , "   +
529                          ""   +  pays[i].otherSubs  +   " , "   +
530                          " ' "   +  pays[i].realPay  +   " ', "   +
531                          " ' "   +  pays[i].bankAccount  +   " ', "   +
532                          " ' "   +  pays[i].payDate  +   " ', "   +
533                          ""   +  pays[i].coAgednessIns  +   " , "   +
534                          ""   +  pays[i].coMedicalIns  +   " , "   +
535                          ""   +  pays[i].coIdlenessIns  +   " , "   +
536                          ""   +  pays[i].coInjureIns  +   " , "   +
537                          ""   +  pays[i].coBearingIns  +   " , "   +
538                          ""   +  pays[i].coReMedicalIns  +   " , "   +
539                          ""   +  pays[i].coHousingFund  +   " , "   +
540                          ""   +  pays[i].coDisease  +   " , "   +
541                          " ' "   +  pays[i].coAll  +   " ', "   +
542                          ""   +  pays[i].staffCost  +   " ) " ;
543                 
544                 stm.executeUpdate(delSQL);
545                 stm.executeUpdate(insSQL);
546             }

547             
548             con.commit();
549             con.close();
550         }
  catch  (SQLException e)  {
551              try   {
552                 con.rollback();
553                 con.close();
554             }
  catch  (SQLException e1)  {
555                 e1.printStackTrace();
556             }

557             e.printStackTrace();
558             setMessage( " 保存数据错误:操作数据库异常。 "   +  e.getMessage());
559              return   false ;
560         }

561
562          return   true ;
563     }

564     
565      private   class  PaySlip  {
566          int  id;                     //  序号
567         String dept;             //  所属部门
568         String name;             //  姓名
569          double  stationPay;         //  岗位工资
570          double  pkiScore;         //  部门PKI得分
571          double  staffPfScore;     //  个人绩效得分
572          double  finalPfScore;     //  最终绩效成绩
573          double  pfPay;             //  绩效工资
574          double  overtimePay;         //  加班工资
575          double  teaFee;             //  凉茶费
576          double  festivalFee;         //  过节费
577          double  nightAllw;         //  夜班补贴
578          double  areaAllw;         //  地区补贴
579          double  otherAllw;         //  其他补贴
580          double  semiYearPrize;     //  半年奖
581          double  finalYearPrize;     //  年终奖
582          double  bounty;             //  奖励金
583          double  reFund;             //  补款
584          double  attFund;             //  考勤扣款
585          double  all_1;             //  应发合计1
586          double  agednessIns;         //  养老保险
587          double  medicalIns;         //  医疗保险
588          double  idlenessIns;         //  失业保险
589          double  housingFund;         //  住房公积金
590          double  allSubtract;         //  扣款合计
591          double  all_2;             //  应发工资2 (计税工资)
592          double  staffTax;         //  代扣个人所得税
593          double  foodFee;             //  扣餐费
594          double  amerce;             //  扣罚款
595          double  otherSubs;         //  扣其他款
596         String realPay;             //  实发工资
597         String bankAccount;         //  银行帐号
598         String payDate;             //  工资年月
599
600          double  coAgednessIns;     //  企业缴交部分 养老保险
601          double  coMedicalIns;     //  企业缴交部分 医疗保险
602          double  coIdlenessIns;     //  企业缴交部分 失业保险
603          double  coInjureIns;         //  企业缴交部分 工伤保险
604          double  coBearingIns;     //  企业缴交部分 生育保险
605          double  coReMedicalIns;     //  企业缴交部分 补充(医疗)
606          double  coHousingFund;     //  企业缴交部分 住房公积
607          double      coDisease;         //  企业缴交部分 重大疾病
608         String coAll;             //  企业缴交部分 合计
609         
610          double  staffCost;         //  人工成本
611     }

612 }

posted on 2006-12-29 11:33 xuyang 阅读(383) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: