新增了两个openId的问题,修改了服务预约记录的功能

This commit is contained in:
chendaze 2024-07-03 17:38:31 +08:00
parent 7abb49419b
commit 52cdfdfe21
35 changed files with 1420 additions and 271 deletions

View File

@ -180,6 +180,43 @@ public class CustomerStaffController extends BaseController {
//如果没有注册小程序的话 //如果没有注册小程序的话
//如果是上海的小程序
Long icsCustomerId = icsCustomerStaff.getIcsCustomerId();
Customer customer1 = customerService.selectCustomerById(icsCustomerId);
if (customer1.getParkId() == 26){
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectUserByMobile(icsCustomerStaff.getMobile());
if (customerStaff != null){
int i = icsCustomerStaffService.updateIcsCustomerStaff(icsCustomerStaff);
StaffCustomer staffCustomer = new StaffCustomer();
staffCustomer.setIcsCustomerId(icsCustomerStaff.getIcsCustomerId());
staffCustomer.setStaffId(customerStaff.getId());
List<StaffCustomer> staffCustomers = staffCustomerService.selectStaffCustomerList(staffCustomer);
if (staffCustomers.size() == 0) {
staffCustomerService.insertStaffCustomer(staffCustomer);
}
return toAjax(i);
}else {
icsCustomerStaff.setDataType("1");
icsCustomerStaff.setParkId(customer1.getParkId());
icsCustomerStaff.setTenantId(customer1.getTenantId());
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
Assert.isTrue(i > 0, "添加失败");
//新增用户和企业 id
StaffCustomer staffCustomer = new StaffCustomer();
staffCustomer.setIcsCustomerId(icsCustomerStaff.getIcsCustomerId());
staffCustomer.setStaffId(icsCustomerStaff.getId());
staffCustomer.setParkId(customer1.getParkId());
staffCustomer.setTenantId(customer1.getTenantId());
staffCustomerService.insertStaffCustomer(staffCustomer);
return toAjax(i);
}
}
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectUserByMobile(icsCustomerStaff.getMobile()); IcsCustomerStaff customerStaff = icsCustomerStaffService.selectUserByMobile(icsCustomerStaff.getMobile());
if (customerStaff != null) { if (customerStaff != null) {
if (icsCustomerStaff.getId() == null) { if (icsCustomerStaff.getId() == null) {
@ -271,6 +308,7 @@ public class CustomerStaffController extends BaseController {
//根据设备id获取设备 //根据设备id获取设备
Equipment equipment = equipmentService.selectEquipmentById(detailEquipment.getEquipmentId()); Equipment equipment = equipmentService.selectEquipmentById(detailEquipment.getEquipmentId());
if (equipment != null) { if (equipment != null) {
if (equipment.getType() == 0){
String persons = DeviceUtils.queryPersons(equipment.getIp(), String.valueOf(customerStaff.getId())); String persons = DeviceUtils.queryPersons(equipment.getIp(), String.valueOf(customerStaff.getId()));
JSONObject jsonObject = JSONUtil.parseObj(persons); JSONObject jsonObject = JSONUtil.parseObj(persons);
Integer amount = (Integer) jsonObject.get("amount"); Integer amount = (Integer) jsonObject.get("amount");
@ -314,6 +352,8 @@ public class CustomerStaffController extends BaseController {
} }
} }
} }
}
} }
@ -323,6 +363,7 @@ public class CustomerStaffController extends BaseController {
//根据设备id获取设备 //根据设备id获取设备
Equipment equipment = equipmentService.selectEquipmentById(roomEquipment.getEquipmentId()); Equipment equipment = equipmentService.selectEquipmentById(roomEquipment.getEquipmentId());
if (equipment != null) { if (equipment != null) {
if (equipment.getType() == 0){
String persons = DeviceUtils.queryPersons(equipment.getIp(), String.valueOf(customerStaff.getId())); String persons = DeviceUtils.queryPersons(equipment.getIp(), String.valueOf(customerStaff.getId()));
JSONObject jsonObject = JSONUtil.parseObj(persons); JSONObject jsonObject = JSONUtil.parseObj(persons);
Integer amount = (Integer) jsonObject.get("amount"); Integer amount = (Integer) jsonObject.get("amount");
@ -366,9 +407,13 @@ public class CustomerStaffController extends BaseController {
} }
} }
} }
} }
} }
} }
}
customerStaff.setParkId(customer1.getParkId());
customerStaff.setTenantId(customer1.getTenantId());
int i = icsCustomerStaffService.updateIcsCustomerStaff(customerStaff); int i = icsCustomerStaffService.updateIcsCustomerStaff(customerStaff);
Assert.isTrue(i > 0, "更新失败"); Assert.isTrue(i > 0, "更新失败");
@ -382,13 +427,21 @@ public class CustomerStaffController extends BaseController {
return toAjax(i); return toAjax(i);
} }
Customer customer = customerService.selectCustomerById(icsCustomerStaff.getIcsCustomerId());
if (null != customer){
icsCustomerStaff.setParkId(customer.getParkId());
icsCustomerStaff.setTenantId(customer.getTenantId());
}
icsCustomerStaff.setDataType("1"); icsCustomerStaff.setDataType("1");
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff); int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
Assert.isTrue(i > 0, "添加失败"); Assert.isTrue(i > 0, "添加失败");
//新增用户和企业 id //新增用户和企业 id
StaffCustomer staffCustomer = new StaffCustomer(); StaffCustomer staffCustomer = new StaffCustomer();
staffCustomer.setIcsCustomerId(icsCustomerStaff.getIcsCustomerId()); staffCustomer.setIcsCustomerId(icsCustomerStaff.getIcsCustomerId());
staffCustomer.setStaffId(icsCustomerStaff.getStaffId()); staffCustomer.setStaffId(customerStaff.getStaffId());
staffCustomer.setParkId(customer.getParkId());
staffCustomer.setTenantId(customer.getTenantId());
staffCustomerService.insertStaffCustomer(staffCustomer); staffCustomerService.insertStaffCustomer(staffCustomer);
return toAjax(i); return toAjax(i);
@ -450,10 +503,12 @@ public class CustomerStaffController extends BaseController {
//删除设备的用户 //删除设备的用户
Equipment equipment = equipmentService.selectEquipmentById(id); Equipment equipment = equipmentService.selectEquipmentById(id);
if (equipment != null) { if (equipment != null) {
if (equipment.getType() == 0){
DeviceUtils.deletePersons(equipment.getIp(), icsCustomerStaff.getId()); DeviceUtils.deletePersons(equipment.getIp(), icsCustomerStaff.getId());
} }
} }
} }
}
return toAjax(i); return toAjax(i);
} }
@ -664,8 +719,10 @@ public class CustomerStaffController extends BaseController {
if (userEquipment != null){ if (userEquipment != null){
Equipment equipment1 = equipmentService.selectEquipmentById(id); Equipment equipment1 = equipmentService.selectEquipmentById(id);
if (equipment1 != null) { if (equipment1 != null) {
if (equipment1.getType() == 0){
DeviceUtils.deletePersons(equipment1.getIp(), equipment.getUserId()); DeviceUtils.deletePersons(equipment1.getIp(), equipment.getUserId());
} }
}
int count = userEquipmentService.deleteUserEquipmentByUserId(equipment.getUserId(), id); int count = userEquipmentService.deleteUserEquipmentByUserId(equipment.getUserId(), id);
Assert.isTrue(count > 0, "删除失败"); Assert.isTrue(count > 0, "删除失败");
}else { }else {
@ -674,17 +731,24 @@ public class CustomerStaffController extends BaseController {
userEquipment1.setUserId(equipment.getUserId()); userEquipment1.setUserId(equipment.getUserId());
IcsCustomerStaff customerStaff1 = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId()); IcsCustomerStaff customerStaff1 = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId());
if (null != customerStaff1) { if (null != customerStaff1) {
Customer customer = customerService.selectCustomerById(customerStaff1.getId()); List<StaffCustomer> staffCustomers = staffCustomerService.selectStaffCustomerByStaffId(customerStaff1.getId());
if (CollUtil.isNotEmpty(staffCustomers)) {
StaffCustomer staffCustomer = staffCustomers.get(0);
Customer customer = customerService.selectCustomerById(staffCustomer.getIcsCustomerId());
if (customer != null) { if (customer != null) {
userEquipment1.setStartTime(customer.getStartDate()); userEquipment1.setStartTime(customer.getStartDate());
userEquipment1.setEndDate(customer.getEndDate()); userEquipment1.setEndDate(customer.getEndDate());
} }
} }
userEquipmentService.insertUserEquipment(userEquipment1);
}
userEquipmentService.insertUserEquipment(userEquipment1);
// //新增人脸 // //新增人脸
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId()); IcsCustomerStaff customerStaff = icsCustomerStaffService.selectIcsCustomerStaffById(equipment.getUserId());
Equipment equipment2 = equipmentService.selectEquipmentById(id);
if (equipment2 != null) {
if (equipment2.getType() == 0){
DevicePersonDto devicePersonDto = new DevicePersonDto(); DevicePersonDto devicePersonDto = new DevicePersonDto();
ArrayList<FacesDto> facesDtos = new ArrayList<>(); ArrayList<FacesDto> facesDtos = new ArrayList<>();
devicePersonDto.setPersonId(String.valueOf(customerStaff.getId())); devicePersonDto.setPersonId(String.valueOf(customerStaff.getId()));
@ -708,6 +772,9 @@ public class CustomerStaffController extends BaseController {
String s = DeviceUtils.addPersons(equipment1.getIp(), devicePersonDto); String s = DeviceUtils.addPersons(equipment1.getIp(), devicePersonDto);
log.info("添加人员返回结果:" + s); log.info("添加人员返回结果:" + s);
} }
}
}
} }
} }

View File

