正在显示
41 个修改的文件
包含
1803 行增加
和
1149 行删除
| @@ -7,3 +7,8 @@ prod 环境 http://performance-back-prd.fjmaimaimai.com/ | @@ -7,3 +7,8 @@ prod 环境 http://performance-back-prd.fjmaimaimai.com/ | ||
| 7 | 7 | ||
| 8 | 前端页面地址 | 8 | 前端页面地址 |
| 9 | test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login | 9 | test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login |
| 10 | + | ||
| 11 | +测试账号 17708397664 密码123456 | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +短信模板ID:5475050 短信内容: 您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦 |
| @@ -10,6 +10,7 @@ require ( | @@ -10,6 +10,7 @@ require ( | ||
| 10 | github.com/bwmarrin/snowflake v0.3.0 | 10 | github.com/bwmarrin/snowflake v0.3.0 |
| 11 | github.com/dgrijalva/jwt-go v3.2.0+incompatible | 11 | github.com/dgrijalva/jwt-go v3.2.0+incompatible |
| 12 | github.com/go-pg/pg/v10 v10.10.7 | 12 | github.com/go-pg/pg/v10 v10.10.7 |
| 13 | + github.com/go-redis/redis/v8 v8.11.5 | ||
| 13 | github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d | 14 | github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d |
| 14 | github.com/xuri/excelize/v2 v2.6.1 | 15 | github.com/xuri/excelize/v2 v2.6.1 |
| 15 | ) | 16 | ) |
| @@ -120,6 +120,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c | @@ -120,6 +120,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c | ||
| 120 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 120 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
| 121 | github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= | 121 | github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= |
| 122 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= | 122 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= |
| 123 | +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= | ||
| 124 | +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= | ||
| 123 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | 125 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= |
| 124 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | 126 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= |
| 125 | github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= | 127 | github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= |
| @@ -171,12 +173,16 @@ github.com/go-pg/pg/v10 v10.10.7 h1:Q7Bs45kP9MIg03v/ejwdqsPd1T0cecgeDoTJVg/UJuQ= | @@ -171,12 +173,16 @@ github.com/go-pg/pg/v10 v10.10.7 h1:Q7Bs45kP9MIg03v/ejwdqsPd1T0cecgeDoTJVg/UJuQ= | ||
| 171 | github.com/go-pg/pg/v10 v10.10.7/go.mod h1:GLmFXufrElQHf5uzM3BQlcfwV3nsgnHue5uzjQ6Nqxg= | 173 | github.com/go-pg/pg/v10 v10.10.7/go.mod h1:GLmFXufrElQHf5uzM3BQlcfwV3nsgnHue5uzjQ6Nqxg= |
| 172 | github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU= | 174 | github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU= |
| 173 | github.com/go-pg/zerochecker v0.2.0/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo= | 175 | github.com/go-pg/zerochecker v0.2.0/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo= |
| 176 | +github.com/go-redis/redis v6.14.2+incompatible h1:UE9pLhzmWf+xHNmZsoccjXosPicuiNaInPgym8nzfg0= | ||
| 174 | github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= | 177 | github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= |
| 175 | github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= | 178 | github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= |
| 179 | +github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= | ||
| 180 | +github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= | ||
| 176 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | 181 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= |
| 177 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | 182 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= |
| 178 | github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | 183 | github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= |
| 179 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= | 184 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
| 185 | +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= | ||
| 180 | github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | 186 | github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= |
| 181 | github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= | 187 | github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= |
| 182 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= | 188 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= |
| @@ -241,6 +247,7 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf | @@ -241,6 +247,7 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf | ||
| 241 | github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= | 247 | github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= |
| 242 | github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= | 248 | github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= |
| 243 | github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= | 249 | github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= |
| 250 | +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= | ||
| 244 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= | 251 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= |
| 245 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 252 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| 246 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 253 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| @@ -284,6 +291,7 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J | @@ -284,6 +291,7 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J | ||
| 284 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= | 291 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |
| 285 | github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= | 292 | github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= |
| 286 | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= | 293 | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= |
| 294 | +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= | ||
| 287 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= | 295 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= |
| 288 | github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= | 296 | github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= |
| 289 | github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjLBdCp5PRlCFijNjvcYANOZXzCfXwCM= | 297 | github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjLBdCp5PRlCFijNjvcYANOZXzCfXwCM= |
| @@ -364,8 +372,9 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi | @@ -364,8 +372,9 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi | ||
| 364 | github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= | 372 | github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= |
| 365 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= | 373 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= |
| 366 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= | 374 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= |
| 367 | -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= | ||
| 368 | github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= | 375 | github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= |
| 376 | +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= | ||
| 377 | +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= | ||
| 369 | github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= | 378 | github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= |
| 370 | github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= | 379 | github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= |
| 371 | github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= | 380 | github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= |
| @@ -374,14 +383,19 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W | @@ -374,14 +383,19 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W | ||
| 374 | github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | 383 | github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
| 375 | github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= | 384 | github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= |
| 376 | github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= | 385 | github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= |
| 377 | -github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M= | ||
| 378 | github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= | 386 | github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= |
| 387 | +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= | ||
| 388 | +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= | ||
| 389 | +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= | ||
| 390 | +github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= | ||
| 379 | github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= | 391 | github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
| 380 | github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= | 392 | github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
| 381 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= | 393 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= |
| 382 | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | 394 | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= |
| 383 | -github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= | ||
| 384 | github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= | 395 | github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= |
| 396 | +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= | ||
| 397 | +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= | ||
| 398 | +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= | ||
| 385 | github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= | 399 | github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= |
| 386 | github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= | 400 | github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= |
| 387 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= | 401 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= |
| @@ -656,6 +670,7 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY | @@ -656,6 +670,7 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY | ||
| 656 | golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | 670 | golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |
| 657 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | 671 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
| 658 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= | 672 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= |
| 673 | +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= | ||
| 659 | golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | 674 | golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
| 660 | golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | 675 | golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
| 661 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | 676 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
| @@ -725,6 +740,7 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w | @@ -725,6 +740,7 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w | ||
| 725 | golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 740 | golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| 726 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 741 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| 727 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 742 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| 743 | +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| 728 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 744 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| 729 | golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 745 | golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| 730 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 746 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
| @@ -735,6 +751,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc | @@ -735,6 +751,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc | ||
| 735 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 751 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| 736 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 752 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| 737 | golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 753 | golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| 754 | +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
| 738 | golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 755 | golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| 739 | golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg= | 756 | golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg= |
| 740 | golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 757 | golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| @@ -803,12 +820,12 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc | @@ -803,12 +820,12 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc | ||
| 803 | golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= | 820 | golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= |
| 804 | golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= | 821 | golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= |
| 805 | golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | 822 | golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= |
| 823 | +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | ||
| 806 | golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | 824 | golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= |
| 807 | golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= | 825 | golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= |
| 808 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 826 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
| 809 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 827 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
| 810 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 828 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
| 811 | -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= | ||
| 812 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 829 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
| 813 | google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= | 830 | google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= |
| 814 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= | 831 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= |
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 5 | "time" | 4 | "time" |
| 6 | 5 | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 7 | + | ||
| 7 | "github.com/beego/beego/v2/server/web" | 8 | "github.com/beego/beego/v2/server/web" |
| 8 | serviceTask "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" | 9 | serviceTask "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" |
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify" | ||
| 11 | + serviceSummary "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/service" | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
| 10 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" | 13 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" |
| @@ -13,12 +16,8 @@ import ( | @@ -13,12 +16,8 @@ import ( | ||
| 13 | 16 | ||
| 14 | func main() { | 17 | func main() { |
| 15 | startNodeTask() | 18 | startNodeTask() |
| 16 | - | ||
| 17 | - // tree := web.PrintTree() | ||
| 18 | - // methods := tree["Data"].(web.M) | ||
| 19 | - // for k, v := range methods { | ||
| 20 | - // fmt.Printf("%s => %v \n", k, v) | ||
| 21 | - // } | 19 | + startSummaryEvaluation() |
| 20 | + go notify.RunTaskSmsNotify() | ||
| 22 | go consumer.Run() | 21 | go consumer.Run() |
| 23 | web.Run() | 22 | web.Run() |
| 24 | } | 23 | } |
| @@ -27,7 +26,7 @@ func main() { | @@ -27,7 +26,7 @@ func main() { | ||
| 27 | func startNodeTask() { | 26 | func startNodeTask() { |
| 28 | go func() { | 27 | go func() { |
| 29 | nodeTaskService := serviceTask.NewNodeTaskService() | 28 | nodeTaskService := serviceTask.NewNodeTaskService() |
| 30 | - for { | 29 | + |
| 31 | var duration time.Duration | 30 | var duration time.Duration |
| 32 | if constant.Env == "prd" { | 31 | if constant.Env == "prd" { |
| 33 | duration = time.Minute * 5 | 32 | duration = time.Minute * 5 |
| @@ -35,10 +34,32 @@ func startNodeTask() { | @@ -35,10 +34,32 @@ func startNodeTask() { | ||
| 35 | duration = time.Minute * 1 | 34 | duration = time.Minute * 1 |
| 36 | } | 35 | } |
| 37 | timer := time.NewTimer(duration) | 36 | timer := time.NewTimer(duration) |
| 37 | + for { | ||
| 38 | <-timer.C | 38 | <-timer.C |
| 39 | if err := nodeTaskService.SendEvaluationNode(); err != nil { | 39 | if err := nodeTaskService.SendEvaluationNode(); err != nil { |
| 40 | log.Logger.Error(err.Error()) | 40 | log.Logger.Error(err.Error()) |
| 41 | } | 41 | } |
| 42 | + timer.Reset(duration) // 重置定时 | ||
| 43 | + } | ||
| 44 | + }() | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +// 定时任务-间隔检查时间,发送周期评估 | ||
| 48 | +func startSummaryEvaluation() { | ||
| 49 | + go func() { | ||
| 50 | + var duration time.Duration | ||
| 51 | + if constant.Env == "prd" { | ||
| 52 | + duration = time.Minute * 5 | ||
| 53 | + } else { | ||
| 54 | + duration = time.Minute * 1 | ||
| 55 | + } | ||
| 56 | + timer := time.NewTimer(duration) | ||
| 57 | + for { | ||
| 58 | + <-timer.C | ||
| 59 | + if err := serviceSummary.TaskSendSummaryEvaluation(); err != nil { | ||
| 60 | + log.Logger.Error(err.Error()) | ||
| 61 | + } | ||
| 62 | + timer.Reset(duration) // 重置定时 | ||
| 42 | } | 63 | } |
| 43 | }() | 64 | }() |
| 44 | } | 65 | } |
| @@ -31,3 +31,20 @@ func TestFontToken(t *testing.T) { | @@ -31,3 +31,20 @@ func TestFontToken(t *testing.T) { | ||
| 31 | } | 31 | } |
| 32 | fmt.Println(userAuth.CreateAccessToken()) | 32 | fmt.Println(userAuth.CreateAccessToken()) |
| 33 | } | 33 | } |
| 34 | + | ||
| 35 | +func TestOtherAccountToken(t *testing.T) { | ||
| 36 | + domain.JWTExpiresSecond = 3600 * 24 * 365 | ||
| 37 | + userAuth := &domain.UserAuth{ | ||
| 38 | + UserId: 3422174102828544, | ||
| 39 | + CompanyId: 8, | ||
| 40 | + Phone: "17708397664", | ||
| 41 | + PlatformId: 29, | ||
| 42 | + Name: "杨欢", | ||
| 43 | + AdminType: 1, | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + tk, _ := userAuth.CreateAccessToken() | ||
| 47 | + t.Log(tk) | ||
| 48 | + | ||
| 49 | + //fmt.Println(userAuth.CreateAccessToken()) | ||
| 50 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +type DepartmentAdapter struct { | ||
| 4 | + Id int64 `comment:"部门ID" json:"id,string"` | ||
| 5 | + Name string `comment:"部门名称" json:"name"` | ||
| 6 | + CompanyId int64 `comment:"公司ID" json:"companyId,string"` | ||
| 7 | + ParentId int64 `comment:"父级ID" json:"parentId,string"` | ||
| 8 | + Departments []*DepartmentAdapter `comment:"子部门" json:"departments"` | ||
| 9 | + UserTotal int `comment:"部门用户总数量(包含子部门)" json:"userTotal"` | ||
| 10 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +import "github.com/beego/beego/v2/core/validation" | ||
| 4 | + | ||
| 5 | +// QueryDepartmentCommand 查询公司的所有部门和人数 | ||
| 6 | +type QueryDepartmentCommand struct { | ||
| 7 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +func (in *QueryDepartmentCommand) Valid(*validation.Validation) { | ||
| 11 | + | ||
| 12 | +} |
| 1 | +package department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/linmadan/egglib-go/core/application" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/department/adapter" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/department/command" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type SDepartmentService struct{} | ||
| 11 | + | ||
| 12 | +func NewDepartmentService() *SDepartmentService { | ||
| 13 | + newService := &SDepartmentService{} | ||
| 14 | + return newService | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +func (ds *SDepartmentService) ListAndCount(in *command.QueryDepartmentCommand) (interface{}, error) { | ||
| 18 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 19 | + if err != nil { | ||
| 20 | + return nil, err | ||
| 21 | + } | ||
| 22 | + defer func() { | ||
| 23 | + transactionContext.RollbackTransaction() | ||
| 24 | + }() | ||
| 25 | + departmentRepository := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 26 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 27 | + companyRepository := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 28 | + | ||
| 29 | + departments, err := departmentRepository.FindAll(in.CompanyId) | ||
| 30 | + if err != nil { | ||
| 31 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + adapters := make([]*adapter.DepartmentAdapter, 0) | ||
| 35 | + mapDep := map[int64]*adapter.DepartmentAdapter{} | ||
| 36 | + mapDepNum := map[int64]int{} | ||
| 37 | + // 已经按等级Level升序排序, 1级> 2级> ... | ||
| 38 | + for i := range departments { | ||
| 39 | + | ||
| 40 | + apt := &adapter.DepartmentAdapter{ | ||
| 41 | + Id: departments[i].Id, | ||
| 42 | + Name: departments[i].Name, | ||
| 43 | + CompanyId: departments[i].CompanyId, | ||
| 44 | + ParentId: departments[i].ParentId, | ||
| 45 | + Departments: make([]*adapter.DepartmentAdapter, 0), | ||
| 46 | + } | ||
| 47 | + mapDep[apt.Id] = apt | ||
| 48 | + | ||
| 49 | + // 一级节点 | ||
| 50 | + if apt.ParentId == 0 { | ||
| 51 | + adapters = append(adapters, apt) | ||
| 52 | + } else { | ||
| 53 | + // 上级节点若存在,加到上级的子节点 | ||
| 54 | + if parent, ok := mapDep[apt.ParentId]; ok { | ||
| 55 | + parent.Departments = append(parent.Departments, apt) | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + // 所有部门ID | ||
| 60 | + mapDepNum[apt.Id] = 0 | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + // 获取公司信息 | ||
| 64 | + company, err := companyRepository.FindOne(map[string]interface{}{"id": in.CompanyId}) | ||
| 65 | + if err != nil { | ||
| 66 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + // 获取所有用户 | ||
| 70 | + userCount, users, err := userRepository.Find(map[string]interface{}{"companyId": in.CompanyId}) | ||
| 71 | + if err != nil { | ||
| 72 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + for i := range users { | ||
| 76 | + v := users[i] | ||
| 77 | + // 注.如果用户部门下挂到公司下,顶级公司数量暂时使用所有用户数量(userCount) | ||
| 78 | + for _, depId := range v.DepartmentId { | ||
| 79 | + if count, ok := mapDepNum[int64(depId)]; ok { | ||
| 80 | + mapDepNum[int64(depId)] = count + 1 // 部门数量 + 1 | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + // 计算部门下的用户总数量 | ||
| 86 | + ds.calculateChildTotal(mapDepNum, adapters) | ||
| 87 | + | ||
| 88 | + // 创建顶级部门(公司) | ||
| 89 | + top := make([]*adapter.DepartmentAdapter, 0) | ||
| 90 | + top = append(top, &adapter.DepartmentAdapter{ | ||
| 91 | + Id: 0, | ||
| 92 | + Name: company.Name, | ||
| 93 | + CompanyId: company.Id, | ||
| 94 | + ParentId: 0, | ||
| 95 | + Departments: adapters, | ||
| 96 | + UserTotal: userCount, // 公司下的所有用户 | ||
| 97 | + }) | ||
| 98 | + | ||
| 99 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 100 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 101 | + } | ||
| 102 | + return map[string]interface{}{"list": top}, nil | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +// 计算子部门总量 | ||
| 106 | +func (ds *SDepartmentService) calculateChildTotal(mapDepNum map[int64]int, departments []*adapter.DepartmentAdapter) int { | ||
| 107 | + var total = 0 | ||
| 108 | + for i := range departments { | ||
| 109 | + // 子部门总数量 | ||
| 110 | + var childTotal = ds.calculateChildTotal(mapDepNum, departments[i].Departments) | ||
| 111 | + // 当前部门数量 | ||
| 112 | + if count, ok := mapDepNum[departments[i].Id]; ok { | ||
| 113 | + childTotal += count | ||
| 114 | + } | ||
| 115 | + // 更新部门数量 | ||
| 116 | + departments[i].UserTotal = childTotal | ||
| 117 | + | ||
| 118 | + total += childTotal | ||
| 119 | + } | ||
| 120 | + return total | ||
| 121 | +} |
| @@ -160,6 +160,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -160,6 +160,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 160 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | 160 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 161 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 161 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 162 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 162 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 163 | + ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 163 | 164 | ||
| 164 | // 检测名称重复(排除自己) | 165 | // 检测名称重复(排除自己) |
| 165 | count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId, "notId": in.Id}) | 166 | count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId, "notId": in.Id}) |
| @@ -208,8 +209,49 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -208,8 +209,49 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 208 | if err != nil { | 209 | if err != nil { |
| 209 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 210 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 210 | } | 211 | } |
| 212 | + | ||
| 213 | + // 获取所有模板中的规则对象数据 | ||
| 214 | + ruleMap := map[int64]*domain.EvaluationRule{} | ||
| 215 | + for i := range templates { | ||
| 216 | + v := templates[i] | ||
| 217 | + for j := range v.LinkNodes { | ||
| 218 | + node := v.LinkNodes[j] | ||
| 219 | + for k := range node.NodeContents { | ||
| 220 | + nodeContent := node.NodeContents[k] | ||
| 221 | + if nodeContent.RuleId != 0 { | ||
| 222 | + ruleMap[nodeContent.RuleId] = nil | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + ruleIds := make([]int64, 0) | ||
| 228 | + for k := range ruleMap { | ||
| 229 | + ruleIds = append(ruleIds, k) | ||
| 230 | + } | ||
| 231 | + if len(ruleIds) > 0 { | ||
| 232 | + if _, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId}); err != nil { | ||
| 233 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 234 | + } else { | ||
| 235 | + for i := range rules { | ||
| 236 | + ruleMap[rules[i].Id] = rules[i] | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | + | ||
| 211 | for i := range templates { | 241 | for i := range templates { |
| 212 | v := templates[i] | 242 | v := templates[i] |
| 243 | + | ||
| 244 | + // 对评估模板中的评估规则进行数据赋值 | ||
| 245 | + for j := range v.LinkNodes { | ||
| 246 | + node := v.LinkNodes[j] | ||
| 247 | + for k := range node.NodeContents { | ||
| 248 | + nodeContent := node.NodeContents[k] | ||
| 249 | + if rule, ok := ruleMap[nodeContent.RuleId]; ok { | ||
| 250 | + nodeContent.Rule = rule | ||
| 251 | + } | ||
| 252 | + } | ||
| 253 | + } | ||
| 254 | + | ||
| 213 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 255 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
| 214 | Id: 0, | 256 | Id: 0, |
| 215 | Name: v.Name, | 257 | Name: v.Name, |
| @@ -2,6 +2,9 @@ package service | @@ -2,6 +2,9 @@ package service | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | + "strconv" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 5 | "github.com/linmadan/egglib-go/core/application" | 8 | "github.com/linmadan/egglib-go/core/application" |
| 6 | "github.com/linmadan/egglib-go/utils/tool_funs" | 9 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/adapter" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/adapter" |
| @@ -9,8 +12,6 @@ import ( | @@ -9,8 +12,6 @@ import ( | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" |
| 12 | - "strconv" | ||
| 13 | - "time" | ||
| 14 | ) | 15 | ) |
| 15 | 16 | ||
| 16 | type EvaluationProjectService struct { | 17 | type EvaluationProjectService struct { |
| @@ -251,7 +252,6 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -251,7 +252,6 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
| 251 | node.TimeStart = &start | 252 | node.TimeStart = &start |
| 252 | node.TimeEnd = &end | 253 | node.TimeEnd = &end |
| 253 | } | 254 | } |
| 254 | - | ||
| 255 | project, err = projectRepository.Insert(project) | 255 | project, err = projectRepository.Insert(project) |
| 256 | if err != nil { | 256 | if err != nil { |
| 257 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 257 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -365,7 +365,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in | @@ -365,7 +365,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in | ||
| 365 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 365 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 366 | taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | 366 | taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 367 | staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | 367 | staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 368 | - | 368 | + summaryRepository := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 369 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | 369 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) |
| 370 | if err != nil { | 370 | if err != nil { |
| 371 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 371 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -378,7 +378,10 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in | @@ -378,7 +378,10 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in | ||
| 378 | if err := staffRepository.RemoveByProjectId(int(project.Id)); err != nil { | 378 | if err := staffRepository.RemoveByProjectId(int(project.Id)); err != nil { |
| 379 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 379 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 380 | } | 380 | } |
| 381 | - | 381 | + // 删除项目已生成的周期评估数据 |
| 382 | + if err := summaryRepository.RemoveByProjectId(int(project.Id)); err != nil { | ||
| 383 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 384 | + } | ||
| 382 | // 移除项目关联的所有定时任务 | 385 | // 移除项目关联的所有定时任务 |
| 383 | tasks, err := taskRepository.Find(map[string]interface{}{"projectId": project.Id}) | 386 | tasks, err := taskRepository.Find(map[string]interface{}{"projectId": project.Id}) |
| 384 | if err != nil { | 387 | if err != nil { |
| @@ -521,6 +524,11 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -521,6 +524,11 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
| 521 | } | 524 | } |
| 522 | } | 525 | } |
| 523 | 526 | ||
| 527 | + err = rs.generateEvaluationItemUsed(transactionContext, project) | ||
| 528 | + if err != nil { | ||
| 529 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 530 | + } | ||
| 531 | + | ||
| 524 | if err := transactionContext.CommitTransaction(); err != nil { | 532 | if err := transactionContext.CommitTransaction(); err != nil { |
| 525 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 533 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 526 | } | 534 | } |
| @@ -600,3 +608,46 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | @@ -600,3 +608,46 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo | ||
| 600 | } | 608 | } |
| 601 | return map[string]interface{}{"repeatNum": repeatNum}, nil | 609 | return map[string]interface{}{"repeatNum": repeatNum}, nil |
| 602 | } | 610 | } |
| 611 | + | ||
| 612 | +func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContext application.TransactionContext, project *domain.EvaluationProject) error { | ||
| 613 | + | ||
| 614 | + var itemUsedList []*domain.EvaluationItemUsed | ||
| 615 | + nowTime := time.Now() | ||
| 616 | + for _, v := range project.Template.LinkNodes { | ||
| 617 | + for i2, v2 := range v.NodeContents { | ||
| 618 | + item := domain.EvaluationItemUsed{ | ||
| 619 | + Id: 0, | ||
| 620 | + CompanyId: int(project.CompanyId), | ||
| 621 | + EvaluationProjectId: int(project.Id), | ||
| 622 | + NodeId: int(v.Id), | ||
| 623 | + NodeType: v.Type, | ||
| 624 | + SortBy: i2 + 1, | ||
| 625 | + Category: v2.Category, | ||
| 626 | + Name: v2.Name, | ||
| 627 | + PromptTitle: v2.PromptTitle, | ||
| 628 | + PromptText: v2.PromptText, | ||
| 629 | + EntryItems: v2.EntryItems, | ||
| 630 | + Weight: v2.Weight, | ||
| 631 | + Required: v2.Required, | ||
| 632 | + EvaluatorId: int(v2.EvaluatorId), | ||
| 633 | + CreatedAt: nowTime, | ||
| 634 | + UpdatedAt: nowTime, | ||
| 635 | + // RuleType: 0, | ||
| 636 | + // Rule: *v2.Rule, | ||
| 637 | + } | ||
| 638 | + if v2.Rule != nil { | ||
| 639 | + item.RuleType = v2.Rule.Type | ||
| 640 | + item.Rule = *v2.Rule | ||
| 641 | + } | ||
| 642 | + itemUsedList = append(itemUsedList, &item) | ||
| 643 | + } | ||
| 644 | + } | ||
| 645 | + itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
| 646 | + "transactionContext": transactionContext, | ||
| 647 | + }) | ||
| 648 | + err := itemUsedRepo.BatchInsert(itemUsedList) | ||
| 649 | + if err != nil { | ||
| 650 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 651 | + } | ||
| 652 | + return nil | ||
| 653 | +} |
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "fmt" | ||
| 4 | "github.com/beego/beego/v2/core/validation" | 5 | "github.com/beego/beego/v2/core/validation" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | ||
| 6 | ) | 8 | ) |
| 7 | 9 | ||
| 8 | type UpdateTemplateCommand struct { | 10 | type UpdateTemplateCommand struct { |
| @@ -20,19 +22,25 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | @@ -20,19 +22,25 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | ||
| 20 | return | 22 | return |
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | - //if len(in.Name) > 40 { | ||
| 24 | - // validation.SetError("name", "模板名称最大长度40个字符") | ||
| 25 | - // return | ||
| 26 | - //} | ||
| 27 | - // | ||
| 28 | - //if len(in.Describe) > 100 { | ||
| 29 | - // validation.SetError("describe", "备注最大长度100个字符") | ||
| 30 | - // return | ||
| 31 | - //} | ||
| 32 | - | ||
| 33 | if len(in.LinkNodes) == 0 { | 25 | if len(in.LinkNodes) == 0 { |
| 34 | validation.SetError("linkNodes", "评估模板流程不能为空") | 26 | validation.SetError("linkNodes", "评估模板流程不能为空") |
| 35 | return | 27 | return |
| 28 | + } else { | ||
| 29 | + for i := range in.LinkNodes { | ||
| 30 | + linkNode := in.LinkNodes[i] | ||
| 31 | + // 如果有评估内容时,内容权重相加 = 100% | ||
| 32 | + if len(linkNode.NodeContents) > 0 { | ||
| 33 | + weightTotal := 0.0 | ||
| 34 | + for i2 := range linkNode.NodeContents { | ||
| 35 | + weightTotal += linkNode.NodeContents[i2].Weight | ||
| 36 | + } | ||
| 37 | + if weightTotal != 100 { | ||
| 38 | + formatWeightTotal := utils.FormatFloatDecimal(weightTotal, 2) | ||
| 39 | + validation.SetError("linkNodes", fmt.Sprintf("总权重值错误,当前%s的总权重值为:%s%%(必须等于100%%)", linkNode.Name, formatWeightTotal)) | ||
| 40 | + return | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | + } | ||
| 36 | } | 44 | } |
| 37 | 45 | ||
| 38 | } | 46 | } |
| @@ -168,3 +168,43 @@ func CreateStaffAssessCacheRepository(options map[string]interface{}) domain.Sta | @@ -168,3 +168,43 @@ func CreateStaffAssessCacheRepository(options map[string]interface{}) domain.Sta | ||
| 168 | } | 168 | } |
| 169 | return repository.NewStaffAssessCacheRepository(transactionContext) | 169 | return repository.NewStaffAssessCacheRepository(transactionContext) |
| 170 | } | 170 | } |
| 171 | + | ||
| 172 | +func CreateSummaryEvaluationRepository(options map[string]interface{}) domain.SummaryEvaluationRepository { | ||
| 173 | + var transactionContext *pg.TransactionContext | ||
| 174 | + if value, ok := options["transactionContext"]; ok { | ||
| 175 | + transactionContext = value.(*pg.TransactionContext) | ||
| 176 | + } | ||
| 177 | + return repository.NewSummaryEvaluationRepository(transactionContext) | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +func CreateSummaryEvaluationValueRepository(options map[string]interface{}) domain.SummaryEvaluationValueRepository { | ||
| 181 | + var transactionContext *pg.TransactionContext | ||
| 182 | + if value, ok := options["transactionContext"]; ok { | ||
| 183 | + transactionContext = value.(*pg.TransactionContext) | ||
| 184 | + } | ||
| 185 | + return repository.NewSummaryEvaluationValueRepository(transactionContext) | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +func CreateEvaluationItemUsedRepository(options map[string]interface{}) domain.EvaluationItemUsedRepository { | ||
| 189 | + var transactionContext *pg.TransactionContext | ||
| 190 | + if value, ok := options["transactionContext"]; ok { | ||
| 191 | + transactionContext = value.(*pg.TransactionContext) | ||
| 192 | + } | ||
| 193 | + return repository.NewEvaluationItemUsedRepository(transactionContext) | ||
| 194 | +} | ||
| 195 | + | ||
| 196 | +func CreatePermissionRepository(options map[string]interface{}) domain.PermissionRepository { | ||
| 197 | + var transactionContext *pg.TransactionContext | ||
| 198 | + if value, ok := options["transactionContext"]; ok { | ||
| 199 | + transactionContext = value.(*pg.TransactionContext) | ||
| 200 | + } | ||
| 201 | + return repository.NewPermissionRepository(transactionContext) | ||
| 202 | +} | ||
| 203 | + | ||
| 204 | +func CreateLogSmsRepository(options map[string]interface{}) domain.LogSmsRepository { | ||
| 205 | + var transactionContext *pg.TransactionContext | ||
| 206 | + if value, ok := options["transactionContext"]; ok { | ||
| 207 | + transactionContext = value.(*pg.TransactionContext) | ||
| 208 | + } | ||
| 209 | + return repository.NewLogSmsRepository(transactionContext) | ||
| 210 | +} |
| @@ -2,10 +2,11 @@ package service | @@ -2,10 +2,11 @@ package service | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
| 6 | "strconv" | 5 | "strconv" |
| 7 | "time" | 6 | "time" |
| 8 | 7 | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
| 9 | + | ||
| 9 | "github.com/linmadan/egglib-go/core/application" | 10 | "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/factory" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
| @@ -153,7 +154,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | @@ -153,7 +154,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | ||
| 153 | // 创建发送任务 | 154 | // 创建发送任务 |
| 154 | _, err := staffAssessService.CreateStaffAssessTask(transactionContext, csat) | 155 | _, err := staffAssessService.CreateStaffAssessTask(transactionContext, csat) |
| 155 | if err != nil { | 156 | if err != nil { |
| 156 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 157 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建发送任务"+err.Error()) |
| 157 | } | 158 | } |
| 158 | } else { | 159 | } else { |
| 159 | task.NextSentAt = nil // 项目不存在,取消周期任务发送 | 160 | task.NextSentAt = nil // 项目不存在,取消周期任务发送 |
pkg/application/notify/run.go
0 → 100644
| 1 | +package notify | ||
| 2 | + | ||
| 3 | +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 4 | + | ||
| 5 | +var taskSmsNotify *notifySms | ||
| 6 | + | ||
| 7 | +// 检查并发送短信通知 | ||
| 8 | +func RunTaskSmsNotify() { | ||
| 9 | + taskSmsNotify = ¬ifySms{} | ||
| 10 | + taskSmsNotify.init() | ||
| 11 | + taskSmsNotify.regist(notifyStaffAssess{}) | ||
| 12 | + taskSmsNotify.regist(notifySummaryEvaluation{}) | ||
| 13 | + taskSmsNotify.runTask() | ||
| 14 | + | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +// 每日自评短信通知 ,预创建待发送的短信消息 | ||
| 18 | +func AddNotifyStaffAssess(param *domain.StaffAssess) { | ||
| 19 | + newNotify := notifyStaffAssess{} | ||
| 20 | + newSms := newNotify.makeNotify(param) | ||
| 21 | + taskSmsNotify.addTask(newSms) | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +// 周期自评短信通知 ,预创建待发送的短信消息 | ||
| 25 | +func AddNotifySummaryEvaluation(param *domain.SummaryEvaluation) { | ||
| 26 | + newNotify := notifySummaryEvaluation{} | ||
| 27 | + newSms := newNotify.makeNotify(param) | ||
| 28 | + taskSmsNotify.addTask(newSms) | ||
| 29 | +} |
pkg/application/notify/sms.go
0 → 100644
| 1 | +package notify | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "time" | ||
| 6 | + | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type notifySendOrNot interface { | ||
| 15 | + from() string | ||
| 16 | + ifSend(index int) (bool, error) | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +// 短信通知 | ||
| 20 | +type notifySms struct { | ||
| 21 | + newSms chan *domain.LogSms | ||
| 22 | + interval time.Duration | ||
| 23 | + sendOrNot map[string]notifySendOrNot //到点后判断是否真的发送短信消息 | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (notices *notifySms) init() { | ||
| 27 | + notices.newSms = make(chan *domain.LogSms, 50) | ||
| 28 | + notices.interval = 5 * time.Minute | ||
| 29 | + if constant.Env != "prd" { | ||
| 30 | + notices.interval = 1 * time.Minute | ||
| 31 | + } | ||
| 32 | + notices.sendOrNot = map[string]notifySendOrNot{} | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +func (notices *notifySms) regist(ifsend notifySendOrNot) { | ||
| 36 | + notices.sendOrNot[ifsend.from()] = ifsend | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +func (notices *notifySms) addTask(task *domain.LogSms) { | ||
| 40 | + notices.newSms <- task | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +// RunTask 执行短信通知任务 | ||
| 44 | +func (notices *notifySms) runTask() { | ||
| 45 | + timer := time.NewTimer(notices.interval) | ||
| 46 | + for { | ||
| 47 | + select { | ||
| 48 | + case newSms := <-notices.newSms: | ||
| 49 | + err := notices.addNewSms(newSms) | ||
| 50 | + if err != nil { | ||
| 51 | + e := fmt.Sprintf("添加短信通知任务:%+v %s", newSms, err) | ||
| 52 | + log.Logger.Error(e) | ||
| 53 | + } | ||
| 54 | + case <-timer.C: | ||
| 55 | + nowTime := time.Now() | ||
| 56 | + err := notices.checkSendSms() | ||
| 57 | + if err != nil { | ||
| 58 | + log.Logger.Error("检查发送短信通知任务:" + err.Error()) | ||
| 59 | + } | ||
| 60 | + log.Logger.Info(fmt.Sprintf("检查发送短信通知任务消耗时间:%.2f s", time.Since(nowTime).Seconds())) | ||
| 61 | + timer.Reset(notices.interval) // 重置定时 | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +// addNewSms 添加新的通知消息 | ||
| 67 | +func (notices *notifySms) addNewSms(newSms *domain.LogSms) error { | ||
| 68 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 69 | + if err != nil { | ||
| 70 | + return err | ||
| 71 | + } | ||
| 72 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 73 | + return err | ||
| 74 | + } | ||
| 75 | + defer func() { | ||
| 76 | + _ = transactionContext.RollbackTransaction() | ||
| 77 | + }() | ||
| 78 | + logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 79 | + err = logSmsRepo.Save(newSms) | ||
| 80 | + if err != nil { | ||
| 81 | + return err | ||
| 82 | + } | ||
| 83 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 84 | + return err | ||
| 85 | + } | ||
| 86 | + return nil | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +// checkSendSms 检查发送短信通知 | ||
| 90 | +func (notices *notifySms) checkSendSms() error { | ||
| 91 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 92 | + if err != nil { | ||
| 93 | + return err | ||
| 94 | + } | ||
| 95 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 96 | + return err | ||
| 97 | + } | ||
| 98 | + defer func() { | ||
| 99 | + _ = transactionContext.RollbackTransaction() | ||
| 100 | + }() | ||
| 101 | + logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 102 | + nowTime := time.Now() | ||
| 103 | + nowDay := dayZeroTime(nowTime) | ||
| 104 | + _, logSmsList, err := logSmsRepo.Find(map[string]interface{}{ | ||
| 105 | + "status": string(domain.SmsWait), | ||
| 106 | + "executeAtBegin": nowDay, | ||
| 107 | + "executeAtEnd": nowTime, | ||
| 108 | + }) | ||
| 109 | + if err != nil { | ||
| 110 | + return err | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 114 | + return err | ||
| 115 | + } | ||
| 116 | + for _, v := range logSmsList { | ||
| 117 | + err = notices.sendSms(v) | ||
| 118 | + if err != nil { | ||
| 119 | + e := fmt.Sprintf("发送短信通知:%+v %s", *v, err) | ||
| 120 | + log.Logger.Error(e) | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + return nil | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | +// sendSms 发送短信消息 | ||
| 127 | +func (notices *notifySms) sendSms(param *domain.LogSms) error { | ||
| 128 | + if constant.Env != "prd" { | ||
| 129 | + return nil | ||
| 130 | + } | ||
| 131 | + //单开处理 数据保存操作,发一条短信更新一条数据 | ||
| 132 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 133 | + if err != nil { | ||
| 134 | + return err | ||
| 135 | + } | ||
| 136 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 137 | + return err | ||
| 138 | + } | ||
| 139 | + defer func() { | ||
| 140 | + _ = transactionContext.RollbackTransaction() | ||
| 141 | + }() | ||
| 142 | + logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 143 | + | ||
| 144 | + sendOk := false | ||
| 145 | + sendOrNot, ok := notices.sendOrNot[param.From] | ||
| 146 | + if ok { | ||
| 147 | + ok, err := sendOrNot.ifSend(param.Index) | ||
| 148 | + if err != nil { | ||
| 149 | + param.Result = err.Error() | ||
| 150 | + } | ||
| 151 | + sendOk = ok | ||
| 152 | + } else { | ||
| 153 | + sendOk = true | ||
| 154 | + } | ||
| 155 | + if !sendOk { | ||
| 156 | + param.Status = domain.SmsIgnore | ||
| 157 | + } else { | ||
| 158 | + sms := serviceGateway.SmsService{} | ||
| 159 | + err = sms.SendNoticeSms(param.Phone, param.TemplateId, param.Value) | ||
| 160 | + if err != nil { | ||
| 161 | + param.Result = err.Error() | ||
| 162 | + param.Status = domain.SmsSuccess | ||
| 163 | + } else { | ||
| 164 | + param.Status = domain.SmsSuccess | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + err = logSmsRepo.Save(param) | ||
| 168 | + if err != nil { | ||
| 169 | + return err | ||
| 170 | + } | ||
| 171 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 172 | + return err | ||
| 173 | + } | ||
| 174 | + return nil | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | +func dayZeroTime(t time.Time) time.Time { | ||
| 178 | + y, m, d := t.Local().Date() | ||
| 179 | + t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local) | ||
| 180 | + return t2 | ||
| 181 | +} |
pkg/application/notify/sms_staff_assess.go
0 → 100644
| 1 | +package notify | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +// 每日自评短信通知 | ||
| 11 | +type notifyStaffAssess struct { | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +func (notices notifyStaffAssess) from() string { | ||
| 15 | + return "StaffAssess" | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +// makeNotify 生成待执行的短信通知内容 | ||
| 19 | +func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.LogSms { | ||
| 20 | + newSms := domain.LogSms{ | ||
| 21 | + Id: 0, | ||
| 22 | + Phone: param.Executor.Account, | ||
| 23 | + TemplateId: 5475050, | ||
| 24 | + Template: "您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦", | ||
| 25 | + Value: map[string]string{ | ||
| 26 | + "name": param.Executor.UserName, | ||
| 27 | + }, | ||
| 28 | + Result: "", | ||
| 29 | + Status: domain.SmsWait, | ||
| 30 | + From: notices.from(), | ||
| 31 | + Index: param.Id, | ||
| 32 | + // ExecuteAt: executeAt, | ||
| 33 | + CreatedAt: time.Now(), | ||
| 34 | + } | ||
| 35 | + // 每日自评 结束前30 分钟 | ||
| 36 | + // newSms.ExecuteAt = param.EndTime.Add(-1800 * time.Second) | ||
| 37 | + //改为 固定在截止时间 那天的 前一天晚上10 | ||
| 38 | + y, m, d := param.EndTime.Local().Date() | ||
| 39 | + dayTime := time.Date(y, m, d, 0, 0, 0, 0, time.Local) | ||
| 40 | + newSms.ExecuteAt = dayTime.Add(-2 * time.Hour) | ||
| 41 | + return &newSms | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +// ifSend 确认是否发送通知 | ||
| 45 | +func (notices notifyStaffAssess) ifSend(index int) (bool, error) { | ||
| 46 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 47 | + if err != nil { | ||
| 48 | + return false, err | ||
| 49 | + } | ||
| 50 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 51 | + return false, err | ||
| 52 | + } | ||
| 53 | + defer func() { | ||
| 54 | + _ = transactionContext.RollbackTransaction() | ||
| 55 | + }() | ||
| 56 | + staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 57 | + assessData, err := staffAssessRepo.FindOne(map[string]interface{}{"id": index}) | ||
| 58 | + if err != nil { | ||
| 59 | + return false, err | ||
| 60 | + } | ||
| 61 | + //还未完成评估填写,时发送短信 | ||
| 62 | + if assessData.Status == domain.StaffAssessUncompleted { | ||
| 63 | + return true, nil | ||
| 64 | + } | ||
| 65 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 66 | + return false, err | ||
| 67 | + } | ||
| 68 | + return false, nil | ||
| 69 | +} |
| 1 | +package notify | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +// 周期评估短信通知 | ||
| 11 | +// 条件:周期自评结束前4个小时,且还未完成评估填写 | ||
| 12 | +type notifySummaryEvaluation struct { | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +func (notices notifySummaryEvaluation) from() string { | ||
| 16 | + return "SummaryEvaluation" | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +// makeNotify 生成待执行的短信通知内容 | ||
| 20 | +func (notices notifySummaryEvaluation) makeNotify(param *domain.SummaryEvaluation) *domain.LogSms { | ||
| 21 | + newSms := domain.LogSms{ | ||
| 22 | + Id: 0, | ||
| 23 | + Phone: param.Executor.Account, | ||
| 24 | + TemplateId: 5536232, | ||
| 25 | + Template: "您好,#name#,百忙之中不要忘记填写本月综合自评哦", | ||
| 26 | + Value: map[string]string{ | ||
| 27 | + "name": param.Executor.UserName, | ||
| 28 | + }, | ||
| 29 | + Result: "", | ||
| 30 | + Status: domain.SmsWait, | ||
| 31 | + From: notices.from(), | ||
| 32 | + Index: param.Id, | ||
| 33 | + // ExecuteAt: executeAt, | ||
| 34 | + CreatedAt: time.Now(), | ||
| 35 | + } | ||
| 36 | + // 周期自评结束前4个小时, | ||
| 37 | + // newSms.ExecuteAt = param.EndTime.Add(-4 * time.Hour) | ||
| 38 | + //改为 固定在截止时间 那天的 前一天晚上10 | ||
| 39 | + y, m, d := param.EndTime.Local().Date() | ||
| 40 | + dayTime := time.Date(y, m, d, 0, 0, 0, 0, time.Local) | ||
| 41 | + newSms.ExecuteAt = dayTime.Add(-2 * time.Hour) | ||
| 42 | + return &newSms | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +// ifSend 确认是否发送通知 | ||
| 46 | +func (notices notifySummaryEvaluation) ifSend(index int) (bool, error) { | ||
| 47 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 48 | + if err != nil { | ||
| 49 | + return false, err | ||
| 50 | + } | ||
| 51 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 52 | + return false, err | ||
| 53 | + } | ||
| 54 | + defer func() { | ||
| 55 | + _ = transactionContext.RollbackTransaction() | ||
| 56 | + }() | ||
| 57 | + summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 58 | + summaryEvaluationData, err := summaryEvaluationRepo.FindOne(map[string]interface{}{"id": index}) | ||
| 59 | + if err != nil { | ||
| 60 | + return false, err | ||
| 61 | + } | ||
| 62 | + //还未完成评估填写,时发送短信 | ||
| 63 | + if summaryEvaluationData.Status == domain.EvaluationUncompleted { | ||
| 64 | + return true, nil | ||
| 65 | + } | ||
| 66 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 67 | + return false, err | ||
| 68 | + } | ||
| 69 | + return false, nil | ||
| 70 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/core/validation" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +type UpdatePermissionCommand struct { | ||
| 9 | + CompanyId int64 `cname:"公司Id"` | ||
| 10 | + OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"` | ||
| 11 | + OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"` | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +func (in *UpdatePermissionCommand) Valid(validation *validation.Validation) { | ||
| 15 | + switch in.OptHrScore { | ||
| 16 | + case domain.PermissionOff, domain.PermissionOn: | ||
| 17 | + default: | ||
| 18 | + validation.SetError("optHrScore", "修改人资综评分数参数错误") | ||
| 19 | + return | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + switch in.OptEvalScore { | ||
| 23 | + case domain.PermissionOff, domain.PermissionOn: | ||
| 24 | + default: | ||
| 25 | + validation.SetError("optEvalScore", "修改360°综评分数参数错误") | ||
| 26 | + return | ||
| 27 | + } | ||
| 28 | +} |
| 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/permission/command" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type PermissionService struct { | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +func NewPermissionService() *PermissionService { | ||
| 14 | + newPermissionService := &PermissionService{} | ||
| 15 | + return newPermissionService | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interface{}, error) { | ||
| 19 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 20 | + if err != nil { | ||
| 21 | + return nil, err | ||
| 22 | + } | ||
| 23 | + defer func() { | ||
| 24 | + transactionContext.RollbackTransaction() | ||
| 25 | + }() | ||
| 26 | + permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 27 | + // 获取权限配置 | ||
| 28 | + _, permissions, err := permissionRepository.Find(map[string]interface{}{"companyId": in.CompanyId}) | ||
| 29 | + if err != nil { | ||
| 30 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 31 | + } | ||
| 32 | + if len(permissions) == 0 { | ||
| 33 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "权限配置数据错误") | ||
| 34 | + } | ||
| 35 | + permission := permissions[0] | ||
| 36 | + permission.OptHrScore = in.OptHrScore | ||
| 37 | + permission.OptEvalScore = in.OptEvalScore | ||
| 38 | + | ||
| 39 | + permission, err = permissionRepository.Insert(permission) | ||
| 40 | + if err != nil { | ||
| 41 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 42 | + } | ||
| 43 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 44 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 45 | + } | ||
| 46 | + return permission, nil | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +func (rs *PermissionService) Get(in *command.GetPermissionCommand) (interface{}, error) { | ||
| 50 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 51 | + if err != nil { | ||
| 52 | + return nil, err | ||
| 53 | + } | ||
| 54 | + defer func() { | ||
| 55 | + transactionContext.RollbackTransaction() | ||
| 56 | + }() | ||
| 57 | + permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 58 | + | ||
| 59 | + // 获取权限配置 | ||
| 60 | + _, permissions, err := permissionRepository.Find(map[string]interface{}{"companyId": in.CompanyId}) | ||
| 61 | + if err != nil { | ||
| 62 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 63 | + } | ||
| 64 | + var permission *domain.Permission | ||
| 65 | + if len(permissions) == 0 { // 不存在时,新增权限配置 | ||
| 66 | + value := &domain.Permission{ | ||
| 67 | + Id: 0, | ||
| 68 | + CompanyId: in.CompanyId, | ||
| 69 | + OptHrScore: domain.PermissionOff, | ||
| 70 | + OptEvalScore: domain.PermissionOff, | ||
| 71 | + } | ||
| 72 | + permission, err = permissionRepository.Insert(value) | ||
| 73 | + if err != nil { | ||
| 74 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 75 | + } | ||
| 76 | + } else { | ||
| 77 | + permission = permissions[0] | ||
| 78 | + } | ||
| 79 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 80 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 81 | + } | ||
| 82 | + return permission, nil | ||
| 83 | +} |
| 1 | package service | 1 | package service |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "strconv" | ||
| 5 | + | ||
| 4 | "github.com/linmadan/egglib-go/core/application" | 6 | "github.com/linmadan/egglib-go/core/application" |
| 5 | "github.com/linmadan/egglib-go/utils/tool_funs" | 7 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 9 | - "strconv" | ||
| 10 | ) | 11 | ) |
| 11 | 12 | ||
| 12 | type RoleUserService struct { | 13 | type RoleUserService struct { |
| @@ -113,3 +114,33 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface | @@ -113,3 +114,33 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface | ||
| 113 | } | 114 | } |
| 114 | return tool_funs.SimpleWrapGridMap(total, tempList), nil | 115 | return tool_funs.SimpleWrapGridMap(total, tempList), nil |
| 115 | } | 116 | } |
| 117 | + | ||
| 118 | +// GetHRBP 当前操作人是否拥有HRBP权限 | ||
| 119 | +// 返回 1 是 表示具有hrbp 权限 | ||
| 120 | + | ||
| 121 | +func GetHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { | ||
| 122 | + roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 123 | + roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 124 | + _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId}) | ||
| 125 | + if err != nil { | ||
| 126 | + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
| 127 | + } | ||
| 128 | + _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId}) | ||
| 129 | + if err != nil { | ||
| 130 | + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
| 131 | + } | ||
| 132 | + // 拥有HRBP权限 | ||
| 133 | + hrbp := -1 | ||
| 134 | + for _, v := range userRoleList { | ||
| 135 | + for _, v2 := range roleList { | ||
| 136 | + if v.RoleId == v2.Id { | ||
| 137 | + hrbp = 1 | ||
| 138 | + break | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + if hrbp == 1 { | ||
| 142 | + break | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + return hrbp, nil | ||
| 146 | +} |
| 1 | package query | 1 | package query |
| 2 | 2 | ||
| 3 | type AssessSelfListQuery struct { | 3 | type AssessSelfListQuery struct { |
| 4 | - UserId int `json:"userId"` //用户id | ||
| 5 | - CompanyId int `json:"companyId"` //公司Id | 4 | + UserId int `json:"userId,string"` //用户id |
| 5 | + CompanyId int `json:"-"` //公司Id | ||
| 6 | PageSize int `json:"pageSize"` //每页的记录数 | 6 | PageSize int `json:"pageSize"` //每页的记录数 |
| 7 | PageNumber int `json:"pageNumber"` //页码 | 7 | PageNumber int `json:"pageNumber"` //页码 |
| 8 | } | 8 | } |
| @@ -32,29 +32,29 @@ func (h *HeaderLevel) addChild(name string) (child *HeaderLevel) { | @@ -32,29 +32,29 @@ func (h *HeaderLevel) addChild(name string) (child *HeaderLevel) { | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | // 获取表头的所有列表名 | 34 | // 获取表头的所有列表名 |
| 35 | -func (h *HeaderLevel) collectAllColumn(all *[][]string) { | ||
| 36 | - for _, v := range h.Child { | ||
| 37 | - v.collectColumn(&v, all, nil) | ||
| 38 | - } | ||
| 39 | -} | ||
| 40 | - | ||
| 41 | -func (h *HeaderLevel) collectColumn(child *HeaderLevel, columns *[][]string, column *[]string) { | ||
| 42 | - if column == nil { | ||
| 43 | - column = &[]string{} | ||
| 44 | - } | ||
| 45 | - *column = append(*column, h.Name) | ||
| 46 | - for _, v := range child.Child { | ||
| 47 | - if len(v.Child) > 0 { | ||
| 48 | - v.collectColumn(&v, columns, column) | ||
| 49 | - } | ||
| 50 | - if len(v.Child) == 0 { | ||
| 51 | - item := make([]string, len(*column)) | ||
| 52 | - copy(item, *column) | ||
| 53 | - item = append(item, v.Name) | ||
| 54 | - *columns = append(*columns, item) | ||
| 55 | - } | ||
| 56 | - } | ||
| 57 | -} | 35 | +// func (h *HeaderLevel) collectAllColumn(all *[][]string) { |
| 36 | +// for _, v := range h.Child { | ||
| 37 | +// v.collectColumn(&v, all, nil) | ||
| 38 | +// } | ||
| 39 | +// } | ||
| 40 | + | ||
| 41 | +// func (h *HeaderLevel) collectColumn(child *HeaderLevel, columns *[][]string, column *[]string) { | ||
| 42 | +// if column == nil { | ||
| 43 | +// column = &[]string{} | ||
| 44 | +// } | ||
| 45 | +// *column = append(*column, h.Name) | ||
| 46 | +// for _, v := range child.Child { | ||
| 47 | +// if len(v.Child) > 0 { | ||
| 48 | +// v.collectColumn(&v, columns, column) | ||
| 49 | +// } | ||
| 50 | +// if len(v.Child) == 0 { | ||
| 51 | +// item := make([]string, len(*column)) | ||
| 52 | +// copy(item, *column) | ||
| 53 | +// item = append(item, v.Name) | ||
| 54 | +// *columns = append(*columns, item) | ||
| 55 | +// } | ||
| 56 | +// } | ||
| 57 | +// } | ||
| 58 | 58 | ||
| 59 | type exportData struct { | 59 | type exportData struct { |
| 60 | userName []string //员工的名称列表 ,对应excel文件的多个sheet | 60 | userName []string //员工的名称列表 ,对应excel文件的多个sheet |
| @@ -156,9 +156,9 @@ func (e *exportData) weightDesc(weight float64) string { | @@ -156,9 +156,9 @@ func (e *exportData) weightDesc(weight float64) string { | ||
| 156 | } | 156 | } |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | -func (e *exportData) userDayKey(userName string) string { | ||
| 160 | - return userName | ||
| 161 | -} | 159 | +// func (e *exportData) userDayKey(userName string) string { |
| 160 | +// return userName | ||
| 161 | +// } | ||
| 162 | 162 | ||
| 163 | type exportData2 struct { | 163 | type exportData2 struct { |
| 164 | tableHeader HeaderLevel //数据表格对应表头 | 164 | tableHeader HeaderLevel //数据表格对应表头 |
| @@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
| 9 | "github.com/linmadan/egglib-go/core/application" | 9 | "github.com/linmadan/egglib-go/core/application" |
| 10 | "github.com/linmadan/egglib-go/utils/tool_funs" | 10 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify" | ||
| 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter" |
| 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" |
| 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | 15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" |
| @@ -53,197 +54,6 @@ func (srv StaffAssessServeice) getHRBP(transactionContext application.Transactio | @@ -53,197 +54,6 @@ func (srv StaffAssessServeice) getHRBP(transactionContext application.Transactio | ||
| 53 | return hrbp, nil | 54 | return hrbp, nil |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | -// 获取我参与过的评估任务列表 | ||
| 57 | -// func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { | ||
| 58 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 59 | -// if err != nil { | ||
| 60 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 61 | -// } | ||
| 62 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 63 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 64 | -// } | ||
| 65 | -// defer func() { | ||
| 66 | -// _ = transactionContext.RollbackTransaction() | ||
| 67 | -// }() | ||
| 68 | - | ||
| 69 | -// staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{ | ||
| 70 | -// "transactionContext": transactionContext, | ||
| 71 | -// }) | ||
| 72 | - | ||
| 73 | -// var limit int = 200 | ||
| 74 | -// var offset int = 0 | ||
| 75 | -// if param.PageSize > 0 { | ||
| 76 | -// limit = param.PageSize | ||
| 77 | -// } | ||
| 78 | -// offset = (param.PageNumber - 1) * param.PageSize | ||
| 79 | -// assessTaskList, err := staffAssessTaskRepo.SearchAssessTaskMe(param.UserId, param.CompanyId, limit, offset) | ||
| 80 | -// if err != nil { | ||
| 81 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error()) | ||
| 82 | -// } | ||
| 83 | -// cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId) | ||
| 84 | -// if err != nil { | ||
| 85 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error()) | ||
| 86 | -// } | ||
| 87 | - | ||
| 88 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 89 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 90 | -// } | ||
| 91 | -// listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList)) | ||
| 92 | -// var temp adapter.SearchAssessMeResp | ||
| 93 | -// for _, v := range assessTaskList { | ||
| 94 | -// temp = adapter.SearchAssessMeResp{ | ||
| 95 | -// AssessTaskId: v.Id, | ||
| 96 | -// BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"), | ||
| 97 | -// EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 98 | -// CycleId: v.CycleId, | ||
| 99 | -// CycleName: v.CycleName, | ||
| 100 | -// EvaluationProjectId: v.EvaluationProjectId, | ||
| 101 | -// EvaluationProjectName: v.EvaluationProjectName, | ||
| 102 | -// } | ||
| 103 | -// listData = append(listData, temp) | ||
| 104 | -// } | ||
| 105 | -// return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil | ||
| 106 | -// } | ||
| 107 | - | ||
| 108 | -// 获取项目评估进度描述 | ||
| 109 | -// func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) { | ||
| 110 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 111 | -// if err != nil { | ||
| 112 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 113 | -// } | ||
| 114 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 115 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 116 | -// } | ||
| 117 | -// defer func() { | ||
| 118 | -// _ = transactionContext.RollbackTransaction() | ||
| 119 | -// }() | ||
| 120 | -// // 获取评估任务 | ||
| 121 | -// staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 122 | -// "transactionContext": transactionContext, | ||
| 123 | -// }) | ||
| 124 | -// //获取个人参与的评估流程 | ||
| 125 | -// staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 126 | -// "transactionContext": transactionContext, | ||
| 127 | -// }) | ||
| 128 | -// assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{ | ||
| 129 | -// "id": param.AssessTaskId, | ||
| 130 | -// }) | ||
| 131 | -// if err != nil { | ||
| 132 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error()) | ||
| 133 | -// } | ||
| 134 | -// //返回的数据结果 | ||
| 135 | -// result := adapter.AssessTaskDescResp{ | ||
| 136 | -// AssessTaskId: assessTaskData.Id, | ||
| 137 | -// EvaluationProjectId: assessTaskData.EvaluationProjectId, | ||
| 138 | -// EvaluationProjectName: assessTaskData.EvaluationProjectName, | ||
| 139 | -// CycleName: assessTaskData.CycleName, | ||
| 140 | -// BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"), | ||
| 141 | -// EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"), | ||
| 142 | -// StepList: []adapter.AssessTaskStep{}, | ||
| 143 | -// } | ||
| 144 | - | ||
| 145 | -// for _, v := range assessTaskData.StepList { | ||
| 146 | -// stepItem := adapter.AssessTaskStep{ | ||
| 147 | -// SortBy: v.SortBy, | ||
| 148 | -// LinkNodeName: v.LinkNodeName, | ||
| 149 | -// LinkNodeId: v.LinkNodeId, | ||
| 150 | -// BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"), | ||
| 151 | -// EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 152 | -// LinkNodeType: v.LinkNodeType, | ||
| 153 | -// Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")), | ||
| 154 | -// Status: "", | ||
| 155 | -// } | ||
| 156 | -// switch v.LinkNodeType { | ||
| 157 | -// case domain.LinkNodeSelfAssessment: | ||
| 158 | -// //个人自评完成情况 | ||
| 159 | -// _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 160 | -// "staffAssessTaskId": assessTaskData.Id, | ||
| 161 | -// "executorId": param.UserId, | ||
| 162 | -// "typesList": []string{string(domain.AssessSelf)}, | ||
| 163 | -// }) | ||
| 164 | -// if err != nil { | ||
| 165 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 166 | -// } | ||
| 167 | -// if len(assessSelfData) > 0 { | ||
| 168 | -// stepItem.Status = string(assessSelfData[0].Status) | ||
| 169 | -// } | ||
| 170 | -// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 171 | -// case domain.LinkNodeAllInvite: | ||
| 172 | -// //邀请别人评估自己 | ||
| 173 | -// _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 174 | -// "staffAssessTaskId": assessTaskData.Id, | ||
| 175 | -// "targetUserId": param.UserId, | ||
| 176 | -// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 177 | -// "limit": 5, | ||
| 178 | -// }) | ||
| 179 | -// if err != nil { | ||
| 180 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 181 | -// } | ||
| 182 | -// if len(assessInviteData) > 0 { | ||
| 183 | -// stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 184 | -// } else { | ||
| 185 | -// stepItem.Status = string(domain.StaffAssessUncompleted) | ||
| 186 | -// } | ||
| 187 | -// //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可 | ||
| 188 | -// if len(assessInviteData) > 5 { | ||
| 189 | -// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 190 | -// } else { | ||
| 191 | -// stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData)) | ||
| 192 | -// } | ||
| 193 | -// case domain.LinkNodeAllAssessment: | ||
| 194 | -// //我评估别人,被邀请评估 | ||
| 195 | -// _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 196 | -// "staffAssessTaskId": assessTaskData.Id, | ||
| 197 | -// "executorId": param.UserId, | ||
| 198 | -// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 199 | -// }) | ||
| 200 | -// if err != nil { | ||
| 201 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 202 | -// } | ||
| 203 | - | ||
| 204 | -// if len(assessInviteList) > 0 { | ||
| 205 | -// stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 206 | -// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 207 | -// for _, v := range assessInviteList { | ||
| 208 | -// if v.Status == domain.StaffAssessUncompleted { | ||
| 209 | -// stepItem.Status = string(domain.StaffAssessUncompleted) | ||
| 210 | -// break | ||
| 211 | -// } | ||
| 212 | -// } | ||
| 213 | -// } | ||
| 214 | -// case domain.LinkNodeSuperiorAssessment: | ||
| 215 | -// //我评估别人,上级评估 | ||
| 216 | -// _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 217 | -// "staffAssessTaskId": assessTaskData.Id, | ||
| 218 | -// "executorId": param.UserId, | ||
| 219 | -// "typesList": []string{string(domain.AssessSuper)}, | ||
| 220 | -// }) | ||
| 221 | -// if err != nil { | ||
| 222 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 223 | -// } | ||
| 224 | -// if len(assessSupperList) > 0 { | ||
| 225 | -// stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 226 | -// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 227 | -// uncompletedNum := 0 | ||
| 228 | -// for _, v := range assessSupperList { | ||
| 229 | -// if v.Status == domain.StaffAssessUncompleted { | ||
| 230 | -// uncompletedNum += 1 | ||
| 231 | -// } | ||
| 232 | -// } | ||
| 233 | -// if uncompletedNum > 0 { | ||
| 234 | -// stepItem.Status = string(domain.StaffAssessUncompleted) | ||
| 235 | -// stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum) | ||
| 236 | -// } | ||
| 237 | -// } | ||
| 238 | -// } | ||
| 239 | -// result.StepList = append(result.StepList, stepItem) | ||
| 240 | -// } | ||
| 241 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 242 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 243 | -// } | ||
| 244 | -// return &result, nil | ||
| 245 | -// } | ||
| 246 | - | ||
| 247 | // 获取个人的自评反馈历史记录列表 | 57 | // 获取个人的自评反馈历史记录列表 |
| 248 | func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) { | 58 | func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) { |
| 249 | transactionContext, err := factory.CreateTransactionContext(nil) | 59 | transactionContext, err := factory.CreateTransactionContext(nil) |
| @@ -451,10 +261,11 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | @@ -451,10 +261,11 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(transactionContext applicat | ||
| 451 | if err != nil { | 261 | if err != nil { |
| 452 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) | 262 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) |
| 453 | } | 263 | } |
| 264 | + if assessList[i].Types == domain.AssessSelf { | ||
| 265 | + //添加待发送的短信通知 | ||
| 266 | + notify.AddNotifyStaffAssess(&assessList[i]) | ||
| 267 | + } | ||
| 454 | } | 268 | } |
| 455 | - | ||
| 456 | - //处理生成的项目评估 | ||
| 457 | - | ||
| 458 | return map[string]interface{}{ | 269 | return map[string]interface{}{ |
| 459 | "assessTaskId": assessTaskData.Id, | 270 | "assessTaskId": assessTaskData.Id, |
| 460 | }, nil | 271 | }, nil |
| @@ -925,93 +736,6 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv | @@ -925,93 +736,6 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv | ||
| 925 | return result, nil | 736 | return result, nil |
| 926 | } | 737 | } |
| 927 | 738 | ||
| 928 | -// 获取员工自评的评估内容详情 | ||
| 929 | -// func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, error) { | ||
| 930 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 931 | -// if err != nil { | ||
| 932 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 933 | -// } | ||
| 934 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 935 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 936 | -// } | ||
| 937 | -// defer func() { | ||
| 938 | -// _ = transactionContext.RollbackTransaction() | ||
| 939 | -// }() | ||
| 940 | -// assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 941 | -// "transactionContext": transactionContext, | ||
| 942 | -// }) | ||
| 943 | -// //获取员工的评估 | ||
| 944 | -// _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
| 945 | -// "companyId": param.CompanyId, | ||
| 946 | -// "staffAssessTaskId": param.AssessTaskId, | ||
| 947 | -// "targetUserId": param.TargetUserId, | ||
| 948 | -// "typesList": []string{string(domain.AssessSelf)}, | ||
| 949 | -// }) | ||
| 950 | -// if err != nil { | ||
| 951 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
| 952 | -// } | ||
| 953 | -// if len(assessList) == 0 { | ||
| 954 | -// return &adapter.AssessInfoResp{}, nil | ||
| 955 | -// } | ||
| 956 | -// assessData := assessList[0] | ||
| 957 | - | ||
| 958 | -// assessContentList := []*domain.StaffAssessContent{} | ||
| 959 | -// if assessData.Status == domain.StaffAssessCompleted { | ||
| 960 | -// //已完成 | ||
| 961 | -// assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
| 962 | -// "transactionContext": transactionContext, | ||
| 963 | -// }) | ||
| 964 | -// _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{ | ||
| 965 | -// "staffAssessId": assessData.Id, | ||
| 966 | -// }) | ||
| 967 | -// if err != nil { | ||
| 968 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
| 969 | -// } | ||
| 970 | -// } else if assessData.Status == domain.StaffAssessUncompleted { | ||
| 971 | -// //未完成 | ||
| 972 | -// assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData) | ||
| 973 | -// if err != nil { | ||
| 974 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) | ||
| 975 | -// } | ||
| 976 | -// } | ||
| 977 | - | ||
| 978 | -// // 恢复缓存数据 | ||
| 979 | -// if param.AcquireCache != 0 { | ||
| 980 | -// srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList) | ||
| 981 | -// } | ||
| 982 | - | ||
| 983 | -// //获取员工描述 | ||
| 984 | -// staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId)) | ||
| 985 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 986 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 987 | -// } | ||
| 988 | -// result := adapter.AssessInfoResp{ | ||
| 989 | -// AssessId: assessData.Id, | ||
| 990 | -// CycleId: assessData.CycleId, | ||
| 991 | -// CycleName: assessData.CycleName, | ||
| 992 | -// LinkNodeId: assessData.LinkNodeId, | ||
| 993 | -// LinkNodeName: assessData.LinkNodeName, | ||
| 994 | -// EvaluationProjectId: assessData.EvaluationProjectId, | ||
| 995 | -// EvaluationProjectName: assessData.EvaluationProjectName, | ||
| 996 | -// BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), | ||
| 997 | -// EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 998 | -// Status: string(assessData.Status), | ||
| 999 | -// TargetUserId: assessData.TargetUser.UserId, | ||
| 1000 | -// TargetUserName: assessData.TargetUser.UserName, | ||
| 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 | ||
| 1011 | -// } | ||
| 1012 | -// return &result, nil | ||
| 1013 | -// } | ||
| 1014 | - | ||
| 1015 | // 获取未完成的员工评估内容 | 739 | // 获取未完成的员工评估内容 |
| 1016 | func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext application.TransactionContext, | 740 | func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext application.TransactionContext, |
| 1017 | assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) { | 741 | assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) { |
| @@ -1105,426 +829,6 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a | @@ -1105,426 +829,6 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a | ||
| 1105 | return contentList, nil | 829 | return contentList, nil |
| 1106 | } | 830 | } |
| 1107 | 831 | ||
| 1108 | -// 选择员工评估可邀请的用户 | ||
| 1109 | -func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) { | ||
| 1110 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 1111 | - if err != nil { | ||
| 1112 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1113 | - } | ||
| 1114 | - if err := transactionContext.StartTransaction(); err != nil { | ||
| 1115 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1116 | - } | ||
| 1117 | - defer func() { | ||
| 1118 | - _ = transactionContext.RollbackTransaction() | ||
| 1119 | - }() | ||
| 1120 | - //获取被评估的目标用户 | ||
| 1121 | - userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 1122 | - "transactionContext": transactionContext, | ||
| 1123 | - }) | ||
| 1124 | - //获取公司信息 | ||
| 1125 | - companyRepo := factory.CreateCompanyRepository(map[string]interface{}{ | ||
| 1126 | - "transactionContext": transactionContext, | ||
| 1127 | - }) | ||
| 1128 | - companyInfo, _ := companyRepo.FindOne(map[string]interface{}{ | ||
| 1129 | - "id": param.CompanyId, | ||
| 1130 | - }) | ||
| 1131 | - targetUser, err := userRepo.FindOne(map[string]interface{}{ | ||
| 1132 | - "id": param.TargetUserId, | ||
| 1133 | - }) | ||
| 1134 | - if err != nil { | ||
| 1135 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error()) | ||
| 1136 | - } | ||
| 1137 | - //获取被评估的目标用户的部门 | ||
| 1138 | - departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
| 1139 | - "transactionContext": transactionContext, | ||
| 1140 | - }) | ||
| 1141 | - var targetUserDepartment []*domain.Department | ||
| 1142 | - if len(targetUser.DepartmentId) > 0 { | ||
| 1143 | - _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{ | ||
| 1144 | - "ids": targetUser.DepartmentId, | ||
| 1145 | - }) | ||
| 1146 | - if err != nil { | ||
| 1147 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) | ||
| 1148 | - } | ||
| 1149 | - } | ||
| 1150 | - //获取部门主管的id | ||
| 1151 | - targetUserCharge := map[int64]struct{}{} | ||
| 1152 | - for _, v := range targetUserDepartment { | ||
| 1153 | - for _, vv := range v.ChargeUserIds { | ||
| 1154 | - targetUserCharge[vv] = struct{}{} | ||
| 1155 | - } | ||
| 1156 | - } | ||
| 1157 | - // | ||
| 1158 | - targetUserDepartmentMap := map[int64]struct{}{} | ||
| 1159 | - for _, v := range targetUserDepartment { | ||
| 1160 | - targetUserDepartmentMap[v.Id] = struct{}{} | ||
| 1161 | - } | ||
| 1162 | - //查询员工数据 | ||
| 1163 | - condition := map[string]interface{}{ | ||
| 1164 | - "companyId": param.CompanyId, | ||
| 1165 | - "name": param.InviteUserName, | ||
| 1166 | - "limit": 20, | ||
| 1167 | - "status": 1, | ||
| 1168 | - } | ||
| 1169 | - if param.PageSize > 0 { | ||
| 1170 | - condition["limit"] = param.PageSize | ||
| 1171 | - } | ||
| 1172 | - offset := (param.PageNumber - 1) * param.PageSize | ||
| 1173 | - if offset > 0 { | ||
| 1174 | - condition["offset"] = offset | ||
| 1175 | - } | ||
| 1176 | - cnt, userList, err := userRepo.Find(condition) | ||
| 1177 | - if err != nil { | ||
| 1178 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error()) | ||
| 1179 | - } | ||
| 1180 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 1181 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1182 | - } | ||
| 1183 | - listData := []adapter.SelectInviteUser{} | ||
| 1184 | - companyName := "" | ||
| 1185 | - if companyInfo != nil { | ||
| 1186 | - companyName = companyInfo.Name | ||
| 1187 | - } | ||
| 1188 | - for _, v := range userList { | ||
| 1189 | - item := adapter.SelectInviteUser{ | ||
| 1190 | - UserId: int(v.Id), | ||
| 1191 | - UserName: v.Name, | ||
| 1192 | - CompanyName: companyName, | ||
| 1193 | - IsSupper: false, | ||
| 1194 | - Types: 2, //默认是不同上级 | ||
| 1195 | - } | ||
| 1196 | - if _, ok := targetUserCharge[v.Id]; ok { | ||
| 1197 | - item.IsSupper = true | ||
| 1198 | - } | ||
| 1199 | - for _, vv := range v.DepartmentId { | ||
| 1200 | - if _, ok := targetUserDepartmentMap[int64(vv)]; ok { | ||
| 1201 | - item.Types = 1 //设为相同上级 | ||
| 1202 | - break | ||
| 1203 | - } | ||
| 1204 | - } | ||
| 1205 | - listData = append(listData, item) | ||
| 1206 | - } | ||
| 1207 | - return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil | ||
| 1208 | -} | ||
| 1209 | - | ||
| 1210 | -// 获取我要执行的的360评估,用户列表和评估填写的值 | ||
| 1211 | -// func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteUserAssessQuery) ( | ||
| 1212 | -// *adapter.ListInviteUserAssessResp, error) { | ||
| 1213 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 1214 | -// if err != nil { | ||
| 1215 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1216 | -// } | ||
| 1217 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 1218 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1219 | -// } | ||
| 1220 | -// defer func() { | ||
| 1221 | -// _ = transactionContext.RollbackTransaction() | ||
| 1222 | -// }() | ||
| 1223 | -// //获取对应的评估任务 | ||
| 1224 | -// assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 1225 | -// "transactionContext": transactionContext, | ||
| 1226 | -// }) | ||
| 1227 | -// assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 1228 | -// "transactionContext": transactionContext, | ||
| 1229 | -// }) | ||
| 1230 | - | ||
| 1231 | -// //获取 executorId 对应的360评估任务 用户 | ||
| 1232 | -// condition := map[string]interface{}{ | ||
| 1233 | -// "staffAssessTaskId": param.AssessTaskId, | ||
| 1234 | -// "executorId": param.ExecutorId, | ||
| 1235 | -// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 1236 | -// "limit": 20, | ||
| 1237 | -// } | ||
| 1238 | -// if param.PageSize > 0 { | ||
| 1239 | -// condition["limit"] = param.PageSize | ||
| 1240 | -// } | ||
| 1241 | -// offset := (param.PageNumber - 1) * param.PageSize | ||
| 1242 | -// if offset > 0 { | ||
| 1243 | -// condition["offset"] = offset | ||
| 1244 | -// } | ||
| 1245 | - | ||
| 1246 | -// cnt, assessList, err := assessRepo.Find(condition) | ||
| 1247 | -// if err != nil { | ||
| 1248 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1249 | -// } | ||
| 1250 | -// var assessContentList []*domain.StaffAssessContent | ||
| 1251 | -// if len(assessList) > 0 { | ||
| 1252 | -// //获取评估用的所有评估项 | ||
| 1253 | -// assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessList[0]) | ||
| 1254 | -// if err != nil { | ||
| 1255 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error()) | ||
| 1256 | -// } | ||
| 1257 | -// } | ||
| 1258 | -// //可变的表格列 | ||
| 1259 | -// changeableHeader := []adapter.ListTableHeader{} | ||
| 1260 | -// //列名与字段对应 | ||
| 1261 | -// keyMap := map[string]string{} | ||
| 1262 | -// for i, v := range assessContentList { | ||
| 1263 | -// name := fmt.Sprintf("%s-%s", v.Category, v.Name) | ||
| 1264 | -// key := fmt.Sprintf("k%d", i) | ||
| 1265 | -// keyMap[name] = key | ||
| 1266 | -// changeableHeader = append(changeableHeader, adapter.ListTableHeader{ | ||
| 1267 | -// Key: key, | ||
| 1268 | -// Name: name, | ||
| 1269 | -// }) | ||
| 1270 | -// } | ||
| 1271 | -// assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
| 1272 | -// "transactionContext": transactionContext, | ||
| 1273 | -// }) | ||
| 1274 | -// // 获取已经填报的内容 | ||
| 1275 | -// changeableRows := map[int]map[string]string{} | ||
| 1276 | -// for _, v := range assessList { | ||
| 1277 | -// _, contentList, err := assessContentRepo.Find(map[string]interface{}{ | ||
| 1278 | -// "staffAssessId": v.Id, | ||
| 1279 | -// }) | ||
| 1280 | -// if err != nil { | ||
| 1281 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error()) | ||
| 1282 | -// } | ||
| 1283 | -// row := map[string]string{} | ||
| 1284 | -// for _, vv := range contentList { | ||
| 1285 | -// name := fmt.Sprintf("%s-%s", vv.Category, vv.Name) | ||
| 1286 | -// if kk, ok := keyMap[name]; ok { | ||
| 1287 | -// row[kk] = vv.Value | ||
| 1288 | -// } | ||
| 1289 | -// } | ||
| 1290 | -// changeableRows[v.TargetUser.UserId] = row | ||
| 1291 | -// } | ||
| 1292 | - | ||
| 1293 | -// //获取360邀请评估完成情况 | ||
| 1294 | -// //我评估别人,被邀请评估 | ||
| 1295 | -// cnnt, _, err := assessRepo.Find(map[string]interface{}{ | ||
| 1296 | -// "staffAssessTaskId": param.AssessTaskId, | ||
| 1297 | -// "executorId": param.ExecutorId, | ||
| 1298 | -// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 1299 | -// "status": domain.StaffAssessUncompleted, | ||
| 1300 | -// }) | ||
| 1301 | -// if err != nil { | ||
| 1302 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 1303 | -// } | ||
| 1304 | - | ||
| 1305 | -// assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{ | ||
| 1306 | -// "id": param.AssessTaskId, | ||
| 1307 | -// }) | ||
| 1308 | -// if err != nil { | ||
| 1309 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error()) | ||
| 1310 | -// } | ||
| 1311 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 1312 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1313 | -// } | ||
| 1314 | - | ||
| 1315 | -// //评估填写数据行转列 | ||
| 1316 | -// tableHeader := []adapter.ListTableHeader{ | ||
| 1317 | -// {Key: "userName", Name: "姓名"}, | ||
| 1318 | -// {Key: "status", Name: "状态"}, | ||
| 1319 | -// {Key: "types", Name: "360°评估关系"}, | ||
| 1320 | -// {Key: "endTime", Name: "360°评估截止日期"}, | ||
| 1321 | -// } | ||
| 1322 | -// tableHeader = append(tableHeader, changeableHeader...) | ||
| 1323 | -// listData := []map[string]interface{}{} | ||
| 1324 | -// for _, v := range assessList { | ||
| 1325 | -// m := map[string]interface{}{ | ||
| 1326 | -// "userName": v.TargetUser.UserName, | ||
| 1327 | -// "userId": strconv.Itoa(v.TargetUser.UserId), | ||
| 1328 | -// "status": string(v.Status), | ||
| 1329 | -// "types": string(v.Types), | ||
| 1330 | -// "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 1331 | -// "assessId": strconv.Itoa(v.Id), | ||
| 1332 | -// } | ||
| 1333 | -// switch v.Status { | ||
| 1334 | -// case domain.StaffAssessCompleted: | ||
| 1335 | -// m["status"] = "已经完成" | ||
| 1336 | -// case domain.StaffAssessUncompleted: | ||
| 1337 | -// m["status"] = "未完成" | ||
| 1338 | -// } | ||
| 1339 | - | ||
| 1340 | -// switch v.Types { | ||
| 1341 | -// case domain.AssessInviteDiffSuper: | ||
| 1342 | -// m["types"] = "不同上级同事" | ||
| 1343 | -// case domain.AssessInviteSameSuper: | ||
| 1344 | -// m["types"] = "相同上级同事" | ||
| 1345 | -// } | ||
| 1346 | -// if row, ok := changeableRows[v.TargetUser.UserId]; ok { | ||
| 1347 | -// for k, v := range row { | ||
| 1348 | -// m[k] = v | ||
| 1349 | -// } | ||
| 1350 | -// } else { | ||
| 1351 | -// for _, v := range changeableHeader { | ||
| 1352 | -// m[v.Key] = "" | ||
| 1353 | -// } | ||
| 1354 | -// } | ||
| 1355 | -// listData = append(listData, m) | ||
| 1356 | -// } | ||
| 1357 | -// result := adapter.ListInviteUserAssessResp{ | ||
| 1358 | -// TableHeader: tableHeader, | ||
| 1359 | -// List: listData, | ||
| 1360 | -// Total: cnt, | ||
| 1361 | -// } | ||
| 1362 | -// for _, v := range assessTaskData.StepList { | ||
| 1363 | -// if v.LinkNodeType == domain.LinkNodeAllAssessment { | ||
| 1364 | -// result.LinkNodeId = v.LinkNodeId | ||
| 1365 | -// result.LinkNodeName = v.LinkNodeName | ||
| 1366 | -// result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt) | ||
| 1367 | -// } | ||
| 1368 | -// } | ||
| 1369 | -// return &result, nil | ||
| 1370 | -// } | ||
| 1371 | - | ||
| 1372 | -// 获取我需要执行的上级评估成员列表 | ||
| 1373 | -// func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) { | ||
| 1374 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 1375 | -// if err != nil { | ||
| 1376 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1377 | -// } | ||
| 1378 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 1379 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1380 | -// } | ||
| 1381 | -// defer func() { | ||
| 1382 | -// _ = transactionContext.RollbackTransaction() | ||
| 1383 | -// }() | ||
| 1384 | -// //获取对应的评估任务 | ||
| 1385 | -// assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 1386 | -// "transactionContext": transactionContext, | ||
| 1387 | -// }) | ||
| 1388 | - | ||
| 1389 | -// limit := 20 | ||
| 1390 | -// if param.PageSize > 0 { | ||
| 1391 | -// limit = param.PageSize | ||
| 1392 | -// } | ||
| 1393 | -// condition := map[string]interface{}{ | ||
| 1394 | -// "staffAssessTaskId": param.AssessTaskId, | ||
| 1395 | -// "executorId": param.ExecutorId, | ||
| 1396 | -// "typesList": []string{string(domain.AssessSuper)}, | ||
| 1397 | -// "limit": limit, | ||
| 1398 | -// "targetUserName": param.UserName, | ||
| 1399 | -// } | ||
| 1400 | -// offset := (param.PageNumber - 1) * param.PageSize | ||
| 1401 | -// if offset > 0 { | ||
| 1402 | -// condition["offset"] = offset | ||
| 1403 | -// } | ||
| 1404 | -// //获取 executorId 对应的上级评估列表 | ||
| 1405 | -// cnt, assessList, err := assessRepo.Find(condition) | ||
| 1406 | -// if err != nil { | ||
| 1407 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1408 | -// } | ||
| 1409 | - | ||
| 1410 | -// userIds := []int{} | ||
| 1411 | -// for _, v := range assessList { | ||
| 1412 | -// userIds = append(userIds, v.TargetUser.UserId) | ||
| 1413 | -// } | ||
| 1414 | -// //获取员工信息 | ||
| 1415 | -// userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 1416 | -// "transactionContext": transactionContext, | ||
| 1417 | -// }) | ||
| 1418 | -// var targetUserList []*domain.User | ||
| 1419 | -// if len(userIds) > 0 { | ||
| 1420 | -// _, targetUserList, _ = userRepo.Find(map[string]interface{}{ | ||
| 1421 | -// "ids": userIds, | ||
| 1422 | -// }) | ||
| 1423 | -// } | ||
| 1424 | -// //获取职位信息 | ||
| 1425 | -// positionRepo := factory.CreatePositionRepository(map[string]interface{}{ | ||
| 1426 | -// "transactionContext": transactionContext, | ||
| 1427 | -// }) | ||
| 1428 | -// //获取员工的职位 | ||
| 1429 | -// userPositionMap := map[int64][]*domain.Position{} | ||
| 1430 | -// for _, v := range targetUserList { | ||
| 1431 | -// if len(v.PositionId) == 0 { | ||
| 1432 | -// continue | ||
| 1433 | -// } | ||
| 1434 | -// _, positionList, _ := positionRepo.Find(map[string]interface{}{ | ||
| 1435 | -// "ids": v.PositionId, | ||
| 1436 | -// }) | ||
| 1437 | -// userPositionMap[v.Id] = positionList | ||
| 1438 | -// } | ||
| 1439 | - | ||
| 1440 | -// //获取员工邀请的人完成360评估的数量 | ||
| 1441 | -// var inviteCompletedCount []dao.CountData | ||
| 1442 | -// if len(userIds) > 0 { | ||
| 1443 | -// d := dao.NewStaffAssessDao(map[string]interface{}{ | ||
| 1444 | -// "transactionContext": transactionContext, | ||
| 1445 | -// }) | ||
| 1446 | -// inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId) | ||
| 1447 | -// if err != nil { | ||
| 1448 | -// log.Logger.Error("获取员工邀请的人完成情况" + err.Error()) | ||
| 1449 | -// } | ||
| 1450 | -// } | ||
| 1451 | -// assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 1452 | -// "transactionContext": transactionContext, | ||
| 1453 | -// }) | ||
| 1454 | -// assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{ | ||
| 1455 | -// "id": param.AssessTaskId, | ||
| 1456 | -// }) | ||
| 1457 | -// if err != nil { | ||
| 1458 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error()) | ||
| 1459 | -// } | ||
| 1460 | -// //我评估别人,被邀请评估 | ||
| 1461 | -// cnnt, _, err := assessRepo.Find(map[string]interface{}{ | ||
| 1462 | -// "staffAssessTaskId": param.AssessTaskId, | ||
| 1463 | -// "executorId": param.ExecutorId, | ||
| 1464 | -// "typesList": []string{string(domain.AssessSuper)}, | ||
| 1465 | -// "status": string(domain.StaffAssessUncompleted), | ||
| 1466 | -// }) | ||
| 1467 | -// if err != nil { | ||
| 1468 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 1469 | -// } | ||
| 1470 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 1471 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1472 | -// } | ||
| 1473 | - | ||
| 1474 | -// resultList := []adapter.ListSupperAssessResp{} | ||
| 1475 | -// for _, v := range assessList { | ||
| 1476 | -// item := adapter.ListSupperAssessResp{ | ||
| 1477 | -// AssessId: v.Id, | ||
| 1478 | -// UserId: v.TargetUser.UserId, | ||
| 1479 | -// UserName: v.TargetUser.UserName, | ||
| 1480 | -// EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 1481 | -// InviteCompleted: 0, | ||
| 1482 | -// Status: string(v.Status), | ||
| 1483 | -// InviteTotal: 5, | ||
| 1484 | -// Department: "", | ||
| 1485 | -// Position: "", | ||
| 1486 | -// DutyTime: "", | ||
| 1487 | -// } | ||
| 1488 | -// //填入部门 | ||
| 1489 | -// for _, vv := range v.TargetDepartment { | ||
| 1490 | -// item.Department += vv.DepartmentName + " " | ||
| 1491 | -// } | ||
| 1492 | -// for _, vv := range targetUserList { | ||
| 1493 | -// if vv.Id != int64(v.TargetUser.UserId) { | ||
| 1494 | -// continue | ||
| 1495 | -// } | ||
| 1496 | -// //填入入职时间 | ||
| 1497 | -// item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05") | ||
| 1498 | -// //填入职位 | ||
| 1499 | -// for _, vvv := range userPositionMap[vv.Id] { | ||
| 1500 | -// item.Position += vvv.Name + " " | ||
| 1501 | -// } | ||
| 1502 | -// break | ||
| 1503 | -// } | ||
| 1504 | -// // | ||
| 1505 | -// for _, vv := range inviteCompletedCount { | ||
| 1506 | -// if v.TargetUser.UserId == vv.TargetUserId { | ||
| 1507 | -// item.InviteCompleted = vv.InviteCompleted | ||
| 1508 | -// item.InviteTotal = vv.InviteTotal | ||
| 1509 | -// break | ||
| 1510 | -// } | ||
| 1511 | -// } | ||
| 1512 | -// resultList = append(resultList, item) | ||
| 1513 | -// } | ||
| 1514 | -// result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList) | ||
| 1515 | -// result["linkNodeName"] = "" | ||
| 1516 | -// result["linkNodeId"] = "" | ||
| 1517 | -// result["lintNodeDesc"] = "" | ||
| 1518 | -// for _, v := range assessTaskData.StepList { | ||
| 1519 | -// if v.LinkNodeType == domain.LinkNodeSuperiorAssessment { | ||
| 1520 | -// result["linkNodeName"] = v.LinkNodeName | ||
| 1521 | -// result["linkNodeId"] = fmt.Sprintf("%d", v.LinkNodeId) | ||
| 1522 | -// result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt) | ||
| 1523 | -// } | ||
| 1524 | -// } | ||
| 1525 | -// return result, nil | ||
| 1526 | -// } | ||
| 1527 | - | ||
| 1528 | // 根据staffAssessId 获取评估的填写信息 | 832 | // 根据staffAssessId 获取评估的填写信息 |
| 1529 | func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { | 833 | func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { |
| 1530 | transactionContext, err := factory.CreateTransactionContext(nil) | 834 | transactionContext, err := factory.CreateTransactionContext(nil) |
| @@ -1777,126 +1081,22 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma | @@ -1777,126 +1081,22 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma | ||
| 1777 | }, nil | 1081 | }, nil |
| 1778 | } | 1082 | } |
| 1779 | 1083 | ||
| 1780 | -// 获取员工被评估的列表 | ||
| 1781 | -// func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserAssessQuery) (map[string]interface{}, error) { | ||
| 1782 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 1783 | -// if err != nil { | ||
| 1784 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1785 | -// } | ||
| 1786 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 1787 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 1788 | -// } | ||
| 1789 | -// defer func() { | ||
| 1790 | -// _ = transactionContext.RollbackTransaction() | ||
| 1791 | -// }() | ||
| 1792 | -// assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 1793 | -// "transactionContext": transactionContext, | ||
| 1794 | -// }) | ||
| 1795 | -// //获取员工的评估 | ||
| 1796 | -// cnt, assessList, err := assessReps.Find(map[string]interface{}{ | ||
| 1797 | -// "staffAssessTaskId": param.AssessTaskId, | ||
| 1798 | -// "companyId": param.CompanyId, | ||
| 1799 | -// "targetUserId": param.TargetUserId, | ||
| 1800 | -// "typesList": param.Types, | ||
| 1801 | -// }) | ||
| 1802 | -// if err != nil { | ||
| 1803 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
| 1804 | -// } | ||
| 1805 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 1806 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1807 | -// } | ||
| 1808 | - | ||
| 1809 | -// return tool_funs.SimpleWrapGridMap(int64(cnt), assessList), nil | ||
| 1810 | -// } | ||
| 1811 | - | ||
| 1812 | // 获取员工的上级是谁 | 1084 | // 获取员工的上级是谁 |
| 1813 | func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) { | 1085 | func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) { |
| 1814 | - departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
| 1815 | - "transactionContext": transactionContext, | ||
| 1816 | - }) | ||
| 1817 | - userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 1818 | - "transactionContext": transactionContext, | ||
| 1819 | - }) | ||
| 1820 | - | ||
| 1821 | - var departmemtList []*domain.Department | ||
| 1822 | - var err error | ||
| 1823 | - if len(targetUser.DepartmentId) > 0 { | ||
| 1824 | - _, departmemtList, err = departmentRepo.Find(map[string]interface{}{ | ||
| 1825 | - "ids": targetUser.DepartmentId, | ||
| 1826 | - }) | ||
| 1827 | - if err != nil { | ||
| 1828 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的部门列表"+err.Error()) | ||
| 1829 | - } | 1086 | + if targetUser.ParentId == 0 { |
| 1087 | + return nil, nil | ||
| 1830 | } | 1088 | } |
| 1831 | - if len(departmemtList) == 0 { | ||
| 1832 | - //找不到员工的部门 | ||
| 1833 | - companyRepo := factory.CreateCompanyRepository(map[string]interface{}{ | 1089 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ |
| 1834 | "transactionContext": transactionContext, | 1090 | "transactionContext": transactionContext, |
| 1835 | }) | 1091 | }) |
| 1836 | - companyData, err := companyRepo.FindOne(map[string]interface{}{ | ||
| 1837 | - "id": targetUser.CompanyId, | ||
| 1838 | - }) | ||
| 1839 | - if err != nil { | ||
| 1840 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error()) | ||
| 1841 | - } | ||
| 1842 | - //公司作为最顶级 | ||
| 1843 | - departmemtList = append(departmemtList, &domain.Department{ | ||
| 1844 | - Id: 0, | ||
| 1845 | - CompanyId: companyData.Id, | ||
| 1846 | - Level: 0, | ||
| 1847 | - Name: companyData.Name, | ||
| 1848 | - ParentId: 0, | ||
| 1849 | - ChargeUserIds: companyData.ChargeUserIds, | ||
| 1850 | - Path: "", | ||
| 1851 | - CreatedAt: time.Time{}, | ||
| 1852 | - UpdatedAt: time.Time{}, | ||
| 1853 | - DeletedAt: &time.Time{}, | ||
| 1854 | - }) | ||
| 1855 | - | ||
| 1856 | - } | ||
| 1857 | - //获取部门管理员 | ||
| 1858 | - var chargeUserIds []int64 | ||
| 1859 | - var targetUserAsManager *domain.Department | ||
| 1860 | -loop: | ||
| 1861 | - for _, v := range departmemtList { | ||
| 1862 | - if len(v.ChargeUserIds) == 0 { | ||
| 1863 | - continue | ||
| 1864 | - } | ||
| 1865 | - //检查员工自身是否是管理员 | ||
| 1866 | - for _, vv := range v.ChargeUserIds { | ||
| 1867 | - if vv == targetUser.Id { | ||
| 1868 | - targetUserAsManager = v | ||
| 1869 | - break loop | ||
| 1870 | - } | ||
| 1871 | - } | ||
| 1872 | - chargeUserIds = append(chargeUserIds, v.ChargeUserIds...) | ||
| 1873 | - } | ||
| 1874 | - if targetUserAsManager != nil { | ||
| 1875 | - //清空原有的管理员 | ||
| 1876 | - chargeUserIds = []int64{} | ||
| 1877 | - //员工自身是否是管理员,查找父级部门 | ||
| 1878 | - _, parentDepartment, err := departmentRepo.Find(map[string]interface{}{ | ||
| 1879 | - "id": targetUserAsManager.ParentId, | ||
| 1880 | - }) | ||
| 1881 | - if err != nil { | ||
| 1882 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工现在部门的父级"+err.Error()) | ||
| 1883 | - } | ||
| 1884 | - for _, v := range parentDepartment { | ||
| 1885 | - chargeUserIds = append(chargeUserIds, v.ChargeUserIds...) | ||
| 1886 | - } | ||
| 1887 | - } | ||
| 1888 | 1092 | ||
| 1889 | - var chargeUserList []*domain.User | ||
| 1890 | - if len(chargeUserIds) > 0 { | ||
| 1891 | - _, chargeUserList, err = userRepo.Find(map[string]interface{}{ | ||
| 1892 | - "ids": chargeUserIds, | ||
| 1893 | - "status": 1, //正常的用户 | 1093 | + userData, err := userRepo.FindOne(map[string]interface{}{ |
| 1094 | + "id": targetUser.ParentId, | ||
| 1894 | }) | 1095 | }) |
| 1895 | if err != nil { | 1096 | if err != nil { |
| 1896 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error()) | ||
| 1897 | - } | 1097 | + return nil, err |
| 1898 | } | 1098 | } |
| 1899 | - return chargeUserList, nil | 1099 | + return []*domain.User{userData}, nil |
| 1900 | } | 1100 | } |
| 1901 | 1101 | ||
| 1902 | func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) { | 1102 | func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) { |
| @@ -2,6 +2,9 @@ package service | @@ -2,6 +2,9 @@ package service | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | + "strconv" | ||
| 6 | + "strings" | ||
| 7 | + | ||
| 5 | "github.com/linmadan/egglib-go/core/application" | 8 | "github.com/linmadan/egglib-go/core/application" |
| 6 | "github.com/linmadan/egglib-go/utils/tool_funs" | 9 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 7 | "github.com/xuri/excelize/v2" | 10 | "github.com/xuri/excelize/v2" |
| @@ -11,31 +14,29 @@ import ( | @@ -11,31 +14,29 @@ import ( | ||
| 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | 14 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" |
| 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 15 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | 16 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" |
| 14 | - "strconv" | ||
| 15 | - "strings" | ||
| 16 | ) | 17 | ) |
| 17 | 18 | ||
| 18 | // 调试用,手动调用CreateStaffAssessTask | 19 | // 调试用,手动调用CreateStaffAssessTask |
| 19 | func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { | 20 | func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { |
| 20 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 21 | - if err != nil { | ||
| 22 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 23 | - } | ||
| 24 | - if err := transactionContext.StartTransaction(); err != nil { | ||
| 25 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 26 | - } | ||
| 27 | - defer func() { | ||
| 28 | - _ = transactionContext.RollbackTransaction() | ||
| 29 | - }() | 21 | + // transactionContext, err := factory.CreateTransactionContext(nil) |
| 22 | + // if err != nil { | ||
| 23 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 24 | + // } | ||
| 25 | + // if err := transactionContext.StartTransaction(); err != nil { | ||
| 26 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 27 | + // } | ||
| 28 | + // defer func() { | ||
| 29 | + // _ = transactionContext.RollbackTransaction() | ||
| 30 | + // }() | ||
| 30 | 31 | ||
| 31 | - data, err := srv.CreateStaffAssessTask(transactionContext, param) | ||
| 32 | - if err != nil { | ||
| 33 | - return nil, err | ||
| 34 | - } | ||
| 35 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 36 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 37 | - } | ||
| 38 | - return data, nil | 32 | + // data, err := srv.CreateStaffAssessTask(transactionContext, param) |
| 33 | + // if err != nil { | ||
| 34 | + // return nil, err | ||
| 35 | + // } | ||
| 36 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
| 37 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 38 | + // } | ||
| 39 | + return nil, nil | ||
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[string]interface{}, error) { | 42 | func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[string]interface{}, error) { |
| @@ -82,7 +83,7 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | @@ -82,7 +83,7 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | ||
| 82 | if invite.EndTime == nil { | 83 | if invite.EndTime == nil { |
| 83 | invite.EndTime = &d.EndTime | 84 | invite.EndTime = &d.EndTime |
| 84 | } | 85 | } |
| 85 | - break | 86 | + |
| 86 | case domain.AssessSuper: | 87 | case domain.AssessSuper: |
| 87 | supper.Total++ | 88 | supper.Total++ |
| 88 | if d.Status == domain.StaffAssessCompleted { | 89 | if d.Status == domain.StaffAssessCompleted { |
| @@ -91,7 +92,7 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | @@ -91,7 +92,7 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | ||
| 91 | if supper.EndTime == nil { | 92 | if supper.EndTime == nil { |
| 92 | supper.EndTime = &d.EndTime | 93 | supper.EndTime = &d.EndTime |
| 93 | } | 94 | } |
| 94 | - break | 95 | + |
| 95 | case domain.AssessInviteDiffSuper, domain.AssessInviteSameSuper: | 96 | case domain.AssessInviteDiffSuper, domain.AssessInviteSameSuper: |
| 96 | inviteAssess.Total++ | 97 | inviteAssess.Total++ |
| 97 | if d.Status == domain.StaffAssessCompleted { | 98 | if d.Status == domain.StaffAssessCompleted { |
| @@ -102,7 +103,7 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | @@ -102,7 +103,7 @@ func (srv StaffAssessServeice) QuerySummary(in *query.SummaryCommand) (map[strin | ||
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | inviteTargetIdMap[d.TargetUserId] = 0 // 360评估类型都是被人邀请的评估,过滤相同的目标用户后,就是完成邀请的数量 | 105 | inviteTargetIdMap[d.TargetUserId] = 0 // 360评估类型都是被人邀请的评估,过滤相同的目标用户后,就是完成邀请的数量 |
| 105 | - break | 106 | + |
| 106 | } | 107 | } |
| 107 | } | 108 | } |
| 108 | invite.Completed = len(inviteTargetIdMap) | 109 | invite.Completed = len(inviteTargetIdMap) |
| @@ -91,38 +91,6 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs | @@ -91,38 +91,6 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs | ||
| 91 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 91 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | - //roleRepo := factory.CreateRoleRepository(map[string]interface{}{ | ||
| 95 | - // "transactionContext": transactionContext, | ||
| 96 | - //}) | ||
| 97 | - //roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{ | ||
| 98 | - // "transactionContext": transactionContext, | ||
| 99 | - //}) | ||
| 100 | - //_, roleList, err := roleRepo.Find(map[string]interface{}{ | ||
| 101 | - // "type": domain.RoleTypeSystem, | ||
| 102 | - // "companyId": param.CompanyId, | ||
| 103 | - //}) | ||
| 104 | - //if err != nil { | ||
| 105 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) | ||
| 106 | - //} | ||
| 107 | - //_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{ | ||
| 108 | - // "companyId": param.CompanyId, | ||
| 109 | - // "userId": param.OperaterId, | ||
| 110 | - //}) | ||
| 111 | - //if err != nil { | ||
| 112 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) | ||
| 113 | - //} | ||
| 114 | - //hrbp := -1 | ||
| 115 | - //for _, v := range userRoleList { | ||
| 116 | - // for _, v2 := range roleList { | ||
| 117 | - // if v.RoleId == v2.Id { | ||
| 118 | - // hrbp = 1 | ||
| 119 | - // break | ||
| 120 | - // } | ||
| 121 | - // } | ||
| 122 | - // if hrbp == 1 { | ||
| 123 | - // break | ||
| 124 | - // } | ||
| 125 | - //} | ||
| 126 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | 94 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{ |
| 127 | "transactionContext": transactionContext, | 95 | "transactionContext": transactionContext, |
| 128 | }) | 96 | }) |
| @@ -209,224 +177,6 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs | @@ -209,224 +177,6 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs | ||
| 209 | return &result, nil | 177 | return &result, nil |
| 210 | } | 178 | } |
| 211 | 179 | ||
| 212 | -// func (srv StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) { | ||
| 213 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 214 | -// if err != nil { | ||
| 215 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 216 | -// } | ||
| 217 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 218 | -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 219 | -// } | ||
| 220 | -// defer func() { | ||
| 221 | -// _ = transactionContext.RollbackTransaction() | ||
| 222 | -// }() | ||
| 223 | - | ||
| 224 | -// hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId) | ||
| 225 | -// if err != nil { | ||
| 226 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 227 | -// } | ||
| 228 | - | ||
| 229 | -// assessDao := dao.NewStaffAssessDao(map[string]interface{}{ | ||
| 230 | -// "transactionContext": transactionContext, | ||
| 231 | -// }) | ||
| 232 | -// contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{ | ||
| 233 | -// CompanyId: param.CompanyId, | ||
| 234 | -// CycleId: param.CycleId, | ||
| 235 | -// BeginDay: param.BeginDay, | ||
| 236 | -// TargetUserName: param.TargetUserName, | ||
| 237 | -// TargetUserId: param.TargetUserId, | ||
| 238 | -// Limit: 5000, | ||
| 239 | -// Offset: 0, | ||
| 240 | -// OperaterId: param.OperaterId, | ||
| 241 | -// Hrbp: hrbp, | ||
| 242 | -// }) | ||
| 243 | -// if err != nil { | ||
| 244 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取数据列表"+err.Error()) | ||
| 245 | -// } | ||
| 246 | - | ||
| 247 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 248 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 249 | -// } | ||
| 250 | -// //选择导出的评估项 | ||
| 251 | -// includeCol := map[string]struct{}{} | ||
| 252 | -// for _, v := range param.ExportItems { | ||
| 253 | -// includeCol[v.Category+"+"+v.Name] = struct{}{} | ||
| 254 | -// } | ||
| 255 | - | ||
| 256 | -// //处理查询到的数据 | ||
| 257 | -// //汇总 Excel表格的表头描述 | ||
| 258 | -// level1 := []string{} //分类 | ||
| 259 | -// level3 := map[string][]string{} //key=分类+得分项类型 val=名称 | ||
| 260 | -// level4 := map[string]string{} //key=分类+名称 val=评估标准 | ||
| 261 | -// for _, v := range contentList { | ||
| 262 | -// if v.ContentId == 0 { | ||
| 263 | -// continue | ||
| 264 | -// } | ||
| 265 | -// if len(includeCol) > 0 { | ||
| 266 | -// if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok { | ||
| 267 | -// continue | ||
| 268 | -// } | ||
| 269 | -// } | ||
| 270 | -// level1Item := "" | ||
| 271 | -// for _, v1 := range level1 { | ||
| 272 | -// if v.Category == v1 { | ||
| 273 | -// level1Item = v1 | ||
| 274 | -// } | ||
| 275 | -// } | ||
| 276 | -// if len(level1Item) == 0 { | ||
| 277 | -// level1 = append(level1, v.Category) | ||
| 278 | -// } | ||
| 279 | -// if v.Weight == 0 { | ||
| 280 | -// level3Key := v.Category + "-加分项" | ||
| 281 | -// if _, ok := level3[level3Key]; !ok { | ||
| 282 | -// level3[level3Key] = []string{} | ||
| 283 | -// } | ||
| 284 | -// level3Item := "" | ||
| 285 | -// for _, v3 := range level3[level3Key] { | ||
| 286 | -// if v3 == v.ContentName { | ||
| 287 | -// level3Item = v.ContentName | ||
| 288 | -// } | ||
| 289 | -// } | ||
| 290 | -// if len(level3Item) == 0 { | ||
| 291 | -// level3[level3Key] = append(level3[level3Key], v.ContentName) | ||
| 292 | -// } | ||
| 293 | -// } | ||
| 294 | -// if v.Weight > 0 { | ||
| 295 | -// level3Key := v.Category + "-得分项" | ||
| 296 | -// if _, ok := level3[level3Key]; !ok { | ||
| 297 | -// level3[level3Key] = []string{} | ||
| 298 | -// } | ||
| 299 | -// level3Item := "" | ||
| 300 | -// for _, v3 := range level3[level3Key] { | ||
| 301 | -// if v3 == v.ContentName { | ||
| 302 | -// level3Item = v.ContentName | ||
| 303 | -// } | ||
| 304 | -// } | ||
| 305 | -// if len(level3Item) == 0 { | ||
| 306 | -// level3[level3Key] = append(level3[level3Key], v.ContentName) | ||
| 307 | -// } | ||
| 308 | -// } | ||
| 309 | - | ||
| 310 | -// level4Key := v.Category + "+" + v.ContentName | ||
| 311 | -// if _, ok := level4[level4Key]; !ok { | ||
| 312 | -// level4[level4Key] = v.PromptText | ||
| 313 | -// } | ||
| 314 | -// } | ||
| 315 | -// //汇总表头,按列 | ||
| 316 | -// headerList := []excelTableHeader{ | ||
| 317 | -// { | ||
| 318 | -// Level1: "日期", | ||
| 319 | -// Level2: "", | ||
| 320 | -// Level3: "", | ||
| 321 | -// Level4: "评估标准", | ||
| 322 | -// }, { | ||
| 323 | -// Level1: "姓名", | ||
| 324 | -// Level2: "", | ||
| 325 | -// Level3: "", | ||
| 326 | -// Level4: "", | ||
| 327 | -// }, | ||
| 328 | -// } | ||
| 329 | -// for _, v := range level1 { | ||
| 330 | -// item := excelTableHeader{ | ||
| 331 | -// Level1: v, | ||
| 332 | -// } | ||
| 333 | -// level3Key := v + "-加分项" | ||
| 334 | -// if _, ok := level3[level3Key]; ok { | ||
| 335 | -// for _, v2 := range level3[level3Key] { | ||
| 336 | -// item.Level2 = "加分项" | ||
| 337 | -// item.Level3 = v2 | ||
| 338 | -// level4Key := v + "+" + v2 | ||
| 339 | -// item.Level4 = level4[level4Key] | ||
| 340 | -// headerList = append(headerList, item) | ||
| 341 | -// } | ||
| 342 | -// } | ||
| 343 | -// level3Key = v + "-得分项" | ||
| 344 | -// if _, ok := level3[level3Key]; ok { | ||
| 345 | -// for _, v2 := range level3[level3Key] { | ||
| 346 | -// item.Level2 = "得分项" | ||
| 347 | -// item.Level3 = v2 | ||
| 348 | -// level4Key := v + "+" + v2 | ||
| 349 | -// item.Level4 = level4[level4Key] | ||
| 350 | -// headerList = append(headerList, item) | ||
| 351 | -// } | ||
| 352 | -// } | ||
| 353 | -// } | ||
| 354 | -// //数据形式 进行 行列转换 | ||
| 355 | -// tableRows := map[string]map[string]string{} | ||
| 356 | -// tableRowSort := []string{} | ||
| 357 | -// for _, v := range contentList { | ||
| 358 | -// if _, ok := tableRows[v.TargetUserId]; !ok { | ||
| 359 | -// tableRows[v.TargetUserId] = map[string]string{} | ||
| 360 | -// tableRowSort = append(tableRowSort, v.TargetUserId) | ||
| 361 | -// } | ||
| 362 | -// tableRows[v.TargetUserId]["TargetUserName"] = v.TargetUserName | ||
| 363 | -// tableRows[v.TargetUserId]["BeginDay"] = v.BeginDay | ||
| 364 | -// if v.ContentId > 0 { | ||
| 365 | -// if len(includeCol) > 0 { | ||
| 366 | -// if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok { | ||
| 367 | -// continue | ||
| 368 | -// } | ||
| 369 | -// } | ||
| 370 | -// value := []string{v.Value} | ||
| 371 | -// for _, v2 := range v.Remark { | ||
| 372 | -// value = append(value, v2.RemarkText) | ||
| 373 | -// } | ||
| 374 | -// key := v.Category + "+" + v.ContentName | ||
| 375 | -// tableRows[v.TargetUserId][key] = strings.Join(value, "\n") | ||
| 376 | -// } | ||
| 377 | -// } | ||
| 378 | -// //将数据写入xlsx | ||
| 379 | -// xlsxFile := excelize.NewFile() | ||
| 380 | -// sheetIndex := xlsxFile.GetActiveSheetIndex() | ||
| 381 | -// sheetName := xlsxFile.GetSheetName(sheetIndex) | ||
| 382 | -// //写入第一行 | ||
| 383 | -// xlsxFile.SetCellStr(sheetName, "A1", "每日绩效汇总") | ||
| 384 | -// //写入二到五行 | ||
| 385 | -// for k, v := range headerList { | ||
| 386 | -// colName, _ := excelize.ColumnNumberToName(k + 1) | ||
| 387 | -// xlsxFile.SetCellStr(sheetName, colName+"2", v.Level1) | ||
| 388 | -// xlsxFile.SetCellStr(sheetName, colName+"3", v.Level2) | ||
| 389 | -// xlsxFile.SetCellStr(sheetName, colName+"4", v.Level3) | ||
| 390 | -// xlsxFile.SetCellStr(sheetName, colName+"5", v.Level4) | ||
| 391 | -// } | ||
| 392 | -// //从第六行开始写入用户填写的评估数据 | ||
| 393 | -// for k, v := range tableRowSort { | ||
| 394 | -// rowNum := strconv.Itoa(k + 6) | ||
| 395 | -// row := tableRows[v] | ||
| 396 | -// for k2, v2 := range headerList { | ||
| 397 | -// if k2 == 0 { | ||
| 398 | -// xlsxFile.SetCellStr(sheetName, "A"+rowNum, row["BeginDay"]) | ||
| 399 | -// continue | ||
| 400 | -// } | ||
| 401 | -// if k2 == 1 { | ||
| 402 | -// xlsxFile.SetCellStr(sheetName, "B"+rowNum, row["TargetUserName"]) | ||
| 403 | -// continue | ||
| 404 | -// } | ||
| 405 | -// colName, _ := excelize.ColumnNumberToName(k2 + 1) | ||
| 406 | -// key := v2.Level1 + "+" + v2.Level3 | ||
| 407 | -// if mVal, ok := row[key]; ok { | ||
| 408 | -// xlsxFile.SetCellStr(sheetName, colName+rowNum, mVal) | ||
| 409 | -// } | ||
| 410 | -// } | ||
| 411 | -// } | ||
| 412 | -// //TODO 调整样式 | ||
| 413 | -// xlsxFile.MergeCell(sheetName, "A2", "A4") | ||
| 414 | -// xlsxFile.MergeCell(sheetName, "B2", "B4") | ||
| 415 | -// xlsxFile.MergeCell(sheetName, "B5", "B5") | ||
| 416 | -// //设置行高 | ||
| 417 | -// for i := range tableRowSort { | ||
| 418 | -// xlsxFile.SetRowHeight(sheetName, i+5, 50) | ||
| 419 | -// } | ||
| 420 | -// //设置列宽 | ||
| 421 | -// for i := range headerList { | ||
| 422 | -// colName, _ := excelize.ColumnNumberToName(i + 1) | ||
| 423 | -// if i == 0 { | ||
| 424 | -// xlsxFile.SetColWidth(sheetName, colName, colName, 30) | ||
| 425 | -// } | ||
| 426 | -// } | ||
| 427 | -// return xlsxFile, nil | ||
| 428 | -// } | ||
| 429 | - | ||
| 430 | //员工绩效-项目管理-矩阵分析 | 180 | //员工绩效-项目管理-矩阵分析 |
| 431 | 181 | ||
| 432 | func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleDay) (*adapter.AssessAnalysisResp, error) { | 182 | func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleDay) (*adapter.AssessAnalysisResp, error) { |
| @@ -708,7 +458,7 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess | @@ -708,7 +458,7 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess | ||
| 708 | 458 | ||
| 709 | // 员工绩效-项目管理-成员列表导出 | 459 | // 员工绩效-项目管理-成员列表导出 |
| 710 | 460 | ||
| 711 | -func (srv StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) { | 461 | +func (srv *StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) { |
| 712 | transactionContext, err := factory.CreateTransactionContext(nil) | 462 | transactionContext, err := factory.CreateTransactionContext(nil) |
| 713 | if err != nil { | 463 | if err != nil { |
| 714 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 464 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| @@ -27,7 +27,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ | @@ -27,7 +27,7 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ | ||
| 27 | _ = transactionContext.RollbackTransaction() | 27 | _ = transactionContext.RollbackTransaction() |
| 28 | }() | 28 | }() |
| 29 | 29 | ||
| 30 | - staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{ | 30 | + staffAssessDao := dao.NewStaffAssessDao(map[string]interface{}{ |
| 31 | "transactionContext": transactionContext, | 31 | "transactionContext": transactionContext, |
| 32 | }) | 32 | }) |
| 33 | var limit int = 360 | 33 | var limit int = 360 |
| @@ -36,20 +36,39 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ | @@ -36,20 +36,39 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ | ||
| 36 | limit = param.PageSize | 36 | limit = param.PageSize |
| 37 | } | 37 | } |
| 38 | offset = (param.PageNumber - 1) * param.PageSize | 38 | offset = (param.PageNumber - 1) * param.PageSize |
| 39 | - assessCycleList, err := staffAssessTaskRepo.SearchAssessCycleMe(param.UserId, param.CompanyId, limit, offset) | 39 | + // assessCycleList, err := staffAssessTaskRepo.SearchAssessCycleMe(param.UserId, param.CompanyId, limit, offset) |
| 40 | + // if err != nil { | ||
| 41 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) | ||
| 42 | + // } | ||
| 43 | + // cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId) | ||
| 44 | + // if err != nil { | ||
| 45 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) | ||
| 46 | + // } | ||
| 47 | + | ||
| 48 | + assessCycleList, cnt, err := staffAssessDao.SearchExecutorAssessBeforeNow(param.UserId, param.CompanyId, limit, offset) | ||
| 40 | if err != nil { | 49 | if err != nil { |
| 41 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) | 50 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) |
| 42 | } | 51 | } |
| 43 | - cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId) | 52 | + assessCycleList2, err := staffAssessDao.SearchExecutorAssessAfterNow(param.UserId, param.CompanyId) |
| 44 | if err != nil { | 53 | if err != nil { |
| 45 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) | 54 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error()) |
| 46 | } | 55 | } |
| 47 | - | ||
| 48 | if err := transactionContext.CommitTransaction(); err != nil { | 56 | if err := transactionContext.CommitTransaction(); err != nil { |
| 49 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 57 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 50 | } | 58 | } |
| 51 | listData := make([]adapter.AssessCycleDayResp, 0, len(assessCycleList)) | 59 | listData := make([]adapter.AssessCycleDayResp, 0, len(assessCycleList)) |
| 60 | + | ||
| 52 | var temp adapter.AssessCycleDayResp | 61 | var temp adapter.AssessCycleDayResp |
| 62 | + for _, v := range assessCycleList2 { | ||
| 63 | + temp = adapter.AssessCycleDayResp{ | ||
| 64 | + CycleId: v.CycleId, | ||
| 65 | + CycleName: v.CycleName, | ||
| 66 | + BeginDay: v.BeginDay, | ||
| 67 | + BeginTime: v.BeginTime, | ||
| 68 | + EndTime: v.EndTime, | ||
| 69 | + } | ||
| 70 | + listData = append(listData, temp) | ||
| 71 | + } | ||
| 53 | for _, v := range assessCycleList { | 72 | for _, v := range assessCycleList { |
| 54 | temp = adapter.AssessCycleDayResp{ | 73 | temp = adapter.AssessCycleDayResp{ |
| 55 | CycleId: v.CycleId, | 74 | CycleId: v.CycleId, |
| @@ -686,7 +705,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA | @@ -686,7 +705,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA | ||
| 686 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | 705 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) |
| 687 | } | 706 | } |
| 688 | if len(assessList) == 0 { | 707 | if len(assessList) == 0 { |
| 689 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "不存在员工的自评内容") | 708 | + return &adapter.AssessInfoResp{AssessId: -1}, nil |
| 690 | } | 709 | } |
| 691 | assessData := assessList[0] | 710 | assessData := assessList[0] |
| 692 | 711 | ||
| @@ -832,3 +851,77 @@ func (srv StaffAssessServeice) ListTargetUserSuperAssess(param *query.ListTarget | @@ -832,3 +851,77 @@ func (srv StaffAssessServeice) ListTargetUserSuperAssess(param *query.ListTarget | ||
| 832 | } | 851 | } |
| 833 | return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil | 852 | return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil |
| 834 | } | 853 | } |
| 854 | + | ||
| 855 | +// 选择员工评估可邀请的用户 | ||
| 856 | +func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAssessInviteUser) (map[string]interface{}, error) { | ||
| 857 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 858 | + if err != nil { | ||
| 859 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 860 | + } | ||
| 861 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 862 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 863 | + } | ||
| 864 | + defer func() { | ||
| 865 | + _ = transactionContext.RollbackTransaction() | ||
| 866 | + }() | ||
| 867 | + //获取被评估的目标用户 | ||
| 868 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 869 | + "transactionContext": transactionContext, | ||
| 870 | + }) | ||
| 871 | + //获取公司信息 | ||
| 872 | + companyRepo := factory.CreateCompanyRepository(map[string]interface{}{ | ||
| 873 | + "transactionContext": transactionContext, | ||
| 874 | + }) | ||
| 875 | + companyInfo, _ := companyRepo.FindOne(map[string]interface{}{ | ||
| 876 | + "id": param.CompanyId, | ||
| 877 | + }) | ||
| 878 | + targetUser, err := userRepo.FindOne(map[string]interface{}{ | ||
| 879 | + "id": param.TargetUserId, | ||
| 880 | + }) | ||
| 881 | + if err != nil { | ||
| 882 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error()) | ||
| 883 | + } | ||
| 884 | + | ||
| 885 | + //查询员工数据 | ||
| 886 | + condition := map[string]interface{}{ | ||
| 887 | + "companyId": param.CompanyId, | ||
| 888 | + "name": param.InviteUserName, | ||
| 889 | + "limit": 20, | ||
| 890 | + "status": 1, | ||
| 891 | + } | ||
| 892 | + if param.PageSize > 0 { | ||
| 893 | + condition["limit"] = param.PageSize | ||
| 894 | + } | ||
| 895 | + offset := (param.PageNumber - 1) * param.PageSize | ||
| 896 | + if offset > 0 { | ||
| 897 | + condition["offset"] = offset | ||
| 898 | + } | ||
| 899 | + cnt, userList, err := userRepo.Find(condition) | ||
| 900 | + if err != nil { | ||
| 901 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error()) | ||
| 902 | + } | ||
| 903 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 904 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 905 | + } | ||
| 906 | + listData := []adapter.SelectInviteUser{} | ||
| 907 | + companyName := "" | ||
| 908 | + if companyInfo != nil { | ||
| 909 | + companyName = companyInfo.Name | ||
| 910 | + } | ||
| 911 | + for _, v := range userList { | ||
| 912 | + _ = v | ||
| 913 | + _ = companyName | ||
| 914 | + item := adapter.SelectInviteUser{ | ||
| 915 | + UserId: int(v.Id), | ||
| 916 | + UserName: v.Name, | ||
| 917 | + CompanyName: companyName, | ||
| 918 | + IsSupper: false, | ||
| 919 | + Types: 2, //默认是不同上级 | ||
| 920 | + } | ||
| 921 | + if targetUser.ParentId == v.ParentId { | ||
| 922 | + item.Types = 1 | ||
| 923 | + } | ||
| 924 | + listData = append(listData, item) | ||
| 925 | + } | ||
| 926 | + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil | ||
| 927 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 4 | + | ||
| 5 | +// 评估信息详情 | ||
| 6 | +type EvaluationInfoAdapter struct { | ||
| 7 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` // | ||
| 8 | + CycleId int `json:"cycleId,string"` //周期id | ||
| 9 | + CycleName string `json:"cycleName"` //周期名称 | ||
| 10 | + EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
| 11 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 12 | + LinkNodeId int `json:"linkNodeId,string"` //评估环节id | ||
| 13 | + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
| 14 | + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
| 15 | + TargetUserId int `json:"targetUserId"` //被评估的目标用户,被执行的 | ||
| 16 | + TargetUserName string `json:"targetUserName"` // | ||
| 17 | + CompanyLogo string `json:"companyLogo"` //公司logo | ||
| 18 | + CompanyName string `json:"companyName"` //公司名称 | ||
| 19 | + SupperUser string `json:"superUser"` //目标用户的上级 | ||
| 20 | + DutyTime string `json:"dutyTime"` //入职时间 | ||
| 21 | + Status string `json:"status"` //完成状态 | ||
| 22 | + EvaluationItems []EvaluationItemAdapter `json:"evaluationItems"` | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +// 评估填写项 | ||
| 26 | +type EvaluationItemAdapter struct { | ||
| 27 | + EvaluationItemId int `json:"evaluationItemId,string"` //评估条目的id | ||
| 28 | + SortBy int `json:"sortBy"` //排序 | ||
| 29 | + Category string `json:"category"` //类别 | ||
| 30 | + Name string `json:"name"` //名称 | ||
| 31 | + PromptTitle string `json:"promptTitle"` //提示项标题 | ||
| 32 | + PromptText string `json:"promptText"` //提示项正文 | ||
| 33 | + EntryItems []*domain.EntryItem `json:"entryItems"` //填写的反馈 | ||
| 34 | + RuleType int `json:"ruleType"` //评估方式(0评级、1评分) | ||
| 35 | + Rule domain.EvaluationRule `json:"rule"` //评估的选项规则 | ||
| 36 | + Weight float64 `json:"weight"` //"权重" | ||
| 37 | + Required int `json:"required"` // 必填项 | ||
| 38 | + Value string `json:"value"` //评估填写的评分 | ||
| 39 | + Score string `json:"score"` //计算的评定得分 | ||
| 40 | + Rating domain.RatingLevel `json:"rating"` //评级的选项 | ||
| 41 | + Remark string `json:"remark"` //填写的内容反馈 | ||
| 42 | + EvaluatorId int `json:"evaluatorId"` //评估人id | ||
| 43 | + EvaluatorName string `json:"evaluatorName"` //评估人名称 | ||
| 44 | + ForbidEdit bool `json:"forbidEdit"` //页面操作控制是否禁用编辑 | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +// 评级数量 | ||
| 48 | +type LevalCodeCount struct { | ||
| 49 | + Code string `json:"code"` //评级代码 | ||
| 50 | + Number int `json:"number"` //数量 | ||
| 51 | + ItemList []string `json:"itemList"` //对应的评估项名称 | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +// 评估任务的基本信息 | ||
| 55 | +type EvaluationBaseAdapter struct { | ||
| 56 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` // | ||
| 57 | + CycleId int `json:"cycleId,string"` //周期id | ||
| 58 | + CycleName string `json:"cycleName"` //周期名称 | ||
| 59 | + EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id | ||
| 60 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 61 | + LinkNodeId int `json:"linkNodeId,string"` //评估环节id | ||
| 62 | + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
| 63 | + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
| 64 | + TargetUserId int `json:"targetUserId,string"` //被评估的目标用户,被执行的 | ||
| 65 | + TargetUserName string `json:"targetUserName"` // | ||
| 66 | + CompanyLogo string `json:"companyLogo,"` //公司logo | ||
| 67 | + CompanyName string `json:"companyName"` //公司名称 | ||
| 68 | + SupperUser string `json:"superUser"` //目标用户的上级 | ||
| 69 | + Types int `json:"types"` //评估类型 | ||
| 70 | + DutyTime string `json:"dutyTime"` //入职时间 | ||
| 71 | + Status string `json:"status"` //完成状态 | ||
| 72 | + CheckResult string `json:"checkResult"` //确认绩效结果 | ||
| 73 | + TotalScore string `json:"totalScore"` //评估总分 | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +// 自评估内容详情 | ||
| 77 | +type EvaluationInfoSelfAdapter struct { | ||
| 78 | + EvaluationBaseAdapter | ||
| 79 | + EvaluationItems []EvaluationItemAdapter `json:"evaluationItems"` | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +// 自评小结展示,每个评估项 | ||
| 83 | +type EvaluationItemCountCodeAdapter struct { | ||
| 84 | + EvaluationItemAdapter | ||
| 85 | + LevelCount []LevalCodeCount `json:"levelCount"` //周期内每次评估的等级数量统计 | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +// 自评小结展示 | ||
| 89 | +type EvaluationInfoCountCodeAdapter struct { | ||
| 90 | + EvaluationBaseAdapter | ||
| 91 | + EvaluationItems []EvaluationItemCountCodeAdapter `json:"evaluationItems"` | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +// 上级评估详情 | ||
| 95 | +type EvaluationInfoSuperAdapter struct { | ||
| 96 | + EvaluationBaseAdapter | ||
| 97 | + LevelCount []*LevalCodeCount `json:"levelCount"` //周期内每次评估的等级数量统计 | ||
| 98 | + EvaluationItems []EvaluationItemAdapter `json:"evaluationItems"` | ||
| 99 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +type EvaluationSuperListAdapter struct { | ||
| 4 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` //评估任务id | ||
| 5 | + TargetUserName string `json:"targetUserName"` //目标用户,被评估的员工 | ||
| 6 | + TargetUserId int `json:"targetUserId,string"` //目标用户,被评估的员工 | ||
| 7 | + EvaluationStatus string `json:"evaluationStatus"` //上级评估完成状态 | ||
| 8 | + EndTime string `json:"endTime"` //截止时间 | ||
| 9 | + TotalScoreSelf string `json:"totalScoreSelf"` //综合自评总分 | ||
| 10 | + Department string `json:"department"` //部门 | ||
| 11 | + Position string `json:"position"` //职位 | ||
| 12 | + EntryTime string `json:"entryTime"` //入职时间 | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +type EvaluationSuperItemAdapter struct { | ||
| 16 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` //评估任务id | ||
| 17 | + TargetUserName string `json:"targetUserName"` //目标用户,被评估的员工 | ||
| 18 | + TargetUserId int `json:"targetUserId,string"` //目标用户,被评估的员工 | ||
| 19 | + CycleId int64 `json:"cycleId,string"` //周期id | ||
| 20 | + TotalScore string `json:"totalScore"` //得分 | ||
| 21 | + Department string `json:"department"` //部门 | ||
| 22 | + Position string `json:"position"` //职位 | ||
| 23 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +type MenuListAdapter struct { | ||
| 4 | + CycleId int `json:"cycleId,string"` | ||
| 5 | + NodeName string `json:"nodeName"` | ||
| 6 | + StatusName string `json:"statusName"` | ||
| 7 | + TargetUserId int `json:"targetUserId,string"` | ||
| 8 | + Types string `json:"types"` | ||
| 9 | + Child []MenuListAdapter `json:"child"` | ||
| 10 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +type TableHeader struct { | ||
| 4 | + Key string `json:"key"` | ||
| 5 | + Name string `json:"name"` | ||
| 6 | +} | ||
| 7 | + | ||
| 8 | +type SummaryEvaluationAdapter struct { | ||
| 9 | + TableHeader []TableHeader `json:"tableHeader"` | ||
| 10 | + List []map[string]interface{} `json:"list"` | ||
| 11 | + Total int `json:"total"` | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +type SummaryEvaluationHRBPAdapter struct { | ||
| 15 | + Id int `json:"id,string"` // 周期评估ID | ||
| 16 | + TargetUserId int `json:"targetUserId,string"` // 目标用户ID | ||
| 17 | + TargetUserName string `json:"targetUserName"` // 目标用户名称 | ||
| 18 | + Department string `json:"departmentVal"` // 部门(拼接文本) | ||
| 19 | + Position string `json:"positionVal"` // 职位(拼接文本) | ||
| 20 | + DutyTime string `json:"dutyTime"` // 入职时间(2006-01-02 15:04) | ||
| 21 | + Status string `json:"statusVal"` // 完成状态(拼接文本) | ||
| 22 | + EndTime string `json:"endTime"` // 截止时间(2006-01-02 15:04) | ||
| 23 | + OverdueCount int `json:"overdueCount"` // 自评逾期次数 | ||
| 24 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +type EditEvaluationValue struct { | ||
| 4 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` | ||
| 5 | + ExecutorId int `json:"-"` // 执行人id | ||
| 6 | + CompanyId int `json:"-"` // 公司id | ||
| 7 | + EvaluationItems []UpdatedItemValue `json:"evaluationItems"` | ||
| 8 | + IsTemporary bool `json:"isTemporary"` //是否是临时提交 | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +type UpdatedItemValue struct { | ||
| 12 | + Value string `json:"value"` | ||
| 13 | + Remark string `json:"remark"` | ||
| 14 | + EvaluationItemId int `json:"evaluationItemId,string"` | ||
| 15 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +// type QueryEvaluationInfo struct { | ||
| 4 | +// CycleId int `json:"cycleId,string"` //周期id | ||
| 5 | +// ExecutorId int `json:"executorId,string"` //执行人id | ||
| 6 | +// CompanyId int `json:"-"` //公司id | ||
| 7 | +// } | ||
| 8 | + | ||
| 9 | +type QueryEvaluation struct { | ||
| 10 | + CycleId int `json:"cycleId,string"` //周期id | ||
| 11 | + TargetUserId int `json:"targetUserId,string"` //员工id | ||
| 12 | + CompanyId int `json:"-"` //公司id | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// QueryEvaluation360My [我] 对 [目标用户]进行360评估 | ||
| 16 | +type QueryEvaluation360My struct { | ||
| 17 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` | ||
| 18 | + CompanyId int `json:"-"` // 公司ID | ||
| 19 | + UserId int `json:"-"` // 用户ID | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +// QueryEvaluation360 [他人] 对 [目标用户]进行360评估 | ||
| 23 | +type QueryEvaluation360 struct { | ||
| 24 | + CycleId int `json:"cycleId,string"` // 周期ID | ||
| 25 | + TargetUserId int `json:"targetUserId,string"` // 目标人ID | ||
| 26 | + CompanyId int `json:"-"` // 公司ID | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +// QueryEvaluationHRBPMy [HRBP] 对 [目标用户] 进行评估 | ||
| 30 | +type QueryEvaluationHRBPMy struct { | ||
| 31 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` | ||
| 32 | + CompanyId int `json:"-"` // 公司ID | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +// QueryEvaluationHRBP [HRBP] 对 [目标用户]进行评估,状态已完成 | ||
| 36 | +type QueryEvaluationHRBP struct { | ||
| 37 | + CycleId int `json:"cycleId,string"` // 周期ID | ||
| 38 | + TargetUserId int `json:"targetUserId,string"` // 目标人ID | ||
| 39 | + CompanyId int `json:"-"` // 公司ID | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +// QueryEvaluationSuper 获取上级评估详情 | ||
| 43 | +type QueryEvaluationSuper struct { | ||
| 44 | + SummaryEvaluationId int `json:"summaryEvaluationId,string"` | ||
| 45 | + CompanyId int `json:"-"` | ||
| 46 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +// QueryEvaluation360List 360综评列表 | ||
| 4 | +type QueryEvaluation360List struct { | ||
| 5 | + CycleId int `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
| 6 | + PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
| 7 | + PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
| 8 | + SearchName string `cname:"用户名称" json:"searchName"` | ||
| 9 | + CompanyId int `cname:"公司ID" json:"-"` | ||
| 10 | + UserId int `cname:"用户ID" json:"-"` | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +// QueryEvaluationHRList 人资综评列表 | ||
| 14 | +type QueryEvaluationHRList struct { | ||
| 15 | + CycleId int `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
| 16 | + PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | ||
| 17 | + PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | ||
| 18 | + SearchName string `cname:"用户名称" json:"searchName"` | ||
| 19 | + CompanyId int `cname:"公司ID" json:"-"` | ||
| 20 | + UserId int `cname:"用户ID" json:"-"` | ||
| 21 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +// 查询执行人的评估列表 | ||
| 4 | +type QueryExecutorEvaluationList struct { | ||
| 5 | + PageNumber int `json:"pageNumber"` | ||
| 6 | + PageSize int `json:"pageSize"` | ||
| 7 | + CycleId int `json:"cycleId,string"` | ||
| 8 | + CompanyId int `json:"-"` | ||
| 9 | + ExecutorId int `json:"-"` | ||
| 10 | + TargetUserName string `json:"targetUserName"` | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +// 查询上级评估列表 | ||
| 14 | +type QueryEvaluationList struct { | ||
| 15 | + PageNumber int `json:"pageNumber"` | ||
| 16 | + PageSize int `json:"pageSize"` | ||
| 17 | + CycleId int `json:"cycleId,string"` | ||
| 18 | + CompanyId int `json:"-"` //当前公司 | ||
| 19 | + UserId int `json:"-"` //当前操作的员工id | ||
| 20 | + TargetUserName string `json:"targetUserName"` //按照目标员工的名称搜索 | ||
| 21 | + SummaryEvaluationId []string `json:"summaryEvaluationId"` //按照id 获取数据 | ||
| 22 | +} |
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "strconv" | ||
| 6 | + | ||
| 7 | + "github.com/linmadan/egglib-go/core/application" | ||
| 8 | + "github.com/xuri/excelize/v2" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 10 | + roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +// 导出数据 | ||
| 16 | +// 综合管理-周期评估 | ||
| 17 | +func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.QueryEvaluationList) (*excelize.File, error) { | ||
| 18 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 19 | + if err != nil { | ||
| 20 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 21 | + } | ||
| 22 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 23 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 24 | + } | ||
| 25 | + defer func() { | ||
| 26 | + _ = transactionContext.RollbackTransaction() | ||
| 27 | + }() | ||
| 28 | + //判断是否是hrbp | ||
| 29 | + flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) | ||
| 30 | + if err != nil { | ||
| 31 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 32 | + } | ||
| 33 | + if flagHrbp != 1 { | ||
| 34 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") | ||
| 35 | + } | ||
| 36 | + //判断是否是上级 | ||
| 37 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 38 | + "transactionContext": transactionContext, | ||
| 39 | + }) | ||
| 40 | + _, parentUser, _ := userRepo.Find(map[string]interface{}{ | ||
| 41 | + "parentId": param.UserId, | ||
| 42 | + "limit": 1, | ||
| 43 | + }) | ||
| 44 | + if len(parentUser) == 0 { | ||
| 45 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") | ||
| 46 | + } | ||
| 47 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
| 48 | + "transactionContext": transactionContext, | ||
| 49 | + }) | ||
| 50 | + positionRepo := factory.CreatePositionRepository(map[string]interface{}{ | ||
| 51 | + "transactionContext": transactionContext, | ||
| 52 | + }) | ||
| 53 | + limit := param.PageSize | ||
| 54 | + offset := (param.PageNumber - 1) * param.PageSize | ||
| 55 | + | ||
| 56 | + //获取评估列表信息 | ||
| 57 | + condition1 := map[string]interface{}{ | ||
| 58 | + "cycleId": param.CycleId, | ||
| 59 | + "types": int(domain.EvaluationSuper), | ||
| 60 | + "limit": limit, | ||
| 61 | + } | ||
| 62 | + if offset > 0 { | ||
| 63 | + condition1["offset"] = offset | ||
| 64 | + } | ||
| 65 | + if len(param.TargetUserName) > 0 { | ||
| 66 | + condition1["targetUserName"] = "%" + param.TargetUserName + "%" | ||
| 67 | + } | ||
| 68 | + if len(param.SummaryEvaluationId) > 0 { | ||
| 69 | + summaryEvaluationIds := []int{} | ||
| 70 | + for _, v := range param.SummaryEvaluationId { | ||
| 71 | + id, _ := strconv.Atoi(v) | ||
| 72 | + summaryEvaluationIds = append(summaryEvaluationIds, id) | ||
| 73 | + } | ||
| 74 | + if len(summaryEvaluationIds) > 0 { | ||
| 75 | + condition1["id"] = summaryEvaluationIds | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + //获取评估列表信息 | ||
| 79 | + _, evaluationList, err := evaluationRepo.Find(condition1) | ||
| 80 | + if err != nil { | ||
| 81 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 82 | + } | ||
| 83 | + targetUserIds := []int{} | ||
| 84 | + //获取员工信息 | ||
| 85 | + userMap := map[int64]*domain.User{} | ||
| 86 | + for _, v := range evaluationList { | ||
| 87 | + if _, ok := userMap[int64(v.TargetUser.UserId)]; ok { | ||
| 88 | + continue | ||
| 89 | + } | ||
| 90 | + userMap[int64(v.TargetUser.UserId)] = nil | ||
| 91 | + targetUserIds = append(targetUserIds, v.TargetUser.UserId) | ||
| 92 | + } | ||
| 93 | + if len(targetUserIds) > 0 { | ||
| 94 | + _, userList, err := userRepo.Find(map[string]interface{}{ | ||
| 95 | + "ids": targetUserIds, | ||
| 96 | + }) | ||
| 97 | + if err != nil { | ||
| 98 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 99 | + } | ||
| 100 | + userMap = map[int64]*domain.User{} | ||
| 101 | + for _, v := range userList { | ||
| 102 | + userMap[v.Id] = v | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + var positionIds []int | ||
| 106 | + //获取职位列表 | ||
| 107 | + positionMap := map[int64]*domain.Position{} | ||
| 108 | + for _, v := range userMap { | ||
| 109 | + for _, v2 := range v.DepartmentId { | ||
| 110 | + if _, ok := positionMap[int64(v2)]; ok { | ||
| 111 | + continue | ||
| 112 | + } | ||
| 113 | + positionMap[int64(v2)] = nil | ||
| 114 | + positionIds = append(positionIds, v2) | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + if len(positionIds) > 0 { | ||
| 118 | + _, positionList, err := positionRepo.Find(map[string]interface{}{"ids": positionIds}) | ||
| 119 | + if err != nil { | ||
| 120 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) | ||
| 121 | + } | ||
| 122 | + positionMap = map[int64]*domain.Position{} | ||
| 123 | + for _, v := range positionList { | ||
| 124 | + positionMap[v.Id] = v | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 128 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 129 | + } | ||
| 130 | + ratingHeader := []string{} //动态列,评级内容 | ||
| 131 | + ratingMap := map[string]struct{}{} //过滤重复code | ||
| 132 | + evaluationRatingMap := map[int]map[string]int{} | ||
| 133 | + for _, v := range evaluationList { | ||
| 134 | + evaluationRatingMap[v.Id] = map[string]int{} | ||
| 135 | + for _, v2 := range v.TotalRating { | ||
| 136 | + if _, ok := ratingMap[v2.Code]; !ok { | ||
| 137 | + ratingMap[v2.Code] = struct{}{} | ||
| 138 | + ratingHeader = append(ratingHeader, v2.Code) | ||
| 139 | + } | ||
| 140 | + evaluationRatingMap[v.Id][v2.Code] = v2.Number | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + xlsxFile := excelize.NewFile() | ||
| 145 | + //设置默认的第一个sheet | ||
| 146 | + sheetIndex := xlsxFile.GetActiveSheetIndex() | ||
| 147 | + firstSheetName := xlsxFile.GetSheetName(sheetIndex) | ||
| 148 | + tableHead := []string{"姓名", "部门", "职位", "最终绩效得分"} | ||
| 149 | + tableHead = append(tableHead, ratingHeader...) | ||
| 150 | + xlsxFile.SetSheetRow(firstSheetName, "A1", &tableHead) | ||
| 151 | + for i, v := range evaluationList { | ||
| 152 | + departmentName := "" | ||
| 153 | + for _, dep := range v.TargetDepartment { | ||
| 154 | + departmentName += dep.DepartmentName + " " | ||
| 155 | + } | ||
| 156 | + //填充员工信息 | ||
| 157 | + positinName := "" | ||
| 158 | + if targetUser, ok := userMap[int64(v.TargetUser.UserId)]; ok { | ||
| 159 | + //填充职位信息 | ||
| 160 | + for _, positionId := range targetUser.PositionId { | ||
| 161 | + if position, ok := positionMap[int64(positionId)]; ok { | ||
| 162 | + positinName += position.Name + " " | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + dataRaw := []string{ | ||
| 167 | + v.TargetUser.UserName, | ||
| 168 | + departmentName, | ||
| 169 | + positinName, | ||
| 170 | + v.TotalScore, | ||
| 171 | + } | ||
| 172 | + for _, v2 := range ratingHeader { | ||
| 173 | + if num, ok := evaluationRatingMap[v.Id][v2]; ok { | ||
| 174 | + dataRaw = append(dataRaw, fmt.Sprintf("%d", num)) | ||
| 175 | + } else { | ||
| 176 | + dataRaw = append(dataRaw, "0") | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + xlsxFile.SetSheetRow(firstSheetName, fmt.Sprintf("A%d", i+2), &dataRaw) | ||
| 180 | + } | ||
| 181 | + return xlsxFile, nil | ||
| 182 | +} |
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "strconv" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +// sendSummaryEvaluafionTask 根据评估项目设置,确认是否下发评估任务 | ||
| 16 | +// project 需要处理的项目 | ||
| 17 | +// userList 全体的员工数据 map[id]=>domain.User | ||
| 18 | +// departmetList 全部的部门数据 map[id]=>domain.Department | ||
| 19 | +func sendSummaryEvaluation(project *domain.EvaluationProject, | ||
| 20 | + userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { | ||
| 21 | + //自评的时间范围 | ||
| 22 | + beginTimeSelf := project.EndTime | ||
| 23 | + endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second) | ||
| 24 | + //人资、360评估的时间范围 | ||
| 25 | + beginTime360 := beginTimeSelf | ||
| 26 | + endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | ||
| 27 | + //上级评估的是时间范围 | ||
| 28 | + beginTimeSuper := endTime360 | ||
| 29 | + endTimeSuper := endTime360.Add(2 * 24 * time.Hour) | ||
| 30 | + // | ||
| 31 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 32 | + if err != nil { | ||
| 33 | + return nil, err | ||
| 34 | + } | ||
| 35 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 36 | + return nil, err | ||
| 37 | + } | ||
| 38 | + defer func() { | ||
| 39 | + _ = transactionContext.RollbackTransaction() | ||
| 40 | + }() | ||
| 41 | + cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 42 | + | ||
| 43 | + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 44 | + | ||
| 45 | + cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId}) | ||
| 46 | + if err != nil { | ||
| 47 | + return nil, err | ||
| 48 | + } | ||
| 49 | + //确定 被评估的人 | ||
| 50 | + targetUserId := []int64{} | ||
| 51 | + for _, v := range project.Recipients { | ||
| 52 | + id, err := strconv.ParseInt(v, 10, 64) | ||
| 53 | + if err == nil { | ||
| 54 | + targetUserId = append(targetUserId, id) | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + if len(targetUserId) == 0 { | ||
| 58 | + return nil, nil | ||
| 59 | + } | ||
| 60 | + //被评估的员工 | ||
| 61 | + targetUserMap := map[int64]*domain.User{} | ||
| 62 | + | ||
| 63 | + for _, v := range targetUserId { | ||
| 64 | + u, ok := userMap[v] | ||
| 65 | + if ok { | ||
| 66 | + targetUserMap[v] = u | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + //确定360评估的执行人 | ||
| 70 | + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)}) | ||
| 71 | + if err != nil { | ||
| 72 | + return nil, err | ||
| 73 | + } | ||
| 74 | + nodeId := 0 | ||
| 75 | + executor360Map := map[int64]*domain.User{} | ||
| 76 | + for _, v := range itemList { | ||
| 77 | + nodeId = v.NodeId | ||
| 78 | + if v.EvaluatorId <= 0 { | ||
| 79 | + continue | ||
| 80 | + } | ||
| 81 | + if u, ok := userMap[int64(v.EvaluatorId)]; ok { | ||
| 82 | + executor360Map[u.Id] = u | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + //创建周期评估任务 | ||
| 86 | + var newEvaluationList []domain.SummaryEvaluation | ||
| 87 | + evaluationTemp := domain.SummaryEvaluation{ | ||
| 88 | + Id: 0, | ||
| 89 | + CompanyId: int(project.CompanyId), | ||
| 90 | + EvaluationProjectId: int(project.Id), | ||
| 91 | + EvaluationProjectName: project.Name, | ||
| 92 | + CycleId: cycleData.Id, | ||
| 93 | + CycleName: cycleData.Name, | ||
| 94 | + NodeId: nodeId, | ||
| 95 | + TargetUser: domain.StaffDesc{}, | ||
| 96 | + TargetDepartment: []domain.StaffDepartment{}, | ||
| 97 | + Executor: domain.StaffDesc{}, | ||
| 98 | + Types: 0, | ||
| 99 | + Status: domain.EvaluationUncompleted, | ||
| 100 | + CheckResult: domain.EvaluationCheckUncompleted, | ||
| 101 | + BeginTime: time.Time{}, | ||
| 102 | + EndTime: time.Time{}, | ||
| 103 | + TotalScore: "", | ||
| 104 | + CreatedAt: time.Now(), | ||
| 105 | + UpdatedAt: time.Now(), | ||
| 106 | + DeletedAt: nil, | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + //确定自评 | ||
| 110 | + //确定 被评估人的 上级评估 | ||
| 111 | + for _, v := range targetUserMap { | ||
| 112 | + //处理自评 | ||
| 113 | + evaluationTemp.TargetUser = domain.StaffDesc{ | ||
| 114 | + UserId: int(v.Id), | ||
| 115 | + Account: v.Account, | ||
| 116 | + UserName: v.Name, | ||
| 117 | + } | ||
| 118 | + evaluationTemp.Executor = domain.StaffDesc{ | ||
| 119 | + UserId: int(v.Id), | ||
| 120 | + Account: v.Account, | ||
| 121 | + UserName: v.Name, | ||
| 122 | + } | ||
| 123 | + evaluationTemp.BeginTime = beginTimeSelf | ||
| 124 | + evaluationTemp.EndTime = endTimeSelf | ||
| 125 | + evaluationTemp.TargetDepartment = []domain.StaffDepartment{} | ||
| 126 | + evaluationTemp.Types = domain.EvaluationSelf | ||
| 127 | + for _, departId := range v.DepartmentId { | ||
| 128 | + depart, ok := departmentMap[int64(departId)] | ||
| 129 | + if !ok { | ||
| 130 | + continue | ||
| 131 | + } | ||
| 132 | + evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{ | ||
| 133 | + DepartmentId: int(depart.Id), | ||
| 134 | + DepartmentName: depart.Name, | ||
| 135 | + }) | ||
| 136 | + } | ||
| 137 | + //确定自评 | ||
| 138 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
| 139 | + //处理人资评估 | ||
| 140 | + evaluationTemp.BeginTime = beginTime360 | ||
| 141 | + evaluationTemp.EndTime = endTime360 | ||
| 142 | + evaluationTemp.Executor = domain.StaffDesc{} | ||
| 143 | + evaluationTemp.Types = domain.EvaluationHrbp | ||
| 144 | + //确定人资评估 | ||
| 145 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
| 146 | + //处理360 评估 | ||
| 147 | + for _, v2 := range executor360Map { | ||
| 148 | + evaluationTemp.BeginTime = beginTime360 | ||
| 149 | + evaluationTemp.EndTime = endTime360 | ||
| 150 | + evaluationTemp.Executor = domain.StaffDesc{ | ||
| 151 | + UserId: int(v2.Id), | ||
| 152 | + Account: v2.Account, | ||
| 153 | + UserName: v2.Name, | ||
| 154 | + } | ||
| 155 | + evaluationTemp.Types = domain.Evaluation360 | ||
| 156 | + //确定人资评估 | ||
| 157 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + //处理上级评估 | ||
| 161 | + superUser, ok := userMap[v.ParentId] | ||
| 162 | + if ok { | ||
| 163 | + evaluationTemp.Types = domain.EvaluationSuper | ||
| 164 | + evaluationTemp.Executor = domain.StaffDesc{ | ||
| 165 | + UserId: int(superUser.Id), | ||
| 166 | + Account: superUser.Account, | ||
| 167 | + UserName: superUser.Name, | ||
| 168 | + } | ||
| 169 | + evaluationTemp.BeginTime = beginTimeSuper | ||
| 170 | + evaluationTemp.EndTime = endTimeSuper | ||
| 171 | + //确定上级评估 | ||
| 172 | + newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 176 | + for i := range newEvaluationList { | ||
| 177 | + err = summaryEvaluationRepo.Save(&newEvaluationList[i]) | ||
| 178 | + if err != nil { | ||
| 179 | + return nil, err | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + //回填 项目的状态 | ||
| 183 | + projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 184 | + err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes) | ||
| 185 | + if err != nil { | ||
| 186 | + return nil, err | ||
| 187 | + } | ||
| 188 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 189 | + return nil, err | ||
| 190 | + } | ||
| 191 | + return newEvaluationList, nil | ||
| 192 | +} | ||
| 193 | + | ||
| 194 | +func dayZeroTime(t time.Time) time.Time { | ||
| 195 | + y, m, d := t.UTC().Date() | ||
| 196 | + t2 := time.Date(y, m, d, 0, 0, 0, 0, time.UTC) | ||
| 197 | + return t2 | ||
| 198 | +} | ||
| 199 | + | ||
| 200 | +// 下发周期评估 | ||
| 201 | +func TaskSendSummaryEvaluation() error { | ||
| 202 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 203 | + if err != nil { | ||
| 204 | + return err | ||
| 205 | + } | ||
| 206 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 207 | + return err | ||
| 208 | + } | ||
| 209 | + defer func() { | ||
| 210 | + _ = transactionContext.RollbackTransaction() | ||
| 211 | + }() | ||
| 212 | + | ||
| 213 | + projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
| 214 | + "transactionContext": transactionContext, | ||
| 215 | + }) | ||
| 216 | + | ||
| 217 | + userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 218 | + | ||
| 219 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 220 | + | ||
| 221 | + _, projectList, err := projectRepo.Find(map[string]interface{}{ | ||
| 222 | + "endTime": time.Now(), | ||
| 223 | + "summaryState": domain.ProjectSummaryStateNo, | ||
| 224 | + "state": domain.ProjectStateEnable, | ||
| 225 | + }, "template") | ||
| 226 | + if err != nil { | ||
| 227 | + return fmt.Errorf("获取可用的项目数据,%s", err) | ||
| 228 | + } | ||
| 229 | + companyIdMap := map[int64]struct{}{} | ||
| 230 | + for _, v := range projectList { | ||
| 231 | + companyIdMap[v.CompanyId] = struct{}{} | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + var createdEvalationList []domain.SummaryEvaluation | ||
| 235 | + | ||
| 236 | + //获取可执行的项目 | ||
| 237 | + for companyId := range companyIdMap { | ||
| 238 | + //获取员工数据,部门数据 | ||
| 239 | + _, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
| 240 | + if err != nil { | ||
| 241 | + log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error()) | ||
| 242 | + continue | ||
| 243 | + } | ||
| 244 | + _, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
| 245 | + if err != nil { | ||
| 246 | + log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error()) | ||
| 247 | + continue | ||
| 248 | + } | ||
| 249 | + //转map | ||
| 250 | + userMap := map[int64]*domain.User{} | ||
| 251 | + for _, v := range userList { | ||
| 252 | + userMap[v.Id] = v | ||
| 253 | + } | ||
| 254 | + departmentMap := map[int64]*domain.Department{} | ||
| 255 | + for _, v := range departmentList { | ||
| 256 | + departmentMap[v.Id] = v | ||
| 257 | + } | ||
| 258 | + for _, v := range projectList { | ||
| 259 | + if v.CompanyId != companyId { | ||
| 260 | + continue | ||
| 261 | + } | ||
| 262 | + evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap) | ||
| 263 | + if err != nil { | ||
| 264 | + log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error()) | ||
| 265 | + continue | ||
| 266 | + } | ||
| 267 | + createdEvalationList = append(createdEvalationList, evalationList...) | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 271 | + return err | ||
| 272 | + } | ||
| 273 | + //添加待发送的短信通知 | ||
| 274 | + err = sendSmsEvalation(createdEvalationList) | ||
| 275 | + return err | ||
| 276 | +} | ||
| 277 | + | ||
| 278 | +// 添加待发送的短信通知 | ||
| 279 | +func sendSmsEvalation(param []domain.SummaryEvaluation) error { | ||
| 280 | + for i := range param { | ||
| 281 | + if param[i].Types == domain.EvaluationSelf { | ||
| 282 | + notify.AddNotifySummaryEvaluation(¶m[i]) | ||
| 283 | + } | ||
| 284 | + } | ||
| 285 | + return nil | ||
| 286 | +} |
-
请 注册 或 登录 后发表评论