提交 9f087532 编写于 作者: S shi.zeyuan

1.整理因字段变更出现问题常用的sql

2.....
上级 8403ee36
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -28,8 +28,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -48,8 +48,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -44,8 +44,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -44,8 +44,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -44,8 +44,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -44,8 +44,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -44,8 +44,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -44,8 +44,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -42,8 +42,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
......@@ -26,8 +26,8 @@
<table style="font-size: 12px;font-weight: bold">
<tr>
<td>模型</td>
<td>时间</td>
<td>联赛</td>
<td style="min-width: 47px">时间</td>
<td style="min-width: 45px">联赛</td>
<td>主队(让球)客队</td>
<td>比分</td>
<td>推荐</td>
......
#Linux处理性能问题常用命令(物联网后台开发)
~~~
本人专职于物联网后台,以下是一些自己在开发调试问题常用到一些Linux命令.
~~~
##$ 命令集
~~~
#@监控系统命令
vmstat 1
#@sysstat 每秒显示1次,仅显示3次
#监控网上
sar -n DEV 1 3
#系统负载
sar -q 1 3
#磁盘读写
sar -b 1 3
#@磁盘使用,查看占用磁盘最高的是哪个进程
iotop
#io性能 每秒显示1次,仅显示3次
iostat -x 1 3
#@dump数据包
tcpdump -nn port 80
tcpdump -nn -c 100 -w 1.cap
tcpdump udp port 17905 -w 17905.cap
#@查看网卡是否连接
mii-tool ens33
ethtool ens33
#@性能调试监控工具
iperf -u -s -p5003
iperf -c 172.168.7.152 -u -b 600m
iperf -c 172.19.53.107 -p5003 -u -b 600m
#@流量监控
iftop -Pn
#@查看端口占用
netstat -su
#一个小技巧:直接查看以下数据的并发量
netstat -an |awk '/^tcp/{++sta[$NF]} END {for(key in sta) print key,"\t",sta[key]}'
netstat -an |awk '/^udp/{++sta[$NF]} END {for(key in sta) print key,"\t",sta[key]}'
#@ss -an 和nestat 异曲同工,不足是不会显示进程的名字
ss -an
#@ping的话可以来判断丢包率,tracert可以用来跟踪路由,在Linux中有一个更好的网络连通性判断工具,它可以结合ping nslookup tracert 来判断网络的相关特性,这个命令就是mtr
mtr -rw www.baidu.com
#@文档格式转unix
yum install dos2unix -y
dos2unix *.sh
~~~
#VirtualBox安装CentOS的网络配置
##$ 前言
* 镜像:CentOS-6.4-i386-minimal.iso
##$ 配置目标
* 虚拟机里的CentOS既可以和主机互联,同时也可以连上外网
##$ 碰到的错误
~~~
使用ping时,错误:
network is unreachable
service network restart时,错误:
Device eth0 does not seem to be present.
~~~
## 1.先配置好Host-only和Nat
![virtualbox_1.jpg](https://upload-images.jianshu.io/upload_images/3285005-cc541cb072f8b9c4.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![virtualbox_2.jpg](https://upload-images.jianshu.io/upload_images/3285005-04ab2bd7cd665bdf.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 2.查看文件cat /etc/udev/rules.d/70-persistent-net.rules
查看配置的上图的mac地址 是否与 文件中的ATTR[address]对应上.
如果不对应可以选择删除该文件重启,也可以直接修改该文件
~~~
[root@localhost network-scripts]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e2:c7:25", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:bb:f0:79", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
~~~
## 3.进入 cd /etc/sysconfig/network-scripts目录
### 3.1 修改目录下的ifcfg-eth0 文件
该文件的DEVICE,HWADDR 应该与/etc/udev/rule.d/70-persistent-net.rules中的eth1一致.
我的ifcfg-eth0 文件,修改后为:
~~~
[root@localhost network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth1
HWADDR=08:00:27:E2:C7:25
TYPE=Ethernet
UUID=459bb09f-ce67-4276-a510-371dc8b8a12e
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
~~~
### 3.2 修改目录下的ifcfg-eth1 文件(没有则创建)
该文件的DEVICE,HWADDR 应该与/etc/udev/rule.d/70-persistent-net.rules中的eth2一致.
我的ifcfg-eth1 文件,修改后为:
~~~
[root@localhost network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth2
HWADDR=08:00:27:BB:F0:79
TYPE=Ethernet
UUID=459bb09f-ce67-4276-a510-371dc8b8a12e
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
~~~
## 4.重启服务, service network restart
执行ifconfig命令,输出
~~~
[root@localhost network-scripts]# ifconfig
eth1 Link encap:Ethernet HWaddr 08:00:27:E2:C7:25
inet addr:192.168.56.103 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee2:c725/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:924 errors:0 dropped:0 overruns:0 frame:0
TX packets:500 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:90940 (88.8 KiB) TX bytes:80641 (78.7 KiB)
eth2 Link encap:Ethernet HWaddr 08:00:27:BB:F0:79
inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:febb:f079/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1066 (1.0 KiB) TX bytes:1145 (1.1 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
~~~
\ No newline at end of file
#docker-compose配置redis集群搭建(三主三从分槽模式)
##$ 前言
* docker-compose配置redis集群.三主三从分槽模式
## 1.0 下载redis配置
~~~
链接:https://pan.baidu.com/s/1BFUDaI1JgENUB1NoqQbtPQ
提取码:wad1
~~~
### 1.1配置内容 redis.conf
~~~
port 7001
pidfile /var/run/redis.pid
timeout 60
rdbchecksum no
rdbcompression yes
loglevel notice
appendonly yes
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
maxclients 50000
maxmemory 10gb
maxmemory-policy volatile-lru
slowlog-log-slower-than 10000
slowlog-max-len 1024
hz 50
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-announce-ip 172.169.7.101
cluster-announce-port 7001
cluster-announce-bus-port 17001
~~~
## 2.0将压缩包内所有的配置文件放到/var/lib/docker/volumes/下
~~~
[root@xxx]# ll -h /var/lib/docker/volumes/| grep service_redis-700
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7001-conf
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7001-data
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7002-conf
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7002-data
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7003-conf
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7003-data
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7004-conf
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7004-data
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7005-conf
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7005-data
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7006-conf
drwxr-xr-x 3 root root 4.0K Jul 1 2019 service_redis-7006-data
~~~
## 3.0 首先创建一个Docker网卡
~~~
#创建swarm网络
docker network create -d overlay service_ov_net --attachable --subnet 172.169.0.0/16 --gateway
~~~
## 4.0 下载保存redis.yml 源配置
~~~
version: '3.4'
x-logging:
&default-logging
options:
max-size: '256m'
max-file: '3'
driver: json-file
networks:
ov_net:
external:
name: service_ov_net
volumes:
redis-7001-conf:
redis-7002-conf:
redis-7003-conf:
redis-7004-conf:
redis-7005-conf:
redis-7006-conf:
redis-7001-data:
redis-7002-data:
redis-7003-data:
redis-7004-data:
redis-7005-data:
redis-7006-data:
services:
redis-7001:
image: redis:5.0.4
logging: *default-logging
restart: always
hostname: redis-7001
ports:
- "6379:7001"
- "7001:7001"
volumes:
- redis-7001-conf:/etc/redis
- redis-7001-data:/data
networks:
ov_net:
ipv4_address: 172.169.7.101
command: bash -c "redis-server /etc/redis/redis.conf"
redis-7002:
image: redis:5.0.4
logging: *default-logging
restart: always
hostname: redis-7002
ports:
- "7002:7002"
volumes:
- redis-7002-conf:/etc/redis
- redis-7002-data:/data
networks:
ov_net:
ipv4_address: 172.169.7.102
command: bash -c "redis-server /etc/redis/redis.conf"
redis-7003:
image: redis:5.0.4
logging: *default-logging
restart: always
hostname: redis-7003
ports:
- "7003:7003"
volumes:
- redis-7003-conf:/etc/redis
- redis-7003-data:/data
networks:
ov_net:
ipv4_address: 172.169.7.103
command: bash -c "redis-server /etc/redis/redis.conf"
redis-7004:
image: redis:5.0.4
logging: *default-logging
restart: always
hostname: redis-7004
ports:
- "7004:7004"
volumes:
- redis-7004-conf:/etc/redis
- redis-7004-data:/data
networks:
ov_net:
ipv4_address: 172.169.7.104
command: bash -c "redis-server /etc/redis/redis.conf"
redis-7005:
image: redis:5.0.4
logging: *default-logging
restart: always
hostname: redis-7005
ports:
- "7005:7005"
volumes:
- redis-7005-conf:/etc/redis
- redis-7005-data:/data
networks:
ov_net:
ipv4_address: 172.169.7.105
command: bash -c "redis-server /etc/redis/redis.conf"
redis-7006:
image: redis:5.0.4
logging: *default-logging
restart: always
hostname: redis-7006
ports:
- "7006:7006"
volumes:
- redis-7006-conf:/etc/redis
- redis-7006-data:/data
networks:
ov_net:
ipv4_address: 172.169.7.106
command: bash -c "redis-server /etc/redis/redis.conf"
~~~
## 5.0 启动集群
~~~
docker-compose -f redis.yml up -d
~~~
## 6.0 进入redis容器中配置集群
~~~
这后面的命令也可以配置在redis.yml中,等配置写成所有的容器启动后去执行以下命令.
## 进入容器中(随意进入一个。这里是进入第一个)
docker exec -it service_redis-7001_1 /bin/bash
##执行构建集群命令
redis-cli --cluster create 172.168.7.12:7001 172.168.7.12:7002 172.168.7.12:7003 172.168.7.12:7004 172.168.7.12:7005 172.168.7.12:7006 --cluster-replicas 1
##查看集群
root@redis-7001:/data# redis-cli -p 7001
127.0.0.1:7001> CLUSTER NODES
d202b7f6b80f4b189874a8b00558814e6cc052c0 172.169.7.105:7005@17005 slave 970a5eeae2a9d614ff26da26c6642ba948f497b7 0 1586673798000 5 connected
9e3cfb6fb8ed277665e055d433cfbd8c16a41bf6 172.169.7.102:7002@17002 master - 0 1586673799549 2 connected 5461-10922
1e7ca7c0890f801082479691af177012e4d923e9 172.169.7.106:7006@17006 slave 9e3cfb6fb8ed277665e055d433cfbd8c16a41bf6 0 1586673799046 6 connected
970a5eeae2a9d614ff26da26c6642ba948f497b7 172.169.7.101:7001@17001 myself,master - 0 1586673798000 1 connected 0-5460
c40154631f25724742302a6de5e76f4db575ed6c 172.169.7.104:7004@17004 slave c04c6b91d799e9e2f7eb0813974ab55881b19041 0 1586673799046 4 connected
c04c6b91d799e9e2f7eb0813974ab55881b19041 172.169.7.103:7003@17003 master - 0 1586673800054 3 connected 10923-16383
127.0.0.1:7001> CLUSTER INFO
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_ping_sent:43565215
cluster_stats_messages_pong_sent:43434582
cluster_stats_messages_sent:86999797
cluster_stats_messages_ping_received:43434577
cluster_stats_messages_pong_received:43565215
cluster_stats_messages_meet_received:5
cluster_stats_messages_received:86999797
127.0.0.1:7001>
##redis集群三主三从分槽配置完成
~~~
##$ 附带上自己docker环境下常用到的命令
~~~
####docker启动单个容器
docker start 容器名
####docker停止单个容器
docker stop 容器名
####停止删除所有容器
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) -f
####删除所有镜像
docker image rm $(docker images -q) -f
####删除无用的卷
docker volume prune
####查看docker日志文件大小
ls -lh $(find /var/lib/docker/containers/ -name *-json.log)
####查找大文件
find / -type f -size +100M
####docker-compose方式创建启动容器
docker-compose -f zk.yml up -d
####docker-compose方式停止销毁容器
docker-compose -f zk.yml down
~~~
\ No newline at end of file
#docker-compose配置zookeeper分布式集群
##$ 前言
* 记录一次,在docker swarm 下利用docker-compose创建的3个节点的zookeer分布式集群.
## 首先创建一个Docker网卡
~~~
#创建swarm网络
docker network create -d overlay service_ov_net --attachable --subnet 172.169.0.0/16 --gateway
~~~
## zookeeper配置 zk.yml 配置说明
* x-logging 配置docker容器的日志文件大小最大256m 最多3个
* networks 指定网络为我们上面创建的网络
* volumes 不需要刻意创建,docker默认会在/var/lib/docker/volume/ 进行创建
* ZOO_MY_ID: 配置各个节点的ID
* ZOO_SERVERS: server.1 配置各个节点的连接地址
* ZOO_AUTOPURGE_PURGEINTERVAL: 配置1个小时清理一下zk日志
* ZOO_AUTOPURGE_SNAPRETAINCOUNT: 配置最多保留3个zk日志
## zk.yml 源配置
~~~
version: '3.4'
x-logging:
&default-logging
options:
max-size: '256m'
max-file: '3'
driver: json-file
networks:
ov_net:
external:
name: service_ov_net
volumes:
zk-1-data:
zk-2-data:
zk-3-data:
zk-1-datalog:
zk-2-datalog:
zk-3-datalog:
services:
zk-1:
image: zookeeper:3.4.14
logging: *default-logging
restart: always
hostname: zk-1
ports:
- "2181:2181"
volumes:
- zk-1-data:/data
- zk-1-datalog:/datalog
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888 server.2=zk-2:2888:3888 server.3=zk-3:2888:3888
ZOO_AUTOPURGE_PURGEINTERVAL: 1
ZOO_AUTOPURGE_SNAPRETAINCOUNT: 3
networks:
ov_net:
ipv4_address: 172.169.11.101
zk-2:
image: zookeeper:3.4.14
logging: *default-logging
restart: always
hostname: zk-2
volumes:
- zk-2-data:/data
- zk-2-datalog:/datalog
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zk-1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zk-3:2888:3888
ZOO_AUTOPURGE_PURGEINTERVAL: 1
ZOO_AUTOPURGE_SNAPRETAINCOUNT: 3
networks:
ov_net:
ipv4_address: 172.169.11.102
zk-3:
image: zookeeper:3.4.14
logging: *default-logging
restart: always
hostname: zk-3
volumes:
- zk-3-data:/data
- zk-3-datalog:/datalog
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zk-1:2888:3888 server.2=zk-2:2888:3888 server.3=0.0.0.0:2888:3888
ZOO_AUTOPURGE_PURGEINTERVAL: 1
ZOO_AUTOPURGE_SNAPRETAINCOUNT: 3
networks:
ov_net:
ipv4_address: 172.169.11.103
~~~
##$ 附带上自己docker环境下常用到的命令
~~~
####docker启动单个容器
docker start 容器名
####docker停止单个容器
docker stop 容器名
####停止删除所有容器
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) -f
####删除所有镜像
docker image rm $(docker images -q) -f
####删除无用的卷
docker volume prune
####查看docker日志文件大小
ls -lh $(find /var/lib/docker/containers/ -name *-json.log)
####查找大文件
find / -type f -size +100M
####docker-compose方式创建启动容器
docker-compose -f zk.yml up -d
####docker-compose方式停止销毁容器
docker-compose -f zk.yml down
~~~
\ No newline at end of file
#go-xorm封装公共CURD类
##$ 前言
* go-xorm是一个简单而强大的Go语言ORM库. 通过它可以使数据库操作非常简便。
##$ 配置目标
* 封装一个公共的父级操作类,
* 通过继承可让子类带有简单的操作CRUD分页查询数据库的能力
* 可减少很多冗余,重复相似性很高的查询的代码编写
* 提高代码整洁性,可维护性
## app.ini配置
~~~
[mysql]
url=root:abc.123@tcp(localhost:3306)/foot?charset=utf8
maxIdle=10
maxConn=50
~~~
## utils工具类源码(用于读取配置信息)
~~~
package utils
import (
"gopkg.in/ini.v1"
"tesou.io/platform/foot-parent/foot-api/common/base"
)
var (
//配置信息
iniFile *ini.File
)
func init() {
file, e := ini.Load("conf/app.ini")
if e != nil {
base.Log.Info("Fail to load conf/app.ini" + e.Error())
return
}
iniFile = file
}
func GetSection(sectionName string) *ini.Section {
section, e := iniFile.GetSection(sectionName)
if e != nil {
base.Log.Info("未找到对应的配置信息:" + sectionName + e.Error())
return nil
}
return section
}
func GetSectionMap(sectionName string) map[string]string {
section, e := iniFile.GetSection(sectionName)
if e != nil {
base.Log.Info("未找到对应的配置信息:" + sectionName + e.Error())
return nil
}
section_map := make(map[string]string, 0)
for _, e := range section.Keys() {
section_map[e.Name()] = e.Value()
}
return section_map
}
func GetVal(sectionName string, key string) string {
var temp_val string
section := GetSection(sectionName)
if nil != section {
temp_val = section.Key(key).Value()
}
return temp_val;
}
~~~
## Page源码(分页结构体)
~~~
package pojo
type Page struct {
//记录总数
Counts int64
//每页显示记录数
PageSize int64
//总页数
TotalPage int64
//当前页
CurPage int64
//页面显示开始记录数
FirstResult int64
//页面显示最后记录数
LastResult int64
//排序类型
OrderType string
//排序名称
OrderName string
}
func (this *Page) Build(counts int64, pageSize int64) {
this.Counts = counts
this.PageSize = pageSize
if (counts%pageSize == 0) {
this.TotalPage = this.Counts / this.PageSize
} else {
this.TotalPage = this.Counts/this.PageSize + 1
}
}
func (this *Page) GetCounts() int64 {
return this.Counts
}
/**
* Counts
* the Counts to set
*/
func (this *Page) SetCounts(counts int64) {
// 计算所有的页面数
this.Counts = counts
// this.TotalPage = (int)Math.ceil((this.Counts + this.perPageSize - 1)
// / this.perPageSize)
if (counts%this.PageSize == 0) {
this.TotalPage = this.Counts / this.PageSize
} else {
this.TotalPage = this.Counts/this.PageSize + 1
}
}
func (this *Page) GetPageSize() int64 {
return this.PageSize
}
func (this *Page) SetPageSize(pageSize int64) {
this.PageSize = pageSize
}
/**
* the TotalPage
*/
func (this *Page) GetTotalPage() int64 {
if this.TotalPage < 1 {
return 1
}
return this.TotalPage
}
/**
* TotalPage
* the TotalPage to set
*/
func (this *Page) SetTotalPage(totalPage int64) {
this.TotalPage = totalPage
}
func (this *Page) GetCurPage() int64 {
return this.CurPage
}
func (this *Page) SetCurPage(curPage int64) {
this.CurPage = curPage
}
/**
* the FirstResult
*/
func (this *Page) GetFirstResult() int64 {
temp := this.CurPage - 1
if (temp <= 0) {
return 0
}
this.FirstResult = (this.CurPage - 1) * this.PageSize
return this.FirstResult
}
/**
* FirstResult
* the FirstResult to set
*/
func (this *Page) SetFirstResult(firstResult int64) {
this.FirstResult = firstResult
}
/**
* the LastResult
*/
func (this *Page) GetLastResult() int64 {
this.LastResult = this.FirstResult + this.PageSize
return this.LastResult
}
/**
* LastResult
* the LastResult to set
*/
func (this *Page) SetLastResult(lastResult int64) {
this.LastResult = lastResult
}
/**
* the OrderName
*/
func (this *Page) GetOrderName() string {
return this.OrderName
}
/**
* OrderName
* the OrderName to set
*/
func (this *Page) SetOrderName(orderName string) {
this.OrderName = orderName
}
/**
* the orderBy
*/
func (this *Page) getOrderType() string {
return this.OrderType
}
/**
* orderBy
* the orderBy to set
*/
func (this *Page) SetOrderType(orderType string) {
this.OrderType = orderType
}
/**
* the orderBy
*/
func (this *Page) GetOrderBy() string {
if len(this.GetOrderName()) <= 0 {
return ""
}
orderBy := " order by " + this.GetOrderName() + " " + this.getOrderType()
return orderBy
}
~~~
## BaseService源码(公共的CRUD类)
~~~
package mysql
import (
"container/list"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
"gopkg.in/mgo.v2/bson"
"reflect"
"strconv"
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-api/common/base/pojo"
"tesou.io/platform/foot-parent/foot-core/common/utils"
)
type BaseService struct {
}
var (
engine *xorm.Engine
)
func GetEngine() *xorm.Engine {
if nil == engine {
setEngine()
}
return engine
}
func ShowSQL(show bool) {
engine := GetEngine()
engine.ShowSQL(show)
engine.ShowExecTime(show)
}
func setEngine() *xorm.Engine {
url := utils.GetVal("mysql", "url")
maxIdle, _ := strconv.Atoi(utils.GetVal("mysql", "maxIdle"))
maxConn, _ := strconv.Atoi(utils.GetVal("mysql", "maxConn"))
var err error
engine, err = xorm.NewEngine("mysql", url)
if nil != err {
base.Log.Error("init" + err.Error())
}
//engine.ShowExecTime(true)
//则会在控制台打印出生成的SQL语句
//则会在控制台打印调试及以上的信息
engine.ShowSQL(true)
//engine.Logger().SetLevel(core.LOG_DEBUG)
engine.SetMaxIdleConns(maxIdle)
engine.SetMaxOpenConns(maxConn)
tbMapper := core.NewPrefixMapper(core.SnakeMapper{}, "t_")
engine.SetTableMapper(tbMapper)
engine.SetColumnMapper(core.SameMapper{})
/**
当使用了Distinct,Having,GroupBy方法将不会使用缓存
Get或者Find时使用了Cols,Omit方法,则在开启缓存后此方法无效,系统仍旧会取出这个表中的所有字段。
在使用Exec方法执行了方法之后,可能会导致缓存与数据库不一致的地方。因此如果启用缓存,尽量避免使用Exec
如果必须使用,则需要在使用了Exec之后调用ClearCache手动做缓存清除的工作。比如:
engine.Exec("update user set name = ? where id = ?", "xlw", 1)
engine.ClearCache(new(User))
*/
//cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 999)
//engine.SetDefaultCacher(cacher)
return engine
}
func init() {
//设置初始化数据库引擎
setEngine()
}
func beforeModify(entity interface{}) {
//当前时间
//current_date := time.Now().Format("2006-01-02 15:04:05")
//默认更新者
default_user := "100000"
//对象操作
entity_value := reflect.ValueOf(entity).Elem()
/*//设置更新时间
field_ModifyDate := entity_value.FieldByName("ModifyTime")
if field_ModifyDate.String() == "" {
field_ModifyDate.SetString(current_date)
}*/
//设置更新者
field_ModifyUser := entity_value.FieldByName("ModifyUser")
if field_ModifyUser.String() == "" {
field_ModifyUser.SetString(default_user)
}
}
func beforeDelete(entity interface{}) {
//当前时间
//current_date := time.Now().Format("2006-01-02 15:04:05")
//默认删除者
default_user := "100000"
//对象操作
entity_value := reflect.ValueOf(entity).Elem()
/*//设置更新时间
field_ModifyDate := entity_value.FieldByName("ModifyTime")
if field_ModifyDate.String() == "" {
field_ModifyDate.SetString(current_date)
}*/
//设置删除者
field_DeleteUser := entity_value.FieldByName("DeleteUser")
if field_DeleteUser.String() == "" {
field_DeleteUser.SetString(default_user)
}
}
func beforeSave(entity interface{}) interface{} {
//当前时间
//current_date := time.Now().Format("2006-01-02 15:04:05")
//默认创建者
default_user := "100000"
//对象操作
entity_value := reflect.ValueOf(entity).Elem()
/* //设置创建时间 通过`xorm:"created"`配置
field_CreateDate := entity_value.FieldByName("CreateTime")
if field_CreateDate.String() == "" {
field_CreateDate.SetString(current_date)
}*/
//设置创建者
field_CreateUser := entity_value.FieldByName("CreateUser")
if field_CreateUser.String() == "" {
field_CreateUser.SetString(default_user)
}
beforeModify(entity)
var id interface{}
//设置id
field_Id := entity_value.FieldByName("Id")
if field_Id.String() == "" {
//使用bson.NewObject作为主键
id = bson.NewObjectId().Hex()
field_Id.Set(reflect.ValueOf(id))
}
return id
}
func (this *BaseService) SaveOrModify(entity interface{}) {
b, err := engine.Exist(entity)
if nil != err {
base.Log.Info("SaveOrModify:" + err.Error())
}
if b {
this.Modify(entity)
} else {
this.Save(entity)
}
}
func (this *BaseService) Save(entity interface{}) interface{} {
id := beforeSave(entity)
_, err := engine.InsertOne(entity)
if nil != err {
base.Log.Info("Save:" + err.Error())
}
return id
}
func (this *BaseService) SaveList(entitys []interface{}) *list.List {
if len(entitys) <= 0 {
return nil
}
list_ids := list.New()
for _, v := range entitys {
id := beforeSave(v)
list_ids.PushBack(id)
}
_, err := engine.Insert(entitys...)
if nil != err {
base.Log.Info("SaveList:" + err.Error())
}
return list_ids
}
func (this *BaseService) Del(entity interface{}) int64 {
beforeDelete(entity)
entity_value := reflect.ValueOf(entity).Elem()
id_field := entity_value.FieldByName("Id")
i, err := engine.Id(id_field.Interface()).Delete(entity)
if err != nil {
base.Log.Info("Del:", err)
}
return i
}
func (this *BaseService) Modify(entity interface{}) int64 {
beforeModify(entity)
entity_value := reflect.ValueOf(entity).Elem()
id_field := entity_value.FieldByName("Id")
i, err := engine.Id(id_field.Interface()).AllCols().Update(entity)
if err != nil {
base.Log.Info("Modify:", err)
}
return i
}
func (this *BaseService) ModifyList(entitys []interface{}) int64 {
if len(entitys) <= 0 {
return 0
}
//i, err := engine.In("id",ids).Update(entitys)
for _, v := range entitys {
//entity_value := reflect.ValueOf(v).Elem()
//id_field := entity_value.FieldByName("Id")
this.Modify(v)
}
return 1
}
func (this *BaseService) Exist(entity interface{}) bool {
//对象操作
exist, err := engine.Exist(entity)
if nil != err {
base.Log.Info("ExistByName:" + err.Error())
}
return exist
}
func (this *BaseService) Find(entity interface{}) {
engine.Find(entity)
}
func (this *BaseService) FindBySQL(sql string, entity interface{}) {
engine.SQL(sql).Find(entity)
}
func (this *BaseService) FindAll(entity interface{}) {
err := engine.Find(entity)
if nil != err {
base.Log.Info("FindAll: " + err.Error())
}
}
/**
分页查询
*/
func (this *BaseService) Page(v interface{}, page *pojo.Page, dataList interface{}) error {
tableName := engine.TableName(v)
sql := "select t.* from " + tableName + " t where 1=1 "
return this.PageSql(sql, page, dataList)
}
/**
分页查询
*/
func (this *BaseService) PageSql(sql string, page *pojo.Page, dataList interface{}) error {
//声明结果变量
var err error
var counts int64
//获取总记录数处理
countSql := " select count(1) from (" + sql + ") t"
counts, err = engine.SQL(countSql).Count()
if nil != err {
return err
} else {
page.SetCounts(counts)
}
//排序处理
orderBy := page.GetOrderBy()
if len(orderBy) > 0 {
sql += orderBy
}
sql += " limit " + strconv.FormatInt(page.GetFirstResult(), 10) + "," + strconv.FormatInt(page.GetPageSize(), 10)
err = engine.SQL(sql).Find(dataList)
return err
}
~~~
## 使用示例
~~~
package service
import (
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
)
type MatchHisService struct {
//引入公共类
mysql.BaseService
}
func (this *MatchHisService) Exist(v *pojo.MatchHis) bool {
has, err := mysql.GetEngine().Table("`t_match_his`").Where(" `Id` = ? ", v.Id).Exist()
if err != nil {
base.Log.Error("Exist", err)
}
return has
}
func (this *MatchHisService) FindAll() []*pojo.MatchHis {
dataList := make([]*pojo.MatchHis, 0)
mysql.GetEngine().OrderBy("MatchDate").Find(&dataList)
return dataList
}
func (this *MatchHisService) FindById(matchId string) *pojo.MatchHis {
data := new(pojo.MatchHis)
data.Id = matchId
_, err := mysql.GetEngine().Get(data)
if err != nil {
base.Log.Error("FindById:", err)
}
return data
}
func (this *MatchHisService) FindBySeason(season string) []*pojo.MatchLast {
sql_build := `
SELECT
la.*
FROM
foot.t_match_his la
WHERE 1=1
`
sql_build = sql_build + " AND la.MatchDate >= '" + season + "-01-01 00:00:00' AND la.MatchDate <= '" + season + "-12-31 23:59:59'"
//结果值
dataList := make([]*pojo.MatchLast, 0)
//执行查询
this.FindBySQL(sql_build, &dataList)
return dataList
}
~~~
#golang打包部署脚本
~~~
开发环境都是在Windows进行开发,经常打包发布到Linux下部署.
~~~
##$ Linux 打包 build_linux.bat
~~~
@echo off
echo=
echo set sytem env
set GOOS=linux
set GOARCH=amd64
echo copy config
if not exist %cd%\bin\conf\ md %cd%\bin\conf\
xcopy /Y /S %cd%\conf %cd%\bin\conf\
xcopy /Y /S %cd%\conf\app_prod.ini %cd%\bin\conf\app.ini
xcopy /Y /S %cd%\conf\app_pord.conf %cd%\bin\conf\app.conf
echo copy resource
if not exist %cd%\bin\assets\ md %cd%\bin\assets\
xcopy /Y /S %cd%\assets %cd%\bin\assets\
echo build
go build -v -x -o bin/FOOT000 FOOT000.go
echo=
pause
~~~
##$ Windows exe 打包 build_windows.bat
~~~
@echo off
echo=
echo copy config
if not exist %cd%\bin\conf\ md %cd%\bin\conf\
xcopy /Y /S %cd%\conf %cd%\bin\conf\
xcopy /Y /S %cd%\conf\app_prod.ini %cd%\bin\conf\app.ini
xcopy /Y /S %cd%\conf\app_pord.conf %cd%\bin\conf\app.conf
echo copy resource
if not exist %cd%\bin\assets\ md %cd%\bin\assets\
xcopy /Y /S %cd%\assets %cd%\bin\assets\
echo build
go build -v -x -o bin/FOOT000.exe FOOT000Cmd.go
echo=
pause
~~~
#golang日志框架zap简洁配置
##$ 前言
* zap是uber开源的一款高性能日志组件框架
##$ 配置目标
* 错误信息独立的文件记录
* 日志按天分割,一天一个文件
* 只保留近七天的日志
* 错误日志输出堆栈
## 源码
~~~
package base
import (
"fmt"
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"io"
"os"
"time"
)
var Log *zap.SugaredLogger
const (
output_dir = "./logs/"
out_path = "foot.log"
err_path = "foot.err"
)
func init() {
_, err := os.Stat(output_dir)
if err != nil {
if os.IsNotExist(err) {
err := os.Mkdir(output_dir, os.ModePerm)
if err != nil {
fmt.Printf("mkdir failed![%v]\n", err)
}
}
}
// 设置一些基本日志格式 具体含义还比较好理解,直接看zap源码也不难懂
encoder := zapcore.NewConsoleEncoder(zapcore.EncoderConfig{
MessageKey: "msg",
LevelKey: "level",
TimeKey: "ts",
//CallerKey: "file",
CallerKey: "caller",
StacktraceKey: "trace",
LineEnding: zapcore.DefaultLineEnding,
EncodeLevel: zapcore.LowercaseLevelEncoder,
//EncodeLevel: zapcore.CapitalLevelEncoder,
EncodeCaller: zapcore.ShortCallerEncoder,
EncodeTime: func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
enc.AppendString(t.Format("2006-01-02 15:04:05"))
},
//EncodeDuration: zapcore.SecondsDurationEncoder,
EncodeDuration: func(d time.Duration, enc zapcore.PrimitiveArrayEncoder) {
enc.AppendInt64(int64(d) / 1000000)
},
})
// 实现两个判断日志等级的interface
infoLevel := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
return true
})
warnLevel := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
return lvl >= zapcore.WarnLevel
})
// 获取 infowarn日志文件的io.Writer 抽象 getWriter() 在下方实现
infoHook_1 := os.Stdout
infoHook_2 := getWriter(out_path)
errorHook := getWriter(err_path)
// 最后创建具体的Logger
core := zapcore.NewTee(
zapcore.NewCore(encoder, zapcore.AddSync(infoHook_1), infoLevel),
zapcore.NewCore(encoder, zapcore.AddSync(infoHook_2), infoLevel),
zapcore.NewCore(encoder, zapcore.AddSync(errorHook), warnLevel),
)
// 需要传入 zap.AddCaller() 才会显示打日志点的文件名和行数, 有点小坑
logger := zap.New(core, zap.AddCaller(), zap.AddStacktrace(zap.ErrorLevel))
Log = logger.Sugar()
defer logger.Sync()
}
func getWriter(filename string) io.Writer {
// 生成rotatelogsLogger 实际生成的文件名 demo.log.YYmmddHH
// demo.log是指向最新日志的链接
// 保存7天内的日志,每1小时(整点)分割一次日志
hook, err := rotatelogs.New(
// 没有使用go风格反人类的format格式
output_dir+filename+".%Y%m%d",
rotatelogs.WithLinkName(filename),
rotatelogs.WithMaxAge(time.Hour*24*7),
rotatelogs.WithRotationTime(time.Hour*24),
)
if err != nil {
panic(err)
}
return hook
}
~~~
## 使用
~~~
package main
import "tesou.io/platform/foot-parent/foot-api/common/base"
func main() {
base.Log.Info("日志1")
base.Log.Info("日志2")
base.Log.Error("错误的日志")
base.Log.Info("日志3")
}
~~~
#go-xorm封装公共CURD类
##$ 前言
* go-xorm是一个简单而强大的Go语言ORM库. 通过它可以使数据库操作非常简便。
##$ 配置目标
* 封装一个公共的父级操作类,
* 通过继承可让子类带有简单的操作CRUD分页查询数据库的能力
* 可减少很多冗余,重复相似性很高的查询的代码编写
* 提高代码整洁性,可维护性
## app.ini配置
~~~
[mysql]
url=root:abc.123@tcp(localhost:3306)/foot?charset=utf8
maxIdle=10
maxConn=50
~~~
## utils工具类源码(用于读取配置信息)
~~~
package utils
import (
"gopkg.in/ini.v1"
"tesou.io/platform/foot-parent/foot-api/common/base"
)
var (
//配置信息
iniFile *ini.File
)
func init() {
file, e := ini.Load("conf/app.ini")
if e != nil {
base.Log.Info("Fail to load conf/app.ini" + e.Error())
return
}
iniFile = file
}
func GetSection(sectionName string) *ini.Section {
section, e := iniFile.GetSection(sectionName)
if e != nil {
base.Log.Info("未找到对应的配置信息:" + sectionName + e.Error())
return nil
}
return section
}
func GetSectionMap(sectionName string) map[string]string {
section, e := iniFile.GetSection(sectionName)
if e != nil {
base.Log.Info("未找到对应的配置信息:" + sectionName + e.Error())
return nil
}
section_map := make(map[string]string, 0)
for _, e := range section.Keys() {
section_map[e.Name()] = e.Value()
}
return section_map
}
func GetVal(sectionName string, key string) string {
var temp_val string
section := GetSection(sectionName)
if nil != section {
temp_val = section.Key(key).Value()
}
return temp_val;
}
~~~
## Page源码(分页结构体)
~~~
package pojo
type Page struct {
//记录总数
Counts int64
//每页显示记录数
PageSize int64
//总页数
TotalPage int64
//当前页
CurPage int64
//页面显示开始记录数
FirstResult int64
//页面显示最后记录数
LastResult int64
//排序类型
OrderType string
//排序名称
OrderName string
}
func (this *Page) Build(counts int64, pageSize int64) {
this.Counts = counts
this.PageSize = pageSize
if (counts%pageSize == 0) {
this.TotalPage = this.Counts / this.PageSize
} else {
this.TotalPage = this.Counts/this.PageSize + 1
}
}
func (this *Page) GetCounts() int64 {
return this.Counts
}
/**
* Counts
* the Counts to set
*/
func (this *Page) SetCounts(counts int64) {
// 计算所有的页面数
this.Counts = counts
// this.TotalPage = (int)Math.ceil((this.Counts + this.perPageSize - 1)
// / this.perPageSize)
if (counts%this.PageSize == 0) {
this.TotalPage = this.Counts / this.PageSize
} else {
this.TotalPage = this.Counts/this.PageSize + 1
}
}
func (this *Page) GetPageSize() int64 {
return this.PageSize
}
func (this *Page) SetPageSize(pageSize int64) {
this.PageSize = pageSize
}
/**
* the TotalPage
*/
func (this *Page) GetTotalPage() int64 {
if this.TotalPage < 1 {
return 1
}
return this.TotalPage
}
/**
* TotalPage
* the TotalPage to set
*/
func (this *Page) SetTotalPage(totalPage int64) {
this.TotalPage = totalPage
}
func (this *Page) GetCurPage() int64 {
return this.CurPage
}
func (this *Page) SetCurPage(curPage int64) {
this.CurPage = curPage
}
/**
* the FirstResult
*/
func (this *Page) GetFirstResult() int64 {
temp := this.CurPage - 1
if (temp <= 0) {
return 0
}
this.FirstResult = (this.CurPage - 1) * this.PageSize
return this.FirstResult
}
/**
* FirstResult
* the FirstResult to set
*/
func (this *Page) SetFirstResult(firstResult int64) {
this.FirstResult = firstResult
}
/**
* the LastResult
*/
func (this *Page) GetLastResult() int64 {
this.LastResult = this.FirstResult + this.PageSize
return this.LastResult
}
/**
* LastResult
* the LastResult to set
*/
func (this *Page) SetLastResult(lastResult int64) {
this.LastResult = lastResult
}
/**
* the OrderName
*/
func (this *Page) GetOrderName() string {
return this.OrderName
}
/**
* OrderName
* the OrderName to set
*/
func (this *Page) SetOrderName(orderName string) {
this.OrderName = orderName
}
/**
* the orderBy
*/
func (this *Page) getOrderType() string {
return this.OrderType
}
/**
* orderBy
* the orderBy to set
*/
func (this *Page) SetOrderType(orderType string) {
this.OrderType = orderType
}
/**
* the orderBy
*/
func (this *Page) GetOrderBy() string {
if len(this.GetOrderName()) <= 0 {
return ""
}
orderBy := " order by " + this.GetOrderName() + " " + this.getOrderType()
return orderBy
}
~~~
## BaseService源码(公共的CRUD类)
~~~
package mysql
import (
"container/list"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
"gopkg.in/mgo.v2/bson"
"reflect"
"strconv"
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-api/common/base/pojo"
"tesou.io/platform/foot-parent/foot-core/common/utils"
)
type BaseService struct {
}
var (
engine *xorm.Engine
)
func GetEngine() *xorm.Engine {
if nil == engine {
setEngine()
}
return engine
}
func ShowSQL(show bool) {
engine := GetEngine()
engine.ShowSQL(show)
engine.ShowExecTime(show)
}
func setEngine() *xorm.Engine {
url := utils.GetVal("mysql", "url")
maxIdle, _ := strconv.Atoi(utils.GetVal("mysql", "maxIdle"))
maxConn, _ := strconv.Atoi(utils.GetVal("mysql", "maxConn"))
var err error
engine, err = xorm.NewEngine("mysql", url)
if nil != err {
base.Log.Error("init" + err.Error())
}
//engine.ShowExecTime(true)
//则会在控制台打印出生成的SQL语句
//则会在控制台打印调试及以上的信息
engine.ShowSQL(true)
//engine.Logger().SetLevel(core.LOG_DEBUG)
engine.SetMaxIdleConns(maxIdle)
engine.SetMaxOpenConns(maxConn)
tbMapper := core.NewPrefixMapper(core.SnakeMapper{}, "t_")
engine.SetTableMapper(tbMapper)
engine.SetColumnMapper(core.SameMapper{})
/**
当使用了Distinct,Having,GroupBy方法将不会使用缓存
Get或者Find时使用了Cols,Omit方法,则在开启缓存后此方法无效,系统仍旧会取出这个表中的所有字段。
在使用Exec方法执行了方法之后,可能会导致缓存与数据库不一致的地方。因此如果启用缓存,尽量避免使用Exec
如果必须使用,则需要在使用了Exec之后调用ClearCache手动做缓存清除的工作。比如:
engine.Exec("update user set name = ? where id = ?", "xlw", 1)
engine.ClearCache(new(User))
*/
//cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 999)
//engine.SetDefaultCacher(cacher)
return engine
}
func init() {
//设置初始化数据库引擎
setEngine()
}
func beforeModify(entity interface{}) {
//当前时间
//current_date := time.Now().Format("2006-01-02 15:04:05")
//默认更新者
default_user := "100000"
//对象操作
entity_value := reflect.ValueOf(entity).Elem()
/*//设置更新时间
field_ModifyDate := entity_value.FieldByName("ModifyTime")
if field_ModifyDate.String() == "" {
field_ModifyDate.SetString(current_date)
}*/
//设置更新者
field_ModifyUser := entity_value.FieldByName("ModifyUser")
if field_ModifyUser.String() == "" {
field_ModifyUser.SetString(default_user)
}
}
func beforeDelete(entity interface{}) {
//当前时间
//current_date := time.Now().Format("2006-01-02 15:04:05")
//默认删除者
default_user := "100000"
//对象操作
entity_value := reflect.ValueOf(entity).Elem()
/*//设置更新时间
field_ModifyDate := entity_value.FieldByName("ModifyTime")
if field_ModifyDate.String() == "" {
field_ModifyDate.SetString(current_date)
}*/
//设置删除者
field_DeleteUser := entity_value.FieldByName("DeleteUser")
if field_DeleteUser.String() == "" {
field_DeleteUser.SetString(default_user)
}
}
func beforeSave(entity interface{}) interface{} {
//当前时间
//current_date := time.Now().Format("2006-01-02 15:04:05")
//默认创建者
default_user := "100000"
//对象操作
entity_value := reflect.ValueOf(entity).Elem()
/* //设置创建时间 通过`xorm:"created"`配置
field_CreateDate := entity_value.FieldByName("CreateTime")
if field_CreateDate.String() == "" {
field_CreateDate.SetString(current_date)
}*/
//设置创建者
field_CreateUser := entity_value.FieldByName("CreateUser")
if field_CreateUser.String() == "" {
field_CreateUser.SetString(default_user)
}
beforeModify(entity)
var id interface{}
//设置id
field_Id := entity_value.FieldByName("Id")
if field_Id.String() == "" {
//使用bson.NewObject作为主键
id = bson.NewObjectId().Hex()
field_Id.Set(reflect.ValueOf(id))
}
return id
}
func (this *BaseService) SaveOrModify(entity interface{}) {
b, err := engine.Exist(entity)
if nil != err {
base.Log.Info("SaveOrModify:" + err.Error())
}
if b {
this.Modify(entity)
} else {
this.Save(entity)
}
}
func (this *BaseService) Save(entity interface{}) interface{} {
id := beforeSave(entity)
_, err := engine.InsertOne(entity)
if nil != err {
base.Log.Info("Save:" + err.Error())
}
return id
}
func (this *BaseService) SaveList(entitys []interface{}) *list.List {
if len(entitys) <= 0 {
return nil
}
list_ids := list.New()
for _, v := range entitys {
id := beforeSave(v)
list_ids.PushBack(id)
}
_, err := engine.Insert(entitys...)
if nil != err {
base.Log.Info("SaveList:" + err.Error())
}
return list_ids
}
func (this *BaseService) Del(entity interface{}) int64 {
beforeDelete(entity)
entity_value := reflect.ValueOf(entity).Elem()
id_field := entity_value.FieldByName("Id")
i, err := engine.Id(id_field.Interface()).Delete(entity)
if err != nil {
base.Log.Info("Del:", err)
}
return i
}
func (this *BaseService) Modify(entity interface{}) int64 {
beforeModify(entity)
entity_value := reflect.ValueOf(entity).Elem()
id_field := entity_value.FieldByName("Id")
i, err := engine.Id(id_field.Interface()).AllCols().Update(entity)
if err != nil {
base.Log.Info("Modify:", err)
}
return i
}
func (this *BaseService) ModifyList(entitys []interface{}) int64 {
if len(entitys) <= 0 {
return 0
}
//i, err := engine.In("id",ids).Update(entitys)
for _, v := range entitys {
//entity_value := reflect.ValueOf(v).Elem()
//id_field := entity_value.FieldByName("Id")
this.Modify(v)
}
return 1
}
func (this *BaseService) Exist(entity interface{}) bool {
//对象操作
exist, err := engine.Exist(entity)
if nil != err {
base.Log.Info("ExistByName:" + err.Error())
}
return exist
}
func (this *BaseService) Find(entity interface{}) {
engine.Find(entity)
}
func (this *BaseService) FindBySQL(sql string, entity interface{}) {
engine.SQL(sql).Find(entity)
}
func (this *BaseService) FindAll(entity interface{}) {
err := engine.Find(entity)
if nil != err {
base.Log.Info("FindAll: " + err.Error())
}
}
/**
分页查询
*/
func (this *BaseService) Page(v interface{}, page *pojo.Page, dataList interface{}) error {
tableName := engine.TableName(v)
sql := "select t.* from " + tableName + " t where 1=1 "
return this.PageSql(sql, page, dataList)
}
/**
分页查询
*/
func (this *BaseService) PageSql(sql string, page *pojo.Page, dataList interface{}) error {
//声明结果变量
var err error
var counts int64
//获取总记录数处理
countSql := " select count(1) from (" + sql + ") t"
counts, err = engine.SQL(countSql).Count()
if nil != err {
return err
} else {
page.SetCounts(counts)
}
//排序处理
orderBy := page.GetOrderBy()
if len(orderBy) > 0 {
sql += orderBy
}
sql += " limit " + strconv.FormatInt(page.GetFirstResult(), 10) + "," + strconv.FormatInt(page.GetPageSize(), 10)
err = engine.SQL(sql).Find(dataList)
return err
}
~~~
## 使用示例
~~~
package service
import (
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
)
type MatchHisService struct {
//引入公共类
mysql.BaseService
}
func (this *MatchHisService) Exist(v *pojo.MatchHis) bool {
has, err := mysql.GetEngine().Table("`t_match_his`").Where(" `Id` = ? ", v.Id).Exist()
if err != nil {
base.Log.Error("Exist", err)
}
return has
}
func (this *MatchHisService) FindAll() []*pojo.MatchHis {
dataList := make([]*pojo.MatchHis, 0)
mysql.GetEngine().OrderBy("MatchDate").Find(&dataList)
return dataList
}
func (this *MatchHisService) FindById(matchId string) *pojo.MatchHis {
data := new(pojo.MatchHis)
data.Id = matchId
_, err := mysql.GetEngine().Get(data)
if err != nil {
base.Log.Error("FindById:", err)
}
return data
}
func (this *MatchHisService) FindBySeason(season string) []*pojo.MatchLast {
sql_build := `
SELECT
la.*
FROM
foot.t_match_his la
WHERE 1=1
`
sql_build = sql_build + " AND la.MatchDate >= '" + season + "-01-01 00:00:00' AND la.MatchDate <= '" + season + "-12-31 23:59:59'"
//结果值
dataList := make([]*pojo.MatchLast, 0)
//执行查询
this.FindBySQL(sql_build, &dataList)
return dataList
}
~~~
#tcp粘包问题处理
以上图的协议结构,来举个粟子:
###1.我们收到完整的一个协议串为hex码为:
~~~
232301314731424c35325037545231313535323001000000
~~~
###2.对应的拆解一下,各项数值为
| 列名 | HEX值 |
| ----------- | ---------------------|
|起始符| 2323 |
|命令单元| 01 |
|车辆识别码| 314731424c353250375452313135353230 |
|数据加密方式| 01 |
|数据单元长度| 0000 |
|校验码| 00 |
###3.而我们收到粘包的时,或者半包的情况是这样的。
* 3.1 场景1
~~~
一次收到完整两个数据串:
232301314731424c35325037545231313535323001000000232301314731424c35325037545231313535323001000000
~~~
* 3.2 场景2
~~~
一次收到一个半的数据串:
232301314731424c35325037545231313535323001000000232301314731424c35325037545231
第二次会收到剩余的数据串:
313535323001000000
~~~
###4. 第三点就是我们收到粘包,半包,大概就这些情况。
一般处理的方法也很简单,就通过起始符处理分割一下就可以。这个协议在定义的时候,就考虑到。
####如:遇到场景1
通过起始符进行分割,就可以拆成两个单独的包了。
####如:遇到场景2
通过起始符进行分割,可以拿到第一个包。再继续等待后面的数据包过来,这样第二个包也就完整了。
####这种具体代码中处理的时候,流程大概是这样:
* 4.1 读取流的数据,
* 4.2 检查数据格式
* 4.3 如果满足一个整包,就丢业务线程
* 4.4 如果不满足,将读标重置为读取之前就好.(当然也适当的间隔检索一下缓冲区,以防垃圾包太多过来让缓冲区爆了,程序挂了)
\ No newline at end of file
#历年足球数据下载
~~~
足球历年数据,数据的年份范围为:2010-2020. 10年间的数据.没有杯赛,友谊赛,联赛次级的数据.
包含澳门,bet365,威廉,立博等多菠菜公司的欧赔数据.
当前数据提供的有
csv文件,可自行转excel.
sql文件,可自行导入自己的mysql库中.
~~~
##$ Mysql 文件
* 链接:[https://pan.baidu.com/s/1DSva_tkTB433iRtmbg7q0w ](https://pan.baidu.com/s/1DSva_tkTB433iRtmbg7q0w )
* 提取码:wmwl
##$ Mysql 表说明
| 表名 | 数据行数| 表说明 |
| ----------- | :--------------:| ---------------------|
| t_asia_track | 2702052 | 亚赔变化表 |
| t_euro_his | 2186160 | 欧赔历史表(只有各家初即数据) |
| t_asia_his | 2039445 | 亚赔历史表(只有各家初即数据) |
| t_b_f_score | 1485341 | 积分榜数据表 |
| t_b_f_future_event | 1000137 | 未来赛事表 |
| t_euro_track | 917214 | 欧赔变化表(部分历史比赛己无法获取) |
| t_b_f_jin | 497977 | 近期战绩表 |
| t_match_his | 397253 | 比赛数据表 |
| t_b_f_battle | 356232 | 主客队对战历史表 |
| t_analy_result | 123793 | 分析预测结果表 |
| t_league_sub | 23953 | 联赛次级表 |
| t_league_season | 9550 | 联赛赛季表 |
| t_match_last | 3056 | 比赛临时表 |
| t_league | 1149 | 联赛表 |
| t_asia_last | 155 | 亚赔临时表 |
| t_comp | 40 | 波菜公司表 |
| t_euro_last | 36 | 欧赔临时表 |
| t_pub | 0 | 无用 |
##$ CSV 20W行版本
* 链接:[https://pan.baidu.com/s/1t8RtDtlk38MxZzsnNmrRlg](https://pan.baidu.com/s/1t8RtDtlk38MxZzsnNmrRlg)
* 提取码:a0kw
##$ CSV 4W行版本
* 链接:[https://pan.baidu.com/s/1-70U-_gm26s2RcjWNooebg](https://pan.baidu.com/s/1-70U-_gm26s2RcjWNooebg)
* 提取码:2fdm
##$ CSV 数据截图
<img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5S7uoIx92S3coZD6UJMK4PKVY31wo4Fml9EJNtEHXfO5aHpMPUk3eeIGlz5Qia2oTxsbe21XLofnVA/0?wx_fmt=png" width="200px">
#历年足球数据下载
~~~
足球历年数据,数据的年份范围为:2010-2020. 10年间的数据.没有杯赛,友谊赛,联赛次级的数据.
包含澳门,bet365,威廉,立博等多菠菜公司的欧赔数据.
当前数据提供的有
csv文件,可自行转excel.
sql文件,可自行导入自己的mysql库中.
~~~
##$ Mysql 文件
* 链接:[https://pan.baidu.com/s/1DSva_tkTB433iRtmbg7q0w ](https://pan.baidu.com/s/1DSva_tkTB433iRtmbg7q0w )
##$ Mysql 表说明
| 表名 | 数据行数| 表说明 |
| ----------- | :--------------:| ---------------------|
| t_asia_track | 2702052 | 亚赔变化表 |
| t_euro_his | 2186160 | 欧赔历史表(只有各家初即数据) |
| t_asia_his | 2039445 | 亚赔历史表(只有各家初即数据) |
| t_b_f_score | 1485341 | 积分榜数据表 |
| t_b_f_future_event | 1000137 | 未来赛事表 |
| t_euro_track | 917214 | 欧赔变化表(部分历史比赛己无法获取) |
| t_b_f_jin | 497977 | 近期战绩表 |
| t_match_his | 397253 | 比赛数据表 |
| t_b_f_battle | 356232 | 主客队对战历史表 |
| t_analy_result | 123793 | 分析预测结果表 |
| t_league_sub | 23953 | 联赛次级表 |
| t_league_season | 9550 | 联赛赛季表 |
| t_match_last | 3056 | 比赛临时表 |
| t_league | 1149 | 联赛表 |
| t_asia_last | 155 | 亚赔临时表 |
| t_comp | 40 | 波菜公司表 |
| t_euro_last | 36 | 欧赔临时表 |
| t_pub | 0 | 无用 |
##$ CSV 20W行版本
* 链接:[https://pan.baidu.com/s/1t8RtDtlk38MxZzsnNmrRlg](https://pan.baidu.com/s/1t8RtDtlk38MxZzsnNmrRlg)
##$ CSV 4W行版本
* 链接:[https://pan.baidu.com/s/1-70U-_gm26s2RcjWNooebg](https://pan.baidu.com/s/1-70U-_gm26s2RcjWNooebg)
##$ CSV 数据截图
<img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5S7uoIx92S3coZD6UJMK4PKVY31wo4Fml9EJNtEHXfO5aHpMPUk3eeIGlz5Qia2oTxsbe21XLofnVA/0?wx_fmt=png" width="90%">
<img src="https://mmbiz.qpic.cn/sz_mmbiz_jpg/BePaFicK2B5TMk6YiaklXBhMVfHebGiaToXdcpS6WFbfrOMUerm6EqNibJHEtwFH38esYnXyqdMY8YOWiaTsgFh9iaDQ/0?wx_fmt=jpeg" width="50%">
* 关注公众号"AI球探",发送"数据下载",获取提取码.
#C4模型
~~~
疫情下比赛较少.为适应当下,临时新增C4模型.
鸡肋,鸡肋,食之无味,弃之可惜!!!
~~~
##$ 说明
* C4准确率有保证.周末准确率更佳.
* C4模型仅为适合的比赛场计算出球差与分差.
* C4模型当前推荐的结果,亦可参照以下规则得出.
* 通过(球差与分差)与(让球)对比,
>> * 以上盘的视角,切入对比查看.
>> * 让球0盘的场次,建议放过.
>> * 相差在0.25及以内,(球差与分差满足一项即可).意味着让球合理,上盘可出.
>> * 相差在0.50及以上,(球差与分差两项都需要满足).意味着让球不合理,下盘可出.
* 具体的其他对比方法,及其他边角料的影响,请自行观察控制.
* 注意项
>> * 让球有负号"-"如"-0.25",表示主队受让0.25球.
>> * 没有负号,表示主队让0.25球.
>> * 球差与分差,产生后基本上不会再变动,除极少概率在数据方提供数据不完全及有延时的情况下.
>> * 让球为亚盘让球,如亚盘变动推荐的结果也可会随之变动.这里是AI球探无法管控的.
>> * 让球变动幅度,超过0.50不建议再跟进.AI球探也会对对应的场次,并移除推荐场次.
* 建议多查多看AI球探,尽量压时间跟进
* C4模型为AI球探阶段最后更新的一个模型.
##$ 入口
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_jpg/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsT2CIqkmEDFBD6oGO2riaKYgKBia8BjgUH30F3SlJdJsbheUfrBN8iafMw/0?wx_fmt=jpeg" width="200px">
##$ 效果图
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsQaYFu9haJF8EVicQDxpxO6RoSUQpIH3je7rexpDN8a8tukfibcib5RTCA/0?wx_fmt=png" width="200px">
##$ 昨日战绩
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5TM5B8RbSXPBDD7RlicZ4nbFR7SntbwkL4vYsx2C6TnSeyibrxyicWvSNosYficWkK83Cae0nEqP0tfkA/0?wx_fmt=png" width="200px">
* 其中错误的一场,初盘为0.75.早期时间跟进仅为错一半.
* 另尼拉甲08:00那场,就遭遇了数据方提供的数据出现了很大延迟问题."球差分差"出现了变动.但昨日比赛中且仅有这一场有这种情况.
#C4模型
~~~
疫情下比赛较少.为适应当下,临时新增C4模型.
鸡肋,鸡肋,食之无味,弃之可惜!!!
~~~
##$ 说明
* C4准确率有保证.周末准确率更佳.
* C4模型仅为适合的比赛场计算出球差与分差.
* C4模型当前推荐的结果,亦可参照以下规则得出.
* 通过(球差与分差)与(让球)对比,
>> * 以上盘的视角,切入对比查看.
>> * 让球0盘的场次,建议放过.
>> * 相差在0.25及以内,(球差与分差满足一项即可).意味着让球合理,上盘可出.
>> * 相差在0.50及以上,(球差与分差两项都需要满足).意味着让球不合理,下盘可出.
* 具体的其他对比方法,及其他边角料的影响,请自行观察控制.
* 注意项
>> * 让球有负号"-"如"-0.25",表示主队受让0.25球.
>> * 没有负号,表示主队让0.25球.
>> * 球差与分差,产生后基本上不会再变动,除极少概率在数据方提供数据不完全及有延时的情况下.
>> * 让球为亚盘让球,如亚盘变动推荐的结果也可会随之变动.这里是AI球探无法管控的.
>> * 让球变动幅度,超过0.50不建议再跟进.AI球探也会对对应的场次,并移除推荐场次.
* 建议多查多看AI球探,尽量压时间跟进
* C4模型为AI球探阶段最后更新的一个模型.
##$ 入口
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_jpg/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsT2CIqkmEDFBD6oGO2riaKYgKBia8BjgUH30F3SlJdJsbheUfrBN8iafMw/0?wx_fmt=jpeg" width="200px">
##$ 效果图
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsQaYFu9haJF8EVicQDxpxO6RoSUQpIH3je7rexpDN8a8tukfibcib5RTCA/0?wx_fmt=png" width="200px">
##$ 昨日战绩
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5TM5B8RbSXPBDD7RlicZ4nbFR7SntbwkL4vYsx2C6TnSeyibrxyicWvSNosYficWkK83Cae0nEqP0tfkA/0?wx_fmt=png" width="200px">
* 其中错误的一场,初盘为0.75.早期时间跟进仅为错一半.
* 另尼拉甲08:00那场,就遭遇了数据方提供的数据出现了很大延迟问题."球差分差"出现了变动.但昨日比赛中且仅有这一场有这种情况.
#C4模型
~~~
疫情下比赛较少.为适应当下,临时新增C4模型.
鸡肋,鸡肋,食之无味,弃之可惜!!!
~~~
##$ 说明
* C4准确率有保证.周末准确率更佳.
* C4模型仅为适合的比赛场计算出球差与分差.
* C4模型当前推荐的结果,亦可参照以下规则得出.
* 通过(球差与分差)与(让球)对比,
>> * 以上盘的视角,切入对比查看.
>> * 让球0盘的场次,建议放过.
>> * 相差在0.25及以内,(球差与分差满足一项即可).意味着让球合理,上盘可出.
>> * 相差在0.50及以上,(球差与分差两项都需要满足).意味着让球不合理,下盘可出.
* 具体的其他对比方法,及其他边角料的影响,请自行观察控制.
* 注意项
>> * 让球有负号"-"如"-0.25",表示主队受让0.25球.
>> * 没有负号,表示主队让0.25球.
>> * 球差与分差,产生后基本上不会再变动,除极少概率在数据方提供数据不完全及有延时的情况下.
>> * 让球为亚盘让球,如亚盘变动推荐的结果也可会随之变动.这里是AI球探无法管控的.
>> * 让球变动幅度,超过0.50不建议再跟进.AI球探也会对对应的场次,并移除推荐场次.
* 建议多查多看AI球探,尽量压时间跟进
* C4模型为AI球探阶段最后更新的一个模型.
##$ 入口
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_jpg/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsT2CIqkmEDFBD6oGO2riaKYgKBia8BjgUH30F3SlJdJsbheUfrBN8iafMw/0?wx_fmt=jpeg" width="200px">
##$ 效果图
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsQaYFu9haJF8EVicQDxpxO6RoSUQpIH3je7rexpDN8a8tukfibcib5RTCA/0?wx_fmt=png" width="200px">
##$ 昨日战绩
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5TM5B8RbSXPBDD7RlicZ4nbFR7SntbwkL4vYsx2C6TnSeyibrxyicWvSNosYficWkK83Cae0nEqP0tfkA/0?wx_fmt=png" width="200px">
* 其中错误的一场,初盘为0.75.早期时间跟进仅为错一半.
* 另尼拉甲08:00那场,就遭遇了数据方提供的数据出现了很大延迟问题."球差分差"出现了变动.但昨日比赛中且仅有这一场有这种情况.
#C4模型
~~~
疫情下比赛较少.为适应当下,临时新增C4模型.
鸡肋,鸡肋,食之无味,弃之可惜!!!
~~~
##$ 说明
* C4准确率有保证.周末准确率更佳.
* C4模型仅为适合的比赛场计算出球差与分差.
* C4模型当前推荐的结果,亦可参照以下规则得出.
* 通过(球差与分差)与(让球)对比,
>> * 以上盘的视角,切入对比查看.
>> * 让球0盘的场次,建议放过.
>> * 相差在0.25及以内,(球差与分差满足一项即可).意味着让球合理,上盘可出.
>> * 相差在0.50及以上,(球差与分差两项都需要满足).意味着让球不合理,下盘可出.
* 具体的其他对比方法,及其他边角料的影响,请自行观察控制.
* 注意项
>> * 让球有负号"-"如"-0.25",表示主队受让0.25球.
>> * 没有负号,表示主队让0.25球.
>> * 球差与分差,产生后基本上不会再变动,除极少概率在数据方提供数据不完全及有延时的情况下.
>> * 让球为亚盘让球,如亚盘变动推荐的结果也可会随之变动.这里是AI球探无法管控的.
>> * 让球变动幅度,超过0.50不建议再跟进.AI球探也会对对应的场次,并移除推荐场次.
* 建议多查多看AI球探,尽量压时间跟进
* C4模型为AI球探阶段最后更新的一个模型.
##$ 入口
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_jpg/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsT2CIqkmEDFBD6oGO2riaKYgKBia8BjgUH30F3SlJdJsbheUfrBN8iafMw/0?wx_fmt=jpeg" width="200px">
##$ 效果图
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5Q7FGbk2sDZWPwjGapANXrsQaYFu9haJF8EVicQDxpxO6RoSUQpIH3je7rexpDN8a8tukfibcib5RTCA/0?wx_fmt=png" width="200px">
##$ 昨日战绩
* <img src="https://mmbiz.qpic.cn/sz_mmbiz_png/BePaFicK2B5TM5B8RbSXPBDD7RlicZ4nbFR7SntbwkL4vYsx2C6TnSeyibrxyicWvSNosYficWkK83Cae0nEqP0tfkA/0?wx_fmt=png" width="200px">
* 其中错误的一场,初盘为0.75.早期时间跟进仅为错一半.
* 另尼拉甲08:00那场,就遭遇了数据方提供的数据出现了很大延迟问题."球差分差"出现了变动.但昨日比赛中且仅有这一场有这种情况.
package service
import (
"math"
"tesou.io/platform/foot-parent/foot-api/common/base"
entity5 "tesou.io/platform/foot-parent/foot-api/module/analy/pojo"
"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
entity3 "tesou.io/platform/foot-parent/foot-api/module/odds/pojo"
"tesou.io/platform/foot-parent/foot-core/module/analy/constants"
"tesou.io/platform/foot-parent/foot-core/module/match/service"
"time"
)
type C2Service struct {
AnalyService
service.BFScoreService
service.BFBattleService
service.BFJinService
service.BFFutureEventService
//最大让球数据
MaxLetBall float64
}
func (this *C2Service) ModelName() string {
//alFlag := reflect.TypeOf(*this).Name()
return "C2"
}
func (this *C2Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
func (this *C2Service) Analy(analyAll bool) {
this.AnalyService.Analy(analyAll, this)
}
func (this *C2Service) Analy_Near() {
this.AnalyService.Analy_Near(this)
}
/**
-1 参数错误
-2 不符合让球数
-3 计算分析错误
0 新增的分析结果
1 需要更新结果
*/
func (this *C2Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult) {
temp_data := this.Find(v.Id, this.ModelName())
matchId := v.Id
if matchId == "1836932" {
base.Log.Info("-")
}
//声明使用变量
var a18Bet *entity3.AsiaHis
//亚赔
aList := this.AsiaHisService.FindByMatchIdCompId(matchId, constants.C1_REFER_ASIA)
if len(aList) < 1 {
return -1, temp_data
}
a18Bet = aList[0]
temp_data.LetBall = a18Bet.ELetBall
if math.Abs(a18Bet.ELetBall) > this.MaxLetBall {
//temp_data.Result =""
return -2, temp_data
}
//限制初盘,即时盘让球在0.25以内
if math.Abs(a18Bet.SLetBall-a18Bet.ELetBall) > 0.25 {
//temp_data.Result =""
//return -2, temp_data
}
//得出结果
preResult := -1
letBall := 0.00
//------
bfs_arr := this.BFScoreService.FindByMatchId(matchId)
if len(bfs_arr) < 1 {
return -1, temp_data
}
var temp_val float64
var mainZongBfs *pojo.BFScore
var mainZhuBfs *pojo.BFScore
var guestZongBfs *pojo.BFScore
var guestKeBfs *pojo.BFScore
for _, e := range bfs_arr { //bfs_arr有多语言版本,条数很多
if e.TeamId == v.MainTeamId {
if e.Type == "总" {
mainZongBfs = e
}
if e.Type == "主" {
mainZhuBfs = e
}
} else if e.TeamId == v.GuestTeamId {
if e.Type == "总" {
guestZongBfs = e
}
if e.Type == "客" {
guestKeBfs = e
}
}
}
if mainZongBfs == nil || guestZongBfs == nil || mainZhuBfs == nil || guestKeBfs == nil {
return -1, temp_data
}
baseVal := 0.068
rankDiff := 3.0
if mainZongBfs.MatchCount >= 8 && guestZongBfs.MatchCount >= 8 {
//排名越小越好
temp_val = float64(mainZongBfs.Ranking - guestZongBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
if temp_val > 11 {
xishu = 3.0
} else if temp_val > 5 {
xishu = 2.0
}
letBall -= (temp_val / rankDiff) * baseVal * xishu
}
temp_val = float64(guestZongBfs.Ranking - mainZongBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
if temp_val > 11 {
xishu = 3.0
} else if temp_val > 5 {
xishu = 2.0
}
letBall += (temp_val / rankDiff) * baseVal * xishu
}
temp_val = float64(mainZhuBfs.Ranking - guestKeBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
letBall -= (temp_val / rankDiff / 2) * baseVal * xishu
}
temp_val = float64(guestKeBfs.Ranking - mainZhuBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
letBall += (temp_val / rankDiff / 2) * baseVal * xishu
}
} else {
//return -1, temp_data
}
//------
//对战历史只取近5场
bfb_arr := this.BFBattleService.FindNearByMatchId(matchId, 4)
mainWin := 0
guestWin := 0
for _, e := range bfb_arr {
if e.BattleMainTeamId == v.MainTeamId && e.BattleMainTeamGoals > e.BattleGuestTeamGoals {
mainWin++
}
if e.BattleGuestTeamId == v.MainTeamId && e.BattleGuestTeamGoals > e.BattleMainTeamGoals {
mainWin++
}
if e.BattleMainTeamId == v.GuestTeamId && e.BattleMainTeamGoals > e.BattleGuestTeamGoals {
guestWin++
}
if e.BattleGuestTeamId == v.GuestTeamId && e.BattleGuestTeamGoals > e.BattleMainTeamGoals {
guestWin++
}
}
if mainWin > guestWin {
letBall += baseVal + float64(mainWin-guestWin)*baseVal*3
}
if guestWin > mainWin {
letBall -= baseVal + float64(guestWin-mainWin)*baseVal*3
}
//
bfj_main := this.BFJinService.FindNearByTeamName(v.MatchDate, v.MainTeamId, 4)
bfj_guest := this.BFJinService.FindNearByTeamName(v.MatchDate, v.GuestTeamId, 4)
bfj_mainWin := 0
bfj_guestWin := 0
for _, e := range bfj_main {
if e.HomeTeam == v.MainTeamId && e.HomeScore > e.GuestScore {
bfj_mainWin++
}
if e.GuestTeam == v.MainTeamId && e.GuestScore > e.HomeScore {
bfj_mainWin++
}
}
for _, e := range bfj_guest {
if e.HomeTeam == v.GuestTeamId && e.HomeScore > e.GuestScore {
bfj_guestWin++
}
if e.GuestTeam == v.GuestTeamId && e.GuestScore > e.HomeScore {
bfj_guestWin++
}
}
if bfj_mainWin > bfj_guestWin {
letBall += baseVal + float64(mainWin-guestWin)*baseVal*3
}
if bfj_guestWin > bfj_mainWin {
letBall -= baseVal + float64(guestWin-mainWin)*baseVal*3
}
//------
//未来赛事
bffe_main := this.BFFutureEventService.FindNextBattle(matchId, v.MainTeamId)
bffe_guest := this.BFFutureEventService.FindNextBattle(matchId, v.GuestTeamId)
if this.IsCupMatch(bffe_main.EventLeagueId) {
//下一场打杯赛
return -3, temp_data
} else {
//如果主队下一场打客场,战意充足
if v.MainTeamId == bffe_main.EventGuestTeamId {
letBall += (baseVal)
}
}
if this.IsCupMatch(bffe_guest.EventLeagueId) {
//下一场打杯赛
return -3, temp_data
} else {
//如果客队下一场打主场,战意懈怠
if v.GuestTeamId == bffe_guest.EventMainTeamId {
letBall += (baseVal)
}
}
//1.0判断主队是否是让球方
mainLetball := this.AnalyService.mainLetball(a18Bet)
//2.0区间段
sLetBall := math.Abs(a18Bet.SLetBall)
eLetBall := math.Abs(a18Bet.ELetBall)
var sectionBlock1, sectionBlock2 int
tLetBall := math.Abs(letBall)
//maxLetBall := math.Max(sLetBall, eLetBall)
tempLetball1 := math.Abs(sLetBall - tLetBall)
if tempLetball1 < 0.0 {
sectionBlock1 = 1
} else if tempLetball1 < 0.29 {
sectionBlock1 = 2
} else if tempLetball1 < 0.51 {
sectionBlock1 = 3
} else if tempLetball1 < 0.76 {
sectionBlock1 = 4
} else {
sectionBlock1 = 10000
}
tempLetball2 := math.Abs(eLetBall - tLetBall)
if tempLetball2 < 0.0 {
sectionBlock2 = 1
} else if tempLetball2 < 0.29 {
sectionBlock2 = 2
} else if tempLetball2 < 0.51 {
sectionBlock2 = 3
} else if tempLetball2 < 0.76 {
sectionBlock2 = 4
} else {
sectionBlock2 = 10000
}
//3.0即时盘赔率大于等于初盘赔率
endUp := eLetBall >= sLetBall
//3.1即时盘初盘非0
notZero := eLetBall >= 0 && sLetBall >= 0
//看两个区间是否属于同一个区间
//if sectionBlock1 == 1 && sectionBlock2 == 1 {
if sectionBlock1 <= 3 && sectionBlock2 <= 3 {
if mainLetball && letBall > 0.1 && endUp && notZero {
preResult = 3
} else if !mainLetball && letBall < -0.1 && endUp && notZero {
//preResult = 0
}
}
if preResult < 0 {
return -3, temp_data
}
temp_bfb_arr := this.BFBattleService.FindNearByMatchId(matchId, 1)
for _, e := range temp_bfb_arr {
if e.BattleMainTeamId == v.MainTeamId && e.BattleMainTeamGoals > e.BattleGuestTeamGoals {
continue
}
if e.BattleGuestTeamId == v.MainTeamId && e.BattleGuestTeamGoals > e.BattleMainTeamGoals {
continue
}
if e.BattleMainTeamId == v.GuestTeamId && e.BattleMainTeamGoals > e.BattleGuestTeamGoals {
return -3, temp_data
}
if e.BattleGuestTeamId == v.GuestTeamId && e.BattleGuestTeamGoals > e.BattleMainTeamGoals {
return -3, temp_data
}
}
temp_bfj_main := this.BFJinService.FindNearByTeamName(v.MatchDate, v.MainTeamId, 1)
temp_bfj_guest := this.BFJinService.FindNearByTeamName(v.MatchDate, v.GuestTeamId, 1)
for _, e := range temp_bfj_main {
if e.HomeTeam == v.MainTeamId && e.HomeScore > e.GuestScore {
continue
} else if e.GuestTeam == v.MainTeamId && e.GuestScore > e.HomeScore {
continue
} else {
return -3, temp_data
}
}
for _, e := range temp_bfj_guest {
if e.HomeTeam == v.GuestTeamId && e.HomeScore > e.GuestScore {
return -3, temp_data
} else if e.GuestTeam == v.GuestTeamId && e.GuestScore > e.HomeScore {
return -3, temp_data
} else {
continue
}
}
var data *entity5.AnalyResult
if len(temp_data.Id) > 0 {
temp_data.MatchDate = v.MatchDate
temp_data.PreResult = preResult
temp_data.HitCount = temp_data.HitCount + 1
temp_data.LetBall = a18Bet.ELetBall
temp_data.MyLetBall = Decimal(letBall)
data = temp_data
//比赛结果
data.Result = this.IsRight2Option(v, data)
return 1, data
} else {
data = new(entity5.AnalyResult)
data.MatchId = v.Id
data.MatchDate = v.MatchDate
data.SLetBall = a18Bet.SLetBall
data.LetBall = a18Bet.ELetBall
data.AlFlag = this.ModelName()
format := time.Now().Format("0102150405")
data.AlSeq = format
data.PreResult = preResult
data.HitCount = 3
data.MyLetBall = Decimal(letBall)
//比赛结果
data.Result = this.IsRight2Option(v, data)
return 0, data
}
}
SELECT
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
1,
0
)
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id`
AND ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('C4')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
#用于查询稳定的场次
SELECT
ar.`MatchDate`,
ar.`AlFlag`,
ar.`PreResult`,
ar.`Result`,
ar.`HitCount`,
ar.MatchDate,
ar.AlFlag,
ar.PreResult,
ar.Result,
ar.HitCount,
l.Name AS LeagueName,
mh.MainTeamId AS MainTeam,
mh.GuestTeamId AS GuestTeam,
mh.MainTeamGoals AS MainTeamGoal,
mh.GuestTeamGoals AS GuestTeamGoal
mh.MainTeamGoal AS MainTeamGoal,
mh.GuestTeamGoal AS GuestTeamGoal
FROM
foot.t_league l,
foot.t_match_his mh,
foot.t_analy_result ar,
t_league l,
t_match_his mh,
t_analy_result ar,
(SELECT
ar1.`Id`
ar1.Id
FROM
foot.`t_analy_result` ar1
WHERE ar1.`MatchId` IN
t_analy_result ar1
WHERE ar1.MatchId IN
(SELECT
temp.matchId
FROM
foot.`t_analy_result` temp
GROUP BY temp.`MatchId`
t_analy_result temp
GROUP BY temp.MatchId
HAVING COUNT(1) >= 3)) temp
WHERE mh.LeagueId = l.Id
AND mh.Id = ar.MatchId
AND ar.`Id` = temp.id
AND ar.Id = temp.id
ORDER BY ar.MatchDate DESC,
l.id ASC,
mh.MainTeamId ASC,
ar.`AlFlag` DESC
\ No newline at end of file
ar.AlFlag DESC
\ No newline at end of file
SELECT
ar.`MatchDate`,
ar.`AlFlag`,
ar.`PreResult`,
ar.`Result`,
ar.`HitCount`,
ar.MatchDate,
ar.AlFlag,
ar.PreResult,
ar.Result,
ar.HitCount,
l.Name AS LeagueName,
mh.MainTeamId AS MainTeam,
mh.GuestTeamId AS GuestTeam,
mh.MainTeamGoals AS MainTeamGoal,
mh.GuestTeamGoals AS GuestTeamGoal
mh.MainTeamGoal AS MainTeamGoal,
mh.GuestTeamGoal AS GuestTeamGoal
FROM
foot.t_league l,
foot.t_match_his mh,
foot.t_analy_result ar,
t_league l,
t_match_his mh,
t_analy_result ar,
(SELECT
ar1.`MatchId`
ar1.MatchId
FROM
foot.`t_analy_result` ar1,
foot.`t_analy_result` ar2
WHERE ar1.`MatchId` = ar2.`MatchId`
AND ar1.`AlFlag` = 'Q1'
AND ar2.`AlFlag` = 'A1'
t_analy_result ar1,
t_analy_result ar2
WHERE ar1.MatchId = ar2.MatchId
AND ar1.AlFlag = 'Q1'
AND ar2.AlFlag = 'A1'
) temp
WHERE mh.LeagueId = l.Id
AND mh.Id = ar.MatchId
AND ar.`MatchId` = temp.MatchId
AND ar.MatchId = temp.MatchId
ORDER BY ar.MatchDate DESC,
l.id ASC,
mh.MainTeamId ASC,
ar.`AlFlag` DESC ,
ar.`PreResult` DESC
\ No newline at end of file
ar.AlFlag DESC ,
ar.PreResult DESC
\ No newline at end of file
SELECT
ar.`MatchDate`,
ar.`TOVoid`,
ar.`TOVoidDesc`,
ar.`AlFlag`,
ar.`PreResult`,
ar.`Result`,
mh.MainTeamGoals AS MainTeamGoal,
mh.GuestTeamGoals AS GuestTeamGoal,
ar.`HitCount`,
ar.`LetBall`,
ar.`MyLetBall`,
ar.MatchDate,
ar.TOVoid,
ar.TOVoidDesc,
ar.AlFlag,
ar.PreResult,
ar.Result,
mh.MainTeamGoal AS MainTeamGoal,
mh.GuestTeamGoal AS GuestTeamGoal,
ar.HitCount,
ar.LetBall,
ar.MyLetBall,
l.Name AS LeagueName,
mh.MainTeamId AS MainTeam,
mh.GuestTeamId AS GuestTeam
FROM
foot.t_league l,
foot.t_match_his mh,
foot.t_analy_result ar,
t_league l,
t_match_his mh,
t_analy_result ar,
(SELECT
temp.`MatchId`
temp.MatchId
FROM
(SELECT
ar1.`MatchId`,
ar1.`PreResult`
ar1.MatchId,
ar1.PreResult
FROM
foot.`t_analy_result` ar1,
foot.`t_analy_result` ar2
WHERE ar1.`MatchId` = ar2.`MatchId`
AND ar1.`AlFlag` = 'E2'
AND ar2.`AlFlag` = 'C1'
AND ar1.`PreResult` = ar2.`PreResult`
AND ar2.`TOVoidDesc` = '') temp,
foot.`t_analy_result` a1
WHERE a1.`MatchId` = temp.`MatchId`
AND a1.`AlFlag` = 'A1'
AND a1.`PreResult` = temp.`PreResult`) temp
t_analy_result ar1,
t_analy_result ar2
WHERE ar1.MatchId = ar2.MatchId
AND ar1.AlFlag = 'E2'
AND ar2.AlFlag = 'C1'
AND ar1.PreResult = ar2.PreResult
AND ar2.TOVoidDesc = '') temp,
t_analy_result a1
WHERE a1.MatchId = temp.MatchId
AND a1.AlFlag = 'A1'
AND a1.PreResult = temp.PreResult) temp
WHERE mh.LeagueId = l.Id
AND mh.Id = ar.MatchId
AND ar.`MatchId` = temp.MatchId
AND ar.`AlFlag` IN ('E2', 'C1','A1')
AND ar.MatchId = temp.MatchId
AND ar.AlFlag IN ('E2', 'C1','A1')
ORDER BY ar.MatchDate DESC,
l.id ASC,
mh.MainTeamId ASC,
ar.`AlFlag` DESC,
ar.`PreResult` DESC
\ No newline at end of file
ar.AlFlag DESC,
ar.PreResult DESC
\ No newline at end of file
SELECT ar.`MatchDate`,
ar.`TOVoid`,
ar.`TOVoidDesc`,
ar.`AlFlag`,
ar.`PreResult`,
ar.`Result`,
ar.`HitCount`,
ar.`LetBall`,
ar.`MyLetBall`,
SELECT ar.MatchDate,
ar.TOVoid,
ar.TOVoidDesc,
ar.AlFlag,
ar.PreResult,
ar.Result,
ar.HitCount,
ar.LetBall,
ar.MyLetBall,
l.Name AS LeagueName,
mh.MainTeamId AS MainTeam,
mh.GuestTeamId AS GuestTeam,
mh.MainTeamGoals AS MainTeamGoal,
mh.GuestTeamGoals AS GuestTeamGoal
mh.MainTeamGoal AS MainTeamGoal,
mh.GuestTeamGoal AS GuestTeamGoal
FROM
foot.t_league l,
foot.t_match_his mh,
foot.t_analy_result ar,
t_league l,
t_match_his mh,
t_analy_result ar,
(SELECT
ar1.`MatchId`
ar1.MatchId
FROM
foot.`t_analy_result` ar1,
foot.`t_analy_result` ar2
WHERE ar1.`MatchId` = ar2.`MatchId`
AND ar1.`AlFlag` = 'E2'
AND ar2.`AlFlag` = 'C1'
AND ar1.`PreResult` = ar2.`PreResult`
t_analy_result ar1,
t_analy_result ar2
WHERE ar1.MatchId = ar2.MatchId
AND ar1.AlFlag = 'E2'
AND ar2.AlFlag = 'C1'
AND ar1.PreResult = ar2.PreResult
) temp
WHERE mh.LeagueId = l.Id
AND mh.Id = ar.MatchId
AND ar.`MatchId` = temp.MatchId
AND ar.`AlFlag` IN ('E2' ,'C1')
AND ar.MatchId = temp.MatchId
AND ar.AlFlag IN ('E2' ,'C1')
ORDER BY ar.MatchDate DESC,
l.id ASC,
mh.MainTeamId ASC,
ar.`AlFlag` DESC ,
ar.`PreResult` DESC
\ No newline at end of file
ar.AlFlag DESC ,
ar.PreResult DESC
\ No newline at end of file
SELECT
ar.`MatchDate`,
ar.`TOVoid`,
ar.`TOVoidDesc`,
ar.`AlFlag`,
ar.`PreResult`,
ar.`Result`,
mh.MainTeamGoals AS MainTeamGoal,
mh.GuestTeamGoals AS GuestTeamGoal,
ar.`HitCount`,
ar.`LetBall`,
ar.`MyLetBall`,
ar.MatchDate,
ar.TOVoid,
ar.TOVoidDesc,
ar.AlFlag,
ar.PreResult,
ar.Result,
mh.MainTeamGoal AS MainTeamGoal,
mh.GuestTeamGoal AS GuestTeamGoal,
ar.HitCount,
ar.LetBall,
ar.MyLetBall,
l.Name AS LeagueName,
mh.MainTeamId AS MainTeam,
mh.GuestTeamId AS GuestTeam
FROM
foot.t_league l,
foot.t_match_his mh,
foot.t_analy_result ar,
t_league l,
t_match_his mh,
t_analy_result ar,
(SELECT
ar1.`MatchId`
ar1.MatchId
FROM
foot.`t_analy_result` ar1,
foot.`t_analy_result` ar2
WHERE ar1.`MatchId` = ar2.`MatchId`
AND ar1.`AlFlag` = 'E2'
AND ar2.`AlFlag` = 'C1'
AND ar1.`PreResult` = ar2.`PreResult`
AND ar2.`TOVoidDesc` = '') temp
t_analy_result ar1,
t_analy_result ar2
WHERE ar1.MatchId = ar2.MatchId
AND ar1.AlFlag = 'E2'
AND ar2.AlFlag = 'C1'
AND ar1.PreResult = ar2.PreResult
AND ar2.TOVoidDesc = '') temp
WHERE mh.LeagueId = l.Id
AND mh.Id = ar.MatchId
#AND mh.`MainTeamGoals` != mh.`GuestTeamGoals`
AND ar.`MatchId` = temp.MatchId
AND ar.`AlFlag` IN ('E2', 'C1')
#AND mh.MainTeamGoal != mh.GuestTeamGoal
AND ar.MatchId = temp.MatchId
AND ar.AlFlag IN ('E2', 'C1')
ORDER BY ar.MatchDate DESC,
l.id ASC,
mh.MainTeamId ASC,
ar.`AlFlag` DESC,
ar.`PreResult` DESC
ar.AlFlag DESC,
ar.PreResult DESC
#-------------------------------------
#-------------------------------------
#-------------------------------------
SELECT
COUNT(1) / 2,
ar.`Result`
ar.Result
FROM
foot.t_league l,
foot.t_match_his mh,
foot.t_analy_result ar,
t_league l,
t_match_his mh,
t_analy_result ar,
(SELECT
ar1.`MatchId`
ar1.MatchId
FROM
foot.`t_analy_result` ar1,
foot.`t_analy_result` ar2
WHERE ar1.`MatchId` = ar2.`MatchId`
AND ar1.`AlFlag` = 'E2'
AND ar2.`AlFlag` = 'C1'
AND ar1.`PreResult` = ar2.`PreResult`
AND ar2.`TOVoidDesc` = '') temp
t_analy_result ar1,
t_analy_result ar2
WHERE ar1.MatchId = ar2.MatchId
AND ar1.AlFlag = 'E2'
AND ar2.AlFlag = 'C1'
AND ar1.PreResult = ar2.PreResult
AND ar2.TOVoidDesc = '') temp
WHERE mh.LeagueId = l.Id
AND mh.Id = ar.MatchId
#AND mh.`MainTeamGoals` != mh.`GuestTeamGoals`
AND ar.`MatchId` = temp.MatchId
AND ar.`AlFlag` IN ('E2', 'C1')
GROUP BY ar.`Result`
\ No newline at end of file
#AND mh.MainTeamGoal != mh.GuestTeamGoal
AND ar.MatchId = temp.MatchId
AND ar.AlFlag IN ('E2', 'C1')
GROUP BY ar.Result
\ No newline at end of file
SELECT
COUNT(IF(r.Result = "命中", 1, 0)) AS hitCount,
COUNT(IF(r.Result = "错误", 1, 0)) AS failCount,
DATE_FORMAT(r.MatchDate, '%Y-%m') AS md
FROM
t_analy_result r
WHERE r.AlFlag = 'C1'
GROUP BY md ORDER BY md ASC
\ No newline at end of file
......@@ -2,53 +2,54 @@ SELECT
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
ar.AlFlag AS 'flag',
DATE_FORMAT(ar.MatchDate, '%w') AS 'week',
ar.LetBall AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(IF (ar.Result = "命中", 1, 0)) AS 'right',
SUM(IF (ar.Result = "错误", 1, 0)) AS 'error',
SUM(IF (ar.Result = "走盘", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
mh.MainTeamGoal > mh.GuestTeamGoal,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
mh.MainTeamGoal = mh.GuestTeamGoal,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
mh.MainTeamGoal < mh.GuestTeamGoal,
1,
0
)
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id` #and ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('A1', 'A3')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
t_analy_result ar,
t_match_his mh,
t_league l
WHERE ar.MatchId = mh.Id
AND mh.LeagueId = l.Id
AND ar.TOVoidDesc = ''
AND ar.Result != "待定"
AND ar.AlFlag IN ('A1', 'A3') #AND DATE_FORMAT(ar.MatchDate, '%w') = 0
GROUP BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall
ORDER BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall) t
WHERE 1 = 1 #and t.total > 10
#AND (
# t.error / t.total >= 0.8
# OR t.right / t.total >= 0.8
# OR t.none / t.total >= 0.8
# OR t .1 / t.total > 0.5
#)
ORDER BY t.flag, t.week ASC
\ No newline at end of file
SELECT
*
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
(SELECT
ar.AlFlag AS 'flag',
DATE_FORMAT(ar.MatchDate, '%w') AS 'week',
ar.LetBall AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(IF (ar.Result = "命中", 1, 0)) AS 'right',
SUM(IF (ar.Result = "错误", 1, 0)) AS 'error',
SUM(IF (ar.Result = "走盘", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
mh.MainTeamGoal > mh.GuestTeamGoal,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
mh.MainTeamGoal = mh.GuestTeamGoal,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
mh.MainTeamGoal < mh.GuestTeamGoal,
1,
0
)
) AS '0'
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id`
AND ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('C1', 'C2')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
t_analy_result ar,
t_match_his mh,
t_league l
WHERE ar.MatchId = mh.Id
AND mh.LeagueId = l.Id
AND ar.TOVoidDesc = ''
AND ar.Result != "待定"
AND ar.AlFlag IN ('C1', 'C2') #AND DATE_FORMAT(ar.MatchDate, '%w') = 0
GROUP BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall
ORDER BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall) t
WHERE 1 = 1 # and t.total > 10
# AND (
# t.error / t.total >= 0.8
# OR t.right / t.total >= 0.8
# OR t.none / t.total >= 0.8
# OR t .1 / t.total > 0.5
# )
ORDER BY t.week ASC
\ No newline at end of file
......@@ -2,54 +2,54 @@ SELECT
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
ar.AlFlag AS 'flag',
DATE_FORMAT(ar.MatchDate, '%w') AS 'week',
ar.LetBall AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(IF (ar.Result = "命中", 1, 0)) AS 'right',
SUM(IF (ar.Result = "错误", 1, 0)) AS 'error',
SUM(IF (ar.Result = "走盘" OR ar.Result = "未知" OR ar.Result = "", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
mh.MainTeamGoal > mh.GuestTeamGoal,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
mh.MainTeamGoal = mh.GuestTeamGoal,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
mh.MainTeamGoal < mh.GuestTeamGoal,
1,
0
)
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id`
AND ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('C4')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
t_analy_result ar,
t_match_his mh,
t_league l
WHERE ar.MatchId = mh.Id
AND mh.LeagueId = l.Id
AND ar.TOVoidDesc = ''
AND ar.Result != "待定"
AND ar.AlFlag IN ('C4') #AND DATE_FORMAT(ar.MatchDate, '%w') = 0
GROUP BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall
ORDER BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall) t
WHERE 1 = 1 # and t.total > 10
# AND (
# t.error / t.total >= 0.8
# OR t.right / t.total >= 0.8
# OR t.none / t.total >= 0.8
# OR t .1 / t.total > 0.5
# )
ORDER BY t.week ASC
\ No newline at end of file
......@@ -2,54 +2,54 @@ SELECT
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
ar.AlFlag AS 'flag',
DATE_FORMAT(ar.MatchDate, '%w') AS 'week',
ar.LetBall AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(IF (ar.Result = "命中", 1, 0)) AS 'right',
SUM(IF (ar.Result = "错误", 1, 0)) AS 'error',
SUM(IF (ar.Result = "走盘", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
mh.MainTeamGoal > mh.GuestTeamGoal,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
mh.MainTeamGoal = mh.GuestTeamGoal,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
mh.MainTeamGoal < mh.GuestTeamGoal,
1,
0
)
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id`
AND ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('E1', 'E2')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
t_analy_result ar,
t_match_his mh,
t_league l
WHERE ar.MatchId = mh.Id
AND mh.LeagueId = l.Id
AND ar.TOVoidDesc = ''
AND ar.Result != "待定"
AND ar.AlFlag IN ('E1', 'E2') #AND DATE_FORMAT(ar.MatchDate, '%w') = 0
GROUP BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall
ORDER BY ar.AlFlag,
DATE_FORMAT(ar.MatchDate, '%w'),
ar.LetBall) t
WHERE 1 = 1 #and t.total > 10
#AND (
# t.error / t.total >= 0.8
# OR t.right / t.total >= 0.8
# OR t.none / t.total >= 0.8
# OR t .1 / t.total > 0.5
#)
ORDER BY t.flag, t.week ASC
\ No newline at end of file
SELECT CONCAT('ALTER TABLE ',i.TABLE_NAME,' CHANGE ',i.COLUMN_NAME,' ',i.COLUMN_NAME,' ',i.COLUMN_TYPE,' COMMENT "',i.COLUMN_COMMENT,'";')
FROM INFORMATION_SCHEMA.COLUMNS i
WHERE TABLE_SCHEMA = 'foot' ;
\ No newline at end of file
SELECT CONCAT('ALTER TABLE ',i.TABLE_NAME,' ENGINE=MyISAM',' ;')
FROM INFORMATION_SCHEMA.TABLES i
WHERE TABLE_SCHEMA = 'foot' ;
\ No newline at end of file
SELECT CONCAT('ALTER TABLE ',i.TABLE_NAME,' DROP INDEX ',i.INDEX_NAME,' ;')
FROM INFORMATION_SCHEMA.STATISTICS i
#过滤主键索引
WHERE TABLE_SCHEMA = 'foot' AND i.INDEX_NAME <> 'PRIMARY';
##$ AI球探-帮助
> 1. AI球探为程序全自动处理,全程无人为参与干预足球分析预测程序.
> 2. 避免了人为分析的主观性及不稳定因素.
> 3. 程序根据各大指数多维度数据,结合作者多年足球分析经验,精雕细琢历经26个月得出的产物.
> 4. 程序执行流程包括且不仅限于(数据自动获取-->分析学习-->自动推送发布).
> 5. 经近三个月的实验准确率一直能维持在一个较高的水平.
> 6. 依据该项目为依托已经吸引了不少朋友,望大家长期关注校验.
## 关注本号须知
> 1. 新进来的朋友不要盲目跟进,应先观察一个自己认为合理的周期,再慎重跟进.
> 2. 新进来的朋友不要盲目跟进,应先观察一个自己认为合理的周期,再慎重跟进.
> 3. 新进来的朋友不要盲目跟进,应先观察一个自己认为合理的周期,再慎重跟进.
## 项目为什么开源?
~~~
让有编程能力的朋友,同样爱好足球的朋友,也可以参与进来.
该项目公众号更多的面对的是足球彩民服务并进行持续优化.
为什么选择彩民,有如下原因:
大家购彩多年,都有自己购彩的心得.
如果大家将这些心得,集中起来,形成一个模型习惯算法库.
再交给机器来对之前的大数据量的比赛进行复盘学习,学习过程中对各种模型习惯进行加权重加评分.
再有新比赛出来时,借助程序的计算,是否我们离比赛结果的真相就不远了???
~~~
## 菜单说明
* 今日推荐
>> 1. 实时获取最新预测数据,更新时间周期为30~60分钟.
>> 2. 因群发次数限制(每日一次),还请大家自行点击该按钮,以获取最新的推荐.
* 历史战绩
* 历史战绩-历史回顾
* 历史战绩-最近七天
* 历史战绩-最近一月
* 关于球探
* 联系我们
* 开源项目
>>> 开源项目说明,源码地址都在这里可查看. 欢迎大家一起研讨,并跟我取得联系
* 使用说明
## 推荐选项说明
*
>> 主队盘口打出
*
>> 客队盘口打出
* 胜平
>> 首选主队胜,次防平..
* 负平
>> 首选客队胜,次防平..
## 模型说明
* A1模型
>> A1模型分析算法,以亚指指数为校验基准,为亚欧盘联动变化过程不符合模型设定值时,产生.
* A2模型
>> A2模型分析算法,以亚指指数为校验基准,比较复杂,开发实现中...
* C1模型
>> C1模型分析算法,以亚指指数为校验基准,纯基本面分析.
>> 通过基本面计算出让球(BF让球),与盘口让球对比是否在合理范畴内
* E1模型
>> E1模型分析算法,以亚指指数为校验基准,比较复杂,暂无说明.
* E2模型
>> E2模型分析算法,以胜平负为校验基准,由于是单边防平双选,因此结果非对即错.
>> 为公众号主推模型,望大家长期关注,对比历史查看.
* Q1模型
>> Q1模型分析算法,以亚指指数为校验基准,由网友(强)提供,逻辑简单有效,经长测表现稳定.
>> 分析算法逻辑,对比计算对竞彩官方与***波菜的即时盘赔率得出预测结果.
>> 目前只可在待选池中可查看,未加入到推荐列表中.
## 以下是在各种情况下使用的常见命令
* 获取推荐 (获取赛事实时推荐)
* 推荐
>>> 在对话框中输入"推荐"发送
* 今日推荐
>>> 在对话框中输入"今日推荐"发送
* 联系我们 (与我们取得联系)
* 联系
>>> 在对话框中输入"联系"发送
* 联系我们
>>> 在对话框中输入"联系我们"发送
* 使用说明 (查看使用说明)
* ?
>>> 在对话框中输入"?"发送
* help
>>> 在对话框中输入"help"发送
* 帮助
>>> 在对话框中输入"帮助"发送
* 说明
>>> 在对话框中输入"说明"发送
* 使用说明
>>> 在对话框中输入"使用说明"发送
##$ AI球探-帮助
> 1. AI球探为程序全自动处理,全程无人为参与干预足球分析预测程序.
> 2. 避免了人为分析的主观性及不稳定因素.
> 3. 程序根据各大指数多维度数据,结合作者多年足球分析经验,精雕细琢历经26个月得出的产物.
> 4. 程序执行流程包括且不仅限于(数据自动获取-->分析学习-->自动推送发布).
> 5. 经近三个月的实验准确率一直能维持在一个较高的水平.
> 6. 依据该项目为依托已经吸引了不少朋友,望大家长期关注校验.
## 关注本号须知
> 1. 新进来的朋友不要盲目跟进,应先观察一个自己认为合理的周期,再慎重跟进.
> 2. 新进来的朋友不要盲目跟进,应先观察一个自己认为合理的周期,再慎重跟进.
> 3. 新进来的朋友不要盲目跟进,应先观察一个自己认为合理的周期,再慎重跟进.
## 项目为什么开源?
~~~
让有编程能力的朋友,同样爱好足球的朋友,也可以参与进来.
该项目公众号更多的面对的是足球彩民服务并进行持续优化.
为什么选择彩民,有如下原因:
大家购彩多年,都有自己购彩的心得.
如果大家将这些心得,集中起来,形成一个模型习惯算法库.
再交给机器来对之前的大数据量的比赛进行复盘学习,学习过程中对各种模型习惯进行加权重加评分.
再有新比赛出来时,借助程序的计算,是否我们离比赛结果的真相就不远了???
~~~
## 菜单说明
* 今日推荐
>> 1. 实时获取最新预测数据,更新时间周期为30~60分钟.
>> 2. 因群发次数限制(每日一次),还请大家自行点击该按钮,以获取最新的推荐.
* 历史战绩
* 历史战绩-历史回顾
* 历史战绩-最近七天
* 历史战绩-最近一月
* 关于球探
* 联系我们
* 开源项目
>>> 开源项目说明,源码地址都在这里可查看. 欢迎大家一起研讨,并跟我取得联系
* 使用说明
## 推荐选项说明
*
>> 主队盘口打出
*
>> 客队盘口打出
* 胜平
>> 首选主队胜,次防平..
* 负平
>> 首选客队胜,次防平..
## 模型说明
* A1模型
>> A1模型分析算法,以亚指指数为校验基准,为亚欧盘联动变化过程不符合模型设定值时,产生.
* A2模型
>> A2模型分析算法,以亚指指数为校验基准,比较复杂,开发实现中...
* C1模型
>> C1模型分析算法,以亚指指数为校验基准,纯基本面分析.
>> 通过基本面计算出让球(BF让球),与盘口让球对比是否在合理范畴内
* E1模型
>> E1模型分析算法,以亚指指数为校验基准,比较复杂,暂无说明.
* E2模型
>> E2模型分析算法,以胜平负为校验基准,由于是单边防平双选,因此结果非对即错.
>> 为公众号主推模型,望大家长期关注,对比历史查看.
* Q1模型
>> Q1模型分析算法,以亚指指数为校验基准,由网友(强)提供,逻辑简单有效,经长测表现稳定.
>> 分析算法逻辑,对比计算对竞彩官方与***波菜的即时盘赔率得出预测结果.
>> 目前只可在待选池中可查看,未加入到推荐列表中.
## 以下是在各种情况下使用的常见命令
* 获取推荐 (获取赛事实时推荐)
* 推荐
>>> 在对话框中输入"推荐"发送
* 今日推荐
>>> 在对话框中输入"今日推荐"发送
* 联系我们 (与我们取得联系)
* 联系
>>> 在对话框中输入"联系"发送
* 联系我们
>>> 在对话框中输入"联系我们"发送
* 使用说明 (查看使用说明)
* ?
>>> 在对话框中输入"?"发送
* help
>>> 在对话框中输入"help"发送
* 帮助
>>> 在对话框中输入"帮助"发送
* 说明
>>> 在对话框中输入"说明"发送
* 使用说明
>>> 在对话框中输入"使用说明"发送
<span style="color: red;font-weight: bold;font-size: 12px">声明:彩市有风险,购彩需谨慎.AI球探只提供预测参考,不构成购彩建议,据AI球探购彩者风险自担.</span>
\ No newline at end of file
# 二串一双选玩法
~~~
二串一双选玩法共4个注单,25一个注单,100一个二串一双选
~~~
## 稳胆C1E2
### 非杯赛非排斥-对106 错22
### 胜率106/(106+22)=82.8125%
* 对最多106/2=53串
* 对最少(106-22)/2=41串
* 错最多22*2=44串
* 错最少22/2=11串
### 投注25个一注单,100一个串算
~~~
按错最多44串,最少对41串,计算盈利
输44*100+41*75=4400+3075=7475
赢41*25*(最高平局按3.5)*(最低水1.8)=6457.5
亏7475-6457=1018
~~~
### 投注25个一注单,100一个串算
~~~
按错最少11串,最多对53串,计算盈利
输11*100+53*75=1100+3975=5075
赢53*25*(最高平局按3.5)*(最低水1.8)=8347.5
盈8347-5075=3272.5
~~~
## C2
### 非杯赛非排斥-对104 错12
### 胜率104/(104+12)=89.6551724137931%
* 对最多104/2=52串
* 对最少(104-12)/2=46串
* 错最多12*2=24串
* 错最少12/2=6串
### 投注25个一注单,100一个串算
~~~
按错最多24串,最少对46串,计算盈利
输24*100+46*75=2400+3450=5850
赢46*25*(最高平局按3.5)*(最低水1.8)=7245.5
盈7245-5850=1395
~~~
### 投注25个一注单,100一个串算
~~~
按错最少6串,最多对52串,计算盈利
输6*100+52*75=600+3900=4500
赢52*25*(最高平局按3.5)*(最低水1.8)=8190
盈8190-4500=3690.5
~~~
# 二串一双选玩法
~~~
二串一双选玩法共4个注单,25一个注单,100一个二串一双选
~~~
## 稳胆C1E2
### 非杯赛非排斥-对106 错22
### 胜率106/(106+22)=82.8125%
* 对最多106/2=53串
* 对最少(106-22)/2=41串
* 错最多22*2=44串
* 错最少22/2=11串
### 投注25个一注单,100一个串算
~~~
按错最多44串,最少对41串,计算盈利
输44*100+41*75=4400+3075=7475
赢41*25*(最高平局按3.5)*(最低水1.8)=6457.5
亏7475-6457=1018
~~~
### 投注25个一注单,100一个串算
~~~
按错最少11串,最多对53串,计算盈利
输11*100+53*75=1100+3975=5075
赢53*25*(最高平局按3.5)*(最低水1.8)=8347.5
盈8347-5075=3272.5
~~~
## C2
### 非杯赛非排斥-对104 错12
### 胜率104/(104+12)=89.6551724137931%
* 对最多104/2=52串
* 对最少(104-12)/2=46串
* 错最多12*2=24串
* 错最少12/2=6串
### 投注25个一注单,100一个串算
~~~
按错最多24串,最少对46串,计算盈利
输24*100+46*75=2400+3450=5850
赢46*25*(最高平局按3.5)*(最低水1.8)=7245.5
盈7245-5850=1395
~~~
### 投注25个一注单,100一个串算
~~~
按错最少6串,最多对52串,计算盈利
输6*100+52*75=600+3900=4500
赢52*25*(最高平局按3.5)*(最低水1.8)=8190
盈8190-4500=3690.5
~~~
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册