📄 clerkoperationservice.java
字号:
package com.datang.struts.service;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import com.datang.struts.common.ClerkCommon;
import com.datang.struts.common.DbCommon;
import com.datang.struts.daoface.ClerkPlanDao;
import com.datang.struts.daoface.ClerkTaskDao;
import com.datang.struts.daofactory.ClerkDaoFactory;
import com.datang.struts.dto.TangEmployee;
import com.datang.struts.dto.TangPlan;
import com.datang.struts.dto.TangPlanPro;
import com.datang.struts.dto.TangTask;
import com.datang.struts.form.AddPlanForm;
import com.datang.struts.form.DeletePlanForm;
import com.datang.struts.form.SelectPlanForm;
import com.datang.struts.form.ShowClerkTaskForm;
import com.datang.struts.form.ShowClerkTaskPlanForm;
import com.datang.struts.form.ShowFeedbackForm;
import com.datang.struts.form.UpdateFeedbackForm;
public class ClerkOperationService {
public int showClerkTask(ActionForm form,HttpServletRequest request){
ShowClerkTaskForm showClerkTaskForm = (ShowClerkTaskForm)form;
ClerkDaoFactory cdf = ClerkDaoFactory.newInstance();
ClerkTaskDao ctd = cdf.createClerkTaskDao();
TangTask task = new TangTask();
HttpSession session = request.getSession();
TangEmployee employee = (TangEmployee)session.getAttribute("LOGIN_TANGEMPLOYEE");
//shili
// employee = new TangEmployee();
// employee.setEmployee_id("C001");
// employee.setEmployee_name("TOM");
if(employee == null){
return ClerkCommon.NOT_LOGIN_EMPLOYEE;
}
String manager_name = ctd.selectManager_name(employee.getEmployee_id());
task.setClerk_id(employee.getEmployee_id());
ArrayList al = ctd.selectClerkTask(task);
if(al != null||manager_name!=null){
session.setAttribute("TangTask_List", al);
showClerkTaskForm.setTasklist(al);
showClerkTaskForm.setManager_name(manager_name);
return ClerkCommon.SHOW_CLERKTASK_RIGHT;
}else{
return ClerkCommon.SHOW_CLERKTASK_ERROR;
}
}
public int showClerkTaskPlan(ActionForm form,HttpServletRequest request){
ShowClerkTaskPlanForm showClerkTaskPlanForm = (ShowClerkTaskPlanForm)form;
int task_id = showClerkTaskPlanForm.getTask_id();
HttpSession session = request.getSession();
if(task_id <= 0){
Integer id = (Integer)session.getAttribute("TangTask_ID");
if(id == null){
return ClerkCommon.SHOW_CLERKTASKPLAN_ERROR;
}
task_id = id.intValue();
}
TangEmployee employee = (TangEmployee)session.getAttribute("LOGIN_TANGEMPLOYEE");
//shili
// employee = new TangEmployee();
// employee.setEmployee_id("C001");
// employee.setEmployee_name("TOM");
if(employee == null){
return ClerkCommon.NOT_LOGIN_EMPLOYEE;
}
ArrayList tasklist = (ArrayList)session.getAttribute("TangTask_List");
if(tasklist == null){
return ClerkCommon.SHOW_CLERKTASKPLAN_ERROR;
}
Iterator it = tasklist.iterator();
while(it.hasNext()){
TangTask task = (TangTask)it.next();
if(task_id == task.getTask_id()){
showClerkTaskPlanForm.setTask(task);
session.setAttribute("TangTask_ID", task_id);
break;
}
}
ClerkDaoFactory cdf = ClerkDaoFactory.newInstance();
ClerkPlanDao cpd = cdf.createClerkPlanDao();
TangPlanPro planpro = new TangPlanPro();
planpro.setTask_id(task_id);
planpro.setClerk_id(employee.getEmployee_id());
ArrayList planlist = cpd.selectClerkPlan(planpro);
if(planlist == null){
return ClerkCommon.SHOW_CLERKTASKPLAN_ERROR;
}
session.setAttribute("TangPlan_List", planlist);
showClerkTaskPlanForm.setClerk_name(employee.getEmployee_name());
showClerkTaskPlanForm.setPlanlist(planlist);
return ClerkCommon.SHOW_CLERKTASKPLAN_RIGHT;
}
public int addPlan(ActionForm form,HttpServletRequest request){
AddPlanForm addPlanForm = (AddPlanForm)form;
HttpSession session = request.getSession();
Integer id = (Integer)session.getAttribute("TangTask_ID");
if(id == null){
return ClerkCommon.ADD_CLERKPLAN_ERROR;
}
int task_id = id.intValue();
TangEmployee employee = (TangEmployee)session.getAttribute("LOGIN_TANGEMPLOYEE");
//shili
// employee = new TangEmployee();
// employee.setEmployee_id("C001");
// employee.setEmployee_name("TOM");
if(employee == null){
return ClerkCommon.NOT_LOGIN_EMPLOYEE;
}
ClerkDaoFactory cdf = ClerkDaoFactory.newInstance();
ClerkPlanDao cpd = cdf.createClerkPlanDao();
TangPlan plan = new TangPlan();
plan.setClerk_id(employee.getEmployee_id());
plan.setTask_id(task_id);
plan.setPlan_name(addPlanForm.getPlan_name());
plan.setPlan_description(addPlanForm.getPlan_description());
plan.setPlan_state("not");
plan.setPlan_feedback("not");
Date plan_start = Date.valueOf(addPlanForm.getPlan_start());
plan.setPlan_start(plan_start);
Date plan_end = Date.valueOf(addPlanForm.getPlan_end());
plan.setPlan_end(plan_end);
plan.setPlan_exp_end(plan_end);
int current = cpd.addClerkPlan(plan);
if(DbCommon.INSERT_CLERKPLAN_RIGHT == current){
return ClerkCommon.ADD_CLERKPLAN_RIGHT;
}else{
return ClerkCommon.ADD_CLERKPLAN_ERROR;
}
}
public int deletePlan(ActionForm form,HttpServletRequest request){
DeletePlanForm deletePlanForm = (DeletePlanForm)form;
ClerkDaoFactory cdf = ClerkDaoFactory.newInstance();
ClerkPlanDao cpd = cdf.createClerkPlanDao();
int[] idarray = deletePlanForm.getIdarray();
for(int i=0;i<idarray.length;i++){
TangPlan plan = new TangPlan();
plan.setPlan_id(idarray[i]);
cpd.deleteClerkPlan(plan);
}
return ClerkCommon.DELETE_PLAN_RIGHT;
}
public int selectPlan(ActionForm form,HttpServletRequest request){
SelectPlanForm selectPlanForm = (SelectPlanForm)form;
HttpSession session = request.getSession();
ArrayList tasklist = (ArrayList)session.getAttribute("TangTask_List");
if(tasklist == null){
int i = showClerkTask(new ShowClerkTaskForm(),request);
if(i == ClerkCommon.SHOW_CLERKTASK_RIGHT){
tasklist = (ArrayList)session.getAttribute("TangTask_List");
}else{
return ClerkCommon.SELECT_PLAN_ERROR;
}
}
selectPlanForm.setTasklist(tasklist);
if(selectPlanForm.getPlan_name()==null && selectPlanForm.getTask_id()<=0
&& selectPlanForm.getPlan_start_fir()==null
&& selectPlanForm.getPlan_end_sec() == null
&& selectPlanForm.getPlan_end_fir() == null
&& selectPlanForm.getPlan_end_sec() == null
&& selectPlanForm.getPlan_feedback() == null){
return ClerkCommon.SELECT_PLAN_RIGHT;
}
ClerkDaoFactory cdf = ClerkDaoFactory.newInstance();
ClerkPlanDao cpd = cdf.createClerkPlanDao();
TangEmployee employee = (TangEmployee)session.getAttribute("LOGIN_TANGEMPLOYEE");
//shili
// employee = new TangEmployee();
// employee.setEmployee_id("C001");
// employee.setEmployee_name("TOM");
if(employee == null){
return ClerkCommon.NOT_LOGIN_EMPLOYEE;
}
TangPlanPro planpro = new TangPlanPro();
planpro.setClerk_id(employee.getEmployee_id());
planpro.setTask_id(selectPlanForm.getTask_id());
Iterator it = tasklist.iterator();
while(it.hasNext()){
TangTask task = (TangTask)it.next();
if(selectPlanForm.getTask_id()==task.getTask_id()){
selectPlanForm.setTask_name(task.getTask_name());
}
}
if((!"".equals(selectPlanForm.getPlan_start_fir())) && (!"".equals(selectPlanForm.getPlan_start_sec()))){
planpro.setPlan_start_fir(Date.valueOf(selectPlanForm.getPlan_start_fir()));
planpro.setPlan_start_sec(Date.valueOf(selectPlanForm.getPlan_start_sec()));
}
if((!"".equals(selectPlanForm.getPlan_end_fir())) && (!"".equals(selectPlanForm.getPlan_end_sec()))){
planpro.setPlan_end_fir(Date.valueOf(selectPlanForm.getPlan_end_fir()));
planpro.setPlan_end_sec(Date.valueOf(selectPlanForm.getPlan_end_sec()));
}
if(!"".equals(selectPlanForm.getPlan_feedback())){
planpro.setPlan_feedback(selectPlanForm.getPlan_feedback());
}
if(!"".equals(selectPlanForm.getPlan_name())){
planpro.setPlan_name(selectPlanForm.getPlan_name());
}
ArrayList planlist = cpd.selectClerkPlan(planpro);
selectPlanForm.setPlanlist(planlist);
return ClerkCommon.SELECT_PLAN_RIGHT;
}
public int updateFeedback(ActionForm form,HttpServletRequest request){
UpdateFeedbackForm updateFeedbackForm = (UpdateFeedbackForm)form;
HttpSession session = request.getSession();
TangPlan plan = (TangPlan)session.getAttribute("TangPlan");
if(plan == null){
return ClerkCommon.UPDATE_FEEDBACK_ERROR;
}
plan.setPlan_state(updateFeedbackForm.getPlan_state());
plan.setPlan_feedback(updateFeedbackForm.getPlan_feedback());
plan.setPlan_feedback_msg(updateFeedbackForm.getPlan_feedback_msg());
ClerkDaoFactory cdf = ClerkDaoFactory.newInstance();
ClerkPlanDao cpd = cdf.createClerkPlanDao();
int current = cpd.updateClerkPlan(plan);
if(current == DbCommon.UPDATE_CLERKPLAN_RIGHT){
return ClerkCommon.UPDATE_FEEDBACK_RIGHT;
}else{
return ClerkCommon.UPDATE_FEEDBACK_ERROR;
}
}
public int initSelectPlan(ActionForm form,HttpServletRequest request){
SelectPlanForm selectplan = (SelectPlanForm)form;
HttpSession session = request.getSession();
ArrayList al = (ArrayList) session.getAttribute("TangTask_List");
if(al == null||al.isEmpty()){
ClerkDaoFactory cdf = ClerkDaoFactory.newInstance();
ClerkTaskDao ctd = cdf.createClerkTaskDao();
TangTask task = new TangTask();
TangEmployee employee = (TangEmployee)session.getAttribute("TangEmployee");
if(employee == null){
return ClerkCommon.NOT_LOGIN_EMPLOYEE;
}
task.setClerk_id(employee.getEmployee_id());
al = ctd.selectClerkTask(task);
session.setAttribute("TangTask_List", al);
selectplan.setTasklist(al);
return 0;
}
return 0;
}
public int showFeedback(ActionForm form,HttpServletRequest request){
ShowFeedbackForm showFeedbackForm = (ShowFeedbackForm)form;
int plan_id = showFeedbackForm.getPlan_id();
HttpSession session = request.getSession();
ArrayList planlist = (ArrayList)session.getAttribute("TangPlan_List");
if(planlist == null){
return ClerkCommon.SHOW_FEEDBACK_ERROR;
}
Iterator it = planlist.iterator();
while(it.hasNext()){
TangPlan plan = (TangPlan)it.next();
if(plan_id == plan.getPlan_id()){
showFeedbackForm.setPlan(plan);
session.setAttribute("TangPlan", plan);
return ClerkCommon.SHOW_FEEDBACK_RIGHT;
}
}
return ClerkCommon.SHOW_FEEDBACK_ERROR;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -