Search in sources :

Example 6 with ContactSign

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

the class ContactSignController method update.

/**
 *  联系单审核的更新,同时更新对应的联系单
 * @param contactSign
 * @return
 */
@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(String contactSign) {
    if (contactSign == null || "".equals(contactSign)) {
        ResultGenerator.genFailResult("联系单审核信息不能为空!");
    }
    logger.info("contactSign:" + contactSign);
    ContactSign cs = JSON.parseObject(contactSign, ContactSign.class);
    if (cs == null) {
        ResultGenerator.genFailResult("审核信息JSON解析失败!");
    }
    ContactForm cf = contactFormService.findById(cs.getContactFormId());
    if (null == cf) {
        ResultGenerator.genFailResult("根据传入的签核信息里的联系单ID 找不到对应的联系单");
    }
    cs.setUpdateTime(new Date());
    List<SignContentItem> contactSignContentList = JSON.parseArray(cs.getSignContent(), SignContentItem.class);
    boolean haveReject = false;
    String currentStep = "";
    for (SignContentItem item : contactSignContentList) {
        if (item.getResult().equals(Constant.SIGN_REJECT)) {
            haveReject = true;
        }
        // 签核在初始化,则把当前步骤设为发起部门 --> 就是下个要签核的部门
        if (item.getResult() == Constant.SIGN_INITIAL && item.getShenHeEnabled()) {
            currentStep = roleService.findById(item.getRoleId()).getRoleName();
            break;
        }
    }
    // 都已经签核
    if (!haveReject) {
        if (currentStep.equals("")) {
            currentStep = Constant.SIGN_FINISHED;
        }
        cs.setCurrentStep(currentStep);
    }
    contactSignService.update(cs);
    String msgInfo = null;
    if (haveReject) {
        /**
         * 被拒绝了,
         * contactSign的每个状态,更新为 初始状态
         * contactForm的状态,更新为 被拒绝。
         */
        for (SignContentItem item : contactSignContentList) {
            item.setResult(Constant.SIGN_INITIAL);
        }
        cs.setSignContent(JSONObject.toJSONString(contactSignContentList));
        logger.warn("got Reject signContent: " + JSONObject.toJSONString(contactSignContentList));
        contactSignService.update(cs);
        cf.setStatus(Constant.STR_LXD_REJECTED);
        contactFormService.update(cf);
        /**
         * 推送 "签核被拒绝"消息
         */
        msgInfo = Constant.STR_MSG_PUSH_SIGN_REFUESED;
    } else {
        // 没有被拒,且刚刚开始
        if (cf.getStatus().equals(Constant.STR_LXD_INITIAL)) {
            cf.setStatus(Constant.STR_LXD_CHECKING);
        }
        // 没有被拒,且联系单签核完成
        if (currentStep.equals(Constant.SIGN_FINISHED)) {
            cf.setStatus(Constant.STR_LXD_CHECKING_FINISHED);
            // 推送 "签核完成" 消息给 发起人
            msgInfo = Constant.STR_MSG_PUSH_SIGN_DONE;
        } else {
            // 推送 "轮到签核" 消息给 轮到联系单签核的人
            msgInfo = Constant.STR_MSG_PUSH_IS_TURN_TO_SIGN;
        }
        contactFormService.update(cf);
    }
    commonService.pushLxdMsgToAftersale(cs, cf, haveReject, msgInfo);
    return ResultGenerator.genSuccessResult();
}
Also used : ContactSign(com.eservice.api.model.contact_sign.ContactSign) SignContentItem(com.eservice.api.model.contract_sign.SignContentItem) ContactForm(com.eservice.api.model.contact_form.ContactForm) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with ContactSign

use of com.eservice.api.model.contact_sign.ContactSign 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 8 with ContactSign

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

the class ContactFormController method startSign.

/**
 * 联系单发起审核
 *
 * @param lxdId
 * @return
 */
@PostMapping("/startSign")
@Transactional(rollbackFor = Exception.class)
public Result startSign(@RequestParam Integer lxdId) {
    if (lxdId == null) {
        ResultGenerator.genFailResult("联系单ID为空!");
    } else {
        ContactSign contactSign = contactSignService.getContactSignByLxdId((lxdId));
        if (contactSign == null) {
            return ResultGenerator.genFailResult("根据联系单ID号获取 签核信息失败!");
        } else {
            List<SignContentItem> contactSignContentList = JSON.parseArray(contactSign.getSignContent(), SignContentItem.class);
            String currentStep = "";
            for (SignContentItem item : contactSignContentList) {
                // 签核在初始化,则把当前步骤设为发起部门
                if (item.getResult() == Constant.SIGN_INITIAL && item.getShenHeEnabled()) {
                    currentStep = roleService.findById(item.getRoleId()).getRoleName();
                    break;
                }
            }
            contactSign.setCurrentStep(currentStep);
            logger.info("开始 联系单签核 currentStep " + currentStep);
            // 更新审核数据currentstep
            contactSignService.update(contactSign);
            // 更新联系单状态为 STR_LXD_CHECKING
            ContactForm contactForm = contactFormService.findById(lxdId);
            if (contactForm == null) {
                return ResultGenerator.genFailResult("联系单号ID无效");
            } else {
                contactForm.setStatus(Constant.STR_LXD_CHECKING);
                contactForm.setUpdateDate(new Date());
                logger.info("联系单签核 setStatus " + Constant.STR_LXD_CHECKING);
                contactFormService.update(contactForm);
                commonService.pushLxdMsgToAftersale(contactSign, contactForm, false, Constant.STR_MSG_PUSH_IS_START_TO_SIGN);
            }
        }
    }
    return ResultGenerator.genSuccessResult();
}
Also used : ContactSign(com.eservice.api.model.contact_sign.ContactSign) SignContentItem(com.eservice.api.model.contract_sign.SignContentItem) ContactForm(com.eservice.api.model.contact_form.ContactForm) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

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