224 lines
6.2 KiB
Plaintext
224 lines
6.2 KiB
Plaintext
package com.bonus.bm.controller;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import com.bonus.bm.beans.ProjectManageBean;
|
|
import com.bonus.bm.service.ProjectManageService;
|
|
import com.bonus.core.DateTimeHelper;
|
|
import com.bonus.core.StringHelper;
|
|
import com.bonus.sys.AjaxRes;
|
|
import com.bonus.sys.BaseController;
|
|
import com.bonus.sys.GlobalConst;
|
|
import com.bonus.sys.Page;
|
|
import com.bonus.sys.beans.ZNode;
|
|
|
|
@Controller
|
|
@RequestMapping("/backstage/project/")
|
|
public class ProjectManageController extends BaseController<ProjectManageBean> {
|
|
|
|
@Autowired
|
|
private ProjectManageService pmService;
|
|
|
|
@RequestMapping("list")
|
|
public String index(Model model) {
|
|
return "/bm/projectManage";
|
|
}
|
|
|
|
@RequestMapping("projectTree")
|
|
public String unitTree(Model model) {
|
|
return "/bm/projectTree";
|
|
}
|
|
|
|
@RequestMapping(value = "findByPage", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes findByPage(Page<ProjectManageBean> page, ProjectManageBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
if (ar.setNoAuth(doSecurityIntercept(GlobalConst.RESOURCES_TYPE_MENU, "/backstage/project/list"))) {
|
|
try {
|
|
if (o != null && !"".equals(o.getEndTime())) {
|
|
String time = DateTimeHelper.getAddNumDay(o.getEndTime(), 1);
|
|
o.setEndTime(time);
|
|
}
|
|
Page<ProjectManageBean> station = pmService.findByPage(o, page);
|
|
Map<String, Object> p = new HashMap<String, Object>();
|
|
p.put("list", station);
|
|
ar.setSucceed(p);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "insert", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes insert(ProjectManageBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
ProjectManageBean bean = pmService.findByName(o.getName());
|
|
if (bean == null) {
|
|
String typeId = o.getTypeId1();
|
|
String companyId = o.getCompanyId1();
|
|
if("0".equals(typeId)||"0".equals(companyId)){
|
|
ar.setFailMsg("请选择所属分公司或者工程类别");
|
|
}else{
|
|
pmService.insert(o);
|
|
ar.setSucceedMsg(GlobalConst.SAVE_SUCCEED);
|
|
}
|
|
} else {
|
|
ar.setFailMsg("工程名称重复,请重新填写");
|
|
}
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.SAVE_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "update", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes update(ProjectManageBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
pmService.update(o);
|
|
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "find", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes find(ProjectManageBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
List<ProjectManageBean> list = pmService.find(o);
|
|
ar.setSucceed(list);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "getProjectType", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes getProjectType() {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
List<ProjectManageBean> list = pmService.getProjectType();
|
|
Map<String, Object> p = new HashMap<String, Object>();
|
|
p.put("list", list);
|
|
ar.setSucceed(p);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "getProjectName", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes getProjectName(ProjectManageBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
List<ProjectManageBean> list = pmService.getProjectName(o);
|
|
Map<String, Object> p = new HashMap<String, Object>();
|
|
p.put("list", list);
|
|
ar.setSucceed(p);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "getVolLever", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes getVolLever() {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
List<ProjectManageBean> list = pmService.getVolLever();
|
|
Map<String, Object> p = new HashMap<String, Object>();
|
|
p.put("list", list);
|
|
ar.setSucceed(p);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "findWorkTree", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes roleTree() {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
List<ZNode> list = pmService.findWorkTree();
|
|
ar.setSucceed(list);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
@RequestMapping(value = "projectTree", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes projectTree(ProjectManageBean o, HttpServletRequest req) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
List<ZNode> list = null;
|
|
if("0".equals(o.getUnitId())){
|
|
list = pmService.projectTree(o);
|
|
}else{
|
|
if (StringHelper.isNotEmpty(o.getUnitId())) {
|
|
list = pmService.projectTreeByUnitId(o);
|
|
} else {
|
|
list = pmService.projectTree(o);
|
|
}
|
|
}
|
|
String isOpen = req.getParameter("isOpen");
|
|
if (StringHelper.isNotEmpty(isOpen)) {
|
|
for (ZNode zNode : list) {
|
|
zNode.setOpen(true);
|
|
}
|
|
}
|
|
Map<String, Object> p = new HashMap<String, Object>();
|
|
p.put("list", list);
|
|
ar.setSucceed(p);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
@RequestMapping(value = "del", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes del(ProjectManageBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
pmService.delete(o);
|
|
ar.setSucceedMsg(GlobalConst.DEL_SUCCEED);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DEL_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
}
|