@ -207,7 +207,7 @@ public class EquipmentController extends BaseController {
Assert.isTrue(i > 0, "添加失败"); Assert.isTrue(i > 0, "添加失败");
boolean ipv4 = Validator.isIpv4(equipment.getIp()); boolean ipv4 = Validator.isIpv4(equipment.getIp());
Assert.isTrue(!ipv4, "IP不合法"); Assert.isTrue(ipv4, "IP不合法");
boolean ping = DeviceUtils.ping(equipment.getIp()); boolean ping = DeviceUtils.ping(equipment.getIp());

View File

@ -0,0 +1,76 @@
package com.ics.admin.controller.meeting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ics.common.core.domain.R;
import com.ics.common.core.controller.BaseController;
import com.ics.admin.domain.meeting.ReservationServe;
import com.ics.admin.service.meeting.IReservationServeService;
import org.wf.jwtp.annotation.RequiresPermissions;
/**
* 预约服务关联 提供者
*
* @author chen
* @date 2024-06-26
*/
@RestController
@RequestMapping("serve")
public class ReservationServeController extends BaseController {
@Autowired
private IReservationServeService reservationServeService;
/**
* 查询预约服务关联
*/
@GetMapping("get/{id}")
public ReservationServe get(@PathVariable("id") Long id) {
return reservationServeService.selectReservationServeById(id);
}
/**
* 查询预约服务关联列表
*/
@RequiresPermissions("meeting:serve:list")
@GetMapping("list")
public R list(ReservationServe reservationServe) {
startPage();
return result(reservationServeService.selectReservationServeList(reservationServe));
}
/**
* 新增保存预约服务关联
*/
@RequiresPermissions("meeting:serve:add")
@PostMapping("save")
public R addSave(@RequestBody ReservationServe reservationServe) {
return toAjax(reservationServeService.insertReservationServe(reservationServe));
}
/**
* 修改保存预约服务关联
*/
@RequiresPermissions("meeting:serve:edit")
@PostMapping("update")
public R editSave(@RequestBody ReservationServe reservationServe) {
return toAjax(reservationServeService.updateReservationServe(reservationServe));
}
/**
* 删除预约服务关联
*/
@RequiresPermissions("meeting:serve:remove")
@PostMapping("remove")
public R remove(String ids) {
return toAjax(reservationServeService.deleteReservationServeByIds(ids));
}
}

View File

@ -274,6 +274,7 @@ public class RoomContentController extends BaseController {
List<Room> rooms = roomService.selectRoomList(room); List<Room> rooms = roomService.selectRoomList(room);
if (StrUtil.isNotBlank(room.getCustomerId())){
String customerId = room.getCustomerId(); String customerId = room.getCustomerId();
Customer customer = customerService.selectCustomerById(Long.valueOf(customerId)); Customer customer = customerService.selectCustomerById(Long.valueOf(customerId));
String roomId = customer.getRoomId(); String roomId = customer.getRoomId();
@ -289,6 +290,8 @@ public class RoomContentController extends BaseController {
} }
} }
}
return R.ok().put("data",rooms); return R.ok().put("data",rooms);
} }

View File

@ -0,0 +1,76 @@
package com.ics.admin.controller.meeting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ics.common.core.domain.R;
import com.ics.common.core.controller.BaseController;
import com.ics.admin.domain.meeting.StaffOpen;
import com.ics.admin.service.meeting.IStaffOpenService;
import org.wf.jwtp.annotation.RequiresPermissions;
/**
* 用户和小程序关联 提供者
*
* @author ics
* @date 2024-06-25
*/
@RestController
@RequestMapping("open")
public class StaffOpenController extends BaseController {
@Autowired
private IStaffOpenService staffOpenService;
/**
* 查询用户和小程序关联
*/
@GetMapping("get/{id}")
public StaffOpen get(@PathVariable("id") Long id) {
return staffOpenService.selectStaffOpenById(id);
}
/**
* 查询用户和小程序关联列表
*/
@RequiresPermissions("meeting:open:list")
@GetMapping("list")
public R list(StaffOpen staffOpen) {
startPage();
return result(staffOpenService.selectStaffOpenList(staffOpen));
}
/**
* 新增保存用户和小程序关联
*/
@RequiresPermissions("meeting:open:add")
@PostMapping("save")
public R addSave(@RequestBody StaffOpen staffOpen) {
return toAjax(staffOpenService.insertStaffOpen(staffOpen));
}
/**
* 修改保存用户和小程序关联
*/
@RequiresPermissions("meeting:open:edit")
@PostMapping("update")
public R editSave(@RequestBody StaffOpen staffOpen) {
return toAjax(staffOpenService.updateStaffOpen(staffOpen));
}
/**
* 删除用户和小程序关联
*/
@RequiresPermissions("meeting:open:remove")
@PostMapping("remove")
public R remove(String ids) {
return toAjax(staffOpenService.deleteStaffOpenByIds(ids));
}
}

View File

@ -0,0 +1,10 @@
package com.ics.admin.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
@AllArgsConstructor
@Data
public class TemplateData {
private String value;
}

View File

@ -0,0 +1,15 @@
package com.ics.admin.domain;
import lombok.Data;
import java.util.Map;
@Data
public class WxMssVO {
private String touser;//用户openid
private String template_id;//订阅消息模版id
private String page = "pages/index/index";//默认跳到小程序首页
private Map<String, TemplateData> data;//推送文字
}

View File

