mirror of
https://gitee.com/elegant_wings/xiongan-meeting.git
synced 2025-06-21 03:49:36 +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);
|
||||
int i1 = roomService.updateRoom(room);
|
||||
Assert.isTrue(i1 > 0, "修改房间已租状态失败");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -244,6 +243,30 @@ public class CustomerController extends BaseController {
|
||||
// }
|
||||
ValidatorUtils.validateEntity(customer);
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -181,11 +181,12 @@ public class EquipmentController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions("meeting:equipment:add")
|
||||
@PostMapping("save")
|
||||
public R addSave(@RequestBody Equipment equipment) {
|
||||
public R addSave(@RequestBody Equipment equipment) throws Exception {
|
||||
int i = equipmentService.insertEquipment(equipment);
|
||||
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){
|
||||
equipment.setEquipmentNum(String.valueOf((new Date()).getTime()));
|
||||
|
||||
@ -289,22 +290,25 @@ public class EquipmentController extends BaseController {
|
||||
//根据企业id新增用户设备
|
||||
public void addPersonDeviceByCustomer(Room room,Long deviceId) {
|
||||
if (room != null) {
|
||||
Customer customer = customerService.selectByRoomId(room.getId());
|
||||
if (customer != null) {
|
||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer.getId());
|
||||
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
||||
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
||||
return item.getId();
|
||||
}).collect(Collectors.toList());
|
||||
for (Long id : ids) {
|
||||
UserEquipment userEquipment = new UserEquipment();
|
||||
userEquipment.setEquipmentId(deviceId);
|
||||
userEquipment.setUserId(id);
|
||||
userEquipment.setStartTime(customer.getStartDate());
|
||||
userEquipment.setEndDate(customer.getEndDate());
|
||||
userEquipmentService.insertUserEquipment(userEquipment);
|
||||
List<Customer> customer = customerService.selectByRoomId(room.getId(),room.getParkId());
|
||||
if (CollUtil.isNotEmpty(customer)) {
|
||||
for (Customer customer1 : customer) {
|
||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer1.getId());
|
||||
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
||||
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
||||
return item.getId();
|
||||
}).collect(Collectors.toList());
|
||||
for (Long id : ids) {
|
||||
UserEquipment userEquipment = new UserEquipment();
|
||||
userEquipment.setEquipmentId(deviceId);
|
||||
userEquipment.setUserId(id);
|
||||
userEquipment.setStartTime(customer1.getStartDate());
|
||||
userEquipment.setEndDate(customer1.getEndDate());
|
||||
userEquipmentService.insertUserEquipment(userEquipment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,9 @@ public class RoomContentController extends BaseController {
|
||||
if (CollUtil.isNotEmpty(room.getIds()) ){
|
||||
for (Long id : room.getIds()) {
|
||||
Room room1 = roomService.selectRoomById(id);
|
||||
rooms.add(room1);
|
||||
if (null != room1){
|
||||
rooms.add(room1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok().put("data",rooms);
|
||||
|
@ -373,22 +373,25 @@ public class VisitorPersonController extends BaseController {
|
||||
|
||||
public void addPersonDeviceByCustomer(Room room, Long deviceId) {
|
||||
if (room != null) {
|
||||
Customer customer = customerService.selectByRoomId(room.getId());
|
||||
if (customer != null) {
|
||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer.getId());
|
||||
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
||||
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
||||
return item.getId();
|
||||
}).collect(Collectors.toList());
|
||||
for (Long id : ids) {
|
||||
UserEquipment userEquipment = new UserEquipment();
|
||||
userEquipment.setEquipmentId(deviceId);
|
||||
userEquipment.setUserId(id);
|
||||
userEquipment.setStartTime(customer.getStartDate());
|
||||
userEquipment.setEndDate(customer.getEndDate());
|
||||
userEquipmentService.insertUserEquipment(userEquipment);
|
||||
List<Customer> customers = customerService.selectByRoomId(room.getId(),room.getParkId());
|
||||
if ( CollUtil.isNotEmpty(customers)) {
|
||||
for (Customer customer : customers) {
|
||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectUserByCustomer(customer.getId());
|
||||
if (CollUtil.isNotEmpty(icsCustomerStaffs)) {
|
||||
List<Long> ids = icsCustomerStaffs.stream().map(item -> {
|
||||
return item.getId();
|
||||
}).collect(Collectors.toList());
|
||||
for (Long id : ids) {
|
||||
UserEquipment userEquipment = new UserEquipment();
|
||||
userEquipment.setEquipmentId(deviceId);
|
||||
userEquipment.setUserId(id);
|
||||
userEquipment.setStartTime(customer.getStartDate());
|
||||
userEquipment.setEndDate(customer.getEndDate());
|
||||
userEquipmentService.insertUserEquipment(userEquipment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public interface ICustomerService extends IService<Customer> {
|
||||
*/
|
||||
int deleteCustomerById(Long id);
|
||||
|
||||
Customer selectByRoomId(Long id);
|
||||
List<Customer> selectByRoomId(Long id,Long parkId);
|
||||
|
||||
Customer selectCustomerByIdAndParkId(Long icsCustomerId, Long parkId);
|
||||
}
|
@ -92,11 +92,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Customer selectByRoomId(Long id) {
|
||||
public List<Customer> selectByRoomId(Long id, Long parkId) {
|
||||
|
||||
QueryWrapper<Customer> queryWrapper =new QueryWrapper<>();
|
||||
queryWrapper.likeLeft("room_id",id);
|
||||
return customerMapper.selectOne(queryWrapper);
|
||||
queryWrapper.like("room_id",id);
|
||||
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());
|
||||
// System.out.println(equipment1);
|
||||
//
|
||||
Boolean isHost = DeviceUtils.ping(equipment.getIp(), 1,3000);
|
||||
Boolean isHost = DeviceUtils.ping(equipment.getIp());
|
||||
if (!isHost) {
|
||||
equipment.setStatus(2L);
|
||||
equipmentMapper.updateEquipment(equipment);
|
||||
|
@ -21,6 +21,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
@ -291,34 +292,41 @@ public class DeviceUtils {
|
||||
return msg;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ping(String ipAddress) throws Exception {
|
||||
int timeOut = 3000 ; //超时应该在3钞以上
|
||||
boolean status = InetAddress.getByName(ipAddress).isReachable(timeOut); // 当返回值是true时,说明host是可用的,false则不可。
|
||||
return status;
|
||||
}
|
||||
|
||||
// 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.
|
||||
private static int getCheckResult(String line) { // System.out.println("控制台输出的结果为:"+line);
|
||||
Pattern pattern = Pattern.compile("(\\d+ms)(\\s+)(TTL=\\d+)", Pattern.CASE_INSENSITIVE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user