Search in sources :

Example 1 with TaskRecord

use of com.eservice.api.model.task_record.TaskRecord in project sinsim by WilsonHu.

the class TaskQualityRecordController method updateTaskQualityRecordDetail.

/**
 * 根据传入的strTaskQualityRecordDetail,更新对应多表:
 *     "machine_id":"",  --> machine.machine_id
 *     "检验是否合格":"", --> task_quality_record.status 质检结果: "1"==>通过; “0”==>不通过
 *     "不合格原因":"",	--> task_quality_record.comment
 *     "不合格照片":"",	--> quality_record_image.image
 *     "检验完成":"",		--> task_record.status  task状态,“1”==>未开始, “2”==>进行中,“3”==>安装完成, “4”==>质检完成,“5“===>异常
 * @param strTaskQualityRecordDetail
 * @return
 */
@PostMapping("updateTaskQualityRecordDetail")
public Result updateTaskQualityRecordDetail(@RequestParam String strTaskQualityRecordDetail) {
    TaskQualityRecordDetail taskQualityRecordDetail = JSON.parseObject(strTaskQualityRecordDetail, TaskQualityRecordDetail.class);
    Integer taskQualityRecordDetail_ID = taskQualityRecordDetail.getId();
    TaskQualityRecord taskQualityRecord = taskQualityRecordService.findById(taskQualityRecordDetail_ID);
    taskQualityRecord.setTaskRecordId(taskQualityRecordDetail.getTaskRecordId());
    taskQualityRecord.setName(taskQualityRecordDetail.getName());
    taskQualityRecord.setStatus(taskQualityRecordDetail.getStatus());
    taskQualityRecord.setCreateTime(taskQualityRecordDetail.getCreateTime());
    taskQualityRecord.setComment(taskQualityRecordDetail.getComment());
    QualityRecordImage qualityRecordImage = taskQualityRecordDetail.getQualityRecordImage();
    TaskRecord taskRecord = taskQualityRecordDetail.getTaskRecord();
    taskQualityRecordService.update(taskQualityRecord);
    qualityRecordImageService.update(qualityRecordImage);
    taskRecordService.update(taskRecord);
    return ResultGenerator.genSuccessResult();
}
Also used : TaskQualityRecordDetail(com.eservice.api.model.task_quality_record.TaskQualityRecordDetail) TaskRecord(com.eservice.api.model.task_record.TaskRecord) TaskQualityRecord(com.eservice.api.model.task_quality_record.TaskQualityRecord) QualityRecordImage(com.eservice.api.model.quality_record_image.QualityRecordImage) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with TaskRecord

use of com.eservice.api.model.task_record.TaskRecord in project sinsim by WilsonHu.

the class AbnormalRecordController method update.

@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(String abnormalRecord) {
    AbnormalRecord abnormalRecord1 = JSON.parseObject(abnormalRecord, AbnormalRecord.class);
    abnormalRecord1.setSolveTime(new Date());
    if (abnormalRecord1.getSolution() == null || abnormalRecord1.getSolution().isEmpty()) {
        // abnormalRecord1.setSolution("空");
        return ResultGenerator.genFailResult("请填写解决内容");
    }
    // 修改对应工序的状态为"安装中"或者“质检中”,需要检查安装开始时间和质检开始时间,质检已开始则状态为质检中
    AbnormalRecord completeInfo = abnormalRecordService.findById(abnormalRecord1.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_INSTALLING);
        taskRecordService.update(tr);
        // 更新task record状态时候,必须去更新process record中对应task的状态
        commonService.updateTaskRecordRelatedStatus(tr);
        ProcessRecord pr = processRecordService.findById(tr.getProcessRecordId());
        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_INSTALL_ABNORMAL_RESOLVE + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
    } else {
        throw new RuntimeException();
    }
    abnormalRecordService.update(abnormalRecord1);
    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) AbnormalRecord(com.eservice.api.model.abnormal_record.AbnormalRecord) 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 3 with TaskRecord

use of com.eservice.api.model.task_record.TaskRecord in project sinsim by WilsonHu.

the class TaskPlanServiceImpl method addTaskPlans.

