package com.fh.controller.fhoa.fhfile; import java.io.PrintWriter; 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 javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; 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.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import com.fh.controller.base.BaseController; import com.fh.entity.Page; import com.fh.util.AppUtil; import com.fh.util.Const; import com.fh.util.DelAllFile; import com.fh.util.FileDownload; import com.fh.util.FileUtil; import com.fh.util.PageData; import com.fh.util.Jurisdiction; import com.fh.util.PathUtil; import com.fh.util.Tools; import com.fh.service.fhoa.fhfile.FhfileManager; /** * 说明:文件管理 * 创建人:Elvis * 创建时间:2016-05-27 */ @Controller @RequestMapping(value="/fhfile") public class FhfileController extends BaseController { String menuUrl = "fhfile/list.do"; //菜单地址(权限用) @Resource(name="fhfileService") private FhfileManager fhfileService; /**保存 * @param * @throws Exception */ @RequestMapping(value="/save") public ModelAndView save() throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"新增Fhfile"); if(!Jurisdiction.buttonJurisdiction(menuUrl, "add")){return null;} //校验权限 ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); pd.put("FHFILE_ID", this.get32UUID()); //主键 pd.put("CTIME", Tools.date2Str(new Date())); //上传时间 pd.put("USERNAME", Jurisdiction.getUsername()); //上传者 pd.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID()); //部门ID pd.put("FILESIZE", FileUtil.getFilesize(PathUtil.getClasspath() + Const.FILEPATHFILEOA + pd.getString("FILEPATH"))); //文件大小 fhfileService.save(pd); mv.addObject("msg","success"); mv.setViewName("save_result"); return mv; } /**删除 * @param out * @throws Exception */ @RequestMapping(value="/delete") public void delete(PrintWriter out) throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"删除Fhfile"); if(!Jurisdiction.buttonJurisdiction(menuUrl, "del")){return;} //校验权限 PageData pd = new PageData(); pd = this.getPageData(); pd = fhfileService.findById(pd); fhfileService.delete(pd); DelAllFile.delFolder(PathUtil.getClasspath()+ Const.FILEPATHFILEOA + pd.getString("FILEPATH")); //删除文件 out.write("success"); out.close(); } /**列表 * @param page * @throws Exception */ @RequestMapping(value="/list") public ModelAndView list(Page page) throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"列表Fhfile"); //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 item = Jurisdiction.getDEPARTMENT_IDS(); if("0".equals(item) || "无权".equals(item)){ pd.put("item",""); //根据部门ID过滤 }else{ pd.put("item", item.replaceFirst("\\(", "\\('"+Jurisdiction.getDEPARTMENT_ID()+"',")); } page.setPd(pd); List varList = fhfileService.list(page); //列出Fhfile列表 List nvarList = new ArrayList(); for(int i=0;i map = new HashMap(); pd = this.getPageData(); List pdList = new ArrayList(); String DATA_IDS = pd.getString("DATA_IDS"); if(null != DATA_IDS && !"".equals(DATA_IDS)){ String ArrayDATA_IDS[] = DATA_IDS.split(","); PageData fpd = new PageData(); for(int i=0;i