Search in sources :

Example 16 with MachineOrder

use of com.eservice.api.model.machine_order.MachineOrder 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 17 with MachineOrder

use of com.eservice.api.model.machine_order.MachineOrder in project sinsim by WilsonHu.

the class TaskRecordController method exportToExcel.

/**
 *  在”生产管理”的“生产报表”导出到excel.
 */
@PostMapping("/exportToExcel")
public Result exportToExcel(Integer taskRecordId, String taskName, String machineOrderNumber, String queryStartTime, String queryFinishTime, String nameplate) {
    List<TaskRecordDetail> list = taskRecordService.searchTaskRecordDetail(taskRecordId, taskName, machineOrderNumber, queryStartTime, queryFinishTime, nameplate);
    HSSFWorkbook wb = null;
    FileOutputStream out = null;
    String downloadPath = "";
    /*
        返回给docker外部下载
         */
    String downloadPathForNginx = "";
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm");
    String dateString;
    try {
        // 生成一个空的Excel文件
        wb = new HSSFWorkbook();
        Sheet sheet1 = wb.createSheet("生产报表");
        // 设置标题行格式
        HSSFCellStyle headcellstyle = wb.createCellStyle();
        HSSFFont headfont = wb.createFont();
        headfont.setFontHeightInPoints((short) 10);
        // 粗体显示
        headfont.setBold(true);
        headcellstyle.setFont(headfont);
        Row row;
        // 创建行和列
        for (int r = 0; r < list.size() + 1; r++) {
            // 新创建一行,行号为row+1
            row = sheet1.createRow(r);
            // 序号,工序名称,订单号,机器编号,安装组长,安装的开始时间,安装的结束时间,耗时
            for (int c = 0; c < 8; c++) {
                // 创建一个单元格,列号为col+1
                row.createCell(c);
                sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
            }
        }
        for (int k = 1; k < 8; k++) {
            sheet1.setColumnWidth(k, 4500);
        }
        // 第一行为标题
        sheet1.getRow(0).getCell(0).setCellValue("序号");
        sheet1.getRow(0).getCell(1).setCellValue("工序名称");
        sheet1.getRow(0).getCell(2).setCellValue("订单号");
        sheet1.getRow(0).getCell(3).setCellValue("铭牌号/机器类型/针数/头数/头距/X行程/Y行程");
        sheet1.getRow(0).getCell(4).setCellValue("安装组长");
        sheet1.getRow(0).getCell(5).setCellValue("开始时间");
        sheet1.getRow(0).getCell(6).setCellValue("结束时间");
        sheet1.getRow(0).getCell(7).setCellValue("耗时(分钟)");
        // 第二行开始,填入值
        MachineType machineType1 = null;
        Byte taskStatus = 0;
        for (int r = 0; r < list.size(); r++) {
            row = sheet1.getRow(r + 1);
            row.getCell(0).setCellValue(r + 1);
            // 工序名称
            if (list.get(r).getTaskName() != null) {
                row.getCell(1).setCellValue(list.get(r).getTaskName());
            }
            // 订单号
            if (list.get(r).getMachineOrder().getOrderNum() != null) {
                row.getCell(2).setCellValue(list.get(r).getMachineOrder().getOrderNum());
            }
            // 机器编号等机器信息
            Machine machine = list.get(r).getMachine();
            MachineOrder machineOrder = list.get(r).getMachineOrder();
            MachineOrderDetail machineOrderDetail = machineOrderService.getOrderAllDetail(machineOrder.getId());
            if (machine != null && machineOrder != null) {
                String machineInfo = machine.getNameplate() + "/" + machineOrderDetail.getMachineType().getName() + "/" + machineOrder.getNeedleNum() + "/" + machineOrder.getHeadNum() + "/" + machineOrder.getHeadDistance() + "/" + machineOrder.getxDistance() + "/" + machineOrder.getyDistance();
                row.getCell(3).setCellValue(machineInfo);
            }
            // 安装组长
            if (list.get(r).getLeader() != null) {
                row.getCell(4).setCellValue(list.get(r).getLeader());
            }
            // 开始时间
            if (list.get(r).getInstallBeginTime() != null) {
                dateString = formatter.format(list.get(r).getInstallBeginTime());
                row.getCell(5).setCellValue(dateString);
            }
            // 结束时间
            if (list.get(r).getInstallEndTime() != null) {
                dateString = formatter.format(list.get(r).getInstallEndTime());
                row.getCell(6).setCellValue(dateString);
            }
            // 耗时
            if (list.get(r).getInstallBeginTime() != null && list.get(r).getInstallEndTime() != null) {
                long minHourDay = commonService.secondsToMin(list.get(r).getInstallEndTime().getTime() - list.get(r).getInstallBeginTime().getTime());
                row.getCell(7).setCellValue(minHourDay);
            }
        }
        downloadPath = taskRecordExcelOutputDir + "生产报表" + ".xls";
        downloadPathForNginx = "/excel/" + "生产报表" + ".xls";
        out = new FileOutputStream(downloadPath);
        wb.write(out);
        out.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    if ("".equals(downloadPath)) {
        return ResultGenerator.genFailResult("异常导出失败!");
    } else {
        return ResultGenerator.genSuccessResult(downloadPathForNginx);
    }
}
Also used : MachineType(com.eservice.api.model.machine_type.MachineType) MachineOrderDetail(com.eservice.api.model.machine_order.MachineOrderDetail) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Machine(com.eservice.api.model.machine.Machine) HSSFCellStyle(org.apache.poi.hssf.usermodel.HSSFCellStyle) TaskRecordDetail(com.eservice.api.model.task_record.TaskRecordDetail) HSSFFont(org.apache.poi.hssf.usermodel.HSSFFont) Row(org.apache.poi.ss.usermodel.Row) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) SimpleDateFormat(java.text.SimpleDateFormat) Sheet(org.apache.poi.ss.usermodel.Sheet) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 18 with MachineOrder

