Search in sources :

Example 1 with ContactSign

use of com.eservice.api.model.contact_sign.ContactSign in project sinsim by WilsonHu.

the class ContactFormController method delete.

// 删除时,联系单对应的 变更条目,联系单签核,都删除。
@Transactional(rollbackFor = Exception.class)
@PostMapping("/delete")
public Result delete(@RequestParam Integer id) {
    ContactForm cf = contactFormService.findById(id);
    if (null == cf) {
        return ResultGenerator.genFailResult("根据该id" + id + " 找不到对应的联系单");
    }
    if (cf.getContactType().equals(Constant.STR_LXD_TYPE_BIANGENG)) {
        List<ChangeItem> ciList = changeItemService.selectChangeItemList(id);
        for (int i = 0; i < ciList.size(); i++) {
            changeItemService.deleteById(ciList.get(i).getId());
        }
    }
    ContactSign cs = contactSignService.getContactSignByLxdId(id);
    contactSignService.deleteById(cs.getId());
    contactFormService.deleteById(id);
    return ResultGenerator.genSuccessResult();
}
Also used : ContactSign(com.eservice.api.model.contact_sign.ContactSign) ContactForm(com.eservice.api.model.contact_form.ContactForm) ChangeItem(com.eservice.api.model.change_item.ChangeItem) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ContactSign

use of com.eservice.api.model.contact_sign.ContactSign in project sinsim by WilsonHu.

the class ContactFormServiceImpl method getAllInfo.

public ContactFormAllInfo getAllInfo(Integer contactFormId) {
    ContactFormAllInfo contactFormAllInfo = new ContactFormAllInfo();
    ContactForm cf = contactFormService.findById(contactFormId);
    if (null == cf) {
        logger.warn("根据该contactFormId" + contactFormId + " 找不到对应的contactForm");
        return null;
    }
    // //
    ContactSign cs = contactSignService.getContactSignByLxdId(contactFormId);
    if (null == cs) {
        logger.warn("根据该contactFormId" + contactFormId + " 找不到对应的contactSign");
        return null;
    }
    // 落实单
    // 如果有多个落实单,只认最新的落实单(创建日期最新)
    ContactFulfill cff = contactFulfillService.getLatestFulFillByLxdId(contactFormId);
    if (null == cff) {
        logger.warn("根据该contactFormId " + contactFormId + " 找不到对应的落实单 (之前期的联系单还不存在落实单信息)");
        /**
         * 方便前台处理
         *(cff为空时,对于旧的联系单,前端无法读取cff的信息, Cannot read property 'xxxx' of null",会造成无法显示)
         */
        cff = new ContactFulfill();
        logger.warn("cff为空时,对于旧的联系单,前端无法读取cff的信息");
    } else {
    }
    contactFormAllInfo.setContactFulfill(cff);
    contactFormAllInfo.setContactForm(cf);
    contactFormAllInfo.setContactSign(cs);
    if (cf.getContactType().equals(Constant.STR_LXD_TYPE_BIANGENG)) {
        List<ChangeItem> changeItemList = changeItemService.selectChangeItemList(contactFormId);
        contactFormAllInfo.setChangeItemList(changeItemList);
    }
    return contactFormAllInfo;
}
Also used : ContactFulfill(com.eservice.api.model.contact_fulfill.ContactFulfill) ContactSign(com.eservice.api.model.contact_sign.ContactSign) ContactForm(com.eservice.api.model.contact_form.ContactForm) ContactFormAllInfo(com.eservice.api.model.contact_form.ContactFormAllInfo) ChangeItem(com.eservice.api.model.change_item.ChangeItem)

Example 3 with ContactSign

use of com.eservice.api.model.contact_sign.ContactSign in project sinsim by WilsonHu.

the class ContactFormController method add.

