Search in sources :

Example 1 with ContactFormDetail

use of com.eservice.api.model.contact_form.ContactFormDetail in project sinsim by WilsonHu.

the class ContactFormController method uploadAttachedFile.

/**
 * 上传联系单附件文件 只保存文件,不保存数据库,保存路径返回给前端,前端统一写入
 *
 * @param request 参数带一个文件,以及一个lxdNum(联系单的编号,客户可见)
 * @return 后端保存的文件名称(相对地址在: lxdAttachedSavedDir)
 */
@PostMapping("/uploadAttachedFile")
public Result uploadAttachedFile(HttpServletRequest request) {
    try {
        /**
         * 联系单的编号,在保存文件时,文件名称中包含。
         * 在第一次新建时,联系单单号 名称中包含 xxx, 这个在add时会倍更新,对应的文件也会重命名。
         */
        String lxdNum = request.getParameterValues("lxdNum")[0];
        // 联系单附件 or 联系单签核过程的附件
        String type = request.getParameterValues("type")[0];
        String uploadMan = request.getParameterValues("uploadMan")[0];
        List<MultipartFile> fileList = ((MultipartHttpServletRequest) request).getFiles("file");
        if (fileList == null || fileList.size() == 0) {
            return ResultGenerator.genFailResult("Error: no available file");
        }
        MultipartFile file = fileList.get(0);
        File dir = new File(lxdAttachedSavedDir);
        if (!dir.exists()) {
            dir.mkdir();
        }
        try {
            int typeInt = 0;
            if (type.equals(Constant.STRING_LXD_ATTACHED_FILE_BY_CREATER)) {
                typeInt = Constant.LXD_ATTACHED_FILE_BY_CREATER;
            } else if (type.equals(Constant.STRING_LXD_ATTACHED_FILE_DURING_SIGN)) {
                typeInt = Constant.LXD_ATTACHED_FILE_DURING_SIGN;
            }
            // save file, 只保存文件,不保存数据库,保存路径返回给前端,前端统一写入 。
            String resultPath = commonService.saveFile(lxdAttachedSavedDir, file, "", lxdNum, typeInt, 0);
            if (resultPath == null || resultPath == "") {
                return ResultGenerator.genFailResult("文件名为空,联系单附件上传失败!");
            }
            logger.info("====/contact/form/uploadAttachedFile(): success======== " + resultPath);
            /**
             * 如果是签核过程中上传的附件,在附件保存之后,还需要特别地把数据库更新。
             */
            if (type.equals(Constant.STRING_LXD_ATTACHED_FILE_DURING_SIGN)) {
                List<ContactFormDetail> list = contactFormService.selectContacts(lxdNum, null, null, null, null, null, // 可能有多个联系单,所以不能用 Constant.STR_LXD_CHECKING_FINISHED,
                null, null, null, null, null, null, null);
                if (list == null || list.isEmpty()) {
                    return ResultGenerator.genFailResult(lxdNum + " 找不到对应的联系单!");
                }
                // 
                ContactForm contactForm = list.get(0);
                contactForm.setAttachedDuringSign(resultPath);
                contactForm.setAttachedDuringSignMan(uploadMan);
                contactFormService.update(contactForm);
            }
            return ResultGenerator.genSuccessResult(resultPath);
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return ResultGenerator.genFailResult("联系单附件 上传失败!" + e.getMessage());
        }
    } catch (Exception e) {
        e.printStackTrace();
        return ResultGenerator.genFailResult("联系单附件 上传失败!" + e.getMessage());
    }
}
Also used : MultipartFile(org.springframework.web.multipart.MultipartFile) ContactFormDetail(com.eservice.api.model.contact_form.ContactFormDetail) ContactForm(com.eservice.api.model.contact_form.ContactForm) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) MultipartHttpServletRequest(org.springframework.web.multipart.MultipartHttpServletRequest) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with ContactFormDetail

use of com.eservice.api.model.contact_form.ContactFormDetail in project sinsim by WilsonHu.

the class ContactFormController method selectContacts.

/**
 * 按条件 查下联系单信息
 *
 * @param contactNum         联系单 编号
 * @param contactTitle         联系单 主题
 * @param contactType         联系单类型
 * @param orderNum            订单 编号
 * @param applicantDepartment 发起部门
 * @param applicantPerson     发起人
 * @param userRoleName      查询者的角色 TODO:...
 * @param status              状态
 * @param queryStartTime
 * @param queryFinishTime
 * @Param currentStep -审核的当前步骤
 * @Param designatedSaleManager -- 指定的要去签核的销售部经理, 但是所有人 都要看 自己发起的联系单.
 *                                  即,查询 指定的销售部经理为 designatedSaleManager的订单,以及 designatedSaleManager 自己发起的订单
 * @param isFuzzy
 * @return
 */
@PostMapping("/selectContacts")
public Result selectContacts(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, String contactNum, String contactTitle, String contactType, String orderNum, String applicantDepartment, String applicantPerson, String userRoleName, Integer status, String queryStartTime, String queryFinishTime, String currentStep, // 指定的要去签核的销售部经理 但是所有人 都要看 自己发起的联系单
String designatedSaleManager, @RequestParam(defaultValue = "true") Boolean isFuzzy) {
    PageHelper.startPage(page, size);
    String strStatus = null;
    // String -- integer 转换
    if (status != null) {
        if (status.equals(Integer.valueOf(Constant.LXD_INITIAL))) {
            strStatus = Constant.STR_LXD_INITIAL;
        } else if (status.equals(Integer.valueOf(Constant.LXD_CHECKING))) {
            strStatus = Constant.STR_LXD_CHECKING;
        } else if (status.equals(Integer.valueOf(Constant.LXD_CHECKING_FINISHED))) {
            strStatus = Constant.STR_LXD_CHECKING_FINISHED;
        } else if (status.equals(Integer.valueOf(Constant.LXD_REJECTED))) {
            strStatus = Constant.STR_LXD_REJECTED;
        } else if (status.equals(Integer.valueOf(Constant.LXD_CANCELED))) {
            strStatus = Constant.STR_LXD_CANCELED;
        }
    }
    List<ContactFormDetail> list = contactFormService.selectContacts(contactNum, contactTitle, contactType, orderNum, applicantDepartment, applicantPerson, userRoleName, strStatus, queryStartTime, queryFinishTime, currentStep, designatedSaleManager, isFuzzy);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) ContactFormDetail(com.eservice.api.model.contact_form.ContactFormDetail) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

ContactFormDetail (com.eservice.api.model.contact_form.ContactFormDetail)2 HSSFRichTextString (org.apache.poi.hssf.usermodel.HSSFRichTextString)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ContactForm (com.eservice.api.model.contact_form.ContactForm)1 PageInfo (com.github.pagehelper.PageInfo)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1 MultipartHttpServletRequest (org.springframework.web.multipart.MultipartHttpServletRequest)1