Merge branch 'master' of 10.10.14.250:huanghai/dsMin

master
wubin 5 years ago
commit 3d334ba2cb

80
.gitignore vendored

@ -1,39 +1,41 @@
/dsBaseRpc/.idea/
/dsBaseRpc/build/
/dsBaseRpc/WinBuild/
/dsBaseRpc/Logs/
/dsAutoCode/Logs/
/dsAutoCode/.idea/
/dsAutoCode/build/
/dsAutoCode/WinBuild/
/dsAutoCode/lastupdate.log
/dsBaseWeb/.idea/
/dsBaseWeb/build/
/dsBaseWeb/WinBuild/
/dsBaseWeb/Logs/
/dsBaseWeb/dsBaseRpc.log
/dsData/.idea/
/dsData/build/
/dsData/WinBuild/
/dsData/Logs/
/dsSso/.idea/
/dsSso/build/
/dsSso/WinBuild/
/dsSso/Logs/
/dsTools/.idea/
/dsTools/build/
/dsTools/WinBuild/
/dsWatch/.idea/
/dsWatch/build/
/dsWatch/WinBuild/
/dsBaseRpc/Java调用示例/JavaGRpc/target/
/dsWatch/Logs/
/dsAutoCode/.idea/
/dsBaseRpc/.idea/
/dsBaseRpc/build/
/dsBaseRpc/WinBuild/
/dsBaseRpc/Logs/
/dsAutoCode/Logs/
/dsAutoCode/.idea/
/dsAutoCode/build/
/dsAutoCode/WinBuild/
/dsAutoCode/lastupdate.log
/dsBaseWeb/.idea/
/dsBaseWeb/build/
/dsBaseWeb/WinBuild/
/dsBaseWeb/Logs/
/dsBaseWeb/dsBaseRpc.log
/dsData/.idea/
/dsData/build/
/dsData/WinBuild/
/dsData/Logs/
/dsSso/.idea/
/dsSso/build/
/dsSso/WinBuild/
/dsSso/Logs/
/dsTools/.idea/
/dsTools/build/
/dsTools/WinBuild/
/dsWatch/.idea/
/dsWatch/build/
/dsWatch/WinBuild/
/dsBaseRpc/Java调用示例/JavaGRpc/target/
/dsWatch/Logs/
/dsAutoCode/.idea/
/dsSupport/Source/
/dsSupport/Target/

@ -1,7 +0,0 @@
package DefaultConst
var (
IdentityId = "-1"
PersonId = "-1"
DeviceId = "-1"
)

@ -1,16 +0,0 @@
需求分析与整理:
1、要根据业务场景来对各表维护进行串联。
2、添加学校或教辅单位时需要给定area_code同时有单位类型代码可以根据这些创建单位管理员
t_base_organization,t_base_teacher,t_sys_loginperson,t_base_role四张表。--->OK
3、如果启用的是教育局因为教育局是黄海通过程序代码初始化完的现在需要判断是不是b_use正在发生变化如果是变为零
需要检查下面是不是有隶属的单位或人员(b_use=1)如果存在不允许禁用。如果不存在可以禁用需要在t_base_organization和
t_base_teacher,t_sys_loginperson三张表上b_use=-1.
如果是设置了b_use=1则需要检查原来对应的各表中是否存在旧数据如存在直接恢复b_use=1如不存在则需要创建之。
(1) t_base_organization--->这个不用添加只需修改b_use
(2) t_base_teacher---->需要添加
(3) t_sys_loginperson--->需要添加
(4) t_base_role----> 需要添加

@ -1,3 +0,0 @@
/*
https://github.com/xormplus/xorm
*/