/**
 * 一次性同时上传 联系单,联系单的变更条目,联系单的签核信息
 *
 * @param jsonContactFormAllInfo
 * @return
 */
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
public Result add(String jsonContactFormAllInfo) {
    ContactFormAllInfo contactFormAllInfo = JSON.parseObject(jsonContactFormAllInfo, ContactFormAllInfo.class);
    if (contactFormAllInfo == null || contactFormAllInfo.equals("")) {
        return ResultGenerator.genFailResult("JSON数据异常");
    }
    String message = null;
    ContactForm contactForm = contactFormAllInfo.getContactForm();
    List<ChangeItem> changeItemList = contactFormAllInfo.getChangeItemList();
    ContactSign contactSign = contactFormAllInfo.getContactSign();
    try {
        if (null == contactForm) {
            message = " contactForm 为空!";
            throw new RuntimeException();
        }
        if (contactForm.getContactType().equals(Constant.STR_LXD_TYPE_BIANGENG)) {
            if (null == changeItemList) {
                message = " 类型为变更联系单时,变更条目不能为空!";
                throw new RuntimeException();
            }
        }
        if (null == contactSign) {
            message = " contactSign 为空!";
            throw new RuntimeException();
        }
        // 生成联系单
        contactForm.setCreateDate(new Date());
        contactForm.setStatus(Constant.STR_LXD_INITIAL);
        String firstPartOfLxdNum = contactForm.getNum().replace("xxx", "");
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
        String thisYear = formatter.format(new Date());
        String lastSerialNumber = getLxdLastSerialNumber(thisYear, contactForm.getApplicantDepartment());
        if (lastSerialNumber == "") {
            String firstLxdOfTheDepartment = contactForm.getNum().replace("xxx", "001");
            contactForm.setNum(firstLxdOfTheDepartment);
        } else {
            Integer newSerialNumber;
            try {
                newSerialNumber = Integer.valueOf(lastSerialNumber) + 1;
            } catch (Exception e) {
                logger.warn("exception: " + e);
                newSerialNumber = 0;
            }
            String newNum = firstPartOfLxdNum + String.format("%03d", newSerialNumber);
            contactForm.setNum(newNum);
        }
        // 如果是在新建联系单就添加附件,此时联系单单号未确定。需要后端来更新。
        if (contactForm.getAttachedFile().contains("xxx")) {
            String oldNameOfAttachedFile = contactForm.getAttachedFile();
            String newNameOfAttachedFile = contactForm.getAttachedFile().replace("xxx", contactForm.getNum().split("-")[2]);
            // 根据订单名称 重新命名附件文件
            File file = new File(oldNameOfAttachedFile);
            if (file == null || !file.exists()) {
                logger.error(oldNameOfAttachedFile + "文件不存在!");
            } else {
                file.renameTo(new File(newNameOfAttachedFile));
            }
            contactForm.setAttachedFile(newNameOfAttachedFile);
        }
        contactFormService.saveAndGetID(contactForm);
        // 生成联系单变更条目, 如果类型不是变更联系单时,这部分为空
        if (contactForm.getContactType().equals(Constant.STR_LXD_TYPE_BIANGENG)) {
            for (int i = 0; i < changeItemList.size(); i++) {
                changeItemList.get(i).setContactFormId(contactForm.getId());
                changeItemService.save(changeItemList.get(i));
            }
        }
        // 生成联系单的审核记录
        contactSign.setCreateTime(new Date());
        contactSign.setContactFormId(contactForm.getId());
        contactSignService.save(contactSign);
        /**
         * 联系单的落实,也在add时添加,比如技术部(联系单的主要落实者)也可以在发起联系单时,直接指定落实信息。
         */
        ContactFulfill contactFulfill = contactFormAllInfo.getContactFulfill();
        if (contactFulfill != null) {
            contactFulfill.setContactFormId(contactForm.getId());
            if (contactFulfill.getFulfillMan() == null || contactFulfill.getFulfillMan().equals("")) {
                contactFulfill.setStatus(Constant.STR_FULFILL_STATUS_UN_ASSIGN);
            } else {
                contactFulfill.setStatus(Constant.STR_FULFILL_STATUS_FULFILLING);
            }
            contactFulfill.setCreateDate(new Date());
            contactFulfillService.save(contactFulfill);
        } else {
            logger.info("新增联系单时,落实单为空");
        }
    } catch (Exception ex) {
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        logger.warn("添加联系单/联系单变更条目/联系单审核信息 出错: " + message);
        return ResultGenerator.genFailResult("添加联系单/联系单变更条目/联系单审核信息 出错!" + message + ex.getMessage());
    }
    // 返回ID给前端,前端新增联系单时不关闭页面。
    return ResultGenerator.genSuccessResult(contactForm.getId());
}
Also used : ContactFulfill(com.eservice.api.model.contact_fulfill.ContactFulfill) ContactSign(com.eservice.api.model.contact_sign.ContactSign) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) Date(java.util.Date) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ContactForm(com.eservice.api.model.contact_form.ContactForm) ContactFormAllInfo(com.eservice.api.model.contact_form.ContactFormAllInfo) ChangeItem(com.eservice.api.model.change_item.ChangeItem) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ContactSign

use of com.eservice.api.model.contact_sign.ContactSign in project sinsim by WilsonHu.

the class ContactFormController method buildLxdExcel.

