Search in sources :

Example 11 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class MachineController method selectMachines.

@PostMapping("/selectMachines")
public Result selectMachines(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, Integer id, Integer order_id, String machine_strid, String nameplate, String location, Byte status, Integer machine_type, String query_start_time, String query_finish_time, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
    PageHelper.startPage(page, size);
    List<Machine> list = machineService.selectMachines(id, order_id, machine_strid, nameplate, location, status, machine_type, query_start_time, query_finish_time, is_fuzzy);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 12 with Machine

use of com.eservice.api.model.machine.Machine 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);
    PageInfo pageInfo = new PageInfo(list);
    InputStream fs = null;
    POIFSFileSystem pfs = null;
    HSSFWorkbook wb = null;
    FileOutputStream out = null;
    String downloadPath = "";
    /*
        返回给docker外部下载
         */
    String downloadPathForNginx = "";
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
    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 = formatter.format(list.get(r).getInstallBeginTime());
                row.getCell(6).setCellValue(dateString);
            }
            // 安装的结束时间
            if (list.get(r).getInstallEndTime() != null) {
                dateString = formatter.format(list.get(r).getInstallEndTime());
                row.getCell(7).setCellValue(dateString);
            }
            // 质检的开始时间
            if (list.get(r).getQualityBeginTime() != null) {
                dateString = formatter.format(list.get(r).getQualityBeginTime());
                row.getCell(8).setCellValue(dateString);
            }
            // 质检的结束时间
            if (list.get(r).getQualityEndTime() != null) {
                dateString = formatter.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) PageInfo(com.github.pagehelper.PageInfo) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) 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 13 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class TaskRecordController method updateTaskInfo.

@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为空,数据更新失败!");
    }
    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();
        }
    }
    if (tr.getStatus().equals(Constant.TASK_INSTALLED)) {
        // MQTT 如果当前工序状态是安装完成等待质检的状态,则通知App
        // 找到工序对应的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());
        mqttMessageHelper.sendToClient(Constant.S2C_TASK_QUALITY + taskList.get(0).getQualityUserId(), JSON.toJSONString(msg));
    }
    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) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class DashboardController method getStatistics.

/**
 * @return 返回dashboard中用到的安装中、改拆单等数据信息
 */
@PostMapping("/getStatistic")
public Result getStatistics() {
    Statistic statistic = new Statistic();
    Condition condition = new Condition(Machine.class);
    condition.createCriteria().andCondition("status !=", Constant.MACHINE_INITIAL).andCondition("status !=", Constant.MACHINE_CONFIGURED).andCondition("status !=", Constant.MACHINE_CANCELED).andCondition("status !=", Constant.MACHINE_INSTALLED);
    List<Machine> machineList = machineService.findByCondition(condition);
    int installingNum = machineList.size();
    int changeNum = 0;
    int splitNum = 0;
    for (Machine item : machineList) {
        if (item.getStatus().equals(Constant.MACHINE_CHANGED)) {
            changeNum++;
        } else if (item.getStatus().equals(Constant.MACHINE_SPLITED)) {
            splitNum++;
        }
    }
    statistic.setInstallingMachineNum(installingNum);
    statistic.setChangeMachineNum(changeNum);
    statistic.setSplitMachineNum(splitNum);
    // 获取异常工序数量
    Condition taskRecordCondition = new Condition(TaskRecord.class);
    taskRecordCondition.createCriteria().andCondition("status >= ", Constant.TASK_INSTALL_ABNORMAL).andCondition("status <= ", Constant.TASK_QUALITY_ABNORMAL);
    List<TaskRecord> abnormalTaskRecordList = taskRecordService.findByCondition(taskRecordCondition);
    statistic.setAbnormalTaskNum(abnormalTaskRecordList.size());
    return ResultGenerator.genSuccessResult(statistic);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) TaskRecord(com.eservice.api.model.task_record.TaskRecord) Statistic(com.eservice.api.model.dashboard.Statistic) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 15 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class ProcessRecordController method addProcessForMachine.

@PostMapping("/addProcessForMachine")
@Transactional(rollbackFor = Exception.class)
public Result addProcessForMachine(String taskRecords, String processRecord, String machine) {
    ProcessRecord pr = JSON.parseObject(processRecord, ProcessRecord.class);
    List<TaskRecord> trList = JSON.parseArray(taskRecords, TaskRecord.class);
    Machine machineObj = JSON.parseObject(machine, Machine.class);
    if (pr == null || trList == null) {
        return ResultGenerator.genFailResult("提交到服务端的JSON数据解析错误");
    }
    Integer prId = pr.getId();
    pr.setCreateTime(new Date());
    try {
        // 已经保存过配置流程的,需要更新
        if (prId != null && prId > 0) {
            processRecordService.update(pr);
            try {
                // 删除旧的taskrecorder表中对应的任务,根据process_recorder_id删除 status==0的
                taskRecordService.deleteTaskRecordByCondition(null, prId, null, (byte) 0);
            } catch (Exception e) {
                e.printStackTrace();
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return ResultGenerator.genFailResult("taskRecordService删除旧任务失败");
            }
        } else {
            processRecordService.save(pr);
        }
    } catch (Exception e) {
        e.printStackTrace();
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return ResultGenerator.genFailResult("processRecordService数据库操作失败");
    }
    trList.forEach((item) -> {
        item.setProcessRecordId(pr.getId());
    });
    try {
        taskRecordService.save(trList);
    } catch (Exception e) {
        e.printStackTrace();
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return ResultGenerator.genFailResult("taskRecordService数据库操作失败");
    }
    try {
        // 如果机器处于初始化状态,则设置为“已配置”
        if (machineObj.getStatus().equals(Constant.MACHINE_INITIAL)) {
            // 如果已经是其他状态,则不需要更改机器状态
            machineObj.setStatus(Constant.MACHINE_CONFIGURED);
            if (machineObj.getId() == 0) {
                return ResultGenerator.genFailResult("机器Id为空,数据更新失败");
            }
            machineService.update(machineObj);
        }
    } catch (Exception e) {
        e.printStackTrace();
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return ResultGenerator.genFailResult("machineService数据库操作失败");
    }
    return ResultGenerator.genSuccessResult();
}
Also used : TaskRecord(com.eservice.api.model.task_record.TaskRecord) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) Machine(com.eservice.api.model.machine.Machine) Date(java.util.Date) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Machine (com.eservice.api.model.machine.Machine)15 PostMapping (org.springframework.web.bind.annotation.PostMapping)12 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)8 Condition (tk.mybatis.mapper.entity.Condition)8 TaskRecord (com.eservice.api.model.task_record.TaskRecord)7 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)6 Transactional (org.springframework.transaction.annotation.Transactional)6 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)5 Date (java.util.Date)5 Task (com.eservice.api.model.task.Task)4 PageInfo (com.github.pagehelper.PageInfo)3 AbnormalRecord (com.eservice.api.model.abnormal_record.AbnormalRecord)2 Contract (com.eservice.api.model.contract.Contract)2 MachineOrderWrapper (com.eservice.api.model.contract.MachineOrderWrapper)2 ContractSign (com.eservice.api.model.contract_sign.ContractSign)2 MachineOrderDetail (com.eservice.api.model.machine_order.MachineOrderDetail)2 OrderDetail (com.eservice.api.model.order_detail.OrderDetail)2 OrderSign (com.eservice.api.model.order_sign.OrderSign)2 Abnormal (com.eservice.api.model.abnormal.Abnormal)1 AbnormalImage (com.eservice.api.model.abnormal_image.AbnormalImage)1