package com.zcloud.controller.bus; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import org.apache.shiro.authz.annotation.RequiresPermissions; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.util.DateUtil; import com.zcloud.util.ObjectExcelView; import com.zcloud.util.Tools; import com.zcloud.entity.PageData; import com.zcloud.service.bus.SysDateService; /** * 说明:系统日期 * 作者:luoxiaobao * 时间:2021-05-07 * 官网:www.zcloudchina.com */ @Controller @RequestMapping("/sysdate") public class SysDateController extends BaseController { @Autowired private SysDateService sysdateService; /**新增 * @param * @throws Exception */ @RequestMapping(value="/add") @ResponseBody public Object add() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("SYSDATE_ID", this.get32UUID()); //主键 pd.put("DATE", DateUtil.getDay()); pd.put("DAY_START", DateUtil.getDay()+" 00:00:00"); pd.put("DAY_END", DateUtil.getDay()+" 23:59:59"); pd.put("WEEK_START", DateUtil.getWeekStart()); pd.put("WEEK_END", DateUtil.getWeekEnd()); String year = DateUtil.getYear().toString(); String month = DateUtil.getMonth().toString(); Integer day = Integer.parseInt(DateUtil.getOnlyDay().toString()); String xunStartTime = year + "-" + month + "-"; String xunEndTime = year + "-" + month + "-"; if(day <= 10) { xunStartTime = xunStartTime+"01 00:00:00"; xunEndTime = xunEndTime+"10 23:59:59"; } else if(day > 10 && day <= 20) { xunStartTime = xunStartTime+"11 00:00:00"; xunEndTime = xunEndTime+"20 23:59:59"; } else { xunStartTime = xunStartTime+"21 00:00:00"; xunEndTime = DateUtil.getMonthEndDay()+" 23:59:59"; } pd.put("XUN_START", xunStartTime); pd.put("XUN_END", xunEndTime); pd.put("MONTH_START", DateUtil.getMonthFirstDay()+" 00:00:00"); pd.put("MONTH_END", DateUtil.getMonthEndDay()+" 23:59:59"); pd.put("QUARTER_START", DateUtil.quarterStart()+" 00:00:00"); pd.put("QUARTER_END", DateUtil.quarterEnd()+" 23:59:59"); String HalfYearStartTime = DateUtil.getYear().toString(); String HalfYearEndTime = DateUtil.getYear().toString(); Integer bmonth = Integer.parseInt(DateUtil.getMonth().toString()); if(bmonth <= 6) { HalfYearStartTime = HalfYearStartTime+"-01-01 00:00:00"; HalfYearEndTime = HalfYearEndTime+"-06-30 23:59:59"; } else if(bmonth > 6) { HalfYearStartTime = HalfYearStartTime+"-07-01 00:00:00"; HalfYearEndTime = HalfYearEndTime+"-12-31 23:59:59"; } pd.put("HALFYEAR_START", HalfYearStartTime); pd.put("HALFYEAR_END", HalfYearEndTime); pd.put("YEAR_START", DateUtil.getCurrYearFirst()+" 00:00:00"); pd.put("YEAR_END", DateUtil.getCurrYearLast()+" 23:59:59"); sysdateService.save(pd); map.put("result", errInfo); return map; } /**删除 * @param out * @throws Exception */ @RequestMapping(value="/delete") @RequiresPermissions("sysdate:del") @ResponseBody public Object delete() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); sysdateService.delete(pd); map.put("result", errInfo); //返回结果 return map; } /**修改 * @param * @throws Exception */ @RequestMapping(value="/edit") @RequiresPermissions("sysdate:edit") @ResponseBody public Object edit() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); sysdateService.edit(pd); map.put("result", errInfo); return map; } /**列表 * @param page * @throws Exception */ @RequestMapping(value="/list") @RequiresPermissions("sysdate:list") @ResponseBody public Object list(Page page) throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); page.setPd(pd); List varList = sysdateService.list(page); //列出SysDate列表 map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } /**去修改页面获取数据 * @param * @throws Exception */ @RequestMapping(value="/goEdit") @RequiresPermissions("sysdate:edit") @ResponseBody public Object goEdit() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = sysdateService.findById(pd); //根据ID读取 map.put("pd", pd); map.put("result", errInfo); return map; } /**批量删除 * @param * @throws Exception */ @RequestMapping(value="/deleteAll") @RequiresPermissions("sysdate:del") @ResponseBody public Object deleteAll() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String DATA_IDS = pd.getString("DATA_IDS"); if(Tools.notEmpty(DATA_IDS)){ String ArrayDATA_IDS[] = DATA_IDS.split(","); sysdateService.deleteAll(ArrayDATA_IDS); errInfo = "success"; }else{ errInfo = "fail"; } map.put("result", errInfo); //返回结果 return map; } /**导出到excel * @param * @throws Exception */ @RequestMapping(value="/excel") @RequiresPermissions("toExcel") public ModelAndView exportExcel() throws Exception{ ModelAndView mv = new ModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); Map dataMap = new HashMap(); List titles = new ArrayList(); titles.add("日期"); //1 titles.add("日-开始时间"); //2 titles.add("日-结束时间"); //3 titles.add("周-开始时间"); //4 titles.add("周-结束时间"); //5 titles.add("旬-开始时间"); //6 titles.add("旬-结束时间"); //7 titles.add("月-开始时间"); //8 titles.add("月-结束时间"); //9 titles.add("季-开始时间"); //10 titles.add("季-结束时间"); //11 titles.add("半年-开始时间"); //12 titles.add("半年-结束时间"); //13 titles.add("年-开始时间"); //14 titles.add("年-结束时间"); //15 dataMap.put("titles", titles); List varOList = sysdateService.listAll(pd); List varList = new ArrayList(); for(int i=0;i