@ -1,65 +0,0 @@
package CommonUtil
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"encoding/base64"
)
func AesEncrypt(orig string, key string) string {
// 转成字节数组
origData := []byte(orig)
k := []byte(key)
// 分组秘钥
block, _ := aes.NewCipher(k)
// 获取秘钥块的长度
blockSize := block.BlockSize()
// 补全码
origData = PKCS7Padding(origData, blockSize)
// 加密模式
blockMode := cipher.NewCBCEncrypter(block, k[:blockSize])
// 创建数组
cryted := make([]byte, len(origData))
// 加密
blockMode.CryptBlocks(cryted, origData)
return base64.StdEncoding.EncodeToString(cryted)
}
func AesDecrypt(cryted string, key string) string {
// 转成字节数组
crytedByte, _ := base64.StdEncoding.DecodeString(cryted)
k := []byte(key)
// 分组秘钥
block, _ := aes.NewCipher(k)
// 获取秘钥块的长度
blockSize := block.BlockSize()
// 加密模式
blockMode := cipher.NewCBCDecrypter(block, k[:blockSize])
// 创建数组
orig := make([]byte, len(crytedByte))
// 解密
blockMode.CryptBlocks(orig, crytedByte)
// 去补全码
orig = PKCS7UnPadding(orig)
return string(orig)
}
//补码
func PKCS7Padding(ciphertext []byte, blocksize int) []byte {
padding := blocksize - len(ciphertext)%blocksize
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
return append(ciphertext, padtext...)
}
//去码
func PKCS7UnPadding(origData []byte) []byte {
length := len(origData)
unpadding := int(origData[length-1])
return origData[:(length - unpadding)]
}

@ -1,30 +0,0 @@
package CommonUtil
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
/**
POST
2020-02-21
dataid=123
*/
func HttpPost(url string, data string) (string, error) {
request, err := http.Post(url, "application/x-www-form-urlencoded", strings.NewReader(data))
defer request.Body.Close()
if err != nil {
fmt.Printf("post data error:%v\n", err)
return "", err
} else {
respBody, err := ioutil.ReadAll(request.Body)
if err != nil {
return "", err
} else {
return string(respBody), nil
}
}
}

@ -1,30 +0,0 @@
package NetUtil
import (
"fmt"
"net"
)
/**
MAC
2020-01-19
*/
func GetMacAddrs() (macAddrs []string) {
netInterfaces, err := net.Interfaces()
if err != nil {
fmt.Printf("fail to get net interfaces: %v", err)
return macAddrs
}
for _, netInterface := range netInterfaces {
macAddr := netInterface.HardwareAddr.String()
if len(macAddr) == 0 {
continue
}
macAddrs = append(macAddrs, macAddr)
}
return macAddrs
}

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/dsSupport.iml" filepath="$PROJECT_DIR$/.idea/dsSupport.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

@ -0,0 +1,23 @@
package main
import (
"dsSupport/Utils/ConvertUtil"
)
func main() {
//源文件
source := "B7318F5D-46B8-4AA1-8811-1A9D65528E19.wmv"
//1、对视频文件进行切片
ConvertUtil.Cut(source)
//2、切片完成后尝试进行转码
var childMovie = ConvertUtil.GetAllCutChild(source)
for i := range childMovie {
ConvertUtil.ConvertToH264Mp4(childMovie[i])
}
//3、生成拼接的索引文件
indexName := ConvertUtil.GenerateIndexTxt(source, childMovie)
//4、合成MP4
ConvertUtil.Merge(source, indexName)
//5、清除垃圾
ConvertUtil.ClearRubbish(source)
}