@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.ics.common.core.domain.BaseEntity; import com.ics.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 预约记录对象 tb_reservation * 预约记录对象 tb_reservation
@ -34,6 +35,8 @@ public class Reservation extends BaseEntity<Reservation> {
/** 优惠卷id */ /** 优惠卷id */
private Long ticketId; private Long ticketId;
private Integer personNum;
@TableField(exist = false) @TableField(exist = false)
private String ticketName; private String ticketName;
@ -52,6 +55,10 @@ public class Reservation extends BaseEntity<Reservation> {
@TableField(exist = false) @TableField(exist = false)
private Integer statusValue; private Integer statusValue;
@TableField(exist = false)
private List<ReservationServe> reservationServes;
/** 预约状态 0待支付1.已预约2.进行中3已结束4.已取消 */ /** 预约状态 0待支付1.已预约2.进行中3已结束4.已取消 */
private Status stauts; private Status stauts;
public enum Status implements IEnum<Integer> { public enum Status implements IEnum<Integer> {
@ -189,4 +196,10 @@ public class Reservation extends BaseEntity<Reservation> {
@TableField(exist = false) @TableField(exist = false)
private String buildName; private String buildName;
private String createBy;
private Date createTime;
} }

View File

@ -0,0 +1,34 @@
package com.ics.admin.domain.meeting;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ics.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 预约服务关联对象 tb_reservation_serve
*
* @author chen
* @date 2024-06-26
*/
@Data
@TableName("tb_reservation_serve")
public class ReservationServe extends BaseEntity<ReservationServe> {
private static final long serialVersionUID = 1L;
/** 服务id */
private Long serveId;
/** 预约记录id */
private Long reservationId;
/** 数量 */
private Integer num;
/** 园区ID */
private Long parkId;
@TableField(exist = false)
private String serveName;
}

View File

@ -0,0 +1,27 @@
package com.ics.admin.domain.meeting;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ics.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 用户和小程序关联对象 tb_staff_open
*
* @author ics
* @date 2024-06-25
*/
@Data
@TableName("tb_staff_open")
public class StaffOpen extends BaseEntity<StaffOpen> {
private static final long serialVersionUID = 1L;
/** 企业id */
private String openid;
/** 用户id */
private Long staffId;
/** 园区ID */
private Long parkId;
}

View File

@ -77,4 +77,6 @@ public interface IcsCustomerStaffMapper extends BaseMapper<IcsCustomerStaff> {
List<IcsCustomerStaff> getUserList(IcsCustomerStaff customerStaff); List<IcsCustomerStaff> getUserList(IcsCustomerStaff customerStaff);
IcsCustomerStaff selectUserByMobileAndParkId(@Param("mobile") String phoneNumber, @Param("parkId") String parkId);
} }

View File

@ -0,0 +1,64 @@
package com.ics.admin.mapper.meeting;
import com.ics.admin.domain.meeting.ReservationServe;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 预约服务关联Mapper接口
*
* @author chen
* @date 2024-06-26
*/
@Mapper
public interface ReservationServeMapper extends BaseMapper<ReservationServe> {
/**
* 查询预约服务关联
*
* @param id 预约服务关联ID
* @return 预约服务关联
*/
ReservationServe selectReservationServeById(Long id);
/**
* 查询预约服务关联列表
*
* @param reservationServe 预约服务关联
* @return 预约服务关联集合
*/
List<ReservationServe> selectReservationServeList(ReservationServe reservationServe);
/**
* 新增预约服务关联
*
* @param reservationServe 预约服务关联
* @return 结果
*/
int insertReservationServe(ReservationServe reservationServe);
/**
* 修改预约服务关联
*
* @param reservationServe 预约服务关联
* @return 结果
*/
int updateReservationServe(ReservationServe reservationServe);
/**
* 删除预约服务关联
*
* @param id 预约服务关联ID
* @return 结果
*/
int deleteReservationServeById(Long id);
/**
* 批量删除预约服务关联
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteReservationServeByIds(String[] ids);
}

View File

@ -3,6 +3,7 @@ package com.ics.admin.mapper.meeting;
import com.ics.admin.domain.meeting.StaffCustomer; import com.ics.admin.domain.meeting.StaffCustomer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -63,4 +64,6 @@ public interface StaffCustomerMapper extends BaseMapper<StaffCustomer> {
int deleteStaffCustomerByIds(String[] ids); int deleteStaffCustomerByIds(String[] ids);
List<StaffCustomer> selectStaffCustomerByStaffId(Long id); List<StaffCustomer> selectStaffCustomerByStaffId(Long id);
List<StaffCustomer> selectStaffCustomerByStaffIdAndParkId(@Param("staffId") Long id,@Param("parkId") String parkId);
} }

View File

@ -0,0 +1,70 @@
package com.ics.admin.mapper.meeting;
import com.ics.admin.domain.meeting.StaffOpen;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 用户和小程序关联Mapper接口
*
* @author ics
* @date 2024-06-25
*/
@Mapper
public interface StaffOpenMapper extends BaseMapper<StaffOpen> {
/**
* 查询用户和小程序关联
*
* @param id 用户和小程序关联ID
* @return 用户和小程序关联
*/
StaffOpen selectStaffOpenById(Long id);
/**
* 查询用户和小程序关联列表
*
* @param staffOpen 用户和小程序关联
* @return 用户和小程序关联集合
*/
List<StaffOpen> selectStaffOpenList(StaffOpen staffOpen);
/**
* 新增用户和小程序关联
*
* @param staffOpen 用户和小程序关联
* @return 结果
*/
int insertStaffOpen(StaffOpen staffOpen);
/**
* 修改用户和小程序关联
*
* @param staffOpen 用户和小程序关联
* @return 结果
*/
int updateStaffOpen(StaffOpen staffOpen);
/**
* 删除用户和小程序关联
*
* @param id 用户和小程序关联ID
* @return 结果
*/
int deleteStaffOpenById(Long id);
/**
* 批量删除用户和小程序关联
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteStaffOpenByIds(String[] ids);
StaffOpen selectStaffOpenByOpenId(String openid);
StaffOpen selectStaffOpenByStaffIdAndOpenId(@Param("staffId") Long id,@Param("openid") String openId);
}

View File

@ -89,4 +89,6 @@ public interface IIcsCustomerStaffService extends IService<IcsCustomerStaff> {
IcsCustomerStaff selectByPhoneAndOpenId(String phoneNumber, String openid); IcsCustomerStaff selectByPhoneAndOpenId(String phoneNumber, String openid);
IcsCustomerStaff selectUserByMobile(String phone); IcsCustomerStaff selectUserByMobile(String phone);
// IcsCustomerStaff selectUserByMobileAndParkId(String phoneNumber, String parkId);
} }

View File

@ -293,6 +293,8 @@ public class IcsCustomerStaffServiceImpl extends ServiceImpl<IcsCustomerStaffMap
return icsCustomerStaffMapper.selectUserByMobile(phone); return icsCustomerStaffMapper.selectUserByMobile(phone);
} }
//根据企业查询对应的设备 //根据企业查询对应的设备
public void queryDeviceByCustomerId(Long customerId,Long userId){ public void queryDeviceByCustomerId(Long customerId,Long userId){
ArrayList<Long> ids = new ArrayList<>(); ArrayList<Long> ids = new ArrayList<>();

View File

@ -0,0 +1,101 @@
package com.ics.admin.service.impl.meeting;
import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ics.admin.mapper.meeting.ReservationServeMapper;
import com.ics.admin.domain.meeting.ReservationServe;
import com.ics.admin.service.meeting.IReservationServeService;
/**
* 预约服务关联Service业务层处理
*
* @author chen
* @date 2024-06-26
*/
@Service
public class ReservationServeServiceImpl extends ServiceImpl<ReservationServeMapper, ReservationServe> implements IReservationServeService {
@Autowired
private ReservationServeMapper reservationServeMapper;
/**
* 查询预约服务关联
*
* @param id 预约服务关联ID
* @return 预约服务关联
*/
@Override
public ReservationServe selectReservationServeById(Long id) {
return reservationServeMapper.selectById(id);
}
/**
* 查询预约服务关联列表
*
* @param reservationServe 预约服务关联
* @return 预约服务关联
*/
@Override
public List<ReservationServe> selectReservationServeList(ReservationServe reservationServe) {
QueryWrapper queryWrapper = new QueryWrapper();
return reservationServeMapper.selectList(queryWrapper);
}
/**
* 新增预约服务关联
*
* @param reservationServe 预约服务关联
* @return 结果
*/
@Override
public int insertReservationServe(ReservationServe reservationServe) {
return reservationServeMapper.insert(reservationServe);
}
/**
* 修改预约服务关联
*
* @param reservationServe 预约服务关联
* @return 结果
*/
@Override
public int updateReservationServe(ReservationServe reservationServe) {
return reservationServeMapper.updateById(reservationServe);
}
/**
* 删除预约服务关联对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteReservationServeByIds(String ids) {
String[] idsArray = StrUtil.split(ids,",");
return reservationServeMapper.deleteBatchIds(CollUtil.toList(idsArray));
}
/**
* 删除预约服务关联信息
*
* @param id 预约服务关联ID
* @return 结果
*/
@Override
public int deleteReservationServeById(Long id) {
return reservationServeMapper.deleteReservationServeById(id);
}
@Override
public List<ReservationServe> selectReservationServeByReservationId(Long id) {
QueryWrapper<ReservationServe> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("reservation_id",id);
return reservationServeMapper.selectList(queryWrapper);
}
}

View File

@ -343,6 +343,13 @@ public class RoomContentServiceImpl extends ServiceImpl<RoomContentMapper, RoomC
for (Reservation reservation1 : reservation) { for (Reservation reservation1 : reservation) {
reservation1.setStatusValue(reservation1.getStauts().getValue()); reservation1.setStatusValue(reservation1.getStauts().getValue());
reservation1.setStatusName(reservation1.getStauts().getName()); reservation1.setStatusName(reservation1.getStauts().getName());
Long userId = reservation1.getUserId();
IcsCustomerStaff customerStaff = staffService.selectIcsCustomerStaffById(userId);
if (null != customerStaff){
reservation1.setUserName(customerStaff.getUsername());
reservation1.setPhone(customerStaff.getMobile());
}
} }
reservationDTO.setReservations(reservation); reservationDTO.setReservations(reservation);
list.add(reservationDTO); list.add(reservationDTO);

View File

@ -43,6 +43,7 @@ public class RoomItemByRoomServiceImpl extends ServiceImpl<RoomItemByRoomMapper,
public List<RoomItemByRoom> selectRoomItemByRoomList(RoomItemByRoom roomItemByRoom) { public List<RoomItemByRoom> selectRoomItemByRoomList(RoomItemByRoom roomItemByRoom) {
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(roomItemByRoom.getRoomContentId() !=null,"room_content_id",roomItemByRoom.getRoomContentId()); queryWrapper.eq(roomItemByRoom.getRoomContentId() !=null,"room_content_id",roomItemByRoom.getRoomContentId());
queryWrapper.eq(roomItemByRoom.getParkId() !=null,"park_id",roomItemByRoom.getParkId());
return roomItemByRoomMapper.selectList(queryWrapper); return roomItemByRoomMapper.selectList(queryWrapper);
} }

View File

@ -106,4 +106,10 @@ public class StaffCustomerServiceImpl extends ServiceImpl<StaffCustomerMapper, S
queryWrapper.eq("ics_customer_id",icsCustomerId); queryWrapper.eq("ics_customer_id",icsCustomerId);
return staffCustomerMapper.selectOne(queryWrapper); return staffCustomerMapper.selectOne(queryWrapper);
} }
@Override
public List<StaffCustomer> selectStaffCustomerByStaffIdAndParkId(Long id, String parkId) {
return staffCustomerMapper.selectStaffCustomerByStaffIdAndParkId(id,parkId);
}
} }

View File

@ -0,0 +1,107 @@
package com.ics.admin.service.impl.meeting;
import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ics.admin.mapper.meeting.StaffOpenMapper;
import com.ics.admin.domain.meeting.StaffOpen;
import com.ics.admin.service.meeting.IStaffOpenService;
/**
* 用户和小程序关联Service业务层处理
*
* @author ics
* @date 2024-06-25
*/
@Service
public class StaffOpenServiceImpl extends ServiceImpl<StaffOpenMapper, StaffOpen> implements IStaffOpenService {
@Autowired
private StaffOpenMapper staffOpenMapper;
/**
* 查询用户和小程序关联
*
* @param id 用户和小程序关联ID
* @return 用户和小程序关联
*/
@Override
public StaffOpen selectStaffOpenById(Long id) {
return staffOpenMapper.selectById(id);
}
/**
* 查询用户和小程序关联列表
*
* @param staffOpen 用户和小程序关联
* @return 用户和小程序关联
*/
@Override
public List<StaffOpen> selectStaffOpenList(StaffOpen staffOpen) {
QueryWrapper queryWrapper = new QueryWrapper();
return staffOpenMapper.selectList(queryWrapper);
}
/**
* 新增用户和小程序关联
*
* @param staffOpen 用户和小程序关联
* @return 结果
*/
@Override
public int insertStaffOpen(StaffOpen staffOpen) {
return staffOpenMapper.insert(staffOpen);
}
/**
* 修改用户和小程序关联
*
* @param staffOpen 用户和小程序关联
* @return 结果
*/
@Override
public int updateStaffOpen(StaffOpen staffOpen) {
return staffOpenMapper.updateById(staffOpen);
}
/**
* 删除用户和小程序关联对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteStaffOpenByIds(String ids) {
String[] idsArray = StrUtil.split(ids,",");
return staffOpenMapper.deleteBatchIds(CollUtil.toList(idsArray));
}
/**
* 删除用户和小程序关联信息
*
* @param id 用户和小程序关联ID
* @return 结果
*/
@Override
public int deleteStaffOpenById(Long id) {
return staffOpenMapper.deleteStaffOpenById(id);
}
@Override
public StaffOpen selectStaffOpenByOpenId(String openid) {
return staffOpenMapper.selectStaffOpenByOpenId(openid);
}
@Override
public StaffOpen selectStaffOpenByStaffIdAndOpenId(Long id, String openId) {
return staffOpenMapper.selectStaffOpenByStaffIdAndOpenId(id,openId);
}
}

