diff --git a/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/MeetingReservationServiceImpl.java b/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/MeetingReservationServiceImpl.java index 47d130e..ad220f3 100644 --- a/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/MeetingReservationServiceImpl.java +++ b/shoot-hand/ics-admin/src/main/java/com/ics/admin/service/impl/MeetingReservationServiceImpl.java @@ -137,9 +137,11 @@ public class MeetingReservationServiceImpl implements IMeetingReservationService meetingReservation.getTimeFormat() > 0 ? (Date) meetingReservation.getParams().get("endTime") : meetingReservation.getEnd() ); if (ids.size() > 0) return "会议室已被占用,预约失败"; + IcsCustomerStaff staff = customerStaffMapper.selectIcsCustomerStaffById(currentUserId); + boolean isAdmin = staff.getRoomRole() == 5;//是否管理员 Date now = new Date(); meetingReservation.setSn(snService.generate(Sn.Type.REPAIR)); - meetingReservation.setStatus(5); + meetingReservation.setStatus(isAdmin ? 7 : 5); meetingReservation.setDeleteFlag(0); meetingReservation.setCreateTime(now); meetingReservation.setCreateBy(currentUserId.toString()); @@ -156,7 +158,7 @@ public class MeetingReservationServiceImpl implements IMeetingReservationService } } //提醒--start - List rList = processRemind(meetingReservation, currentUserId, null, 5, null, null); + List rList = processRemind(meetingReservation, currentUserId, null, isAdmin ? 7 : 5, null, null); for (RepairRemind repairRemind : rList) { repairRemindMapper.insertRepairRemind(repairRemind); } diff --git a/shoot-hand/ics-admin/src/main/resources/mapper/admin/MeetingStatsMapper.xml b/shoot-hand/ics-admin/src/main/resources/mapper/admin/MeetingStatsMapper.xml index fe663c8..d98a27c 100644 --- a/shoot-hand/ics-admin/src/main/resources/mapper/admin/MeetingStatsMapper.xml +++ b/shoot-hand/ics-admin/src/main/resources/mapper/admin/MeetingStatsMapper.xml @@ -58,7 +58,7 @@ select room.name name,count(mr.id) value from ics_meeting_room room left join ics_meeting_reservation mr on room.id=mr.room_id and room.delete_flag=0 and mr.delete_flag=0 and mr.status>7 and mr.start between #{start} and #{end} - GROUP BY room.name order by room.id + GROUP BY room.name order by value desc ]]> diff --git a/shoot-hand/ics-web/src/main/java/com/ics/controller/mobile/WxScanController.java b/shoot-hand/ics-web/src/main/java/com/ics/controller/mobile/WxScanController.java new file mode 100644 index 0000000..aab877a --- /dev/null +++ b/shoot-hand/ics-web/src/main/java/com/ics/controller/mobile/WxScanController.java @@ -0,0 +1,152 @@ +package com.ics.controller.mobile; + +import com.alibaba.fastjson.JSONObject; +import com.ics.admin.service.IIcsCustomerStaffService; +import com.ics.common.core.domain.IcsCustomerStaff; +import com.ics.common.core.domain.R; +import com.ics.common.redis.util.RedisUtils; +import com.ics.common.utils.StringUtils; +import com.ics.system.domain.User; +import com.ics.system.log.publish.PublishFactory; +import com.ics.system.service.IMenuService; +import com.ics.system.service.IRoleService; +import com.ics.system.service.IUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import org.wf.jwtp.annotation.Ignore; +import org.wf.jwtp.provider.Token; +import org.wf.jwtp.provider.TokenStore; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.List; +import java.util.UUID; + +/** + * 扫码登录 + * created at 2024-10-22 20:05 + * + * @author lujiang + * @version 1.0.0 + * @since 1.0.0 + */ +@RestController +@RequestMapping("/wxscan") +public class WxScanController { + @Value("${webchatGZH.appid}") + private String appid; + + @Value("${webchatGZH.secret}") + private String secret; + + @Value("${webchatGZH.access}") + private String access; + + @Autowired + private IIcsCustomerStaffService customerStaffService; + + @Autowired + private TokenStore tokenStore; + + @Autowired + private IUserService userService; + + @Autowired + private IMenuService menuService; + + @Autowired + private IRoleService roleService; + + @Autowired + private RedisUtils redis; + + //微信公众号网页授权地址 + private final static String OAUTH2_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=sh1022#wechat_redirect"; + + private final static String OAUTH2_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code"; + + /** + * 获取认证标识及url,有效期1小时 + * 返回 + * url,用此url生成二维码,使用微信“扫一扫”扫描二维码 + * unique,认证标识 + */ + @Ignore + @RequestMapping("/get") + public R index() throws IOException { + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + redis.set("QR:" + uuid, "",3600); + String redirectUrl = access + "/wxscan/goin/" + uuid; + String encodedUrl = URLEncoder.encode(redirectUrl, "UTF-8"); + String url = String.format(OAUTH2_URL, appid, encodedUrl); + return R.ok().put("url", url).put("unique", uuid); + } + + /** + * 扫码登录 + */ + @Ignore + @ResponseBody + @RequestMapping(value = "/goin/{unique}", produces = "text/html;charset=utf-8") + public String goin(@PathVariable("unique") String unique, String code, String state) { + if (!"sh1022".equals(state)) return ""; + String sToken = redis.get("QR:" + unique); + if (StringUtils.isNotBlank(sToken)) return "已扫码登录"; + String url = String.format(OAUTH2_TOKEN, appid, secret, code); + JSONObject result = SmallWxOkHttp.sendGet(url, null); + String openid = result.getString("openid"); + List list = customerStaffService.getUserByGzhOpenid(openid); + if (list.size() > 0) {//已经绑定的用户 + Long staffId = list.get(0).getId(); + User user = userService.selectUserByStaffId(staffId); + if (user != null) { +// System.out.println("**************************"); +// System.out.println(user.getId().toString()); +// System.out.println(menuService.selectPermsStrArray(user.getId())); +// System.out.println(roleService.selectRoleStrArray(user.getId())); +// System.out.println(tokenStore); +// System.out.println("**************************"); + Token token = tokenStore.createNewToken(user.getId().toString(), menuService.selectPermsStrArray(user.getId()), roleService.selectRoleStrArray(user.getId()), RedisUtils.DEFAULT_EXPIRE); + // 登记在线信息 + PublishFactory.recordUserOnlineInfo(user, token.getAccessToken()); + redis.set("QR:" + unique, token.getAccessToken(), 3600);//存储token值 + return "扫码成功"; + } else { + return "未在公众号绑定手机号"; + } + } else { //未绑定 + return "请先在公众号绑定手机号"; + } +// System.out.println("**************************"); +// System.out.println(sToken); +// System.out.println(unique); +// System.out.println(code); +// System.out.println(state); +// System.out.println(openid); +// System.out.println("**************************"); +// return "ssss"; + } + + /** + * 轮询是否登录 + * 参数:unique 认证标识,为get接口获取的字符串 + * 返回: + * code 为500时表示未成功扫码 + * code 为0 时,表示已经成功扫码登录,可以获取token值 + * + */ + @Ignore + @RequestMapping("/isLogin/{unique}") + public R isLogin(@PathVariable("unique") String unique) { + String token = redis.get("QR:" + unique); + if (StringUtils.isBlank(token)) return R.error("未成功扫码登录"); + return R.ok().put("token", token); + } + + +}