213 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			Java
		
	
	
			
		
		
	
	
			213 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			Java
		
	
	
| package com.zcloud.controller.bus;
 | ||
| 
 | ||
| import com.zcloud.controller.base.BaseController;
 | ||
| import com.zcloud.entity.PageData;
 | ||
| import com.zcloud.service.bus.ArchivesFilesService;
 | ||
| import com.zcloud.util.*;
 | ||
| import org.apache.commons.io.FileUtils;
 | ||
| import org.apache.shiro.authz.annotation.RequiresPermissions;
 | ||
| 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.RequestParam;
 | ||
| import org.springframework.web.bind.annotation.ResponseBody;
 | ||
| import org.springframework.web.multipart.MultipartFile;
 | ||
| import org.springframework.web.servlet.ModelAndView;
 | ||
| 
 | ||
| import java.io.File;
 | ||
| import java.util.ArrayList;
 | ||
| import java.util.HashMap;
 | ||
| import java.util.List;
 | ||
| import java.util.Map;
 | ||
| 
 | ||
| /**
 | ||
|  * 说明:档案文件
 | ||
|  * 时间:2021-12-14
 | ||
|  * 官网:www.zcloudchina.com
 | ||
|  */
 | ||
| @Controller
 | ||
| @RequestMapping("/archivesfiles")
 | ||