View File

@ -0,0 +1,63 @@
package com.ics.admin.service.meeting;
import com.ics.admin.domain.meeting.ReservationServe;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 预约服务关联Service接口
*
* @author chen
* @date 2024-06-26
*/
public interface IReservationServeService extends IService<ReservationServe> {
/**
* 查询预约服务关联
*
* @param id 预约服务关联ID
* @return 预约服务关联
*/
ReservationServe selectReservationServeById(Long id);
/**
* 查询预约服务关联列表
*
* @param reservationServe 预约服务关联
* @return 预约服务关联集合
*/
List<ReservationServe> selectReservationServeList(ReservationServe reservationServe);
/**
* 新增预约服务关联
*
* @param reservationServe 预约服务关联
* @return 结果
*/
int insertReservationServe(ReservationServe reservationServe);
/**
* 修改预约服务关联
*
* @param reservationServe 预约服务关联
* @return 结果
*/
int updateReservationServe(ReservationServe reservationServe);
/**
* 批量删除预约服务关联
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteReservationServeByIds(String ids);
/**
* 删除预约服务关联信息
*
* @param id 预约服务关联ID
* @return 结果
*/
int deleteReservationServeById(Long id);
List<ReservationServe> selectReservationServeByReservationId(Long id);
}

View File

@ -62,4 +62,6 @@ public interface IStaffCustomerService extends IService<StaffCustomer> {
List<StaffCustomer> selectStaffCustomerByStaffId(Long id); List<StaffCustomer> selectStaffCustomerByStaffId(Long id);
StaffCustomer selectStaffIdAndCustomerId(Long icsCustomerId, Long staffId); StaffCustomer selectStaffIdAndCustomerId(Long icsCustomerId, Long staffId);
List<StaffCustomer> selectStaffCustomerByStaffIdAndParkId(Long id, String parkId);
} }

View File

@ -0,0 +1,66 @@
package com.ics.admin.service.meeting;
import com.ics.admin.domain.meeting.StaffOpen;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 用户和小程序关联Service接口
*
* @author ics
* @date 2024-06-25
*/
public interface IStaffOpenService extends IService<StaffOpen> {
/**
* 查询用户和小程序关联
*
* @param id 用户和小程序关联ID
* @return 用户和小程序关联
*/
StaffOpen selectStaffOpenById(Long id);
/**
* 查询用户和小程序关联列表
*
* @param staffOpen 用户和小程序关联
* @return 用户和小程序关联集合
*/
List<StaffOpen> selectStaffOpenList(StaffOpen staffOpen);
/**
* 新增用户和小程序关联
*
* @param staffOpen 用户和小程序关联
* @return 结果
*/
int insertStaffOpen(StaffOpen staffOpen);
/**
* 修改用户和小程序关联
*
* @param staffOpen 用户和小程序关联
* @return 结果
*/
int updateStaffOpen(StaffOpen staffOpen);
/**
* 批量删除用户和小程序关联
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteStaffOpenByIds(String ids);
/**
* 删除用户和小程序关联信息
*
* @param id 用户和小程序关联ID
* @return 结果
*/
int deleteStaffOpenById(Long id);
StaffOpen selectStaffOpenByOpenId(String openid);
StaffOpen selectStaffOpenByStaffIdAndOpenId(Long id, String openId);
}

View File

@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="visitTime" column="visit_time" /> <result property="visitTime" column="visit_time" />
<result property="leaveTime" column="leave_time" /> <result property="leaveTime" column="leave_time" />
<result property="visitContent" column="visit_content" /> <result property="visitContent" column="visit_content" />
<result property="tenantId" column="tenant_id" />
<result property="toName" column="to_name" /> <result property="toName" column="to_name" />
<result property="toPhone" column="to_phone" /> <result property="toPhone" column="to_phone" />
<result property="toCustomer" column="to_customer" /> <result property="toCustomer" column="to_customer" />
@ -38,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectIcsCustomerStaffVo"> <sql id="selectIcsCustomerStaffVo">
SELECT id, username, mobile, create_by, create_time, update_by,name,photo,address,email,degree,urgent, update_time, delete_flag, ics_customer_id, openid, avatar, gender, status, park_id,card_no, visit_time, SELECT id, username, mobile, create_by, create_time, update_by,name,photo,address,email,degree,urgent, update_time, delete_flag, ics_customer_id, openid, avatar, gender, status, park_id,card_no, visit_time,
leave_time,visit_content,to_name,to_phone,to_customer,to_customer_id,data_type leave_time,visit_content,to_name,to_phone,to_customer,to_customer_id,data_type,park_id,tenant_id
FROM ics_customer_staff FROM ics_customer_staff
</sql> </sql>
@ -212,6 +213,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
group by cs.id group by cs.id
</select> </select>
<select id="selectUserByMobileAndOpenId" resultType="com.ics.common.core.domain.IcsCustomerStaff">
<include refid="selectIcsCustomerStaffVo"/> where mobile = #{mobile} and park_id = #{parkId}
</select>
</mapper> </mapper>

View File

@ -33,11 +33,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remake" column="remake" /> <result property="remake" column="remake" />
<result property="personNum" column="person_num" />
</resultMap> </resultMap>
<sql id="selectReservationVo"> <sql id="selectReservationVo">
SELECT id, room_content_id, user_id, ticket_id, SELECT id, room_content_id, user_id, ticket_id,
customer_id, title, stauts,serve_id,end_date, is_after_sale, customer_id, title, stauts,serve_id,end_date, is_after_sale,person_num,
oder_number,reservation_number, order_money, cancel_time,prepay_id, oder_number,reservation_number, order_money, cancel_time,prepay_id,
cancel_resaon, visit_type, explain_need_type, meeting_need_type, photograph_type, start_time, cancel_resaon, visit_type, explain_need_type, meeting_need_type, photograph_type, start_time,
delete_flag, create_by, create_time, update_by, update_time, remake FROM tb_reservation delete_flag, create_by, create_time, update_by, update_time, remake FROM tb_reservation
@ -109,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by,</if> <if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null ">update_time,</if> <if test="updateTime != null ">update_time,</if>
<if test="remake != null and remake != ''">remake,</if> <if test="remake != null and remake != ''">remake,</if>
<if test="personNum != null and personNum != ''">person_num,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null ">#{id},</if> <if test="id != null ">#{id},</if>
@ -139,6 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">#{updateBy},</if> <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null ">#{updateTime},</if> <if test="updateTime != null ">#{updateTime},</if>
<if test="remake != null and remake != ''">#{remake},</if> <if test="remake != null and remake != ''">#{remake},</if>
<if test="personNum != null and personNum != ''">#{personNum},</if>
</trim> </trim>
</insert> </insert>
@ -172,6 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if> <if test="updateTime != null ">update_time = #{updateTime},</if>
<if test="remake != null and remake != ''">remake = #{remake},</if> <if test="remake != null and remake != ''">remake = #{remake},</if>
<if test="personNum != null and personNum != ''">person_num = #{personNum},</if>
</trim> </trim>
WHERE id = #{id} WHERE id = #{id}
</update> </update>

View File

@ -33,6 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectStaffCustomerVo"/> <include refid="selectStaffCustomerVo"/>
WHERE staff_id = #{id} WHERE staff_id = #{id}
</select> </select>
<select id="selectStaffCustomerByStaffIdAndParkId" resultType="com.ics.admin.domain.meeting.StaffCustomer">
<include refid="selectStaffCustomerVo"/>
WHERE staff_id = #{staffId} AND park_id = #{parkId}
</select>
<insert id="insertStaffCustomer" parameterType="StaffCustomer"> <insert id="insertStaffCustomer" parameterType="StaffCustomer">
INSERT INTO tb_staff_customer INSERT INTO tb_staff_customer

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ics.admin.mapper.meeting.StaffOpenMapper">
<resultMap type="com.ics.admin.domain.meeting.StaffOpen" id="StaffOpenResult">
<result property="id" column="id" />
<result property="openid" column="openid" />
<result property="staffId" column="staff_id" />
<result property="createTime" column="create_time" />
<result property="deleteFlag" column="delete_flag" />
<result property="createBy" column="create_by" />
<result property="tenantId" column="tenant_id" />
<result property="parkId" column="park_id" />
</resultMap>
<sql id="selectStaffOpenVo">
SELECT id, openid, staff_id, create_time, delete_flag, create_by, tenant_id, park_id FROM tb_staff_open
</sql>
<select id="selectStaffOpenList" parameterType="StaffOpen" resultMap="StaffOpenResult">
<include refid="selectStaffOpenVo"/>
<where>
</where>
</select>
<select id="selectStaffOpenById" parameterType="Long" resultMap="StaffOpenResult">
<include refid="selectStaffOpenVo"/>
WHERE id = #{id}
</select>
<select id="selectStaffOpenByOpenId" resultType="com.ics.admin.domain.meeting.StaffOpen">
SELECT * FROM tb_staff_open WHERE openid = #{openid}
</select>
<select id="selectStaffOpenByStaffIdAndOpenId" resultType="com.ics.admin.domain.meeting.StaffOpen">
SELECT * FROM tb_staff_open WHERE staff_id = #{staffId} AND openid = #{openid}
</select>
<insert id="insertStaffOpen" parameterType="StaffOpen" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_staff_open
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="openid != null and openid != ''">openid,</if>
<if test="staffId != null ">staff_id,</if>
<if test="createTime != null ">create_time,</if>
<if test="deleteFlag != null and deleteFlag != ''">delete_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="tenantId != null ">tenant_id,</if>
<if test="parkId != null ">park_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="openid != null and openid != ''">#{openid},</if>
<if test="staffId != null ">#{staffId},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="deleteFlag != null and deleteFlag != ''">#{deleteFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="tenantId != null ">#{tenantId},</if>
<if test="parkId != null ">#{parkId},</if>
</trim>
</insert>
<update id="updateStaffOpen" parameterType="StaffOpen">
UPDATE tb_staff_open
<trim prefix="SET" suffixOverrides=",">
<if test="openid != null and openid != ''">openid = #{openid},</if>
<if test="staffId != null ">staff_id = #{staffId},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="deleteFlag != null and deleteFlag != ''">delete_flag = #{deleteFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="tenantId != null ">tenant_id = #{tenantId},</if>
<if test="parkId != null ">park_id = #{parkId},</if>
</trim>
WHERE id = #{id}
</update>
<delete id="deleteStaffOpenById" parameterType="Long">
DELETE FROM tb_staff_open WHERE id = #{id}
</delete>
<delete id="deleteStaffOpenByIds" parameterType="String">
DELETE FROM tb_staff_open where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -355,4 +355,12 @@ public class DeviceUtils {
} }
public static String openControlLock(String ip) {
String url = "http://192.168.30.36:808/api/Op/OpDoor?ipaddress="+ip;
String msg = HttpUtil.get(url);
log.info("查询人员id:{}", msg);
return msg;
}
} }

