首页>代码>全站功能最佳UI体验最好的一套基于SpringMVC+Spring+Mybatis的商户管理系统,值得学习!>/FHSHGL/src/com/fh/controller/erp/allcustomer/AllCustomerController.java
package com.fh.controller.erp.allcustomer; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; import javax.annotation.Resource; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.fh.controller.base.BaseController; import com.fh.entity.Page; import com.fh.service.erp.customer.CustomerManager; import com.fh.service.erp.goods.GoodsManager; import com.fh.service.erp.level.LevelManager; import com.fh.service.erp.remarks.RemarksManager; import com.fh.util.Jurisdiction; import com.fh.util.ObjectExcelView; import com.fh.util.PageData; import com.fh.util.Tools; /** * 说明:所有客户 * 创建人: * 创建时间:2017-03-04 */ @Controller @RequestMapping(value="/allcustomer") public class AllCustomerController extends BaseController { String menuUrl = "allcustomer/list.do"; //菜单地址(权限用) @Resource(name="customerService") private CustomerManager customerService; @Resource(name="remarksService") private RemarksManager remarksService; @Resource(name="levelService") private LevelManager levelService; @Resource(name="goodsService") private GoodsManager goodsService; /**列表 * @param page * @throws Exception */ @RequestMapping(value="/list") public ModelAndView list(Page page) throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"列表Customer"); //if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;} //校验权限(无权查看时页面会有提示,如果不注释掉这句代码就无法进入列表页面,所以根据情况是否加入本句代码) ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); String keywords = pd.getString("keywords"); //关键词检索条件 if(null != keywords && !"".equals(keywords)){ pd.put("keywords", keywords.trim()); } String lastLoginStart = pd.getString("lastStart"); //开始时间 String lastLoginEnd = pd.getString("lastEnd"); //结束时间 if(lastLoginStart != null && !"".equals(lastLoginStart)){ pd.put("lastStart", lastLoginStart+" 00:00:00"); } if(lastLoginEnd != null && !"".equals(lastLoginEnd)){ pd.put("lastEnd", lastLoginEnd+" 00:00:00"); } page.setPd(pd); List<PageData> varList = customerService.list(page); //列出Customer列表 mv.setViewName("erp/customer/allcustomer_list"); mv.addObject("varList", varList); mv.addObject("pd", pd); mv.addObject("QX",Jurisdiction.getHC()); //按钮权限 return mv; } /**库存盘点 * @return * @throws Exception */ @RequestMapping(value="/kucunchar") public ModelAndView kucunchar() throws Exception{ ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); String USERNAME = pd.getString("USERNAME"); USERNAME = Tools.notEmpty(USERNAME)?USERNAME:Jurisdiction.getUsername(); pd.put("USERNAME", USERNAME); List<PageData> goodsList = goodsService.listAll(pd); String[] color = {"AFD8F8","F6BD0F","8BBA00","FF8E46","008E8E","D64646","8E468E","588526","B3AA00","008ED6","9D080D","A186BE"}; String strXML = "<graph caption='商品库存盘点' xAxisName='商品名' yAxisName='库存' decimalPrecision='0' formatNumberScale='0' baseFontSize='13'>"; Random rand = new Random(); for(int i=0;i<goodsList.size();i++){ PageData goodsPd = goodsList.get(i); strXML += "<set name='"+goodsPd.getString("TITLE")+"' value='"+goodsPd.get("ZCOUNT").toString()+"' color='"+color[rand.nextInt(11)]+"'/>"; } mv.addObject("strXML", strXML+"</graph>"); mv.setViewName("erp/kucun/kucun_char"); return mv; } /**导出到excel * @param * @throws Exception */ @RequestMapping(value="/excel") public ModelAndView exportExcel() throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"导出Customer到excel"); if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;} ModelAndView mv = new ModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); Map<String,Object> dataMap = new HashMap<String,Object>(); List<String> titles = new ArrayList<String>(); titles.add("姓名"); //1 titles.add("年龄"); //2 titles.add("手机"); //3 titles.add("地址"); //4 titles.add("QQ"); //5 titles.add("微信"); //6 titles.add("建档时间"); //7 titles.add("消费金额"); //8 titles.add("级别"); //9 titles.add("备注1"); //10 titles.add("备注2"); //11 dataMap.put("titles", titles); List<PageData> varOList = customerService.listAll(pd); List<PageData> varList = new ArrayList<PageData>(); for(int i=0;i<varOList.size();i++){ PageData vpd = new PageData(); vpd.put("var1", varOList.get(i).getString("NAME")); //1 vpd.put("var2", varOList.get(i).getString("AGE")); //2 vpd.put("var3", varOList.get(i).get("PHONE").toString()); //3 vpd.put("var4", varOList.get(i).getString("ADDRESS")); //4 vpd.put("var5", varOList.get(i).get("QQ").toString()); //5 vpd.put("var6", varOList.get(i).getString("WEIXIN")); //6 vpd.put("var7", varOList.get(i).getString("CTIME")); //7 vpd.put("var8", varOList.get(i).get("MONEY").toString()); //8 vpd.put("var9", varOList.get(i).getString("LEVEL")); //9 vpd.put("var10", varOList.get(i).getString("REMARKS1")); //10 vpd.put("var11", varOList.get(i).getString("REMARKS2")); //11 varList.add(vpd); } dataMap.put("varList", varList); ObjectExcelView erv = new ObjectExcelView(); mv = new ModelAndView(erv,dataMap); return mv; } @InitBinder public void initBinder(WebDataBinder binder){ DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true)); } }
![](https://static.zuidaima.com/resource/img/heart_ico.png)
![](https://static.zuidaima.com/resource/img/cattle_ico.png)
TY0165 LV20
6月20日
全斐 LV6
6月19日
bingo111
5月25日
暂无贡献等级
yangguang LV8
5月19日
李俊雄 LV3
5月8日
zolscy LV12
4月23日
xiaozhi丶 LV15
3月24日
微信网友_6902352269217792 LV3
3月12日
Gin19960217 LV4
1月15日
123456wadff LV3
1月15日