|
|
|
@ -297,50 +297,46 @@ public class DeviceController {
|
|
|
|
|
return JSONUtil.toJsonStr(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//手机号登录
|
|
|
|
|
@PostMapping("/customerLogin")
|
|
|
|
|
@ApiOperation("投递员手机号登录")
|
|
|
|
|
public CommonResult<LoginRespVO> customerLogin(@RequestBody LoginReqVO loginReqVO) {
|
|
|
|
|
CommonResult<LoginRespVO> result = new CommonResult<>();
|
|
|
|
|
Client client = clientService.getLastestClientByPhone(loginReqVO.getPhone());
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new BizIllegalException("登录失败:您还未注册,请先扫码注册!");
|
|
|
|
|
}
|
|
|
|
|
@PostMapping("/login")
|
|
|
|
|
@ApiOperation("清运员手机号登录")
|
|
|
|
|
public CommonResult<String> login(@RequestBody LoginReqVO loginReqVO) {
|
|
|
|
|
RecycleDevice device = deviceService.getByDeviceCode(loginReqVO.getDeviceCode());
|
|
|
|
|
if (device == null) {
|
|
|
|
|
throw new BizIllegalException("登录失败:未查询到对应设备信息!");
|
|
|
|
|
}
|
|
|
|
|
UserDTO userDTO = commonService.loginDeviceByClient(client);
|
|
|
|
|
Recycler recycler = recyclerService.getRecyclerByPhoneNumber(loginReqVO.getPhone());
|
|
|
|
|
CommandVO command = new CommandVO();
|
|
|
|
|
command.setDeviceCode(loginReqVO.getDeviceCode());
|
|
|
|
|
command.setCmd(CMDEnum.login);
|
|
|
|
|
command.setOptTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
command.setRemark("登录成功");
|
|
|
|
|
if (null != recycler) {
|
|
|
|
|
RecycleStaffDevice staffDevice = staffDeviceService.getByDeviceCode(loginReqVO.getDeviceCode(), loginReqVO.getPhone());
|
|
|
|
|
if (null == staffDevice) {
|
|
|
|
|
throw new BizIllegalException("登录失败:你不是当前设备的管理人员!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//如果不是回收员 则走 投递员登录
|
|
|
|
|
else {
|
|
|
|
|
Client client = clientService.getLastestClientByPhone(loginReqVO.getPhone());
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new BizIllegalException("登录失败:您还未注册,请先扫码注册!");
|
|
|
|
|
}
|
|
|
|
|
UserDTO userInfo = commonService.loginDeviceByClient(client);
|
|
|
|
|
LoginRespVO respVO = new LoginRespVO();
|
|
|
|
|
respVO.setUserId(client.getId());
|
|
|
|
|
respVO.setOpenId(client.getWxOpenid());
|
|
|
|
|
respVO.setUserName(client.getNickName());
|
|
|
|
|
respVO.setStatus(client.getEnabledMark());
|
|
|
|
|
respVO.setToken(userDTO.getToken());
|
|
|
|
|
respVO.setTimeExpire(userDTO.getTimeExpire());
|
|
|
|
|
respVO.setToken(userInfo.getToken());
|
|
|
|
|
respVO.setBalance(client.getBanlance());
|
|
|
|
|
respVO.setPhone(client.getMobilePhone());
|
|
|
|
|
respVO.setTimeExpire(userInfo.getTimeExpire());
|
|
|
|
|
respVO.setRole(1);
|
|
|
|
|
result.setData(respVO);
|
|
|
|
|
result.setCode(200);
|
|
|
|
|
result.setMsg("登录成功");
|
|
|
|
|
return result;
|
|
|
|
|
command.setData(respVO);
|
|
|
|
|
mqttClient.publish(loginReqVO.getDeviceCode() + "/command", JSONUtil.toJsonStr(command));
|
|
|
|
|
return CommonResult.success("登录成功!", "success");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/cleanerLogin")
|
|
|
|
|
@ApiOperation("清运员手机号登录")
|
|
|
|
|
public CommonResult<LoginRespVO> cleanerLogin(@RequestBody LoginReqVO loginReqVO) {
|
|
|
|
|
Recycler recycler = recyclerService.getRecyclerByPhoneNumber(loginReqVO.getPhone());
|
|
|
|
|
if (recycler == null) {
|
|
|
|
|
throw new BizIllegalException("登录失败:你还不是清运员,请先注册!");
|
|
|
|
|
}
|
|
|
|
|
RecycleDevice device = deviceService.getByDeviceCode(loginReqVO.getDeviceCode());
|
|
|
|
|
if (device == null) {
|
|
|
|
|
throw new BizIllegalException("登录失败:未查询到对应设备信息!");
|
|
|
|
|
}
|
|
|
|
|
RecycleStaffDevice staffDevice = staffDeviceService.getByDeviceCode(loginReqVO.getDeviceCode(), loginReqVO.getPhone());
|
|
|
|
|
if (null == staffDevice) {
|
|
|
|
|
throw new BizIllegalException("登录失败:你不是当前设备的管理人员!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//登录成功
|
|
|
|
|
UserDTO userDTO = commonService.loginDeviceByRecycler(recycler);
|
|
|
|
|
LoginRespVO respVO = new LoginRespVO();
|
|
|
|
@ -349,9 +345,12 @@ public class DeviceController {
|
|
|
|
|
respVO.setUserName(recycler.getStaffsName());
|
|
|
|
|
respVO.setStatus(recycler.getStatus());
|
|
|
|
|
respVO.setToken(userDTO.getToken());
|
|
|
|
|
respVO.setPhone(recycler.getMobilePhone());
|
|
|
|
|
respVO.setBalance(BigDecimal.ZERO);
|
|
|
|
|
respVO.setTimeExpire(userDTO.getTimeExpire());
|
|
|
|
|
respVO.setRole(2);
|
|
|
|
|
return CommonResult.success(respVO);
|
|
|
|
|
mqttClient.publish(loginReqVO.getDeviceCode() + "/command", JSONUtil.toJsonStr(respVO));
|
|
|
|
|
return CommonResult.success("登录成功!", "success");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -515,8 +514,8 @@ public class DeviceController {
|
|
|
|
|
RecycleDeviceEvent event = new RecycleDeviceEvent();
|
|
|
|
|
event.setDeviceCode(deviceCode);
|
|
|
|
|
event.setBucketCode("");//桶编码
|
|
|
|
|
if (StrUtil.isNotEmpty(cmd.getData())) {
|
|
|
|
|
event.setBucketCode(cmd.getData());//桶编码
|
|
|
|
|
if (null != cmd.getData() && StrUtil.isNotEmpty(cmd.getData().toString())) {
|
|
|
|
|
event.setBucketCode(cmd.getData().toString());//桶编码
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event.setEventType(deviceCode);
|
|
|
|
|