Search in sources :

Example 1 with IotMachine

use of com.eservice.api.model.iot_machine.IotMachine in project sinsim by WilsonHu.

the class IotMachineController method list.

@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
    PageHelper.startPage(page, size);
    List<IotMachine> list = iotMachineService.findAll();
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) IotMachine(com.eservice.api.model.iot_machine.IotMachine)

Example 2 with IotMachine

use of com.eservice.api.model.iot_machine.IotMachine in project sinsim by WilsonHu.

the class IotMachineController method selectIotMachine.

/**
 * 根据账户、铭牌号 获取该账户名下对应的机器IOT信息
 * 比如用户可以以此查看自己的机器
 */
@PostMapping("/selectIotMachine")
public Result selectIotMachine(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, String account, String nameplate) {
    PageHelper.startPage(page, size);
    List<IotMachine> list = iotMachineService.selectIotMachine(account, nameplate);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) IotMachine(com.eservice.api.model.iot_machine.IotMachine)

Example 3 with IotMachine

use of com.eservice.api.model.iot_machine.IotMachine in project sinsim by WilsonHu.

the class IotMachineController method updateInfo.

/**
 * 接收绣花机传来的信息
 * 如果该绣花机已经存在,则更新该机器信息
 * 如果该绣花机不存在,则新增该绣花机
 *
 * account/password
 */
@PostMapping("/updateInfo")
public // public Result updateInfo(@RequestParam  String iotMachine) {
Result updateInfo(@RequestBody String iotMachine, @RequestParam String account, @RequestParam String password) {
    User user = userService.selectByAccount(account);
    if (user == null) {
        return ResultGenerator.genFailResult(account + " 不存在该账号!");
    } else if (user.getValid() == Constant.INVALID) {
        return ResultGenerator.genFailResult("禁止登录," + account + " 已设为离职");
    }
    UserDetail userDetail = userService.requestLogin(account, password);
    if (userDetail == null) {
        logger.info(account + "login 账号或密码不正确");
        return ResultGenerator.genFailResult("账号或密码不正确!");
    } else {
        logger.info(account + "login success");
    }
    IotMachine iotMachine1 = JSON.parseObject(iotMachine, IotMachine.class);
    String msg = null;
    if (iotMachine1 == null) {
        msg = "iotMachine1对象JSON解析失败!";
        logger.warn(msg);
        return ResultGenerator.genFailResult(msg);
    }
    // 暂定 机器铭牌号是唯一的,后续可以考虑 同个品牌下的铭牌号是唯一
    Condition tempCondition = new Condition(IotMachine.class);
    tempCondition.createCriteria().andCondition("nameplate = ", iotMachine1.getNameplate());
    // List<IotMachine> existIotMachines = iotMachineService.findByCondition(tempCondition);
    /**
     * 改为要记录历史记录之后,要记录创建时间,更新时间就没用了
     */
    iotMachine1.setCreateTime(new Date());
    iotMachine1.setUser(account);
    iotMachineService.save(iotMachine1);
    msg = iotMachine1.getNameplate() + iotMachine1.getCreateTime() + ",已记录该机器的信息";
    logger.info(msg);
    return ResultGenerator.genSuccessResult(msg);
}
Also used : UserDetail(com.eservice.api.model.user.UserDetail) Condition(tk.mybatis.mapper.entity.Condition) User(com.eservice.api.model.user.User) IotMachine(com.eservice.api.model.iot_machine.IotMachine) Date(java.util.Date)

Aggregations

IotMachine (com.eservice.api.model.iot_machine.IotMachine)3 PageInfo (com.github.pagehelper.PageInfo)2 User (com.eservice.api.model.user.User)1 UserDetail (com.eservice.api.model.user.UserDetail)1 Date (java.util.Date)1 Condition (tk.mybatis.mapper.entity.Condition)1