You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
343 lines
9.3 KiB
343 lines
9.3 KiB
package maptostruct
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"fmt"
|
|
"key_performance_indicators/middleware/wechatapp/wechatcallback"
|
|
"key_performance_indicators/models/modelshr"
|
|
"key_performance_indicators/models/modelskpi"
|
|
"key_performance_indicators/overall"
|
|
"key_performance_indicators/overall/publicmethod"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// map 装 struct 实验
|
|
func (a *ApiMethod) MapToStructShiyan(c *gin.Context) {
|
|
mapShiyan := map[string]string{
|
|
"name": "秦东",
|
|
"age": "1",
|
|
"time": "456313",
|
|
"time1": "45631321654654",
|
|
"time2": "4.5631321654654",
|
|
"time3": "45.631321654654",
|
|
}
|
|
var shiyanVal shiyanType
|
|
err := publicmethod.MapToStruct(mapShiyan, &shiyanVal, "json")
|
|
if err != nil {
|
|
publicmethod.Result(1, err.Error(), c)
|
|
return
|
|
}
|
|
fmt.Printf("shiyanType---->%v\n", shiyanVal)
|
|
publicmethod.Result(0, shiyanVal, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 11:08:11
|
|
@ 功能: 模拟回调
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SimulationCallBack(c *gin.Context) {
|
|
var receivedValue callBackCont
|
|
c.ShouldBindJSON(&receivedValue)
|
|
|
|
var jieMiCont wechatcallback.DecryptMsgCont
|
|
jieMiCont.MsgSignature = receivedValue.MsgSignature
|
|
jieMiCont.Timestamp = receivedValue.Timestamp
|
|
jieMiCont.Nonce = receivedValue.Nonce
|
|
jieMiCont.ToUsername = receivedValue.ToUsername
|
|
jieMiCont.Agentid = receivedValue.Agentid
|
|
jieMiCont.Encrypt = receivedValue.Encrypt
|
|
decryptMsgCont, jsonErr := jieMiCont.DecryptMsgInfo()
|
|
fmt.Printf("Xml----->%v----->%v\n\n", string(decryptMsgCont), jsonErr)
|
|
|
|
var msgCont wechatcallback.MsgContentXml
|
|
errXml := xml.Unmarshal(decryptMsgCont, &msgCont)
|
|
if errXml != nil {
|
|
fmt.Printf("回调事件失败!%v\n", errXml)
|
|
return
|
|
}
|
|
fmt.Printf("XmlCont----->%v\n\nwxcptJson----->%v\n\n", string(decryptMsgCont), msgCont)
|
|
|
|
switch msgCont.MsgType {
|
|
/*消息格式类型
|
|
*/
|
|
case "text": //文本
|
|
case "image": //图片
|
|
case "voice": //语音
|
|
case "video": //视频
|
|
case "location": //位置
|
|
wechatcallback.GeographicalPosition(decryptMsgCont)
|
|
case "link": //链接
|
|
/*事件格式类型*/
|
|
case "event":
|
|
/*
|
|
事件附属格式
|
|
*/
|
|
wechatcallback.EventProcessing(decryptMsgCont, jieMiCont, c)
|
|
// return
|
|
default:
|
|
}
|
|
|
|
// outData := publicmethod.MapOut[string]()
|
|
// outData["Xml"] = string(decryptMsgCont)
|
|
// outData["jieMiCont"] = jieMiCont
|
|
// outData["jsonErr"] = jsonErr
|
|
// outData["msgCont"] = msgCont
|
|
// publicmethod.Result(0, outData, c)
|
|
}
|
|
|
|
// 设置HR系统对接账号和密码
|
|
func (a *ApiMethod) SetUpHrSystem(c *gin.Context) {
|
|
var receivedValue hrUsernameAndPassword
|
|
err := c.ShouldBindJSON(&receivedValue)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
var hrCont modelshr.EmpowerUser
|
|
err = hrCont.GetCont(map[string]interface{}{"`userkey`": receivedValue.Username}, "`id`")
|
|
if err == nil {
|
|
publicmethod.Result(1, err, c, "该授权已经存在!请不要重复!")
|
|
return
|
|
}
|
|
//密码加密
|
|
var passWordMd5 publicmethod.Md5Encryption
|
|
passWordMd5.Md5EncryptionInit(receivedValue.Password)
|
|
passWordMd5Str := passWordMd5.Md5EncryptionAlgorithm()
|
|
hrCont.UserKey = receivedValue.Username
|
|
hrCont.Password = passWordMd5Str
|
|
hrCont.Name = receivedValue.Name
|
|
hrCont.State = 1
|
|
hrCont.Time = time.Now().Unix()
|
|
hrCont.EiteTime = time.Now().Unix()
|
|
hrCont.VerificationCode = receivedValue.VerificationCode
|
|
err = overall.CONSTANT_DB_HR.Create(&hrCont).Error
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-01-05 13:25:07
|
|
@ 功能: 审批流规制发生时间
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EvalProcTime(c *gin.Context) {
|
|
var listCont []modelskpi.EvaluationProcess
|
|
err := overall.CONSTANT_DB_KPI.Find(&listCont).Error
|
|
var dingXingOrd []int64
|
|
var dingLiangOrd []int64
|
|
if err == nil {
|
|
for _, v := range listCont {
|
|
if v.TypeClass == 1 {
|
|
if publicmethod.IsInTrue[int64](v.OrderKey, dingXingOrd) == false {
|
|
dingXingOrd = append(dingXingOrd, v.OrderKey)
|
|
}
|
|
} else {
|
|
if publicmethod.IsInTrue[int64](v.OrderKey, dingLiangOrd) == false {
|
|
dingLiangOrd = append(dingLiangOrd, v.OrderKey)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
syncSeting.Add(1)
|
|
go DingXingJiaoDui(dingXingOrd)
|
|
syncSeting.Add(1)
|
|
go DingLiangJiaoDui(dingLiangOrd)
|
|
syncSeting.Wait()
|
|
outData := publicmethod.MapOut[string]()
|
|
outData["err"] = err
|
|
outData["dingXingOrd"] = dingXingOrd
|
|
outData["dingXingOrdCount"] = len(dingXingOrd)
|
|
outData["dingLiangOrd"] = dingLiangOrd
|
|
outData["dingLiangOrdCount"] = len(dingLiangOrd)
|
|
publicmethod.Result(0, outData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-01-05 13:40:35
|
|
@ 功能: 定性审批流校对
|
|
@ 参数
|
|
|
|
#ordId 审批单ID
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func DingXingJiaoDui(ordId []int64) {
|
|
defer syncSeting.Done()
|
|
if len(ordId) > 100 {
|
|
var fenPi []int64
|
|
for i, v := range ordId {
|
|
if publicmethod.IsInTrue[int64](v, fenPi) == false {
|
|
fenPi = append(fenPi, v)
|
|
}
|
|
if (i+1)%100 == 0 {
|
|
syncSetings.Add(1)
|
|
go EditEvalProcDingXing(fenPi)
|
|
// fmt.Printf("%v--------->%v--------->%v\n", i, len(fenPi), fenPi)
|
|
fenPi = []int64{}
|
|
}
|
|
}
|
|
if len(fenPi) > 0 {
|
|
syncSetings.Add(1)
|
|
go EditEvalProcDingXing(fenPi)
|
|
}
|
|
syncSetings.Wait()
|
|
// fmt.Printf("结束--------->%v--------->%v\n", len(fenPi), fenPi)
|
|
} else {
|
|
if len(ordId) > 0 {
|
|
for _, v := range ordId {
|
|
var scoreFlowCont modelskpi.ScoreFlow
|
|
err := scoreFlowCont.GetCont(map[string]interface{}{"`sf_key`": v}, "`sf_happen_time`", "`sf_duty_department`")
|
|
if err == nil {
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["ep_happen_time"] = scoreFlowCont.HappenTime
|
|
saveData["ep_accept_department"] = scoreFlowCont.DutyDepartment
|
|
saveData["ep_time"] = time.Now().Unix()
|
|
var editEvalProce modelskpi.EvaluationProcess
|
|
editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
func EditEvalProcDingXing(ordId []int64) {
|
|
defer syncSetings.Done()
|
|
if len(ordId) > 0 {
|
|
for _, v := range ordId {
|
|
var scoreFlowCont modelskpi.ScoreFlow
|
|
err := scoreFlowCont.GetCont(map[string]interface{}{"`sf_key`": v}, "`sf_happen_time`", "`sf_duty_department`")
|
|
if err == nil {
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["ep_happen_time"] = scoreFlowCont.HappenTime
|
|
saveData["ep_accept_department"] = scoreFlowCont.DutyDepartment
|
|
saveData["ep_time"] = time.Now().Unix()
|
|
var editEvalProce modelskpi.EvaluationProcess
|
|
editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-01-05 13:40:35
|
|
@ 功能: 定量审批流校对
|
|
@ 参数
|
|
|
|
#ordId 审批单ID
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func DingLiangJiaoDui(ordId []int64) {
|
|
defer syncSeting.Done()
|
|
if len(ordId) > 100 {
|
|
var fenPi []int64
|
|
for i, v := range ordId {
|
|
if publicmethod.IsInTrue[int64](v, fenPi) == false {
|
|
fenPi = append(fenPi, v)
|
|
}
|
|
if (i+1)%100 == 0 {
|
|
syncSetings.Add(1)
|
|
go EditEvalProcDingLiang(fenPi)
|
|
// fmt.Printf("定量----》%v--------->%v--------->%v\n", i, len(fenPi), fenPi)
|
|
fenPi = []int64{}
|
|
}
|
|
}
|
|
if len(fenPi) > 0 {
|
|
syncSetings.Add(1)
|
|
go EditEvalProcDingLiang(fenPi)
|
|
}
|
|
syncSetings.Wait()
|
|
// fmt.Printf("定量----》结束--------->%v--------->%v\n", len(fenPi), fenPi)
|
|
} else {
|
|
if len(ordId) > 0 {
|
|
for _, v := range ordId {
|
|
var flowLogCont modelskpi.FlowLog
|
|
err := flowLogCont.GetCont(map[string]interface{}{"`fl_key`": v}, "`fl_year`", "`fl_month`", "`fl_day`", "`fl_duty_department`")
|
|
if err == nil {
|
|
monthStr := fmt.Sprintf("%v", flowLogCont.Month)
|
|
if flowLogCont.Month <= 9 {
|
|
monthStr = fmt.Sprintf("0%v", flowLogCont.Month)
|
|
}
|
|
dayStr := fmt.Sprintf("%v", flowLogCont.ToDay)
|
|
if flowLogCont.ToDay <= 9 {
|
|
dayStr = fmt.Sprintf("0%v", flowLogCont.ToDay)
|
|
}
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["ep_happen_time"] = publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-%v-%v 12:00:00", flowLogCont.Year, monthStr, dayStr))
|
|
saveData["ep_accept_department"] = flowLogCont.DutyDepartment
|
|
saveData["ep_time"] = time.Now().Unix()
|
|
var editEvalProce modelskpi.EvaluationProcess
|
|
editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
func EditEvalProcDingLiang(ordId []int64) {
|
|
defer syncSetings.Done()
|
|
if len(ordId) > 0 {
|
|
for _, v := range ordId {
|
|
var flowLogCont modelskpi.FlowLog
|
|
err := flowLogCont.GetCont(map[string]interface{}{"`fl_key`": v}, "`fl_year`", "`fl_month`", "`fl_day`", "`fl_duty_department`")
|
|
if err == nil {
|
|
monthStr := fmt.Sprintf("%v", flowLogCont.Month)
|
|
if flowLogCont.Month <= 9 {
|
|
monthStr = fmt.Sprintf("0%v", flowLogCont.Month)
|
|
}
|
|
dayStr := fmt.Sprintf("%v", flowLogCont.ToDay)
|
|
if flowLogCont.ToDay <= 9 {
|
|
dayStr = fmt.Sprintf("0%v", flowLogCont.ToDay)
|
|
}
|
|
timeString := fmt.Sprintf("%v-%v-%v 12:00:00", flowLogCont.Year, monthStr, dayStr)
|
|
fmt.Printf("定量---->%v---------->%v\n", v, timeString)
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["ep_happen_time"] = publicmethod.DateToTimeStampOld(timeString)
|
|
saveData["ep_accept_department"] = flowLogCont.DutyDepartment
|
|
saveData["ep_time"] = time.Now().Unix()
|
|
var editEvalProce modelskpi.EvaluationProcess
|
|
editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|