use of com.eservice.api.model.machine_order.MachineOrder in project sinsim by WilsonHu.

the class TaskQualityRecordController method update.

/**
 * web在提交解决方案时“在用”,但是因为 app没有在用, 即没有提交质检结果的地方。所以实际上没有作用。
 * 三期采用新的质检体系,这些都不会再被用
 */
// /
@PostMapping("/update")
public Result update(String taskQualityRecord) {
    TaskQualityRecord taskQualityRecord1 = JSON.parseObject(taskQualityRecord, TaskQualityRecord.class);
    taskQualityRecord1.setSolveTime(new Date());
    // 修改对应工序的状态为“质检中”
    TaskQualityRecord completeInfo = taskQualityRecordService.findById(taskQualityRecord1.getId());
    Integer taskRecordId = completeInfo.getTaskRecordId();
    if (taskRecordId != null && taskRecordId > 0) {
        TaskRecord tr = taskRecordService.findById(taskRecordId);
        // MQTT 异常解决后,通知工序的质检员
        String taskName = tr.getTaskName();
        Condition condition = new Condition(Task.class);
        condition.createCriteria().andCondition("task_name = ", taskName);
        List<Task> taskList = taskService.findByCondition(condition);
        if (taskList == null || taskList.size() <= 0) {
            throw new RuntimeException();
        }
        tr.setStatus(Constant.TASK_QUALITY_DOING);
        taskRecordService.update(tr);
        // 更新task record状态时候,必须去更新process record中对应task的状态
        commonService.updateTaskRecordRelatedStatus(tr);
        ProcessRecord pr = processRecordService.findById(tr.getProcessRecordId());
        Machine machine = machineService.findById(pr.getMachineId());
        ServerToClientMsg msg = new ServerToClientMsg();
        MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
        msg.setOrderNum(machineOrder.getOrderNum());
        msg.setNameplate(machine.getNameplate());
        mqttMessageHelper.sendToClient(Constant.S2C_QUALITY_ABNORMAL_RESOLVE + taskList.get(0).getQualityUserId(), JSON.toJSONString(msg));
    } else {
        throw new RuntimeException();
    }
    taskQualityRecordService.update(taskQualityRecord1);
    return ResultGenerator.genSuccessResult();
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) TaskRecord(com.eservice.api.model.task_record.TaskRecord) Task(com.eservice.api.model.task.Task) ServerToClientMsg(com.eservice.api.service.mqtt.ServerToClientMsg) TaskQualityRecord(com.eservice.api.model.task_quality_record.TaskQualityRecord) Date(java.util.Date) Machine(com.eservice.api.model.machine.Machine) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 19 with MachineOrder

use of com.eservice.api.model.machine_order.MachineOrder in project sinsim by WilsonHu.

