package com.ts.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.ts.dao.imp.GotripDAO;
import com.ts.dao.imp.LeaveDAO;
import com.ts.service.UserService;
import com.ts.vo.Gotrip;
import com.ts.vo.Leave;
import com.ts.vo.Users;

public class CheckWorkAction extends ActionSupport {
	private LeaveDAO leaveDao;
	private GotripDAO gotripDao;
	private UserService userService;
	
	public Leave leave;
	public Gotrip gotrip;
	
	public int leaveid;
	private int flag;
	
	public int getLeaveid() {
		return leaveid;
	}
	public void setLeaveid(int leaveid) {
		this.leaveid = leaveid;
	}
	public int getFlag() {
		return flag;
	}
	public void setFlag(int flag) {
		this.flag = flag;
	}
	public Gotrip getGotrip() {
		return gotrip;
	}
	public void setGotrip(Gotrip gotrip) {
		this.gotrip = gotrip;
	}
	public Leave getLeave() {
		return leave;
	}
	public void setLeave(Leave leave) {
		this.leave = leave;
	}
	public UserService getUserService() {
		return userService;
	}
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	public LeaveDAO getLeaveDao() {
		return leaveDao;
	}
	public void setLeaveDao(LeaveDAO leaveDao) {
		this.leaveDao = leaveDao;
	}
	public GotripDAO getGotripDao() {
		return gotripDao;
	}
	public void setGotripDao(GotripDAO gotripDao) {
		this.gotripDao = gotripDao;
	}
	
	public String listLeaveCheckWorkAction(){
		HttpSession session = ServletActionContext.getRequest().getSession();
		Users user=(Users) session.getAttribute("user");
		List<Leave> list = leaveDao.findAll();
		List<Leave> leaveList=new ArrayList<Leave>();
		for(Leave l:list){
			if(l.getUseId().equals(user.getUserid())){
				l.setLeaveName(user.getUsername());
				if(l.getIsagree()==0){
					l.setAgree("同意");
				}else{
					l.setAgree("不同意");
				}
				if(l.getAgreeor().equals("0")){
					l.setAgreeor("还没批示");
				}
				leaveList.add(l);
			}
		}
		session.setAttribute("leaveList", leaveList);
		return "listLeaveusc";
	}
	public String listGotripCheckWorkAction(){
		HttpSession session = ServletActionContext.getRequest().getSession();
		Users user=(Users) session.getAttribute("user");
		List<Gotrip> list = gotripDao.findAll();
		List<Gotrip> gotripList=new ArrayList<Gotrip>();
		for(Gotrip l:list){
			if(l.getArrangeor().equals(user.getUsername())){
				l.setGotripName(userService.getUserById(l.getUserId()).getUsername());
				gotripList.add(l);
			}
		}
		session.setAttribute("gotripList", gotripList);
		
		return "listGotripusc";
	}
	public String addLeaveCheckWorkAction(){
		
		leaveDao.save(leave);
		return "listLeave";
	}
	public String addGotripCheckWorkAction(){
		
		gotripDao.save(gotrip);
		return "listAllGotrip";
	}
	
	public String listAllLeaveCheckWorkAction(){
		System.out.println("----------------------------------");
		HttpSession session = ServletActionContext.getRequest().getSession();
		List<Leave> list = leaveDao.findAll();
		System.out.println(list.size());
		for(Leave l:list){
				l.setLeaveName(userService.getUserById(l.getUseId()).getUsername());
				if(l.getIsagree()==0){
					l.setAgree("同意");
				}else{
					l.setAgree("不同意");
				}
				if(l.getAgreeor().equals("0")){
					System.out.println("----------------------------------");
					l.setAgreeor("还没批示");
				}
		}
		session.setAttribute("leaveList", list);
		return "listAllLeaveusc";
	}
	public String listAllGotripCheckWorkAction(){
		HttpSession session = ServletActionContext.getRequest().getSession();
		List<Gotrip> list = gotripDao.findAll();
		List<Gotrip> gotripList=new ArrayList<Gotrip>();
		for(Gotrip l:list){
				l.setGotripName(userService.getUserById(l.getUserId()).getUsername());
				if(l.getIsget()==0){
					l.setGet("收到");
				}else{
					l.setGet("没收到");
				}
				gotripList.add(l);
		}
		session.setAttribute("gotripList", gotripList);
		
		return "listAllGotripusc";
	}
	public String getCheckWorkAction(){
		HttpSession session = ServletActionContext.getRequest().getSession();
		
		Gotrip leave2 = gotripDao.findById(leaveid);
		System.out.println("----------------------------------");
		if(flag==0){
			//agree
			leave2.setIsget(0);
		}else{
			leave2.setIsget(1);
		}
		gotripDao.update(leave2);
		return "listGotrip";
	}
	public String agreeCheckWorkAction(){
		HttpSession session = ServletActionContext.getRequest().getSession();
		
		Leave leave2 = leaveDao.findById(leaveid);
		System.out.println("----------------------------------");
		String name=((Users)session.getAttribute("user")).getUsername();
		leave2.setAgreeor(name);
		System.out.println(leave2.getAgreeor());
		if(flag==0){
			//agree
			leave2.setIsagree(0);
		}else{
			leave2.setIsagree(1);
		}
		leaveDao.update(leave2);
		return "listAllLeave";
	}
}
最近下载更多
微信网友_5963854197018624  LV7 2023年4月6日
akbar2020  LV9 2022年9月4日
19857460815  LV1 2022年6月20日
zeze2580  LV2 2022年5月9日
wanglinddad  LV55 2022年3月26日
habiya  LV3 2022年3月14日
ds9527  LV2 2022年3月3日
MarkLee 琥珀川  LV13 2022年1月21日
小豆芽  LV8 2021年6月10日
xufei123  LV4 2021年6月2日
最近浏览更多
张泽帅  LV6 10月22日
krispeng  LV13 8月12日
9605451tjb  LV4 8月7日
yunsgui  LV1 6月25日
liyan54188  LV2 6月25日
暂无贡献等级
26737721  LV4 5月27日
jhyan127 2月18日
暂无贡献等级
米继宝是憨憨  LV4 1月29日
森sdfgf  LV8 1月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友