| public class ArchivesFilesController extends BaseController {
 | ||
| 
 | ||
| 	@Autowired
 | ||
| 	private ArchivesFilesService archivesfilesService;
 | ||
| 
 | ||
| 	/**新增
 | ||
| 	 * @param
 | ||
| 	 * @throws Exception
 | ||
| 	 */
 | ||
| 	@RequestMapping(value="/add")
 | ||
| 	@ResponseBody
 | ||
| 	public Object add(
 | ||
| 			@RequestParam(value="FFILE",required=false) MultipartFile[] files,
 | ||
| 			@RequestParam(value="TYPE",required=false) String TYPE,
 | ||
| 			@RequestParam(value="YEAR",required=false) String YEAR,
 | ||
| 			@RequestParam(value="STUDYTASK_ID",required=false) String STUDYTASK_ID
 | ||
| 	) throws Exception{
 | ||
| 		Map<String,Object> map = new HashMap<String,Object>();
 | ||
| 		String errInfo = "success";
 | ||
| 		PageData pd = new PageData();
 | ||
| 		pd.put("ARCHIVESFILES_ID", this.get32UUID());	//主键
 | ||
| 		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业
 | ||
| 		pd.put("TYPE", TYPE);
 | ||
| 		pd.put("YEAR", YEAR);
 | ||
| 		pd.put("STUDYTASK_ID", STUDYTASK_ID);
 | ||
| 
 | ||
| 		if (files != null && files.length > 0) {
 | ||
| 			for (int i = 0; i < files.length; i++) {
 | ||
| 				String suffixName = files[i].getOriginalFilename().substring(files[i].getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
 | ||
| 				if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
 | ||
| 					errInfo = "fail";
 | ||
| 					map.put("result", errInfo);
 | ||
| 					map.put("msg", "文件格式不正确!");
 | ||
| 					return map;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			for (MultipartFile file : files) {
 | ||
| 				String filename = file.getOriginalFilename();
 | ||
| 				pd.put("FILE_NAME", filename);
 | ||
| 
 | ||
| 				String ffile = DateUtil.getDays();
 | ||
| 				String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
 | ||
| 				Smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile);
 | ||
| 
 | ||
| 				pd.put("FILE_PATH", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName);
 | ||
| 			}
 | ||
| 		}
 | ||
| 
 | ||
| 		archivesfilesService.save(pd);
 | ||
| 		map.put("result", errInfo);
 | ||
| 		return map;
 | ||
| 	}
 | ||
| 	/**删除
 | ||
| 	 * @param out
 | ||
| 	 * @throws Exception
 | ||
| 	 */
 | ||
| 	@RequestMapping(value="/delete")
 | ||
| 	@ResponseBody
 | ||
| 	public Object delete() throws Exception{
 | ||
| 		Map<String,String> map = new HashMap<String,String>();
 | ||
| 		String errInfo = "success";
 | ||
| 		PageData pd = new PageData();
 | ||
| 		pd = this.getPageData();
 | ||
| 		Smb.deleteFile(pd.getString("FILE_PATH"));
 | ||
| 		archivesfilesService.delete(pd);
 | ||
| 		map.put("result", errInfo);				//返回结果
 | ||
| 		return map;
 | ||
| 	}
 | ||
| 
 | ||
| 	/**修改
 | ||
| 	 * @param
 | ||
| 	 * @throws Exception
 | ||
| 	 */
 | ||
| 	@RequestMapping(value="/edit")
 | ||
| 	@RequiresPermissions("archivesfiles:edit")
 | ||
| 	@ResponseBody
 | ||
| 	public Object edit() throws Exception{
 | ||
| 		Map<String,Object> map = new HashMap<String,Object>();
 | ||
| 		String errInfo = "success";
 | ||
| 		PageData pd = new PageData();
 | ||
| 		pd = this.getPageData();
 | ||
| 		archivesfilesService.edit(pd);
 | ||
| 		map.put("result", errInfo);
 | ||
| //		map.put("pd", pd);
 | ||
| 		return map;
 | ||
| 	}
 | ||
| 
 | ||
| 	/**列表
 | ||
| 	 * @param page
 | ||
| 	 * @throws Exception
 | ||
| 	 */
 | ||
| 	@RequestMapping(value="/list")
 | ||
| 	@ResponseBody
 | ||
| 	public Object list() throws Exception{
 | ||
| 		Map<String,Object> map = new HashMap<String,Object>();
 | ||
| 		String errInfo = "success";
 | ||
| 		PageData pd = new PageData();
 | ||
| 		pd = this.getPageData();
 | ||
| 		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业
 | ||
| 		List<PageData> varList = archivesfilesService.listAll(pd);	//列出ArchivesFiles列表
 | ||
| 		map.put("varList", varList);
 | ||
| 		map.put("result", errInfo);
 | ||
| 		return map;
 | ||
| 	}
 | ||
| 
 | ||
| 	 /**去修改页面获取数据
 | ||
| 	 * @param
 | ||
| 	 * @throws Exception
 | ||
| 	 */
 | ||
| 	@RequestMapping(value="/goEdit")
 | ||
| 	@RequiresPermissions("archivesfiles:edit")
 | ||
| 	@ResponseBody
 | ||
| 	public Object goEdit() throws Exception{
 | ||
| 		Map<String,Object> map = new HashMap<String,Object>();
 | ||
| 		String errInfo = "success";
 | ||
| 		PageData pd = new PageData();
 | ||
| 		pd = this.getPageData();
 | ||
| 		pd = archivesfilesService.findById(pd);	//根据ID读取
 | ||
| 		map.put("pd", pd);
 | ||
| 		map.put("result", errInfo);
 | ||
| 		return map;
 | ||
| 	}
 | ||
| 
 | ||
| 	 /**批量删除
 | ||
| 	 * @param
 | ||
| 	 * @throws Exception
 | ||
| 	 */
 | ||
| 	@RequestMapping(value="/deleteAll")
 | ||
| 	@RequiresPermissions("archivesfiles:del")
 | ||
| 	@ResponseBody
 | ||
| 	public Object deleteAll() throws Exception{
 | ||
| 		Map<String,Object> map = new HashMap<String,Object>();
 | ||
| 		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(",");
 | ||
| 			archivesfilesService.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<String,Object> dataMap = new HashMap<String,Object>();
 | ||
| 		List<String> titles = new ArrayList<String>();
 | ||
| 		titles.add("企业ID");	//1
 | ||
| 		titles.add("年");	//2
 | ||
| 		titles.add("文件");	//3
 | ||
| 		titles.add("文件名");	//4
 | ||
| 		titles.add("类型");	//5
 | ||
| 		dataMap.put("titles", titles);
 | ||
| 		List<PageData> varOList = archivesfilesService.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("CORPINFO_ID"));	    //1
 | ||
| 			vpd.put("var2", varOList.get(i).getString("YEAR"));	    //2
 | ||
| 			vpd.put("var3", varOList.get(i).getString("FILE_PATH"));	    //3
 | ||
| 			vpd.put("var4", varOList.get(i).getString("FILE_NAME"));	    //4
 | ||
| 			vpd.put("var5", varOList.get(i).get("TYPE").toString());	//5
 | ||
| 			varList.add(vpd);
 | ||
| 		}
 | ||
| 		dataMap.put("varList", varList);
 | ||
| 		ObjectExcelView erv = new ObjectExcelView();
 | ||
| 		mv = new ModelAndView(erv,dataMap);
 | ||
| 		return mv;
 | ||
| 	}
 | ||
| 
 | ||
| }
 |