作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !27
正在显示 89 个修改的文件 包含 4436 行增加172 行删除
1 FROM 192.168.0.243:5000/mmm/allied-creation-gateway:libfontconfig 1 FROM 192.168.0.243:5000/mmm/allied-creation-gateway:libfontconfig
2 -ENV APP_DIR $GOPATH/src/project-20211222 2 +ENV APP_DIR $GOPATH/src/project-20220324
3 RUN mkdir -p $APP_DIR 3 RUN mkdir -p $APP_DIR
4 WORKDIR $APP_DIR/ 4 WORKDIR $APP_DIR/
5 COPY ./pkg pkg 5 COPY ./pkg pkg
@@ -111,10 +111,14 @@ spec: @@ -111,10 +111,14 @@ spec:
111 value: "http://allied-creation-user-dev.fjmaimaimai.com" 111 value: "http://allied-creation-user-dev.fjmaimaimai.com"
112 - name: ALLIED_CREATION_COOPERATION_HOST 112 - name: ALLIED_CREATION_COOPERATION_HOST
113 value: "http://allied-creation-cooperation-dev.fjmaimaimai.com" 113 value: "http://allied-creation-cooperation-dev.fjmaimaimai.com"
  114 + - name: ALLIED_CREATION_MANUFACTURE_HOST
  115 + value: "http://106.75.231.90:9999"
114 - name: ALLIED_CREATION_BASIC_HOST 116 - name: ALLIED_CREATION_BASIC_HOST
115 value: "http://allied-creation-basic-dev.fjmaimaimai.com" 117 value: "http://allied-creation-basic-dev.fjmaimaimai.com"
116 - name: SMS_SERVE_HOST 118 - name: SMS_SERVE_HOST
117 value: "https://sms.fjmaimaimai.com:9897" 119 value: "https://sms.fjmaimaimai.com:9897"
  120 + - name: COST_STRUCTURED
  121 + value: "http://cost-structured-dev.fjmaimaimai.com"
118 - name: SUPLUS_SALE_APP 122 - name: SUPLUS_SALE_APP
119 value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com" 123 value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
120 # - name: REDIS_HOST 124 # - name: REDIS_HOST
@@ -115,10 +115,14 @@ spec: @@ -115,10 +115,14 @@ spec:
115 value: "https://allied-creation-user-prd.fjmaimaimai.com" 115 value: "https://allied-creation-user-prd.fjmaimaimai.com"
116 - name: ALLIED_CREATION_COOPERATION_HOST 116 - name: ALLIED_CREATION_COOPERATION_HOST
117 value: "https://allied-creation-cooperation-prd.fjmaimaimai.com" 117 value: "https://allied-creation-cooperation-prd.fjmaimaimai.com"
  118 + - name: ALLIED_CREATION_MANUFACTURE_HOST
  119 + value: "https://allied-creation-manufacture-prd.fjmaimaimai.com"
118 - name: ALLIED_CREATION_BASIC_HOST 120 - name: ALLIED_CREATION_BASIC_HOST
119 value: "https://allied-creation-basic-prd.fjmaimaimai.com" 121 value: "https://allied-creation-basic-prd.fjmaimaimai.com"
120 - name: SMS_SERVE_HOST 122 - name: SMS_SERVE_HOST
121 value: "https://sms.fjmaimaimai.com:9897" 123 value: "https://sms.fjmaimaimai.com:9897"
  124 + - name: COST_STRUCTURED
  125 + value: "http://cost-structured-prd.fjmaimaimai.com"
122 # - name: REDIS_HOST 126 # - name: REDIS_HOST
123 # valueFrom: 127 # valueFrom:
124 # configMapKeyRef: 128 # configMapKeyRef:
@@ -119,10 +119,18 @@ spec: @@ -119,10 +119,18 @@ spec:
119 value: "https://allied-creation-cooperation-test.fjmaimaimai.com" 119 value: "https://allied-creation-cooperation-test.fjmaimaimai.com"
120 - name: ALLIED_CREATION_BASIC_HOST 120 - name: ALLIED_CREATION_BASIC_HOST
121 value: "https://allied-creation-basic-test.fjmaimaimai.com" 121 value: "https://allied-creation-basic-test.fjmaimaimai.com"
  122 + - name: ALLIED_CREATION_MANUFACTURE_HOST
  123 + value: "http://allied-creation-manufacture-test.fjmaimaimai.com"
122 - name: SMS_SERVE_HOST 124 - name: SMS_SERVE_HOST
123 value: "https://sms.fjmaimaimai.com:9897" 125 value: "https://sms.fjmaimaimai.com:9897"
  126 + - name: COST_STRUCTURED
  127 + value: "http://cost-structured-test.fjmaimaimai.com"
124 - name: SUPLUS_SALE_APP 128 - name: SUPLUS_SALE_APP
125 value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com" 129 value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
  130 + - name: MANUFACTURE_WEIGH_DEFAULT_COMPANYID
  131 + value: "23"
  132 + - name: MANUFACTURE_WEIGH_DEFAULT_ORGID
  133 + value: "487"
126 # - name: REDIS_HOST 134 # - name: REDIS_HOST
127 # valueFrom: 135 # valueFrom:
128 # configMapKeyRef: 136 # configMapKeyRef:
@@ -4,16 +4,21 @@ go 1.16 @@ -4,16 +4,21 @@ go 1.16
4 4
5 require ( 5 require (
6 github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2 6 github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2
  7 + github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible
  8 + github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
7 github.com/beego/beego/v2 v2.0.1 9 github.com/beego/beego/v2 v2.0.1
8 github.com/dgrijalva/jwt-go v3.2.0+incompatible 10 github.com/dgrijalva/jwt-go v3.2.0+incompatible
9 github.com/disintegration/imaging v1.6.2 11 github.com/disintegration/imaging v1.6.2
  12 + github.com/emirpasic/gods v1.12.0
10 github.com/forgoer/openssl v0.0.0-20210828150411-6c5378b5b719 13 github.com/forgoer/openssl v0.0.0-20210828150411-6c5378b5b719
11 github.com/go-pg/pg/v10 v10.10.1 14 github.com/go-pg/pg/v10 v10.10.1
12 github.com/go-redis/redis v6.15.7+incompatible 15 github.com/go-redis/redis v6.15.7+incompatible
13 github.com/google/uuid v1.1.1 16 github.com/google/uuid v1.1.1
14 github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d 17 github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d
15 github.com/pdfcpu/pdfcpu v0.3.13 18 github.com/pdfcpu/pdfcpu v0.3.13
  19 + github.com/satori/go.uuid v1.2.0 // indirect
16 github.com/stretchr/testify v1.7.0 20 github.com/stretchr/testify v1.7.0
17 github.com/tal-tech/go-queue v1.0.5 21 github.com/tal-tech/go-queue v1.0.5
  22 + github.com/xuri/excelize/v2 v2.4.1
18 golang.org/x/text v0.3.6 23 golang.org/x/text v0.3.6
19 ) 24 )
@@ -16,7 +16,11 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF @@ -16,7 +16,11 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
16 github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 16 github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
17 github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= 17 github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
18 github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk= 18 github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
  19 +github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible h1:uuJIwCFhbZy+zdvLy5zrcIToPEQP0s5CFOZ0Zj03O/w=
  20 +github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
19 github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= 21 github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
  22 +github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA=
  23 +github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
20 github.com/beanstalkd/go-beanstalk v0.1.0/go.mod h1:/G8YTyChOtpOArwLTQPY1CHB+i212+av35bkPXXj56Y= 24 github.com/beanstalkd/go-beanstalk v0.1.0/go.mod h1:/G8YTyChOtpOArwLTQPY1CHB+i212+av35bkPXXj56Y=
21 github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE= 25 github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE=
22 github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI= 26 github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
@@ -73,6 +77,8 @@ github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox @@ -73,6 +77,8 @@ github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox
73 github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= 77 github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
74 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= 78 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
75 github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= 79 github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
  80 +github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
  81 +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
76 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 82 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
77 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 83 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
78 github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 84 github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -299,6 +305,8 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So @@ -299,6 +305,8 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
299 github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= 305 github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
300 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 306 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
301 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 307 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
  308 +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
  309 +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
302 github.com/segmentio/kafka-go v0.4.2 h1:QXZ6q9Bu1JkAJQ/CQBb2Av8pFRG8LQ0kWCrLXgQyL8c= 310 github.com/segmentio/kafka-go v0.4.2 h1:QXZ6q9Bu1JkAJQ/CQBb2Av8pFRG8LQ0kWCrLXgQyL8c=
303 github.com/segmentio/kafka-go v0.4.2/go.mod h1:Inh7PqOsxmfgasV8InZYKVXWsdjcCq2d9tFV75GLbuM= 311 github.com/segmentio/kafka-go v0.4.2/go.mod h1:Inh7PqOsxmfgasV8InZYKVXWsdjcCq2d9tFV75GLbuM=
304 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo= 312 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
@@ -481,6 +489,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -481,6 +489,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
481 golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 489 golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
482 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 490 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
483 golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 491 golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
  492 +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