the class ContactFormController method checkTheContactFormValid.

@PostMapping("/checkTheContactFormValid")
public Result checkTheContactFormValid(String contactForm) {
    if (contactForm == null) {
        return ResultGenerator.genFailResult("参数 contactFormDetail 不能为null ");
    }
    ContactForm contactForm1 = JSON.parseObject(contactForm, ContactForm.class);
    if (contactForm1 == null) {
        return ResultGenerator.genFailResult("错误,解析得到的 contactForm1为 null!");
    }
    /**
     * 逐一检查各个必要参数的合法性
     */
    if (contactForm1.getApplicantDepartment() == null) {
        return ResultGenerator.genFailResult("错误,getApplicantDepartment 为 null!");
    }
    if (contactForm1.getContactTitle() == null) {
        return ResultGenerator.genFailResult("错误,getContactTitle 为 null!");
    }
    // if(contactForm1.getOrderNum() == null){
    // return ResultGenerator.genFailResult("错误,orderNum 为 null!");
    // }
    // 根据订单号找订单
    MachineOrder machineOrder = machineOrderService.getMachineOrder(contactForm1.getOrderNum());
    if (machineOrder == null) {
        return ResultGenerator.genFailResult("错误,根据该订单号 找不到对应的订单 ");
    }
    return ResultGenerator.genSuccessResult("OK");
}
Also used : ContactForm(com.eservice.api.model.contact_form.ContactForm) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 20 with MachineOrder

use of com.eservice.api.model.machine_order.MachineOrder in project sinsim by WilsonHu.

the class CommonService method createMachineByContractId.

/**
 * 根据合同编号对应的需求单的机器
 * 目前 合同签核已经不存在了,即,只对订单进行签核。即应该已经不调用了。
 *
 * @param contractId
 */
public void createMachineByContractId(Integer contractId) {
    Condition condition = new Condition(MachineOrder.class);
    condition.createCriteria().andCondition("contract_id = ", contractId);
    List<MachineOrder> orderList = machineOrderService.findByCondition(condition);
    for (MachineOrder orderItem : orderList) {
        // 选取有效需求单,无效需求单对应的机器数不cover在内
        if (orderItem.getStatus().equals(Constant.ORDER_CHECKING_FINISHED) || orderItem.getStatus().equals(Constant.ORDER_SPLITED)) {
            Condition tempCondition = new Condition(Machine.class);
            tempCondition.createCriteria().andCondition("order_id = ", orderItem.getId());
            List<Machine> machineExistList = machineService.findByCondition(tempCondition);
            int haveToCreate = orderItem.getMachineNum() - machineExistList.size();
            int i = 1;
            while (i <= haveToCreate) {
                Machine machine = new Machine();
                machine.setMachineStrId(Utils.createMachineBasicId() + i);
                machine.setOrderId(orderItem.getId());
                machine.setMachineType(orderItem.getMachineType());
                machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_INITIAL)));
                machine.setCreateTime(new Date());
                machineService.save(machine);
                i++;
            }
        }
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) Machine(com.eservice.api.model.machine.Machine)

Aggregations

MachineOrder (com.eservice.api.model.machine_order.MachineOrder)29 PostMapping (org.springframework.web.bind.annotation.PostMapping)25 Machine (com.eservice.api.model.machine.Machine)16 Condition (tk.mybatis.mapper.entity.Condition)15 Date (java.util.Date)14 Transactional (org.springframework.transaction.annotation.Transactional)13 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)10 OrderSign (com.eservice.api.model.order_sign.OrderSign)9 Contract (com.eservice.api.model.contract.Contract)8 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)8 Task (com.eservice.api.model.task.Task)8 ContractSign (com.eservice.api.model.contract_sign.ContractSign)7 MachineOrderDetail (com.eservice.api.model.machine_order.MachineOrderDetail)7 TaskRecord (com.eservice.api.model.task_record.TaskRecord)7 OrderDetail (com.eservice.api.model.order_detail.OrderDetail)5 ArrayList (java.util.ArrayList)5 MachineOrderWrapper (com.eservice.api.model.contract.MachineOrderWrapper)4 SignContentItem (com.eservice.api.model.contract_sign.SignContentItem)4 SimpleDateFormat (java.text.SimpleDateFormat)4 MachineType (com.eservice.api.model.machine_type.MachineType)3