KPI绩效考核系统
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.

225 lines
8.4 KiB

package maptostruct
import (
"fmt"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/models/modelsstorage"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2022-11-14 16:43:22
@ 功能: 实验仓储类型树
@ 参数
#
@ 返回值
#
*/
func (a *ApiMethod) CangChuThree(c *gin.Context) {
var mType []modelsstorage.MaterialType
overall.CONSTANT_DB_Storage.Where("`state` = 1").Find(&mType)
var toalVal int64
// overall.CONSTANT_DB_Storage.Model(&modelsstorage.Material{}).Where("`state` = 1").Count(&toalVal)
// var materList []modelsstorage.Material
// err = overall.CONSTANT_DB_Storage.Find(&materList).Error
// var jibuq []int
// toalVal := 0
var mTypeGroup []modelsstorage.MaterialType
var mttt readDataLock
for i, v := range mType {
if (i+1)%100 == 0 {
syncSeting.Add(1)
mTypeGroup = append(mTypeGroup, v)
go mttt.chuLiType(mTypeGroup, toalVal)
mTypeGroup = []modelsstorage.MaterialType{}
} else {
mTypeGroup = append(mTypeGroup, v)
}
// if i == 0 {
// // syncSeting.Add(1)
// mTypeGroup = append(mTypeGroup, v)
// // go mttt.chuLiType(mTypeGroup, toalVal)
// }
}
if len(mTypeGroup) > 0 {
syncSeting.Add(1)
go mttt.chuLiType(mTypeGroup, toalVal)
}
syncSeting.Wait()
// fmt.Printf("%v", mttt)
var chanzongshu int
chanzongshu = 0
for _, vvv := range mttt.MaterialAry {
chanzongshu = chanzongshu + len(vvv.MaterialList)
fmt.Printf("%v------>%v------>%v\n", vvv.Id, vvv.Name, len(vvv.MaterialList))
}
threeList := GetMenuThreePeiQuan(0, mttt.MaterialAry)
outData := publicmethod.MapOut[string]()
outData["mttt_count"] = len(mttt.MaterialAry)
outData["chanzongshu"] = chanzongshu
// outData["mtttList"] = mttt.MaterialAry
outData["threeList"] = threeList
fmt.Printf("%v------>%v------>%v------>%v\n", len(mType), toalVal, toalVal/1000, toalVal%1000)
publicmethod.Result(0, outData, c)
}
// 多类别数据处理
func (m *readDataLock) chuLiType(mType []modelsstorage.MaterialType, toalVal int64) {
defer syncSeting.Done()
var idList []int64
for _, v := range mType {
idList = append(idList, v.OrderId)
}
pageSum := toalVal / 1000
if toalVal%1000 > 0 {
pageSum = pageSum + 1
}
var i int64
for i = 1; i <= pageSum; i++ {
// pageSize := publicmethod.LimitPage64(i, 1000)
// fmt.Printf("第%v页,结束点%v\n", i, pageSize)
// syncSetings.Add(1)
// go m.Xiecheng(idList, pageSize, mType)
}
pageSize := publicmethod.LimitPage64(i, 1000)
syncSetings.Add(1)
go m.Xiecheng(idList, pageSize, mType)
syncSetings.Wait()
// fmt.Println("--------------------------------")
}
func (m *readDataLock) Xiecheng(id []int64, pageSize int64, mType []modelsstorage.MaterialType) {
defer syncSetings.Done()
// pageSizeStr := strconv.FormatInt(pageSize, 10)
// pageSizeInt, _ := strconv.Atoi(pageSizeStr)
var materList []modelsstorage.Material
// overall.CONSTANT_DB_Storage.Where("`type_id` IN ? AND `state` = 1", id).Limit(1000).Offset(pageSizeInt).Find(&materList)
overall.CONSTANT_DB_Storage.Where("`type_id` IN ? AND `state` = 1", id).Find(&materList)
for _, v := range mType {
var materialCont MaterialCont
materialCont.Id = v.Id //
materialCont.Name = v.Name // 类型名称"`
materialCont.Introduce = v.Introduce // 类型介绍"`
materialCont.State = v.State //状态(启用2禁用3删除4不对其做任何操作)"`
materialCont.ParentId = v.ParentId //父级"`
materialCont.OrderId = v.OrderId //导入时id"`
for _, mv := range materList {
if v.OrderId == mv.TypeId {
var materialcont modelsstorage.Material
materialcont.Id = mv.Id // `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;index"`
materialcont.DepositoryId = mv.DepositoryId // `json:"depositoryid" gorm:"column:depository_id;type:bigint(20) unsigned;default:0;not null;comment:仓库编号"`
materialcont.Name = mv.Name // `json:"name" gorm:"column:mname;type:varchar(100);comment:材料名称"`
materialcont.Quantity = mv.Quantity // `json:"quantity" gorm:"column:type;quantity:int(11) unsigned;default:1;not null;comment:数量"`
materialcont.Amounts = mv.Amounts // `json:"amounts" gorm:"column:amounts;type:int(11) unsigned;default:1;not null;comment:总金额"`
materialcont.TypeId = mv.TypeId // `json:"typeid" gorm:"column:type_id;type:bigint(20) unsigned;default:0;not null;comment:材料种类id"`
materialcont.State = mv.State // `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
materialcont.Code = mv.Code // `json:"code" gorm:"column:code;type:varchar(255);comment:存货编码"`
materialcont.Version = mv.Version // `json:"version" gorm:"column:version;type:varchar(255);comment:规格型号"`
materialcont.Price = mv.Price // `json:"price" gorm:"column:price;type:int(11) unsigned;default:1;not null;comment:单价"`
materialcont.Unit = mv.Unit // `json:"unit" gorm:"column:unit;type:varchar(255);comment:计量单位"`
materialcont.Texture = mv.Texture // `json:"texture" gorm:"column:texture;type:varchar(255);comment:材质"`
materialcont.DepositoryCode = mv.DepositoryCode // `json:"depositoryCode" gorm:"column:depositoryCode;type:varchar(255);comment:货位码(存放位置)"`
materialcont.Kingdeecode = mv.Kingdeecode // `json:"kingdeecode" gorm:"column:kingdeecode;type:varchar(255);comment:计量单位"`
materialcont.NumberOfTemporary = mv.NumberOfTemporary // `json:"numberoftemporary" gorm:"column:number_of_temporary;type:int(11) unsigned;default:1;not null;comment:临时数目(临时出库数目)"`
materialCont.MaterialList = append(materialCont.MaterialList, materialcont)
}
}
m.MaterialAry = append(m.MaterialAry, materialCont)
}
}
// 递归无限极菜单树
/*
@parentId 上级ID
@threeData 结果值
*/
func GetMenuThreePeiQuan(parentId int64, threeData []MaterialCont) []CaiDanShu {
treeList := []CaiDanShu{}
for _, v := range threeData {
if v.ParentId == parentId {
child := GetMenuThreePeiQuan(v.OrderId, threeData)
var node CaiDanShu
node.Id = v.Id //
node.Name = v.Name // 类型名称"`
node.Introduce = v.Introduce // 类型介绍"`
node.State = v.State //状态(启用2禁用3删除4不对其做任何操作)"`
node.ParentId = v.ParentId //父级"`
node.OrderId = v.OrderId //导入时id"`
node.MaterialList = v.MaterialList
node.Child = child
treeList = append(treeList, node)
}
}
return treeList
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-08 15:25:49
@ 功能: 校正原审批流信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CheckOldWorkflow(c *gin.Context) {
var oldFlowList []modelskpi.EvaluationProcess
err := overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationProcess{}).Find(&oldFlowList).Error
if err == nil {
for _, v := range oldFlowList {
if v.TypeClass == 1 {
//定性
var scoreFlowCont modelskpi.ScoreFlow
errSore := scoreFlowCont.GetCont(map[string]interface{}{"`sf_key`": v.OrderKey})
if errSore == nil {
scoreEdit := publicmethod.MapOut[string]()
scoreEdit["ep_setup_department"] = scoreFlowCont.EvaluationDepartment
scoreEdit["ep_target"] = scoreFlowCont.TargetId
scoreEdit["ep_detailedtarget"] = scoreFlowCont.DetailedId
scoreEdit["ep_creater"] = scoreFlowCont.EvaluationUser
var editDingXingEvalPros modelskpi.EvaluationProcess
editDingXingEvalPros.EiteCont(map[string]interface{}{"`ep_id`": v.Id}, scoreEdit)
}
} else {
//定量
var dingLiangCont modelskpi.FlowLog
errSore := dingLiangCont.GetCont(map[string]interface{}{"`fl_key`": v.OrderKey})
if errSore == nil {
scoreEditLiang := publicmethod.MapOut[string]()
scoreEditLiang["ep_setup_department"] = dingLiangCont.EvaluationDepartment
scoreEditLiang["ep_creater"] = dingLiangCont.EvaluationUser
var editDingLiangEvalPros modelskpi.EvaluationProcess
editDingLiangEvalPros.EiteCont(map[string]interface{}{"`ep_id`": v.Id}, scoreEditLiang)
}
}
}
}
}