Search in sources :

Example 1 with DesignDepInfoDetail

use of com.eservice.api.model.design_dep_info.DesignDepInfoDetail in project sinsim by WilsonHu.

the class OrderSignController method update.

@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(Integer contractId, String orderSign) {
    if (orderSign == null || "".equals(orderSign)) {
        ResultGenerator.genFailResult("签核信息为空!");
    }
    if (contractId == null || contractId <= 0) {
        ResultGenerator.genFailResult("合同ID不存在或者无效!");
    }
    OrderSign orderSignObj = JSONObject.parseObject(orderSign, OrderSign.class);
    if (orderSignObj == null) {
        ResultGenerator.genFailResult("签核信息JSON解析失败!");
    } else {
        // 更新需求单签核记录
        orderSignObj.setUpdateTime(new Date());
        // 更新需求单状态
        List<SignContentItem> orderSignContentList = JSON.parseArray(orderSignObj.getSignContent(), SignContentItem.class);
        boolean haveReject = false;
        boolean needMakeUpOrderSignForForeignDirector = false;
        String currentStep = "";
        MachineOrder machineOrder = machineOrderService.findById(orderSignObj.getOrderId());
        User machineOrderCreator = userService.findById(machineOrder.getCreateUserId());
        for (SignContentItem item : orderSignContentList) {
            // 如果签核内容中有“拒绝”状态的签核信息,需要将该
            if (item.getResult().equals(Constant.SIGN_REJECT)) {
                haveReject = true;
            }
            if (item.getResult() == Constant.SIGN_INITIAL) {
                currentStep = roleService.findById(item.getRoleId()).getRoleName();
                break;
            }
            /**
             * 订单审核完成时,创建设计单 2020-1207改了:
             * 如果是技术部经理签核且通过,则要生成对应的设计单
             * 并且没有生成过联系单
             */
            if (item.getRoleId() == Constant.ROLE_ID_TECH_MANAGER && item.getResult().equals(Constant.SIGN_APPROVE)) {
                logger.info("技术部经理签核,且通过");
                // 查找订单对应的设计单
                List<DesignDepInfoDetail> designDepInfoDetailList = designDepInfoService.selectDesignDepInfo(machineOrder.getOrderNum(), null, null, // 审核中
                Integer.valueOf(Constant.ORDER_CHECKING), null, null, null, null, null, null);
                if (designDepInfoDetailList == null || designDepInfoDetailList.size() == 0) {
                    commonService.createDesignDepInfo(machineOrder);
                }
            }
            /**
             * 技术部签核,更新相关内容:
             * 1. 机架长度 来自于技术部经理的签核内容,从“长度”字符开始截取。
             */
            if (item.getRoleId() == Constant.ROLE_ID_TECH_MANAGER) {
                String commentOfTechManager = item.getComment();
                int start = 0;
                start = commentOfTechManager.indexOf("机架长度");
                if (start == -1) {
                    start = commentOfTechManager.indexOf("【长度】");
                }
                if (start == -1) {
                    start = commentOfTechManager.indexOf("[长度]");
                }
                if (start == -1) {
                    start = commentOfTechManager.indexOf("长度");
                }
                if (start != -1) {
                    machineOrder.setMachineFrameLength(commentOfTechManager.substring(start));
                    machineOrderService.update(machineOrder);
                    logger.info("更新了机架长度为: " + commentOfTechManager.substring(start));
                }
            }
            /**
             * 成本核算员签核,更新相关内容:
             * 1. 毛利率
             */
            if (item.getRoleId() == Constant.ROLE_ID_COST_ACCOUNTANT) {
                String grossProfitString = "";
                int start = 0;
                start = item.getComment().indexOf("【毛利率】");
                if (start == -1) {
                    start = item.getComment().indexOf("[毛利率]");
                }
                if (start == -1) {
                    start = item.getComment().indexOf("毛利率");
                }
                if (start != -1) {
                    grossProfitString = item.getComment().substring(start);
                    machineOrder.setGrossProfit(grossProfitString);
                    machineOrderService.update(machineOrder);
                    logger.info("更新了毛利率为: " + grossProfitString);
                }
            }
            /**
             * 外贸部特殊情况,【外贸部销售经理】审核之后,再由【外贸部总监】审核
             * 非外贸部,不需要经过【外贸部总监】审核
             */
            if (orderSignObj.getCurrentStep().equals(Constant.SING_STEP_SALES_MANAGER) && item.getRoleId() == Constant.ROLE_ID_SALES_MANAGER && item.getResult().equals(Constant.SIGN_APPROVE)) {
                User userSalesManager = userService.selectByAccount(item.getUser());
                if (userSalesManager.getMarketGroupName().equals("外贸一部") || userSalesManager.getMarketGroupName().equals("外贸二部")) {
                    logger.info("外贸部经理签核,且通过,需要【外贸部总监】审核");
                } else {
                    /**
                     * 内贸部的订单不需要外贸总监审核
                     * 外贸总监已经在流程中,把数据补充填上,流程往后走
                     */
                    needMakeUpOrderSignForForeignDirector = true;
                }
            }
        }
        // 都已经签核
        if (!haveReject) {
            if (currentStep.equals("")) {
                currentStep = Constant.SIGN_FINISHED;
            }
            orderSignObj.setCurrentStep(currentStep);
            orderSignService.update(orderSignObj);
            if (needMakeUpOrderSignForForeignDirector) {
                makeUpSignContent(orderSignObj);
            }
        }
        /**
         * 推送公众号消息给轮到的人(通过售后系统)
         */
        Contract contract = contractService.findById(contractId);
        String msgInfo = null;
        if (haveReject) {
            machineOrder.setStatus(Constant.ORDER_REJECTED);
            // /需求单相关,当前需求单审核变为初始化“SIGN_INITIAL”
            for (SignContentItem item : orderSignContentList) {
                item.setResult(Constant.SIGN_INITIAL);
            }
            orderSignObj.setSignContent(JSONObject.toJSONString(orderSignContentList));
            orderSignService.update(orderSignObj);
            // 如果有订单驳回,则设置合同为initial状态
            contract.setStatus(Constant.CONTRACT_INITIAL);
            msgInfo = Constant.STR_MSG_PUSH_SIGN_REFUESED;
        } else {
            if (machineOrder.getStatus().equals(Constant.ORDER_INITIAL)) {
                machineOrder.setStatus(Constant.ORDER_CHECKING);
            }
            // 需求单签核完成
            if (currentStep.equals(Constant.SIGN_FINISHED)) {
                machineOrder.setStatus(Constant.ORDER_CHECKING_FINISHED);
                commonService.createMachineByOrderId(machineOrder);
                msgInfo = Constant.STR_MSG_PUSH_SIGN_DONE;
            } else {
                msgInfo = Constant.STR_MSG_PUSH_IS_TURN_TO_SIGN;
            }
        }
        machineOrderService.update(machineOrder);
        commonService.syncMachineOrderStatusInDesignDepInfo(machineOrder);
        // 推送消息
        commonService.pushMachineOrderMsgToAftersale(orderSignObj, contract, machineOrder, haveReject, msgInfo);
        // 更新合同签核记录
        String step = commonService.getCurrentSignStep(contractId);
        ContractSign contractSign = contractSignService.detailByContractId(String.valueOf(contractId));
        if (step == null || contractSign == null) {
            throw new RuntimeException();
        } else {
            if (step.equals(Constant.SIGN_FINISHED)) {
                // 表示签核已经完成,合同设置“CONTRACT_CHECKING_FINISHED”
                contract.setStatus(Constant.CONTRACT_CHECKING_FINISHED);
            // //需求单也需要设置为签核完成状态“ORDER_CHECKING_FINISHED”
            // Condition tempCondition = new Condition(ContractSign.class);
            // tempCondition.createCriteria().andCondition("contract_id = ", contractId);
            // List<MachineOrder> machineOrderList = machineOrderService.findByCondition(tempCondition);
            // for (MachineOrder item : machineOrderList) {
            // if (item.getStatus().equals(Constant.ORDER_CHECKING)) {
            // item.setStatus(Constant.ORDER_CHECKING_FINISHED);
            // }
            // machineOrderService.update(item);
            // }
            // 根据合同中的需求单进行机器添加, 在需求单签核、合同签核都加上是因为最后一步审核可能是需求单,也可能是合同
            // commonService.createMachineByContractId(contractId);
            }
            // else {
            // if (haveReject) {
            // contract.setStatus(Constant.CONTRACT_REJECTED);
            // } else if (contract.getStatus().equals(Constant.CONTRACT_REJECTED)) {
            // contract.setStatus(Constant.CONTRACT_CHECKING);
            // }
            // }
            contract.setUpdateTime(new Date());
            contractService.update(contract);
        }
    // contractSign.setCurrentStep(step);
    // contractSignService.update(contractSign);
    }
    return ResultGenerator.genSuccessResult();
}
Also used : User(com.eservice.api.model.user.User) Date(java.util.Date) OrderSign(com.eservice.api.model.order_sign.OrderSign) SignContentItem(com.eservice.api.model.contract_sign.SignContentItem) ContractSign(com.eservice.api.model.contract_sign.ContractSign) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) DesignDepInfoDetail(com.eservice.api.model.design_dep_info.DesignDepInfoDetail) Contract(com.eservice.api.model.contract.Contract) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with DesignDepInfoDetail

