Search in sources :

Example 1 with FileIssue

use of com.itrus.portal.db.FileIssue in project portal by ixinportal.

the class CustomerServiceCallWebContoller method theDownloadSection.

/**
 * 获取发布信息,进入下载专区
 * @param eid 客服id
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping(value = "/thedownloaddection/index/{eid}", produces = "text/html")
public String theDownloadSection(@PathVariable("eid") Long eid, // @RequestParam(value = "status", required = false) Integer status,
@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel, HttpServletRequest request) {
    Service service = questionService.getService(eid);
    List<FileIssue> FileIssues = new ArrayList<FileIssue>();
    List<FileIssue> Filecount = new ArrayList<FileIssue>();
    Map<Long, FileConfig> mconfig = new HashMap<Long, FileConfig>();
    if (service != null && service.getProject() != null) {
        if (page == null || page < 1) {
            page = 1;
        }
        if (size == null || size < 1) {
            size = 5;
        }
        // 结束
        // 查询发布文件
        FileIssueExample fileIssueExample = new FileIssueExample();
        FileIssueExample.Criteria cec = fileIssueExample.createCriteria();
        cec.andProjectEqualTo(service.getProject());
        Filecount = configServiceImpl.getList(fileIssueExample);
        // ////分页开始
        Integer count = Filecount.size();
        if (page > 1 && size * (page - 1) >= count) {
            page = (count + size - 1) / size;
        }
        uiModel.addAttribute("count", count);
        uiModel.addAttribute("pages", (count + size - 1) / size);
        uiModel.addAttribute("page", page);
        Integer offset = size * (page - 1);
        fileIssueExample.setOffset(offset);
        fileIssueExample.setLimit(size);
        fileIssueExample.setOrderByClause("priority ASC");
        // ////结束
        FileIssues = configServiceImpl.getList(fileIssueExample);
        for (FileIssue issue : FileIssues) {
            FileConfig fileconfig = configServiceImpl.getFileConfigById(issue.getFileConfig());
            mconfig.put(issue.getId(), fileconfig);
        }
    }
    uiModel.addAttribute("FileIssues", FileIssues);
    // 分页开始
    uiModel.addAttribute("eid", eid);
    // 分页结束
    uiModel.addAttribute("mconfig", mconfig);
    return "ixinweb/kehufuwu_xiazaizhuanqv";
}
Also used : FileConfig(com.itrus.portal.db.FileConfig) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SystemConfigService(com.itrus.portal.service.SystemConfigService) CustomerService(com.itrus.portal.db.CustomerService) Service(com.itrus.portal.db.Service) FileIssue(com.itrus.portal.db.FileIssue) FileIssueExample(com.itrus.portal.db.FileIssueExample)

Example 2 with FileIssue

use of com.itrus.portal.db.FileIssue in project portal by ixinportal.

the class DownloadConfigController method create.

// 新建处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid FileConfig fileConfig, @RequestParam(value = "upFile", required = false) MultipartFile upFile, @RequestParam(value = "status", required = false) Integer status, @RequestParam(value = "projectId", required = false) Long projectId, @RequestParam(value = "fileIdArr", required = false) String fileIdArr, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        return createForm(status, uiModel);
    }
    if (status == 2) {
        String nameAll = null;
        Long fid = 0L;
        Project project = null;
        String[] arr = fileIdArr.split(",");
        for (String s : arr) {
            FileIssue fileIssue = new FileIssue();
            fileIssue.setId(null);
            fileIssue.setProject(projectId);
            fileIssue.setFileConfig(Long.parseLong(s));
            fileIssue.setCreateTime(new Date());
            fileIssue.setCreator(getAdmin().getId());
            configServiceImpl.insertFileIssue(fileIssue, projectId, null);
            project = projectServiceImpl.selectByPrimaryKey(projectId);
            FileConfig config = configServiceImpl.getFileConfigById(Long.parseLong(s));
            if (nameAll == null) {
                nameAll = config.getName();
            } else {
                nameAll = nameAll + "," + config.getName();
            }
            fid = fileIssue.getId();
        }
        LogUtil.adminlog(sqlSession, "创建文件发布信息", project.getName() + "项目发布文件有:" + nameAll);
        return "redirect:/downloadconfig/" + fid + "/" + status;
    } else {
        Map<String, Object> retMap = null;
        if (upFile != null) {
            // 上传文件
            retMap = saveFile(upFile);
            if (retMap == null || (int) retMap.get("retCode") != 1) {
                return "redirect:/downloadconfig?form&status=3";
            }
            fileConfig.setFileSize(retMap.get("fileSize").toString());
            fileConfig.setFile(retMap.get("name").toString());
            fileConfig.setHash(retMap.get("hash").toString());
        }
        fileConfig.setId(null);
        fileConfig.setCreateTime(new Date());
        fileConfig.setCreator(getAdmin().getId());
        configServiceImpl.insertFileConfig(fileConfig);
        LogUtil.adminlog(sqlSession, "创建文件管理信息", "文件名称:" + fileConfig.getName());
        return "redirect:/downloadconfig/" + fileConfig.getId() + "/" + status;
    }
}
Also used : Project(com.itrus.portal.db.Project) FileConfig(com.itrus.portal.db.FileConfig) FileIssue(com.itrus.portal.db.FileIssue) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with FileIssue

use of com.itrus.portal.db.FileIssue in project portal by ixinportal.

the class DownloadConfigController method update.

// 修改处理
@RequestMapping(params = "update", produces = "text/html")
public String update(@Valid FileConfig fileConfig, @RequestParam(value = "upFile", required = false) MultipartFile upFile, @RequestParam(value = "status", required = false) Integer status, @RequestParam(value = "projectId", required = false) Long projectId, @RequestParam(value = "fileIdArr", required = false) String fileIdArr, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        return updateForm(fileConfig.getId(), status, uiModel);
    }
    if (status == 1) {
        FileConfig fileConfig0 = configServiceImpl.getFileConfigById(fileConfig.getId());
        if (!(upFile == null || upFile.isEmpty())) {
            try {
                // 保存新文件
                Map<String, Object> retMap = null;
                if (upFile != null) {
                    // 上传文件
                    retMap = saveFile(upFile);
                    if (retMap == null || (int) retMap.get("retCode") != 1) {
                        return updateForm(fileConfig.getId(), 3, uiModel);
                    }
                    fileConfig.setFileSize(retMap.get("fileSize").toString());
                    fileConfig.setFile(retMap.get("name").toString());
                    fileConfig.setHash(retMap.get("hash").toString());
                }
                // 删除旧文件
                if (StringUtils.isNotEmpty(fileConfig0.getFile())) {
                    FileUtils.deleteQuietly(new File(systemConfigService.getSoftDir(), fileConfig0.getFile()));
                }
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
        } else if (StringUtils.isNotEmpty(fileConfig.getDownloadUrl()) && StringUtils.isNotEmpty(fileConfig0.getFile())) {
            // 删除旧文件
            if (StringUtils.isNotEmpty(fileConfig0.getFile())) {
                try {
                    FileUtils.deleteQuietly(new File(systemConfigService.getSoftDir(), fileConfig0.getFile()));
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        } else if (StringUtils.isNotEmpty(fileConfig0.getFile())) {
            fileConfig.setFile(fileConfig0.getFile());
            fileConfig.setFileSize(fileConfig0.getFileSize());
            fileConfig.setHash(fileConfig0.getHash());
        }
        fileConfig.setCreator(fileConfig0.getCreator());
        fileConfig.setCreateTime(fileConfig0.getCreateTime());
        fileConfig.setModifier(getAdmin().getId());
        fileConfig.setModifyTime(new Date());
        configServiceImpl.updateFileConfig(fileConfig);
        String oper = "修改文件管理信息";
        String info = "文件名称: " + fileConfig.getName();
        LogUtil.adminlog(sqlSession, oper, info);
        return "redirect:/downloadconfig/" + fileConfig.getId() + "/" + status;
    } else {
        Long FileIssueId = 0L;
        // 修改删除的发布文件信息
        FileIssueExample issueExample = new FileIssueExample();
        FileIssueExample.Criteria fec = issueExample.createCriteria();
        fec.andProjectEqualTo(projectId);
        List<FileIssue> issues = configServiceImpl.getList(issueExample);
        for (FileIssue fileIssue : issues) {
            if (!fileIdArr.contains(fileIssue.getFileConfig().toString())) {
                configServiceImpl.deleteFileIssueById(fileIssue.getId());
            }
        }
        // 修改发布文件信息 没有的信息则添加
        String[] idArr = fileIdArr.split(",");
        String nameAll = null;
        for (int i = 0; i < idArr.length; i++) {
            FileIssue fileIssue = configServiceImpl.selectFileIssue(Long.parseLong(idArr[i]), projectId);
            if (fileIssue != null) {
                fileIssue.setPriority(i + 1);
                fileIssue.setModifier(getAdmin().getId());
                fileIssue.setModifyTime(new Date());
                configServiceImpl.updateFileIssue(fileIssue);
                if (i == 0) {
                    FileIssueId = fileIssue.getId();
                }
            } else {
                FileIssue fileIssue2 = new FileIssue();
                fileIssue2.setCreator(getAdmin().getId());
                fileIssue2.setCreateTime(new Date());
                fileIssue2.setFileConfig(Long.parseLong(idArr[i]));
                fileIssue2.setProject(projectId);
                fileIssue2.setPriority(i + 1);
                configServiceImpl.insertFileIssue(fileIssue2, null, null);
                if (i == 0) {
                    FileIssueId = fileIssue2.getId();
                }
            }
            FileConfig config = configServiceImpl.getFileConfigById(Long.parseLong(idArr[i]));
            if (nameAll == null) {
                nameAll = config.getName();
            } else {
                nameAll = nameAll + "," + config.getName();
            }
        }
        Project project = projectServiceImpl.selectByPrimaryKey(projectId);
        String oper = "修改文件发布信息";
        String info = project.getName() + "项目下发布文件: " + nameAll;
        LogUtil.adminlog(sqlSession, oper, info);
        return "redirect:/downloadconfig/" + FileIssueId + "/" + status;
    }
}
Also used : FileConfig(com.itrus.portal.db.FileConfig) FileIssueExample(com.itrus.portal.db.FileIssueExample) Date(java.util.Date) Project(com.itrus.portal.db.Project) FileIssue(com.itrus.portal.db.FileIssue) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with FileIssue

use of com.itrus.portal.db.FileIssue in project portal by ixinportal.

the class DownloadConfigController method delete.

// 删除
@RequestMapping(value = "/{id}/{status}", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, @PathVariable("status") Integer status, HttpServletRequest request, Model uiModel) {
    if (status == 2) {
        FileIssue fileIssue = configServiceImpl.getFileIssueById(id);
        if (fileIssue == null) {
            // uiModel.addAttribute("message", "未找到要删除快递");
            return "未找到要删除文件发布信息";
        } else {
            Project project = null;
            FileConfig config = null;
            try {
                configServiceImpl.deleteFileIssueById(id);
                project = projectServiceImpl.selectByPrimaryKey(fileIssue.getProject());
                config = configServiceImpl.getFileConfigById(fileIssue.getFileConfig());
                String oper = "删除文件发布信息";
                String info = "所属项目" + project.getName() + "的" + config.getName() + "文件发布信息";
                LogUtil.adminlog(sqlSession, oper, info);
            } catch (Exception e) {
                // + "】存在关联,无法删除");
                return "要删除文件发表信息【" + "所属项目" + project.getName() + "的" + config.getName() + "信息" + "】存在关联,无法删除";
            }
        }
    } else {
        FileConfig fileConfig = configServiceImpl.getFileConfigById(id);
        if (fileConfig == null) {
            // uiModel.addAttribute("message", "未找到要删除快递");
            return "未找到要删除的文件信息";
        } else {
            try {
                if (StringUtils.isNotEmpty(fileConfig.getFile())) {
                    FileUtils.deleteQuietly(new File(systemConfigService.getSoftDir(), fileConfig.getFile()));
                }
                configServiceImpl.deleteFileConfigById(id);
                String oper = "删除文件管理信息";
                String info = "文件名称: " + fileConfig.getName();
                LogUtil.adminlog(sqlSession, oper, info);
            } catch (Exception e) {
                // + "】存在关联,无法删除");
                return "要删除文件信息【" + fileConfig.getName() + "】存在关联,无法删除";
            }
        }
    }
    return null;
}
Also used : Project(com.itrus.portal.db.Project) FileConfig(com.itrus.portal.db.FileConfig) FileIssue(com.itrus.portal.db.FileIssue) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with FileIssue

use of com.itrus.portal.db.FileIssue in project portal by ixinportal.

the class DownloadConfigController method show.

// 显示详情
@RequestMapping(value = "/{id}/{status}", produces = "text/html")
public String show(@PathVariable("id") Long id, @PathVariable("status") Integer status, Model uiModel) {
    if (status == 1) {
        FileConfig fileConfig = configServiceImpl.getFileConfigById(id);
        uiModel.addAttribute("fileConfig", fileConfig);
        return "downloadconfig/show1";
    } else {
        FileIssue fileIssue = configServiceImpl.getFileIssueById(id);
        Map<String, Object> param = new HashMap<>();
        param.put("projectId1", fileIssue.getProject());
        List<Map<String, Object>> fileIssues = configServiceImpl.getList(param);
        for (Map<String, Object> m : fileIssues) {
            uiModel.addAttribute("pName", m.get("p_name"));
            break;
        }
        uiModel.addAttribute("fileIssues", fileIssues);
        return "downloadconfig/show2";
    }
}
Also used : FileConfig(com.itrus.portal.db.FileConfig) HashMap(java.util.HashMap) FileIssue(com.itrus.portal.db.FileIssue) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FileIssue (com.itrus.portal.db.FileIssue)8 FileConfig (com.itrus.portal.db.FileConfig)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 FileIssueExample (com.itrus.portal.db.FileIssueExample)5 Project (com.itrus.portal.db.Project)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Service (com.itrus.portal.db.Service)2 File (java.io.File)2 Date (java.util.Date)2 List (java.util.List)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 CustomerService (com.itrus.portal.db.CustomerService)1 EnterpriseQq (com.itrus.portal.db.EnterpriseQq)1 EnterpriseQqExample (com.itrus.portal.db.EnterpriseQqExample)1 FileConfigExample (com.itrus.portal.db.FileConfigExample)1 Product (com.itrus.portal.db.Product)1 ServiceExample (com.itrus.portal.db.ServiceExample)1 SystemConfigService (com.itrus.portal.service.SystemConfigService)1 Map (java.util.Map)1