mirror of
https://gitee.com/elegant_wings/dbd-meeting.git
synced 2025-06-21 05:39:36 +08:00
修改了对应的bug
This commit is contained in:
parent
0d72f65a20
commit
f91b6c7429
@ -18,6 +18,8 @@
|
||||
<artifactId>velocity</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- 系统模块-->
|
||||
<dependency>
|
||||
<groupId>com.ics</groupId>
|
||||
|
@ -1,12 +1,23 @@
|
||||
package com.ics.admin.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ics.admin.domain.Building;
|
||||
import com.ics.admin.domain.BuildingDetail;
|
||||
import com.ics.admin.domain.Customer;
|
||||
import com.ics.admin.service.IBuildingDetailService;
|
||||
import com.ics.admin.service.IBuildingService;
|
||||
import com.ics.common.core.controller.BaseController;
|
||||
import com.ics.common.core.domain.R;
|
||||
import com.ics.system.domain.User;
|
||||
import com.ics.system.service.ICurrentUserService;
|
||||
import com.ics.system.service.IUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.wf.jwtp.annotation.RequiresPermissions;
|
||||
import org.wf.jwtp.util.SubjectUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 楼层管理 提供者
|
||||
@ -21,6 +32,15 @@ public class BuildingDetailController extends BaseController {
|
||||
@Autowired
|
||||
private IBuildingDetailService buildingDetailService;
|
||||
|
||||
@Autowired
|
||||
private IBuildingService buildingService;
|
||||
|
||||
@Autowired
|
||||
private ICurrentUserService currentUserService;
|
||||
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
/**
|
||||
* 查询楼层管理
|
||||
*/
|
||||
@ -37,6 +57,11 @@ public class BuildingDetailController extends BaseController {
|
||||
@GetMapping("list")
|
||||
public R list(BuildingDetail buildingDetail) {
|
||||
startPage();
|
||||
boolean isAdmin = SubjectUtil.hasRole(getRequest(),"manager");
|
||||
if (isAdmin){
|
||||
Long parkId = currentUserService.getParkId();
|
||||
buildingDetail.setParkId(parkId);
|
||||
}
|
||||
return result(buildingDetailService.selectBuildingDetailList(buildingDetail));
|
||||
}
|
||||
|
||||
@ -47,6 +72,17 @@ public class BuildingDetailController extends BaseController {
|
||||
@RequiresPermissions("admin:buildingDetail:add")
|
||||
@PostMapping("save")
|
||||
public R addSave(@RequestBody BuildingDetail buildingDetail) {
|
||||
boolean isAdmin = SubjectUtil.hasRole(getRequest(),"super");
|
||||
if (isAdmin){
|
||||
//获取楼宇id
|
||||
Long buildingId = buildingDetail.getBuildingId();
|
||||
Building building = buildingService.selectBuildingById(buildingId);
|
||||
if (null != building){
|
||||
buildingDetail.setParkId(building.getParkId());
|
||||
buildingDetail.setTenantId(building.getTenantId());
|
||||
}
|
||||
}
|
||||
|
||||
return toAjax(buildingDetailService.insertBuildingDetail(buildingDetail));
|
||||
}
|
||||
|
||||
|
@ -189,6 +189,7 @@ public class CustomerStaffController extends BaseController {
|
||||
|
||||
List<Long> result = new ArrayList<>();
|
||||
|
||||
// 按照逗号分割
|
||||
List<String> buildIds = StrUtil.split(buildId, ',');
|
||||
|
||||
List<String> roomIds = StrUtil.split(roomId, ',');
|
||||
@ -373,9 +374,11 @@ public class CustomerStaffController extends BaseController {
|
||||
result.addAll(collect);
|
||||
//获取了房间集合,循环对应集合,
|
||||
for (Long id : result) {
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
@ -502,9 +505,11 @@ public class CustomerStaffController extends BaseController {
|
||||
Room room = roomService.selectRoomById(roomid);
|
||||
if (null != room) {
|
||||
Long id = room.getId();
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
@ -587,6 +592,7 @@ public class CustomerStaffController extends BaseController {
|
||||
ArrayList<Long> ids = new ArrayList<>();
|
||||
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId());
|
||||
if (null != customerStaff) {
|
||||
//查询多个企业
|
||||
List<StaffCustomer> staffCustomers = staffCustomerService.selectStaffCustomerByStaffId(customerStaff.getId());
|
||||
for (StaffCustomer staffCustomer : staffCustomers) {
|
||||
Customer customer = customerService.selectCustomerById(staffCustomer.getIcsCustomerId());
|
||||
@ -594,11 +600,8 @@ public class CustomerStaffController extends BaseController {
|
||||
//根据企业 查询对应的 房间,和对应的楼层
|
||||
String roomId = customer.getRoomId();
|
||||
String buildId = customer.getBuildId();
|
||||
|
||||
List<Long> result = new ArrayList<>();
|
||||
|
||||
List<String> buildIds = StrUtil.split(buildId, ',');
|
||||
|
||||
List<String> roomIds = StrUtil.split(roomId, ',');
|
||||
List<Long> collect = roomIds.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
List<Long> buildCollect = buildIds.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
@ -606,9 +609,11 @@ public class CustomerStaffController extends BaseController {
|
||||
result.addAll(collect);
|
||||
//获取了房间集合,循环对应集合,
|
||||
for (Long id : result) {
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment1 : roomEquipment) {
|
||||
ids.add(equipment1.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
|
@ -343,7 +343,18 @@ public class EquipmentController extends BaseController {
|
||||
@RequiresPermissions("meeting:equipment:remove")
|
||||
@PostMapping("remove")
|
||||
public R remove(String ids) {
|
||||
return toAjax(equipmentService.deleteEquipmentByIds(ids));
|
||||
int i = equipmentService.deleteEquipmentByIds(ids);
|
||||
List<String> deviceIds = StrUtil.split(ids, ',');
|
||||
for (String deviceId : deviceIds) {
|
||||
int i1 = userEquipmentService.deleteUserEquipmentByEquipmentId(Long.parseLong(deviceId));
|
||||
log.info("删除用户绑定设备成功"+i1);
|
||||
int i2 = roomEquipmentService.deleteRoomEquipment(Long.parseLong(deviceId));
|
||||
log.info("删除房间绑定设备成功"+i2);
|
||||
int i3 = detailEquipmentService.deleteDetailEquipment(Long.parseLong(deviceId));
|
||||
log.info("删除楼层绑定设备成功"+i3);
|
||||
}
|
||||
|
||||
return toAjax(i);
|
||||
}
|
||||
|
||||
|
||||
@ -422,9 +433,7 @@ public class EquipmentController extends BaseController {
|
||||
boolean isAdmin = SubjectUtil.hasRole(getRequest(),"manager");
|
||||
if (isAdmin){
|
||||
Long parkId = currentUserService.getParkId();
|
||||
Long tenantId = currentUserService.getTenantId();
|
||||
userEquipment.setParkId(parkId);
|
||||
// userEquipment.setTenantId(tenantId);
|
||||
}
|
||||
boolean b = SubjectUtil.hasRole(getRequest(),"admin");
|
||||
if (b){
|
||||
@ -445,14 +454,19 @@ public class EquipmentController extends BaseController {
|
||||
return item.getUserId();
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectListByUserIds(userIds);
|
||||
for (IcsCustomerStaff icsCustomerStaff : icsCustomerStaffs) {
|
||||
Customer customer = customerService.selectCustomerById(icsCustomerStaff.getIcsCustomerId());
|
||||
if (null != customer) {
|
||||
icsCustomerStaff.setCustomerName(customer.getName());
|
||||
if(CollUtil.isNotEmpty(userIds)){
|
||||
List<IcsCustomerStaff> icsCustomerStaffs = staffService.selectListByUserIds(userIds);
|
||||
for (IcsCustomerStaff icsCustomerStaff : icsCustomerStaffs) {
|
||||
Customer customer = customerService.selectCustomerById(icsCustomerStaff.getIcsCustomerId());
|
||||
if (null != customer) {
|
||||
icsCustomerStaff.setCustomerName(customer.getName());
|
||||
}
|
||||
}
|
||||
return R.data(icsCustomerStaffs);
|
||||
}else {
|
||||
return R.data(new ArrayList<>());
|
||||
}
|
||||
return R.data(icsCustomerStaffs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@ public class StaffCustomer extends BaseEntity<StaffCustomer> {
|
||||
private Long icsCustomerId;
|
||||
|
||||
/** 用户id */
|
||||
|
||||
private Long staffId;
|
||||
|
||||
/** 园区ID */
|
||||
|
@ -61,4 +61,6 @@ public interface StaffCustomerMapper extends BaseMapper<StaffCustomer> {
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteStaffCustomerByIds(String[] ids);
|
||||
|
||||
List<StaffCustomer> selectStaffCustomerByStaffId(Long id);
|
||||
}
|
||||
|
@ -87,4 +87,5 @@ public interface IIcsCustomerStaffService extends IService<IcsCustomerStaff> {
|
||||
|
||||
List<IcsCustomerStaff> getUserList(IcsCustomerStaff customerStaff);
|
||||
|
||||
IcsCustomerStaff selectByPhoneAndOpenId(String phoneNumber, String openid);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public class BuildingDetailServiceImpl extends ServiceImpl<BuildingDetailMapper,
|
||||
public List<BuildingDetail> selectBuildingDetailList(BuildingDetail buildingDetail) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("building_id", buildingDetail.getBuildingId());
|
||||
queryWrapper.eq(buildingDetail.getParkId() !=null,"park_id", buildingDetail.getParkId());
|
||||
return buildingDetailMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
@ -284,6 +284,17 @@ public class IcsCustomerStaffServiceImpl extends ServiceImpl<IcsCustomerStaffMap
|
||||
return icsCustomerStaffMapper.getUserList(customerStaff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IcsCustomerStaff selectByPhoneAndOpenId(String phoneNumber, String openid) {
|
||||
|
||||
QueryWrapper<IcsCustomerStaff> wrapper = new QueryWrapper<>();
|
||||
|
||||
wrapper.eq("mobile", phoneNumber);
|
||||
wrapper.in("openid", openid);
|
||||
|
||||
return icsCustomerStaffMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
//根据企业查询对应的设备
|
||||
public void queryDeviceByCustomerId(Long customerId,Long userId){
|
||||
ArrayList<Long> ids = new ArrayList<>();
|
||||
@ -297,9 +308,11 @@ public class IcsCustomerStaffServiceImpl extends ServiceImpl<IcsCustomerStaffMap
|
||||
Room room = roomService.selectRoomById(roomid);
|
||||
if (null != room) {
|
||||
Long id = room.getId();
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
|
@ -117,11 +117,11 @@ public class RoomEquipmentServiceImpl extends ServiceImpl<RoomEquipmentMapper, R
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomEquipment selectByRoomId(Long id) {
|
||||
public List<RoomEquipment> selectByRoomId(Long id) {
|
||||
|
||||
QueryWrapper<RoomEquipment> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("room_id",id);
|
||||
return roomEquipmentMapper.selectOne(wrapper);
|
||||
return roomEquipmentMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,7 +183,7 @@ public class UserEquipmentServiceImpl extends ServiceImpl<UserEquipmentMapper, U
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteUserEquipmentByEquipmentId(Long id) {
|
||||
|
||||
|
@ -106,4 +106,11 @@ public class DetailEquipmentServiceImpl extends ServiceImpl<DetailEquipmentMappe
|
||||
queryWrapper.eq("building_detail_id", id);
|
||||
return detailEquipmentMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteDetailEquipment(Long id) {
|
||||
QueryWrapper<DetailEquipment> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("equipment_id", id);
|
||||
return detailEquipmentMapper.delete(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.ics.admin.mapper.meeting.EquipmentMapper;
|
||||
import com.ics.admin.domain.meeting.Equipment;
|
||||
import com.ics.admin.service.meeting.IEquipmentService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 设备Service业务层处理
|
||||
@ -77,6 +78,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteEquipmentByIds(String ids) {
|
||||
String[] idsArray = StrUtil.split(ids,",");
|
||||
|
@ -137,8 +137,8 @@ public class IVisitorPersonServiceImpl extends ServiceImpl<VisitorPersonMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<VisitorPerson> selectVisitorRecordByIntervieweeId(Long intervieweeId, Integer pageNum, Integer pageSize) {
|
||||
QueryWrapper<VisitorPerson> wrapper = new QueryWrapper<VisitorPerson>().eq("interviewee_id", intervieweeId);
|
||||
public IPage<VisitorPerson> selectVisitorRecordByIntervieweeId(Long intervieweeId,Long parkId, Integer pageNum, Integer pageSize) {
|
||||
QueryWrapper<VisitorPerson> wrapper = new QueryWrapper<VisitorPerson>().eq("interviewee_id", intervieweeId).eq("park_id",parkId);
|
||||
wrapper.orderByDesc("create_time");
|
||||
IPage<VisitorPerson> pages = new Page<>(pageNum,pageSize);
|
||||
IPage<VisitorPerson> userIPage = visitorPersonMapper.selectPage(pages,wrapper);
|
||||
|
@ -132,9 +132,10 @@ public class ReservationPersonServiceImpl extends ServiceImpl<ReservationPersonM
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Reservation> selectListByParticipantId(Long userId,Integer page,Integer limit) {
|
||||
public IPage<Reservation> selectListByParticipantId(Long userId,Long parkId,Integer page,Integer limit) {
|
||||
QueryWrapper<ReservationPerson> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("participant_id",userId);
|
||||
queryWrapper.eq("park_id",parkId);
|
||||
List<ReservationPerson> list = reservationPersonMapper.selectList(queryWrapper);
|
||||
List<Long> collect = list.stream().map(item -> {
|
||||
return item.getReservationId();
|
||||
|
@ -239,6 +239,7 @@ public class ReservationServiceImpl extends ServiceImpl<ReservationMapper, Reser
|
||||
|
||||
QueryWrapper<Reservation> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id",reservation.getUserId());
|
||||
queryWrapper.eq("park_id",reservation.getParkId());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
IPage<Reservation> pages = new Page<>(pageNum,pageSize);
|
||||
IPage<Reservation> userIPage = reservationMapper.selectPage(pages,queryWrapper);
|
||||
|
@ -157,6 +157,7 @@ public class ShowroomRecordServiceImpl extends ServiceImpl<ShowroomRecordMapper,
|
||||
QueryWrapper<ShowroomRecord> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.eq("user_id",showroomRecord.getUserId());
|
||||
queryWrapper.eq("park_id",showroomRecord.getParkId());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
IPage<ShowroomRecord> pages = new Page<>(pageNum,pageSize);
|
||||
|
||||
|
@ -94,9 +94,7 @@ public class StaffCustomerServiceImpl extends ServiceImpl<StaffCustomerMapper, S
|
||||
|
||||
@Override
|
||||
public List<StaffCustomer> selectStaffCustomerByStaffId(Long id) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("staff_id",id);
|
||||
return staffCustomerMapper.selectList(queryWrapper);
|
||||
return staffCustomerMapper.selectStaffCustomerByStaffId(id);
|
||||
|
||||
}
|
||||
|
||||
|
@ -62,4 +62,6 @@ public interface IDetailEquipmentService extends IService<DetailEquipment> {
|
||||
DetailEquipment selectByEquipmentId(Long id);
|
||||
|
||||
List<DetailEquipment> selectByRoomId(Long id);
|
||||
|
||||
int deleteDetailEquipment(Long id);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public interface IReservationPersonService extends IService<ReservationPerson> {
|
||||
|
||||
ReservationPerson isVisitor(ReservationPerson reservationPerson);
|
||||
|
||||
IPage<Reservation> selectListByParticipantId(Long userId, Integer page, Integer limit);
|
||||
IPage<Reservation> selectListByParticipantId(Long userId,Long parkId, Integer page, Integer limit);
|
||||
|
||||
List<ReservationPerson> selectListByReservationId(Long reservationId);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public interface IRoomEquipmentService extends IService<RoomEquipment> {
|
||||
|
||||
RoomEquipment selectByEquipmentIdAndRoomId(RoomEquipment roomEquipment);
|
||||
|
||||
RoomEquipment selectByRoomId(Long id);
|
||||
List<RoomEquipment> selectByRoomId(Long id);
|
||||
|
||||
List<RoomEquipment> selectListByRoomId(Long aLong);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public interface IVisitorPersonService extends IService<VisitorPerson> {
|
||||
|
||||
IPage<VisitorPerson> selectVisitorRecord(Long userId, Integer pageNum, Integer pageSize);
|
||||
|
||||
IPage<VisitorPerson> selectVisitorRecordByIntervieweeId(Long intervieweeId, Integer pageNum, Integer pageSize);
|
||||
IPage<VisitorPerson> selectVisitorRecordByIntervieweeId(Long intervieweeId,Long parkId, Integer pageNum, Integer pageSize);
|
||||
|
||||
int updateVisitorPersonStatus(VisitorPerson person);
|
||||
|
||||
|
@ -29,6 +29,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectStaffCustomerVo"/>
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
<select id="selectStaffCustomerByStaffId" resultType="com.ics.admin.domain.meeting.StaffCustomer">
|
||||
<include refid="selectStaffCustomerVo"/>
|
||||
WHERE staff_id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertStaffCustomer" parameterType="StaffCustomer">
|
||||
INSERT INTO tb_staff_customer
|
||||
|
@ -161,7 +161,12 @@
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-websocket</artifactId>
|
||||
<version>5.3.24</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,71 @@
|
||||
package com.ics.common.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.server.HandshakeInterceptor;
|
||||
|
||||
@Component
|
||||
public class MyInterceptor implements HandshakeInterceptor {
|
||||
|
||||
private static final Map<String, WebSocketSession> connections = new HashMap<>();
|
||||
/**
|
||||
* 向连接的客户端发送消息
|
||||
*
|
||||
* @author lucky_fd
|
||||
* @param clientId 客户端标识
|
||||
* @param message 消息体
|
||||
**/
|
||||
public void sendMessage(String clientId, TextMessage message) {
|
||||
for (String client : connections.keySet()) {
|
||||
if (client.equals(clientId)) {
|
||||
try {
|
||||
WebSocketSession session = connections.get(client);
|
||||
// 判断连接是否正常
|
||||
if (session.isOpen()) {
|
||||
session.sendMessage(message);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 握手前
|
||||
*/
|
||||
@Override
|
||||
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
|
||||
System.out.println("握手开始");
|
||||
String hostName = request.getRemoteAddress().getHostName();
|
||||
String sessionId = hostName+String.valueOf((int)(Math.random()*1000));
|
||||
if (Strings.isNotBlank(sessionId)) {
|
||||
// 放入属性域
|
||||
attributes.put("session_id", sessionId);
|
||||
System.out.println("用户 session_id " + sessionId + " 握手成功!");
|
||||
return true;
|
||||
}
|
||||
System.out.println("用户登录已失效");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 握手后
|
||||
*/
|
||||
@Override
|
||||
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) {
|
||||
System.out.println("握手完成");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.ics.common.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* @author wangyan
|
||||
* @description
|
||||
* @date 2019/7/30 18:56
|
||||
*/
|
||||
public class SocketClient {
|
||||
public static void main(String[] args) throws IOException {
|
||||
socketClient2F();
|
||||
}
|
||||
public static void socketClient2F() throws IOException{
|
||||
final Logger logger = LoggerFactory.getLogger(SocketClient.class);
|
||||
|
||||
String host = "192.168.0.4";
|
||||
int port = 8090;
|
||||
Socket socket = new Socket(host, port);
|
||||
// 建立连接后获得输出流
|
||||
OutputStream outputStream = socket.getOutputStream();
|
||||
String message = "2222";
|
||||
//首先需要计算得知消息的长度
|
||||
byte[] sendBytes = message.getBytes("UTF-8");
|
||||
//然后将消息的长度优先发送出去
|
||||
outputStream.write(sendBytes.length >>8);
|
||||
outputStream.write(sendBytes.length);
|
||||
//然后将消息再次发送出去
|
||||
outputStream.write(sendBytes);
|
||||
outputStream.flush();
|
||||
socket.shutdownOutput();
|
||||
|
||||
InputStream inputStream = socket.getInputStream();
|
||||
byte[] bytes = new byte[1024];
|
||||
int len;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while ((len = inputStream.read(bytes)) != -1) {
|
||||
// 注意指定编码格式,发送方和接收方一定要统一,建议使用UTF-8
|
||||
sb.append(new String(bytes, 0, len, "UTF-8"));
|
||||
}
|
||||
System.out.println(sb);
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
socket.close();
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.ics.common.config;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @description 服务端socket
|
||||
* @date 2019/7/30 14:57
|
||||
*/
|
||||
@Service
|
||||
public class SocketServer {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
// @Value("${port}")
|
||||
private Integer port;
|
||||
private boolean started;
|
||||
private ServerSocket serverSocket;
|
||||
//使用多线程,需要线程池,防止并发过高时创建过多线程耗尽资源
|
||||
private ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||
|
||||
public void start(){
|
||||
start(8090);
|
||||
}
|
||||
private void start(Integer port){
|
||||
try {
|
||||
serverSocket = new ServerSocket(port == null ? this.port : port);
|
||||
started = true;
|
||||
logger.info("Socket服务已启动,占用端口: {}", serverSocket.getLocalSocketAddress());
|
||||
}catch (IOException e){
|
||||
logger.error("端口异常信息",e);
|
||||
System.exit(0);
|
||||
}
|
||||
while (started){
|
||||
try {
|
||||
Socket socket = serverSocket.accept();
|
||||
Runnable runnable = () -> {
|
||||
try {
|
||||
//接收客户端数据
|
||||
StringBuilder xmlString = onMessage(socket);
|
||||
logger.info("接收到客户端数据:{}",xmlString);
|
||||
//处理逻辑:xmlStringToEsb为处理结果
|
||||
//返回给客户端
|
||||
sendMessage(socket,"true");
|
||||
socket.close();
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
//接收线程返回结果
|
||||
Future future = threadPool.submit(runnable);
|
||||
logger.info(future.isDone()+"--------");
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
private static StringBuilder onMessage(Socket socket){
|
||||
byte[] bytes = new byte[1024];
|
||||
int len;
|
||||
try{
|
||||
// 建立好连接后,从socket中获取输入流,并建立缓冲区进行读取
|
||||
InputStream inputStream = socket.getInputStream();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while ((len = inputStream.read(bytes)) != -1) {
|
||||
// 注意指定编码格式,发送方和接收方一定要统一,建议使用UTF-8
|
||||
sb.append(new String(bytes, 0, len, "UTF-8"));
|
||||
}
|
||||
//此处,需要关闭服务器的输出流,但不能使用inputStream.close().
|
||||
socket.shutdownInput();
|
||||
return sb;
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static void sendMessage(Socket socket,String message){
|
||||
try {
|
||||
//向客户端返回数据
|
||||
OutputStream outputStream = socket.getOutputStream();
|
||||
//首先需要计算得知消息的长度
|
||||
byte[] sendBytes = message.getBytes("UTF-8");
|
||||
//然后将消息的长度优先发送出去
|
||||
outputStream.write(sendBytes.length >> 8);
|
||||
outputStream.write(sendBytes.length);
|
||||
//然后将消息再次发送出去
|
||||
outputStream.write(sendBytes);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.ics.common.config;
|
||||
|
||||
|
||||
import com.ics.common.handlers.HttpAuthHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
||||
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableWebSocket
|
||||
public class WebsocketConfig implements WebSocketConfigurer {
|
||||
|
||||
@Autowired
|
||||
private HttpAuthHandler httpAuthHandler;
|
||||
@Autowired
|
||||
private MyInterceptor myInterceptor;
|
||||
|
||||
@Override
|
||||
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
||||
registry
|
||||
.addHandler(httpAuthHandler, "myWS")
|
||||
.addInterceptors(myInterceptor)
|
||||
.setAllowedOrigins("*");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,66 @@
|
||||
package com.ics.common.config;
|
||||
|
||||
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class WsSessionManager {
|
||||
/**
|
||||
* 保存连接 session 的地方
|
||||
*/
|
||||
private static ConcurrentHashMap<String, WebSocketSession> SESSION_POOL = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 添加 session
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public static void add(String key, WebSocketSession session) {
|
||||
// 添加 session
|
||||
SESSION_POOL.put(key, session);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 session,会返回删除的 session
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static WebSocketSession remove(String key) {
|
||||
// 删除 session
|
||||
return SESSION_POOL.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除并同步关闭连接
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public static void removeAndClose(String key) {
|
||||
WebSocketSession session = remove(key);
|
||||
if (session != null) {
|
||||
try {
|
||||
// 关闭连接
|
||||
session.close();
|
||||
} catch (IOException e) {
|
||||
// todo: 关闭出现异常处理
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得 session
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static WebSocketSession get(String key) {
|
||||
// 获得 session
|
||||
return SESSION_POOL.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
package com.ics.common.handlers;
|
||||
|
||||
import com.ics.common.config.WsSessionManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Component
|
||||
public class HttpAuthHandler extends TextWebSocketHandler {
|
||||
|
||||
/**
|
||||
* socket 建立成功事件
|
||||
*
|
||||
* @param session
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
Object sessionId = session.getAttributes().get("session_id");
|
||||
if (sessionId != null) {
|
||||
// 用户连接成功,放入在线用户缓存
|
||||
WsSessionManager.add(sessionId.toString(), session);
|
||||
} else {
|
||||
throw new RuntimeException("用户登录已经失效!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收消息事件
|
||||
*
|
||||
* @param session
|
||||
* @param message
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
||||
// 获得客户端传来的消息
|
||||
String payload = message.getPayload();
|
||||
Object sessionId = session.getAttributes().get("session_id");
|
||||
System.out.println("server 接收到 " + sessionId + " 发送的 " + payload);
|
||||
session.sendMessage(new TextMessage("server 发送给 " + sessionId + " 消息 " + payload + " " + LocalDateTime.now().toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* socket 断开连接时
|
||||
*
|
||||
* @param session
|
||||
* @param status
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
||||
Object sessionId = session.getAttributes().get("session_id");
|
||||
if (sessionId != null) {
|
||||
// 用户退出,移除缓存
|
||||
WsSessionManager.remove(sessionId.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class MyParkLineHandler implements TenantLineHandler {
|
||||
"sys_job", "sys_job_log", "sys_login_info", "sys_menu", "sys_notice", "sys_oper_log", "sys_oss", "sys_role", "sys_role_dept", "sys_role_menu",
|
||||
"sys_sn", "sys_user_role", "sys_dept", "ics_customer_contract_room", "ics_park", "ics_apply_room", "ics_customer_contract_refund_room", "ics_apply_park_file",
|
||||
"ics_apply_settle_file", "ics_apply_move_in_file", "ics_activity","ics_customer_staff","tb_customer_ticket","tb_reservation","tb_reservation_person",
|
||||
"tb_room_content","tb_room_item","tb_room_item_by_room","tb_room_serve_by_room","tb_room_serve","tb_equipment",
|
||||
"tb_room_content","tb_room_item","tb_room_item_by_room","tb_room_serve_by_room","tb_room_serve","tb_equipment","tb_staff_customer",
|
||||
"tb_room_equipment","tb_room_record","tb_room_serve","tb_showroom","tb_showroom_record","tb_ticket","tb_user_equipment","tb_visitor_person"
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class MyTenantLineHandler implements TenantLineHandler {
|
||||
"sys_job", "sys_job_log", "sys_login_info", "sys_menu", "sys_notice", "sys_oper_log", "sys_oss", "sys_role_dept", "sys_role_menu",
|
||||
"sys_sn", "sys_user_role", "ics_customer_contract_room", "ics_apply_room", "ics_customer_contract_refund_room", "ics_apply_park_file",
|
||||
"ics_apply_settle_file", "ics_apply_move_in_file", "ics_activity","ics_customer_staff","tb_customer_ticket","tb_reservation","tb_reservation_person",
|
||||
"tb_room_content","tb_room_item","tb_room_item_by_room","tb_room_serve_by_room","tb_room_serve","tb_equipment",
|
||||
"tb_room_content","tb_room_item","tb_room_item_by_room","tb_room_serve_by_room","tb_room_serve","tb_equipment","tb_staff_customer",
|
||||
"tb_room_equipment","tb_room_record","tb_room_serve","tb_showroom","tb_showroom_record","tb_ticket","tb_user_equipment","tb_visitor_person"
|
||||
};
|
||||
|
||||
|
@ -1,8 +1,13 @@
|
||||
package com.ics;
|
||||
|
||||
import com.ics.common.config.SocketServer;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.wf.jwtp.configuration.EnableJwtPermission;
|
||||
|
||||
/**
|
||||
@ -15,4 +20,6 @@ public class ApplicationRun {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ApplicationRun.class, args);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -65,14 +65,14 @@ public class SmallWxOkHttp {
|
||||
/**
|
||||
* 获取AccessToken
|
||||
*/
|
||||
public static String getAccessToken(){
|
||||
public static String getAccessToken(String appId, String secret){
|
||||
// url
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
// 参数
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("grant_type", "client_credential");
|
||||
map.put("appid", APP_ID);
|
||||
map.put("secret", SECRET);
|
||||
map.put("appid", appId);
|
||||
map.put("secret", secret);
|
||||
// 发送请求
|
||||
JSONObject jsonObject = sendGet(url, map);
|
||||
String accessToken = jsonObject.getString("access_token");
|
||||
@ -83,13 +83,13 @@ public class SmallWxOkHttp {
|
||||
/**
|
||||
* 小程序登录
|
||||
*/
|
||||
public static JSONObject code2Session(String jsCode){
|
||||
public static JSONObject code2Session(String jsCode,String appId,String secret){
|
||||
// url
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session";
|
||||
// 参数
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("appid", APP_ID);
|
||||
map.put("secret", SECRET);
|
||||
map.put("appid", appId);
|
||||
map.put("secret", secret);
|
||||
map.put("js_code", jsCode);
|
||||
map.put("grant_type", "authorization_code");
|
||||
// 发送请求
|
||||
|
@ -95,12 +95,14 @@ public class WxLoginAPIController extends BaseController {
|
||||
public R login(@RequestBody Map<String, String> paramMap) {
|
||||
// 参数
|
||||
String jsCode = paramMap.get("jsCode");
|
||||
String appId = paramMap.get("appId");
|
||||
String appSecret = paramMap.get("appSecret");
|
||||
// 必填
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(jsCode)) {
|
||||
throw new RuntimeException("请传递jsCode");
|
||||
}
|
||||
// 小程序登录
|
||||
JSONObject sessionObject = SmallWxOkHttp.code2Session(jsCode);
|
||||
JSONObject sessionObject = SmallWxOkHttp.code2Session(jsCode,appId,appSecret);
|
||||
String openid = sessionObject.getString("openid");
|
||||
String unionid = sessionObject.getString("unionid");
|
||||
//
|
||||
@ -123,6 +125,7 @@ public class WxLoginAPIController extends BaseController {
|
||||
// ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("user", sysUser);
|
||||
ajax.put("openid", openid);
|
||||
|
||||
return ajax;
|
||||
} else { // 用户不存在返回openid进行注册登录
|
||||
ajax.put("openid", openid);
|
||||
@ -137,6 +140,8 @@ public class WxLoginAPIController extends BaseController {
|
||||
// 参数
|
||||
String code = paramMap.get("code");
|
||||
String openid = paramMap.get("openid");
|
||||
String appId = paramMap.get("appId");
|
||||
String appSecret = paramMap.get("appSecret");
|
||||
// 必填
|
||||
if (StringUtils.isBlank(code)) {
|
||||
throw new RuntimeException("请传递code");
|
||||
@ -145,7 +150,7 @@ public class WxLoginAPIController extends BaseController {
|
||||
throw new RuntimeException("请传递openid");
|
||||
}
|
||||
// 获取微信小程序 AccessToken
|
||||
String smallWxAccessToken = getSmallWxAccessToken();
|
||||
String smallWxAccessToken = getSmallWxAccessToken(appId,appSecret);
|
||||
// 获取手机号
|
||||
JSONObject jsonObj = SmallWxOkHttp.getPhoneNumber(code, openid, smallWxAccessToken);
|
||||
JSONObject phoneInfo = jsonObj.getJSONObject("phone_info");
|
||||
@ -153,7 +158,8 @@ public class WxLoginAPIController extends BaseController {
|
||||
String phoneNumber = phoneInfo.getString("phoneNumber");
|
||||
IcsCustomerStaff icsCustomerStaff = new IcsCustomerStaff();
|
||||
icsCustomerStaff.setMobile(phoneNumber);
|
||||
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectByPhone(phoneNumber);
|
||||
//todo 需要根据手机号和对应的openId 查询对应的用户。
|
||||
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectByPhoneAndOpenId(phoneNumber,openid);
|
||||
if (customerStaff != null) {
|
||||
if (StringUtils.isBlank(customerStaff.getOpenid())) {
|
||||
// 根据 用户绑定的企业 绑定对应的设备
|
||||
@ -165,9 +171,11 @@ public class WxLoginAPIController extends BaseController {
|
||||
List<Long> collect = roomIds.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
//获取了房间集合,循环对应集合,
|
||||
for (Long id : collect) {
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
@ -207,18 +215,37 @@ public class WxLoginAPIController extends BaseController {
|
||||
return ajax;
|
||||
} else {
|
||||
// 新增用户信息
|
||||
icsCustomerStaff.setUsername(phoneNumber);
|
||||
icsCustomerStaff.setDataType(Constants.CUSTOMER_VISIT);
|
||||
icsCustomerStaff.setOpenid(openid);
|
||||
icsCustomerStaff.setGender("0");
|
||||
icsCustomerStaff.setStatus("0");
|
||||
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
|
||||
Map<String, Object> token = tokenService.createStaffToken(icsCustomerStaff);
|
||||
R ajax = R.ok();
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("user", icsCustomerStaff);
|
||||
ajax.put("openid", openid);
|
||||
return ajax;
|
||||
// todo 现根据手机号查询对应的数据。如果存在则不新增,如果不存在则新增
|
||||
|
||||
IcsCustomerStaff customerStaff1 = icsCustomerStaffService.selectByPhone(phoneNumber);
|
||||
//如果手机号等于null 就新增用户
|
||||
if (null == customerStaff1) {
|
||||
icsCustomerStaff.setUsername(phoneNumber);
|
||||
icsCustomerStaff.setDataType(Constants.CUSTOMER_VISIT);
|
||||
icsCustomerStaff.setOpenid(openid);
|
||||
icsCustomerStaff.setGender("0");
|
||||
icsCustomerStaff.setStatus("0");
|
||||
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
|
||||
Map<String, Object> token = tokenService.createStaffToken(icsCustomerStaff);
|
||||
R ajax = R.ok();
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("user", icsCustomerStaff);
|
||||
ajax.put("openid", openid);
|
||||
return ajax;
|
||||
}else {
|
||||
String openid1 = customerStaff1.getOpenid();
|
||||
customerStaff1.setOpenid(openid1 + ","+openid);
|
||||
icsCustomerStaffService.updateIcsCustomerStaff(customerStaff1);
|
||||
User user = new User();
|
||||
PublishFactory.recordLoginInfo(customerStaff1.getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
BeanUtils.copyBeanProp(user, customerStaff1);
|
||||
Map<String, Object> token = tokenService.createToken(user);
|
||||
R ajax = R.ok();
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("user", user);
|
||||
ajax.put("openid", openid);
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@ -230,11 +257,11 @@ public class WxLoginAPIController extends BaseController {
|
||||
/**
|
||||
* 获取微信小程序AccessToken
|
||||
*/
|
||||
public String getSmallWxAccessToken() {
|
||||
public String getSmallWxAccessToken(String appId, String appSecret) {
|
||||
// 从缓存获取微信小程序 AccessToken
|
||||
String smallWxAccessToken = redisTemplate.opsForValue().get(smallWxAccessTokenKey);
|
||||
if (StringUtils.isBlank(smallWxAccessToken)) {
|
||||
smallWxAccessToken = SmallWxOkHttp.getAccessToken();
|
||||
smallWxAccessToken = SmallWxOkHttp.getAccessToken(appId, appSecret);
|
||||
redisTemplate.opsForValue().set(smallWxAccessTokenKey, smallWxAccessToken, 7200, TimeUnit.SECONDS);
|
||||
}
|
||||
return smallWxAccessToken;
|
||||
@ -242,7 +269,7 @@ public class WxLoginAPIController extends BaseController {
|
||||
|
||||
@RequiresPermissions("member:center:view")
|
||||
@GetMapping("/wx/getUserInfo")
|
||||
public R login(Long userId,Long parkId) {
|
||||
public R login(Long userId, Long parkId) {
|
||||
try {
|
||||
//检查是否是否存在
|
||||
|
||||
@ -251,10 +278,10 @@ public class WxLoginAPIController extends BaseController {
|
||||
StaffCustomer staffCustomer = new StaffCustomer();
|
||||
staffCustomer.setStaffId(userId);
|
||||
List<StaffCustomer> staffCustomers = staffCustomerService.selectStaffCustomerByStaffId(userId);
|
||||
if(CollUtil.isNotEmpty(staffCustomers)){
|
||||
if (CollUtil.isNotEmpty(staffCustomers)) {
|
||||
for (StaffCustomer staffCustomer1 : staffCustomers) {
|
||||
Customer customer = customerService.selectCustomerByIdAndParkId(staffCustomer1.getIcsCustomerId(), parkId);
|
||||
if (null != customer){
|
||||
if (null != customer) {
|
||||
customerStaff.setCustomerName(customer.getName());
|
||||
customerStaff.setIcsCustomerId(customer.getId());
|
||||
break;
|
||||
|
@ -256,9 +256,11 @@ public class ApiRoomContentController extends BaseController {
|
||||
Room room = roomService.selectRoomById(roomContent.getRoomId());
|
||||
if (null != room) {
|
||||
Long id = room.getId();
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
@ -310,9 +312,11 @@ public class ApiRoomContentController extends BaseController {
|
||||
Room room = roomService.selectRoomById(roomContent.getRoomId());
|
||||
if (null != room) {
|
||||
Long id = room.getId();
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
@ -415,12 +419,12 @@ public class ApiRoomContentController extends BaseController {
|
||||
roomContent.setBuildingName(buildingDetail.getFloorName() + "F");
|
||||
}
|
||||
//根据房间id查询设备
|
||||
QueryWrapper<RoomEquipment> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("room_id", room.getId());
|
||||
RoomEquipment roomEquipment = roomEquipmentMapper.selectOne(wrapper);
|
||||
if (roomEquipment != null) {
|
||||
roomContent.setEquipmentId(roomEquipment.getEquipmentId());
|
||||
}
|
||||
// QueryWrapper<RoomEquipment> wrapper = new QueryWrapper<>();
|
||||
// wrapper.eq("room_id", room.getId());
|
||||
// RoomEquipment roomEquipment = roomEquipmentMapper.selectOne(wrapper);
|
||||
// if (roomEquipment != null) {
|
||||
// roomContent.setEquipmentId(roomEquipment.getEquipmentId());
|
||||
// }
|
||||
}
|
||||
reservation.setRoomContent(roomContent);
|
||||
return R.ok().put("data", reservation);
|
||||
@ -481,9 +485,11 @@ public class ApiRoomContentController extends BaseController {
|
||||
Room room = roomService.selectRoomById(roomContent.getRoomId());
|
||||
if (null != room) {
|
||||
Long id = room.getId();
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
@ -574,9 +580,11 @@ public class ApiRoomContentController extends BaseController {
|
||||
Room room = roomService.selectRoomById(roomContent.getRoomId());
|
||||
if (null != room) {
|
||||
Long id = room.getId();
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
|
@ -113,8 +113,10 @@ public class ApiRoomController extends BaseController {
|
||||
*/
|
||||
@Ignore
|
||||
@GetMapping("selectParkList")
|
||||
public R selectParkList() {
|
||||
List<Park> parkList = parkService.selectParkList(new Park());
|
||||
public R selectParkList(Long tenantId) {
|
||||
Park park = new Park();
|
||||
park.setTenantId(tenantId);
|
||||
List<Park> parkList = parkService.selectParkList(park);
|
||||
return R.data(parkList);
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public class ApiVisitorController extends BaseController {
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
|
||||
IPage<VisitorPerson> visitorPersons = visitorPersonService.selectVisitorRecordByIntervieweeId(visitorPerson1.getIntervieweeId(), pageNum, pageSize);
|
||||
IPage<VisitorPerson> visitorPersons = visitorPersonService.selectVisitorRecordByIntervieweeId(visitorPerson1.getIntervieweeId(),visitorPerson1.getParkId(), pageNum, pageSize);
|
||||
for (VisitorPerson visitorPerson : visitorPersons.getRecords()) {
|
||||
if (visitorPerson.getStatus() == 0) {
|
||||
visitorPerson.setStatusName("待审核");
|
||||
@ -228,9 +228,11 @@ public class ApiVisitorController extends BaseController {
|
||||
List<Long> collect = roomIds.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
//获取了房间集合,循环对应集合,
|
||||
for (Long id : collect) {
|
||||
RoomEquipment roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (null != roomEquipment) {
|
||||
ids.add(roomEquipment.getEquipmentId());
|
||||
List<RoomEquipment> roomEquipment = roomEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(roomEquipment)) {
|
||||
for (RoomEquipment equipment : roomEquipment) {
|
||||
ids.add(equipment.getEquipmentId());
|
||||
}
|
||||
}
|
||||
List<DetailEquipment> detailEquipments = detailEquipmentService.selectByRoomId(id);
|
||||
if (CollUtil.isNotEmpty(detailEquipments)) {
|
||||
@ -299,16 +301,16 @@ public class ApiVisitorController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 访客邀请记录
|
||||
* 会议邀请记录
|
||||
*/
|
||||
@RequiresPermissions("member:center:view")
|
||||
@GetMapping("selectVisitorInvitationRecord/{userId}")
|
||||
public R selectVisitorInvitationRecord(@PathVariable("userId") Long userId) {
|
||||
public R selectVisitorInvitationRecord(@PathVariable("userId") Long userId,Long parkId) {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
|
||||
IPage<Reservation> list = reservationPersonService.selectListByParticipantId(userId, pageNum, pageSize);
|
||||
System.out.println(parkId);
|
||||
IPage<Reservation> list = reservationPersonService.selectListByParticipantId(userId,parkId, pageNum, pageSize);
|
||||
return R.ok().put("page", list);
|
||||
}
|
||||
|
||||
|
5
pom.xml
5
pom.xml
@ -83,6 +83,11 @@
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user