Search in sources :

Example 1 with ContactFulfill

use of com.eservice.api.model.contact_fulfill.ContactFulfill in project sinsim by WilsonHu.

the class ContactFulfillController method list.

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

Example 2 with ContactFulfill

use of com.eservice.api.model.contact_fulfill.ContactFulfill in project sinsim by WilsonHu.

the class ContactFormController method update.

/**
 * 一是修改联系单时要update (包括变更条目的修改),二是审核联系单时也要Update。 即使已经开始审批过程了,还要允许修改。
 * 允许财务部修改是否需要总经理审核
 *
 * @param
 * @return
 */
@Transactional(rollbackFor = Exception.class)
@PostMapping("/update")
public Result update(String jsonContactFormAllInfo) {
    ContactFormAllInfo contactFormAllInfo = JSON.parseObject(jsonContactFormAllInfo, ContactFormAllInfo.class);
    if (contactFormAllInfo == null || contactFormAllInfo.equals("")) {
        return ResultGenerator.genFailResult("JSON数据异常");
    }
    logger.info("更新联系单 " + jsonContactFormAllInfo);
    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 (null == contactForm.getId()) {
            message = " contactForm 的Id 不能为空!";
            throw new RuntimeException();
        }
        if (contactFormService.findById(contactForm.getId()) == null) {
            message = " 根据该id找不到对应的联系单!";
            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();
        }
        if (contactForm.getStatus().equals(Constant.STR_LXD_CHECKING)) {
            // 重新计算当前审核阶段
            List<SignContentItem> contactSignContentList = JSON.parseArray(contactSign.getSignContent(), SignContentItem.class);
            String currentStep = "";
            // int num=-1;
            for (SignContentItem item : contactSignContentList) {
                String step = roleService.findById(item.getRoleId()).getRoleName();
                // 审核状态是初始化,并且是启用的就是当前步骤
                if (item.getResult() == Constant.SIGN_INITIAL && item.getShenHeEnabled()) {
                    currentStep = step;
                    break;
                }
            // 检查当前current step 是否禁用掉
            // if(step.equals(contactSign.getCurrentStep()))
            // {
            // num=item.getNumber();
            // if(item.getResult() == Constant.SIGN_INITIAL&&item.getShenHeEnabled()) {
            // break;
            // }
            // }else{
            // if(num>-1&&item.getNumber()>num)
            // {
            // if(item.getResult() == Constant.SIGN_INITIAL&&item.getShenHeEnabled()) {
            // currentStep=step;
            // break;
            // }
            // }
            // }
            }
            if (currentStep != "") {
                contactSign.setCurrentStep(currentStep);
                logger.info("当前审核阶段 不为空:" + currentStep);
            } else {
                /**
                 * 当前审核阶段 为空, 表示已经不存在:需要审核但是还没审核(Result为0)的步骤,即已经全部审核完成了。
                 * 此时需要更新状态。【被取消的那一步,刚好是最后一步,且前面都已经完成审核】
                 * 实列:一开始是勾着王总审核的,王总前面全部审批完成,再修改取消了王总审核,此时审核应该为完成。
                 */
                logger.info("当前审核阶段 为空:" + currentStep);
                contactSign.setCurrentStep(Constant.SIGN_FINISHED);
                contactForm.setStatus(Constant.STR_LXD_CHECKING_FINISHED);
            }
        }
        if (contactForm.getContactType().equals(Constant.STR_LXD_TYPE_BIANGENG)) {
            // 更新联系单变更条目
            List<ChangeItem> changeItemListExist = changeItemService.selectChangeItemList(contactForm.getId());
            for (int i = 0; i < changeItemList.size(); i++) {
                if (changeItemList.get(i).getContactFormId() != null) {
                    if (changeItemList.get(i).getContactFormId().intValue() != contactForm.getId().intValue()) {
                        message = " 变更条目里的ContactFormId 和 联系单的id 不匹配!";
                        throw new RuntimeException();
                    }
                }
                // step1.如果是已经存在的条目,则更新
                if (changeItemService.findById(changeItemList.get(i).getId()) != null) {
                    changeItemService.update(changeItemList.get(i));
                    logger.info("更新了 id为 " + changeItemList.get(i).getId() + " 的变更条目");
                } else {
                    // step2.如果是新增的条目,则新增。
                    changeItemList.get(i).setContactFormId(contactForm.getId());
                    changeItemService.save(changeItemList.get(i));
                    logger.info("新增了一个 " + changeItemList.get(i).getNewInfo() + " 的变更条目");
                }
                // step3. 如果目前已存在的条目 不在传进来的条目中,表示该条目应该删除。
                boolean isIncluded = false;
                // List<ChangeItem> changeItemListExist = changeItemService.selectChangeItemList(contactForm.getId());
                for (int ei = 0; ei < changeItemListExist.size(); ei++) {
                    // exist item
                    // 每个条目都和传进来的每个条目进行比较
                    isIncluded = false;
                    for (int ii = 0; ii < changeItemList.size(); ii++) {
                        // input item
                        if (changeItemListExist.get(ei).getId().equals(changeItemList.get(ii).getId())) {
                            isIncluded = true;
                            break;
                        }
                    }
                    if (!isIncluded) {
                        changeItemService.deleteById(changeItemListExist.get(ei).getId());
                        logger.info("删除了 id为 " + changeItemListExist.get(ei).getId() + " 的变更条目");
                    }
                }
            }
            // 如果传进来变更列表的是空的,说明要把之前旧的全部都删除
            if (changeItemList.size() == 0) {
                for (int ei = 0; ei < changeItemListExist.size(); ei++) {
                    // exist item
                    changeItemService.deleteById(changeItemListExist.get(ei).getId());
                    logger.info("all, 删除了 id为 " + changeItemListExist.get(ei).getId() + " 的变更条目");
                }
            }
        }
        // 更新 联系单的审核记录
        contactSign.setUpdateTime(new Date());
        if (contactSign.getContactFormId().intValue() != contactForm.getId()) {
            message = " contactSign里的ContactFormId 和 联系单的id 不匹配!";
            throw new RuntimeException();
        }
        // 统一更新审核数据, currentstep等
        contactSignService.update(contactSign);
        contactForm.setUpdateDate(new Date());
        // 统一更新联系单
        contactFormService.update(contactForm);
        /**
         * 联系单的落实,新增/更新
         */
        ContactFulfill contactFulfill = contactFormAllInfo.getContactFulfill();
        if (contactFulfill != null) {
            contactFulfill.setContactFormId(contactForm.getId());
            if (contactFulfill.getId() == null || contactFulfill.getId() == 0) {
                // 新增加的落实信息,比如在二期旧的联系单上添加落实信息,比如在新建联系单时未写落实信息,后面再补上时。
                if (contactFulfill.getFulfillMan() == null) {
                    contactFulfill.setStatus(Constant.STR_FULFILL_STATUS_UN_ASSIGN);
                } else {
                    contactFulfill.setStatus(Constant.STR_FULFILL_STATUS_FULFILLING);
                }
                contactFulfill.setCreateDate(new Date());
                contactFulfillService.save(contactFulfill);
            } else {
                contactFulfill.setUpdateDate(new Date());
                contactFulfillService.update(contactFulfill);
            }
        } else {
            logger.info("更新联系单时,落实单为空");
        }
    } catch (Exception ex) {
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        logger.warn("更新 联系单/联系单变更条目/联系单审核信息 出错: " + message);
        return ResultGenerator.genFailResult("更新 联系单/联系单变更条目/联系单审核信息 出错!" + message + ex.getMessage());
    }
    return ResultGenerator.genSuccessResult();
}
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) SignContentItem(com.eservice.api.model.contract_sign.SignContentItem) ContactForm(com.eservice.api.model.contact_form.ContactForm) ContactFormAllInfo(com.eservice.api.model.contact_form.ContactFormAllInfo) ChangeItem(com.eservice.api.model.change_item.ChangeItem) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with ContactFulfill

use of com.eservice.api.model.contact_fulfill.ContactFulfill 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 ContactFulfill

use of com.eservice.api.model.contact_fulfill.ContactFulfill 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)

Aggregations

ContactFulfill (com.eservice.api.model.contact_fulfill.ContactFulfill)4 ChangeItem (com.eservice.api.model.change_item.ChangeItem)3 ContactForm (com.eservice.api.model.contact_form.ContactForm)3 ContactFormAllInfo (com.eservice.api.model.contact_form.ContactFormAllInfo)3 ContactSign (com.eservice.api.model.contact_sign.ContactSign)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Date (java.util.Date)2 HSSFRichTextString (org.apache.poi.hssf.usermodel.HSSFRichTextString)2 Transactional (org.springframework.transaction.annotation.Transactional)2 SignContentItem (com.eservice.api.model.contract_sign.SignContentItem)1 PageInfo (com.github.pagehelper.PageInfo)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1