合并分支 'test' 到 'master'
Test 查看合并请求 !3
正在显示
80 个修改的文件
包含
2938 行增加
和
602 行删除
@@ -3,10 +3,12 @@ module gitlab.fjmaimaimai.com/allied-creation/performance | @@ -3,10 +3,12 @@ module gitlab.fjmaimaimai.com/allied-creation/performance | ||
3 | go 1.16 | 3 | go 1.16 |
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | + github.com/Andrew-M-C/go.timeconv v0.4.0 | ||
6 | github.com/Shopify/sarama v1.25.0 | 7 | github.com/Shopify/sarama v1.25.0 |
7 | github.com/beego/beego/v2 v2.0.5 | 8 | github.com/beego/beego/v2 v2.0.5 |
8 | github.com/bwmarrin/snowflake v0.3.0 | 9 | github.com/bwmarrin/snowflake v0.3.0 |
9 | github.com/dgrijalva/jwt-go v3.2.0+incompatible | 10 | github.com/dgrijalva/jwt-go v3.2.0+incompatible |
10 | github.com/go-pg/pg/v10 v10.10.7 | 11 | github.com/go-pg/pg/v10 v10.10.7 |
11 | github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d | 12 | github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d |
13 | + github.com/xuri/excelize/v2 v2.6.1 | ||
12 | ) | 14 | ) |
@@ -31,6 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl | @@ -31,6 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl | ||
31 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= | 31 | cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= |
32 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= | 32 | cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= |
33 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= | 33 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= |
34 | +github.com/Andrew-M-C/go.timeconv v0.4.0 h1:jwSSP1Nru7Hh+XDxIy8Bt/a2kdjqW/xIKkLFhBc/bmA= | ||
35 | +github.com/Andrew-M-C/go.timeconv v0.4.0/go.mod h1:qKsoTE6tDyot1aOcAESJA5GBDxl3sns9YesrA8gBLVo= | ||
34 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | 36 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= |
35 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= | 37 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= |
36 | github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= | 38 | github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= |
@@ -344,6 +346,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ | @@ -344,6 +346,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ | ||
344 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= | 346 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= |
345 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= | 347 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= |
346 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= | 348 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= |
349 | +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= | ||
347 | github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= | 350 | github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= |
348 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= | 351 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= |
349 | github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= | 352 | github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= |
@@ -439,7 +442,11 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 | @@ -439,7 +442,11 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 | ||
439 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= | 442 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= |
440 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= | 443 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= |
441 | github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= | 444 | github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= |
445 | +github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM= | ||
446 | +github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= | ||
442 | github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= | 447 | github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= |
448 | +github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM= | ||
449 | +github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= | ||
443 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= | 450 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= |
444 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= | 451 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= |
445 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= | 452 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= |
@@ -502,7 +509,13 @@ github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhe | @@ -502,7 +509,13 @@ github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhe | ||
502 | github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= | 509 | github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= |
503 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= | 510 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= |
504 | github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= | 511 | github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= |
512 | +github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj09jdMlkY0aiA6+Skbtl3/c= | ||
513 | +github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= | ||
505 | github.com/xuri/excelize/v2 v2.4.1/go.mod h1:rSu0C3papjzxQA3sdK8cU544TebhrPUoTOaGPIh0Q1A= | 514 | github.com/xuri/excelize/v2 v2.4.1/go.mod h1:rSu0C3papjzxQA3sdK8cU544TebhrPUoTOaGPIh0Q1A= |
515 | +github.com/xuri/excelize/v2 v2.6.1 h1:ICBdtw803rmhLN3zfvyEGH3cwSmZv+kde7LhTDT659k= | ||
516 | +github.com/xuri/excelize/v2 v2.6.1/go.mod h1:tL+0m6DNwSXj/sILHbQTYsLi9IF4TW59H2EF3Yrx1AU= | ||
517 | +github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M= | ||
518 | +github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ= | ||
506 | github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | 519 | github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
507 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | 520 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
508 | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | 521 | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
@@ -556,8 +569,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh | @@ -556,8 +569,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh | ||
556 | golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= | 569 | golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= |
557 | golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= | 570 | golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= |
558 | golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | 571 | golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= |
559 | -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= | ||
560 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | 572 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= |
573 | +golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c= | ||
574 | +golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= | ||
561 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | 575 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= |
562 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | 576 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= |
563 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= | 577 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= |
@@ -571,6 +585,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk | @@ -571,6 +585,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk | ||
571 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= | 585 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= |
572 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | 586 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= |
573 | golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | 587 | golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= |
588 | +golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE= | ||
589 | +golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= | ||
574 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | 590 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
575 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= | 591 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= |
576 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | 592 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
@@ -634,8 +650,10 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY | @@ -634,8 +650,10 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY | ||
634 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | 650 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
635 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= | 651 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= |
636 | golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | 652 | golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
637 | -golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 h1:4CSI6oo7cOjJKajidEljs9h+uP0rRZBPPPhcCbj5mw8= | ||
638 | golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | 653 | golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
654 | +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
655 | +golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E= | ||
656 | +golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= | ||
639 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | 657 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
640 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | 658 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= |
641 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | 659 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= |
@@ -710,18 +728,21 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc | @@ -710,18 +728,21 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc | ||
710 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 728 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
711 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 729 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
712 | golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 730 | golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
713 | -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= | ||
714 | golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 731 | golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
732 | +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg= | ||
733 | +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
715 | golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= | 734 | golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= |
716 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | 735 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= |
736 | +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||
717 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | 737 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
718 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | 738 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
719 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | 739 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
720 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | 740 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
721 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | 741 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
722 | golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | 742 | golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
723 | -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= | ||
724 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | 743 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
744 | +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | ||
745 | +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||
725 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | 746 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
726 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | 747 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
727 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | 748 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
@@ -907,6 +928,7 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | @@ -907,6 +928,7 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||
907 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | 928 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= |
908 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | 929 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
909 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | 930 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
931 | +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
910 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | 932 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
911 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | 933 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
912 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | 934 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
不能预览此文件类型
1 | package main | 1 | package main |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "fmt" | ||
5 | - | ||
6 | "github.com/beego/beego/v2/server/web" | 4 | "github.com/beego/beego/v2/server/web" |
5 | + service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
7 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" | 7 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" |
9 | + "time" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | func main() { | 12 | func main() { |
12 | - tree := web.PrintTree() | ||
13 | - methods := tree["Data"].(web.M) | ||
14 | - for k, v := range methods { | ||
15 | - fmt.Printf("%s => %v \n", k, v) | ||
16 | - } | 13 | + startNodeTask() |
14 | + | ||
15 | + // tree := web.PrintTree() | ||
16 | + // methods := tree["Data"].(web.M) | ||
17 | + // for k, v := range methods { | ||
18 | + // fmt.Printf("%s => %v \n", k, v) | ||
19 | + // } | ||
17 | go consumer.Run() | 20 | go consumer.Run() |
18 | web.Run() | 21 | web.Run() |
19 | } | 22 | } |
23 | + | ||
24 | +// 定时任务-间隔发送评估环节 | ||
25 | +func startNodeTask() { | ||
26 | + go func() { | ||
27 | + nodeTaskService := service.NewNodeTaskService() | ||
28 | + for { | ||
29 | + timer := time.NewTimer(time.Second * 60) | ||
30 | + <-timer.C | ||
31 | + if err := nodeTaskService.SendEvaluationNode(); err != nil { | ||
32 | + log.Logger.Error(err.Error()) | ||
33 | + } | ||
34 | + } | ||
35 | + }() | ||
36 | +} |
@@ -142,6 +142,8 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | @@ -142,6 +142,8 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | ||
142 | } | 142 | } |
143 | if len(param.ChargeUserIds) > 0 { | 143 | if len(param.ChargeUserIds) > 0 { |
144 | departmentList[i].ChargeUserIds = param.ChargeUserIds | 144 | departmentList[i].ChargeUserIds = param.ChargeUserIds |
145 | + } else { | ||
146 | + departmentList[i].ChargeUserIds = make([]int64, 0) | ||
145 | } | 147 | } |
146 | continue | 148 | continue |
147 | } | 149 | } |
@@ -2,17 +2,16 @@ package command | @@ -2,17 +2,16 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type CreateCycleCommand struct { | 7 | type CreateCycleCommand struct { |
9 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
10 | - CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
11 | - Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
12 | - TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | ||
13 | - TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | ||
14 | - KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | ||
15 | - TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 8 | + CompanyId int64 `cname:"公司ID" json:"companyId"` |
9 | + CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
10 | + Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
11 | + TimeStart string `cname:"起始时间" json:"timeStart"` | ||
12 | + TimeEnd string `cname:"截至时间" json:"timeEnd"` | ||
13 | + KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"` | ||
14 | + TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | ||
16 | } | 15 | } |
17 | 16 | ||
18 | func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | 17 | func (in *CreateCycleCommand) Valid(validation *validation.Validation) { |
@@ -25,19 +24,24 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | @@ -25,19 +24,24 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | ||
25 | return | 24 | return |
26 | } | 25 | } |
27 | if len(in.Name) > 40 { | 26 | if len(in.Name) > 40 { |
28 | - validation.SetError("name", "角色名称最大长度40个字符") | 27 | + validation.SetError("name", "名称最大长度40个字符") |
29 | return | 28 | return |
30 | } | 29 | } |
31 | - if in.TimeStart == nil { | 30 | + if in.KpiCycle == 0 { |
31 | + validation.SetError("kpiCycle", "请选择考核周期") | ||
32 | + return | ||
33 | + } | ||
34 | + | ||
35 | + if len(in.TimeStart) == 0 { | ||
32 | validation.SetError("timeStart", "请选择考核周期的开始时间") | 36 | validation.SetError("timeStart", "请选择考核周期的开始时间") |
33 | return | 37 | return |
34 | } | 38 | } |
35 | - if in.TimeEnd == nil { | 39 | + if len(in.TimeEnd) == 0 { |
36 | validation.SetError("timeEnd", "请选择考核周期的结束时间") | 40 | validation.SetError("timeEnd", "请选择考核周期的结束时间") |
37 | return | 41 | return |
38 | } | 42 | } |
39 | if len(in.TemplateIds) == 0 { | 43 | if len(in.TemplateIds) == 0 { |
40 | - validation.SetError("templates", "请选择周期内使用的评估模板") | 44 | + validation.SetError("templates", "请添加评估模板") |
41 | return | 45 | return |
42 | } | 46 | } |
43 | } | 47 | } |
@@ -5,8 +5,21 @@ import "github.com/beego/beego/v2/core/validation" | @@ -5,8 +5,21 @@ import "github.com/beego/beego/v2/core/validation" | ||
5 | type QueryCycleCommand struct { | 5 | type QueryCycleCommand struct { |
6 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 6 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
7 | Name string `cname:"周期名称" json:"name"` | 7 | Name string `cname:"周期名称" json:"name"` |
8 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
9 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 8 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
9 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
10 | +} | ||
11 | + | ||
12 | +type StatisticCycleProjectUserCommand struct { | ||
13 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
14 | + CycleId int64 `cname:"周期ID" json:"cycleId,string"` | ||
15 | +} | ||
16 | + | ||
17 | +type CycleTemplateListCommand struct { | ||
18 | + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
19 | +} | ||
20 | + | ||
21 | +type CycleTemplateCommand struct { | ||
22 | + Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | ||
10 | } | 23 | } |
11 | 24 | ||
12 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | 25 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { |
@@ -15,3 +28,15 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | @@ -15,3 +28,15 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | ||
15 | return | 28 | return |
16 | } | 29 | } |
17 | } | 30 | } |
31 | + | ||
32 | +func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | ||
33 | + | ||
34 | +} | ||
35 | + | ||
36 | +func (in *CycleTemplateListCommand) Valid(*validation.Validation) { | ||
37 | + | ||
38 | +} | ||
39 | + | ||
40 | +func (in *CycleTemplateCommand) Valid(*validation.Validation) { | ||
41 | + | ||
42 | +} |
@@ -2,17 +2,16 @@ package command | @@ -2,17 +2,16 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type UpdateCycleCommand struct { | 7 | type UpdateCycleCommand struct { |
9 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
10 | - Id int64 `cname:"周期ID" json:"id,string" valid:"Required"` | ||
11 | - Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
12 | - TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | ||
13 | - TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | ||
14 | - KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | ||
15 | - TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 8 | + CompanyId int64 `cname:"公司ID" json:"companyId"` |
9 | + Id int64 `cname:"周期ID" json:"id,string" valid:"Required"` | ||
10 | + Name string `cname:"周期名称" json:"name" valid:"Required"` | ||
11 | + TimeStart string `cname:"起始时间" json:"timeStart"` | ||
12 | + TimeEnd string `cname:"截至时间" json:"timeEnd"` | ||
13 | + KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | ||
14 | + TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | ||
16 | } | 15 | } |
17 | 16 | ||
18 | func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | 17 | func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { |
@@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | @@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | ||
20 | validation.SetError("name", "角色名称最大长度40个字符") | 19 | validation.SetError("name", "角色名称最大长度40个字符") |
21 | return | 20 | return |
22 | } | 21 | } |
23 | - if in.TimeStart == nil { | 22 | + if len(in.TimeStart) == 0 { |
24 | validation.SetError("timeStart", "请选择考核周期的开始时间") | 23 | validation.SetError("timeStart", "请选择考核周期的开始时间") |
25 | return | 24 | return |
26 | } | 25 | } |
27 | - if in.TimeEnd == nil { | 26 | + if len(in.TimeEnd) == 0 { |
28 | validation.SetError("timeEnd", "请选择考核周期的结束时间") | 27 | validation.SetError("timeEnd", "请选择考核周期的结束时间") |
29 | return | 28 | return |
30 | } | 29 | } |
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
10 | "strconv" | 10 | "strconv" |
11 | + "time" | ||
11 | ) | 12 | ) |
12 | 13 | ||
13 | type EvaluationCycleService struct { | 14 | type EvaluationCycleService struct { |
@@ -30,6 +31,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -30,6 +31,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
30 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | 31 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) |
31 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 32 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
32 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 33 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
34 | + ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
33 | 35 | ||
34 | // 检测名称重复 | 36 | // 检测名称重复 |
35 | count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId}) | 37 | count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId}) |
@@ -37,7 +39,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -37,7 +39,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
37 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
38 | } | 40 | } |
39 | if count > 0 { | 41 | if count > 0 { |
40 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 42 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的周期") |
41 | } | 43 | } |
42 | 44 | ||
43 | _, templates, err := templateRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "ids": in.TemplateIds}) | 45 | _, templates, err := templateRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "ids": in.TemplateIds}) |
@@ -48,11 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -48,11 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
48 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") | 50 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") |
49 | } | 51 | } |
50 | 52 | ||
53 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
54 | + if err != nil { | ||
55 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
56 | + } | ||
57 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
58 | + if err != nil { | ||
59 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
60 | + } | ||
61 | + | ||
62 | + // 生成新周期数据 | ||
51 | newCycle := &domain.EvaluationCycle{ | 63 | newCycle := &domain.EvaluationCycle{ |
52 | Id: 0, | 64 | Id: 0, |
53 | Name: in.Name, | 65 | Name: in.Name, |
54 | - TimeStart: in.TimeStart, | ||
55 | - TimeEnd: in.TimeEnd, | 66 | + TimeStart: &start, |
67 | + TimeEnd: &end, | ||
56 | CompanyId: in.CompanyId, | 68 | CompanyId: in.CompanyId, |
57 | CreatorId: in.CreatorId, | 69 | CreatorId: in.CreatorId, |
58 | KpiCycle: in.KpiCycle, | 70 | KpiCycle: in.KpiCycle, |
@@ -62,24 +74,73 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -62,24 +74,73 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 74 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
63 | } | 75 | } |
64 | 76 | ||
77 | + // 获取所有模板中的规则对象数据 | ||
78 | + ruleIdsMap := map[int64]int64{} | ||
65 | for i := range templates { | 79 | for i := range templates { |
66 | v := templates[i] | 80 | v := templates[i] |
81 | + for j := range v.LinkNodes { | ||
82 | + node := v.LinkNodes[j] | ||
83 | + for k := range node.NodeContents { | ||
84 | + nodeContent := node.NodeContents[k] | ||
85 | + if nodeContent.RuleId != 0 { | ||
86 | + ruleIdsMap[nodeContent.RuleId] = nodeContent.RuleId | ||
87 | + } | ||
88 | + } | ||
89 | + } | ||
90 | + } | ||
91 | + ruleIds := make([]int64, 0) | ||
92 | + for k := range ruleIdsMap { | ||
93 | + ruleIds = append(ruleIds, k) | ||
94 | + } | ||
95 | + | ||
96 | + _, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId}) | ||
97 | + | ||
98 | + ruleMap := map[int64]*domain.EvaluationRule{} | ||
99 | + for i := range rules { | ||
100 | + ruleMap[rules[i].Id] = rules[i] | ||
101 | + } | ||
102 | + | ||
103 | + ctAdapter := &adapter.CycleTemplateAdapter{} | ||
104 | + ctAdapter.EvaluationCycle = cycle | ||
105 | + for i := range templates { | ||
106 | + v := templates[i] | ||
107 | + | ||
108 | + // 对评估模板中的评估规则进行数据赋值 | ||
109 | + for j := range v.LinkNodes { | ||
110 | + node := v.LinkNodes[j] | ||
111 | + for k := range node.NodeContents { | ||
112 | + nodeContent := node.NodeContents[k] | ||
113 | + if rule, ok := ruleMap[nodeContent.RuleId]; ok { | ||
114 | + nodeContent.Rule = rule | ||
115 | + } | ||
116 | + } | ||
117 | + } | ||
118 | + | ||
119 | + // 周期模板数据表中插入数据 | ||
67 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 120 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
68 | - Id: 0, | ||
69 | - Name: v.Name, | ||
70 | - Template: v, | ||
71 | - CycleId: cycle.Id, | 121 | + Id: 0, |
122 | + Name: v.Name, | ||
123 | + TemplateCreatedAt: v.CreatedAt, | ||
124 | + Template: v, | ||
125 | + CycleId: cycle.Id, | ||
72 | } | 126 | } |
73 | _, err := cycleTemplateRepository.Insert(cycleTemplate) | 127 | _, err := cycleTemplateRepository.Insert(cycleTemplate) |
74 | if err != nil { | 128 | if err != nil { |
75 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 129 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
76 | } | 130 | } |
131 | + | ||
132 | + // 输出模板简单信息 | ||
133 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
134 | + Id: cycleTemplate.Id, | ||
135 | + Name: cycleTemplate.Name, | ||
136 | + CreatedAt: cycleTemplate.TemplateCreatedAt, // 模板创建时间 | ||
137 | + }) | ||
77 | } | 138 | } |
78 | 139 | ||
79 | if err := transactionContext.CommitTransaction(); err != nil { | 140 | if err := transactionContext.CommitTransaction(); err != nil { |
80 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 141 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
81 | } | 142 | } |
82 | - return cycle, nil | 143 | + return ctAdapter, nil |
83 | 144 | ||
84 | } | 145 | } |
85 | 146 | ||
@@ -146,10 +207,11 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -146,10 +207,11 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
146 | for i := range templates { | 207 | for i := range templates { |
147 | v := templates[i] | 208 | v := templates[i] |
148 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 209 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
149 | - Id: 0, | ||
150 | - Name: v.Name, | ||
151 | - Template: v, | ||
152 | - CycleId: cycle.Id, | 210 | + Id: 0, |
211 | + Name: v.Name, | ||
212 | + TemplateCreatedAt: v.CreatedAt, | ||
213 | + Template: v, | ||
214 | + CycleId: cycle.Id, | ||
153 | } | 215 | } |
154 | _, err := cycleTemplateRepository.Insert(cycleTemplate) | 216 | _, err := cycleTemplateRepository.Insert(cycleTemplate) |
155 | if err != nil { | 217 | if err != nil { |
@@ -158,18 +220,43 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -158,18 +220,43 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
158 | } | 220 | } |
159 | } | 221 | } |
160 | 222 | ||
223 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
224 | + if err != nil { | ||
225 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
226 | + } | ||
227 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) | ||
228 | + if err != nil { | ||
229 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
230 | + } | ||
231 | + | ||
161 | cycle.Name = in.Name | 232 | cycle.Name = in.Name |
162 | - cycle.TimeStart = in.TimeStart | ||
163 | - cycle.TimeEnd = in.TimeEnd | 233 | + cycle.TimeStart = &start |
234 | + cycle.TimeEnd = &end | ||
164 | cycle.KpiCycle = in.KpiCycle | 235 | cycle.KpiCycle = in.KpiCycle |
165 | cycle, err = cycleRepository.Insert(cycle) | 236 | cycle, err = cycleRepository.Insert(cycle) |
166 | if err != nil { | 237 | if err != nil { |
167 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 238 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
168 | } | 239 | } |
240 | + | ||
241 | + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": cycle.Id}, "template") | ||
242 | + if err != nil { | ||
243 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
244 | + } | ||
245 | + | ||
246 | + ctAdapter := &adapter.CycleTemplateAdapter{} | ||
247 | + ctAdapter.EvaluationCycle = cycle | ||
248 | + for i := range cycleTemplates { | ||
249 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
250 | + Id: cycleTemplates[i].Id, | ||
251 | + Name: cycleTemplates[i].Name, | ||
252 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, | ||
253 | + }) | ||
254 | + } | ||
255 | + | ||
169 | if err := transactionContext.CommitTransaction(); err != nil { | 256 | if err := transactionContext.CommitTransaction(); err != nil { |
170 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 257 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
171 | } | 258 | } |
172 | - return cycle, nil | 259 | + return ctAdapter, nil |
173 | } | 260 | } |
174 | 261 | ||
175 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { | 262 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { |
@@ -199,7 +286,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, | @@ -199,7 +286,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, | ||
199 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | 286 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ |
200 | Id: cycleTemplates[i].Id, | 287 | Id: cycleTemplates[i].Id, |
201 | Name: cycleTemplates[i].Name, | 288 | Name: cycleTemplates[i].Name, |
202 | - CreatedAt: cycleTemplates[i].CreatedAt, | 289 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, |
203 | }) | 290 | }) |
204 | } | 291 | } |
205 | 292 | ||
@@ -253,5 +340,107 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | @@ -253,5 +340,107 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | ||
253 | if err != nil { | 340 | if err != nil { |
254 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 341 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
255 | } | 342 | } |
343 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
344 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
345 | + } | ||
346 | + | ||
256 | return tool_funs.SimpleWrapGridMap(total, cycles), nil | 347 | return tool_funs.SimpleWrapGridMap(total, cycles), nil |
257 | } | 348 | } |
349 | + | ||
350 | +func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | ||
351 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
352 | + if err != nil { | ||
353 | + return nil, err | ||
354 | + } | ||
355 | + defer func() { | ||
356 | + transactionContext.RollbackTransaction() | ||
357 | + }() | ||
358 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
359 | + _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template") | ||
360 | + if err != nil { | ||
361 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
362 | + } | ||
363 | + | ||
364 | + userIds := make([]int64, 0) | ||
365 | + userIdMap := map[int64]int64{} | ||
366 | + for i := range projects { | ||
367 | + project := projects[i] | ||
368 | + for j := range project.Recipients { | ||
369 | + userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
370 | + userIdMap[userId] = userId | ||
371 | + } | ||
372 | + } | ||
373 | + for k := range userIdMap { | ||
374 | + userIds = append(userIds, k) | ||
375 | + } | ||
376 | + | ||
377 | + userTotal := 0 | ||
378 | + departmentTotal := 0 | ||
379 | + if len(userIds) > 0 { | ||
380 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
381 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
382 | + departmentIdMap := map[int]int{} | ||
383 | + for i := range users { | ||
384 | + for _, v := range users[i].DepartmentId { | ||
385 | + departmentIdMap[v] = v | ||
386 | + } | ||
387 | + } | ||
388 | + userTotal = len(users) | ||
389 | + departmentTotal = len(departmentIdMap) | ||
390 | + } | ||
391 | + | ||
392 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
393 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
394 | + } | ||
395 | + return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | ||
396 | +} | ||
397 | + | ||
398 | +func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateListCommand) (interface{}, error) { | ||
399 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
400 | + if err != nil { | ||
401 | + return nil, err | ||
402 | + } | ||
403 | + defer func() { | ||
404 | + transactionContext.RollbackTransaction() | ||
405 | + }() | ||
406 | + | ||
407 | + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
408 | + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": in.CycleId}, "template") | ||
409 | + if err != nil { | ||
410 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
411 | + } | ||
412 | + | ||
413 | + list := make([]*domain.TemplateSimple, 0) | ||
414 | + for i := range cycleTemplates { | ||
415 | + list = append(list, &domain.TemplateSimple{ | ||
416 | + Id: cycleTemplates[i].Id, | ||
417 | + Name: cycleTemplates[i].Name, | ||
418 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, | ||
419 | + }) | ||
420 | + } | ||
421 | + | ||
422 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
423 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
424 | + } | ||
425 | + return map[string]interface{}{"list": list}, nil | ||
426 | +} | ||
427 | + | ||
428 | +func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand) (interface{}, error) { | ||
429 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
430 | + if err != nil { | ||
431 | + return nil, err | ||
432 | + } | ||
433 | + defer func() { | ||
434 | + transactionContext.RollbackTransaction() | ||
435 | + }() | ||
436 | + | ||
437 | + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
438 | + cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
439 | + if err != nil { | ||
440 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
441 | + } | ||
442 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
443 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
444 | + } | ||
445 | + return cycleTemplate.Template, nil | ||
446 | +} |
@@ -9,7 +9,7 @@ type CreateProjectCommand struct { | @@ -9,7 +9,7 @@ type CreateProjectCommand struct { | ||
9 | CreatorId int64 `cname:"创建人ID" json:"creatorId"` | 9 | CreatorId int64 `cname:"创建人ID" json:"creatorId"` |
10 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | 10 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` |
11 | Name string `cname:"项目名称" json:"name" valid:"Required"` | 11 | Name string `cname:"项目名称" json:"name" valid:"Required"` |
12 | - Describe string `cname:"项目描述" json:"describe" valid:"Required"` | 12 | + Describe string `cname:"项目描述" json:"describe"` |
13 | HrBp int `cname:"HR角色权限" json:"hrBp"` | 13 | HrBp int `cname:"HR角色权限" json:"hrBp"` |
14 | Pmp int `cname:"PM角色权限" json:"pmp"` | 14 | Pmp int `cname:"PM角色权限" json:"pmp"` |
15 | PmpIds []string `cname:"项目管理员ID" json:"pmpIds"` | 15 | PmpIds []string `cname:"项目管理员ID" json:"pmpIds"` |
@@ -2,25 +2,19 @@ package command | @@ -2,25 +2,19 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | -type StateProjectCommand struct { | ||
9 | - Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | ||
10 | - State int `cname:"项目状态" json:"state"` | 7 | +type ActivateProjectCommand struct { |
8 | + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | ||
11 | } | 9 | } |
12 | 10 | ||
13 | type CopyProjectCommand struct { | 11 | type CopyProjectCommand struct { |
14 | - Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | 12 | + CreatorId int64 `cname:"创建人ID" json:"creatorId"` |
13 | + Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | ||
15 | } | 14 | } |
16 | 15 | ||
17 | -func (in *StateProjectCommand) Valid(validation *validation.Validation) { | ||
18 | - switch in.State { | ||
19 | - case domain.ProjectStateWaitConfig, domain.ProjectStateWaitActive, domain.ProjectStateEnable, domain.ProjectStateDisable: | ||
20 | - default: | ||
21 | - validation.SetError("state", "状态设置错误") | ||
22 | - return | ||
23 | - } | 16 | +func (in *ActivateProjectCommand) Valid(validation *validation.Validation) { |
17 | + | ||
24 | } | 18 | } |
25 | 19 | ||
26 | func (in *CopyProjectCommand) Valid(*validation.Validation) { | 20 | func (in *CopyProjectCommand) Valid(*validation.Validation) { |
@@ -8,8 +8,8 @@ type QueryProjectCommand struct { | @@ -8,8 +8,8 @@ type QueryProjectCommand struct { | ||
8 | Name string `cname:"项目名称" json:"name"` | 8 | Name string `cname:"项目名称" json:"name"` |
9 | State int `cname:"项目状态" json:"state"` | 9 | State int `cname:"项目状态" json:"state"` |
10 | PmpIds []string `cname:"项目管理员ID" json:"pmpIds"` | 10 | PmpIds []string `cname:"项目管理员ID" json:"pmpIds"` |
11 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
12 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 11 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
12 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
13 | } | 13 | } |
14 | 14 | ||
15 | func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | 15 | func (in *QueryProjectCommand) Valid(validation *validation.Validation) { |
@@ -18,12 +18,3 @@ func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | @@ -18,12 +18,3 @@ func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | ||
18 | return | 18 | return |
19 | } | 19 | } |
20 | } | 20 | } |
21 | - | ||
22 | -type StatisticCycleProjectUserCommand struct { | ||
23 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
24 | - CycleId int64 `cname:"周期ID" json:"cycleId,string"` | ||
25 | -} | ||
26 | - | ||
27 | -func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | ||
28 | - | ||
29 | -} |
@@ -2,7 +2,6 @@ package command | @@ -2,7 +2,6 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type UpdateProjectCommand struct { | 7 | type UpdateProjectCommand struct { |
@@ -17,22 +16,25 @@ type UpdateProjectCommand struct { | @@ -17,22 +16,25 @@ type UpdateProjectCommand struct { | ||
17 | } | 16 | } |
18 | 17 | ||
19 | type UpdateProjectTemplateCommand struct { | 18 | type UpdateProjectTemplateCommand struct { |
19 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
20 | + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
21 | + Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | ||
22 | + TemplateId int64 `cname:"模板ID" json:"templateId,string"` | ||
23 | + Recipients []string `cname:"被评估人ID" json:"recipients"` | ||
24 | + TimeStart string `cname:"自评起始时间" json:"timeStart" valid:"Required"` | ||
25 | + TimeEnd string `cname:"自评截止时间" json:"timeEnd" valid:"Required"` | ||
26 | + KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"` | ||
27 | + KpiResultStart string `cname:"绩效结果开始查看时间" json:"kpiResultStart"` | ||
28 | + Activate int `cname:"启动项目" json:"activate"` | ||
29 | +} | ||
30 | + | ||
31 | +type CheckRecipientCommand struct { | ||
20 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 32 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
21 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | 33 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` |
22 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 34 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
23 | - TemplateId int64 `cname:"模板ID" json:"templateId,string"` | ||
24 | Recipients []string `cname:"被评估人ID" json:"recipients"` | 35 | Recipients []string `cname:"被评估人ID" json:"recipients"` |
25 | } | 36 | } |
26 | 37 | ||
27 | -type UpdateProjectTemplateNodeCommand struct { | ||
28 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
29 | - CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
30 | - Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | ||
31 | - TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"` | ||
32 | - LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` | ||
33 | - Activate int `cname:"启动项目" json:"activate"` | ||
34 | -} | ||
35 | - | ||
36 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { | 38 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { |
37 | if len(in.Name) > 40 { | 39 | if len(in.Name) > 40 { |
38 | validation.SetError("name", "项目名称最大长度40个字符") | 40 | validation.SetError("name", "项目名称最大长度40个字符") |
@@ -45,11 +47,13 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | @@ -45,11 +47,13 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | ||
45 | validation.SetError("recipients", "请添加被评估人") | 47 | validation.SetError("recipients", "请添加被评估人") |
46 | return | 48 | return |
47 | } | 49 | } |
48 | -} | ||
49 | - | ||
50 | -func (in *UpdateProjectTemplateNodeCommand) Valid(validation *validation.Validation) { | ||
51 | - if len(in.LinkNodes) == 0 { | ||
52 | - validation.SetError("linkNodes", "请添加评估流程") | 50 | + if len(in.TimeStart) == 0 { |
51 | + validation.SetError("timeEnd", "请选择开始时间") | ||
52 | + return | ||
53 | + } | ||
54 | + if len(in.TimeEnd) == 0 { | ||
55 | + validation.SetError("timeEnd", "请选择结束时间") | ||
53 | return | 56 | return |
54 | } | 57 | } |
58 | + | ||
55 | } | 59 | } |
@@ -8,7 +8,9 @@ import ( | @@ -8,7 +8,9 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | ||
11 | "strconv" | 12 | "strconv" |
13 | + "time" | ||
12 | ) | 14 | ) |
13 | 15 | ||
14 | type EvaluationProjectService struct { | 16 | type EvaluationProjectService struct { |
@@ -55,10 +57,19 @@ func (rs *EvaluationProjectService) Create(in *command.CreateProjectCommand) (in | @@ -55,10 +57,19 @@ func (rs *EvaluationProjectService) Create(in *command.CreateProjectCommand) (in | ||
55 | if err != nil { | 57 | if err != nil { |
56 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 58 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
57 | } | 59 | } |
60 | + | ||
61 | + projectAdapter := &adapter.EvaluationProjectAdapter{} | ||
62 | + projectAdapter.EvaluationProject = project | ||
63 | + if len(project.PmpIds) > 0 { | ||
64 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
65 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.PmpIds, "limit": len(project.PmpIds)}) | ||
66 | + projectAdapter.TransformPmpAdapter(users) | ||
67 | + } | ||
68 | + | ||
58 | if err := transactionContext.CommitTransaction(); err != nil { | 69 | if err := transactionContext.CommitTransaction(); err != nil { |
59 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 70 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
60 | } | 71 | } |
61 | - return project, nil | 72 | + return projectAdapter, nil |
62 | 73 | ||
63 | } | 74 | } |
64 | 75 | ||
@@ -96,10 +107,19 @@ func (rs *EvaluationProjectService) Update(in *command.UpdateProjectCommand) (in | @@ -96,10 +107,19 @@ func (rs *EvaluationProjectService) Update(in *command.UpdateProjectCommand) (in | ||
96 | if err != nil { | 107 | if err != nil { |
97 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 108 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
98 | } | 109 | } |
110 | + | ||
111 | + projectAdapter := &adapter.EvaluationProjectAdapter{} | ||
112 | + projectAdapter.EvaluationProject = project | ||
113 | + if len(project.PmpIds) > 0 { | ||
114 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
115 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.PmpIds, "limit": len(project.PmpIds)}) | ||
116 | + projectAdapter.TransformPmpAdapter(users) | ||
117 | + } | ||
118 | + | ||
99 | if err := transactionContext.CommitTransaction(); err != nil { | 119 | if err := transactionContext.CommitTransaction(); err != nil { |
100 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 120 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
101 | } | 121 | } |
102 | - return project, nil | 122 | + return projectAdapter, nil |
103 | } | 123 | } |
104 | 124 | ||
105 | func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemplateCommand) (interface{}, error) { | 125 | func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemplateCommand) (interface{}, error) { |
@@ -112,9 +132,15 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -112,9 +132,15 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
112 | }() | 132 | }() |
113 | 133 | ||
114 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 134 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
135 | + cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
115 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 136 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
116 | 137 | ||
117 | - _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes") | 138 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") |
139 | + if err != nil { | ||
140 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
141 | + } | ||
142 | + | ||
143 | + cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.CycleId}) | ||
118 | if err != nil { | 144 | if err != nil { |
119 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 145 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
120 | } | 146 | } |
@@ -145,48 +171,64 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -145,48 +171,64 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
145 | if err != nil { | 171 | if err != nil { |
146 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 172 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
147 | } | 173 | } |
174 | + | ||
148 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) | 175 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) |
149 | if err != nil { | 176 | if err != nil { |
150 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 177 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
151 | } | 178 | } |
152 | 179 | ||
153 | - project.Recipients = in.Recipients | ||
154 | - project.Template = cycleTemplate.Template | 180 | + if cycleTemplate == nil || cycleTemplate.Template == nil { |
181 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加模板") | ||
182 | + } | ||
155 | 183 | ||
156 | - project, err = projectRepository.Insert(project) | 184 | + if len(in.Recipients) == 0 { |
185 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | ||
186 | + } | ||
187 | + | ||
188 | + start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local) | ||
157 | if err != nil { | 189 | if err != nil { |
158 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 190 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
159 | } | 191 | } |
160 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
161 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 192 | + end, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeEnd, time.Local) |
193 | + if err != nil { | ||
194 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
162 | } | 195 | } |
163 | - return project, nil | ||
164 | -} | ||
165 | - | ||
166 | -func (rs *EvaluationProjectService) UpdateTemplateNode(in *command.UpdateProjectTemplateNodeCommand) (interface{}, error) { | ||
167 | - transactionContext, err := factory.ValidateStartTransaction(in) | 196 | + kpiStart, err := time.ParseInLocation("2006-01-02 15:04:05", in.KpiResultStart, time.Local) |
168 | if err != nil { | 197 | if err != nil { |
169 | - return nil, err | 198 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
170 | } | 199 | } |
171 | - defer func() { | ||
172 | - transactionContext.RollbackTransaction() | ||
173 | - }() | ||
174 | 200 | ||
175 | - projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 201 | + minTime := cycle.TimeStart.Local() |
202 | + maxTime := cycle.TimeEnd.Local() | ||
176 | 203 | ||
177 | - project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
178 | - if err != nil { | ||
179 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 204 | + if start.Before(minTime) { |
205 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间") | ||
180 | } | 206 | } |
181 | 207 | ||
182 | - // FIXME 启动时,需要激活定时任务 | ||
183 | - if in.Activate == 1 { | ||
184 | - project.State = domain.ProjectStateEnable | 208 | + if end.After(maxTime) { |
209 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间") | ||
185 | } | 210 | } |
186 | - for i := range in.LinkNodes { | ||
187 | - project.Template.LinkNodes[i].TimeStart = in.LinkNodes[i].TimeStart | ||
188 | - project.Template.LinkNodes[i].TimeEnd = in.LinkNodes[i].TimeEnd | ||
189 | - project.Template.LinkNodes[i].KpiCycle = in.LinkNodes[i].KpiCycle | 211 | + |
212 | + //// FIXME 启动时,需要激活定时任务 | ||
213 | + //if in.Activate == 1 { | ||
214 | + // project.State = domain.ProjectStateEnable | ||
215 | + //} else { | ||
216 | + // project.State = domain.ProjectStateWaitActive | ||
217 | + //} | ||
218 | + project.State = domain.ProjectStateWaitActive | ||
219 | + | ||
220 | + project.Recipients = in.Recipients | ||
221 | + project.Template = cycleTemplate.Template | ||
222 | + for i := range project.Template.LinkNodes { | ||
223 | + node := project.Template.LinkNodes[i] | ||
224 | + node.KpiCycle = in.KpiCycle // 设置周期 | ||
225 | + if node.Type == domain.LinkNodeViewResult { | ||
226 | + node.TimeStart = &kpiStart | ||
227 | + node.TimeEnd = &maxTime // 绩效查看时间跟随周期截止时间 | ||
228 | + } else { | ||
229 | + node.TimeStart = &start | ||
230 | + node.TimeEnd = &end | ||
231 | + } | ||
190 | } | 232 | } |
191 | 233 | ||
192 | project, err = projectRepository.Insert(project) | 234 | project, err = projectRepository.Insert(project) |
@@ -268,7 +310,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -268,7 +310,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
268 | }() | 310 | }() |
269 | 311 | ||
270 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 312 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
271 | - total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 313 | + total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "template") |
272 | if err != nil { | 314 | if err != nil { |
273 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 315 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
274 | } | 316 | } |
@@ -290,7 +332,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -290,7 +332,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
290 | return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil | 332 | return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil |
291 | } | 333 | } |
292 | 334 | ||
293 | -func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (interface{}, error) { | 335 | +func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) (interface{}, error) { |
294 | transactionContext, err := factory.ValidateStartTransaction(in) | 336 | transactionContext, err := factory.ValidateStartTransaction(in) |
295 | if err != nil { | 337 | if err != nil { |
296 | return nil, err | 338 | return nil, err |
@@ -300,23 +342,122 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | @@ -300,23 +342,122 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | ||
300 | }() | 342 | }() |
301 | 343 | ||
302 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 344 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
345 | + //cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
303 | 346 | ||
304 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | 347 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) |
305 | if err != nil { | 348 | if err != nil { |
306 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 349 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
307 | } | 350 | } |
308 | 351 | ||
309 | - project.State = in.State | 352 | + if project.Template == nil { |
353 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加评估模板") | ||
354 | + } | ||
355 | + | ||
356 | + if len(project.Recipients) == 0 { | ||
357 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | ||
358 | + } | ||
359 | + if project.State == domain.TemplateStateEnable { | ||
360 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动") | ||
361 | + } | ||
362 | + //cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": project.CycleId}) | ||
363 | + //if err != nil { | ||
364 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
365 | + //} | ||
366 | + //startMin := cycle.TimeStart | ||
367 | + //maxTime := cycle.TimeEnd | ||
368 | + | ||
369 | + project.State = domain.TemplateStateEnable | ||
310 | project, err = projectRepository.Insert(project) | 370 | project, err = projectRepository.Insert(project) |
311 | if err != nil { | 371 | if err != nil { |
312 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 372 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
313 | } | 373 | } |
374 | + | ||
375 | + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
376 | + | ||
377 | + now := time.Now().Local() | ||
378 | + nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | ||
379 | + | ||
380 | + for i := range project.Template.LinkNodes { | ||
381 | + node := project.Template.LinkNodes[i] | ||
382 | + task := &domain.NodeTask{ | ||
383 | + Id: 0, | ||
384 | + CompanyId: project.CompanyId, | ||
385 | + CycleId: project.CycleId, | ||
386 | + ProjectId: project.Id, | ||
387 | + NodeId: node.Id, | ||
388 | + NodeType: node.Type, | ||
389 | + NodeName: node.Name, | ||
390 | + NodeDescribe: node.Describe, | ||
391 | + NodeSort: i + 1, | ||
392 | + TimeStart: node.TimeStart, | ||
393 | + TimeEnd: node.TimeEnd, | ||
394 | + KpiCycle: node.KpiCycle, | ||
395 | + } | ||
396 | + | ||
397 | + // 环节起始和截止本地时间 | ||
398 | + startLocal := node.TimeStart.Local() | ||
399 | + endLocal := node.TimeEnd.Local() | ||
400 | + | ||
401 | + // 在当前时间之前,则计算下一个周期时间 | ||
402 | + if startLocal.Before(now) { | ||
403 | + nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle) | ||
404 | + task.NextSentAt = &nextTime | ||
405 | + } else { | ||
406 | + task.NextSentAt = &startLocal | ||
407 | + } | ||
408 | + // 如果超出截至时间,则周期置空 | ||
409 | + if task.NextSentAt.After(endLocal) { | ||
410 | + task.NextSentAt = nil | ||
411 | + } | ||
412 | + | ||
413 | + task, err := taskRepository.Insert(task) | ||
414 | + if err != nil { | ||
415 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
416 | + } | ||
417 | + } | ||
418 | + | ||
314 | if err := transactionContext.CommitTransaction(); err != nil { | 419 | if err := transactionContext.CommitTransaction(); err != nil { |
315 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 420 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
316 | } | 421 | } |
317 | return project, nil | 422 | return project, nil |
318 | } | 423 | } |
319 | 424 | ||
425 | +// | ||
426 | +//// 0点时刻为标准计算 | ||
427 | +//func (rs *EvaluationProjectService) nextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time { | ||
428 | +// // 起始时间0点时刻 | ||
429 | +// start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local) | ||
430 | +// | ||
431 | +// var nextTime time.Time | ||
432 | +// switch kpiCycle { | ||
433 | +// case domain.KpiCycleDay: | ||
434 | +// nextTime = timeconv.AddDate(now0, 0, 0, 1) // 当前时间的下一天开始发送 | ||
435 | +// break | ||
436 | +// case domain.KpiCycleWeek: | ||
437 | +// offsetSeconds := int64(now0.Sub(start0).Seconds()) | ||
438 | +// offsetDay := offsetSeconds / (24 * 60 * 60) | ||
439 | +// cycleCount := int(offsetDay)/7 + 1 | ||
440 | +// nextTime = timeconv.AddDate(start0, 0, 0, cycleCount*7) | ||
441 | +// break | ||
442 | +// case domain.KpiCycleOneMonth: | ||
443 | +// nextTime = timeconv.AddDate(start0, 0, 1, 0) | ||
444 | +// break | ||
445 | +// case domain.KpiCycleTwoMonth: | ||
446 | +// nextTime = timeconv.AddDate(start0, 0, 2, 0) | ||
447 | +// break | ||
448 | +// case domain.KpiCycleThreeMonth: | ||
449 | +// nextTime = timeconv.AddDate(start0, 0, 3, 0) | ||
450 | +// break | ||
451 | +// case domain.KpiCycleSixMonth: | ||
452 | +// nextTime = timeconv.AddDate(start0, 0, 6, 0) | ||
453 | +// break | ||
454 | +// case domain.KpiCycleYear: | ||
455 | +// nextTime = timeconv.AddDate(start0, 1, 0, 0) | ||
456 | +// break | ||
457 | +// } | ||
458 | +// return nextTime | ||
459 | +//} | ||
460 | + | ||
320 | func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) { | 461 | func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) { |
321 | transactionContext, err := factory.ValidateStartTransaction(in) | 462 | transactionContext, err := factory.ValidateStartTransaction(in) |
322 | if err != nil { | 463 | if err != nil { |
@@ -332,6 +473,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -332,6 +473,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
332 | } | 473 | } |
333 | // ID重置 | 474 | // ID重置 |
334 | project.Id = 0 | 475 | project.Id = 0 |
476 | + project.Name = project.Name + " 副本" | ||
477 | + project.CreatorId = in.CreatorId | ||
478 | + project.Recipients = make([]string, 0) // 重置被评估人 | ||
479 | + | ||
335 | // 如果拷贝已经启用的模板,默认先设置为待启用 | 480 | // 如果拷贝已经启用的模板,默认先设置为待启用 |
336 | if project.State == domain.ProjectStateEnable { | 481 | if project.State == domain.ProjectStateEnable { |
337 | project.State = domain.ProjectStateWaitActive | 482 | project.State = domain.ProjectStateWaitActive |
@@ -346,7 +491,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -346,7 +491,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
346 | return project, nil | 491 | return project, nil |
347 | } | 492 | } |
348 | 493 | ||
349 | -func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | 494 | +func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCommand) (interface{}, error) { |
350 | transactionContext, err := factory.ValidateStartTransaction(in) | 495 | transactionContext, err := factory.ValidateStartTransaction(in) |
351 | if err != nil { | 496 | if err != nil { |
352 | return nil, err | 497 | return nil, err |
@@ -354,42 +499,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | @@ -354,42 +499,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | ||
354 | defer func() { | 499 | defer func() { |
355 | transactionContext.RollbackTransaction() | 500 | transactionContext.RollbackTransaction() |
356 | }() | 501 | }() |
502 | + | ||
357 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 503 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
358 | - _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 504 | + |
505 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template") | ||
359 | if err != nil { | 506 | if err != nil { |
360 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 507 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
361 | } | 508 | } |
362 | 509 | ||
363 | - userIds := make([]int64, 0) | ||
364 | - userIdMap := map[int64]int64{} | 510 | + // 周期内的所有项目,员工不能重复被评估 |
511 | + rids := map[string]bool{} | ||
365 | for i := range projects { | 512 | for i := range projects { |
366 | - project := projects[i] | ||
367 | - for j := range project.Recipients { | ||
368 | - userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
369 | - userIdMap[userId] = userId | 513 | + // 排除当前项目 |
514 | + if in.Id != projects[i].Id { | ||
515 | + ids := projects[i].Recipients | ||
516 | + for j := range ids { | ||
517 | + rids[ids[j]] = true | ||
518 | + } | ||
370 | } | 519 | } |
371 | } | 520 | } |
372 | - for _, v := range userIdMap { | ||
373 | - userIds = append(userIds, v) | ||
374 | - } | ||
375 | - | ||
376 | - userTotal := 0 | ||
377 | - departmentTotal := 0 | ||
378 | - if len(userIds) > 0 { | ||
379 | - userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
380 | - _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
381 | - departmentIdMap := map[int]int{} | ||
382 | - for i := range users { | ||
383 | - for _, v := range users[i].DepartmentId { | ||
384 | - departmentIdMap[v] = v | ||
385 | - } | 521 | + repeatNum := 0 |
522 | + for i := range in.Recipients { | ||
523 | + id := in.Recipients[i] | ||
524 | + if _, ok := rids[id]; ok { | ||
525 | + repeatNum++ | ||
386 | } | 526 | } |
387 | - userTotal = len(users) | ||
388 | - departmentTotal = len(departmentIdMap) | ||
389 | } | 527 | } |
528 | + //if repeatNum > 0 { | ||
529 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum)) | ||
530 | + //} | ||
390 | 531 | ||
532 | + if err != nil { | ||
533 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
534 | + } | ||
391 | if err := transactionContext.CommitTransaction(); err != nil { | 535 | if err := transactionContext.CommitTransaction(); err != nil { |
392 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 536 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
393 | } | 537 | } |
394 | - return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | 538 | + return map[string]interface{}{"repeatNum": repeatNum}, nil |
395 | } | 539 | } |
@@ -8,3 +8,8 @@ type RuleAdapter struct { | @@ -8,3 +8,8 @@ type RuleAdapter struct { | ||
8 | *domain.EvaluationRule | 8 | *domain.EvaluationRule |
9 | CreatorName string `json:"creatorName" comment:"创建人名称"` | 9 | CreatorName string `json:"creatorName" comment:"创建人名称"` |
10 | } | 10 | } |
11 | + | ||
12 | +type CreatorAdapter struct { | ||
13 | + Id int64 `json:"id,string" comment:"创建人ID"` | ||
14 | + Name string `json:"name" comment:"创建人名称"` | ||
15 | +} |
@@ -7,8 +7,12 @@ type QueryRuleCommand struct { | @@ -7,8 +7,12 @@ type QueryRuleCommand struct { | ||
7 | NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"` | 7 | NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"` |
8 | Type int `cname:"评估方式(0评级、1评分)" json:"type"` | 8 | Type int `cname:"评估方式(0评级、1评分)" json:"type"` |
9 | CreatorId int64 `cname:"创建人ID" json:"creatorId,string"` | 9 | CreatorId int64 `cname:"创建人ID" json:"creatorId,string"` |
10 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
11 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 10 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
11 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
12 | +} | ||
13 | + | ||
14 | +type QueryCreatorCommand struct { | ||
15 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
12 | } | 16 | } |
13 | 17 | ||
14 | func (in *QueryRuleCommand) Valid(validation *validation.Validation) { | 18 | func (in *QueryRuleCommand) Valid(validation *validation.Validation) { |
@@ -17,3 +21,10 @@ func (in *QueryRuleCommand) Valid(validation *validation.Validation) { | @@ -17,3 +21,10 @@ func (in *QueryRuleCommand) Valid(validation *validation.Validation) { | ||
17 | return | 21 | return |
18 | } | 22 | } |
19 | } | 23 | } |
24 | + | ||
25 | +func (in *QueryCreatorCommand) Valid(validation *validation.Validation) { | ||
26 | + if in.CompanyId == 0 { | ||
27 | + validation.SetError("companyId", "公司ID无效") | ||
28 | + return | ||
29 | + } | ||
30 | +} |
@@ -8,7 +8,6 @@ import ( | @@ -8,7 +8,6 @@ import ( | ||
8 | type UpdateRuleCommand struct { | 8 | type UpdateRuleCommand struct { |
9 | Id int64 `cname:"规则ID" json:"id,string" valid:"Required"` | 9 | Id int64 `cname:"规则ID" json:"id,string" valid:"Required"` |
10 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 10 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
11 | - CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
12 | Name string `cname:"规则名称" json:"name" valid:"Required"` | 11 | Name string `cname:"规则名称" json:"name" valid:"Required"` |
13 | Remark string `cname:"规则备注" json:"remark"` | 12 | Remark string `cname:"规则备注" json:"remark"` |
14 | Type int `cname:"评估方式" json:"type"` | 13 | Type int `cname:"评估方式" json:"type"` |
@@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | @@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | ||
21 | validation.SetError("companyId", "公司ID无效") | 20 | validation.SetError("companyId", "公司ID无效") |
22 | return | 21 | return |
23 | } | 22 | } |
24 | - if in.CreatorId == 0 { | ||
25 | - validation.SetError("creatorId", "创建人ID无效") | ||
26 | - return | ||
27 | - } | ||
28 | 23 | ||
29 | if len(in.Name) > 40 { | 24 | if len(in.Name) > 40 { |
30 | validation.SetError("name", "名称最大长度40个字符") | 25 | validation.SetError("name", "名称最大长度40个字符") |
@@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | @@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | ||
35 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 35 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
36 | } | 36 | } |
37 | if count > 0 { | 37 | if count > 0 { |
38 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 38 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则") |
39 | } | 39 | } |
40 | 40 | ||
41 | if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 | 41 | if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 |
@@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac | @@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac | ||
82 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 82 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
83 | } | 83 | } |
84 | if count > 0 { | 84 | if count > 0 { |
85 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 85 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则") |
86 | } | 86 | } |
87 | 87 | ||
88 | rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id}) | 88 | rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id}) |
@@ -212,3 +212,40 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -212,3 +212,40 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
212 | } | 212 | } |
213 | return tool_funs.SimpleWrapGridMap(total, ras), nil | 213 | return tool_funs.SimpleWrapGridMap(total, ras), nil |
214 | } | 214 | } |
215 | + | ||
216 | +func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (interface{}, error) { | ||
217 | + transactionContext, err := factory.StartTransaction() | ||
218 | + if err != nil { | ||
219 | + return nil, err | ||
220 | + } | ||
221 | + defer func() { | ||
222 | + transactionContext.RollbackTransaction() | ||
223 | + }() | ||
224 | + ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
225 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
226 | + | ||
227 | + _, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) | ||
228 | + if err != nil { | ||
229 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
230 | + } | ||
231 | + | ||
232 | + // 获取所有创建人ID | ||
233 | + creatorMap := map[int64]int64{} | ||
234 | + for i := range rules { | ||
235 | + creatorMap[rules[i].CreatorId] = rules[i].CreatorId | ||
236 | + } | ||
237 | + creatorIds := make([]int64, 0) | ||
238 | + for k := range creatorMap { | ||
239 | + creatorIds = append(creatorIds, k) | ||
240 | + } | ||
241 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)}) | ||
242 | + cas := make([]*adapter.CreatorAdapter, 0) | ||
243 | + for i := range users { | ||
244 | + ca := &adapter.CreatorAdapter{ | ||
245 | + Id: users[i].Id, | ||
246 | + Name: users[i].Name, | ||
247 | + } | ||
248 | + cas = append(cas, ca) | ||
249 | + } | ||
250 | + return map[string]interface{}{"list": cas}, nil | ||
251 | +} |
@@ -2,16 +2,15 @@ package command | @@ -2,16 +2,15 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
5 | - "time" | ||
6 | ) | 5 | ) |
7 | 6 | ||
8 | type QueryTemplateCommand struct { | 7 | type QueryTemplateCommand struct { |
9 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
10 | - Name string `cname:"模板名称" json:"name"` | ||
11 | - State int `cname:"模板状态" json:"state"` | ||
12 | - CreatedAt *time.Time `cname:"创建时间" json:"createdAt"` | ||
13 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
14 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 8 | + CompanyId int64 `cname:"公司ID" json:"companyId"` |
9 | + Name string `cname:"模板名称" json:"name"` | ||
10 | + State int `cname:"模板状态" json:"state"` | ||
11 | + CreatedAt string `cname:"创建时间" json:"createdAt"` | ||
12 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
13 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
15 | } | 14 | } |
16 | 15 | ||
17 | func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | 16 | func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { |
@@ -20,15 +19,3 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | @@ -20,15 +19,3 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | ||
20 | return | 19 | return |
21 | } | 20 | } |
22 | } | 21 | } |
23 | - | ||
24 | -//// AllEnableTemplateCommand 查询所有已启用的模板 | ||
25 | -//type AllEnableTemplateCommand struct { | ||
26 | -// CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
27 | -//} | ||
28 | -// | ||
29 | -//func (in *AllEnableTemplateCommand) Valid(validation *validation.Validation) { | ||
30 | -// if in.CompanyId == 0 { | ||
31 | -// validation.SetError("companyId", "公司ID无效") | ||
32 | -// return | ||
33 | -// } | ||
34 | -//} |
@@ -6,11 +6,12 @@ import ( | @@ -6,11 +6,12 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type UpdateTemplateCommand struct { | 8 | type UpdateTemplateCommand struct { |
9 | - Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | ||
10 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
11 | - Name string `cname:"模板名称" json:"name" valid:"Required"` | ||
12 | - Describe string `cname:"模板描述" json:"describe"` | ||
13 | - LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` | 9 | + Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` |
10 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
11 | + Name string `cname:"模板名称" json:"name" valid:"Required"` | ||
12 | + Describe string `cname:"模板描述" json:"describe"` | ||
13 | + LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` | ||
14 | + FinishConfig int `cname:"配置" json:"finishConfig"` | ||
14 | } | 15 | } |
15 | 16 | ||
16 | func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | 17 | func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { |
@@ -34,41 +34,46 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( | @@ -34,41 +34,46 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( | ||
34 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 34 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
35 | } | 35 | } |
36 | if count > 0 { | 36 | if count > 0 { |
37 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 37 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估模板") |
38 | } | 38 | } |
39 | 39 | ||
40 | linkNodes := make([]*domain.LinkNode, 0) | 40 | linkNodes := make([]*domain.LinkNode, 0) |
41 | 41 | ||
42 | sid, _ := utils.NewSnowflakeId() | 42 | sid, _ := utils.NewSnowflakeId() |
43 | linkNodes = append(linkNodes, &domain.LinkNode{ | 43 | linkNodes = append(linkNodes, &domain.LinkNode{ |
44 | - Id: sid + 1, | ||
45 | - Type: domain.LinkNodeSelfAssessment, | ||
46 | - Name: "填写自评反馈", | ||
47 | - KpiCycle: domain.KpiCycleDay, | 44 | + Id: sid + 1, |
45 | + Type: domain.LinkNodeSelfAssessment, | ||
46 | + Name: "填写自评反馈", | ||
47 | + NodeContents: make([]*domain.NodeContent, 0), | ||
48 | + KpiCycle: domain.KpiCycleDay, | ||
48 | }) | 49 | }) |
49 | linkNodes = append(linkNodes, &domain.LinkNode{ | 50 | linkNodes = append(linkNodes, &domain.LinkNode{ |
50 | - Id: sid + 2, | ||
51 | - Type: domain.LinkNodeAllInvite, | ||
52 | - Name: "360°邀请", | ||
53 | - KpiCycle: domain.KpiCycleDay, | 51 | + Id: sid + 2, |
52 | + Type: domain.LinkNodeAllInvite, | ||
53 | + Name: "360°邀请", | ||
54 | + NodeContents: make([]*domain.NodeContent, 0), | ||
55 | + KpiCycle: domain.KpiCycleDay, | ||
54 | }) | 56 | }) |
55 | linkNodes = append(linkNodes, &domain.LinkNode{ | 57 | linkNodes = append(linkNodes, &domain.LinkNode{ |
56 | - Id: sid + 3, | ||
57 | - Type: domain.LinkNodeAllAssessment, | ||
58 | - Name: "360°评估", | ||
59 | - KpiCycle: domain.KpiCycleDay, | 58 | + Id: sid + 3, |
59 | + Type: domain.LinkNodeAllAssessment, | ||
60 | + Name: "360°评估", | ||
61 | + NodeContents: make([]*domain.NodeContent, 0), | ||
62 | + KpiCycle: domain.KpiCycleDay, | ||
60 | }) | 63 | }) |
61 | linkNodes = append(linkNodes, &domain.LinkNode{ | 64 | linkNodes = append(linkNodes, &domain.LinkNode{ |
62 | - Id: sid + 4, | ||
63 | - Type: domain.LinkNodeSuperiorAssessment, | ||
64 | - Name: "上级评估", | ||
65 | - KpiCycle: domain.KpiCycleDay, | 65 | + Id: sid + 4, |
66 | + Type: domain.LinkNodeSuperiorAssessment, | ||
67 | + Name: "上级评估", | ||
68 | + NodeContents: make([]*domain.NodeContent, 0), | ||
69 | + KpiCycle: domain.KpiCycleDay, | ||
66 | }) | 70 | }) |
67 | linkNodes = append(linkNodes, &domain.LinkNode{ | 71 | linkNodes = append(linkNodes, &domain.LinkNode{ |
68 | - Id: sid + 5, | ||
69 | - Type: domain.LinkNodeViewResult, | ||
70 | - Name: "绩效结果查看", | ||
71 | - KpiCycle: domain.KpiCycleDay, | 72 | + Id: sid + 5, |
73 | + Type: domain.LinkNodeViewResult, | ||
74 | + Name: "绩效结果查看", | ||
75 | + NodeContents: make([]*domain.NodeContent, 0), | ||
76 | + KpiCycle: domain.KpiCycleDay, | ||
72 | }) | 77 | }) |
73 | 78 | ||
74 | newTemplate := &domain.EvaluationTemplate{ | 79 | newTemplate := &domain.EvaluationTemplate{ |
@@ -120,6 +125,11 @@ func (rs *EvaluationTemplateService) Update(in *command.UpdateTemplateCommand) ( | @@ -120,6 +125,11 @@ func (rs *EvaluationTemplateService) Update(in *command.UpdateTemplateCommand) ( | ||
120 | template.Describe = in.Describe | 125 | template.Describe = in.Describe |
121 | template.LinkNodes = in.LinkNodes | 126 | template.LinkNodes = in.LinkNodes |
122 | 127 | ||
128 | + // 完成配置保存,更新状态 | ||
129 | + if in.FinishConfig == 1 && template.State == domain.TemplateStateWaitConfig { | ||
130 | + template.State = domain.TemplateStateWaitActive | ||
131 | + } | ||
132 | + | ||
123 | template, err = templateRepository.Insert(template) | 133 | template, err = templateRepository.Insert(template) |
124 | if err != nil { | 134 | if err != nil { |
125 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 135 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -183,8 +193,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | @@ -183,8 +193,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | ||
183 | defer func() { | 193 | defer func() { |
184 | transactionContext.RollbackTransaction() | 194 | transactionContext.RollbackTransaction() |
185 | }() | 195 | }() |
196 | + | ||
197 | + queryOptions := tool_funs.SimpleStructToMap(in) | ||
198 | + if len(in.CreatedAt) == 0 { | ||
199 | + delete(queryOptions, "createdAt") // 删除创建时间 | ||
200 | + } | ||
201 | + | ||
186 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 202 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
187 | - total, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 203 | + total, templates, err := templateRepository.Find(queryOptions, "link_nodes") |
188 | if err != nil { | 204 | if err != nil { |
189 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 205 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
190 | } | 206 | } |
@@ -129,6 +129,14 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev | @@ -129,6 +129,14 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev | ||
129 | return repository.NewEvaluationProjectRepository(transactionContext) | 129 | return repository.NewEvaluationProjectRepository(transactionContext) |
130 | } | 130 | } |
131 | 131 | ||
132 | +func CreateNodeTaskRepository(options map[string]interface{}) domain.NodeTaskRepository { | ||
133 | + var transactionContext *pg.TransactionContext | ||
134 | + if value, ok := options["transactionContext"]; ok { | ||
135 | + transactionContext = value.(*pg.TransactionContext) | ||
136 | + } | ||
137 | + return repository.NewNodeTaskRepository(transactionContext) | ||
138 | +} | ||
139 | + | ||
132 | func CreateStaffAssessRepository(options map[string]interface{}) domain.StaffAssessRepository { | 140 | func CreateStaffAssessRepository(options map[string]interface{}) domain.StaffAssessRepository { |
133 | var transactionContext *pg.TransactionContext | 141 | var transactionContext *pg.TransactionContext |
134 | if value, ok := options["transactionContext"]; ok { | 142 | if value, ok := options["transactionContext"]; ok { |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
6 | + "strconv" | ||
7 | + "time" | ||
8 | + | ||
9 | + "github.com/linmadan/egglib-go/core/application" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | ||
15 | +) | ||
16 | + | ||
17 | +type NodeTaskService struct { | ||
18 | +} | ||
19 | + | ||
20 | +func NewNodeTaskService() *NodeTaskService { | ||
21 | + newRoleService := &NodeTaskService{} | ||
22 | + return newRoleService | ||
23 | +} | ||
24 | + | ||
25 | +// SendEvaluationNode 发送评估环节 | ||
26 | +func (rs *NodeTaskService) SendEvaluationNode() error { | ||
27 | + transactionContext, err := factory.StartTransaction() | ||
28 | + if err != nil { | ||
29 | + return err | ||
30 | + } | ||
31 | + defer func() { | ||
32 | + transactionContext.RollbackTransaction() | ||
33 | + | ||
34 | + if err := recover(); err != nil { | ||
35 | + log.Logger.Error(application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("定时发送评估任务异常:%s", err)).Error()) | ||
36 | + } | ||
37 | + }() | ||
38 | + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
39 | + tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()}) | ||
40 | + if err != nil { | ||
41 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
42 | + } | ||
43 | + if len(tasks) == 0 { | ||
44 | + return nil | ||
45 | + } | ||
46 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
47 | + cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
48 | + | ||
49 | + projectIdsMap := map[int64]*domain.EvaluationProject{} | ||
50 | + cycleIdsMap := map[int64]*domain.EvaluationCycle{} | ||
51 | + for i := range tasks { | ||
52 | + task := tasks[i] | ||
53 | + projectIdsMap[task.ProjectId] = nil | ||
54 | + cycleIdsMap[task.CycleId] = nil | ||
55 | + } | ||
56 | + projectIds := make([]int64, 0) | ||
57 | + cycleIds := make([]int64, 0) | ||
58 | + for k := range projectIdsMap { | ||
59 | + projectIds = append(projectIds, k) | ||
60 | + } | ||
61 | + for k := range cycleIdsMap { | ||
62 | + cycleIds = append(cycleIds, k) | ||
63 | + } | ||
64 | + | ||
65 | + _, projects, err := projectRepository.Find(map[string]interface{}{"ids": projectIds}, "template") | ||
66 | + if err != nil { | ||
67 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
68 | + } | ||
69 | + _, cycles, err := cycleRepository.Find(map[string]interface{}{"ids": cycleIds}) | ||
70 | + if err != nil { | ||
71 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
72 | + } | ||
73 | + | ||
74 | + for i := range projects { | ||
75 | + projectIdsMap[projects[i].Id] = projects[i] | ||
76 | + } | ||
77 | + for i := range cycles { | ||
78 | + cycleIdsMap[cycles[i].Id] = cycles[i] | ||
79 | + } | ||
80 | + | ||
81 | + staffAssessService := service.NewStaffAssessServeice() | ||
82 | + for i := range tasks { | ||
83 | + task := tasks[i] | ||
84 | + project, ok := projectIdsMap[task.ProjectId] // 项目 | ||
85 | + if ok && project != nil { | ||
86 | + // 环节截止时间 | ||
87 | + maxTime := task.TimeEnd.Local() | ||
88 | + | ||
89 | + // 当前周起始时间和截止时间 | ||
90 | + var cycleTimeStart = task.NextSentAt.Local() | ||
91 | + var cycleTimeEnd time.Time | ||
92 | + | ||
93 | + // 下个周期起始时间 | ||
94 | + nextTime := utils.NextTimeInc(cycleTimeStart, task.KpiCycle) | ||
95 | + // 超过截止时间 | ||
96 | + if nextTime.After(maxTime) { | ||
97 | + task.NextSentAt = nil | ||
98 | + } else { | ||
99 | + task.NextSentAt = &nextTime | ||
100 | + } | ||
101 | + | ||
102 | + // 下个周期的起始时间=当前周期的截止时间 | ||
103 | + if task.NextSentAt == nil { | ||
104 | + cycleTimeEnd = maxTime | ||
105 | + } else { | ||
106 | + cycleTimeEnd = task.NextSentAt.Local() | ||
107 | + } | ||
108 | + | ||
109 | + // 格式化周期的起始和截止时间 | ||
110 | + fmCycleStartTime := cycleTimeStart.Format("2006-1-2 15:04:05") | ||
111 | + fmCycleTimeEnd := cycleTimeEnd.Format("2006-1-2 15:04:05") | ||
112 | + | ||
113 | + csat := &command.CreateStaffAssessTask{ | ||
114 | + CompanyId: int(project.CompanyId), | ||
115 | + EvaluationProjectId: int(project.Id), | ||
116 | + EvaluationProjectName: project.Name, | ||
117 | + CycleId: project.CycleId, | ||
118 | + StepList: make([]command.AssessTaskStep, 0), | ||
119 | + } | ||
120 | + | ||
121 | + // 周期名称 | ||
122 | + if cycle, ok := cycleIdsMap[project.CycleId]; ok { | ||
123 | + csat.CycleName = cycle.Name | ||
124 | + } | ||
125 | + | ||
126 | + // 接收人 | ||
127 | + csat.ExecutorId = make([]int, 0) | ||
128 | + for rIndex := range project.Recipients { | ||
129 | + vInt, _ := strconv.Atoi(project.Recipients[rIndex]) | ||
130 | + csat.ExecutorId = append(csat.ExecutorId, vInt) | ||
131 | + } | ||
132 | + | ||
133 | + csat.BeginTime = fmCycleStartTime | ||
134 | + csat.EndTime = fmCycleTimeEnd | ||
135 | + csat.StepList = append(csat.StepList, command.AssessTaskStep{ | ||
136 | + SortBy: task.NodeSort, | ||
137 | + LinkNodeId: int(task.NodeId), | ||
138 | + LinkNodeName: task.NodeName, | ||
139 | + LinkNodeType: task.NodeType, | ||
140 | + BeginTime: fmCycleStartTime, | ||
141 | + EndTime: fmCycleTimeEnd, | ||
142 | + }) | ||
143 | + | ||
144 | + // 创建发送任务 | ||
145 | + _, err := staffAssessService.CreateStaffAssessTask(transactionContext, csat) | ||
146 | + if err != nil { | ||
147 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
148 | + } | ||
149 | + } else { | ||
150 | + task.NextSentAt = nil // 项目不存在,取消周期任务发送 | ||
151 | + } | ||
152 | + | ||
153 | + task, err := taskRepository.Insert(task) | ||
154 | + if err != nil { | ||
155 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
156 | + } | ||
157 | + } | ||
158 | + | ||
159 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
160 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
161 | + } | ||
162 | + | ||
163 | + return nil | ||
164 | + | ||
165 | +} |
@@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | @@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | ||
5 | // QueryRoleUserCommand 查询角色列表(关联用户) | 5 | // QueryRoleUserCommand 查询角色列表(关联用户) |
6 | type QueryRoleUserCommand struct { | 6 | type QueryRoleUserCommand struct { |
7 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 7 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
8 | - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
9 | - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 8 | + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"` |
9 | + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
10 | } | 10 | } |
11 | 11 | ||
12 | func (in *QueryRoleUserCommand) Valid(validation *validation.Validation) { | 12 | func (in *QueryRoleUserCommand) Valid(validation *validation.Validation) { |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/adapter" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/adapter" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type RoleService struct { | 12 | type RoleService struct { |
@@ -91,47 +92,53 @@ func NewRoleService() *RoleService { | @@ -91,47 +92,53 @@ func NewRoleService() *RoleService { | ||
91 | // return role, nil | 92 | // return role, nil |
92 | //} | 93 | //} |
93 | // | 94 | // |
94 | -//func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error) { | ||
95 | -// transactionContext, err := factory.ValidateStartTransaction(in) | ||
96 | -// if err != nil { | ||
97 | -// return nil, err | ||
98 | -// } | ||
99 | -// defer func() { | ||
100 | -// transactionContext.RollbackTransaction() | ||
101 | -// }() | ||
102 | -// | ||
103 | -// roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
104 | -// roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
105 | -// | ||
106 | -// role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
107 | -// if err != nil { | ||
108 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
109 | -// } | ||
110 | -// if _, err := roleRepository.Remove(role); err != nil { | ||
111 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
112 | -// } | ||
113 | -// | ||
114 | -// // 获取角色所有关联的用户,并删除 | ||
115 | -// _, roleUsers, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.Id, "companyId": in.CompanyId}) | ||
116 | -// if err != nil { | ||
117 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
118 | -// } | ||
119 | -// ids := make([]int64, 0) | ||
120 | -// for i := range roleUsers { | ||
121 | -// ids = append(ids, roleUsers[i].Id) | ||
122 | -// } | ||
123 | -// if len(ids) > 0 { | ||
124 | -// err := roleUserRepository.BatchDeleteById(ids) | ||
125 | -// if err != nil { | ||
126 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
127 | -// } | ||
128 | -// } | ||
129 | -// | ||
130 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
131 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
132 | -// } | ||
133 | -// return role, nil | ||
134 | -//} | 95 | + |
96 | +func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error) { | ||
97 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
98 | + if err != nil { | ||
99 | + return nil, err | ||
100 | + } | ||
101 | + defer func() { | ||
102 | + transactionContext.RollbackTransaction() | ||
103 | + }() | ||
104 | + | ||
105 | + roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
106 | + roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
107 | + | ||
108 | + role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
109 | + if err != nil { | ||
110 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
111 | + } | ||
112 | + | ||
113 | + if role.Type == domain.RoleTypeSystem { | ||
114 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除") | ||
115 | + } | ||
116 | + | ||
117 | + if _, err := roleRepository.Remove(role); err != nil { | ||
118 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
119 | + } | ||
120 | + | ||
121 | + // 获取角色所有关联的用户,并删除 | ||
122 | + _, roleUsers, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.Id, "companyId": in.CompanyId}) | ||
123 | + if err != nil { | ||
124 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
125 | + } | ||
126 | + ids := make([]int64, 0) | ||
127 | + for i := range roleUsers { | ||
128 | + ids = append(ids, roleUsers[i].Id) | ||
129 | + } | ||
130 | + if len(ids) > 0 { | ||
131 | + err := roleUserRepository.BatchDeleteById(ids) | ||
132 | + if err != nil { | ||
133 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
134 | + } | ||
135 | + } | ||
136 | + | ||
137 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
138 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
139 | + } | ||
140 | + return role, nil | ||
141 | +} | ||
135 | 142 | ||
136 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { | 143 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { |
137 | transactionContext, err := factory.StartTransaction() | 144 | transactionContext, err := factory.StartTransaction() |
@@ -150,11 +157,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -150,11 +157,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
150 | if err != nil { | 157 | if err != nil { |
151 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 158 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
152 | } | 159 | } |
153 | - if len(roles) == 0 { | ||
154 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到角色数据") | ||
155 | - } | ||
156 | 160 | ||
157 | adapterList := make([]*adapter.RoleUserAdapter, 0) | 161 | adapterList := make([]*adapter.RoleUserAdapter, 0) |
162 | + | ||
163 | + // 如果不存在系统预支hrbp角色时,插入一条数据 | ||
164 | + var havaSystemType = false | ||
165 | + for i := range roles { | ||
166 | + if roles[i].Type == domain.RoleTypeSystem { | ||
167 | + havaSystemType = true | ||
168 | + break | ||
169 | + } | ||
170 | + } | ||
171 | + if !havaSystemType { | ||
172 | + role := &domain.Role{ | ||
173 | + Id: 0, | ||
174 | + Name: "HRBP", | ||
175 | + Type: domain.RoleTypeSystem, | ||
176 | + Description: "拥有全部权限,预置角色不可删除", | ||
177 | + CompanyId: in.CompanyId, | ||
178 | + } | ||
179 | + role, err = roleRepository.Insert(role) | ||
180 | + if err != nil { | ||
181 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
182 | + } | ||
183 | + | ||
184 | + // 创建HRBP角色 | ||
185 | + roleUser := &adapter.RoleUserAdapter{} | ||
186 | + roleUser.Role = role | ||
187 | + roleUser.Users = make([]*domain.RoleContainUser, 0) | ||
188 | + adapterList = append(adapterList, roleUser) | ||
189 | + } | ||
190 | + | ||
158 | for i := range roles { | 191 | for i := range roles { |
159 | v := roles[i] | 192 | v := roles[i] |
160 | tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) | 193 | tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) |
@@ -162,13 +195,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -162,13 +195,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
162 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 195 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
163 | } | 196 | } |
164 | roleUser := &adapter.RoleUserAdapter{} | 197 | roleUser := &adapter.RoleUserAdapter{} |
165 | - roleUser.Id = v.Id | ||
166 | - roleUser.Name = v.Name | ||
167 | - roleUser.Type = v.Type | ||
168 | - roleUser.Description = v.Description | ||
169 | - roleUser.CompanyId = v.CompanyId | 198 | + roleUser.Role = v |
170 | roleUser.Users = tempList | 199 | roleUser.Users = tempList |
171 | adapterList = append(adapterList, roleUser) | 200 | adapterList = append(adapterList, roleUser) |
172 | } | 201 | } |
202 | + | ||
203 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
204 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
205 | + } | ||
206 | + | ||
173 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil | 207 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil |
174 | } | 208 | } |
@@ -28,8 +28,13 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | @@ -28,8 +28,13 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ | ||
28 | }() | 28 | }() |
29 | roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 29 | roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
30 | 30 | ||
31 | + //int64Array := make([]int64, 0) | ||
32 | + //for i := range in.UserIds { | ||
33 | + // int64Num, _ := strconv.ParseInt(in.UserIds[i], 10, 64) | ||
34 | + // int64Array = append(int64Array, int64Num) | ||
35 | + //} | ||
31 | // 检测已存在的关联用户 | 36 | // 检测已存在的关联用户 |
32 | - _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999}) | 37 | + _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": int64(9999999)}) |
33 | if err != nil { | 38 | if err != nil { |
34 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 39 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
35 | } | 40 | } |
@@ -4,22 +4,37 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | @@ -4,22 +4,37 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
4 | 4 | ||
5 | //评估内容详情 | 5 | //评估内容详情 |
6 | type AssessInfoResp struct { | 6 | type AssessInfoResp struct { |
7 | - CycleId int64 `json:"cycleId"` //周期id | ||
8 | - CycleName string `json:"cycleName"` //周期名称 | ||
9 | - EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
10 | - EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
11 | - BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
12 | - EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
13 | - Status string `json:"status"` //完成状态 | ||
14 | - TargetUserId int `json:"targetUser"` // | ||
15 | - TargetUserName string `json:"targetUserName"` // | ||
16 | - AssessContent []AssessContent `json:"assessContent"` //评估内容 | 7 | + AssessId int `json:"assessId"` |
8 | + CycleId int64 `json:"cycleId"` //周期id | ||
9 | + CycleName string `json:"cycleName"` //周期名称 | ||
10 | + EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
11 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
12 | + LinkNodeId int `json:"linkNodeId"` | ||
13 | + LinkNodeName string `json:"linkNodeName"` | ||
14 | + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
15 | + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
16 | + Status string `json:"status"` //完成状态 | ||
17 | + TargetUserId int `json:"targetUser"` //目标用户 | ||
18 | + TargetUserName string `json:"targetUserName"` //目标用户名称 | ||
19 | + CompanyId int `json:"companyId,string,"` // | ||
20 | + CompanyName string `json:"companyName"` //公司名称 | ||
21 | + SupperUser string `json:"superUser"` //目标用户的上级 | ||
22 | + DutyTime string `json:"dutyTime"` //入职时间 // | ||
23 | + AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容 | ||
17 | } | 24 | } |
18 | 25 | ||
19 | type AssessContent struct { | 26 | type AssessContent struct { |
20 | - Category string `json:"category" comment:"类别"` | ||
21 | - Name string `json:"name" comment:"名称"` | ||
22 | - PromptTitle string `json:"promptTitle" comment:"提示项标题"` | ||
23 | - PromptText string `json:"promptText" comment:"提示项正文"` | ||
24 | - EntryItems []*domain.EntryItem `json:"entryItems" comment:"填写项"` | 27 | + Category string `json:"category"` //comment:"类别" |
28 | + Name string `json:"name"` // comment:"名称" | ||
29 | + PromptTitle string `json:"promptTitle"` //comment:"提示项标题" | ||
30 | + PromptText string `json:"promptText"` // comment:"提示项正文" | ||
31 | + Rule AssessContentRule `json:"rules"` //评定规则 | ||
32 | + Value string `json:"value"` // 实际填写评定值 | ||
33 | + Remark []domain.AssessContemtRemark `json:"entryItems"` // comment:"填写反馈" | ||
34 | +} | ||
35 | + | ||
36 | +type AssessContentRule struct { | ||
37 | + Types int `json:"types"` //评估方式(0评级、1评分) | ||
38 | + Rating domain.Rating `json:"rating"` //评级 | ||
39 | + Score domain.Score `json:"score"` //评分 | ||
25 | } | 40 | } |
@@ -2,6 +2,7 @@ package adapter | @@ -2,6 +2,7 @@ package adapter | ||
2 | 2 | ||
3 | import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 3 | import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
4 | 4 | ||
5 | +//获取评估的邀请人 | ||
5 | type AssessInviteUserResp struct { | 6 | type AssessInviteUserResp struct { |
6 | LinkNodeId int `json:"linkNodeId"` | 7 | LinkNodeId int `json:"linkNodeId"` |
7 | LinkNodeName string `json:"linkNodeName"` | 8 | LinkNodeName string `json:"linkNodeName"` |
1 | +package adapter | ||
2 | + | ||
3 | +type ListInviteUserAssessResp struct { | ||
4 | + LinkNodeName string `json:"linkNodeName"` | ||
5 | + LinkNodeId int `json:"linkNodeId"` | ||
6 | + LintNodeDesc string `json:"lintNodeDesc"` | ||
7 | + TableHeader []ListTableHeader `json:"tableHeader"` | ||
8 | + List []map[string]string `json:"list"` | ||
9 | + Total int `json:"total"` | ||
10 | +} | ||
11 | +type ListTableHeader struct { | ||
12 | + Key string `json:"key"` | ||
13 | + Name string `json:"name"` | ||
14 | +} |
1 | +package adapter | ||
2 | + | ||
3 | +type ListSupperAssessResp struct { | ||
4 | + AssessId int `json:"assessId"` // | ||
5 | + UsrId int `json:"userId"` | ||
6 | + UserName string `json:"userName"` //用户名称 | ||
7 | + EndTime string `json:"endTime"` //截止时间 | ||
8 | + InviteTotal int `json:"inviteTota"` //邀请总数 | ||
9 | + InviteCompleted int `json:"inviteCompleted"` //邀请未完成 | ||
10 | + Status string `json:"status"` | ||
11 | + Department string `json:"department"` //部门 | ||
12 | + Position string `json:"position"` //职位 | ||
13 | + DutyTime string `json:"dutyTime"` //入职时间 | ||
14 | +} |
@@ -6,8 +6,8 @@ type CreateStaffAssessTask struct { | @@ -6,8 +6,8 @@ type CreateStaffAssessTask struct { | ||
6 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 6 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
7 | CycleId int64 `json:"cycleId"` //对应的周期id | 7 | CycleId int64 `json:"cycleId"` //对应的周期id |
8 | CycleName string `json:"cycleName"` //对应周期的名称 | 8 | CycleName string `json:"cycleName"` //对应周期的名称 |
9 | - BeginTime string `json:"beginTime"` //绩效考核开始时间 | ||
10 | - EndTime string `json:"endTime"` //绩效考核截止时间 | 9 | + BeginTime string `json:"beginTime"` //绩效考核开始时间 2006-01-02 15:04:05 |
10 | + EndTime string `json:"endTime"` //绩效考核截止时间 2006-01-02 15:04:05 | ||
11 | StepList []AssessTaskStep `json:"steps"` //考评的流程 | 11 | StepList []AssessTaskStep `json:"steps"` //考评的流程 |
12 | ExecutorId []int `json:"executorId"` //参与此次考评的人 | 12 | ExecutorId []int `json:"executorId"` //参与此次考评的人 |
13 | } | 13 | } |
1 | +package command | ||
2 | + | ||
3 | +//保存员工填写评估内容 | ||
4 | +type SaveAssessInfoCommand struct { | ||
5 | + AssessId int `json:"assessId"` | ||
6 | + AssessContent []AssesssContent `json:"assessContent"` | ||
7 | +} | ||
8 | + | ||
9 | +type AssesssContent struct { | ||
10 | + Category string `json:"category"` | ||
11 | + Name string `json:"name"` | ||
12 | + Value string `json:"value"` | ||
13 | + Remark []RemarkText `json:"remark"` | ||
14 | +} | ||
15 | + | ||
16 | +type RemarkText struct { | ||
17 | + Title string `json:"title"` | ||
18 | + RemarkText string `json:"remarkText"` | ||
19 | +} |
1 | +package query | ||
2 | + | ||
3 | +type ListSupperAssessQuery struct { | ||
4 | + PageNumber int `json:"pageNumber"` | ||
5 | + PageSize int `json:"pageSize"` | ||
6 | + UserName string `json:"userName"` //查询条件 员工的名称 | ||
7 | + CompanyId int `json:"companyId"` // | ||
8 | + ExecutorId int `json:"executorId"` //评估的执行人 | ||
9 | + AssessTaskId int `json:"assessTaskId"` //评估任务id | ||
10 | +} |
1 | package query | 1 | package query |
2 | 2 | ||
3 | +//获取评估任务详情 | ||
3 | type AssessInfoQuery struct { | 4 | type AssessInfoQuery struct { |
4 | - AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id | ||
5 | - TargetUserId int `json:"targetUserId"` //被评估的人id | ||
6 | - CompanyId int `json:"companyId"` //公司id | ||
7 | - | 5 | + AssessId int `json:"assessId"` // |
6 | + CompanyId int `json:"companyId"` // | ||
8 | } | 7 | } |
@@ -2,6 +2,6 @@ package query | @@ -2,6 +2,6 @@ package query | ||
2 | 2 | ||
3 | type GetAssessInviteUserQuery struct { | 3 | type GetAssessInviteUserQuery struct { |
4 | CompanyId int `json:"companyId"` //对公司 | 4 | CompanyId int `json:"companyId"` //对公司 |
5 | - UsrId int `json:"usrId"` //被评估的员工id | 5 | + UserId int `json:"userId"` //被评估的员工id |
6 | AssessTaskId int `json:"assessTaskId"` //评估任务的id | 6 | AssessTaskId int `json:"assessTaskId"` //评估任务的id |
7 | } | 7 | } |
1 | +package query | ||
2 | + | ||
3 | +type ListInviteUserAssessQuery struct { | ||
4 | + PageNumber int `json:"pageNumber"` | ||
5 | + PageSize int `json:"pageSize"` | ||
6 | + UserName string `json:"userName"` //查询条件 员工的名称 | ||
7 | + CompanyId int `json:"companyId"` // | ||
8 | + ExecutorId int `json:"executorId"` //评估的执行人,必填 | ||
9 | + AssessTaskId int `json:"assessTaskId"` //评估任务id 必填 | ||
10 | +} |
@@ -12,6 +12,7 @@ import ( | @@ -12,6 +12,7 @@ import ( | ||
12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" |
14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
15 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 16 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
16 | ) | 17 | ) |
17 | 18 | ||
@@ -36,27 +37,40 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue | @@ -36,27 +37,40 @@ func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQue | ||
36 | defer func() { | 37 | defer func() { |
37 | _ = transactionContext.RollbackTransaction() | 38 | _ = transactionContext.RollbackTransaction() |
38 | }() | 39 | }() |
39 | - staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | 40 | + // staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ |
41 | + // "transactionContext": transactionContext, | ||
42 | + // }) | ||
43 | + | ||
44 | + staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{ | ||
40 | "transactionContext": transactionContext, | 45 | "transactionContext": transactionContext, |
41 | }) | 46 | }) |
42 | - var limit int = 20 | 47 | + |
48 | + var limit int = 200 | ||
43 | var offset int = 0 | 49 | var offset int = 0 |
44 | if param.PageSize > 0 { | 50 | if param.PageSize > 0 { |
45 | limit = param.PageSize | 51 | limit = param.PageSize |
46 | } | 52 | } |
47 | offset = (param.PageNumber - 1) * param.PageSize | 53 | offset = (param.PageNumber - 1) * param.PageSize |
48 | - condition := map[string]interface{}{ | ||
49 | - "executorId": param.UserId, | ||
50 | - "companyId": param.CompanyId, | ||
51 | - "limit": limit, | ||
52 | - } | ||
53 | - if offset > 0 { | ||
54 | - condition["offset"] = offset | 54 | + assessTaskList, err := staffAssessTaskRepo.SearchAssessTaskMe(param.UserId, param.CompanyId, limit, offset) |
55 | + if err != nil { | ||
56 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error()) | ||
55 | } | 57 | } |
56 | - cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition) | 58 | + cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId) |
57 | if err != nil { | 59 | if err != nil { |
58 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error()) | 60 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error()) |
59 | } | 61 | } |
62 | + // condition := map[string]interface{}{ | ||
63 | + // "executorId": param.UserId, | ||
64 | + // "companyId": param.CompanyId, | ||
65 | + // "limit": limit, | ||
66 | + // } | ||
67 | + // if offset > 0 { | ||
68 | + // condition["offset"] = offset | ||
69 | + // } | ||
70 | + // cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition) | ||
71 | + // if err != nil { | ||
72 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error()) | ||
73 | + // } | ||
60 | if err := transactionContext.CommitTransaction(); err != nil { | 74 | if err := transactionContext.CommitTransaction(); err != nil { |
61 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 75 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
62 | } | 76 | } |
@@ -199,6 +213,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) | @@ -199,6 +213,7 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) | ||
199 | } | 213 | } |
200 | } | 214 | } |
201 | if uncompletedNum > 0 { | 215 | if uncompletedNum > 0 { |
216 | + stepItem.Status = string(domain.StaffAssessUncompleted) | ||
202 | stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum) | 217 | stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum) |
203 | } | 218 | } |
204 | } | 219 | } |
@@ -321,27 +336,31 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) | @@ -321,27 +336,31 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) | ||
321 | DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"), | 336 | DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"), |
322 | } | 337 | } |
323 | for _, v := range supperUserList { | 338 | for _, v := range supperUserList { |
324 | - userInfo.SupperUserName = userInfo.SupperUserName + v.Name + ";" | 339 | + userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " " |
325 | } | 340 | } |
326 | result := tool_funs.SimpleWrapGridMap(int64(cnt), listData) | 341 | result := tool_funs.SimpleWrapGridMap(int64(cnt), listData) |
327 | result["userInfo"] = userInfo | 342 | result["userInfo"] = userInfo |
328 | return result, nil | 343 | return result, nil |
329 | } | 344 | } |
330 | 345 | ||
331 | -// 更具项目评估的配置,创建员工的评估任务 | ||
332 | -func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { | ||
333 | - | ||
334 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
335 | - if err != nil { | ||
336 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
337 | - } | ||
338 | - if err := transactionContext.StartTransaction(); err != nil { | ||
339 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
340 | - } | ||
341 | - defer func() { | ||
342 | - _ = transactionContext.RollbackTransaction() | ||
343 | - }() | ||
344 | - | 346 | +// 根据项目评估的配置,创建员工的评估任务 |
347 | +func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext application.TransactionContext, param *command.CreateStaffAssessTask) (map[string]interface{}, error) { | ||
348 | + // transactionContext, err := factory.CreateTransactionContext(nil) | ||
349 | + // if err != nil { | ||
350 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
351 | + // } | ||
352 | + // if err := transactionContext.StartTransaction(); err != nil { | ||
353 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
354 | + // } | ||
355 | + // defer func() { | ||
356 | + // _ = transactionContext.RollbackTransaction() | ||
357 | + // }() | ||
358 | + log.Logger.Debug("CreateStaffAssessTask 获取参数", map[string]interface{}{ | ||
359 | + "param": param, | ||
360 | + }) | ||
361 | + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
362 | + "transactionContext": transactionContext, | ||
363 | + }) | ||
345 | taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | 364 | taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) |
346 | if err != nil { | 365 | if err != nil { |
347 | return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime) | 366 | return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime) |
@@ -352,7 +371,7 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -352,7 +371,7 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
352 | } | 371 | } |
353 | nowTime := time.Now() | 372 | nowTime := time.Now() |
354 | //建立评估任务 | 373 | //建立评估任务 |
355 | - assessTask := domain.StaffAssessTask{ | 374 | + assessTaskData := &domain.StaffAssessTask{ |
356 | Id: 0, | 375 | Id: 0, |
357 | CompanyId: param.CompanyId, | 376 | CompanyId: param.CompanyId, |
358 | EvaluationProjectId: param.EvaluationProjectId, | 377 | EvaluationProjectId: param.EvaluationProjectId, |
@@ -366,9 +385,17 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -366,9 +385,17 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
366 | CreatedAt: nowTime, | 385 | CreatedAt: nowTime, |
367 | UpdatedAt: nowTime, | 386 | UpdatedAt: nowTime, |
368 | DeletedAt: nil, | 387 | DeletedAt: nil, |
388 | + BeginDay: taskBeginTime.Local().Format("2006-01-02"), | ||
369 | } | 389 | } |
390 | + // } | ||
391 | + | ||
370 | //填充评估环节 | 392 | //填充评估环节 |
371 | for _, v := range param.StepList { | 393 | for _, v := range param.StepList { |
394 | + for _, vv := range assessTaskData.StepList { | ||
395 | + if vv.LinkNodeType == v.LinkNodeType { | ||
396 | + continue | ||
397 | + } | ||
398 | + } | ||
372 | stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | 399 | stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) |
373 | if err != nil { | 400 | if err != nil { |
374 | return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime) | 401 | return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime) |
@@ -385,41 +412,71 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -385,41 +412,71 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
385 | BeginTime: stepBeginTime, | 412 | BeginTime: stepBeginTime, |
386 | EndTime: stepEndTime, | 413 | EndTime: stepEndTime, |
387 | } | 414 | } |
388 | - assessTask.StepList = append(assessTask.StepList, step) | 415 | + assessTaskData.StepList = append(assessTaskData.StepList, step) |
389 | } | 416 | } |
390 | - | ||
391 | - assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
392 | - "transactionContext": transactionContext, | 417 | + //评估的参与人 |
418 | + executorIds := []int{} | ||
419 | + executorIdMap := map[int]struct{}{} //过滤重复的用户 | ||
420 | + for _, v := range param.ExecutorId { | ||
421 | + if _, ok := executorIdMap[v]; ok { | ||
422 | + continue | ||
423 | + } | ||
424 | + executorIdMap[v] = struct{}{} | ||
425 | + executorIds = append(executorIds, v) | ||
426 | + } | ||
427 | + assessTaskData.ExecutorId = executorIds | ||
428 | + assessList, err := srv.createStaffAssess(transactionContext, assessTaskData) | ||
429 | + if err != nil { | ||
430 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) | ||
431 | + } | ||
432 | + // var assessTaskData *domain.StaffAssessTask | ||
433 | + _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{ | ||
434 | + "evaluationProjectId": param.EvaluationProjectId, | ||
435 | + "beginDay": taskBeginTime.Local().Format("2006-01-02"), | ||
393 | }) | 436 | }) |
394 | - _, err = assessTaskRepo.Save(&assessTask) | ||
395 | if err != nil { | 437 | if err != nil { |
396 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | 438 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error()) |
397 | } | 439 | } |
398 | 440 | ||
399 | - assessList, err := srv.createStaffAssess(transactionContext, &assessTask) | 441 | + if len(assassessTaskList) > 0 { |
442 | + //过滤就数据 | ||
443 | + assessTaskData.Id = assassessTaskList[0].Id | ||
444 | + for _, v := range assassessTaskList[0].ExecutorId { | ||
445 | + if _, ok := executorIdMap[v]; ok { | ||
446 | + continue | ||
447 | + } | ||
448 | + executorIdMap[v] = struct{}{} | ||
449 | + executorIds = append(executorIds, v) | ||
450 | + } | ||
451 | + assessTaskData.ExecutorId = executorIds | ||
452 | + assessTaskData.StepList = append(assassessTaskList[0].StepList, assessTaskData.StepList...) | ||
453 | + | ||
454 | + } | ||
455 | + _, err = assessTaskRepo.Save(assessTaskData) | ||
400 | if err != nil { | 456 | if err != nil { |
401 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) | 457 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) |
402 | } | 458 | } |
403 | 459 | ||
404 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | 460 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
405 | "transactionContext": transactionContext, | 461 | "transactionContext": transactionContext, |
406 | }) | 462 | }) |
407 | - | ||
408 | for i := range assessList { | 463 | for i := range assessList { |
464 | + assessList[i].StaffAssessTaskId = assessTaskData.Id | ||
409 | _, err = assessRepo.Save(&assessList[i]) | 465 | _, err = assessRepo.Save(&assessList[i]) |
410 | if err != nil { | 466 | if err != nil { |
411 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) | 467 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) |
412 | } | 468 | } |
413 | } | 469 | } |
414 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
415 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
416 | - } | 470 | + |
471 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
472 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
473 | + // } | ||
417 | return map[string]interface{}{ | 474 | return map[string]interface{}{ |
418 | - "assessTaskId": assessTask.Id, | 475 | + "assessTaskId": assessTaskData.Id, |
419 | }, nil | 476 | }, nil |
420 | } | 477 | } |
421 | 478 | ||
422 | -// 添加自评节点任务 | 479 | +// 添加节点任务 |
423 | func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) { | 480 | func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) { |
424 | //评估的参与人 | 481 | //评估的参与人 |
425 | selfUserId := []int{} | 482 | selfUserId := []int{} |
@@ -432,6 +489,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -432,6 +489,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
432 | } | 489 | } |
433 | // 获取用户的信息 | 490 | // 获取用户的信息 |
434 | if len(selfUserId) == 0 { | 491 | if len(selfUserId) == 0 { |
492 | + log.Logger.Error("createStaffAssess", map[string]interface{}{ | ||
493 | + "param": param, | ||
494 | + }) | ||
435 | return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人") | 495 | return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人") |
436 | } | 496 | } |
437 | userRepo := factory.CreateUserRepository(map[string]interface{}{ | 497 | userRepo := factory.CreateUserRepository(map[string]interface{}{ |
@@ -450,6 +510,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -450,6 +510,9 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
450 | //获取用户的部门 | 510 | //获取用户的部门 |
451 | userDepartmentMap := map[int64][]*domain.Department{} | 511 | userDepartmentMap := map[int64][]*domain.Department{} |
452 | for _, v := range userList { | 512 | for _, v := range userList { |
513 | + if len(v.DepartmentId) == 0 { | ||
514 | + continue | ||
515 | + } | ||
453 | _, departmemtList, err := departmentRepo.Find(map[string]interface{}{ | 516 | _, departmemtList, err := departmentRepo.Find(map[string]interface{}{ |
454 | "ids": v.DepartmentId, | 517 | "ids": v.DepartmentId, |
455 | }) | 518 | }) |
@@ -471,7 +534,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -471,7 +534,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
471 | // TargetUser: domain.StaffDesc{}, | 534 | // TargetUser: domain.StaffDesc{}, |
472 | // TargetDepartment: nil, | 535 | // TargetDepartment: nil, |
473 | // Executor: domain.StaffDesc{}, | 536 | // Executor: domain.StaffDesc{}, |
474 | - Types: domain.AssessSelf, | 537 | + Types: "", |
475 | // LinkNodeId: v.LinkNodeId, | 538 | // LinkNodeId: v.LinkNodeId, |
476 | Status: domain.StaffAssessUncompleted, | 539 | Status: domain.StaffAssessUncompleted, |
477 | // BeginTime: time.Time{}, | 540 | // BeginTime: time.Time{}, |
@@ -487,6 +550,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -487,6 +550,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
487 | stepSelfTemp.EndTime = v.EndTime | 550 | stepSelfTemp.EndTime = v.EndTime |
488 | stepSelfTemp.LinkNodeId = v.LinkNodeId | 551 | stepSelfTemp.LinkNodeId = v.LinkNodeId |
489 | stepSelfTemp.LinkNodeName = v.LinkNodeName | 552 | stepSelfTemp.LinkNodeName = v.LinkNodeName |
553 | + stepSelfTemp.Types = domain.AssessSelf | ||
490 | assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap) | 554 | assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap) |
491 | assessList = append(assessList, assessListTemp...) | 555 | assessList = append(assessList, assessListTemp...) |
492 | } | 556 | } |
@@ -496,11 +560,12 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | @@ -496,11 +560,12 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. | ||
496 | stepSelfTemp.EndTime = v.EndTime | 560 | stepSelfTemp.EndTime = v.EndTime |
497 | stepSelfTemp.LinkNodeId = v.LinkNodeId | 561 | stepSelfTemp.LinkNodeId = v.LinkNodeId |
498 | stepSelfTemp.LinkNodeName = v.LinkNodeName | 562 | stepSelfTemp.LinkNodeName = v.LinkNodeName |
499 | - assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap) | 563 | + stepSelfTemp.Types = domain.AssessSuper |
564 | + assessListTemp2, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap) | ||
500 | if err != nil { | 565 | if err != nil { |
501 | return nil, err | 566 | return nil, err |
502 | } | 567 | } |
503 | - assessList = append(assessList, assessListTemp...) | 568 | + assessList = append(assessList, assessListTemp2...) |
504 | } | 569 | } |
505 | } | 570 | } |
506 | return assessList, nil | 571 | return assessList, nil |
@@ -511,15 +576,16 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse | @@ -511,15 +576,16 @@ func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAsse | ||
511 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess { | 576 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess { |
512 | result := []domain.StaffAssess{} | 577 | result := []domain.StaffAssess{} |
513 | for _, usr := range userList { | 578 | for _, usr := range userList { |
579 | + | ||
514 | assessTemp.TargetUser = domain.StaffDesc{ | 580 | assessTemp.TargetUser = domain.StaffDesc{ |
515 | UserId: int(usr.Id), | 581 | UserId: int(usr.Id), |
516 | Account: usr.Account, | 582 | Account: usr.Account, |
517 | - UserName: usr.Account, | 583 | + UserName: usr.Name, |
518 | } | 584 | } |
519 | assessTemp.Executor = domain.StaffDesc{ | 585 | assessTemp.Executor = domain.StaffDesc{ |
520 | UserId: int(usr.Id), | 586 | UserId: int(usr.Id), |
521 | Account: usr.Account, | 587 | Account: usr.Account, |
522 | - UserName: usr.Account, | 588 | + UserName: usr.Name, |
523 | } | 589 | } |
524 | if depList, ok := userDepartmentMap[usr.Id]; ok { | 590 | if depList, ok := userDepartmentMap[usr.Id]; ok { |
525 | for _, dep := range depList { | 591 | for _, dep := range depList { |
@@ -540,13 +606,49 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | @@ -540,13 +606,49 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | ||
540 | assessTemp domain.StaffAssess, | 606 | assessTemp domain.StaffAssess, |
541 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, | 607 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, |
542 | ) ([]domain.StaffAssess, error) { | 608 | ) ([]domain.StaffAssess, error) { |
543 | - | 609 | + var assessList []domain.StaffAssess |
544 | // 获取员工的上级用户 | 610 | // 获取员工的上级用户 |
545 | - | ||
546 | - return nil, nil | 611 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ |
612 | + "transactionContext": transactionContext, | ||
613 | + }) | ||
614 | + for _, v := range userList { | ||
615 | + departmentList, ok := userDepartmentMap[v.Id] | ||
616 | + if !ok { | ||
617 | + continue | ||
618 | + } | ||
619 | + for _, vv2 := range departmentList { | ||
620 | + if len(vv2.ChargeUserIds) == 0 { | ||
621 | + continue | ||
622 | + } | ||
623 | + _, chargeUserList, err := userRepo.Find(map[string]interface{}{ | ||
624 | + "ids": vv2.ChargeUserIds, | ||
625 | + "limit": 40, | ||
626 | + }) | ||
627 | + if err != nil { | ||
628 | + return nil, application.ThrowError(application.ARG_ERROR, "获取部门主管信息"+err.Error()) | ||
629 | + } | ||
630 | + for _, vvv3 := range chargeUserList { | ||
631 | + assessTemp.TargetDepartment = []domain.StaffDepartment{ | ||
632 | + {DepartmentId: int(vv2.Id), DepartmentName: vv2.Name}, | ||
633 | + } | ||
634 | + assessTemp.TargetUser = domain.StaffDesc{ | ||
635 | + UserId: int(v.Id), | ||
636 | + Account: v.Account, | ||
637 | + UserName: v.Name, | ||
638 | + } | ||
639 | + assessTemp.Executor = domain.StaffDesc{ | ||
640 | + UserId: int(vvv3.Id), | ||
641 | + Account: vvv3.Account, | ||
642 | + UserName: vvv3.Name, | ||
643 | + } | ||
644 | + assessList = append(assessList, assessTemp) | ||
645 | + } | ||
646 | + } | ||
647 | + } | ||
648 | + return assessList, nil | ||
547 | } | 649 | } |
548 | 650 | ||
549 | -// 获取某个员工360邀请的人员 | 651 | +// 获取某个员工360评估邀请的人员 |
550 | func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) { | 652 | func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) { |
551 | transactionContext, err := factory.CreateTransactionContext(nil) | 653 | transactionContext, err := factory.CreateTransactionContext(nil) |
552 | if err != nil { | 654 | if err != nil { |
@@ -575,7 +677,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU | @@ -575,7 +677,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU | ||
575 | _, assessList, err := assessReps.Find(map[string]interface{}{ | 677 | _, assessList, err := assessReps.Find(map[string]interface{}{ |
576 | "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | 678 | "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, |
577 | "staffAssessTaskId": param.AssessTaskId, | 679 | "staffAssessTaskId": param.AssessTaskId, |
578 | - "targetUserId": param.UsrId, | 680 | + "targetUserId": param.UserId, |
579 | }) | 681 | }) |
580 | if err != nil { | 682 | if err != nil { |
581 | return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error()) | 683 | return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error()) |
@@ -585,7 +687,9 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU | @@ -585,7 +687,9 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU | ||
585 | } | 687 | } |
586 | 688 | ||
587 | result := adapter.AssessInviteUserResp{ | 689 | result := adapter.AssessInviteUserResp{ |
588 | - AssessTaskId: assessTaskData.Id, | 690 | + AssessTaskId: assessTaskData.Id, |
691 | + InviteDiffSuper: []domain.StaffDesc{}, | ||
692 | + InviteSameSuper: []domain.StaffDesc{}, | ||
589 | } | 693 | } |
590 | for _, v := range assessTaskData.StepList { | 694 | for _, v := range assessTaskData.StepList { |
591 | if v.LinkNodeType != domain.LinkNodeAllInvite { | 695 | if v.LinkNodeType != domain.LinkNodeAllInvite { |
@@ -608,8 +712,8 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU | @@ -608,8 +712,8 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU | ||
608 | return &result, nil | 712 | return &result, nil |
609 | } | 713 | } |
610 | 714 | ||
611 | -// 获取某个员工360邀请的人员 | ||
612 | -func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) { | 715 | +// 保存某个员工360邀请的人员 |
716 | +func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (map[string]interface{}, error) { | ||
613 | inviteSameSuperId := []int{} | 717 | inviteSameSuperId := []int{} |
614 | InviteDiffSuperId := []int{} | 718 | InviteDiffSuperId := []int{} |
615 | for _, v := range param.InviteDiffSuper { | 719 | for _, v := range param.InviteDiffSuper { |
@@ -657,6 +761,19 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv | @@ -657,6 +761,19 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv | ||
657 | return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error()) | 761 | return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error()) |
658 | } | 762 | } |
659 | 763 | ||
764 | + //获取邀请评估的节点 | ||
765 | + var inviteNode *domain.AssessTaskStep | ||
766 | + for _, v := range assessTaskData.StepList { | ||
767 | + if v.LinkNodeType == domain.LinkNodeAllAssessment { | ||
768 | + cp := v | ||
769 | + inviteNode = &cp | ||
770 | + break | ||
771 | + } | ||
772 | + } | ||
773 | + if inviteNode == nil { | ||
774 | + return nil, application.ThrowError(application.ARG_ERROR, "评估任务没有邀请评估的环节") | ||
775 | + } | ||
776 | + | ||
660 | targetUser, err := userRepo.FindOne(map[string]interface{}{ | 777 | targetUser, err := userRepo.FindOne(map[string]interface{}{ |
661 | "id": param.TargetUserId, | 778 | "id": param.TargetUserId, |
662 | }) | 779 | }) |
@@ -713,50 +830,108 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv | @@ -713,50 +830,108 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv | ||
713 | }) | 830 | }) |
714 | } | 831 | } |
715 | } | 832 | } |
716 | - _ = assessReps | ||
717 | - _ = inviteSameSuper | ||
718 | - _ = inviteDiffSuper | ||
719 | - _ = targetUserDepartment | ||
720 | - // _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
721 | - // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
722 | - // "staffAssessTaskId": param.AssessTaskId, | ||
723 | - // "targetUserId": param.TargetUserId, | ||
724 | - // }) | ||
725 | - // if err != nil { | ||
726 | - // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error()) | ||
727 | - // } | ||
728 | - // TODO | ||
729 | - | 833 | + //获取员工邀请的人 |
834 | + _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
835 | + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
836 | + "staffAssessTaskId": param.AssessTaskId, | ||
837 | + "targetUserId": param.TargetUserId, | ||
838 | + }) | ||
839 | + if err != nil { | ||
840 | + return nil, application.ThrowError(application.ARG_ERROR, "获取员工邀请的人"+err.Error()) | ||
841 | + } | ||
842 | + //比对新旧数据 | ||
843 | + nowTime := time.Now() | ||
844 | + assessMap := map[string]*domain.StaffAssess{} | ||
845 | + for _, v := range assessList { | ||
846 | + //假设为删除 | ||
847 | + v.DeletedAt = &nowTime | ||
848 | + key := fmt.Sprintf("%s%d", string(v.Types), v.Executor.UserId) | ||
849 | + assessMap[key] = v | ||
850 | + } | ||
851 | + newAssessList := []*domain.StaffAssess{} | ||
852 | + //邀请同上级的员工 | ||
853 | + for _, v := range inviteSameSuper { | ||
854 | + key := fmt.Sprintf("%s%d", string(domain.AssessInviteSameSuper), v.UserId) | ||
855 | + if _, ok := assessMap[key]; ok { | ||
856 | + assessMap[key].DeletedAt = nil | ||
857 | + } else { | ||
858 | + newAssessList = append(newAssessList, &domain.StaffAssess{ | ||
859 | + Id: 0, | ||
860 | + CompanyId: assessTaskData.CompanyId, | ||
861 | + EvaluationProjectId: assessTaskData.EvaluationProjectId, | ||
862 | + EvaluationProjectName: assessTaskData.EvaluationProjectName, | ||
863 | + CycleId: assessTaskData.CycleId, | ||
864 | + CycleName: assessTaskData.CycleName, | ||
865 | + StaffAssessTaskId: assessTaskData.Id, | ||
866 | + TargetUser: domain.StaffDesc{ | ||
867 | + UserId: int(targetUser.Id), | ||
868 | + Account: targetUser.Account, | ||
869 | + UserName: targetUser.Name, | ||
870 | + }, | ||
871 | + TargetDepartment: targetUserDepartment, | ||
872 | + Executor: v, | ||
873 | + Types: domain.AssessInviteSameSuper, | ||
874 | + LinkNodeId: inviteNode.LinkNodeId, | ||
875 | + LinkNodeName: inviteNode.LinkNodeName, | ||
876 | + Status: domain.StaffAssessUncompleted, | ||
877 | + BeginTime: inviteNode.BeginTime, | ||
878 | + EndTime: inviteNode.EndTime, | ||
879 | + CreatedAt: nowTime, | ||
880 | + UpdatedAt: nowTime, | ||
881 | + DeletedAt: nil, | ||
882 | + }) | ||
883 | + } | ||
884 | + } | ||
885 | + for _, v := range inviteDiffSuper { | ||
886 | + key := fmt.Sprintf("%s%d", string(domain.AssessInviteDiffSuper), v.UserId) | ||
887 | + if _, ok := assessMap[key]; ok { | ||
888 | + assessMap[key].DeletedAt = nil | ||
889 | + } else { | ||
890 | + newAssessList = append(newAssessList, &domain.StaffAssess{ | ||
891 | + Id: 0, | ||
892 | + CompanyId: assessTaskData.CompanyId, | ||
893 | + EvaluationProjectId: assessTaskData.EvaluationProjectId, | ||
894 | + EvaluationProjectName: assessTaskData.EvaluationProjectName, | ||
895 | + CycleId: assessTaskData.CycleId, | ||
896 | + CycleName: assessTaskData.CycleName, | ||
897 | + StaffAssessTaskId: assessTaskData.Id, | ||
898 | + TargetUser: domain.StaffDesc{ | ||
899 | + UserId: int(targetUser.Id), | ||
900 | + Account: targetUser.Account, | ||
901 | + UserName: targetUser.Name, | ||
902 | + }, | ||
903 | + TargetDepartment: targetUserDepartment, | ||
904 | + Executor: v, | ||
905 | + Types: domain.AssessInviteDiffSuper, | ||
906 | + LinkNodeId: inviteNode.LinkNodeId, | ||
907 | + LinkNodeName: inviteNode.LinkNodeName, | ||
908 | + Status: domain.StaffAssessUncompleted, | ||
909 | + BeginTime: inviteNode.BeginTime, | ||
910 | + EndTime: inviteNode.EndTime, | ||
911 | + CreatedAt: nowTime, | ||
912 | + UpdatedAt: nowTime, | ||
913 | + DeletedAt: nil, | ||
914 | + }) | ||
915 | + } | ||
916 | + } | ||
917 | + assessList = append(assessList, newAssessList...) | ||
918 | + for i := range assessList { | ||
919 | + _, err = assessReps.Save(assessList[i]) | ||
920 | + if err != nil { | ||
921 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存员工邀请评估"+err.Error()) | ||
922 | + } | ||
923 | + } | ||
730 | if err := transactionContext.CommitTransaction(); err != nil { | 924 | if err := transactionContext.CommitTransaction(); err != nil { |
731 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 925 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
732 | } | 926 | } |
733 | - | ||
734 | - result := adapter.AssessInviteUserResp{ | ||
735 | - AssessTaskId: assessTaskData.Id, | ||
736 | - } | ||
737 | - // for _, v := range assessTaskData.StepList { | ||
738 | - // if v.LinkNodeType != domain.LinkNodeAllInvite { | ||
739 | - // continue | ||
740 | - // } | ||
741 | - // result.LinkNodeId = v.LinkNodeId | ||
742 | - // result.LinkNodeName = v.LinkNodeName | ||
743 | - // result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05") | ||
744 | - // result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05") | ||
745 | - // break | ||
746 | - // } | ||
747 | - // for _, v := range assessList { | ||
748 | - // if v.Types == domain.AssessInviteDiffSuper { | ||
749 | - // result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor) | ||
750 | - // } | ||
751 | - // if v.Types == domain.AssessInviteSameSuper { | ||
752 | - // result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor) | ||
753 | - // } | ||
754 | - // } | ||
755 | - return &result, nil | 927 | + result := map[string]interface{}{ |
928 | + "assessTaskId": assessTaskData.Id, | ||
929 | + } | ||
930 | + return result, nil | ||
756 | } | 931 | } |
757 | 932 | ||
758 | // 获取员工自评的评估内容详情 | 933 | // 获取员工自评的评估内容详情 |
759 | -func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { | 934 | +func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, error) { |
760 | transactionContext, err := factory.CreateTransactionContext(nil) | 935 | transactionContext, err := factory.CreateTransactionContext(nil) |
761 | if err != nil { | 936 | if err != nil { |
762 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 937 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -770,7 +945,6 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( | @@ -770,7 +945,6 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( | ||
770 | assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | 945 | assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ |
771 | "transactionContext": transactionContext, | 946 | "transactionContext": transactionContext, |
772 | }) | 947 | }) |
773 | - | ||
774 | //获取员工的评估 | 948 | //获取员工的评估 |
775 | _, assessList, err := assessReps.Find(map[string]interface{}{ | 949 | _, assessList, err := assessReps.Find(map[string]interface{}{ |
776 | "companyId": param.CompanyId, | 950 | "companyId": param.CompanyId, |
@@ -785,45 +959,38 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( | @@ -785,45 +959,38 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( | ||
785 | return &adapter.AssessInfoResp{}, nil | 959 | return &adapter.AssessInfoResp{}, nil |
786 | } | 960 | } |
787 | assessData := assessList[0] | 961 | assessData := assessList[0] |
788 | - projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
789 | - "transactionContext": transactionContext, | ||
790 | - }) | ||
791 | - projectData, err := projectRepo.FindOne(map[string]interface{}{ | ||
792 | - "id": assessData.EvaluationProjectId, | ||
793 | - }) | ||
794 | - if err != nil { | ||
795 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估配置"+err.Error()) | ||
796 | - } | ||
797 | - if projectData.Template == nil { | ||
798 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估配置模板") | ||
799 | - } | ||
800 | - var selfLinkNode *domain.LinkNode | ||
801 | - for _, v := range projectData.Template.LinkNodes { | ||
802 | - if v.Type == domain.LinkNodeSelfAssessment { | ||
803 | - selfLinkNode = v | ||
804 | - break | 962 | + |
963 | + assessContentList := []*domain.StaffAssessContent{} | ||
964 | + if assessData.Status == domain.StaffAssessCompleted { | ||
965 | + //已完成 | ||
966 | + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
967 | + "transactionContext": transactionContext, | ||
968 | + }) | ||
969 | + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{ | ||
970 | + "staffAssessId": assessData.Id, | ||
971 | + }) | ||
972 | + if err != nil { | ||
973 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
974 | + } | ||
975 | + } else if assessData.Status == domain.StaffAssessUncompleted { | ||
976 | + //未完成 | ||
977 | + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData) | ||
978 | + if err != nil { | ||
979 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
805 | } | 980 | } |
806 | } | 981 | } |
807 | - if selfLinkNode == nil { | ||
808 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置") | ||
809 | - } | ||
810 | - //获取员工评估的填写内容 | ||
811 | - // assessContentReps := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
812 | - // "transactionContext": transactionContext, | ||
813 | - // }) | ||
814 | - // _, assessContentList, err := assessContentReps.Find(map[string]interface{}{ | ||
815 | - // "staffAssessId": assessData.Id, | ||
816 | - // }) | ||
817 | - // if err != nil { | ||
818 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估员工填写的内容"+err.Error()) | ||
819 | - // } | 982 | + |
983 | + //获取员工描述 | ||
984 | + staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId)) | ||
820 | if err := transactionContext.CommitTransaction(); err != nil { | 985 | if err := transactionContext.CommitTransaction(); err != nil { |
821 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 986 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
822 | } | 987 | } |
823 | - | ||
824 | result := adapter.AssessInfoResp{ | 988 | result := adapter.AssessInfoResp{ |
989 | + AssessId: assessData.Id, | ||
825 | CycleId: assessData.CycleId, | 990 | CycleId: assessData.CycleId, |
826 | CycleName: assessData.CycleName, | 991 | CycleName: assessData.CycleName, |
992 | + LinkNodeId: assessData.LinkNodeId, | ||
993 | + LinkNodeName: assessData.LinkNodeName, | ||
827 | EvaluationProjectId: assessData.EvaluationProjectId, | 994 | EvaluationProjectId: assessData.EvaluationProjectId, |
828 | EvaluationProjectName: assessData.EvaluationProjectName, | 995 | EvaluationProjectName: assessData.EvaluationProjectName, |
829 | BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), | 996 | BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), |
@@ -831,18 +998,715 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( | @@ -831,18 +998,715 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( | ||
831 | Status: string(assessData.Status), | 998 | Status: string(assessData.Status), |
832 | TargetUserId: assessData.TargetUser.UserId, | 999 | TargetUserId: assessData.TargetUser.UserId, |
833 | TargetUserName: assessData.TargetUser.UserName, | 1000 | TargetUserName: assessData.TargetUser.UserName, |
834 | - AssessContent: nil, | ||
835 | - } | ||
836 | - assessContent := make([]adapter.AssessContent, 0) | ||
837 | - for _, v := range selfLinkNode.NodeContents { | ||
838 | - assessContent = append(assessContent, adapter.AssessContent{ | ||
839 | - Category: v.Category, | ||
840 | - Name: v.Name, | ||
841 | - PromptTitle: v.PromptTitle, | ||
842 | - PromptText: v.PromptText, | ||
843 | - EntryItems: v.EntryItems, | ||
844 | - }) | 1001 | + CompanyId: assessData.CompanyId, |
1002 | + CompanyName: "", | ||
1003 | + SupperUser: "", | ||
1004 | + DutyTime: "", | ||
1005 | + AssessContent: assessContentList, | ||
1006 | + } | ||
1007 | + if staffDesc != nil { | ||
1008 | + result.CompanyName = staffDesc.CompanyName | ||
1009 | + result.SupperUser = staffDesc.SupperUserName | ||
1010 | + result.DutyTime = staffDesc.DutyTime | ||
845 | } | 1011 | } |
846 | - result.AssessContent = assessContent | ||
847 | return &result, nil | 1012 | return &result, nil |
848 | } | 1013 | } |
1014 | + | ||
1015 | +// 获取未完成的员工评估内容 | ||
1016 | +func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext application.TransactionContext, | ||
1017 | + assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) { | ||
1018 | + projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
1019 | + "transactionContext": transactionContext, | ||
1020 | + }) | ||
1021 | + projectData, err := projectRepo.FindOne(map[string]interface{}{ | ||
1022 | + "id": assess.EvaluationProjectId, | ||
1023 | + }) | ||
1024 | + if err != nil { | ||
1025 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
1026 | + } | ||
1027 | + var linkNode *domain.LinkNode | ||
1028 | + for _, v := range projectData.Template.LinkNodes { | ||
1029 | + if v.Id == int64(assess.LinkNodeId) { | ||
1030 | + linkNode = v | ||
1031 | + break | ||
1032 | + } | ||
1033 | + } | ||
1034 | + if linkNode == nil { | ||
1035 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获得评估环节配置"+err.Error()) | ||
1036 | + } | ||
1037 | + ruleRepo := factory.CreateEvaluationRuleRepository(map[string]interface{}{ | ||
1038 | + "transactionContext": transactionContext, | ||
1039 | + }) | ||
1040 | + ruleMap := map[int64]*domain.EvaluationRule{} | ||
1041 | + for _, v := range linkNode.NodeContents { | ||
1042 | + if _, ok := ruleMap[v.RuleId]; ok { | ||
1043 | + continue | ||
1044 | + } | ||
1045 | + ruleData, err := ruleRepo.FindOne(map[string]interface{}{ | ||
1046 | + "id": v.RuleId, | ||
1047 | + }) | ||
1048 | + if err == nil { | ||
1049 | + ruleMap[v.RuleId] = ruleData | ||
1050 | + } | ||
1051 | + } | ||
1052 | + | ||
1053 | + var contentList []*domain.StaffAssessContent | ||
1054 | + nowTime := time.Now() | ||
1055 | + for i, v := range linkNode.NodeContents { | ||
1056 | + item := &domain.StaffAssessContent{ | ||
1057 | + Id: 0, | ||
1058 | + StaffAssessId: assess.Id, | ||
1059 | + SortBy: i + 1, | ||
1060 | + Category: v.Category, | ||
1061 | + Name: v.Name, | ||
1062 | + PromptTitle: v.PromptTitle, | ||
1063 | + PromptText: v.PromptText, | ||
1064 | + Remark: nil, | ||
1065 | + Value: "", | ||
1066 | + ReteResult: "", | ||
1067 | + CreatedAt: nowTime, | ||
1068 | + Weight: v.Weight, | ||
1069 | + UpdatedAt: nowTime, | ||
1070 | + DeletedAt: nil, | ||
1071 | + // Rule: , | ||
1072 | + } | ||
1073 | + if ruleVal, ok := ruleMap[v.RuleId]; ok { | ||
1074 | + item.Rule = *ruleVal | ||
1075 | + } | ||
1076 | + var remarks []domain.AssessContemtRemark | ||
1077 | + for _, vv := range v.EntryItems { | ||
1078 | + ritem := domain.AssessContemtRemark{ | ||
1079 | + Title: vv.Title, | ||
1080 | + HintText: vv.HintText, | ||
1081 | + RemarkText: "", | ||
1082 | + } | ||
1083 | + remarks = append(remarks, ritem) | ||
1084 | + } | ||
1085 | + item.Remark = remarks | ||
1086 | + contentList = append(contentList, item) | ||
1087 | + } | ||
1088 | + return contentList, nil | ||
1089 | +} | ||
1090 | + | ||
1091 | +// 选择员工评估可邀请的用户 | ||
1092 | +func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) { | ||
1093 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1094 | + if err != nil { | ||
1095 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1096 | + } | ||
1097 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1098 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1099 | + } | ||
1100 | + defer func() { | ||
1101 | + _ = transactionContext.RollbackTransaction() | ||
1102 | + }() | ||
1103 | + //获取被评估的目标用户 | ||
1104 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
1105 | + "transactionContext": transactionContext, | ||
1106 | + }) | ||
1107 | + targetUser, err := userRepo.FindOne(map[string]interface{}{ | ||
1108 | + "id": param.TargetUserId, | ||
1109 | + }) | ||
1110 | + if err != nil { | ||
1111 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error()) | ||
1112 | + } | ||
1113 | + //获取被评估的目标用户的部门 | ||
1114 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
1115 | + "transactionContext": transactionContext, | ||
1116 | + }) | ||
1117 | + var targetUserDepartment []*domain.Department | ||
1118 | + if len(targetUser.DepartmentId) > 0 { | ||
1119 | + _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{ | ||
1120 | + "ids": targetUser.DepartmentId, | ||
1121 | + }) | ||
1122 | + if err != nil { | ||
1123 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) | ||
1124 | + } | ||
1125 | + } | ||
1126 | + //获取部门主管的id | ||
1127 | + targetUserCharge := map[int64]struct{}{} | ||
1128 | + for _, v := range targetUserDepartment { | ||
1129 | + for _, vv := range v.ChargeUserIds { | ||
1130 | + targetUserCharge[vv] = struct{}{} | ||
1131 | + } | ||
1132 | + } | ||
1133 | + // | ||
1134 | + targetUserDepartmentMap := map[int64]struct{}{} | ||
1135 | + for _, v := range targetUserDepartment { | ||
1136 | + targetUserDepartmentMap[v.Id] = struct{}{} | ||
1137 | + } | ||
1138 | + //查询员工数据 | ||
1139 | + condition := map[string]interface{}{ | ||
1140 | + "companyId": param.CompanyId, | ||
1141 | + "name": param.InviteUserName, | ||
1142 | + "limit": 20, | ||
1143 | + } | ||
1144 | + if param.PageSize > 0 { | ||
1145 | + condition["limit"] = param.PageSize | ||
1146 | + } | ||
1147 | + offset := (param.PageNumber - 1) * param.PageSize | ||
1148 | + if offset > 0 { | ||
1149 | + condition["offset"] = offset | ||
1150 | + } | ||
1151 | + cnt, userList, err := userRepo.Find(condition) | ||
1152 | + if err != nil { | ||
1153 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error()) | ||
1154 | + } | ||
1155 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1156 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1157 | + } | ||
1158 | + listData := []adapter.SelectInviteUser{} | ||
1159 | + for _, v := range userList { | ||
1160 | + item := adapter.SelectInviteUser{ | ||
1161 | + UserId: int(v.Id), | ||
1162 | + UserName: v.Name, | ||
1163 | + IsSupper: false, | ||
1164 | + Types: 2, //默认是不同上级 | ||
1165 | + } | ||
1166 | + if _, ok := targetUserCharge[v.Id]; ok { | ||
1167 | + item.IsSupper = true | ||
1168 | + } | ||
1169 | + for _, vv := range v.DepartmentId { | ||
1170 | + if _, ok := targetUserDepartmentMap[int64(vv)]; ok { | ||
1171 | + item.Types = 1 //设为相同上级 | ||
1172 | + break | ||
1173 | + } | ||
1174 | + } | ||
1175 | + listData = append(listData, item) | ||
1176 | + } | ||
1177 | + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil | ||
1178 | +} | ||
1179 | + | ||
1180 | +// 获取我要执行的的360评估,用户列表和评估填写的值 | ||
1181 | +func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteUserAssessQuery) ( | ||
1182 | + *adapter.ListInviteUserAssessResp, error) { | ||
1183 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1184 | + if err != nil { | ||
1185 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1186 | + } | ||
1187 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1188 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1189 | + } | ||
1190 | + defer func() { | ||
1191 | + _ = transactionContext.RollbackTransaction() | ||
1192 | + }() | ||
1193 | + //获取对应的评估任务 | ||
1194 | + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1195 | + "transactionContext": transactionContext, | ||
1196 | + }) | ||
1197 | + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
1198 | + "transactionContext": transactionContext, | ||
1199 | + }) | ||
1200 | + | ||
1201 | + //获取 executorId 对应的360评估任务 用户 | ||
1202 | + condition := map[string]interface{}{ | ||
1203 | + "staffAssessTaskId": param.AssessTaskId, | ||
1204 | + "executorId": param.ExecutorId, | ||
1205 | + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
1206 | + "limit": 20, | ||
1207 | + } | ||
1208 | + if param.PageSize > 0 { | ||
1209 | + condition["limit"] = param.PageSize | ||
1210 | + } | ||
1211 | + offset := (param.PageNumber - 1) * param.PageSize | ||
1212 | + if offset > 0 { | ||
1213 | + condition["offset"] = offset | ||
1214 | + } | ||
1215 | + | ||
1216 | + cnt, assessList, err := assessRepo.Find(condition) | ||
1217 | + if err != nil { | ||
1218 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1219 | + } | ||
1220 | + var assessContentList []*domain.StaffAssessContent | ||
1221 | + if len(assessList) > 0 { | ||
1222 | + //获取评估用的所有评估项 | ||
1223 | + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessList[0]) | ||
1224 | + if err != nil { | ||
1225 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error()) | ||
1226 | + } | ||
1227 | + } | ||
1228 | + //可变的表格列 | ||
1229 | + changeableHeader := []adapter.ListTableHeader{} | ||
1230 | + //列名与字段对应 | ||
1231 | + keyMap := map[string]string{} | ||
1232 | + for i, v := range assessContentList { | ||
1233 | + name := fmt.Sprintf("%s-%s", v.Category, v.Name) | ||
1234 | + key := fmt.Sprintf("k%d", i) | ||
1235 | + keyMap[name] = key | ||
1236 | + changeableHeader = append(changeableHeader, adapter.ListTableHeader{ | ||
1237 | + Key: key, | ||
1238 | + Name: name, | ||
1239 | + }) | ||
1240 | + } | ||
1241 | + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
1242 | + "transactionContext": transactionContext, | ||
1243 | + }) | ||
1244 | + // 获取已经填报的内容 | ||
1245 | + changeableRows := map[int]map[string]string{} | ||
1246 | + for _, v := range assessList { | ||
1247 | + _, contentList, err := assessContentRepo.Find(map[string]interface{}{ | ||
1248 | + "staffAssessId": v.Id, | ||
1249 | + }) | ||
1250 | + if err != nil { | ||
1251 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error()) | ||
1252 | + } | ||
1253 | + row := map[string]string{} | ||
1254 | + for _, vv := range contentList { | ||
1255 | + name := fmt.Sprintf("%s-%s", vv.Category, vv.Name) | ||
1256 | + if kk, ok := keyMap[name]; ok { | ||
1257 | + row[kk] = vv.Value | ||
1258 | + } | ||
1259 | + } | ||
1260 | + changeableRows[v.TargetUser.UserId] = row | ||
1261 | + } | ||
1262 | + | ||
1263 | + //获取360邀请评估完成情况 | ||
1264 | + //我评估别人,被邀请评估 | ||
1265 | + cnnt, _, err := assessRepo.Find(map[string]interface{}{ | ||
1266 | + "staffAssessTaskId": param.AssessTaskId, | ||
1267 | + "executorId": param.ExecutorId, | ||
1268 | + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
1269 | + "status": domain.StaffAssessUncompleted, | ||
1270 | + }) | ||
1271 | + if err != nil { | ||
1272 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
1273 | + } | ||
1274 | + | ||
1275 | + assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{ | ||
1276 | + "id": param.AssessTaskId, | ||
1277 | + }) | ||
1278 | + if err != nil { | ||
1279 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error()) | ||
1280 | + } | ||
1281 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1282 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1283 | + } | ||
1284 | + | ||
1285 | + //评估填写数据行转列 | ||
1286 | + tableHeader := []adapter.ListTableHeader{ | ||
1287 | + {Key: "userName", Name: "姓名"}, | ||
1288 | + {Key: "status", Name: "状态"}, | ||
1289 | + {Key: "types", Name: "360°评估关系"}, | ||
1290 | + {Key: "endTime", Name: "360°评估截止日期"}, | ||
1291 | + } | ||
1292 | + tableHeader = append(tableHeader, changeableHeader...) | ||
1293 | + listData := []map[string]string{} | ||
1294 | + for _, v := range assessList { | ||
1295 | + m := map[string]string{ | ||
1296 | + "userName": v.TargetUser.UserName, | ||
1297 | + "userId": strconv.Itoa(v.TargetUser.UserId), | ||
1298 | + "status": string(v.Status), | ||
1299 | + "types": string(v.Types), | ||
1300 | + "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
1301 | + "assessId": strconv.Itoa(v.Id), | ||
1302 | + } | ||
1303 | + if row, ok := changeableRows[v.TargetUser.UserId]; ok { | ||
1304 | + for k, v := range row { | ||
1305 | + m[k] = v | ||
1306 | + } | ||
1307 | + } else { | ||
1308 | + for _, v := range changeableHeader { | ||
1309 | + m[v.Key] = "" | ||
1310 | + } | ||
1311 | + } | ||
1312 | + listData = append(listData, m) | ||
1313 | + } | ||
1314 | + result := adapter.ListInviteUserAssessResp{ | ||
1315 | + TableHeader: tableHeader, | ||
1316 | + List: listData, | ||
1317 | + Total: cnt, | ||
1318 | + } | ||
1319 | + for _, v := range assessTaskData.StepList { | ||
1320 | + if v.LinkNodeType == domain.LinkNodeAllAssessment { | ||
1321 | + result.LinkNodeId = v.LinkNodeId | ||
1322 | + result.LinkNodeName = v.LinkNodeName | ||
1323 | + result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt) | ||
1324 | + } | ||
1325 | + } | ||
1326 | + return &result, nil | ||
1327 | +} | ||
1328 | + | ||
1329 | +// 获取我需要执行的上级评估成员列表 | ||
1330 | +func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) { | ||
1331 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1332 | + if err != nil { | ||
1333 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1334 | + } | ||
1335 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1336 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1337 | + } | ||
1338 | + defer func() { | ||
1339 | + _ = transactionContext.RollbackTransaction() | ||
1340 | + }() | ||
1341 | + //获取对应的评估任务 | ||
1342 | + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1343 | + "transactionContext": transactionContext, | ||
1344 | + }) | ||
1345 | + | ||
1346 | + limit := 20 | ||
1347 | + if param.PageSize > 0 { | ||
1348 | + limit = param.PageSize | ||
1349 | + } | ||
1350 | + condition := map[string]interface{}{ | ||
1351 | + "staffAssessTaskId": param.AssessTaskId, | ||
1352 | + "executorId": param.ExecutorId, | ||
1353 | + "typesList": []string{string(domain.AssessSuper)}, | ||
1354 | + "limit": limit, | ||
1355 | + "targetUserName": param.UserName, | ||
1356 | + } | ||
1357 | + offset := (param.PageNumber - 1) * param.PageSize | ||
1358 | + if offset > 0 { | ||
1359 | + condition["offset"] = offset | ||
1360 | + } | ||
1361 | + //获取 executorId 对应的上级评估列表 | ||
1362 | + cnt, assessList, err := assessRepo.Find(condition) | ||
1363 | + if err != nil { | ||
1364 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1365 | + } | ||
1366 | + | ||
1367 | + userIds := []int{} | ||
1368 | + for _, v := range assessList { | ||
1369 | + userIds = append(userIds, v.TargetUser.UserId) | ||
1370 | + } | ||
1371 | + //获取员工信息 | ||
1372 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
1373 | + "transactionContext": transactionContext, | ||
1374 | + }) | ||
1375 | + var targetUserList []*domain.User | ||
1376 | + if len(userIds) > 0 { | ||
1377 | + _, targetUserList, _ = userRepo.Find(map[string]interface{}{ | ||
1378 | + "ids": userIds, | ||
1379 | + }) | ||
1380 | + } | ||
1381 | + //获取职位信息 | ||
1382 | + positionRepo := factory.CreatePositionRepository(map[string]interface{}{ | ||
1383 | + "transactionContext": transactionContext, | ||
1384 | + }) | ||
1385 | + //获取员工的职位 | ||
1386 | + userPositionMap := map[int64][]*domain.Position{} | ||
1387 | + for _, v := range targetUserList { | ||
1388 | + if len(v.PositionId) == 0 { | ||
1389 | + continue | ||
1390 | + } | ||
1391 | + _, positionList, _ := positionRepo.Find(map[string]interface{}{ | ||
1392 | + "ids": v.PositionId, | ||
1393 | + }) | ||
1394 | + userPositionMap[v.Id] = positionList | ||
1395 | + } | ||
1396 | + | ||
1397 | + //获取员工邀请的人完成360评估的数量 | ||
1398 | + var inviteCompletedCount []dao.CountData | ||
1399 | + if len(userIds) > 0 { | ||
1400 | + d := dao.NewStaffAssessDao(map[string]interface{}{ | ||
1401 | + "transactionContext": transactionContext, | ||
1402 | + }) | ||
1403 | + inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId) | ||
1404 | + if err != nil { | ||
1405 | + log.Logger.Error("获取员工邀请的人完成情况" + err.Error()) | ||
1406 | + } | ||
1407 | + } | ||
1408 | + | ||
1409 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1410 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1411 | + } | ||
1412 | + | ||
1413 | + resultList := []adapter.ListSupperAssessResp{} | ||
1414 | + for _, v := range assessList { | ||
1415 | + item := adapter.ListSupperAssessResp{ | ||
1416 | + AssessId: v.Id, | ||
1417 | + UsrId: v.TargetUser.UserId, | ||
1418 | + UserName: v.TargetUser.UserName, | ||
1419 | + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
1420 | + InviteCompleted: 0, | ||
1421 | + Status: string(v.Status), | ||
1422 | + InviteTotal: 5, | ||
1423 | + Department: "", | ||
1424 | + Position: "", | ||
1425 | + DutyTime: "", | ||
1426 | + } | ||
1427 | + //填入部门 | ||
1428 | + for _, vv := range v.TargetDepartment { | ||
1429 | + item.Department += vv.DepartmentName + " " | ||
1430 | + } | ||
1431 | + for _, vv := range targetUserList { | ||
1432 | + if vv.Id != int64(v.TargetUser.UserId) { | ||
1433 | + continue | ||
1434 | + } | ||
1435 | + //填入入职时间 | ||
1436 | + item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05") | ||
1437 | + //填入职位 | ||
1438 | + for _, vvv := range userPositionMap[vv.Id] { | ||
1439 | + item.Position += vvv.Name + " " | ||
1440 | + } | ||
1441 | + break | ||
1442 | + } | ||
1443 | + // | ||
1444 | + for _, vv := range inviteCompletedCount { | ||
1445 | + if v.TargetUser.UserId == vv.TargetUserId { | ||
1446 | + item.InviteCompleted = vv.InviteCompleted | ||
1447 | + item.InviteTotal = vv.InviteTotal | ||
1448 | + break | ||
1449 | + } | ||
1450 | + } | ||
1451 | + resultList = append(resultList, item) | ||
1452 | + } | ||
1453 | + return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil | ||
1454 | +} | ||
1455 | + | ||
1456 | +// 根据staffAssessId 获取评估的填写信息 | ||
1457 | +func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { | ||
1458 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1459 | + if err != nil { | ||
1460 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1461 | + } | ||
1462 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1463 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1464 | + } | ||
1465 | + defer func() { | ||
1466 | + _ = transactionContext.RollbackTransaction() | ||
1467 | + }() | ||
1468 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1469 | + "transactionContext": transactionContext, | ||
1470 | + }) | ||
1471 | + //获取员工的评估 | ||
1472 | + _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
1473 | + "companyId": param.CompanyId, | ||
1474 | + "id": param.AssessId, | ||
1475 | + }) | ||
1476 | + if err != nil { | ||
1477 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
1478 | + } | ||
1479 | + if len(assessList) == 0 { | ||
1480 | + return &adapter.AssessInfoResp{}, nil | ||
1481 | + } | ||
1482 | + assessData := assessList[0] | ||
1483 | + assessContentList := []*domain.StaffAssessContent{} | ||
1484 | + if assessData.Status == domain.StaffAssessCompleted { | ||
1485 | + //已完成 | ||
1486 | + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
1487 | + "transactionContext": transactionContext, | ||
1488 | + }) | ||
1489 | + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{ | ||
1490 | + "staffAssessId": assessData.Id, | ||
1491 | + }) | ||
1492 | + if err != nil { | ||
1493 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
1494 | + } | ||
1495 | + } else if assessData.Status == domain.StaffAssessUncompleted { | ||
1496 | + //未完成 | ||
1497 | + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData) | ||
1498 | + if err != nil { | ||
1499 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
1500 | + } | ||
1501 | + } | ||
1502 | + | ||
1503 | + targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId)) | ||
1504 | + if err != nil { | ||
1505 | + log.Logger.Error("获取员工描述" + err.Error()) | ||
1506 | + } | ||
1507 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1508 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1509 | + } | ||
1510 | + | ||
1511 | + result := adapter.AssessInfoResp{ | ||
1512 | + AssessId: assessData.Id, | ||
1513 | + CycleId: assessData.CycleId, | ||
1514 | + CycleName: assessData.CycleName, | ||
1515 | + LinkNodeId: assessData.LinkNodeId, | ||
1516 | + LinkNodeName: assessData.LinkNodeName, | ||
1517 | + EvaluationProjectId: assessData.EvaluationProjectId, | ||
1518 | + EvaluationProjectName: assessData.EvaluationProjectName, | ||
1519 | + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), | ||
1520 | + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
1521 | + Status: string(assessData.Status), | ||
1522 | + TargetUserId: assessData.TargetUser.UserId, | ||
1523 | + TargetUserName: assessData.TargetUser.UserName, | ||
1524 | + CompanyId: assessData.CompanyId, | ||
1525 | + CompanyName: "", | ||
1526 | + SupperUser: "", | ||
1527 | + DutyTime: "", | ||
1528 | + AssessContent: assessContentList, | ||
1529 | + } | ||
1530 | + if len(assessContentList) == 0 { | ||
1531 | + result.AssessContent = []*domain.StaffAssessContent{} | ||
1532 | + } | ||
1533 | + if targetUserDesc != nil { | ||
1534 | + result.CompanyName = targetUserDesc.CompanyName | ||
1535 | + result.SupperUser = targetUserDesc.SupperUserName | ||
1536 | + result.DutyTime = targetUserDesc.DutyTime | ||
1537 | + } | ||
1538 | + return &result, nil | ||
1539 | +} | ||
1540 | + | ||
1541 | +// 获取员工信息描述 | ||
1542 | +func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.TransactionContext, userid int64) (*adapter.StaffInfo, error) { | ||
1543 | + //获取用户数据 | ||
1544 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
1545 | + "transactionContext": transactionContext, | ||
1546 | + }) | ||
1547 | + userData, err := userRepo.FindOne(map[string]interface{}{ | ||
1548 | + "id": userid, | ||
1549 | + }) | ||
1550 | + if err != nil { | ||
1551 | + log.Logger.Error("获取用户信息," + err.Error()) | ||
1552 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error()) | ||
1553 | + } | ||
1554 | + | ||
1555 | + //获取公司数据 | ||
1556 | + companyRep := factory.CreateCompanyRepository(map[string]interface{}{ | ||
1557 | + "transactionContext": transactionContext, | ||
1558 | + }) | ||
1559 | + companyData, err := companyRep.FindOne(map[string]interface{}{ | ||
1560 | + "id": userData.CompanyId, | ||
1561 | + }) | ||
1562 | + if err != nil { | ||
1563 | + log.Logger.Error("获取公司信息," + err.Error()) | ||
1564 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error()) | ||
1565 | + } | ||
1566 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
1567 | + "transactionContext": transactionContext, | ||
1568 | + }) | ||
1569 | + var supperUserList []*domain.User | ||
1570 | + if len(userData.DepartmentId) > 0 { | ||
1571 | + _, departmentList, err := departmentRepo.Find(map[string]interface{}{ | ||
1572 | + "ids": userData.DepartmentId, | ||
1573 | + }) | ||
1574 | + if err != nil { | ||
1575 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error()) | ||
1576 | + } | ||
1577 | + var chargeUserIds []int64 | ||
1578 | + for _, v := range departmentList { | ||
1579 | + chargeUserIds = append(chargeUserIds, v.ChargeUserIds...) | ||
1580 | + } | ||
1581 | + if len(chargeUserIds) > 0 { | ||
1582 | + _, supperUserList, err = userRepo.Find(map[string]interface{}{ | ||
1583 | + "ids": chargeUserIds, | ||
1584 | + }) | ||
1585 | + if err != nil { | ||
1586 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error()) | ||
1587 | + } | ||
1588 | + } | ||
1589 | + } | ||
1590 | + userInfo := adapter.StaffInfo{ | ||
1591 | + UserName: userData.Name, | ||
1592 | + CompanyName: companyData.Name, | ||
1593 | + SupperUserName: "", | ||
1594 | + DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"), | ||
1595 | + } | ||
1596 | + for _, v := range supperUserList { | ||
1597 | + userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " " | ||
1598 | + } | ||
1599 | + return &userInfo, nil | ||
1600 | +} | ||
1601 | + | ||
1602 | +// 提交评估数据 | ||
1603 | +func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoCommand) (map[string]interface{}, error) { | ||
1604 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1605 | + if err != nil { | ||
1606 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1607 | + } | ||
1608 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1609 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1610 | + } | ||
1611 | + defer func() { | ||
1612 | + _ = transactionContext.RollbackTransaction() | ||
1613 | + }() | ||
1614 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1615 | + "transactionContext": transactionContext, | ||
1616 | + }) | ||
1617 | + //获取员工的评估 | ||
1618 | + assessData, err := assessReps.FindOne(map[string]interface{}{ | ||
1619 | + "id": param.AssessId, | ||
1620 | + }) | ||
1621 | + if err != nil { | ||
1622 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
1623 | + } | ||
1624 | + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
1625 | + "transactionContext": transactionContext, | ||
1626 | + }) | ||
1627 | + //待更新的评估填写信息 | ||
1628 | + assessContentList := []*domain.StaffAssessContent{} | ||
1629 | + if assessData.Status == domain.StaffAssessCompleted { | ||
1630 | + //已完成 | ||
1631 | + | ||
1632 | + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{ | ||
1633 | + "staffAssessId": assessData.Id, | ||
1634 | + }) | ||
1635 | + if err != nil { | ||
1636 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
1637 | + } | ||
1638 | + } else if assessData.Status == domain.StaffAssessUncompleted { | ||
1639 | + //未完成 | ||
1640 | + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData) | ||
1641 | + if err != nil { | ||
1642 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
1643 | + } | ||
1644 | + } | ||
1645 | + //处理提交上来的数据 | ||
1646 | + paramContentMap := map[string]command.AssesssContent{} | ||
1647 | + for i, v := range param.AssessContent { | ||
1648 | + key := fmt.Sprintf("%s-%s", v.Category, v.Name) | ||
1649 | + paramContentMap[key] = param.AssessContent[i] | ||
1650 | + } | ||
1651 | + //更新的评估填写信息 | ||
1652 | + for _, v := range assessContentList { | ||
1653 | + key := fmt.Sprintf("%s-%s", v.Category, v.Name) | ||
1654 | + item, ok := paramContentMap[key] | ||
1655 | + if !ok { | ||
1656 | + continue | ||
1657 | + } | ||
1658 | + v.Value = item.Value | ||
1659 | + for ii := range v.Remark { | ||
1660 | + for _, vvv := range item.Remark { | ||
1661 | + if v.Remark[ii].Title == vvv.Title { | ||
1662 | + v.Remark[ii].RemarkText = vvv.RemarkText | ||
1663 | + break | ||
1664 | + } | ||
1665 | + } | ||
1666 | + } | ||
1667 | + } | ||
1668 | + //保存信息 | ||
1669 | + for i := range assessContentList { | ||
1670 | + _, err = assessContentRepo.Save(assessContentList[i]) | ||
1671 | + if err != nil { | ||
1672 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error()) | ||
1673 | + } | ||
1674 | + } | ||
1675 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1676 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1677 | + } | ||
1678 | + return map[string]interface{}{ | ||
1679 | + "assessId": assessData.Id, | ||
1680 | + }, nil | ||
1681 | +} | ||
1682 | + | ||
1683 | +// 获取员工被评估的列表 | ||
1684 | +func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserAssessQuery) (map[string]interface{}, error) { | ||
1685 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1686 | + if err != nil { | ||
1687 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1688 | + } | ||
1689 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1690 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1691 | + } | ||
1692 | + defer func() { | ||
1693 | + _ = transactionContext.RollbackTransaction() | ||
1694 | + }() | ||
1695 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
1696 | + "transactionContext": transactionContext, | ||
1697 | + }) | ||
1698 | + //获取员工的评估 | ||
1699 | + cnt, assessList, err := assessReps.Find(map[string]interface{}{ | ||
1700 | + "assessTaskId": param.AssessTaskId, | ||
1701 | + "companyId": param.CompanyId, | ||
1702 | + "targetUserId": param.TargetUserId, | ||
1703 | + }) | ||
1704 | + if err != nil { | ||
1705 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
1706 | + } | ||
1707 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1708 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1709 | + } | ||
1710 | + | ||
1711 | + return tool_funs.SimpleWrapGridMap(int64(cnt), assessList), nil | ||
1712 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | ||
7 | +) | ||
8 | + | ||
9 | +func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { | ||
10 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
11 | + if err != nil { | ||
12 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
13 | + } | ||
14 | + if err := transactionContext.StartTransaction(); err != nil { | ||
15 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
16 | + } | ||
17 | + defer func() { | ||
18 | + _ = transactionContext.RollbackTransaction() | ||
19 | + }() | ||
20 | + | ||
21 | + data, err := srv.CreateStaffAssessTask(transactionContext, param) | ||
22 | + if err != nil { | ||
23 | + return nil, err | ||
24 | + } | ||
25 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
26 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
27 | + } | ||
28 | + return data, nil | ||
29 | +} |
pkg/application/user/command/batch_remove.go
0 → 100644
@@ -8,6 +8,7 @@ type SaveUserCommand struct { | @@ -8,6 +8,7 @@ type SaveUserCommand struct { | ||
8 | AdminType int `json:"admin_type"` // 1普通员工 2 主管理员 | 8 | AdminType int `json:"admin_type"` // 1普通员工 2 主管理员 |
9 | Name string `json:"name"` // 用户姓名 | 9 | Name string `json:"name"` // 用户姓名 |
10 | Status int `json:"status"` // 用户状态(1正常 2禁用) | 10 | Status int `json:"status"` // 用户状态(1正常 2禁用) |
11 | + EntryTime string `json:"entryTime"` //入职日期 | ||
11 | Email string `json:"email"` // 邮箱 | 12 | Email string `json:"email"` // 邮箱 |
12 | UserDepartments []struct { | 13 | UserDepartments []struct { |
13 | DepartmentId int `json:"department_id" ` | 14 | DepartmentId int `json:"department_id" ` |
@@ -62,6 +62,13 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | @@ -62,6 +62,13 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | ||
62 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 62 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
63 | } | 63 | } |
64 | err = srv.importUser(¶m4) | 64 | err = srv.importUser(¶m4) |
65 | + case "employee/batchRemove": | ||
66 | + batchRemove := &command.BatchRemove{} | ||
67 | + err = json.Unmarshal(param.Data, batchRemove) | ||
68 | + if err != nil { | ||
69 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
70 | + } | ||
71 | + err = srv.BatchRemove(batchRemove) | ||
65 | default: | 72 | default: |
66 | log.Logger.Error("action err:" + action) | 73 | log.Logger.Error("action err:" + action) |
67 | } | 74 | } |
@@ -95,6 +102,7 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | @@ -95,6 +102,7 @@ func (srv SyncDataUserService) AddUser(param *command.SaveUserCommand) error { | ||
95 | Name: param.Name, | 102 | Name: param.Name, |
96 | Email: param.Email, | 103 | Email: param.Email, |
97 | Status: param.Status, | 104 | Status: param.Status, |
105 | + EntryTime: param.EntryTime, | ||
98 | UpdatedAt: nowTime, | 106 | UpdatedAt: nowTime, |
99 | CreatedAt: nowTime, | 107 | CreatedAt: nowTime, |
100 | } | 108 | } |
@@ -153,6 +161,7 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | @@ -153,6 +161,7 @@ func (srv SyncDataUserService) UpdateUser(param *command.SaveUserCommand) error | ||
153 | newUser.AdminType = param.AdminType | 161 | newUser.AdminType = param.AdminType |
154 | newUser.Name = param.Name | 162 | newUser.Name = param.Name |
155 | newUser.Status = param.Status | 163 | newUser.Status = param.Status |
164 | + newUser.EntryTime = param.EntryTime | ||
156 | newUser.PositionId = param.PositionIds() | 165 | newUser.PositionId = param.PositionIds() |
157 | newUser.DepartmentId = param.DepartmentIds() | 166 | newUser.DepartmentId = param.DepartmentIds() |
158 | 167 | ||
@@ -287,6 +296,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | @@ -287,6 +296,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | ||
287 | editUserList[i].Name = mVal.Name | 296 | editUserList[i].Name = mVal.Name |
288 | editUserList[i].Status = mVal.Status | 297 | editUserList[i].Status = mVal.Status |
289 | editUserList[i].CompanyId = mVal.CompanyId | 298 | editUserList[i].CompanyId = mVal.CompanyId |
299 | + editUserList[i].EntryTime = mVal.EntryTime | ||
290 | editUserList[i].UpdatedAt = nowTime | 300 | editUserList[i].UpdatedAt = nowTime |
291 | _, err = userRepo.Update(editUserList[i]) | 301 | _, err = userRepo.Update(editUserList[i]) |
292 | if err != nil { | 302 | if err != nil { |
@@ -305,6 +315,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | @@ -305,6 +315,7 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | ||
305 | AdminType: param.AddUsers[i].AdminType, | 315 | AdminType: param.AddUsers[i].AdminType, |
306 | Name: param.AddUsers[i].Name, | 316 | Name: param.AddUsers[i].Name, |
307 | Status: param.AddUsers[i].Status, | 317 | Status: param.AddUsers[i].Status, |
318 | + EntryTime: param.AddUsers[i].EntryTime, | ||
308 | UpdatedAt: nowTime, | 319 | UpdatedAt: nowTime, |
309 | DeletedAt: nil, | 320 | DeletedAt: nil, |
310 | CreatedAt: nowTime, | 321 | CreatedAt: nowTime, |
@@ -320,3 +331,38 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | @@ -320,3 +331,38 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | ||
320 | 331 | ||
321 | return nil | 332 | return nil |
322 | } | 333 | } |
334 | + | ||
335 | +// BatchRemove 调整部门 | ||
336 | +func (srv SyncDataUserService) BatchRemove(batchRemove *command.BatchRemove) error { | ||
337 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
338 | + if err != nil { | ||
339 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
340 | + } | ||
341 | + if err := transactionContext.StartTransaction(); err != nil { | ||
342 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
343 | + } | ||
344 | + defer func() { | ||
345 | + _ = transactionContext.RollbackTransaction() | ||
346 | + }() | ||
347 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
348 | + "transactionContext": transactionContext, | ||
349 | + }) | ||
350 | + if len(batchRemove.UserIds) > 0 { | ||
351 | + for _, item := range batchRemove.UserIds { | ||
352 | + user, err := userRepo.FindOne(map[string]interface{}{"id": item, "companyId": batchRemove.CompanyId}) | ||
353 | + if err != nil { | ||
354 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
355 | + } | ||
356 | + user.DepartmentId = batchRemove.DepartmentIds | ||
357 | + user.UpdatedAt = time.Now() | ||
358 | + _, err = userRepo.Update(user) | ||
359 | + if err != nil { | ||
360 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
361 | + } | ||
362 | + } | ||
363 | + } | ||
364 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
365 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
366 | + } | ||
367 | + return nil | ||
368 | +} |
pkg/application/user/user.go
0 → 100644
1 | +package user | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query" | ||
8 | +) | ||
9 | + | ||
10 | +type UserService struct{} | ||
11 | + | ||
12 | +func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (interface{}, error) { | ||
13 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
14 | + if err != nil { | ||
15 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
16 | + } | ||
17 | + if err := transactionContext.StartTransaction(); err != nil { | ||
18 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
19 | + } | ||
20 | + defer func() { | ||
21 | + _ = transactionContext.RollbackTransaction() | ||
22 | + }() | ||
23 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
24 | + "transactionContext": transactionContext, | ||
25 | + }) | ||
26 | + count, list, err := userRepo.Find(map[string]interface{}{ | ||
27 | + "companyId": listUserQuery.CompanyId, | ||
28 | + "name": listUserQuery.Name, | ||
29 | + }) | ||
30 | + if err != nil { | ||
31 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
32 | + } | ||
33 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
34 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
35 | + } | ||
36 | + return tool_funs.SimpleWrapGridMap(int64(count), list), nil | ||
37 | +} |
@@ -4,10 +4,20 @@ import ( | @@ -4,10 +4,20 @@ import ( | ||
4 | "time" | 4 | "time" |
5 | ) | 5 | ) |
6 | 6 | ||
7 | +const ( | ||
8 | + KpiCycleDay int = 1 // 考核周期-日 | ||
9 | + KpiCycleWeek int = 2 // 考核周期-周 | ||
10 | + KpiCycleOneMonth int = 3 // 考核周期-月 | ||
11 | + KpiCycleTwoMonth int = 4 // 考核周期-双月 | ||
12 | + KpiCycleThreeMonth int = 5 // 考核周期-季度 | ||
13 | + KpiCycleSixMonth int = 6 // 考核周期-半年 | ||
14 | + KpiCycleYear int = 7 // 考核周期-年 | ||
15 | +) | ||
16 | + | ||
7 | type TemplateSimple struct { | 17 | type TemplateSimple struct { |
8 | Id int64 `json:"id,string" comment:"模板ID"` | 18 | Id int64 `json:"id,string" comment:"模板ID"` |
9 | Name string `json:"name" comment:"模板名称"` | 19 | Name string `json:"name" comment:"模板名称"` |
10 | - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 20 | + CreatedAt time.Time `json:"createdAt" comment:"模板创建时间"` |
11 | } | 21 | } |
12 | 22 | ||
13 | type EvaluationCycle struct { | 23 | type EvaluationCycle struct { |
@@ -17,7 +27,7 @@ type EvaluationCycle struct { | @@ -17,7 +27,7 @@ type EvaluationCycle struct { | ||
17 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | 27 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` |
18 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` | 28 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` |
19 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` | 29 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` |
20 | - KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"` | 30 | + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` |
21 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 31 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
22 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | 32 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` |
23 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 33 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
@@ -5,13 +5,14 @@ import ( | @@ -5,13 +5,14 @@ import ( | ||
5 | ) | 5 | ) |
6 | 6 | ||
7 | type EvaluationCycleTemplate struct { | 7 | type EvaluationCycleTemplate struct { |
8 | - Id int64 `json:"id,string" comment:"模板ID"` | ||
9 | - Name string `json:"name" comment:"模板名称"` | ||
10 | - Template *EvaluationTemplate `json:"template" comment:"模板数据"` | ||
11 | - CycleId int64 `json:"cycleId,string" comment:"周期ID"` | ||
12 | - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
13 | - UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
14 | - DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 8 | + Id int64 `json:"id,string" comment:"模板ID"` |
9 | + Name string `json:"name" comment:"模板名称"` | ||
10 | + TemplateCreatedAt time.Time `json:"templateCreatedAt" comment:"模板创建时间"` | ||
11 | + Template *EvaluationTemplate `json:"template" comment:"模板数据"` | ||
12 | + CycleId int64 `json:"cycleId,string" comment:"周期ID"` | ||
13 | + CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
14 | + UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
15 | + DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | ||
15 | } | 16 | } |
16 | 17 | ||
17 | type EvaluationCycleTemplateRepository interface { | 18 | type EvaluationCycleTemplateRepository interface { |
@@ -24,16 +24,6 @@ const ( | @@ -24,16 +24,6 @@ const ( | ||
24 | 24 | ||
25 | ) | 25 | ) |
26 | 26 | ||
27 | -const ( | ||
28 | - KpiCycleDay int = 1 // 考核周期-日 | ||
29 | - KpiCycleWeek int = 2 // 考核周期-周 | ||
30 | - KpiCycleOneMonth int = 3 // 考核周期-月 | ||
31 | - KpiCycleTwoMonth int = 4 // 考核周期-双月 | ||
32 | - KpiCycleThreeMonth int = 5 // 考核周期-季度 | ||
33 | - KpiCycleSixMonth int = 6 // 考核周期-半年 | ||
34 | - KpiCycleYear int = 7 // 考核周期-年 | ||
35 | -) | ||
36 | - | ||
37 | type EntryItem struct { | 27 | type EntryItem struct { |
38 | Title string `json:"title" comment:"填写标题"` | 28 | Title string `json:"title" comment:"填写标题"` |
39 | HintText string `json:"hintText" comment:"文本内容提示"` | 29 | HintText string `json:"hintText" comment:"文本内容提示"` |
@@ -41,12 +31,14 @@ type EntryItem struct { | @@ -41,12 +31,14 @@ type EntryItem struct { | ||
41 | 31 | ||
42 | // NodeContent 评估内容 | 32 | // NodeContent 评估内容 |
43 | type NodeContent struct { | 33 | type NodeContent struct { |
44 | - Category string `json:"category" comment:"类别"` | ||
45 | - Name string `json:"name" comment:"名称"` | ||
46 | - RuleId string `json:"ruleId" comment:"评估规则ID"` | ||
47 | - PromptTitle string `json:"promptTitle" comment:"提示项标题"` | ||
48 | - PromptText string `json:"promptText" comment:"提示项正文"` | ||
49 | - EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` | 34 | + Category string `json:"category" comment:"类别"` |
35 | + Name string `json:"name" comment:"名称"` | ||
36 | + RuleId int64 `json:"ruleId,string" comment:"评估规则ID"` | ||
37 | + Rule *EvaluationRule `json:"rule" comment:"评估规则对象"` | ||
38 | + Weight int `json:"weight" comment:"权重"` | ||
39 | + PromptTitle string `json:"promptTitle" comment:"提示项标题"` | ||
40 | + PromptText string `json:"promptText" comment:"提示项正文"` | ||
41 | + EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` | ||
50 | } | 42 | } |
51 | 43 | ||
52 | //// NodeAllInvite 360°邀请 | 44 | //// NodeAllInvite 360°邀请 |
@@ -68,9 +60,7 @@ type LinkNode struct { | @@ -68,9 +60,7 @@ type LinkNode struct { | ||
68 | NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"` | 60 | NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"` |
69 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` | 61 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` |
70 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | 62 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` |
71 | - KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"` | ||
72 | - //NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"` | ||
73 | - | 63 | + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` |
74 | } | 64 | } |
75 | 65 | ||
76 | // 评估模板 | 66 | // 评估模板 |
pkg/domain/node_task.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | +) | ||
6 | + | ||
7 | +type NodeTask struct { | ||
8 | + Id int64 `json:"id,string" comment:"ID"` | ||
9 | + CompanyId int64 `json:"companyId,string" comment:"公司ID"` | ||
10 | + CycleId int64 `json:"cycleId,string" comment:"周期ID"` | ||
11 | + ProjectId int64 `json:"projectId,string" comment:"项目ID"` | ||
12 | + NodeId int64 `json:"nodeId,string" comment:"节点ID"` | ||
13 | + NodeType int `json:"nodeType" comment:"环节类型"` | ||
14 | + NodeName string `json:"nodeName" comment:"环节名称"` | ||
15 | + NodeDescribe string `json:"nodeDescribe" comment:"环节描述"` | ||
16 | + NodeSort int `json:"nodeSort" comment:"环节顺序"` | ||
17 | + TimeStart *time.Time `json:"timeStart" comment:"起始时间"` | ||
18 | + TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | ||
19 | + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` | ||
20 | + NextSentAt *time.Time `json:"nextSentAt" comment:"下一次发送时间"` | ||
21 | + CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
22 | + UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
23 | + DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | ||
24 | +} | ||
25 | + | ||
26 | +type NodeTaskRepository interface { | ||
27 | + Insert(task *NodeTask) (*NodeTask, error) | ||
28 | + Remove(task *NodeTask) (*NodeTask, error) | ||
29 | + FindOne(queryOptions map[string]interface{}) (*NodeTask, error) | ||
30 | + Find(queryOptions map[string]interface{}) ([]*NodeTask, error) | ||
31 | +} |
pkg/domain/node_timer_task.go
已删除
100644 → 0
1 | -package domain | ||
2 | - | ||
3 | -import ( | ||
4 | - "time" | ||
5 | -) | ||
6 | - | ||
7 | -type NodeTimerTask struct { | ||
8 | - Id int64 `json:"id,string" comment:"ID"` | ||
9 | - CompanyId int64 `json:"companyId,string" comment:"公司ID"` | ||
10 | - CycleId int64 `json:"cycleId,string" comment:"周期ID"` | ||
11 | - ProjectId int64 `json:"projectId,string" comment:"项目ID"` | ||
12 | - NodeId int64 `json:"nodeId,string" comment:"节点ID"` | ||
13 | - LastSentAt *time.Time `json:"lastSentAt" comment:"最后一次发送时间"` | ||
14 | - NextSentAt *time.Time `json:"nextSentAt" comment:"下一次发送时间"` | ||
15 | - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | ||
16 | - UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | ||
17 | - DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | ||
18 | -} | ||
19 | - | ||
20 | -type NodeTimerTaskRepository interface { | ||
21 | - Insert(template *NodeTimerTask) (*NodeTimerTask, error) | ||
22 | - Remove(template *NodeTimerTask) (*NodeTimerTask, error) | ||
23 | - FindOne(queryOptions map[string]interface{}) (*NodeTimerTask, error) | ||
24 | - Find(queryOptions map[string]interface{}, excludeColumns ...string) (int64, []*NodeTimerTask, error) | ||
25 | - Count(queryOptions map[string]interface{}) (int64, error) | ||
26 | -} |
pkg/domain/performance_application_form.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "errors" | ||
5 | + "strings" | ||
6 | +) | ||
7 | + | ||
8 | +type PerformanceApplicationForm struct { | ||
9 | + DimensionName string //维度名称 | ||
10 | + ModuleName string //模块名称 | ||
11 | + Weight string //权重 | ||
12 | + Standard string //标准 | ||
13 | + Task string //任务、指标 | ||
14 | +} | ||
15 | + | ||
16 | +type PerformanceDimension struct { | ||
17 | + Name string `json:"name"` //维度名称 | ||
18 | + PerformanceModule []*PerformanceModule `json:"performanceModule"` //模块 | ||
19 | +} | ||
20 | + | ||
21 | +type PerformanceModule struct { | ||
22 | + ModuleName string `json:"moduleName"` //模块名称 | ||
23 | + Weight string `json:"weight"` //权重 | ||
24 | + Standard string `json:"standard"` //标准(结构化的成果描述) | ||
25 | + Target []*PerformanceTarget `json:"performanceTarget"` //任务\指标 | ||
26 | +} | ||
27 | + | ||
28 | +type PerformanceTarget struct { | ||
29 | + Task string `json:"task"` | ||
30 | +} | ||
31 | + | ||
32 | +func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) { | ||
33 | + formRows := make([]*PerformanceApplicationForm, 0) | ||
34 | + var dimensionName, moduleName, taskName, weightName, standardName string | ||
35 | + for key, item := range rows { | ||
36 | + if key < 3 { | ||
37 | + continue | ||
38 | + } | ||
39 | + if len(item) >= 1 { | ||
40 | + if item[0] == "部门长审核" || strings.Contains(item[0], "审核") { | ||
41 | + break | ||
42 | + } | ||
43 | + } | ||
44 | + form := &PerformanceApplicationForm{} | ||
45 | + //维度名称 | ||
46 | + if len(item) > 1 && item[1] != "" { | ||
47 | + dimensionName = item[1] | ||
48 | + } | ||
49 | + form.DimensionName = dimensionName | ||
50 | + //模块名称 | ||
51 | + if len(item) > 3 && item[3] != "" { | ||
52 | + moduleName = item[3] | ||
53 | + } | ||
54 | + form.ModuleName = moduleName | ||
55 | + //指标任务 | ||
56 | + if len(item) > 4 && item[4] != "" { | ||
57 | + taskName = item[4] | ||
58 | + } | ||
59 | + form.Task = taskName | ||
60 | + //权重 | ||
61 | + if len(item) > 6 && item[6] != "" { | ||
62 | + weightName = item[6] | ||
63 | + } | ||
64 | + form.Weight = weightName | ||
65 | + //标准 | ||
66 | + if len(item) > 7 && item[7] != "" { | ||
67 | + standardName = item[7] | ||
68 | + } | ||
69 | + form.Standard = standardName | ||
70 | + formRows = append(formRows, form) | ||
71 | + } | ||
72 | + dimensions := make([]*PerformanceDimension, 0) | ||
73 | + //按维度分 | ||
74 | + mapData := make(map[string][]*PerformanceApplicationForm) | ||
75 | + //维度顺序 | ||
76 | + sortBy := make([]string, 0) | ||
77 | + for _, item := range formRows { | ||
78 | + if _, ok := mapData[item.DimensionName]; !ok { | ||
79 | + mapData[item.DimensionName] = make([]*PerformanceApplicationForm, 0) | ||
80 | + sortBy = append(sortBy, item.DimensionName) | ||
81 | + } | ||
82 | + mapData[item.DimensionName] = append(mapData[item.DimensionName], item) | ||
83 | + } | ||
84 | + for dimensionName, item := range mapData { | ||
85 | + dimension := &PerformanceDimension{ | ||
86 | + Name: dimensionName, | ||
87 | + } | ||
88 | + modules, err := loadPerformanceModule(item) | ||
89 | + if err != nil { | ||
90 | + return dimensions, err | ||
91 | + } | ||
92 | + dimension.PerformanceModule = modules | ||
93 | + dimensions = append(dimensions, dimension) | ||
94 | + } | ||
95 | + result := make([]*PerformanceDimension, 0) | ||
96 | + for _, name := range sortBy { | ||
97 | + for _, item := range dimensions { | ||
98 | + if name == item.Name { | ||
99 | + result = append(result, item) | ||
100 | + } | ||
101 | + } | ||
102 | + } | ||
103 | + return result, nil | ||
104 | +} | ||
105 | + | ||
106 | +// 筛选出模块 | ||
107 | +func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceModule, error) { | ||
108 | + mapData := make(map[string][]*PerformanceApplicationForm) | ||
109 | + sortBy := make([]string, 0) | ||
110 | + for _, item := range forms { | ||
111 | + if _, ok := mapData[item.ModuleName]; !ok { | ||
112 | + mapData[item.ModuleName] = make([]*PerformanceApplicationForm, 0) | ||
113 | + sortBy = append(sortBy, item.ModuleName) | ||
114 | + } | ||
115 | + mapData[item.ModuleName] = append(mapData[item.ModuleName], item) | ||
116 | + } | ||
117 | + modules := make([]*PerformanceModule, 0) | ||
118 | + for moduleName, item := range mapData { | ||
119 | + if moduleName == "" { | ||
120 | + return modules, errors.New(item[0].DimensionName + "对应的模块不能为空") | ||
121 | + } | ||
122 | + weightName, err := getWeight(item) | ||
123 | + if err != nil { | ||
124 | + return modules, err | ||
125 | + } | ||
126 | + standardName, err := getStandard(item) | ||
127 | + if err != nil { | ||
128 | + return modules, err | ||
129 | + } | ||
130 | + tasks, err := getTasks(item) | ||
131 | + if err != nil { | ||
132 | + return modules, err | ||
133 | + } | ||
134 | + module := &PerformanceModule{ | ||
135 | + ModuleName: moduleName, | ||
136 | + Weight: weightName, | ||
137 | + Standard: standardName, | ||
138 | + Target: tasks, | ||
139 | + } | ||
140 | + modules = append(modules, module) | ||
141 | + } | ||
142 | + result := make([]*PerformanceModule, 0) | ||
143 | + | ||
144 | + for _, name := range sortBy { | ||
145 | + for _, item := range modules { | ||
146 | + if name == item.ModuleName { | ||
147 | + result = append(result, item) | ||
148 | + } | ||
149 | + } | ||
150 | + } | ||
151 | + return result, nil | ||
152 | +} | ||
153 | + | ||
154 | +// 获取权重 | ||
155 | +func getWeight(items []*PerformanceApplicationForm) (string, error) { | ||
156 | + if len(items) <= 0 { | ||
157 | + return "", nil | ||
158 | + } | ||
159 | + var name string | ||
160 | + for _, item := range items { | ||
161 | + if name == "" { | ||
162 | + name = item.Weight | ||
163 | + } | ||
164 | + if name != item.Weight { | ||
165 | + return "", errors.New(item.ModuleName + " 对应的权重值不一致") | ||
166 | + } | ||
167 | + } | ||
168 | + if name == "/" { | ||
169 | + name = "0%" | ||
170 | + } | ||
171 | + return name, nil | ||
172 | +} | ||
173 | + | ||
174 | +// 获取标准 | ||
175 | +func getStandard(items []*PerformanceApplicationForm) (string, error) { | ||
176 | + if len(items) <= 0 { | ||
177 | + return "", nil | ||
178 | + } | ||
179 | + var name string | ||
180 | + for _, item := range items { | ||
181 | + if name == "" { | ||
182 | + name = item.Standard | ||
183 | + } | ||
184 | + if name != item.Standard { | ||
185 | + return "", errors.New(item.ModuleName + " 对应的标准值不一致") | ||
186 | + } | ||
187 | + } | ||
188 | + return name, nil | ||
189 | +} | ||
190 | + | ||
191 | +// 获取任务 | ||
192 | +func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) { | ||
193 | + tasks := make([]*PerformanceTarget, 0) | ||
194 | + for _, item := range items { | ||
195 | + target := &PerformanceTarget{Task: item.Task} | ||
196 | + tasks = append(tasks, target) | ||
197 | + } | ||
198 | + return tasks, nil | ||
199 | +} |
@@ -20,4 +20,5 @@ type PositionRepository interface { | @@ -20,4 +20,5 @@ type PositionRepository interface { | ||
20 | Update(position *Position) (*Position, error) | 20 | Update(position *Position) (*Position, error) |
21 | Remove(ids []int64) error | 21 | Remove(ids []int64) error |
22 | FindOne(queryOption map[string]interface{}) (*Position, error) | 22 | FindOne(queryOption map[string]interface{}) (*Position, error) |
23 | + Find(queryOptions map[string]interface{}) (int, []*Position, error) | ||
23 | } | 24 | } |
@@ -10,7 +10,7 @@ const ( | @@ -10,7 +10,7 @@ const ( | ||
10 | type Role struct { | 10 | type Role struct { |
11 | Id int64 `json:"id,string"` | 11 | Id int64 `json:"id,string"` |
12 | Name string `json:"name"` | 12 | Name string `json:"name"` |
13 | - Type int `json:"type"` | 13 | + Type int `json:"type" pg:",use_zero"` |
14 | Description string `json:"description"` | 14 | Description string `json:"description"` |
15 | CompanyId int64 `json:"companyId,string"` | 15 | CompanyId int64 `json:"companyId,string"` |
16 | CreatedAt time.Time `json:"createdAt"` | 16 | CreatedAt time.Time `json:"createdAt"` |
@@ -7,7 +7,7 @@ type StaffAssessType string | @@ -7,7 +7,7 @@ type StaffAssessType string | ||
7 | 7 | ||
8 | const ( | 8 | const ( |
9 | AssessSelf StaffAssessType = "self" //自评 | 9 | AssessSelf StaffAssessType = "self" //自评 |
10 | - AssessSuper StaffAssessType = "super" //上级评估 | 10 | + AssessSuper StaffAssessType = "supper" //上级评估 |
11 | AssessInviteSameSuper StaffAssessType = "invite_same_super" //360 邀请评估-相同上级的同事 | 11 | AssessInviteSameSuper StaffAssessType = "invite_same_super" //360 邀请评估-相同上级的同事 |
12 | AssessInviteDiffSuper StaffAssessType = "invite_diff_super" //360 邀请评估-不同上级的同事 | 12 | AssessInviteDiffSuper StaffAssessType = "invite_diff_super" //360 邀请评估-不同上级的同事 |
13 | ) | 13 | ) |
@@ -4,22 +4,27 @@ import "time" | @@ -4,22 +4,27 @@ import "time" | ||
4 | 4 | ||
5 | //填写的评估内容 | 5 | //填写的评估内容 |
6 | type StaffAssessContent struct { | 6 | type StaffAssessContent struct { |
7 | - Id int `json:"id"` //id | ||
8 | - StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id | ||
9 | - SortBy int `json:"sortBy"` //排序 | ||
10 | - Category string `json:"category"` //类别 | ||
11 | - Title string `json:"title"` //问题标题 | ||
12 | - Remark string `json:"remark"` //填写的反馈 | ||
13 | - Rate string `json:"rate"` //评估填写的值 | ||
14 | - ReteResult string `json:"reteResult"` //评估的结果 | ||
15 | - CreatedAt time.Time `json:"createdAt"` //数据创建时间 | ||
16 | - UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 | ||
17 | - //TODO | 7 | + Id int `json:"id"` //id |
8 | + StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id | ||
9 | + SortBy int `json:"sortBy"` //排序 | ||
10 | + Category string `json:"category"` //类别 | ||
11 | + Name string `json:"name"` //名称 | ||
12 | + PromptTitle string `json:"promptTitle"` //提示项标题 | ||
13 | + PromptText string `json:"promptText"` //提示项正文 | ||
14 | + Remark []AssessContemtRemark `json:"remark"` //填写的反馈 | ||
15 | + Value string `json:"value"` //评估填写的值 | ||
16 | + ReteResult string `json:"reteResult"` //评估的结果 | ||
17 | + Rule EvaluationRule `json:"rule"` //评估的选项规则 | ||
18 | + Weight int `json:"weight" ` //"权重" | ||
19 | + CreatedAt time.Time `json:"createdAt"` //数据创建时间 | ||
20 | + UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 | ||
21 | + DeletedAt *time.Time `json:"deletedAt"` | ||
18 | } | 22 | } |
19 | 23 | ||
20 | type AssessContemtRemark struct { | 24 | type AssessContemtRemark struct { |
21 | - Title string `json:"title"` //comment:"填写标题" | ||
22 | - RemarkText string `json:"hintText"` // comment:"填写文本内容" | 25 | + Title string `json:"title"` //comment:"填写标题" |
26 | + HintText string `json:"hintText"` // comment:"文本内容提示" | ||
27 | + RemarkText string `json:"remarkText"` // comment:"填写文本内容" | ||
23 | } | 28 | } |
24 | 29 | ||
25 | type StaffAssessContentRepository interface { | 30 | type StaffAssessContentRepository interface { |
@@ -2,19 +2,6 @@ package domain | @@ -2,19 +2,6 @@ package domain | ||
2 | 2 | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | -//评估任务重复执行的方式 | ||
6 | -// type AssessTaskRepeatWay string | ||
7 | - | ||
8 | -// const ( | ||
9 | -// AssessTaskRepeatDay AssessTaskRepeatWay = "day" //按天重复 | ||
10 | -// AssessTaskRepeatWeek AssessTaskRepeatWay = "week" //按周重复 | ||
11 | -// AssessTaskRepeatMonth AssessTaskRepeatWay = "month" //按月 | ||
12 | -// AssessTaskRepeatMonthDouble AssessTaskRepeatWay = "month_double" //按双月 | ||
13 | -// AssessTaskRepeatQuarter AssessTaskRepeatWay = "quarter" //按季度 | ||
14 | -// AssessTaskRepeatYearHalf AssessTaskRepeatWay = "year_half" //按半年 | ||
15 | -// AssessTaskRepeatYear AssessTaskRepeatWay = "year" //按年 | ||
16 | -// ) | ||
17 | - | ||
18 | // 执行评估的任务列表 | 5 | // 执行评估的任务列表 |
19 | type StaffAssessTask struct { | 6 | type StaffAssessTask struct { |
20 | Id int `json:"id"` | 7 | Id int `json:"id"` |
@@ -23,6 +10,7 @@ type StaffAssessTask struct { | @@ -23,6 +10,7 @@ type StaffAssessTask struct { | ||
23 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 10 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
24 | CycleId int64 `json:"cycleId"` //对应的周期id | 11 | CycleId int64 `json:"cycleId"` //对应的周期id |
25 | CycleName string `json:"cycleName"` //对应周期的名称 | 12 | CycleName string `json:"cycleName"` //对应周期的名称 |
13 | + BeginDay string `json:"beginDay"` //绩效考核日期 | ||
26 | BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 | 14 | BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 |
27 | EndTime time.Time `json:"endTime"` //绩效考核截止时间 | 15 | EndTime time.Time `json:"endTime"` //绩效考核截止时间 |
28 | StepList []AssessTaskStep `json:"stepList"` //考评的流程 | 16 | StepList []AssessTaskStep `json:"stepList"` //考评的流程 |
@@ -2,13 +2,18 @@ package domain | @@ -2,13 +2,18 @@ package domain | ||
2 | 2 | ||
3 | //员工基本信息描述 | 3 | //员工基本信息描述 |
4 | type StaffDesc struct { | 4 | type StaffDesc struct { |
5 | - UserId int `json:"userId"` //用户id | ||
6 | - Account string `json:"account"` //用户的账号 | ||
7 | - UserName string `json:"userName"` //用户的名称 | 5 | + UserId int `json:"userId,string"` //用户id |
6 | + Account string `json:"account"` //用户的账号 | ||
7 | + UserName string `json:"userName"` //用户的名称 | ||
8 | } | 8 | } |
9 | 9 | ||
10 | //员工的部门 | 10 | //员工的部门 |
11 | type StaffDepartment struct { | 11 | type StaffDepartment struct { |
12 | - DepartmentId int `json:"departmentId"` //部门id | ||
13 | - DepartmentName string `json:"departmentName"` //部门名称 | 12 | + DepartmentId int `json:"departmentId,string"` //部门id |
13 | + DepartmentName string `json:"departmentName"` //部门名称 | ||
14 | +} | ||
15 | + | ||
16 | +type StaffPosition struct { | ||
17 | + PositionId int `json:"positionId,string"` | ||
18 | + PositionName string `json:"positionName"` | ||
14 | } | 19 | } |
@@ -3,19 +3,20 @@ package domain | @@ -3,19 +3,20 @@ package domain | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | type User struct { | 5 | type User struct { |
6 | - Id int64 // 用户Id | ||
7 | - Account string // 用户账号 | ||
8 | - AvatarUrl string // 用户头像URL | ||
9 | - CompanyId int64 // 公司编号 | ||
10 | - AdminType int // 1普通员工 2 主管理员 | ||
11 | - Name string // 用户姓名 | ||
12 | - Email string // 邮箱 | ||
13 | - Status int // 用户状态(1正常 2禁用) | ||
14 | - DepartmentId []int // 用户归属的部门 | ||
15 | - PositionId []int //用户职位 | ||
16 | - UpdatedAt time.Time // 更新时间 | ||
17 | - DeletedAt *time.Time | ||
18 | - CreatedAt time.Time | 6 | + Id int64 `json:"id,string"` // 用户Id |
7 | + Account string `json:"account"` // 用户账号 | ||
8 | + AvatarUrl string `json:"avatarUrl"` // 用户头像URL | ||
9 | + CompanyId int64 `json:"companyId"` // 公司编号 | ||
10 | + AdminType int `json:"adminType"` // 1普通员工 2 主管理员 | ||
11 | + Name string `json:"name"` // 用户姓名 | ||
12 | + Email string `json:"email"` // 邮箱 | ||
13 | + Status int `json:"status"` // 用户状态(1正常 2禁用) | ||
14 | + DepartmentId []int `json:"departmentId"` // 用户归属的部门 | ||
15 | + PositionId []int `json:"PositionId"` //用户职位 | ||
16 | + EntryTime string `json:"entryTime"` //入职日期 | ||
17 | + UpdatedAt time.Time `json:"updatedAt"` // 更新时间 | ||
18 | + DeletedAt *time.Time `json:"deletedAt"` | ||
19 | + CreatedAt time.Time `json:"createdAt"` | ||
19 | } | 20 | } |
20 | 21 | ||
21 | // 1普通员工 2 主管理员 | 22 | // 1普通员工 2 主管理员 |
pkg/infrastructure/dao/staff_assess_dao.go
0 → 100644
1 | +package dao | ||
2 | + | ||
3 | +import ( | ||
4 | + "strconv" | ||
5 | + | ||
6 | + "github.com/go-pg/pg/v10" | ||
7 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
9 | +) | ||
10 | + | ||
11 | +type StaffAssessDao struct { | ||
12 | + transactionContext *pgTransaction.TransactionContext | ||
13 | +} | ||
14 | + | ||
15 | +func NewStaffAssessDao(options map[string]interface{}) *StaffAssessDao { | ||
16 | + var transactionContext *pgTransaction.TransactionContext | ||
17 | + if value, ok := options["transactionContext"]; ok { | ||
18 | + transactionContext = value.(*pgTransaction.TransactionContext) | ||
19 | + } | ||
20 | + return &StaffAssessDao{ | ||
21 | + transactionContext: transactionContext, | ||
22 | + } | ||
23 | +} | ||
24 | + | ||
25 | +type CountData struct { | ||
26 | + TargetUserId int | ||
27 | + InviteTotal int | ||
28 | + InviteCompleted int | ||
29 | +} | ||
30 | + | ||
31 | +// 获取员工邀请的人完成360评估的数量 | ||
32 | +func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTaskId int) ([]CountData, error) { | ||
33 | + sqlStr := `SELECT staff_assess.target_user->>'userId' as target_user_id, | ||
34 | + count(staff_assess."id") AS invite_total, | ||
35 | + sum( | ||
36 | + case WHEN staff_assess.status='completed' THEN 1 | ||
37 | + ELSE 0 END | ||
38 | + ) as invite_completed | ||
39 | + FROM staff_assess | ||
40 | + WHERE staff_assess.target_user->>'userId' IN(?) | ||
41 | + AND staff_assess.types IN ('invite_same_super','invite_diff_super') | ||
42 | + AND staff_assess.staff_assess_task_id = ? | ||
43 | + GROUP BY userId` | ||
44 | + | ||
45 | + userIdList := []string{} | ||
46 | + for _, v := range userIds { | ||
47 | + uid := strconv.Itoa(v) | ||
48 | + userIdList = append(userIdList, uid) | ||
49 | + } | ||
50 | + condition := []interface{}{ | ||
51 | + pg.In(userIdList), assessTaskId, | ||
52 | + } | ||
53 | + tx := d.transactionContext.PgTx | ||
54 | + result := []CountData{} | ||
55 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
56 | + return result, err | ||
57 | +} | ||
58 | + | ||
59 | +// 搜索 executorId 参与的评估任务 | ||
60 | +func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) { | ||
61 | + | ||
62 | + if limit < 0 { | ||
63 | + limit = 20 | ||
64 | + } | ||
65 | + if offset < 0 { | ||
66 | + offset = 0 | ||
67 | + } | ||
68 | + | ||
69 | + sqlStr := `SELECT DISTINCT staff_assess_task.* FROM staff_assess_task | ||
70 | + JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id" | ||
71 | + WHERE staff_assess.company_id=? | ||
72 | + and staff_assess.executor->>'userId'='?' | ||
73 | + limit ? offset ? | ||
74 | + ` | ||
75 | + tx := d.transactionContext.PgTx | ||
76 | + condition := []interface{}{ | ||
77 | + companyId, executorId, limit, offset, | ||
78 | + } | ||
79 | + result := []*domain.StaffAssessTask{} | ||
80 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
81 | + return result, err | ||
82 | + | ||
83 | +} | ||
84 | + | ||
85 | +// 搜索 executorId 参与的评估任务 | ||
86 | +func (d *StaffAssessDao) CountAssessTaskMe(executorId int, companyId int) (int, error) { | ||
87 | + sqlStr := `SELECT count( DISTINCT staff_assess_task."id") FROM staff_assess_task | ||
88 | + JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id" | ||
89 | + WHERE staff_assess.company_id=? | ||
90 | + and staff_assess.executor->>'userId'='?' | ||
91 | + ` | ||
92 | + tx := d.transactionContext.PgTx | ||
93 | + condition := []interface{}{ | ||
94 | + companyId, executorId, | ||
95 | + } | ||
96 | + result := 0 | ||
97 | + _, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...) | ||
98 | + return result, err | ||
99 | + | ||
100 | +} |
@@ -40,8 +40,10 @@ func init() { | @@ -40,8 +40,10 @@ func init() { | ||
40 | &models.EvaluationCycle{}, | 40 | &models.EvaluationCycle{}, |
41 | &models.EvaluationCycleTemplate{}, | 41 | &models.EvaluationCycleTemplate{}, |
42 | &models.EvaluationProject{}, | 42 | &models.EvaluationProject{}, |
43 | + &models.NodeTask{}, | ||
43 | &models.StaffAssess{}, | 44 | &models.StaffAssess{}, |
44 | &models.StaffAssessTask{}, | 45 | &models.StaffAssessTask{}, |
46 | + &models.StaffAssessContent{}, | ||
45 | } | 47 | } |
46 | for _, model := range tables { | 48 | for _, model := range tables { |
47 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | 49 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
@@ -6,12 +6,13 @@ import ( | @@ -6,12 +6,13 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type EvaluationCycleTemplate struct { | 8 | type EvaluationCycleTemplate struct { |
9 | - tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` | ||
10 | - Id int64 `comment:"模板ID" pg:"pk:id"` | ||
11 | - Name string `comment:"模板名称"` | ||
12 | - Template *domain.EvaluationTemplate `comment:"模板数据"` | ||
13 | - CycleId int64 `comment:"周期ID"` | ||
14 | - CreatedAt time.Time `comment:"创建时间"` | ||
15 | - UpdatedAt time.Time `comment:"更新时间"` | ||
16 | - DeletedAt *time.Time `comment:"删除时间"` | 9 | + tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` |
10 | + Id int64 `comment:"模板ID" pg:"pk:id"` | ||
11 | + Name string `comment:"模板名称"` | ||
12 | + TemplateCreatedAt time.Time `comment:"模板创建时间"` | ||
13 | + Template *domain.EvaluationTemplate `comment:"模板数据"` | ||
14 | + CycleId int64 `comment:"周期ID"` | ||
15 | + CreatedAt time.Time `comment:"创建时间"` | ||
16 | + UpdatedAt time.Time `comment:"更新时间"` | ||
17 | + DeletedAt *time.Time `comment:"删除时间"` | ||
17 | } | 18 | } |
@@ -17,5 +17,5 @@ type EvaluationRule struct { | @@ -17,5 +17,5 @@ type EvaluationRule struct { | ||
17 | Score domain.Score `comment:"评分"` | 17 | Score domain.Score `comment:"评分"` |
18 | CreatedAt time.Time `comment:"创建时间"` | 18 | CreatedAt time.Time `comment:"创建时间"` |
19 | UpdatedAt time.Time `comment:"更新时间"` | 19 | UpdatedAt time.Time `comment:"更新时间"` |
20 | - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` | 20 | + DeletedAt *time.Time `comment:"删除时间"` |
21 | } | 21 | } |
pkg/infrastructure/pg/models/node_task.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | +) | ||
6 | + | ||
7 | +type NodeTask struct { | ||
8 | + tableName struct{} `comment:"环节任务" pg:"node_task"` | ||
9 | + Id int64 `comment:"ID" pg:"pk:id"` | ||
10 | + CompanyId int64 `comment:"公司ID"` | ||
11 | + CycleId int64 `comment:"周期ID"` | ||
12 | + ProjectId int64 `comment:"项目ID"` | ||
13 | + NodeId int64 `comment:"环节ID"` | ||
14 | + NodeType int `comment:"环节类型"` | ||
15 | + NodeName string `comment:"环节名称"` | ||
16 | + NodeDescribe string `comment:"环节描述"` | ||
17 | + NodeSort int `comment:"环节顺序"` | ||
18 | + TimeStart *time.Time `comment:"起始时间"` | ||
19 | + TimeEnd *time.Time `comment:"截至时间"` | ||
20 | + KpiCycle int `comment:"考核周期(1日、2周、3月)"` | ||
21 | + NextSentAt *time.Time `comment:"下一次发送时间"` | ||
22 | + CreatedAt time.Time `comment:"创建时间"` | ||
23 | + UpdatedAt time.Time `comment:"更新时间"` | ||
24 | + DeletedAt *time.Time `comment:"删除时间"` | ||
25 | +} |
@@ -3,13 +3,13 @@ package models | @@ -3,13 +3,13 @@ package models | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | type Role struct { | 5 | type Role struct { |
6 | - tableName struct{} `pg:"role" comment:"角色"` | ||
7 | - Id int64 `pg:"pk:id" comment:"ID"` | 6 | + tableName struct{} `comment:"角色" pg:"role"` |
7 | + Id int64 `comment:"ID" pg:"pk:id"` | ||
8 | Name string `comment:"角色名称"` | 8 | Name string `comment:"角色名称"` |
9 | Type int `comment:"角色类型(0角色可删、1系统预置角色不可删)" pg:",use_zero"` | 9 | Type int `comment:"角色类型(0角色可删、1系统预置角色不可删)" pg:",use_zero"` |
10 | Description string `comment:"角色描述"` | 10 | Description string `comment:"角色描述"` |
11 | CompanyId int64 `comment:"公司ID"` | 11 | CompanyId int64 `comment:"公司ID"` |
12 | CreatedAt time.Time `comment:"创建时间"` | 12 | CreatedAt time.Time `comment:"创建时间"` |
13 | UpdatedAt time.Time `comment:"更新时间"` | 13 | UpdatedAt time.Time `comment:"更新时间"` |
14 | - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` | 14 | + DeletedAt *time.Time `comment:"删除时间"` |
15 | } | 15 | } |
@@ -10,5 +10,5 @@ type RoleUser struct { | @@ -10,5 +10,5 @@ type RoleUser struct { | ||
10 | CompanyId int64 `comment:"公司ID"` | 10 | CompanyId int64 `comment:"公司ID"` |
11 | CreatedAt time.Time `comment:"创建时间"` | 11 | CreatedAt time.Time `comment:"创建时间"` |
12 | UpdatedAt time.Time `comment:"更新时间"` | 12 | UpdatedAt time.Time `comment:"更新时间"` |
13 | - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` | 13 | + DeletedAt *time.Time `comment:"删除时间"` |
14 | } | 14 | } |
1 | package models | 1 | package models |
2 | 2 | ||
3 | -import "time" | 3 | +import ( |
4 | + "time" | ||
4 | 5 | ||
5 | -//填写的评估内容 | 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
7 | +) | ||
8 | + | ||
9 | +// 填写的评估内容 | ||
6 | type StaffAssessContent struct { | 10 | type StaffAssessContent struct { |
7 | - tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"` | ||
8 | - Id int `pg:",pk"` //id | ||
9 | - StaffAssessId int //用户需要的评估项id | ||
10 | - SortBy int //排序 | ||
11 | - Category string //类别 | ||
12 | - Title string //问题标题 | ||
13 | - Remark string //填写的反馈 | ||
14 | - Rate string //评估填写的值 | ||
15 | - ReteResult string //评估的结果 | 11 | + tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"` |
12 | + Id int `pg:",pk"` //id | ||
13 | + StaffAssessId int //用户需要的评估项id | ||
14 | + SortBy int //排序 | ||
15 | + Category string //类别 | ||
16 | + Name string //名称 | ||
17 | + PromptTitle string //问题标题 | ||
18 | + PromptText string //提示项正文 | ||
19 | + Value string //评估填写的值 | ||
20 | + ReteResult string //评估的结果 | ||
21 | + Rule domain.EvaluationRule | ||
22 | + Remark []domain.AssessContemtRemark | ||
23 | + Weight int //权重 | ||
16 | CreatedAt time.Time //数据创建时间 | 24 | CreatedAt time.Time //数据创建时间 |
17 | UpdatedAt time.Time //数据更新时间 | 25 | UpdatedAt time.Time //数据更新时间 |
26 | + DeletedAt *time.Time | ||
18 | } | 27 | } |
19 | 28 | ||
20 | type StaffAssessContentRepository interface { | 29 | type StaffAssessContentRepository interface { |
@@ -17,6 +17,7 @@ type StaffAssessTask struct { | @@ -17,6 +17,7 @@ type StaffAssessTask struct { | ||
17 | CycleName string //对应周期的名称 | 17 | CycleName string //对应周期的名称 |
18 | ExecutorId []int //参与考评的人 | 18 | ExecutorId []int //参与考评的人 |
19 | StepList []domain.AssessTaskStep `` //考评的流程 | 19 | StepList []domain.AssessTaskStep `` //考评的流程 |
20 | + BeginDay string //日期 天 2006-01-02 | ||
20 | BeginTime time.Time //开始时间 | 21 | BeginTime time.Time //开始时间 |
21 | EndTime time.Time //截止时间 | 22 | EndTime time.Time //截止时间 |
22 | CreatedAt time.Time //数据创建时间 | 23 | CreatedAt time.Time //数据创建时间 |
@@ -14,6 +14,7 @@ type User struct { | @@ -14,6 +14,7 @@ type User struct { | ||
14 | Status int // 用户状态(1正常 2禁用) | 14 | Status int // 用户状态(1正常 2禁用) |
15 | DepartmentId []int // 用户归属的部门 | 15 | DepartmentId []int // 用户归属的部门 |
16 | PositionId []int // 用户职位 | 16 | PositionId []int // 用户职位 |
17 | + EntryTime string //入职日期 | ||
17 | CreatedAt time.Time // 创建时间 | 18 | CreatedAt time.Time // 创建时间 |
18 | UpdatedAt time.Time // 更新时间 | 19 | UpdatedAt time.Time // 更新时间 |
19 | DeletedAt *time.Time `pg:",soft_delete"` // 删除时间 | 20 | DeletedAt *time.Time `pg:",soft_delete"` // 删除时间 |
@@ -92,7 +92,7 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -92,7 +92,7 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | ||
92 | func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { | 92 | func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { |
93 | tx := repo.transactionContext.PgTx | 93 | tx := repo.transactionContext.PgTx |
94 | dparmentModel := []models.Department{} | 94 | dparmentModel := []models.Department{} |
95 | - query := tx.Model(&dparmentModel).Where("delete_at isnull") | 95 | + query := tx.Model(&dparmentModel) |
96 | if v, ok := queryOptions["id"]; ok { | 96 | if v, ok := queryOptions["id"]; ok { |
97 | query.Where("id=?", v) | 97 | query.Where("id=?", v) |
98 | } | 98 | } |
@@ -119,19 +119,23 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | @@ -119,19 +119,23 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | ||
119 | 119 | ||
120 | query := tx.Model(&m).Where("deleted_at isnull") | 120 | query := tx.Model(&m).Where("deleted_at isnull") |
121 | 121 | ||
122 | - if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { | 122 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
123 | query.Where("name LIKE ?", v) | 123 | query.Where("name LIKE ?", v) |
124 | } | 124 | } |
125 | 125 | ||
126 | + if v, ok := queryOptions["ids"]; ok { | ||
127 | + query.Where("id in (?)", pg.In(v)) | ||
128 | + } | ||
129 | + | ||
126 | if v, ok := queryOptions["companyId"]; ok { | 130 | if v, ok := queryOptions["companyId"]; ok { |
127 | query.Where("company_id = ?", v) | 131 | query.Where("company_id = ?", v) |
128 | } | 132 | } |
129 | 133 | ||
130 | - if v, ok := queryOptions["limit"].(int); ok { | ||
131 | - query.Limit(v) | 134 | + if v, ok := queryOptions["limit"].(int64); ok { |
135 | + query.Limit(int(v)) | ||
132 | } | 136 | } |
133 | - if v, ok := queryOptions["offset"].(int); ok { | ||
134 | - query.Offset(v) | 137 | + if v, ok := queryOptions["offset"].(int64); ok { |
138 | + query.Offset(int(v)) | ||
135 | } | 139 | } |
136 | 140 | ||
137 | if v, ok := queryOptions["timeStart"]; ok { | 141 | if v, ok := queryOptions["timeStart"]; ok { |
@@ -170,7 +174,7 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | @@ -170,7 +174,7 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{} | ||
170 | query.Where("id != ?", notId) | 174 | query.Where("id != ?", notId) |
171 | } | 175 | } |
172 | 176 | ||
173 | - if v, ok := queryOptions["name"]; ok { | 177 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
174 | query.Where("name = ?", v) | 178 | query.Where("name = ?", v) |
175 | } | 179 | } |
176 | 180 |
@@ -22,25 +22,27 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran | @@ -22,25 +22,27 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran | ||
22 | 22 | ||
23 | func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate { | 23 | func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate { |
24 | return domain.EvaluationCycleTemplate{ | 24 | return domain.EvaluationCycleTemplate{ |
25 | - Id: m.Id, | ||
26 | - Name: m.Name, | ||
27 | - Template: m.Template, | ||
28 | - CycleId: m.CycleId, | ||
29 | - CreatedAt: m.CreatedAt, | ||
30 | - UpdatedAt: m.UpdatedAt, | ||
31 | - DeletedAt: m.DeletedAt, | 25 | + Id: m.Id, |
26 | + Name: m.Name, | ||
27 | + TemplateCreatedAt: m.TemplateCreatedAt, | ||
28 | + Template: m.Template, | ||
29 | + CycleId: m.CycleId, | ||
30 | + CreatedAt: m.CreatedAt, | ||
31 | + UpdatedAt: m.UpdatedAt, | ||
32 | + DeletedAt: m.DeletedAt, | ||
32 | } | 33 | } |
33 | } | 34 | } |
34 | 35 | ||
35 | func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.EvaluationCycleTemplate) models.EvaluationCycleTemplate { | 36 | func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.EvaluationCycleTemplate) models.EvaluationCycleTemplate { |
36 | return models.EvaluationCycleTemplate{ | 37 | return models.EvaluationCycleTemplate{ |
37 | - Id: d.Id, | ||
38 | - Name: d.Name, | ||
39 | - Template: d.Template, | ||
40 | - CycleId: d.CycleId, | ||
41 | - CreatedAt: d.CreatedAt, | ||
42 | - UpdatedAt: d.UpdatedAt, | ||
43 | - DeletedAt: d.DeletedAt, | 38 | + Id: d.Id, |
39 | + Name: d.Name, | ||
40 | + TemplateCreatedAt: d.TemplateCreatedAt, | ||
41 | + Template: d.Template, | ||
42 | + CycleId: d.CycleId, | ||
43 | + CreatedAt: d.CreatedAt, | ||
44 | + UpdatedAt: d.UpdatedAt, | ||
45 | + DeletedAt: d.DeletedAt, | ||
44 | } | 46 | } |
45 | } | 47 | } |
46 | 48 | ||
@@ -58,9 +60,14 @@ func (repo *EvaluationCycleTemplateRepository) Insert(d *domain.EvaluationCycleT | @@ -58,9 +60,14 @@ func (repo *EvaluationCycleTemplateRepository) Insert(d *domain.EvaluationCycleT | ||
58 | d.Id = id | 60 | d.Id = id |
59 | d.CreatedAt = time.Now() | 61 | d.CreatedAt = time.Now() |
60 | d.UpdatedAt = d.CreatedAt | 62 | d.UpdatedAt = d.CreatedAt |
63 | + // 模板对象ID也更新 | ||
64 | + if d.Template != nil { | ||
65 | + d.Template.Id = id | ||
66 | + } | ||
61 | } else { | 67 | } else { |
62 | d.UpdatedAt = time.Now() | 68 | d.UpdatedAt = time.Now() |
63 | } | 69 | } |
70 | + | ||
64 | m := repo.TransformToModel(d) | 71 | m := repo.TransformToModel(d) |
65 | tx := repo.transactionContext.PgTx | 72 | tx := repo.transactionContext.PgTx |
66 | var err error | 73 | var err error |
@@ -146,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte | @@ -146,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte | ||
146 | query.Where("cycle_id = ?", v) | 153 | query.Where("cycle_id = ?", v) |
147 | } | 154 | } |
148 | 155 | ||
149 | - if v, ok := queryOptions["limit"].(int); ok { | ||
150 | - query.Limit(v) | 156 | + if v, ok := queryOptions["limit"].(int64); ok { |
157 | + query.Limit(int(v)) | ||
151 | } | 158 | } |
152 | - if v, ok := queryOptions["offset"].(int); ok { | ||
153 | - query.Offset(v) | 159 | + if v, ok := queryOptions["offset"].(int64); ok { |
160 | + query.Offset(int(v)) | ||
154 | } | 161 | } |
155 | 162 | ||
156 | count, err := query.SelectAndCount() | 163 | count, err := query.SelectAndCount() |
@@ -179,7 +186,7 @@ func (repo *EvaluationCycleTemplateRepository) Count(queryOptions map[string]int | @@ -179,7 +186,7 @@ func (repo *EvaluationCycleTemplateRepository) Count(queryOptions map[string]int | ||
179 | query.Where("id != ?", v) | 186 | query.Where("id != ?", v) |
180 | } | 187 | } |
181 | 188 | ||
182 | - if v, ok := queryOptions["name"]; ok { | 189 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
183 | query.Where("name = ?", v) | 190 | query.Where("name = ?", v) |
184 | } | 191 | } |
185 | 192 |
@@ -131,8 +131,12 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | @@ -131,8 +131,12 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | ||
131 | query.ExcludeColumn(excludeColumns...) | 131 | query.ExcludeColumn(excludeColumns...) |
132 | } | 132 | } |
133 | 133 | ||
134 | - if v, ok := queryOptions["name"]; ok { | ||
135 | - query.Where("name = ?", v) | 134 | + if v, ok := queryOptions["ids"]; ok { |
135 | + query.Where("id in (?)", pg.In(v)) | ||
136 | + } | ||
137 | + | ||
138 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { | ||
139 | + query.Where("name LIKE ?", v) | ||
136 | } | 140 | } |
137 | 141 | ||
138 | if v, ok := queryOptions["companyId"]; ok { | 142 | if v, ok := queryOptions["companyId"]; ok { |
@@ -147,23 +151,20 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | @@ -147,23 +151,20 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ | ||
147 | query.Where("state = ?", v) | 151 | query.Where("state = ?", v) |
148 | } | 152 | } |
149 | 153 | ||
150 | - if v, ok := queryOptions["pmpIds"]; ok { | ||
151 | - pmpIds := v.([]string) | ||
152 | - if len(pmpIds) > 0 { | ||
153 | - query.WhereGroup(func(query *pg.Query) (*pg.Query, error) { | ||
154 | - for i := range pmpIds { | ||
155 | - query.WhereOr("pmp_ids @> ?", pmpIds[i]) | ||
156 | - } | ||
157 | - return query, nil | ||
158 | - }) | ||
159 | - } | 154 | + if v, ok := queryOptions["pmpIds"].([]string); ok && len(v) > 0 { |
155 | + query.WhereGroup(func(query *pg.Query) (*pg.Query, error) { | ||
156 | + for i := range v { | ||
157 | + query.WhereOr("pmp_ids @> ?", `"`+v[i]+`"`) | ||
158 | + } | ||
159 | + return query, nil | ||
160 | + }) | ||
160 | } | 161 | } |
161 | 162 | ||
162 | - if v, ok := queryOptions["limit"].(int); ok { | ||
163 | - query.Limit(v) | 163 | + if v, ok := queryOptions["limit"].(int64); ok { |
164 | + query.Limit(int(v)) | ||
164 | } | 165 | } |
165 | - if v, ok := queryOptions["offset"].(int); ok { | ||
166 | - query.Offset(v) | 166 | + if v, ok := queryOptions["offset"].(int64); ok { |
167 | + query.Offset(int(v)) | ||
167 | } | 168 | } |
168 | 169 | ||
169 | count, err := query.SelectAndCount() | 170 | count, err := query.SelectAndCount() |
@@ -192,7 +193,7 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface | @@ -192,7 +193,7 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface | ||
192 | query.Where("id != ?", v) | 193 | query.Where("id != ?", v) |
193 | } | 194 | } |
194 | 195 | ||
195 | - if v, ok := queryOptions["name"]; ok { | 196 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
196 | query.Where("name = ?", v) | 197 | query.Where("name = ?", v) |
197 | } | 198 | } |
198 | 199 |
@@ -123,7 +123,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -123,7 +123,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
123 | query.Where("name LIKE ? or remark LIKE ?", v, v) | 123 | query.Where("name LIKE ? or remark LIKE ?", v, v) |
124 | } | 124 | } |
125 | 125 | ||
126 | - if v, ok := queryOptions["name"]; ok { | 126 | + if v, ok := queryOptions["ids"]; ok { |
127 | + query.Where("id in(?)", pg.In(v)) | ||
128 | + } | ||
129 | + | ||
130 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { | ||
127 | query.Where("name = ?", v) | 131 | query.Where("name = ?", v) |
128 | } | 132 | } |
129 | 133 | ||
@@ -139,13 +143,16 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -139,13 +143,16 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
139 | query.Where("type = ?", v) | 143 | query.Where("type = ?", v) |
140 | } | 144 | } |
141 | 145 | ||
142 | - if v, ok := queryOptions["limit"].(int); ok { | ||
143 | - query.Limit(v) | 146 | + if v, ok := queryOptions["limit"].(int64); ok { |
147 | + query.Limit(int(v)) | ||
144 | } | 148 | } |
145 | - if v, ok := queryOptions["offset"].(int); ok { | ||
146 | - query.Offset(v) | 149 | + if v, ok := queryOptions["offset"].(int64); ok { |
150 | + query.Offset(int(v)) | ||
147 | } | 151 | } |
148 | 152 | ||
153 | + // 按创建时间降序 | ||
154 | + query.Order("created_at DESC") | ||
155 | + | ||
149 | count, err := query.SelectAndCount() | 156 | count, err := query.SelectAndCount() |
150 | if err != nil { | 157 | if err != nil { |
151 | return 0, nil, err | 158 | return 0, nil, err |
@@ -172,7 +179,7 @@ func (repo *EvaluationRuleRepository) Count(queryOptions map[string]interface{}) | @@ -172,7 +179,7 @@ func (repo *EvaluationRuleRepository) Count(queryOptions map[string]interface{}) | ||
172 | query.Where("id != ?", v) | 179 | query.Where("id != ?", v) |
173 | } | 180 | } |
174 | 181 | ||
175 | - if v, ok := queryOptions["name"]; ok { | 182 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
176 | query.Where("name = ?", v) | 183 | query.Where("name = ?", v) |
177 | } | 184 | } |
178 | 185 |
@@ -129,7 +129,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -129,7 +129,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
129 | query.Where("id != ?", v) | 129 | query.Where("id != ?", v) |
130 | } | 130 | } |
131 | 131 | ||
132 | - if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { | 132 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
133 | query.Where("name LIKE ?", v) | 133 | query.Where("name LIKE ?", v) |
134 | } | 134 | } |
135 | 135 | ||
@@ -142,16 +142,27 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -142,16 +142,27 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
142 | } | 142 | } |
143 | 143 | ||
144 | if v, ok := queryOptions["createdAt"]; ok { | 144 | if v, ok := queryOptions["createdAt"]; ok { |
145 | - query.Where("created_at = ?", v) | 145 | + ts := v.(string) |
146 | + t, err := time.ParseInLocation("2006-01-02", ts, time.Local) | ||
147 | + if err == nil { | ||
148 | + year, month, day := t.Date() | ||
149 | + begin := time.Date(year, month, day, 0, 0, 0, 0, time.Local) | ||
150 | + end := time.Date(year, month, day, 23, 59, 59, 0, time.Local) | ||
151 | + query.Where("created_at >= ?", begin) | ||
152 | + query.Where("created_at <= ?", end) | ||
153 | + } | ||
146 | } | 154 | } |
147 | 155 | ||
148 | - if v, ok := queryOptions["limit"].(int); ok { | ||
149 | - query.Limit(v) | 156 | + if v, ok := queryOptions["limit"].(int64); ok { |
157 | + query.Limit(int(v)) | ||
150 | } | 158 | } |
151 | - if v, ok := queryOptions["offset"].(int); ok { | ||
152 | - query.Offset(v) | 159 | + if v, ok := queryOptions["offset"].(int64); ok { |
160 | + query.Offset(int(v)) | ||
153 | } | 161 | } |
154 | 162 | ||
163 | + // 按创建时间降序 | ||
164 | + query.Order("created_at DESC") | ||
165 | + | ||
155 | count, err := query.SelectAndCount() | 166 | count, err := query.SelectAndCount() |
156 | if err != nil { | 167 | if err != nil { |
157 | return 0, nil, err | 168 | return 0, nil, err |
@@ -178,7 +189,7 @@ func (repo *EvaluationTemplateRepository) Count(queryOptions map[string]interfac | @@ -178,7 +189,7 @@ func (repo *EvaluationTemplateRepository) Count(queryOptions map[string]interfac | ||
178 | query.Where("id != ?", v) | 189 | query.Where("id != ?", v) |
179 | } | 190 | } |
180 | 191 | ||
181 | - if v, ok := queryOptions["name"]; ok { | 192 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
182 | query.Where("name = ?", v) | 193 | query.Where("name = ?", v) |
183 | } | 194 | } |
184 | 195 |
1 | +package repository | ||
2 | + | ||
3 | +import ( | ||
4 | + "errors" | ||
5 | + "fmt" | ||
6 | + "time" | ||
7 | + | ||
8 | + "github.com/go-pg/pg/v10" | ||
9 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | ||
13 | +) | ||
14 | + | ||
15 | +type NodeTaskRepository struct { | ||
16 | + transactionContext *pgTransaction.TransactionContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewNodeTaskRepository(transactionContext *pgTransaction.TransactionContext) *NodeTaskRepository { | ||
20 | + return &NodeTaskRepository{transactionContext: transactionContext} | ||
21 | +} | ||
22 | + | ||
23 | +func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.NodeTask { | ||
24 | + return domain.NodeTask{ | ||
25 | + Id: m.Id, | ||
26 | + CompanyId: m.CompanyId, | ||
27 | + CycleId: m.CycleId, | ||
28 | + ProjectId: m.ProjectId, | ||
29 | + NodeId: m.NodeId, | ||
30 | + NodeType: m.NodeType, | ||
31 | + NodeName: m.NodeName, | ||
32 | + NodeDescribe: m.NodeDescribe, | ||
33 | + NodeSort: m.NodeSort, | ||
34 | + TimeStart: m.TimeStart, | ||
35 | + TimeEnd: m.TimeEnd, | ||
36 | + KpiCycle: m.KpiCycle, | ||
37 | + NextSentAt: m.NextSentAt, | ||
38 | + CreatedAt: m.CreatedAt, | ||
39 | + UpdatedAt: m.UpdatedAt, | ||
40 | + DeletedAt: m.DeletedAt, | ||
41 | + } | ||
42 | +} | ||
43 | + | ||
44 | +func (repo *NodeTaskRepository) TransformToModel(d *domain.NodeTask) models.NodeTask { | ||
45 | + return models.NodeTask{ | ||
46 | + Id: d.Id, | ||
47 | + CompanyId: d.CompanyId, | ||
48 | + CycleId: d.CycleId, | ||
49 | + ProjectId: d.ProjectId, | ||
50 | + NodeId: d.NodeId, | ||
51 | + NodeType: d.NodeType, | ||
52 | + NodeName: d.NodeName, | ||
53 | + NodeDescribe: d.NodeDescribe, | ||
54 | + NodeSort: d.NodeSort, | ||
55 | + TimeStart: d.TimeStart, | ||
56 | + TimeEnd: d.TimeEnd, | ||
57 | + KpiCycle: d.KpiCycle, | ||
58 | + NextSentAt: d.NextSentAt, | ||
59 | + CreatedAt: d.CreatedAt, | ||
60 | + UpdatedAt: d.UpdatedAt, | ||
61 | + DeletedAt: d.DeletedAt, | ||
62 | + } | ||
63 | +} | ||
64 | + | ||
65 | +func (repo *NodeTaskRepository) nextIdentify() (int64, error) { | ||
66 | + return utils.NewSnowflakeId() | ||
67 | +} | ||
68 | + | ||
69 | +func (repo *NodeTaskRepository) Insert(d *domain.NodeTask) (*domain.NodeTask, error) { | ||
70 | + var isCreate = d.Id == 0 | ||
71 | + if isCreate { | ||
72 | + id, err := repo.nextIdentify() | ||
73 | + if err != nil { | ||
74 | + return d, err | ||
75 | + } | ||
76 | + d.Id = id | ||
77 | + d.CreatedAt = time.Now() | ||
78 | + d.UpdatedAt = d.CreatedAt | ||
79 | + } else { | ||
80 | + d.UpdatedAt = time.Now() | ||
81 | + } | ||
82 | + m := repo.TransformToModel(d) | ||
83 | + tx := repo.transactionContext.PgTx | ||
84 | + var err error | ||
85 | + if isCreate { | ||
86 | + _, err = tx.Model(&m).Returning("id").Insert() | ||
87 | + } else { | ||
88 | + _, err = tx.Model(&m).Returning("id").WherePK().Update() // 更新和删除必须增加条件 | ||
89 | + } | ||
90 | + if err != nil { | ||
91 | + return nil, err | ||
92 | + } | ||
93 | + d.Id = m.Id | ||
94 | + return d, nil | ||
95 | +} | ||
96 | + | ||
97 | +func (repo *NodeTaskRepository) Remove(d *domain.NodeTask) (*domain.NodeTask, error) { | ||
98 | + tx := repo.transactionContext.PgTx | ||
99 | + nowTime := time.Now() | ||
100 | + m := repo.TransformToModel(d) | ||
101 | + m.DeletedAt = &nowTime | ||
102 | + if _, err := tx.Model(&m).WherePK().Update(); err != nil { | ||
103 | + return d, err | ||
104 | + } | ||
105 | + return d, nil | ||
106 | +} | ||
107 | + | ||
108 | +func (repo *NodeTaskRepository) FindOne(queryOptions map[string]interface{}) (*domain.NodeTask, error) { | ||
109 | + tx := repo.transactionContext.PgTx | ||
110 | + m := new(models.NodeTask) | ||
111 | + query := tx.Model(m) | ||
112 | + query.Where("deleted_at isnull") | ||
113 | + if id, ok := queryOptions["id"]; ok { | ||
114 | + query.Where("id=?", id) | ||
115 | + } | ||
116 | + if err := query.First(); err != nil { | ||
117 | + if errors.Is(err, pg.ErrNoRows) { | ||
118 | + return nil, fmt.Errorf("没有此资源") | ||
119 | + } else { | ||
120 | + return nil, err | ||
121 | + } | ||
122 | + } | ||
123 | + u := repo.TransformToDomain(m) | ||
124 | + return &u, nil | ||
125 | +} | ||
126 | + | ||
127 | +func (repo *NodeTaskRepository) Find(queryOptions map[string]interface{}) ([]*domain.NodeTask, error) { | ||
128 | + tx := repo.transactionContext.PgTx | ||
129 | + var m []*models.NodeTask | ||
130 | + query := tx.Model(&m).Where("deleted_at isnull") | ||
131 | + | ||
132 | + if v, ok := queryOptions["now"].(time.Time); ok { | ||
133 | + query.Where("next_sent_at <= ?", v) | ||
134 | + } | ||
135 | + | ||
136 | + if v, ok := queryOptions["ids"]; ok { | ||
137 | + query.Where("id in(?)", pg.In(v)) | ||
138 | + } | ||
139 | + | ||
140 | + if v, ok := queryOptions["companyId"]; ok { | ||
141 | + query.Where("company_id = ?", v) | ||
142 | + } | ||
143 | + | ||
144 | + if v, ok := queryOptions["cycleId"]; ok { | ||
145 | + query.Where("cycle_id = ?", v) | ||
146 | + } | ||
147 | + | ||
148 | + if v, ok := queryOptions["projectId"]; ok { | ||
149 | + query.Where("project_id = ?", v) | ||
150 | + } | ||
151 | + | ||
152 | + if v, ok := queryOptions["nodeId"]; ok { | ||
153 | + query.Where("node_id = ?", v) | ||
154 | + } | ||
155 | + | ||
156 | + err := query.Select() | ||
157 | + if err != nil { | ||
158 | + return nil, err | ||
159 | + } | ||
160 | + var arrays []*domain.NodeTask | ||
161 | + for _, v := range m { | ||
162 | + d := repo.TransformToDomain(v) | ||
163 | + arrays = append(arrays, &d) | ||
164 | + } | ||
165 | + return arrays, nil | ||
166 | +} |
1 | package repository | 1 | package repository |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "time" | ||
5 | + | ||
4 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
5 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" |
8 | - "time" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type PositionRepository struct { | 12 | type PositionRepository struct { |
@@ -66,6 +67,37 @@ func (repository *PositionRepository) FindOne(queryOption map[string]interface{} | @@ -66,6 +67,37 @@ func (repository *PositionRepository) FindOne(queryOption map[string]interface{} | ||
66 | return repository.transferToDomain(position), nil | 67 | return repository.transferToDomain(position), nil |
67 | } | 68 | } |
68 | 69 | ||
70 | +func (repo *PositionRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Position, error) { | ||
71 | + tx := repo.transactionContext.PgTx | ||
72 | + positionModel := []models.Position{} | ||
73 | + query := tx.Model(&positionModel) | ||
74 | + if v, ok := queryOptions["id"]; ok { | ||
75 | + query.Where("id=?", v) | ||
76 | + } | ||
77 | + if v, ok := queryOptions["ids"]; ok { | ||
78 | + query.Where("id in(?)", pg.In(v)) | ||
79 | + } | ||
80 | + if v, ok := queryOptions["companyId"]; ok { | ||
81 | + query.Where("company_id=?", v) | ||
82 | + } | ||
83 | + if v, ok := queryOptions["offset"]; ok { | ||
84 | + query.Offset(v.(int)) | ||
85 | + } | ||
86 | + if v, ok := queryOptions["limit"]; ok { | ||
87 | + query.Limit(v.(int)) | ||
88 | + } | ||
89 | + cnt, err := query.SelectAndCount() | ||
90 | + if err != nil { | ||
91 | + return 0, nil, err | ||
92 | + } | ||
93 | + var resultList []*domain.Position | ||
94 | + for i := range positionModel { | ||
95 | + result := repo.transferToDomain(&positionModel[i]) | ||
96 | + resultList = append(resultList, result) | ||
97 | + } | ||
98 | + return cnt, resultList, nil | ||
99 | +} | ||
100 | + | ||
69 | func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position { | 101 | func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position { |
70 | return &domain.Position{ | 102 | return &domain.Position{ |
71 | Id: model.Id, | 103 | Id: model.Id, |
@@ -113,19 +113,19 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | @@ -113,19 +113,19 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, [] | ||
113 | var m []*models.Role | 113 | var m []*models.Role |
114 | query := tx.Model(&m).Where("deleted_at isnull") | 114 | query := tx.Model(&m).Where("deleted_at isnull") |
115 | 115 | ||
116 | - if name, ok := queryOptions["name"]; ok { | ||
117 | - query.Where("name = ?", name) | 116 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
117 | + query.Where("name = ?", v) | ||
118 | } | 118 | } |
119 | 119 | ||
120 | if companyId, ok := queryOptions["companyId"]; ok { | 120 | if companyId, ok := queryOptions["companyId"]; ok { |
121 | query.Where("company_id = ?", companyId) | 121 | query.Where("company_id = ?", companyId) |
122 | } | 122 | } |
123 | 123 | ||
124 | - if v, ok := queryOptions["limit"].(int); ok { | ||
125 | - query.Limit(v) | 124 | + if v, ok := queryOptions["limit"].(int64); ok { |
125 | + query.Limit(int(v)) | ||
126 | } | 126 | } |
127 | - if v, ok := queryOptions["offset"].(int); ok { | ||
128 | - query.Offset(v) | 127 | + if v, ok := queryOptions["offset"].(int64); ok { |
128 | + query.Offset(int(v)) | ||
129 | } | 129 | } |
130 | 130 | ||
131 | count, err := query.SelectAndCount() | 131 | count, err := query.SelectAndCount() |
@@ -154,8 +154,8 @@ func (repo *RoleRepository) Count(queryOptions map[string]interface{}) (int64, e | @@ -154,8 +154,8 @@ func (repo *RoleRepository) Count(queryOptions map[string]interface{}) (int64, e | ||
154 | query.Where("id != ?", notId) | 154 | query.Where("id != ?", notId) |
155 | } | 155 | } |
156 | 156 | ||
157 | - if name, ok := queryOptions["name"]; ok { | ||
158 | - query.Where("name = ?", name) | 157 | + if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
158 | + query.Where("name = ?", v) | ||
159 | } | 159 | } |
160 | 160 | ||
161 | if companyId, ok := queryOptions["companyId"]; ok { | 161 | if companyId, ok := queryOptions["companyId"]; ok { |
-
请 注册 或 登录 后发表评论