View File

@ -1,10 +1,14 @@
package com.ics.controller.mobile; package com.ics.controller.mobile;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import okhttp3.*; import okhttp3.*;
import org.springframework.web.client.RestTemplate;
import java.io.IOException; import java.io.IOException;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,12 +17,12 @@ public class SmallWxOkHttp {
static String APP_ID = "wx5582a07c1fbbcf06"; static String APP_ID = "wx5582a07c1fbbcf06";
static String SECRET = "ad24130a8919c613efd9538f69abafd3"; static String SECRET = "ad24130a8919c613efd9538f69abafd3";
public static JSONObject sendGet(String url , Map<String, String> map){ public static JSONObject sendGet(String url, Map<String, String> map) {
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
// 创建url // 创建url
HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder(); HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
// 添加参数 // 添加参数
if(map != null){ if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) { for (Map.Entry<String, String> entry : map.entrySet()) {
urlBuilder.addQueryParameter(entry.getKey(), entry.getValue()); urlBuilder.addQueryParameter(entry.getKey(), entry.getValue());
} }
@ -38,8 +42,8 @@ public class SmallWxOkHttp {
} }
} }
public static JSONObject sendPost(String url, Map<String , String> paramMap) { public static JSONObject sendPost(String url, Map<String, String> paramMap) {
if(paramMap == null){ if (paramMap == null) {
paramMap = new HashMap<>(); paramMap = new HashMap<>();
} }
String jsonString = JSON.toJSONString(paramMap); String jsonString = JSON.toJSONString(paramMap);
@ -65,7 +69,7 @@ public class SmallWxOkHttp {
/** /**
* 获取AccessToken * 获取AccessToken
*/ */
public static String getAccessToken(String appId, String secret){ public static String getAccessToken(String appId, String secret) {
// url // url
String url = "https://api.weixin.qq.com/cgi-bin/token"; String url = "https://api.weixin.qq.com/cgi-bin/token";
// 参数 // 参数
@ -83,7 +87,7 @@ public class SmallWxOkHttp {
/** /**
* 小程序登录 * 小程序登录
*/ */
public static JSONObject code2Session(String jsCode,String appId,String secret){ public static JSONObject code2Session(String jsCode, String appId, String secret) {
// url // url
String url = "https://api.weixin.qq.com/sns/jscode2session"; String url = "https://api.weixin.qq.com/sns/jscode2session";
// 参数 // 参数
@ -100,7 +104,7 @@ public class SmallWxOkHttp {
/** /**
* 获取手机号 * 获取手机号
*/ */
public static JSONObject getPhoneNumber(String code, String openid, String accessToken){ public static JSONObject getPhoneNumber(String code, String openid, String accessToken) {
// url // url
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken; String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
// 参数 // 参数
@ -113,9 +117,74 @@ public class SmallWxOkHttp {
} }
public static void main(String[] args) { /*
// getAccessToken(); * 发送模板
getPhoneNumber("", "", "74_NGF_xru4Mt5gDVperBd9LYwtMjWaXGb7JNleZ-nqSOSGvtW3vIGYKkFY0ymMFn2aLYZaN9d1rAZ65X5X-mGX556bWQWFy1mawkWUorOvz37QH34q2YBJjsDCih8FYOfAHAWPF"); *
* name01 :{
* value :
* }
*/
public static String push() {
JSONObject map = new JSONObject();
JSONObject jsonObject = new JSONObject();
JSONObject thing1 = new JSONObject();
thing1.put("value","123456");
jsonObject.put("thing1",thing1);
JSONObject time2 = new JSONObject();
time2.put("value","2022-01-01 12:00:00");
jsonObject.put("time2",time2);
JSONObject thing3 = new JSONObject();
thing3.put("value","789");
jsonObject.put("thing3",thing3);
map.put("touser", "o0_yY69LcLUi_x62WyH5Wvpe0tsA");
map.put("template_id", "lSuc6ocmiPVoXP7ohyJ38wAqZKP2Nn-rhjCxM9JjvBI");
map.put("page","/page/index/index");
map.put("miniprogram_state","formal");
map.put("lang","zh_CN");
map.put("data",jsonObject);
System.out.println(map);
String result = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+getAccessToken(APP_ID,SECRET))
.body(map.toString()).timeout(30*1000).execute().body();
JSONObject jsonObject1 = JSON.parseObject(result);
System.out.println(jsonObject1);
// Boolean success = Boolean.valueOf(jsonObject1.getString("success"));
// log.info("情景面板接口返回结果:{}",jsonObject1);
//
// log.info(DateUtil.date()+" -------情景面板接口结果:{}",success);
// String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+getAccessToken(APP_ID,SECRET);
//
//
// System.out.println("-------"+jsonObject);
// Map<String, String> map = new HashMap<>();
// map.put("touser", "o0_yY69LcLUi_x62WyH5Wvpe0tsA");
// map.put("template_id", "lSuc6ocmiPVoXP7ohyJ38wAqZKP2Nn-rhjCxM9JjvBI");
//
// map.put("page","/page/index/index");
// map.put("miniprogram_state","formal");
// map.put("lang","zh_CN");
// map.put("data",jsonObject.toString());
// System.out.println(map);
//// return new JSONObject();
// JSONObject jsonObject1 = sendPost(url, map);
return "jsonObject1";
} }
}
public static void main (String[]args){
push();
// getAccessToken();
// getPhoneNumber("", "", "74_NGF_xru4Mt5gDVperBd9LYwtMjWaXGb7JNleZ-nqSOSGvtW3vIGYKkFY0ymMFn2aLYZaN9d1rAZ65X5X-mGX556bWQWFy1mawkWUorOvz37QH34q2YBJjsDCih8FYOfAHAWPF");
}
}

View File

@ -3,14 +3,12 @@ package com.ics.controller.mobile;
import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ics.admin.domain.Customer; import com.ics.admin.domain.Customer;
import com.ics.admin.domain.Park; import com.ics.admin.domain.Park;
import com.ics.admin.domain.meeting.DetailEquipment; import com.ics.admin.domain.meeting.*;
import com.ics.admin.domain.meeting.RoomEquipment;
import com.ics.admin.domain.meeting.StaffCustomer;
import com.ics.admin.domain.meeting.UserEquipment;
import com.ics.admin.service.ICustomerService; import com.ics.admin.service.ICustomerService;
import com.ics.admin.service.IIcsCustomerStaffService; import com.ics.admin.service.IIcsCustomerStaffService;
import com.ics.admin.service.IParkService; import com.ics.admin.service.IParkService;
@ -84,6 +82,9 @@ public class WxLoginAPIController extends BaseController {
@Autowired @Autowired
private IStaffCustomerService staffCustomerService; private IStaffCustomerService staffCustomerService;
@Autowired
private IStaffOpenService staffOpenService;
String smallWxAccessTokenKey = "smallWxAccessToken"; String smallWxAccessTokenKey = "smallWxAccessToken";
String smallWxUserPassword = "123456"; String smallWxUserPassword = "123456";
@ -102,30 +103,32 @@ public class WxLoginAPIController extends BaseController {
throw new RuntimeException("请传递jsCode"); throw new RuntimeException("请传递jsCode");
} }
// 小程序登录 // 小程序登录
JSONObject sessionObject = SmallWxOkHttp.code2Session(jsCode,appId,appSecret); JSONObject sessionObject = SmallWxOkHttp.code2Session(jsCode, appId, appSecret);
String openid = sessionObject.getString("openid"); String openid = sessionObject.getString("openid");
String unionid = sessionObject.getString("unionid");
// //
R ajax = R.ok(); R ajax = R.ok();
// 校验用户是否存在 // 校验用户是否存在
IcsCustomerStaff sysUser = icsCustomerStaffService.selectUserByOpenid(openid); StaffOpen staffOpen = staffOpenService.selectStaffOpenByOpenId(openid);
// 用户存在直接获取token // 用户存在直接获取token
if (sysUser != null) { if (staffOpen != null) {
IcsCustomerStaff sysUser = icsCustomerStaffService.selectIcsCustomerStaffById(staffOpen.getStaffId());
if (null != sysUser) {
Long parkId = sysUser.getParkId(); Long parkId = sysUser.getParkId();
if (parkId != null) { if (parkId != null) {
Park park = parkService.selectParkById(parkId); Park park = parkService.selectParkById(parkId);
sysUser.setParkName(park.getName()); sysUser.setParkName(park.getName());
} }
String phonenumber = sysUser.getMobile();
User user = new User(); User user = new User();
PublishFactory.recordLoginInfo(sysUser.getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")); PublishFactory.recordLoginInfo(sysUser.getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
BeanUtils.copyBeanProp(user, sysUser); BeanUtils.copyBeanProp(user, sysUser);
Map<String, Object> token = tokenService.createToken(user); Map<String, Object> token = tokenService.createToken(user);
ajax.put(Constants.TOKEN, token); ajax.put(Constants.TOKEN, token);
// ajax.put(Constants.TOKEN, token);
ajax.put("user", sysUser); ajax.put("user", sysUser);
ajax.put("openid", openid); ajax.put("openid", openid);
return ajax;
}
ajax.put("openid", openid);
return ajax; return ajax;
} else { // 用户不存在返回openid进行注册登录 } else { // 用户不存在返回openid进行注册登录
ajax.put("openid", openid); ajax.put("openid", openid);
@ -134,14 +137,15 @@ public class WxLoginAPIController extends BaseController {
} }
@PostMapping("/social_user_login/login") @PostMapping("/changyang_user_login/login")
public R social(@RequestBody Map<String, String> paramMap) { public R userLogin(@RequestBody Map<String, String> paramMap) {
try {
// 参数 // 参数
String code = paramMap.get("code"); String code = paramMap.get("code");
String openid = paramMap.get("openid"); String openid = paramMap.get("openid");
String appId = paramMap.get("appId"); String appId = paramMap.get("appId");
String appSecret = paramMap.get("appSecret"); String appSecret = paramMap.get("appSecret");
String parkId = paramMap.get("parkId");
String tenantId = paramMap.get("tenantId");
// 必填 // 必填
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
throw new RuntimeException("请传递code"); throw new RuntimeException("请传递code");
@ -150,7 +154,79 @@ public class WxLoginAPIController extends BaseController {
throw new RuntimeException("请传递openid"); throw new RuntimeException("请传递openid");
} }
// 获取微信小程序 AccessToken // 获取微信小程序 AccessToken
String smallWxAccessToken = getSmallWxAccessToken(appId,appSecret); String smallWxAccessToken = getSmallWxAccessToken(appId, appSecret);
// 获取手机号
JSONObject jsonObj = SmallWxOkHttp.getPhoneNumber(code, openid, smallWxAccessToken);
JSONObject phoneInfo = jsonObj.getJSONObject("phone_info");
// 手机号
String phoneNumber = phoneInfo.getString("phoneNumber");
IcsCustomerStaff icsCustomerStaff = new IcsCustomerStaff();
icsCustomerStaff.setMobile(phoneNumber);
// 需要根据手机号 查询对应的用户
IcsCustomerStaff customerStaff1 = icsCustomerStaffService.selectUserByMobile(phoneNumber);
//如果手机号等于null 就新增用户
if (null == customerStaff1) {
Assert.isTrue(false, "外部人员注册,请联系管理员");
return R.error("外部人员注册,请联系管理员");
} else {
List<StaffCustomer> staffCustomers = staffCustomerService.selectStaffCustomerByStaffIdAndParkId(customerStaff1.getId(),parkId);
if (CollUtil.isEmpty(staffCustomers)) {
Assert.isTrue(false, "外部人员注册,请联系管理员");
return R.error("外部人员注册,请联系管理员");
}
StaffOpen staffOpen = staffOpenService.selectStaffOpenByOpenId(openid);
if (null == staffOpen) {
StaffOpen staffOpen1 = new StaffOpen();
staffOpen1.setOpenid(openid);
staffOpen1.setStaffId(customerStaff1.getId());
staffOpen1.setParkId(Long.valueOf(parkId));
staffOpen1.setTenantId(Long.valueOf(tenantId));
staffOpenService.insertStaffOpen(staffOpen1);
}
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;
}
}
/**
* 郑州授权登录
*
* @param paramMap
* @return
*/
@PostMapping("/social_user_login/login")
public R social(@RequestBody Map<String, String> paramMap) {
try {
// 参数
String code = paramMap.get("code");
String openid = paramMap.get("openid");
String appId = paramMap.get("appId");
String appSecret = paramMap.get("appSecret");
String parkId = paramMap.get("parkId");
String tenantId = paramMap.get("tenantId");
// 必填
if (StringUtils.isBlank(code)) {
throw new RuntimeException("请传递code");
}
if (StringUtils.isBlank(openid)) {
throw new RuntimeException("请传递openid");
}
// 获取微信小程序 AccessToken
String smallWxAccessToken = getSmallWxAccessToken(appId, appSecret);
// 获取手机号 // 获取手机号
JSONObject jsonObj = SmallWxOkHttp.getPhoneNumber(code, openid, smallWxAccessToken); JSONObject jsonObj = SmallWxOkHttp.getPhoneNumber(code, openid, smallWxAccessToken);
JSONObject phoneInfo = jsonObj.getJSONObject("phone_info"); JSONObject phoneInfo = jsonObj.getJSONObject("phone_info");
@ -159,9 +235,12 @@ public class WxLoginAPIController extends BaseController {
IcsCustomerStaff icsCustomerStaff = new IcsCustomerStaff(); IcsCustomerStaff icsCustomerStaff = new IcsCustomerStaff();
icsCustomerStaff.setMobile(phoneNumber); icsCustomerStaff.setMobile(phoneNumber);
//todo 需要根据手机号和对应的openId 查询对应的用户 //todo 需要根据手机号和对应的openId 查询对应的用户
IcsCustomerStaff customerStaff = icsCustomerStaffService.selectByPhoneAndOpenId(phoneNumber,openid); IcsCustomerStaff customerStaff = icsCustomerStaffService.selectUserByMobile(phoneNumber);
if (customerStaff != null) { if (customerStaff != null) {
if (StringUtils.isBlank(customerStaff.getOpenid())) {
StaffOpen staffOpen = staffOpenService.selectStaffOpenByStaffIdAndOpenId(customerStaff.getId(),openid);
if (staffOpen != null) {
// 根据 用户绑定的企业 绑定对应的设备 // 根据 用户绑定的企业 绑定对应的设备
ArrayList<Long> ids = new ArrayList<>(); ArrayList<Long> ids = new ArrayList<>();
Customer customer = customerService.selectCustomerById(customerStaff.getIcsCustomerId()); Customer customer = customerService.selectCustomerById(customerStaff.getIcsCustomerId());
@ -195,15 +274,20 @@ public class WxLoginAPIController extends BaseController {
userEquipmentService.insertUserEquipment(userEquipment); userEquipmentService.insertUserEquipment(userEquipment);
} }
} }
customerStaff.setOpenid(openid); }else {
icsCustomerStaffService.updateIcsCustomerStaff(customerStaff); StaffOpen staffOpen1 = new StaffOpen();
staffOpen1.setOpenid(openid);
staffOpen1.setStaffId(customerStaff.getId());
// staffOpen1.setParkId(Long.valueOf(parkId));
// staffOpen1.setTenantId(Long.valueOf(tenantId));
staffOpenService.insertStaffOpen(staffOpen1);
} }
Long parkId = customerStaff.getParkId();
if (parkId != null) { if (parkId != null) {
Park park = parkService.selectParkById(parkId); Park park = parkService.selectParkById(Long.valueOf(parkId));
customerStaff.setParkName(park.getName()); customerStaff.setParkName(park.getName());
} }
User user = new User(); User user = new User();
PublishFactory.recordLoginInfo(customerStaff.getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")); PublishFactory.recordLoginInfo(customerStaff.getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
BeanUtils.copyBeanProp(user, customerStaff); BeanUtils.copyBeanProp(user, customerStaff);
@ -217,35 +301,53 @@ public class WxLoginAPIController extends BaseController {
// 新增用户信息 // 新增用户信息
// todo 现根据手机号查询对应的数据如果存在则不新增如果不存在则新增 // todo 现根据手机号查询对应的数据如果存在则不新增如果不存在则新增
IcsCustomerStaff customerStaff1 = icsCustomerStaffService.selectUserByMobile(phoneNumber);
//如果手机号等于null 就新增用户
if (null == customerStaff1) {
icsCustomerStaff.setUsername(phoneNumber); icsCustomerStaff.setUsername(phoneNumber);
icsCustomerStaff.setDataType(Constants.CUSTOMER_VISIT);
icsCustomerStaff.setOpenid(openid);
icsCustomerStaff.setGender("0"); icsCustomerStaff.setGender("0");
icsCustomerStaff.setStatus("0"); icsCustomerStaff.setStatus("0");
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff); int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
StaffOpen staffOpen1 = new StaffOpen();
staffOpen1.setOpenid(openid);
staffOpen1.setStaffId(icsCustomerStaff.getId());
// staffOpen1.setParkId(Long.valueOf(parkId));
// staffOpen1.setTenantId(Long.valueOf(tenantId));
staffOpenService.insertStaffOpen(staffOpen1);
Map<String, Object> token = tokenService.createStaffToken(icsCustomerStaff); Map<String, Object> token = tokenService.createStaffToken(icsCustomerStaff);
R ajax = R.ok(); R ajax = R.ok();
ajax.put(Constants.TOKEN, token); ajax.put(Constants.TOKEN, token);
ajax.put("user", icsCustomerStaff); ajax.put("user", icsCustomerStaff);
ajax.put("openid", openid); ajax.put("openid", openid);
// IcsCustomerStaff customerStaff1 = icsCustomerStaffService.selectUserByMobile(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; 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) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@ -262,7 +364,7 @@ public class WxLoginAPIController extends BaseController {
String smallWxAccessToken = redisTemplate.opsForValue().get(smallWxAccessTokenKey); String smallWxAccessToken = redisTemplate.opsForValue().get(smallWxAccessTokenKey);
if (StringUtils.isBlank(smallWxAccessToken)) { if (StringUtils.isBlank(smallWxAccessToken)) {
smallWxAccessToken = SmallWxOkHttp.getAccessToken(appId, appSecret); smallWxAccessToken = SmallWxOkHttp.getAccessToken(appId, appSecret);
redisTemplate.opsForValue().set(smallWxAccessTokenKey, smallWxAccessToken, 7200, TimeUnit.SECONDS); redisTemplate.opsForValue().set(appId + smallWxAccessTokenKey, appId + smallWxAccessToken, 7200, TimeUnit.SECONDS);
} }
return smallWxAccessToken; return smallWxAccessToken;
} }

View File

@ -1,14 +1,9 @@
package com.ics.controller.mobile.meeting; package com.ics.controller.mobile.meeting;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.gson.Gson;
import com.ics.admin.controller.meeting.UserEquipmentController;
import com.ics.admin.domain.meeting.*; import com.ics.admin.domain.meeting.*;
import com.ics.admin.domain.meeting.vo.DeviceData; import com.ics.admin.domain.meeting.vo.DeviceData;
import com.ics.admin.service.meeting.*; import com.ics.admin.service.meeting.*;
@ -16,9 +11,7 @@ import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.R; import com.ics.common.core.domain.R;
import com.ics.common.core.page.PageDomain; import com.ics.common.core.page.PageDomain;
import com.ics.common.core.page.TableSupport; import com.ics.common.core.page.TableSupport;
import com.ics.common.json.JsonUtils;
import com.ics.common.utils.DeviceUtils; import com.ics.common.utils.DeviceUtils;
import com.ics.common.utils.IpUtils;
import com.ics.common.utils.StringUtils; import com.ics.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -27,9 +20,7 @@ import org.springframework.web.bind.annotation.*;
import org.wf.jwtp.annotation.Ignore; import org.wf.jwtp.annotation.Ignore;
import org.wf.jwtp.annotation.RequiresPermissions; import org.wf.jwtp.annotation.RequiresPermissions;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
@RestController @RestController
@ -60,14 +51,13 @@ public class ApiEquipmentController extends BaseController {
//根据用户id查询对应的设备 楼层分割房间设备信息 //根据用户id查询对应的设备 楼层分割房间设备信息
@RequiresPermissions("member:center:view") @RequiresPermissions("member:center:view")
@GetMapping("/getEquipmentByUserId/{userId}") @GetMapping("/getEquipmentByUserId/{userId}")
public R getEquipmentByUserId(@PathVariable("userId") Long userId){ public R getEquipmentByUserId(@PathVariable("userId") Long userId) {
List<UserEquipment> equipments = userEquipmentService.getEquipmentByUserId(userId); List<UserEquipment> equipments = userEquipmentService.getEquipmentByUserId(userId);
return R.ok().put("data", equipments);
return R.ok().put("data",equipments);
} }
@ -76,28 +66,34 @@ public class ApiEquipmentController extends BaseController {
*/ */
@RequiresPermissions("member:center:view") @RequiresPermissions("member:center:view")
@PostMapping("/openDoor") @PostMapping("/openDoor")
public R openDoor(@RequestBody RoomRecord roomRecord){ public R openDoor(@RequestBody RoomRecord roomRecord) {
//判断用户是否有权限开门 //判断用户是否有权限开门
UserEquipment userEquipment1 = new UserEquipment(); UserEquipment userEquipment1 = new UserEquipment();
userEquipment1.setEquipmentId(roomRecord.getDeviceId()); userEquipment1.setEquipmentId(roomRecord.getDeviceId());
userEquipment1.setUserId(roomRecord.getUserId()); userEquipment1.setUserId(roomRecord.getUserId());
int count =userEquipmentService.selectCountByUserIdAndDeviceId(userEquipment1); int count = userEquipmentService.selectCountByUserIdAndDeviceId(userEquipment1);
if (count == 0){ if (count == 0) {
return R.error("您没有权限开门,不在开门时间内"); return R.error("您没有权限开门,不在开门时间内");
} }
String ip = equipmentService.selectEquipmentById(roomRecord.getDeviceId()).getIp(); Equipment equipment = equipmentService.selectEquipmentById(roomRecord.getDeviceId());
if (equipment.getType() == 0){
String openlock = DeviceUtils.openlock(ip); String openlock = DeviceUtils.openlock(equipment.getIp());
JSONObject jsonObject = JSONUtil.parseObj(openlock); JSONObject jsonObject = JSONUtil.parseObj(openlock);
Integer code = (Integer) jsonObject.get("status"); Integer code = (Integer) jsonObject.get("status");
Assert.isTrue(code == 0,"开门失败"); Assert.isTrue(code == 0, "开门失败");
}else if (equipment.getType() == 1){
String openlock = DeviceUtils.openControlLock(equipment.getIp());
log.info("开门控制器的结果为结果:{}", openlock);;
}
roomRecord.setType("0"); roomRecord.setType("0");
int i = roomRecordService.insertRoomRecord(roomRecord); int i = roomRecordService.insertRoomRecord(roomRecord);
Assert.isTrue(i == 1,"开门失败"); Assert.isTrue(i == 1, "开门失败");
return R.ok("开门成功"); return R.ok("开门成功");
} }
@ -117,34 +113,35 @@ public class ApiEquipmentController extends BaseController {
Equipment equipment = equipmentService.selectEquipmentById(record.getDeviceId()); Equipment equipment = equipmentService.selectEquipmentById(record.getDeviceId());
record.setDeviceName(equipment.getEquipmentName()); record.setDeviceName(equipment.getEquipmentName());
} }
return R.ok().put("data",openDoorRecord); return R.ok().put("data", openDoorRecord);
} }
/** /**
* 获取对比记录,获取设备的对比记录设备往服务端传输数据 * 获取对比记录,获取设备的对比记录设备往服务端传输数据
* @return *
*/ */
@Ignore @Ignore
@PostMapping("/getEquipmentByUserIdAndEquipmentId") @PostMapping("/getEquipmentByUserIdAndEquipmentId")
public R getEquipmentByUserIdAndEquipmentId(@RequestBody DeviceData data){ public R getEquipmentByUserIdAndEquipmentId(@RequestBody DeviceData data) {
// 对比personId 和用户 id // 对比personId 和用户 id
// 对比equipmentId 和设备id // 对比equipmentId 和设备id
if (data.getData() != null && data.getData().getEventType() != 17 && StringUtils.isNotEmpty(data.getData().getPersonId())){ if (data.getData() != null && data.getData().getEventType() != 17 && StringUtils.isNotEmpty(data.getData().getPersonId())) {
//用户id //用户id
String personId = data.getData().getPersonId(); String personId = data.getData().getPersonId();
String deviceId = data.getData().getDeviceId(); String deviceId = data.getData().getDeviceId();
Equipment equipment = equipmentService.selectByDeviceCode(deviceId); Equipment equipment = equipmentService.selectByDeviceCode(deviceId);
Assert.isTrue(equipment != null,"设备不存在"); Assert.isTrue(equipment != null, "设备不存在");
RoomRecord record = new RoomRecord(); RoomRecord record = new RoomRecord();
record.setUserId(Long.valueOf(personId)); record.setUserId(Long.valueOf(personId));
if (data.getData().getPersonType().equals("visitor")){ if (data.getData().getPersonType().equals("visitor")) {
VisitorPerson visitorPerson =visitorPersonService.selectByUserId(personId); VisitorPerson visitorPerson = visitorPersonService.selectByUserId(personId);
record.setUserId(visitorPerson.getIntervieweeId()); record.setUserId(visitorPerson.getIntervieweeId());
} }
assert equipment != null;
record.setParkId(equipment.getParkId()); record.setParkId(equipment.getParkId());
record.setType("1"); record.setType("1");
record.setDeviceId(equipment.getId()); record.setDeviceId(equipment.getId());
@ -165,57 +162,68 @@ public class ApiEquipmentController extends BaseController {
*/ */
@RequiresPermissions("member:center:view") @RequiresPermissions("member:center:view")
@GetMapping("/scanOpenDoor") @GetMapping("/scanOpenDoor")
public R scanOpenDoor( RoomRecord roomRecord){ public R scanOpenDoor(RoomRecord roomRecord) {
log.info("用户id为{}",roomRecord.getUserId()); log.info("用户id为{}", roomRecord.getUserId());
log.info("房间id为{}",roomRecord.getRoomId()); log.info("房间id为{}", roomRecord.getRoomId());
if (roomRecord.getEquipmentType().equals("displayScreen")){ if (roomRecord.getEquipmentType().equals("displayScreen")) {
Long deviceId = roomRecord.getDeviceId(); // Long deviceId = roomRecord.getDeviceId();
Long userId = roomRecord.getUserId(); // Long userId = roomRecord.getUserId();
UserEquipment userEquipment = userEquipmentService.selectUserAndEquipment(userId, deviceId);
if (null == userEquipment){ UserEquipment userEquipment1 = new UserEquipment();
return R.error("您没有该设备的权限"); userEquipment1.setEquipmentId(roomRecord.getDeviceId());
userEquipment1.setUserId(roomRecord.getUserId());
int count = userEquipmentService.selectCountByUserIdAndDeviceId(userEquipment1);
if (count == 0) {
return R.error("您没有权限开门");
} }
String ip = equipmentService.selectEquipmentById(roomRecord.getDeviceId()).getIp(); String ip = equipmentService.selectEquipmentById(roomRecord.getDeviceId()).getIp();
String openlock = DeviceUtils.openlock(ip); String openlock = DeviceUtils.openlock(ip);
JSONObject jsonObject = JSONUtil.parseObj(openlock); JSONObject jsonObject = JSONUtil.parseObj(openlock);
Integer code = (Integer) jsonObject.get("status"); Integer code = (Integer) jsonObject.get("status");
Assert.isTrue(code == 0,"开门失败"); Assert.isTrue(code == 0, "开门失败");
int i = roomRecordService.insertRoomRecord(roomRecord); int i = roomRecordService.insertRoomRecord(roomRecord);
Assert.isTrue(i == 1,"开门失败"); Assert.isTrue(i == 1, "开门失败");
} }
// String openlock = DeviceUtils.openlock(ip); if (roomRecord.getEquipmentType().equals("control")) {
// JSONObject jsonObject = JSONUtil.parseObj(openlock); UserEquipment userEquipment1 = new UserEquipment();
// Integer code = (Integer) jsonObject.get("status"); userEquipment1.setEquipmentId(roomRecord.getDeviceId());
// Assert.isTrue(code == 0,"开门失败"); userEquipment1.setUserId(roomRecord.getUserId());
//
// int i = roomRecordService.insertRoomRecord(roomRecord);
// Assert.isTrue(i == 1,"开门失败"); int count = userEquipmentService.selectCountByUserIdAndDeviceId(userEquipment1);
if (count == 0) {
return R.error("您没有权限开门");
}
String ip = equipmentService.selectEquipmentById(roomRecord.getDeviceId()).getIp();
String openlock = DeviceUtils.openControlLock(ip);
log.info("开门控制器的结果为结果:{}", openlock);;
}
return R.ok("开门成功"); return R.ok("开门成功");
} }
/** /**
* 扫描二维码开门 用户id 和设备id * 扫描二维码开门 用户id 和设备id
*
*/ */
@Ignore @Ignore
@PostMapping("/scanDoor") @PostMapping("/scanDoor")
public R scanDoor(String ip ){ public R scanDoor(String ip) {
// todo 开门 // todo 开门
// todo 获取ip后key为ipvalue为设备id 存入redis // todo 获取ip后key为ipvalue为设备id 存入redis
// 所有设备的ip都存入redis 里面 // 所有设备的ip都存入redis 里面
System.out.println(ip); System.out.println(ip);
log.info("ip为{}",ip); log.info("ip为{}", ip);
return R.ok("开门成功"); return R.ok("开门成功");
} }
@ -224,16 +232,16 @@ public class ApiEquipmentController extends BaseController {
*/ */
@Ignore @Ignore
@GetMapping("/isOpenDoor") @GetMapping("/isOpenDoor")
public R isOpenDoor(String ip ){ public R isOpenDoor(String ip) {
// 根据ip 去redis读取数据 // 根据ip 去redis读取数据
String smallWxAccessToken = redisTemplate.opsForValue().get(smallWxAccessTokenKey+ip); String smallWxAccessToken = redisTemplate.opsForValue().get(smallWxAccessTokenKey + ip);
if (StringUtils.isNotBlank(smallWxAccessToken)){ if (StringUtils.isNotBlank(smallWxAccessToken)) {
Boolean delete = redisTemplate.delete(smallWxAccessTokenKey + ip); Boolean delete = redisTemplate.delete(smallWxAccessTokenKey + ip);
if (delete){ if (delete) {
R.error("删除redis失败"); R.error("删除redis失败");
} }
return R.ok("开门成功"); return R.ok("开门成功");
}else { } else {
return R.error("开门失败"); return R.error("开门失败");
} }
} }

View File

@ -27,6 +27,7 @@ import com.ics.controller.mobile.pay.wx.dto.WxChatBasePayDto;
import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto; import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.wf.jwtp.annotation.Ignore;
import org.wf.jwtp.annotation.RequiresPermissions; import org.wf.jwtp.annotation.RequiresPermissions;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -50,8 +51,6 @@ public class ApiRoomContentController extends BaseController {
@Autowired @Autowired
private IReservationPersonService reservationPersonService; private IReservationPersonService reservationPersonService;
@Autowired
private ICustomerService customerService;
@Autowired @Autowired
private RoomContentMapper roomContentMapper; private RoomContentMapper roomContentMapper;
@ -71,8 +70,7 @@ public class ApiRoomContentController extends BaseController {
@Autowired @Autowired
private IParkService parkService; private IParkService parkService;
@Autowired
private RoomEquipmentMapper roomEquipmentMapper;
@Autowired @Autowired
private IRoomEquipmentService roomEquipmentService; private IRoomEquipmentService roomEquipmentService;
@ -86,6 +84,12 @@ public class ApiRoomContentController extends BaseController {
@Autowired @Autowired
private IDetailEquipmentService detailEquipmentService; private IDetailEquipmentService detailEquipmentService;
@Autowired
private IReservationServeService reservationServeService;
@Autowired
private IRoomServeService roomServeService;
/** /**
* 查询条件筛选 * 查询条件筛选
@ -199,13 +203,42 @@ public class ApiRoomContentController extends BaseController {
return R.ok().put("count", count).put("msg", msg); return R.ok().put("count", count).put("msg", msg);
} }
/**
* 上海会议预约记录
*/
@RequiresPermissions("member:center:view")
@PostMapping("/saveChangyangMeetingRecord")
public R saveMeetingRoomRecord(@RequestBody Reservation reservation) {
reservation.setStauts(Reservation.Status.APPOINTMENT);
reservation.setOderNumber(RandomUtil.randomNumbers(18));
boolean b = reservationService.selectFreeMeetingRoom(reservation);
Assert.isFalse(b, "会议室不可用");
IcsCustomerStaff customerStaff = customerStaffService.selectIcsCustomerStaffById(reservation.getUserId());
Assert.isTrue(customerStaff != null, "用户不存在");
boolean save = reservationService.save(reservation);
Assert.isTrue(save, "预约失败");
//新增预约服务数据
for (ReservationServe reservationServe : reservation.getReservationServes()) {
reservationServe.setReservationId(reservation.getId());
reservationServe.setParkId(reservation.getParkId());
reservationServe.setTenantId(reservation.getTenantId());
reservationServeService.insertReservationServe(reservationServe);
}
Long id = reservation.getId();
return toAjax(save).put("reservationId", id);
}
/** /**
* 提交会议预约记录 * 提交会议预约记录
*/ */
@RequiresPermissions("member:center:view") @RequiresPermissions("member:center:view")
@PostMapping("/saveMeetingRecord") @PostMapping("/saveMeetingRecord")
public R getMeetingRoomRecord(@RequestBody Reservation reservation) { public R saveMeetingRecord(@RequestBody Reservation reservation) {
//根据用户获取对应的企业id查询该企业下对应的优惠卷 //根据用户获取对应的企业id查询该企业下对应的优惠卷
reservation.setStauts(Reservation.Status.APPOINTMENT); reservation.setStauts(Reservation.Status.APPOINTMENT);
@ -418,15 +451,16 @@ public class ApiRoomContentController extends BaseController {
if (buildingDetail != null) { if (buildingDetail != null) {
roomContent.setBuildingName(buildingDetail.getFloorName() + "F"); 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());
// }
} }
reservation.setRoomContent(roomContent); reservation.setRoomContent(roomContent);
List<ReservationServe> reservationServes = reservationServeService.selectReservationServeByReservationId(reservation.getId());
if (CollUtil.isNotEmpty(reservationServes)){
for (ReservationServe reservationServe : reservationServes) {
reservationServe.setServeName(roomServeService.selectRoomServeById(reservationServe.getServeId()).getServeName());
}
}
reservation.setReservationServes(reservationServes);
return R.ok().put("data", reservation); return R.ok().put("data", reservation);
} }

View File

@ -25,6 +25,7 @@ import org.wf.jwtp.annotation.Ignore;
import org.wf.jwtp.annotation.RequiresPermissions; import org.wf.jwtp.annotation.RequiresPermissions;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -76,8 +77,13 @@ public class ApiRoomController extends BaseController {
*/ */
@Ignore @Ignore
@PostMapping("list") @PostMapping("list")
public R list() { public R list(@RequestBody HashMap<String,Long> map) {
List<RoomContent> roomContents = roomContentService.selectApiRoomList(new RoomContent()); Long parkId = map.get("parkId");
RoomContent roomContent1 = new RoomContent();
if (parkId != null){
roomContent1.setParkId(parkId);
}
List<RoomContent> roomContents = roomContentService.selectApiRoomList(roomContent1);
for (RoomContent roomContent : roomContents) { for (RoomContent roomContent : roomContents) {
RoomEquipment roomEquipment = roomEquipmentService.selectRoomId(roomContent.getRoomId()); RoomEquipment roomEquipment = roomEquipmentService.selectRoomId(roomContent.getRoomId());
if (null != roomEquipment){ if (null != roomEquipment){
@ -115,7 +121,6 @@ public class ApiRoomController extends BaseController {
@GetMapping("selectParkList") @GetMapping("selectParkList")
public R selectParkList(Long tenantId) { public R selectParkList(Long tenantId) {
Park park = new Park(); Park park = new Park();
park.setTenantId(tenantId);
List<Park> parkList = parkService.selectParkList(park); List<Park> parkList = parkService.selectParkList(park);
return R.data(parkList); return R.data(parkList);
} }

View File

@ -166,6 +166,12 @@ public class ApiShowroomController extends BaseController {
showroomRecord.setCreateTime(new Date()); showroomRecord.setCreateTime(new Date());
boolean save = recordService.save(showroomRecord); boolean save = recordService.save(showroomRecord);
if (showroomRecord.getParkId() == 25){
}
Long id = showroomRecord.getId(); Long id = showroomRecord.getId();
return toAjax(save).put("showroomRecord",id); return toAjax(save).put("showroomRecord",id);
} }
@ -173,7 +179,8 @@ public class ApiShowroomController extends BaseController {
/** /**
* 查询字典 * 查询字典
*/ */
@RequiresPermissions("member:center:view") @Ignore
// @RequiresPermissions("member:center:view")
@PostMapping("/listByType") @PostMapping("/listByType")
public R list(@RequestBody DictData dictData) { public R list(@RequestBody DictData dictData) {
return R.ok().put("data",dictDataService.selectDictDataList(dictData)); return R.ok().put("data",dictDataService.selectDictDataList(dictData));