package com.msd.affair.projectRenew.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.msd.affair.base.BaseAction;
import com.msd.affair.base.bean.Condition;
import com.msd.affair.base.bean.Sys;
import com.msd.affair.base.service.SysService;
import com.msd.affair.base.util.JacksonHelper;
import com.msd.affair.client.entity.Cus;
import com.msd.affair.client.service.CusService;
import com.msd.affair.projectRenew.entity.Project;
import com.msd.affair.projectRenew.service.ProjectService;
import com.msd.affair.system.entity.User;
import com.msd.affair.system.service.UserService;
public class ProjectAction extends BaseAction {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(ProjectAction.class);
private ProjectService projectService;
private UserService userService;
private SysService sysService;
private Project project=new Project();
private CusService cusService;
private Integer proId;
private Condition condition=new Condition();
/**
*分页查询
*/
public String list() {
/*
String orderField = req().getParameter("orderField");
String pageNum = req().getParameter("pageNum");
*/
project=new Project();
List<Cus> cusList=new ArrayList<Cus>();
Cus c1=new Cus();
c1.setId(1);
c1.setCus_name("能达");
Cus c2=new Cus();
c2.setId(2);
c2.setCus_name("安能");
Cus c3=new Cus();
c3.setId(3);
c3.setCus_name("中铁");
Cus c4=new Cus();
c4.setId(4);
c4.setCus_name("申通");
Cus c5=new Cus();
c5.setId(5);
c5.setCus_name("汇通");
cusList.add(c1);
cusList.add(c2);
cusList.add(c3);
cusList.add(c4);
cusList.add(c5);
req().setAttribute("cusList", cusList);
try {
int totalCount=projectService.getCount(condition);//总记录数
Map<String, Object> map = new HashMap<String, Object>();
map.put("page", page);
map.put("cusId", condition.getCusId());
map.put("projectName",condition.getProjectName());
map.put("projectManager", condition.getProjectManager());
map.put("projectDeveloper", condition.getProjectDeveloper());
map.put("projectCommissioner", condition.getProjectCommissioner());
map.put("stateId", condition.getStateId());
map.put("createDate", condition.getCreateDate());
map.put("startDate", condition.getStartDate());
map.put("onlineDate", condition.getOnlineDate());
map.put("orderBy", condition.getOrderBy());
List<Project> projectList=null;
if(totalCount > 0){
projectList = projectService.selectProjectList(map);
}
page.setTotalCount(totalCount);
req().setAttribute("totalCount", totalCount);
req().setAttribute("projectList", projectList);
req().setAttribute("map", map);
} catch (Exception e) {
log.error("list【项目】公告出错 ==> " + e);
resJson.setStatusCode("300");
resJson.setMessage("系统异常。");
out().print(JacksonHelper.toJSON(resJson));
}
return "success";
}
/**
* 添加初始化
*/
public String toInsert() {
try {
project=new Project();
List<Cus> cusList=new ArrayList<Cus>();
Cus c1=new Cus();
c1.setId(1);
c1.setCus_name("能达");
Cus c2=new Cus();
c2.setId(2);
c2.setCus_name("安能");
Cus c3=new Cus();
c3.setId(3);
c3.setCus_name("中铁");
Cus c4=new Cus();
c4.setId(4);
c4.setCus_name("申通");
Cus c5=new Cus();
c5.setId(5);
c5.setCus_name("汇通");
cusList.add(c1);
cusList.add(c2);
cusList.add(c3);
cusList.add(c4);
cusList.add(c5);
req().setAttribute("cusList", cusList);
//加载状态
List<Sys> statuList=sysService.selectListBySysId("sys_001");
req().setAttribute("statuList", statuList);
//查询所有项目经理
List<User> managerList=userService.selectUserAll("项目部");
req().setAttribute("managerList", managerList);
//查询所有开发部人员
List<User> developerList=userService.selectUserAll("开发部");
req().setAttribute("developerList", developerList);
} catch (Exception e) {
log.error("toInsert【项目】公告出错 ==> " + e);
}
return "success";
}
/**
* 项目操作(新增/更新)
*/
public void insert() {
try {
if(project.getId()==null || "".equals(project.getId())){
//新增操作
projectService.insertProject(project);
}else{
//更新操作
projectService.updateProjectById(project);
}
resJson.setStatusCode("200");
resJson.setMessage("操作成功");
resJson.setForwardUrl("project/projectList.action");
resJson.setNavTabId("projectList");
resJson.setCallbackType("closeCurrent");
resJson.setRel("");
} catch (Exception e) {
log.error("insert【项目】公告出错 ==> " + e);
resJson.setStatusCode("300");
resJson.setMessage("系统异常。");
}
out().print(JacksonHelper.toJSON(resJson));
}
/**
* 删除项目
*/
public void delete() {
try {
String id=req().getParameter("proId");
projectService.deleteById(id);
resJson.setStatusCode("200");
resJson.setMessage("操作成功");
resJson.setForwardUrl("project/projectList.action");
resJson.setNavTabId("projectList");
// resJson.setCallbackType("closeCurrent");
resJson.setRel("");
} catch (Exception e) {
log.error("delete【项目】公告出错 ==> " + e);
resJson.setStatusCode("300");
resJson.setMessage("系统异常。");
}
out().print(JacksonHelper.toJSON(resJson));
}
/**
* 项目编辑
*/
public String toEdit() {
try {
String id=req().getParameter("proId");
List<Project> list=projectService.findProjectById(id);
Project pro=null;
if(list!=null && list.size()==1){
pro=list.get(0);
}
req().setAttribute("project", pro);
//查询所有项目经理
List<User> managerList=userService.selectUserAll("项目部");
req().setAttribute("managerList", managerList);
//查询所有开发部人员
List<User> developerList=userService.selectUserAll("开发部");
req().setAttribute("developerList", developerList);
//加载状态
List<Sys> statuList=sysService.selectListBySysId("sys_001");
req().setAttribute("statuList", statuList);
List<Cus> cusList=new ArrayList<Cus>();
Cus c1=new Cus();
c1.setId(1);
c1.setCus_name("能达");
Cus c2=new Cus();
c2.setId(2);
c2.setCus_name("安能");
Cus c3=new Cus();
c3.setId(3);
c3.setCus_name("中铁");
Cus c4=new Cus();
c4.setId(4);
c4.setCus_name("申通");
Cus c5=new Cus();
c5.setId(5);
c5.setCus_name("汇通");
cusList.add(c1);
cusList.add(c2);
cusList.add(c3);
cusList.add(c4);
cusList.add(c5);
req().setAttribute("cusList", cusList);
} catch (Exception e) {
log.error("toEdit【项目】公告出错 ==> " + e);
}
return SUCCESS;
}
/**
* 高级检索查询
* @return
*/
public String detailQuery() {
try {
//查询所有项目经理
List<User> managerList=userService.selectUserAll("项目部");
req().setAttribute("managerList", managerList);
//查询所有开发部人员
List<User> developerList=userService.selectUserAll("开发部");
req().setAttribute("developerList", developerList);
//加载状态
List<Sys> statuList=sysService.selectListBySysId("sys_001");
req().setAttribute("statuList", statuList);
List<Cus> cusList=new ArrayList<Cus>();
Cus c1=new Cus();
c1.setId(1);
c1.setCus_name("能达");
Cus c2=new Cus();
c2.setId(2);
c2.setCus_name("安能");
Cus c3=new Cus();
c3.setId(3);
c3.setCus_name("中铁");
Cus c4=new Cus();
c4.setId(4);
c4.setCus_name("申�
- 1
- 2
- 3
前往页