|
|
|
|
package callback
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"encoding/xml"
|
|
|
|
|
"fmt"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/utils/redishandel"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
//相关事件处理
|
|
|
|
|
func GeographicalPosition(eventMsg []byte) { //进入应用上报地址位置
|
|
|
|
|
var msgContent GeographicalPositionType
|
|
|
|
|
err := xml.Unmarshal(eventMsg, &msgContent)
|
|
|
|
|
if nil != err {
|
|
|
|
|
fmt.Println("***********Unmarshal fail")
|
|
|
|
|
}
|
|
|
|
|
userAddress := commonus.MapOut()
|
|
|
|
|
userAddress["userid"] = msgContent.FromUsername //userID
|
|
|
|
|
userAddress["latitude"] = msgContent.Latitude //地理位置纬度
|
|
|
|
|
userAddress["longitude"] = msgContent.Longitude //地理位置经度
|
|
|
|
|
userAddress["precision"] = msgContent.Precision //地理位置精度
|
|
|
|
|
userAddress["time"] = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
marshal, err := json.Marshal(userAddress)
|
|
|
|
|
if err != nil {
|
|
|
|
|
marshal = []byte{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
redisPrefix := "Location:GeographicalPosition_" + global.GVA_CONFIG.RedisPrefix.PreFix + ":userId_" + msgContent.FromUsername //redis KEY
|
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
|
|
|
redisClient.SetRedisDb(1)
|
|
|
|
|
// fmt.Printf("button===101===>%v\n", redisClient)
|
|
|
|
|
locationJson, locationErr := redisClient.Lindex(redisPrefix, 0)
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("button===102===>%v===>%v\n", locationJson, locationErr)
|
|
|
|
|
|
|
|
|
|
if locationErr != nil {
|
|
|
|
|
redisClient.Lpush(redisPrefix, string(marshal))
|
|
|
|
|
// fmt.Printf("button===1===>%v\n", marshal)
|
|
|
|
|
} else {
|
|
|
|
|
var geographicalPositionRedis GeographicalPositionRedis
|
|
|
|
|
jsonErr := json.Unmarshal([]byte(locationJson), &geographicalPositionRedis)
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("button===2111===>%v===>%v\n", jsonErr, geographicalPositionRedis)
|
|
|
|
|
if jsonErr != nil {
|
|
|
|
|
redisClient.Lpush(redisPrefix, string(marshal))
|
|
|
|
|
// fmt.Printf("button===2===>%v===>%v\n", jsonErr, locationJson)
|
|
|
|
|
} else {
|
|
|
|
|
timeVal := geographicalPositionRedis.Time
|
|
|
|
|
if time.Now().Unix()-timeVal >= 300 {
|
|
|
|
|
redisClient.Lpush(redisPrefix, string(marshal))
|
|
|
|
|
// fmt.Printf("button===4===>%v\n", marshal)
|
|
|
|
|
} else {
|
|
|
|
|
// fmt.Printf("button===412===>%v===>%v\n", timeVal, time.Now().Unix()-timeVal)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// longFloat, _ := strconv.ParseFloat(msgContent.Longitude, 64)
|
|
|
|
|
// latFloat, _ := strconv.ParseFloat(msgContent.Latitude, 64)
|
|
|
|
|
// long, latg := commonus.GCJ02toBD09(longFloat, latFloat)
|
|
|
|
|
// fmt.Printf("button======>%v======>%v======>%v\n", msgContent, long, latg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//自建应用审批处理
|
|
|
|
|
func OpenApprovalChange(eventMsg []byte) {
|
|
|
|
|
var msgContent OpenApprovalChangeType
|
|
|
|
|
err := xml.Unmarshal(eventMsg, &msgContent)
|
|
|
|
|
if nil != err {
|
|
|
|
|
fmt.Println("***********Unmarshal fail")
|
|
|
|
|
}
|
|
|
|
|
// jsonstr, _ := json.Marshal(msgContent)
|
|
|
|
|
|
|
|
|
|
if msgContent.ApprovalInfo.ThirdNo != "" {
|
|
|
|
|
//审批状态
|
|
|
|
|
approvalStatus := 1
|
|
|
|
|
agree := 0
|
|
|
|
|
agreeCount := 0
|
|
|
|
|
for _, approvalNode := range msgContent.ApprovalInfo.ApprovalNodes.ApprovalNode {
|
|
|
|
|
agreeCount++
|
|
|
|
|
if approvalNode.NodeStatus == 2 {
|
|
|
|
|
agree++
|
|
|
|
|
}
|
|
|
|
|
if approvalNode.NodeStatus > 2 {
|
|
|
|
|
approvalStatus = int(approvalNode.NodeStatus)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if agree == agreeCount {
|
|
|
|
|
approvalStatus = 2
|
|
|
|
|
}
|
|
|
|
|
eiteCont := commonus.MapOut()
|
|
|
|
|
eiteCont["al_states"] = approvalStatus
|
|
|
|
|
eiteCont["al_eite_time"] = time.Now().Unix()
|
|
|
|
|
var assessLog assessmentmodel.AssessmentLog //考核记录
|
|
|
|
|
eiteErr := global.GVA_DB_Performanceappraisal.Model(&assessLog).Select("al_states", "al_eite_time").Where("`al_order_id` = ?", msgContent.ApprovalInfo.ThirdNo).Updates(eiteCont).Error
|
|
|
|
|
if eiteErr == nil {
|
|
|
|
|
}
|
|
|
|
|
// fmt.Printf("approvalStatus================>%v\n", approvalStatus)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("open================>%v\n", string(jsonstr))
|
|
|
|
|
}
|