Search in sources :

Example 1 with QualityInspectRecord

use of com.eservice.api.model.quality_inspect_record.QualityInspectRecord in project sinsim by WilsonHu.

the class QualityInspectRecordController method updateQualityInspectRecordList.

/**
 *  更新质检记录
 *  接收的是JSON化的数组
 */
@PostMapping("/updateQualityInspectRecordList")
public Result updateQualityInspectRecordList(String mQualityInspectRecordTobeUploadList) {
    // logger.info(mQualityInspectRecordTobeUploadList);
    JSONArray jsonArray = JSON.parseArray(mQualityInspectRecordTobeUploadList);
    if (null != jsonArray) {
        int size = jsonArray.size();
        logger.info("更新质检记录,size: " + size);
        for (int i = 0; i < size; i++) {
            QualityInspectRecord qualityInspectRecordTobeUpdate = JSON.parseObject((String) jsonArray.get(i).toString(), QualityInspectRecord.class);
            // 机器的所有质检一起发过来,但是时间不能都更新,应该只更新改变的, 所以在APP上设置更新时间
            // qualityInspectRecordTobeUpdate.setUpdateTime(new Date());
            qualityInspectRecordService.update(qualityInspectRecordTobeUpdate);
        }
    }
    return ResultGenerator.genSuccessResult();
}
Also used : JSONArray(com.alibaba.fastjson.JSONArray) QualityInspectRecord(com.eservice.api.model.quality_inspect_record.QualityInspectRecord) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with QualityInspectRecord

use of com.eservice.api.model.quality_inspect_record.QualityInspectRecord in project sinsim by WilsonHu.

the class QualityInspectRecordController method list.

@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
    PageHelper.startPage(page, size);
    List<QualityInspectRecord> list = qualityInspectRecordService.findAll();
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) QualityInspectRecord(com.eservice.api.model.quality_inspect_record.QualityInspectRecord) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with QualityInspectRecord

use of com.eservice.api.model.quality_inspect_record.QualityInspectRecord in project sinsim by WilsonHu.

the class MachineController method update.

@PostMapping("/update")
public Result update(String machine) {
    logger.info(machine);
    Machine machine1 = JSON.parseObject(machine, Machine.class);
    machine1.setUpdateTime(new Date());
    // 如果该机器有对应的工序是跳过未完成的,不允许设置为已完成。
    if (machine1.getNameplate() != null && !machine1.getNameplate().isEmpty()) {
        List<TaskRecordDetail> list = taskRecordService.selectTaskRecordByMachineNameplate(machine1.getNameplate());
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getStatus().equals(Constant.TASK_SKIP)) {
                return ResultGenerator.genFailResult("该机器还有处于跳过状态的工序:" + list.get(i).getTaskName() + ",不允许设置为完成!");
            }
        }
    }
    /**
     * 3期新质检:
     * 如果是设置了 机器位置(从无到有),则创建质检记录(状态为未质检),发消息给质检人员,表示要开始安装了,可以过来看了。
     * 大概是因为有些质检需要在安装过程中看。
     *
     * 创建该机器的所有工序对应的所有质检项, 注意: 如果工序没有包含质检项,则不会生成该工序的质检项。
     */
    Machine machineOld = machineService.findById(machine1.getId());
    if (machineOld != null) {
        if ((machineOld.getLocation() == null || machineOld.getLocation().isEmpty()) && (machine1.getLocation() != null)) {
            MachineOrder machineOrder = machineOrderService.getMachineOrderByNameplate(machine1.getNameplate());
            List<Task> taskList = taskService.getTaskByNameplate(machine1.getNameplate());
            if (taskList != null) {
                logger.info("该机器包含的工序数:" + taskList.size());
                for (int i = 0; i < taskList.size(); i++) {
                    // 找到该工序名下的质检项
                    List<QualityInspect> qualityInspectListlist = qualityInspectService.getQualityInspectByTaskName(taskList.get(i).getTaskName());
                    if (qualityInspectListlist != null) {
                        logger.info(taskList.get(i).getTaskName() + " 工序包含的质检项有:" + qualityInspectListlist.size());
                        for (int q = 0; q < qualityInspectListlist.size(); q++) {
                            QualityInspectRecord qualityInspectRecord = new QualityInspectRecord();
                            qualityInspectRecord.setCreateTime(new Date());
                            qualityInspectRecord.setTaskName(taskList.get(i).getTaskName());
                            qualityInspectRecord.setInspectName(qualityInspectListlist.get(q).getInspectName());
                            qualityInspectRecord.setMachineNameplate(machine1.getNameplate());
                            if (machineOrder != null) {
                                qualityInspectRecord.setOrderNumber(machineOrder.getOrderNum());
                            } else {
                                logger.warn("根据" + machine1.getNameplate() + " 找不到订单号");
                            }
                            /**
                             * 因为要和APP其他状态共用一些代码,所以这里不要用字符串,用数字
                             */
                            // qualityInspectRecord.setRecordStatus(Constant.STR_QUALITY_INSPECT_NOT_START);
                            qualityInspectRecord.setRecordStatus(Constant.TASK_QUALITY_INSPECT_NOT_STARTED.toString());
                            qualityInspectRecordService.save(qualityInspectRecord);
                            logger.info("生成qualityInspectRecord成功, 铭牌号:" + qualityInspectRecord.getMachineNameplate() + ",inspectName:" + qualityInspectRecord.getInspectName() + ",taskName:" + qualityInspectRecord.getTaskName() + ",状态:" + qualityInspectRecord.getRecordStatus());
                        }
                    }
                }
            }
            /**
             * 发MQTT消息给质检 (一个机器发一次,发给所有质检员/质检组长 谁订阅谁收到)
             */
            ServerToClientMsg msg = new ServerToClientMsg();
            msg.setOrderNum(machineOrder.getOrderNum());
            msg.setNameplate(machine1.getNameplate());
            msg.setType(ServerToClientMsg.MsgType.QUALITY_INSPECT);
            mqttMessageHelper.sendToClient(Constant.S2C_MACHINE_QUALITY_INSPECT, JSON.toJSONString(msg));
            logger.info("MQTT " + Constant.S2C_MACHINE_QUALITY_INSPECT + ", 铭牌号:" + msg.getNameplate() + "设置了区域位置");
        }
    }
    machineService.update(machine1);
    return ResultGenerator.genSuccessResult();
}
Also used : Task(com.eservice.api.model.task.Task) TaskRecordDetail(com.eservice.api.model.task_record.TaskRecordDetail) QualityInspect(com.eservice.api.model.quality_inspect.QualityInspect) ServerToClientMsg(com.eservice.api.service.mqtt.ServerToClientMsg) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) QualityInspectRecord(com.eservice.api.model.quality_inspect_record.QualityInspectRecord) Machine(com.eservice.api.model.machine.Machine) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

QualityInspectRecord (com.eservice.api.model.quality_inspect_record.QualityInspectRecord)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 JSONArray (com.alibaba.fastjson.JSONArray)1 Machine (com.eservice.api.model.machine.Machine)1 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)1 QualityInspect (com.eservice.api.model.quality_inspect.QualityInspect)1 Task (com.eservice.api.model.task.Task)1 TaskRecordDetail (com.eservice.api.model.task_record.TaskRecordDetail)1 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)1 PageInfo (com.github.pagehelper.PageInfo)1 Date (java.util.Date)1