Search in sources :

Example 11 with MachineOrder

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

the class MachineOrderController method getValidList.

@PostMapping("/getValidList")
public Result getValidList(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
    PageHelper.startPage(page, size);
    Condition condition = new Condition(MachineOrder.class);
    condition.createCriteria().andCondition("valid = ", 1);
    List<MachineOrder> list = machineOrderService.findByCondition(condition);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PageInfo(com.github.pagehelper.PageInfo) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 12 with MachineOrder

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

the class MachineOrderController method isOrderNumExist.

@PostMapping("/isOrderNumExist")
public Result isOrderNumExist(@RequestParam String orderNum) {
    if (orderNum == null) {
        return ResultGenerator.genFailResult("请输入需求单编号!");
    } else {
        Condition condition = new Condition(MachineOrder.class);
        condition.createCriteria().andCondition("order_num = ", orderNum).andCondition("valid = ", 1);
        List<MachineOrder> list = machineOrderService.findByCondition(condition);
        if (list.size() == 0) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult("需求单编号已存在!");
        }
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 13 with MachineOrder

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

the class TaskRecordController method addTrTqrQri.

/**
 * 3个表 task_record/TaskQualityRecord/QualityRecordImage 更新。
 * app端,上传质检异常状态,task_record(update),增加 TaskQualityRecord(add), QualityRecordImage (add)
 * 没有质检员了,这个接口没在用。
 */
@Transactional(rollbackFor = Exception.class)
@PostMapping("/addTrTqrQri")
public Result addTrTqrQri(@RequestParam String taskRecord, @RequestParam String taskQualityRecord, @RequestParam MultipartFile[] files) {
    // task_record(update)
    TaskRecord taskRecord1 = JSON.parseObject(taskRecord, TaskRecord.class);
    taskRecordService.update(taskRecord1);
    TaskQualityRecord taskQualityRecord1 = JSON.parseObject(taskQualityRecord, TaskQualityRecord.class);
    // 质检异常类型,目前未使用,default值为1
    taskQualityRecord1.setAbnormalType(1);
    taskQualityRecordService.saveAndGetID(taskQualityRecord1);
    // 获取保存后分配到的id
    Integer taskQualityRecordId = taskQualityRecord1.getId();
    // 构建 qualityRecordImage1
    QualityRecordImage qualityRecordImage1 = new QualityRecordImage();
    File dir = new File(qualityImagesSavedDir);
    if (!dir.exists()) {
        dir.mkdir();
    }
    String machineID = machineService.searchMachineByTaskQualityRecordId(taskQualityRecordId).getMachineStrId();
    Integer orderId = machineService.searchMachineByTaskQualityRecordId(taskQualityRecordId).getOrderId();
    String orderNum = machineOrderService.findById(orderId).getOrderNum();
    List<String> listResultPath = new ArrayList<>();
    for (int i = 0; i < files.length; i++) {
        try {
            listResultPath.add(commonService.saveFile(qualityImagesSavedDir, files[i], machineID, orderNum, Constant.QUALITY_IMAGE, i));
        } catch (IOException e) {
            e.printStackTrace();
            // 抛异常引发回滚,防止数据只更新了前面部分。
            throw new RuntimeException();
        }
    }
    if (listResultPath.size() != files.length) {
        throw new RuntimeException();
    } else {
        qualityRecordImage1.setTaskQualityRecordId(taskQualityRecordId);
        qualityRecordImage1.setImage(listResultPath.toString());
        qualityRecordImage1.setCreateTime(taskQualityRecord1.getCreateTime());
        qualityRecordImageService.save(qualityRecordImage1);
    }
    // 找到工序对应的quality_user_id
    String taskName = taskRecord1.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();
    }
    Integer prId = taskRecord1.getProcessRecordId();
    if (prId == null || prId < 0) {
        Logger.getLogger("").log(Level.INFO, "processrecord Id 为空");
    } else {
        // Update task record相关的状态
        if (!commonService.updateTaskRecordRelatedStatus(taskRecord1)) {
            // 更新出错进行事务回退
            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 (taskRecord1.getStatus().equals(Constant.TASK_QUALITY_ABNORMAL)) {
        // MQTT 发生质检异常时,通知安装组长以及生产部管理员
        mqttMessageHelper.sendToClient(Constant.S2C_QUALITY_ABNORMAL + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
    }
    return ResultGenerator.genSuccessResult("3个表 task_record + TaskQualityRecord + QualityRecordImage 更新成功");
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) TaskRecord(com.eservice.api.model.task_record.TaskRecord) Task(com.eservice.api.model.task.Task) ArrayList(java.util.ArrayList) ServerToClientMsg(com.eservice.api.service.mqtt.ServerToClientMsg) TaskQualityRecord(com.eservice.api.model.task_quality_record.TaskQualityRecord) QualityRecordImage(com.eservice.api.model.quality_record_image.QualityRecordImage) Machine(com.eservice.api.model.machine.Machine) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) MultipartFile(org.springframework.web.multipart.MultipartFile) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with MachineOrder

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

the class TaskRecordController method addTrArAi.

/**
 * task_record, abnormal_record, abnormal_image  3个表一起更新。
 * app端,在安装异常时需要更新task_record(update),增加 abnormal_record(add), abnormal_image (add)
 *
 * app扫码报异常时,调用addTrArAi (app报正常时,调用的是 updateTaskInfo, 少了异常记录和文件两个参数)
 */
@Transactional(rollbackFor = Exception.class)
@PostMapping("/addTrArAi")
public Result addTrArAi(@RequestParam String taskRecord, @RequestParam String abnormalRecord, @RequestParam MultipartFile[] files) {
    // task_record(update)
    TaskRecord taskRecord1 = JSON.parseObject(taskRecord, TaskRecord.class);
    taskRecordService.update(taskRecord1);
    // abnormal_record add:
    AbnormalRecord abnormalRecord1 = JSON.parseObject(abnormalRecord, AbnormalRecord.class);
    // 在安装异常时,并没有SolutionUser,即还不知道SolutionUser,所以这里设为null
    abnormalRecord1.setSolutionUser(null);
    // 在47服务器saveAndGetID执行成功,但是实际没有数据保存在数据库 --是因为数据库从5.7改为了最新的8,改回旧的mysql docker即可。
    abnormalRecordService.saveAndGetID(abnormalRecord1);
    // 获取保存后分配到的id
    Integer abnormalRecordId = abnormalRecord1.getId();
    // if(abnormalRecord1 !=null) {
    // logger.info("abnormalRecordId: " + abnormalRecordId);
    // AbnormalRecord abInserted = null;
    // abInserted = abnormalRecordService.findById(abnormalRecordId);
    // if(abInserted == null){
    // logger.info("刚刚尝试插入的数据,却没有在数据库里找到");
    // 
    // } else {   logger.info("刚刚尝试插入的数据,却没有在数据库里找到");
    // logger.info("刚刚尝试插入的数据,可以根据abnormalRecordId找到");
    // }
    // } else {
    // logger.error("异常,生成 abnormalRecord1 为null");
    // }
    /**
     * abnormal_image add
     * 因为此时从app端无法知道 abnormal_record_id,所以需要在服务端获取abnormal_record_id
     * abnormal_image的create_time和abnormal_record.create_time一样
     */
    AbnormalImage abnormalImage1 = new AbnormalImage();
    File dir = new File(imagesSavedDir);
    if (!dir.exists()) {
        dir.mkdir();
    }
    String machineID = machineService.searchMachineByAbnormalRecordId(abnormalRecordId).getMachineStrId();
    Integer orderId = machineService.searchMachineByAbnormalRecordId(abnormalRecordId).getOrderId();
    String orderNum = machineOrderService.findById(orderId).getOrderNum();
    List<String> listResultPath = new ArrayList<>();
    for (int i = 0; i < files.length; i++) {
        try {
            listResultPath.add(commonService.saveFile(imagesSavedDir, files[i], machineID, orderNum, Constant.ABNORMAL_IMAGE, i));
        } catch (IOException e) {
            e.printStackTrace();
            // 抛异常引发回滚,防止数据只更新了前面部分。
            throw new RuntimeException();
        }
    }
    if (listResultPath.size() != files.length) {
        throw new RuntimeException();
    } else {
        abnormalImage1.setImage(listResultPath.toString());
        abnormalImage1.setAbnormalRecordId(abnormalRecordId);
        abnormalImage1.setCreateTime(abnormalRecord1.getCreateTime());
        abnormalImageService.save(abnormalImage1);
    }
    // 找到工序对应的quality_user_id
    String taskName = taskRecord1.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();
    }
    Integer prId = taskRecord1.getProcessRecordId();
    if (prId == null || prId < 0) {
        Logger.getLogger("").log(Level.INFO, "processrecord Id 为空");
    } else {
        // Update task record相关的状态
        if (!commonService.updateTaskRecordRelatedStatus(taskRecord1)) {
            // 更新出错进行事务回退
            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 (taskRecord1.getStatus().equals(Constant.TASK_INSTALL_ABNORMAL)) {
        // MQTT 发生安装异常时,通知生产部管理员
        // mqttMessageHelper.sendToClient(Constant.S2C_INSTALL_ABNORMAL + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
        // MQTT 发生安装异常时,通知对应质检员
        mqttMessageHelper.sendToClient(Constant.S2C_INSTALL_ABNORMAL_TO_QUALITY + taskList.get(0).getQualityUserId(), JSON.toJSONString(msg));
    }
    // createInstallPlanActual(taskRecord1);
    return ResultGenerator.genSuccessResult("3个表 task_record + abnormal_record + abnormal_image更新成功");
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) TaskRecord(com.eservice.api.model.task_record.TaskRecord) Task(com.eservice.api.model.task.Task) AbnormalImage(com.eservice.api.model.abnormal_image.AbnormalImage) ArrayList(java.util.ArrayList) ServerToClientMsg(com.eservice.api.service.mqtt.ServerToClientMsg) Machine(com.eservice.api.model.machine.Machine) AbnormalRecord(com.eservice.api.model.abnormal_record.AbnormalRecord) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) MultipartFile(org.springframework.web.multipart.MultipartFile) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with MachineOrder

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

the class MachineController method processMachineExport.

@PostMapping("/processMachineExport")
public Result processMachineExport(Integer order_id, String orderNum, String contractNum, String machine_strid, String nameplate, String location, String status, String query_start_time, String query_finish_time, // 工序集合,逗号分隔,支持UI按多个工序查询
String taskNameList, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
    List<MachineInfo> list = machineService.selectProcessMachine(order_id, orderNum, contractNum, machine_strid, nameplate, location, status, query_start_time, query_finish_time, taskNameList, is_fuzzy);
    InputStream fs = null;
    POIFSFileSystem pfs = null;
    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 < 10; c++) {
                // 创建一个单元格,列号为col+1
                row.createCell(c);
                sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
                sheet1.setColumnWidth(c, 4500);
                sheet1.setColumnWidth(0, 2500);
            }
        }
        // 第一行为标题
        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("计划交货日期");
        // 第二行开始,填入值
        Machine machine = null;
        MachineOrder machineOrder = null;
        MachineType machineType1 = null;
        Byte machineStatus = 0;
        for (int r = 0; r < list.size(); r++) {
            // 序号,机器编号,机型,订单号,位置,当前工序,已完成/总工序,安装状态,开始时间,计划交货日期
            row = sheet1.getRow(r + 1);
            row.getCell(0).setCellValue(r + 1);
            // 机器编号
            if (list.get(r).getMachineStrId() != null) {
                row.getCell(1).setCellValue(list.get(r).getNameplate());
            }
            // 机型
            int machineTypeID = list.get(r).getMachineType();
            // machine = machineService.selectMachinesByNameplate(list.get(r).getNameplate());
            /**
             * 获取机型类型的名称 machine_type.name
             */
            machineType1 = machineTypeService.findById(machineTypeID);
            if (machineType1 != null) {
                // 机型
                row.getCell(2).setCellValue(machineType1.getName());
            }
            // 订单号
            if (list.get(r).getOrderNum() != null) {
                row.getCell(3).setCellValue(list.get(r).getOrderNum());
            }
            // 位置
            if (list.get(r).getLocation() != null) {
                row.getCell(4).setCellValue(list.get(r).getLocation());
            }
            // 当前工序
            // /todo: 从 nodeData中解析出工序? 注意可能有多个。
            // 已完成/总工序
            // / todo: 从 nodeData中解析计算?
            // 状态
            machineStatus = list.get(r).getStatus();
            if (machineStatus == Constant.MACHINE_INITIAL) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_INITIAL);
            } else if (machineStatus == Constant.MACHINE_CONFIGURED) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_CONFIGURED);
            } else if (machineStatus == Constant.MACHINE_PLANING) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_PLANING);
            } else if (machineStatus == Constant.MACHINE_INSTALLING) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_INSTALLING);
            } else if (machineStatus == Constant.MACHINE_INSTALLED) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_INSTALLED);
            } else if (machineStatus == Constant.MACHINE_CHANGED) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_CHANGED);
            } else if (machineStatus == Constant.MACHINE_SPLITED) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_SPLITED);
            } else if (machineStatus == Constant.MACHINE_CANCELED) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_CANCELED);
            } else if (machineStatus == Constant.MACHINE_INSTALLING_INCLUDE_SKIP_TASK) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_INSTALLING_INCLUDE_SKIP_TASK);
            } else if (machineStatus == Constant.MACHINE_SHIPPED) {
                row.getCell(7).setCellValue(Constant.STR_MACHINE_SHIPPED);
            }
            // 的开始时间
            if (list.get(r).getProcessCreateTime() != null) {
                dateString = formatter2.format(list.get(r).getProcessCreateTime());
                row.getCell(8).setCellValue(dateString);
            }
            // 计划交货日期
            if (list.get(r).getPlanShipDate() != null) {
                dateString = formatter.format(list.get(r).getPlanShipDate());
                row.getCell(9).setCellValue(dateString);
            }
        }
        downloadPath = machinePorcessExcelOutputDir + "安装进度" + ".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 : InputStream(java.io.InputStream) MachineType(com.eservice.api.model.machine_type.MachineType) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Machine(com.eservice.api.model.machine.Machine) HSSFCellStyle(org.apache.poi.hssf.usermodel.HSSFCellStyle) MachineInfo(com.eservice.api.model.machine.MachineInfo) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) FileOutputStream(java.io.FileOutputStream) 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)

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