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();
}
}
}
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();
}
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("质检员角色没有设置!");
}
}
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);
}
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();
}
Aggregations