@PostMapping("/buildLxdExcel")
public Result buildLxdExcel(@RequestParam Integer contact_form_id, String account) {
    ContactFormAllInfo cf = contactFormService.getAllInfo(contact_form_id);
    if (null == cf) {
        return ResultGenerator.genFailResult("根据该contact_form_id 找不到对应的联系单");
    }
    // 是否是变更单
    Boolean isChange = cf.getContactForm().getContactType().indexOf(Constant.STR_LXD_TYPE_BIANGENG) >= 0;
    InputStream fs = null;
    POIFSFileSystem pfs = null;
    HSSFWorkbook wb = null;
    FileOutputStream out = null;
    String downloadPath = "";
    /*
         * 返回给docker外部下载
         */
    String downloadPathForNginx = "";
    Boolean displayEnable = commonService.isDisplayPrice(account);
    try {
        String templateFile = isChange ? "empty_lxd_change_template.xls" : "empty_lxd_work_template.xls";
        ClassPathResource resource = new ClassPathResource(templateFile);
        fs = resource.getInputStream();
        pfs = new POIFSFileSystem(fs);
        wb = new HSSFWorkbook(pfs);
        // 读取了模板内所有sheet1内容
        HSSFSheet workSheet = wb.getSheetAt(0);
        // 在相应的单元格进行赋值(A2)
        // 表单编号
        HSSFCell numCell = workSheet.getRow(1).getCell((short) 3);
        numCell.setCellValue(new HSSFRichTextString(cf.getContactForm().getNum()));
        // 订单号
        numCell = workSheet.getRow(1).getCell((short) 6);
        numCell.setCellValue(new HSSFRichTextString(cf.getContactForm().getOrderNum()));
        // 提出部门
        HSSFCell dpartCell = workSheet.getRow(2).getCell((short) 2);
        dpartCell.setCellValue(cf.getContactForm().getApplicantDepartment());
        // 申请人
        HSSFCell apCell = workSheet.getRow(2).getCell((short) 7);
        apCell.setCellValue(cf.getContactForm().getApplicantPerson());
        // 审核状态
        HSSFCell statusCell = workSheet.getRow(2).getCell((short) 11);
        statusCell.setCellValue(cf.getContactForm().getStatus());
        // 申请日期
        HSSFCell dateCell = workSheet.getRow(3).getCell((short) 2);
        String createDate = cf.getContactForm().getCreateDate() == null ? "" : formatter.format(cf.getContactForm().getCreateDate());
        dateCell.setCellValue(createDate);
        // ECO希望完成日期
        HSSFCell ECODateCell = workSheet.getRow(3).getCell((short) 9);
        String ecoDate = cf.getContactForm().getHopeDate() == null ? "" : formatter.format(cf.getContactForm().getHopeDate());
        ECODateCell.setCellValue(ecoDate);
        // 变更理由/主题
        HSSFCell titleCell = workSheet.getRow(4).getCell((short) 2);
        titleCell.setCellValue(cf.getContactForm().getContactTitle());
        // 变更内容 (包含已知常规内容 + “其他变更”)
        HSSFCell contentCell = workSheet.getRow(5).getCell((short) 2);
        if (cf.getContactForm().getContactContentElse() != null && !cf.getContactForm().getContactContentElse().isEmpty()) {
            contentCell.setCellValue(cf.getContactForm().getContactContent() + "(" + cf.getContactForm().getContactContentElse() + ")");
        } else {
            contentCell.setCellValue(cf.getContactForm().getContactContent());
        }
        short startRow = 6;
        if (// 是变更单  (变更条目的列表)
        isChange) {
            startRow = 7;
            // 设置变更项目内容
            HSSFRow curRow = workSheet.getRow(startRow);
            List<ChangeItem> changeItemList = cf.getChangeItemList();
            Integer index = 0;
            for (ChangeItem item : changeItemList) {
                if (index > 0) {
                    startRow += index;
                    // insert new row
                    // set the style for each cell
                    insertRow(workSheet, startRow - 1, 1);
                    workSheet.addMergedRegion(new CellRangeAddress(7 + index, 7 + index, 1, 4));
                    workSheet.addMergedRegion(new CellRangeAddress(7 + index, 7 + index, 5, 9));
                    workSheet.addMergedRegion(new CellRangeAddress(7 + index, 7 + index, 10, 11));
                    curRow = workSheet.getRow(startRow);
                }
                curRow.getCell((short) 1).setCellValue(item.getOldInfo());
                curRow.getCell((short) 5).setCellValue(item.getNewInfo());
                if (displayEnable) {
                    curRow.getCell((short) 10).setCellValue(item.getRemarks());
                } else {
                    curRow.getCell((short) 10).setCellValue("/");
                }
                index++;
            }
        } else {
        }
        for (short i = startRow; i < workSheet.getLastRowNum(); i++) {
            if (this.getCellStringValue(workSheet.getRow(i).getCell((short) 1)).indexOf("附件") >= 0) {
                // 附件
                workSheet.getRow(i).getCell((short) 2).setCellValue("有");
            }
            if (this.getCellStringValue(workSheet.getRow(i).getCell((short) 1)).indexOf("签核角色") >= 0) {
                ContactSign contactSign = cf.getContactSign();
                List<SignContentItem> contactSignContentList = JSON.parseArray(contactSign.getSignContent(), SignContentItem.class);
                short j = 0;
                for (SignContentItem item : contactSignContentList) {
                    j++;
                    String checkRole = roleService.findById(item.getRoleId()).getRoleName();
                    workSheet.getRow(i + j).getCell((short) 1).setCellValue(new HSSFRichTextString(checkRole));
                    workSheet.getRow(i + j).getCell((short) 2).setCellValue(new HSSFRichTextString(item.getUser()));
                    String date = item.getDate() == null ? "" : formatter.format(item.getDate());
                    workSheet.getRow(i + j).getCell((short) 3).setCellValue(new HSSFRichTextString(date));
                    // 成本核算员跟财务经理的意见,只给销售人员和王总看。
                    if (item.getRoleId() == 13 || item.getRoleId() == 14) {
                        if (displayEnable) {
                            workSheet.getRow(i + j).getCell((short) 4).setCellValue(new HSSFRichTextString(item.getComment()));
                        } else {
                            workSheet.getRow(i + j).getCell((short) 4).setCellValue(new HSSFRichTextString("/"));
                        }
                    } else {
                        workSheet.getRow(i + j).getCell((short) 4).setCellValue(new HSSFRichTextString(item.getComment()));
                    }
                    workSheet.getRow(i + j).getCell((short) 11).setCellValue(new HSSFRichTextString(this.getResultString(item.getShenHeEnabled(), item.getResult())));
                    if (!item.getShenHeEnabled()) {
                        for (int q = 0; q < 11; q++) {
                            HSSFCellStyle style = workSheet.getRow(i + j).getCell(q + 1).getCellStyle();
                            style.setFillBackgroundColor((short) IndexedColors.GREY_80_PERCENT.index);
                            workSheet.getRow(i + j).getCell(q + 1).setCellStyle(style);
                        }
                    }
                }
                break;
            }
        }
        String fileName = cf.getContactForm().getNum().replaceAll("/", "-") + ".xls";
        downloadPath = lxdAttachedSavedDir + fileName;
        // downloadPathForNginx = "/excel/" + fileName;
        downloadPathForNginx = "/" + fileName;
        out = new FileOutputStream(downloadPath);
        wb.write(out);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            fs.close();
            pfs.close();
            out.close();
            wb.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if ("".equals(downloadPath)) {
        return ResultGenerator.genFailResult("生成文件失败!");
    } else {
        return ResultGenerator.genSuccessResult(downloadPathForNginx);
    }
}
Also used : ContactSign(com.eservice.api.model.contact_sign.ContactSign) FileNotFoundException(java.io.FileNotFoundException) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) HSSFCellStyle(org.apache.poi.hssf.usermodel.HSSFCellStyle) SignContentItem(com.eservice.api.model.contract_sign.SignContentItem) ContactFormAllInfo(com.eservice.api.model.contact_form.ContactFormAllInfo) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) InputStream(java.io.InputStream) IOException(java.io.IOException) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) ClassPathResource(org.springframework.core.io.ClassPathResource) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) FileOutputStream(java.io.FileOutputStream) ChangeItem(com.eservice.api.model.change_item.ChangeItem) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with ContactSign