// 每新增1个工序,调用一次。
@Transactional(rollbackFor = Exception.class)
public boolean addTaskPlans(@RequestParam List<Integer> taskRecordIds, Integer planType, String machineStrId, Date planDate, Integer userId) {
    for (int i = 0; i < taskRecordIds.size(); i++) {
        Condition tempCondition = new Condition(TaskPlan.class);
        Integer id = taskRecordIds.get(i);
        tempCondition.createCriteria().andCondition("task_record_id = ", id);
        List<TaskPlan> existPlans = findByCondition(tempCondition);
        if (existPlans.size() > 0) {
            return false;
        }
        TaskPlan plan = new TaskPlan();
        plan.setCreateTime(new Date());
        plan.setUserId(userId);
        plan.setTaskRecordId(id);
        plan.setPlanType(Constant.DAILY_PLAN);
        if (planType.intValue() == Constant.DAILY_PLAN.intValue()) {
            plan.setPlanTime(planDate);
        } else if (planType.intValue() == Constant.FLEX_PLAN.intValue()) {
            plan.setDeadline(planDate);
        }
        save(plan);
        // 更改task record状态为已计划
        TaskRecord taskRecord = taskRecordService.findById(id);
        if (taskRecord != null) {
            // 检查是否为第一个计划项,如果是,需要设置为待安装状态
            Integer processRecordId = taskRecord.getProcessRecordId();
            ProcessRecord processRecord = processRecordService.findById(processRecordId);
            List<LinkDataModel> linkDataList = JSON.parseArray(processRecord.getLinkData(), LinkDataModel.class);
            for (LinkDataModel item : linkDataList) {
                if (item.getTo().equals(taskRecord.getNodeKey().intValue())) {
                    if (item.getFrom() == null || item.getFrom() == -1) {
                        taskRecord.setUpdateTime(new Date());
                        taskRecord.setStatus(Constant.TASK_INSTALL_WAITING);
                        break;
                    } else {
                        // TODO:如果是重新配置流程项,比如:改单、拆单以后再最后增加了安装项,则需要设置成待安装状态
                        List<Integer> parentNodeList = new ArrayList<>();
                        String nodeData = processRecord.getNodeData();
                        List<NodeDataModel> ndList = JSON.parseArray(nodeData, NodeDataModel.class);
                        for (LinkDataModel tmp : linkDataList) {
                            if (tmp.getTo() == taskRecord.getNodeKey().intValue()) {
                                parentNodeList.add(tmp.getFrom());
                            }
                        }
                        boolean allParentFinished = true;
                        for (Integer parentNodeKey : parentNodeList) {
                            for (NodeDataModel nodeDataModel : ndList) {
                                if (parentNodeKey.intValue() == Integer.valueOf(nodeDataModel.getKey())) {
                                    if (Integer.valueOf(nodeDataModel.getTaskStatus()) != Constant.TASK_QUALITY_DONE.intValue()) {
                                        allParentFinished = false;
                                        break;
                                    }
                                }
                            }
                            if (!allParentFinished) {
                                break;
                            }
                        }
                        if (allParentFinished) {
                            taskRecord.setUpdateTime(new Date());
                            taskRecord.setStatus(Constant.TASK_INSTALL_WAITING);
                        }
                    }
                }
            }
            if (taskRecord.getStatus().equals(Constant.TASK_INITIAL)) {
                taskRecord.setStatus(Constant.TASK_PLANED);
            }
            taskRecordService.update(taskRecord);
            // 更新task_record以外,但是跟task record相关的状态,机器状态,process_record中的task_status
            commonService.updateTaskRecordRelatedStatus(taskRecord);
            if (taskRecord.getStatus().equals(Constant.TASK_INSTALL_WAITING)) {
                // MQTT 计划后,通知安装组长,可以进行安装
                String taskName = taskRecord.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(taskRecord.getProcessRecordId());
                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_INSTALL + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
            }
            // /在”计划管理“中 添加计划安排时,自动添加了 总装排产 InstallPlan。 (InstallPlanActual则在app扫码完成工序时添加)
            // 因为把总装排产,合并到“计划管理”,所以需要在安排计划时 自动生成总装排产(这样在app上扫码完成时,才能有总装完成自动填充完成头数)
            InstallPlan installPlan1 = new InstallPlan();
            installPlan1.setType(Constant.STR_INSTALL_TYPE_WHOLE);
            InstallGroup installGroup = installGroupService.getInstallGroupByTaskName(taskRecord.getTaskName());
            installPlan1.setInstallGroupId(installGroup.getId());
            installPlan1.setInstallDatePlan(plan.getPlanTime());
            ProcessRecord pr = processRecordService.findById(taskRecord.getProcessRecordId());
            Machine machine = machineService.findById(pr.getMachineId());
            MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
            installPlan1.setOrderId(machineOrder.getId());
            installPlan1.setMachineId(machine.getId());
            installPlan1.setValid(Byte.valueOf("1"));
            installPlan1.setCreateDate(new Date());
            installPlanService.save(installPlan1);
            logger.info("自动添加了 总装排产 for 铭牌号: " + machine.getNameplate() + ", 工序: " + taskRecord.getTaskName());
        } else {
            // 进行事务操作
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            throw new RuntimeException();
        }
    }
    if (taskRecordIds.size() > 0 && machineStrId != null) {
        List<Machine> machineList = machineService.selectMachines(null, null, null, machineStrId, null, null, null, null, null, null, false);
        if (machineList.size() == 1) {
            // 如果机器状态小于计划中,则更新为计划中
            Machine machine = machineList.get(0);
            if (machine.getStatus() < Constant.MACHINE_PLANING) {
                machine.setStatus(Constant.MACHINE_PLANING);
                machineService.update(machine);
            }
        } else {
            // 进行事务rollback操作
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            throw new RuntimeException();
        }
    }
    return true;
}
Also used : TaskRecord(com.eservice.api.model.task_record.TaskRecord) Task(com.eservice.api.model.task.Task) TaskPlan(com.eservice.api.model.task_plan.TaskPlan) ArrayList(java.util.ArrayList) InstallGroup(com.eservice.api.model.install_group.InstallGroup) Machine(com.eservice.api.model.machine.Machine) NodeDataModel(com.eservice.api.service.common.NodeDataModel) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) Condition(tk.mybatis.mapper.entity.Condition) LinkDataModel(com.eservice.api.service.common.LinkDataModel) ServerToClientMsg(com.eservice.api.service.mqtt.ServerToClientMsg) Date(java.util.Date) InstallPlan(com.eservice.api.model.install_plan.InstallPlan) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with TaskRecord