484 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 493 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
485 golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 494 golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
486 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 495 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -2,6 +2,7 @@ package command @@ -2,6 +2,7 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
5 "reflect" 6 "reflect"
6 "strings" 7 "strings"
7 8
@@ -23,6 +24,15 @@ type CompanySignUpCommand struct { @@ -23,6 +24,15 @@ type CompanySignUpCommand struct {
23 Password string `cname:"密码" json:"password" valid:"Required"` 24 Password string `cname:"密码" json:"password" valid:"Required"`
24 // 短信验证码 25 // 短信验证码
25 SmsCode string `cname:"短信验证码" json:"smsCode" valid:"Required"` 26 SmsCode string `cname:"短信验证码" json:"smsCode" valid:"Required"`
  27 +
  28 + // 法人
  29 + LegalPerson string `cname:"法人" json:"legalPerson" valid:"Required"`
  30 + // 社会信用代码
  31 + SocialCreditCode string `cname:"社会信用代码" json:"socialCreditCode" valid:"Required"`
  32 + // 营业执照所在地
  33 + BusinessLicenseAddress domain.BusinessLicenseAddress `cname:"营业执照所在地" json:"businessLicenseAddress" valid:"Required"`
  34 + // 营业执照-附件
  35 + BusinessLicenseAttachments []domain.Attachment `cname:"营业执照-附件" json:"businessLicenseAttachments" valid:"Required"`
26 } 36 }
27 37
28 func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) { 38 func (companySignUpCommand *CompanySignUpCommand) Valid(validation *validation.Validation) {
@@ -7,12 +7,13 @@ import ( @@ -7,12 +7,13 @@ import (
7 ) 7 )
8 8
9 type LoginCommand struct { 9 type LoginCommand struct {
10 - Phone string `json:"phone" valid:"Required"`  
11 - GrantType string `json:"grantType" valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录)  
12 - Password string `json:"password"`  
13 - Captcha string `json:"captcha"`  
14 - SessionMode int `json:"sessionMode"`  
15 - DeviceType string `json:"-"` 10 + Phone string `json:"phone" valid:"Required"`
  11 + GrantType string `json:"grantType" valid:"Required"` //登录方式(signInPassword 密码登录、signInCaptcha 验证码登录)
  12 + Password string `json:"password"`
  13 + Captcha string `json:"captcha"`
  14 + SessionMode int `json:"sessionMode"`
  15 + DeviceType string `json:"-"`
  16 + LoginPlatform string `json:"-"` //登录平台
16 } 17 }
17 18
18 func (orgAddCommand *LoginCommand) Valid(validation *validation.Validation) { 19 func (orgAddCommand *LoginCommand) Valid(validation *validation.Validation) {
@@ -40,6 +40,9 @@ func (svr AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{ @@ -40,6 +40,9 @@ func (svr AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
40 if loginCommand.DeviceType == domain.DeviceTypeWeb { 40 if loginCommand.DeviceType == domain.DeviceTypeWeb {
41 loginPlatform = domain.LoginPlatformWeb 41 loginPlatform = domain.LoginPlatformWeb
42 } 42 }
  43 + if len(loginCommand.LoginPlatform) != 0 {
  44 + loginPlatform = loginCommand.LoginPlatform
  45 + }
43 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) 46 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
44 _, err = creationUserGateway.AuthRefreshIM(allied_creation_user.ReqAuthRefreshIM{ 47 _, err = creationUserGateway.AuthRefreshIM(allied_creation_user.ReqAuthRefreshIM{
45 Phone: loginCommand.Phone, 48 Phone: loginCommand.Phone,
@@ -406,6 +409,11 @@ func (svr AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUp @@ -406,6 +409,11 @@ func (svr AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUp
406 Contacts: companySignUpCommand.Contacts, 409 Contacts: companySignUpCommand.Contacts,
407 IndustryCategory: companySignUpCommand.IndustryCategory, 410 IndustryCategory: companySignUpCommand.IndustryCategory,
408 Scale: companySignUpCommand.Scale, 411 Scale: companySignUpCommand.Scale,
  412 +
  413 + LegalPerson: companySignUpCommand.LegalPerson,
  414 + SocialCreditCode: companySignUpCommand.SocialCreditCode,
  415 + BusinessLicenseAttachments: companySignUpCommand.BusinessLicenseAttachments,
  416 + BusinessLicenseAddress: companySignUpCommand.BusinessLicenseAddress,
409 }) 417 })
410 if err != nil { 418 if err != nil {
411 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 419 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -548,7 +556,7 @@ func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error @@ -548,7 +556,7 @@ func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error
548 556
549 func (svr AuthService) getToken(loginToken domain.LoginToken) (map[string]interface{}, error) { 557 func (svr AuthService) getToken(loginToken domain.LoginToken) (map[string]interface{}, error) {
550 // 1.匹配账号对应的用户 558 // 1.匹配账号对应的用户
551 - currentUser, err := svr.matchUser(&loginToken) 559 + currentUser, err := svr.matchUserV2(&loginToken)
552 if err != nil { 560 if err != nil {
553 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 561 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
554 } 562 }
@@ -629,7 +637,7 @@ func (svr AuthService) matchUser(loginToken *domain.LoginToken) (*allied_creatio @@ -629,7 +637,7 @@ func (svr AuthService) matchUser(loginToken *domain.LoginToken) (*allied_creatio
629 loopUser1: 637 loopUser1:
630 for _, v := range userSearchResult.Users { 638 for _, v := range userSearchResult.Users {
631 for _, vv := range v.UserOrg { 639 for _, vv := range v.UserOrg {
632 - if vv.OrgID == int(loginToken.OrgId) { 640 + if vv.OrgID == int(loginToken.OrgId) && v.Company.Status == domain.CompanyAuthenticated {
633 currentOrgIsOK = true 641 currentOrgIsOK = true
634 currentUser = v 642 currentUser = v
635 break loopUser1 643 break loopUser1
@@ -688,6 +696,99 @@ loopUser1: @@ -688,6 +696,99 @@ loopUser1:
688 return &currentUser, nil 696 return &currentUser, nil
689 } 697 }
690 698
  699 +func (svr AuthService) matchUserV2(loginToken *domain.LoginToken) (*allied_creation_user.UserDetail, error) {
  700 + var users []allied_creation_user.UserDetail
  701 + var currentUser *allied_creation_user.UserDetail
  702 + var defaultUser *allied_creation_user.UserDetail
  703 + var ok bool
  704 + var mapOrgUser = make(map[int]*allied_creation_user.UserDetail)
  705 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  706 + switch loginToken.Platform {
  707 + case domain.LoginPlatformWeb:
  708 + userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  709 + Phone: loginToken.Account,
  710 + UserType: domain.UserTypeEmployee,
  711 + EnableStatus: domain.UserStatusEnable,
  712 + })
  713 + if err != nil {
  714 + return nil, application.ThrowError(application.BUSINESS_ERROR, "用户信息获取失败,"+err.Error())
  715 + }
  716 + users = userSearchResult.Users
  717 + case domain.LoginPlatformApp:
  718 + userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  719 + Phone: loginToken.Account,
  720 + UserType: domain.UserTypeEmployee | domain.UserTypeCooperation | domain.UserTypeVisitor,
  721 + EnableStatus: domain.UserStatusEnable,
  722 + })
  723 + if err != nil {
  724 + return nil, application.ThrowError(application.BUSINESS_ERROR, "用户信息获取失败,"+err.Error())
  725 + }
  726 + users = userSearchResult.Users
  727 + case domain.LoginPlatformOperatorWeb:
  728 + userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  729 + Phone: loginToken.Account,
  730 + UserType: domain.UserTypeOperationAdmin,
  731 + EnableStatus: domain.UserStatusEnable,
  732 + })
  733 + if err != nil {
  734 + return nil, application.ThrowError(application.BUSINESS_ERROR, "用户信息获取失败,"+err.Error())
  735 + }
  736 + users = userSearchResult.Users
  737 + }
  738 + if len(users) == 0 {
  739 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "账号不存在")
  740 + }
  741 +
  742 + for index, user := range users {
  743 + if user.Company != nil && user.Company.Status != domain.CompanyAuthenticated {
  744 + continue
  745 + }
  746 + for _, userOrg := range user.UserOrg {
  747 + mapOrgUser[userOrg.OrgID] = &users[index]
  748 + if defaultUser == nil {
  749 + defaultUser = &users[index]
  750 + }
  751 + }
  752 + }
  753 + if defaultUser == nil {
  754 + defaultUser = &users[0]
  755 + }
  756 + //切换组织
  757 + if loginToken.OrgId != 0 {
  758 + if currentUser, ok = mapOrgUser[int(loginToken.OrgId)]; !ok { //&& loginToken.Platform == domain.LoginPlatformWeb
  759 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用")
  760 + }
  761 + }
  762 + // 使用默认账号
  763 + if currentUser == nil {
  764 + currentUser = defaultUser
  765 + }
  766 +
  767 + SetLoginToken(loginToken, currentUser)
  768 +
  769 + return currentUser, nil
  770 +}
  771 +
  772 +func SetLoginToken(loginToken *domain.LoginToken, currentUser *allied_creation_user.UserDetail) {
  773 + // 当前登录的公司用户信息
  774 + loginToken.UserId = int64(currentUser.UserId)
  775 + loginToken.UserBaseId = int64(currentUser.UserBaseId)
  776 + if currentUser.Company != nil {
  777 + loginToken.CompanyId = int64(currentUser.Company.CompanyId)
  778 + }
  779 +
  780 + // 关联的组织
  781 + var orgIds []int64
  782 + for i := range currentUser.UserOrg {
  783 + orgIds = append(orgIds, int64(currentUser.UserOrg[i].OrgID))
  784 + // 默认组织
  785 + if loginToken.OrgId == 0 {
  786 + loginToken.OrgId = int64(currentUser.UserOrg[i].OrgID)
  787 + }
  788 + }
  789 + loginToken.OrgIds = orgIds
  790 +}
  791 +
691 //GetCompanyOrgsByUser 获取登录用户的公司组织列表 792 //GetCompanyOrgsByUser 获取登录用户的公司组织列表
692 func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUserQuery) (interface{}, error) { 793 func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUserQuery) (interface{}, error) {
693 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(queryParam.Operator) 794 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(queryParam.Operator)
@@ -713,6 +814,9 @@ func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUs @@ -713,6 +814,9 @@ func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUs
713 CompanyId: user.Company.CompanyId, 814 CompanyId: user.Company.CompanyId,
714 CompanyName: user.Company.CompanyName, 815 CompanyName: user.Company.CompanyName,
715 }) 816 })
  817 + if user.Company.Status != domain.CompanyAuthenticated {
  818 + continue
  819 + }
716 } 820 }
717 for j := range user.UserOrg { 821 for j := range user.UserOrg {
718 org := user.UserOrg[j] 822 org := user.UserOrg[j]
@@ -792,3 +896,53 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac @@ -792,3 +896,53 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac
792 rsp = rspData 896 rsp = rspData
793 return rsp, err 897 return rsp, err
794 } 898 }
  899 +
  900 +/*******************运营登录**********************/
  901 +//AuthLogin 用户登录
  902 +func (svr AuthService) AuthAdminLogin(loginCommand *command.LoginPwdCommand) (interface{}, error) {
  903 + login := &command.LoginCommand{
  904 + GrantType: "signInPassword",
  905 + Phone: loginCommand.Username,
  906 + Password: loginCommand.Password,
  907 + SessionMode: loginCommand.SessionMode,
  908 + DeviceType: loginCommand.DeviceType,
  909 + LoginPlatform: domain.LoginPlatformOperatorWeb,
  910 + }
  911 + return svr.AuthLogin(login)
  912 +}
  913 +
  914 +//AuthLogin 用户登录
  915 +//func (svr AuthService) AuthAdminLoginBak(loginCommand *command.LoginPwdCommand) (interface{}, error) {
  916 +// if err := loginCommand.ValidateCommand(); err != nil {
  917 +// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  918 +// }
  919 +// if len(loginCommand.Username) == 0 {
  920 +// return nil, application.ThrowError(application.BUSINESS_ERROR, "账号不存在")
  921 +// }
  922 +// creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  923 +// users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  924 +// UserType: domain.UserTypeOperationAdmin,
  925 +// Phone: loginCommand.Username,
  926 +// })
  927 +// if err != nil {
  928 +// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  929 +// }
  930 +// if len(users.Users) == 0 {
  931 +// return nil, application.ThrowError(application.BUSINESS_ERROR, "账号不存在")
  932 +// }
  933 +// login := &command.LoginCommand{
  934 +// GrantType: "signInPassword",
  935 +// Phone: loginCommand.Username,
  936 +// Password: loginCommand.Password,
  937 +// SessionMode: loginCommand.SessionMode,
  938 +// DeviceType: loginCommand.DeviceType,
  939 +// }
  940 +// if len(loginCommand.CaptchaChallenge) > 0 {
  941 +// geetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
  942 +// validateResult := geetest.SuccessValidate(loginCommand.CaptchaChallenge, loginCommand.CaptchaValidate, loginCommand.CaptchaSeccode, "", "")
  943 +// if !validateResult {
  944 +// log.Logger.Error("validate captcha fail")
  945 +// }
  946 +// }
  947 +// return svr.AuthLogin(login)
  948 +//}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type AuditCompanyCommand struct {
  12 + // 企业id
  13 + CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
  14 + // 手机号
  15 + Phone string `cname:"手机号" json:"phone" valid:"Required"`
  16 + // 审核状态
  17 + Status int `cname:"审核状态" json:"status" valid:"Required"`
  18 + // 备注
  19 + Remark string `cname:"备注" json:"remark" valid:"Required"`
  20 +}
  21 +
  22 +func (updateCompanyCommand *AuditCompanyCommand) Valid(validation *validation.Validation) {
  23 + if !(updateCompanyCommand.Status == 1 || updateCompanyCommand.Status == 2) {
  24 + validation.Error("状态有误")
  25 + return
  26 + }
  27 + if updateCompanyCommand.Status == 1 {
  28 + updateCompanyCommand.Status = 2
  29 + return
  30 + }
  31 + if updateCompanyCommand.Status == 2 {
  32 + updateCompanyCommand.Status = 3
  33 + return
  34 + }
  35 +}
  36 +
  37 +func (updateCompanyCommand *AuditCompanyCommand) ValidateCommand() error {
  38 + valid := validation.Validation{}
  39 + b, err := valid.Valid(updateCompanyCommand)
  40 + if err != nil {
  41 + return err
  42 + }
  43 + if !b {
  44 + elem := reflect.TypeOf(updateCompanyCommand).Elem()
  45 + for _, validErr := range valid.Errors {
  46 + field, isExist := elem.FieldByName(validErr.Field)
  47 + if isExist {
  48 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  49 + } else {
  50 + return fmt.Errorf(validErr.Message)
  51 + }
  52 + }
  53 + }
  54 + return nil
  55 +}
  1 +package command
  2 +
  3 +// type CreateCompanyCommand struct {
  4 +// // 企业名称
  5 +// CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
  6 +// // 规模
  7 +// Scale string `cname:"规模" json:"scale" valid:"Required"`
  8 +// // 公司Logo地址
  9 +// Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
  10 +// // 公司地址
  11 +// Address string `cname:"公司地址" json:"address" valid:"Required"`
  12 +// // 所属行业
  13 +// IndustryCategory string `cname:"所属行业" json:"industryCategory" valid:"Required"`
  14 +// // 联系人
  15 +// Contacts string `cname:"联系人" json:"contacts" valid:"Required"`
  16 +// // 注册时间
  17 +// RegisteredTime time.Time `cname:"注册时间" json:"registeredTime,omitempty"`
  18 +// // 注册状态 1:已注册 2:待认证 3:已认证
  19 +// Status int `cname:"注册状态 1:已注册 2:待认证 3:已认证" json:"status,omitempty"`
  20 +// }
  21 +
  22 +// func (createCompanyCommand *CreateCompanyCommand) Valid(validation *validation.Validation) {
  23 +
  24 +// }
  25 +
  26 +// func (createCompanyCommand *CreateCompanyCommand) ValidateCommand() error {
  27 +// valid := validation.Validation{}
  28 +// b, err := valid.Valid(createCompanyCommand)
  29 +// if err != nil {
  30 +// return err
  31 +// }
  32 +// if !b {
  33 +// elem := reflect.TypeOf(createCompanyCommand).Elem()
  34 +// for _, validErr := range valid.Errors {
  35 +// field, isExist := elem.FieldByName(validErr.Field)
  36 +// if isExist {
  37 +// return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  38 +// } else {
  39 +// return fmt.Errorf(validErr.Message)
  40 +// }
  41 +// }
  42 +// }
  43 +// return nil
  44 +// }
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type EnableCompanyCommand struct {
  12 + // 企业id
  13 + CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
  14 + // 审核状态
  15 + Status int `cname:"审核状态" json:"status" valid:"Required"`
  16 +}
  17 +
  18 +func (updateCompanyCommand *EnableCompanyCommand) Valid(validation *validation.Validation) {
  19 + //validation.SetError("CustomValid", "未实现的自定义认证")
  20 + if !(updateCompanyCommand.Status == 1 || updateCompanyCommand.Status == 2) {
  21 + validation.Error("状态有误")
  22 + return
  23 + }
  24 + if updateCompanyCommand.Status == 1 {
  25 + updateCompanyCommand.Status = 2
  26 + return
  27 + }
  28 + if updateCompanyCommand.Status == 2 {
  29 + updateCompanyCommand.Status = 4
  30 + return
  31 + }
  32 +}
  33 +
  34 +func (updateCompanyCommand *EnableCompanyCommand) ValidateCommand() error {
  35 + valid := validation.Validation{}
  36 + b, err := valid.Valid(updateCompanyCommand)
  37 + if err != nil {
  38 + return err
  39 + }
  40 + if !b {
  41 + elem := reflect.TypeOf(updateCompanyCommand).Elem()
  42 + for _, validErr := range valid.Errors {
  43 + field, isExist := elem.FieldByName(validErr.Field)
  44 + if isExist {
  45 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  46 + } else {
  47 + return fmt.Errorf(validErr.Message)
  48 + }
  49 + }
  50 + }
  51 + return nil
  52 +}
  1 +package command
  2 +
  3 +// type ListCompanyCustomizeMenusCommand struct {
  4 +// // 企业id
  5 +// CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
  6 +// // 菜单类别 web app
  7 +// MenuCategory string `cname:"菜单类别" json:"menuCategory,omitempty" valid:"Required"`
  8 +// }
  9 +
  10 +// func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
  11 +
  12 +// }
  13 +
  14 +// func (listCompanyCustomizeMenusCommand *ListCompanyCustomizeMenusCommand) ValidateCommand() error {
  15 +// valid := validation.Validation{}
  16 +// b, err := valid.Valid(listCompanyCustomizeMenusCommand)
  17 +// if err != nil {
  18 +// return err
  19 +// }
  20 +// if !b {
  21 +// elem := reflect.TypeOf(listCompanyCustomizeMenusCommand).Elem()
  22 +// for _, validErr := range valid.Errors {
  23 +// field, isExist := elem.FieldByName(validErr.Field)
  24 +// if isExist {
  25 +// return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  26 +// } else {
  27 +// return fmt.Errorf(validErr.Message)
  28 +// }
  29 +// }
  30 +// }
  31 +// return nil
  32 +// }
  1 +package command
  2 +
  3 +// type RemoveCompanyCommand struct {
  4 +// // 企业id
  5 +// CompanyId int64 `cname:"企业id" json:"companyId,string" valid:"Required"`
  6 +// }
  7 +
  8 +// func (removeCompanyCommand *RemoveCompanyCommand) Valid(validation *validation.Validation) {
  9 +// validation.SetError("CustomValid", "未实现的自定义认证")
  10 +// }
  11 +
  12 +// func (removeCompanyCommand *RemoveCompanyCommand) ValidateCommand() error {
  13 +// valid := validation.Validation{}
  14 +// b, err := valid.Valid(removeCompanyCommand)
  15 +// if err != nil {
  16 +// return err
  17 +// }
  18 +// if !b {
  19 +// elem := reflect.TypeOf(removeCompanyCommand).Elem()
  20 +// for _, validErr := range valid.Errors {
  21 +// field, isExist := elem.FieldByName(validErr.Field)
  22 +// if isExist {
  23 +// return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  24 +// } else {
  25 +// return fmt.Errorf(validErr.Message)
  26 +// }
  27 +// }
  28 +// }
  29 +// return nil
  30 +// }
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type UpdateCompanyCommand struct {
  13 + //操作人
  14 + Operator domain.Operator `json:"-"`
  15 + // 企业名称
  16 + CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"`
  17 + // 公司地址
  18 + Address string `cname:"公司地址" json:"address" valid:"Required"`
  19 + // 系统名称
  20 + SystemName string `cname:"系统名称" json:"systemName" valid:"Required"`
  21 + // 公司Logo地址
  22 + Logo string `cname:"公司Logo地址" json:"logo" valid:"Required"`
  23 +}
  24 +
  25 +func (updateCompanyCommand *UpdateCompanyCommand) Valid(validation *validation.Validation) {
  26 + validation.SetError("CustomValid", "未实现的自定义认证")
  27 +}
  28 +
  29 +func (updateCompanyCommand *UpdateCompanyCommand) ValidateCommand() error {
  30 + valid := validation.Validation{}
  31 + b, err := valid.Valid(updateCompanyCommand)
  32 + if err != nil {
  33 + return err
  34 + }
  35 + if !b {
  36 + elem := reflect.TypeOf(updateCompanyCommand).Elem()
  37 + for _, validErr := range valid.Errors {
  38 + field, isExist := elem.FieldByName(validErr.Field)
  39 + if isExist {
  40 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  41 + } else {
  42 + return fmt.Errorf(validErr.Message)
  43 + }
  44 + }
  45 + }
  46 + return nil
  47 +}
  1 +package command
  2 +
  3 +// type UpdateCompanyCustomizeMenusCommand struct {
  4 +// // 企业id
  5 +// CompanyId int64 `cname:"企业id" json:"companyId" valid:"Required"`
  6 +// // 菜单编号
  7 +// MenuId int64 `cname:"菜单编号" json:"menuId" valid:"Required"`
  8 +// // 菜单名称
  9 +// //MenuName string `cname:"菜单名称" json:"menuName" valid:"Required"`
  10 +// // 菜单别名
  11 +// MenuAlias string `cname:"菜单别名" json:"menuAlias" valid:"Required"`
  12 +// // 排序
  13 +// Sort int `cname:"排序" json:"sort" valid:"Required"`
  14 +// }
  15 +
  16 +// func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) Valid(validation *validation.Validation) {
  17 +// //validation.SetError("CustomValid", "未实现的自定义认证")
  18 +// }
  19 +
  20 +// func (updateCompanyCustomizeMenusCommand *UpdateCompanyCustomizeMenusCommand) ValidateCommand() error {
  21 +// valid := validation.Validation{}
  22 +// b, err := valid.Valid(updateCompanyCustomizeMenusCommand)
  23 +// if err != nil {
  24 +// return err
  25 +// }
  26 +// if !b {
  27 +// elem := reflect.TypeOf(updateCompanyCustomizeMenusCommand).Elem()
  28 +// for _, validErr := range valid.Errors {
  29 +// field, isExist := elem.FieldByName(validErr.Field)
  30 +// if isExist {
  31 +// return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  32 +// } else {
  33 +// return fmt.Errorf(validErr.Message)
  34 +// }
  35 +// }
  36 +// }
  37 +// return nil
  38 +// }
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  6 +)
  7 +
  8 +type CompanyGetItemDto struct {
  9 + CompanyListItemDto
  10 + Remark string `json:"remark"`
  11 +
  12 + // 法律相关
  13 + // 法人
  14 + LegalPerson string `json:"legalPerson"`
  15 + // 社会信用代码
  16 + SocialCreditCode string `json:"socialCreditCode"`
  17 + // 营业执照所在地
  18 + BusinessLicenseAddress interface{} `json:"businessLicenseAddress"`
  19 + // 营业执照-附件
  20 + BusinessLicenseAttachments []domain.Attachment `json:"businessLicenseAttachments"`
  21 +}
  22 +
  23 +func (dto *CompanyGetItemDto) LoadDto(c allied_creation_user.CompanyItem, u allied_creation_user.UserDetail) {
  24 + companyListItemDto := &CompanyListItemDto{}
  25 + companyListItemDto.LoadDto(c, u)
  26 + dto.CompanyListItemDto = *companyListItemDto
  27 + dto.Remark = c.CompanyInfo.Remark
  28 + dto.LegalPerson = c.CompanyInfo.Legal.LegalPerson
  29 + dto.SocialCreditCode = c.CompanyInfo.Legal.SocialCreditCode
  30 + dto.BusinessLicenseAddress = c.CompanyInfo.Legal.BusinessLicenseAddress
  31 + dto.BusinessLicenseAttachments = c.CompanyInfo.Legal.BusinessLicenseAttachments
  32 +}
  1 +package dto
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  4 +
  5 +type CompanyListItemDto struct {
  6 + // 企业id
  7 + CompanyId int `json:"companyId"`
  8 + // 公司名称
  9 + CompanyName string `json:"companyName"`
  10 + // 规模
  11 + Scale string `json:"scale,omitempty"`
  12 + // 所属行业
  13 + IndustryCategory string `json:"industryCategory,omitempty"`
  14 + // 联系人
  15 + Contacts string `cname:"联系人" json:"contacts"`
  16 + // 手机号码
  17 + Phone string `cname:"手机号码" json:"phone"`
  18 + // 注册时间
  19 + RegisteredTime string `json:"registeredTime,omitempty"`
  20 + // 公司状态 1:已注册(待审核) 2:已通过 3:已拒绝
  21 + Status int `json:"status"`
  22 +}
  23 +
  24 +func (dto *CompanyListItemDto) LoadDto(c allied_creation_user.CompanyItem, u allied_creation_user.UserDetail) *CompanyListItemDto {
  25 + dto.CompanyId = c.CompanyId
  26 + dto.CompanyName = c.CompanyInfo.CompanyName
  27 + dto.Scale = c.CompanyInfo.Scale
  28 + dto.IndustryCategory = c.CompanyInfo.IndustryCategory
  29 + dto.Contacts = u.UserInfo.UserName
  30 + dto.Phone = u.UserInfo.Phone
  31 + dto.RegisteredTime = c.CompanyInfo.RegisteredTime.Format("2006-01-02")
  32 + dto.Status = c.Status
  33 + return dto
  34 +}
  35 +
  36 +type CompanyListItemsDto []*CompanyListItemDto
  37 +
  38 +func (dto *CompanyListItemsDto) LoadDto(items []allied_creation_user.CompanyItem, users []allied_creation_user.UserDetail) {
  39 + var mapItems = make(map[int]allied_creation_user.CompanyItem)
  40 + for i := range items {
  41 + mapItems[items[i].CompanyId] = items[i]
  42 + }
  43 + for i := range users {
  44 + if v, ok := mapItems[users[i].Company.CompanyId]; ok {
  45 + company := &CompanyListItemDto{}
  46 + *dto = append(*dto, company.LoadDto(v, users[i]))
  47 + }
  48 + }
  49 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type GetCompanyQuery struct {
  12 + // 企业id
  13 + CompanyId int `cname:"企业id" json:"companyId" valid:"Required"`
  14 +}
  15 +
  16 +func (getCompanyQuery *GetCompanyQuery) Valid(validation *validation.Validation) {
  17 + validation.SetError("CustomValid", "未实现的自定义认证")
  18 +}
  19 +
  20 +func (getCompanyQuery *GetCompanyQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(getCompanyQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + elem := reflect.TypeOf(getCompanyQuery).Elem()
  28 + for _, validErr := range valid.Errors {
  29 + field, isExist := elem.FieldByName(validErr.Field)
  30 + if isExist {
  31 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  32 + } else {
  33 + return fmt.Errorf(validErr.Message)
  34 + }
  35 + }
  36 + }
  37 + return nil
  38 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/beego/beego/v2/core/validation"
  6 + "reflect"
  7 + "strings"
  8 +)
  9 +
  10 +type ListCompanyQuery struct {
  11 + // 查询偏离量
  12 + PageNumber int `json:"pageNumber"`
  13 + // 查询限制
  14 + PageSize int `json:"pageSize" valid:"Required"`
  15 + // 状态
  16 + Status int `cname:"状态" json:"status,omitempty"`
  17 + // 企业名称
  18 + CompanyName string `cname:"企业名称" json:"companyName,omitempty"`
  19 +}
  20 +
  21 +func (listCompanyQuery *ListCompanyQuery) Valid(validation *validation.Validation) {
  22 +
  23 +}
  24 +
  25 +func (listCompanyQuery *ListCompanyQuery) ValidateQuery() error {
  26 + valid := validation.Validation{}
  27 + b, err := valid.Valid(listCompanyQuery)
  28 + if err != nil {
  29 + return err
  30 + }
  31 + if !b {
  32 + elem := reflect.TypeOf(listCompanyQuery).Elem()
  33 + for _, validErr := range valid.Errors {
  34 + field, isExist := elem.FieldByName(validErr.Field)
  35 + if isExist {
  36 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  37 + } else {
  38 + return fmt.Errorf(validErr.Message)
  39 + }
  40 + }
  41 + }
  42 + return nil
  43 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/emirpasic/gods/sets/hashset"
  5 + "github.com/linmadan/egglib-go/core/application"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/company/command"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/company/dto"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/company/query"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/sms_serve"
  12 +)
  13 +
  14 +// 企业
  15 +type CompanyService struct {
  16 +}
  17 +
  18 +// 创建企业
  19 +// func (companyService *CompanyService) CreateCompany(createCompanyCommand *command.CreateCompanyCommand) (interface{}, error) {
  20 +// return nil, nil
  21 +// }
  22 +
  23 +// 返回企业
  24 +func (companyService *CompanyService) GetCompany(getCompanyQuery *query.GetCompanyQuery) (interface{}, error) {
  25 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  26 + result, err := creationUserGateway.CompanyGet(allied_creation_user.ReqCompanyGet{
  27 + CompanyId: getCompanyQuery.CompanyId,
  28 + })
  29 + if err != nil {
  30 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  31 + }
  32 + userResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  33 + InCompanyIds: []interface{}{result.CompanyId},
  34 + UserType: domain.UserTypeCompanyAdmin,
  35 + })
  36 + if err != nil {
  37 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  38 + }
  39 + var user allied_creation_user.UserDetail
  40 + if len(userResult.Users) > 0 {
  41 + user = userResult.Users[0]
  42 + }
  43 + companyDto := &dto.CompanyGetItemDto{}
  44 + companyDto.LoadDto(allied_creation_user.CompanyItem(*result), user)
  45 + return companyDto, nil
  46 +}
  47 +
  48 +func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyCommand) (interface{}, error) {
  49 + if err := cmd.ValidateCommand(); err != nil {
  50 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  51 + }
  52 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  53 + _, err := creationUserGateway.AuditCompany(allied_creation_user.ReqCompanyAudit{
  54 + CompanyId: int(cmd.CompanyId),
  55 + Status: cmd.Status,
  56 + Remark: cmd.Remark,
  57 + })
  58 + if err != nil {
  59 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  60 + }
  61 + smsServe := sms_serve.NewHttplibHttplibSmsServe()
  62 + if cmd.Status == domain.CompanyAuthenticated {
  63 + var tmpPhone []rune = []rune(cmd.Phone)
  64 + for i := 0; i < 4; i++ {
  65 + tmpPhone[i+3] = rune('*')
  66 + }
  67 + err = smsServe.SendNoticeSms(cmd.Phone, 5007040, map[string]interface{}{"phone": string(tmpPhone)})
  68 + } else if cmd.Status == domain.CompanyUnauthenticated {
  69 + err = smsServe.SendNoticeSms(cmd.Phone, 5006964, map[string]interface{}{"reason": cmd.Remark})
  70 + }
  71 + if err != nil {
  72 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  73 + }
  74 + return struct{}{}, nil
  75 +}
  76 +
  77 +func (companyService *CompanyService) EnableCompany(cmd *command.EnableCompanyCommand) (interface{}, error) {
  78 + if err := cmd.ValidateCommand(); err != nil {
  79 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  80 + }
  81 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  82 + _, err := creationUserGateway.EnableCompany(allied_creation_user.ReqCompanyEnable{
  83 + CompanyId: int(cmd.CompanyId),
  84 + Status: cmd.Status,
  85 + })
  86 + if err != nil {
  87 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  88 + }
  89 + return struct{}{}, nil
  90 +}
  91 +
  92 +// 返回企业列表
  93 +func (companyService *CompanyService) ListCompany(listCompanyQuery *query.ListCompanyQuery) (int64, interface{}, error) {
  94 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  95 + result, err := creationUserGateway.CompanySearch(allied_creation_user.ReqCompanySearch{
  96 + Offset: (listCompanyQuery.PageNumber - 1) * listCompanyQuery.PageSize,
  97 + Limit: listCompanyQuery.PageSize,
  98 + Status: listCompanyQuery.Status,
  99 + CompanyName: listCompanyQuery.CompanyName,
  100 + })
  101 + if err != nil {
  102 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  103 + }
  104 + companySet := hashset.New()
  105 + for i := range result.Companys {
  106 + companySet.Add(result.Companys[i].CompanyId)
  107 + }
  108 + var users = make([]allied_creation_user.UserDetail, 0)
  109 + if companySet.Size() > 0 {
  110 + userResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  111 + InCompanyIds: companySet.Values(),
  112 + UserType: domain.UserTypeCompanyAdmin,
  113 + })
  114 + if err != nil {
  115 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  116 + }
  117 + users = userResult.Users
  118 + }
  119 + companyListItemsDto := dto.CompanyListItemsDto{}
  120 + companyListItemsDto.LoadDto(result.Companys, users)
  121 + return int64(result.Count), companyListItemsDto, nil
  122 +}
  123 +
  124 +// 返回自定义菜单列表(匹配有设置的菜单)
  125 +// func (companyService *CompanyService) ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand *command.ListCompanyCustomizeMenusCommand) (interface{}, error) {
  126 +// return nil, nil
  127 +// }
  128 +
  129 +// 移除企业
  130 +// func (companyService *CompanyService) RemoveCompany(removeCompanyCommand *command.RemoveCompanyCommand) (interface{}, error) {
  131 +// return nil, nil
  132 +// }
  133 +
  134 +// 更新企业
  135 +func (companyService *CompanyService) UpdateCompany(updateCompanyCommand *command.UpdateCompanyCommand) (interface{}, error) {
  136 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(updateCompanyCommand.Operator)
  137 + _, err := creationUserGateway.CompanyUpdate(allied_creation_user.ReqCompanyUpdate{
  138 + CompanyId: updateCompanyCommand.Operator.CompanyId,
  139 + CompanyName: updateCompanyCommand.CompanyName,
  140 + Address: updateCompanyCommand.Address,
  141 + SystemName: updateCompanyCommand.SystemName,
  142 + Logo: updateCompanyCommand.Logo,
  143 + })
  144 + if err != nil {
  145 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  146 + }
  147 + return updateCompanyCommand, nil
  148 +}
  149 +
  150 +func NewCompanyService(options map[string]interface{}) *CompanyService {
  151 + newCompanyService := &CompanyService{}
  152 + return newCompanyService
  153 +}
  1 +package command
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 +)
  6 +
  7 +type AdminUserAddCommand struct {
  8 + //操作人
  9 + Operator domain.Operator `json:"-"`
  10 + // 用户编号
  11 + UsersCode string `json:"userCode" valid:"Required"`
  12 + // 用户姓名
  13 + UsersName string `json:"userName" valid:"Required"`
  14 + // 部门id
  15 + DepartmentName string `json:"departmentName" valid:"Required"`
  16 + // 手机号码
  17 + Phone string `json:"phone" valid:"Required"`
  18 +}
  19 +
  20 +//func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
  21 +//
  22 +//}
  23 +//
  24 +//func (companyUserAddCommand *CompanyUserAddCommand) ValidateCommand() error {
  25 +// valid := validation.Validation{}
  26 +// b, err := valid.Valid(companyUserAddCommand)
  27 +// if err != nil {
  28 +// return err
  29 +// }
  30 +// if !b {
  31 +// for _, validErr := range valid.Errors {
  32 +// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  33 +// }
  34 +// }
  35 +// return nil
  36 +//}
  1 +package command
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 +)
  6 +
  7 +type AdminUserEditCommand struct {
  8 + //操作人
  9 + Operator domain.Operator `json:"-"`
  10 + UserId int64 `json:"userId"`
  11 + // 用户编号
  12 + UsersCode string `json:"userCode" valid:"Required"`
  13 + // 用户姓名
  14 + UsersName string `json:"userName" valid:"Required"`
  15 + // 部门id
  16 + DepartmentName string `json:"departmentName" valid:"Required"`
  17 + // 手机号码
  18 + Phone string `json:"phone" valid:"Required"`
  19 +}
  20 +
  21 +//func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
  22 +//
  23 +//}
  24 +//
  25 +//func (companyUserAddCommand *CompanyUserAddCommand) ValidateCommand() error {
  26 +// valid := validation.Validation{}
  27 +// b, err := valid.Valid(companyUserAddCommand)
  28 +// if err != nil {
  29 +// return err
  30 +// }
  31 +// if !b {
  32 +// for _, validErr := range valid.Errors {
  33 +// return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  34 +// }
  35 +// }
  36 +// return nil
  37 +//}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type EnableAdminUserCommand struct {
  13 + Operator domain.Operator `json:"-"`
  14 + UserId int64 `cname:"用户id列表" json:"userId" valid:"Required"`
  15 + // 启用状态(启用:1 禁用:2 )
  16 + EnableStatus int `cname:"启用状态(启用:1 禁用:2 )" json:"enableStatus" valid:"Required"`
  17 +}
  18 +
  19 +func (batchEnableCommand *EnableAdminUserCommand) Valid(validation *validation.Validation) {
  20 +}
  21 +
  22 +func (batchEnableCommand *EnableAdminUserCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(batchEnableCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(batchEnableCommand).Elem()
  30 + for _, validErr := range valid.Errors {
  31 + field, isExist := elem.FieldByName(validErr.Field)
  32 + if isExist {
  33 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  34 + } else {
  35 + return fmt.Errorf(validErr.Message)
  36 + }
  37 + }
  38 + }
  39 + return nil
  40 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type EnableUserCommand struct {
  13 + Operator domain.Operator `json:"-"`
  14 + UserBaseId int64 `cname:"用户id列表" json:"userBaseId" valid:"Required"`
  15 + // 启用状态(启用:1 禁用:2 注销:3)
  16 + EnableStatus int `cname:"启用状态(启用:1 禁用:2 注销:3)" json:"enableStatus" valid:"Required"`
  17 +}
  18 +
  19 +func (batchEnableCommand *EnableUserCommand) Valid(validation *validation.Validation) {
  20 +}
  21 +
  22 +func (batchEnableCommand *EnableUserCommand) ValidateCommand() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(batchEnableCommand)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(batchEnableCommand).Elem()
  30 + for _, validErr := range valid.Errors {
  31 + field, isExist := elem.FieldByName(validErr.Field)
  32 + if isExist {
  33 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  34 + } else {
  35 + return fmt.Errorf(validErr.Message)
  36 + }
  37 + }
  38 + }
  39 + return nil
  40 +}
  1 +package command
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  4 +
  5 +type ResetPasswordCommand struct {
  6 + Operator domain.Operator `json:"-"`
  7 + Account string `json:"account"`
  8 +}
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  5 + "time"
  6 +)
  7 +
  8 +type AdminUserDto struct {
  9 + // 用户基础数据id
  10 + UserId int `json:"userId,omitempty"`
  11 + // 用工编号
  12 + UserCode string `json:"userCode"`
  13 + //姓名
  14 + UserName string `json:"userName"`
  15 + // 账号
  16 + Phone string `json:"phone"`
  17 + // 用户关联的组织
  18 + DepartmentName string `json:"departmentName"`
  19 + // 账号状态 1:正常 2.禁用 3:注销
  20 + EnableStatus int `json:"enableStatus,omitempty"`
  21 + // 推荐人
  22 + Referer string `json:"referer"`
  23 + // 创建时间
  24 + RegistrationDate string `json:"registrationDate,omitempty"`
  25 + // 最后登录时间
  26 + LastLogIn string `json:"lastLogIn"`
  27 +}
  28 +
  29 +func NewAdminUserDto(v allied_creation_user.UserDetail) AdminUserDto {
  30 + item := AdminUserDto{
  31 + UserCode: v.UserCode,
  32 + UserId: v.UserId,
  33 + Phone: v.UserInfo.Phone,
  34 + DepartmentName: v.Department.DepartmentName,
  35 + EnableStatus: v.EnableStatus,
  36 + UserName: v.UserInfo.UserName,
  37 + RegistrationDate: v.CreatedAt.Format("2006-01-02"),
  38 + LastLogIn: "",
  39 + }
  40 + if v.Favorite.LastLogInAt > 0 {
  41 + item.LastLogIn = time.Unix(v.Favorite.LastLogInAt, 0).Format("2006-01-02 15:04:05")
  42 + }
  43 + return item
  44 +}
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  5 + "strings"
  6 +)
  7 +
  8 +type UserBaseDto struct {
  9 + // 用户基础数据id
  10 + UserBaseId int `json:"userBaseId,omitempty"`
  11 + //姓名
  12 + UserName string `json:"userName"`
  13 + // 账号
  14 + Account string `json:"account"`
  15 + // 用户关联的组织
  16 + Organizations string `json:"organizations"`
  17 + // 账号状态 1:正常 2.禁用 3:注销
  18 + Status int `json:"status,omitempty"`
  19 + // 推荐人
  20 + Referer string `json:"referer"`
  21 + // 创建时间
  22 + RegistrationDate string `json:"registrationDate,omitempty"`
  23 + // 最后登录时间
  24 + LastLogIn string `json:"lastLogIn"`
  25 +}
  26 +
  27 +func (dto *UserBaseDto) LoadDto(detail allied_creation_user.UserBaseDetail) {
  28 + dto.UserBaseId = detail.UserBaseId
  29 + dto.UserName = detail.UserInfo.UserName
  30 + dto.Account = detail.UserInfo.Phone
  31 + dto.Status = detail.Status
  32 + dto.Referer = detail.Referer
  33 + dto.RegistrationDate = detail.RegistrationDate
  34 + dto.LastLogIn = detail.LastLogIn
  35 + var organizations []string
  36 + for i := range detail.UserOrg {
  37 + if len(detail.UserOrg[i].OrgName) == 0 {
  38 + continue
  39 + }
  40 + organizations = append(organizations, detail.UserOrg[i].OrgName)
  41 + }
  42 + dto.Organizations = strings.Join(organizations, ",")
  43 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type ListAdminUserQuery struct {
  13 + Operator domain.Operator `json:"-"`
  14 + // 查询偏离量
  15 + PageNumber int `cname:"查询偏离量" json:"pageNumber"`
  16 + // 查询限制
  17 + PageSize int `cname:"查询限制" json:"pageSize"`
  18 + // 用户姓名
  19 + UserName string `cname:"用户姓名" json:"userName,omitempty"`
  20 + // 所属组织
  21 + DepartmentName string `cname:"所属部门" json:"departmentName,omitempty"`
  22 +}
  23 +
  24 +func (listUserQuery *ListAdminUserQuery) Valid(validation *validation.Validation) {
  25 + //validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (listUserQuery *ListAdminUserQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(listUserQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(listUserQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type ListUserQuery struct {
  13 + Operator domain.Operator `json:"-"`
  14 + // 查询偏离量
  15 + PageNumber int `cname:"查询偏离量" json:"pageNumber"`
  16 + // 查询限制
  17 + PageSize int `cname:"查询限制" json:"pageSize"`
  18 + // 用户姓名
  19 + UserName string `cname:"用户姓名" json:"userName,omitempty"`
  20 + // 在用户列表内
  21 + //InUserBaseIds []int64 `cname:"用户姓名" json:"inUserBaseIds,omitempty"`
  22 + // 所属组织
  23 + OrgName string `cname:"所属组织" json:"orgName,omitempty"`
  24 + // 关闭查询限制
  25 + //DisableLimit bool `cname:"关闭查询限制" json:"disableLimit,omitempty"`
  26 +
  27 + // 获取组织
  28 + //FetchOrgBelong bool `cname:"获取组织" json:"fetchOrgBelong,omitempty"`
  29 +}
  30 +
  31 +func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) {
  32 + //validation.SetError("CustomValid", "未实现的自定义认证")
  33 +}
  34 +
  35 +func (listUserQuery *ListUserQuery) ValidateQuery() error {
  36 + valid := validation.Validation{}
  37 + b, err := valid.Valid(listUserQuery)
  38 + if err != nil {
  39 + return err
  40 + }
  41 + if !b {
  42 + elem := reflect.TypeOf(listUserQuery).Elem()
  43 + for _, validErr := range valid.Errors {
  44 + field, isExist := elem.FieldByName(validErr.Field)
  45 + if isExist {
  46 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  47 + } else {
  48 + return fmt.Errorf(validErr.Message)
  49 + }
  50 + }
  51 + }
  52 + return nil
  53 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  10 + "strconv"
  11 +)
  12 +
  13 +// 返回公司用户信息列表
  14 +func (usersService *UserService) AdminUserList(companyUserListQuery *query.ListAdminUserQuery) (int64, interface{}, error) {
  15 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  16 + result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  17 + Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize,
  18 + Limit: companyUserListQuery.PageSize,
  19 + OrganizationId: 0,
  20 + DepartmentId: 0,
  21 + UserName: companyUserListQuery.UserName,
  22 + DepName: companyUserListQuery.DepartmentName,
  23 + Phone: "",
  24 + UserType: domain.UserTypeOperationAdmin,
  25 + PullRealTime: true,
  26 + })
  27 +
  28 + if err != nil {
  29 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  30 + }
  31 + //数据转换
  32 + cnt := int64(result.Count)
  33 + var (
  34 + listData = make([]dto.AdminUserDto, 0)
  35 + item dto.AdminUserDto
  36 + )
  37 + for _, v := range result.Users {
  38 + item = dto.NewAdminUserDto(v)
  39 + listData = append(listData, item)
  40 + }
  41 + return cnt, listData, nil
  42 +}
  43 +
  44 +// 启用禁用用户
  45 +func (usersService *UserService) EnableAdminUser(companyUserEnableCommand *command.EnableAdminUserCommand) (interface{}, error) {
  46 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  47 + companyUserEnableCommand.Operator)
  48 +
  49 + var userIds []int64 = []int64{companyUserEnableCommand.UserId}
  50 + _, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
  51 + UserIds: userIds,
  52 + EnableStatus: companyUserEnableCommand.EnableStatus,
  53 + })
  54 + if err != nil {
  55 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  56 + }
  57 + return companyUserEnableCommand, err
  58 +}
  59 +
  60 +func (usersService *UserService) GetAdminUser(userId int) (interface{}, error) {
  61 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  62 + domain.Operator{})
  63 + result, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
  64 + UserId: userId,
  65 + })
  66 + if err != nil {
  67 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  68 + }
  69 + userInfo := dto.NewAdminUserDto(result.UserDetail)
  70 + return userInfo, nil
  71 +}
  72 +
  73 +func (usersService *UserService) CreateAdminUser(cmd *command.AdminUserAddCommand) (interface{}, error) {
  74 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  75 + cmd.Operator)
  76 + userOrg := []int64{}
  77 + userRole := []int64{}
  78 + initPassword := domain.DefaultPassword
  79 +
  80 + result, err := creationUserGateway.AdminUserCreate(allied_creation_user.ReqCreateUser{
  81 + CompanyId: cmd.Operator.CompanyId,
  82 + // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
  83 + UserType: domain.UserTypeOperationAdmin,
  84 + UserCode: cmd.UsersCode,
  85 + UserOrg: userOrg,
  86 + UserRole: userRole,
  87 + // 启用状态(启用:1 禁用:2)
  88 + EnableStatus: 1,
  89 + UserName: cmd.UsersName,
  90 + Phone: cmd.Phone,
  91 + Password: initPassword,
  92 + DepartmentName: cmd.DepartmentName,
  93 + })
  94 + if err != nil {
  95 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  96 + }
  97 +
  98 + data := struct {
  99 + UserId string `json:"userId"`
  100 + command.AdminUserAddCommand
  101 + }{
  102 + UserId: strconv.Itoa(result.UserId),
  103 + AdminUserAddCommand: *cmd,
  104 + }
  105 + return data, err
  106 +}
  107 +
  108 +func (usersService *UserService) UpdateAdminUser(cmd *command.AdminUserEditCommand) (interface{}, error) {
  109 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  110 + cmd.Operator)
  111 + user, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
  112 + Account: cmd.Phone,
  113 + })
  114 + _, err = creationUserGateway.AdminUserUpdate(allied_creation_user.ReqUpdateUser{
  115 + UserId: cmd.UserId,
  116 + //CooperationCompany: cmd.CooperationCompany,
  117 + //CooperationDeadline: time.Unix(cmd.CooperationDeadline/1000, 0),
  118 + Email: user.UserInfo.Email,
  119 + //EnableStatus: user.,
  120 + UserCode: cmd.UsersCode,
  121 + UserName: cmd.UsersName,
  122 + Avatar: user.UserInfo.Avatar,
  123 + //OrgId: cmd.Operator.OrgId,
  124 + Phone: cmd.Phone,
  125 + DepartmentName: cmd.DepartmentName,
  126 + })
  127 + if err != nil {
  128 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  129 + }
  130 + return cmd, err
  131 +}
  132 +
  133 +func (svr *UserService) GetAdminUserInfo(operator domain.Operator) (interface{}, error) {
  134 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  135 + operator)
  136 +
  137 + resultUser, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
  138 + Account: operator.Phone,
  139 + })
  140 + if err != nil {
  141 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  142 + }
  143 +
  144 + users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  145 + UserBaseId: int64(resultUser.UserBaseID),
  146 + UserType: domain.UserTypeOperationAdmin,
  147 + })
  148 + if err != nil {
  149 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  150 + }
  151 + if len(users.Users) == 0 {
  152 + return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
  153 + }
  154 + var user = map[string]interface{}{
  155 + "userId": users.Users[0].UserId,
  156 + "userInfo": map[string]interface{}{
  157 + "userName": resultUser.UserInfo.UserName,
  158 + "userPhone": resultUser.UserInfo.Phone,
  159 + "userAvatar": resultUser.UserInfo.Avatar,
  160 + "email": resultUser.UserInfo.Email,
  161 + },
  162 + "department": struct{}{},
  163 + "company": map[string]interface{}{},
  164 + //"im": resultUser.Im,
  165 + "org": struct{}{},
  166 + }
  167 + return user, nil
  168 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/dto"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  10 +)
  11 +
  12 +type UserService struct {
  13 +}
  14 +
  15 +// 创建菜单服务
  16 +func (userService *UserService) SearchUser(cmd *query.ListUserQuery) (int64, interface{}, error) {
  17 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
  18 + result, err := creationUserGateway.UserBaseSearch(allied_creation_user.ReqUserBaseSearch{
  19 + Offset: (cmd.PageNumber - 1) * cmd.PageSize,
  20 + Limit: cmd.PageSize,
  21 + UserName: cmd.UserName,
  22 + OrgName: cmd.OrgName,
  23 + FetchOrgBelong: true,
  24 + })
  25 + if err != nil {
  26 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  27 + }
  28 + var users = make([]dto.UserBaseDto, 0)
  29 + for i := range result.Users {
  30 + item := &dto.UserBaseDto{}
  31 + item.LoadDto(result.Users[i])
  32 + users = append(users, *item)
  33 + }
  34 + return result.Count, users, nil
  35 +}
  36 +
  37 +func (userService *UserService) EnableUser(cmd *command.EnableUserCommand) (interface{}, error) {
  38 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
  39 + _, err := creationUserGateway.EnableUserBase(allied_creation_user.ReqEnableUserBase{
  40 + UserBaseIds: []int64{cmd.UserBaseId},
  41 + EnableStatus: cmd.EnableStatus,
  42 + })
  43 + if err != nil {
  44 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  45 + }
  46 + return struct{}{}, nil
  47 +}
  48 +
  49 +func (userService *UserService) ResetPassword(cmd *command.ResetPasswordCommand) (interface{}, error) {
  50 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(cmd.Operator)
  51 + _, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
  52 + Phone: cmd.Account,
  53 + Password: domain.DefaultPassword, //TL123456!
  54 + })
  55 + if err != nil {
  56 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  57 + }
  58 + return struct{}{}, nil
  59 +}
  60 +
  61 +func NewUserService(options map[string]interface{}) *UserService {
  62 + newUserService := &UserService{}
  63 + return newUserService
  64 +}
