mirror of
https://gitee.com/elegant_wings/dbd-meeting.git
synced 2025-06-21 10:19:35 +08:00
修改了对应bug
This commit is contained in:
parent
d2764af4f7
commit
9aad1f159e
@ -225,7 +225,6 @@ public class CustomerController extends BaseController {
|
|||||||
room.setStatus(Room.Status.YES);
|
room.setStatus(Room.Status.YES);
|
||||||
int i1 = roomService.updateRoom(room);
|
int i1 = roomService.updateRoom(room);
|
||||||
Assert.isTrue(i1 > 0, "修改房间已租状态失败");
|
Assert.isTrue(i1 > 0, "修改房间已租状态失败");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -244,6 +243,30 @@ public class CustomerController extends BaseController {
|
|||||||
// }
|
// }
|
||||||
ValidatorUtils.validateEntity(customer);
|
ValidatorUtils.validateEntity(customer);
|
||||||
customer.setUpdateBy(getLoginName());
|
customer.setUpdateBy(getLoginName());
|
||||||
|
|
||||||
|
|
||||||
|
//房间转成逗号隔开
|
||||||
|
List<Long> buildingDetailIds = customer.getBuildingDetailIds();
|
||||||
|
|
||||||
|
String buildIds = CollUtil.join(buildingDetailIds, ",");
|
||||||
|
|
||||||
|
customer.setBuildId(buildIds);
|
||||||
|
List<Long> roomIds = customer.getRoomIds();
|
||||||
|
|
||||||
|
String roomids = CollUtil.join(roomIds, ",");
|
||||||
|
customer.setRoomId(roomids);
|
||||||
|
|
||||||
|
//如果新增成功,把房间的状态改为已启用
|
||||||
|
for (Long roomId : roomIds) {
|
||||||
|
Room room = roomService.selectRoomById(roomId);
|
||||||
|
if (null != room){
|
||||||
|
room.setStatus(Room.Status.YES);
|
||||||
|
int i1 = roomService.updateRoom(room);
|
||||||
|
Assert.isTrue(i1 > 0, "修改房间已租状态失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return toAjax(customerService.updateCustomer(customer));
|
return toAjax(customerService.updateCustomer(customer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,11 +181,12 @@ public class EquipmentController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@RequiresPermissions("meeting:equipment:add")
|
@RequiresPermissions("meeting:equipment:add")
|
||||||
@PostMapping("save")
|
@PostMapping("save")
|
||||||
public R addSave(@RequestBody Equipment equipment) {
|
public R addSave(@RequestBody Equipment equipment) throws Exception {
|
||||||
int i = equipmentService.insertEquipment(equipment);
|
int i = equipmentService.insertEquipment(equipment);
|
||||||
Assert.isTrue(i > 0, "添加失败");
|
Assert.isTrue(i > 0, "添加失败");
|
||||||
|
|
||||||
boolean ping = DeviceUtils.ping(equipment.getIp(), 1, 2000);
|
boolean ping = DeviceUtils.ping(equipment.getIp());
|
||||||
|
log.info("设备IP:{} 是否ping通:{}", equipment.getIp(), ping);
|
||||||
if (ping){
|
if (ping){
|
||||||
equipment.setEquipmentNum(String.valueOf((new Date()).getTime()));
|
equipment.setEquipmentNum(String.valueOf((new Date()).getTime()));
|
||||||
|
|
||||||
@ -289,22 +290,25 @@ public class EquipmentController extends BaseController {
|
|||||||
//根据企业id新增用户设备
|
//根据企业id新增用户设备
|
||||||
public void addPersonDeviceByCustomer(Room room,Long deviceId) {
|
public void addPersonDeviceByCustomer(Room room,Long deviceId) {
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
Customer customer = customerService.selectByRoomId(room.getId());
|
List<Customer> customer = customerService.selectByRoomId(room.getId(),room.getParkId());
|
||||||
if (customer != null) {
|
if (CollUtil.isNotEmpty(customer)) {
|
||||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer.getId());
|
for (Customer customer1 : customer) {
|
||||||
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer1.getId());
|
||||||
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
||||||
return item.getId();
|
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
||||||
}).collect(Collectors.toList());
|
return item.getId();
|
||||||
for (Long id : ids) {
|
}).collect(Collectors.toList());
|
||||||
UserEquipment userEquipment = new UserEquipment();
|
for (Long id : ids) {
|
||||||
userEquipment.setEquipmentId(deviceId);
|
UserEquipment userEquipment = new UserEquipment();
|
||||||
userEquipment.setUserId(id);
|
userEquipment.setEquipmentId(deviceId);
|
||||||
userEquipment.setStartTime(customer.getStartDate());
|
userEquipment.setUserId(id);
|
||||||
userEquipment.setEndDate(customer.getEndDate());
|
userEquipment.setStartTime(customer1.getStartDate());
|
||||||
userEquipmentService.insertUserEquipment(userEquipment);
|
userEquipment.setEndDate(customer1.getEndDate());
|
||||||
|
userEquipmentService.insertUserEquipment(userEquipment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,9 @@ public class RoomContentController extends BaseController {
|
|||||||
if (CollUtil.isNotEmpty(room.getIds()) ){
|
if (CollUtil.isNotEmpty(room.getIds()) ){
|
||||||
for (Long id : room.getIds()) {
|
for (Long id : room.getIds()) {
|
||||||
Room room1 = roomService.selectRoomById(id);
|
Room room1 = roomService.selectRoomById(id);
|
||||||
rooms.add(room1);
|
if (null != room1){
|
||||||
|
rooms.add(room1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return R.ok().put("data",rooms);
|
return R.ok().put("data",rooms);
|
||||||
|
@ -373,22 +373,25 @@ public class VisitorPersonController extends BaseController {
|
|||||||
|
|
||||||
public void addPersonDeviceByCustomer(Room room, Long deviceId) {
|
public void addPersonDeviceByCustomer(Room room, Long deviceId) {
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
Customer customer = customerService.selectByRoomId(room.getId());
|
List<Customer> customers = customerService.selectByRoomId(room.getId(),room.getParkId());
|
||||||
if (customer != null) {
|
if ( CollUtil.isNotEmpty(customers)) {
|
||||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer.getId());
|
for (Customer customer : customers) {
|
||||||
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer.getId());
|
||||||
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
||||||
return item.getId();
|
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
||||||
}).collect(Collectors.toList());
|
return item.getId();
|
||||||
for (Long id : ids) {
|
}).collect(Collectors.toList());
|
||||||
UserEquipment userEquipment = new UserEquipment();
|
for (Long id : ids) {
|
||||||
userEquipment.setEquipmentId(deviceId);
|
UserEquipment userEquipment = new UserEquipment();
|
||||||
userEquipment.setUserId(id);
|
userEquipment.setEquipmentId(deviceId);
|
||||||
userEquipment.setStartTime(customer.getStartDate());
|
userEquipment.setUserId(id);
|
||||||
userEquipment.setEndDate(customer.getEndDate());
|
userEquipment.setStartTime(customer.getStartDate());
|
||||||
userEquipmentService.insertUserEquipment(userEquipment);
|
userEquipment.setEndDate(customer.getEndDate());
|
||||||
|
userEquipmentService.insertUserEquipment(userEquipment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public interface ICustomerService extends IService<Customer> {
|
|||||||
*/
|
*/
|
||||||
int deleteCustomerById(Long id);
|
int deleteCustomerById(Long id);
|
||||||
|
|
||||||
Customer selectByRoomId(Long id);
|
List<Customer> selectByRoomId(Long id,Long parkId);
|
||||||
|
|
||||||
Customer selectCustomerByIdAndParkId(Long icsCustomerId, Long parkId);
|
Customer selectCustomerByIdAndParkId(Long icsCustomerId, Long parkId);
|
||||||
}
|
}
|
@ -92,11 +92,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Customer selectByRoomId(Long id) {
|
public List<Customer> selectByRoomId(Long id, Long parkId) {
|
||||||
|
|
||||||
QueryWrapper<Customer> queryWrapper =new QueryWrapper<>();
|
QueryWrapper<Customer> queryWrapper =new QueryWrapper<>();
|
||||||
queryWrapper.likeLeft("room_id",id);
|
queryWrapper.like("room_id",id);
|
||||||
return customerMapper.selectOne(queryWrapper);
|
queryWrapper.eq("park_id",parkId);
|
||||||
|
return customerMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ public class UserEquipmentServiceImpl extends ServiceImpl<UserEquipmentMapper, U
|
|||||||
// Equipment equipment1 = equipmentMapper.selectEquipmentById(equipment.getId());
|
// Equipment equipment1 = equipmentMapper.selectEquipmentById(equipment.getId());
|
||||||
// System.out.println(equipment1);
|
// System.out.println(equipment1);
|
||||||
//
|
//
|
||||||
Boolean isHost = DeviceUtils.ping(equipment.getIp(), 1,3000);
|
Boolean isHost = DeviceUtils.ping(equipment.getIp());
|
||||||
if (!isHost) {
|
if (!isHost) {
|
||||||
equipment.setStatus(2L);
|
equipment.setStatus(2L);
|
||||||
equipmentMapper.updateEquipment(equipment);
|
equipmentMapper.updateEquipment(equipment);
|
||||||
|
@ -21,6 +21,7 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -291,34 +292,41 @@ public class DeviceUtils {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ping(String ipAddress, int pingTimes, int timeOut) {
|
|
||||||
BufferedReader in = null;
|
public static boolean ping(String ipAddress) throws Exception {
|
||||||
Runtime r = Runtime.getRuntime(); // 将要执行的ping命令,此命令是windows格式的命令
|
int timeOut = 3000 ; //超时应该在3钞以上
|
||||||
String pingCommand = "ping " + ipAddress + " -n " + pingTimes + " -w " + timeOut;
|
boolean status = InetAddress.getByName(ipAddress).isReachable(timeOut); // 当返回值是true时,说明host是可用的,false则不可。
|
||||||
try { // 执行命令并获取输出
|
return status;
|
||||||
System.out.println(pingCommand);
|
|
||||||
Process p = r.exec(pingCommand);
|
|
||||||
if (p == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
in = new BufferedReader( new InputStreamReader(p.getInputStream())); // 逐行检查输出,计算类似出现=23ms TTL=62字样的次数
|
|
||||||
int connectedCount = 0;
|
|
||||||
String line = null;
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
connectedCount += getCheckResult(line);
|
|
||||||
} // 如果出现类似=23ms TTL=62这样的字样,出现的次数=测试次数则返回真
|
|
||||||
return connectedCount == pingTimes;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace(); // 出现异常则返回假
|
|
||||||
return false;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static boolean ping(String ipAddress, int pingTimes, int timeOut) {
|
||||||
|
// BufferedReader in = null;
|
||||||
|
// Runtime r = Runtime.getRuntime(); // 将要执行的ping命令,此命令是windows格式的命令
|
||||||
|
// String pingCommand = "ping " + ipAddress + " -n " + pingTimes + " -w " + timeOut;
|
||||||
|
// try { // 执行命令并获取输出
|
||||||
|
// System.out.println(pingCommand);
|
||||||
|
// Process p = r.exec(pingCommand);
|
||||||
|
// if (p == null) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// in = new BufferedReader( new InputStreamReader(p.getInputStream())); // 逐行检查输出,计算类似出现=23ms TTL=62字样的次数
|
||||||
|
// int connectedCount = 0;
|
||||||
|
// String line = null;
|
||||||
|
// while ((line = in.readLine()) != null) {
|
||||||
|
// connectedCount += getCheckResult(line);
|
||||||
|
// } // 如果出现类似=23ms TTL=62这样的字样,出现的次数=测试次数则返回真
|
||||||
|
// return connectedCount == pingTimes;
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// ex.printStackTrace(); // 出现异常则返回假
|
||||||
|
// return false;
|
||||||
|
// } finally {
|
||||||
|
// try {
|
||||||
|
// in.close();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
// 若line含有=18ms TTL=16字样,说明已经ping通,返回1,否則返回0.
|
// 若line含有=18ms TTL=16字样,说明已经ping通,返回1,否則返回0.
|
||||||
private static int getCheckResult(String line) { // System.out.println("控制台输出的结果为:"+line);
|
private static int getCheckResult(String line) { // System.out.println("控制台输出的结果为:"+line);
|
||||||
Pattern pattern = Pattern.compile("(\\d+ms)(\\s+)(TTL=\\d+)", Pattern.CASE_INSENSITIVE);
|
Pattern pattern = Pattern.compile("(\\d+ms)(\\s+)(TTL=\\d+)", Pattern.CASE_INSENSITIVE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user