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.
3053 lines
106 KiB
3053 lines
106 KiB
package shiyan
|
|
|
|
import (
|
|
"encoding/json"
|
|
"encoding/xml"
|
|
"fmt"
|
|
"math"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/api/textcomparison"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/api/wechatapp/sendmessage"
|
|
"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/approvalprocess"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/wechat"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/utils/redishandel"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/mitchellh/mapstructure"
|
|
)
|
|
|
|
type ShiyanApi struct {
|
|
}
|
|
|
|
func (a *ShiyanApi) AddBaseMenu(c *gin.Context) {
|
|
// var answerMap testpage.Answer
|
|
// err := global.GVA_DB_Master.First(&answerMap)
|
|
// if err != nil {
|
|
|
|
// }
|
|
// fmt.Printf("%v\n", answerMap)
|
|
commonus.GetLastMonth()
|
|
Fanxing(1, []int8{123})
|
|
response.Ok(c)
|
|
}
|
|
|
|
type faxingType interface {
|
|
int | int8 | int16 | int32 | int64 | string
|
|
}
|
|
|
|
func Fanxing[T faxingType](key T, keyAry []T) bool {
|
|
for _, v := range keyAry {
|
|
if v == key {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// 校正定量审核流水全奖值零奖值封顶值设置
|
|
func (s *ShiyanApi) XiaoZhengDingliang(c *gin.Context) {
|
|
var flowLogList []assessmentmodel.FlowLog
|
|
err := global.GVA_DB_Performanceappraisal.Find(&flowLogList).Error
|
|
if err != nil {
|
|
response.Result(250, err, "没有数据", c)
|
|
return
|
|
}
|
|
for _, v := range flowLogList {
|
|
// fmt.Println(v)
|
|
var allZreoConfig []FlowLogAllZreo
|
|
evalQualId := strings.Split(v.EvaluationPlan, ",")
|
|
if len(evalQualId) > 0 {
|
|
for _, ev := range evalQualId {
|
|
var allZreoConfigInfo FlowLogAllZreo
|
|
allZreoConfigInfo.Id = ev
|
|
|
|
targetInfo, _ := commonus.GetQualitativeEvaluation(ev)
|
|
allZreoConfigInfo.TargetId = strconv.FormatInt(targetInfo.Target, 10)
|
|
switch targetInfo.Cycles {
|
|
case 5:
|
|
qualConfig, _ := commonus.GetDingLiangMuBiao(v.DutyGroup, v.DutyDepartment, targetInfo.Dimension, targetInfo.Target, v.Year, v.Quarter)
|
|
allZreoConfigInfo.Zeroprize = qualConfig.Zeroprize
|
|
allZreoConfigInfo.Allprize = qualConfig.Allprize
|
|
allZreoConfigInfo.Capping = qualConfig.CappingVal
|
|
case 6:
|
|
qualConfig, _ := commonus.GetDingLiangMuBiao(v.DutyGroup, v.DutyDepartment, targetInfo.Dimension, targetInfo.Target, v.Year, 1)
|
|
allZreoConfigInfo.Zeroprize = qualConfig.Zeroprize
|
|
allZreoConfigInfo.Allprize = qualConfig.Allprize
|
|
allZreoConfigInfo.Capping = qualConfig.CappingVal
|
|
default:
|
|
qualConfig, _ := commonus.GetDingLiangMuBiao(v.DutyGroup, v.DutyDepartment, targetInfo.Dimension, targetInfo.Target, v.Year, v.Month)
|
|
allZreoConfigInfo.Zeroprize = qualConfig.Zeroprize
|
|
allZreoConfigInfo.Allprize = qualConfig.Allprize
|
|
allZreoConfigInfo.Capping = qualConfig.CappingVal
|
|
}
|
|
|
|
allZreoConfig = append(allZreoConfig, allZreoConfigInfo)
|
|
}
|
|
}
|
|
editData := commonus.MapOut()
|
|
baselineJson, _ := json.Marshal(allZreoConfig)
|
|
editData["fl_baseline"] = string(baselineJson)
|
|
editData["fl_eite_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Where("fl_id = ?", v.Id).Updates(editData)
|
|
}
|
|
response.Result(0, err, "完成", c)
|
|
}
|
|
|
|
// get请求获参
|
|
func (a *ShiyanApi) GetRequestOperation(c *gin.Context) {
|
|
id := c.Query("id")
|
|
fmt.Printf("====>%v\n", id)
|
|
// strconv.Atoi(id)
|
|
idint, _ := strconv.Atoi(id)
|
|
GetNextMonth(idint)
|
|
response.Ok(c)
|
|
}
|
|
|
|
func GetNextMonth(dataSet int) {
|
|
dataSet = dataSet * -1
|
|
now := time.Now()
|
|
lastMonthFirstDay := now.AddDate(0, dataSet, -now.Day()+1)
|
|
lastMonthStart := time.Date(lastMonthFirstDay.Year(), lastMonthFirstDay.Month(), lastMonthFirstDay.Day(), 0, 0, 0, 0, now.Location()).Unix()
|
|
lastMonthEndDay := lastMonthFirstDay.AddDate(0, 1, -1)
|
|
lastMonthEnd := time.Date(lastMonthEndDay.Year(), lastMonthEndDay.Month(), lastMonthEndDay.Day(), 23, 59, 59, 0, now.Location()).Unix()
|
|
|
|
monthData := commonus.TimeStampToDate(lastMonthStart, 11)
|
|
monthDatas := commonus.TimeStampToDate(lastMonthEnd, 11)
|
|
fmt.Printf("%v------------------->%v------------------->%v------------------->%v------------------->%v\n", dataSet, lastMonthStart, lastMonthEnd, monthData, monthDatas)
|
|
}
|
|
|
|
// get请求获参
|
|
type postGroupCanshu struct {
|
|
Id int `json:"id" from:"id"`
|
|
}
|
|
|
|
func (a *ShiyanApi) PostRequestOperation(c *gin.Context) {
|
|
var ids postGroupCanshu
|
|
_ = c.ShouldBindJSON(&ids)
|
|
// name := c.Query("id")
|
|
fmt.Printf("====>%v\n", ids.Id)
|
|
response.Ok(c)
|
|
}
|
|
|
|
func Round(val float64, precision int) float64 {
|
|
p := math.Pow10(precision)
|
|
return math.Floor(val*p+0.5) / p
|
|
}
|
|
|
|
// 实验递归
|
|
func (s *ShiyanApi) DiGui(c *gin.Context) {
|
|
// var group []wechat.GroupForm
|
|
// listErr := global.GVA_DB_WatchDate.Find(&group).Error
|
|
// if listErr == nil {
|
|
// }
|
|
sdf := Round(19.2365233642256, 2)
|
|
response.Result(0, sdf, "查询成功", c)
|
|
return
|
|
var ids wechat.GroupForm
|
|
_ = c.ShouldBindJSON(&ids)
|
|
var setid int64
|
|
setid = 51
|
|
if ids.Id != 0 {
|
|
setid = ids.Id
|
|
}
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisDb(2)
|
|
redisClient.Set("cesi", "ccccc")
|
|
_, connn, _ := commonus.GetOfficeWork(16118387069540343, setid)
|
|
response.Result(0, connn, "查询成功", c)
|
|
return
|
|
// var parentId []int64
|
|
// var dd Ddigui
|
|
// dd.faherDigui(81, group, parentId)
|
|
// dd.Date = commonus.BubbleSort(dd.Date)
|
|
// var dd commonus.ErgodicStruct
|
|
// dd.ParentId = 1
|
|
// dd.ErgodicParentClassGroup(setid, group)
|
|
// dd.Date = append(dd.Date, setid)
|
|
// dd.Date = commonus.BubbleSort(dd.Date)
|
|
// setidIntString := strconv.FormatInt(setid, 10)
|
|
// setidInt, _ := strconv.Atoi(setidIntString)
|
|
// depart, isTrue := commonus.GetDepartment(setidInt)
|
|
// dateary := commonus.MapOut()
|
|
// dateary["data"] = depart
|
|
// dateary["istrue"] = isTrue
|
|
// dateary["digui"] = dd.Date
|
|
// response.Result(0, dateary, "查询失败", c)
|
|
}
|
|
|
|
type Ddigui struct {
|
|
Date []int64
|
|
}
|
|
|
|
// 递归递归函数
|
|
func (d *Ddigui) faherDigui(id int64, groupStruct []wechat.GroupForm, parentId []int64) []int64 {
|
|
var parentIds []int64
|
|
// parentId = append(parentId, id)
|
|
for _, v := range groupStruct {
|
|
if v.Id == id {
|
|
d.Date = append(d.Date, v.Parentid)
|
|
|
|
d.faherDigui(v.Parentid, groupStruct, parentId)
|
|
// parentId = append(parentId, v.Parentid)
|
|
// fmt.Printf("%v==========>%v*******%v\n", id, v.Parentid, parentId)
|
|
// parentIds = parentId
|
|
// parentIds = faherDigui(v.Parentid, groupStruct, parentIds)
|
|
|
|
// parentId = append(parentId, v.Parentid)
|
|
|
|
// fmt.Printf("%v==========>%v*******%v\n", id, v.Parentid, parentId)
|
|
|
|
}
|
|
}
|
|
// parentId = parentIds
|
|
// fmt.Printf("%v==========>*******\n", parentIds)
|
|
return parentIds
|
|
}
|
|
|
|
// 实验结果保存到数组
|
|
func (s *ShiyanApi) GormToMap(c *gin.Context) {
|
|
// returnData := commonus.MapOut()
|
|
// var returnData []map[string]interface{}
|
|
// tableName := "groupform"
|
|
// global.GVA_DB_WatchDate.Table(tableName).Find(&returnData)
|
|
var pGorm commonus.GormTopMap
|
|
pGorm.Db = global.GVA_DB_WatchDate
|
|
pGorm.TableName = "groupform"
|
|
returnData := commonus.MapOut()
|
|
returnData["ary"] = pGorm.PublicOrmToMap()
|
|
returnData["one"] = pGorm.PublicOrmToMapOne()
|
|
response.Result(0, returnData, "查询成功", c)
|
|
}
|
|
|
|
type PersonInfo struct {
|
|
DefinitIons interface{} `json:"definitions"`
|
|
}
|
|
|
|
// 读取json文件解析
|
|
func (s *ShiyanApi) ReadJsonFiles(c *gin.Context) {
|
|
|
|
filePtr, err := os.Open("conf/forkflow.json")
|
|
defer filePtr.Close()
|
|
if err != nil {
|
|
dfg := fmt.Sprintf("Open file failed [Err:%s]", err.Error())
|
|
// fmt.Println("Open file failed [Err:%s]", err.Error())
|
|
response.Result(0, dfg, "查询成功", c)
|
|
return
|
|
}
|
|
decoder := json.NewDecoder(filePtr)
|
|
|
|
var person []PersonInfo
|
|
|
|
err = decoder.Decode(&person)
|
|
if err != nil {
|
|
fmt.Println("Decoder failed", err.Error())
|
|
|
|
}
|
|
|
|
fmt.Println("Open file failed [Err:%s]", person)
|
|
returnData := commonus.MapOut()
|
|
returnData["json"] = person
|
|
response.Result(0, returnData, "查询成功", c)
|
|
}
|
|
|
|
//XML转换处理
|
|
|
|
/*
|
|
*XML结构体
|
|
*/
|
|
type Definitions struct {
|
|
XMLName xml.Name `xml:"definitions" json:"definitions"`
|
|
Text string `xml:",chardata" json:"chardata"`
|
|
Bpmn2 string `xml:"bpmn2,attr" json:"bpmn2"`
|
|
Xsi string `xml:"xsi,attr" json:"xsi"`
|
|
Bpmndi string `xml:"bpmndi,attr" json:"bpmndi"`
|
|
Dc string `xml:"dc,attr" json:"dc"`
|
|
Flowable string `xml:"flowable,attr" json:"flowable"`
|
|
Di string `xml:"di,attr" json:"di"`
|
|
ID string `xml:"id,attr" json:"id"`
|
|
TargetNamespace string `xml:"targetNamespace,attr" json:"targetNamespace"`
|
|
SchemaLocation string `xml:"schemaLocation,attr" json:"schemaLocation"`
|
|
Process ProcessStruct `xml:"process" json:"process"` //工作流过程
|
|
BPMNDiagram BPMNDiagramStruct `xml:"BPMNDiagram" json:"BPMNDiagram"` //BPMN图结构
|
|
}
|
|
|
|
// 工作流过程
|
|
type ProcessStruct struct {
|
|
TextAndIdStruct
|
|
NameStruct
|
|
Documentation Documentationstruct `xml:"documentation" json:"documentation"` //结构描述
|
|
StartEvent StartEventStruct `xml:"startEvent" json:"startEvent"` //开始事件
|
|
UserTask []UserTaskStruct `xml:"userTask" json:"userTask"` //流程主体(用户任务)
|
|
EndEvent EndEventStruct `xml:"endEvent" json:"endEvent"` //结束事件
|
|
SequenceFlow []SequenceFlowStruct `xml:"sequenceFlow" json:"sequenceFlow"` //序列流
|
|
}
|
|
|
|
// text结构体
|
|
type TextStruct struct {
|
|
Text string `xml:",chardata" json:",text"`
|
|
}
|
|
|
|
// name结构体
|
|
type NameStruct struct {
|
|
Name string `xml:"name,attr" json:"name"`
|
|
}
|
|
|
|
// Text与ID 结构
|
|
type TextAndIdStruct struct {
|
|
TextStruct
|
|
ID string `xml:"id,attr" json:"id"`
|
|
}
|
|
|
|
type Documentationstruct struct {
|
|
TextStruct
|
|
}
|
|
|
|
// 工作流开始事件
|
|
type StartEventStruct struct {
|
|
TextAndIdStruct
|
|
NameStruct
|
|
Outgoing []OutgoingStruct `xml:"outgoing" json:"outgoing"` //流程出口
|
|
}
|
|
|
|
// 流程出口结构
|
|
type OutgoingStruct struct {
|
|
TextStruct
|
|
}
|
|
|
|
// 流程主体(用户任务)
|
|
type UserTaskStruct struct {
|
|
TextAndIdStruct
|
|
NameStruct
|
|
Assignee string `xml:"assignee,attr" json:"assignee"` //处理人
|
|
CandidateGroups string `xml:"candidateGroups,attr" json:"candidateGroups"` //处理角色
|
|
CandidateUsers string `xml:"candidateUsers,attr" json:"candidateUsers"` //处理人
|
|
Incoming []IncomingStruct `xml:"incoming" json:"incoming"` //来源
|
|
Outgoing []OutgoingStruct `xml:"outgoing" json:"outgoing"` //流程去向(下一个节点)
|
|
}
|
|
|
|
// 本节点来源
|
|
type IncomingStruct struct {
|
|
TextStruct
|
|
}
|
|
|
|
// 结束事件
|
|
type EndEventStruct struct {
|
|
TextAndIdStruct
|
|
NameStruct
|
|
Incoming []IncomingStruct `xml:"incoming" json:"incoming"` //来源
|
|
}
|
|
|
|
// 序列流
|
|
type SequenceFlowStruct struct {
|
|
TextAndIdStruct
|
|
NameStruct
|
|
SourceRef string `xml:"sourceRef,attr" json:"sourceRef"` //源
|
|
TargetRef string `xml:"targetRef,attr" json:"targetRef"` //流向
|
|
ConditionExpression ConditionExpressionStruct `xml:"conditionExpression" json:"conditionExpression"` //条件表达式
|
|
}
|
|
|
|
// 条件表达式
|
|
type ConditionExpressionStruct struct {
|
|
TextStruct
|
|
Type string `xml:"type,attr" json:"type"`
|
|
}
|
|
|
|
// BPMN图结构
|
|
type BPMNDiagramStruct struct {
|
|
TextAndIdStruct
|
|
BPMNPlane BPMNPlaneStruct `xml:"BPMNPlane" json:"BPMNPlane"`
|
|
}
|
|
|
|
// 图平面坐标参数
|
|
type BPMNPlaneStruct struct {
|
|
TextAndIdStruct
|
|
BpmnElement string `xml:"bpmnElement,attr" json:"bpmnElement"` //Bpmn元素
|
|
BPMNShape []BPMNShapeStruct `xml:"BPMNShape" json:"BPMNShape"` //Bpmn 坐标参数
|
|
BPMNEdge []BPMNEdgeStruct `xml:"BPMNEdge" json:"BPMNEdge"` //Bpmn界限
|
|
}
|
|
|
|
// Bpmn 坐标参数
|
|
type BPMNShapeStruct struct {
|
|
TextAndIdStruct
|
|
BpmnElement string `xml:"bpmnElement,attr" json:"bpmnElement"`
|
|
Bounds BoundsStruct `xml:"Bounds" json:"Bounds"` //图形元素坐标
|
|
BPMNLabel BPMNLabelStruct `xml:"BPMNLabel" json:"BPMNLabel"` //BPMN标签
|
|
}
|
|
|
|
// 图形元素坐标
|
|
type BoundsStruct struct {
|
|
TextStruct
|
|
X string `xml:"x,attr" json:"x"`
|
|
Y string `xml:"y,attr" json:"y"`
|
|
Width string `xml:"width,attr" json:"width"`
|
|
Height string `xml:"height,attr" json:"height"`
|
|
}
|
|
|
|
// BPMN标签
|
|
type BPMNLabelStruct struct {
|
|
TextStruct
|
|
Bounds BoundsStruct `xml:"Bounds" json:"Bounds"` //图形元素坐标
|
|
}
|
|
|
|
// Bpmn界限
|
|
type BPMNEdgeStruct struct {
|
|
TextAndIdStruct
|
|
BpmnElement string `xml:"bpmnElement,attr" json:"bpmnElement"`
|
|
Waypoint []WaypointStruct `xml:"waypoint" json:"waypoint"` //线路径坐标
|
|
}
|
|
|
|
// 线路径坐标
|
|
type WaypointStruct struct {
|
|
TextStruct
|
|
X string `xml:"x,attr" json:"x"`
|
|
Y string `xml:"y,attr" json:"y"`
|
|
}
|
|
|
|
// 接收参数
|
|
type XmlCanShu struct {
|
|
ProcessKey string `json:"processKey"`
|
|
ProcessName string `json:"processName"`
|
|
ResourceName string `json:"resourceName"`
|
|
Xml string `json:"xml"`
|
|
Svg string `json:"svg"`
|
|
JsonStr string `json:"jsonstr"`
|
|
}
|
|
|
|
// 工作流XML解析
|
|
func (s *ShiyanApi) XmlToJson(c *gin.Context) {
|
|
var xmlToStruct Definitions
|
|
var reportAnswer XmlCanShu
|
|
err := c.ShouldBindJSON(&reportAnswer)
|
|
// if err != nil {
|
|
// response.Result(101, err, "参数错误!", c)
|
|
// return
|
|
// }
|
|
if reportAnswer.Xml == "" {
|
|
response.Result(102, err, "参数错误!", c)
|
|
return
|
|
}
|
|
errs := xml.Unmarshal([]byte(reportAnswer.Xml), &xmlToStruct)
|
|
if nil != errs {
|
|
fmt.Println("Unmarshal fail")
|
|
} else {
|
|
fmt.Println("struct", xmlToStruct)
|
|
}
|
|
returnData := commonus.MapOut()
|
|
returnData["reportAnswer"] = reportAnswer
|
|
returnData["xmlToStruct"] = xmlToStruct
|
|
|
|
var approvalProcess approvalprocess.ApprovalProcess
|
|
processMap := commonus.MapOut()
|
|
|
|
processId := commonus.GetFileNumberEs()
|
|
approvalProcess.Id = processId
|
|
processMap["id"] = processId
|
|
|
|
approvalProcess.Name = xmlToStruct.Process.Name
|
|
|
|
processMap["name"] = xmlToStruct.Process.Name
|
|
|
|
result, jsonErr := json.Marshal(xmlToStruct)
|
|
if jsonErr == nil {
|
|
approvalProcess.Flow = string(result)
|
|
processMap["flow"] = string(result)
|
|
} else {
|
|
processMap["flow"] = ""
|
|
}
|
|
approvalProcess.FlowJson = reportAnswer.JsonStr
|
|
processMap["flowjson"] = reportAnswer.JsonStr
|
|
approvalProcess.FlowXml = reportAnswer.Xml
|
|
processMap["flowxml"] = reportAnswer.Xml
|
|
approvalProcess.FlowSvg = reportAnswer.Svg
|
|
processMap["flowsvg"] = reportAnswer.Svg
|
|
|
|
resultPro, jsonErrPro := json.Marshal(xmlToStruct.Process)
|
|
if jsonErrPro == nil {
|
|
approvalProcess.GetFlowJson = string(resultPro)
|
|
processMap["getflowjson"] = string(resultPro)
|
|
} else {
|
|
processMap["getflowjson"] = ""
|
|
}
|
|
approvalProcess.Time = time.Now().Unix()
|
|
approvalProcess.EiteTime = time.Now().Unix()
|
|
approvalProcess.Sate = 1
|
|
processMap["sate"] = 1
|
|
|
|
batchNum := commonus.GetFileNumberEs()
|
|
approvalProcess.Batch = batchNum
|
|
processMap["batchnum"] = batchNum
|
|
approvalProcess.EditionNum = "V1.0"
|
|
processMap["editionnum"] = "V1.0"
|
|
|
|
returnData["approvalProcess"] = approvalProcess
|
|
|
|
// writeRedisData := map[string]interface{}{
|
|
// "name": xmlToStruct.Process.Name,
|
|
// "flow": string(result),
|
|
// "flowjson": reportAnswer.JsonStr,
|
|
// "flowxml": reportAnswer.Xml,
|
|
// "flowsvg": reportAnswer.Svg,
|
|
// "getflowjson": string(resultPro),
|
|
// "sate": 1,
|
|
// "batchnum": batchNum,
|
|
// "editionnum": "V1.0",
|
|
// }
|
|
// addProcess := global.GVA_DB_ApprovalProcess.Create(&approvalProcess)
|
|
// if addProcess.Error != nil {
|
|
// response.Result(104, addProcess.Error, "流程创建失败", c)
|
|
// return
|
|
// }
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisTime(0)
|
|
kks := redisClient.HashMsetAdd("Process:ApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(batchNum, 10), processMap)
|
|
|
|
response.Result(103, kks, "参数错误!", c)
|
|
}
|
|
|
|
type ExamineApprove struct {
|
|
ProcessId int64 `json:"processId"` //流程批次
|
|
ExamineApproveId int64 `json:"examineApproveId"` //正在执行的流程
|
|
Type int `json:"type"` //状态(1:同意;2:驳回;3:暂存)
|
|
Condition string `json:"condition"` //判断条件
|
|
State int `json:"state"` //状态
|
|
}
|
|
|
|
// 审批记录Redis过度
|
|
type ApprovalProcessLogRedis struct {
|
|
Id string `json:"id"`
|
|
Process string `json:"process" `
|
|
CurrentNode string `json:"currentNode"`
|
|
Title string `json:"title" `
|
|
Time string `json:"time"`
|
|
EiteTime string `json:"eiteTime"`
|
|
ProcessNum string `json:"processNum"`
|
|
IsEnd string `json:"isEnd"`
|
|
State string `json:"state"`
|
|
}
|
|
|
|
// 创建及审批
|
|
func (s *ShiyanApi) EstablishApprove(c *gin.Context) {
|
|
var examineApprove ExamineApprove
|
|
err := c.ShouldBindJSON(&examineApprove)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!", c)
|
|
return
|
|
}
|
|
if examineApprove.ProcessId == 0 || examineApprove.ExamineApproveId == 0 {
|
|
response.Result(102, examineApprove, "参数错误!", c)
|
|
return
|
|
}
|
|
if examineApprove.Type == 0 {
|
|
examineApprove.Type = 2
|
|
}
|
|
//正在执行的流程
|
|
var runApprovalProcess approvalprocess.ApprovalProcessLog
|
|
//缓存设置
|
|
redisClient := redishandel.RunRedis()
|
|
|
|
approvalProcessRedis, isTrue := redisClient.HashGetAll("Process:RunApprovalProcess_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + strconv.FormatInt(examineApprove.ExamineApproveId, 10))
|
|
if isTrue != true { //判断是否存在缓存
|
|
runProcessMap := commonus.MapOut()
|
|
appProLogErr := global.GVA_DB_ApprovalProcess.Where("`apl_id` = ?", examineApprove.ExamineApproveId).First(&runApprovalProcess).Error
|
|
if appProLogErr != nil {
|
|
var getApprovalProcess approvalprocess.ApprovalProcess
|
|
getProLogErr := global.GVA_DB_ApprovalProcess.Where("`ap_batch` = ? AND `ap_state` = 1", examineApprove.ProcessId).First(&getApprovalProcess).Error
|
|
if getProLogErr != nil {
|
|
response.Result(103, getApprovalProcess, "对不起该流程不存在", c)
|
|
return
|
|
}
|
|
|
|
runApprovalProcess.Process = getApprovalProcess.GetFlowJson
|
|
runProcessMap["process"] = getApprovalProcess.GetFlowJson
|
|
//流程json转为struct
|
|
var process ProcessStruct
|
|
jsonErrPro := json.Unmarshal([]byte(getApprovalProcess.GetFlowJson), &process)
|
|
if jsonErrPro == nil {
|
|
runApprovalProcess.CurrentNode = process.StartEvent.ID
|
|
runApprovalProcess.Title = process.StartEvent.Name
|
|
runApprovalProcess.ProcessNum = getApprovalProcess.Batch
|
|
|
|
runProcessMap["currentNode"] = process.StartEvent.ID
|
|
runProcessMap["title"] = process.StartEvent.Name
|
|
runProcessMap["processNum"] = getApprovalProcess.Batch
|
|
} else {
|
|
runApprovalProcess.CurrentNode = ""
|
|
runApprovalProcess.Title = ""
|
|
runApprovalProcess.ProcessNum = 0
|
|
|
|
runProcessMap["currentNode"] = ""
|
|
runProcessMap["title"] = ""
|
|
runProcessMap["processNum"] = 0
|
|
}
|
|
runApprovalProcess.Time = time.Now().Unix()
|
|
runApprovalProcess.EiteTime = time.Now().Unix()
|
|
|
|
runApprovalProcess.IsEnd = 1
|
|
runProcessMap["isend"] = 1
|
|
if examineApprove.State == 0 {
|
|
runApprovalProcess.Sate = 1
|
|
runProcessMap["state"] = 1
|
|
} else {
|
|
runApprovalProcess.Sate = examineApprove.State
|
|
runProcessMap["state"] = examineApprove.State
|
|
}
|
|
|
|
runProcessMap["time"] = time.Now().Unix()
|
|
runProcessMap["eiteTime"] = time.Now().Unix()
|
|
|
|
addProcess := global.GVA_DB_ApprovalProcess.Create(&runApprovalProcess).Error
|
|
if addProcess != nil {
|
|
response.Result(104, getApprovalProcess, "对不起该流程启用失败", c)
|
|
return
|
|
}
|
|
runProcessMap["id"] = runApprovalProcess.Id
|
|
redisClient.SetRedisTime(0)
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
} else {
|
|
runProcessMap["process"] = runApprovalProcess.Process
|
|
runProcessMap["currentNode"] = runApprovalProcess.CurrentNode
|
|
runProcessMap["title"] = runApprovalProcess.Title
|
|
runProcessMap["processNum"] = runApprovalProcess.ProcessNum
|
|
runProcessMap["time"] = runApprovalProcess.Time
|
|
runProcessMap["eiteTime"] = runApprovalProcess.EiteTime
|
|
runProcessMap["id"] = runApprovalProcess.Id
|
|
runProcessMap["isend"] = runApprovalProcess.IsEnd
|
|
runProcessMap["state"] = runApprovalProcess.Sate
|
|
if runApprovalProcess.IsEnd == 1 {
|
|
redisClient.SetRedisTime(0)
|
|
} else {
|
|
redisClient.SetRedisTime(604800)
|
|
}
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
if runApprovalProcess.IsEnd != 1 {
|
|
response.Result(105, runApprovalProcess, "该流程已经结束!请不要重复执行!", c)
|
|
return
|
|
}
|
|
}
|
|
} else {
|
|
// fmt.Printf("Redis====》%v\n", runApprovalProcess)
|
|
var approvalProcessLogRedis ApprovalProcessLogRedis
|
|
err := mapstructure.Decode(approvalProcessRedis, &approvalProcessLogRedis)
|
|
if err != nil {
|
|
response.Result(104, err, "对不起该流程启用失败", c)
|
|
return
|
|
// return departmentlist, false
|
|
}
|
|
appId, appIdErr := strconv.ParseInt(approvalProcessLogRedis.Id, 10, 64)
|
|
|
|
if appIdErr == nil {
|
|
runApprovalProcess.Id = appId
|
|
}
|
|
|
|
// fmt.Printf("审批ID==Redis==》%v-------------%v\n", approvalProcessLogRedis.Id, appId)
|
|
|
|
processNum, processNumErr := strconv.ParseInt(approvalProcessLogRedis.ProcessNum, 10, 64)
|
|
if processNumErr == nil {
|
|
runApprovalProcess.ProcessNum = processNum
|
|
}
|
|
|
|
timeVal, timeErr := strconv.ParseInt(approvalProcessLogRedis.Time, 10, 64)
|
|
if timeErr == nil {
|
|
runApprovalProcess.Time = timeVal
|
|
}
|
|
eiteTime, eiteTimeErr := strconv.ParseInt(approvalProcessLogRedis.EiteTime, 10, 64)
|
|
if eiteTimeErr == nil {
|
|
runApprovalProcess.EiteTime = eiteTime
|
|
}
|
|
|
|
isEnd, isEndErr := strconv.Atoi(approvalProcessLogRedis.IsEnd)
|
|
if isEndErr == nil {
|
|
runApprovalProcess.IsEnd = isEnd
|
|
} else {
|
|
response.Result(107, runApprovalProcess, "对不起该流程启用失败!", c)
|
|
return
|
|
}
|
|
sateSet, sateErr := strconv.Atoi(approvalProcessLogRedis.State)
|
|
if sateErr == nil {
|
|
runApprovalProcess.Sate = sateSet
|
|
} else {
|
|
response.Result(108, sateErr, "对不起该流程启用失败!", c)
|
|
return
|
|
}
|
|
|
|
runApprovalProcess.Process = approvalProcessLogRedis.Process
|
|
runApprovalProcess.CurrentNode = approvalProcessLogRedis.CurrentNode
|
|
runApprovalProcess.Title = approvalProcessLogRedis.Title
|
|
|
|
if runApprovalProcess.IsEnd != 1 {
|
|
response.Result(106, runApprovalProcess, "该流程已经结束!请不要重复执行!", c)
|
|
return
|
|
}
|
|
}
|
|
// fmt.Printf("数据结构===========>%v\n", runApprovalProcess)
|
|
switch examineApprove.Type {
|
|
case 1: //批准
|
|
ApproveOperation(runApprovalProcess, examineApprove)
|
|
case 3: //暂存
|
|
default: //驳回
|
|
}
|
|
}
|
|
|
|
// 批准操作
|
|
func ApproveOperation(runApprovalProcess approvalprocess.ApprovalProcessLog, examineApprove ExamineApprove) (isTrue bool) {
|
|
// fmt.Printf("审批ID==Redis==》%v-------------%v\n", runApprovalProcess.Id, runApprovalProcess)
|
|
isTrue = false
|
|
// fmt.Printf("结果====》%v\n", runApprovalProcess)
|
|
var process ProcessStruct
|
|
jsonErrPro := json.Unmarshal([]byte(runApprovalProcess.Process), &process)
|
|
if jsonErrPro != nil {
|
|
fmt.Printf("转换失败====》%v\n", process)
|
|
return
|
|
}
|
|
if runApprovalProcess.CurrentNode == process.EndEvent.ID {
|
|
fmt.Printf("执行结束节点====》%v\n", process.EndEvent.ID)
|
|
return
|
|
}
|
|
|
|
if runApprovalProcess.CurrentNode == process.StartEvent.ID {
|
|
fmt.Printf("执行开始节点====》%v\n", process.StartEvent.ID)
|
|
|
|
if len(process.StartEvent.Outgoing) > 1 {
|
|
fmt.Printf("执行开始节点====有条件》%v\n", process.StartEvent.ID)
|
|
|
|
currentId := runApprovalProcess.CurrentNode
|
|
|
|
appId, appTitle, appIsTrue, isEnd := ApprovalCriteria(1, process, examineApprove, runApprovalProcess.CurrentNode)
|
|
|
|
fmt.Printf("执行审批节点==11111==下一个节点》%v----%v-----%v\n", appId, appTitle, appIsTrue)
|
|
if appIsTrue != true {
|
|
return
|
|
}
|
|
isTrue = true
|
|
currentId = appId
|
|
|
|
// for _, outGoing := range process.StartEvent.Outgoing {
|
|
// for _, seqFlow := range process.SequenceFlow {
|
|
// if outGoing.Text == seqFlow.ID {
|
|
// // fmt.Printf("条件(%v)====》对比条件-----%v\n", seqFlow.ConditionExpression.Text, examineApprove.Condition)
|
|
// if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
// isTrue = true
|
|
// currentId = seqFlow.TargetRef
|
|
// fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
runApprovalProcess.CurrentNode = currentId
|
|
runApprovalProcess.Title = appTitle
|
|
runApprovalProcess.EiteTime = time.Now().Unix()
|
|
|
|
runProcessMap := commonus.MapOut()
|
|
runProcessMap["process"] = runApprovalProcess.Process
|
|
runProcessMap["currentNode"] = currentId
|
|
|
|
runProcessMap["processNum"] = runApprovalProcess.ProcessNum
|
|
runProcessMap["time"] = time.Now().Unix()
|
|
|
|
runProcessMap["title"] = appTitle
|
|
runProcessMap["eiteTime"] = time.Now().Unix()
|
|
|
|
if isEnd == true {
|
|
runApprovalProcess.IsEnd = 2
|
|
runProcessMap["isend"] = 2
|
|
}
|
|
|
|
//缓存设置
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisTime(604800)
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
|
|
fmt.Printf("审批ID==22222==》%v\n", runApprovalProcess.Id)
|
|
|
|
eiteProcess := global.GVA_DB_ApprovalProcess.Where("`apl_id` = ?", runApprovalProcess.Id).Updates(&runApprovalProcess).Error
|
|
|
|
if eiteProcess == nil {
|
|
fmt.Printf("更新成功====》%v\n", runApprovalProcess)
|
|
} else {
|
|
fmt.Printf("更新失败====》%v\n", runApprovalProcess)
|
|
}
|
|
return
|
|
} else if len(process.StartEvent.Outgoing) < 1 {
|
|
fmt.Printf("执行开始节点====未知下个节点》%v\n", process.StartEvent.ID)
|
|
} else {
|
|
fmt.Printf("执行开始节点====直接到审批》%v\n", process.StartEvent.ID)
|
|
}
|
|
|
|
}
|
|
|
|
for _, taskVal := range process.UserTask {
|
|
if runApprovalProcess.CurrentNode == taskVal.ID {
|
|
fmt.Printf("执行审批节点====》%v\n", taskVal.ID)
|
|
appId, appTitle, appIsTrue, isEnd := ApprovalCriteria(3, process, examineApprove, runApprovalProcess.CurrentNode)
|
|
|
|
fmt.Printf("执行审批节点====下一个节点》%v----%v-----%v\n", appId, appTitle, appIsTrue)
|
|
|
|
currentId := runApprovalProcess.CurrentNode
|
|
if appIsTrue != true {
|
|
return
|
|
}
|
|
isTrue = true
|
|
currentId = appId
|
|
runApprovalProcess.CurrentNode = currentId
|
|
runApprovalProcess.Title = appTitle
|
|
runApprovalProcess.EiteTime = time.Now().Unix()
|
|
|
|
runProcessMap := commonus.MapOut()
|
|
runProcessMap["process"] = runApprovalProcess.Process
|
|
runProcessMap["currentNode"] = currentId
|
|
|
|
runProcessMap["processNum"] = runApprovalProcess.ProcessNum
|
|
runProcessMap["time"] = time.Now().Unix()
|
|
|
|
runProcessMap["title"] = appTitle
|
|
runProcessMap["eiteTime"] = time.Now().Unix()
|
|
|
|
if isEnd == true {
|
|
runApprovalProcess.IsEnd = 2
|
|
runProcessMap["isend"] = 2
|
|
}
|
|
|
|
//缓存设置
|
|
redisClient := redishandel.RunRedis()
|
|
redisClient.SetRedisTime(604800)
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
|
|
fmt.Printf("审批ID====》%v\n", runApprovalProcess.Id)
|
|
|
|
eiteProcess := global.GVA_DB_ApprovalProcess.Where("`apl_id` = ?", runApprovalProcess.Id).Updates(&runApprovalProcess).Error
|
|
|
|
if eiteProcess == nil {
|
|
fmt.Printf("更新成功uis====》%v\n", runApprovalProcess)
|
|
} else {
|
|
fmt.Printf("更新失败uis====》%v\n", runApprovalProcess)
|
|
}
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//审批条件解析
|
|
/*
|
|
@execStatus 执行状态 1:开始;2:结束;3:审批
|
|
*/
|
|
func ApprovalCriteria(execStatus int, process ProcessStruct, examineApprove ExamineApprove, currentNode string) (currentId, nextTitle string, isTrue, isEnd bool) {
|
|
isTrue = false
|
|
isEnd = false
|
|
//解析条件判断,获取出下个节点的ID
|
|
switch execStatus {
|
|
case 1:
|
|
fmt.Printf("State ----------> %v\n", execStatus)
|
|
for _, outGoing := range process.StartEvent.Outgoing {
|
|
for _, seqFlow := range process.SequenceFlow {
|
|
if outGoing.Text == seqFlow.ID {
|
|
fmt.Printf("条件(%v)====》对比条件-----%v\n", seqFlow.ConditionExpression.Text, examineApprove.Condition)
|
|
if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
isTrue = true
|
|
currentId = seqFlow.TargetRef
|
|
fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case 2:
|
|
fmt.Printf("State ----------> %v\n", execStatus)
|
|
default:
|
|
fmt.Printf("State ----------> %v\n", execStatus)
|
|
for _, taskVal := range process.UserTask {
|
|
if taskVal.ID == currentNode {
|
|
for _, outGoing := range taskVal.Outgoing {
|
|
for _, seqFlow := range process.SequenceFlow {
|
|
if outGoing.Text == seqFlow.ID {
|
|
fmt.Printf("条件(%v)====》对比条件-----%v\n", seqFlow.ConditionExpression.Text, examineApprove.Condition)
|
|
if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
isTrue = true
|
|
currentId = seqFlow.TargetRef
|
|
fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// for _, seqFlow := range process.SequenceFlow {
|
|
|
|
// fmt.Printf("条件(%v)====》对比条件-----%v\n", taskVal.ID, seqFlow.ID)
|
|
|
|
// if taskVal.ID == seqFlow.ID {
|
|
|
|
// if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
// isTrue = true
|
|
// currentId = seqFlow.TargetRef
|
|
// fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
// }
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
nextNameIsTrue := false
|
|
//获取审批节点名称
|
|
for _, taskVal := range process.UserTask {
|
|
if taskVal.ID == currentId {
|
|
nextTitle = taskVal.Name
|
|
nextNameIsTrue = true
|
|
}
|
|
}
|
|
if nextNameIsTrue != true {
|
|
if currentId == process.EndEvent.ID {
|
|
nextTitle = process.EndEvent.Name
|
|
nextNameIsTrue = true
|
|
isEnd = true
|
|
return
|
|
}
|
|
if currentId == process.StartEvent.ID {
|
|
nextTitle = process.StartEvent.Name
|
|
nextNameIsTrue = true
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 实验发送按钮交互模板
|
|
func (s *ShiyanApi) SendButtonMsg(c *gin.Context) {
|
|
// var sendMsg commonus.ButtonTemplateAll
|
|
var sendMsg commonus.ButtonTemplate
|
|
sendMsg.Touser = "KaiXinGuo"
|
|
sendMsg.MsgType = "template_card"
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
sendMsg.AgentId = appId
|
|
sendMsg.EnableIdTrans = 0
|
|
sendMsg.EnableDuplicateCheck = 0
|
|
sendMsg.DuplicateCheckInterval = 1800
|
|
//模板卡片类型,按钮交互型卡片填写"button_interaction" (必填)
|
|
sendMsg.TemplateCard.CardType = "button_interaction"
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
sendMsg.TemplateCard.Source.Desc = "知行学院"
|
|
sendMsg.TemplateCard.Source.DescColor = 2
|
|
//卡片右上角更多操作按钮 (非必填)
|
|
// sendMsg.TemplateCard.ActionMenu =
|
|
// sendMsg.TemplateCard.ActionMenu.Desc = "卡片副交互辅助文本说明"
|
|
// var actionList []commonus.ActionListStruct
|
|
// var actionCont commonus.ActionListStruct
|
|
// actionCont.Text = "接受推送"
|
|
// actionCont.Key = "A"
|
|
// actionList = append(actionList, actionCont)
|
|
// actionCont.Text = "不再推"
|
|
// actionCont.Key = "b"
|
|
// actionList = append(actionList, actionCont)
|
|
// sendMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
//一级标题,建议不超过36个字,(支持id转译)
|
|
sendMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
sendMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
//引用文献样式
|
|
sendMsg.TemplateCard.QuoteArea.Type = 1
|
|
sendMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
sendMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
sendMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
//二级普通文本,建议不超过160个字(非必填)
|
|
// sendMsg.TemplateCard.SubTitleText = "二级普通文本,下载企业微信还能抢红包!"
|
|
|
|
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6(非必填)
|
|
var htalConListStrMap []commonus.HorizontalContentListStruct
|
|
var htalConListStrCon commonus.HorizontalContentListStruct
|
|
htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "申请人"
|
|
htalConListStrCon.Value = "秦东"
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
// htalConListStrCon.Type = 1
|
|
// htalConListStrCon.KeyName = "企业微信官网"
|
|
// htalConListStrCon.Value = "点击访问"
|
|
// htalConListStrCon.Url = "http://admin.hxgk.group"
|
|
// htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
htalConListStrCon.Value = "秦东"
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
sendMsg.TemplateCard.HorizontalContentList = htalConListStrMap
|
|
//整体卡片的点击跳转事件 (非必填)
|
|
sendMsg.TemplateCard.CardAction.Type = 1
|
|
sendMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
taskId := commonus.GetFileNumberEs()
|
|
sendMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
//下拉式的选择器 (未知是否必填)
|
|
// questionKey := commonus.GetFileNumberEs()
|
|
// sendMsg.TemplateCard.ButtonSelection.QuestionKey = strconv.FormatInt(questionKey, 10)
|
|
// sendMsg.TemplateCard.ButtonSelection.Title = "下拉标题"
|
|
// //下拉内容设置
|
|
// var optionListMap []commonus.OptionListStructes
|
|
// var optionListCont commonus.OptionListStructes
|
|
// optionListCont.Id = "btn_selection_id1"
|
|
// optionListCont.Text = "100分"
|
|
// optionListMap = append(optionListMap, optionListCont)
|
|
// optionListCont.Id = "btn_selection_id2"
|
|
// optionListCont.Text = "110分"
|
|
// optionListMap = append(optionListMap, optionListCont)
|
|
// sendMsg.TemplateCard.ButtonSelection.OptionList = optionListMap
|
|
// sendMsg.TemplateCard.ButtonSelection.SelectedId = "btn_selection_id1"
|
|
//按钮列表,列表长度不超过6(必填)
|
|
var buttonMap []commonus.ButtonListStruct
|
|
var buttonCont commonus.ButtonListStruct
|
|
buttonCont.Type = 0
|
|
buttonCont.Text = "批准"
|
|
buttonCont.Style = 1
|
|
buttonCont.Key = "button_key_1"
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
buttonCont.Type = 0
|
|
buttonCont.Text = "驳回"
|
|
buttonCont.Style = 3
|
|
buttonCont.Key = "button_key_2"
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
sendMsg.TemplateCard.ButtonList = buttonMap
|
|
response.Result(0, sendMsg, "查询成功", c)
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendMsg.SendButtonMessage()
|
|
fmt.Printf("发送信息返回:%v-----------%v----------->%v\n", string(callbakcMsg), isTrueCall, callBackCont)
|
|
}
|
|
|
|
func (s *ShiyanApi) SendButtonMessageAll(c *gin.Context) {
|
|
var sendMsg commonus.ButtonTemplateAll
|
|
// var sendMsg commonus.ButtonTemplate
|
|
sendMsg.Touser = "KaiXinGuo"
|
|
sendMsg.MsgType = "template_card"
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
sendMsg.AgentId = appId
|
|
sendMsg.EnableIdTrans = 0
|
|
sendMsg.EnableDuplicateCheck = 0
|
|
sendMsg.DuplicateCheckInterval = 1800
|
|
//模板卡片类型,按钮交互型卡片填写"button_interaction" (必填)
|
|
sendMsg.TemplateCard.CardType = "button_interaction"
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
sendMsg.TemplateCard.Source.Desc = "知行学院"
|
|
sendMsg.TemplateCard.Source.DescColor = 2
|
|
//卡片右上角更多操作按钮 (非必填)
|
|
// sendMsg.TemplateCard.ActionMenu =
|
|
sendMsg.TemplateCard.ActionMenu.Desc = "卡片副交互辅助文本说明"
|
|
var actionList []commonus.ActionListStruct
|
|
var actionCont commonus.ActionListStruct
|
|
actionCont.Text = "接受推送"
|
|
actionCont.Key = "A"
|
|
actionList = append(actionList, actionCont)
|
|
actionCont.Text = "不再推"
|
|
actionCont.Key = "b"
|
|
actionList = append(actionList, actionCont)
|
|
sendMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
//一级标题,建议不超过36个字,(支持id转译)
|
|
sendMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
sendMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
//引用文献样式
|
|
sendMsg.TemplateCard.QuoteArea.Type = 1
|
|
sendMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
sendMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
sendMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
//二级普通文本,建议不超过160个字(非必填)
|
|
sendMsg.TemplateCard.SubTitleText = "二级普通文本,下载企业微信还能抢红包!"
|
|
|
|
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6(非必填)
|
|
var htalConListStrMap []commonus.HorizontalContentListStruct
|
|
var htalConListStrCon commonus.HorizontalContentListStruct
|
|
htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "申请人"
|
|
htalConListStrCon.Value = "秦东"
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
htalConListStrCon.Type = 1
|
|
htalConListStrCon.KeyName = "企业微信官网"
|
|
htalConListStrCon.Value = "点击访问"
|
|
htalConListStrCon.Url = "tel:15069130853"
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
htalConListStrCon.Value = "秦东"
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
sendMsg.TemplateCard.HorizontalContentList = htalConListStrMap
|
|
//整体卡片的点击跳转事件 (非必填)
|
|
sendMsg.TemplateCard.CardAction.Type = 1
|
|
sendMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
taskId := commonus.GetFileNumberEs()
|
|
sendMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
//下拉式的选择器 (未知是否必填)
|
|
questionKey := commonus.GetFileNumberEs()
|
|
sendMsg.TemplateCard.ButtonSelection.QuestionKey = strconv.FormatInt(questionKey, 10)
|
|
sendMsg.TemplateCard.ButtonSelection.Title = "下拉标题"
|
|
// //下拉内容设置
|
|
var optionListMap []commonus.OptionListStructes
|
|
var optionListCont commonus.OptionListStructes
|
|
optionListCont.Id = "btn_selection_id1"
|
|
optionListCont.Text = "100分"
|
|
optionListMap = append(optionListMap, optionListCont)
|
|
optionListCont.Id = "btn_selection_id2"
|
|
optionListCont.Text = "110分"
|
|
optionListMap = append(optionListMap, optionListCont)
|
|
sendMsg.TemplateCard.ButtonSelection.OptionList = optionListMap
|
|
sendMsg.TemplateCard.ButtonSelection.SelectedId = "btn_selection_id1"
|
|
//按钮列表,列表长度不超过6(必填)
|
|
var buttonMap []commonus.ButtonListStruct
|
|
var buttonCont commonus.ButtonListStruct
|
|
buttonCont.Type = 0
|
|
buttonCont.Text = "批准"
|
|
buttonCont.Style = 1
|
|
buttonCont.Key = "button_key_1"
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
buttonCont.Type = 0
|
|
buttonCont.Text = "驳回"
|
|
buttonCont.Style = 3
|
|
buttonCont.Key = "button_key_2"
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
sendMsg.TemplateCard.ButtonList = buttonMap
|
|
response.Result(0, sendMsg, "查询成功", c)
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendMsg.SendButtonMessage()
|
|
fmt.Printf("发送信息返回:%v-----------%v----------->%v\n", string(callbakcMsg), isTrueCall, callBackCont)
|
|
|
|
}
|
|
|
|
// 模板卡片消息
|
|
// 文本通知型
|
|
func (s *ShiyanApi) SendTextMessageAll(c *gin.Context) {
|
|
// var sendTextMsg commonus.TextNotice
|
|
|
|
var sendTextMsg sendmessage.TextNoticeTemplateMedium
|
|
// var sendTextMsg sendmessage.TextNoticeTemplateSimplify
|
|
sendTextMsg.Touser = "KaiXinGuo"
|
|
sendTextMsg.MsgType = "template_card"
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
sendTextMsg.AgentId = appId
|
|
sendTextMsg.EnableIdTrans = 0
|
|
sendTextMsg.EnableDuplicateCheck = 0
|
|
sendTextMsg.DuplicateCheckInterval = 1800
|
|
|
|
sendTextMsg.TemplateCard.CardType = "text_notice"
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
sendTextMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
sendTextMsg.TemplateCard.Source.Desc = "知行学院"
|
|
sendTextMsg.TemplateCard.Source.DescColor = 2
|
|
|
|
// sendTextMsg.TemplateCard.ActionMenu.Desc = "是否继续关注"
|
|
// var actionList []commonus.ActionListStruct
|
|
// var actionCont commonus.ActionListStruct
|
|
// actionCont.Text = "接受推送"
|
|
// actionCont.Key = "A"
|
|
// actionList = append(actionList, actionCont)
|
|
// actionCont.Text = "不再推"
|
|
// actionCont.Key = "b"
|
|
// actionList = append(actionList, actionCont)
|
|
// sendTextMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
taskId := commonus.GetFileNumberEs()
|
|
sendTextMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
|
|
sendTextMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
sendTextMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
|
|
//引用文献样式
|
|
sendTextMsg.TemplateCard.QuoteArea.Type = 0
|
|
// sendTextMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
sendTextMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
sendTextMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
// sendTextMsg.TemplateCard.EmphasisContent.Title = "100"
|
|
// sendTextMsg.TemplateCard.EmphasisContent.DescStruct.Desc = "核心数据"
|
|
|
|
//二级普通文本,建议不超过160个字(非必填)
|
|
// sendTextMsg.TemplateCard.SubTitleText = "二级普通文本,下载企业微信还能抢红包!"
|
|
|
|
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6(非必填)
|
|
var htalConListStrMap []sendmessage.HorizontalContentListType
|
|
var htalConListStrCon sendmessage.HorizontalContentListType
|
|
// htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "申请人"
|
|
htalConListStrCon.Value = "秦东"
|
|
// htalConListStrCon.UserId = "KaiXinGuo"
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
// htalConListStrCon.Type = 1
|
|
// htalConListStrCon.KeyName = "企业微信官网"
|
|
// htalConListStrCon.Value = "点击访问"
|
|
// htalConListStrCon.Url = "tel:15069130853"
|
|
// htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
htalConListStrCon.Value = "秦东"
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap
|
|
|
|
var jumpListStruct sendmessage.JumpListType
|
|
jumpListStruct.Type = 1
|
|
jumpListStruct.Title = "查看详情"
|
|
jumpListStruct.Url = "http://www.hxgk.group"
|
|
sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct)
|
|
|
|
sendTextMsg.TemplateCard.CardAction.Type = 1
|
|
sendTextMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMessage("school")
|
|
outData := commonus.MapOut()
|
|
outData["callbakcMsg"] = string(callbakcMsg)
|
|
outData["isTrueCall"] = isTrueCall
|
|
outData["callBackCont"] = callBackCont
|
|
response.Result(0, outData, "查询成功", c)
|
|
}
|
|
|
|
// 图文展示型
|
|
func (s *ShiyanApi) SendImageMessageAll(c *gin.Context) {
|
|
// var sendTextMsg commonus.ImageTextTemplate
|
|
|
|
var sendTextMsg sendmessage.ImgTextTemplate
|
|
|
|
sendTextMsg.Touser = "KaiXinGuo"
|
|
sendTextMsg.MsgType = "template_card"
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
sendTextMsg.AgentId = appId
|
|
sendTextMsg.EnableIdTrans = 0
|
|
sendTextMsg.EnableDuplicateCheck = 0
|
|
sendTextMsg.DuplicateCheckInterval = 1800
|
|
|
|
sendTextMsg.TemplateCard.CardType = "news_notice"
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
sendTextMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
sendTextMsg.TemplateCard.Source.Desc = "知行学院"
|
|
sendTextMsg.TemplateCard.Source.DescColor = 2
|
|
|
|
sendTextMsg.TemplateCard.ActionMenu.Desc = "是否继续关注"
|
|
var actionList []sendmessage.ActionListType
|
|
var actionCont sendmessage.ActionListType
|
|
actionCont.Text = "接受推送"
|
|
actionCont.Key = "A"
|
|
actionList = append(actionList, actionCont)
|
|
actionCont.Text = "不再推"
|
|
actionCont.Key = "b"
|
|
actionList = append(actionList, actionCont)
|
|
sendTextMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
taskId := commonus.GetFileNumberEs()
|
|
sendTextMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
|
|
sendTextMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
sendTextMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
|
|
//引用文献样式
|
|
sendTextMsg.TemplateCard.QuoteArea.Type = 1
|
|
sendTextMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
sendTextMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
sendTextMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
sendTextMsg.TemplateCard.ImageTextArea.Type = 1
|
|
sendTextMsg.TemplateCard.ImageTextArea.Url = "http://www.baidu.com"
|
|
sendTextMsg.TemplateCard.ImageTextArea.Title = "企业微信的左图右文样式"
|
|
sendTextMsg.TemplateCard.ImageTextArea.Desc = "企业微信真好用呀真好用"
|
|
sendTextMsg.TemplateCard.ImageTextArea.ImageUrl = "https://img.iplaysoft.com/wp-content/uploads/2019/free-images/free_stock_photo_2x.jpg"
|
|
|
|
sendTextMsg.TemplateCard.CardImage.Url = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
sendTextMsg.TemplateCard.CardImage.AspectRatio = 1.3
|
|
|
|
var verCont sendmessage.EmphasisContentType
|
|
verCont.Title = "惊喜红包等你来拿"
|
|
verCont.Desc = "下载企业微信还能抢红包!"
|
|
sendTextMsg.TemplateCard.VerticalContentList = append(sendTextMsg.TemplateCard.VerticalContentList, verCont)
|
|
verCont.Title = "====>惊喜红包等你来拿"
|
|
verCont.Desc = "====>下载企业微信还能抢红包!"
|
|
sendTextMsg.TemplateCard.VerticalContentList = append(sendTextMsg.TemplateCard.VerticalContentList, verCont)
|
|
|
|
var htalConListStrCon sendmessage.HorizontalContentListType
|
|
htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "申请人"
|
|
htalConListStrCon.Value = "秦东"
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
sendTextMsg.TemplateCard.HorizontalContentList = append(sendTextMsg.TemplateCard.HorizontalContentList, htalConListStrCon)
|
|
htalConListStrCon.Type = 1
|
|
htalConListStrCon.KeyName = "企业微信官网"
|
|
htalConListStrCon.Value = "点击访问"
|
|
htalConListStrCon.Url = "tel:15069130853"
|
|
sendTextMsg.TemplateCard.HorizontalContentList = append(sendTextMsg.TemplateCard.HorizontalContentList, htalConListStrCon)
|
|
htalConListStrCon.Type = 3
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
htalConListStrCon.Value = "秦东"
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
sendTextMsg.TemplateCard.HorizontalContentList = append(sendTextMsg.TemplateCard.HorizontalContentList, htalConListStrCon)
|
|
|
|
var jumpListStruct sendmessage.JumpListType
|
|
|
|
jumpListStruct.Type = 1
|
|
jumpListStruct.Title = "知行学院官网"
|
|
jumpListStruct.Url = "http://www.hxgk.group"
|
|
|
|
sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct)
|
|
|
|
jumpListStruct.Type = 1
|
|
jumpListStruct.Title = "知行学院官网====>"
|
|
jumpListStruct.Url = "http://www.hxgk.group"
|
|
|
|
sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct)
|
|
|
|
sendTextMsg.TemplateCard.CardAction.Type = 1
|
|
sendTextMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMessage("school")
|
|
outData := commonus.MapOut()
|
|
outData["callbakcMsg"] = string(callbakcMsg)
|
|
outData["isTrueCall"] = isTrueCall
|
|
outData["callBackCont"] = callBackCont
|
|
outData["sendTextMsg"] = sendTextMsg
|
|
response.Result(0, outData, "查询成功", c)
|
|
}
|
|
|
|
// 获取审批模板详情
|
|
func (s *ShiyanApi) GetEatilTemplate(c *gin.Context) {
|
|
var requestData sendmessage.TemplatedEtailType
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
// msgbtye, isTrue, msg := requestData.GetTemplatedeTail("school")
|
|
|
|
msgbtyees, isTruees, msges := sendmessage.JsSdkSignAlgorithm("school", 1)
|
|
|
|
noncestr := commonus.GetFileNumberEs()
|
|
timestamp := time.Now().Unix()
|
|
url := "http://gin.admin.net/shiyan/geteatiltemplate"
|
|
|
|
jiamistr := fmt.Sprintf("jsapi_ticket=%v&noncestr=%v×tamp=%v&url=%v", msges, noncestr, timestamp, url)
|
|
|
|
// jiamistr = "jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg&noncestr=Wm3WZYTPz0wzccnW×tamp=1414587457&url=http://mp.weixin.qq.com?params=value"
|
|
|
|
jiamistrHa1 := commonus.Sha1Encryption(jiamistr)
|
|
|
|
outData := commonus.MapOut()
|
|
// outData["msgbtye"] = msgbtye
|
|
// outData["isTrue"] = isTrue
|
|
// outData["msg"] = msg
|
|
outData["msgbtyees"] = msgbtyees
|
|
outData["isTruees"] = isTruees
|
|
outData["msges"] = msges
|
|
outData["jiamistr"] = jiamistr
|
|
outData["jiamistrHa1"] = jiamistrHa1
|
|
response.Result(0, outData, "查询成功", c)
|
|
}
|
|
|
|
type timeDataType struct {
|
|
Time int64 `json:"time"`
|
|
Type int `json:"type"`
|
|
}
|
|
|
|
// 时间日期实现
|
|
func (s *ShiyanApi) DateTime(c *gin.Context) {
|
|
// var requestData timeDataType
|
|
// err := c.ShouldBindJSON(&requestData)
|
|
// if err != nil {
|
|
// }
|
|
// if requestData.Time == 0 {
|
|
// requestData.Time = time.Now().Unix()
|
|
// }
|
|
// if requestData.Type == 0 {
|
|
// requestData.Type = 1
|
|
// }
|
|
// quer := commonus.ComputingTime(requestData.Time, requestData.Type)
|
|
|
|
commonus.GetLastMonth()
|
|
response.Result(0, 0, "查询成功", c)
|
|
}
|
|
|
|
// 校正权重
|
|
func (s *ShiyanApi) CorrectionWeight(c *gin.Context) {
|
|
var ddwList assessmentmodel.DepartmentDimensionWeight
|
|
err := global.GVA_DB_Performanceappraisal.Find(&ddwList)
|
|
if err != nil {
|
|
fmt.Println()
|
|
return
|
|
}
|
|
}
|
|
|
|
// 考核方案去重
|
|
func (s *ShiyanApi) DeltDutyChongfu(c *gin.Context) {
|
|
var list []assessmentmodel.QualitativeEvaluation
|
|
err := global.GVA_DB_Performanceappraisal.Find(&list).Error
|
|
if err != nil {
|
|
response.Result(0, err, "没有数据", c)
|
|
return
|
|
}
|
|
for _, v := range list {
|
|
DelteGroup(v.Group, v.AcceptEvaluation, v.Dimension, v.Target, v.TargetSun, v.DetailedTarget, v.DepartmentId)
|
|
|
|
}
|
|
}
|
|
|
|
// 执行去重删除操作
|
|
func DelteGroup(group, depart, dime, target, suntar, detaid int64, runDepart string) {
|
|
var countId []int64
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("`qe_group` = ? AND `qe_accept_evaluation` = ? AND `qe_dimension` = ? AND `qe_target` = ? AND `qe_target_sun` = ? AND `qe_detailed_target` = ? AND `qe_department_id` = ?", group, depart, dime, target, suntar, detaid, runDepart).Find(&countId).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
if len(countId) < 2 {
|
|
return
|
|
}
|
|
for i, v := range countId {
|
|
if i != 0 {
|
|
fmt.Printf("%v\n", v)
|
|
global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", v).Delete(&assessmentmodel.QualitativeEvaluation{})
|
|
}
|
|
}
|
|
}
|
|
|
|
// 文本实验 textcomparison
|
|
func (s *ShiyanApi) TextShiyan(c *gin.Context) {
|
|
participle := textcomparison.NewGoJieba()
|
|
//去除文本Html标签
|
|
srcStr := textcomparison.RemoveHtml("关于区块链和数字货币的关系,很多人或多或少都存在疑惑。简单来说,区块链是比特币的底层运用,而比特币只是区块链的一个小应用而已。" +
|
|
"数字货币即虚拟货币,最早的数字货币诞生于2009年,其发明者中本聪为了应对经济危机对于实体货币经济的冲击。比特币是最早的数字货币,后来出现了以太币、火币以及莱特币等虚拟货币,这些虚拟货币是不能用来交易的。" +
|
|
"狭义来讲,区块链是一种按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构, 并以密码学方式保证的不可篡改和不可伪造的分布式账本。" +
|
|
"广义来讲,区块链技术是利用块链式数据结构来验证与存储数据、利用分布式节点共识算法来生成和更新数据、利用密码学的方式保证数据传输和访问的安全、利用由自动化脚本代码组成的智能合约来编程和操作数据的一种全新的分布式基础架构与计算方式。")
|
|
dstStr := textcomparison.RemoveHtml("区块链技术为我们的信息防伪与数据追踪提供了革新手段。区块链中的数据区块顺序相连构成了一个不可篡改的数据链条,时间戳为所有的交易行为贴上了一套不讲课伪造的真是标签,这对于人们在现实生活中打击假冒伪劣产品大有裨益; " +
|
|
"市场分析指出,整体而言,区块链技术目前在十大金融领域显示出应用前景,分别是资产证券化、保险、供应链金融、场外市场、资产托管、大宗商品交易、风险信息共享机制、贸易融资、银团贷款、股权交易交割。" +
|
|
"这些金融场景有三大共性:参与节点多、验真成本高、交易流程长,而区块链的分布式记账、不可篡改、内置合约等特性可以为这些金融业务中的痛点提供解决方案。" +
|
|
"传统的工业互联网模式是由一个中心化的机构收集和管理所有的数据信息,容易产生因设备生命周期和安全等方面的缺陷引起的数据丢失、篡改等问题。区块链技术可以在无需任何信任单个节点的同时构建整个网络的信任共识,从而很好的解决目前工业互联网技术领域的一些缺陷,让物与物之间能够实现更好的连接.")
|
|
|
|
srcWordsWeight := participle.C.ExtractWithWeight(srcStr, 30)
|
|
dstWordsWeight := participle.C.ExtractWithWeight(dstStr, 30)
|
|
fmt.Printf("srcWordsWeight: %v\n", srcWordsWeight)
|
|
fmt.Printf("dstWordsWeight: %v\n", dstWordsWeight)
|
|
|
|
srcWords := make([]textcomparison.WordWeight, len(srcWordsWeight))
|
|
dstWords := make([]textcomparison.WordWeight, len(dstWordsWeight))
|
|
|
|
for i, ww := range srcWordsWeight {
|
|
word := textcomparison.WordWeight{Word: ww.Word, Weight: ww.Weight}
|
|
srcWords[i] = word
|
|
}
|
|
for i, ww := range dstWordsWeight {
|
|
word := textcomparison.WordWeight{Word: ww.Word, Weight: ww.Weight}
|
|
dstWords[i] = word
|
|
}
|
|
fmt.Printf("srcWords:%v\n", srcWords)
|
|
fmt.Printf("dstWords:%v\n", dstWords)
|
|
|
|
distance, err := textcomparison.SimHashSimilar(srcWords, dstWords)
|
|
if err != nil {
|
|
// t.Errorf("failed: %v", err.Error())
|
|
fmt.Printf("failed:%v\n", c.Errors)
|
|
}
|
|
fmt.Printf("SimHashSimilar distance:%v\n", distance)
|
|
// t.Logf("SimHashSimilar distance: %v", distance)
|
|
}
|
|
|
|
type jimishiyan struct {
|
|
KeyStr string `json:"key"`
|
|
Number string `json:"number"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
// 加密实验
|
|
func (s *ShiyanApi) JiaMi(c *gin.Context) {
|
|
|
|
var user jimishiyan
|
|
_ = c.ShouldBindJSON(&user)
|
|
|
|
userAgent := "250"
|
|
|
|
var md5JiaMi commonus.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
// response.Result(101, md5Token, "加密实验!", c)
|
|
|
|
sha1Str := user.KeyStr + user.Number + user.Password + md5Token
|
|
sha1Token := commonus.Sha1Encryption(sha1Str)
|
|
|
|
outMap := commonus.MapOut()
|
|
outMap["md5Token"] = md5Token
|
|
outMap["sha1Token"] = sha1Token
|
|
|
|
response.Result(101, outMap, "sha1Token加密实验!", c)
|
|
}
|
|
|
|
// 处理子栏目归属
|
|
func (s *ShiyanApi) SunTar(c *gin.Context) {
|
|
var sunList []assessmentmodel.QualitativeTarget
|
|
err := global.GVA_DB_Performanceappraisal.Find(&sunList).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
for _, v := range sunList {
|
|
departStr := GetGuishuDepart(v.ParentId)
|
|
|
|
eiteCont := commonus.MapOut()
|
|
eiteCont["q_depart"] = departStr
|
|
eiteCont["q_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeTarget{}).Where("`q_id` = ?", v.Id).Updates(eiteCont)
|
|
fmt.Printf("%v\n", v.Id)
|
|
}
|
|
}
|
|
|
|
// 获取指标归属分厂
|
|
func GetGuishuDepart(targetId int64) (departStr string) {
|
|
var targetCont assessmentmodel.EvaluationTarget
|
|
err := global.GVA_DB_Performanceappraisal.Where("et_id = ?", targetId).First(&targetCont).Error
|
|
if err == nil {
|
|
departStr = targetCont.RelevantDepartments
|
|
}
|
|
return
|
|
}
|
|
|
|
// 数据迁移
|
|
func (s *ShiyanApi) DataQianyi(c *gin.Context) {
|
|
var assTarCont []assessmentmodel.Assesstarget
|
|
assErr := global.GVA_DB_Performanceappraisal.Find(&assTarCont).Error
|
|
if assErr == nil {
|
|
for _, assV := range assTarCont {
|
|
// synPro.Add(1)
|
|
qianyiAssTar(assV.Id, assV.Group, assV.Departmentmap)
|
|
}
|
|
}
|
|
//部门考核指标权重
|
|
var deparDimeWeigh []assessmentmodel.DepartmentDimensionWeight
|
|
ddwErr := global.GVA_DB_Performanceappraisal.Find(&deparDimeWeigh).Error
|
|
if ddwErr == nil {
|
|
for _, ddwV := range deparDimeWeigh {
|
|
// synPro.Add(1)
|
|
qianyiDdwTar(ddwV.Id, ddwV.Group, ddwV.DepartmentId)
|
|
}
|
|
}
|
|
//划分责任
|
|
var divRes []assessmentmodel.DivisionResponsibilities
|
|
divresErr := global.GVA_DB_Performanceappraisal.Find(&divRes).Error
|
|
if divresErr == nil {
|
|
for _, divresV := range divRes {
|
|
// synPro.Add(1)
|
|
qianyidivresTar(divresV.Id, divresV.Group, divresV.Department, divresV.EvaluationGroup, divresV.EvaluationDepartment)
|
|
}
|
|
}
|
|
|
|
//测评指标
|
|
var evalTar []assessmentmodel.EvaluationTarget
|
|
evalTarErr := global.GVA_DB_Performanceappraisal.Find(&evalTar).Error
|
|
if evalTarErr == nil {
|
|
for _, evalTarV := range evalTar {
|
|
// synPro.Add(1)
|
|
qianyievalTarTar(evalTarV.Id, evalTarV.RelevantDepartments)
|
|
}
|
|
}
|
|
//考核方案版本内容
|
|
var planVersio []assessmentmodel.PlanVersio
|
|
planVersioErr := global.GVA_DB_Performanceappraisal.Find(&planVersio).Error
|
|
if planVersioErr == nil {
|
|
for _, planVersioV := range planVersio {
|
|
// synPro.Add(1)
|
|
qianyiplanVersioTar(planVersioV.Id, planVersioV.Group, planVersioV.Department)
|
|
}
|
|
}
|
|
//定性考核
|
|
var qualEval []assessmentmodel.QualitativeEvaluation
|
|
qualEvalErr := global.GVA_DB_Performanceappraisal.Find(&qualEval).Error
|
|
if qualEvalErr == nil {
|
|
for _, qualEvalV := range qualEval {
|
|
// synPro.Add(1)
|
|
qianyiqualEvalTar(qualEvalV.Id, qualEvalV.Group, qualEvalV.AcceptEvaluation, qualEvalV.DepartmentId)
|
|
}
|
|
}
|
|
//定性指标子栏目
|
|
var qualTar []assessmentmodel.QualitativeTarget
|
|
qualTarErr := global.GVA_DB_Performanceappraisal.Find(&qualTar).Error
|
|
if qualTarErr == nil {
|
|
for _, qualTarV := range qualTar {
|
|
// synPro.Add(1)
|
|
qianyiqualTarTar(qualTarV.Id, qualTarV.Depart)
|
|
}
|
|
}
|
|
//整改措施
|
|
var recMea []assessmentmodel.RectificationMeasures
|
|
recMeaErr := global.GVA_DB_Performanceappraisal.Find(&recMea).Error
|
|
if recMeaErr == nil {
|
|
for _, recMeaV := range recMea {
|
|
// synPro.Add(1)
|
|
qianyirecMeaTar(recMeaV.Id, recMeaV.Group, recMeaV.Department)
|
|
}
|
|
}
|
|
//分数流水
|
|
var scoreFlowCont []assessmentmodel.ScoreFlow
|
|
scoreFlowContErr := global.GVA_DB_Performanceappraisal.Find(&scoreFlowCont).Error
|
|
if scoreFlowContErr == nil {
|
|
for _, scoreFlowContV := range scoreFlowCont {
|
|
// synPro.Add(1)
|
|
qianyiscoreFlowContTar(scoreFlowContV.Id, scoreFlowContV.EvaluationGroup, scoreFlowContV.EvaluationDepartment, scoreFlowContV.DutyGroup, scoreFlowContV.DutyDepartment)
|
|
}
|
|
}
|
|
|
|
// synPro.Wait()
|
|
}
|
|
|
|
// 分数流水
|
|
func qianyiscoreFlowContTar(id, groupId, departStr, evaGroup, evalDep int64) {
|
|
saveData := commonus.MapOut()
|
|
saveData["sf_eite_time"] = time.Now().Unix()
|
|
// groupIdInt,departId := getUserOrgSchool
|
|
saveData["sf_evaluation_group"] = getGroupToOrg(groupId)
|
|
saveData["sf_evaluation_department"] = getDepartToOrgInt(departStr)
|
|
|
|
saveData["sf_duty_group"] = getGroupToOrg(evaGroup)
|
|
saveData["sf_duty_department"] = getDepartToOrgInt(evalDep)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("sf_id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 整改措施
|
|
func qianyirecMeaTar(id, groupId, departStr int64) {
|
|
// defer synPro.Done()
|
|
saveData := commonus.MapOut()
|
|
saveData["rm_eite_time"] = time.Now().Unix()
|
|
saveData["rm_group"] = getGroupToOrg(groupId)
|
|
saveData["rm_department"] = getDepartToOrgInt(departStr)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.RectificationMeasures{}).Where("rm_id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 定性指标子栏目
|
|
func qianyiqualTarTar(id int64, departStr string) {
|
|
saveData := commonus.MapOut()
|
|
saveData["q_time"] = time.Now().Unix()
|
|
saveData["q_depart"] = getDepartToOrg(departStr)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeTarget{}).Where("q_id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 定性考核
|
|
func qianyiqualEvalTar(id, groupId, departInt int64, departStr string) {
|
|
saveData := commonus.MapOut()
|
|
saveData["qe_eitetime"] = time.Now().Unix()
|
|
saveData["qe_group"] = getGroupToOrg(groupId)
|
|
saveData["qe_accept_evaluation"] = getDepartToOrgInt(departInt)
|
|
saveData["qe_department_id"] = getDepartToOrg(departStr)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("qe_id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 考核方案版本内容
|
|
func qianyiplanVersioTar(id, groupId, departStr int64) {
|
|
// defer synPro.Done()
|
|
saveData := commonus.MapOut()
|
|
saveData["eitetime"] = time.Now().Unix()
|
|
// groupIdInt,departId := getUserOrgSchool
|
|
saveData["group"] = getGroupToOrg(groupId)
|
|
saveData["department"] = getDepartToOrgInt(departStr)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 测评指标
|
|
func qianyievalTarTar(id int64, departStr string) {
|
|
saveData := commonus.MapOut()
|
|
saveData["et_time"] = time.Now().Unix()
|
|
saveData["et_relevant_departments"] = getDepartToOrg(departStr)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Where("et_id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 划分责任
|
|
func qianyidivresTar(id, groupId, departStr, evaGroup, evalDep int64) {
|
|
saveData := commonus.MapOut()
|
|
saveData["df_eite_time"] = time.Now().Unix()
|
|
// groupIdInt,departId := getUserOrgSchool
|
|
saveData["df_group"] = getGroupToOrg(groupId)
|
|
saveData["df_department_id"] = getDepartToOrgInt(departStr)
|
|
|
|
saveData["df_evaluation_group"] = getGroupToOrg(evaGroup)
|
|
saveData["df_evaluation_department"] = getDepartToOrgInt(evalDep)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DivisionResponsibilities{}).Where("df_id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 迁移部门考核指标权重
|
|
func qianyiDdwTar(id, groupId, departStr int64) {
|
|
// defer synPro.Done()
|
|
saveData := commonus.MapOut()
|
|
saveData["ddw_time"] = time.Now().Unix()
|
|
// groupIdInt,departId := getUserOrgSchool
|
|
saveData["ddw_group"] = getGroupToOrg(groupId)
|
|
saveData["ddw_derpatment"] = getDepartToOrgInt(departStr)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("ddw_id = ?", id).Updates(saveData)
|
|
}
|
|
|
|
// 迁移考核指标
|
|
func qianyiAssTar(id, groupId int64, departStr string) {
|
|
// defer synPro.Done()
|
|
// fmt.Printf("AssTar--------->%v---->%v---->%v\n", id, groupId, departStr)
|
|
saveData := commonus.MapOut()
|
|
saveData["time"] = time.Now().Unix()
|
|
// groupIdInt,departId := getUserOrgSchool
|
|
saveData["group"] = getGroupToOrg(groupId)
|
|
saveData["departmentmap"] = getDepartToOrg(departStr)
|
|
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.Assesstarget{}).Where("at_id = ?", id).Updates(saveData)
|
|
|
|
// fmt.Printf("AssAry-----%v------>%v\n", id, saveData)
|
|
}
|
|
|
|
// 获取集团对照码
|
|
func getGroupToOrg(group int64) (groupId int64) {
|
|
groupId = 0
|
|
groupAry := map[int64]int64{3: 2}
|
|
for gi, gv := range groupAry {
|
|
if gi == group {
|
|
groupId = gv
|
|
break
|
|
}
|
|
}
|
|
if groupId == 0 {
|
|
groupId = group
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取部门对照码
|
|
func getDepartToOrgInt(depart int64) (departStr string) {
|
|
departAry := map[int64]string{
|
|
11: "3",
|
|
12: "4",
|
|
9: "5",
|
|
14: "6",
|
|
13: "7",
|
|
15: "8",
|
|
5: "9",
|
|
6: "10",
|
|
8: "11",
|
|
2: "13",
|
|
1: "14",
|
|
3: "15",
|
|
16: "16",
|
|
17: "17",
|
|
39: "19",
|
|
50: "20",
|
|
7: "41",
|
|
4: "42",
|
|
}
|
|
for si, sv := range departAry {
|
|
if depart == si {
|
|
departStr = sv
|
|
return
|
|
}
|
|
}
|
|
if departStr == "" {
|
|
departStr = strconv.FormatInt(depart, 10)
|
|
}
|
|
return
|
|
}
|
|
func getDepartToOrg(depart string) (departStr string) {
|
|
departAry := map[int64]string{
|
|
11: "3",
|
|
12: "4",
|
|
9: "5",
|
|
14: "6",
|
|
13: "7",
|
|
15: "8",
|
|
5: "9",
|
|
6: "10",
|
|
8: "11",
|
|
2: "13",
|
|
1: "14",
|
|
3: "15",
|
|
16: "16",
|
|
17: "17",
|
|
39: "19",
|
|
50: "20",
|
|
7: "41",
|
|
4: "42",
|
|
}
|
|
var depAry []string
|
|
oldDepartAry := strings.Split(depart, ",")
|
|
for _, v := range oldDepartAry {
|
|
vInt64, _ := strconv.ParseInt(v, 10, 64)
|
|
for si, sv := range departAry {
|
|
if vInt64 == si {
|
|
if commonus.IsItTrueString(sv, depAry) == false {
|
|
depAry = append(depAry, sv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
departStr = strings.Join(depAry, ",")
|
|
return
|
|
}
|
|
|
|
// 获取人员组织架构信息
|
|
func getUserOrgSchool(group, depart int64) (gro int64, department string) {
|
|
groupAry := map[int64]int64{3: 2}
|
|
for gi, gv := range groupAry {
|
|
if gi == group {
|
|
gro = gv
|
|
break
|
|
}
|
|
}
|
|
//部门对照
|
|
//部门
|
|
var buMen string
|
|
// departAry := map[int64]string{
|
|
// 11: "3",
|
|
// 12: "4",
|
|
// 9: "5",
|
|
// 14: "6",
|
|
// 13: "7",
|
|
// 15: "8",
|
|
// 5: "9",
|
|
// 6: "10",
|
|
// 8: "11",
|
|
// 2: "13",
|
|
// 1: "14",
|
|
// 3: "15",
|
|
// 16: "16",
|
|
// 17: "17",
|
|
// 39: "19",
|
|
// 50: "20",
|
|
// 7: "12,41",
|
|
// 4: "12,42",
|
|
// }
|
|
departAry := map[int64]string{
|
|
11: "3",
|
|
12: "4",
|
|
9: "5",
|
|
14: "6",
|
|
13: "7",
|
|
15: "8",
|
|
5: "9",
|
|
6: "10",
|
|
8: "11",
|
|
2: "13",
|
|
1: "14",
|
|
3: "15",
|
|
16: "16",
|
|
17: "17",
|
|
39: "19",
|
|
50: "20",
|
|
7: "41",
|
|
4: "42",
|
|
}
|
|
for di, dv := range departAry {
|
|
if depart == di {
|
|
buMen = dv
|
|
break
|
|
}
|
|
}
|
|
// _, org = getOrgSchool(workid)
|
|
// departId, org := getOrgSchool(workid)
|
|
// if departId != 0 {
|
|
// buMen = fmt.Sprintf("%v,%v", buMen, departId)
|
|
// }
|
|
if buMen == "" {
|
|
buMen = strconv.FormatInt(depart, 10)
|
|
}
|
|
department = buMen
|
|
|
|
return
|
|
}
|
|
|
|
// 获取组织架构对照
|
|
func getOrgSchool(id int64) (deparmentId, orgId int64) {
|
|
var orgInfo outOrgCont
|
|
err := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("id,organization_type,superior").Where("schoole = ?", id).First(&orgInfo).Error
|
|
if err != nil {
|
|
deparmentId = 0
|
|
orgId = 0
|
|
return
|
|
}
|
|
if orgInfo.OrganizationType == 5 {
|
|
var suoOrgInfo hrsystem.AdministrativeOrganization
|
|
whereAry := commonus.MapOut()
|
|
whereAry["id"] = orgInfo.Superior
|
|
supErr := suoOrgInfo.GetCont(whereAry)
|
|
if supErr == nil {
|
|
deparmentId = suoOrgInfo.Id
|
|
}
|
|
}
|
|
orgId = orgInfo.Id
|
|
return
|
|
}
|
|
|
|
// 获取hr系统中的职务
|
|
func getHrPosition(posId int64) int64 {
|
|
var id int64
|
|
err := global.GVA_DB_HrDataBase.Model(&hrsystem.Position{}).Select("id").Where("`school` = ?", posId).First(&id).Error
|
|
if err == nil {
|
|
return id
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// 获取职务相关属性
|
|
func getJobInfo(jobId int64) (cont jobAttber, err error) {
|
|
var positionInfo hrsystem.Position
|
|
// err = global.GVA_DB_HrDataBase.Table(fmt.Sprintf("%s p", positionInfo.TableName())).Select("p.id,p.number,p.name,p.person_in_charge,d.id as dutid,d.name as dutname,d.number as dutnumber,j.id as jobid,j.name as jobname").Joins("left join duties as d on d.id = p.duties").Joins("left join job_class as j on j.id = d.job_type").Where("`p`.`id` = ?", jobId).First(&cont).Error
|
|
err = global.GVA_DB_HrDataBase.Model(&positionInfo).Select("position.id,position.number,position.name,position.person_in_charge,d.id as dutid,d.name as dutname,d.number as dutnumber,j.id as jobid,j.name as jobname").Joins("left join duties as d on d.id = position.duties").Joins("left join job_class as j on j.id = d.job_type").Where("`position`.`id` = ?", jobId).First(&cont).Error
|
|
return
|
|
}
|
|
|
|
// 删除指标数据
|
|
func (s *ShiyanApi) DeleteTarget(c *gin.Context) {
|
|
var requestData delTargetStr
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Id == 0 && requestData.OutId == "" {
|
|
response.Result(102, requestData, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if requestData.OutId != "" {
|
|
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64)
|
|
if inIntErr == nil {
|
|
requestData.Id = idInt
|
|
}
|
|
}
|
|
var qualEvalId []int64
|
|
|
|
qualEvalErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_target = ?", requestData.Id).Find(&qualEvalId).Error
|
|
if qualEvalErr != nil {
|
|
response.Result(102, qualEvalErr, "没有数据!", c)
|
|
return
|
|
}
|
|
if len(qualEvalId) <= 0 {
|
|
response.Result(102, qualEvalErr, "没有数据!", c)
|
|
return
|
|
}
|
|
//定性考核
|
|
var scoreFlowOrderKey []int64
|
|
sfGormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_key").Where("sf_evaluation_plan IN ?", qualEvalId)
|
|
if requestData.UserKey != "" {
|
|
sfGormDb = sfGormDb.Where("sf_evaluation_user = ?", requestData.UserKey)
|
|
}
|
|
scoreFlowOrderKeyErr := sfGormDb.Find(&scoreFlowOrderKey).Error
|
|
if scoreFlowOrderKeyErr != nil {
|
|
if len(scoreFlowOrderKey) > 0 {
|
|
global.GVA_DB_Performanceappraisal.Where("ep_order_key IN ?", scoreFlowOrderKey).Delete(&assessmentmodel.EvaluationProcess{})
|
|
global.GVA_DB_Performanceappraisal.Where("sf_evaluation_plan IN ?", qualEvalId).Delete(&assessmentmodel.ScoreFlow{})
|
|
}
|
|
}
|
|
//定量考核
|
|
var flowIdAry []int64
|
|
var flowKey []int64
|
|
for _, v := range qualEvalId {
|
|
var flowLogCont []assessmentmodel.FlowLog
|
|
flGormDb := global.GVA_DB_Performanceappraisal.Where("FIND_IN_SET(?,`fl_evaluation_id`)", v)
|
|
if requestData.UserKey != "" {
|
|
sfGormDb = sfGormDb.Where("fl_evaluation_user = ?", requestData.UserKey)
|
|
}
|
|
flErr := flGormDb.Find(&flowLogCont).Error
|
|
if flErr == nil {
|
|
if len(flowLogCont) > 0 {
|
|
for _, flcv := range flowLogCont {
|
|
if commonus.IsInTrue[int64](flcv.Id, flowIdAry) == false {
|
|
flowIdAry = append(flowIdAry, flcv.Id)
|
|
}
|
|
|
|
if commonus.IsInTrue[int64](flcv.Key, flowKey) == false {
|
|
flowKey = append(flowKey, flcv.Key)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
if len(flowIdAry) > 0 {
|
|
global.GVA_DB_Performanceappraisal.Where("fl_id IN ?", flowIdAry).Delete(&assessmentmodel.FlowLog{})
|
|
}
|
|
if len(flowKey) > 0 {
|
|
global.GVA_DB_Performanceappraisal.Where("ep_order_key IN ?", flowKey).Delete(&assessmentmodel.EvaluationProcess{})
|
|
global.GVA_DB_Performanceappraisal.Where("fld_flow_log IN ?", flowKey).Delete(&assessmentmodel.FlowLogData{})
|
|
}
|
|
response.Result(0, qualEvalId, "处理完成!", c)
|
|
}
|
|
|
|
// 根据提交人删除定量数据
|
|
func (s *ShiyanApi) BasisMan(c *gin.Context) {
|
|
var requestData basisType
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.UserKey == "" {
|
|
response.Result(102, requestData, "请输入人员KEY", c)
|
|
return
|
|
}
|
|
var flowKey []int64
|
|
flowLogErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_key").Where("fl_evaluation_user = ?", requestData.UserKey).Find(&flowKey).Error
|
|
if flowLogErr != nil {
|
|
response.Result(102, flowLogErr, "没有数据!", c)
|
|
return
|
|
}
|
|
if len(flowKey) <= 0 {
|
|
response.Result(102, flowLogErr, "没有数据!", c)
|
|
return
|
|
}
|
|
global.GVA_DB_Performanceappraisal.Where("ep_order_key IN ?", flowKey).Delete(&assessmentmodel.EvaluationProcess{})
|
|
global.GVA_DB_Performanceappraisal.Where("fld_flow_log IN ?", flowKey).Delete(&assessmentmodel.FlowLogData{})
|
|
global.GVA_DB_Performanceappraisal.Where("fl_id IN ?", flowKey).Delete(&assessmentmodel.FlowLog{})
|
|
response.Result(0, flowLogErr, "处理完成!", c)
|
|
}
|
|
|
|
// 归档审批流程
|
|
func (s *ShiyanApi) EvalProcesGuiDang(c *gin.Context) {
|
|
var epList []assessmentmodel.EvaluationProcess
|
|
err := global.GVA_DB_Performanceappraisal.Find(&epList).Error
|
|
if err != nil {
|
|
response.Result(102, err, "没有数据!", c)
|
|
return
|
|
}
|
|
for _, v := range epList {
|
|
saveDate := commonus.MapOut()
|
|
if v.TypeClass == 1 {
|
|
//定性
|
|
var scoreFlowInfo assessmentmodel.ScoreFlow
|
|
sfiErr := global.GVA_DB_Performanceappraisal.Select("sf_evaluation_plan,sf_evaluation_department").Where("sf_key = ?", v.OrderKey).First(&scoreFlowInfo).Error
|
|
if sfiErr == nil {
|
|
saveDate["ep_setup_department"] = scoreFlowInfo.EvaluationDepartment
|
|
//获取维度,指标,指标详情
|
|
var qeInfo assessmentmodel.QualitativeEvaluation
|
|
qeErr := global.GVA_DB_Performanceappraisal.Select("qe_dimension,qe_target,qe_detailed_target").Where("qe_id = ?", scoreFlowInfo.EvaluationPlan).First(&qeInfo).Error
|
|
if qeErr == nil {
|
|
saveDate["ep_dimension"] = qeInfo.Dimension
|
|
saveDate["ep_target"] = qeInfo.Target
|
|
saveDate["ep_detailedtarget"] = qeInfo.DetailedTarget
|
|
}
|
|
saveDate["ep_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("ep_id = ?", v.Id).Updates(&saveDate)
|
|
}
|
|
} else {
|
|
//定量
|
|
var flowLogList assessmentmodel.FlowLog
|
|
sfiErr := global.GVA_DB_Performanceappraisal.Select("fl_evaluation_id,fl_evaluation_department").Where("fl_key = ?", v.OrderKey).First(&flowLogList).Error
|
|
if sfiErr == nil {
|
|
saveDate["ep_setup_department"] = flowLogList.EvaluationDepartment
|
|
evalId := strings.Split(flowLogList.EvaluationPlan, ",")
|
|
var dimAry []string
|
|
var tarAry []string
|
|
if len(evalId) > 0 {
|
|
for _, flv := range evalId {
|
|
var qeInfo assessmentmodel.QualitativeEvaluation
|
|
qeErr := global.GVA_DB_Performanceappraisal.Select("qe_dimension,qe_target").Where("qe_id = ?", flv).First(&qeInfo).Error
|
|
if qeErr == nil {
|
|
if commonus.IsInTrue[string](strconv.FormatInt(qeInfo.Dimension, 10), dimAry) == false {
|
|
dimAry = append(dimAry, strconv.FormatInt(qeInfo.Dimension, 10))
|
|
}
|
|
if commonus.IsInTrue[string](strconv.FormatInt(qeInfo.Target, 10), tarAry) == false {
|
|
tarAry = append(tarAry, strconv.FormatInt(qeInfo.Target, 10))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(dimAry) > 0 {
|
|
saveDate["ep_dimension"] = strings.Join(dimAry, ",")
|
|
}
|
|
if len(tarAry) > 0 {
|
|
saveDate["ep_target"] = strings.Join(tarAry, ",")
|
|
}
|
|
saveDate["ep_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("ep_id = ?", v.Id).Updates(&saveDate)
|
|
}
|
|
}
|
|
}
|
|
response.Result(0, err, "处理完成!", c)
|
|
}
|
|
|
|
// 归档定性考核指标数据
|
|
func (s *ShiyanApi) GuiDangDingLiangKaoHeData(c *gin.Context) {
|
|
var fldList []assessmentmodel.FlowLogData
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLogData{}).Select("fld_id,fld_evaluation_id").Find(&fldList).Error
|
|
if err != nil {
|
|
response.Result(102, err, "没有数据!", c)
|
|
return
|
|
}
|
|
for _, v := range fldList {
|
|
var qeInfo assessmentmodel.QualitativeEvaluation
|
|
qeErr := global.GVA_DB_Performanceappraisal.Select("qe_target").Where("qe_id = ?", v.EvaluationPlan).First(&qeInfo).Error
|
|
if qeErr == nil {
|
|
saveData := commonus.MapOut()
|
|
saveData["fld_target_id"] = qeInfo.Target
|
|
saveData["fld_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLogData{}).Where("fld_id = ?", v.Id).Updates(&saveData)
|
|
}
|
|
}
|
|
response.Result(0, err, "处理完成!", c)
|
|
}
|
|
|
|
// 定性考核归档指标ID
|
|
func (s *ShiyanApi) GuiDangDingXingKaoHeData(c *gin.Context) {
|
|
var slDataList []assessmentmodel.ScoreFlow
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_id,sf_evaluation_plan").Find(&slDataList).Error
|
|
if err != nil {
|
|
response.Result(102, err, "没有数据!", c)
|
|
return
|
|
}
|
|
for _, v := range slDataList {
|
|
var qeInfo assessmentmodel.QualitativeEvaluation
|
|
qeErr := global.GVA_DB_Performanceappraisal.Select("qe_target,qe_detailed_target").Where("qe_id = ?", v.EvaluationPlan).First(&qeInfo).Error
|
|
if qeErr == nil {
|
|
saveData := commonus.MapOut()
|
|
saveData["sf_target_id"] = qeInfo.Target
|
|
saveData["sf_detailed_id"] = qeInfo.DetailedTarget
|
|
saveData["sf_eite_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("sf_id = ?", v.Id).Updates(&saveData)
|
|
}
|
|
}
|
|
response.Result(0, err, "处理完成!", c)
|
|
}
|
|
|
|
// 获取数据异常得提交
|
|
func (s *ShiyanApi) Shujuyichang(c *gin.Context) {
|
|
var looknoepares []Looknoepares
|
|
idIns := []int{1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 179, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198}
|
|
|
|
err := global.GVA_DB_Performanceappraisal.Where("fid IN ?", idIns).Find(&looknoepares).Error
|
|
if err != nil {
|
|
response.Result(102, err, "没有数据!", c)
|
|
return
|
|
}
|
|
for _, v := range looknoepares {
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v.DutyDepartment
|
|
orgContDer, _ := commonus.GetNewOrgCont(whereDepart, "name")
|
|
|
|
// GetNewHrPeopleInfo
|
|
|
|
whereUser := commonus.MapOut()
|
|
whereUser["key"] = v.Tjuser
|
|
userContDer, _ := commonus.GetNewHrPeopleInfo(whereUser, "name")
|
|
|
|
fmt.Printf("%v %v %v %v-%v %v %v\n", v.Title, orgContDer.Name, commonus.Decimal(v.Score/100), v.Year, v.Month, userContDer.Name, v.ScoringScore)
|
|
}
|
|
}
|
|
|
|
// 归档部门考核方案版本时间周期问题
|
|
func (s *ShiyanApi) DepartmentPlanVersion(c *gin.Context) {
|
|
//获取考核方案
|
|
var assessTargetContentList []assessmentmodel.PlanVersio
|
|
|
|
planVersioErr := global.GVA_DB_Performanceappraisal.Find(&assessTargetContentList).Error
|
|
if planVersioErr != nil {
|
|
response.Result(103, planVersioErr, "数据获取失败!", c)
|
|
return
|
|
}
|
|
for _, v := range assessTargetContentList {
|
|
|
|
var planVersioInfo []AddDutyNewCont
|
|
jsonErr := json.Unmarshal([]byte(v.Content), &planVersioInfo)
|
|
if jsonErr == nil {
|
|
var planVersionList []AddDutyNewCont
|
|
for _, pv := range planVersioInfo {
|
|
var plvAry AddDutyNewCont
|
|
plvAry.Id = pv.Id
|
|
plvAry.Name = pv.Name
|
|
plvAry.ZhiFraction = pv.ZhiFraction
|
|
for _, pvChild := range pv.Child {
|
|
var pvcList EvaluPross
|
|
pvcList.Id = pvChild.Id
|
|
|
|
var evalTarConttv assessmentmodel.EvaluationTarget
|
|
evalTarConttv.GetCont(map[string]interface{}{"et_id": pvChild.Id}, "`et_title`")
|
|
|
|
pvcList.Name = evalTarConttv.Title
|
|
pvcList.Unit = pvChild.Unit
|
|
pvcList.ReferenceScore = pvChild.ReferenceScore
|
|
|
|
var qualEvalCont assessmentmodel.QualitativeEvaluation
|
|
qualErr := qualEvalCont.GetCont(map[string]interface{}{"`qe_qual_eval_id`": v.Key, "qe_dimension": pv.Id, "qe_target": pvChild.Id, "qe_accept_evaluation": v.Department}, "`qe_cycle`,`qe_cycleattr`")
|
|
if qualErr == nil {
|
|
pvcList.Cycles = qualEvalCont.Cycles
|
|
pvcList.CycleAttres = qualEvalCont.CycleAttres
|
|
} else {
|
|
var evalTarCont assessmentmodel.EvaluationTarget
|
|
evalErr := evalTarCont.GetCont(map[string]interface{}{"et_id": pvChild.Id}, "`et_cycle`,`et_cycleattr`")
|
|
if evalErr == nil {
|
|
pvcList.Cycles = evalTarCont.Cycles
|
|
pvcList.CycleAttres = evalTarCont.CycleAttres
|
|
}
|
|
}
|
|
pvcList.Content = pvChild.Name
|
|
pvcList.State = pvChild.State
|
|
pvcList.Score = pvChild.Score
|
|
pvcList.QualEvalId = pvChild.QualEvalId
|
|
pvcList.Status = pvChild.Status
|
|
|
|
plvAry.Child = append(plvAry.Child, pvcList)
|
|
}
|
|
planVersionList = append(planVersionList, plvAry)
|
|
}
|
|
if len(planVersionList) > 0 {
|
|
jsonVal, _ := json.Marshal(planVersionList)
|
|
saveDataJson := commonus.MapOut()
|
|
saveDataJson["content"] = string(jsonVal)
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("id = ?", v.Id).Updates(saveDataJson)
|
|
}
|
|
}
|
|
}
|
|
response.Result(0, planVersioErr, "完成!", c)
|
|
}
|
|
|
|
// 行政组织树
|
|
func (s *ShiyanApi) GovThree(c *gin.Context) {
|
|
var requestData govThreeType
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Id == 0 && requestData.IdStr == "" {
|
|
requestData.Id = 0
|
|
}
|
|
if requestData.IdStr != "" {
|
|
idInt64, _ := strconv.ParseInt(requestData.IdStr, 10, 64)
|
|
requestData.Id = idInt64
|
|
}
|
|
var govMap MenuList
|
|
|
|
gormDb := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` IN ?", []int{1, 2})
|
|
if requestData.Level != 0 {
|
|
gormDb = gormDb.Where("aot.level <= ?", requestData.Level)
|
|
}
|
|
err := gormDb.Find(&govMap).Error
|
|
if err != nil {
|
|
response.Result(2222, err, "完成!", c)
|
|
return
|
|
}
|
|
// fmt.Printf("id==========>%v", govMap)
|
|
// govMap.GovRecursion(requestData.Id, 0)
|
|
govMapThree := GovThreeList(requestData.Id, govMap)
|
|
response.Result(0, govMapThree, "完成!", c)
|
|
}
|
|
|
|
func GovThreeList(parentId int64, govAry []OutGovCont) []govThree {
|
|
var govMap []govThree
|
|
// fmt.Printf("govAry---------------->%v\n", govAry)
|
|
for _, v := range govAry {
|
|
// var zhucont govThree
|
|
// fmt.Printf("govAry---------------->%v\n", v.Superior)
|
|
if v.Superior == parentId {
|
|
|
|
child := GovThreeList(v.Id, govAry)
|
|
govMap = append(govMap, govThree{v, child})
|
|
}
|
|
|
|
}
|
|
return govMap
|
|
}
|
|
|
|
// 绩效考核系统对照行政组织关系
|
|
func (s *ShiyanApi) CorrectingOrg(c *gin.Context) {
|
|
//assessment_loging
|
|
// synPro.Add(1)
|
|
// go corAssMentLog() //考核记录自建审批流
|
|
|
|
// synPro.Add(1)
|
|
// go corAssAssesstarget() //考核指标
|
|
// //部门维度
|
|
// synPro.Add(1)
|
|
// go corDeparDime()
|
|
|
|
// //部门考核指标权重
|
|
// synPro.Add(1)
|
|
// go corDepartDimWeight()
|
|
// //指标细则
|
|
// synPro.Add(1)
|
|
// go corDetailedTarget()
|
|
// //划分责任
|
|
// synPro.Add(1)
|
|
// go corDivResp()
|
|
//审批流程
|
|
synPro.Add(1)
|
|
go corEvalProcess()
|
|
|
|
// //测评指标
|
|
// synPro.Add(1)
|
|
// go corEvaluaTionTarget()
|
|
|
|
// //定量考核数据表
|
|
// synPro.Add(1)
|
|
// go flowLogDivResp()
|
|
|
|
// //考核方案版本内容
|
|
// synPro.Add(1)
|
|
// go corPlanversio()
|
|
|
|
// //定性考核
|
|
// synPro.Add(1)
|
|
// go corQualitativeEvaluation()
|
|
|
|
// //定性指标子栏目
|
|
// synPro.Add(1)
|
|
// go corQualitativeTarget()
|
|
|
|
// //定量考核目标设定
|
|
// synPro.Add(1)
|
|
// go corQualitativeConfig()
|
|
|
|
// //整改措施
|
|
// synPro.Add(1)
|
|
// go corRectificationMeasures()
|
|
|
|
// //分数流水
|
|
// synPro.Add(1)
|
|
// go corScoreFlow()
|
|
|
|
synPro.Wait()
|
|
|
|
response.Result(0, nil, "完成!", c)
|
|
}
|
|
|
|
// 考核指标
|
|
func corAssAssesstarget() {
|
|
defer synPro.Done()
|
|
var assList []assessmentmodel.Assesstarget
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.Assesstarget{}).Select("`at_id`,`group`,`departmentmap`").Find(&assList).Error
|
|
if err == nil {
|
|
if len(assList) >= 1 {
|
|
for _, v := range assList {
|
|
saveData := commonus.MapOut()
|
|
if v.Group == 2 {
|
|
saveData["group"] = 309
|
|
}
|
|
if v.Departmentmap != "" {
|
|
idAry := strings.Split(v.Departmentmap, ",")
|
|
idIntAry := orgTransCodingAry(idAry)
|
|
saveData["departmentmap"] = strings.Join(idIntAry, ",")
|
|
}
|
|
saveData["time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.Assesstarget{}).Where("`at_id` = ?", v.Id).Updates(saveData)
|
|
// return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 考核记录自建审批流
|
|
func corAssMentLog() {
|
|
defer synPro.Done()
|
|
var assessmentLoging []assessmentmodel.AssessmentLogIng
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.AssessmentLogIng{}).Select("`al_id`,`al_assdepart`,`al_executor_depart`").Find(&assessmentLoging).Error
|
|
if err == nil {
|
|
if len(assessmentLoging) >= 1 {
|
|
for _, v := range assessmentLoging {
|
|
saveData := commonus.MapOut()
|
|
assdepart := orgTransCoding(v.Assdepart)
|
|
if assdepart != 0 {
|
|
saveData["al_assdepart"] = assdepart
|
|
}
|
|
excedepart := orgTransCoding(v.ExecutorDepart)
|
|
if excedepart != 0 {
|
|
saveData["al_executor_depart"] = excedepart
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["al_eite_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.AssessmentLogIng{}).Where("`al_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 行政组织转码
|
|
func orgTransCoding(ordId int64) (newOrgId int64) {
|
|
if ordId == 0 {
|
|
return
|
|
}
|
|
var oldOrgCont hrsystem.AdministrativeOrganization
|
|
oldErr := global.GVA_DB_HrDataBase.Model(&oldOrgCont).Select("`number`").Where("`id` = ?", ordId).First(&oldOrgCont).Error
|
|
if oldErr != nil {
|
|
return
|
|
}
|
|
if oldOrgCont.Number == "" {
|
|
return
|
|
}
|
|
var newOrgCont hrsystem.AdministrativeOrganization
|
|
newErr := global.GVA_DB_HrKingDee.Model(&newOrgCont).Select("`id`").Where("`number` = ?", oldOrgCont.Number).First(&newOrgCont).Error
|
|
if newErr != nil {
|
|
return
|
|
}
|
|
if newOrgCont.Id == 0 {
|
|
return
|
|
}
|
|
newOrgId = newOrgCont.Id
|
|
return
|
|
}
|
|
|
|
// 行政组织转码
|
|
func orgTransCodingName(ordId int64, field ...string) (newOrgCont hrsystem.AdministrativeOrganization) {
|
|
if ordId == 0 {
|
|
return
|
|
}
|
|
var oldOrgCont hrsystem.AdministrativeOrganization
|
|
oldErr := global.GVA_DB_HrDataBase.Model(&oldOrgCont).Select("`number`").Where("`id` = ?", ordId).First(&oldOrgCont).Error
|
|
if oldErr != nil {
|
|
return
|
|
}
|
|
if oldOrgCont.Number == "" {
|
|
return
|
|
}
|
|
// var newOrgCont hrsystem.AdministrativeOrganization
|
|
gormDb := global.GVA_DB_HrKingDee.Model(&newOrgCont)
|
|
|
|
if len(field) > 0 {
|
|
fieldStr := strings.Join(field, ",")
|
|
gormDb = gormDb.Select(fieldStr)
|
|
}
|
|
newErr := gormDb.Where("`number` = ?", oldOrgCont.Number).First(&newOrgCont).Error
|
|
if newErr != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// 行政组织转码数组
|
|
func orgTransCodingAry(ordId []string) (newOrgId []string) {
|
|
if len(ordId) <= 0 {
|
|
return
|
|
}
|
|
var oldNumberAry []string
|
|
oldErr := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("`number`").Where("`id` IN ?", ordId).Find(&oldNumberAry).Error
|
|
if oldErr != nil {
|
|
return
|
|
}
|
|
if len(oldNumberAry) <= 0 {
|
|
return
|
|
}
|
|
var newOrgIntId []int64
|
|
newErr := global.GVA_DB_HrKingDee.Model(&hrsystem.AdministrativeOrganization{}).Select("`id`").Where("`number` IN ?", oldNumberAry).Find(&newOrgId).Error
|
|
if newErr != nil {
|
|
return
|
|
}
|
|
if len(newOrgIntId) == 0 {
|
|
return
|
|
}
|
|
// newOrgId = newOrgCont.Id
|
|
return
|
|
}
|
|
|
|
// 职位对照
|
|
func positToKingdeePosit(ordId int64, field ...string) (newCont hrsystem.Position) {
|
|
if ordId == 0 {
|
|
return
|
|
}
|
|
var oldOrgCont hrsystem.Position
|
|
oldErr := global.GVA_DB_HrDataBase.Model(&oldOrgCont).Select("`number`").Where("`id` = ?", ordId).First(&oldOrgCont).Error
|
|
if oldErr != nil {
|
|
return
|
|
}
|
|
if oldOrgCont.Number == "" {
|
|
return
|
|
}
|
|
// var newOrgCont hrsystem.AdministrativeOrganization
|
|
gormDb := global.GVA_DB_HrKingDee.Model(&newCont)
|
|
|
|
if len(field) > 0 {
|
|
fieldStr := strings.Join(field, ",")
|
|
gormDb = gormDb.Select(fieldStr)
|
|
}
|
|
newErr := gormDb.Where("`number` = ?", oldOrgCont.Number).First(&newCont).Error
|
|
if newErr != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|
|
func positToKingdeePositScho(ordId int64, field ...string) (newCont hrsystem.Position) {
|
|
if ordId == 0 {
|
|
return
|
|
}
|
|
var oldOrgCont hrsystem.Position
|
|
oldErr := global.GVA_DB_HrDataBase.Model(&oldOrgCont).Select("`number`").Where("`school` = ?", ordId).First(&oldOrgCont).Error
|
|
if oldErr != nil {
|
|
return
|
|
}
|
|
if oldOrgCont.Number == "" {
|
|
return
|
|
}
|
|
// var newOrgCont hrsystem.AdministrativeOrganization
|
|
gormDb := global.GVA_DB_HrKingDee.Model(&newCont)
|
|
|
|
if len(field) > 0 {
|
|
fieldStr := strings.Join(field, ",")
|
|
gormDb = gormDb.Select(fieldStr)
|
|
}
|
|
newErr := gormDb.Where("`number` = ?", oldOrgCont.Number).First(&newCont).Error
|
|
if newErr != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 部门维度
|
|
func corDeparDime() {
|
|
defer synPro.Done()
|
|
// var departDimeList []assessmentmodel.DepartmentDimension
|
|
// err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimension{}).Select("`dd_id`,`dd_department`,`dd_group`").Find(&departDimeList).Error
|
|
// if err == nil{
|
|
// if len(departDimeList) > 0{
|
|
// for _,v := range departDimeList{
|
|
// saveData := commonus.MapOut()
|
|
// if v.Group == 2 {
|
|
// saveData["group"] = 309
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
}
|
|
|
|
// 部门考核指标权重
|
|
func corDepartDimWeight() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.DepartmentDimensionWeight
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Select("`ddw_id`,`ddw_group`,`ddw_derpatment`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
if v.Group == 2 {
|
|
saveData["ddw_group"] = 309
|
|
}
|
|
excedepart := orgTransCoding(v.DepartmentId)
|
|
if excedepart != 0 {
|
|
saveData["ddw_derpatment"] = excedepart
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["ddw_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimensionWeight{}).Where("`ddw_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 指标细则
|
|
func corDetailedTarget() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.DetailedTarget
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DetailedTarget{}).Select("`dt_id`,`dt_paretment`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
if v.Paretment != "" {
|
|
idAry := strings.Split(v.Paretment, ",")
|
|
idIntAry := orgTransCodingAry(idAry)
|
|
saveData["dt_paretment"] = strings.Join(idIntAry, ",")
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["dt_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DetailedTarget{}).Where("`dt_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 划分责任
|
|
func corDivResp() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.DivisionResponsibilities
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DivisionResponsibilities{}).Select("`df_id`,`df_department_id`,`df_group`,`df_evaluation_group`,`df_evaluation_department`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
saveData["df_group"] = 309
|
|
excedepart := orgTransCoding(v.Department)
|
|
if excedepart != 0 {
|
|
saveData["df_department_id"] = excedepart
|
|
}
|
|
|
|
saveData["df_evaluation_group"] = 309
|
|
excedepartEval := orgTransCoding(v.EvaluationDepartment)
|
|
if excedepartEval != 0 {
|
|
saveData["df_evaluation_department"] = excedepartEval
|
|
}
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["df_eite_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DivisionResponsibilities{}).Where("`df_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 审批流程
|
|
func corEvalProcess() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.EvaluationProcess
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Select("`ep_id`,`ep_cont`,`ep_next_cont`,`ep_setup_department`,`ep_accept_department`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
if v.NextContent != "" {
|
|
var flowAllMapList []commonus.FlowAllMap
|
|
jsonFlowErr := json.Unmarshal([]byte(v.NextContent), &flowAllMapList)
|
|
if jsonFlowErr == nil {
|
|
if len(flowAllMapList) > 0 {
|
|
for fi, fv := range flowAllMapList {
|
|
if len(fv.UserList) > 0 {
|
|
var userList []commonus.UserListFlowAll
|
|
for _, fvu := range fv.UserList {
|
|
var userCont commonus.UserListFlowAll
|
|
|
|
userCont.Id = fvu.Id //操作人ID
|
|
userCont.Name = fvu.Name //操作人姓名
|
|
userCont.Icon = fvu.Icon //操作人头像
|
|
userCont.Wechat = fvu.Wechat //微信Openid
|
|
userCont.Group = 309 //集团公司
|
|
|
|
var manCont hrsystem.PersonArchives
|
|
manCont.GetCont(map[string]interface{}{"`key`": fvu.Id}, "company", "maindeparment", "admin_org", "position", "job_id", "teamid")
|
|
// var groupCont hrsystem.AdministrativeOrganization
|
|
// groupCont.GetCont(map[string]interface{}{"`id`": 309}, "`name`")
|
|
// userCont.GroupName = groupCont.Name //集团公司名称
|
|
userCont.GroupName = "山东恒信高科能源有限公司"
|
|
|
|
var orgComy hrsystem.AdministrativeOrganization
|
|
orgComy.GetCont(map[string]interface{}{"`id`": manCont.MainDeparment}, "name")
|
|
userCont.DepartmentId = manCont.MainDeparment //分厂Id
|
|
userCont.DepartmentName = orgComy.Name //分厂名称
|
|
var orgComyPost hrsystem.AdministrativeOrganization
|
|
orgComyPost.GetCont(map[string]interface{}{"`id`": manCont.AdminOrg}, "name")
|
|
userCont.WorkshopId = manCont.AdminOrg //工段Id
|
|
userCont.WorkshopName = orgComyPost.Name //工段名称
|
|
var postContuse hrsystem.PostDutiesJob
|
|
postContuse.GetCont(map[string]interface{}{"`id`": manCont.Position}, "name")
|
|
userCont.PostId = manCont.Position //职务Id
|
|
userCont.PostName = postContuse.Name //职务名称
|
|
|
|
// if fvu.DepartmentName == "" {
|
|
// departInfo := oldSchooldBf(fvu.DepartmentId, "`id`", "`name`")
|
|
// fmt.Printf("departInfo---------->%v--------->%v--------->%v\n", fvu.DepartmentId, departInfo.Id, departInfo.Name)
|
|
// userCont.DepartmentId = departInfo.Id //分厂Id
|
|
// userCont.DepartmentName = departInfo.Name //分厂名称
|
|
// } else {
|
|
// userCont.DepartmentId = fvu.DepartmentId //分厂Id
|
|
// }
|
|
// if fvu.WorkshopName == "" {
|
|
// worksInfo := oldSchooldBf(fvu.WorkshopId, "`id`", "`name`")
|
|
// userCont.WorkshopId = worksInfo.Id //工段Id
|
|
// userCont.WorkshopName = worksInfo.Name //工段名称
|
|
// } else {
|
|
// userCont.WorkshopId = fvu.WorkshopId //工段Id
|
|
// }
|
|
// if fvu.PostName == "" {
|
|
// positInfo := positToKingdeePositScho(fvu.PostId, "`id`", "`name`")
|
|
// userCont.PostId = positInfo.Id //职务Id
|
|
// userCont.PostName = positInfo.Name //职务名称
|
|
// } else {
|
|
// userCont.PostId = fvu.PostId //职务Id
|
|
// }
|
|
var teamCont hrsystem.TeamGroup
|
|
teamErr := teamCont.GetCont(map[string]interface{}{"`id`": manCont.TeamId}, "name")
|
|
if teamErr == nil {
|
|
userCont.Tema = manCont.TeamId //班组Id
|
|
userCont.TemaName = teamCont.Name //班组名称
|
|
} else {
|
|
userCont.Tema = fvu.Tema //班组Id
|
|
userCont.TemaName = fvu.TemaName //班组名称
|
|
}
|
|
|
|
userCont.LogList = fvu.LogList //操作记录
|
|
|
|
userList = append(userList, userCont)
|
|
}
|
|
flowAllMapList[fi].UserList = userList
|
|
}
|
|
|
|
}
|
|
|
|
jsonStr, jsonErr := json.Marshal(flowAllMapList)
|
|
if jsonErr == nil {
|
|
saveData["ep_next_cont"] = string(jsonStr)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
// if v.SetupDepartment != 0 {
|
|
// excedepart := orgTransCoding(v.SetupDepartment)
|
|
// if excedepart != 0 {
|
|
// saveData["ep_setup_department"] = excedepart
|
|
// }
|
|
// }
|
|
|
|
// if v.AcceptDepartment != 0 {
|
|
// excedepartEval := orgTransCoding(v.AcceptDepartment)
|
|
// if excedepartEval != 0 {
|
|
// saveData["ep_accept_department"] = excedepartEval
|
|
// }
|
|
// }
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["ep_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
// return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取原知行学院部门代码
|
|
func oldSchooldBf(ordId int64, field ...string) (newOrgCont hrsystem.AdministrativeOrganization) {
|
|
if ordId == 0 {
|
|
return
|
|
}
|
|
var oldOrgCont hrsystem.AdministrativeOrganization
|
|
oldErr := global.GVA_DB_HrDataBase.Model(&oldOrgCont).Select("`number`").Where("`schoole` = ?", ordId).First(&oldOrgCont).Error
|
|
if oldErr != nil {
|
|
oldErr = global.GVA_DB_HrDataBase.Model(&oldOrgCont).Select("`number`").Where("`wechat_organization_id` = ?", ordId).First(&oldOrgCont).Error
|
|
}
|
|
if oldErr != nil {
|
|
return
|
|
}
|
|
if oldOrgCont.Number == "" {
|
|
return
|
|
}
|
|
// var newOrgCont hrsystem.AdministrativeOrganization
|
|
gormDb := global.GVA_DB_HrKingDee.Model(&newOrgCont)
|
|
|
|
if len(field) > 0 {
|
|
fieldStr := strings.Join(field, ",")
|
|
gormDb = gormDb.Select(fieldStr)
|
|
}
|
|
newErr := gormDb.Where("`number` = ?", oldOrgCont.Number).First(&newOrgCont).Error
|
|
if newErr != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// 测评指标 测评指标
|
|
func corEvaluaTionTarget() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.EvaluationTarget
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Select("`et_id`,`et_relevant_departments`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
if v.RelevantDepartments != "" {
|
|
idAry := strings.Split(v.RelevantDepartments, ",")
|
|
idIntAry := orgTransCodingAry(idAry)
|
|
saveData["et_relevant_departments"] = strings.Join(idIntAry, ",")
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["et_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Where("`et_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 定量考核数据表
|
|
func flowLogDivResp() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.FlowLog
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("`fl_id`,`fl_evaluation_department`,`fl_evaluation_group`,`fl_duty_group`,`fl_duty_department`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
saveData["fl_evaluation_group"] = 309
|
|
excedepart := orgTransCoding(v.EvaluationDepartment)
|
|
if excedepart != 0 {
|
|
saveData["fl_evaluation_department"] = excedepart
|
|
}
|
|
|
|
saveData["fl_duty_group"] = 309
|
|
excedepartEval := orgTransCoding(v.DutyDepartment)
|
|
if excedepartEval != 0 {
|
|
saveData["fl_duty_department"] = excedepartEval
|
|
}
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["fl_eite_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Where("`fl_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 考核方案版本内容
|
|
func corPlanversio() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.PlanVersio
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Select("`id`,`department`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
saveData["group"] = 309
|
|
excedepart := orgTransCoding(v.Department)
|
|
if excedepart != 0 {
|
|
saveData["department"] = excedepart
|
|
}
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["eitetime"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("`id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 定性考核
|
|
func corQualitativeEvaluation() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.QualitativeEvaluation
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("`qe_id`,`qe_department_id`,`qe_accept_evaluation`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
saveData["qe_group"] = 309
|
|
excedepart := orgTransCoding(v.AcceptEvaluation)
|
|
if excedepart != 0 {
|
|
saveData["qe_accept_evaluation"] = excedepart
|
|
}
|
|
if v.DepartmentId != "" {
|
|
idAry := strings.Split(v.DepartmentId, ",")
|
|
idIntAry := orgTransCodingAry(idAry)
|
|
saveData["qe_department_id"] = strings.Join(idIntAry, ",")
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["qe_eitetime"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 定性指标子栏目
|
|
func corQualitativeTarget() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.QualitativeTarget
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeTarget{}).Select("`q_id`,`q_depart`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
if v.Depart != "" {
|
|
idAry := strings.Split(v.Depart, ",")
|
|
idIntAry := orgTransCodingAry(idAry)
|
|
saveData["q_depart"] = strings.Join(idIntAry, ",")
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["q_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeTarget{}).Where("`q_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 定量考核目标设定
|
|
func corQualitativeConfig() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.QuantitativeConfig
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QuantitativeConfig{}).Select("`id`,`departmentid`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
saveData["group"] = 309
|
|
excedepart := orgTransCoding(v.DepartmentId)
|
|
if excedepart != 0 {
|
|
saveData["departmentid"] = excedepart
|
|
}
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QuantitativeConfig{}).Where("`id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 整改措施
|
|
func corRectificationMeasures() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.RectificationMeasures
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.RectificationMeasures{}).Select("`rm_id`,`rm_department`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
saveData["rm_group"] = 309
|
|
excedepart := orgTransCoding(v.Department)
|
|
if excedepart != 0 {
|
|
saveData["rm_department"] = excedepart
|
|
}
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["rm_eite_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.RectificationMeasures{}).Where("`rm_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func corScoreFlow() {
|
|
defer synPro.Done()
|
|
var departDimWeigList []assessmentmodel.ScoreFlow
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("`sf_id`,`sf_evaluation_department`,`sf_evaluation_group`,`sf_duty_group`,`sf_duty_department`").Find(&departDimWeigList).Error
|
|
if err == nil {
|
|
if len(departDimWeigList) > 0 {
|
|
for _, v := range departDimWeigList {
|
|
saveData := commonus.MapOut()
|
|
|
|
saveData["sf_evaluation_group"] = 309
|
|
excedepart := orgTransCoding(v.EvaluationDepartment)
|
|
if excedepart != 0 {
|
|
saveData["sf_evaluation_department"] = excedepart
|
|
}
|
|
|
|
saveData["sf_duty_group"] = 309
|
|
excedepartEval := orgTransCoding(v.DutyDepartment)
|
|
if excedepartEval != 0 {
|
|
saveData["sf_duty_department"] = excedepartEval
|
|
}
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["sf_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_id` = ?", v.Id).Updates(saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 删除指定人的考核数据
|
|
func (s *ShiyanApi) DelFlowDataUser(c *gin.Context) {
|
|
var requestData FlowLogAllZreo
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Id == "" {
|
|
response.Result(1000, requestData, "请输入人员ID", c)
|
|
return
|
|
}
|
|
//定量删除
|
|
var flowKey []int64
|
|
flErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("`fl_key`").Where("fl_evaluation_user = ?", requestData.Id).Find(&flowKey).Error
|
|
if flErr == nil {
|
|
if len(flowKey) > 0 {
|
|
global.GVA_DB_Performanceappraisal.Where("fld_flow_log IN ?", flowKey).Delete(&assessmentmodel.FlowLogData{})
|
|
global.GVA_DB_Performanceappraisal.Where("fl_key IN ?", flowKey).Delete(&assessmentmodel.FlowLog{})
|
|
global.GVA_DB_Performanceappraisal.Where("ep_order_key IN ?", flowKey).Delete(&assessmentmodel.EvaluationProcess{})
|
|
}
|
|
}
|
|
//定性审核
|
|
var dingxinOrderid []int64
|
|
dxErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_key").Where("sf_evaluation_user = ?", requestData.Id).Find(&dingxinOrderid)
|
|
if dxErr == nil && len(dingxinOrderid) > 0 {
|
|
global.GVA_DB_Performanceappraisal.Where("sf_evaluation_user = ?", requestData.Id).Delete(&assessmentmodel.ScoreFlow{})
|
|
global.GVA_DB_Performanceappraisal.Where("ep_order_key IN ?", dingxinOrderid).Delete(&assessmentmodel.EvaluationProcess{})
|
|
}
|
|
|
|
response.Result(0, requestData, "处理完毕", c)
|
|
|
|
//判断定量考核有无后续数据
|
|
var flowKeyAll []int64
|
|
allErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("`fl_key`").Find(&flowKeyAll).Error
|
|
if allErr == nil {
|
|
for _, v := range flowKeyAll {
|
|
var flowData assessmentmodel.FlowLogData
|
|
delErr := global.GVA_DB_Performanceappraisal.Where("fld_flow_log = ?", v).First(&flowData).Error
|
|
if delErr != nil {
|
|
global.GVA_DB_Performanceappraisal.Where("fl_key = ?", v).Delete(&assessmentmodel.FlowLog{})
|
|
global.GVA_DB_Performanceappraisal.Where("ep_order_key = ?", v).Delete(&assessmentmodel.EvaluationProcess{})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 查看定量考核是否有审批流程
|
|
func (s *ShiyanApi) DingLiangPass(c *gin.Context) {
|
|
var flowKey []int64
|
|
flErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("`fl_key`").Find(&flowKey).Error
|
|
if flErr != nil {
|
|
response.Result(1000, flErr, "没有数据", c)
|
|
return
|
|
}
|
|
if len(flowKey) < 1 {
|
|
response.Result(10001, flErr, "没有数据", c)
|
|
return
|
|
}
|
|
var errVal []int64
|
|
for _, v := range flowKey {
|
|
var evalProCont assessmentmodel.EvaluationProcess
|
|
evalErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Select("`ep_id`").Where("ep_order_key = ?", v).First(&evalProCont).Error
|
|
if evalErr != nil {
|
|
if commonus.IsInTrue[int64](v, errVal) == false {
|
|
errVal = append(errVal, v)
|
|
}
|
|
}
|
|
}
|
|
if len(errVal) > 0 {
|
|
global.GVA_DB_Performanceappraisal.Where("fld_flow_log IN ?", errVal).Delete(&assessmentmodel.FlowLogData{})
|
|
global.GVA_DB_Performanceappraisal.Where("fl_key IN ?", errVal).Delete(&assessmentmodel.FlowLog{})
|
|
}
|
|
response.Result(0, errVal, "处理完成", c)
|
|
}
|
|
|
|
// 定性考核没有审批流的数据
|
|
func (s *ShiyanApi) DingXingPass(c *gin.Context) {
|
|
var flowKey []int64
|
|
flErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("`sf_key`").Find(&flowKey).Error
|
|
if flErr != nil {
|
|
response.Result(1000, flErr, "没有数据", c)
|
|
return
|
|
}
|
|
if len(flowKey) < 1 {
|
|
response.Result(10001, flErr, "没有数据", c)
|
|
return
|
|
}
|
|
var errVal []int64
|
|
for _, v := range flowKey {
|
|
var evalProCont assessmentmodel.EvaluationProcess
|
|
evalErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Select("`ep_id`").Where("ep_order_key = ?", v).First(&evalProCont).Error
|
|
if evalErr != nil {
|
|
if commonus.IsInTrue[int64](v, errVal) == false {
|
|
errVal = append(errVal, v)
|
|
}
|
|
}
|
|
}
|
|
if len(errVal) > 0 {
|
|
global.GVA_DB_Performanceappraisal.Where("sf_key IN ?", errVal).Delete(&assessmentmodel.ScoreFlow{})
|
|
}
|
|
response.Result(0, errVal, "处理完成", c)
|
|
}
|
|
|