use of com.eservice.api.model.design_dep_info.DesignDepInfoDetail in project sinsim by WilsonHu.

the class DesignDepInfoController method selectDesignDepInfo.

@PostMapping("/selectDesignDepInfo")
public Result selectDesignDepInfo(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, String orderNum, String saleman, String guestName, // 订单状态
Integer orderStatus, // 图纸状态
Integer drawingLoadingDoneStatus, String machineSpec, String keywords, String designer, String updateDateStart, String updateDateEnd) {
    PageHelper.startPage(page, size);
    List<DesignDepInfoDetail> list = designDepInfoService.selectDesignDepInfo(orderNum, saleman, guestName, orderStatus, drawingLoadingDoneStatus, machineSpec, keywords, designer, updateDateStart, updateDateEnd);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) DesignDepInfoDetail(com.eservice.api.model.design_dep_info.DesignDepInfoDetail) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

DesignDepInfoDetail (com.eservice.api.model.design_dep_info.DesignDepInfoDetail)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 Contract (com.eservice.api.model.contract.Contract)1 ContractSign (com.eservice.api.model.contract_sign.ContractSign)1 SignContentItem (com.eservice.api.model.contract_sign.SignContentItem)1 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)1 OrderSign (com.eservice.api.model.order_sign.OrderSign)1 User (com.eservice.api.model.user.User)1 PageInfo (com.github.pagehelper.PageInfo)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1