Search in sources :

Example 31 with Condition

use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.

the class MachineController method update.

@PostMapping("/update")
public Result update(String machine) {
    Machine machine1 = JSON.parseObject(machine, Machine.class);
    if (machine1.getNameplate() == null || machine1.getNameplate() == "") {
        return ResultGenerator.genFailResult("机器编号不能为空!");
    } else {
        // 检查机器编号是否存在,存在则返回错误
        Condition condition = new Condition(Machine.class);
        condition.createCriteria().andCondition("nameplate = ", machine1.getNameplate());
        List<Machine> list = machineService.findByCondition(condition);
        if (list.size() >= 1) {
            return ResultGenerator.genFailResult("机器编号已存在!");
        } else {
            machineService.update(machine1);
            return ResultGenerator.genSuccessResult();
        }
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 32 with Condition

use of tk.mybatis.mapper.entity.Condition 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 33 with Condition

use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.

the class UserController method selectAllQuality.

@PostMapping("/selectAllQuality")
public Result selectAllQuality(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
    PageHelper.startPage(page, size);
    Condition tempCondition = new Condition(Role.class);
    tempCondition.createCriteria().andCondition("role_name = ", "质检员");
    List<Role> roleList = roleService.findByCondition(tempCondition);
    // 这里正常情况下,list中有且仅有一个
    if (roleList != null && roleList.size() > 0) {
        Condition userCondition = new Condition(User.class);
        userCondition.createCriteria().andCondition("role_id = ", roleList.get(0).getId());
        List<User> userList = userService.findByCondition(userCondition);
        PageInfo pageInfo = new PageInfo(userList);
        return ResultGenerator.genSuccessResult(pageInfo);
    } else {
        return ResultGenerator.genFailResult("质检员角色没有设置!");
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) Role(com.eservice.api.model.role.Role) PageInfo(com.github.pagehelper.PageInfo) User(com.eservice.api.model.user.User) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 34 with Condition

use of tk.mybatis.mapper.entity.Condition 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 35 with Condition

use of tk.mybatis.mapper.entity.Condition 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

Condition (tk.mybatis.mapper.entity.Condition)59 Criteria (tk.mybatis.mapper.entity.Example.Criteria)25 Transactional (org.springframework.transaction.annotation.Transactional)17 PostMapping (org.springframework.web.bind.annotation.PostMapping)13 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)10 Machine (com.eservice.api.model.machine.Machine)8 PageInfo (com.github.pagehelper.PageInfo)8 TaskRecord (com.eservice.api.model.task_record.TaskRecord)6 PanoramicRealTimeConsumptionGather (com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather)6 Date (java.util.Date)6 Contract (com.eservice.api.model.contract.Contract)5 ContractSign (com.eservice.api.model.contract_sign.ContractSign)5 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)5 User (com.cas.sim.tis.entity.User)4 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)4 Task (com.eservice.api.model.task.Task)4 OrderSign (com.eservice.api.model.order_sign.OrderSign)3 Library (com.cas.sim.tis.entity.Library)2 Resource (com.cas.sim.tis.entity.Resource)2 ResourceMapper (com.cas.sim.tis.mapper.ResourceMapper)2