@@ -26,7 +26,7 @@ func (menuService *MenuService) MenuFavorite(menuFavoriteCommand *command.MenuFa @@ -26,7 +26,7 @@ func (menuService *MenuService) MenuFavorite(menuFavoriteCommand *command.MenuFa
26 } 26 }
27 27
28 // 返回菜单列表 28 // 返回菜单列表
29 -func (menuService *MenuService) MenuList(menuListQuery *query.MenuListQuery) (interface{}, error) { 29 +func (menuService *MenuService) CustomizeMenus(menuListQuery *query.MenuListQuery) (interface{}, error) {
30 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( 30 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
31 menuListQuery.Operator, 31 menuListQuery.Operator,
32 ) 32 )
@@ -59,6 +59,21 @@ func (menuService *MenuService) MenuUpdate(menuUpdateCommand *command.MenuUpdate @@ -59,6 +59,21 @@ func (menuService *MenuService) MenuUpdate(menuUpdateCommand *command.MenuUpdate
59 return menuUpdateCommand, nil 59 return menuUpdateCommand, nil
60 } 60 }
61 61
  62 +func (menuService *MenuService) MenuSearch(menuListQuery *query.MenuListQuery) (interface{}, error) {
  63 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  64 + menuListQuery.Operator,
  65 + )
  66 + result, err := creationUserGateway.MenusSearch(allied_creation_user.ReqMenusSearch{
  67 + MenuCategory: menuListQuery.MenuCategory,
  68 + })
  69 + if err != nil {
  70 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  71 + }
  72 + return map[string]interface{}{
  73 + "menus": result.Menus,
  74 + }, nil
  75 +}
  76 +
