Commit 34e40bee by zhanghj

V1.4.0--提交给在线的管理员推送竞价单3小时无人竞价消息提醒功能代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@23473 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 821d1c54
Showing 23 changed files with 772 additions and 38 deletions
......@@ -3,7 +3,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.glsx</groupId>
<artifactId>car-service-common</artifactId>
<version>1.0.0</version>
......@@ -90,6 +90,12 @@
<artifactId>feign-okhttp</artifactId>
<version>10.1.0</version>
</dependency>
<!-- websocket -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
</dependencies>
<build>
......
package com.glsx.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
*
* @Title WebSocketConfig.java
* @Package com.glsx.common.config
* @Description TODO websocket配置
* @author zhanghj
* @date 2019年8月16日 上午11:19:15
* @version 1.0.0
*/
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
......@@ -2,6 +2,7 @@ package com.glsx.common.feign.client;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -53,5 +54,19 @@ import org.springframework.web.bind.annotation.RequestParam;
@RequestMapping(value="/carservice/ordercenter/order/getOrderOnHand", method= RequestMethod.GET)
public JSONObject getOrderOnHand();
/**
*
* @author zhanghj
* @Title: getBiddingOrderNoBidRemindList
* @Description: TODO 查询超过多少分钟内没有竞价,获取对拥有该单数据权限的普通账号进行推送列表
* @param minute 超过多少分钟
* @param timeInterval 定时任务时间间隔
* @return
* JSONObject
*
*/
@RequestMapping(value="/carservice/ordercenter/orderBidding/getBiddingOrderNoBidRemindList", method= RequestMethod.GET)
public JSONObject getBiddingOrderNoBidRemindList(@RequestParam("minute")Integer minute, @RequestParam("timeInterval")Integer timeInterval);
}
package com.glsx.common.feign.client;
import java.util.List;
import java.util.Map;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -128,4 +132,18 @@ public interface UserClient {
@RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/user/getMechanicSP")
JSONObject getMechanicSP(@RequestParam("userId")Integer userId);
/**
*
* @author zhanghj
* @Title: getOnlineManagerList
* @Description: TODO 获取在线管理员列表
* @return
* JSONObject
*
*/
@RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/user/getOnlineManagerList")
JSONObject getOnlineManagerList();
@RequestMapping(method = RequestMethod.POST, value = "/carservice/usercenter/user/sendBiddingOrderNoBidRemindMsg")
JSONObject sendBiddingOrderNoBidRemindMsg(@RequestParam("orderList")String orderList);
}
......@@ -25,6 +25,7 @@
package com.glsx.ordercenter.controller;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -196,4 +197,22 @@ public class OrderBiddingController extends BaseController{
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
/**
*
* @author zhanghj
* @Title: getBiddingOrderNoBidRemindList
* @Description: TODO 查询超过多少分钟内没有竞价,获取对拥有该单数据权限的普通账号进行推送列表
* @param request
* @param minute
* @param timeInterval
* @return
* ResultObject
*
*/
@RequestMapping(value = "/getBiddingOrderNoBidRemindList", method = {RequestMethod.GET})
public ResultObject getBiddingOrderNoBidRemindList(HttpServletRequest request, Integer minute, Integer timeInterval) {
List<SysOrder> list = orderBiddingService.getBiddingOrderNoBidRemindList(minute, timeInterval);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), list);
}
}
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.ordercenter.dto;
import java.io.Serializable;
/**
* @ClassName: Merchant
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月25日
*
*/
public class ManagerInfo implements Serializable{
/**
*
*/
private static final long serialVersionUID = -9112150707570352119L;
private Integer id;
private String name;
private String phone;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -64,5 +64,4 @@ public class MerchantInfo implements Serializable{
this.name = name;
}
}
package com.glsx.ordercenter.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.glsx.ordercenter.pojo.SysOrder;
/**
*
* @Title SysOrderBiddingMapper.java
* @Package com.glsx.ordercenter.mapper
* @Description TODO 竞价单相关mapper
* @author zhanghj
* @date 2019年8月19日 下午5:20:20
* @version 1.0.0
*/
public interface SysOrderBiddingMapper {
List<SysOrder> getBiddingOrderNoBidRemindList(@Param("minute")Integer minute,
@Param("timeInterval")Integer timeInterval);
}
\ No newline at end of file
......@@ -6,6 +6,8 @@ public class SysOrderServiceType {
private Integer orderId;
private String serviceType;
private String serviceTypeName;
public Integer getId() {
return id;
......@@ -30,4 +32,13 @@ public class SysOrderServiceType {
public void setServiceType(String serviceType) {
this.serviceType = serviceType == null ? null : serviceType.trim();
}
public String getServiceTypeName() {
return serviceTypeName;
}
public void setServiceTypeName(String serviceTypeName) {
this.serviceTypeName = serviceTypeName;
}
}
\ No newline at end of file
......@@ -49,6 +49,20 @@ public interface IOrderBiddingService {
ResultObject appointServiceProvider(SysOrderBiddingRecords record);
List<BiddingOrderResp> selectByOrderIdAndKeyWord(int pageIndex, int pageSize, Integer orderId, String keyWord);
/**
*
* @author zhanghj
* @Title: getBiddingOrderNoBidRemindList
* @Description: TODO 查询超过多少分钟内没有竞价,获取对拥有该单数据权限的普通账号进行推送列表
* @param minute
* @param timeInterval
* @return
* List<SysOrder>
*
*/
List<SysOrder> getBiddingOrderNoBidRemindList(Integer minute,
Integer timeInterval);
List<SysOrder> orderMarket(Page page,Integer serviceId, String keyWord);
......
......@@ -271,4 +271,5 @@ public interface IOrderService {
*
*/
ResultObject addBiddingOrder(HttpServletRequest request, SysOrder sysOrder);
}
......@@ -44,6 +44,7 @@ import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.OrderActiveStatusEnum;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.BiddingOrderResp;
import com.glsx.ordercenter.mapper.SysOrderBiddingMapper;
import com.glsx.ordercenter.dto.CarInfo;
import com.glsx.ordercenter.dto.MerchantInfo;
import com.glsx.ordercenter.mapper.DictionaryDataMapper;
......@@ -81,6 +82,9 @@ public class OrderBiddingServiceImpl implements IOrderBiddingService {
@Autowired
private CarBrandClient carBrandClient;
@Autowired
private SysOrderBiddingMapper sysOrderBiddingDao;
@Autowired
private DictionaryDataMapper dictionaryDataMapper;
......@@ -201,6 +205,14 @@ public class OrderBiddingServiceImpl implements IOrderBiddingService {
return list;
}
@Override
public List<SysOrder> getBiddingOrderNoBidRemindList(Integer minute,
Integer timeInterval) {
// TODO Auto-generated method stub
List<SysOrder> list = sysOrderBiddingDao.getBiddingOrderNoBidRemindList(minute, timeInterval);
return list;
}
/**
* 服务商端订单市场列表
*/
......
<?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.glsx.ordercenter.mapper.SysOrderBiddingMapper">
<resultMap type="com.glsx.ordercenter.pojo.SysOrder" id="noBidRemindResult">
<id column="uniqId" jdbcType="TINYINT" property="id"/>
<result column="order_sn" jdbcType="VARCHAR" property="orderSn" />
<result column="order_type" jdbcType="TINYINT" property="orderType" />
<result column="serviceTypes" jdbcType="VARCHAR" property="serviceTypes" />
<result column="shop_name" jdbcType="VARCHAR" property="merchantName" />
<!-- 用shopId放管理员id,不新加字段 -->
<result column="managerId" jdbcType="TINYINT" property="shopId"/>
</resultMap>
<select id="getBiddingOrderNoBidRemindList" resultMap="noBidRemindResult">
select
so.id as orderId, so.order_sn, su2.id as managerId, CONCAT(so.id, su2.id) as uniqId, sm.shop_name,
GROUP_CONCAT( sdd.data_value SEPARATOR ',') serviceTypes
from
sys_order so
LEFT JOIN sys_user su ON so.shop_id = su.id
LEFT JOIN sys_merchant sm ON su.id = sm.user_id
LEFT JOIN sys_user_org suo ON su.org_id = suo.org_id
LEFT JOIN sys_user su2 ON suo.user_id = su2.id
LEFT JOIN sys_order_service_type sost ON so.id = sost.order_id
LEFT JOIN sys_dict_data sdd ON sost.service_type = sdd.data_key
where
su2.user_type = 0
AND so.order_type = 4
AND so.active_status = 15
AND so.canceled = 1
and so.quote_last_time > NOW()
AND TIMESTAMPDIFF(MINUTE, so.create_time, NOW()) &gt;= #{minute}
AND TIMESTAMPDIFF(MINUTE, so.create_time, NOW()) &lt;= (#{minute} + #{timeInterval} -1)
GROUP BY so.order_sn, su2.id
ORDER BY so.order_sn desc, su2.id DESC
</select>
</mapper>
\ No newline at end of file
package com.glsx.task.config;
import com.glsx.task.schedule.OderPendingRemindTask;
import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
......@@ -9,6 +8,8 @@ import org.quartz.TriggerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.glsx.task.schedule.BiddingOrderNoBidRemindTask;
import com.glsx.task.schedule.OderPendingRemindTask;
import com.glsx.task.schedule.OrderTimeoutRemindTask;
@Configuration
......@@ -49,4 +50,22 @@ public class QuartzConfig {
.withSchedule(scheduleBuilder).build();
return trigger;
}
@Bean
public JobDetail biddingOrderNoBidRemindTaskDetail() {
JobDetail jobDetail = JobBuilder.newJob(BiddingOrderNoBidRemindTask.class)
.withIdentity("biddingOrderNoBidRemindTask").storeDurably().build();
return jobDetail;
}
@Bean
public Trigger biddingOrderNoBidRemindTaskDetailTrigger() {
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder
.cronSchedule("0 /1 * * * ?");
Trigger trigger = TriggerBuilder.newTrigger()
.forJob(biddingOrderNoBidRemindTaskDetail())
.withIdentity("biddingOrderNoBidRemindTask")
.withSchedule(scheduleBuilder).build();
return trigger;
}
}
......@@ -27,5 +27,7 @@ public class Constants {
* 订单微信消息提醒状态
*/
public static final int ORDER_TIME_OUT_REMIND = 6;
public static final String ORDER_BIDDING_ORDER_NO_BID_REMIND_HOUR = "order.biddingorder.nobid.remind.hour";
}
package com.glsx.task.schedule;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultCodeEnum;
import com.glsx.common.feign.client.OrderClient;
import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.task.constants.Constants;
/**
*
* @Title BiddingOrderTask.java
* @Package com.glsx.task.schedule
* @Description TODO 竞价单定时任务:超过3小时无人报价的竞价单,则通过浏览器级别弹窗对拥有该单数据权限的普通账号进行推送
* @author zhanghj
* @date 2019年8月16日 下午5:43:25
* @version 1.0.0
*/
public class BiddingOrderNoBidRemindTask extends QuartzJobBean{
private static final Logger logger = LoggerFactory.getLogger(BiddingOrderNoBidRemindTask.class);
@Autowired
private OrderClient orderClient;
@Autowired
private UserClient userClient;
@Override
protected void executeInternal(JobExecutionContext context)
throws JobExecutionException {
// TODO Auto-generated method stub
logger.info("开始执行竞价单超时定时任务提醒");
Integer hour = Integer.parseInt(PropertiesUtil.getProperty(Constants.ORDER_BIDDING_ORDER_NO_BID_REMIND_HOUR, "3"));
Integer minute = hour * 60;
Integer timeInterval = 5;
JSONObject result = orderClient.getBiddingOrderNoBidRemindList(minute, timeInterval);
JSONArray orderArray = new JSONArray();
if (result != null && result.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
orderArray = result.getJSONArray("data");
}
JSONObject managerResult = userClient.getOnlineManagerList();
JSONArray userArray = new JSONArray();
if (managerResult != null && managerResult.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
userArray = managerResult.getJSONArray("data");
}
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
for (int j = 0; j < userArray.size(); j++) {
Integer mId = userArray.getInteger(j);
for (int i = 0; i < orderArray.size(); i++) {
Integer managerId = orderArray.getJSONObject(i).getInteger(
"shopId");
if (managerId.equals(mId)) {
Map<String, Object> map = new HashMap<String, Object>();
String shopName = orderArray.getJSONObject(i).getString(
"merchantName");
String orderSn = orderArray.getJSONObject(i).getString(
"orderSn");
String serviceTypes = orderArray.getJSONObject(i)
.getString("serviceTypes");
map.put("hour", hour);
map.put("managerId", managerId);
map.put("orderSn", orderSn);
map.put("shopName", shopName);
map.put("serviceTypes", serviceTypes);
list.add(map);
}
}
}
if (list.size() > 0) {
logger.info("竞价单超时可发送列表", JSON.toJSONString(list));
userClient.sendBiddingOrderNoBidRemindMsg(JSON.toJSONString(list));
}
logger.info("结束执行竞价单超时定时任务提醒");
}
}
......@@ -17,7 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* @Title Application.java
* @Package com.glsx.usercenter
* @Description TODO
* @author zhanghj
* @author zhanghjzheg
* @date 2019年1月16日 下午2:25:01
* @version 1.0.0
*/
......
package com.glsx.usercenter.component;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.EncodeException;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
*
* @Title AsyncWebScocketMsgSend.java
* @Package com.glsx.usercenter.component
* @Description TODO 异步websocke消息发送
* @author zhanghj
* @date 2019年8月16日 下午4:11:55
* @version 1.0.0
*/
@Component
public class AsyncWebScocketMsgSend {
/**
* 群发自定义消息
* @throws EncodeException
* */
@Async
public void sendInfo(JSONArray orderList) {
ConcurrentHashMap<Integer, MyWebSocket> webSocketSet = MyWebSocket.webSocketSet;
for (Map.Entry<Integer, MyWebSocket> param : webSocketSet.entrySet()) {
for (int i = 0; i < orderList.size(); i++) {
try {
JSONObject orderObj = orderList.getJSONObject(i);
Integer managerId = orderObj.getInteger("managerId");
if (param.getKey().equals(managerId)) {
MyWebSocket myWebSocket = param.getValue();
myWebSocket.sendMessage(orderObj);
}
} catch (Exception e) {
continue;
}
}
}
}
}
package com.glsx.usercenter.component;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.websocket.EncodeException;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject;
import com.glsx.usercenter.constants.ResultCodeEnum;
/**
*
* @Title MyWebSocket.java
* @Package com.glsx.usercenter.component
* @Description TODO websocket的配置
* @author zhanghj
* @date 2019年8月16日 下午2:32:55
* @version 1.0.0
*/
@ServerEndpoint(value = "/websocket/{userId}")
@Component
public class MyWebSocket {
//静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
private static int onlineCount = 0;
//concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
public static ConcurrentHashMap<Integer, MyWebSocket> webSocketSet = new ConcurrentHashMap<Integer, MyWebSocket>(16);
//与某个客户端的连接会话,需要通过它来给客户端发送数据
private Session session;
private static Logger log = LoggerFactory.getLogger(MyWebSocket.class);
/**
* 连接建立成功调用的方法*/
@OnOpen
public void onOpen(@PathParam(value="userId") Integer userId,Session session) {
log.info("userId="+userId);
this.session = session;
addWebSocketSet(userId, this);
}
private void addWebSocketSet(Integer userId, MyWebSocket myWebSocket) {
// TODO Auto-generated method stub
if (webSocketSet.containsKey(userId)) {
webSocketSet.replace(userId, myWebSocket);
} else {
webSocketSet.put(userId, myWebSocket);
addOnlineCount(); //在线数加1
log.info("有新连接加入!当前在线人数为" + getOnlineCount());
}
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose(@PathParam(value="userId") Integer userId) {
webSocketSet.remove(userId); //从set中删除
subOnlineCount(); //在线数减1
log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息*/
@OnMessage
public void onMessage(String message, Session session) throws Exception {
this.session = session;
message = "来自客户端的消息:" + message;
log.info(message);
try {
JSONObject json = new JSONObject();
sendMessage( json);
} catch (Exception e) {
log.error("onMessage方法异常"+e.toString());
e.printStackTrace();
}
//群发消息
// sendInfo("群发消息"+message);
}
/**
* 发生错误时调用
@OnError
**/
public void onError(Session session, Throwable error) {
log.error("onMessage方法异常"+error.toString());
error.printStackTrace();
}
/**
* 发送消息需注意方法加锁synchronized,避免阻塞报错
* 注意session.getBasicRemote()与session.getAsyncRemote()的区别
* @param message
* @throws IOException
* @throws EncodeException
*/
public synchronized void sendMessage(JSONObject message) throws IOException, EncodeException {
//this.session.getBasicRemote().sendText(message);
ResultObject result = new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), message);
this.session.getAsyncRemote().sendText(JSON.toJSONString(result));
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
MyWebSocket.onlineCount++;
}
public static synchronized void subOnlineCount() {
MyWebSocket.onlineCount--;
}
}
package com.glsx.usercenter.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.validation.groups.Default;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.ExcessiveAttemptsException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.subject.Subject;
import org.crazycake.shiro.RedisSessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.util.StringUtil;
......@@ -17,32 +45,19 @@ import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.dto.MerchantInfo;
import com.glsx.usercenter.mapper.SysUserImageMapper;
import com.glsx.usercenter.mapper.SysUserMapper;
import com.glsx.usercenter.pojo.user.*;
import com.glsx.usercenter.pojo.user.SysManager;
import com.glsx.usercenter.pojo.user.SysMechanic;
import com.glsx.usercenter.pojo.user.SysMerchant;
import com.glsx.usercenter.pojo.user.SysResourceMatching;
import com.glsx.usercenter.pojo.user.SysUser;
import com.glsx.usercenter.pojo.user.SysUserExample;
import com.glsx.usercenter.pojo.vo.UserQueryVo;
import com.glsx.usercenter.service.IAreaService;
import com.glsx.usercenter.service.ISysOrganizationService;
import com.glsx.usercenter.service.SysUserService;
import com.glsx.usercenter.shiro.CustomToken;
import com.glsx.usercenter.utils.AccountValidatorUtil;
import com.glsx.usercenter.utils.QRCodeUtil;
import com.glsx.usercenter.utils.ShiroUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.subject.Subject;
import org.crazycake.shiro.RedisSessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.validation.groups.Default;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author duanht
......@@ -1201,4 +1216,36 @@ public class UserController extends BaseController {
result.setData(map);
return result;
}
/**
*
* @author zhanghj
* @Title: getOnlineManagerList
* @Description: TODO 获取在线的管理员用户
* @return
* ResultObject
*
*/
@RequestMapping(value = "/getOnlineManagerList", method = {RequestMethod.GET})
public ResultObject getOnlineManagerList() {
Set<Integer> set = new HashSet<Integer>();
set = sysUserService.getOnlineManagerList();
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), set);
}
/**
*
* @author zhanghj
* @Title: sendBiddingOrderNoBidRemindMsg
* @Description: TODO 给在线的管理员推送竞价单3小时无人竞价消息提醒
* @param array
* @return
* ResultObject
*
*/
@RequestMapping(value = "/sendBiddingOrderNoBidRemindMsg", method = {RequestMethod.POST})
public ResultObject sendBiddingOrderNoBidRemindMsg(@RequestParam("orderList")String orderList) {
sysUserService.sendBiddingOrderNoBidRemindMsg(orderList);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
}
......@@ -8,11 +8,14 @@ import com.glsx.usercenter.dto.ServiceInfo;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.user.*;
import com.glsx.usercenter.pojo.vo.UserQueryVo;
import org.apache.shiro.authc.AuthenticationException;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author duanht
......@@ -336,4 +339,28 @@ public interface SysUserService {
* @Description: TODO
*/
SysUser wxLogin(HttpServletRequest request, Integer userType, String miniCode);
/**
*
* @author zhanghj
* @Title: BiddingOrderNoBidRemindMsg
* @Description: TODO
* void
*
*/
void BiddingOrderNoBidRemindMsg();
Set<Integer> getOnlineManagerList();
/**
*
* @author zhanghj
* @Title: sendBiddingOrderNoBidRemindMsg
* @Description: TODO
* @param orderList
* void
*
*/
void sendBiddingOrderNoBidRemindMsg(String orderList);
}
package com.glsx.usercenter.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.glsx.common.constants.ResultObject;
......@@ -9,31 +30,38 @@ import com.glsx.common.utils.Page;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.wehcat.WechatMiniUtils;
import com.glsx.common.utils.wehcat.WechatUtils;
import com.glsx.usercenter.component.AsyncWebScocketMsgSend;
import com.glsx.usercenter.component.MyWebSocket;
import com.glsx.usercenter.constants.Constants;
import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.dto.ServiceInfo;
import com.glsx.usercenter.exception.BusinessException;
import com.glsx.usercenter.exception.SysException;
import com.glsx.usercenter.mapper.*;
import com.glsx.usercenter.mapper.SysOrganizationMapper;
import com.glsx.usercenter.mapper.SysResourceMatchingMapper;
import com.glsx.usercenter.mapper.SysUserImageMapper;
import com.glsx.usercenter.mapper.SysUserMapper;
import com.glsx.usercenter.mapper.SysUserOrgMapper;
import com.glsx.usercenter.mapper.SysUserRoleMapper;
import com.glsx.usercenter.mapper.SysUserServicesMapper;
import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.user.*;
import com.glsx.usercenter.pojo.user.SysManager;
import com.glsx.usercenter.pojo.user.SysMechanic;
import com.glsx.usercenter.pojo.user.SysMerchant;
import com.glsx.usercenter.pojo.user.SysResourceMatching;
import com.glsx.usercenter.pojo.user.SysResourceMatchingExample;
import com.glsx.usercenter.pojo.user.SysUser;
import com.glsx.usercenter.pojo.user.SysUserExample;
import com.glsx.usercenter.pojo.user.SysUserImage;
import com.glsx.usercenter.pojo.user.SysUserImageExample;
import com.glsx.usercenter.pojo.user.SysUserOrg;
import com.glsx.usercenter.pojo.user.SysUserRole;
import com.glsx.usercenter.pojo.user.SysUserServices;
import com.glsx.usercenter.pojo.user.SysUserServicesExample;
import com.glsx.usercenter.pojo.vo.UserQueryVo;
import com.glsx.usercenter.service.IAreaService;
import com.glsx.usercenter.service.SysUserService;
import com.glsx.usercenter.utils.ShiroUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
......@@ -64,6 +92,10 @@ public class SysUserServiceImpl implements SysUserService {
private SysUserImageMapper sysUserImageMapper;
@Autowired
private IAreaService iAreaService;
@Autowired
private MyWebSocket myWebSocket;
@Autowired
private AsyncWebScocketMsgSend asyncWebScocketMsgSend;
public static void main(String[] args) {
System.out.println(new SysUserServiceImpl().encryptPassword("123456"));
......@@ -919,4 +951,25 @@ public class SysUserServiceImpl implements SysUserService {
}
return sysUser;
}
@Override
public void BiddingOrderNoBidRemindMsg() {
// TODO Auto-generated method stub
}
@Override
public Set<Integer> getOnlineManagerList() {
// TODO Auto-generated method stub
Map map = myWebSocket.webSocketSet;
Set set = map.keySet();
return set;
}
@Override
public void sendBiddingOrderNoBidRemindMsg(String orderList) {
// TODO Auto-generated method stub
JSONArray array = JSONArray.parseArray(orderList);
asyncWebScocketMsgSend.sendInfo(array);
}
}
<!DOCTYPE HTML>
<html>
<head>
<title>My WebSocket</title>
</head>
<body>
Welcome<br/>
<input id="text" type="text" /><button onclick="send()">Send</button> <button onclick="closeWebSocket()">Close</button>
<div id="message">
</div>
</body>
<script type="text/javascript">
var websocket = null;
//判断当前浏览器是否支持WebSocket
if('WebSocket' in window){
websocket = new WebSocket("ws://localhost:8087/carservice/usercenter/websocket/739");
}
else{
alert('Not support websocket')
}
//连接发生错误的回调方法
websocket.onerror = function(){
setMessageInnerHTML("error");
};
//连接成功建立的回调方法
websocket.onopen = function(event){
setMessageInnerHTML("open");
}
//接收到消息的回调方法
websocket.onmessage = function(event){
setMessageInnerHTML(event.data);
}
//连接关闭的回调方法
websocket.onclose = function(){
setMessageInnerHTML("close");
}
//监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
window.onbeforeunload = function(){
websocket.close();
}
//将消息显示在网页上
function setMessageInnerHTML(innerHTML){
document.getElementById('message').innerHTML += innerHTML + '<br/>';
}
//关闭连接
function closeWebSocket(){
websocket.close();
}
//发送消息
function send(){
var message = document.getElementById('text').value;
websocket.send(message);
}
</script>
</html>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!