Search in sources :

Example 1 with UserDetail

use of com.eservice.api.model.user.UserDetail 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)

Example 2 with UserDetail

use of com.eservice.api.model.user.UserDetail in project sinsim by WilsonHu.

the class CommonService method pushLxdMsgToAftersale.

/**
 * 推送公众号消息给轮到联系单签核的人(通过售后系统)
 * @param cs
 * @param cf
 * @param haveReject 是否驳回 ( 虽然这个信息可以从cs中提取,但是调用该函数的地方前面已经提前过了,方便用)
 */
public void pushLxdMsgToAftersale(ContactSign cs, ContactForm cf, boolean haveReject, String msgInfo) {
    // 指定格式,因为售后解析要用到
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    // 指定北京时间
    formatter.setTimeZone(TimeZone.getTimeZone("GMT+8"));
    String createDateStr = formatter.format(cf.getCreateDate());
    if (cs.getCurrentStep().equals(Constant.SIGN_FINISHED)) {
        // 审核完成时,通知发起人
        logger.info(cf.getContactTitle() + ", 审核完成时,通知发起人");
        List<UserDetail> userList = userService.selectUsers(cf.getApplicantPerson(), null, null, null, null, 1);
        if (userList.isEmpty() || userList == null) {
            logger.error("根据 " + cf.getApplicantPerson() + "找不到User");
        } else {
            // 找到发起人
            UserDetail toUser = userList.get(0);
            commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
        }
    } else {
        /**
         * 审核没有结束,
         *      驳回  :推送给参与签核的人,以及发起人
         *      无驳回:推送给下一个轮到签核的角色
         */
        Role role = roleService.findBy("roleName", cs.getCurrentStep());
        if (role == null) {
            logger.error("根据该 role_name " + cs.getCurrentStep() + "找不到Role");
            return;
        }
        List<UserDetail> userList = userService.selectUsers(null, null, role.getId(), null, null, 1);
        if (haveReject) {
            List<User> userNameList = commonService.getUsersInLxdSign(cs);
            for (User toUser : userNameList) {
                logger.info("联系单被拒绝,发给参与签核的人 " + toUser.getAccount());
                commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
            }
            logger.info("联系单被拒绝,发给发起签核的人 " + cf.getApplicantPerson());
            commonService.sendSignInfoViWxMsg(cf.getApplicantPerson(), "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
        } else {
            // 如果是销售部经理还要细分发给哪个经理,
            if (role.getRoleName().equals(Constant.SING_STEP_SALES_MANAGER)) {
                String userSalesManagerAccount = cf.getDesignatedSaleManager();
                logger.info(" 发给被指定的销售部经理 " + userSalesManagerAccount);
                commonService.sendSignInfoViWxMsg(userSalesManagerAccount, "", cf.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
            } else {
                if (userList.isEmpty() || userList == null) {
                    logger.error("根据该roleId " + role.getId() + "找不到User");
                } else {
                    // 可能有多个负责人,比如研发部现在就两个经理,都通知。
                    for (UserDetail toUser : userList) {
                        ContactForm contactForm = contactFormService.findById(cs.getContactFormId());
                        logger.info(" 发给参与签核的角色(可能多个) " + toUser.getAccount());
                        commonService.sendSignInfoViWxMsg(toUser.getAccount(), "", contactForm.getNum(), createDateStr, cf.getApplicantDepartment(), cf.getApplicantPerson(), msgInfo);
                    }
                }
            }
        }
    }
}
Also used : UserDetail(com.eservice.api.model.user.UserDetail) Role(com.eservice.api.model.role.Role) User(com.eservice.api.model.user.User) ContactForm(com.eservice.api.model.contact_form.ContactForm) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with UserDetail

use of com.eservice.api.model.user.UserDetail in project sinsim by WilsonHu.

the class UserController method selectUsers.

@PostMapping("/selectUsers")
public Result selectUsers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, String account, String name, Integer roleId, Integer groupId, String marketGroupName, Integer valid) {
    PageHelper.startPage(page, size);
    List<UserDetail> list = userService.selectUsers(account, name, roleId, groupId, marketGroupName, valid);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : UserDetail(com.eservice.api.model.user.UserDetail) PageInfo(com.github.pagehelper.PageInfo) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with UserDetail

use of com.eservice.api.model.user.UserDetail in project sinsim by WilsonHu.

the class UserController method requestLogin.

/**
 * @param account
 * @param password
 * @param meid
 * @param isExtranet 如果是外网,则该参数有值true, 没有该参数,则是内网。 其他原有接口不影响
 * @return
 */
@PostMapping("/requestLogin")
public Result requestLogin(@RequestParam String account, @RequestParam String password, @RequestParam(defaultValue = "0") String meid, @RequestParam(defaultValue = "false") Boolean isExtranet) {
    User user = userService.selectByAccount(account);
    if (user == null) {
        return ResultGenerator.genFailResult(account + " 不存在该账号!");
    } else if (user.getValid() == Constant.INVALID) {
        return ResultGenerator.genFailResult("禁止登录," + account + " 已设为离职");
    }
    boolean isPermitted = false;
    if (isExtranet) {
        logger.info(account + " 外网登录");
        Condition condition = new Condition(User.class);
        condition.createCriteria().andEqualTo("extranetPermit", 1);
        List<User> userAllowExtranetList = userService.findByCondition(condition);
        for (int i = 0; i < userAllowExtranetList.size(); i++) {
            if (userAllowExtranetList.get(i).getAccount().equals(account)) {
                isPermitted = true;
                break;
            }
        }
        if (!isPermitted) {
            return ResultGenerator.genFailResult(account + " 用户没有外网登入权限!");
        }
    } else {
        logger.info(account + " 内网登录");
    }
    if (account == null || "".equals(account)) {
        return ResultGenerator.genFailResult("账号不能为空!");
    } else if (password == null || "".equals(password)) {
        return ResultGenerator.genFailResult("密码不能为空!");
    } else {
        // 移动端MEID值需要传入,且不为“0”
        if (!ZERO_STRING.equals(meid)) {
            if (deviceService.findDeviceByMEID(meid) == null) {
                return ResultGenerator.genFailResult("设备没有登陆权限!");
            }
        }
        UserDetail userDetail = userService.requestLogin(account, password);
        if (userDetail == null) {
            logger.info(account + "login 账号或密码不正确");
            return ResultGenerator.genFailResult("账号或密码不正确!");
        } else {
            logger.info(account + "login success");
            // /mqttMessageHelper.sendToClient("topic/client/2", JSON.toJSONString(userDetail));
            return ResultGenerator.genSuccessResult(userDetail);
        }
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) UserDetail(com.eservice.api.model.user.UserDetail) User(com.eservice.api.model.user.User) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with UserDetail

use of com.eservice.api.model.user.UserDetail in project sinsim by WilsonHu.

the class UserController method selectAllInstallGroupByUserId.

/**
 * 根据user的id号,获得该用户所在的install_group的所有在职安装工.
 * @param id
 * @return
 */
@PostMapping("/selectAllInstallGroupByUserId")
public Result selectAllInstallGroupByUserId(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, @RequestParam Integer id) {
    PageHelper.startPage(page, size);
    List<UserDetail> list = userService.selectAllInstallGroupByUserId(id);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : UserDetail(com.eservice.api.model.user.UserDetail) PageInfo(com.github.pagehelper.PageInfo) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

UserDetail (com.eservice.api.model.user.UserDetail)6 User (com.eservice.api.model.user.User)4 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 Role (com.eservice.api.model.role.Role)2 PageInfo (com.github.pagehelper.PageInfo)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Condition (tk.mybatis.mapper.entity.Condition)2 ContactForm (com.eservice.api.model.contact_form.ContactForm)1 IotMachine (com.eservice.api.model.iot_machine.IotMachine)1 Date (java.util.Date)1