xboot-admin/src/main/resources/application.yml
@@ -26,7 +26,7 @@ url: jdbc:mysql://127.0.0.1:3306/tobacco?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8 username: root # Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456 password: ENC(BM0tNVy9I6d8RXo2G/TS8ItskvLDlA5UwAaqExN5zun31YUmmULLPNrKCg26Ood1) password: ENC(/1qjpLsQSzc4KM+2VhqLecwQu3npNYZo/zclpH/VR34dMdLeW2IVin6V1vH1Xug4) type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.jdbc.Driver # Druid StatViewServlet配置 @@ -168,7 +168,7 @@ # token中存储用户权限数据 设为true开启后可避免每次请求再获取用户权限,但有可能导致编辑权限菜单后无法读取到最新权限数据(需用户重新登录) storePerms: true # token过期时间 redis模式有请求自动刷新(分钟) tokenExpireTime: 60 tokenExpireTime: 600 # 用户选择 保存登录状态/记住我 对应token过期时间(天) saveLoginTime: 7 # 限制用户登陆错误次数(次) @@ -288,6 +288,7 @@ - /**/*.png - /**/*.ico - /xboot/test/** - /xboot/fingerprint/getAll # 限流及黑名单不拦截的路径 limitUrls: - /**/*.js xboot-core/src/main/java/cn/exrick/xboot/core/dao/UserDao.java
@@ -64,4 +64,7 @@ @Modifying @Query("update User u set u.departmentTitle=?2 where u.departmentId=?1") void updateDepartmentTitle(String departmentId, String departmentTitle); @Query("select count(id) from User u where u.type2=?1") int countByType(int type); } xboot-core/src/main/java/cn/exrick/xboot/core/service/UserService.java
@@ -76,4 +76,6 @@ * @param departmentTitle */ void updateDepartmentTitle(String departmentId, String departmentTitle); int countByType(int type); } xboot-core/src/main/java/cn/exrick/xboot/core/serviceimpl/UserServiceImpl.java
@@ -196,4 +196,9 @@ userDao.updateDepartmentTitle(departmentId, departmentTitle); } @Override public int countByType(int type) { return userDao.countByType(type); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/appController/LoginController.java
File was deleted xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java
New file @@ -0,0 +1,38 @@ package cn.exrick.xboot.your.controller.pc; import cn.exrick.xboot.core.common.redis.RedisTemplateHelper; import cn.exrick.xboot.core.common.utils.ResultUtil; import cn.exrick.xboot.core.common.vo.Result; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.*; /** * @author whj */ @Slf4j @RestController @Api(tags = "大屏统计接口") @RequestMapping("/xboot/pcStatistic") @Transactional public class StatisticController { @Autowired private RedisTemplateHelper redisTemplateHelper; @RequestMapping(value = "/getIndex1", method = RequestMethod.GET) @ApiOperation(value = "获取首页数据") public Result<Object> getIndex1() { Map<String,Object> map = new HashMap<>(); Set<String> scan = redisTemplateHelper.scan("*statistic1::*"); for (String str : scan) { map.put(str.substring(12),redisTemplateHelper.get(str)); } return new ResultUtil<Object>().setData(map); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/Customer.java
@@ -78,6 +78,9 @@ @ApiModelProperty(value = "接货人名称") private String recvName; @ApiModelProperty(value = "微信id") private String openId; @Transient @TableField(exist = false) @ApiModelProperty(value = "接货人列表") xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/DrivingRecord.java
@@ -101,6 +101,9 @@ @ApiModelProperty(value = "处理意见") private String content; @ApiModelProperty(value = "被赞数") private String likes; @Transient @TableField(exist = false) private double beginMileage; xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderTask.java
@@ -94,6 +94,9 @@ @ApiModelProperty(value = "收货人id") private String customerReceiveId; @ApiModelProperty(value = "是否点赞 0:否 1:是") private String likes; @Transient @TableField(exist = false) @ApiModelProperty(value = "商户名称") xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CustomerMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import cn.exrick.xboot.your.entity.Customer; import org.apache.ibatis.annotations.Select; import java.util.List; @@ -11,4 +12,6 @@ */ public interface CustomerMapper extends BaseMapper<Customer> { @Select("select count(id) from t_customer") int count(); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/EquipmentMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import cn.exrick.xboot.your.entity.Equipment; import org.apache.ibatis.annotations.Select; import java.util.List; @@ -11,4 +12,6 @@ */ public interface EquipmentMapper extends BaseMapper<Equipment> { @Select("select count(id) from t_equipment where type=#{arg0} and status=0") int countByTypeAndStatus(int type); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/OrderTaskMapper.java
@@ -27,4 +27,13 @@ @Select("SELECT a.*,b.name as temp FROM t_order_task a LEFT JOIN t_customer b ON a.customer_id=b.id ${ew.customSqlSegment} ") @Results({@Result(column="temp", property="customerName", jdbcType = JdbcType.VARCHAR)}) List<OrderTask> list2(@Param(Constants.WRAPPER) QueryWrapper<OrderTask> wrapper2); @Select("SELECT sum(num) FROM t_order_task") int sumNum(); @Select("SELECT count(id) FROM t_order_task where status=#{arg0}") int sumStatus(int type); @Select("SELECT count(id) FROM t_order_task where likes=1") int countLike(); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/UserStatisticMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import cn.exrick.xboot.your.entity.UserStatistic; import org.apache.ibatis.annotations.Select; import java.util.List; @@ -11,4 +12,6 @@ */ public interface UserStatisticMapper extends BaseMapper<UserStatistic> { @Select("select sum(driving) from t_user_statistic") int sumDriving(); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticPcScheduleImpl.java
New file @@ -0,0 +1,96 @@ package cn.exrick.xboot.your.schedulings; import cn.exrick.xboot.core.common.redis.RedisTemplateHelper; import cn.exrick.xboot.core.entity.User; import cn.exrick.xboot.core.service.MessageService; import cn.exrick.xboot.core.service.UserService; import cn.exrick.xboot.your.entity.*; import cn.exrick.xboot.your.service.*; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.Date; import java.util.List; @Component public class StatisticPcScheduleImpl { @Autowired private IUserStatisticService iUserStatisticService; @Autowired private UserService userService; @Autowired private IDrivingRecordService iDrivingRecordService; @Autowired private IOrderTaskService iOrderTaskService; @Autowired private IAreaService iAreaService; @Autowired private ICustomerService iCustomerService; @Autowired private RedisTemplateHelper redisTemplate; @Autowired private ICarService iCarService; @Autowired private MessageService messageService; @Autowired private IRemoteCallService iRemoteCallService; @Autowired private IEquipmentService iEquipmentService; public static final String HEAD = "statistic1::"; @Scheduled(cron="0 */10 * * * ?")//每小时 public void execute(){ redisTemplate.set(HEAD+"car",iCarService.count()+"");//车辆 redisTemplate.set(HEAD+"user",userService.countByType(0)+"");//司机 redisTemplate.set(HEAD+"user2",userService.countByType(1)+"");//配送员 redisTemplate.set(HEAD+"dept","3");//转运站数 redisTemplate.set(HEAD+"area",iAreaService.count()+"");//片区数 redisTemplate.set(HEAD+"customer",iCustomerService.count()+"");//商户数 redisTemplate.set(HEAD+"out",iDrivingRecordService.count()+"");//出车次数 redisTemplate.set(HEAD+"driving",iUserStatisticService.sumDriving()+"");//行驶里程 redisTemplate.set(HEAD+"num",iOrderTaskService.sumNum()+"");//送货包数 redisTemplate.set(HEAD+"status",iOrderTaskService.sumStatus(1)+"");//电子签收次数 redisTemplate.set(HEAD+"notice",messageService.getTotalCount()+"");//通知公告条数 redisTemplate.set(HEAD+"video","0");//视频监控次数 redisTemplate.set(HEAD+"call",iRemoteCallService.count()+"");//远程呼叫次数 redisTemplate.set(HEAD+"paiCha","0");//事故隐患排查 //redisTemplate.set(HEAD+"wx",iCustomerService.sumLogin()+"");//小程序登陆次数 redisTemplate.set(HEAD+"wxRate",iCustomerService.countOpenId()+"");//小程序使用率 int i = iOrderTaskService.countLike(); redisTemplate.set(HEAD+"like",i+"");//互动次数 int count = iOrderTaskService.count(); if(count==0){ redisTemplate.set(HEAD+"likeRate","0");//互动率 }else{ redisTemplate.set(HEAD+"likeRate",(i*100)/count+"");//互动率 } redisTemplate.set(HEAD+"outCar",iEquipmentService.countByTypeAndStatus(0)+"");//出发车辆 redisTemplate.set(HEAD+"outCar","0");//危险开启 QueryWrapper<Customer> wrapper = new QueryWrapper<>(); String format = DateUtil.format(new Date(), "yyyy-MM-dd"); wrapper.between("create_time",format+" 00:00:00",format+" 23:59:59"); redisTemplate.set(HEAD+"outCar",iCustomerService.count(wrapper)+"");//今日新增商户 } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICustomerService.java
@@ -11,4 +11,5 @@ */ public interface ICustomerService extends IService<Customer> { int countOpenId(); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/IEquipmentService.java
@@ -11,4 +11,5 @@ */ public interface IEquipmentService extends IService<Equipment> { int countByTypeAndStatus(int i); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/IOrderTaskService.java
@@ -15,4 +15,10 @@ int sum(String id, String format); List<OrderTask> list2(QueryWrapper<OrderTask> wrapper2); int sumNum(); int sumStatus(int i); int countLike(); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/IUserStatisticService.java
@@ -11,4 +11,5 @@ */ public interface IUserStatisticService extends IService<UserStatistic> { int sumDriving(); } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICustomerServiceImpl.java
@@ -3,6 +3,7 @@ import cn.exrick.xboot.your.mapper.CustomerMapper; import cn.exrick.xboot.your.entity.Customer; import cn.exrick.xboot.your.service.ICustomerService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -23,4 +24,17 @@ @Autowired private CustomerMapper customerMapper; @Override public int countOpenId() { QueryWrapper<Customer> wrapper = new QueryWrapper<>(); wrapper.isNotNull("open_id"); int i = customerMapper.selectCount(wrapper); int i2 = customerMapper.count(); if(i2==0){ return 0; }else{ return (i*100)/i2; } } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/IEquipmentServiceImpl.java
@@ -23,4 +23,9 @@ @Autowired private EquipmentMapper equipmentMapper; @Override public int countByTypeAndStatus(int type) { return equipmentMapper.countByTypeAndStatus(type); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/IOrderTaskServiceImpl.java
@@ -38,4 +38,19 @@ public List<OrderTask> list2(QueryWrapper<OrderTask> wrapper2) { return orderTaskMapper.list2(wrapper2); } @Override public int sumNum() { return orderTaskMapper.sumNum(); } @Override public int sumStatus(int type) { return orderTaskMapper.sumStatus(type); } @Override public int countLike() { return orderTaskMapper.countLike(); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/IUserStatisticServiceImpl.java
@@ -23,4 +23,9 @@ @Autowired private UserStatisticMapper userStatisticMapper; @Override public int sumDriving() { return userStatisticMapper.sumDriving(); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/ClientMQTT.java
New file @@ -0,0 +1,60 @@ package cn.exrick.xboot.your.util; import java.util.concurrent.ScheduledExecutorService; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttTopic; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; public class ClientMQTT { public static final String HOST = "tcp://10.10.101.1:1883"; //public static final String TOPIC = "\"5201154049\": \"artemis/event_msa_alarm/5201154049/admin\""; public static final String TOPIC = "5201154049"; private static final String clientid = "28156526"; private MqttClient client; private MqttConnectOptions options; private String userName = "artemis_28156526_8SS2BGXE"; private String passWord = "1GVZ2F7C"; private ScheduledExecutorService scheduler; private void start() { try { // host为主机名,clientid即连接MQTT的客户端ID,一般以唯一标识符表示,MemoryPersistence设置clientid的保存形式,默认为以内存保存 client = new MqttClient(HOST, clientid, new MemoryPersistence()); // MQTT的连接设置 options = new MqttConnectOptions(); // 设置是否清空session,这里如果设置为false表示服务器会保留客户端的连接记录,这里设置为true表示每次连接到服务器都以新的身份连接 options.setCleanSession(true); // 设置连接的用户名 options.setUserName(userName); // 设置连接的密码 options.setPassword(passWord.toCharArray()); // 设置超时时间 单位为秒 options.setConnectionTimeout(30); // 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制 options.setKeepAliveInterval(20); // 设置回调 client.setCallback(new PushCallback()); MqttTopic topic = client.getTopic(TOPIC); //setWill方法,如果项目中需要知道客户端是否掉线可以调用该方法。设置最终端口的通知消息 options.setWill(topic, "close".getBytes(), 2, true); client.connect(options); //订阅消息 int[] Qos = {1}; String[] topic1 = {TOPIC}; client.subscribe(topic1, Qos); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws MqttException { ClientMQTT client = new ClientMQTT(); client.start(); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java
@@ -1,5 +1,6 @@ package cn.exrick.xboot.your.util; import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; @@ -102,13 +103,18 @@ put("https://",findHistoryGpsDataApi); } }; String eventTypes[] = {"5201154049"}; String body= JSONUtil.toJsonStr(eventTypes); BigDecimal eventTypes[] = {new BigDecimal(new String("5201154049"))}; Map<String,Object> map = new HashMap<>(); map.put("eventTypes",eventTypes); String body= JSONUtil.toJsonStr(map); System.out.println(body); String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json"); return result; } public static void main(String[] args) { getTopicInfo(); // FindHistoryGpsRequest findHistoryGpsRequest = new FindHistoryGpsRequest(); // findHistoryGpsRequest.setVehicleIndexCode("b279d865eabe497db465eb2f4d2cc87d"); // findHistoryGpsRequest.setPageNo(1); @@ -119,5 +125,9 @@ // String code[] = {"b279d865eabe497db465eb2f4d2cc87d"}; // System.out.println(findLatestGps(code)); // PreviewURLsVo previewURLsVo = new PreviewURLsVo(); // previewURLsVo.setCameraIndexCode("b279d865eabe497db465eb2f4d2cc87d"); // previewURLs(previewURLsVo); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/PushCallback.java
New file @@ -0,0 +1,41 @@ package cn.exrick.xboot.your.util; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttMessage; /** * 发布消息的回调类 * * 必须实现MqttCallback的接口并实现对应的相关接口方法CallBack 类将实现 MqttCallBack。 * 每个客户机标识都需要一个回调实例。在此示例中,构造函数传递客户机标识以另存为实例数据。 * 在回调中,将它用来标识已经启动了该回调的哪个实例。 * 必须在回调类中实现三个方法: * * public void messageArrived(MqttTopic topic, MqttMessage message)接收已经预订的发布。 * * public void connectionLost(Throwable cause)在断开连接时调用。 * * public void deliveryComplete(MqttDeliveryToken token)) * 接收到已经发布的 QoS 1 或 QoS 2 消息的传递令牌时调用。 * 由 MqttClient.connect 激活此回调。 * */ public class PushCallback implements MqttCallback { public void connectionLost(Throwable cause) { // 连接丢失后,一般在这里面进行重连 System.out.println("连接断开,可以做重连"); } public void deliveryComplete(IMqttDeliveryToken token) { System.out.println("deliveryComplete---------" + token.isComplete()); } public void messageArrived(String topic, MqttMessage message) throws Exception { // subscribe后得到的消息会执行到这里面 System.out.println("接收消息主题 : " + topic); System.out.println("接收消息Qos : " + message.getQos()); System.out.println("接收消息内容 : " + new String(message.getPayload())); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/Recv.java
New file @@ -0,0 +1,30 @@ package cn.exrick.xboot.your.util; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.DeliverCallback; public class Recv { private final static String QUEUE_NAME = "5201154049"; public static void main(String[] argv) throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("111.63.178.115"); factory.setPort(1883); factory.setUsername("artemis_28156526_8SS2BGXE"); factory.setPassword("1GVZ2F7C"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); //请注意,我们也在这里声明了队列。因为我们可能在发布者之前启动消费者,所以我们希望在尝试使用消息之前确保队列存在。 channel.queueDeclare(QUEUE_NAME, false, false, false, null); System.out.println(" [*] Waiting for messages. To exit press CTRL+C"); //我们即将告诉服务器从队列中传递消息。因为它会异步地向我们发送消息, // 所以我们以对象的形式提供一个回调,它将缓冲消息,直到我们准备好使用它们。这就是DeliverCallback子类的作用。 DeliverCallback deliverCallback = (consumerTag, delivery) -> { String message = new String(delivery.getBody(), "UTF-8"); System.out.println(" [x] Received '" + message + "'"); }; channel.basicConsume(QUEUE_NAME, true, deliverCallback, consumerTag -> { }); } } xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/vo/PreviewURLsVo.java
@@ -1,7 +1,7 @@ package cn.exrick.xboot.your.vo; public class PreviewURLsVo { private String protocol;//协议类型(rtsp-rtsp协议,rtmp-rtmp协议,hls-hLS协议),未填写为rtsp协议 private String protocol="rtsp";//协议类型(rtsp-rtsp协议,rtmp-rtmp协议,hls-hLS协议),未填写为rtsp协议 private String cameraIndexCode; private Integer streamType=0;//码流类型(0-主码流,1-子码流),未填默认为主码流 private Integer transmode=0;//协议类型( 0-udp,1-tcp),默认为tcp,在protocol设置为rtsp或者rtmp时有效