123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- package com.zhcs.dt.controller.information.monthProgress;
- import java.math.BigDecimal;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import javax.annotation.Resource;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import com.zhcs.dt.controller.base.BaseController;
- import com.zhcs.dt.entity.Page;
- import com.zhcs.dt.service.information.monthProgress.YbfManager;
- import com.zhcs.dt.util.AppUtil;
- import com.zhcs.dt.util.Jurisdiction;
- import com.zhcs.dt.util.PageData;
- /**
- * 类名称:预备费
- * 创建人:zhengfei
- * 创建时间:2019-04-09
- */
- @Controller
- @RequestMapping(value="/ybf")
- class YbfController extends BaseController {
- String menuUrl = "ybf/list.do"; //菜单地址(权限用)
- String pageUrl = "information/monthProgress/ybf/";
-
- private final String MSG_SAVE = "save";
- private final String MSG_EDIT = "edit";
-
-
- @Resource(name="ybfManagerService")
- private YbfManager ybfManagerService;
-
- /**列表
- * @param page
- * @throws Exception
- */
- @RequestMapping(value="/list")
- public ModelAndView list(Page page) throws Exception{
- logBefore(logger, Jurisdiction.getUsername()+"预备费");
- //if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;} //校验权限(无权查看时页面会有提示,如果不注释掉这句代码就无法进入列表页面,所以根据情况是否加入本句代码)
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- List<PageData> loadCostList = ybfManagerService.findTotalCostByCompanyAndYear(pd);
- if(null != loadCostList && !loadCostList.isEmpty()){
- List<PageData> ybfList = ybfManagerService.listAll(pd);
- for (PageData l : loadCostList) {
- String loadId = l.getString("ROAD_ID");
- List<PageData> loadList = new ArrayList<PageData>();
-
- BigDecimal total = new BigDecimal(0);
- for (PageData y : ybfList){
- if(loadId.equals(y.getString("ROAD_ID"))){
- loadList.add(y);
- if(null != y.get("ACTUAL_COST"))
- total = total.add((BigDecimal)y.get("ACTUAL_COST"));
-
- }
- }
- l.put("count", loadList.size());
- l.put("total", total.toString());
- l.put("loadList", loadList);
- }
- }
- mv.setViewName(pageUrl+"ybf_list");
- mv.addObject("loadCostList", loadCostList);
- mv.addObject("pd",pd);
- mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
- return mv;
- }
-
-
- /**
- * 去新增页面
- *
- * @param
- * @throws Exception
- */
- @RequestMapping(value = "/goAdd")
- public ModelAndView goAdd() throws Exception {
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- mv.setViewName(pageUrl+"ybf_edit");
- pd.put("table", "oa_department_"+pd.getString("year").toString());
- List<PageData> loadData = ybfManagerService.findLoadByParentId(pd);
- mv.addObject("loadData",loadData);
- mv.addObject("msg", MSG_SAVE);
- mv.addObject("pd", pd);
- return mv;
- }
-
-
- /**
- * 去修改页面
- *
- * @param
- * @throws Exception
- */
- @RequestMapping(value = "/goEdit")
- public ModelAndView goEdit() throws Exception {
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- pd = ybfManagerService.findByCompanyAndLoadAndYearAndProjectName(pd);
- mv.setViewName(pageUrl+"ybf_edit");
- mv.addObject("msg",MSG_EDIT);
- mv.addObject("pd", pd);
- return mv;
- }
-
-
- /**
- * 保存
- *
- * @param
- * @throws Exception
- */
- @RequestMapping(value = "/save",method=RequestMethod.POST)
- @ResponseBody
- public Object save() throws Exception {
- logBefore(logger, Jurisdiction.getUsername() + "新增预备费");
- if (!Jurisdiction.buttonJurisdiction(menuUrl, "add")) {
- return null;
- } // 校验权限
- PageData pd = new PageData();
- pd = this.getPageData();
-
- ybfManagerService.save(pd);
-
- Map<String,String> map = new HashMap<String,String>();
- map.put("result", "success");
- return AppUtil.returnObject(new PageData(), map);
- }
-
- /**判断路段项目是否存在
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/checkProjectName")
- @ResponseBody
- public Object checkProjectName()throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- PageData pd = new PageData();
- pd = this.getPageData();
- String tipmsg = "success";
-
- List<PageData> list = ybfManagerService.checkLoadId(pd);
- if(null == list || list.size()==0){
- tipmsg = "error";
- map.put("result", tipmsg);
- map.put("error", "该路段计划金额为空");
- return AppUtil.returnObject(new PageData(), map);
- }
-
- String msg = pd.getString("msg");
- PageData data = ybfManagerService.findByCompanyAndLoadAndYearAndProjectName(pd);
- if(MSG_SAVE.equals(msg) && null != data){
- tipmsg = "error";
- map.put("error", "该项目名称已存在");
- }else{
- if(null != data && !pd.getString("oldProjectName").equals(pd.getString("projectName"))){
- tipmsg = "error";
- map.put("error", "该项目名称已存在");
- }
- }
-
- //查询系统已存在的养护计划
- map.put("result", tipmsg);
- return AppUtil.returnObject(new PageData(), map);
- }
- /**删除预备费
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/del")
- @ResponseBody
- public Object delAnnualPlan()throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- PageData pd = new PageData();
- pd = this.getPageData();
- try{
- ybfManagerService.delete(pd);
- map.put("result", "success");
- }catch(Exception e){
- map.put("result", "删除失败");
- }
- return AppUtil.returnObject(new PageData(), map);
- }
-
- /**
- *
- * @Title: checkLoadId
- * @Description: 校验预备费是否存在
- * @param @return
- * @param @throws Exception
- * @return Object
- * @throws
- */
- @RequestMapping(value = "/checkLoadId")
- @ResponseBody
- public Object checkLoadId() throws Exception {
-
- Map<String,String> map = new HashMap<String,String>();
- PageData pd = new PageData();
- pd = this.getPageData();
- map.put("result", "error");
- try{
- List<PageData> list = ybfManagerService.checkLoadId(pd);
- if(null != list && list.size() >0)
- map.put("result", "success");
- }catch(Exception e){
- e.printStackTrace();
- }
-
- return AppUtil.returnObject(new PageData(), map);
- }
- }
|