@ -0,0 +1,135 @@
package ConvertUtil
import (
"dsSupport/Utils/FileUtil"
"dsSupport/Utils/ShellUtil"
"fmt"
"os"
"path"
"path/filepath"
"strings"
)
//运行的目录
var runDir string
// ffmpeg 的命令行位置
var ffmpeg string
func init() {
runDir, _ = os.Getwd()
ffmpeg=runDir + `\ffmpeg\ffmpeg.exe`
}
/**
2020-07-08
*/
func Cut(source string) {
//1、源视频文件
sourcePath := runDir + "/Source/" + source[0:2] + "/" + source
//2、获取文件后缀
extension := path.Ext(source)
//3、输出的文件通配名称
workingPath := runDir + `/Working/` + source[0:2] + "/"
if !FileUtil.Exists(workingPath) {
os.Mkdir(workingPath, os.ModePerm)
}
workingPath = workingPath + source[0:36] + "/"
if !FileUtil.Exists(workingPath) {
os.Mkdir(workingPath, os.ModePerm)
}
targetPath := workingPath + source[0:36] + `_%03d` + extension
//尝试删除已存在的视频
var i = 0
for {
var f = workingPath + source[0:36] + "_" + fmt.Sprintf("%03d", i) + extension
if FileUtil.Exists(f) {
os.Remove(f)
} else {
break
}
i++
}
//4、切片
cmdLine := ffmpeg + ` -fflags +genpts -i ` + sourcePath + ` -acodec copy -vcodec copy -f segment -segment_time 300 -reset_timestamps 1 -map 0:0 -map 0:1 ` + targetPath
ShellUtil.ExecCommand(cmdLine)
}
/**
2020-07-08
*/
func GetAllCutChild(source string) []string {
filepathNames, err := filepath.Glob(filepath.Join(runDir+`/Working/`+source[0:2]+"/"+source[0:36]+"/", "*"))
if err!=nil{
fmt.Println(err.Error())
}
return filepathNames
}
/**
H264MP4
:
2020-07-08
*/
func ConvertToH264Mp4(childMovie string) {
extension := path.Ext(childMovie)
childMovieMp4 := strings.Replace(childMovie, extension, ".mp4", -1)
//如果存在则删除之
if FileUtil.Exists(childMovieMp4) {
os.Remove(childMovieMp4)
}
cmdLine := ffmpeg + ` -i ` + childMovie + ` -c:v libx264 -strict -2 ` + childMovieMp4
ShellUtil.ExecCommand(cmdLine)
}
/**
2020-07-08
*/
func GenerateIndexTxt(source string,childMovie []string)string{
content:=make([]string,0)
for i := range childMovie {
extension := path.Ext(childMovie[i])
content= append(content, `file '`+strings.Replace(childMovie[i],extension,".mp4",-1)+`'`)
}
//文件位置
indexName:=runDir+`/Working/`+source[0:2]+"/"+source[0:36]+"/"+source[0:36]+".txt"
FileUtil.WriteLines(content,indexName)
return indexName
}
/**
2020-07-08
*/
func Merge(source string,indexName string){
Target := runDir + `/Target/` + source[0:2] + "/"
if !FileUtil.Exists(Target) {
os.Mkdir(Target, os.ModePerm)
}
Target = Target + source[0:36] + "/"
if !FileUtil.Exists(Target) {
os.Mkdir(Target, os.ModePerm)
}
cmdLine:=ffmpeg+` -f concat -i `+indexName+` -c copy `+Target+"/"+source[0:36]+".mp4"
ShellUtil.ExecCommand(cmdLine)
}
/**
2020-07-08
*/
func ClearRubbish(source string){
var deletePath=[]string{"Working","Target"}
for i := range deletePath {
//删除目录
os.RemoveAll(runDir+`/`+deletePath[i]+`/`+source[0:2]+"/"+source[0:36])
}
}

@ -0,0 +1,58 @@
package FileUtil
import (
"bufio"
"fmt"
"os"
)
// 判断所给路径文件/文件夹是否存在
func Exists(path string) bool {
_, err := os.Stat(path) //os.Stat获取文件信息
if err != nil {
if os.IsExist(err) {
return true
}
return false
}
return true
}
/**
2020-07-08
*/
func ReadLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, scanner.Err()
}
/**
2020-07-08
*/
func WriteLines(lines []string, path string) error {
file, err := os.Create(path)
if err != nil {
return err
}
defer file.Close()
w := bufio.NewWriter(file)
for _, line := range lines {
fmt.Fprintln(w, line)
}
return w.Flush()
}

@ -0,0 +1,15 @@
package ShellUtil
import (
"fmt"
"os/exec"
)
//封装一个函数来执行命令
func ExecCommand(cmdLine string) {
cmd := exec.Command("cmd.exe", "/c", cmdLine)
err := cmd.Run()
cmd.Wait()
fmt.Printf("%s, error:%v \n", cmdLine, err)
}

Binary file not shown.

@ -0,0 +1,3 @@
module dsSupport
go 1.14
Loading…
Cancel
Save