use of com.eservice.api.model.contact_sign.ContactSign in project sinsim by WilsonHu.

the class ContactSignController method list.

@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
    PageHelper.startPage(page, size);
    List<ContactSign> list = contactSignService.findAll();
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) ContactSign(com.eservice.api.model.contact_sign.ContactSign) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

ContactSign (com.eservice.api.model.contact_sign.ContactSign)8 PostMapping (org.springframework.web.bind.annotation.PostMapping)7 ContactForm (com.eservice.api.model.contact_form.ContactForm)6 ChangeItem (com.eservice.api.model.change_item.ChangeItem)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ContactFormAllInfo (com.eservice.api.model.contact_form.ContactFormAllInfo)4 SignContentItem (com.eservice.api.model.contract_sign.SignContentItem)4 Date (java.util.Date)4 HSSFRichTextString (org.apache.poi.hssf.usermodel.HSSFRichTextString)4 ContactFulfill (com.eservice.api.model.contact_fulfill.ContactFulfill)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 PageInfo (com.github.pagehelper.PageInfo)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HSSFCell (org.apache.poi.hssf.usermodel.HSSFCell)1 HSSFCellStyle (org.apache.poi.hssf.usermodel.HSSFCellStyle)1 HSSFRow (org.apache.poi.hssf.usermodel.HSSFRow)1