Search in sources :

Example 21 with MachineOrder

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

the class CommonService method updateTaskRecordRelatedStatus.

public boolean updateTaskRecordRelatedStatus(TaskRecord tr) {
    if (tr == null || tr.getProcessRecordId() == null) {
        return false;
    } else {
        Integer prId = tr.getProcessRecordId();
        ProcessRecord pr = processRecordService.findById(prId);
        Machine machine = machineService.findById(pr.getMachineId());
        boolean isNeedUpdateMachine = false;
        if (pr != null) {
            String nodeData = pr.getNodeData();
            List<NodeDataModel> ndList = JSON.parseArray(nodeData, NodeDataModel.class);
            NodeDataModel ndItem = null;
            Integer index = -1;
            for (int i = 0; i < ndList.size(); i++) {
                if (Integer.parseInt(ndList.get(i).getKey()) == tr.getNodeKey()) {
                    index = i;
                    break;
                }
            }
            if (index > -1) {
                ndItem = ndList.get(index);
                ndItem.setTaskStatus(tr.getStatus().toString());
                if (tr.getStatus().intValue() == Constant.TASK_PLANED.intValue() || tr.getStatus().intValue() == Constant.TASK_INSTALL_WAITING.intValue()) {
                    if (tr.getInstallBeginTime() == null) {
                        String date = Utils.getFormatStringDate(new Date(), "yyyy-MM-dd HH:mm:ss");
                        ndItem.setBeginTime(date);
                    }
                }
                if (tr.getInstallBeginTime() != null) {
                    String date = Utils.getFormatStringDate(tr.getInstallBeginTime(), "yyyy-MM-dd HH:mm:ss");
                    ndItem.setBeginTime(date);
                }
                // 质检完成,工序才算完成
                if (tr.getQualityEndTime() != null) {
                    String date = Utils.getFormatStringDate(tr.getQualityEndTime(), "yyyy-MM-dd HH:mm:ss");
                    ndItem.setEndTime(date);
                }
                // 组长信息
                if (tr.getLeader() != null && tr.getLeader().length() > 0) {
                    ndItem.setLeader(tr.getLeader());
                }
                // 工作人员信息
                if (tr.getWorkerList() != null && tr.getWorkerList().length() > 0) {
                    ndItem.setWorkList(tr.getWorkerList());
                }
                ndList.set(index, ndItem);
                // 如果当前工序是质检完成状态或者跳过状态,需要检查其子节点是否可以开始 -->3期时,工序安装完成,状态不再是“质检完成”而是“安装完成”
                if (tr.getStatus().intValue() == Constant.TASK_QUALITY_DONE.intValue() || tr.getStatus().intValue() == Constant.TASK_INSTALLED.intValue() || tr.getStatus().intValue() == Constant.TASK_SKIP.intValue()) {
                    List<LinkDataModel> linkDataList = JSON.parseArray(pr.getLinkData(), LinkDataModel.class);
                    for (LinkDataModel item : linkDataList) {
                        if (String.valueOf(item.getFrom()).equals(String.valueOf(ndItem.getKey()))) {
                            for (NodeDataModel childNode : ndList) {
                                // 先找到子节点
                                if (childNode.getKey().equals(String.valueOf(item.getTo()))) {
                                    // 找到子节点的所有父节点
                                    boolean allParentFinished = true;
                                    for (LinkDataModel parentOfChild : linkDataList) {
                                        if (!allParentFinished) {
                                            break;
                                        }
                                        if (String.valueOf(parentOfChild.getTo()).equals(childNode.getKey())) {
                                            for (NodeDataModel parentOfChildNode : ndList) {
                                                if (!allParentFinished) {
                                                    break;
                                                }
                                                if (String.valueOf(parentOfChild.getFrom()).equals(parentOfChildNode.getKey())) {
                                                    if (parentOfChildNode.getCategory() != null && (parentOfChildNode.getCategory().equals("Start") || parentOfChildNode.getCategory().equals("End"))) {
                                                        break;
                                                    }
                                                    // 3期质检,安装完成是真的“安装完成”。3期之前,安装完成时,状态是“质检完成”
                                                    if ((Integer.valueOf(parentOfChildNode.getTaskStatus()) != Constant.TASK_QUALITY_DONE.intValue() && Integer.valueOf(parentOfChildNode.getTaskStatus()) != Constant.TASK_INSTALLED.intValue()) && Integer.valueOf(parentOfChildNode.getTaskStatus()) != Constant.TASK_SKIP.intValue()) {
                                                        allParentFinished = false;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // 子节点的所有父节点都已经完成,则更新子节点的状态
                                    if (allParentFinished) {
                                        // 如果子工序不是结束“End”
                                        if (!"End".equals(childNode.getCategory())) {
                                            if (Integer.valueOf(childNode.getTaskStatus()) < Constant.TASK_INSTALL_WAITING.intValue()) {
                                                String dateStr = Utils.getFormatStringDate(new Date(), "yyyy-MM-dd HH:mm:ss");
                                                childNode.setBeginTime(dateStr);
                                                childNode.setTaskStatus(Constant.TASK_INSTALL_WAITING.toString());
                                                List<TaskRecord> taskRecordList = taskRecordService.getTaskRecordData(null, prId);
                                                for (TaskRecord record : taskRecordList) {
                                                    if (String.valueOf(record.getNodeKey().intValue()).equals(childNode.getKey())) {
                                                        record.setUpdateTime(new Date());
                                                        record.setStatus(Constant.TASK_INSTALL_WAITING);
                                                        taskRecordService.update(record);
                                                        // MQTT 通知下一道工序可以开始安装
                                                        ServerToClientMsg msg = new ServerToClientMsg();
                                                        MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
                                                        msg.setOrderNum(machineOrder.getOrderNum());
                                                        msg.setNameplate(machine.getNameplate());
                                                        // 找到工序对应的group_id
                                                        String taskName = record.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();
                                                        }
                                                        mqttMessageHelper.sendToClient(Constant.S2C_TASK_INSTALL + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
                                                    // 这个break需要去掉,因为存在多个子工序可以安装的情况
                                                    // break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Boolean isFinished = true;
            for (int i = 0; i < ndList.size() && isFinished; i++) {
                // 开始和结束节点不考虑在内
                if (ndList.get(i).getCategory() != null && (ndList.get(i).getCategory().equals("Start") || ndList.get(i).getCategory().equals("End"))) {
                    continue;
                }
                if (ndList.get(i).getTaskStatus() != null && (Integer.parseInt(ndList.get(i).getTaskStatus()) != Constant.TASK_QUALITY_DONE.intValue() && Integer.parseInt(ndList.get(i).getTaskStatus()) != Constant.TASK_INSTALLED.intValue())) {
                    isFinished = false;
                }
            }
            // 所有工序完成
            if (isFinished && (tr.getStatus() == Constant.TASK_QUALITY_DONE.intValue() || tr.getStatus() == Constant.TASK_INSTALLED.intValue())) {
                pr.setEndTime(new Date());
                // 安装完成
                machine.setStatus(Constant.MACHINE_INSTALLED);
                isNeedUpdateMachine = true;
            }
            if (machine.getStatus().equals(Constant.MACHINE_PLANING)) {
                // 安装中
                machine.setStatus(Constant.MACHINE_INSTALLING);
                isNeedUpdateMachine = true;
            }
            if (isNeedUpdateMachine) {
                machine.setUpdateTime(new Date());
                machineService.update(machine);
            }
            pr.setNodeData(JSON.toJSONString(ndList));
            processRecordService.update(pr);
            return true;
        } else {
            return false;
        }
    }
}
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) Machine(com.eservice.api.model.machine.Machine) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder)

Example 22 with MachineOrder

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

the class TaskRecordController method export.

/**
 * 导出计划到excel表格
 * @param orderNum
 * @param machineStrId
 * @param taskName
 * @param nameplate
 * @param installStatus
 * @param machineType
 * @param query_start_time
 * @param query_finish_time
 * @param is_fuzzy
 * @return
 */
@PostMapping("/export")
public Result export(String orderNum, String machineStrId, String taskName, String nameplate, Integer installStatus, Integer machineType, String query_start_time, String query_finish_time, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
    List<TaskRecordDetail> list = taskRecordService.selectPlanedTaskRecords(orderNum, machineStrId, taskName, nameplate, installStatus, machineType, query_start_time, query_finish_time, is_fuzzy);
    HSSFWorkbook wb = null;
    FileOutputStream out = null;
    String downloadPath = "";
    /*
        返回给docker外部下载
         */
    String downloadPathForNginx = "";
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
    SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy/MM/dd HH:mm");
    String dateString;
    try {
        // 生成一个空的Excel文件
        wb = new HSSFWorkbook();
        Sheet sheet1 = wb.createSheet("sheet1");
        // 设置标题行格式
        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 < 13; c++) {
                // 创建一个单元格,列号为col+1
                row.createCell(c);
                sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
            }
        }
        for (int k = 1; k < 13; 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("机型");
        sheet1.getRow(0).getCell(4).setCellValue("工序");
        sheet1.getRow(0).getCell(5).setCellValue("状态");
        sheet1.getRow(0).getCell(6).setCellValue("安装的开始时间");
        sheet1.getRow(0).getCell(7).setCellValue("安装的结束时间");
        sheet1.getRow(0).getCell(8).setCellValue("质检的开始时间");
        sheet1.getRow(0).getCell(9).setCellValue("质检的结束时间");
        sheet1.getRow(0).getCell(10).setCellValue("计划完成时间");
        sheet1.getRow(0).getCell(11).setCellValue("合同交货日期");
        sheet1.getRow(0).getCell(12).setCellValue("计划交货日期");
        // 第二行开始,填入值
        Machine machine = null;
        MachineOrder machineOrder = null;
        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).getMachineOrder().getOrderNum() != null) {
                row.getCell(1).setCellValue(list.get(r).getMachineOrder().getOrderNum());
            }
            // 机器编号
            if (list.get(r).getMachine().getNameplate() != null) {
                row.getCell(2).setCellValue(list.get(r).getMachine().getNameplate());
            }
            int machineTypeID = list.get(r).getMachine().getMachineType();
            machine = machineService.selectMachinesByNameplate(list.get(r).getMachine().getNameplate());
            /**
             * 获取机型类型的名称 machine_type.name
             */
            machineType1 = machineTypeService.findById(machineTypeID);
            if (machineType1 != null) {
                // 机型
                row.getCell(3).setCellValue(machineType1.getName());
            }
            // 工序
            if (list.get(r).getTaskName() != null) {
                row.getCell(4).setCellValue(list.get(r).getTaskName());
            }
            // 状态
            taskStatus = list.get(r).getStatus();
            if (taskStatus == Constant.TASK_INITIAL) {
                row.getCell(5).setCellValue(Constant.STR_TASK_INITIAL);
            } else if (taskStatus == Constant.TASK_PLANED) {
                row.getCell(5).setCellValue(Constant.STR_TASK_PLANED);
            } else if (taskStatus == Constant.TASK_INSTALL_WAITING) {
                row.getCell(5).setCellValue(Constant.STR_TASK_INSTALL_WAITING);
            } else if (taskStatus == Constant.TASK_INSTALLING) {
                row.getCell(5).setCellValue(Constant.STR_TASK_INSTALLING);
            } else if (taskStatus == Constant.TASK_INSTALLED) {
                row.getCell(5).setCellValue(Constant.STR_TASK_INSTALLED);
            } else if (taskStatus == Constant.TASK_QUALITY_DOING) {
                row.getCell(5).setCellValue(Constant.STR_TASK_QUALITY_DOING);
            } else if (taskStatus == Constant.TASK_QUALITY_DONE) {
                row.getCell(5).setCellValue(Constant.STR_TASK_QUALITY_DONE);
            } else if (taskStatus == Constant.TASK_INSTALL_ABNORMAL) {
                row.getCell(5).setCellValue(Constant.STR_TASK_INSTALL_ABNORMAL);
            } else if (taskStatus == Constant.TASK_QUALITY_ABNORMAL) {
                row.getCell(5).setCellValue(Constant.STR_TASK_QUALITY_ABNORMAL);
            } else if (taskStatus == Constant.TASK_SKIP) {
                row.getCell(5).setCellValue(Constant.STR_TASK_SKIP);
            }
            // 安装的开始时间
            if (list.get(r).getInstallBeginTime() != null) {
                dateString = formatter2.format(list.get(r).getInstallBeginTime());
                row.getCell(6).setCellValue(dateString);
            }
            // 安装的结束时间
            if (list.get(r).getInstallEndTime() != null) {
                dateString = formatter2.format(list.get(r).getInstallEndTime());
                row.getCell(7).setCellValue(dateString);
            }
            // 质检的开始时间
            if (list.get(r).getQualityBeginTime() != null) {
                dateString = formatter2.format(list.get(r).getQualityBeginTime());
                row.getCell(8).setCellValue(dateString);
            }
            // 质检的结束时间
            if (list.get(r).getQualityEndTime() != null) {
                dateString = formatter2.format(list.get(r).getQualityEndTime());
                row.getCell(9).setCellValue(dateString);
            }
            // 计划完成时间
            if (list.get(r).getTaskPlan().getPlanTime() != null) {
                dateString = formatter.format(list.get(r).getTaskPlan().getPlanTime());
                row.getCell(10).setCellValue(dateString);
            }
            // 合同交货日期
            if (list.get(r).getMachineOrder().getContractShipDate() != null) {
                dateString = formatter.format(list.get(r).getMachineOrder().getContractShipDate());
                row.getCell(11).setCellValue(dateString);
            }
            // 计划交货日期
            if (list.get(r).getMachineOrder().getPlanShipDate() != null) {
                dateString = formatter.format(list.get(r).getMachineOrder().getPlanShipDate());
                row.getCell(12).setCellValue(dateString);
            }
        }
        downloadPath = abnoramlExcelOutputDir + "导出计划" + ".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) 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 23 with MachineOrder

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

the class TaskRecordController method updateTaskInfo.

/**
 * 比如app扫码&结束开始时调用该接口,开始/完成一个工序各调用一次。
 * (质检报正常也是调该接口,即无论是否质检都调这个接口 --原先的质检已经弃用了)
 *
 * app扫码报异常时,调用 addTrArAi (app报正常时,调用的是 updateTaskInfo, 少了两个参数)
 * (质检报正常也是调addTrArAi)
 *
 * 开始安装,eg:
 * [     {
 *     "cmtFeedback":"",
 *     "id":55531,
 *     "installBeginTime":"20210127141618",
 *     "leader":"",
 *     "machine":{
 *         "createTime":"1609394393000",
 *         "id":5756,
 *         "isUrgent":false,
 *         "location":"上C2",
 *         "machineStrId":"CBB142313294",
 *         "machineType":2,
 *         "nameplate":"2011201",
 *         "orderId":2872,
 *         "status":3,
 *         "updateTime":"1609739671000"
 *     },
 *     "machineOrder":{
 *         "contractShipDate":"1608652800000",
 *         "headNum":"24",
 *         "id":2872,
 *         "machineType":2,
 *         "needleNum":"9",
 *         "orderNum":"骆1417C",
 *         "planShipDate":1609862400000
 *     },
 *     "nodeKey":-19,
 *     "processRecordId":5367,
 *     "status":3,  ====> "3" --> 开始安装
 *     "task":{
 *         "id":2,
 *         "qualityUserId":0
 *     },
 *     "taskName":"下轴安装",
 *     "taskPlan":{
 *         "createTime":"1609394393000",
 *         "id":51821,
 *         "planTime":1609776000000,
 *         "planType":1,
 *         "taskRecordId":55531,
 *         "updateTime":"1609739671000",
 *         "userId":169
 *     },
 *     "workerList":""
 *     }     ]
 *     扫描结束安装:
 *     [     {
 *     "cmtFeedback":"拜拜拜拜布b",
 *     "id":55531,
 *     "installBeginTime":"20210127141618",
 *     "installEndTime":"20210127141958",
 *     "leader":"a1",
 *     "machine":{
 *         "createTime":"1609394393000",
 *         "id":5756,
 *         "isUrgent":false,
 *         "location":"上C2",
 *         "machineStrId":"CBB142313294",
 *         "machineType":2,
 *         "nameplate":"2011201",
 *         "orderId":2872,
 *         "status":3,
 *         "updateTime":"1609739671000"
 *     },
 *     "machineOrder":{
 *         "contractShipDate":"1608652800000",
 *         "headNum":"24",
 *         "id":2872,
 *         "machineType":2,
 *         "needleNum":"9",
 *         "orderNum":"骆1417C",
 *         "planShipDate":1609862400000
 *     },
 *     "nodeKey":-19,
 *     "processRecordId":5367,
 *     "qualityBeginTime":"20210127141958",
 *     "qualityEndTime":"20210127141958",
 *     "status":6,  ========> "6" --> 质检完成, 三期新质检,这里不再是6,改为4
 *     "task":{
 *         "id":2,
 *         "qualityUserId":0
 *     },
 *     "taskName":"下轴安装",
 *     "taskPlan":{
 *         "createTime":"1609394393000",
 *         "id":51821,
 *         "planTime":1609776000000,
 *         "planType":1,
 *         "taskRecordId":55531,
 *         "updateTime":"1609739671000",
 *         "userId":169
 *     },
 *     "workerList":"赵建富"
 *     }     ]
 */
@PostMapping("/updateTaskInfo")
@Transactional(rollbackFor = Exception.class)
public Result updateTaskInfo(String taskRecord) {
    TaskRecord tr = JSON.parseObject(taskRecord, TaskRecord.class);
    Integer id = tr.getId();
    if (id == null || id < 0) {
        return ResultGenerator.genFailResult("TaskRecord的ID为空,数据更新失败!");
    }
    // 防止开始安装时间为空的问题
    if (tr.getStatus().intValue() == Constant.TASK_INSTALLING.intValue()) {
        try {
            if (tr.getUpdateTime() != null) {
                Integer timespan = (int) ((new Date().getTime() - tr.getUpdateTime().getTime()) / (1000 * 60 * 60));
                tr.setWaitTimespan(timespan);
                // 同步更新到ProcessRecord对应的task中
                ProcessRecord processRecord = processRecordService.findById(tr.getProcessRecordId());
                String nodeData = processRecord.getNodeData();
                List<NodeDataModel> ndList = JSON.parseArray(nodeData, NodeDataModel.class);
                for (int i = 0; i < ndList.size(); i++) {
                    if (ndList.get(i).getKey().equals(String.valueOf(tr.getNodeKey()))) {
                        ndList.get(i).setWaitTimespan(timespan);
                        ndList.get(i).setBeginTime(new Date().toString());
                        break;
                    }
                }
                processRecord.setNodeData(JSON.toJSONString(ndList));
                processRecordService.update(processRecord);
            }
        } catch (Exception ex) {
            logger.warn("updateTaskInfo exception: " + ex.getMessage());
        }
        tr.setInstallBeginTime(new Date());
    } else if (tr.getStatus().intValue() == Constant.TASK_PLANED.intValue() || tr.getStatus().intValue() == Constant.TASK_INSTALL_WAITING.intValue()) {
        ProcessRecord pr = processRecordService.findById(tr.getProcessRecordId());
        String nData = pr.getNodeData();
        List<NodeDataModel> ndList = JSON.parseArray(nData, NodeDataModel.class);
        for (int i = 0; i < ndList.size(); i++) {
            if (ndList.get(i).getKey().equals(String.valueOf(tr.getNodeKey()))) {
                if (ndList.get(i).getBeginTime() == "" || ndList.get(i).getBeginTime() == null) {
                    ndList.get(i).setBeginTime(new Date().toString());
                }
                break;
            }
        }
        pr.setNodeData(JSON.toJSONString(ndList));
        processRecordService.update(pr);
    }
    taskRecordService.update(tr);
    Integer prId = tr.getProcessRecordId();
    if (prId == null || prId < 0) {
        Logger.getLogger("").log(Level.INFO, "processrecord Id 为空");
    } else {
        // Update task record相关的状态
        if (!commonService.updateTaskRecordRelatedStatus(tr)) {
            // 更新出错进行事务回退
            throw new RuntimeException();
        }
    }
    // 找到工序对应的quality_user_id
    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();
    }
    ProcessRecord pr = processRecordService.findById(prId);
    Machine machine = machineService.findById(pr.getMachineId());
    MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
    ServerToClientMsg msg = new ServerToClientMsg();
    msg.setOrderNum(machineOrder.getOrderNum());
    msg.setNameplate(machine.getNameplate());
    if (tr.getStatus().equals(Constant.TASK_INSTALLED)) {
        // MQTT 如果当前工序状态是安装完成等待质检的状态,则通知App
        mqttMessageHelper.sendToClient(Constant.S2C_TASK_QUALITY + taskList.get(0).getQualityUserId(), JSON.toJSONString(msg));
    }
    if (tr.getStatus().equals(Constant.TASK_INSTALLED)) {
        createInstallPlanActual(tr);
    }
    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) Date(java.util.Date) Machine(com.eservice.api.model.machine.Machine) NodeDataModel(com.eservice.api.service.common.NodeDataModel) List(java.util.List) ArrayList(java.util.ArrayList) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with MachineOrder

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

the class TaskRecordController method createInstallPlanActual.

/**
 * 根据已完成的工序,自动生成 【对应工序的】的总装排产的实际完成情况
 */
public void createInstallPlanActual(TaskRecord tr) {
    /**
     * 如果机器某个工序已经完成(结束扫码),
     * 则该机器的 对应的总装的 工序的针数头数自动填写为全部完成,
     * 这样app用户就不需要重复去报告总装工序的情况。
     *
     * task_record --> process_record --> machine --> install_plan --> install_plan_actual
     */
    ProcessRecord pr = processRecordService.findById(tr.getProcessRecordId());
    Machine machine = machineService.findById(pr.getMachineId());
    List<InstallPlan> installPlanList = installPlanService.getInstallPlanByMachineId(machine.getId());
    MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
    InstallGroup installGroup = installGroupService.getInstallGroupByTaskName(tr.getTaskName());
    for (InstallPlan installplan : installPlanList) {
        if (installGroup.getId() == installplan.getInstallGroupId()) {
            InstallPlanActual installPlanActual = new InstallPlanActual();
            installPlanActual.setCreateDate(new Date());
            installPlanActual.setInstallPlanId(installplan.getId());
            installPlanActual.setHeadCountDone(commonService.getRealSumValue(machineOrder.getHeadNum()));
            installPlanActualService.save(installPlanActual);
            // /这里可以获取id ! ...
            Logger.getLogger("").log(Level.INFO, "自动生成 实际总装 " + installPlanActual.getId() + ", 头数 " + installPlanActual.getHeadCountDone());
            break;
        } else {
        // Logger.getLogger("").log(Level.INFO, installGroup.getGroupName() + ", 无需生成 ");
        }
    }
}
Also used : InstallPlanActual(com.eservice.api.model.install_plan_actual.InstallPlanActual) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) InstallGroup(com.eservice.api.model.install_group.InstallGroup) Machine(com.eservice.api.model.machine.Machine) Date(java.util.Date) InstallPlan(com.eservice.api.model.install_plan.InstallPlan)

Example 25 with MachineOrder

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

the class ContractController method startSign.

@PostMapping("/startSign")
@Transactional(rollbackFor = Exception.class)
public Result startSign(@RequestParam Integer contractId) {
    if (contractId == null) {
        ResultGenerator.genFailResult("合同ID为空!");
    } else {
        ContractSign contractSign = contractSignService.detailByContractId(String.valueOf(contractId));
        if (contractSign == null) {
            return ResultGenerator.genFailResult("根据合同号获取合同签核信息失败!");
        } else {
            // 更新合同状态为“CONTRACT_CHECKING”
            Contract contract = contractService.findById(contractId);
            if (contract == null) {
                return ResultGenerator.genFailResult("合同编号ID无效");
            } else {
                contract.setStatus(Constant.CONTRACT_CHECKING);
                contract.setUpdateTime(new Date());
                contractService.update(contract);
            }
            // 设置该合同下的需求单状态,如果处于“ORDER_INITIAL”状态,则设置为“ORDER_CHECKING”
            Condition tempCondition = new Condition(MachineOrder.class);
            tempCondition.createCriteria().andCondition("contract_id = ", contractId).andCondition("status = ", Constant.ORDER_INITIAL).andCondition("valid = ", 1);
            List<MachineOrder> orderList = machineOrderService.findByCondition(tempCondition);
            for (MachineOrder orderItem : orderList) {
                if (orderItem.getStatus().equals(Constant.ORDER_INITIAL)) {
                    orderItem.setStatus(Constant.ORDER_CHECKING);
                    machineOrderService.update(orderItem);
                    commonService.syncMachineOrderStatusInDesignDepInfo(orderItem);
                    Condition signCondition = new Condition(OrderSign.class);
                    signCondition.createCriteria().andCondition("order_id = ", orderItem.getId());
                    List<OrderSign> orderSignList = orderSignService.findByCondition(signCondition);
                    // 无签核记录
                    if (orderSignList.size() == 0) {
                        throw new RuntimeException();
                    } else {
                        OrderSign sign = orderSignList.get(orderSignList.size() - 1);
                        List<SignContentItem> orderSignContentList = JSON.parseArray(sign.getSignContent(), SignContentItem.class);
                        sign.setCurrentStep(roleService.findById(orderSignContentList.get(0).getRoleId()).getRoleName());
                        orderSignService.update(sign);
                        /**
                         * 发起签核时 也给第一个签核人推送
                         */
                        commonService.pushMachineOrderMsgToAftersale(sign, contract, orderItem, false, Constant.STR_MSG_PUSH_IS_TURN_TO_SIGN);
                    }
                }
            }
        // 更新签核记录
        // contractSign.setUpdateTime(new Date());
        // String currentStep = commonService.getCurrentSignStep(contractId);
        // if (currentStep == null) {
        // return ResultGenerator.genFailResult("获取当前签核steps失败!");
        // }
        // contractSign.setCurrentStep(currentStep);
        // //设置完状态后更新签核记录
        // contractSignService.update(contractSign);
        }
    }
    return ResultGenerator.genSuccessResult();
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) 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) Contract(com.eservice.api.model.contract.Contract) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

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