use of com.eservice.api.model.task_record.TaskRecord in project sinsim by WilsonHu.

the class MachineServiceImpl method selectPlanningMachines.

public List<MachinePlan> selectPlanningMachines(String orderNum, String machine_strid, String nameplate, String location, Byte status, Integer machineType, Integer dateType, String query_start_time, String query_finish_time, Boolean is_fuzzy) {
    List<MachinePlan> machinePlanList = new ArrayList<>();
    if (is_fuzzy) {
        machinePlanList = machineMapper.selectPlanningMachinesFuzzy(orderNum, machine_strid, nameplate, location, status, machineType, dateType, query_start_time, query_finish_time);
    } else {
        machinePlanList = machineMapper.selectPlanningMachines(orderNum, machine_strid, nameplate, location, status, machineType, dateType, query_start_time, query_finish_time);
    }
    for (MachinePlan itemPlan : machinePlanList) {
        // 获取机器对应task record,
        Condition tempCondition = new Condition(TaskRecord.class);
        tempCondition.createCriteria().andCondition("process_record_id = ", itemPlan.getProcessRecordID());
        tempCondition.createCriteria().andGreaterThanOrEqualTo("status", Constant.TASK_INITIAL);
        List<TaskRecord> taskRecordList = taskRecordService.findByCondition(tempCondition);
        HashMap<Byte, Integer> taskStatusMap = new HashMap<>();
        for (TaskRecord record : taskRecordList) {
            if (record.getStatus().equals(Constant.TASK_INSTALL_WAITING)) {
                if (taskStatusMap.get(Constant.TASK_INSTALL_WAITING) != null) {
                    taskStatusMap.put(Constant.TASK_INSTALL_WAITING, taskStatusMap.get(Constant.TASK_INSTALL_WAITING) + 1);
                } else {
                    taskStatusMap.put(Constant.TASK_INSTALL_WAITING, 1);
                }
            } else if (record.getStatus().equals(Constant.TASK_INSTALLING)) {
                if (taskStatusMap.get(Constant.TASK_INSTALLING) != null) {
                    taskStatusMap.put(Constant.TASK_INSTALLING, taskStatusMap.get(Constant.TASK_INSTALLING) + 1);
                } else {
                    taskStatusMap.put(Constant.TASK_INSTALLING, 1);
                }
            } else if (record.getStatus().equals(Constant.TASK_INSTALLED)) {
                if (taskStatusMap.get(Constant.TASK_INSTALLED) != null) {
                    taskStatusMap.put(Constant.TASK_INSTALLED, taskStatusMap.get(Constant.TASK_INSTALLED) + 1);
                } else {
                    taskStatusMap.put(Constant.TASK_INSTALLED, 1);
                }
            } else if (record.getStatus().equals(Constant.TASK_QUALITY_DOING)) {
                if (taskStatusMap.get(Constant.TASK_QUALITY_DOING) != null) {
                    taskStatusMap.put(Constant.TASK_QUALITY_DOING, taskStatusMap.get(Constant.TASK_QUALITY_DOING) + 1);
                } else {
                    taskStatusMap.put(Constant.TASK_QUALITY_DOING, 1);
                }
            } else if (record.getStatus().equals(Constant.TASK_QUALITY_DONE)) {
                if (taskStatusMap.get(Constant.TASK_QUALITY_DONE) != null) {
                    taskStatusMap.put(Constant.TASK_QUALITY_DONE, taskStatusMap.get(Constant.TASK_QUALITY_DONE) + 1);
                } else {
                    taskStatusMap.put(Constant.TASK_QUALITY_DONE, 1);
                }
            } else if (record.getStatus().equals(Constant.TASK_INSTALL_ABNORMAL)) {
                if (taskStatusMap.get(Constant.TASK_INSTALL_ABNORMAL) != null) {
                    taskStatusMap.put(Constant.TASK_INSTALL_ABNORMAL, taskStatusMap.get(Constant.TASK_INSTALL_ABNORMAL) + 1);
                } else {
                    taskStatusMap.put(Constant.TASK_INSTALL_ABNORMAL, 1);
                }
            } else if (record.getStatus().equals(Constant.TASK_QUALITY_ABNORMAL)) {
                if (taskStatusMap.get(Constant.TASK_QUALITY_ABNORMAL) != null) {
                    taskStatusMap.put(Constant.TASK_QUALITY_ABNORMAL, taskStatusMap.get(Constant.TASK_QUALITY_ABNORMAL) + 1);
                } else {
                    taskStatusMap.put(Constant.TASK_QUALITY_ABNORMAL, 1);
                }
            }
        }
        itemPlan.setInstallWaitingTaskNum(taskStatusMap.get(Constant.TASK_INSTALL_WAITING));
        itemPlan.setInstalledTaskNum(taskStatusMap.get(Constant.TASK_INSTALLED));
        itemPlan.setInstallingTaskNum(taskStatusMap.get(Constant.TASK_INSTALLING));
        itemPlan.setInstallAbnormalTaskNum(taskStatusMap.get(Constant.TASK_INSTALL_ABNORMAL));
        itemPlan.setQualityDoingTaskNum(taskStatusMap.get(Constant.TASK_QUALITY_DOING));
        itemPlan.setQualityDoneTaskNum(taskStatusMap.get(Constant.TASK_QUALITY_DONE));
        itemPlan.setQualityAbnormalTaskNum(taskStatusMap.get(Constant.TASK_QUALITY_ABNORMAL));
    }
    return machinePlanList;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) TaskRecord(com.eservice.api.model.task_record.TaskRecord) HashMap(java.util.HashMap) MachinePlan(com.eservice.api.model.machine.MachinePlan) ArrayList(java.util.ArrayList)

