作者 郑周

Merge remote-tracking branch 'origin/test' into test

... ... @@ -10,4 +10,5 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-pg/pg/v10 v10.10.7
github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d
github.com/xuri/excelize/v2 v2.6.1
)
... ...
... ... @@ -346,6 +346,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
... ... @@ -441,7 +442,11 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
... ... @@ -504,7 +509,13 @@ github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhe
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj09jdMlkY0aiA6+Skbtl3/c=
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/excelize/v2 v2.4.1/go.mod h1:rSu0C3papjzxQA3sdK8cU544TebhrPUoTOaGPIh0Q1A=
github.com/xuri/excelize/v2 v2.6.1 h1:ICBdtw803rmhLN3zfvyEGH3cwSmZv+kde7LhTDT659k=
github.com/xuri/excelize/v2 v2.6.1/go.mod h1:tL+0m6DNwSXj/sILHbQTYsLi9IF4TW59H2EF3Yrx1AU=
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M=
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
... ... @@ -558,8 +569,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
... ... @@ -573,6 +585,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE=
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
... ... @@ -636,8 +650,10 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 h1:4CSI6oo7cOjJKajidEljs9h+uP0rRZBPPPhcCbj5mw8=
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E=
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
... ... @@ -712,18 +728,21 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
... ... @@ -909,6 +928,7 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
... ...
不能预览此文件类型
... ... @@ -6,8 +6,8 @@ type CreateStaffAssessTask struct {
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
CycleId int64 `json:"cycleId"` //对应的周期id
CycleName string `json:"cycleName"` //对应周期的名称
BeginTime string `json:"beginTime"` //绩效考核开始时间
EndTime string `json:"endTime"` //绩效考核截止时间
BeginTime string `json:"beginTime"` //绩效考核开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //绩效考核截止时间 2006-01-02 15:04:05
StepList []AssessTaskStep `json:"steps"` //考评的流程
ExecutorId []int `json:"executorId"` //参与此次考评的人
}
... ...
... ... @@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
defer func() {
_ = transactionContext.RollbackTransaction()
}()
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime)
... ... @@ -351,8 +353,22 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime)
}
nowTime := time.Now()
var assessTaskData *domain.StaffAssessTask
_, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{
"evaluationProjectId": param.EvaluationProjectId,
"beginDay": taskBeginTime.Local().Format("2006-01-02"),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error())
}
// 获取旧数据
if len(assassessTaskList) > 0 {
assessTaskData = assassessTaskList[0]
assessTaskData.UpdatedAt = nowTime
} else {
//建立评估任务
assessTask := domain.StaffAssessTask{
assessTaskData = &domain.StaffAssessTask{
Id: 0,
CompanyId: param.CompanyId,
EvaluationProjectId: param.EvaluationProjectId,
... ... @@ -367,8 +383,15 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
UpdatedAt: nowTime,
DeletedAt: nil,
}
}
//填充评估环节
for _, v := range param.StepList {
for _, vv := range assessTaskData.StepList {
if vv.LinkNodeType == v.LinkNodeType {
continue
}
}
stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime)
... ... @@ -385,13 +408,10 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
BeginTime: stepBeginTime,
EndTime: stepEndTime,
}
assessTask.StepList = append(assessTask.StepList, step)
assessTaskData.StepList = append(assessTaskData.StepList, step)
}
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessList, err := srv.createStaffAssess(transactionContext, &assessTask)
assessList, err := srv.createStaffAssess(transactionContext, assessTaskData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error())
}
... ... @@ -405,27 +425,35 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
}
executorIds = append(executorIds, v)
}
//过滤就数据
for _, v := range assessTaskData.ExecutorId {
if _, ok := executorIdMap[v]; ok {
continue
}
executorIds = append(executorIds, v)
}
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData.ExecutorId = executorIds
_, err = assessTaskRepo.Save(assessTaskData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
}
for i := range assessList {
assessList[i].StaffAssessTaskId = assessTaskData.Id
_, err = assessRepo.Save(&assessList[i])
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error())
}
}
assessTask.ExecutorId = executorIds
_, err = assessTaskRepo.Save(&assessTask)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return map[string]interface{}{
"assessTaskId": assessTask.Id,
"assessTaskId": assessTaskData.Id,
}, nil
}
... ...
package domain
import (
"errors"
"strings"
)
type PerformanceApplicationForm struct {
DimensionName string //维度名称
ModuleName string //模块名称
Weight string //权重
Standard string //标准
Task string //任务、指标
}
type PerformanceDimension struct {
Name string `json:"name"` //维度名称
PerformanceModule []*PerformanceModule `json:"performanceModule"` //模块
}
type PerformanceModule struct {
ModuleName string `json:"moduleName"` //模块名称
Weight string `json:"weight"` //权重
Standard string `json:"standard"` //标准(结构化的成果描述)
Target []*PerformanceTarget `json:"performanceTarget"` //任务\指标
}
type PerformanceTarget struct {
Task string `json:"task"`
}
func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) {
formRows := make([]*PerformanceApplicationForm, 0)
var dimensionName, moduleName, taskName, weightName, standardName string
for key, item := range rows {
if key < 3 {
continue
}
if len(item) >= 1 {
if item[0] == "部门长审核" || strings.Contains(item[0], "审核") {
break
}
}
form := &PerformanceApplicationForm{}
//维度名称
if len(item) > 1 && item[1] != "" {
dimensionName = item[1]
}
form.DimensionName = dimensionName
//模块名称
if len(item) > 3 && item[3] != "" {
moduleName = item[3]
}
form.ModuleName = moduleName
//指标任务
if len(item) > 4 && item[4] != "" {
taskName = item[4]
}
form.Task = taskName
//权重
if len(item) > 6 && item[6] != "" {
weightName = item[6]
}
form.Weight = weightName
//标准
if len(item) > 7 && item[7] != "" {
standardName = item[7]
}
form.Standard = standardName
formRows = append(formRows, form)
}
dimensions := make([]*PerformanceDimension, 0)
//按维度分
mapData := make(map[string][]*PerformanceApplicationForm)
//维度顺序
sortBy := make([]string, 0)
for _, item := range formRows {
if _, ok := mapData[item.DimensionName]; !ok {
mapData[item.DimensionName] = make([]*PerformanceApplicationForm, 0)
sortBy = append(sortBy, item.DimensionName)
}
mapData[item.DimensionName] = append(mapData[item.DimensionName], item)
}
for dimensionName, item := range mapData {
dimension := &PerformanceDimension{
Name: dimensionName,
}
modules, err := loadPerformanceModule(item)
if err != nil {
return dimensions, err
}
dimension.PerformanceModule = modules
dimensions = append(dimensions, dimension)
}
result := make([]*PerformanceDimension, 0)
for _, name := range sortBy {
for _, item := range dimensions {
if name == item.Name {
result = append(result, item)
}
}
}
return result, nil
}
// 筛选出模块
func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceModule, error) {
mapData := make(map[string][]*PerformanceApplicationForm)
sortBy := make([]string, 0)
for _, item := range forms {
if _, ok := mapData[item.ModuleName]; !ok {
mapData[item.ModuleName] = make([]*PerformanceApplicationForm, 0)
sortBy = append(sortBy, item.ModuleName)
}
mapData[item.ModuleName] = append(mapData[item.ModuleName], item)
}
modules := make([]*PerformanceModule, 0)
for moduleName, item := range mapData {
if moduleName == "" {
return modules, errors.New(item[0].DimensionName + "对应的模块不能为空")
}
weightName, err := getWeight(item)
if err != nil {
return modules, err
}
standardName, err := getStandard(item)
if err != nil {
return modules, err
}
tasks, err := getTasks(item)
if err != nil {
return modules, err
}
module := &PerformanceModule{
ModuleName: moduleName,
Weight: weightName,
Standard: standardName,
Target: tasks,
}
modules = append(modules, module)
}
result := make([]*PerformanceModule, 0)
for _, name := range sortBy {
for _, item := range modules {
if name == item.ModuleName {
result = append(result, item)
}
}
}
return result, nil
}
// 获取权重
func getWeight(items []*PerformanceApplicationForm) (string, error) {
if len(items) <= 0 {
return "", nil
}
var name string
for _, item := range items {
if name == "" {
name = item.Weight
}
if name != item.Weight {
return "", errors.New(item.ModuleName + " 对应的权重值不一致")
}
}
if name == "/" {
name = "0%"
}
return name, nil
}
// 获取标准
func getStandard(items []*PerformanceApplicationForm) (string, error) {
if len(items) <= 0 {
return "", nil
}
var name string
for _, item := range items {
if name == "" {
name = item.Standard
}
if name != item.Standard {
return "", errors.New(item.ModuleName + " 对应的标准值不一致")
}
}
return name, nil
}
// 获取任务
func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) {
tasks := make([]*PerformanceTarget, 0)
for _, item := range items {
target := &PerformanceTarget{Task: item.Task}
tasks = append(tasks, target)
}
return tasks, nil
}
... ...
... ... @@ -2,19 +2,6 @@ package domain
import "time"
//评估任务重复执行的方式
// type AssessTaskRepeatWay string
// const (
// AssessTaskRepeatDay AssessTaskRepeatWay = "day" //按天重复
// AssessTaskRepeatWeek AssessTaskRepeatWay = "week" //按周重复
// AssessTaskRepeatMonth AssessTaskRepeatWay = "month" //按月
// AssessTaskRepeatMonthDouble AssessTaskRepeatWay = "month_double" //按双月
// AssessTaskRepeatQuarter AssessTaskRepeatWay = "quarter" //按季度
// AssessTaskRepeatYearHalf AssessTaskRepeatWay = "year_half" //按半年
// AssessTaskRepeatYear AssessTaskRepeatWay = "year" //按年
// )
// 执行评估的任务列表
type StaffAssessTask struct {
Id int `json:"id"`
... ... @@ -23,6 +10,7 @@ type StaffAssessTask struct {
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
CycleId int64 `json:"cycleId"` //对应的周期id
CycleName string `json:"cycleName"` //对应周期的名称
BeginDay string `json:"beginDay"` //绩效考核日期
BeginTime time.Time `json:"beginTime"` //绩效考核开始时间
EndTime time.Time `json:"endTime"` //绩效考核截止时间
StepList []AssessTaskStep `json:"stepList"` //考评的流程
... ...
... ... @@ -17,6 +17,7 @@ type StaffAssessTask struct {
CycleName string //对应周期的名称
ExecutorId []int //参与考评的人
StepList []domain.AssessTaskStep `` //考评的流程
BeginDay string //日期 天 2006-01-02
BeginTime time.Time //开始时间
EndTime time.Time //截止时间
CreatedAt time.Time //数据创建时间
... ...
... ... @@ -29,6 +29,7 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa
EvaluationProjectName: d.EvaluationProjectName,
CycleId: d.CycleId,
CycleName: d.CycleName,
BeginDay: d.BeginDay,
BeginTime: d.BeginTime,
EndTime: d.EndTime,
StepList: d.StepList,
... ... @@ -47,6 +48,7 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain.
EvaluationProjectName: d.EvaluationProjectName,
CycleId: d.CycleId,
CycleName: d.CycleName,
BeginDay: d.BeginDay,
ExecutorId: d.ExecutorId,
StepList: d.StepList,
BeginTime: d.BeginTime,
... ... @@ -115,9 +117,15 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
}
if v, ok := queryOptions["beginDay"]; ok {
query.Where("begin_day=?", v)
}
if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
query.Where(`executor_id @>'[?]'`, v)
}
if v, ok := queryOptions["evaluationProjectId"]; ok {
query.Where("evaluation_project_id=?", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
package controllers
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/web/beego"
"github.com/xuri/excelize/v2"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type ImportController struct {
beego.BaseController
}
func (controller *ImportController) Import() {
_, header, err := controller.GetFile("file")
if err != nil {
controller.Response(nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传错误:"+err.Error()))
return
}
file, err := header.Open()
if err != nil {
controller.Response(nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传错误:"+err.Error()))
return
}
reader, err := excelize.OpenReader(file)
if err != nil {
controller.Response(nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传错误:"+err.Error()))
return
}
index := reader.GetActiveSheetIndex()
rows, err := reader.GetRows(reader.GetSheetName(index))
if err != nil {
controller.Response(nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取excel错误:"+err.Error()))
return
}
formType := controller.GetString("type")
switch formType {
case "PerformanceDimension":
dimensions, _ := domain.LoadPerformanceDimensions(rows)
controller.Response(dimensions, nil)
default:
controller.Response(nil, application.ThrowError(application.ARG_ERROR, "请确认您导入的表单类型"))
}
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"github.com/linmadan/egglib-go/web/beego/filters"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
func init() {
ns := web.NewNamespace("/v1/import",
web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()),
web.NSRouter("/", &controllers.ImportController{}, "Post:Import"),
)
web.AddNamespace(ns)
}
... ...