Search in sources :

Example 6 with AbnormalRecord

use of com.eservice.api.model.abnormal_record.AbnormalRecord in project sinsim by WilsonHu.

the class AbnormalController method delete.

@PostMapping("/delete")
public Result delete(@RequestParam Integer id) {
    if (id == null || id <= 0) {
        return ResultGenerator.genFailResult("异常ID有误!");
    } else {
        // 检查异常记录中是否使用了该异常,如果已经使用,不能删除
        Condition condition = new Condition(AbnormalRecord.class);
        condition.createCriteria().andCondition("abnormal_type = ", id);
        List<AbnormalRecord> list = abnormalRecordService.findByCondition(condition);
        if (list == null || list.size() > 0) {
            return ResultGenerator.genFailResult("该异常已经被使用,删除会导致之前的y异常记录有误;如不想使用,可把该项设置为无效!");
        }
    }
    abnormalService.deleteById(id);
    return ResultGenerator.genSuccessResult();
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) AbnormalRecord(com.eservice.api.model.abnormal_record.AbnormalRecord) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

AbnormalRecord (com.eservice.api.model.abnormal_record.AbnormalRecord)6 PostMapping (org.springframework.web.bind.annotation.PostMapping)6 Machine (com.eservice.api.model.machine.Machine)3 TaskRecord (com.eservice.api.model.task_record.TaskRecord)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Condition (tk.mybatis.mapper.entity.Condition)3 AbnormalImage (com.eservice.api.model.abnormal_image.AbnormalImage)2 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)2 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)2 Task (com.eservice.api.model.task.Task)2 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)2 Abnormal (com.eservice.api.model.abnormal.Abnormal)1 AbnormalRecordDetail (com.eservice.api.model.abnormal_record.AbnormalRecordDetail)1 PageInfo (com.github.pagehelper.PageInfo)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1