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.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; 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.Const; import com.zcloud.util.DateUtil; import com.zcloud.util.FileUpload; import com.zcloud.util.Jurisdiction; import com.zcloud.util.ObjectExcelView; import com.zcloud.util.PathUtil; import com.zcloud.util.Smb; import com.zcloud.util.Tools; import net.sf.json.JSONArray; import com.zcloud.entity.PageData; import com.zcloud.service.bus.PersonObtainEvidenceService; import com.zcloud.service.system.DepartmentService; import com.zcloud.service.system.PostService; import com.zcloud.service.system.UsersService; /** * 说明:人员取证情况 * 作者:luoxiaobao * 时间:2020-12-29 * 官网:www.zcloudchina.com */ @Controller @RequestMapping("/personobtainevidence") public class PersonObtainEvidenceController extends BaseController { @Autowired private PersonObtainEvidenceService personobtainevidenceService; @Autowired private UsersService usersService; @Autowired private DepartmentService departmentService; @Autowired private PostService postService; /**新增 * @param * @throws Exception */ @RequestMapping(value="/add") @RequiresPermissions("personobtainevidence:add") @ResponseBody public Object add(@RequestParam(value="file",required=false) MultipartFile file) throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("PERSONOBTAINEVIDENCE_ID", this.get32UUID()); //主键 pd.put("CREATOR", Jurisdiction.getUsername()); //添加人 pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间 pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); pd.put("ISDELETE", "0"); //是否删除 1-是 0-否 if (null != file && !file.isEmpty()) { String suffixName = file.getOriginalFilename().substring(file.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; } String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); Smb.sshSftp(file, fileName,Const.FILEPATHIMG + Jurisdiction.getCORPINFO_ID() + "/" + ffile); pd.put("IMGPATH", Const.FILEPATHIMG + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); } personobtainevidenceService.save(pd); map.put("result", errInfo); return map; } /**删除 * @param out * @throws Exception */ @RequestMapping(value="/delete") @RequiresPermissions("personobtainevidence:del") @ResponseBody public Object delete() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 personobtainevidenceService.delete(pd); map.put("result", errInfo); //返回结果 return map; } /**修改 * @param * @throws Exception */ @RequestMapping(value="/edit") @RequiresPermissions("personobtainevidence:edit") @ResponseBody public Object edit(@RequestParam(value="file",required=false) MultipartFile file) throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 if (null != file && !file.isEmpty()) { String suffixName = file.getOriginalFilename().substring(file.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; } String ffile = DateUtil.getDays(); String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); Smb.sshSftp(file, fileName,Const.FILEPATHIMG + Jurisdiction.getCORPINFO_ID() + "/" + ffile); pd.put("IMGPATH", Const.FILEPATHIMG + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); } personobtainevidenceService.edit(pd); map.put("result", errInfo); return map; } /**列表 * @param page * @throws Exception */ @RequestMapping(value="/list") @RequiresPermissions("personobtainevidence: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()); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); page.setPd(pd); List varList = personobtainevidenceService.list(page); //列出PersonObtainEvidence列表 map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } /**去修改页面获取数据 * @param * @throws Exception */ @RequestMapping(value="/goEdit") @RequiresPermissions("personobtainevidence:edit") @ResponseBody public Object goEdit() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = personobtainevidenceService.findById(pd); //根据ID读取 // //获取部门下拉树 ; // List zdepartmentPdList = new ArrayList(); // String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID(); // ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID; // PageData dept = new PageData(); // dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID); // dept=departmentService.findById(dept); //获取部门下拉树 List zdepartmentPdList = new ArrayList(); PageData dept = new PageData(); dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); dept=this.departmentService.findByCorpId(dept); String ZDEPARTMENT_ID = dept.getString("DEPARTMENT_ID"); PageData node = new PageData(); node.put("id", dept.get("DEPARTMENT_ID")); node.put("parentId", dept.get("PARENT_ID")); node.put("name", dept.get("NAME")); node.put("icon", "../../../assets/images/user.gif"); zdepartmentPdList.add(node); JSONArray arr = JSONArray.fromObject(departmentService.listAllDepartmentToSelect(ZDEPARTMENT_ID,zdepartmentPdList)); map.put("zTreeNodes", (null == arr ?"":"{\"treeNodes\":" + arr.toString() + "}")); PageData seletctDept = new PageData(); seletctDept.put("DEPARTMENT_ID",pd.getString("DEPARTMENT_ID")); seletctDept = departmentService.findById(seletctDept); String depname = null == seletctDept?"请选择":seletctDept.getString("NAME"); map.put("depname", null == depname?"请选择":depname); //获取岗位下拉 PageData post = new PageData(); post.put("DEPARTMENT_ID", pd.getString("DEPARTMENT_ID")); post.put("STATUS", 0); List postList = postService.listAll(post); map.put("postList", postList); map.put("pd", pd); map.put("result", errInfo); return map; } /**获取部门下拉树 * @param * @throws Exception */ @RequestMapping(value="/getDept") @ResponseBody public Object getDept() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); //获取部门下拉树 List zdepartmentPdList = new ArrayList(); PageData dept = new PageData(); dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); dept=this.departmentService.findByCorpId(dept); String ZDEPARTMENT_ID = dept.getString("DEPARTMENT_ID"); // String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID(); // ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID; // PageData dept = new PageData(); // dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID); // dept=this.departmentService.findById(dept); PageData node = new PageData(); node.put("id", dept.get("DEPARTMENT_ID")); node.put("parentId", dept.get("PARENT_ID")); node.put("name", dept.get("NAME")); node.put("icon", "../../../assets/images/user.gif"); zdepartmentPdList.add(node); JSONArray arr = JSONArray.fromObject(departmentService.listAllDepartmentToSelect(ZDEPARTMENT_ID,zdepartmentPdList)); map.put("zTreeNodes", (null == arr ?"":"{\"treeNodes\":" + arr.toString() + "}")); PageData loginDept = new PageData(); loginDept.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID()); loginDept = departmentService.findById(loginDept); // //获取岗位下拉 // PageData post = new PageData(); // post.put("DEPARTMENT_ID", ZDEPARTMENT_ID); // post.put("STATUS", 0); // List postList = this.postService.listAll(post); // map.put("postList", postList); map.put("result", errInfo); map.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID()); map.put("USER_ID", Jurisdiction.getUSER_ID()); map.put("DEPT_NAME", loginDept.get("NAME")); return map; } /**批量删除 * @param * @throws Exception */ @RequestMapping(value="/deleteAll") @RequiresPermissions("personobtainevidence: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(","); personobtainevidenceService.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("部门DI"); //1 titles.add("职务ID"); //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("企业ID"); //12 titles.add("添加人"); //13 titles.add("添加时间"); //14 titles.add("修改人"); //15 titles.add("修改时间"); //16 titles.add("是否删除 1-是 0-否"); //17 dataMap.put("titles", titles); List varOList = personobtainevidenceService.listAll(pd); List varList = new ArrayList(); for(int i=0;i