Example 5 with TaskRecord

use of com.eservice.api.model.task_record.TaskRecord in project sinsim by WilsonHu.

the class TaskPlanController method deletePlan.

@PostMapping("/deletePlan")
@Transactional(rollbackFor = Exception.class)
public Result deletePlan(@RequestParam Integer id, @RequestParam Integer taskRecordId) {
    taskPlanService.deleteById(id);
    TaskRecord record = new TaskRecord();
    record.setId(taskRecordId);
    record.setStatus(Constant.TASK_INITIAL);
    taskRecordService.update(record);
    return ResultGenerator.genSuccessResult();
}
Also used : TaskRecord(com.eservice.api.model.task_record.TaskRecord) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TaskRecord (com.eservice.api.model.task_record.TaskRecord)20 PostMapping (org.springframework.web.bind.annotation.PostMapping)17 Machine (com.eservice.api.model.machine.Machine)10 Condition (tk.mybatis.mapper.entity.Condition)10 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)9 Transactional (org.springframework.transaction.annotation.Transactional)9 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)7 Task (com.eservice.api.model.task.Task)7 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)5 PageInfo (com.github.pagehelper.PageInfo)4 AbnormalRecord (com.eservice.api.model.abnormal_record.AbnormalRecord)3 TaskQualityRecord (com.eservice.api.model.task_quality_record.TaskQualityRecord)3 NodeDataModel (com.eservice.api.service.common.NodeDataModel)3 AbnormalImage (com.eservice.api.model.abnormal_image.AbnormalImage)2 QualityRecordImage (com.eservice.api.model.quality_record_image.QualityRecordImage)2 TaskPlan (com.eservice.api.model.task_plan.TaskPlan)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 Abnormal (com.eservice.api.model.abnormal.Abnormal)1