|
@@ -81,6 +81,7 @@ public class TEquipmentController {
|
|
private int j;
|
|
private int j;
|
|
|
|
|
|
private static final int TIMEOUT = 30000; // 超时时间为30秒
|
|
private static final int TIMEOUT = 30000; // 超时时间为30秒
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @param adminName 商户的登录名
|
|
* @param adminName 商户的登录名
|
|
* @param equipmentName 机器名称
|
|
* @param equipmentName 机器名称
|
|
@@ -96,11 +97,11 @@ public class TEquipmentController {
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
TAdmin admin = tAdminService.getById(id);
|
|
TAdmin admin = tAdminService.getById(id);
|
|
// 申泽管理员
|
|
// 申泽管理员
|
|
- if(id == 2738) {
|
|
|
|
|
|
+ if (id == 2738) {
|
|
companyType = "0";
|
|
companyType = "0";
|
|
}
|
|
}
|
|
// 七云管理员
|
|
// 七云管理员
|
|
- if(id == 2739) {
|
|
|
|
|
|
+ if (id == 2739) {
|
|
companyType = "1";
|
|
companyType = "1";
|
|
}
|
|
}
|
|
Integer type = admin.getType();
|
|
Integer type = admin.getType();
|
|
@@ -153,10 +154,10 @@ public class TEquipmentController {
|
|
}
|
|
}
|
|
// 公司平台
|
|
// 公司平台
|
|
if (StringUtils.isNotEmpty(companyType)) {
|
|
if (StringUtils.isNotEmpty(companyType)) {
|
|
- if(companyType.equals("0")) {
|
|
|
|
|
|
+ if (companyType.equals("0")) {
|
|
query.isNull(TEquipment::getCompanyType)
|
|
query.isNull(TEquipment::getCompanyType)
|
|
.or().eq(TEquipment::getCompanyType, companyType);
|
|
.or().eq(TEquipment::getCompanyType, companyType);
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
query.eq(TEquipment::getCompanyType, companyType);
|
|
query.eq(TEquipment::getCompanyType, companyType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -180,7 +181,7 @@ public class TEquipmentController {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
Date date = null;
|
|
Date date = null;
|
|
try {
|
|
try {
|
|
- date = sdf.parse(todayDate);
|
|
|
|
|
|
+ date = sdf.parse(todayDate);
|
|
} catch (ParseException e) {
|
|
} catch (ParseException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -243,12 +244,12 @@ public class TEquipmentController {
|
|
TEquipmentDTO equipmentDTO = new TEquipmentDTO();
|
|
TEquipmentDTO equipmentDTO = new TEquipmentDTO();
|
|
// BeanUtils.copyProperties(equipment, equipmentDTO);
|
|
// BeanUtils.copyProperties(equipment, equipmentDTO);
|
|
BeanUtils.copyPropertiesIgnoreNull(equipment, equipmentDTO, true);
|
|
BeanUtils.copyPropertiesIgnoreNull(equipment, equipmentDTO, true);
|
|
- TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
|
|
|
|
|
|
+ TEquipmentDesc equipmentDesc = equipmentDescService.getById(id);
|
|
if (equipmentDesc != null) {
|
|
if (equipmentDesc != null) {
|
|
equipmentDTO.setCouponStatus(equipmentDesc.getCouponStatus());
|
|
equipmentDTO.setCouponStatus(equipmentDesc.getCouponStatus());
|
|
equipmentDTO.setInDoor(equipmentDesc.getInDoor());
|
|
equipmentDTO.setInDoor(equipmentDesc.getInDoor());
|
|
equipmentDTO.setOutDoor(equipmentDesc.getOutDoor());
|
|
equipmentDTO.setOutDoor(equipmentDesc.getOutDoor());
|
|
- if(equipmentDesc.getFlowers() != null) {
|
|
|
|
|
|
+ if (equipmentDesc.getFlowers() != null) {
|
|
equipmentDTO.setFlowers(equipmentDesc.getFlowers());
|
|
equipmentDTO.setFlowers(equipmentDesc.getFlowers());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -772,14 +773,27 @@ public class TEquipmentController {
|
|
if (equipment == null || equipment.getId() == null) {
|
|
if (equipment == null || equipment.getId() == null) {
|
|
return R.fail(ResponseCodesEnum.A0001, "找不到设备");
|
|
return R.fail(ResponseCodesEnum.A0001, "找不到设备");
|
|
}
|
|
}
|
|
-// tEquipmentService.sentMessage(equipment.getClientId(),PushUtils.buildJson("couponStatus", couponStatus).toString());
|
|
|
|
TEquipmentDesc tEquipmentDesc = equipmentDescService.getById(equipment.getId());
|
|
TEquipmentDesc tEquipmentDesc = equipmentDescService.getById(equipment.getId());
|
|
- if (tEquipmentDesc != null) {
|
|
|
|
-// tEquipmentDesc.setCouponStatus(couponStatus);
|
|
|
|
-// equipmentDescService.updateById(tEquipmentDesc);
|
|
|
|
- tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("couponStatus", couponStatus).toString());
|
|
|
|
|
|
+
|
|
|
|
+ Long adminId = equipment.getAdminId();
|
|
|
|
+ LambdaQueryWrapper<TAdmin> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ wrapper.eq(TAdmin::getId, adminId);
|
|
|
|
+ TAdmin admin = tAdminService.getOne(wrapper);
|
|
|
|
+ Integer type = admin.getType();
|
|
|
|
+// String ifForeign = admin.getIfForeign();
|
|
|
|
+// if (type < 2 && "0".equals(ifForeign)) {
|
|
|
|
+ if (type < 2) {
|
|
|
|
+ if (tEquipmentDesc != null) {
|
|
|
|
+ tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("couponStatus", couponStatus).toString());
|
|
|
|
+ equipment.setCouponStatus(couponStatus);
|
|
|
|
+ tEquipmentService.saveOrUpdate(equipment);
|
|
|
|
+ tEquipmentDesc.setCouponStatus(couponStatus);
|
|
|
|
+ equipmentDescService.saveOrUpdate(tEquipmentDesc);
|
|
|
|
+ } else {
|
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "找不到设备描述");
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- return R.fail(ResponseCodesEnum.A0001, "找不到设备");
|
|
|
|
|
|
+ return R.fail("仅管理员可操作");
|
|
}
|
|
}
|
|
return R.ok(null, "修改成功");
|
|
return R.ok(null, "修改成功");
|
|
}
|
|
}
|
|
@@ -856,7 +870,7 @@ public class TEquipmentController {
|
|
String adminPwd = passwordParam.getAdminPwd();
|
|
String adminPwd = passwordParam.getAdminPwd();
|
|
String guestPwd = passwordParam.getGuestPwd();
|
|
String guestPwd = passwordParam.getGuestPwd();
|
|
TEquipment tEquipment = tEquipmentService.getById(equipmentId);
|
|
TEquipment tEquipment = tEquipmentService.getById(equipmentId);
|
|
- if(tEquipment==null) {
|
|
|
|
|
|
+ if (tEquipment == null) {
|
|
return R.fail(ResponseCodesEnum.A0001, "找不到设备");
|
|
return R.fail(ResponseCodesEnum.A0001, "找不到设备");
|
|
}
|
|
}
|
|
if (StringUtils.isNotEmpty(guestPwd)) {
|
|
if (StringUtils.isNotEmpty(guestPwd)) {
|
|
@@ -879,7 +893,7 @@ public class TEquipmentController {
|
|
String equipmentId = param.getEquipmentId();
|
|
String equipmentId = param.getEquipmentId();
|
|
Long id = Long.valueOf(equipmentId);
|
|
Long id = Long.valueOf(equipmentId);
|
|
TEquipment equipment = tEquipmentService.getById(id);
|
|
TEquipment equipment = tEquipmentService.getById(id);
|
|
- tEquipmentService.sentMessage(equipment.getClientId(),PushUtils.buildJson("openDoor", "0").toString());
|
|
|
|
|
|
+ tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("openDoor", "0").toString());
|
|
// PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("openDoor", "0").toString());
|
|
// PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("openDoor", "0").toString());
|
|
return ResponseEntity
|
|
return ResponseEntity
|
|
.status(HttpStatus.OK)
|
|
.status(HttpStatus.OK)
|
|
@@ -1493,6 +1507,7 @@ public class TEquipmentController {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 下载日志
|
|
* 下载日志
|
|
|
|
+ *
|
|
* @param equipmentId
|
|
* @param equipmentId
|
|
* @param day
|
|
* @param day
|
|
* @param response
|
|
* @param response
|
|
@@ -1504,18 +1519,18 @@ public class TEquipmentController {
|
|
/* if(day.length()!=8){
|
|
/* if(day.length()!=8){
|
|
return R.fail(A0001,"日期格式有误");
|
|
return R.fail(A0001,"日期格式有误");
|
|
}*/
|
|
}*/
|
|
- if(StringUtils.isEmpty(equipmentId)) {
|
|
|
|
|
|
+ if (StringUtils.isEmpty(equipmentId)) {
|
|
return R.fail(A0001);
|
|
return R.fail(A0001);
|
|
}
|
|
}
|
|
TEquipment tEquipment = tEquipmentService.getById(equipmentId);
|
|
TEquipment tEquipment = tEquipmentService.getById(equipmentId);
|
|
if (tEquipment == null) {
|
|
if (tEquipment == null) {
|
|
- return R.fail(A0001,"该设备不存在");
|
|
|
|
|
|
+ return R.fail(A0001, "该设备不存在");
|
|
}
|
|
}
|
|
String clientId = tEquipment.getClientId();
|
|
String clientId = tEquipment.getClientId();
|
|
- String kind = day+"-"+clientId;
|
|
|
|
- String filepath = "/home/hboxs/log/"+kind+".txt";
|
|
|
|
|
|
+ String kind = day + "-" + clientId;
|
|
|
|
+ String filepath = "/home/hboxs/log/" + kind + ".txt";
|
|
// 1.1 如果文件已存在,直接下载
|
|
// 1.1 如果文件已存在,直接下载
|
|
- if(Files.exists(Paths.get(filepath))) {
|
|
|
|
|
|
+ if (Files.exists(Paths.get(filepath))) {
|
|
// DownloadUtils.downloadFile(filepath, response);
|
|
// DownloadUtils.downloadFile(filepath, response);
|
|
// return R.ok();
|
|
// return R.ok();
|
|
try {
|
|
try {
|
|
@@ -1523,16 +1538,16 @@ public class TEquipmentController {
|
|
return R.ok();
|
|
return R.ok();
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- return R.fail(B0004,"请重试");
|
|
|
|
|
|
+ return R.fail(B0004, "请重试");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
String channel = tEquipment.getChannel();
|
|
String channel = tEquipment.getChannel();
|
|
String equimentType = tEquipment.getEquimentType();
|
|
String equimentType = tEquipment.getEquimentType();
|
|
- if(StringUtils.isEmpty(channel)||channel.equals("1")||StringUtils.isEmpty(equimentType)){
|
|
|
|
|
|
+ if (StringUtils.isEmpty(channel) || channel.equals("1") || StringUtils.isEmpty(equimentType)) {
|
|
//用个推
|
|
//用个推
|
|
PushUtils.push(tEquipment.getGtClientId(), "", "", PushUtils.buildJson("log", kind).toString());
|
|
PushUtils.push(tEquipment.getGtClientId(), "", "", PushUtils.buildJson("log", kind).toString());
|
|
}
|
|
}
|
|
- if(StringUtils.isNotEmpty(channel)&&channel.equals("2")&&StringUtils.isNotEmpty(equimentType)){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(channel) && channel.equals("2") && StringUtils.isNotEmpty(equimentType)) {
|
|
//用Mq
|
|
//用Mq
|
|
tEquipmentService.sentMessage(tEquipment.getClientId(), PushUtils.buildJson("log", kind).toString());
|
|
tEquipmentService.sentMessage(tEquipment.getClientId(), PushUtils.buildJson("log", kind).toString());
|
|
}
|
|
}
|
|
@@ -1553,7 +1568,7 @@ public class TEquipmentController {
|
|
// 文件存在,取消定时器
|
|
// 文件存在,取消定时器
|
|
future.cancel(false);
|
|
future.cancel(false);
|
|
break;
|
|
break;
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
Thread.sleep(1000);
|
|
Thread.sleep(1000);
|
|
if (System.currentTimeMillis() - startTime >= TIMEOUT) {
|
|
if (System.currentTimeMillis() - startTime >= TIMEOUT) {
|
|
// 超过最大等待时间,抛出异常
|
|
// 超过最大等待时间,抛出异常
|
|
@@ -1592,7 +1607,7 @@ public class TEquipmentController {
|
|
public ResponseModel<List<TEquipment>> findEquipmentByClientIds(@RequestParam("clientIds") List<String> clientIds) {
|
|
public ResponseModel<List<TEquipment>> findEquipmentByClientIds(@RequestParam("clientIds") List<String> clientIds) {
|
|
|
|
|
|
LambdaQueryWrapper<TEquipment> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<TEquipment> wrapper = new LambdaQueryWrapper<>();
|
|
- wrapper.in(TEquipment::getClientId,clientIds);
|
|
|
|
|
|
+ wrapper.in(TEquipment::getClientId, clientIds);
|
|
List<TEquipment> list = tEquipmentService.list(wrapper);
|
|
List<TEquipment> list = tEquipmentService.list(wrapper);
|
|
return R.ok(list);
|
|
return R.ok(list);
|
|
}
|
|
}
|