package com.ssh.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.UUID;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ssh.utils.ExportExcelUtil;
import com.ssh.dao.ClockDAO;
import com.ssh.dao.WagesDAO;
import com.ssh.domain.Clock;
import com.ssh.domain.Wages;
import com.ssh.dao.EmployeeDAO;
import com.ssh.domain.Employee;
@Controller @Scope("prototype")
public class WagesAction extends ActionSupport {
/*图片字段wagesPhoto参数接收*/
private File wagesPhotoFile;
private String wagesPhotoFileFileName;
private String wagesPhotoFileContentType;
public File getWagesPhotoFile() {
return wagesPhotoFile;
}
public void setWagesPhotoFile(File wagesPhotoFile) {
this.wagesPhotoFile = wagesPhotoFile;
}
public String getWagesPhotoFileFileName() {
return wagesPhotoFileFileName;
}
public void setWagesPhotoFileFileName(String wagesPhotoFileFileName) {
this.wagesPhotoFileFileName = wagesPhotoFileFileName;
}
public String getWagesPhotoFileContentType() {
return wagesPhotoFileContentType;
}
public void setWagesPhotoFileContentType(String wagesPhotoFileContentType) {
this.wagesPhotoFileContentType = wagesPhotoFileContentType;
}
/*界面层需要查询的属性: 图书条形码*/
private String wagesid;
private int employeeid;
public int getEmployeeid() {
return employeeid;
}
public void setEmployeeid(int employeeid) {
this.employeeid = employeeid;
}
public String getWagesid() {
return wagesid;
}
public void setWagesid(String wagesid) {
this.wagesid = wagesid;
}
private String barcode;
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public String getBarcode() {
return this.barcode;
}
/*界面层需要查询的属性: 图书名称*/
private String wagesname;
public void setWagesName(String wagesName) {
this.wagesname = wagesName;
}
public String getWagesName() {
return this.wagesname;
}
/*界面层需要查询的属性: 图书所在类别*/
private Employee employee;
public void setEmployee(Employee employee) {
this.employee = employee;
}
public Employee getEmployee() {
return this.employee;
}
/*界面层需要查询的属性: 出版日期*/
private String publishDate;
public void setPublishDate(String publishDate) {
this.publishDate = publishDate;
}
public String getPublishDate() {
return this.publishDate;
}
/*当前第几页*/
private int currentPage;
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getCurrentPage() {
return currentPage;
}
/*一共多少页*/
private int totalPage;
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getTotalPage() {
return totalPage;
}
/*当前查询的总记录数目*/
private int recordNumber;
public void setRecordNumber(int recordNumber) {
this.recordNumber = recordNumber;
}
public int getRecordNumber() {
return recordNumber;
}
/*业务层对象*/
@Resource WagesDAO wagesDAO;
@Resource ClockDAO clockDAO;
@Resource EmployeeDAO employeeDAO;
/*待操作的Wages对象*/
private Wages wages;
public void setWages(Wages wages) {
this.wages = wages;
}
public Wages getWages() {
return this.wages;
}
/*跳转到添加Wages视图*/
public String AddView() {
ActionContext ctx = ActionContext.getContext();
/*查询所有的Employee信息*/
List<Employee> employeeList = employeeDAO.QueryAllEmployeeInfo();
ctx.put("employeeList", employeeList);
return "add_view";
}
public String Addcsh() {
ActionContext ctx = ActionContext.getContext();
/*查询所有的Employee信息*/
List<Employee> employeeList = employeeDAO.QueryAllEmployeeInfo();
ctx.put("employeeList", employeeList);
return "add_csh";
}
//####初始化工资信息
/*添加Wages信息*/
@SuppressWarnings("deprecation")
public String AddWagescsh() {
ActionContext ctx = ActionContext.getContext();
List yuefen=new ArrayList();
yuefen.add("201701");
yuefen.add("201702");
yuefen.add("201703");
yuefen.add("201704");
yuefen.add("201705");
yuefen.add("201706");
yuefen.add("201707");
yuefen.add("201708");
yuefen.add("201709");
yuefen.add("201710");
yuefen.add("201711");
yuefen.add("201712");
try {
if(true) {
Employee employee = employeeDAO.GetEmployeeByLoadId(wages.getEmployee().getEmployeeid());
wages.setEmployee(employee);
}
//String id=employee.getEmployeeid().toString();
//List<Employee> employeeList = employeeDAO.QueryAllEmployeeInfo();
for (int i = 0; i < yuefen.size(); i++) {
wages.setWagesid(wages.getEmployee().getEmployeeid().toString()+yuefen.get(i));
wages.setEmployee(employeeDAO.GetEmployeeByLoadId(wages.getEmployee().getEmployeeid()));
wages.setZf("未支付");
wagesDAO.AddWages(wages);
}
ctx.put("message", java.net.URLEncoder.encode("Wages添加成功!"));
return "add_success";
} catch (Exception e) {
e.printStackTrace();
ctx.put("error", java.net.URLEncoder.encode("Wages添加失败!"));
return "error";
}
}
//当前日期
SimpleDateFormat sdfdb=new SimpleDateFormat("yyyy-MM");
java.util.Date datedb=new java.util.Date();
String strdb=sdfdb.format(datedb);
//当前日期
SimpleDateFormat sdfjs=new SimpleDateFormat("yyyy-MM-dd");
java.util.Date datejs=new java.util.Date();
String strjs=sdfjs.format(datejs);
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
//####计算本月工资全勤信息
/*添加Wages信息*/
@SuppressWarnings("deprecation")
public String AddWagesjs() {
ActionContext ctx = ActionContext.getContext();
try {
//查询全部人员
List<Employee> employeeList = employeeDAO.QueryAllEmployeeInfo();
//查询全部签到
for(Employee employeetem:employeeList){
int sum=0;
List<Clock> clocllist=(List<Clock>)clockDAO.QueryAllClockInfojs(employeetem.getEmployeeid(),strdb);
for(Clock clocktem:clocllist){
long strsb=Long.valueOf(clocktem.getSbdate().replaceAll("[-\\s:]",""));
long strxb=Long.valueOf(clocktem.getXbdate().replaceAll("[-\\s:]",""));
String sb="09:00:00";
String xb="18:00:00";
long strsbsj=Long.valueOf(sb.replaceAll("[-\\s:]",""));
long strxbsj=Long.valueOf(xb.replaceAll("[-\\s:]",""));