62 func NewMenuService(options map[string]interface{}) *MenuService { 77 func NewMenuService(options map[string]interface{}) *MenuService {
63 newMenuService := &MenuService{} 78 newMenuService := &MenuService{}
64 return newMenuService 79 return newMenuService
  1 +package command
  2 +
  3 +type ImportCostDataCommand struct {
  4 + Types int `json:"types"`
  5 +}
@@ -14,6 +14,10 @@ type ImportDataCommand struct { @@ -14,6 +14,10 @@ type ImportDataCommand struct {
14 FileExt string `json:"-"` 14 FileExt string `json:"-"`
15 // 业务编码 15 // 业务编码
16 Code string `form:"code"` 16 Code string `form:"code"`
  17 + // 条件 - 成本结构会增加条件
  18 + Where string `form:"where"`
  19 + // 文件名
  20 + FileName string `json:"fileName"`
17 } 21 }
18 22
19 func (importDataCommand *ImportDataCommand) Valid(validation *validation.Validation) { 23 func (importDataCommand *ImportDataCommand) Valid(validation *validation.Validation) {
  1 +package query
  2 +
  3 +type ExcelDataFieldsQuery struct {
  4 + //操作人
  5 + // 业务编码
  6 + Code string `form:"code"`
  7 +}
  1 +package query
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  4 +
  5 +type ManufactureEmployeeProductiveQuery struct {
  6 + // 页码
  7 + PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
  8 + // 页数
  9 + PageSize int `cname:"页数" json:"pageSize,omitempty"`
  10 + // 车间名称
  11 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  12 + // 生产线名称
  13 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  14 + // 工段名称
  15 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  16 + // 姓名
  17 + UserName string `cname:"姓名" json:"userName"`
  18 + // 员工类型 1:固定 2:派遣 3.临时
  19 + EmployeeType string `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
  20 + // 开始时间
  21 + BeginTime string `cname:"开始时间" json:"beginTime"`
  22 + // 结束时间
  23 + EndTime string `cname:"结束时间" json:"endTime"`
  24 + //操作人
  25 + Operator domain.Operator `json:"-"`
  26 + SelectedField []string `json:"selectedField"`
  27 +}
  1 +package query
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
  6 +)
  7 +
  8 +type ManufactureExportEmployeeAttendanceStaticsQuery struct {
  9 + *allied_creation_manufacture.SearchEmployeeAttendanceStaticsRequest
  10 + //操作人
  11 + Operator domain.Operator `json:"-"`
  12 + SelectedField []string `json:"selectedField"`
  13 +}
  1 +package query
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
  6 +)
  7 +
  8 +type ManufactureExportWorkshopAttendanceStaticsQuery struct {
  9 + *allied_creation_manufacture.SearchWorkshopWorkTimeStaticsRequest
  10 + //操作人
  11 + Operator domain.Operator `json:"-"`
  12 + SelectedField []string `json:"selectedField"`
  13 +}
  1 +package query
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
  6 +)
  7 +
  8 +type ManufactureSecondLevelRecordQuery struct {
  9 + *allied_creation_manufacture.SearchSecondLevelRecordRequest
  10 + //操作人
  11 + Operator domain.Operator `json:"-"`
  12 + SelectedField []string `json:"selectedField"`
  13 +}
  1 +package query
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  4 +
  5 +type ManufactureWorkshopProductiveQuery struct {
  6 + // 工段名称
  7 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  8 + // 品名
  9 + PlanProductName string `cname:"品名" json:"planProductName,omitempty"`
  10 + // 开始时间
  11 + BeginTime string `cname:"开始时间" json:"beginTime"`
  12 + // 结束时间
  13 + EndTime string `cname:"结束时间" json:"endTime"`
  14 + //操作人
  15 + Operator domain.Operator `json:"-"`
  16 + SelectedField []string `json:"selectedField"`
  17 +}
  1 +package query
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  4 +
  5 +type SearchProductQuery struct {
  6 + // 产品名称
  7 + ProductName string `json:"productName,omitempty"`
  8 + // 产品类别
  9 + ProductCategory string `cname:"产品类别" json:"productCategory"`
  10 + //操作人
  11 + Operator domain.Operator `json:"-"`
  12 + SelectedField []string `json:"selectedField"`
  13 +}
@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
@@ -51,3 +52,88 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co @@ -51,3 +52,88 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co
51 } 52 }
52 return ExportCooperationUserData{SourceData: result.Users, SelectedField: companyUserListQuery.SelectedField}, nil 53 return ExportCooperationUserData{SourceData: result.Users, SelectedField: companyUserListQuery.SelectedField}, nil
53 } 54 }
  55 +
  56 +// ExportCooperationUser 导出共创用户信息列表
  57 +func (srv ExcelDataService) ExportProducts(cmd *query.SearchProductQuery) (ExportProductsData, error) {
  58 + creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
  59 + result, err := creationUserGateway.SearchProduct(allied_creation_manufacture.SearchProductRequest{
  60 + ProductName: cmd.ProductName,
  61 + ProductCategory: cmd.ProductCategory,
  62 + })
  63 + if err != nil {
  64 + return ExportProductsData{}, fmt.Errorf("获取企业用户数据失败:%w", err)
  65 + }
  66 + return ExportProductsData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
  67 +}
  68 +
  69 +// ExportEmployeeProductive 导出员工产能
  70 +func (srv ExcelDataService) ExportEmployeeProductive(cmd *query.ManufactureEmployeeProductiveQuery) (ExportEmployeeProductiveData, error) {
  71 + creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
  72 + result, err := creationUserGateway.SearchEmployeeProductive(allied_creation_manufacture.SearchEmployeeProductiveRequest{
  73 + WorkshopName: cmd.WorkshopName,
  74 + LineName: cmd.LineName,
  75 + SectionName: cmd.SectionName,
  76 + UserName: cmd.UserName,
  77 + EmployeeType: cmd.EmployeeType,
  78 + BeginTime: cmd.BeginTime,
  79 + EndTime: cmd.EndTime,
  80 + })
  81 + if err != nil {
  82 + return ExportEmployeeProductiveData{}, fmt.Errorf("获取员工产能数据失败:%w", err)
  83 + }
  84 + return ExportEmployeeProductiveData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
  85 +}
  86 +
  87 +// ExportEmployeeProductive 导出车间产能
  88 +func (srv ExcelDataService) ExportWorkshopProductive(cmd *query.ManufactureWorkshopProductiveQuery) (ExportWorkshopProductiveData, error) {
  89 + creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
  90 + result, err := creationUserGateway.SearchWorkshopProductive(allied_creation_manufacture.SearchWorkshopProductiveRequest{
  91 + SectionName: cmd.SectionName,
  92 + PlanProductName: cmd.PlanProductName,
  93 + BeginTime: cmd.BeginTime,
  94 + EndTime: cmd.EndTime,
  95 + })
  96 + if err != nil {
  97 + return ExportWorkshopProductiveData{}, fmt.Errorf("获取员工产能数据失败:%w", err)
  98 + }
  99 + return ExportWorkshopProductiveData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
  100 +}
  101 +
  102 +// ExportSecondLevelRecord 二级废品
  103 +func (srv ExcelDataService) ExportSecondLevelRecord(cmd *query.ManufactureSecondLevelRecordQuery) (ExportSecondLevelData, error) {
  104 + creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
  105 + result, err := creationUserGateway.SearchSecondLevelRecord(allied_creation_manufacture.SearchSecondLevelRecordRequest{
  106 + WorkshopName: cmd.WorkshopName,
  107 + BatchNumber: cmd.BatchNumber,
  108 + UserName: cmd.UserName,
  109 + LineName: cmd.LineName,
  110 + SectionName: cmd.SectionName,
  111 + EmployeeType: cmd.EmployeeType,
  112 + BeginTime: cmd.BeginTime,
  113 + EndTime: cmd.EndTime,
  114 + })
  115 + if err != nil {
  116 + return ExportSecondLevelData{}, fmt.Errorf("获取二级废品数据失败:%w", err)
  117 + }
  118 + return ExportSecondLevelData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
  119 +}
  120 +
  121 +// ExportEmployeeAttendanceStatics 导出员工工时
  122 +func (srv ExcelDataService) ExportEmployeeAttendanceStatics(cmd *query.ManufactureExportEmployeeAttendanceStaticsQuery) (ExportEmployeeAttendanceStaticsData, error) {
  123 + creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
  124 + result, err := creationUserGateway.SearchEmployeeAttendanceStatics(*cmd.SearchEmployeeAttendanceStaticsRequest)
  125 + if err != nil {
  126 + return ExportEmployeeAttendanceStaticsData{}, fmt.Errorf("获取员工工时数据失败:%w", err)
  127 + }
  128 + return ExportEmployeeAttendanceStaticsData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
  129 +}
  130 +
  131 +// ExportWorkshopAttendanceStatics 导出车间工时
  132 +func (srv ExcelDataService) ExportWorkshopAttendanceStatics(cmd *query.ManufactureExportWorkshopAttendanceStaticsQuery) (ExportWorkshopAttendanceStaticsData, error) {
  133 + creationUserGateway := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(cmd.Operator)
  134 + result, err := creationUserGateway.SearchWorkshopWorkTimeStatics(*cmd.SearchWorkshopWorkTimeStaticsRequest)
  135 + if err != nil {
  136 + return ExportWorkshopAttendanceStaticsData{}, fmt.Errorf("获取车间工时数据失败:%w", err)
  137 + }
  138 + return ExportWorkshopAttendanceStaticsData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
  139 +}
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "bytes"
  5 + "encoding/json"
4 "fmt" 6 "fmt"
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/converter"  
6 - "strings"  
7 -  
8 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
9 "github.com/linmadan/egglib-go/utils/excel" 8 "github.com/linmadan/egglib-go/utils/excel"
  9 + "github.com/xuri/excelize/v2"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService" 13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
  14 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 15 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  16 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
  17 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/converter"
  18 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/oss"
  19 + "io"
  20 + "strings"
14 ) 21 )
15 22
16 type ExcelDataService struct { 23 type ExcelDataService struct {
@@ -90,6 +97,8 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD @@ -90,6 +97,8 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
90 {EnName: "department", CnName: "*所属部门"}, 97 {EnName: "department", CnName: "*所属部门"},
91 {EnName: "enableStatus", CnName: "*用户状态"}, 98 {EnName: "enableStatus", CnName: "*用户状态"},
92 {EnName: "phone", CnName: "*手机号"}, 99 {EnName: "phone", CnName: "*手机号"},
  100 + {EnName: "employeeType", CnName: "*员工类型"},
  101 + {EnName: "icCardNumber", CnName: "IC卡号"},
93 {EnName: "email", CnName: "邮箱"}, 102 {EnName: "email", CnName: "邮箱"},
94 } 103 }
95 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader) 104 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
@@ -111,6 +120,8 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD @@ -111,6 +120,8 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
111 Phone: strings.TrimSpace(v["phone"]), 120 Phone: strings.TrimSpace(v["phone"]),
112 Email: strings.TrimSpace(v["email"]), 121 Email: strings.TrimSpace(v["email"]),
113 EnableStatus: strings.TrimSpace(v["enableStatus"]), 122 EnableStatus: strings.TrimSpace(v["enableStatus"]),
  123 + EmployeeType: strings.TrimSpace(v["employeeType"]),
  124 + IcCardNumber: strings.TrimSpace(v["icCardNumber"]),
114 } 125 }
115 users = append(users, item) 126 users = append(users, item)
116 } 127 }
@@ -161,6 +172,247 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import @@ -161,6 +172,247 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import
161 return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(items)), nil 172 return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(items)), nil
162 } 173 }
163 174
  175 +// ImportProduct 导入生产信息
  176 +func (srv ExcelDataService) ImportProduct(importDataCommand *command.ImportDataCommand) (interface{}, error) {
  177 + excelImport := excel.NewExcelImport()
  178 + excelImport.RowBegin = 3 //第二行开始读取
  179 + excelImport.DataFields = []excel.DataField{
  180 + {EnName: "productCode", CnName: "产品编号"},
  181 + {EnName: "productName", CnName: "*品名"},
  182 + {EnName: "unit", CnName: "*规格"},
  183 + {EnName: "productCategory", CnName: "*类别"},
  184 + {EnName: "unitWeight", CnName: "投入单份重量"},
  185 + }
  186 + excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
  187 + if err != nil {
  188 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  189 + }
  190 + items := make([]*domain.ImportProductItem, 0)
  191 + for _, v := range excelData {
  192 + item := &domain.ImportProductItem{
  193 + ProductCode: strings.TrimSpace(v["productCode"]),
  194 + ProductName: strings.TrimSpace(v["productName"]),
  195 + ProductCategory: strings.TrimSpace(v["productCategory"]),
  196 + Unit: strings.TrimSpace(v["unit"]),
  197 + UnitWeight: strings.TrimSpace(v["unitWeight"]),
  198 + }
  199 + items = append(items, item)
  200 + }
  201 +
  202 + svr := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(importDataCommand.Operator)
  203 + result, err := svr.BatchAddProduct(allied_creation_manufacture.BatchAddProductRequest{
  204 + List: items,
  205 + })
  206 + if err != nil {
  207 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  208 + }
  209 + return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
  210 +}
  211 +
  212 +// ImportProduct 导入生产信息
  213 +func (srv ExcelDataService) ImportDevice(importDataCommand *command.ImportDataCommand) (interface{}, error) {
  214 + excelImport := excel.NewExcelImport()
  215 + excelImport.RowBegin = 3 //第二行开始读取
  216 + excelImport.DataFields = []excel.DataField{
  217 + {EnName: "deviceCode", CnName: "*设备编号"},
  218 + {EnName: "deviceName", CnName: "*设备名称"},
  219 + {EnName: "deviceModel", CnName: "*设备型号"},
  220 + {EnName: "deviceType", CnName: "*设备类型"},
  221 + {EnName: "brand", CnName: "品牌"},
  222 + {EnName: "status", CnName: "*状态"},
  223 + {EnName: "level", CnName: "*风险等级"},
  224 + }
  225 + excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
  226 + if err != nil {
  227 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  228 + }
  229 + items := make([]*domain.ImportDeviceItem, 0)
  230 + for _, v := range excelData {
  231 + item := &domain.ImportDeviceItem{
  232 + DeviceCode: strings.TrimSpace(v["deviceCode"]),
  233 + DeviceName: strings.TrimSpace(v["deviceName"]),
  234 + DeviceModel: strings.TrimSpace(v["deviceModel"]),
  235 + DeviceType: strings.TrimSpace(v["deviceType"]),
  236 + Brand: strings.TrimSpace(v["brand"]),
  237 + Status: strings.TrimSpace(v["status"]),
  238 + Level: strings.TrimSpace(v["level"]),
  239 + }
  240 + items = append(items, item)
  241 + }
  242 +
  243 + svr := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(importDataCommand.Operator)
  244 + result, err := svr.BatchAddDevice(allied_creation_manufacture.BatchAddDeviceRequest{
  245 + List: items,
  246 + })
  247 + if err != nil {
  248 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  249 + }
  250 + return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
  251 +}
  252 +
  253 +// ImportCost 导入成本结构化
  254 +func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataCommand) (interface{}, error) {
  255 + excelImport := excel.NewExcelImport()
  256 + excelImport.RowBegin = 2 //第二行开始读取
  257 + excelImport.DataFields = []excel.DataField{
  258 + {EnName: "projectCode", CnName: "*项目编码"},
  259 + {EnName: "itemName", CnName: "*细项名称"},
  260 + {EnName: "choiceId", CnName: "*节点类型"},
  261 + {EnName: "text", CnName: "文本(数值)内容"},
  262 + {EnName: "image1", CnName: "图片1"},
  263 + {EnName: "image2", CnName: "图片2"},
  264 + {EnName: "image3", CnName: "图片3"},
  265 + {EnName: "formula", CnName: "计算公式"},
  266 + {EnName: "chargePersons", CnName: "*负责人"},
  267 + {EnName: "target", CnName: "目标值"},
  268 + {EnName: "targetPeriod", CnName: "目标值期限"},
  269 + {EnName: "present", CnName: "现状值"},
  270 + {EnName: "schedulePlanPercent", CnName: "进度计划比"},
  271 + {EnName: "benchmark", CnName: "标杆值"},
  272 + {EnName: "highest", CnName: "历史最高值"},
  273 + {EnName: "yesterdayActual", CnName: "昨日实际值"},
  274 + }
  275 + var buf bytes.Buffer
  276 + tee := io.TeeReader(importDataCommand.Reader, &buf)
  277 + excelData, err := converter.OpenImportFileFromIoReader(excelImport, tee, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
  278 + if err != nil {
  279 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  280 + }
  281 + importCostCommand := &command.ImportCostDataCommand{}
  282 + err = json.Unmarshal([]byte(importDataCommand.Where), importCostCommand)
  283 + if err != nil {
  284 + return nil, application.ThrowError(application.ARG_ERROR, "风险类型不能为空")
  285 + }
  286 + if importCostCommand.Types <= 0 {
  287 + return nil, application.ThrowError(application.ARG_ERROR, "风险类型不能为空")
  288 + }
  289 + f, err := excelize.OpenReader(&buf)
  290 + if err != nil {
  291 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  292 + }
  293 + index := f.GetActiveSheetIndex()
  294 + //获取公司下所有用户
  295 + users, err := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator).UserSearch(allied_creation_user.ReqUserSearch{CompanyId: importDataCommand.Operator.CompanyId, Limit: 10000})
  296 + if err != nil {
  297 + return nil, application.ThrowError(application.ARG_ERROR, "获取用户数据失败")
  298 + }
  299 + userMap := make(map[string]allied_creation_user.UserDetail)
  300 + for _, item := range users.Users {
  301 + userMap[item.UserInfo.UserName] = item
  302 + }
  303 + createCostManagemant := cost_structured.BatchAddCostManagemantRequest{
  304 + BatchCreateCostManagemant: &domain.BatchCreateCostManagemant{
  305 + UserId: importDataCommand.Operator.UserId,
  306 + CompanyId: importDataCommand.Operator.CompanyId,
  307 + ProjectName: importDataCommand.FileName,
  308 + Types: importCostCommand.Types,
  309 + CostManagemants: make([]*domain.CostManagemant, 0),
  310 + },
  311 + }
  312 + for key, v := range excelData {
  313 + //图片1
  314 + _, mBytes1, err := f.GetPicture(f.GetSheetName(index), "E"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
  315 + if err != nil {
  316 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
  317 + }
  318 + var ossFile []string
  319 + if mBytes1 != nil {
  320 + ossFile1, err := oss.UploadOss(mBytes1)
  321 + if err != nil {
  322 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
  323 + }
  324 + ossFile = append(ossFile,ossFile1)
  325 + }
  326 + //图片2
  327 + _,mBytes2,err := f.GetPicture(f.GetSheetName(index), "F"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
  328 + if err != nil {
  329 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
  330 + }
  331 + if mBytes2 != nil {
  332 + ossFile2, err := oss.UploadOss(mBytes2)
  333 + if err != nil {
  334 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
  335 + }
  336 + ossFile = append(ossFile,ossFile2)
  337 + }
  338 + //图片3
  339 + _,mBytes3,err := f.GetPicture(f.GetSheetName(index), "G"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
  340 + if err != nil {
  341 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
  342 + }
  343 + if mBytes3 != nil {
  344 + ossFile3, err := oss.UploadOss(mBytes3)
  345 + if err != nil {
  346 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
  347 + }
  348 + ossFile = append(ossFile,ossFile3)
  349 + }
  350 + //choiceId, err := strconv.Atoi(v["choiceId"])
  351 + choiceId := domain.NodeType{}.GetIdByName(strings.TrimSpace(v["choiceId"]))
  352 + // 负责人
  353 + chargePersons := make([]string, 0)
  354 + names := strings.Split(strings.TrimSpace(v["chargePersons"]), " ")
  355 +
  356 + for _, userName := range names {
  357 + if userName == "" {
  358 + continue
  359 + }
  360 + if user, ok := userMap[userName]; ok {
  361 + chargePersons = append(chargePersons, fmt.Sprintf("%v", user.UserId))
  362 + } else {
  363 + chargePersons = append(chargePersons, "0")
  364 + }
  365 + }
  366 + //目标值期限
  367 + targetPeriod := domain.GetTargetPeriod(v["targetPeriod"])
  368 + item := &domain.CostManagemant{
  369 + ProjectCode: strings.TrimSpace(v["projectCode"]),
  370 + ProjectName: importDataCommand.FileName,
  371 + ItemName: strings.TrimSpace(v["itemName"]),
  372 + ChoiceId: choiceId,
  373 + Text: strings.TrimSpace(v["text"]),
  374 + Formula: strings.TrimSpace(v["formula"]),
  375 + ChargePersons: chargePersons,
  376 + Target: strings.TrimSpace(v["target"]),
  377 + TargetPeriod: targetPeriod,
  378 + Present: strings.TrimSpace(v["present"]),
  379 + SchedulePlanPercent: strings.TrimSpace(v["schedulePlanPercent"]),
  380 + Benchmark: strings.TrimSpace(v["benchmark"]),
  381 + Highest: strings.TrimSpace(v["highest"]),
  382 + YesterdayActual: strings.TrimSpace(v["yesterdayActual"]),
  383 + Types: importCostCommand.Types,
  384 + }
  385 + if len(ossFile) >0 {
  386 + item.Urls = ossFile
  387 + } else {
  388 + item.Urls = []string{}
  389 + }
  390 + createCostManagemant.CostManagemants = append(createCostManagemant.CostManagemants, item)
  391 + }
  392 + result, err := cost_structured.NewHttpLibCostStructured(importDataCommand.Operator).BatchCreateCostManagemant(createCostManagemant)
  393 + if err != nil {
  394 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  395 + }
  396 + if result.Code != 0 {
  397 + return map[string]interface{}{
  398 + "successCount": 0,
  399 + "fail": map[string]interface{}{
  400 + "header": map[string]string{
  401 + "failReason": "错误详情",
  402 + "projectCode": "项目编码",
  403 + "itemName": "细项名称",
  404 + },
  405 + "body": []map[string]interface{}{
  406 + {"failReason":result.Msg,"projectCode":"","itemName":""},
  407 + },
  408 + },
  409 + "successData":nil,
  410 + }, nil
  411 + } else {
  412 + return result.Data, nil
  413 + }
  414 +}
  415 +
164 // 导入结果 416 // 导入结果
165 func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, failRows []interface{}, totalRow int) interface{} { 417 func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, failRows []interface{}, totalRow int) interface{} {
166 var result = map[string]interface{}{ 418 var result = map[string]interface{}{
@@ -199,11 +451,14 @@ func (srv ExcelDataService) fieldValueAllEmpty(param map[string]string) bool { @@ -199,11 +451,14 @@ func (srv ExcelDataService) fieldValueAllEmpty(param map[string]string) bool {
199 // FileImportTemplate 导入模板 451 // FileImportTemplate 导入模板
200 func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) { 452 func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) {
201 var mapTemplate = map[string]string{ 453 var mapTemplate = map[string]string{
202 - domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807485_EaxECeRz23WpzrMZmbwdEPRJ3Pdxpx5X.xlsx", 454 + domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/opportunity/dev_online/20220222/object/1645495589_cFNDGRTfCxYMZ5hPYzfKxThYd3ywARRz.xlsx",
203 domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx", 455 domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx",
204 domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743206_NPYTKw6RGhXn4TpYNEQhGGdCkXKXTnxM.xlsx", 456 domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743206_NPYTKw6RGhXn4TpYNEQhGGdCkXKXTnxM.xlsx",
205 domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210926/object/1632635345_SbfzmkXjQHhCwPw4MB7zb5EBBtdp2MSE.xlsx", 457 domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210926/object/1632635345_SbfzmkXjQHhCwPw4MB7zb5EBBtdp2MSE.xlsx",
206 domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx", 458 domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx",
  459 + domain.ImportProducts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220120/object/1642670543_cbraNKjNPHcbN6RNBYQBrwhC7BXGbDWp.xlsx",
  460 + domain.ImportDevices: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220126/object/1643184320_hT6sY5BKHmBa4TynfSGSCGyZ2KTTtzkj.xlsx",
  461 + domain.ImportCosts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20220318/object/1647587204_B5azRmr2TB73jRKWsnFyDe4yxXJWnrDT.xlsx",
207 } 462 }
208 var url string 463 var url string
209 var ok bool 464 var ok bool
@@ -215,9 +470,9 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import @@ -215,9 +470,9 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import
215 }, nil 470 }, nil
216 } 471 }
217 472
218 -func (srv ExcelDataService) GetExcelDataFields(code string) (interface{}, error) { 473 +func (srv ExcelDataService) GetExcelDataFields(param *query.ExcelDataFieldsQuery) (interface{}, error) {
219 dataFileds := []DataFieldOptions{} 474 dataFileds := []DataFieldOptions{}
220 - switch code { 475 + switch param.Code {
221 case domain.ExportCompanyUser: 476 case domain.ExportCompanyUser:
222 dataFileds = (ExportCompanyUserData{}).AllFields() 477 dataFileds = (ExportCompanyUserData{}).AllFields()
223 case domain.ExportCooperationUser: 478 case domain.ExportCooperationUser:
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "fmt"
4 "github.com/linmadan/egglib-go/utils/excel" 5 "github.com/linmadan/egglib-go/utils/excel"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
6 ) 9 )
7 10
@@ -175,3 +178,461 @@ func (data ExportCooperationUserData) DataListLen() int { @@ -175,3 +178,461 @@ func (data ExportCooperationUserData) DataListLen() int {
175 func (data ExportCooperationUserData) TableTitle() []string { 178 func (data ExportCooperationUserData) TableTitle() []string {
176 return nil 179 return nil
177 } 180 }
  181 +
  182 +//ExportProductsData 导出产品数据
  183 +type ExportProductsData struct {
  184 + SourceData []allied_creation_manufacture.SearchProductItem
  185 + SelectedField []string
  186 +}
  187 +
  188 +var _ excel.ExcelMaker = (*ExportProductsData)(nil)
  189 +
  190 +func (data ExportProductsData) AllFields() []DataFieldOptions {
  191 + return []DataFieldOptions{
  192 + {EnName: "productCode", CnName: "产品编号"},
  193 + {EnName: "productName", CnName: "*品名"},
  194 + {EnName: "unit", CnName: "*规格"},
  195 + {EnName: "productCategory", CnName: "*类别"},
  196 + {EnName: "unitWeight", CnName: "投入单份重量"},
  197 + }
  198 +}
  199 +
  200 +func (data ExportProductsData) DataFieldList() []excel.DataField {
  201 + fields := []excel.DataField{}
  202 + allFields := data.AllFields()
  203 + for _, value2 := range allFields {
  204 + if len(data.SelectedField) == 0 || value2.IsDefault {
  205 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  206 + continue
  207 + }
  208 + for _, value3 := range data.SelectedField {
  209 + if value2.EnName == value3 {
  210 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  211 + }
  212 + }
  213 + }
  214 + return fields
  215 +}
  216 +
  217 +func (data ExportProductsData) CellValue(index int, enName string) (value interface{}) {
  218 + if index > data.DataListLen() {
  219 + return ""
  220 + }
  221 + switch enName {
  222 + case "productCode":
  223 + return data.SourceData[index].ProductCode
  224 + case "productName":
  225 + return data.SourceData[index].ProductName
  226 + case "unit":
  227 + return data.SourceData[index].Unit
  228 + case "productCategory":
  229 + return data.SourceData[index].ProductCategory
  230 + case "unitWeight":
  231 + return fmt.Sprintf("%v", data.SourceData[index].UnitWeight)
  232 + }
  233 + return nil
  234 +}
  235 +
  236 +func (data ExportProductsData) DataListLen() int {
  237 + return len(data.SourceData)
  238 +}
  239 +
  240 +func (data ExportProductsData) TableTitle() []string {
  241 + return nil
  242 +}
  243 +
  244 +//ExportEmployeeProductiveData 导出员工产能数据
  245 +type ExportEmployeeProductiveData struct {
  246 + SourceData []allied_creation_manufacture.EmployeeProductiveItem
  247 + SelectedField []string
  248 +}
  249 +
  250 +var _ excel.ExcelMaker = (*ExportEmployeeProductiveData)(nil)
  251 +
  252 +func (data ExportEmployeeProductiveData) AllFields() []DataFieldOptions {
  253 + return []DataFieldOptions{
  254 + {EnName: "createdAt", CnName: "日期"},
  255 + {EnName: "workshopName", CnName: "车间名称"},
  256 + {EnName: "lineName", CnName: "线别"},
  257 + {EnName: "sectionName", CnName: "工段"},
  258 + {EnName: "workOn", CnName: "班别"},
  259 + {EnName: "userName", CnName: "姓名"},
  260 + {EnName: "employeeType", CnName: "员工类型"},
  261 + {EnName: "participateType", CnName: "类别"},
  262 + {EnName: "planProductName", CnName: "品名"},
  263 + {EnName: "productWeigh", CnName: "产能"},
  264 + {EnName: "secondLevelWeigh", CnName: "二级品"},
  265 + {EnName: "qualificationRate", CnName: "合格率"},
  266 + {EnName: "orgName", CnName: "组织机构"},
  267 + }
  268 +}
  269 +
  270 +func (data ExportEmployeeProductiveData) DataFieldList() []excel.DataField {
  271 + fields := []excel.DataField{}
  272 + allFields := data.AllFields()
  273 + for _, value2 := range allFields {
  274 + if len(data.SelectedField) == 0 || value2.IsDefault {
  275 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  276 + continue
  277 + }
  278 + for _, value3 := range data.SelectedField {
  279 + if value2.EnName == value3 {
  280 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  281 + }
  282 + }
  283 + }
  284 + return fields
  285 +}
  286 +
  287 +func (data ExportEmployeeProductiveData) CellValue(index int, enName string) (value interface{}) {
  288 + if index > data.DataListLen() {
  289 + return ""
  290 + }
  291 + switch enName {
  292 + case "createdAt":
  293 + return data.SourceData[index].CreatedAt
  294 + case "workshopName":
  295 + return data.SourceData[index].WorkshopName
  296 + case "lineName":
  297 + return data.SourceData[index].LineName
  298 + case "sectionName":
  299 + return data.SourceData[index].SectionName
  300 + case "workOn":
  301 + return data.SourceData[index].WorkOn
  302 + case "userName":
  303 + return data.SourceData[index].ProductWorker.UserName
  304 + case "employeeType":
  305 + return domain.EmployeeTypeDescription(data.SourceData[index].ProductWorker.EmployeeType)
  306 + case "participateType":
  307 + return domain.ParticipateTypeDescription(data.SourceData[index].ParticipateType)
  308 + case "planProductName":
  309 + return data.SourceData[index].PlanProductName
  310 + case "productWeigh":
  311 + return fmt.Sprintf("%vKg", data.SourceData[index].ProductWeigh)
  312 + case "secondLevelWeigh":
  313 + return fmt.Sprintf("%vKg", data.SourceData[index].SecondLevelWeigh)
  314 + case "qualificationRate":
  315 + return fmt.Sprintf("%v%%", data.SourceData[index].QualificationRate)
  316 + case "orgName":
  317 + return data.SourceData[index].OrgName
  318 + }
  319 + return nil
  320 +}
  321 +
  322 +func (data ExportEmployeeProductiveData) DataListLen() int {
  323 + return len(data.SourceData)
  324 +}
  325 +
  326 +func (data ExportEmployeeProductiveData) TableTitle() []string {
  327 + return nil
  328 +}
  329 +
  330 +//ExportWorkshopProductiveData 导出员工产能数据
  331 +type ExportWorkshopProductiveData struct {
  332 + SourceData []allied_creation_manufacture.WorkshopProductiveItem
  333 + SelectedField []string
  334 +}
  335 +
  336 +var _ excel.ExcelMaker = (*ExportWorkshopProductiveData)(nil)
  337 +
  338 +func (data ExportWorkshopProductiveData) AllFields() []DataFieldOptions {
  339 + return []DataFieldOptions{
  340 + {EnName: "createdAt", CnName: "日期"},
  341 + {EnName: "batchNumber", CnName: "批次号"},
  342 + {EnName: "workshopName", CnName: "车间名称"},
  343 + {EnName: "lineName", CnName: "线别"},
  344 + {EnName: "sectionName", CnName: "工段"},
  345 + {EnName: "planProductName", CnName: "品名"},
  346 + {EnName: "devotedProductWeigh", CnName: "投入量"},
  347 + {EnName: "productWeigh", CnName: "产出量"},
  348 + {EnName: "secondLevelWeigh", CnName: "二级品"},
  349 + {EnName: "qualificationRate", CnName: "出品率"},
  350 + {EnName: "orgName", CnName: "组织机构"},
  351 + }
  352 +}
  353 +
  354 +func (data ExportWorkshopProductiveData) DataFieldList() []excel.DataField {
  355 + fields := []excel.DataField{}
  356 + allFields := data.AllFields()
  357 + for _, value2 := range allFields {
  358 + if len(data.SelectedField) == 0 || value2.IsDefault {
  359 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  360 + continue
  361 + }
  362 + for _, value3 := range data.SelectedField {
  363 + if value2.EnName == value3 {
  364 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  365 + }
  366 + }
  367 + }
  368 + return fields
  369 +}
  370 +
  371 +func (data ExportWorkshopProductiveData) CellValue(index int, enName string) (value interface{}) {
  372 + if index > data.DataListLen() {
  373 + return ""
  374 + }
  375 + switch enName {
  376 + case "createdAt":
  377 + return data.SourceData[index].CreatedAt
  378 + case "batchNumber":
  379 + return data.SourceData[index].BatchNumber
  380 + case "workshopName":
  381 + return data.SourceData[index].WorkshopName
  382 + case "lineName":
  383 + return data.SourceData[index].LineName
  384 + case "sectionName":
  385 + return data.SourceData[index].SectionName
  386 + case "userName":
  387 + return data.SourceData[index].ProductWorker.UserName
  388 + case "planProductName":
  389 + return data.SourceData[index].PlanProductName
  390 + case "devotedProductWeigh":
  391 + return fmt.Sprintf("%vKg", data.SourceData[index].DevotedProductWeigh)
  392 + case "productWeigh":
  393 + return fmt.Sprintf("%vKg", data.SourceData[index].ProductWeigh)
  394 + case "secondLevelWeigh":
  395 + return fmt.Sprintf("%vKg", data.SourceData[index].SecondLevelWeigh)
  396 + case "qualificationRate":
  397 + return fmt.Sprintf("%v%%", data.SourceData[index].QualificationRate)
  398 + case "orgName":
  399 + return data.SourceData[index].OrgName
  400 + }
  401 + return nil
  402 +}
  403 +
  404 +func (data ExportWorkshopProductiveData) DataListLen() int {
  405 + return len(data.SourceData)
  406 +}
  407 +
  408 +func (data ExportWorkshopProductiveData) TableTitle() []string {
  409 + return nil
  410 +}
  411 +
  412 +//ExportEmployeeAttendanceStaticsData 导出员工产能数据
  413 +type ExportEmployeeAttendanceStaticsData struct {
  414 + SourceData []allied_creation_manufacture.SearchEmployeeAttendanceStaticsItem
  415 + SelectedField []string
  416 +}
  417 +
  418 +var _ excel.ExcelMaker = (*ExportEmployeeAttendanceStaticsData)(nil)
  419 +
  420 +func (data ExportEmployeeAttendanceStaticsData) AllFields() []DataFieldOptions {
  421 + return []DataFieldOptions{
  422 + {EnName: "signDate", CnName: "日期"},
  423 + {EnName: "workshopName", CnName: "车间名称"},
  424 + {EnName: "lineName", CnName: "线别"},
  425 + {EnName: "sectionName", CnName: "工段"},
  426 + {EnName: "userName", CnName: "姓名"},
  427 + {EnName: "employeeTypeDescription", CnName: "员工类型"},
  428 + {EnName: "attendanceTypeDescription", CnName: "类别"},
  429 + {EnName: "workTime", CnName: "工时"},
  430 + {EnName: "attendanceStatusDescription", CnName: "状态"},
  431 + {EnName: "orgName", CnName: "组织机构"},
  432 + }
  433 +}
  434 +
  435 +func (data ExportEmployeeAttendanceStaticsData) DataFieldList() []excel.DataField {
  436 + fields := []excel.DataField{}
  437 + allFields := data.AllFields()
  438 + for _, value2 := range allFields {
  439 + if len(data.SelectedField) == 0 || value2.IsDefault {
  440 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  441 + continue
  442 + }
  443 + for _, value3 := range data.SelectedField {
  444 + if value2.EnName == value3 {
  445 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  446 + }
  447 + }
  448 + }
  449 + return fields
  450 +}
  451 +
  452 +func (data ExportEmployeeAttendanceStaticsData) CellValue(index int, enName string) (value interface{}) {
  453 + if index > data.DataListLen() {
  454 + return ""
  455 + }
  456 + switch enName {
  457 + case "signDate":
  458 + return data.SourceData[index].SignDate
  459 + case "workshopName":
  460 + return data.SourceData[index].WorkshopName
  461 + case "lineName":
  462 + return data.SourceData[index].LineName
  463 + case "sectionName":
  464 + return data.SourceData[index].SectionName
  465 + case "userName":
  466 + return data.SourceData[index].ProductWorker.UserName
  467 + case "employeeTypeDescription":
  468 + return data.SourceData[index].EmployeeTypeDescription
  469 + case "attendanceTypeDescription":
  470 + return data.SourceData[index].AttendanceTypeDescription
  471 + case "workTime":
  472 + return fmt.Sprintf("%vh", data.SourceData[index].WorkTime)
  473 + case "attendanceStatusDescription":
  474 + return data.SourceData[index].AttendanceStatusDescription
  475 + case "orgName":
  476 + return data.SourceData[index].OrgName
  477 + }
  478 + return nil
  479 +}
  480 +
  481 +func (data ExportEmployeeAttendanceStaticsData) DataListLen() int {
  482 + return len(data.SourceData)
  483 +}
  484 +
  485 +func (data ExportEmployeeAttendanceStaticsData) TableTitle() []string {
  486 + return nil
  487 +}
  488 +
  489 +//ExportWorkshopAttendanceStaticsData 导出车间工时统计
  490 +type ExportWorkshopAttendanceStaticsData struct {
  491 + SourceData []allied_creation_manufacture.SearchWorkshopWorkTimeStaticsItem
  492 + SelectedField []string
  493 +}
  494 +
  495 +var _ excel.ExcelMaker = (*ExportWorkshopAttendanceStaticsData)(nil)
  496 +
  497 +func (data ExportWorkshopAttendanceStaticsData) AllFields() []DataFieldOptions {
  498 + return []DataFieldOptions{
  499 + {EnName: "recordDate", CnName: "日期"},
  500 + {EnName: "workshopName", CnName: "车间名称"},
  501 + {EnName: "lineName", CnName: "线别"},
  502 + {EnName: "sectionName", CnName: "工段"},
  503 + {EnName: "eftWorkTime", CnName: "固定工时"},
  504 + {EnName: "edWorkTime", CnName: "临时工时"},
  505 + {EnName: "epWorkTime", CnName: "派遣工时"},
  506 + {EnName: "orgName", CnName: "组织机构"},
  507 + }
  508 +}
  509 +
  510 +func (data ExportWorkshopAttendanceStaticsData) DataFieldList() []excel.DataField {
  511 + fields := []excel.DataField{}
  512 + allFields := data.AllFields()
  513 + for _, value2 := range allFields {
  514 + if len(data.SelectedField) == 0 || value2.IsDefault {
  515 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  516 + continue
  517 + }
  518 + for _, value3 := range data.SelectedField {
  519 + if value2.EnName == value3 {
  520 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  521 + }
  522 + }
  523 + }
  524 + return fields
  525 +}
  526 +
  527 +func (data ExportWorkshopAttendanceStaticsData) CellValue(index int, enName string) (value interface{}) {
  528 + if index > data.DataListLen() {
  529 + return ""
  530 + }
  531 + switch enName {
  532 + case "recordDate":
  533 + return data.SourceData[index].RecordDate
  534 + case "workshopName":
  535 + return data.SourceData[index].WorkshopName
  536 + case "lineName":
  537 + return data.SourceData[index].LineName
  538 + case "sectionName":
  539 + return data.SourceData[index].SectionName
  540 + case "eftWorkTime":
  541 + return data.SourceData[index].EftWorkTime
  542 + case "edWorkTime":
  543 + return data.SourceData[index].EdWorkTime
  544 + case "epWorkTime":
  545 + return data.SourceData[index].EptWorkTime
  546 + case "orgName":
  547 + return data.SourceData[index].OrgName
  548 + }
  549 + return nil
  550 +}
  551 +
  552 +func (data ExportWorkshopAttendanceStaticsData) DataListLen() int {
  553 + return len(data.SourceData)
  554 +}
  555 +
  556 +func (data ExportWorkshopAttendanceStaticsData) TableTitle() []string {
  557 + return nil
  558 +}
  559 +
  560 +//ExportWorkshopProductiveData 导出员工产能数据
  561 +type ExportSecondLevelData struct {
  562 + SourceData []allied_creation_manufacture.SecondLevelRecordItem
  563 + SelectedField []string
  564 +}
  565 +
  566 +var _ excel.ExcelMaker = (*ExportSecondLevelData)(nil)
  567 +
  568 +func (data ExportSecondLevelData) AllFields() []DataFieldOptions {
  569 + return []DataFieldOptions{
  570 + {EnName: "workshopName", CnName: "车间名称"},
  571 + {EnName: "lineName", CnName: "线别"},
  572 + {EnName: "sectionName", CnName: "工段"},
  573 + {EnName: "workOn", CnName: "班别"},
  574 + {EnName: "userName", CnName: "姓名"},
  575 + {EnName: "employeeType", CnName: "员工类型"},
  576 + {EnName: "batchNumber", CnName: "批次号"},
  577 + {EnName: "planProductName", CnName: "生产品名"},
  578 + {EnName: "weightBefore", CnName: "二级品"},
  579 + {EnName: "createdAt", CnName: "提报时间"},
  580 + {EnName: "orgName", CnName: "组织机构"},
  581 + }
  582 +}
  583 +
  584 +func (data ExportSecondLevelData) DataFieldList() []excel.DataField {
  585 + fields := []excel.DataField{}
  586 + allFields := data.AllFields()
  587 + for _, value2 := range allFields {
  588 + if len(data.SelectedField) == 0 || value2.IsDefault {
  589 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  590 + continue
  591 + }
  592 + for _, value3 := range data.SelectedField {
  593 + if value2.EnName == value3 {
  594 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  595 + }
  596 + }
  597 + }
  598 + return fields
  599 +}
  600 +
  601 +func (data ExportSecondLevelData) CellValue(index int, enName string) (value interface{}) {
  602 + if index > data.DataListLen() {
  603 + return ""
  604 + }
  605 + switch enName {
  606 + case "workshopName":
  607 + return data.SourceData[index].WorkshopName
  608 + case "lineName":
  609 + return data.SourceData[index].LineName
  610 + case "sectionName":
  611 + return data.SourceData[index].SectionName
  612 + case "userName":
  613 + return data.SourceData[index].ProductWorker.UserName
  614 + case "workOn":
  615 + return domain.WorkOnDescription(data.SourceData[index].WorkOn)
  616 + case "employeeType":
  617 + return domain.EmployeeTypeDescription(data.SourceData[index].ProductWorker.EmployeeType)
  618 + case "batchNumber":
  619 + return data.SourceData[index].BatchNumber
  620 + case "planProductName":
  621 + return data.SourceData[index].PlanProductName
  622 + case "weightBefore":
  623 + return fmt.Sprintf("%vKg", data.SourceData[index].WeightBefore)
  624 + case "createdAt":
  625 + return data.SourceData[index].CreatedAt
  626 + case "orgName":
  627 + return data.SourceData[index].OrgName
  628 + }
  629 + return nil
  630 +}
  631 +
  632 +func (data ExportSecondLevelData) DataListLen() int {
  633 + return len(data.SourceData)
  634 +}
  635 +
  636 +func (data ExportSecondLevelData) TableTitle() []string {
  637 + return nil
  638 +}
@@ -30,6 +30,10 @@ type CompanyUserAddCommand struct { @@ -30,6 +30,10 @@ type CompanyUserAddCommand struct {
30 UserRole []Role `json:"userRole,omitempty"` 30 UserRole []Role `json:"userRole,omitempty"`
31 // 头像 31 // 头像
32 Avatar string `json:"avatar" valid:"Required"` 32 Avatar string `json:"avatar" valid:"Required"`
  33 + // 员工类型 1:固定 2:派遣 3.临时
  34 + EmployeeType int `cname:"员工类型" json:"employeeType" valid:"Required"`
  35 + // IC卡号
  36 + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"`
33 } 37 }
34 38
35 func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) { 39 func (companyUserAddCommand *CompanyUserAddCommand) Valid(validation *validation.Validation) {
@@ -25,6 +25,10 @@ type CompanyUserUpdateCommand struct { @@ -25,6 +25,10 @@ type CompanyUserUpdateCommand struct {
25 Phone string `json:"phone,omitempty"` 25 Phone string `json:"phone,omitempty"`
26 // 邮箱 26 // 邮箱
27 Email string `json:"email,omitempty"` 27 Email string `json:"email,omitempty"`
  28 + // 员工类型 1:固定 2:派遣 3.临时
  29 + EmployeeType int `cname:"员工类型" json:"employeeType" valid:"Required"`
  30 + // IC卡号
  31 + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"`
28 // 关联的组织机构 32 // 关联的组织机构
29 UserOrg []Org `json:"userOrg,omitempty"` 33 UserOrg []Org `json:"userOrg,omitempty"`
30 // 关联的组织结构 34 // 关联的组织结构
@@ -9,24 +9,32 @@ type CompanyUserItem struct { @@ -9,24 +9,32 @@ type CompanyUserItem struct {
9 UserId string `json:"userId"` 9 UserId string `json:"userId"`
10 UserName string `json:"userName"` 10 UserName string `json:"userName"`
11 UserType int `json:"userType"` 11 UserType int `json:"userType"`
  12 + // 员工类型 1:固定 2:派遣 3.临时
  13 + EmployeeType int `json:"employeeType"`
  14 + // IC卡号
  15 + IcCardNumber string `json:"icCardNumber"`
12 AuthFlag bool `json:"authFlag"` // 1:可操作(编辑,修改等) 16 AuthFlag bool `json:"authFlag"` // 1:可操作(编辑,修改等)
13 } 17 }
14 18
15 //CompanyUserInfo 用户数据详情 19 //CompanyUserInfo 用户数据详情
16 type CompanyUserInfo struct { 20 type CompanyUserInfo struct {
17 - Email string `json:"email"`  
18 - Phone string `json:"phone"`  
19 - Avatar string `json:"avatar"`  
20 - EnableStatus int `json:"enableStatus"`  
21 - UsersCode string `json:"userCode"`  
22 - UsersID string `json:"userId"`  
23 - UsersName string `json:"userName"`  
24 - OrgID string `json:"orgId"`  
25 - OrgName string `json:"orgName"`  
26 - DepartmentID string `json:"departmentId"`  
27 - DepartmentName string `json:"departmentName"`  
28 - UsersOrg []UserOrg `json:"userOrg"`  
29 - UsersRole []UserRole `json:"userRole"` 21 + Email string `json:"email"`
  22 + Phone string `json:"phone"`
  23 + Avatar string `json:"avatar"`
  24 + EnableStatus int `json:"enableStatus"`
  25 + UsersCode string `json:"userCode"`
  26 + UsersID string `json:"userId"`
  27 + UsersName string `json:"userName"`
  28 + OrgID string `json:"orgId"`
  29 + OrgName string `json:"orgName"`
  30 + DepartmentID string `json:"departmentId"`
  31 + DepartmentName string `json:"departmentName"`
  32 + // 员工类型 1:固定 2:派遣 3.临时
  33 + EmployeeType int `json:"employeeType"`
  34 + // IC卡号
  35 + IcCardNumber string `json:"icCardNumber"`
  36 + UsersOrg []UserOrg `json:"userOrg"`
  37 + UsersRole []UserRole `json:"userRole"`
30 } 38 }
31 39
32 type UserOrg struct { 40 type UserOrg struct {
@@ -93,6 +93,8 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp @@ -93,6 +93,8 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp
93 DepartmentName: resultUser.Department.DepartmentName, 93 DepartmentName: resultUser.Department.DepartmentName,
94 UsersOrg: usersOrg, 94 UsersOrg: usersOrg,
95 UsersRole: userRole, 95 UsersRole: userRole,
  96 + EmployeeType: resultUser.UserInfo.EmployeeType,
  97 + IcCardNumber: resultUser.UserInfo.IcCardNumber,
96 } 98 }
97 99
98 datas := map[string]interface{}{ 100 datas := map[string]interface{}{
@@ -141,6 +143,8 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command. @@ -141,6 +143,8 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
141 Phone: companyUserAddCommand.Phone, 143 Phone: companyUserAddCommand.Phone,
142 Avatar: companyUserAddCommand.Avatar, 144 Avatar: companyUserAddCommand.Avatar,
143 Email: companyUserAddCommand.Email, 145 Email: companyUserAddCommand.Email,
  146 + IcCardNumber: companyUserAddCommand.IcCardNumber,
  147 + EmployeeType: companyUserAddCommand.EmployeeType,
144 Password: initPassword, 148 Password: initPassword,
145 }) 149 })
146 if err != nil { 150 if err != nil {
@@ -181,7 +185,7 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co @@ -181,7 +185,7 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co
181 func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (int64, interface{}, error) { 185 func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (int64, interface{}, error) {
182 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) 186 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
183 result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ 187 result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
184 - Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize, 188 + Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize,
185 Limit: companyUserListQuery.PageSize, 189 Limit: companyUserListQuery.PageSize,
186 CompanyId: companyUserListQuery.Operator.CompanyId, 190 CompanyId: companyUserListQuery.Operator.CompanyId,
187 OrganizationId: 0, 191 OrganizationId: 0,
@@ -214,6 +218,8 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co @@ -214,6 +218,8 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co
214 UserId: strconv.Itoa(v.UserId), 218 UserId: strconv.Itoa(v.UserId),
215 UserName: v.UserInfo.UserName, 219 UserName: v.UserInfo.UserName,
216 UserType: v.UserType, 220 UserType: v.UserType,
  221 + EmployeeType: v.UserInfo.EmployeeType,
  222 + IcCardNumber: v.UserInfo.IcCardNumber,
217 } 223 }
218 if v.Org.OrgId == int(companyUserListQuery.Operator.OrgId) { 224 if v.Org.OrgId == int(companyUserListQuery.Operator.OrgId) {
219 item.AuthFlag = true 225 item.AuthFlag = true
@@ -280,6 +286,8 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co @@ -280,6 +286,8 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
280 Phone: companyUserUpdateCommand.Phone, 286 Phone: companyUserUpdateCommand.Phone,
281 Avatar: companyUserUpdateCommand.Avatar, 287 Avatar: companyUserUpdateCommand.Avatar,
282 Email: companyUserUpdateCommand.Email, 288 Email: companyUserUpdateCommand.Email,
  289 + EmployeeType: companyUserUpdateCommand.EmployeeType,
  290 + IcCardNumber: companyUserUpdateCommand.IcCardNumber,
283 }) 291 })
284 if err != nil { 292 if err != nil {
285 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 293 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -27,6 +27,9 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creatio @@ -27,6 +27,9 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creatio
27 //天联共创业务模块 27 //天联共创业务模块
28 var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com" 28 var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com"
29 29
  30 +// 天联共创 生产制造模块
  31 +var ALLIED_CREATION_MANUFACTURE_HOST = "http://localhost:8083"
  32 +
30 // 版本更新模块 33 // 版本更新模块
31 var SUPLUS_ADMIN_BASE_HOST = "http://suplus-admin-base-dev.fjmaimaimai.com" 34 var SUPLUS_ADMIN_BASE_HOST = "http://suplus-admin-base-dev.fjmaimaimai.com"
32 35
@@ -41,6 +44,10 @@ var SMSCODE_ALL_POWER = "999512" @@ -41,6 +44,10 @@ var SMSCODE_ALL_POWER = "999512"
41 44
42 var EnableBlockChain = true 45 var EnableBlockChain = true
43 46
  47 +// 天联共创 成本结构化
  48 +var COST_STRUCTURED = "http://cost-structured-dev.fjmaimaimai.com"
  49 +//var COST_STRUCTURED = "http://localhost:8085"
  50 +
44 func init() { 51 func init() {
45 if os.Getenv("LOG_LEVEL") != "" { 52 if os.Getenv("LOG_LEVEL") != "" {
46 LOG_LEVEL = os.Getenv("LOG_LEVEL") 53 LOG_LEVEL = os.Getenv("LOG_LEVEL")
@@ -63,6 +70,9 @@ func init() { @@ -63,6 +70,9 @@ func init() {
63 if os.Getenv("ALLIED_CREATION_COOPERATION_HOST") != "" { 70 if os.Getenv("ALLIED_CREATION_COOPERATION_HOST") != "" {
64 ALLIED_CREATION_COOPERATION_HOST = os.Getenv("ALLIED_CREATION_COOPERATION_HOST") 71 ALLIED_CREATION_COOPERATION_HOST = os.Getenv("ALLIED_CREATION_COOPERATION_HOST")
65 } 72 }
  73 + if os.Getenv("ALLIED_CREATION_MANUFACTURE_HOST") != "" {
  74 + ALLIED_CREATION_MANUFACTURE_HOST = os.Getenv("ALLIED_CREATION_MANUFACTURE_HOST")
  75 + }
66 if os.Getenv("SMS_SERVE_HOST") != "" { 76 if os.Getenv("SMS_SERVE_HOST") != "" {
67 SMS_SERVE_HOST = os.Getenv("SMS_SERVE_HOST") 77 SMS_SERVE_HOST = os.Getenv("SMS_SERVE_HOST")
68 } 78 }
@@ -75,4 +85,7 @@ func init() { @@ -75,4 +85,7 @@ func init() {
75 if os.Getenv("SUPLUS_SALE_APP") != "" { 85 if os.Getenv("SUPLUS_SALE_APP") != "" {
76 SUPLUS_SALE_APP = os.Getenv("SUPLUS_SALE_APP") 86 SUPLUS_SALE_APP = os.Getenv("SUPLUS_SALE_APP")
77 } 87 }
  88 + if os.Getenv("COST_STRUCTURED") != "" {
  89 + COST_STRUCTURED = os.Getenv("COST_STRUCTURED")
  90 + }
78 } 91 }
  1 +package constant
  2 +
  3 +import (
  4 + "os"
  5 + "strconv"
  6 +)
  7 +
  8 +var (
  9 + // 生产制造 - 称重系统 - 默认公司
  10 + MANUFACTURE_WEIGH_DEFAULT_COMPANYID = 1
  11 + // 生产制造 - 称重系统 - 默认组织
  12 + MANUFACTURE_WEIGH_DEFAULT_ORGID = 1
  13 +)
  14 +
  15 +func init() {
  16 + if os.Getenv("MANUFACTURE_WEIGH_DEFAULT_COMPANYID") != "" {
  17 + MANUFACTURE_WEIGH_DEFAULT_COMPANYID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_WEIGH_DEFAULT_COMPANYID"))
  18 + }
  19 + if os.Getenv("MANUFACTURE_WEIGH_DEFAULT_ORGID") != "" {
  20 + MANUFACTURE_WEIGH_DEFAULT_ORGID, _ = strconv.Atoi(os.Getenv("MANUFACTURE_WEIGH_DEFAULT_ORGID"))
  21 + }
  22 +}
  1 +package constant
  2 +
  3 +const OssAccessKey = "LTAI4Fz1LUBW2fXp6QWaJHRS"
  4 +
  5 +const OssSecret = "aLZXwK8pgrs10Ws03qcN7NsrSXFVsg"
  6 +
  7 +var OssBucket = "timeless-world"
  8 +
  9 +const OssDomain = "http://timeless-world.oss-cn-shenzhen.aliyuncs.com"
@@ -2,11 +2,18 @@ package constant @@ -2,11 +2,18 @@ package constant
2 2
3 import "os" 3 import "os"
4 4
5 -var POSTGRESQL_DB_NAME = "terms" 5 +//var POSTGRESQL_DB_NAME = "terms"
  6 +//var POSTGRESQL_USER = "postgres"
  7 +//var POSTGRESQL_PASSWORD = "123456"
  8 +//var POSTGRESQL_HOST = "127.0.0.1"
  9 +//var POSTGRESQL_PORT = "5432"
  10 +//var DISABLE_CREATE_TABLE = false
  11 +//var DISABLE_SQL_GENERATE_PRINT = false
  12 +var POSTGRESQL_DB_NAME = "allied_creation_dev"
6 var POSTGRESQL_USER = "postgres" 13 var POSTGRESQL_USER = "postgres"
7 var POSTGRESQL_PASSWORD = "123456" 14 var POSTGRESQL_PASSWORD = "123456"
8 -var POSTGRESQL_HOST = "127.0.0.1"  
9 -var POSTGRESQL_PORT = "5432" 15 +var POSTGRESQL_HOST = "114.55.200.59"
  16 +var POSTGRESQL_PORT = "31543"
10 var DISABLE_CREATE_TABLE = false 17 var DISABLE_CREATE_TABLE = false
11 var DISABLE_SQL_GENERATE_PRINT = false 18 var DISABLE_SQL_GENERATE_PRINT = false
12 19
1 package domain 1 package domain
2 2
  3 +// 公司状态状态 1:已注册 2:已通过 3:已拒绝
  4 +const (
  5 + CompanyRegistered = iota + 1
  6 + CompanyAuthenticated
  7 + CompanyUnauthenticated
  8 +)
  9 +
3 //公司 10 //公司
4 type CompanyData struct { 11 type CompanyData struct {
5 CompanyID int `json:"companyId"` 12 CompanyID int `json:"companyId"`
@@ -12,3 +19,10 @@ type Company struct { @@ -12,3 +19,10 @@ type Company struct {
12 Logo string `json:"logo"` 19 Logo string `json:"logo"`
13 CompanyName string `json:"companyName"` 20 CompanyName string `json:"companyName"`
14 } 21 }
  22 +
  23 +// 营业执照所在地
  24 +type BusinessLicenseAddress struct {
  25 + Province string `json:"province"`
  26 + City string `json:"city"`
  27 + Address string `json:"address"`
  28 +}
  1 +package domain
  2 +
  3 +import "strings"
  4 +
  5 +type BatchCreateCostManagemant struct {
  6 + UserId int64 `cname:"操作人id" json:"UserId" valid:"Required"`
  7 + // 公司id
  8 + CompanyId int64 `cname:"公司id" json:"companyId" valid:"Required"`
  9 + // 项目id
  10 + ProjectId int64 `cname:"项目id" json:"projectId,string"`
  11 + // 项目名称
  12 + ProjectName string `cname:"项目名称" json:"projectName" valid:"Required"`
  13 + // 项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌
  14 + Types int `cname:"项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌" json:"types" valid:"Required"`
  15 + //成本數組
  16 + CostManagemants []*CostManagemant `cname:"成本数组" json:"costManagemants" valid:"Required"`
  17 +}
  18 +
  19 +// 成本管理
  20 +type CostManagemant struct {
  21 + // 项目编码
  22 + ProjectCode string `json:"projectCode"`
  23 + // 成本管理Id
  24 + CostManagemantId int64 `json:"costManagemantId,string"`
  25 + // 公式id
  26 + CompanyId int64 `json:"companyId,string"`
  27 + // 标杆值,字符串,如果纯数字的时候参与计算
  28 + Benchmark string `json:"benchmark"`
  29 + // 负责人数组
  30 + ChargePersons []string `json:"chargePersons"`
  31 + // 历史最高值,字符串,如果纯数字的时候参与计算
  32 + Highest string `json:"highest"`
  33 + // 细项名称
  34 + ItemName string `json:"itemName"`
  35 + // 级别
  36 + Level int `json:"level"`
  37 + // 父id
  38 + ParentId int64 `json:"parentId,string"`
  39 + // 现状值,字符串,如果纯数字的时候参与计算
  40 + Present string `json:"present"`
  41 + // 当前选择的节点类型 1、combination 组合框 2、staff 员工选取 3、text 文本框 4、BOM BOM表
  42 + // 5、number数值框 6、calculate计算框
  43 + ChoiceId int `cname:"当前选择的节点类型 1、combination 组合框 2、staff 员工选取 3、text 文本框 4、BOM BOM表 5、number数值框 6、calculate计算框" json:"choiceId"`
  44 + // 文本内容
  45 + Text string `cname:"文本内容" json:"text"`
  46 + // 图片
  47 + Urls []string `cname:"图片" json:"urls"`
  48 + // calculate 计算框:计算框公式
  49 + Formula string `cname:"calculate 计算框:计算框公式" json:"formula" `
  50 + // 项目id
  51 + //ProjectId int64 `json:"projectId,string"`
  52 + // 项目名称
  53 + ProjectName string `json:"projectName"`
  54 + // 进度计划比,字符串,如果纯数字的时候参与计算
  55 + SchedulePlanPercent string `json:"schedulePlanPercent"`
  56 + // 结构类型
  57 + //StructureType int `json:"structureType"`
  58 + // 目标值 字符串 为数字时 参与计算
  59 + Target string `json:"target"`
  60 + // 目标值期限 1 第一季度 2第二季度 3第三季度 4第四季度 5 年度
  61 + TargetPeriod int `json:"targetPeriod"`
  62 + // 顶级成本管理id
  63 + TopCostManagemantId int64 `json:"topCostManagemantId,string"`
  64 + // 项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌
  65 + Types int `json:"types"`
  66 + // 昨日实际值
  67 + YesterdayActual string `json:"yesterdayActual"`
  68 +}
  69 +
  70 +type NodeType struct {
  71 + TypeId int
  72 + TypeName string
  73 +}
  74 +
  75 +var NodeTypeGroup = []NodeType{
  76 + {TypeId: 1, TypeName: "组合框"},
  77 + {TypeId: 2, TypeName: "员工类型"},
  78 + {TypeId: 3, TypeName: "文本类型"},
  79 + {TypeId: 4, TypeName: "BOM表类型"},
  80 + {TypeId: 5, TypeName: "数值类型"},
  81 + {TypeId: 6, TypeName: "计算类型"},
  82 + {TypeId: 7, TypeName: "图片类型"},
  83 +}
  84 +
  85 +func (NodeType) GetIdByName(name string) int {
  86 + group := NodeTypeGroup
  87 + for _, item := range group {
  88 + if item.TypeName == name {
  89 + return item.TypeId
  90 + }
  91 + }
  92 + return 0
  93 +}
  94 +
  95 +func GetTargetPeriod(targetPeriod string) int {
  96 + targetPeriod = strings.TrimSpace(targetPeriod)
  97 + switch targetPeriod {
  98 + case "年度":
  99 + return 5
  100 + case "第一季度":
  101 + return 1
  102 + case "第二季度":
  103 + return 2
  104 + case "第三季度":
  105 + return 3
  106 + case "第四季度":
  107 + return 4
  108 + case "":
  109 + return 0
  110 + }
  111 + return -1
  112 +}
@@ -3,10 +3,11 @@ package domain @@ -3,10 +3,11 @@ package domain
3 /***** 1.用户模块 *****/ 3 /***** 1.用户模块 *****/
4 // 用户类型 4 // 用户类型
5 const ( 5 const (
6 - UserTypeEmployee = 1  
7 - UserTypeCooperation = 2  
8 - UserTypeVisitor = 4  
9 - UserTypeCompanyAdmin = 1024 6 + UserTypeEmployee = 1
  7 + UserTypeCooperation = 2
  8 + UserTypeVisitor = 4
  9 + UserTypeOperationAdmin = 8
  10 + UserTypeCompanyAdmin = 1024
10 ) 11 )
11 12
12 // 用户状态 13 // 用户状态
@@ -62,6 +63,13 @@ const ( @@ -62,6 +63,13 @@ const (
62 ImportDividendsOrders = "BUSINESS_ALLIED-CREATION_BONUS_ORDER" 63 ImportDividendsOrders = "BUSINESS_ALLIED-CREATION_BONUS_ORDER"
63 // 导入退货订单 64 // 导入退货订单
64 ImportDividendsReturnOrders = "BUSINESS_ALLIED-CREATION_BONUS_RETURN" 65 ImportDividendsReturnOrders = "BUSINESS_ALLIED-CREATION_BONUS_RETURN"
  66 +
  67 + // 导入产品
  68 + ImportProducts = "BUSINESS_ALLIED-MANUFACTURING_BASIC_PRODUCT"
  69 + // 导入设备
  70 + ImportDevices = "BUSINESS_ALLIED-MANUFACTURING_BASIC_DEVICE"
  71 + //导入成本结构
  72 + ImportCosts = "BUSINESS_ALLIED-COST"
65 ) 73 )
66 74
67 const ( 75 const (
@@ -69,6 +77,20 @@ const ( @@ -69,6 +77,20 @@ const (
69 ExportCompanyUser = "ExportCompanyUser" 77 ExportCompanyUser = "ExportCompanyUser"
70 // 导入共创用户 78 // 导入共创用户
71 ExportCooperationUser = "ExportCooperationUser" 79 ExportCooperationUser = "ExportCooperationUser"
  80 +
  81 + // 导入产品
  82 + ExportProducts = "ExportProducts"
  83 + // 导出员工产能统计
  84 + ExportManufactureEmployeeProductive = "ExportManufactureEmployeeProductive"
  85 + // 导出车间产能统计
  86 + ExportManufactureWorkshopProductive = "ExportManufactureWorkshopProductive"
  87 + // 报废记录
  88 + ExportSecondLevelRecord = "ExportSecondLevelRecord"
  89 +
  90 + // 员工工时
  91 + ExportManufactureEmployeeAttendanceStatics = "ExportManufactureEmployeeAttendanceStatics"
  92 + // 车间工时
  93 + ExportManufactureWorkshopAttendanceStatics = "ExportManufactureWorkshopAttendanceStatics"
72 ) 94 )
73 95
74 const ( 96 const (
@@ -80,3 +102,54 @@ const ( @@ -80,3 +102,54 @@ const (
80 BlockChainSourceCooperationProject = "allied-creation.cooperation.project" 102 BlockChainSourceCooperationProject = "allied-creation.cooperation.project"
81 BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate" 103 BlockChainSourceCooperationDividendsEstimate = "allied-creation.cooperation.dividends-estimate"
82 ) 104 )
  105 +
  106 +const (
  107 + DefaultPassword = "4a693460c4cf078ea5b6b5a9e2cf382064a6f810" // TL123456!
  108 +)
  109 +
  110 +func EmployeeTypeDescription(employeeType int) string {
  111 + if employeeType == 1 {
  112 + return "固定"
  113 + }
  114 + if employeeType == 2 {
  115 + return "派遣"
  116 + }
  117 + if employeeType == 3 {
  118 + return "临时"
  119 + }
  120 + return "固定"
  121 +}
  122 +
  123 +func ParticipateTypeDescription(participateType int) string {
  124 + if participateType == 1 {
  125 + return "正常"
  126 + }
  127 + if participateType == 2 {
  128 + return "支援"
  129 + }
  130 + return "正常"
  131 +}
  132 +
  133 +// 班次
  134 +const (
  135 + WorkOnFullDay = 1 //全天
  136 + WorkOnDay = 2 //白班
  137 + WorkOnMidDay = 4 //中班
  138 + WorkOnNight = 8 //夜班
  139 +)
  140 +
  141 +func WorkOnDescription(workOn int) string {
  142 + if workOn&WorkOnFullDay > 0 {
  143 + return "全天"
  144 + }
  145 + if workOn&WorkOnDay > 0 {
  146 + return "白班"
  147 + }
  148 + if workOn&WorkOnMidDay > 0 {
  149 + return "中班"
  150 + }
  151 + if workOn&WorkOnNight > 0 {
  152 + return "夜班"
  153 + }
  154 + return ""
  155 +}
  1 +package domain
  2 +
  3 +// 导入数据体
  4 +type ImportProductItem struct {
  5 + // 产品编号 编码规则为“CP”+2 位年+2 位月+2 位日+3 位流水码,如 CP211229001
  6 + ProductCode string `json:"productCode,omitempty"`
  7 + // 产品名称
  8 + ProductName string `json:"productName,omitempty"`
  9 + // 产品类别
  10 + ProductCategory string `json:"productCategory,omitempty"`
  11 + // 单位
  12 + Unit string `json:"unit,omitempty"`
  13 + // 单份重量(原材料)
  14 + UnitWeight string `json:"unitWeight,omitempty"`
  15 + // 失败理由
  16 + FailReason string `json:"failReason"`
  17 +}
  18 +
  19 +// 导入设备数据体
  20 +type ImportDeviceItem struct {
  21 + // 设备编号
  22 + DeviceCode string `json:"deviceCode,omitempty"`
  23 + // 设备名称
  24 + DeviceName string `json:"deviceName,omitempty"`
  25 + // 设备型号
  26 + DeviceModel string `json:"deviceModel,omitempty"`
  27 + // 设备类型
  28 + DeviceType string `json:"deviceType,omitempty"`
  29 + // 品牌
  30 + Brand string `json:"brand,omitempty"`
  31 + // 设备状态 1:正常 2:封存 3:报废
  32 + Status string `json:"status,omitempty"`
  33 + // 风险等级 1:高 2:中 3:低
  34 + Level string `json:"level,omitempty"`
  35 + // 失败理由
  36 + FailReason string `json:"failReason"`
  37 +}
@@ -7,8 +7,9 @@ import ( @@ -7,8 +7,9 @@ import (
7 7
8 //登录的平台 8 //登录的平台
9 const ( 9 const (
10 - LoginPlatformApp string = "app"  
11 - LoginPlatformWeb string = "web" 10 + LoginPlatformApp string = "app" //天联共创app
  11 + LoginPlatformWeb string = "web" //天联共创web
  12 + LoginPlatformOperatorWeb string = "operator-web" //天联共创运营-web
12 ) 13 )
13 14
14 const ( 15 const (
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/linmadan/egglib-go/utils/json" 5 "github.com/linmadan/egglib-go/utils/json"
6 "github.com/tal-tech/go-queue/kq" 6 "github.com/tal-tech/go-queue/kq"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
8 "strings" 9 "strings"
9 ) 10 )
10 11
@@ -32,7 +33,13 @@ func Push(topic string, o interface{}) error { @@ -32,7 +33,13 @@ func Push(topic string, o interface{}) error {
32 if pusher, ok = defaultClientMap[topic]; !ok { 33 if pusher, ok = defaultClientMap[topic]; !ok {
33 return fmt.Errorf("pusher client [%v] not found ", topic) 34 return fmt.Errorf("pusher client [%v] not found ", topic)
34 } 35 }
35 - return pusher.Push(json.MarshalToString(o)) 36 + if err := pusher.Push(json.MarshalToString(o)); err != nil {
  37 + log.Logger.Debug(fmt.Sprintf("Topic:%v error:%v", topic, err.Error()), map[string]interface{}{"value": o})
  38 + return err
  39 + } else {
  40 + log.Logger.Debug(fmt.Sprintf("Topic:%v 发送成功", topic), map[string]interface{}{"value": o})
  41 + }
  42 + return nil
36 } 43 }
37 44
38 // 新建一个推送对象 45 // 新建一个推送对象
  1 +package allied_creation_manufacture
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
  10 +)
  11 +
  12 +//HttpLibAlliedCreationManufacture 生产制造模块
  13 +type HttpLibAlliedCreationManufacture struct {
  14 + service_gateway.BaseServiceGateway
  15 + baseUrL string
  16 +}
  17 +
  18 +func NewHttpLibAlliedCreationManufacture(operator domain.Operator) *HttpLibAlliedCreationManufacture {
  19 + return &HttpLibAlliedCreationManufacture{
  20 + BaseServiceGateway: service_gateway.BaseServiceGateway{
  21 + ConnectTimeout: 100 * time.Second,
  22 + ReadWriteTimeout: 100 * time.Second,
  23 + CompanyId: operator.CompanyId,
  24 + OrgId: operator.OrgId,
  25 + InOrgIds: operator.OrgIds,
  26 + UserId: operator.UserId,
  27 + UserBaseId: operator.UserBaseId,
  28 + },
  29 + baseUrL: constant.ALLIED_CREATION_MANUFACTURE_HOST,
  30 + }
  31 +
  32 +}
  33 +
  34 +func (gateway HttpLibAlliedCreationManufacture) BaseUrl() string {
  35 + return gateway.baseUrL
  36 +}
  37 +
  38 +//BatchAddProduct 批量添加产品
  39 +func (gateway HttpLibAlliedCreationManufacture) BatchAddProduct(param BatchAddProductRequest) (*BatchAddProductResponse, error) {
  40 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/products/batch-add")
  41 + method := "post"
  42 + var data BatchAddProductResponse
  43 + err := gateway.FastDoRequest(url, method, param, &data)
  44 + return &data, err
  45 +}
  46 +
  47 +type BatchAddProductRequest struct {
  48 + List []*domain.ImportProductItem `json:"list"`
  49 +}
  50 +type BatchAddProductResponse []interface{}
  51 +
  52 +//SearchProduct 搜索产品
  53 +func (gateway HttpLibAlliedCreationManufacture) SearchProduct(param SearchProductRequest) (*SearchProductResponse, error) {
  54 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/products/search")
  55 + method := "post"
  56 + var data SearchProductResponse
  57 + err := gateway.FastDoRequest(url, method, param, &data)
  58 + return &data, err
  59 +}
  60 +
  61 +type (
  62 + SearchProductRequest struct {
  63 + // 页码
  64 + PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
  65 + // 页数
  66 + PageSize int `cname:"页数" json:"pageSize,omitempty"`
  67 + // 产品名称
  68 + ProductName string `json:"productName,omitempty"`
  69 + // 产品类别
  70 + ProductCategory string `cname:"产品类别" json:"productCategory"`
  71 + }
  72 + SearchProductResponse struct {
  73 + Grid struct {
  74 + List []SearchProductItem `json:"list"`
  75 + Total int `json:"total"`
  76 + } `json:"grid"`
  77 + }
  78 + SearchProductItem struct {
  79 + ProductID int `json:"productId"`
  80 + ProductCode string `json:"productCode"`
  81 + ProductName string `json:"productName"`
  82 + ProductCategory string `json:"productCategory"`
  83 + Unit string `json:"unit"`
  84 + UnitWeight float64 `json:"unitWeight"`
  85 + }
  86 +)
  87 +
  88 +/*设备*/
  89 +
  90 +//BatchAddProduct 批量添加产品
  91 +func (gateway HttpLibAlliedCreationManufacture) BatchAddDevice(param BatchAddDeviceRequest) (*BatchAddProductResponse, error) {
  92 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/devices/batch-add")
  93 + method := "post"
  94 + var data BatchAddProductResponse
  95 + err := gateway.FastDoRequest(url, method, param, &data)
  96 + return &data, err
  97 +}
  98 +
  99 +type BatchAddDeviceRequest struct {
  100 + List []*domain.ImportDeviceItem `json:"list"`
  101 +}
  102 +type BatchAddDeviceResponse []interface{}
  103 +
  104 +/**生产记录**/
  105 +//SearchProduct 搜索员工产能统计
  106 +func (gateway HttpLibAlliedCreationManufacture) SearchEmployeeProductive(param SearchEmployeeProductiveRequest) (*SearchEmployeeProductiveResponse, error) {
  107 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/employee-productive/search")
  108 + method := "post"
  109 + var data SearchEmployeeProductiveResponse
  110 + err := gateway.FastDoRequest(url, method, param, &data)
  111 + return &data, err
  112 +}
  113 +
  114 +type (
  115 + SearchEmployeeProductiveRequest struct {
  116 + // 页码
  117 + //PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
  118 + // 页数
  119 + //PageSize int `cname:"页数" json:"pageSize,omitempty"`
  120 + // 车间名称
  121 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  122 + // 生产线名称
  123 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  124 + // 工段名称
  125 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  126 + // 姓名
  127 + UserName string `cname:"姓名" json:"userName"`
  128 + // 员工类型 1:固定 2:派遣 3.临时
  129 + EmployeeType string `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
  130 + // 开始时间
  131 + BeginTime string `cname:"开始时间" json:"beginTime"`
  132 + // 结束时间
  133 + EndTime string `cname:"结束时间" json:"endTime"`
  134 + }
  135 + SearchEmployeeProductiveResponse struct {
  136 + Grid struct {
  137 + List []EmployeeProductiveItem `json:"list"`
  138 + Total int `json:"total"`
  139 + } `json:"grid"`
  140 + }
  141 + EmployeeProductiveItem struct {
  142 + EmployeeProductRecordID int `json:"employeeProductRecordId"`
  143 + ProductWorker struct {
  144 + UserID int `json:"userId"`
  145 + UserName string `json:"userName"`
  146 + Avatar string `json:"avatar"`
  147 + Phone string `json:"phone"`
  148 + EmployeeType int `json:"employeeType"`
  149 + } `json:"productWorker"`
  150 + WorkStationID string `json:"workStationId"`
  151 + WorkshopID int `json:"workshopId"`
  152 + WorkshopName string `json:"workshopName"`
  153 + LineID int `json:"lineId"`
  154 + LineName string `json:"lineName"`
  155 + SectionID int `json:"sectionId"`
  156 + SectionName string `json:"sectionName"`
  157 + WorkOn string `json:"workOn"`
  158 + PlanProductName string `json:"planProductName"`
  159 + BatchNumber string `json:"batchNumber"`
  160 + ParticipateType int `json:"participateType"`
  161 + ProductWeigh float64 `json:"productWeigh"`
  162 + SecondLevelWeigh float64 `json:"secondLevelWeigh"`
  163 + CreatedAt string `json:"createdAt"`
  164 + OrgName string `json:"orgName"`
  165 + AuthFlag bool `json:"authFlag"`
  166 + QualificationRate int `json:"qualificationRate"`
  167 + }
  168 +)
  169 +
  170 +//SearchProduct 搜索员工产能统计
  171 +func (gateway HttpLibAlliedCreationManufacture) SearchWorkshopProductive(param SearchWorkshopProductiveRequest) (*SearchWorkshopProductiveResponse, error) {
  172 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/workshop-productive/search")
  173 + method := "post"
  174 + var data SearchWorkshopProductiveResponse
  175 + err := gateway.FastDoRequest(url, method, param, &data)
  176 + return &data, err
  177 +}
  178 +
  179 +type (
  180 + SearchWorkshopProductiveRequest struct {
  181 + // 品名
  182 + PlanProductName string `cname:"品名" json:"planProductName,omitempty"`
  183 + // 工段名称
  184 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  185 + // 开始时间
  186 + BeginTime string `cname:"开始时间" json:"beginTime"`
  187 + // 结束时间
  188 + EndTime string `cname:"结束时间" json:"endTime"`
  189 + }
  190 + SearchWorkshopProductiveResponse struct {
  191 + Grid struct {
  192 + List []WorkshopProductiveItem `json:"list"`
  193 + Total int `json:"total"`
  194 + } `json:"grid"`
  195 + }
  196 + WorkshopProductiveItem struct {
  197 + EmployeeProductRecordID int `json:"employeeProductRecordId"`
  198 + ProductWorker struct {
  199 + UserID int `json:"userId"`
  200 + UserName string `json:"userName"`
  201 + Avatar string `json:"avatar"`
  202 + Phone string `json:"phone"`
  203 + EmployeeType int `json:"employeeType"`
  204 + } `json:"productWorker"`
  205 + WorkStationID string `json:"workStationId"`
  206 + WorkshopID int `json:"workshopId"`
  207 + WorkshopName string `json:"workshopName"`
  208 + LineID int `json:"lineId"`
  209 + LineName string `json:"lineName"`
  210 + SectionID int `json:"sectionId"`
  211 + SectionName string `json:"sectionName"`
  212 + WorkOn string `json:"workOn"`
  213 + PlanProductName string `json:"planProductName"`
  214 + BatchNumber string `json:"batchNumber"`
  215 + //ParticipateType int `json:"participateType"`
  216 + // 投入量
  217 + DevotedProductWeigh float64 `json:"devotedProductWeigh"`
  218 + // 产能
  219 + ProductWeigh float64 `json:"productWeigh"`
  220 + // 二级品产能
  221 + SecondLevelWeigh float64 `json:"secondLevelWeigh"`
  222 + CreatedAt string `json:"createdAt"`
  223 + OrgName string `json:"orgName"`
  224 + AuthFlag bool `json:"authFlag"`
  225 + QualificationRate int `json:"qualificationRate"`
  226 + }
  227 +)
  228 +
  229 +//SearchProduct 搜索员工产能统计
  230 +func (gateway HttpLibAlliedCreationManufacture) SearchSecondLevelRecord(param SearchSecondLevelRecordRequest) (*SearchSecondLevelRecordResponse, error) {
  231 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/second-level-record/search")
  232 + method := "post"
  233 + var data SearchSecondLevelRecordResponse
  234 + err := gateway.FastDoRequest(url, method, param, &data)
  235 + return &data, err
  236 +}
  237 +
  238 +type (
  239 + SearchSecondLevelRecordRequest struct {
  240 + // 车间名称
  241 + WorkshopName string `cname:"车间名称" json:"workshopName"`
  242 + // 批号
  243 + BatchNumber string `cname:"批号" json:"batchNumber"`
  244 + // 姓名
  245 + UserName string `cname:"姓名" json:"userName"`
  246 + // 生产记录类型:1:领料 2:退料 4:称重 8:二级品称重
  247 + //ProductRecordType int `cname:"生产记录类型:1:领料 2:退料 4:称重 8:二级品称重"`
  248 + // 生产线名称
  249 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  250 + // 工段名称
  251 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  252 + // 员工类型 1:固定 2:派遣 3.临时
  253 + EmployeeType int `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
  254 + // 开始时间
  255 + BeginTime string `cname:"开始时间" json:"beginTime"`
  256 + // 结束时间
  257 + EndTime string `cname:"结束时间" json:"endTime"`
  258 + }
  259 + SearchSecondLevelRecordResponse struct {
  260 + Grid struct {
  261 + List []SecondLevelRecordItem `json:"list"`
  262 + Total int `json:"total"`
  263 + } `json:"grid"`
  264 + }
  265 + SecondLevelRecordItem struct {
  266 + ProductRecordID int `json:"productRecordId"`
  267 + ProductWorker struct {
  268 + UserID int `json:"userId"`
  269 + UserName string `json:"userName"`
  270 + EmployeeType int `json:"employeeType"`
  271 + Phone string `json:"phone"`
  272 + } `json:"productWorker"`
  273 + WorkStationID string `json:"workStationId"`
  274 + WorkshopID int `json:"workshopId"`
  275 + WorkshopName string `json:"workshopName"`
  276 + LineID int `json:"lineId"`
  277 + LineName string `json:"lineName"`
  278 + SectionID int `json:"sectionId"`
  279 + SectionName string `json:"sectionName"`
  280 + WorkOn int `json:"workOn"`
  281 + WeightBefore int `json:"weightBefore"`
  282 + WeightAfter int `json:"weightAfter"`
  283 + ApproveStatus int `json:"approveStatus"`
  284 + ApproveUser struct {
  285 + UserID int `json:"userId"`
  286 + UserName string `json:"userName"`
  287 + } `json:"approveUser"`
  288 + ApproveAt string `json:"approveAt"`
  289 + PlanProductName string `json:"planProductName"`
  290 + BatchNumber string `json:"batchNumber"`
  291 + CreatedDate string `json:"createdDate"`
  292 + CreatedAt string `json:"createdAt"`
  293 + OrgName string `json:"orgName"`
  294 + AuthFlag bool `json:"authFlag"`
  295 + }
  296 +)
  297 +
  298 +/*** 考勤记录 ***/
  299 +//SearchEmployeeAttendanceStatics 搜索员工工时统计
  300 +func (gateway HttpLibAlliedCreationManufacture) SearchEmployeeAttendanceStatics(param SearchEmployeeAttendanceStaticsRequest) (*SearchEmployeeAttendanceStaticsResponse, error) {
  301 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/employee-attendance-statics/search")
  302 + method := "post"
  303 + var data SearchEmployeeAttendanceStaticsResponse
  304 + err := gateway.FastDoRequest(url, method, param, &data)
  305 + return &data, err
  306 +}
  307 +
  308 +type (
  309 + SearchEmployeeAttendanceStaticsRequest struct {
  310 + // 车间名称
  311 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  312 + // 生产线名称
  313 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  314 + // 工段名称
  315 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  316 + // 姓名
  317 + UserName string `cname:"姓名" json:"userName,omitempty"`
  318 + // 考勤状态 1.未审核 2:已审核 4.自动审核
  319 + AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 4.自动审核" json:"attendanceStatus,omitempty"`
  320 + // 开始时间
  321 + BeginTime string `cname:"开始时间" json:"beginTime"`
  322 + // 结束时间
  323 + EndTime string `cname:"结束时间" json:"endTime"`
  324 + }
  325 + SearchEmployeeAttendanceStaticsResponse struct {
  326 + Grid struct {
  327 + List []SearchEmployeeAttendanceStaticsItem `json:"list"`
  328 + Total int `json:"total"`
  329 + } `json:"grid"`
  330 + }
  331 + SearchEmployeeAttendanceStaticsItem struct {
  332 + ProductAttendanceID int `json:"productAttendanceId"`
  333 + SignDate string `json:"signDate"`
  334 + WorkStationID string `json:"workStationId"`
  335 + WorkshopID int `json:"workshopId"`
  336 + WorkshopName string `json:"workshopName"`
  337 + LineID int `json:"lineId"`
  338 + LineName string `json:"lineName"`
  339 + SectionID int `json:"sectionId"`
  340 + SectionName string `json:"sectionName"`
  341 + ProductWorker struct {
  342 + UserID int `json:"userId"`
  343 + UserName string `json:"userName"`
  344 + EmployeeType int `json:"employeeType"`
  345 + Avatar string `json:"avatar"`
  346 + Phone string `json:"phone"`
  347 + } `json:"productWorker"`
  348 + AttendanceType int `json:"attendanceType"`
  349 + AttendanceStatus int `json:"attendanceStatus"`
  350 + AttendanceTypeDescription string `json:"attendanceTypeDescription"`
  351 + EmployeeTypeDescription string `json:"employeeTypeDescription"`
  352 + AttendanceStatusDescription string `json:"attendanceStatusDescription"`
  353 + WorkTime float64 `json:"workTime"`
  354 + OrgName string `json:"orgName"`
  355 + AuthFlag bool `json:"authFlag"`
  356 + }
  357 +)
  358 +
  359 +//SearchEmployeeAttendanceStatics 搜索员工工时统计
  360 +func (gateway HttpLibAlliedCreationManufacture) SearchWorkshopWorkTimeStatics(param SearchWorkshopWorkTimeStaticsRequest) (*SearchWorkshopWorkTimeStaticsResponse, error) {
  361 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/workshop-attendance-statics/search")
  362 + method := "post"
  363 + var data SearchWorkshopWorkTimeStaticsResponse
  364 + err := gateway.FastDoRequest(url, method, param, &data)
  365 + return &data, err
  366 +}
  367 +
  368 +type (
  369 + SearchWorkshopWorkTimeStaticsRequest struct {
  370 + // 车间名称
  371 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  372 + // 生产线名称
  373 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  374 + // 开始时间
  375 + BeginTime string `cname:"开始时间" json:"beginTime"`
  376 + // 结束时间
  377 + EndTime string `cname:"结束时间" json:"endTime"`
  378 + }
  379 + SearchWorkshopWorkTimeStaticsResponse struct {
  380 + Grid struct {
  381 + List []SearchWorkshopWorkTimeStaticsItem `json:"list"`
  382 + Total int `json:"total"`
  383 + } `json:"grid"`
  384 + }
  385 + SearchWorkshopWorkTimeStaticsItem struct {
  386 + WorkshopWorkTimeRecordID int `json:"workshopWorkTimeRecordId"`
  387 + WorkStationID string `json:"workStationId"`
  388 + WorkshopID int `json:"workshopId"`
  389 + WorkshopName string `json:"workshopName"`
  390 + LineID int `json:"lineId"`
  391 + LineName string `json:"lineName"`
  392 + SectionID int `json:"sectionId"`
  393 + SectionName string `json:"sectionName"`
  394 + EftWorkTime float64 `json:"eftWorkTime"`
  395 + EdWorkTime int `json:"edWorkTime"`
  396 + EptWorkTime int `json:"eptWorkTime"`
  397 + RecordDate string `json:"recordDate"`
  398 + OrgName string `json:"orgName"`
  399 + AuthFlag bool `json:"authFlag"`
  400 + }
  401 +)
@@ -28,3 +28,7 @@ func NewHttplibAlliedCreationUser(operator domain.Operator) *HttplibAlliedCreati @@ -28,3 +28,7 @@ func NewHttplibAlliedCreationUser(operator domain.Operator) *HttplibAlliedCreati
28 } 28 }
29 29
30 } 30 }
  31 +
  32 +func (gateway HttplibAlliedCreationUser) BaseUrl() string {
  33 + return gateway.baseUrL
  34 +}
@@ -135,7 +135,7 @@ func (gateway HttplibAlliedCreationUser) CompanyRemove(param ReqCompanyRemove) ( @@ -135,7 +135,7 @@ func (gateway HttplibAlliedCreationUser) CompanyRemove(param ReqCompanyRemove) (
135 135
136 // CompanyGet 返回企业 136 // CompanyGet 返回企业
137 func (gateway HttplibAlliedCreationUser) CompanyGet(param ReqCompanyGet) (*DataCompanyGet, error) { 137 func (gateway HttplibAlliedCreationUser) CompanyGet(param ReqCompanyGet) (*DataCompanyGet, error) {
138 - url := gateway.baseUrL + "/company/{companyId}" 138 + url := gateway.baseUrL + "/company/" + strconv.Itoa(param.CompanyId)
139 method := "GET" 139 method := "GET"
140 req := gateway.CreateRequest(url, method) 140 req := gateway.CreateRequest(url, method)
141 log.Logger.Debug("向用户模块请求数据:返回企业。", map[string]interface{}{ 141 log.Logger.Debug("向用户模块请求数据:返回企业。", map[string]interface{}{
@@ -164,6 +164,66 @@ func (gateway HttplibAlliedCreationUser) CompanyGet(param ReqCompanyGet) (*DataC @@ -164,6 +164,66 @@ func (gateway HttplibAlliedCreationUser) CompanyGet(param ReqCompanyGet) (*DataC
164 return &data, err 164 return &data, err
165 } 165 }
166 166
  167 +func (gateway HttplibAlliedCreationUser) AuditCompany(param ReqCompanyAudit) (DataCompanyAudit, error) {
  168 + url := gateway.baseUrL + fmt.Sprintf("/company/%d/audit", param.CompanyId)
  169 + method := "post"
  170 + req := gateway.CreateRequest(url, method)
  171 + moduleDesc := "审核公司"
  172 + //TODO traceID
  173 + log.Logger.Debug("向用户模块请求数据:"+moduleDesc, map[string]interface{}{
  174 + "api": method + ":" + url,
  175 + "param": param,
  176 + })
  177 + req, err := req.JSONBody(param)
  178 + if err != nil {
  179 + return nil, fmt.Errorf("%v失败:%w", moduleDesc, err)
  180 + }
  181 +
  182 + byteResult, err := req.Bytes()
  183 + if err != nil {
  184 + return nil, fmt.Errorf("%v失败:%w", moduleDesc, err)
  185 + }
  186 +
  187 + var result service_gateway.GatewayResponse
  188 + err = json.Unmarshal(byteResult, &result)
  189 + if err != nil {
  190 + return nil, fmt.Errorf("解析错误:%w", err)
  191 + }
  192 + var data DataCompanyAudit
  193 + err = gateway.GetResponseData(result, &data)
  194 + return data, err
  195 +}
  196 +
  197 +func (gateway HttplibAlliedCreationUser) EnableCompany(param ReqCompanyEnable) (DataCompanyEnable, error) {
  198 + url := gateway.baseUrL + fmt.Sprintf("/company/%d/enable", param.CompanyId)
  199 + method := "post"
  200 + req := gateway.CreateRequest(url, method)
  201 + moduleDesc := "启用公司"
  202 + //TODO traceID
  203 + log.Logger.Debug("向用户模块请求数据:"+moduleDesc, map[string]interface{}{
  204 + "api": method + ":" + url,
  205 + "param": param,
  206 + })
  207 + req, err := req.JSONBody(param)
  208 + if err != nil {
  209 + return nil, fmt.Errorf("%v失败:%w", moduleDesc, err)
  210 + }
  211 +
  212 + byteResult, err := req.Bytes()
  213 + if err != nil {
  214 + return nil, fmt.Errorf("%v失败:%w", moduleDesc, err)
  215 + }
  216 +
  217 + var result service_gateway.GatewayResponse
  218 + err = json.Unmarshal(byteResult, &result)
  219 + if err != nil {
  220 + return nil, fmt.Errorf("解析错误:%w", err)
  221 + }
  222 + var data DataCompanyEnable
  223 + err = gateway.GetResponseData(result, &data)
  224 + return data, err
  225 +}
  226 +
167 // CompanySearch 返回企业列表 227 // CompanySearch 返回企业列表
168 func (gateway HttplibAlliedCreationUser) CompanySearch(param ReqCompanySearch) (*DataCompanySearch, error) { 228 func (gateway HttplibAlliedCreationUser) CompanySearch(param ReqCompanySearch) (*DataCompanySearch, error) {
169 url := gateway.baseUrL + "/company/search" 229 url := gateway.baseUrL + "/company/search"
@@ -430,3 +430,131 @@ func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenu @@ -430,3 +430,131 @@ func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenu
430 err = gateway.GetResponseData(result, &data) 430 err = gateway.GetResponseData(result, &data)
431 return &data, err 431 return &data, err
432 } 432 }
  433 +
  434 +//UserSearch 搜索用户列表
  435 +func (gateway HttplibAlliedCreationUser) UserBaseSearch(param ReqUserBaseSearch) (*DataUserBaseSearch, error) {
  436 + url := gateway.baseUrL + "/user-base/search"
  437 + method := "post"
  438 + req := gateway.CreateRequest(url, method)
  439 + //TODO traceID
  440 + log.Logger.Debug("向用户模块请求数据:搜索用户列表。", map[string]interface{}{
  441 + "api": method + ":" + url,
  442 + "param": param,
  443 + })
  444 + req, err := req.JSONBody(param)
  445 + if err != nil {
  446 + return nil, fmt.Errorf("搜索用户列表失败:%w", err)
  447 + }
  448 +
  449 + byteResult, err := req.Bytes()
  450 + if err != nil {
  451 + return nil, fmt.Errorf("获取搜索用户列表失败:%w", err)
  452 + }
  453 + if param.Limit > 50 {
  454 + //太多就不打印了
  455 + log.Logger.Debug("获取用户模块请求数据:搜索用户列表。", map[string]interface{}{
  456 + "result": string(byteResult),
  457 + })
  458 + }
  459 +
  460 + var result service_gateway.GatewayResponse
  461 + err = json.Unmarshal(byteResult, &result)
  462 + if err != nil {
  463 + return nil, fmt.Errorf("解析搜索用户列表:%w", err)
  464 + }
  465 + var data DataUserBaseSearch
  466 + err = gateway.GetResponseData(result, &data)
  467 + return &data, err
  468 +}
  469 +
  470 +func (gateway HttplibAlliedCreationUser) EnableUserBase(param ReqEnableUserBase) (interface{}, error) {
  471 + url := gateway.baseUrL + "/user-base/batch-enable"
  472 + method := "post"
  473 + req := gateway.CreateRequest(url, method)
  474 + //TODO traceID
  475 + log.Logger.Debug("向用户模块请求数据:搜索用户列表。", map[string]interface{}{
  476 + "api": method + ":" + url,
  477 + "param": param,
  478 + })
  479 + req, err := req.JSONBody(param)
  480 + if err != nil {
  481 + return nil, fmt.Errorf("搜索用户列表失败:%w", err)
  482 + }
  483 +
  484 + byteResult, err := req.Bytes()
  485 + if err != nil {
  486 + return nil, fmt.Errorf("获取搜索用户列表失败:%w", err)
  487 + }
  488 +
  489 + var result service_gateway.GatewayResponse
  490 + err = json.Unmarshal(byteResult, &result)
  491 + if err != nil {
  492 + return nil, fmt.Errorf("解析搜索用户列表:%w", err)
  493 + }
  494 + //var data DataCompanyEnable
  495 + //err = gateway.GetResponseData(result, &data)
  496 + return nil, err
  497 +}
  498 +
  499 +func (gateway HttplibAlliedCreationUser) AdminUserCreate(param ReqCreateUser) (*DataCreateUser, error) {
  500 + url := gateway.baseUrL + "/admin-user"
  501 + method := "post"
  502 + req := gateway.CreateRequest(url, method)
  503 + //TODO traceID
  504 + log.Logger.Debug("向用户模块请求数据:创建用户。", map[string]interface{}{
  505 + "api": method + ":" + url,
  506 + "param": param,
  507 + })
  508 + req, err := req.JSONBody(param)
  509 + if err != nil {
  510 + return nil, fmt.Errorf("创建用户失败:%w", err)
  511 + }
  512 +
  513 + byteResult, err := req.Bytes()
  514 + if err != nil {
  515 + return nil, fmt.Errorf("获取创建用户失败:%w", err)
  516 + }
  517 + log.Logger.Debug("获取用户模块请求数据:创建用户。", map[string]interface{}{
  518 + "result": string(byteResult),
  519 + })
  520 + var result service_gateway.GatewayResponse
  521 + err = json.Unmarshal(byteResult, &result)
  522 + if err != nil {
  523 + return nil, fmt.Errorf("解析创建用户:%w", err)
  524 + }
  525 + var data DataCreateUser
  526 + err = gateway.GetResponseData(result, &data)
  527 + return &data, err
  528 +}
  529 +
  530 +//UserUpdate 更新用户
  531 +func (gateway HttplibAlliedCreationUser) AdminUserUpdate(param ReqUpdateUser) (*DataUpdateUser, error) {
  532 + url := gateway.baseUrL + "/admin-user/" + strconv.Itoa(int(param.UserId))
  533 + method := "put"
  534 + req := gateway.CreateRequest(url, method)
  535 + //TODO traceID
  536 + log.Logger.Debug("向用户模块请求数据:更新用户。", map[string]interface{}{
  537 + "api": method + ":" + url,
  538 + "param": param,
  539 + })
  540 + req, err := req.JSONBody(param)
  541 + if err != nil {
  542 + return nil, fmt.Errorf("请求更新用户失败:%w", err)
  543 + }
  544 +
  545 + byteResult, err := req.Bytes()
  546 + if err != nil {
  547 + return nil, fmt.Errorf("获取更新用户失败:%w", err)
  548 + }
  549 + log.Logger.Debug("获取用户模块请求数据:更新用户。", map[string]interface{}{
  550 + "result": string(byteResult),
  551 + })
  552 + var result service_gateway.GatewayResponse
  553 + err = json.Unmarshal(byteResult, &result)
  554 + if err != nil {
  555 + return nil, fmt.Errorf("解析更新用户:%w", err)
  556 + }
  557 + var data DataUpdateUser
  558 + err = gateway.GetResponseData(result, &data)
  559 + return &data, err
  560 +}
1 package allied_creation_user 1 package allied_creation_user
2 2
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  4 +
3 //企业注册 5 //企业注册
4 type ( 6 type (
5 ReqAuthCompanySignUp struct { 7 ReqAuthCompanySignUp struct {
@@ -9,6 +11,15 @@ type ( @@ -9,6 +11,15 @@ type (
9 Password string `json:"password"` 11 Password string `json:"password"`
10 Phone string `json:"phone"` 12 Phone string `json:"phone"`
11 Scale string `json:"scale"` 13 Scale string `json:"scale"`
  14 +
  15 + // 法人
  16 + LegalPerson string `cname:"法人" json:"legalPerson" valid:"Required"`
  17 + // 社会信用代码
  18 + SocialCreditCode string `cname:"社会信用代码" json:"socialCreditCode" valid:"Required"`
  19 + // 营业执照所在地
  20 + BusinessLicenseAddress domain.BusinessLicenseAddress `cname:"营业执照所在地" json:"businessLicenseAddress" valid:"Required"`
  21 + // 营业执照-附件
  22 + BusinessLicenseAttachments []domain.Attachment `cname:"营业执照-附件" json:"businessLicenseAttachments" valid:"Required"`
12 } 23 }
13 24
14 DataAuthCompanySignUp struct { 25 DataAuthCompanySignUp struct {
1 package allied_creation_user 1 package allied_creation_user
2 2
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "time"
  6 +)
  7 +
3 //创建企业 8 //创建企业
4 type ( 9 type (
5 ReqCompanyCreate struct { 10 ReqCompanyCreate struct {
@@ -49,18 +54,78 @@ type ( @@ -49,18 +54,78 @@ type (
49 //返回企业 54 //返回企业
50 type ( 55 type (
51 ReqCompanyGet struct { 56 ReqCompanyGet struct {
  57 + CompanyId int `json:"companyId"`
52 } 58 }
53 59
54 - DataCompanyGet struct { 60 + DataCompanyGet CompanyItem
  61 +)
  62 +
  63 +type (
  64 + ReqCompanyAudit struct {
  65 + CompanyId int `json:"-"`
  66 + // 审核状态
  67 + Status int `cname:"审核状态" json:"status" valid:"Required"`
  68 + // 备注
  69 + Remark string `cname:"备注" json:"remark" valid:"Required"`
55 } 70 }
  71 +
  72 + DataCompanyAudit map[string]interface{}
  73 +)
  74 +
  75 +type (
  76 + ReqCompanyEnable struct {
  77 + CompanyId int `json:"-"`
  78 + // 审核状态
  79 + Status int `cname:"审核状态" json:"status" valid:"Required"`
  80 + }
  81 +
  82 + DataCompanyEnable map[string]interface{}
56 ) 83 )
57 84
58 //返回企业列表 85 //返回企业列表
59 type ( 86 type (
60 ReqCompanySearch struct { 87 ReqCompanySearch struct {
  88 + // 查询偏离量
  89 + Offset int `cname:"查询偏离量" json:"offset,omitempty"`
  90 + // 查询限制
  91 + Limit int `cname:"查询限制" json:"limit,omitempty"`
  92 + // 状态
  93 + Status int `cname:"状态" json:"status,omitempty"`
  94 + // 企业名称
  95 + CompanyName string `cname:"企业名称" json:"companyName,omitempty"`
61 } 96 }
62 97
63 DataCompanySearch struct { 98 DataCompanySearch struct {
  99 + Companys []CompanyItem `json:"companys"`
  100 + Count int `json:"count"`
  101 + }
  102 +
  103 + CompanyItem struct {
  104 + CompanyId int `json:"companyId"`
  105 + CompanyConfig struct {
  106 + SystemName string `json:"systemName"`
  107 + Theme string `json:"theme"`
  108 + } `json:"companyConfig"`
  109 + CompanyInfo struct {
  110 + CompanyName string `json:"companyName"`
  111 + Scale string `json:"scale"`
  112 + IndustryCategory string `json:"industryCategory"`
  113 + RegisteredTime time.Time `json:"registeredTime"`
  114 + Legal struct {
  115 + LegalPerson string `json:"legalPerson"`
  116 + SocialCreditCode string `json:"socialCreditCode"`
  117 + BusinessLicenseAddress struct {
  118 + Province string `json:"province"`
  119 + City string `json:"city"`
  120 + Address string `json:"address"`
  121 + } `json:"businessLicenseAddress"`
  122 + BusinessLicenseAttachments []domain.Attachment `json:"businessLicenseAttachments"`
  123 + } `json:"legal"`
  124 + Remark string `json:"备注"`
  125 + } `json:"companyInfo"`
  126 + Status int `json:"status"`
  127 + CreatedAt time.Time `json:"createdAt"`
  128 + UpdatedAt time.Time `json:"updatedAt"`
64 } 129 }
65 ) 130 )
66 131
@@ -23,6 +23,10 @@ type UserDetail struct { @@ -23,6 +23,10 @@ type UserDetail struct {
23 Email string `json:"email"` 23 Email string `json:"email"`
24 UserName string `json:"userName"` 24 UserName string `json:"userName"`
25 Avatar string `json:"avatar"` 25 Avatar string `json:"avatar"`
  26 + // 员工类型 1:固定 2:派遣 3.临时
  27 + EmployeeType int `json:"employeeType,omitempty"`
  28 + // IC卡号
  29 + IcCardNumber string `json:"icCardNumber,omitempty"`
26 } `json:"userInfo,omitempty"` 30 } `json:"userInfo,omitempty"`
27 Company *struct { 31 Company *struct {
28 CompanyId int `json:"companyId"` 32 CompanyId int `json:"companyId"`
@@ -69,6 +73,11 @@ type UserDetail struct { @@ -69,6 +73,11 @@ type UserDetail struct {
69 } `json:"im"` 73 } `json:"im"`
70 // 收藏的菜单(工作台)(菜单编码列表) 74 // 收藏的菜单(工作台)(菜单编码列表)
71 FavoriteMenus []string `json:"favoriteMenus"` 75 FavoriteMenus []string `json:"favoriteMenus"`
  76 + Favorite struct {
  77 + OrgItems []int64 `json:"orgItems"`
  78 + Referer string `json:"referer"`
  79 + LastLogInAt int64 `json:"lastLogInAt"`
  80 + } `json:"favorite"`
72 // 创建时间 81 // 创建时间
73 CreatedAt time.Time `json:"createdAt,omitempty"` 82 CreatedAt time.Time `json:"createdAt,omitempty"`
74 } 83 }
@@ -106,6 +115,8 @@ type ( @@ -106,6 +115,8 @@ type (
106 EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"` 115 EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"`
107 // 状态(1:启用 2:禁用 3:注销) 116 // 状态(1:启用 2:禁用 3:注销)
108 InEnableStatus []int `cname:"状态(1:启用 2:禁用 3:注销)" json:"inEnableStatus,omitempty"` 117 InEnableStatus []int `cname:"状态(1:启用 2:禁用 3:注销)" json:"inEnableStatus,omitempty"`
  118 + // 匹配多个公司
  119 + InCompanyIds []interface{} `json:"inCompanyIds,omitempty"`
109 120
110 // 自定义高级查询 121 // 自定义高级查询
111 AdvancedQuery string `json:"advancedQuery"` 122 AdvancedQuery string `json:"advancedQuery"`
@@ -151,6 +162,13 @@ type ( @@ -151,6 +162,13 @@ type (
151 Avatar string `json:"avatar"` 162 Avatar string `json:"avatar"`
152 // 邮箱 163 // 邮箱
153 Email string `json:"email"` 164 Email string `json:"email"`
  165 + // 员工类型 1:固定 2:派遣 3.临时
  166 + EmployeeType int `cname:"员工类型" json:"employeeType" valid:"Required"`
  167 + // IC卡号
  168 + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"`
  169 +
  170 + // 部门
  171 + DepartmentName string `cname:"部门" json:"departmentName"`
154 } 172 }
155 DataCreateUser struct { 173 DataCreateUser struct {
156 UserId int `json:"userId"` 174 UserId int `json:"userId"`
@@ -187,6 +205,13 @@ type ( @@ -187,6 +205,13 @@ type (
187 Avatar string `json:"avatar"` 205 Avatar string `json:"avatar"`
188 // 邮箱 206 // 邮箱
189 Email string `json:"email"` 207 Email string `json:"email"`
  208 + // 员工类型 1:固定 2:派遣 3.临时
  209 + EmployeeType int `cname:"员工类型" json:"employeeType" valid:"Required"`
  210 + // IC卡号
  211 + IcCardNumber string `cname:"IC卡号" json:"icCardNumber,omitempty"`
  212 + // 运营管理扩展
  213 + // 部门
  214 + DepartmentName string `cname:"部门" json:"departmentName"`
190 } 215 }
191 216
192 DataUpdateUser struct { 217 DataUpdateUser struct {
@@ -405,7 +430,65 @@ type ( @@ -405,7 +430,65 @@ type (
405 CooperationCompany string `json:"cooperationCompany"` 430 CooperationCompany string `json:"cooperationCompany"`
406 // 共创到期时间 (yyyy-MM-dd) cooperationDeadline 431 // 共创到期时间 (yyyy-MM-dd) cooperationDeadline
407 CooperationDeadline string `json:"cooperationDeadline"` 432 CooperationDeadline string `json:"cooperationDeadline"`
  433 + // 员工类型 1:固定 2:派遣 3.临时
  434 + EmployeeType string `json:"employeeType,omitempty"`
  435 + // IC卡号
  436 + IcCardNumber string `json:"icCardNumber,omitempty"`
408 // 失败理由 437 // 失败理由
409 FailReason string `json:"failReason"` 438 FailReason string `json:"failReason"`
410 } 439 }
411 ) 440 )
  441 +
  442 +//搜索用户列表
  443 +type (
  444 + ReqUserBaseSearch struct {
  445 + // 查询偏离量
  446 + Offset int `json:"offset"`
  447 + // 查询限制
  448 + Limit int `json:"limit"`
  449 + // 用户姓名
  450 + UserName string `cname:"用户姓名" json:"userName,omitempty"`
  451 + // 在用户列表内
  452 + InUserBaseIds []int64 `cname:"用户姓名" json:"inUserBaseIds,omitempty"`
  453 + // 所属组织
  454 + OrgName string `cname:"所属组织" json:"orgName,omitempty"`
  455 + // 关闭查询限制
  456 + DisableLimit bool `cname:"关闭查询限制" json:"disableLimit,omitempty"`
  457 + // 获取组织
  458 + FetchOrgBelong bool `cname:"获取组织" json:"fetchOrgBelong,omitempty"`
  459 + }
  460 +
  461 + //DataUserSearch 搜索用户列表
  462 + DataUserBaseSearch struct {
  463 + Count int64 `json:"count"`
  464 + Users []UserBaseDetail `json:"users"`
  465 + }
  466 +
  467 + UserBaseDetail struct {
  468 + UserBaseId int `json:"userBaseId"`
  469 + LastLogIn string `json:"lastLogIn"`
  470 + UserInfo struct {
  471 + UserName string `json:"userName"`
  472 + Phone string `json:"phone"`
  473 + Avatar string `json:"avatar"`
  474 + } `json:"userInfo"`
  475 + Status int `json:"status"`
  476 + Referer string `json:"referer"`
  477 + UserOrg []struct {
  478 + OrgId int `json:"orgId"`
  479 + OrgName string `json:"orgName"`
  480 + } `json:"userOrg"`
  481 + RegistrationDate string `json:"registrationDate"`
  482 + }
  483 +)
  484 +
  485 +type (
  486 + ReqEnableUserBase struct {
  487 + UserBaseIds []int64 `cname:"用户id列表" json:"userBaseIds" valid:"Required"`
  488 + // 启用状态(启用:1 禁用:2 注销:3)
  489 + EnableStatus int `cname:"启用状态(启用:1 禁用:2 注销:3)" json:"enableStatus" valid:"Required"`
  490 + }
  491 +
  492 + //DataUserSearch 搜索用户列表
  493 + DataEnableUserBase = interface{}
  494 +)
  1 +package cost_structured
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "strings"
  7 + "time"
  8 +
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
  12 +)
  13 +
  14 +//HttpLibCostStructured 成本结构化
  15 +type HttpLibCostStructured struct {
  16 + service_gateway.BaseServiceGateway
  17 + baseUrL string
  18 +}
  19 +
  20 +func NewHttpLibCostStructured(operator domain.Operator) *HttpLibCostStructured {
  21 + return &HttpLibCostStructured{
  22 + BaseServiceGateway: service_gateway.BaseServiceGateway{
  23 + ConnectTimeout: 100 * time.Second,
  24 + ReadWriteTimeout: 100 * time.Second,
  25 + CompanyId: operator.CompanyId,
  26 + OrgId: operator.OrgId,
  27 + InOrgIds: operator.OrgIds,
  28 + UserId: operator.UserId,
  29 + UserBaseId: operator.UserBaseId,
  30 + },
  31 + baseUrL: constant.COST_STRUCTURED,
  32 + }
  33 +
  34 +}
  35 +
  36 +func (gateway HttpLibCostStructured) BaseUrl() string {
  37 + return gateway.baseUrL
  38 +}
  39 +
  40 +//批量添加成本管理
  41 +func (gateway HttpLibCostStructured) BatchCreateCostManagemant(param BatchAddCostManagemantRequest) (*service_gateway.GatewayResponse, error) {
  42 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/batch-create-cost-managemants")
  43 + method := "post"
  44 + //var data BatchAddCostManagemantResponse
  45 + //err := gateway.FastDoRequest(url, method, param, &data)
  46 +
  47 + r := gateway.CreateRequest(url, method)
  48 + if len(gateway.InOrgIds) > 0 {
  49 + r.Header("orgIds", strings.Join(service_gateway.ToArrayString(gateway.InOrgIds), ","))
  50 + }
  51 + req, err := r.JSONBody(param)
  52 + if err != nil {
  53 + return nil,err
  54 + }
  55 + byteResult, err:= req.Bytes()
  56 + if err != nil {
  57 + return nil,err
  58 + }
  59 + var result service_gateway.GatewayResponse
  60 + err = json.Unmarshal(byteResult, &result)
  61 + if err != nil {
  62 + return nil,err
  63 + }
  64 + return &result, nil
  65 +}
  66 +type BatchAddCostManagemantRequest struct {
  67 + *domain.BatchCreateCostManagemant
  68 +}
  69 +type BatchAddCostManagemantResponse []interface{}
  70 +
  71 +func (gateway HttpLibCostStructured) ListCostManagemant(param ListCostManagemantRequest) (*ListCostManagemantResponse, error) {
  72 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/")
  73 + method := "post"
  74 + var data ListCostManagemantResponse
  75 + err := gateway.FastDoRequest(url, method, param, &data)
  76 + return &data, err
  77 +}
  78 +
  79 +
  80 +
  81 +
  82 +
  83 +
  84 +
  85 +type (
  86 + ListCostManagemantRequest struct {
  87 + // 页码
  88 + PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
  89 + // 页数
  90 + PageSize int `cname:"页数" json:"pageSize,omitempty"`
  91 + // 查询项目(结构)类型
  92 + Types int `cname:"查询项目(结构)类型" json:"types" valid:"Required"`
  93 + // 查询项目id
  94 + ProjectId int64 `cname:"查询项目id" json:"projectId"`
  95 + }
  96 + ListCostManagemantResponse struct {
  97 + Grid struct {
  98 + List []SearchProductItem `json:"list"`
  99 + Total int `json:"total"`
  100 + } `json:"grid"`
  101 + }
  102 + SearchProductItem struct {
  103 + ProductID int `json:"productId"`
  104 + ProductCode string `json:"productCode"`
  105 + ProductName string `json:"productName"`
  106 + ProductCategory string `json:"productCategory"`
  107 + Unit string `json:"unit"`
  108 + UnitWeight float64 `json:"unitWeight"`
  109 + }
  110 +)
  111 +
  112 +
  113 +
  114 +
  115 +
  116 +
  117 +
  118 +/*设备*/
  119 +
  120 +
  121 +
  122 +type BatchAddDeviceRequest struct {
  123 + List []*domain.ImportDeviceItem `json:"list"`
  124 +}
  125 +type BatchAddDeviceResponse []interface{}
  126 +
  127 +/**生产记录**/
  128 +//SearchProduct 搜索员工产能统计
  129 +func (gateway HttpLibCostStructured) SearchEmployeeProductive(param SearchEmployeeProductiveRequest) (*SearchEmployeeProductiveResponse, error) {
  130 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/employee-productive/search")
  131 + method := "post"
  132 + var data SearchEmployeeProductiveResponse
  133 + err := gateway.FastDoRequest(url, method, param, &data)
  134 + return &data, err
  135 +}
  136 +
  137 +type (
  138 + SearchEmployeeProductiveRequest struct {
  139 + // 页码
  140 + //PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
  141 + // 页数
  142 + //PageSize int `cname:"页数" json:"pageSize,omitempty"`
  143 + // 车间名称
  144 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  145 + // 生产线名称
  146 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  147 + // 工段名称
  148 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  149 + // 姓名
  150 + UserName string `cname:"姓名" json:"userName"`
  151 + // 员工类型 1:固定 2:派遣 3.临时
  152 + EmployeeType string `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
  153 + // 开始时间
  154 + BeginTime string `cname:"开始时间" json:"beginTime"`
  155 + // 结束时间
  156 + EndTime string `cname:"结束时间" json:"endTime"`
  157 + }
  158 + SearchEmployeeProductiveResponse struct {
  159 + Grid struct {
  160 + List []EmployeeProductiveItem `json:"list"`
  161 + Total int `json:"total"`
  162 + } `json:"grid"`
  163 + }
  164 + EmployeeProductiveItem struct {
  165 + EmployeeProductRecordID int `json:"employeeProductRecordId"`
  166 + ProductWorker struct {
  167 + UserID int `json:"userId"`
  168 + UserName string `json:"userName"`
  169 + Avatar string `json:"avatar"`
  170 + Phone string `json:"phone"`
  171 + EmployeeType int `json:"employeeType"`
  172 + } `json:"productWorker"`
  173 + WorkStationID string `json:"workStationId"`
  174 + WorkshopID int `json:"workshopId"`
  175 + WorkshopName string `json:"workshopName"`
  176 + LineID int `json:"lineId"`
  177 + LineName string `json:"lineName"`
  178 + SectionID int `json:"sectionId"`
  179 + SectionName string `json:"sectionName"`
  180 + WorkOn string `json:"workOn"`
  181 + PlanProductName string `json:"planProductName"`
  182 + BatchNumber string `json:"batchNumber"`
  183 + ParticipateType int `json:"participateType"`
  184 + ProductWeigh float64 `json:"productWeigh"`
  185 + SecondLevelWeigh float64 `json:"secondLevelWeigh"`
  186 + CreatedAt string `json:"createdAt"`
  187 + OrgName string `json:"orgName"`
  188 + AuthFlag bool `json:"authFlag"`
  189 + QualificationRate int `json:"qualificationRate"`
  190 + }
  191 +)
  192 +
  193 +//SearchProduct 搜索员工产能统计
  194 +func (gateway HttpLibCostStructured) SearchWorkshopProductive(param SearchWorkshopProductiveRequest) (*SearchWorkshopProductiveResponse, error) {
  195 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/workshop-productive/search")
  196 + method := "post"
  197 + var data SearchWorkshopProductiveResponse
  198 + err := gateway.FastDoRequest(url, method, param, &data)
  199 + return &data, err
  200 +}
  201 +
  202 +type (
  203 + SearchWorkshopProductiveRequest struct {
  204 + // 品名
  205 + PlanProductName string `cname:"品名" json:"planProductName,omitempty"`
  206 + // 工段名称
  207 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  208 + // 开始时间
  209 + BeginTime string `cname:"开始时间" json:"beginTime"`
  210 + // 结束时间
  211 + EndTime string `cname:"结束时间" json:"endTime"`
  212 + }
  213 + SearchWorkshopProductiveResponse struct {
  214 + Grid struct {
  215 + List []WorkshopProductiveItem `json:"list"`
  216 + Total int `json:"total"`
  217 + } `json:"grid"`
  218 + }
  219 + WorkshopProductiveItem struct {
  220 + EmployeeProductRecordID int `json:"employeeProductRecordId"`
  221 + ProductWorker struct {
  222 + UserID int `json:"userId"`
  223 + UserName string `json:"userName"`
  224 + Avatar string `json:"avatar"`
  225 + Phone string `json:"phone"`
  226 + EmployeeType int `json:"employeeType"`
  227 + } `json:"productWorker"`
  228 + WorkStationID string `json:"workStationId"`
  229 + WorkshopID int `json:"workshopId"`
  230 + WorkshopName string `json:"workshopName"`
  231 + LineID int `json:"lineId"`
  232 + LineName string `json:"lineName"`
  233 + SectionID int `json:"sectionId"`
  234 + SectionName string `json:"sectionName"`
  235 + WorkOn string `json:"workOn"`
  236 + PlanProductName string `json:"planProductName"`
  237 + BatchNumber string `json:"batchNumber"`
  238 + //ParticipateType int `json:"participateType"`
  239 + // 投入量
  240 + DevotedProductWeigh float64 `json:"devotedProductWeigh"`
  241 + // 产能
  242 + ProductWeigh float64 `json:"productWeigh"`
  243 + // 二级品产能
  244 + SecondLevelWeigh float64 `json:"secondLevelWeigh"`
  245 + CreatedAt string `json:"createdAt"`
  246 + OrgName string `json:"orgName"`
  247 + AuthFlag bool `json:"authFlag"`
  248 + QualificationRate int `json:"qualificationRate"`
  249 + }
  250 +)
  251 +
  252 +/*** 考勤记录 ***/
  253 +//SearchEmployeeAttendanceStatics 搜索员工工时统计
  254 +func (gateway HttpLibCostStructured) SearchEmployeeAttendanceStatics(param SearchEmployeeAttendanceStaticsRequest) (*SearchEmployeeAttendanceStaticsResponse, error) {
  255 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/employee-attendance-statics/search")
  256 + method := "post"
  257 + var data SearchEmployeeAttendanceStaticsResponse
  258 + err := gateway.FastDoRequest(url, method, param, &data)
  259 + return &data, err
  260 +}
  261 +
  262 +type (
  263 + SearchEmployeeAttendanceStaticsRequest struct {
  264 + // 车间名称
  265 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  266 + // 生产线名称
  267 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  268 + // 工段名称
  269 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  270 + // 姓名
  271 + UserName string `cname:"姓名" json:"userName,omitempty"`
  272 + // 考勤状态 1.未审核 2:已审核 4.自动审核
  273 + AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 4.自动审核" json:"attendanceStatus,omitempty"`
  274 + // 开始时间
  275 + BeginTime string `cname:"开始时间" json:"beginTime"`
  276 + // 结束时间
  277 + EndTime string `cname:"结束时间" json:"endTime"`
  278 + }
  279 + SearchEmployeeAttendanceStaticsResponse struct {
  280 + Grid struct {
  281 + List []SearchEmployeeAttendanceStaticsItem `json:"list"`
  282 + Total int `json:"total"`
  283 + } `json:"grid"`
  284 + }
  285 + SearchEmployeeAttendanceStaticsItem struct {
  286 + ProductAttendanceID int `json:"productAttendanceId"`
  287 + SignDate string `json:"signDate"`
  288 + WorkStationID string `json:"workStationId"`
  289 + WorkshopID int `json:"workshopId"`
  290 + WorkshopName string `json:"workshopName"`
  291 + LineID int `json:"lineId"`
  292 + LineName string `json:"lineName"`
  293 + SectionID int `json:"sectionId"`
  294 + SectionName string `json:"sectionName"`
  295 + ProductWorker struct {
  296 + UserID int `json:"userId"`
  297 + UserName string `json:"userName"`
  298 + EmployeeType int `json:"employeeType"`
  299 + Avatar string `json:"avatar"`
  300 + Phone string `json:"phone"`
  301 + } `json:"productWorker"`
  302 + AttendanceType int `json:"attendanceType"`
  303 + AttendanceStatus int `json:"attendanceStatus"`
  304 + AttendanceTypeDescription string `json:"attendanceTypeDescription"`
  305 + EmployeeTypeDescription string `json:"employeeTypeDescription"`
  306 + AttendanceStatusDescription string `json:"attendanceStatusDescription"`
  307 + WorkTime float64 `json:"workTime"`
  308 + OrgName string `json:"orgName"`
  309 + AuthFlag bool `json:"authFlag"`
  310 + }
  311 +)
  312 +
  313 +//SearchEmployeeAttendanceStatics 搜索员工工时统计
  314 +func (gateway HttpLibCostStructured) SearchWorkshopWorkTimeStatics(param SearchWorkshopWorkTimeStaticsRequest) (*SearchWorkshopWorkTimeStaticsResponse, error) {
  315 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/workshop-attendance-statics/search")
  316 + method := "post"
  317 + var data SearchWorkshopWorkTimeStaticsResponse
  318 + err := gateway.FastDoRequest(url, method, param, &data)
  319 + return &data, err
  320 +}
  321 +
  322 +type (
  323 + SearchWorkshopWorkTimeStaticsRequest struct {
  324 + // 车间名称
  325 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  326 + // 生产线名称
  327 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  328 + // 开始时间
  329 + BeginTime string `cname:"开始时间" json:"beginTime"`
  330 + // 结束时间
  331 + EndTime string `cname:"结束时间" json:"endTime"`
  332 + }
  333 + SearchWorkshopWorkTimeStaticsResponse struct {
  334 + Grid struct {
  335 + List []SearchWorkshopWorkTimeStaticsItem `json:"list"`
  336 + Total int `json:"total"`
  337 + } `json:"grid"`
  338 + }
  339 + SearchWorkshopWorkTimeStaticsItem struct {
  340 + WorkshopWorkTimeRecordID int `json:"workshopWorkTimeRecordId"`
  341 + WorkStationID string `json:"workStationId"`
  342 + WorkshopID int `json:"workshopId"`
  343 + WorkshopName string `json:"workshopName"`
  344 + LineID int `json:"lineId"`
  345 + LineName string `json:"lineName"`
  346 + SectionID int `json:"sectionId"`
  347 + SectionName string `json:"sectionName"`
  348 + EftWorkTime float64 `json:"eftWorkTime"`
  349 + EdWorkTime int `json:"edWorkTime"`
  350 + EptWorkTime int `json:"eptWorkTime"`
  351 + RecordDate string `json:"recordDate"`
  352 + OrgName string `json:"orgName"`
  353 + AuthFlag bool `json:"authFlag"`
  354 + }
  355 +)
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "fmt" 5 "fmt"
6 "github.com/linmadan/egglib-go/utils/json" 6 "github.com/linmadan/egglib-go/utils/json"
7 "strconv" 7 "strconv"
  8 + "strings"
8 "time" 9 "time"
9 10
10 "github.com/beego/beego/v2/client/httplib" 11 "github.com/beego/beego/v2/client/httplib"
@@ -27,6 +28,7 @@ type BaseServiceGateway struct { @@ -27,6 +28,7 @@ type BaseServiceGateway struct {
27 ReadWriteTimeout time.Duration 28 ReadWriteTimeout time.Duration
28 CompanyId int64 29 CompanyId int64
29 OrgId int64 30 OrgId int64
  31 + InOrgIds []int64
30 UserId int64 32 UserId int64
31 UserBaseId int64 33 UserBaseId int64
32 } 34 }
@@ -66,3 +68,57 @@ func (gateway BaseServiceGateway) GetResponseData(result GatewayResponse, data i @@ -66,3 +68,57 @@ func (gateway BaseServiceGateway) GetResponseData(result GatewayResponse, data i
66 } 68 }
67 return nil 69 return nil
68 } 70 }
  71 +
  72 +func (gateway BaseServiceGateway) FastDoRequest(url, method string, param interface{}, data interface{}) error {
  73 + err := gateway.DoRequest(Request{
  74 + Url: url,
  75 + Method: method,
  76 + Param: param,
  77 + }, &data)
  78 + log.Logger.Info("接口请求:----", map[string]interface{}{
  79 + "url": url,
  80 + "method": method,
  81 + "param": param,
  82 + "data": data,
  83 + })
  84 + if err != nil {
  85 + return err
  86 + }
  87 + return nil
  88 +}
  89 +
  90 +func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{}) error {
  91 + r := gateway.CreateRequest(requestParam.Url, requestParam.Method)
  92 + if len(gateway.InOrgIds) > 0 {
  93 + r.Header("orgIds", strings.Join(ToArrayString(gateway.InOrgIds), ","))
  94 + }
  95 + req, err := r.JSONBody(requestParam.Param)
  96 + if err != nil {
  97 + return err
  98 + }
  99 + byteResult, err := req.Bytes()
  100 + if err != nil {
  101 + return err
  102 + }
  103 + var result GatewayResponse
  104 + err = json.Unmarshal(byteResult, &result)
  105 + if err != nil {
  106 + return err
  107 + }
  108 + err = gateway.GetResponseData(result, val)
  109 + return nil
  110 +}
  111 +
  112 +type Request struct {
  113 + Url string
  114 + Method string
  115 + Param interface{}
  116 +}
  117 +
  118 +func ToArrayString(inputs []int64) []string {
  119 + result := make([]string, 0)
  120 + for i := range inputs {
  121 + result = append(result, strconv.Itoa(int(inputs[i])))
  122 + }
  123 + return result
  124 +}
@@ -63,6 +63,43 @@ func (smsServe HttplibSmsServe) SendSms(phone string) error { @@ -63,6 +63,43 @@ func (smsServe HttplibSmsServe) SendSms(phone string) error {
63 return nil 63 return nil
64 } 64 }
65 65
  66 +//SendSms 公共短信验证码服务 发送验证码
  67 +func (smsServe HttplibSmsServe) SendNoticeSms(phone string, tplId int, tplValues map[string]interface{}) error {
  68 + url := smsServe.baseUrL + "/service/sendNoticeSms"
  69 + method := "post"
  70 + req := smsServe.CreateRequest(url, method)
  71 + param := map[string]interface{}{
  72 + "phone": phone,
  73 + "tplId": tplId,
  74 + "tplValues": tplValues,
  75 + }
  76 + log.Logger.Debug("向公共短信验证码服务请求数据:短信验证码接口。", map[string]interface{}{
  77 + "api": method + ":" + url,
  78 + "param": param,
  79 + })
  80 + req, err := req.JSONBody(param)
  81 + if err != nil {
  82 + return fmt.Errorf("请求公共短信验证码服务失败:%w", err)
  83 + }
  84 +
  85 + byteResult, err := req.Bytes()
  86 + if err != nil {
  87 + return fmt.Errorf("获取公共短信验证码服务失败:%w", err)
  88 + }
  89 + log.Logger.Debug("获取公共短信验证码服务请求数据", map[string]interface{}{
  90 + "result": string(byteResult),
  91 + })
  92 + var result service_gateway.GatewayResponse
  93 + err = json.Unmarshal(byteResult, &result)
  94 + if err != nil {
  95 + return fmt.Errorf("解析更新组织:%w", err)
  96 + }
  97 + if result.Code != 0 {
  98 + return fmt.Errorf(result.Msg)
  99 + }
  100 + return nil
  101 +}
  102 +
66 //CheckSmsCode 公共短信验证码服务 校验验证码 103 //CheckSmsCode 公共短信验证码服务 校验验证码
67 func (smsServe HttplibSmsServe) CheckSmsCode(phone string, code string) error { 104 func (smsServe HttplibSmsServe) CheckSmsCode(phone string, code string) error {
68 if code == constant.SMSCODE_ALL_POWER { 105 if code == constant.SMSCODE_ALL_POWER {
1 package beego 1 package beego
2 2
3 import ( 3 import (
4 - "encoding/json" 4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
5 "net/http" 8 "net/http"
6 "os" 9 "os"
7 "strconv" 10 "strconv"
@@ -48,25 +51,30 @@ func init() { @@ -48,25 +51,30 @@ func init() {
48 filters.SecureKeyMap["token"] = "x-mmm-accesstoken" 51 filters.SecureKeyMap["token"] = "x-mmm-accesstoken"
49 web.InsertFilter("/*", web.BeforeRouter, AllowCors()) 52 web.InsertFilter("/*", web.BeforeRouter, AllowCors())
50 web.InsertFilter("/*", web.BeforeRouter, filters.CreateRequstLogFilter(log.Logger)) 53 web.InsertFilter("/*", web.BeforeRouter, filters.CreateRequstLogFilter(log.Logger))
51 - web.InsertFilter("/v1/web/*", web.BeforeExec, middleware.CheckAccessToken2())  
52 - web.InsertFilter("/v1/app/*", web.BeforeExec, middleware.CheckAccessToken2())  
53 - web.InsertFilter("/v1/user/*", web.BeforeExec, middleware.CheckAccessToken2()) 54 + web.InsertFilter("/v1/background/*", web.BeforeExec, middleware.CheckAccessToken())
  55 + web.InsertFilter("/v1/web/*", web.BeforeExec, middleware.CheckAccessToken())
  56 + web.InsertFilter("/v1/app/*", web.BeforeExec, middleware.CheckAccessToken())
  57 + web.InsertFilter("/v1/user/*", web.BeforeExec, middleware.CheckAccessToken())
54 web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false)) 58 web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false))
55 - web.InsertFilter("/v1/app11/*", web.BeforeExec, filters.SecureHandler(  
56 - filters.WithEnableCheckTimestamp(false),  
57 - filters.WithOnInvalidRequest(func(ctx *context.Context) {  
58 - headerData, _ := json.Marshal(ctx.Input.Context.Request.Header)  
59 - log.Logger.Info("签名验证失败:" + string(headerData))  
60 - }),  
61 - ))  
62 - //web.InsertFilterChain("/v1/*", middleware.CheckAccessToken) 59 + //web.InsertFilter("/v1/app11/*", web.BeforeExec, filters.SecureHandler(
  60 + // filters.WithEnableCheckTimestamp(false),
  61 + // filters.WithOnInvalidRequest(func(ctx *context.Context) {
  62 + // headerData, _ := json.Marshal(ctx.Input.Context.Request.Header)
  63 + // log.Logger.Info("签名验证失败:" + string(headerData))
  64 + // }),
  65 + //))
  66 +
  67 + web.InsertFilter("/v1/common/user/area/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/common/user", allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})))
  68 +
  69 + web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.CheckAccessToken())
  70 + web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/manufacture", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{})))
  71 + web.InsertFilter("/v1/cost/*", web.BeforeRouter, middleware.CheckAccessToken())
  72 + web.InsertFilter("/v1/cost/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/cost", cost_structured.NewHttpLibCostStructured(domain.Operator{})))
63 } 73 }
64 74
65 func AllowCors() func(ctx *context.Context) { 75 func AllowCors() func(ctx *context.Context) {
66 return func(ctx *context.Context) { 76 return func(ctx *context.Context) {
67 ctx.Output.Header("Access-Control-Allow-Methods", "OPTIONS,DELETE,POST,GET,PUT,PATCH") 77 ctx.Output.Header("Access-Control-Allow-Methods", "OPTIONS,DELETE,POST,GET,PUT,PATCH")
68 - //ctx.Output.Header("Access-Control-Max-Age", "3600")  
69 - //ctx.Output.Header("Access-Control-Allow-Headers", "*,x-mmm-version")  
70 ctx.Output.Header("Access-Control-Allow-Headers", "Content-Type,X-Mmm-Accesstoken,X-Mmm-Devicetype,X-Mmm-Sign,X-Mmm-Timestamp,X-Mmm-Uuid,X-Mmm-Version,x-mmm-appname,*") 78 ctx.Output.Header("Access-Control-Allow-Headers", "Content-Type,X-Mmm-Accesstoken,X-Mmm-Devicetype,X-Mmm-Sign,X-Mmm-Timestamp,X-Mmm-Uuid,X-Mmm-Version,x-mmm-appname,*")
71 ctx.Output.Header("Access-Control-Allow-Credentials", "true") 79 ctx.Output.Header("Access-Control-Allow-Credentials", "true")
72 ctx.Output.Header("Access-Control-Allow-Origin", "*") //origin 80 ctx.Output.Header("Access-Control-Allow-Origin", "*") //origin
  1 +package backgroud_client
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/command"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/auth/service"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
  7 +)
  8 +
  9 +type AuthController struct {
  10 + controllers.BaseController
  11 +}
  12 +
  13 +func (controller *AuthController) LoginPwd() {
  14 + authService := service.AuthService{}
  15 + loginCmd := &command.LoginPwdCommand{}
  16 + //Must()
  17 + controller.Unmarshal(loginCmd)
  18 + data, err := authService.AuthAdminLogin(loginCmd)
  19 + controller.Response(data, err)
  20 +}
  1 +package backgroud_client
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/company/command"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/company/query"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/company/service"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
  8 +)
  9 +
  10 +type CompanyController struct {
  11 + controllers.BaseController
  12 +}
  13 +
  14 +// func (controller *CompanyController) CreateCompany() {
  15 +// companyService := service.NewCompanyService(nil)
  16 +// createCompanyCommand := &command.CreateCompanyCommand{}
  17 +// controller.Unmarshal(createCompanyCommand)
  18 +// data, err := companyService.CreateCompany(createCompanyCommand)
  19 +// controller.Response(data, err)
  20 +// }
  21 +
  22 +func (controller *CompanyController) UpdateCompany() {
  23 + companyService := service.NewCompanyService(nil)
  24 + updateCompanyCommand := &command.UpdateCompanyCommand{}
  25 + controller.Unmarshal(updateCompanyCommand)
  26 + updateCompanyCommand.Operator = controller.GetOperator()
  27 + data, err := companyService.UpdateCompany(updateCompanyCommand)
  28 + controller.Response(data, err)
  29 +}
  30 +
  31 +func (controller *CompanyController) GetCompany() {
  32 + companyService := service.NewCompanyService(nil)
  33 + getCompanyQuery := &query.GetCompanyQuery{}
  34 + companyId, _ := controller.GetInt(":companyId")
  35 + getCompanyQuery.CompanyId = companyId
  36 + data, err := companyService.GetCompany(getCompanyQuery)
  37 + controller.Response(data, err)
  38 +}
  39 +
  40 +// func (controller *CompanyController) RemoveCompany() {
  41 +// companyService := service.NewCompanyService(nil)
  42 +// removeCompanyCommand := &command.RemoveCompanyCommand{}
  43 +// controller.Unmarshal(removeCompanyCommand)
  44 +// companyId, _ := controller.GetInt64(":companyId")
  45 +// removeCompanyCommand.CompanyId = companyId
  46 +// data, err := companyService.RemoveCompany(removeCompanyCommand)
  47 +// controller.Response(data, err)
  48 +// }
  49 +
  50 +func (controller *CompanyController) SearchCompany() {
  51 + companyService := service.NewCompanyService(nil)
  52 + listCompanyQuery := &query.ListCompanyQuery{}
  53 + controller.Unmarshal(listCompanyQuery)
  54 + cnt, data, err := companyService.ListCompany(listCompanyQuery)
  55 + controller.ReturnPageListData(cnt, data, err, listCompanyQuery.PageNumber)
  56 +}
  57 +
  58 +func (controller *CompanyController) AuditCompany() {
  59 + companyService := service.NewCompanyService(nil)
  60 + cmd := &command.AuditCompanyCommand{}
  61 + controller.Unmarshal(cmd)
  62 + companyId, _ := controller.GetInt64(":companyId")
  63 + cmd.CompanyId = companyId
  64 + data, err := companyService.AuditCompany(cmd)
  65 + controller.Response(data, err)
  66 +}
  67 +
  68 +func (controller *CompanyController) EnableCompany() {
  69 + companyService := service.NewCompanyService(nil)
  70 + cmd := &command.EnableCompanyCommand{}
  71 + controller.Unmarshal(cmd)
  72 + companyId, _ := controller.GetInt64(":companyId")
  73 + cmd.CompanyId = companyId
  74 + data, err := companyService.EnableCompany(cmd)
  75 + controller.Response(data, err)
  76 +}
  1 +package backgroud_client
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/command"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/query"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/user/service"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
  8 +)
  9 +
  10 +type UserController struct {
  11 + controllers.BaseController
  12 +}
  13 +
  14 +func (controller *UserController) SearchUser() {
  15 + companyService := service.NewUserService(nil)
  16 + listCompanyQuery := &query.ListUserQuery{}
  17 + controller.Unmarshal(listCompanyQuery)
  18 + cnt, data, err := companyService.SearchUser(listCompanyQuery)
  19 + controller.ReturnPageListData(cnt, data, err, listCompanyQuery.PageNumber)
  20 +}
  21 +
  22 +func (controller *UserController) EnableUser() {
  23 + companyService := service.NewUserService(nil)
  24 + cmd := &command.EnableUserCommand{}
  25 + controller.Unmarshal(cmd)
  26 + data, err := companyService.EnableUser(cmd)
  27 + controller.Response(data, err)
  28 +}
  29 +
  30 +func (controller *UserController) ResetPassword() {
  31 + companyService := service.NewUserService(nil)
  32 + cmd := &command.ResetPasswordCommand{}
  33 + controller.Unmarshal(cmd)
  34 + data, err := companyService.ResetPassword(cmd)
  35 + controller.Response(data, err)
  36 +}
  37 +
  38 +func (controller *UserController) SearchAdminUser() {
  39 + companyService := service.NewUserService(nil)
  40 + q := &query.ListAdminUserQuery{}
  41 + controller.Unmarshal(q)
  42 + cnt, data, err := companyService.AdminUserList(q)
  43 + controller.ReturnPageListData(cnt, data, err, q.PageNumber)
  44 +}
  45 +
  46 +func (controller *UserController) EnableAdminUser() {
  47 + companyService := service.NewUserService(nil)
  48 + cmd := &command.EnableAdminUserCommand{}
  49 + controller.Unmarshal(cmd)
  50 + data, err := companyService.EnableAdminUser(cmd)
  51 + controller.Response(data, err)
  52 +}
  53 +
  54 +func (controller *UserController) GetAdminUser() {
  55 + companyService := service.NewUserService(nil)
  56 + userId, _ := controller.GetInt(":userId")
  57 + data, err := companyService.GetAdminUser(userId)
  58 + controller.Response(data, err)
  59 +}
  60 +
  61 +func (controller *UserController) UpdateAdminUser() {
  62 + companyService := service.NewUserService(nil)
  63 + cmd := &command.AdminUserEditCommand{}
  64 + controller.Unmarshal(cmd)
  65 + userId, _ := controller.GetInt(":userId")
  66 + cmd.UserId = int64(userId)
  67 + data, err := companyService.UpdateAdminUser(cmd)
  68 + controller.Response(data, err)
  69 +}
  70 +
  71 +func (controller *UserController) CreateAdminUser() {
  72 + companyService := service.NewUserService(nil)
  73 + cmd := &command.AdminUserAddCommand{}
  74 + controller.Unmarshal(cmd)
  75 + data, err := companyService.CreateAdminUser(cmd)
  76 + controller.Response(data, err)
  77 +}
  78 +
  79 +func (controller *UserController) GetAdminUserInfo() {
  80 + companyService := service.NewUserService(nil)
  81 + operator := controller.GetOperator()
  82 + data, err := companyService.GetAdminUserInfo(operator)
  83 + controller.Response(data, err)
  84 +}
@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
12 "io" 12 "io"
13 "path/filepath" 13 "path/filepath"
  14 + "strings"
14 ) 15 )
15 16
16 type BaseController struct { 17 type BaseController struct {
@@ -97,7 +98,7 @@ func (controller *BaseController) GetOperator() domain.Operator { @@ -97,7 +98,7 @@ func (controller *BaseController) GetOperator() domain.Operator {
97 } 98 }
98 99
99 // 打印测试日志 100 // 打印测试日志
100 - // log.Logger.Debug("operator " + json.MarshalToString(op)) 101 + log.Logger.Debug("operator " + json.MarshalToString(op))
101 return op 102 return op
102 } 103 }
103 104
@@ -124,17 +125,19 @@ func (controller *BaseController) GetExcelFile() (io.Reader, error) { @@ -124,17 +125,19 @@ func (controller *BaseController) GetExcelFile() (io.Reader, error) {
124 return excelFile, nil 125 return excelFile, nil
125 } 126 }
126 127
127 -func (controller *BaseController) GetFileWithExt() (io.Reader, string, error) { 128 +func (controller *BaseController) GetFileWithExt() (io.Reader, string,string, error) {
128 excelFile, fileHeader, err := controller.GetFile("file") 129 excelFile, fileHeader, err := controller.GetFile("file")
129 if err != nil { 130 if err != nil {
130 log.Logger.Error(err.Error()) 131 log.Logger.Error(err.Error())
131 - return nil, "", fmt.Errorf("上传文件不存在") 132 + return nil, "","", fmt.Errorf("上传文件不存在")
132 } 133 }
133 ext := filepath.Ext(fileHeader.Filename) 134 ext := filepath.Ext(fileHeader.Filename)
134 if !(ext == ".xlsx" || ext == ".xls" || ext == ".csv") { 135 if !(ext == ".xlsx" || ext == ".xls" || ext == ".csv") {
135 - return nil, "", fmt.Errorf("仅支持上传文件格式 xls/xlsx/csv") 136 + return nil, "","", fmt.Errorf("仅支持上传文件格式 xls/xlsx/csv")
136 } 137 }
137 - return excelFile, ext, nil 138 + fileName := filepath.Base(fileHeader.Filename)
  139 + fileName = strings.TrimRight(fileName,ext)
  140 + return excelFile, ext,fileName, nil
138 } 141 }
139 142
140 func Must(err error) { 143 func Must(err error) {
@@ -2,6 +2,7 @@ package web_client @@ -2,6 +2,7 @@ package web_client
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
5 "io" 6 "io"
6 "strings" 7 "strings"
7 8
@@ -190,9 +191,10 @@ func defaultImport(controller *ExcelDataController) { @@ -190,9 +191,10 @@ func defaultImport(controller *ExcelDataController) {
190 err error 191 err error
191 r io.Reader 192 r io.Reader
192 ext string 193 ext string
  194 + fileName string
193 ) 195 )
194 excelService := service.NewExcelDataService(nil) 196 excelService := service.NewExcelDataService(nil)
195 - r, ext, err = controller.GetFileWithExt() 197 + r, ext,fileName, err = controller.GetFileWithExt()
196 if err != nil { 198 if err != nil {
197 controller.Response(nil, err) 199 controller.Response(nil, err)
198 return 200 return
@@ -202,6 +204,7 @@ func defaultImport(controller *ExcelDataController) { @@ -202,6 +204,7 @@ func defaultImport(controller *ExcelDataController) {
202 cmd.Operator = controller.GetOperator() 204 cmd.Operator = controller.GetOperator()
203 cmd.Reader = r 205 cmd.Reader = r
204 cmd.FileExt = ext 206 cmd.FileExt = ext
  207 + cmd.FileName = fileName
205 switch cmd.Code { 208 switch cmd.Code {
206 case domain.ImportCompanyUser: 209 case domain.ImportCompanyUser:
207 data, err = excelService.ImportCompanyUser(cmd) 210 data, err = excelService.ImportCompanyUser(cmd)
@@ -209,6 +212,12 @@ func defaultImport(controller *ExcelDataController) { @@ -209,6 +212,12 @@ func defaultImport(controller *ExcelDataController) {
209 data, err = excelService.ImportCooperationUser(cmd) 212 data, err = excelService.ImportCooperationUser(cmd)
210 case domain.ImportOrganization: 213 case domain.ImportOrganization:
211 data, err = excelService.ImportOrganization(cmd) 214 data, err = excelService.ImportOrganization(cmd)
  215 + case domain.ImportProducts:
  216 + data, err = excelService.ImportProduct(cmd)
  217 + case domain.ImportDevices:
  218 + data, err = excelService.ImportDevice(cmd)
  219 + case domain.ImportCosts:
  220 + data,err = excelService.ImportCost(cmd)
212 default: 221 default:
213 err = fmt.Errorf("导入不存在 Code:%v", cmd.Code) 222 err = fmt.Errorf("导入不存在 Code:%v", cmd.Code)
214 } 223 }
@@ -261,6 +270,36 @@ func fileExport(controller *ExcelDataController, code string) { @@ -261,6 +270,36 @@ func fileExport(controller *ExcelDataController, code string) {
261 companyUserListQuery.Operator = exportDataCommand.Operator 270 companyUserListQuery.Operator = exportDataCommand.Operator
262 data, err = excelService.ExportCooperationUser(companyUserListQuery) 271 data, err = excelService.ExportCooperationUser(companyUserListQuery)
263 filename = "导出共创用户" 272 filename = "导出共创用户"
  273 + case domain.ExportProducts:
  274 + companyUserListQuery := &query.SearchProductQuery{}
  275 + exportDataCommand.UnmarshalQuery(companyUserListQuery)
  276 + companyUserListQuery.Operator = exportDataCommand.Operator
  277 + data, err = excelService.ExportProducts(companyUserListQuery)
  278 + filename = "导出商品"
  279 + case domain.ExportManufactureEmployeeProductive:
  280 + companyUserListQuery := &query.ManufactureEmployeeProductiveQuery{}
  281 + exportDataCommand.UnmarshalQuery(companyUserListQuery)
  282 + companyUserListQuery.Operator = exportDataCommand.Operator
  283 + data, err = excelService.ExportEmployeeProductive(companyUserListQuery)
  284 + filename = "导出员工产能统计"
  285 + case domain.ExportManufactureWorkshopProductive:
  286 + companyUserListQuery := &query.ManufactureWorkshopProductiveQuery{}
  287 + exportDataCommand.UnmarshalQuery(companyUserListQuery)
  288 + companyUserListQuery.Operator = exportDataCommand.Operator
  289 + data, err = excelService.ExportWorkshopProductive(companyUserListQuery)
  290 + filename = "导出车间产能汇总"
  291 + case domain.ExportManufactureEmployeeAttendanceStatics:
  292 + companyUserListQuery := &query.ManufactureExportEmployeeAttendanceStaticsQuery{}
  293 + controllers.Must(exportDataCommand.UnmarshalQuery(companyUserListQuery))
  294 + companyUserListQuery.Operator = exportDataCommand.Operator
  295 + data, err = excelService.ExportEmployeeAttendanceStatics(companyUserListQuery)
  296 + filename = "导出员工工时统计"
  297 + case domain.ExportManufactureWorkshopAttendanceStatics:
  298 + companyUserListQuery := &query.ManufactureExportWorkshopAttendanceStaticsQuery{}
  299 + controllers.Must(exportDataCommand.UnmarshalQuery(companyUserListQuery))
  300 + companyUserListQuery.Operator = exportDataCommand.Operator
  301 + data, err = excelService.ExportWorkshopAttendanceStatics(companyUserListQuery)
  302 + filename = "导出车间工时汇总"
264 default: 303 default:
265 err = fmt.Errorf("export type :%v not exists", exportDataCommand.Code) 304 err = fmt.Errorf("export type :%v not exists", exportDataCommand.Code)
266 } 305 }
@@ -291,7 +330,35 @@ func (controller *ExcelDataController) ExportCooperationUser() { @@ -291,7 +330,35 @@ func (controller *ExcelDataController) ExportCooperationUser() {
291 fileExport(controller, domain.ExportCooperationUser) 330 fileExport(controller, domain.ExportCooperationUser)
292 } 331 }
293 332
  333 +// ExportProducts 导出生产制造产品
  334 +func (controller *ExcelDataController) ExportProducts() {
  335 + fileExport(controller, domain.ExportProducts)
  336 +}
  337 +
  338 +// ExportManufactureEmployeeProductive 导出生产制造-员工产能统计
  339 +func (controller *ExcelDataController) ExportManufactureEmployeeProductive() {
  340 + fileExport(controller, domain.ExportManufactureEmployeeProductive)
  341 +}
  342 +
  343 +// ExportManufactureEmployeeProductive 导出生产制造-车间产能统计
  344 +func (controller *ExcelDataController) ExportManufactureWorkshopProductive() {
  345 + fileExport(controller, domain.ExportManufactureWorkshopProductive)
  346 +}
  347 +
  348 +// ExportManufactureEmployeeAttendanceStatics 导出生产制造-员工工时统计
  349 +func (controller *ExcelDataController) ExportManufactureEmployeeAttendanceStatics() {
  350 + fileExport(controller, domain.ExportManufactureEmployeeAttendanceStatics)
  351 +}
  352 +
  353 +// ExportManufactureWorkshopAttendanceStatics 导出生产制造-车间工时统计
  354 +func (controller *ExcelDataController) ExportManufactureWorkshopAttendanceStatics() {
  355 + fileExport(controller, domain.ExportManufactureWorkshopAttendanceStatics)
  356 +}
  357 +
294 //GetExcelDataFields 获取导出excel数据的可选字段 358 //GetExcelDataFields 获取导出excel数据的可选字段
295 func (controller *ExcelDataController) GetExcelDataFields() { 359 func (controller *ExcelDataController) GetExcelDataFields() {
296 - 360 + code := controller.GetString(":code")
  361 + var excelService = service.NewExcelDataService(nil)
  362 + data, _ := excelService.GetExcelDataFields(&query.ExcelDataFieldsQuery{Code: code})
  363 + controller.Response(data, nil)
297 } 364 }
  1 +package web_client
  2 +
  3 +// 称重系统
@@ -19,7 +19,7 @@ func (controller *MenuController) MenuList() { @@ -19,7 +19,7 @@ func (controller *MenuController) MenuList() {
19 log.Logger.Debug("json err:" + err.Error()) 19 log.Logger.Debug("json err:" + err.Error())
20 } 20 }
21 menuListQuery.Operator = controller.GetOperator() 21 menuListQuery.Operator = controller.GetOperator()
22 - data, err := menuService.MenuList(menuListQuery) 22 + data, err := menuService.CustomizeMenus(menuListQuery)
23 controller.Response(data, err) 23 controller.Response(data, err)
24 } 24 }
25 25
@@ -46,3 +46,15 @@ func (controller *MenuController) MenuFavorite() { @@ -46,3 +46,15 @@ func (controller *MenuController) MenuFavorite() {
46 data, err := menuService.MenuFavorite(menuFavoriteCommand) 46 data, err := menuService.MenuFavorite(menuFavoriteCommand)
47 controller.Response(data, err) 47 controller.Response(data, err)
48 } 48 }
  49 +
  50 +func (controller *MenuController) MenuSearch() {
  51 + menuService := service.NewMenuService(nil)
  52 + menuListQuery := &query.MenuListQuery{}
  53 + err := controller.Unmarshal(menuListQuery)
  54 + if err != nil {
  55 + log.Logger.Debug("json err:" + err.Error())
  56 + }
  57 + menuListQuery.Operator = controller.GetOperator()
  58 + data, err := menuService.MenuSearch(menuListQuery)
  59 + controller.Response(data, err)
  60 +}
@@ -2,99 +2,26 @@ package middleware @@ -2,99 +2,26 @@ package middleware
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - log1 "log"  
6 "net/http" 5 "net/http"
7 "net/url" 6 "net/url"
8 7
9 "github.com/beego/beego/v2/server/web" 8 "github.com/beego/beego/v2/server/web"
10 "github.com/beego/beego/v2/server/web/context" 9 "github.com/beego/beego/v2/server/web/context"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
12 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/cache"  
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
14 ) 12 )
15 13
16 type CtxKeyLoginToken struct{} 14 type CtxKeyLoginToken struct{}
17 15
18 -func JWTAuth(ctx *context.Context) {  
19 -  
20 -}  
21 -  
22 -func CheckAccessToken(next web.FilterFunc) web.FilterFunc {  
23 - return func(ctx *context.Context) {  
24 - tokenStr := ctx.Input.Header("x-mmm-accesstoken")  
25 - filterMap := map[string]string{  
26 - "/v1/auth/login/pwd": "",  
27 - "/v1/auth/login/sms": "",  
28 - "/v1/auth/login/qrcode": "",  
29 - "/v1/auth/org-switch": "",  
30 - "/v1/user/company-orgs": "",  
31 - "/v1/auth/captcha-init": "",  
32 - "/v1/auth/qrcode-init": "",  
33 - "/v1/auth/sms-code": "",  
34 - "/v1/auth/check-sms-code": "",  
35 - "/v1/auth/company-sign-up": "",  
36 - "/v1/auth/reset-password": "",  
37 - "/v1/auth/refresh-token": "",  
38 - "/v1/app/cooperation-projects/person/search": "",  
39 - }  
40 - var err error  
41 - if filterUrl, err := url.Parse(ctx.Request.RequestURI); err == nil {  
42 - // 不需要验证的接口  
43 - if _, ok := filterMap[filterUrl.Path]; ok {  
44 - next(ctx)  
45 - return  
46 - }  
47 - } else {  
48 - log.Logger.Error("parse url error:" + err.Error())  
49 - }  
50 - defer func() {  
51 - if err != nil {  
52 - ctx.Output.SetStatus(http.StatusOK)  
53 - ctx.Output.JSON(map[string]interface{}{  
54 - "msg": domain.ParseCodeMsg(domain.InvalidAccessToken),  
55 - "code": domain.InvalidAccessToken,  
56 - "data": struct{}{},  
57 - }, false, false)  
58 - }  
59 - }()  
60 -  
61 - tk := &domain.LoginToken{}  
62 - err = tk.ParseToken(tokenStr)  
63 - if err != nil {  
64 - log.Logger.Error(err.Error())  
65 - return  
66 - }  
67 - platform := domain.ParsePlatform(ctx.Input.Header("x-mmm-devicetype"))  
68 - // redis缓存  
69 - tokenCache := cache.LoginTokenCache{}  
70 - token, err := tokenCache.GetAccessToken(tk.Account, platform)  
71 - if err != nil {  
72 - log.Logger.Error(err.Error())  
73 - return  
74 - }  
75 - if token != tokenStr {  
76 - log1.Println("token not equal \n" + tk.Account + "\n" + tokenStr + "\n" + token)  
77 - err = fmt.Errorf("access token not exists")  
78 - return  
79 - }  
80 - ctx.Input.SetData(CtxKeyLoginToken{}, tk)  
81 - next(ctx)  
82 - }  
83 -}  
84 -  
85 -func NewCtxLoginToken(ctx *context.Context, tk domain.LoginToken) {  
86 - ctx.Input.SetData(CtxKeyLoginToken{}, domain.LoginToken{})  
87 -}  
88 -  
89 func FormCtxLoginToken(ctx *context.Context) (domain.LoginToken, bool) { 16 func FormCtxLoginToken(ctx *context.Context) (domain.LoginToken, bool) {
90 val := ctx.Input.GetData(CtxKeyLoginToken{}) 17 val := ctx.Input.GetData(CtxKeyLoginToken{})
91 - if v, ok := val.(domain.LoginToken); ok {  
92 - return v, true 18 + if v, ok := val.(*domain.LoginToken); ok {
  19 + return *v, true
93 } 20 }
94 return domain.LoginToken{}, false 21 return domain.LoginToken{}, false
95 } 22 }
96 23
97 -func CheckAccessToken2() web.FilterFunc { 24 +func CheckAccessToken() web.FilterFunc {
98 return func(ctx *context.Context) { 25 return func(ctx *context.Context) {
99 tokenStr := ctx.Input.Header("x-mmm-accesstoken") 26 tokenStr := ctx.Input.Header("x-mmm-accesstoken")
100 filterMap := map[string]string{ 27 filterMap := map[string]string{
@@ -116,6 +43,8 @@ func CheckAccessToken2() web.FilterFunc { @@ -116,6 +43,8 @@ func CheckAccessToken2() web.FilterFunc {
116 "/v1/user/cooperation-org": "", 43 "/v1/user/cooperation-org": "",
117 "/v1/app/cooperation-projects/person/shared-info": "", //共创项目详情 - 未登录可以查看 44 "/v1/app/cooperation-projects/person/shared-info": "", //共创项目详情 - 未登录可以查看
118 "/v1/app/cooperation-projects/person/shared-info/attachment": "", 45 "/v1/app/cooperation-projects/person/shared-info/attachment": "",
  46 +
  47 + "/v1/background/auth/login/pwd": "",
119 } 48 }
120 var err error 49 var err error
121 if filterUrl, err := url.Parse(ctx.Request.RequestURI); err == nil { 50 if filterUrl, err := url.Parse(ctx.Request.RequestURI); err == nil {
@@ -136,10 +65,11 @@ func CheckAccessToken2() web.FilterFunc { @@ -136,10 +65,11 @@ func CheckAccessToken2() web.FilterFunc {
136 }, false, false) 65 }, false, false)
137 } 66 }
138 }() 67 }()
139 - 68 + //log.Logger.Debug(tokenStr)
140 tk := &domain.LoginToken{} 69 tk := &domain.LoginToken{}
141 err = tk.ParseToken(tokenStr) 70 err = tk.ParseToken(tokenStr)
142 if err != nil { 71 if err != nil {
  72 + fmt.Println(fmt.Sprintf("token:%v|", tokenStr))
143 log.Logger.Error(err.Error()) 73 log.Logger.Error(err.Error())
144 return 74 return
145 } 75 }
  1 +package middleware
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "github.com/beego/beego/v2/client/httplib"
  7 + "github.com/beego/beego/v2/server/web"
  8 + "github.com/beego/beego/v2/server/web/context"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
  10 + "io/ioutil"
  11 + "net/http"
  12 + "strings"
  13 +)
  14 +
  15 +type internalService interface {
  16 + GetResponseData(result service_gateway.GatewayResponse, data interface{}) error
  17 + CreateRequest(url string, method string) *httplib.BeegoHTTPRequest
  18 + BaseUrl() string
  19 +}
  20 +
  21 +func RedirectInternalService(prefix string, svr internalService) web.FilterFunc {
  22 + return func(ctx *context.Context) {
  23 + if !strings.HasPrefix(ctx.Request.RequestURI, prefix) {
  24 + return
  25 + }
  26 + var err error
  27 + var byteResult []byte
  28 + var data = make(map[string]interface{})
  29 + defer func() {
  30 + if err != nil {
  31 + ctx.Output.SetStatus(http.StatusOK)
  32 + ctx.Output.JSON(map[string]interface{}{
  33 + "msg": err.Error(),
  34 + "code": 1,
  35 + "data": struct{}{},
  36 + }, false, false)
  37 + }
  38 + }()
  39 + method := strings.ToLower(ctx.Request.Method)
  40 + url := strings.Replace(ctx.Request.RequestURI, prefix, "", 1)
  41 + req := svr.CreateRequest(svr.BaseUrl()+url, method)
  42 +
  43 + // 传递当前登录信息(可配置)
  44 + loginToken, ok := FormCtxLoginToken(ctx)
  45 + if ok && loginToken.CompanyId > 0 && loginToken.OrgId > 0 {
  46 + req.Header("companyId", fmt.Sprintf("%v", loginToken.CompanyId))
  47 + req.Header("orgId", fmt.Sprintf("%v", loginToken.OrgId))
  48 + req.Header("userId", fmt.Sprintf("%v", loginToken.UserId))
  49 + orgIdList := make([]string, 0)
  50 + for i := range loginToken.OrgIds {
  51 + orgIdList = append(orgIdList, fmt.Sprintf("%d", loginToken.OrgIds[i]))
  52 + }
  53 + req.Header("orgIds", fmt.Sprintf("%v", strings.Join(orgIdList, ",")))
  54 + }
  55 +
  56 + req.Body(ctx.Input.RequestBody)
  57 + response, err := req.Response()
  58 + if err != nil {
  59 + return
  60 + }
  61 + if response.StatusCode != http.StatusOK {
  62 + err = fmt.Errorf("%v", response.Status)
  63 + return
  64 + }
  65 +
  66 + byteResult, err = ioutil.ReadAll(response.Body)
  67 + if err != nil {
  68 + return
  69 + }
  70 + defer response.Body.Close()
  71 +
  72 + // 透传非json数据
  73 + contentType := response.Header.Get("Content-Type")
  74 + if contentType != "application/json" {
  75 + copyResponse(ctx, response, byteResult)
  76 + return
  77 + }
  78 +
  79 + var result service_gateway.GatewayResponse
  80 + err = json.Unmarshal(byteResult, &result)
  81 + if err != nil {
  82 + return
  83 + }
  84 +
  85 + err = svr.GetResponseData(result, &data)
  86 + if err != nil {
  87 + return
  88 + }
  89 + ctx.Output.SetStatus(http.StatusOK)
  90 + ctx.Output.JSON(map[string]interface{}{
  91 + "msg": "成功",
  92 + "code": 0,
  93 + "data": data,
  94 + }, false, false)
  95 + }
  96 +}
  97 +
  98 +func copyResponse(ctx *context.Context, response *http.Response, data []byte) {
  99 + for k, v := range response.Header {
  100 + if len(v) == 0 {
  101 + continue
  102 + }
  103 + ctx.Output.Header(k, strings.Join(v, ","))
  104 + }
  105 + ctx.Output.SetStatus(response.StatusCode)
  106 + ctx.Output.Body(data)
  107 +}
  1 +package middleware
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
  8 +)
  9 +
  10 +func RedirectManufactureWeigh() web.FilterFunc {
  11 + return RedirectInternalService("/v1/manufacture-weigh", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{
  12 + CompanyId: int64(constant.MANUFACTURE_WEIGH_DEFAULT_COMPANYID),
  13 + OrgId: int64(constant.MANUFACTURE_WEIGH_DEFAULT_ORGID),
  14 + }))
  15 +}
1 -package routers  
2 -  
3 -import (  
4 - "github.com/beego/beego/v2/server/web"  
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client"  
6 -)  
7 -  
8 -func init() {  
9 - web.Router("/v1/background/menus/", &backgroud_client.MenuController{}, "Post:CreateMenu")  
10 - web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Put:UpdateMenu")  
11 - web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Get:GetMenu")  
12 - //web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Delete:RemoveMenu")  
13 - //web.Router("/v1/background/menus/search", &backgroud_client.MenuController{}, "Get:ListMenu")  
14 - web.Router("/v1/background/menus/search", &backgroud_client.MenuController{}, "Post:SearchMenu")  
15 - web.Router("/v1/background/menus/batch-delete", &backgroud_client.MenuController{}, "Post:BatchDeleteMenu")  
16 - web.Router("/v1/background/menus/batch-enable", &backgroud_client.MenuController{}, "Post:BatchEnableMenu")  
17 -}  
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
  7 +)
  8 +
  9 +func init() {
  10 + // dictionary
  11 + web.Router("/v1/background/dictionary/", &backgroud_client.DictionaryController{}, "Post:CreateDictionary")
  12 + web.Router("/v1/background/dictionary/:dictionaryId", &backgroud_client.DictionaryController{}, "Put:UpdateDictionary")
  13 + web.Router("/v1/background/dictionary/:dictionaryId", &backgroud_client.DictionaryController{}, "Get:GetDictionary")
  14 + web.Router("/v1/background/dictionary/search", &backgroud_client.DictionaryController{}, "Post:ListDictionary")
  15 + web.Router("/v1/background/dictionary/remove", &backgroud_client.DictionaryController{}, "Post:RemoveDictionary")
  16 +
  17 + // menu
  18 + web.Router("/v1/background/menus/", &backgroud_client.MenuController{}, "Post:CreateMenu")
  19 + web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Put:UpdateMenu")
  20 + web.Router("/v1/background/menus/:menuId", &backgroud_client.MenuController{}, "Get:GetMenu")
  21 + web.Router("/v1/background/menus/search", &backgroud_client.MenuController{}, "Post:SearchMenu")
  22 + web.Router("/v1/background/menus/batch-delete", &backgroud_client.MenuController{}, "Post:BatchDeleteMenu")
  23 + web.Router("/v1/background/menus/batch-enable", &backgroud_client.MenuController{}, "Post:BatchEnableMenu")
  24 +
  25 + // company
  26 + //web.Router("/v1/background/company/", &backgroud_client.CompanyController{}, "Post:CreateCompany")
  27 + web.Router("/v1/background/company/:companyId", &backgroud_client.CompanyController{}, "Put:UpdateCompany")
  28 + web.Router("/v1/background/company/:companyId", &backgroud_client.CompanyController{}, "Get:GetCompany")
  29 + web.Router("/v1/background/company/search", &backgroud_client.CompanyController{}, "Post:SearchCompany")
  30 + web.Router("/v1/background/company/:companyId/audit", &backgroud_client.CompanyController{}, "Post:AuditCompany")
  31 + web.Router("/v1/background/company/:companyId/enable", &backgroud_client.CompanyController{}, "Post:EnableCompany")
  32 +
  33 + // user
  34 + web.Router("/v1/background/user/search", &backgroud_client.UserController{}, "Post:SearchUser")
  35 + web.Router("/v1/background/user/enable", &backgroud_client.UserController{}, "Post:EnableUser")
  36 + web.Router("/v1/background/user/reset-password", &backgroud_client.UserController{}, "Post:ResetPassword")
  37 +
  38 + // admin
  39 + web.Router("/v1/background/user-admin/search", &backgroud_client.UserController{}, "Post:SearchAdminUser")
  40 + web.Router("/v1/background/user-admin/:userId", &backgroud_client.UserController{}, "Get:GetAdminUser")
  41 + web.Router("/v1/background/user-admin/:userId", &backgroud_client.UserController{}, "Put:UpdateAdminUser")
  42 + web.Router("/v1/background/user-admin/", &backgroud_client.UserController{}, "Post:CreateAdminUser")
  43 + web.Router("/v1/background/user-admin/enable", &backgroud_client.UserController{}, "Post:EnableAdminUser")
  44 + web.Router("/v1/background/user-admin/reset-password", &backgroud_client.UserController{}, "Post:ResetPassword")
  45 +
  46 + web.Router("/v1/background/auth/login/pwd", &backgroud_client.AuthController{}, "Post:LoginPwd")
  47 + web.Router("/v1/background/auth/user-info", &backgroud_client.UserController{}, "Post:GetAdminUserInfo")
  48 + web.Router("/v1/background/auth/user-menu", &web_client.MenuController{}, "Post:MenuSearch")
  49 +}
1 -package routers  
2 -  
3 -import (  
4 - "github.com/beego/beego/v2/server/web"  
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/backgroud_client"  
6 -)  
7 -  
8 -func init() {  
9 - web.Router("/v1/background/dictionary/", &backgroud_client.DictionaryController{}, "Post:CreateDictionary")  
10 - web.Router("/v1/background/dictionary/:dictionaryId", &backgroud_client.DictionaryController{}, "Put:UpdateDictionary")  
11 - web.Router("/v1/background/dictionary/:dictionaryId", &backgroud_client.DictionaryController{}, "Get:GetDictionary")  
12 - web.Router("/v1/background/dictionary/search", &backgroud_client.DictionaryController{}, "Post:ListDictionary")  
13 - web.Router("/v1/background/dictionary/remove", &backgroud_client.DictionaryController{}, "Post:RemoveDictionary")  
14 -}  
@@ -28,6 +28,7 @@ func init() { @@ -28,6 +28,7 @@ func init() {
28 web.Router("/v1/user/cooperation-org", &mobile_client.UserController{}, "Post:CooperationOrg") 28 web.Router("/v1/user/cooperation-org", &mobile_client.UserController{}, "Post:CooperationOrg")
29 29
30 // 特殊处理 30 // 特殊处理
  31 + web.Router("/v1/user/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") //公用的
31 web.Router("/v1/app/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") 32 web.Router("/v1/app/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers")
32 web.Router("/v1/web/orgs/department-users", &web_client.OrgController{}, "Post:DepartmentUsers") 33 web.Router("/v1/web/orgs/department-users", &web_client.OrgController{}, "Post:DepartmentUsers")
33 } 34 }
@@ -8,6 +8,12 @@ import ( @@ -8,6 +8,12 @@ import (
8 func init() { 8 func init() {
9 web.Router("/v1/web/excel/export/company-user", &web_client.ExcelDataController{}, "Post:ExportCompanyUser") 9 web.Router("/v1/web/excel/export/company-user", &web_client.ExcelDataController{}, "Post:ExportCompanyUser")
10 web.Router("/v1/web/excel/export/cooperation-user", &web_client.ExcelDataController{}, "Post:ExportCooperationUser") 10 web.Router("/v1/web/excel/export/cooperation-user", &web_client.ExcelDataController{}, "Post:ExportCooperationUser")
  11 + web.Router("/v1/web/excel/export/manufacture-products", &web_client.ExcelDataController{}, "Post:ExportProducts")
  12 + web.Router("/v1/web/excel/export/manufacture-employee-productive", &web_client.ExcelDataController{}, "Post:ExportManufactureEmployeeProductive")
  13 + web.Router("/v1/web/excel/export/manufacture-workshop-productive", &web_client.ExcelDataController{}, "Post:ExportManufactureWorkshopProductive")
  14 +
  15 + web.Router("/v1/web/excel/export/manufacture-employee-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureEmployeeAttendanceStatics")
  16 + web.Router("/v1/web/excel/export/manufacture-workshop-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureWorkshopAttendanceStatics")
11 17
12 web.Router("/v1/web/excel/import/dividends-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsOrder") 18 web.Router("/v1/web/excel/import/dividends-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsOrder")
13 web.Router("/v1/web/excel/import/dividends-returned-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsReturnedOrder") 19 web.Router("/v1/web/excel/import/dividends-returned-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsReturnedOrder")
@@ -15,4 +21,7 @@ func init() { @@ -15,4 +21,7 @@ func init() {
15 web.Router("/v1/web/file-import", &web_client.ExcelDataController{}, "Post:FileImport") 21 web.Router("/v1/web/file-import", &web_client.ExcelDataController{}, "Post:FileImport")
16 web.Router("/v1/web/file-export", &web_client.ExcelDataController{}, "Post:FileExport") 22 web.Router("/v1/web/file-export", &web_client.ExcelDataController{}, "Post:FileExport")
17 web.Router("/v1/web/file-import-template/:code", &web_client.ExcelDataController{}, "Get:FileImportTemplate") 23 web.Router("/v1/web/file-import-template/:code", &web_client.ExcelDataController{}, "Get:FileImportTemplate")
  24 +
  25 + web.Router("/v1/web/file-export/fields/:code", &web_client.ExcelDataController{}, "Get:GetExcelDataFields")
  26 +
18 } 27 }
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
  6 +)
  7 +
  8 +func init() {
  9 + // 车间列表
  10 + web.Post("/v1/manufacture-weigh/workshops/selector", middleware.RedirectManufactureWeigh())
  11 + // 车间员工
  12 + web.Post("/v1/manufacture-weigh/product-groups/employees", middleware.RedirectManufactureWeigh())
  13 + // 生产批次列表
  14 + web.Post("/v1/manufacture-weigh/product-plans/search", middleware.RedirectManufactureWeigh())
  15 + // 物料列表
  16 + web.Post("/v1/manufacture-weigh/unit-conversions/materials", middleware.RedirectManufactureWeigh())
  17 + // 领料
  18 + web.Post("/v1/manufacture-weigh/product-plans/receive-material", middleware.RedirectManufactureWeigh())
  19 + // 退料
  20 + web.Post("/v1/manufacture-weigh/product-plans/return-material", middleware.RedirectManufactureWeigh())
  21 + // 提交二级品
  22 + web.Post("/v1/manufacture-weigh/product-plans/submit-product-record", middleware.RedirectManufactureWeigh())
  23 + // 车间员工
  24 + web.Post("/v1/manufacture-weigh/product-groups/employee-signing", middleware.RedirectManufactureWeigh())
  25 +
  26 + // 车间生产效率
  27 + web.Post("/v1/manufacture-weigh/statistics/workshop-production-efficiency-statistics", middleware.RedirectManufactureWeigh())
  28 + // 设备运行信息
  29 + web.Post("/v1/manufacture-weigh/statistics/device-running-info", middleware.RedirectManufactureWeigh())
  30 + // 设备生产效率
  31 + web.Post("/v1/manufacture-weigh/statistics/device-production-efficiency-statistics", middleware.RedirectManufactureWeigh())
  32 +
  33 + web.Post("/v1/manufacture-weigh/statistics/internal/:actionType", middleware.RedirectManufactureWeigh())
  34 +}
  1 +package oss
  2 +
  3 +import (
  4 + "bytes"
  5 + "fmt"
  6 + "github.com/aliyun/aliyun-oss-go-sdk/oss"
  7 + "github.com/linmadan/egglib-go/utils/snowflake"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  9 +)
  10 +
  11 +var snow, _ = snowflake.NewIdWorker(1)
  12 +
  13 +func UploadOss(data []byte) (string, error) {
  14 + client, err := oss.New("oss-cn-shenzhen.aliyuncs.com", constant.OssAccessKey, constant.OssSecret)
  15 + if err != nil {
  16 + return "", err
  17 + }
  18 + bucket, err := client.Bucket(constant.OssBucket)
  19 + if err != nil {
  20 + return "", err
  21 + }
  22 + fileId, err := snow.NextId()
  23 + if err != nil {
  24 + return "", err
  25 + }
  26 + fileName := "costs/" + fmt.Sprintf("%v", fileId)
  27 + err = bucket.PutObject(fileName, bytes.NewBuffer(data))
  28 + return constant.OssDomain +"/"+ fileName, err
  29 +}
  1 +package oss
  2 +
  3 +import (
  4 + "fmt"
  5 + "io/ioutil"
  6 + "testing"
  7 +)
  8 +
  9 +func TestOss(t *testing.T){
  10 + mBytes,_:=ioutil.ReadFile("./test.png")
  11 + result,err := UploadOss(mBytes)
  12 + fmt.Println(result,err)
  13 +}