|
|
|
@ -399,6 +399,11 @@ public class DeviceController {
|
|
|
|
|
throw new BizIllegalException("上传失败:根据桶编号,未查询到桶信息!!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Client client = clientService.getClientByMobile(orderVO.getPhone());
|
|
|
|
|
if (null == client) {
|
|
|
|
|
throw new BizIllegalException("上传失败:根据手机号未找到对应的客户信息!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String companyId = device.getBeLongCompanyId();
|
|
|
|
|
//查询配置
|
|
|
|
|
RecycleDeviceConfig config = configService.getByCompanyId(companyId);
|
|
|
|
@ -430,7 +435,7 @@ public class DeviceController {
|
|
|
|
|
order.setAdjustPrice(BigDecimal.ZERO);
|
|
|
|
|
order.setAdjustComm("");
|
|
|
|
|
}
|
|
|
|
|
order.setDeliverId(orderVO.getUserId());
|
|
|
|
|
order.setDeliverId(client.getId());
|
|
|
|
|
order.setPhone(orderVO.getPhone());
|
|
|
|
|
// 上传照片
|
|
|
|
|
List<Snap> images = orderVO.getImages();
|
|
|
|
@ -501,6 +506,11 @@ public class DeviceController {
|
|
|
|
|
if (null == bucket) {
|
|
|
|
|
throw new BizIllegalException("上传失败:根据桶编号,未查询到桶信息!!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Recycler recycle = recyclerService.getLatestRecycleByPhone(orderVO.getPhone());
|
|
|
|
|
if (null == recycle) {
|
|
|
|
|
throw new BizIllegalException("上传失败:根据手机号,未查询到回收员信息!!");
|
|
|
|
|
}
|
|
|
|
|
//查询配置
|
|
|
|
|
RecycleDeviceConfig config = configService.getByCompanyId(device.getBeLongCompanyId());
|
|
|
|
|
String adjustSet = config.getCleanAdjustSet();//审核配置
|
|
|
|
@ -517,7 +527,7 @@ public class DeviceController {
|
|
|
|
|
order.setPrice(orderVO.getPrice());
|
|
|
|
|
order.setWeight(orderVO.getTotalWeight());
|
|
|
|
|
order.setTotalPrice(orderVO.getTotalPrice());
|
|
|
|
|
order.setCleanUserId(orderVO.getUserId());
|
|
|
|
|
order.setCleanUserId(recycle.getId());
|
|
|
|
|
order.setPhone(orderVO.getPhone());
|
|
|
|
|
order.setBagNo(orderVO.getBagNo());
|
|
|
|
|
order.setLoginType("2");
|
|
|
|
@ -553,7 +563,7 @@ public class DeviceController {
|
|
|
|
|
order.setReportTime(DateUtil.parse(orderVO.getReportTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
order.setCreatorUserId(orderVO.getUserId());
|
|
|
|
|
order.setCreatorUserId(recycle.getId());
|
|
|
|
|
order.setCreatorTime(new Date());
|
|
|
|
|
order.setPhone(orderVO.getPhone());
|
|
|
|
|
order.setCompanyId(device.getBeLongCompanyId());
|
|
|
|
@ -1016,4 +1026,69 @@ public class DeviceController {
|
|
|
|
|
}
|
|
|
|
|
return CommonResult.error(400, "桶内桶内无重量!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("小程序接口 用终端操作")
|
|
|
|
|
@PostMapping("/loginDevice")
|
|
|
|
|
public CommonResult loginDevice(CommandVO commandVO) {
|
|
|
|
|
UserDTO user = UserContext.getUser();
|
|
|
|
|
if (null == user) {
|
|
|
|
|
throw new BizIllegalException("登录已过期,请先登录!");
|
|
|
|
|
}
|
|
|
|
|
String phone = user.getPhone();
|
|
|
|
|
String deviceCode = commandVO.getDeviceCode();
|
|
|
|
|
|
|
|
|
|
int role = 0;
|
|
|
|
|
LoginRespVO respVO = new LoginRespVO();
|
|
|
|
|
Recycler recycler = recyclerService.getRecyclerByPhoneNumber(phone);
|
|
|
|
|
Client client = clientService.getLastestClientByPhone(phone);
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new BizIllegalException("登录失败:您还未注册,请先扫码注册!");
|
|
|
|
|
} else {
|
|
|
|
|
role = 1;
|
|
|
|
|
}
|
|
|
|
|
if (null != recycler) {
|
|
|
|
|
RecycleStaffDevice staffDevice = staffDeviceService.getByDeviceCode(deviceCode, phone);
|
|
|
|
|
if (null != staffDevice) {
|
|
|
|
|
if (role == 1) role = 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UserDTO userInfo = null;
|
|
|
|
|
if (role == 1) {
|
|
|
|
|
userInfo = commonService.loginDeviceByClient(client);
|
|
|
|
|
respVO.setUserId(client.getId());
|
|
|
|
|
respVO.setOpenId(client.getWxOpenid());
|
|
|
|
|
respVO.setUserName(client.getNickName());
|
|
|
|
|
respVO.setStatus(client.getEnabledMark());
|
|
|
|
|
respVO.setPhone(client.getMobilePhone());
|
|
|
|
|
respVO.setBalance(client.getBanlance());
|
|
|
|
|
} else if (role == 3) {
|
|
|
|
|
userInfo = commonService.loginDeviceByRecycler(recycler);
|
|
|
|
|
respVO.setUserId(recycler.getId());
|
|
|
|
|
respVO.setOpenId(recycler.getOpenid());
|
|
|
|
|
respVO.setUserName(recycler.getStaffsName());
|
|
|
|
|
respVO.setStatus(recycler.getStatus());
|
|
|
|
|
respVO.setPhone(recycler.getMobilePhone());
|
|
|
|
|
respVO.setBalance(BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
respVO.setToken(userInfo.getToken());
|
|
|
|
|
respVO.setTimeExpire(userInfo.getTimeExpire());
|
|
|
|
|
respVO.setRole(role);
|
|
|
|
|
|
|
|
|
|
CommandVO command = new CommandVO();
|
|
|
|
|
command.setCmd(CMDEnum.login);
|
|
|
|
|
command.setDeviceCode(deviceCode);
|
|
|
|
|
command.setData(respVO);
|
|
|
|
|
command.setOptTime(DateUtil.now());
|
|
|
|
|
command.setRemark("登录成功");
|
|
|
|
|
boolean connected = mqttClient.isConnected();
|
|
|
|
|
if (connected) {
|
|
|
|
|
mqttClient.publish(deviceCode + "/command", JSONUtil.toJsonStr(command));
|
|
|
|
|
log.info("扫描登录 ===> 通知设备 code:{}", deviceCode);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("扫描登录失败 ===> mqtt未连接 code:{}", deviceCode);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|