合并分支 'test' 到 'master'
Test 查看合并请求 !4
正在显示
61 个修改的文件
包含
4420 行增加
和
57 行删除
1 | -FROM 192.168.0.243:5000/mmm/allied-creation-manufacture:20210809 | 1 | +FROM 192.168.0.243:5000/mmm/allied-creation-user:20210809 |
2 | ENV APP_DIR $GOPATH/src/project-20211220 | 2 | ENV APP_DIR $GOPATH/src/project-20211220 |
3 | RUN mkdir -p $APP_DIR | 3 | RUN mkdir -p $APP_DIR |
4 | WORKDIR $APP_DIR/ | 4 | WORKDIR $APP_DIR/ |
Dockerfile_TYYun
0 → 100644
1 | +FROM golang:alpine | ||
2 | +ENV APP_DIR $GOPATH/src/project-20211220 | ||
3 | +ENV POSTGRESQL_DB_NAME="" \ | ||
4 | + POSTGRESQL_USER="" \ | ||
5 | + POSTGRESQL_PASSWORD="" \ | ||
6 | + POSTGRESQL_HOST="" \ | ||
7 | + POSTGRESQL_PORT="" \ | ||
8 | + REDIS_HOST="" \ | ||
9 | + REDIS_PORT="" \ | ||
10 | + REDIS_AUTH="" \ | ||
11 | + LOG_LEVEL="debug" \ | ||
12 | + ERROR_BASE_CODE="1" \ | ||
13 | + ERROR_BASE_CODE_MULTIPLE="2000" \ | ||
14 | + ENABLE_KAFKA_LOG="false" \ | ||
15 | + HTTP_PORT="8082" \ | ||
16 | + SERVICE_ENV="prd" \ | ||
17 | + ALLIED_CREATION_USER_HOST="https://allied-creation-user-prd.fjmaimaimai.com" \ | ||
18 | + MANUFACTURE_DEFAULT_COMPANYID="1" \ | ||
19 | + MANUFACTURE_DEFAULT_ORGID="1" \ | ||
20 | + MANUFACTURE_DEFAULT_WORKSHOPID="2" \ | ||
21 | + MANUFACTURE_PRODUCT_TYPE="0502010004ST,0502010004ST" \ | ||
22 | + MQTT_HOST="47.97.5.102" \ | ||
23 | + MQTT_PORT="6000" | ||
24 | +RUN mkdir -p $APP_DIR | ||
25 | +WORKDIR $APP_DIR/ | ||
26 | +COPY ./pkg pkg | ||
27 | +COPY ./config config | ||
28 | +COPY ./go.mod go.mod | ||
29 | +COPY ./go.sum go.sum | ||
30 | +COPY ./main.go main.go | ||
31 | +RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] | ||
32 | +ENV GO111MODULE on | ||
33 | +ENV GOPROXY https://goproxy.cn | ||
34 | +RUN ["go","mod","tidy"] | ||
35 | +RUN ["go","build"] | ||
36 | +RUN ["ls"] | ||
37 | +ENTRYPOINT ["./allied-creation-manufacture"] |
1 | -#project | ||
1 | +# 生产制造项目说明 | ||
2 | + | ||
3 | +## 1.数据导入导出模块 | ||
4 | + | ||
5 | +### 1.1.Excel导入流程 | ||
6 | + | ||
7 | +- 原型说明 | ||
8 | + | ||
9 | +选择模板下载、文件上传 | ||
10 | +![](https://doc-press.fjmaimaimai.com/team/frontend/plugins/data-transfer-upload.png) | ||
11 | + | ||
12 | +导入数据检验有错,显示具体错误 | ||
13 | +![](https://timeless-world.oss-cn-shenzhen.aliyuncs.com/opportunity/dev_online/20220225/object/1645791913_Rz2JJkkx6xEXtAFdXDH5eH6NTjfhtjxf.jpg) | ||
14 | + | ||
15 | +- [导入接口文档地址](https://doc-press.fjmaimaimai.com/team/frontend/plugins/business/import.html) | ||
16 | + | ||
17 | + | ||
18 | +``` | ||
19 | +POST/v1/web/file-import | ||
20 | + | ||
21 | +Content-Type multipart/form-data | ||
22 | + | ||
23 | +params: | ||
24 | + | ||
25 | +file 文件 | ||
26 | +code 对应导入模块的编码 | ||
27 | +``` | ||
28 | + | ||
29 | +- ``对接步骤``以导入公司用户模块为例 | ||
30 | + | ||
31 | +1.定义接口导入的``code``为``ADMIN_SYSTEM-MANAGE_BASE_USER`` | ||
32 | +2.根据接口解析导入文件的数据 | ||
33 | +3.调用基础库解析数据并传到后台 | ||
34 | +```go | ||
35 | + | ||
36 | +// 1.解析列 | ||
37 | +excelImport := excel.NewExcelImport() | ||
38 | +excelImport.RowBegin = 3 //第二行开始读取 | ||
39 | +excelImport.DataFields = []excel.DataField{ | ||
40 | + {EnName: "userCode", CnName: "*用户编码"}, | ||
41 | + {EnName: "userName", CnName: "*用户姓名"}, | ||
42 | + {EnName: "org", CnName: "*组织机构"}, | ||
43 | + {EnName: "department", CnName: "*所属部门"}, | ||
44 | + {EnName: "enableStatus", CnName: "*用户状态"}, | ||
45 | + {EnName: "phone", CnName: "*手机号"}, | ||
46 | + {EnName: "employeeType", CnName: "*员工类型"}, | ||
47 | + {EnName: "icCardNumber", CnName: "IC卡号"}, | ||
48 | + {EnName: "email", CnName: "邮箱"}, | ||
49 | +} | ||
50 | +excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader) | ||
51 | +if err != nil { | ||
52 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
53 | +} | ||
54 | +users := make([]allied_creation_user.BatchAddUserItem, 0) | ||
55 | +for _, v := range excelData { | ||
56 | + if srv.fieldValueAllEmpty(v) { | ||
57 | + continue | ||
58 | + } | ||
59 | + item := allied_creation_user.BatchAddUserItem{ | ||
60 | + CompanyId: importDataCommand.Operator.CompanyId, | ||
61 | + UserType: domain.UserTypeEmployee, | ||
62 | + UserCode: strings.TrimSpace(v["userCode"]), | ||
63 | + Org: strings.TrimSpace(v["org"]), | ||
64 | + Department: strings.TrimSpace(v["department"]), | ||
65 | + UserName: strings.TrimSpace(v["userName"]), | ||
66 | + Phone: strings.TrimSpace(v["phone"]), | ||
67 | + Email: strings.TrimSpace(v["email"]), | ||
68 | + EnableStatus: strings.TrimSpace(v["enableStatus"]), | ||
69 | + EmployeeType: strings.TrimSpace(v["employeeType"]), | ||
70 | + IcCardNumber: strings.TrimSpace(v["icCardNumber"]), | ||
71 | + } | ||
72 | + users = append(users, item) | ||
73 | +} | ||
74 | +// 2.向后台服务发起批量添加请求 | ||
75 | +userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator) | ||
76 | +result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{ | ||
77 | + Users: users, | ||
78 | + Password: initPassword, | ||
79 | +}) | ||
80 | +``` | ||
81 | + | ||
82 | +```go | ||
83 | +``` | ||
84 | + | ||
85 | +### 2.2 Excel导出流程 | ||
86 | + | ||
87 | +- 功能原型说明 | ||
88 | + | ||
89 | +实现可以自定义选择列进行导出,以及选择导出格式,导出格式有 ``xlsx``\\``csv``,功能如下图所示: | ||
90 | + | ||
91 | +![](https://timeless-world.oss-cn-shenzhen.aliyuncs.com/opportunity/dev_online/20220225/object/1645789890_JbTa22EtANsD3fm2nJ4aH6FJkHzXaHJB.png) | ||
92 | + | ||
93 | +- 前后端交互说明 | ||
94 | + | ||
95 | +``接口定义`` | ||
96 | + | ||
97 | +导出接口 | ||
98 | +```shell | ||
99 | +POST /v1/web/file-export | ||
100 | + | ||
101 | +// request 请求参数 | ||
102 | +{ | ||
103 | + // 业务编码 | ||
104 | + "code":"string" | ||
105 | + // 选择的导出的列 | ||
106 | + "fields":[] | ||
107 | + // 导出文件格式 | ||
108 | + "format":"xlsx" | ||
109 | + // 业务查询条件 | ||
110 | + "where":{} | ||
111 | +} | ||
112 | +``` | ||
113 | + | ||
114 | +导出列查询接口 | ||
115 | + | ||
116 | +```shell | ||
117 | +GET/v1/web/file-export/fields/:code | ||
118 | + | ||
119 | +// response 应答数据 | ||
120 | +{ | ||
121 | + "fields":[ | ||
122 | + { | ||
123 | + "enName":"字段键名", | ||
124 | + "cnName":"字段展示名称", | ||
125 | + "selected":true // 默认勾选 | ||
126 | + } | ||
127 | + ] | ||
128 | +} | ||
129 | +``` | ||
130 | + | ||
131 | +- 交互流程 | ||
132 | + | ||
133 | +1.前台根据 ``导出列查询接口`` 获取可以导出的列; | ||
134 | +2.勾选需要导出的列、文件格式,调用 ``导出接口`` 向后台发起导出数据请求; | ||
135 | + | ||
136 | + | ||
137 | +#### 2.2.1 后端导出实现 | ||
138 | + | ||
139 | +1. 导出数据实现接口 | ||
140 | + | ||
141 | +``` | ||
142 | +type ExcelMaker interface { | ||
143 | + DataFieldList() []DataField //字段元数据列表 | ||
144 | + CellValue(index int, enName string) (value interface{}) //获取单元格字段值 | ||
145 | + DataListLen() int //数据列表大小 | ||
146 | + TableTitle() []string //列表顶部自定义内容 | ||
147 | +} | ||
148 | +``` | ||
149 | + | ||
150 | +如下所示 | ||
151 | +```go | ||
152 | +//ExportCooperationUserData 导出共创用户数据 | ||
153 | +type ExportCooperationUserData struct { | ||
154 | + SourceData []allied_creation_user.UserDetail //具体数据 | ||
155 | + SelectedField []string | ||
156 | +} | ||
157 | + | ||
158 | +var _ excel.ExcelMaker = (*ExportCooperationUserData)(nil) | ||
159 | + | ||
160 | +func (data ExportCooperationUserData) AllFields() []DataFieldOptions { | ||
161 | + return []DataFieldOptions{ | ||
162 | + {EnName: "UserCode", CnName: "用户编码"}, | ||
163 | + {EnName: "UserName", CnName: "用户姓名"}, | ||
164 | + {EnName: "Phone", CnName: "手机号"}, | ||
165 | + {EnName: "CooperationCompany", CnName: "共创公司"}, | ||
166 | + {EnName: "CooperationDeadline", CnName: "共创到期"}, | ||
167 | + {EnName: "EnableStatus", CnName: "状态"}, | ||
168 | + } | ||
169 | +} | ||
170 | + | ||
171 | +func (data ExportCooperationUserData) DataFieldList() []excel.DataField { | ||
172 | + fields := []excel.DataField{} | ||
173 | + allFields := data.AllFields() | ||
174 | + for _, value2 := range allFields { | ||
175 | + if len(data.SelectedField) == 0 || value2.IsDefault { | ||
176 | + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
177 | + continue | ||
178 | + } | ||
179 | + for _, value3 := range data.SelectedField { | ||
180 | + if value2.EnName == value3 { | ||
181 | + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
182 | + } | ||
183 | + } | ||
184 | + } | ||
185 | + return fields | ||
186 | +} | ||
187 | + | ||
188 | +func (data ExportCooperationUserData) CellValue(index int, enName string) (value interface{}) { | ||
189 | + if index > data.DataListLen() { | ||
190 | + return "" | ||
191 | + } | ||
192 | + switch enName { | ||
193 | + case "UserCode": | ||
194 | + return data.SourceData[index].UserCode | ||
195 | + case "UserName": | ||
196 | + return data.SourceData[index].UserInfo.UserName | ||
197 | + case "CooperationCompany": | ||
198 | + return data.SourceData[index].CooperationInfo.CooperationCompany | ||
199 | + case "CooperationDeadline": | ||
200 | + if data.SourceData[index].CooperationInfo.CooperationDeadline.IsZero() || data.SourceData[index].CooperationInfo.CooperationDeadline.Unix() == 0 { | ||
201 | + return "" | ||
202 | + } | ||
203 | + return data.SourceData[index].CooperationInfo.CooperationDeadline.Format("2006-01-02") | ||
204 | + case "Phone": | ||
205 | + return data.SourceData[index].UserInfo.Phone | ||
206 | + case "Email": | ||
207 | + return data.SourceData[index].UserInfo.Email | ||
208 | + case "EnableStatus": | ||
209 | + status := data.SourceData[index].EnableStatus | ||
210 | + statusName := "" | ||
211 | + // 状态(1:启用 2:禁用 3:注销) | ||
212 | + switch status { | ||
213 | + case 1: | ||
214 | + statusName = "启用" | ||
215 | + case 2: | ||
216 | + statusName = "禁用" | ||
217 | + case 3: | ||
218 | + statusName = "注销" | ||
219 | + } | ||
220 | + return statusName | ||
221 | + } | ||
222 | + return nil | ||
223 | +} | ||
224 | + | ||
225 | +func (data ExportCooperationUserData) DataListLen() int { | ||
226 | + return len(data.SourceData) | ||
227 | +} | ||
228 | + | ||
229 | +func (data ExportCooperationUserData) TableTitle() []string { | ||
230 | + return nil | ||
231 | +} | ||
232 | +``` | ||
233 | + | ||
234 | +2. 返回文件 | ||
235 | + | ||
236 | +```go | ||
237 | +//返回文件 | ||
238 | +excelTool := excel.NewExcelExport() | ||
239 | +err = excelTool.ExportData(data, "") | ||
240 | +controller.responseExcelByFile(controller.Ctx, excelTool, filename) | ||
241 | + | ||
242 | + | ||
243 | +func (controller *ExcelDataController) responseExcelByFile(ctx *context.Context, excelExport *excel.ExcelExport, fileName string) error { | ||
244 | + ctx.Output.Header("Content-Disposition", "attachment; filename="+fileName) | ||
245 | + ctx.Output.Header("Content-Description", "File Transfer") | ||
246 | + ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") | ||
247 | + ctx.Output.Header("Content-Transfer-Encoding", "binary") | ||
248 | + ctx.Output.Header("Expires", "0") | ||
249 | + ctx.Output.Header("Cache-Control", "must-revalidate") | ||
250 | + ctx.Output.Header("Pragma", "public") | ||
251 | + //跳过保存文件,直接写入ctx.ResponseWriter | ||
252 | + excelExport.ExcelFile.Write(ctx.ResponseWriter) | ||
253 | + return nil | ||
254 | +} | ||
255 | +``` |
@@ -52,12 +52,54 @@ spec: | @@ -52,12 +52,54 @@ spec: | ||
52 | - mountPath: /opt/logs | 52 | - mountPath: /opt/logs |
53 | name: accesslogs | 53 | name: accesslogs |
54 | env: | 54 | env: |
55 | + - name: POSTGRESQL_DB_NAME | ||
56 | + valueFrom: | ||
57 | + configMapKeyRef: | ||
58 | + name: suplus-config | ||
59 | + key: postgresqlalliedcreation.dbname | ||
60 | + - name: POSTGRESQL_USER | ||
61 | + valueFrom: | ||
62 | + configMapKeyRef: | ||
63 | + name: suplus-config | ||
64 | + key: postgresql.user | ||
65 | + - name: POSTGRESQL_PASSWORD | ||
66 | + valueFrom: | ||
67 | + configMapKeyRef: | ||
68 | + name: suplus-config | ||
69 | + key: postgresql.password | ||
70 | + - name: POSTGRESQL_HOST | ||
71 | + valueFrom: | ||
72 | + configMapKeyRef: | ||
73 | + name: suplus-config | ||
74 | + key: postgresql.host | ||
75 | + - name: POSTGRESQL_PORT | ||
76 | + valueFrom: | ||
77 | + configMapKeyRef: | ||
78 | + name: suplus-config | ||
79 | + key: postgresql.port | ||
80 | + - name: REDIS_HOST | ||
81 | + valueFrom: | ||
82 | + configMapKeyRef: | ||
83 | + name: suplus-config | ||
84 | + key: redis.ip | ||
85 | + - name: REDIS_PORT | ||
86 | + valueFrom: | ||
87 | + configMapKeyRef: | ||
88 | + name: suplus-config | ||
89 | + key: redis.port | ||
90 | + - name: REDIS_AUTH | ||
91 | + value: "" | ||
55 | - name: LOG_LEVEL | 92 | - name: LOG_LEVEL |
56 | value: "debug" | 93 | value: "debug" |
57 | - name: ERROR_BASE_CODE | 94 | - name: ERROR_BASE_CODE |
58 | value: "1" | 95 | value: "1" |
59 | - name: ERROR_BASE_CODE_MULTIPLE | 96 | - name: ERROR_BASE_CODE_MULTIPLE |
60 | - value: "1000" | ||
61 | - volumes: | 97 | + value: "2000" |
98 | + - name: ENABLE_KAFKA_LOG | ||
99 | + value: "true" | ||
100 | + - name: HTTP_PORT | ||
101 | + value: "8082" | ||
102 | + - name: SERVICE_ENV | ||
103 | + value: "dev" | ||
62 | - name: accesslogs | 104 | - name: accesslogs |
63 | emptyDir: {} | 105 | emptyDir: {} |
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: allied-creation-manufacture | ||
5 | + namespace: mmm-suplus-prd | ||
6 | + labels: | ||
7 | + k8s-app: allied-creation-manufacture | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8082 | ||
13 | + selector: | ||
14 | + k8s-app: allied-creation-manufacture | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: allied-creation-manufacture | ||
20 | + namespace: mmm-suplus-prd | ||
21 | + labels: | ||
22 | + k8s-app: allied-creation-manufacture | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: allied-creation-manufacture | ||
29 | + spec: | ||
30 | + affinity: | ||
31 | + nodeAffinity: | ||
32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | + - preference: {} | ||
34 | + weight: 100 | ||
35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | + nodeSelectorTerms: | ||
37 | + - matchExpressions: | ||
38 | + - key: kubernetes.io/hostname | ||
39 | + operator: In | ||
40 | + values: | ||
41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: allied-creation-manufacture | ||
47 | + image: 192.168.0.243:5000/mmm/allied-creation-manufacture:master | ||
48 | + imagePullPolicy: Always | ||
49 | + ports: | ||
50 | + - containerPort: 8082 | ||
51 | + env: | ||
52 | + - name: POSTGRESQL_DB_NAME | ||
53 | + valueFrom: | ||
54 | + configMapKeyRef: | ||
55 | + name: suplus-config | ||
56 | + key: postgresqlalliedcreation.dbname | ||
57 | + - name: POSTGRESQL_USER | ||
58 | + valueFrom: | ||
59 | + configMapKeyRef: | ||
60 | + name: suplus-config | ||
61 | + key: postgresql.user | ||
62 | + - name: POSTGRESQL_PASSWORD | ||
63 | + valueFrom: | ||
64 | + configMapKeyRef: | ||
65 | + name: suplus-config | ||
66 | + key: postgresql.password | ||
67 | + - name: POSTGRESQL_HOST | ||
68 | + valueFrom: | ||
69 | + configMapKeyRef: | ||
70 | + name: suplus-config | ||
71 | + key: postgresql.host | ||
72 | + - name: POSTGRESQL_PORT | ||
73 | + valueFrom: | ||
74 | + configMapKeyRef: | ||
75 | + name: suplus-config | ||
76 | + key: postgresql.port | ||
77 | + - name: REDIS_HOST | ||
78 | + valueFrom: | ||
79 | + configMapKeyRef: | ||
80 | + name: suplus-config | ||
81 | + key: redis.ip | ||
82 | + - name: REDIS_PORT | ||
83 | + valueFrom: | ||
84 | + configMapKeyRef: | ||
85 | + name: suplus-config | ||
86 | + key: redis.port | ||
87 | + - name: REDIS_AUTH | ||
88 | + value: "" | ||
89 | + - name: LOG_LEVEL | ||
90 | + value: "debug" | ||
91 | + - name: ERROR_BASE_CODE | ||
92 | + value: "1" | ||
93 | + - name: ERROR_BASE_CODE_MULTIPLE | ||
94 | + value: "2000" | ||
95 | + - name: ENABLE_KAFKA_LOG | ||
96 | + value: "true" | ||
97 | + - name: HTTP_PORT | ||
98 | + value: "8082" | ||
99 | + - name: SERVICE_ENV | ||
100 | + value: "prd" | ||
101 | + - name: ALLIED_CREATION_GATEWAY_HOST | ||
102 | + value: "https://allied-creation-gateway-prd.fjmaimaimai.com" | ||
103 | + - name: ALLIED_CREATION_USER_HOST | ||
104 | + value: "https://allied-creation-user-prd.fjmaimaimai.com" | ||
105 | + - name: ALLIED_CREATION_BASIC_HOST | ||
106 | + value: "https://allied-creation-basic-prd.fjmaimaimai.com" | ||
107 | + - name: ALLIED_CREATION_MANUFACTURE_HOST | ||
108 | + value: "http://allied-creation-manufacture-prd.fjmaimaimai.com" | ||
109 | + - name: SMS_SERVE_HOST | ||
110 | + value: "https://sms.fjmaimaimai.com:9897" | ||
111 | + - name: MANUFACTURE_DEFAULT_COMPANYID | ||
112 | + value: "4" | ||
113 | + - name: MANUFACTURE_DEFAULT_ORGID | ||
114 | + value: "44" | ||
115 | + - name: MANUFACTURE_DEFAULT_WORKSHOPID | ||
116 | + value: "1" | ||
117 | + - name: MANUFACTURE_PRODUCT_TYPE | ||
118 | + value: "0502010001ST,0502010007ST,0502010008ST,0502010009ST,0502010010ST,0502010011ST,0502010014ST,0502010016ST,0502010018ST,0502010020ST,0502010021ST,0502010022ST,0502010023ST" | ||
119 | + - name: MQTT_HOST | ||
120 | + value: "47.97.5.102" | ||
121 | + - name: MQTT_PORT | ||
122 | + value: "6000" |
deploy/k8s/prd/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-manufacture | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/prd/allied-creation-manufacture/allied-creation-manufacture.yaml --record | ||
6 | + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-manufacture | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "allied-creation-manufacture service install success!" | ||
9 | + else | ||
10 | + echo "allied-creation-manufacture service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-manufacture | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "allied-creation-manufacture deployment install success!" | ||
15 | + else | ||
16 | + echo "allied-creation-manufacture deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/prd/allied-creation-manufacture/allied-creation-manufacture.yaml | ||
20 | + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-manufacture | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-manufacture | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-manufacture | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-manufacture | ||
29 | + done | ||
30 | + kubectl create -f /tmp/prd/allied-creation-manufacture/allied-creation-manufacture.yaml --record | ||
31 | + kubectl -n mmm-suplus-prd get svc | grep -q allied-creation-manufacture | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "allied-creation-manufacture service update success!" | ||
34 | + else | ||
35 | + echo "allied-creation-manufacture service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-prd get pods | grep -q allied-creation-manufacture | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "allied-creation-manufacture deployment update success!" | ||
40 | + else | ||
41 | + echo "allied-creation-manufacture deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
deploy/k8s/test/.gitkeep
0 → 100644
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: allied-creation-manufacture | ||
5 | + namespace: mmm-suplus-test | ||
6 | + labels: | ||
7 | + k8s-app: allied-creation-manufacture | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8082 | ||
13 | + selector: | ||
14 | + k8s-app: allied-creation-manufacture | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: allied-creation-manufacture | ||
20 | + namespace: mmm-suplus-test | ||
21 | + labels: | ||
22 | + k8s-app: allied-creation-manufacture | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: allied-creation-manufacture | ||
29 | + spec: | ||
30 | + affinity: | ||
31 | + nodeAffinity: | ||
32 | + preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | + - preference: {} | ||
34 | + weight: 100 | ||
35 | + requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | + nodeSelectorTerms: | ||
37 | + - matchExpressions: | ||
38 | + - key: kubernetes.io/hostname | ||
39 | + operator: In | ||
40 | + values: | ||
41 | + - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | + - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | + - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | + - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: allied-creation-manufacture | ||
47 | + image: 192.168.0.243:5000/mmm/allied-creation-manufacture:dev | ||
48 | + imagePullPolicy: Always | ||
49 | + ports: | ||
50 | + - containerPort: 8082 | ||
51 | + env: | ||
52 | + - name: POSTGRESQL_DB_NAME | ||
53 | + valueFrom: | ||
54 | + configMapKeyRef: | ||
55 | + name: suplus-config | ||
56 | + key: postgresqlalliedcreation.dbname | ||
57 | + - name: POSTGRESQL_USER | ||
58 | + valueFrom: | ||
59 | + configMapKeyRef: | ||
60 | + name: suplus-config | ||
61 | + key: postgresql.user | ||
62 | + - name: POSTGRESQL_PASSWORD | ||
63 | + valueFrom: | ||
64 | + configMapKeyRef: | ||
65 | + name: suplus-config | ||
66 | + key: postgresql.password | ||
67 | + - name: POSTGRESQL_HOST | ||
68 | + valueFrom: | ||
69 | + configMapKeyRef: | ||
70 | + name: suplus-config | ||
71 | + key: postgresql.host | ||
72 | + - name: POSTGRESQL_PORT | ||
73 | + valueFrom: | ||
74 | + configMapKeyRef: | ||
75 | + name: suplus-config | ||
76 | + key: postgresql.port | ||
77 | + - name: REDIS_HOST | ||
78 | + valueFrom: | ||
79 | + configMapKeyRef: | ||
80 | + name: suplus-config | ||
81 | + key: redis.ip | ||
82 | + - name: REDIS_PORT | ||
83 | + valueFrom: | ||
84 | + configMapKeyRef: | ||
85 | + name: suplus-config | ||
86 | + key: redis.port | ||
87 | + - name: REDIS_AUTH | ||
88 | + value: "" | ||
89 | + - name: LOG_LEVEL | ||
90 | + value: "debug" | ||
91 | + - name: ERROR_BASE_CODE | ||
92 | + value: "1" | ||
93 | + - name: ERROR_BASE_CODE_MULTIPLE | ||
94 | + value: "2000" | ||
95 | + - name: ENABLE_KAFKA_LOG | ||
96 | + value: "true" | ||
97 | + - name: HTTP_PORT | ||
98 | + value: "8082" | ||
99 | + - name: SERVICE_ENV | ||
100 | + value: "test" | ||
101 | + - name: SUPLUS_ADMIN_BASE_HOST | ||
102 | + value: "http://suplus-admin-base-dev.fjmaimaimai.com" | ||
103 | + - name: ALLIED_CREATION_GATEWAY_HOST | ||
104 | + value: "https://allied-creation-gateway-test.fjmaimaimai.com" | ||
105 | + - name: ALLIED_CREATION_USER_HOST | ||
106 | + value: "https://allied-creation-user-test.fjmaimaimai.com" | ||
107 | + - name: ALLIED_CREATION_COOPERATION_HOST | ||
108 | + value: "https://allied-creation-cooperation-test.fjmaimaimai.com" | ||
109 | + - name: ALLIED_CREATION_BASIC_HOST | ||
110 | + value: "https://allied-creation-basic-test.fjmaimaimai.com" | ||
111 | + - name: ALLIED_CREATION_MANUFACTURE_HOST | ||
112 | + value: "http://allied-creation-manufacture-test.fjmaimaimai.com" | ||
113 | + - name: SMS_SERVE_HOST | ||
114 | + value: "https://sms.fjmaimaimai.com:9897" | ||
115 | + - name: SUPLUS_SALE_APP | ||
116 | + value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com" | ||
117 | + - name: MANUFACTURE_DEFAULT_COMPANYID | ||
118 | + value: "23" | ||
119 | + - name: MANUFACTURE_DEFAULT_ORGID | ||
120 | + value: "487" | ||
121 | + - name: MANUFACTURE_DEFAULT_WORKSHOPID | ||
122 | + value: "28" | ||
123 | + - name: MANUFACTURE_PRODUCT_TYPE | ||
124 | + value: "SG,SG" | ||
125 | + - name: MQTT_HOST | ||
126 | + value: "47.97.5.102" | ||
127 | + - name: MQTT_PORT | ||
128 | + value: "6000" |
deploy/k8s/test/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/test/allied-creation-manufacture/allied-creation-manufacture.yaml --record | ||
6 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "allied-creation-manufacture service install success!" | ||
9 | + else | ||
10 | + echo "allied-creation-manufacture service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "allied-creation-manufacture deployment install success!" | ||
15 | + else | ||
16 | + echo "allied-creation-manufacture deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/test/allied-creation-manufacture/allied-creation-manufacture.yaml | ||
20 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
29 | + done | ||
30 | + kubectl create -f /tmp/test/allied-creation-manufacture/allied-creation-manufacture.yaml --record | ||
31 | + kubectl -n mmm-suplus-test get svc | grep -q allied-creation-manufacture | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "allied-creation-manufacture service update success!" | ||
34 | + else | ||
35 | + echo "allied-creation-manufacture service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-test get pods | grep -q allied-creation-manufacture | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "allied-creation-manufacture deployment update success!" | ||
40 | + else | ||
41 | + echo "allied-creation-manufacture deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
@@ -5,24 +5,36 @@ go 1.16 | @@ -5,24 +5,36 @@ go 1.16 | ||
5 | require ( | 5 | require ( |
6 | github.com/ajg/form v1.5.1 // indirect | 6 | github.com/ajg/form v1.5.1 // indirect |
7 | github.com/beego/beego/v2 v2.0.1 | 7 | github.com/beego/beego/v2 v2.0.1 |
8 | + github.com/bwmarrin/snowflake v0.3.0 | ||
9 | + github.com/eclipse/paho.mqtt.golang v1.3.5 | ||
8 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect | 10 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect |
9 | github.com/fatih/structs v1.1.0 // indirect | 11 | github.com/fatih/structs v1.1.0 // indirect |
10 | github.com/gavv/httpexpect v2.0.0+incompatible | 12 | github.com/gavv/httpexpect v2.0.0+incompatible |
11 | github.com/go-pg/pg/v10 v10.9.0 | 13 | github.com/go-pg/pg/v10 v10.9.0 |
14 | + github.com/go-redis/redis v6.15.7+incompatible | ||
12 | github.com/google/go-querystring v1.1.0 // indirect | 15 | github.com/google/go-querystring v1.1.0 // indirect |
16 | + github.com/google/uuid v1.3.0 | ||
17 | + github.com/hibiken/asynq v0.21.0 | ||
13 | github.com/imkira/go-interpol v1.1.0 // indirect | 18 | github.com/imkira/go-interpol v1.1.0 // indirect |
14 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 | 19 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 |
20 | + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 | ||
15 | github.com/moul/http2curl v1.0.0 // indirect | 21 | github.com/moul/http2curl v1.0.0 // indirect |
22 | + github.com/mozillazg/go-pinyin v0.19.0 | ||
16 | github.com/onsi/ginkgo v1.15.2 | 23 | github.com/onsi/ginkgo v1.15.2 |
17 | github.com/onsi/gomega v1.11.0 | 24 | github.com/onsi/gomega v1.11.0 |
18 | github.com/sergi/go-diff v1.2.0 // indirect | 25 | github.com/sergi/go-diff v1.2.0 // indirect |
26 | + github.com/shopspring/decimal v1.2.0 | ||
27 | + github.com/sirupsen/logrus v1.8.0 | ||
19 | github.com/smartystreets/goconvey v1.7.2 // indirect | 28 | github.com/smartystreets/goconvey v1.7.2 // indirect |
29 | + github.com/stretchr/testify v1.7.0 | ||
30 | + github.com/tidwall/gjson v1.13.0 | ||
20 | github.com/valyala/fasthttp v1.32.0 // indirect | 31 | github.com/valyala/fasthttp v1.32.0 // indirect |
21 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect | 32 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect |
22 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect | 33 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect |
23 | github.com/yudai/gojsondiff v1.0.0 // indirect | 34 | github.com/yudai/gojsondiff v1.0.0 // indirect |
24 | github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect | 35 | github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect |
25 | github.com/yudai/pp v2.0.1+incompatible // indirect | 36 | github.com/yudai/pp v2.0.1+incompatible // indirect |
37 | + golang.org/x/text v0.3.6 | ||
26 | ) | 38 | ) |
27 | 39 | ||
28 | -replace github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v0.0.0-20210608073225-c852ce95ae34 | 40 | +replace github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v0.0.0-20220120032512-24dfab2b4987 |
@@ -32,6 +32,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r | @@ -32,6 +32,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r | ||
32 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= | 32 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= |
33 | github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= | 33 | github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= |
34 | github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= | 34 | github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= |
35 | +github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= | ||
36 | +github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= | ||
35 | github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE= | 37 | github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE= |
36 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= | 38 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= |
37 | github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= | 39 | github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= |
@@ -61,6 +63,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c | @@ -61,6 +63,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c | ||
61 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 63 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
62 | github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= | 64 | github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= |
63 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= | 65 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= |
66 | +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= | ||
67 | +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= | ||
64 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | 68 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= |
65 | github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= | 69 | github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= |
66 | github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= | 70 | github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= |
@@ -68,6 +72,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8 | @@ -68,6 +72,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8 | ||
68 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= | 72 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= |
69 | github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= | 73 | github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= |
70 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= | 74 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= |
75 | +github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y= | ||
76 | +github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc= | ||
71 | github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= | 77 | github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= |
72 | github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI= | 78 | github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI= |
73 | github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= | 79 | github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= |
@@ -110,6 +116,8 @@ github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w | @@ -110,6 +116,8 @@ github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w | ||
110 | github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U= | 116 | github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U= |
111 | github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= | 117 | github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= |
112 | github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= | 118 | github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= |
119 | +github.com/go-redis/redis/v8 v8.11.2 h1:WqlSpAwz8mxDSMCvbyz1Mkiqe0LE5OY4j3lgkvu1Ts0= | ||
120 | +github.com/go-redis/redis/v8 v8.11.2/go.mod h1:DLomh7y2e3ggQXQLd1YgmvIfecPJoFl7WU5SOQ/r06M= | ||
113 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | 121 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= |
114 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | 122 | github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= |
115 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= | 123 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
@@ -152,16 +160,19 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ | @@ -152,16 +160,19 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ | ||
152 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 160 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
153 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 161 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
154 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 162 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
155 | -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= | ||
156 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | 163 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
164 | +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= | ||
165 | +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
157 | github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= | 166 | github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= |
158 | github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= | 167 | github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= |
159 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= | 168 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= |
160 | github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQlmgY= | 169 | github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQlmgY= |
161 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= | 170 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= |
162 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 171 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
163 | -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= | ||
164 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 172 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
173 | +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
174 | +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | ||
175 | +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
165 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= | 176 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= |
166 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= | 177 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= |
167 | github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= | 178 | github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= |
@@ -177,6 +188,8 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 | @@ -177,6 +188,8 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 | ||
177 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= | 188 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= |
178 | github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= | 189 | github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= |
179 | github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= | 190 | github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= |
191 | +github.com/hibiken/asynq v0.21.0 h1:uH9XogJhjq/S39E0/DEPWLZQ6hHJ73UiblZTe4RzHwA= | ||
192 | +github.com/hibiken/asynq v0.21.0/go.mod h1:tyc63ojaW8SJ5SBm8mvI4DDONsguP5HE85EEl4Qr5Ig= | ||
180 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= | 193 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |
181 | github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= | 194 | github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= |
182 | github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= | 195 | github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= |
@@ -246,6 +259,8 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9 | @@ -246,6 +259,8 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9 | ||
246 | github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= | 259 | github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= |
247 | github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= | 260 | github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= |
248 | github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= | 261 | github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= |
262 | +github.com/mozillazg/go-pinyin v0.19.0 h1:p+J8/kjJ558KPvVGYLvqBhxf8jbZA2exSLCs2uUVN8c= | ||
263 | +github.com/mozillazg/go-pinyin v0.19.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc= | ||
249 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= | 264 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= |
250 | github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= | 265 | github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= |
251 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= | 266 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= |
@@ -261,6 +276,7 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ | @@ -261,6 +276,7 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ | ||
261 | github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= | 276 | github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= |
262 | github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= | 277 | github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= |
263 | github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= | 278 | github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= |
279 | +github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= | ||
264 | github.com/onsi/ginkgo v1.15.2 h1:l77YT15o814C2qVL47NOyjV/6RbaP7kKdrvZnxQ3Org= | 280 | github.com/onsi/ginkgo v1.15.2 h1:l77YT15o814C2qVL47NOyjV/6RbaP7kKdrvZnxQ3Org= |
265 | github.com/onsi/ginkgo v1.15.2/go.mod h1:Dd6YFfwBW84ETqqtL0CPyPXillHgY6XhQH3uuCCTr/o= | 281 | github.com/onsi/ginkgo v1.15.2/go.mod h1:Dd6YFfwBW84ETqqtL0CPyPXillHgY6XhQH3uuCCTr/o= |
266 | github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= | 282 | github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
@@ -268,6 +284,7 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa | @@ -268,6 +284,7 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa | ||
268 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= | 284 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= |
269 | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | 285 | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= |
270 | github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= | 286 | github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= |
287 | +github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= | ||
271 | github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug= | 288 | github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug= |
272 | github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= | 289 | github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= |
273 | github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= | 290 | github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= |
@@ -305,6 +322,12 @@ github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFB | @@ -305,6 +322,12 @@ github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFB | ||
305 | github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= | 322 | github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= |
306 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= | 323 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= |
307 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= | 324 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= |
325 | +github.com/richardlehane/mscfb v1.0.3 h1:rD8TBkYWkObWO0oLDFCbwMeZ4KoalxQy+QgniCj3nKI= | ||
326 | +github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= | ||
327 | +github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o= | ||
328 | +github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= | ||
329 | +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= | ||
330 | +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= | ||
308 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= | 331 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= |
309 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= | 332 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= |
310 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= | 333 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= |
@@ -316,6 +339,8 @@ github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI | @@ -316,6 +339,8 @@ github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI | ||
316 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= | 339 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= |
317 | github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= | 340 | github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= |
318 | github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= | 341 | github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= |
342 | +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= | ||
343 | +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= | ||
319 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= | 344 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= |
320 | github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= | 345 | github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= |
321 | github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s= | 346 | github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s= |
@@ -331,6 +356,8 @@ github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3 | @@ -331,6 +356,8 @@ github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3 | ||
331 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= | 356 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= |
332 | github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= | 357 | github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= |
333 | github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= | 358 | github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= |
359 | +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= | ||
360 | +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= | ||
334 | github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= | 361 | github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= |
335 | github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= | 362 | github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= |
336 | github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= | 363 | github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= |
@@ -347,8 +374,14 @@ github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2K | @@ -347,8 +374,14 @@ github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2K | ||
347 | github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= | 374 | github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= |
348 | github.com/tal-tech/go-zero v1.0.27 h1:QMIbaTxibMc/OsO5RTAuKZ8ndbl2dGN6pITQEtp2x/A= | 375 | github.com/tal-tech/go-zero v1.0.27 h1:QMIbaTxibMc/OsO5RTAuKZ8ndbl2dGN6pITQEtp2x/A= |
349 | github.com/tal-tech/go-zero v1.0.27/go.mod h1:JtNXlsh/CgeIHyQnt5C5M2IcSevW7V0NAnqO93TQgm8= | 376 | github.com/tal-tech/go-zero v1.0.27/go.mod h1:JtNXlsh/CgeIHyQnt5C5M2IcSevW7V0NAnqO93TQgm8= |
350 | -github.com/tiptok/egglib-go v0.0.0-20210608073225-c852ce95ae34 h1:9iDNyYbfpv5KLWDLpDywD/aIODg+PNnwn+v9on7KGlE= | ||
351 | -github.com/tiptok/egglib-go v0.0.0-20210608073225-c852ce95ae34/go.mod h1:KT8WFA2LPo5zVKbomCR6HocO4prnIY9DUVGekA3Ifo4= | 377 | +github.com/tidwall/gjson v1.13.0 h1:3TFY9yxOQShrvmjdM76K+jc66zJeT6D3/VFFYCGQf7M= |
378 | +github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= | ||
379 | +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= | ||
380 | +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= | ||
381 | +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= | ||
382 | +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= | ||
383 | +github.com/tiptok/egglib-go v0.0.0-20220120032512-24dfab2b4987 h1:0e2hOSL+//5AL7e1r3xCGEugsOPsw2POAm82VZvWLe4= | ||
384 | +github.com/tiptok/egglib-go v0.0.0-20220120032512-24dfab2b4987/go.mod h1:xl9i83IKNUkwlobRF6XLKn1RRbZsT+7yhCicpTGWTKc= | ||
352 | github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= | 385 | github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= |
353 | github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= | 386 | github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= |
354 | github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= | 387 | github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= |
@@ -381,6 +414,10 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17 | @@ -381,6 +414,10 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17 | ||
381 | github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= | 414 | github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= |
382 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= | 415 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= |
383 | github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= | 416 | github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= |
417 | +github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 h1:EpI0bqf/eX9SdZDwlMmahKM+CDBgNbsXMhsN28XrM8o= | ||
418 | +github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= | ||
419 | +github.com/xuri/excelize/v2 v2.4.1 h1:veeeFLAJwsNEBPBlDepzPIYS1eLyBVcXNZUW79exZ1E= | ||
420 | +github.com/xuri/excelize/v2 v2.4.1/go.mod h1:rSu0C3papjzxQA3sdK8cU544TebhrPUoTOaGPIh0Q1A= | ||
384 | github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2/go.mod h1:hzfGeIUDq/j97IG+FhNqkowIyEcD88LrW6fyU3K3WqY= | 421 | github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2/go.mod h1:hzfGeIUDq/j97IG+FhNqkowIyEcD88LrW6fyU3K3WqY= |
385 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= | 422 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= |
386 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= | 423 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= |
@@ -413,6 +450,8 @@ go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bj | @@ -413,6 +450,8 @@ go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bj | ||
413 | go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= | 450 | go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= |
414 | go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= | 451 | go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= |
415 | go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= | 452 | go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= |
453 | +go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4= | ||
454 | +go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI= | ||
416 | go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= | 455 | go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= |
417 | go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= | 456 | go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= |
418 | go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= | 457 | go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= |
@@ -427,9 +466,12 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U | @@ -427,9 +466,12 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U | ||
427 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | 466 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= |
428 | golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= | 467 | golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= |
429 | golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= | 468 | golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= |
430 | -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= | ||
431 | golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= | 469 | golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= |
470 | +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= | ||
471 | +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||
432 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | 472 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= |
473 | +golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk= | ||
474 | +golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||
433 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= | 475 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
434 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= | 476 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= |
435 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= | 477 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= |
@@ -456,6 +498,7 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL | @@ -456,6 +498,7 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL | ||
456 | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 498 | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
457 | golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 499 | golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
458 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 500 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
501 | +golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= | ||
459 | golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= | 502 | golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= |
460 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | 503 | golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= |
461 | golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | 504 | golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |
@@ -463,8 +506,9 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY | @@ -463,8 +506,9 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY | ||
463 | golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | 506 | golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |
464 | golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | 507 | golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |
465 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | 508 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
466 | -golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I= | ||
467 | golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | 509 | golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
510 | +golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 h1:4CSI6oo7cOjJKajidEljs9h+uP0rRZBPPPhcCbj5mw8= | ||
511 | +golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
468 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | 512 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
469 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | 513 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
470 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | 514 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
@@ -504,8 +548,9 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7w | @@ -504,8 +548,9 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7w | ||
504 | golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 548 | golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
505 | golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 549 | golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
506 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | 550 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
507 | -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= | ||
508 | golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | 551 | golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
552 | +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= | ||
553 | +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
509 | golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= | 554 | golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= |
510 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | 555 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= |
511 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | 556 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
@@ -515,6 +560,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | @@ -515,6 +560,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
515 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= | 560 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= |
516 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | 561 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
517 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | 562 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
563 | +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||
564 | +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= | ||
518 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | 565 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
519 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | 566 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
520 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | 567 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
@@ -5,8 +5,13 @@ import ( | @@ -5,8 +5,13 @@ import ( | ||
5 | "github.com/beego/beego/v2/server/web" | 5 | "github.com/beego/beego/v2/server/web" |
6 | "github.com/linmadan/egglib-go/log/logrus" | 6 | "github.com/linmadan/egglib-go/log/logrus" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/mqtt" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/task" | ||
12 | + "time" | ||
9 | 13 | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab" | ||
10 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 15 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
11 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg" | 16 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg" |
12 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | 17 | _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" |
@@ -15,9 +20,11 @@ import ( | @@ -15,9 +20,11 @@ import ( | ||
15 | ) | 20 | ) |
16 | 21 | ||
17 | func main() { | 22 | func main() { |
18 | - log.Logger.Info("server start ....") | ||
19 | - log.Logger.Info(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG)) | ||
20 | - | 23 | + defer func() { |
24 | + if r := recover(); r != nil { | ||
25 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
26 | + } | ||
27 | + }() | ||
21 | if constant.ENABLE_KAFKA_LOG { | 28 | if constant.ENABLE_KAFKA_LOG { |
22 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) | 29 | w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) |
23 | log.Logger.AddHook(w) | 30 | log.Logger.AddHook(w) |
@@ -28,7 +35,17 @@ func main() { | @@ -28,7 +35,17 @@ func main() { | ||
28 | MaxSize: 1024 * 1024 * 2, | 35 | MaxSize: 1024 * 1024 * 2, |
29 | }) | 36 | }) |
30 | log.Logger.AddHook(bw) | 37 | log.Logger.AddHook(bw) |
38 | + redis.InitRedis() | ||
39 | + log.Logger.Info("server start ....") | ||
40 | + log.Logger.Debug(fmt.Sprintf("ENABLE_KAFKA_LOG:%v", constant.ENABLE_KAFKA_LOG)) | ||
31 | 41 | ||
42 | + go mqtt.Start(log.Logger) | ||
43 | + go task.Run() | ||
44 | + cron := crontab.NewCrontabService(nil) | ||
45 | + cron.StartCrontabTask() | ||
46 | + defer cron.StopCrontabTask() | ||
47 | + time.Sleep(time.Second) | ||
32 | log.Logger.Info("server start!") | 48 | log.Logger.Info("server start!") |
33 | web.Run() | 49 | web.Run() |
50 | + log.Logger.Info("server stop!") | ||
34 | } | 51 | } |
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 ApproveAttendanceCommand struct { | ||
12 | + // 考勤记录ID | ||
13 | + ProductAttendanceId int `cname:"考勤记录ID" json:"productAttendanceId" valid:"Required"` | ||
14 | + // 工时 | ||
15 | + WorkTimeAfter float64 `cname:"工时" json:"workTimeAfter,omitempty"` | ||
16 | + // 审核人Id | ||
17 | + ApproveUserId int `json:"approveUserId,omitempty"` | ||
18 | +} | ||
19 | + | ||
20 | +func (approveAttendanceCommand *ApproveAttendanceCommand) Valid(validation *validation.Validation) { | ||
21 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
22 | +} | ||
23 | + | ||
24 | +func (approveAttendanceCommand *ApproveAttendanceCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(approveAttendanceCommand) | ||
27 | + if err != nil { | ||
28 | + return err | ||
29 | + } | ||
30 | + if !b { | ||
31 | + elem := reflect.TypeOf(approveAttendanceCommand).Elem() | ||
32 | + for _, validErr := range valid.Errors { | ||
33 | + field, isExist := elem.FieldByName(validErr.Field) | ||
34 | + if isExist { | ||
35 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
36 | + } else { | ||
37 | + return fmt.Errorf(validErr.Message) | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + return nil | ||
42 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + "time" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type CreateAttendanceCommand struct { | ||
13 | + // 考勤记录ID | ||
14 | + //ProductAttendanceId int `cname:"考勤记录ID" json:"productAttendanceId" valid:"Required"` | ||
15 | + // 考勤类型 1.正常 2.支援 | ||
16 | + AttendanceType int `json:"attendanceType,omitempty"` | ||
17 | + // 生产班组Id | ||
18 | + ProductGroupId int `json:"productGroupId,omitempty" valid:"Required"` | ||
19 | + // 生产工人 | ||
20 | + ProductWorkerId int `json:"productWorkerId,omitempty" valid:"Required"` | ||
21 | + // 车间ID | ||
22 | + WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | ||
23 | + // 生产线ID | ||
24 | + LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | ||
25 | + // 工段ID | ||
26 | + SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | ||
27 | + // 签到 | ||
28 | + SignIn time.Time `json:"signIn,omitempty"` | ||
29 | + // 签退 | ||
30 | + SignOut time.Time `json:"signOut,omitempty"` | ||
31 | + // 考勤状态 1.未审核 2:已审核 3.自动审核 | ||
32 | + //AttendanceStatus int `json:"attendanceStatus,omitempty"` | ||
33 | +} | ||
34 | + | ||
35 | +func (createAttendanceCommand *CreateAttendanceCommand) Valid(validation *validation.Validation) { | ||
36 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
37 | +} | ||
38 | + | ||
39 | +func (createAttendanceCommand *CreateAttendanceCommand) ValidateCommand() error { | ||
40 | + valid := validation.Validation{} | ||
41 | + b, err := valid.Valid(createAttendanceCommand) | ||
42 | + if err != nil { | ||
43 | + return err | ||
44 | + } | ||
45 | + if !b { | ||
46 | + elem := reflect.TypeOf(createAttendanceCommand).Elem() | ||
47 | + for _, validErr := range valid.Errors { | ||
48 | + field, isExist := elem.FieldByName(validErr.Field) | ||
49 | + if isExist { | ||
50 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
51 | + } else { | ||
52 | + return fmt.Errorf(validErr.Message) | ||
53 | + } | ||
54 | + } | ||
55 | + } | ||
56 | + return nil | ||
57 | +} |
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 RemoveAttendanceCommand struct { | ||
12 | + // 考勤记录ID | ||
13 | + ProductAttendanceId int `cname:"考勤记录ID" json:"productAttendanceId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (removeAttendanceCommand *RemoveAttendanceCommand) Valid(validation *validation.Validation) { | ||
17 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (removeAttendanceCommand *RemoveAttendanceCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(removeAttendanceCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(removeAttendanceCommand).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 command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type UpdateAttendanceCommand struct { | ||
12 | + // 考勤记录ID | ||
13 | + ProductAttendanceId int `cname:"考勤记录ID" json:"productAttendanceId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (updateAttendanceCommand *UpdateAttendanceCommand) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (updateAttendanceCommand *UpdateAttendanceCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(updateAttendanceCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(updateAttendanceCommand).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 command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | +) | ||
10 | + | ||
11 | +type WorkerAttendanceReportCommand struct { | ||
12 | + *domain.DeviceZkTeco | ||
13 | +} | ||
14 | + | ||
15 | +func (removeProductRecordCommand *WorkerAttendanceReportCommand) Valid(validation *validation.Validation) { | ||
16 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
17 | +} | ||
18 | + | ||
19 | +func (removeProductRecordCommand *WorkerAttendanceReportCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(removeProductRecordCommand) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + elem := reflect.TypeOf(removeProductRecordCommand).Elem() | ||
27 | + for _, validErr := range valid.Errors { | ||
28 | + field, isExist := elem.FieldByName(validErr.Field) | ||
29 | + if isExist { | ||
30 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
31 | + } else { | ||
32 | + return fmt.Errorf(validErr.Message) | ||
33 | + } | ||
34 | + } | ||
35 | + } | ||
36 | + return nil | ||
37 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | +) | ||
10 | + | ||
11 | +type WorkshopWorkTimeRecordStaticsCommand struct { | ||
12 | + *domain.ProductAttendanceRecord | ||
13 | +} | ||
14 | + | ||
15 | +// Type is a string value that indicates the type of the task. | ||
16 | +//func (t *ProductRecordStaticsCommand) Type() string | ||
17 | + | ||
18 | +// Payload is the data needed for task execution. | ||
19 | +//func (t *ProductRecordStaticsCommand) Payload() []byte | ||
20 | + | ||
21 | +func (removeProductRecordCommand *WorkshopWorkTimeRecordStaticsCommand) Valid(validation *validation.Validation) { | ||
22 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
23 | +} | ||
24 | + | ||
25 | +func (removeProductRecordCommand *WorkshopWorkTimeRecordStaticsCommand) ValidateCommand() error { | ||
26 | + valid := validation.Validation{} | ||
27 | + b, err := valid.Valid(removeProductRecordCommand) | ||
28 | + if err != nil { | ||
29 | + return err | ||
30 | + } | ||
31 | + if !b { | ||
32 | + elem := reflect.TypeOf(removeProductRecordCommand).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 dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type AttendanceRecordDto struct { | ||
10 | + // 考勤记录ID | ||
11 | + ProductAttendanceId int `json:"productAttendanceId"` | ||
12 | + // 企业id | ||
13 | + //CompanyId int `json:"companyId,omitempty"` | ||
14 | + // 组织ID | ||
15 | + //OrgId int `json:"orgId,omitempty"` | ||
16 | + // 考勤类型 1.正常 2.支援 | ||
17 | + AttendanceType int `json:"attendanceType,omitempty"` | ||
18 | + // 班组名称 | ||
19 | + GroupName string `json:"groupName"` | ||
20 | + // 生产工人 | ||
21 | + ProductWorker *domain.User `json:"productWorker,omitempty"` | ||
22 | + // 审核人 | ||
23 | + ApproveUser *domain.User `json:"approveUser"` | ||
24 | + //*domain.ProductAttendanceRecordExt | ||
25 | + ApproveAt string `json:"approveAt"` | ||
26 | + // 工作位置 | ||
27 | + *domain.WorkStation | ||
28 | + // 签到 | ||
29 | + SignIn string `json:"signIn"` | ||
30 | + // 签退 | ||
31 | + SignOut string `json:"signOut"` | ||
32 | + // 考勤状态 1.未审核 2:已审核 3.自动审核 | ||
33 | + AttendanceStatus int `json:"attendanceStatus"` | ||
34 | + // 工时(审核前) | ||
35 | + WorkTimeBefore float64 `json:"workTimeBefore"` | ||
36 | + // 工时(审核后) | ||
37 | + WorkTimeAfter float64 `json:"workTimeAfter"` | ||
38 | + // 签到日期 | ||
39 | + SignDate string `json:"signDate"` | ||
40 | + // 组织名称 | ||
41 | + OrgName string `json:"orgName"` | ||
42 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
43 | + AuthFlag bool `json:"authFlag"` | ||
44 | +} | ||
45 | + | ||
46 | +func (d *AttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId int) *AttendanceRecordDto { | ||
47 | + d.ProductAttendanceId = m.ProductAttendanceId | ||
48 | + d.AttendanceType = m.AttendanceType | ||
49 | + d.ProductWorker = m.ProductWorker | ||
50 | + d.WorkStation = m.WorkStation | ||
51 | + if !m.SignIn.IsZero() { | ||
52 | + d.SignIn = m.SignIn.Local().Format("15:04:05") | ||
53 | + d.SignDate = m.SignIn.Local().Format("2006-01-02") | ||
54 | + } | ||
55 | + if !m.SignOut.IsZero() { | ||
56 | + d.SignOut = m.SignOut.Local().Format("15:04:05") | ||
57 | + } | ||
58 | + d.WorkTimeBefore = utils.Round(m.WorkTimeBefore, 1) | ||
59 | + d.WorkTimeAfter = m.WorkTimeAfter | ||
60 | + d.AttendanceStatus = m.AttendanceStatus | ||
61 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
62 | + if m.Ext != nil { | ||
63 | + d.OrgName = m.Ext.OrgName | ||
64 | + //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt | ||
65 | + //if | ||
66 | + if m.Ext.AttendanceExt != nil { | ||
67 | + if m.Ext.AttendanceExt.ApproveUserId > 0 { | ||
68 | + d.ApproveUser = &domain.User{ | ||
69 | + UserId: m.Ext.AttendanceExt.ApproveUserId, | ||
70 | + UserName: m.Ext.AttendanceExt.ApproveUserName, | ||
71 | + } | ||
72 | + } | ||
73 | + if m.Ext.AttendanceExt.ApproveAt > 0 { | ||
74 | + t := time.Unix(m.Ext.AttendanceExt.ApproveAt, 0) | ||
75 | + d.ApproveAt = t.Local().Format("2006-01-02 15:04:05") | ||
76 | + } | ||
77 | + d.GroupName = m.Ext.AttendanceExt.GroupName | ||
78 | + } | ||
79 | + } | ||
80 | + return d | ||
81 | +} |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
6 | +) | ||
7 | + | ||
8 | +type EmployeeAttendanceRecordDto struct { | ||
9 | + // 考勤记录ID | ||
10 | + ProductAttendanceId int `json:"productAttendanceId"` | ||
11 | + // 签到日期 | ||
12 | + SignDate string `json:"signDate"` | ||
13 | + // 工作位置 | ||
14 | + *domain.WorkStation | ||
15 | + // 班组名称 | ||
16 | + GroupName string `json:"groupName"` | ||
17 | + // 生产工人 | ||
18 | + ProductWorker *domain.User `json:"productWorker,omitempty"` | ||
19 | + // 考勤类型 1.正常 2.支援 | ||
20 | + AttendanceType int `json:"attendanceType,omitempty"` | ||
21 | + //*domain.ProductAttendanceRecordExt | ||
22 | + // 考勤状态 1.未审核 2:已审核 4.自动审核 | ||
23 | + AttendanceStatus int `json:"attendanceStatus"` | ||
24 | + // 考勤类型 1.正常 2.支援 | ||
25 | + AttendanceTypeDescription string `json:"attendanceTypeDescription,omitempty"` | ||
26 | + // 员工类型描述 1:固定 2:派遣 3.临时 | ||
27 | + EmployeeTypeDescription string `json:"employeeTypeDescription,omitempty"` | ||
28 | + // 考勤状态 1.未审核 2:已审核 4.自动审核 | ||
29 | + AttendanceStatusDescription string `json:"attendanceStatusDescription"` | ||
30 | + // 工时 | ||
31 | + WorkTime float64 `json:"workTime"` | ||
32 | + // 组织名称 | ||
33 | + OrgName string `json:"orgName"` | ||
34 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
35 | + AuthFlag bool `json:"authFlag"` | ||
36 | +} | ||
37 | + | ||
38 | +func (d *EmployeeAttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId int) *EmployeeAttendanceRecordDto { | ||
39 | + d.ProductAttendanceId = m.ProductAttendanceId | ||
40 | + d.AttendanceType = m.AttendanceType | ||
41 | + d.ProductWorker = m.ProductWorker | ||
42 | + d.WorkStation = m.WorkStation | ||
43 | + if !m.SignIn.IsZero() { | ||
44 | + //d.SignIn = m.SignIn.Format("15:04:05") | ||
45 | + d.SignDate = m.SignIn.Local().Format("2006-01-02") | ||
46 | + } | ||
47 | + d.WorkTime = utils.Round(m.WorkTimeAfter, 1) | ||
48 | + //d.WorkTimeAfter = m.WorkTimeAfter | ||
49 | + d.AttendanceStatus = m.AttendanceStatus | ||
50 | + d.AttendanceTypeDescription = domain.ParticipateTypeDescription(m.AttendanceType) | ||
51 | + d.EmployeeTypeDescription = domain.EmployeeTypeDescription(m.ProductWorker.EmployeeType) | ||
52 | + d.AttendanceStatusDescription = domain.AttendanceStatusDescription(m.AttendanceStatus) | ||
53 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
54 | + if m.Ext != nil { | ||
55 | + d.OrgName = m.Ext.OrgName | ||
56 | + //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt | ||
57 | + if m.Ext.AttendanceExt != nil { | ||
58 | + d.GroupName = m.Ext.AttendanceExt.GroupName | ||
59 | + } | ||
60 | + } | ||
61 | + return d | ||
62 | +} |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
6 | +) | ||
7 | + | ||
8 | +type WorkshopWorkTimeRecordDto struct { | ||
9 | + // 车间工时记录ID | ||
10 | + WorkshopWorkTimeRecordId int `json:"workshopWorkTimeRecordId"` | ||
11 | + // 工作位置 | ||
12 | + *domain.WorkStation | ||
13 | + // 签到日期 | ||
14 | + //SignDate string `json:"signDate"` | ||
15 | + // 记录信息 | ||
16 | + *domain.WorkshopWorkTimeRecordInfo | ||
17 | + // 记录日期 | ||
18 | + RecordDate string `json:"recordDate"` | ||
19 | + // 组织名称 | ||
20 | + OrgName string `json:"orgName"` | ||
21 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
22 | + AuthFlag bool `json:"authFlag"` | ||
23 | +} | ||
24 | + | ||
25 | +func (d *WorkshopWorkTimeRecordDto) LoadDto(m *domain.WorkshopWorkTimeRecord, orgId int) *WorkshopWorkTimeRecordDto { | ||
26 | + d.WorkshopWorkTimeRecordId = m.WorkshopWorkTimeRecordId | ||
27 | + d.WorkStation = m.WorkStation | ||
28 | + if m.WorkshopWorkTimeRecordInfo != nil { | ||
29 | + d.WorkshopWorkTimeRecordInfo = &domain.WorkshopWorkTimeRecordInfo{} | ||
30 | + d.WorkshopWorkTimeRecordInfo.EPTWorkTime = utils.Round(m.WorkshopWorkTimeRecordInfo.EPTWorkTime, 1) | ||
31 | + d.WorkshopWorkTimeRecordInfo.EDWorkTime = utils.Round(m.WorkshopWorkTimeRecordInfo.EDWorkTime, 1) | ||
32 | + d.WorkshopWorkTimeRecordInfo.EFTWorkTime = utils.Round(m.WorkshopWorkTimeRecordInfo.EFTWorkTime, 1) | ||
33 | + } | ||
34 | + d.WorkStation = m.WorkStation | ||
35 | + d.RecordDate = m.RecordDate.Local().Format("2006-01-02") | ||
36 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
37 | + if m.Ext != nil { | ||
38 | + d.OrgName = m.Ext.OrgName | ||
39 | + //d.ProductAttendanceRecordExt = m.Ext.AttendanceExt | ||
40 | + } | ||
41 | + return d | ||
42 | +} |
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 GetAttendanceQuery struct { | ||
12 | + // 考勤记录ID | ||
13 | + ProductAttendanceId int `cname:"考勤记录ID" json:"productAttendanceId" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (getAttendanceQuery *GetAttendanceQuery) Valid(validation *validation.Validation) { | ||
17 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (getAttendanceQuery *GetAttendanceQuery) ValidateQuery() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(getAttendanceQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(getAttendanceQuery).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 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListAttendanceQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | +} | ||
17 | + | ||
18 | +func (listAttendanceQuery *ListAttendanceQuery) Valid(validation *validation.Validation) { | ||
19 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | +} | ||
21 | + | ||
22 | +func (listAttendanceQuery *ListAttendanceQuery) ValidateQuery() error { | ||
23 | + valid := validation.Validation{} | ||
24 | + b, err := valid.Valid(listAttendanceQuery) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if !b { | ||
29 | + elem := reflect.TypeOf(listAttendanceQuery).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 query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type SearchAttendanceQuery struct { | ||
13 | + // 查询偏离量 | ||
14 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
15 | + // 查询限制 | ||
16 | + Limit int `cname:"查询限制" json:"limit"` | ||
17 | + // 当前公司 | ||
18 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
19 | + // 当前登录的组织 | ||
20 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty" ` | ||
21 | + // 匹配多个组织 | ||
22 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty" ` | ||
23 | + // 页码 | ||
24 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
25 | + // 页数 | ||
26 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
27 | + // 车间名称 | ||
28 | + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"` | ||
29 | + // 姓名 | ||
30 | + UserName string `cname:"姓名" json:"userName,omitempty"` | ||
31 | + // 考勤状态 1.未审核 2:已审核 3.自动审核 | ||
32 | + AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 3.自动审核" json:"attendanceStatus,omitempty"` | ||
33 | +} | ||
34 | + | ||
35 | +func (cmd *SearchAttendanceQuery) Valid(validation *validation.Validation) { | ||
36 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
37 | +} | ||
38 | + | ||
39 | +func (cmd *SearchAttendanceQuery) ValidateQuery() error { | ||
40 | + valid := validation.Validation{} | ||
41 | + b, err := valid.Valid(cmd) | ||
42 | + if err != nil { | ||
43 | + return err | ||
44 | + } | ||
45 | + if !b { | ||
46 | + elem := reflect.TypeOf(cmd).Elem() | ||
47 | + for _, validErr := range valid.Errors { | ||
48 | + field, isExist := elem.FieldByName(validErr.Field) | ||
49 | + if isExist { | ||
50 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
51 | + } else { | ||
52 | + return fmt.Errorf(validErr.Message) | ||
53 | + } | ||
54 | + } | ||
55 | + } | ||
56 | + return nil | ||
57 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
7 | + "reflect" | ||
8 | + "strings" | ||
9 | + "time" | ||
10 | + | ||
11 | + "github.com/beego/beego/v2/core/validation" | ||
12 | +) | ||
13 | + | ||
14 | +type SearchEmployeeAttendanceQuery struct { | ||
15 | + // 查询偏离量 | ||
16 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
17 | + // 查询限制 | ||
18 | + Limit int `cname:"查询限制" json:"limit"` | ||
19 | + // 当前公司 | ||
20 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
21 | + // 当前登录的组织 | ||
22 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty" ` | ||
23 | + // 匹配多个组织 | ||
24 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty" ` | ||
25 | + // 页码 | ||
26 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
27 | + // 页数 | ||
28 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
29 | + // 车间名称 | ||
30 | + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"` | ||
31 | + // 生产线名称 | ||
32 | + LineName string `cname:"生产线名称" json:"lineName,omitempty"` | ||
33 | + // 工段名称 | ||
34 | + SectionName string `cname:"工段名称" json:"sectionName,omitempty"` | ||
35 | + // 姓名 | ||
36 | + UserName string `cname:"姓名" json:"userName,omitempty"` | ||
37 | + // 考勤状态 1.未审核 2:已审核 3.自动审核 | ||
38 | + AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 3.自动审核" json:"attendanceStatus,omitempty"` | ||
39 | + // 员工类型 1:固定 2:派遣 3.临时 | ||
40 | + EmployeeType int `cname:"1:固定 2:派遣 3.临时" json:"employeeType,omitempty"` | ||
41 | + // 开始时间 | ||
42 | + BeginTime string `cname:"开始时间" json:"beginTime"` | ||
43 | + // 结束时间 | ||
44 | + EndTime string `cname:"结束时间" json:"endTime"` | ||
45 | + // 考勤状态 1.未审核 2:已审核 3.自动审核 | ||
46 | + InAttendanceStatus []int `cname:"考勤状态 1.未审核 2:已审核 3.自动审核" json:"inAttendanceStatus,omitempty"` | ||
47 | + | ||
48 | + // 开始时间 | ||
49 | + SignBeginTime time.Time `cname:"开始时间" json:"signBeginTime"` | ||
50 | + // 结束时间 | ||
51 | + SignEndTime time.Time `cname:"结束时间" json:"signEndTime"` | ||
52 | +} | ||
53 | + | ||
54 | +func (cmd *SearchEmployeeAttendanceQuery) Valid(validation *validation.Validation) { | ||
55 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
56 | + var err error | ||
57 | + if len(cmd.BeginTime) > 0 { | ||
58 | + if cmd.SignBeginTime, err = time.ParseInLocation("2006-01-02 15:04:05", cmd.BeginTime, time.Local); err != nil { | ||
59 | + log.Logger.Error(err.Error()) | ||
60 | + validation.Error("开始时间有误") | ||
61 | + return | ||
62 | + } | ||
63 | + } | ||
64 | + if len(cmd.EndTime) > 0 { | ||
65 | + if cmd.SignEndTime, err = time.ParseInLocation("2006-01-02 15:04:05", cmd.EndTime, time.Local); err != nil { | ||
66 | + log.Logger.Error(err.Error()) | ||
67 | + validation.Error("结束时间有误") | ||
68 | + return | ||
69 | + } | ||
70 | + if cmd.SignBeginTime.Equal(cmd.SignEndTime) { | ||
71 | + cmd.SignEndTime = cmd.SignEndTime.Add(time.Hour * 24) | ||
72 | + } | ||
73 | + } | ||
74 | + //cmd.AttendanceStatus = 6 // 审核 + 自动审核 | ||
75 | + cmd.InAttendanceStatus = []int{2, 3} | ||
76 | +} | ||
77 | + | ||
78 | +func (cmd *SearchEmployeeAttendanceQuery) ValidateQuery() error { | ||
79 | + valid := validation.Validation{} | ||
80 | + b, err := valid.Valid(cmd) | ||
81 | + if err != nil { | ||
82 | + return err | ||
83 | + } | ||
84 | + if !b { | ||
85 | + elem := reflect.TypeOf(cmd).Elem() | ||
86 | + for _, validErr := range valid.Errors { | ||
87 | + field, isExist := elem.FieldByName(validErr.Field) | ||
88 | + if isExist { | ||
89 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
90 | + } else { | ||
91 | + return fmt.Errorf(validErr.Message) | ||
92 | + } | ||
93 | + } | ||
94 | + } | ||
95 | + return nil | ||
96 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/dto" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/query" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
12 | + "time" | ||
13 | +) | ||
14 | + | ||
15 | +type AttendanceService struct { | ||
16 | +} | ||
17 | + | ||
18 | +// 审核工时 | ||
19 | +func (attendanceService *AttendanceService) ApproveAttendance(cmd *command.ApproveAttendanceCommand) (interface{}, error) { | ||
20 | + if err := cmd.ValidateCommand(); err != nil { | ||
21 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
22 | + } | ||
23 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
24 | + if err != nil { | ||
25 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
26 | + } | ||
27 | + if err := transactionContext.StartTransaction(); err != nil { | ||
28 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
29 | + } | ||
30 | + defer func() { | ||
31 | + transactionContext.RollbackTransaction() | ||
32 | + }() | ||
33 | + var productAttendanceRecordRepository domain.ProductAttendanceRecordRepository | ||
34 | + var attendance *domain.ProductAttendanceRecord | ||
35 | + productAttendanceRecordRepository, attendance, err = factory.FastPgAttendance(transactionContext, cmd.ProductAttendanceId) | ||
36 | + if err != nil { | ||
37 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
38 | + } | ||
39 | + | ||
40 | + var user *domain.User | ||
41 | + userService := domainService.NewUserService() | ||
42 | + user, err = userService.User(cmd.ApproveUserId) | ||
43 | + if err != nil { | ||
44 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
45 | + } | ||
46 | + | ||
47 | + if err = attendance.Approve(user, cmd.WorkTimeAfter, domain.AttendanceApproved); err != nil { | ||
48 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
49 | + } | ||
50 | + | ||
51 | + if _, err := productAttendanceRecordRepository.Save(attendance); err != nil { | ||
52 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
53 | + } | ||
54 | + if err := domainService.SendWorkshopWorkTimeStaticJob(attendance); err != nil { | ||
55 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
56 | + } | ||
57 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
58 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
59 | + } | ||
60 | + return struct{}{}, nil | ||
61 | +} | ||
62 | + | ||
63 | +// 创建 | ||
64 | +func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain.OperateInfo, cmd *command.CreateAttendanceCommand) (interface{}, error) { | ||
65 | + if err := cmd.ValidateCommand(); err != nil { | ||
66 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
67 | + } | ||
68 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
69 | + if err != nil { | ||
70 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
71 | + } | ||
72 | + if err := transactionContext.StartTransaction(); err != nil { | ||
73 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
74 | + } | ||
75 | + defer func() { | ||
76 | + transactionContext.RollbackTransaction() | ||
77 | + }() | ||
78 | + | ||
79 | + var user *domain.User | ||
80 | + userService := domainService.NewUserService() | ||
81 | + user, err = userService.User(cmd.ProductWorkerId) | ||
82 | + if err != nil { | ||
83 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
84 | + } | ||
85 | + | ||
86 | + var workStation *domain.WorkStation | ||
87 | + _, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId) | ||
88 | + if err != nil { | ||
89 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
90 | + } | ||
91 | + | ||
92 | + var org *domain.Org | ||
93 | + org, err = userService.Organization(operateInfo.OrgId) | ||
94 | + if err != nil { | ||
95 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
96 | + } | ||
97 | + | ||
98 | + var productGroup *domain.ProductGroup | ||
99 | + _, productGroup, err = factory.FastPgProductGroup(transactionContext, cmd.ProductGroupId) | ||
100 | + if err != nil { | ||
101 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
102 | + } | ||
103 | + newAttendance := &domain.ProductAttendanceRecord{ | ||
104 | + //ProductAttendanceId: cmd.ProductAttendanceId, | ||
105 | + CompanyId: operateInfo.CompanyId, | ||
106 | + OrgId: operateInfo.OrgId, | ||
107 | + AttendanceType: cmd.AttendanceType, | ||
108 | + ProductWorker: user, | ||
109 | + WorkStation: workStation, | ||
110 | + SignIn: cmd.SignIn, | ||
111 | + SignOut: cmd.SignOut, | ||
112 | + AttendanceStatus: domain.AttendanceNotApprove, | ||
113 | + WorkTimeBefore: 0, | ||
114 | + WorkTimeAfter: 0, | ||
115 | + CreatedAt: time.Now(), | ||
116 | + UpdatedAt: time.Now(), | ||
117 | + Ext: domain.NewExt(org.OrgName).WithAttendanceExt(&domain.ProductAttendanceRecordExt{ | ||
118 | + GroupName: productGroup.GroupName, | ||
119 | + ProductGroupId: productGroup.ProductGroupId, | ||
120 | + }), | ||
121 | + } | ||
122 | + newAttendance.WorkTimeBefore = newAttendance.ComputeWorkTimeBefore() | ||
123 | + var attendanceRepository domain.ProductAttendanceRecordRepository | ||
124 | + | ||
125 | + attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) | ||
126 | + | ||
127 | + if attendance, err := attendanceRepository.Save(newAttendance); err != nil { | ||
128 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
129 | + } else { | ||
130 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
131 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
132 | + } | ||
133 | + return attendance, nil | ||
134 | + } | ||
135 | +} | ||
136 | + | ||
137 | +// 返回 | ||
138 | +func (attendanceService *AttendanceService) GetAttendance(getAttendanceQuery *query.GetAttendanceQuery) (interface{}, error) { | ||
139 | + if err := getAttendanceQuery.ValidateQuery(); err != nil { | ||
140 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
141 | + } | ||
142 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
143 | + if err != nil { | ||
144 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
145 | + } | ||
146 | + if err := transactionContext.StartTransaction(); err != nil { | ||
147 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
148 | + } | ||
149 | + defer func() { | ||
150 | + transactionContext.RollbackTransaction() | ||
151 | + }() | ||
152 | + //var attendanceRepository domain.ProductAttendanceRecordRepository | ||
153 | + var attendance *domain.ProductAttendanceRecord | ||
154 | + _, attendance, err = factory.FastPgAttendance(transactionContext, getAttendanceQuery.ProductAttendanceId) | ||
155 | + if err != nil { | ||
156 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
157 | + } | ||
158 | + | ||
159 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
160 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
161 | + } | ||
162 | + result := &dto.AttendanceRecordDto{} | ||
163 | + result.LoadDto(attendance, 0) | ||
164 | + return result, nil | ||
165 | +} | ||
166 | + | ||
167 | +// 返回列表 | ||
168 | +func (attendanceService *AttendanceService) ListAttendance(listAttendanceQuery *query.ListAttendanceQuery) (interface{}, error) { | ||
169 | + if err := listAttendanceQuery.ValidateQuery(); err != nil { | ||
170 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
171 | + } | ||
172 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
173 | + if err != nil { | ||
174 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
175 | + } | ||
176 | + if err := transactionContext.StartTransaction(); err != nil { | ||
177 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
178 | + } | ||
179 | + defer func() { | ||
180 | + transactionContext.RollbackTransaction() | ||
181 | + }() | ||
182 | + //var attendanceRepository attendance.AttendanceRepository | ||
183 | + //if value, err := factory.CreateAttendanceRepository(map[string]interface{}{ | ||
184 | + // "transactionContext": transactionContext, | ||
185 | + //}); err != nil { | ||
186 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
187 | + //} else { | ||
188 | + // attendanceRepository = value | ||
189 | + //} | ||
190 | + //if count, attendances, err := attendanceRepository.Find(tool_funs.SimpleStructToMap(listAttendanceQuery)); err != nil { | ||
191 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
192 | + //} else { | ||
193 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
194 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
195 | + // } | ||
196 | + // return map[string]interface{}{ | ||
197 | + // "count": count, | ||
198 | + // "attendances": attendances, | ||
199 | + // }, nil | ||
200 | + //} | ||
201 | + return nil, nil | ||
202 | +} | ||
203 | + | ||
204 | +// 移除 | ||
205 | +func (attendanceService *AttendanceService) RemoveAttendance(removeAttendanceCommand *command.RemoveAttendanceCommand) (interface{}, error) { | ||
206 | + if err := removeAttendanceCommand.ValidateCommand(); err != nil { | ||
207 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
208 | + } | ||
209 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
210 | + if err != nil { | ||
211 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
212 | + } | ||
213 | + if err := transactionContext.StartTransaction(); err != nil { | ||
214 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
215 | + } | ||
216 | + defer func() { | ||
217 | + transactionContext.RollbackTransaction() | ||
218 | + }() | ||
219 | + var attendanceRepository domain.ProductAttendanceRecordRepository | ||
220 | + var attendance *domain.ProductAttendanceRecord | ||
221 | + | ||
222 | + attendanceRepository, attendance, err = factory.FastPgAttendance(transactionContext, removeAttendanceCommand.ProductAttendanceId) | ||
223 | + if err != nil { | ||
224 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
225 | + } | ||
226 | + | ||
227 | + if attendance, err := attendanceRepository.Remove(attendance); err != nil { | ||
228 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
229 | + } else { | ||
230 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
231 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
232 | + } | ||
233 | + return attendance, nil | ||
234 | + } | ||
235 | +} | ||
236 | + | ||
237 | +// 更新 | ||
238 | +func (attendanceService *AttendanceService) UpdateAttendance(updateAttendanceCommand *command.UpdateAttendanceCommand) (interface{}, error) { | ||
239 | + if err := updateAttendanceCommand.ValidateCommand(); err != nil { | ||
240 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
241 | + } | ||
242 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
243 | + if err != nil { | ||
244 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
245 | + } | ||
246 | + if err := transactionContext.StartTransaction(); err != nil { | ||
247 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
248 | + } | ||
249 | + defer func() { | ||
250 | + transactionContext.RollbackTransaction() | ||
251 | + }() | ||
252 | + //var attendanceRepository attendance.AttendanceRepository | ||
253 | + //if value, err := factory.CreateAttendanceRepository(map[string]interface{}{ | ||
254 | + // "transactionContext": transactionContext, | ||
255 | + //}); err != nil { | ||
256 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
257 | + //} else { | ||
258 | + // attendanceRepository = value | ||
259 | + //} | ||
260 | + //attendance, err := attendanceRepository.FindOne(map[string]interface{}{"attendanceId": updateAttendanceCommand.AttendanceId}) | ||
261 | + //if err != nil { | ||
262 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
263 | + //} | ||
264 | + //if attendance == nil { | ||
265 | + // return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateAttendanceCommand.AttendanceId))) | ||
266 | + //} | ||
267 | + //if err := attendance.Update(tool_funs.SimpleStructToMap(updateAttendanceCommand)); err != nil { | ||
268 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
269 | + //} | ||
270 | + //if attendance, err := attendanceRepository.Save(attendance); err != nil { | ||
271 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
272 | + //} else { | ||
273 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
274 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
275 | + // } | ||
276 | + // return attendance, nil | ||
277 | + //} | ||
278 | + return nil, nil | ||
279 | +} | ||
280 | + | ||
281 | +// 返回列表 | ||
282 | +func (attendanceService *AttendanceService) SearchAttendance(operateInfo *domain.OperateInfo, cmd *query.SearchAttendanceQuery) (int64, interface{}, error) { | ||
283 | + if err := cmd.ValidateQuery(); err != nil { | ||
284 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
285 | + } | ||
286 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
287 | + if err != nil { | ||
288 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
289 | + } | ||
290 | + if err := transactionContext.StartTransaction(); err != nil { | ||
291 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
292 | + } | ||
293 | + defer func() { | ||
294 | + transactionContext.RollbackTransaction() | ||
295 | + }() | ||
296 | + var attendanceRepository domain.ProductAttendanceRecordRepository | ||
297 | + attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) | ||
298 | + | ||
299 | + queryOptions := utils.ObjectToMap(cmd) | ||
300 | + | ||
301 | + count, attendances, err := attendanceRepository.Find(queryOptions) | ||
302 | + if err != nil { | ||
303 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
304 | + } | ||
305 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
306 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
307 | + } | ||
308 | + var result = make([]*dto.AttendanceRecordDto, 0) | ||
309 | + for i := range attendances { | ||
310 | + newItem := &dto.AttendanceRecordDto{} | ||
311 | + result = append(result, newItem.LoadDto(attendances[i], operateInfo.OrgId)) | ||
312 | + } | ||
313 | + return count, result, nil | ||
314 | +} | ||
315 | + | ||
316 | +// 员工工时统计 | ||
317 | +func (attendanceService *AttendanceService) SearchEmployeeAttendanceStatics(operateInfo *domain.OperateInfo, cmd *query.SearchEmployeeAttendanceQuery) (int64, interface{}, error) { | ||
318 | + if err := cmd.ValidateQuery(); err != nil { | ||
319 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
320 | + } | ||
321 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
322 | + if err != nil { | ||
323 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
324 | + } | ||
325 | + if err := transactionContext.StartTransaction(); err != nil { | ||
326 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
327 | + } | ||
328 | + defer func() { | ||
329 | + transactionContext.RollbackTransaction() | ||
330 | + }() | ||
331 | + var attendanceRepository domain.ProductAttendanceRecordRepository | ||
332 | + attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0) | ||
333 | + | ||
334 | + queryOptions := utils.ObjectToMap(cmd) | ||
335 | + count, attendances, err := attendanceRepository.Find(queryOptions) | ||
336 | + if err != nil { | ||
337 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
338 | + } | ||
339 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
340 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
341 | + } | ||
342 | + var result = make([]*dto.EmployeeAttendanceRecordDto, 0) | ||
343 | + for i := range attendances { | ||
344 | + newItem := &dto.EmployeeAttendanceRecordDto{} | ||
345 | + result = append(result, newItem.LoadDto(attendances[i], operateInfo.OrgId)) | ||
346 | + } | ||
347 | + return count, result, nil | ||
348 | +} | ||
349 | + | ||
350 | +// 车间工时统计 | ||
351 | +func (attendanceService *AttendanceService) SearchWorkshopWorkTimeStatics(operateInfo *domain.OperateInfo, cmd *query.SearchEmployeeAttendanceQuery) (int64, interface{}, error) { | ||
352 | + if err := cmd.ValidateQuery(); err != nil { | ||
353 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
354 | + } | ||
355 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
356 | + if err != nil { | ||
357 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
358 | + } | ||
359 | + if err := transactionContext.StartTransaction(); err != nil { | ||
360 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
361 | + } | ||
362 | + defer func() { | ||
363 | + transactionContext.RollbackTransaction() | ||
364 | + }() | ||
365 | + var attendanceRepository domain.WorkshopWorkTimeRecordRepository | ||
366 | + attendanceRepository, _, _ = factory.FastPgWorkshopWorkTimeRecord(transactionContext, 0) | ||
367 | + | ||
368 | + queryOptions := utils.ObjectToMap(cmd) | ||
369 | + count, attendances, err := attendanceRepository.Find(queryOptions) | ||
370 | + if err != nil { | ||
371 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
372 | + } | ||
373 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
374 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
375 | + } | ||
376 | + var result = make([]*dto.WorkshopWorkTimeRecordDto, 0) | ||
377 | + for i := range attendances { | ||
378 | + newItem := &dto.WorkshopWorkTimeRecordDto{} | ||
379 | + result = append(result, newItem.LoadDto(attendances[i], operateInfo.OrgId)) | ||
380 | + } | ||
381 | + return count, result, nil | ||
382 | +} | ||
383 | + | ||
384 | +func NewAttendanceService(options map[string]interface{}) *AttendanceService { | ||
385 | + newAttendanceService := &AttendanceService{} | ||
386 | + return newAttendanceService | ||
387 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/command" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
10 | +) | ||
11 | + | ||
12 | +func (attendanceService *AttendanceService) WorkerAttendanceReport(cmd *command.WorkerAttendanceReportCommand) (interface{}, error) { | ||
13 | + if err := cmd.ValidateCommand(); err != nil { | ||
14 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
15 | + } | ||
16 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
17 | + if err != nil { | ||
18 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
19 | + } | ||
20 | + if err := transactionContext.StartTransaction(); err != nil { | ||
21 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
22 | + } | ||
23 | + defer func() { | ||
24 | + transactionContext.RollbackTransaction() | ||
25 | + }() | ||
26 | + | ||
27 | + //svr, _ := domainService.NewPGWorkshopWorkTimeStaticService(transactionContext.(*pgTransaction.TransactionContext)) | ||
28 | + //if _, err := svr.WorkshopWorkTimeStatic(cmd.ProductAttendanceRecord); err != nil { | ||
29 | + // log.Logger.Error(err.Error()) | ||
30 | + // return nil, err | ||
31 | + //} | ||
32 | + attendanceReportService, _ := domainService.NewPGWorkerAttendanceReportService(transactionContext.(*pgTransaction.TransactionContext)) | ||
33 | + if _, err := attendanceReportService.Report(constant.MANUFACTURE_DEFAULT_COMPANYID, constant.MANUFACTURE_DEFAULT_ORGID, cmd.DeviceZkTeco); err != nil { | ||
34 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
35 | + } | ||
36 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
37 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
38 | + } | ||
39 | + return struct{}{}, nil | ||
40 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/attendance/command" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
10 | +) | ||
11 | + | ||
12 | +// 审核工时 | ||
13 | +func (attendanceService *AttendanceService) WorkshopWorkTimeRecordStatics(cmd *command.WorkshopWorkTimeRecordStaticsCommand) (interface{}, error) { | ||
14 | + if err := cmd.ValidateCommand(); err != nil { | ||
15 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
16 | + } | ||
17 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
18 | + if err != nil { | ||
19 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
20 | + } | ||
21 | + if err := transactionContext.StartTransaction(); err != nil { | ||
22 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
23 | + } | ||
24 | + defer func() { | ||
25 | + transactionContext.RollbackTransaction() | ||
26 | + }() | ||
27 | + | ||
28 | + svr, _ := domainService.NewPGWorkshopWorkTimeStaticService(transactionContext.(*pgTransaction.TransactionContext)) | ||
29 | + if _, err := svr.WorkshopWorkTimeStatic(cmd.ProductAttendanceRecord); err != nil { | ||
30 | + log.Logger.Error(err.Error()) | ||
31 | + return nil, err | ||
32 | + } | ||
33 | + | ||
34 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
35 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
36 | + } | ||
37 | + return struct{}{}, nil | ||
38 | +} |
pkg/application/crontab/crontab.go
0 → 100644
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/task" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/syncdata" | ||
10 | +) | ||
11 | + | ||
12 | +type CrontabService struct { | ||
13 | +} | ||
14 | + | ||
15 | +func NewCrontabService(options map[string]interface{}) *CrontabService { | ||
16 | + newCrontabService := &CrontabService{} | ||
17 | + return newCrontabService | ||
18 | +} | ||
19 | + | ||
20 | +func (crontabService *CrontabService) initTask() { | ||
21 | + //拉取物料数据 每5分执行 | ||
22 | + pullMaterialK3cloud := task.NewTask("pullMaterialK3cloud", "0 */5 0 * * *", func(ctx context.Context) error { | ||
23 | + srv := syncdata.PullDataK3CloudService{} | ||
24 | + return srv.PullMaterialNewest() | ||
25 | + }) | ||
26 | + task.AddTask("pullMaterialK3cloud", pullMaterialK3cloud) | ||
27 | + //拉取物料分组数据 每5分执行 | ||
28 | + pullMaterialGroupK3cloud := task.NewTask("pullMaterialGroupK3cloud", "0 */5 0 * * *", func(ctx context.Context) error { | ||
29 | + srv := syncdata.PullDataK3CloudService{} | ||
30 | + return srv.PullMaterialGroup() | ||
31 | + }) | ||
32 | + task.AddTask("pullMaterialGroupK3cloud", pullMaterialGroupK3cloud) | ||
33 | + //拉取订生产订单数据 每5分执行 | ||
34 | + PullPrdMoK3cloud := task.NewTask("PullPrdMoK3cloud", "0 */5 0 * * *", func(ctx context.Context) error { | ||
35 | + srv := syncdata.PullDataK3CloudService{} | ||
36 | + return srv.PullPrdMoNewest() | ||
37 | + }) | ||
38 | + task.AddTask("PullPrdMoK3cloud", PullPrdMoK3cloud) | ||
39 | + | ||
40 | + autoApproveAttendanceRecord := task.NewTask("autoApproveAttendanceRecord", "0 */2 * * * *", AutoApproveProductAttendanceRecord) | ||
41 | + task.AddTask("autoApproveAttendanceRecord", autoApproveAttendanceRecord) | ||
42 | + | ||
43 | + autoApproveRecord := task.NewTask("autoApproveRecord", "0 */2 * * * *", AutoApproveProductRecord) | ||
44 | + task.AddTask("autoApproveRecord", autoApproveRecord) | ||
45 | + | ||
46 | + autoFlushDeviceDailyRunningRecord := task.NewTask("定时刷新设备每日运行记录", "0 */1 * * * *", AutoFlushDeviceDailyRunningRecord) | ||
47 | + task.AddTask("autoFlushDeviceDailyRunningRecord", autoFlushDeviceDailyRunningRecord) | ||
48 | + | ||
49 | + autoFlushDeviceDailyRunningRecordOEE := task.NewTask("定时刷新设备每日运行记录-OEE", "0 */10 * * * *", AutoFlushDeviceDailyRunningRecordOEE) | ||
50 | + task.AddTask("autoFlushDeviceDailyRunningRecordOEE", autoFlushDeviceDailyRunningRecordOEE) | ||
51 | + | ||
52 | + autoWorkshopPlanCompletionRecord := task.NewTask("定时刷新昨日车间计划完成纪录", "0 5 1-17/1 * * *", AutoWorkshopPlanCompletionRecord) | ||
53 | + task.AddTask("autoWorkshopPlanCompletionRecord", autoWorkshopPlanCompletionRecord) | ||
54 | + | ||
55 | + autoTodayWorkshopPlanCompletionRecord := task.NewTask("定时刷新当天车间计划完成纪录", "0 0 1-23/1 * * *", AutoTodayWorkshopPlanCompletionRecord) // 1:00, 4:00, 每三个小时运行一次 | ||
56 | + task.AddTask("autoTodayWorkshopPlanCompletionRecord", autoTodayWorkshopPlanCompletionRecord) | ||
57 | + | ||
58 | + syncProductPlan := task.NewTask("定时同步车间计划", "0 */5 * * * *", SyncProductPlan) | ||
59 | + task.AddTask("SyncProductPlan", syncProductPlan) | ||
60 | + | ||
61 | + syncProduct := task.NewTask("定时同步产品信息", "0 */30 * * * *", SyncProduct) | ||
62 | + task.AddTask("syncProduct", syncProduct) | ||
63 | +} | ||
64 | + | ||
65 | +func (crontabService *CrontabService) StartCrontabTask() { | ||
66 | + crontabService.initTask() | ||
67 | + task.StartTask() | ||
68 | + log.Logger.Info("crontab start!") | ||
69 | +} | ||
70 | + | ||
71 | +func (crontabService *CrontabService) StopCrontabTask() { | ||
72 | + task.StopTask() | ||
73 | + log.Logger.Info("crontab stop!") | ||
74 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
12 | +) | ||
13 | + | ||
14 | +// 定时审核生产考勤记录 | ||
15 | +func AutoApproveProductAttendanceRecord(ctx context.Context) error { | ||
16 | + defer func() { | ||
17 | + if r := recover(); r != nil { | ||
18 | + log.Logger.Error(fmt.Sprintf("%v", r), map[string]interface{}{"task": "定时审核生产考勤记录"}) | ||
19 | + } | ||
20 | + }() | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + if err != nil { | ||
30 | + log.Logger.Error("【定时审核生产考勤记录】 失败:" + err.Error()) | ||
31 | + } | ||
32 | + transactionContext.RollbackTransaction() | ||
33 | + }() | ||
34 | + | ||
35 | + attendanceRecordDao, _ := dao.NewAttendanceRecordDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
36 | + var records []*domain.ProductAttendanceRecord | ||
37 | + _, records, err = attendanceRecordDao.RecentUnApprovedAttendanceRecord(24, 2) | ||
38 | + if err != nil { | ||
39 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时审核生产考勤记录"}) | ||
40 | + return err | ||
41 | + } | ||
42 | + | ||
43 | + approveAttendanceRecordsService, _ := domainService.NewPGApproveAttendanceRecordsService(transactionContext.(*pgTransaction.TransactionContext)) | ||
44 | + | ||
45 | + if _, err = approveAttendanceRecordsService.BatchApproveAttendanceRecords(nil, records, 0, 0, domain.AttendanceAutoApproved); err != nil { | ||
46 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时审核生产考勤记录"}) | ||
47 | + return err | ||
48 | + } | ||
49 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
50 | + return err | ||
51 | + } | ||
52 | + return nil | ||
53 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
12 | +) | ||
13 | + | ||
14 | +// 定时审核生产记录 | ||
15 | +func AutoApproveProductRecord(ctx context.Context) error { | ||
16 | + defer func() { | ||
17 | + if r := recover(); r != nil { | ||
18 | + log.Logger.Error(fmt.Sprintf("%v", r), map[string]interface{}{"task": "定时审核生产记录"}) | ||
19 | + } | ||
20 | + }() | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + if err != nil { | ||
30 | + log.Logger.Error("【定时审核生产考勤记录】 失败:" + err.Error()) | ||
31 | + } | ||
32 | + transactionContext.RollbackTransaction() | ||
33 | + }() | ||
34 | + | ||
35 | + attendanceRecordDao, _ := dao.NewProductRecordDao(transactionContext.(*pgTransaction.TransactionContext)) | ||
36 | + var records []*domain.ProductRecord | ||
37 | + _, records, err = attendanceRecordDao.RecentUnApprovedProductRecord(24, 2, domain.RecordTypeSecondLevelWeigh) | ||
38 | + if err != nil { | ||
39 | + return err | ||
40 | + } | ||
41 | + | ||
42 | + approveAttendanceRecordsService, _ := domainService.NewPGProductRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
43 | + | ||
44 | + if _, err = approveAttendanceRecordsService.BatchApprove(records, 0, 0, domain.AttendanceAutoApproved); err != nil { | ||
45 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时审核生产记录"}) | ||
46 | + return err | ||
47 | + } | ||
48 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
49 | + return err | ||
50 | + } | ||
51 | + return nil | ||
52 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
9 | + "time" | ||
10 | +) | ||
11 | + | ||
12 | +// 定时刷新设备每日运行记录 | ||
13 | +func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | ||
14 | + defer func() { | ||
15 | + if r := recover(); r != nil { | ||
16 | + log.Logger.Error(fmt.Sprintf("%v", r), map[string]interface{}{"task": "定时刷新设备每日运行记录"}) | ||
17 | + } | ||
18 | + }() | ||
19 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
20 | + if err != nil { | ||
21 | + return err | ||
22 | + } | ||
23 | + if err := transactionContext.StartTransaction(); err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + defer func() { | ||
27 | + if err != nil { | ||
28 | + log.Logger.Error("【定时刷新设备每日运行记录】 失败:" + err.Error()) | ||
29 | + } | ||
30 | + transactionContext.RollbackTransaction() | ||
31 | + }() | ||
32 | + | ||
33 | + log.Logger.Debug("【定时刷新设备每日运行记录】 启动") | ||
34 | + deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0) | ||
35 | + // 获取redis里当天的记录 | ||
36 | + span := time.Duration(20) | ||
37 | + t := time.Now().Add(-time.Minute * span) | ||
38 | + records, err := redis.GetDeviceDailyAllRecord(t) | ||
39 | + if err != nil { | ||
40 | + log.Logger.Debug(err.Error()) | ||
41 | + return err | ||
42 | + } | ||
43 | + | ||
44 | + for _, v := range records { | ||
45 | + if v.UpdatedAt.Add(time.Minute * 20).Before(time.Now()) { | ||
46 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) | ||
47 | + continue | ||
48 | + } | ||
49 | + | ||
50 | + // 更新设备效率 OEE = tu * pu * qu | ||
51 | + | ||
52 | + if _, err := deviceDailyRunningRecordRepository.Save(v); err != nil { | ||
53 | + log.Logger.Error(err.Error(), map[string]interface{}{"record": v}) | ||
54 | + continue | ||
55 | + } else { | ||
56 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 刷新记录 %v", v)) | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
61 | + return err | ||
62 | + } | ||
63 | + return nil | ||
64 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/dao" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
14 | + "time" | ||
15 | +) | ||
16 | + | ||
17 | +// 定时刷新设备每日运行记录 | ||
18 | +func AutoFlushDeviceDailyRunningRecordOEE(ctx context.Context) error { | ||
19 | + defer func() { | ||
20 | + if r := recover(); r != nil { | ||
21 | + log.Logger.Error(fmt.Sprintf("%v", r), map[string]interface{}{"task": "定时刷新设备每日运行记录"}) | ||
22 | + } | ||
23 | + }() | ||
24 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
25 | + if err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + if err := transactionContext.StartTransaction(); err != nil { | ||
29 | + return err | ||
30 | + } | ||
31 | + defer func() { | ||
32 | + if err != nil { | ||
33 | + log.Logger.Error("【定时刷新设备每日运行记录-OEE】 失败:" + err.Error()) | ||
34 | + } | ||
35 | + transactionContext.RollbackTransaction() | ||
36 | + }() | ||
37 | + | ||
38 | + log.Logger.Debug("【定时刷新设备每日运行记录-OEE】 启动") | ||
39 | + deviceDailyRunningRecordRepository, _, _ := factory.FastPgDeviceDailyRunningRecord(transactionContext, 0) | ||
40 | + // 获取redis里当天的记录 | ||
41 | + span := time.Duration(20) | ||
42 | + t := time.Now().Add(-time.Minute * span) | ||
43 | + records, err := redis.GetDeviceDailyAllRecord(t) | ||
44 | + if err != nil { | ||
45 | + log.Logger.Error(err.Error()) | ||
46 | + return err | ||
47 | + } | ||
48 | + total := 24 * 60 * 60 | ||
49 | + deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | ||
50 | + workshopProductRecordDao, _ := dao.NewWorkshopProductRecordDao(transactionContext.(*pg.TransactionContext)) | ||
51 | + | ||
52 | + for _, v := range records { | ||
53 | + //if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) { | ||
54 | + // log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录-OEE】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) | ||
55 | + // continue | ||
56 | + //} | ||
57 | + | ||
58 | + var ( | ||
59 | + pu float64 = 100 | ||
60 | + qu float64 = 100 | ||
61 | + ) | ||
62 | + | ||
63 | + // 更新设备效率 OEE = tu * pu * qu | ||
64 | + /* | ||
65 | + pu 性能利用 | ||
66 | + 设备标准工时, | ||
67 | + 没有配置设备标准工时的为100 | ||
68 | + */ | ||
69 | + | ||
70 | + // 只计算串串机 | ||
71 | + if v.DeviceRunningRecordInfo.DeviceType == domain.DeviceTypeChuanChuanJi { | ||
72 | + // 设备数据(标准工时) | ||
73 | + device, err := deviceRepository.FindOne(map[string]interface{}{"deviceId": v.DeviceId}) | ||
74 | + if device != nil && err == nil { | ||
75 | + if device.Ext.DeviceExt != nil { | ||
76 | + pu = utils.Round((float64(v.DeviceRunningRecordInfo.Count)*100.0)/(float64(total)/device.Ext.DeviceExt.UnitProductionSecTime), 1) | ||
77 | + } | ||
78 | + } | ||
79 | + // 工段对应二级品数据 | ||
80 | + | ||
81 | + record, err := workshopProductRecordDao.WorkStationProductRecord(v.CompanyId, v.OrgId, v.WorkStation.WorkStationId, t) | ||
82 | + if record != nil && err == nil { | ||
83 | + qu = float64(v.DeviceRunningRecordInfo.Count) * domainService.DefaultCCJUnitQuantity | ||
84 | + qu = utils.Round((qu-record.SecondLevelWeigh)*100/qu, 1) | ||
85 | + } | ||
86 | + } | ||
87 | + | ||
88 | + v.DeviceRunningRecordInfo.ResetOEE(pu, qu) | ||
89 | + | ||
90 | + if _, err := deviceDailyRunningRecordRepository.Save(v); err != nil { | ||
91 | + log.Logger.Error(err.Error()) | ||
92 | + continue | ||
93 | + } | ||
94 | + if err := redis.SaveDeviceDailyRunningRecord(v); err != nil { | ||
95 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时刷新设备每日运行记录"}) | ||
96 | + continue | ||
97 | + } | ||
98 | + log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录-OEE】 刷新记录 %v", v)) | ||
99 | + } | ||
100 | + | ||
101 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
102 | + return err | ||
103 | + } | ||
104 | + return nil | ||
105 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
11 | + "time" | ||
12 | +) | ||
13 | + | ||
14 | +// 定时刷新车间计划完成纪录 | ||
15 | +func AutoWorkshopPlanCompletionRecord(ctx context.Context) error { | ||
16 | + defer func() { | ||
17 | + if r := recover(); r != nil { | ||
18 | + log.Logger.Error(fmt.Sprintf("%v", r), map[string]interface{}{"task": "定时刷新车间计划完成纪录"}) | ||
19 | + } | ||
20 | + }() | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + if err != nil { | ||
30 | + log.Logger.Error("【定时刷新车间计划备每日运行记录】 失败:" + err.Error()) | ||
31 | + } | ||
32 | + transactionContext.RollbackTransaction() | ||
33 | + }() | ||
34 | + | ||
35 | + log.Logger.Debug("【定时刷新车间计划每日运行记录】 启动") | ||
36 | + end := utils.GetZeroTime(time.Now()) | ||
37 | + begin := utils.GetZeroTime(end.Add(-time.Second)) | ||
38 | + approveAttendanceRecordsService, _ := domainService.NewPGWorkshopPlanCompletionRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
39 | + | ||
40 | + if err = approveAttendanceRecordsService.WorkshopPlanCompletion(begin, end, "yesterday"); err != nil { | ||
41 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时刷新车间计划完成纪录"}) | ||
42 | + return err | ||
43 | + } | ||
44 | + | ||
45 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
46 | + return err | ||
47 | + } | ||
48 | + return nil | ||
49 | +} | ||
50 | + | ||
51 | +// 定时刷新当天车间计划完成纪录 | ||
52 | +func AutoTodayWorkshopPlanCompletionRecord(ctx context.Context) error { | ||
53 | + defer func() { | ||
54 | + if r := recover(); r != nil { | ||
55 | + log.Logger.Error(fmt.Sprintf("%v", r)) | ||
56 | + } | ||
57 | + }() | ||
58 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
59 | + if err != nil { | ||
60 | + return err | ||
61 | + } | ||
62 | + if err := transactionContext.StartTransaction(); err != nil { | ||
63 | + return err | ||
64 | + } | ||
65 | + defer func() { | ||
66 | + if err != nil { | ||
67 | + log.Logger.Error("【定时刷新车间计划今日运行记录】 失败:" + err.Error()) | ||
68 | + } | ||
69 | + transactionContext.RollbackTransaction() | ||
70 | + }() | ||
71 | + | ||
72 | + log.Logger.Debug("【定时刷新车间计划今日运行记录】 启动") | ||
73 | + begin := utils.GetZeroTime(time.Now()) | ||
74 | + end := time.Now() | ||
75 | + approveAttendanceRecordsService, _ := domainService.NewPGWorkshopPlanCompletionRecordService(transactionContext.(*pgTransaction.TransactionContext)) | ||
76 | + | ||
77 | + if err = approveAttendanceRecordsService.WorkshopPlanCompletion(begin, end, "today"); err != nil { | ||
78 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时刷新当天车间计划完成纪录"}) | ||
79 | + return err | ||
80 | + } | ||
81 | + | ||
82 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
83 | + return err | ||
84 | + } | ||
85 | + return nil | ||
86 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/syncdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
11 | + "runtime/debug" | ||
12 | + "time" | ||
13 | +) | ||
14 | + | ||
15 | +// SyncProduct 定时同步产品 | ||
16 | +func SyncProduct(ctx context.Context) error { | ||
17 | + defer func() { | ||
18 | + if r := recover(); r != nil { | ||
19 | + log.Logger.Error(fmt.Sprintf("%v", r), map[string]interface{}{"task": "定时同步产品", "stack": string(debug.Stack())}) | ||
20 | + } | ||
21 | + }() | ||
22 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if err := transactionContext.StartTransaction(); err != nil { | ||
27 | + return err | ||
28 | + } | ||
29 | + defer func() { | ||
30 | + if err != nil { | ||
31 | + log.Logger.Error("【定时同步产品信息】 失败:" + err.Error()) | ||
32 | + } | ||
33 | + transactionContext.RollbackTransaction() | ||
34 | + }() | ||
35 | + | ||
36 | + log.Logger.Debug("【定时同步同步产品信息】 启动") | ||
37 | + pullK3CloudService := syncdata.PullDataK3CloudService{} | ||
38 | + t := ctx.Value("fromTime") | ||
39 | + var fromTime time.Time | ||
40 | + if ctx != nil { | ||
41 | + if t != nil { | ||
42 | + if v, ok := t.(time.Time); ok { | ||
43 | + fromTime = v | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | + if fromTime.IsZero() { | ||
48 | + fromTime, err = redis.GetLastFetchTime(redis.MaterialK3cloudFetchTimeKey()) | ||
49 | + if err != nil { | ||
50 | + log.Logger.Error(err.Error()) | ||
51 | + return nil | ||
52 | + } | ||
53 | + } | ||
54 | + if err := pullK3CloudService.SyncDataProduct(transactionContext.(*pg.TransactionContext), fromTime); err != nil { | ||
55 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时同步产品"}) | ||
56 | + return nil | ||
57 | + } | ||
58 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
59 | + return err | ||
60 | + } | ||
61 | + return nil | ||
62 | +} |
1 | +package crontab | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/syncdata" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
10 | + "runtime/debug" | ||
11 | + "time" | ||
12 | +) | ||
13 | + | ||
14 | +// 定时同步生产计划 | ||
15 | +func SyncProductPlan(ctx context.Context) error { | ||
16 | + defer func() { | ||
17 | + if r := recover(); r != nil { | ||
18 | + log.Logger.Error(fmt.Sprintf("%v", r), map[string]interface{}{"task": "定时同步车间计划", "stack": debug.Stack()}) | ||
19 | + } | ||
20 | + }() | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return err | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + if err != nil { | ||
30 | + log.Logger.Error("【定时同步车间计划】 失败:" + err.Error()) | ||
31 | + } | ||
32 | + transactionContext.RollbackTransaction() | ||
33 | + }() | ||
34 | + | ||
35 | + log.Logger.Debug("【定时同步车间计划】 启动") | ||
36 | + pullK3CloudService := syncdata.PullDataK3CloudService{} | ||
37 | + var fromTime time.Time | ||
38 | + if ctx != nil { | ||
39 | + t := ctx.Value("fromTime") | ||
40 | + if t != nil { | ||
41 | + if v, ok := t.(time.Time); ok { | ||
42 | + fromTime = v | ||
43 | + } | ||
44 | + } | ||
45 | + } | ||
46 | + | ||
47 | + if err := pullK3CloudService.SyncDataProductPlan(transactionContext.(*pg.TransactionContext), fromTime); err != nil { | ||
48 | + log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时同步车间计划"}) | ||
49 | + return nil | ||
50 | + } | ||
51 | + if err = transactionContext.CommitTransaction(); err != nil { | ||
52 | + return err | ||
53 | + } | ||
54 | + return nil | ||
55 | +} |
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 BatchRemoveDeviceCommand struct { | ||
12 | + // ID列表 | ||
13 | + IdList []int `cname:"ID列表" json:"idList" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (removeDeviceCommand *BatchRemoveDeviceCommand) Valid(validation *validation.Validation) { | ||
17 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (removeDeviceCommand *BatchRemoveDeviceCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(removeDeviceCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(removeDeviceCommand).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 | +} |
@@ -22,21 +22,24 @@ type CreateDeviceCommand struct { | @@ -22,21 +22,24 @@ type CreateDeviceCommand struct { | ||
22 | // 设备类型 | 22 | // 设备类型 |
23 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` | 23 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` |
24 | // 车间ID | 24 | // 车间ID |
25 | - WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 25 | + WorkshopId int `cname:"车间ID" json:"workshopId"` |
26 | // 生产线ID | 26 | // 生产线ID |
27 | - LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | 27 | + LineId int `cname:"生产线ID" json:"lineId"` |
28 | // 工段ID | 28 | // 工段ID |
29 | - SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | 29 | + SectionId int `cname:"工段ID" json:"sectionId"` |
30 | // 品牌 | 30 | // 品牌 |
31 | - Brand string `cname:"品牌" json:"brand" valid:"Required"` | 31 | + Brand string `cname:"品牌" json:"brand"` |
32 | // 设备状态 1:正常 2:封存 3:报废 | 32 | // 设备状态 1:正常 2:封存 3:报废 |
33 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` | 33 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` |
34 | // 风险等级 1:高 2:中 3:低 | 34 | // 风险等级 1:高 2:中 3:低 |
35 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` | 35 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` |
36 | + | ||
37 | + // 标准工时 生产单个产品的时间(单位:秒) | ||
38 | + UnitProductionSecTime float64 `cname:"标准工时" json:"unitProductionSecTime"` | ||
36 | } | 39 | } |
37 | 40 | ||
38 | func (createDeviceCommand *CreateDeviceCommand) Valid(validation *validation.Validation) { | 41 | func (createDeviceCommand *CreateDeviceCommand) Valid(validation *validation.Validation) { |
39 | - validation.SetError("CustomValid", "未实现的自定义认证") | 42 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
40 | } | 43 | } |
41 | 44 | ||
42 | func (createDeviceCommand *CreateDeviceCommand) ValidateCommand() error { | 45 | func (createDeviceCommand *CreateDeviceCommand) ValidateCommand() error { |
@@ -14,7 +14,7 @@ type RemoveDeviceCommand struct { | @@ -14,7 +14,7 @@ type RemoveDeviceCommand struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (removeDeviceCommand *RemoveDeviceCommand) Valid(validation *validation.Validation) { | 16 | func (removeDeviceCommand *RemoveDeviceCommand) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (removeDeviceCommand *RemoveDeviceCommand) ValidateCommand() error { | 20 | func (removeDeviceCommand *RemoveDeviceCommand) ValidateCommand() error { |
@@ -20,21 +20,23 @@ type UpdateDeviceCommand struct { | @@ -20,21 +20,23 @@ type UpdateDeviceCommand struct { | ||
20 | // 设备类型 | 20 | // 设备类型 |
21 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` | 21 | DeviceType string `cname:"设备类型" json:"deviceType" valid:"Required"` |
22 | // 车间ID | 22 | // 车间ID |
23 | - WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 23 | + WorkshopId int `cname:"车间ID" json:"workshopId"` |
24 | // 生产线ID | 24 | // 生产线ID |
25 | - LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | 25 | + LineId int `cname:"生产线ID" json:"lineId" ` |
26 | // 工段ID | 26 | // 工段ID |
27 | - SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | 27 | + SectionId int `cname:"工段ID" json:"sectionId"` |
28 | // 品牌 | 28 | // 品牌 |
29 | - Brand string `cname:"品牌" json:"brand" valid:"Required"` | 29 | + Brand string `cname:"品牌" json:"brand"` |
30 | // 设备状态 1:正常 2:封存 3:报废 | 30 | // 设备状态 1:正常 2:封存 3:报废 |
31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` | 31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` |
32 | // 风险等级 1:高 2:中 3:低 | 32 | // 风险等级 1:高 2:中 3:低 |
33 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` | 33 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` |
34 | + // 标准工时 | ||
35 | + UnitProductionSecTime int `cname:"标准工时" json:"unitProductionSecTime"` | ||
34 | } | 36 | } |
35 | 37 | ||
36 | func (updateDeviceCommand *UpdateDeviceCommand) Valid(validation *validation.Validation) { | 38 | func (updateDeviceCommand *UpdateDeviceCommand) Valid(validation *validation.Validation) { |
37 | - validation.SetError("CustomValid", "未实现的自定义认证") | 39 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
38 | } | 40 | } |
39 | 41 | ||
40 | func (updateDeviceCommand *UpdateDeviceCommand) ValidateCommand() error { | 42 | func (updateDeviceCommand *UpdateDeviceCommand) ValidateCommand() error { |
pkg/application/device/dto/device_dto.go
0 → 100644
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | +) | ||
7 | + | ||
8 | +type DeviceDto struct { | ||
9 | + // 设备Id | ||
10 | + DeviceId int `json:"deviceId,omitempty"` | ||
11 | + // 设备编号 | ||
12 | + DeviceCode string `json:"deviceCode,omitempty"` | ||
13 | + // 设备名称 | ||
14 | + DeviceName string `json:"deviceName,omitempty"` | ||
15 | + // 设备型号 | ||
16 | + DeviceModel string `json:"deviceModel,omitempty"` | ||
17 | + // 设备类型 | ||
18 | + DeviceType string `json:"deviceType,omitempty"` | ||
19 | + // 品牌 | ||
20 | + Brand string `json:"brand,omitempty"` | ||
21 | + // 设备状态 1:正常 2:封存 3:报废 | ||
22 | + DeviceStatus int `json:"deviceStatus,omitempty"` | ||
23 | + // 风险等级 1:高 2:中 3:低 | ||
24 | + RiskLevel int `json:"riskLevel,omitempty"` | ||
25 | + // 所属位置 | ||
26 | + *domain.WorkStation | ||
27 | + // 生产单个产品的时间(单位:秒) | ||
28 | + UnitProductionSecTime string `json:"unitProductionSecTime"` | ||
29 | + | ||
30 | + // 组织名称 | ||
31 | + OrgName string `json:"orgName"` | ||
32 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
33 | + AuthFlag bool `json:"authFlag"` | ||
34 | +} | ||
35 | + | ||
36 | +func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | ||
37 | + d.DeviceId = m.DeviceId | ||
38 | + d.DeviceCode = m.DeviceCode | ||
39 | + d.DeviceName = m.DeviceName | ||
40 | + d.DeviceModel = m.DeviceModel | ||
41 | + d.DeviceType = m.DeviceType | ||
42 | + d.Brand = m.Brand | ||
43 | + d.DeviceStatus = m.DeviceStatus | ||
44 | + d.RiskLevel = m.RiskLevel | ||
45 | + d.WorkStation = m.WorkStation | ||
46 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
47 | + if m.Ext != nil { | ||
48 | + d.OrgName = m.Ext.OrgName | ||
49 | + } | ||
50 | + if m.Ext != nil && m.Ext.DeviceExt != nil { | ||
51 | + if m.Ext.DeviceExt.UnitProductionSecTime > 0 { | ||
52 | + d.UnitProductionSecTime = fmt.Sprintf("%v", m.Ext.DeviceExt.UnitProductionSecTime) | ||
53 | + } | ||
54 | + } | ||
55 | + return d | ||
56 | +} |
@@ -14,7 +14,7 @@ type GetDeviceQuery struct { | @@ -14,7 +14,7 @@ type GetDeviceQuery struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (getDeviceQuery *GetDeviceQuery) Valid(validation *validation.Validation) { | 16 | func (getDeviceQuery *GetDeviceQuery) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (getDeviceQuery *GetDeviceQuery) ValidateQuery() error { | 20 | func (getDeviceQuery *GetDeviceQuery) ValidateQuery() error { |
@@ -10,13 +10,13 @@ import ( | @@ -10,13 +10,13 @@ import ( | ||
10 | 10 | ||
11 | type ListDeviceQuery struct { | 11 | type ListDeviceQuery struct { |
12 | // 查询偏离量 | 12 | // 查询偏离量 |
13 | - Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | 13 | + Offset int `cname:"查询偏离量" json:"offset"` |
14 | // 查询限制 | 14 | // 查询限制 |
15 | Limit int `cname:"查询限制" json:"limit" valid:"Required"` | 15 | Limit int `cname:"查询限制" json:"limit" valid:"Required"` |
16 | } | 16 | } |
17 | 17 | ||
18 | func (listDeviceQuery *ListDeviceQuery) Valid(validation *validation.Validation) { | 18 | func (listDeviceQuery *ListDeviceQuery) Valid(validation *validation.Validation) { |
19 | - validation.SetError("CustomValid", "未实现的自定义认证") | 19 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
20 | } | 20 | } |
21 | 21 | ||
22 | func (listDeviceQuery *ListDeviceQuery) ValidateQuery() error { | 22 | func (listDeviceQuery *ListDeviceQuery) ValidateQuery() error { |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type SearchDeviceQuery struct { | ||
13 | + // 查询偏离量 | ||
14 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
15 | + // 查询限制 | ||
16 | + Limit int `cname:"查询限制" json:"limit"` | ||
17 | + // 当前公司 | ||
18 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
19 | + // 当前登录的组织 | ||
20 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
21 | + // 匹配多个组织 | ||
22 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty" valid:"Required"` | ||
23 | + // 页码 | ||
24 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
25 | + // 页数 | ||
26 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
27 | + // 设备名称 | ||
28 | + DeviceName string `json:"deviceName,omitempty"` | ||
29 | + // 设备状态 1:正常 2:封存 3:报废 | ||
30 | + DeviceStatus int `json:"deviceStatus,omitempty"` | ||
31 | + // 排除的设备列表 | ||
32 | + IncludeDevices []int `cname:"排除的设备列表" json:"includeDevices"` | ||
33 | +} | ||
34 | + | ||
35 | +func (cmd *SearchDeviceQuery) Valid(validation *validation.Validation) { | ||
36 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
37 | +} | ||
38 | + | ||
39 | +func (cmd *SearchDeviceQuery) ValidateQuery() error { | ||
40 | + valid := validation.Validation{} | ||
41 | + b, err := valid.Valid(cmd) | ||
42 | + if err != nil { | ||
43 | + return err | ||
44 | + } | ||
45 | + if !b { | ||
46 | + elem := reflect.TypeOf(cmd).Elem() | ||
47 | + for _, validErr := range valid.Errors { | ||
48 | + field, isExist := elem.FieldByName(validErr.Field) | ||
49 | + if isExist { | ||
50 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
51 | + } else { | ||
52 | + return fmt.Errorf(validErr.Message) | ||
53 | + } | ||
54 | + } | ||
55 | + } | ||
56 | + return nil | ||
57 | +} |
@@ -3,11 +3,16 @@ package service | @@ -3,11 +3,16 @@ package service | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "github.com/linmadan/egglib-go/core/application" | 5 | "github.com/linmadan/egglib-go/core/application" |
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | "github.com/linmadan/egglib-go/utils/tool_funs" | 7 | "github.com/linmadan/egglib-go/utils/tool_funs" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/device/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/device/command" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/device/dto" | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/device/query" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/device/query" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
15 | + "time" | ||
11 | ) | 16 | ) |
12 | 17 | ||
13 | // 设备服务 | 18 | // 设备服务 |
@@ -15,8 +20,10 @@ type DeviceService struct { | @@ -15,8 +20,10 @@ type DeviceService struct { | ||
15 | } | 20 | } |
16 | 21 | ||
17 | // 创建设备服务 | 22 | // 创建设备服务 |
18 | -func (deviceService *DeviceService) CreateDevice(createDeviceCommand *command.CreateDeviceCommand) (interface{}, error) { | ||
19 | - if err := createDeviceCommand.ValidateCommand(); err != nil { | 23 | +func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo, cmd *command.CreateDeviceCommand) (interface{}, error) { |
24 | + cmd.OrgId = operateInfo.OrgId | ||
25 | + cmd.CompanyId = operateInfo.CompanyId | ||
26 | + if err := cmd.ValidateCommand(); err != nil { | ||
20 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 27 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
21 | } | 28 | } |
22 | transactionContext, err := factory.CreateTransactionContext(nil) | 29 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -29,27 +36,51 @@ func (deviceService *DeviceService) CreateDevice(createDeviceCommand *command.Cr | @@ -29,27 +36,51 @@ func (deviceService *DeviceService) CreateDevice(createDeviceCommand *command.Cr | ||
29 | defer func() { | 36 | defer func() { |
30 | transactionContext.RollbackTransaction() | 37 | transactionContext.RollbackTransaction() |
31 | }() | 38 | }() |
39 | + | ||
40 | + var workStation *domain.WorkStation | ||
41 | + if cmd.WorkshopId != 0 { | ||
42 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) //, cmd.LineId, cmd.SectionId | ||
43 | + if err != nil { | ||
44 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
45 | + } | ||
46 | + workStation, _ = workshop.FindWorkStationOrNil(cmd.WorkshopId, cmd.LineId, cmd.SectionId) | ||
47 | + } | ||
48 | + | ||
49 | + var userService = domainService.NewUserService() | ||
50 | + var org *domain.Org | ||
51 | + org, err = userService.Organization(operateInfo.OrgId) | ||
52 | + if err != nil { | ||
53 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
54 | + } | ||
55 | + | ||
32 | newDevice := &domain.Device{ | 56 | newDevice := &domain.Device{ |
33 | - CompanyId: createDeviceCommand.CompanyId, | ||
34 | - OrgId: createDeviceCommand.OrgId, | ||
35 | - DeviceCode: createDeviceCommand.DeviceCode, | ||
36 | - DeviceName: createDeviceCommand.DeviceName, | ||
37 | - DeviceModel: createDeviceCommand.DeviceModel, | ||
38 | - DeviceType: createDeviceCommand.DeviceType, | ||
39 | - //WorkshopId: createDeviceCommand.WorkshopId, | ||
40 | - //LineId: createDeviceCommand.LineId, | ||
41 | - //SectionId: createDeviceCommand.SectionId, | ||
42 | - Brand: createDeviceCommand.Brand, | ||
43 | - DeviceStatus: createDeviceCommand.DeviceStatus, | ||
44 | - RiskLevel: createDeviceCommand.RiskLevel, | 57 | + CompanyId: cmd.CompanyId, |
58 | + OrgId: cmd.OrgId, | ||
59 | + DeviceCode: cmd.DeviceCode, | ||
60 | + DeviceName: cmd.DeviceName, | ||
61 | + DeviceModel: cmd.DeviceModel, | ||
62 | + DeviceType: cmd.DeviceType, | ||
63 | + WorkStation: workStation, | ||
64 | + Brand: cmd.Brand, | ||
65 | + DeviceStatus: cmd.DeviceStatus, | ||
66 | + RiskLevel: cmd.RiskLevel, | ||
67 | + CreatedAt: time.Now(), | ||
68 | + UpdatedAt: time.Now(), | ||
69 | + Ext: domain.NewExt(org.OrgName).WithDeviceExt(&domain.DeviceExt{UnitProductionSecTime: cmd.UnitProductionSecTime}), | ||
70 | + } | ||
71 | + deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | ||
72 | + | ||
73 | + if total, _, err := deviceRepository.Find(map[string]interface{}{ | ||
74 | + "deviceCode": cmd.DeviceCode, | ||
75 | + "companyId": cmd.CompanyId, | ||
76 | + "orgId": cmd.OrgId, | ||
77 | + "limit": 1, | ||
78 | + }); err == nil && total > 0 { | ||
79 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "设备编号重复") | ||
45 | } | 80 | } |
46 | - var deviceRepository domain.DeviceRepository | ||
47 | - if value, err := factory.CreateDeviceRepository(map[string]interface{}{ | ||
48 | - "transactionContext": transactionContext, | ||
49 | - }); err != nil { | 81 | + |
82 | + if err := newDevice.Valid(); err != nil { | ||
50 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 83 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
51 | - } else { | ||
52 | - deviceRepository = value | ||
53 | } | 84 | } |
54 | if device, err := deviceRepository.Save(newDevice); err != nil { | 85 | if device, err := deviceRepository.Save(newDevice); err != nil { |
55 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 86 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -94,7 +125,10 @@ func (deviceService *DeviceService) GetDevice(getDeviceQuery *query.GetDeviceQue | @@ -94,7 +125,10 @@ func (deviceService *DeviceService) GetDevice(getDeviceQuery *query.GetDeviceQue | ||
94 | if err := transactionContext.CommitTransaction(); err != nil { | 125 | if err := transactionContext.CommitTransaction(); err != nil { |
95 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 126 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
96 | } | 127 | } |
97 | - return device, nil | 128 | + |
129 | + result := &dto.DeviceDto{} | ||
130 | + result.LoadDto(device, 0) | ||
131 | + return result, nil | ||
98 | } | 132 | } |
99 | } | 133 | } |
100 | 134 | ||
@@ -174,9 +208,9 @@ func (deviceService *DeviceService) RemoveDevice(removeDeviceCommand *command.Re | @@ -174,9 +208,9 @@ func (deviceService *DeviceService) RemoveDevice(removeDeviceCommand *command.Re | ||
174 | } | 208 | } |
175 | } | 209 | } |
176 | 210 | ||
177 | -// 更新设备服务 | ||
178 | -func (deviceService *DeviceService) UpdateDevice(updateDeviceCommand *command.UpdateDeviceCommand) (interface{}, error) { | ||
179 | - if err := updateDeviceCommand.ValidateCommand(); err != nil { | 211 | +// 移除设备服务 |
212 | +func (deviceService *DeviceService) BatchRemoveDevice(cmd *command.BatchRemoveDeviceCommand) (interface{}, error) { | ||
213 | + if err := cmd.ValidateCommand(); err != nil { | ||
180 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 214 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
181 | } | 215 | } |
182 | transactionContext, err := factory.CreateTransactionContext(nil) | 216 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -197,16 +231,89 @@ func (deviceService *DeviceService) UpdateDevice(updateDeviceCommand *command.Up | @@ -197,16 +231,89 @@ func (deviceService *DeviceService) UpdateDevice(updateDeviceCommand *command.Up | ||
197 | } else { | 231 | } else { |
198 | deviceRepository = value | 232 | deviceRepository = value |
199 | } | 233 | } |
200 | - device, err := deviceRepository.FindOne(map[string]interface{}{"deviceId": updateDeviceCommand.DeviceId}) | 234 | + for i := range cmd.IdList { |
235 | + id := cmd.IdList[i] | ||
236 | + device, err := deviceRepository.FindOne(map[string]interface{}{"deviceId": id}) | ||
237 | + if err != nil { | ||
238 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
239 | + } | ||
240 | + if device == nil { | ||
241 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%d", id)) | ||
242 | + } | ||
243 | + if _, err := deviceRepository.Remove(device); err != nil { | ||
244 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
245 | + } | ||
246 | + } | ||
247 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
248 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
249 | + } | ||
250 | + return struct { | ||
251 | + }{}, nil | ||
252 | + | ||
253 | +} | ||
254 | + | ||
255 | +// 更新设备服务 | ||
256 | +func (deviceService *DeviceService) UpdateDevice(cmd *command.UpdateDeviceCommand) (interface{}, error) { | ||
257 | + if err := cmd.ValidateCommand(); err != nil { | ||
258 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
259 | + } | ||
260 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
261 | + if err != nil { | ||
262 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
263 | + } | ||
264 | + if err := transactionContext.StartTransaction(); err != nil { | ||
265 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
266 | + } | ||
267 | + defer func() { | ||
268 | + transactionContext.RollbackTransaction() | ||
269 | + }() | ||
270 | + var deviceRepository domain.DeviceRepository | ||
271 | + var device *domain.Device | ||
272 | + deviceRepository, device, err = factory.FastPgDevice(transactionContext, cmd.DeviceId) | ||
201 | if err != nil { | 273 | if err != nil { |
202 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 274 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
203 | } | 275 | } |
204 | - if device == nil { | ||
205 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDeviceCommand.DeviceId))) | 276 | + |
277 | + var workStation *domain.WorkStation | ||
278 | + //_, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId, factory.WithSetPrincipal()) | ||
279 | + //if err != nil { | ||
280 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
281 | + //} | ||
282 | + if cmd.WorkshopId != 0 { | ||
283 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) //, cmd.LineId, cmd.SectionId | ||
284 | + if err != nil { | ||
285 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
286 | + } | ||
287 | + workStation, _ = workshop.FindWorkStationOrNil(cmd.WorkshopId, cmd.LineId, cmd.SectionId) | ||
288 | + } | ||
289 | + device.WorkStation = workStation | ||
290 | + | ||
291 | + if cmd.DeviceCode != device.DeviceCode { | ||
292 | + if total, _, err := deviceRepository.Find(map[string]interface{}{ | ||
293 | + "deviceCode": cmd.DeviceCode, | ||
294 | + "companyId": device.CompanyId, | ||
295 | + "orgId": device.OrgId, | ||
296 | + "limit": 1, | ||
297 | + }); err == nil && total > 0 { | ||
298 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "设备编号重复") | ||
299 | + } | ||
300 | + } | ||
301 | + | ||
302 | + var userService = domainService.NewUserService() | ||
303 | + var org *domain.Org | ||
304 | + org, err = userService.Organization(device.OrgId) | ||
305 | + if err != nil { | ||
306 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
206 | } | 307 | } |
207 | - if err := device.Update(tool_funs.SimpleStructToMap(updateDeviceCommand)); err != nil { | 308 | + |
309 | + data := tool_funs.SimpleStructToMap(cmd) | ||
310 | + data["orgName"] = org.OrgName | ||
311 | + if err := device.Update(data); err != nil { | ||
208 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 312 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
209 | } | 313 | } |
314 | + if err := device.Valid(); err != nil { | ||
315 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
316 | + } | ||
210 | if device, err := deviceRepository.Save(device); err != nil { | 317 | if device, err := deviceRepository.Save(device); err != nil { |
211 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 318 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
212 | } else { | 319 | } else { |
@@ -217,6 +324,133 @@ func (deviceService *DeviceService) UpdateDevice(updateDeviceCommand *command.Up | @@ -217,6 +324,133 @@ func (deviceService *DeviceService) UpdateDevice(updateDeviceCommand *command.Up | ||
217 | } | 324 | } |
218 | } | 325 | } |
219 | 326 | ||
327 | +// 返回设备服务列表 | ||
328 | +func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo, listDeviceQuery *query.SearchDeviceQuery) (int64, interface{}, error) { | ||
329 | + if err := listDeviceQuery.ValidateQuery(); err != nil { | ||
330 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
331 | + } | ||
332 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
333 | + if err != nil { | ||
334 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
335 | + } | ||
336 | + if err := transactionContext.StartTransaction(); err != nil { | ||
337 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
338 | + } | ||
339 | + defer func() { | ||
340 | + transactionContext.RollbackTransaction() | ||
341 | + }() | ||
342 | + deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | ||
343 | + count, devices, err := deviceRepository.Find(utils.ObjectToMap(listDeviceQuery)) | ||
344 | + if err != nil { | ||
345 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
346 | + } | ||
347 | + workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) | ||
348 | + | ||
349 | + var result = make([]*dto.DeviceDto, 0) | ||
350 | + for i := range devices { | ||
351 | + item := devices[i] | ||
352 | + newJobDto := &dto.DeviceDto{} | ||
353 | + if item.WorkStation != nil && item.WorkStation.WorkshopId > 0 { | ||
354 | + newJobDto.WorkStation = workshops.FindWorkStationOrNil(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
355 | + } | ||
356 | + newJobDto.LoadDto(item, operateInfo.OrgId) | ||
357 | + result = append(result, newJobDto) | ||
358 | + } | ||
359 | + | ||
360 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
361 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
362 | + } | ||
363 | + return count, result, nil | ||
364 | +} | ||
365 | + | ||
366 | +// 返回设备服务列表 | ||
367 | +func (deviceService *DeviceService) SelectorDeviceUnbounded(operateInfo *domain.OperateInfo, listDeviceQuery *query.SearchDeviceQuery) (int64, interface{}, error) { | ||
368 | + if err := listDeviceQuery.ValidateQuery(); err != nil { | ||
369 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
370 | + } | ||
371 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
372 | + if err != nil { | ||
373 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
374 | + } | ||
375 | + if err := transactionContext.StartTransaction(); err != nil { | ||
376 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
377 | + } | ||
378 | + defer func() { | ||
379 | + transactionContext.RollbackTransaction() | ||
380 | + }() | ||
381 | + deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | ||
382 | + count, devices, err := deviceRepository.Find(utils.ObjectToMap(listDeviceQuery)) | ||
383 | + if err != nil { | ||
384 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
385 | + } | ||
386 | + workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) | ||
387 | + | ||
388 | + productJobRepository, _, _ := factory.FastPgProductJob(transactionContext, 0) | ||
389 | + _, productJobs, _ := productJobRepository.Find(map[string]interface{}{"companyId": listDeviceQuery.CompanyId}) | ||
390 | + var excludeMap = make(map[int]int) | ||
391 | + var allBoundedDevice = make([]int, 0) | ||
392 | + for i := range productJobs { | ||
393 | + allBoundedDevice = append(allBoundedDevice, productJobs[i].RelatedDevices...) | ||
394 | + } | ||
395 | + for _, v := range allBoundedDevice { | ||
396 | + exclude := false | ||
397 | + for _, j := range listDeviceQuery.IncludeDevices { | ||
398 | + if j == v { | ||
399 | + exclude = true | ||
400 | + } | ||
401 | + } | ||
402 | + if exclude { | ||
403 | + continue | ||
404 | + } | ||
405 | + excludeMap[v] = v | ||
406 | + } | ||
407 | + var result = make([]*dto.DeviceDto, 0) | ||
408 | + for i := range devices { | ||
409 | + item := devices[i] | ||
410 | + newJobDto := &dto.DeviceDto{} | ||
411 | + if _, ok := excludeMap[item.DeviceId]; ok { | ||
412 | + continue | ||
413 | + } | ||
414 | + if item.WorkStation != nil && item.WorkStation.WorkshopId > 0 { | ||
415 | + newJobDto.WorkStation = workshops.FindWorkStationOrNil(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
416 | + } | ||
417 | + newJobDto.LoadDto(item, operateInfo.OrgId) | ||
418 | + result = append(result, newJobDto) | ||
419 | + } | ||
420 | + | ||
421 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
422 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
423 | + } | ||
424 | + return count, result, nil | ||
425 | +} | ||
426 | + | ||
427 | +// 批量添加产品服务 | ||
428 | +func (deviceService *DeviceService) BatchAddProduct(opt *domain.OperateInfo, list []*domain.ImportDeviceItem) ([]interface{}, error) { | ||
429 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
430 | + if err != nil { | ||
431 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
432 | + } | ||
433 | + if err := transactionContext.StartTransaction(); err != nil { | ||
434 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
435 | + } | ||
436 | + defer func() { | ||
437 | + transactionContext.RollbackTransaction() | ||
438 | + }() | ||
439 | + | ||
440 | + batchAddProductService, _ := domainService.NewPGBatchAddDeviceService(transactionContext.(*pgTransaction.TransactionContext)) | ||
441 | + var failRows []interface{} | ||
442 | + if failRows, err = batchAddProductService.BatchAddDevice(opt, list); err != nil { | ||
443 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
444 | + } | ||
445 | + if len(failRows) != 0 { | ||
446 | + return failRows, nil //有错误行,回滚 | ||
447 | + } | ||
448 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
449 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
450 | + } | ||
451 | + return failRows, nil | ||
452 | +} | ||
453 | + | ||
220 | func NewDeviceService(options map[string]interface{}) *DeviceService { | 454 | func NewDeviceService(options map[string]interface{}) *DeviceService { |
221 | newDeviceService := &DeviceService{} | 455 | newDeviceService := &DeviceService{} |
222 | return newDeviceService | 456 | return newDeviceService |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + "time" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type CreateDeviceCollectionCommand struct { | ||
13 | + // 数据采集ID | ||
14 | + //DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
15 | + // 车间名 | ||
16 | + WorkShopName string `cname:"车间名" json:"workShopName" valid:"Required"` | ||
17 | + // 启动状态 1-启动 0-停止 | ||
18 | + StartupStatus int64 `cname:"启动状态 1-启动 0-停止" json:"startupStatus"` | ||
19 | + // 采集时间 | ||
20 | + CollectionTime time.Time `cname:"采集时间" json:"collectionTime" valid:"Required"` | ||
21 | + // 设备名 | ||
22 | + DeviceSn string `cname:"设备名" json:"deviceSn" valid:"Required"` | ||
23 | + // 设备类型 | ||
24 | + DeviceType string `comment:"设备类型" json:"deviceType" valid:"Required"` | ||
25 | + // 通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障 | ||
26 | + ComStatus int64 `cname:"通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障" json:"comStatus"` | ||
27 | + // 设备数据值 | ||
28 | + Values map[string]interface{} `cname:"设备数据值" json:"values" valid:"Required"` | ||
29 | + // 预查 | ||
30 | + PreCheck bool `json:"check"` | ||
31 | +} | ||
32 | + | ||
33 | +func (createDeviceCollectionCommand *CreateDeviceCollectionCommand) Valid(validation *validation.Validation) { | ||
34 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
35 | +} | ||
36 | + | ||
37 | +func (createDeviceCollectionCommand *CreateDeviceCollectionCommand) ValidateCommand() error { | ||
38 | + valid := validation.Validation{} | ||
39 | + b, err := valid.Valid(createDeviceCollectionCommand) | ||
40 | + if err != nil { | ||
41 | + return err | ||
42 | + } | ||
43 | + if !b { | ||
44 | + elem := reflect.TypeOf(createDeviceCollectionCommand).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 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type RemoveDeviceCollectionCommand struct { | ||
12 | + // 数据采集ID | ||
13 | + DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (removeDeviceCollectionCommand *RemoveDeviceCollectionCommand) Valid(validation *validation.Validation) { | ||
17 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (removeDeviceCollectionCommand *RemoveDeviceCollectionCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(removeDeviceCollectionCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(removeDeviceCollectionCommand).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 command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + "time" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type UpdateDeviceCollectionCommand struct { | ||
13 | + // 数据采集ID | ||
14 | + DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
15 | + // 车间名 | ||
16 | + WorkShopName string `cname:"车间名" json:"workShopName" valid:"Required"` | ||
17 | + // 启动状态 1-启动 0-停止 | ||
18 | + StartupStatus int64 `cname:"启动状态 1-启动 0-停止" json:"startupStatus"` | ||
19 | + // 采集时间 | ||
20 | + CollectionTime time.Time `cname:"采集时间" json:"collectionTime" valid:"Required"` | ||
21 | + // 设备名 | ||
22 | + DeviceSn string `cname:"设备名" json:"deviceSn" valid:"Required"` | ||
23 | + // 设备类型 | ||
24 | + DeviceType string `comment:"设备类型" json:"deviceType" valid:"Required"` | ||
25 | + // 通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障 | ||
26 | + ComStatus int64 `cname:"通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障" json:"comStatus"` | ||
27 | + // 设备数据值 | ||
28 | + Values map[string]interface{} `cname:"设备数据值" json:"values" valid:"Required"` | ||
29 | +} | ||
30 | + | ||
31 | +func (updateDeviceCollectionCommand *UpdateDeviceCollectionCommand) Valid(validation *validation.Validation) { | ||
32 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
33 | +} | ||
34 | + | ||
35 | +func (updateDeviceCollectionCommand *UpdateDeviceCollectionCommand) ValidateCommand() error { | ||
36 | + valid := validation.Validation{} | ||
37 | + b, err := valid.Valid(updateDeviceCollectionCommand) | ||
38 | + if err != nil { | ||
39 | + return err | ||
40 | + } | ||
41 | + if !b { | ||
42 | + elem := reflect.TypeOf(updateDeviceCollectionCommand).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 dto | ||
2 | + | ||
3 | +import "time" | ||
4 | + | ||
5 | +type DeviceCollectionDto struct { | ||
6 | + // 数据采集ID | ||
7 | + DeviceCollectionId int64 `json:"deviceCollectionId,string"` | ||
8 | + // 车间名 | ||
9 | + WorkShopName string `json:"workShopName"` | ||
10 | + // 采集时间 | ||
11 | + CollectionTime time.Time `json:"collectionTime"` | ||
12 | + // 设备名 | ||
13 | + DeviceSn string `json:"deviceSn"` | ||
14 | + // 设备类型 | ||
15 | + DeviceType string `json:"deviceType"` | ||
16 | + // 启动状态 1-启动 0-停止 | ||
17 | + StartupStatus int64 `json:"startupStatus"` | ||
18 | + // 通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障 | ||
19 | + ComStatus int64 `json:"comStatus"` | ||
20 | + // 设备数据值 | ||
21 | + Values map[string]interface{} `json:"values"` | ||
22 | +} |
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 GetDeviceCollectionQuery struct { | ||
12 | + // 数据采集ID | ||
13 | + DeviceCollectionId int64 `cname:"数据采集ID" json:"deviceCollectionId,string" valid:"Required"` | ||
14 | +} | ||
15 | + | ||
16 | +func (getDeviceCollectionQuery *GetDeviceCollectionQuery) Valid(validation *validation.Validation) { | ||
17 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | +} | ||
19 | + | ||
20 | +func (getDeviceCollectionQuery *GetDeviceCollectionQuery) ValidateQuery() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(getDeviceCollectionQuery) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + elem := reflect.TypeOf(getDeviceCollectionQuery).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 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + "time" | ||
9 | + | ||
10 | + "github.com/beego/beego/v2/core/validation" | ||
11 | +) | ||
12 | + | ||
13 | +type ListDeviceCollectionQuery struct { | ||
14 | + // 查询偏离量 | ||
15 | + PageNumber int64 `cname:"查询偏离量" json:"pageNumber" ` | ||
16 | + // 查询限制 | ||
17 | + PageSize int64 `cname:"查询限制" json:"pageSize" valid:"Required"` | ||
18 | + // 设备类型 | ||
19 | + DeviceType string `json:"deviceType" cname:"设备类型"` | ||
20 | + // 车间名 | ||
21 | + WorkShopName string `json:"workShopName"` | ||
22 | + | ||
23 | + // 开始时间 | ||
24 | + BeginTime string `cname:"开始时间" json:"beginTime"` | ||
25 | + // 结束时间 | ||
26 | + EndTime string `cname:"结束时间" json:"endTime"` | ||
27 | + | ||
28 | + // 开始时间 | ||
29 | + ProductBeginTime time.Time `cname:"开始时间" json:"productBeginTime"` | ||
30 | + // 结束时间 | ||
31 | + ProductEndTime time.Time `cname:"结束时间" json:"productEndTime"` | ||
32 | +} | ||
33 | + | ||
34 | +func (cmd *ListDeviceCollectionQuery) Valid(validation *validation.Validation) { | ||
35 | + var err error | ||
36 | + if len(cmd.BeginTime) > 0 { | ||
37 | + if cmd.ProductBeginTime, err = time.ParseInLocation("2006-01-02 15:04:05", cmd.BeginTime, time.Local); err != nil { | ||
38 | + log.Logger.Error(err.Error()) | ||
39 | + validation.Error("开始时间有误") | ||
40 | + return | ||
41 | + } | ||
42 | + } | ||
43 | + if len(cmd.EndTime) > 0 { | ||
44 | + if cmd.ProductEndTime, err = time.ParseInLocation("2006-01-02 15:04:05", cmd.EndTime, time.Local); err != nil { | ||
45 | + log.Logger.Error(err.Error()) | ||
46 | + validation.Error("结束时间有误") | ||
47 | + return | ||
48 | + } | ||
49 | + if cmd.ProductBeginTime.Equal(cmd.ProductEndTime) { | ||
50 | + cmd.ProductEndTime = cmd.ProductEndTime.Add(time.Hour * 24) | ||
51 | + } | ||
52 | + } | ||
53 | +} | ||
54 | + | ||
55 | +func (cmd *ListDeviceCollectionQuery) ValidateQuery() error { | ||
56 | + valid := validation.Validation{} | ||
57 | + b, err := valid.Valid(cmd) | ||
58 | + if err != nil { | ||
59 | + return err | ||
60 | + } | ||
61 | + if !b { | ||
62 | + elem := reflect.TypeOf(cmd).Elem() | ||
63 | + for _, validErr := range valid.Errors { | ||
64 | + field, isExist := elem.FieldByName(validErr.Field) | ||
65 | + if isExist { | ||
66 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
67 | + } else { | ||
68 | + return fmt.Errorf(validErr.Message) | ||
69 | + } | ||
70 | + } | ||
71 | + } | ||
72 | + return nil | ||
73 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "errors" | ||
5 | + "fmt" | ||
6 | + "github.com/linmadan/egglib-go/core/application" | ||
7 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/command" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/deviceCollection/query" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
15 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
16 | + "strconv" | ||
17 | + "sync" | ||
18 | + "time" | ||
19 | +) | ||
20 | + | ||
21 | +type DeviceCollectionService struct { | ||
22 | +} | ||
23 | + | ||
24 | +var ( | ||
25 | + DeviceDataCache = NewDeviceDataInstance() | ||
26 | +) | ||
27 | + | ||
28 | +// 创建 | ||
29 | +func (deviceCollectionService *DeviceCollectionService) CreateDeviceCollection(createDeviceCollectionCommand *command.CreateDeviceCollectionCommand) (interface{}, error) { | ||
30 | + if err := createDeviceCollectionCommand.ValidateCommand(); err != nil { | ||
31 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
32 | + } | ||
33 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
34 | + if err != nil { | ||
35 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
36 | + } | ||
37 | + if err := transactionContext.StartTransaction(); err != nil { | ||
38 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
39 | + } | ||
40 | + defer func() { | ||
41 | + transactionContext.RollbackTransaction() | ||
42 | + }() | ||
43 | + newDeviceCollection := &domain.DeviceCollection{ | ||
44 | + //DeviceCollectionId: createDeviceCollectionCommand.DeviceCollectionId, | ||
45 | + WorkShopName: createDeviceCollectionCommand.WorkShopName, | ||
46 | + DeviceType: createDeviceCollectionCommand.DeviceType, | ||
47 | + StartupStatus: createDeviceCollectionCommand.StartupStatus, | ||
48 | + DeviceSn: createDeviceCollectionCommand.DeviceSn, | ||
49 | + ComStatus: createDeviceCollectionCommand.ComStatus, | ||
50 | + CollectionTime: createDeviceCollectionCommand.CollectionTime, | ||
51 | + Values: createDeviceCollectionCommand.Values, | ||
52 | + } | ||
53 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
54 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
55 | + "transactionContext": transactionContext, | ||
56 | + }); err != nil { | ||
57 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
58 | + } else { | ||
59 | + deviceCollectionRepository = value | ||
60 | + } | ||
61 | + if deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection); err != nil { | ||
62 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
63 | + } else { | ||
64 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
65 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
66 | + } | ||
67 | + return map[string]interface{}{ | ||
68 | + "deviceCollection": deviceCollection, | ||
69 | + }, nil | ||
70 | + } | ||
71 | +} | ||
72 | + | ||
73 | +// 创建 | ||
74 | +func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createDeviceCollectionCommand *command.CreateDeviceCollectionCommand) (interface{}, error) { | ||
75 | + if err := createDeviceCollectionCommand.ValidateCommand(); err != nil { | ||
76 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
77 | + } | ||
78 | + | ||
79 | + newDeviceCollection := &domain.DeviceCollection{ | ||
80 | + //DeviceCollectionId: createDeviceCollectionCommand.DeviceCollectionId, | ||
81 | + WorkShopName: createDeviceCollectionCommand.WorkShopName, | ||
82 | + DeviceType: createDeviceCollectionCommand.DeviceType, | ||
83 | + StartupStatus: createDeviceCollectionCommand.StartupStatus, | ||
84 | + DeviceSn: createDeviceCollectionCommand.DeviceSn, | ||
85 | + ComStatus: createDeviceCollectionCommand.ComStatus, | ||
86 | + CollectionTime: createDeviceCollectionCommand.CollectionTime, | ||
87 | + Values: createDeviceCollectionCommand.Values, | ||
88 | + LatestUpdateTime: time.Now(), | ||
89 | + } | ||
90 | + var lastDeviceCollectionRecord = &domain.DeviceCollection{} | ||
91 | + var err error | ||
92 | + if createDeviceCollectionCommand.PreCheck { | ||
93 | + //前置验证,限制设备上报速率 | ||
94 | + if lastDeviceCollectionRecord, err = DeviceDataCache.Add(newDeviceCollection.DeviceSn, newDeviceCollection.DeviceType, newDeviceCollection); err != nil { | ||
95 | + //log.Logger.Error(err.Error()+newDeviceCollection.DeviceSn) | ||
96 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
97 | + } | ||
98 | + if lastDeviceCollectionRecord == nil { | ||
99 | + //log.Logger.Error("未找到上一条设备数据") | ||
100 | + return nil, nil | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
104 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
105 | + if err != nil { | ||
106 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
107 | + } | ||
108 | + if err := transactionContext.StartTransaction(); err != nil { | ||
109 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
110 | + } | ||
111 | + defer func() { | ||
112 | + transactionContext.RollbackTransaction() | ||
113 | + }() | ||
114 | + | ||
115 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
116 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
117 | + "transactionContext": transactionContext, | ||
118 | + }); err != nil { | ||
119 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
120 | + } else { | ||
121 | + deviceCollectionRepository = value | ||
122 | + } | ||
123 | + | ||
124 | + //计算区间的产能 | ||
125 | + if v, ok := newDeviceCollection.Values["Count"]; ok { | ||
126 | + newDeviceCollection.Values["total"] = v // 记录原始值 | ||
127 | + newDeviceCollection.Values["Count"] = 0 | ||
128 | + curCount, errCurCount := strconv.Atoi(utils.AssertString(v)) | ||
129 | + lastCount, errLastCount := strconv.Atoi(utils.AssertString(lastDeviceCollectionRecord.Values["Count"])) | ||
130 | + var count int | ||
131 | + if errLastCount == nil && errCurCount == nil && lastCount <= curCount { | ||
132 | + if lastCount <= curCount { | ||
133 | + count = curCount - lastCount | ||
134 | + } else { | ||
135 | + count = 0 | ||
136 | + /*设备统计的数量超过一定范围会重置为0,特殊处理0操作*/ | ||
137 | + if lastCount > 10000000 && curCount < 1000 { | ||
138 | + count = curCount | ||
139 | + } | ||
140 | + } | ||
141 | + newDeviceCollection.Values["Count"] = count | ||
142 | + newDeviceCollection.ProductCount = count | ||
143 | + } | ||
144 | + } | ||
145 | + // TODO:测试假数据,后期注释掉 | ||
146 | + //if createDeviceCollectionCommand.DeviceType == domain.DeviceTypeChuanChuanJi { | ||
147 | + // newDeviceCollection.Values["Count"] = rand.Intn(300) | ||
148 | + //} | ||
149 | + deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection) | ||
150 | + if err != nil { | ||
151 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
152 | + } | ||
153 | + err = domainService.SendWorkshopDeviceData(deviceCollection) | ||
154 | + if err != nil { | ||
155 | + log.Logger.Error("车间设备数据加入redis失败:" + err.Error()) | ||
156 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
157 | + } | ||
158 | + | ||
159 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
160 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
161 | + } | ||
162 | + return map[string]interface{}{ | ||
163 | + "deviceCollection": deviceCollection, | ||
164 | + }, nil | ||
165 | + | ||
166 | +} | ||
167 | + | ||
168 | +// 返回 | ||
169 | +func (deviceCollectionService *DeviceCollectionService) GetDeviceCollection(getDeviceCollectionQuery *query.GetDeviceCollectionQuery) (interface{}, error) { | ||
170 | + if err := getDeviceCollectionQuery.ValidateQuery(); err != nil { | ||
171 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
172 | + } | ||
173 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
174 | + if err != nil { | ||
175 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
176 | + } | ||
177 | + if err := transactionContext.StartTransaction(); err != nil { | ||
178 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
179 | + } | ||
180 | + defer func() { | ||
181 | + transactionContext.RollbackTransaction() | ||
182 | + }() | ||
183 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
184 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
185 | + "transactionContext": transactionContext, | ||
186 | + }); err != nil { | ||
187 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
188 | + } else { | ||
189 | + deviceCollectionRepository = value | ||
190 | + } | ||
191 | + deviceCollection, err := deviceCollectionRepository.FindOne(map[string]interface{}{"deviceCollectionId": getDeviceCollectionQuery.DeviceCollectionId}) | ||
192 | + if err != nil { | ||
193 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
194 | + } | ||
195 | + if deviceCollection == nil { | ||
196 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDeviceCollectionQuery.DeviceCollectionId))) | ||
197 | + } else { | ||
198 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
199 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
200 | + } | ||
201 | + return deviceCollection, nil | ||
202 | + } | ||
203 | +} | ||
204 | + | ||
205 | +// 返回列表 | ||
206 | +func (deviceCollectionService *DeviceCollectionService) ListDeviceCollection(listDeviceCollectionQuery *query.ListDeviceCollectionQuery) (interface{}, error) { | ||
207 | + if err := listDeviceCollectionQuery.ValidateQuery(); err != nil { | ||
208 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
209 | + } | ||
210 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
211 | + if err != nil { | ||
212 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
213 | + } | ||
214 | + if err := transactionContext.StartTransaction(); err != nil { | ||
215 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
216 | + } | ||
217 | + defer func() { | ||
218 | + transactionContext.RollbackTransaction() | ||
219 | + }() | ||
220 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
221 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
222 | + "transactionContext": transactionContext, | ||
223 | + }); err != nil { | ||
224 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
225 | + } else { | ||
226 | + deviceCollectionRepository = value | ||
227 | + } | ||
228 | + if count, deviceCollections, err := deviceCollectionRepository.Find(tool_funs.SimpleStructToMap(listDeviceCollectionQuery)); err != nil { | ||
229 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
230 | + } else { | ||
231 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
232 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
233 | + } | ||
234 | + return tool_funs.SimpleWrapGridMap(count, deviceCollections), nil | ||
235 | + } | ||
236 | +} | ||
237 | + | ||
238 | +// 移除 | ||
239 | +func (deviceCollectionService *DeviceCollectionService) RemoveDeviceCollection(removeDeviceCollectionCommand *command.RemoveDeviceCollectionCommand) (interface{}, error) { | ||
240 | + if err := removeDeviceCollectionCommand.ValidateCommand(); err != nil { | ||
241 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
242 | + } | ||
243 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
244 | + if err != nil { | ||
245 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
246 | + } | ||
247 | + if err := transactionContext.StartTransaction(); err != nil { | ||
248 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
249 | + } | ||
250 | + defer func() { | ||
251 | + transactionContext.RollbackTransaction() | ||
252 | + }() | ||
253 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
254 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
255 | + "transactionContext": transactionContext, | ||
256 | + }); err != nil { | ||
257 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
258 | + } else { | ||
259 | + deviceCollectionRepository = value | ||
260 | + } | ||
261 | + deviceCollection, err := deviceCollectionRepository.FindOne(map[string]interface{}{"deviceCollectionId": removeDeviceCollectionCommand.DeviceCollectionId}) | ||
262 | + if err != nil { | ||
263 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
264 | + } | ||
265 | + if deviceCollection == nil { | ||
266 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeDeviceCollectionCommand.DeviceCollectionId))) | ||
267 | + } | ||
268 | + if deviceCollection, err := deviceCollectionRepository.Remove(deviceCollection); err != nil { | ||
269 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
270 | + } else { | ||
271 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
272 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
273 | + } | ||
274 | + return map[string]interface{}{ | ||
275 | + "deviceCollection": deviceCollection, | ||
276 | + }, nil | ||
277 | + } | ||
278 | +} | ||
279 | + | ||
280 | +// 更新 | ||
281 | +func (deviceCollectionService *DeviceCollectionService) UpdateDeviceCollection(updateDeviceCollectionCommand *command.UpdateDeviceCollectionCommand) (interface{}, error) { | ||
282 | + if err := updateDeviceCollectionCommand.ValidateCommand(); err != nil { | ||
283 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
284 | + } | ||
285 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
286 | + if err != nil { | ||
287 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
288 | + } | ||
289 | + if err := transactionContext.StartTransaction(); err != nil { | ||
290 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
291 | + } | ||
292 | + defer func() { | ||
293 | + transactionContext.RollbackTransaction() | ||
294 | + }() | ||
295 | + var deviceCollectionRepository domain.DeviceCollectionRepository | ||
296 | + if value, err := factory.CreateDeviceCollectionRepository(map[string]interface{}{ | ||
297 | + "transactionContext": transactionContext, | ||
298 | + }); err != nil { | ||
299 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
300 | + } else { | ||
301 | + deviceCollectionRepository = value | ||
302 | + } | ||
303 | + deviceCollection, err := deviceCollectionRepository.FindOne(map[string]interface{}{"deviceCollectionId": updateDeviceCollectionCommand.DeviceCollectionId}) | ||
304 | + if err != nil { | ||
305 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
306 | + } | ||
307 | + if deviceCollection == nil { | ||
308 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDeviceCollectionCommand.DeviceCollectionId))) | ||
309 | + } | ||
310 | + if err := deviceCollection.Update(tool_funs.SimpleStructToMap(updateDeviceCollectionCommand)); err != nil { | ||
311 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
312 | + } | ||
313 | + if deviceCollection, err := deviceCollectionRepository.Save(deviceCollection); err != nil { | ||
314 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
315 | + } else { | ||
316 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
317 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
318 | + } | ||
319 | + return map[string]interface{}{ | ||
320 | + "deviceCollection": deviceCollection, | ||
321 | + }, nil | ||
322 | + } | ||
323 | +} | ||
324 | + | ||
325 | +func NewDeviceCollectionService(options map[string]interface{}) *DeviceCollectionService { | ||
326 | + newDeviceCollectionService := &DeviceCollectionService{} | ||
327 | + return newDeviceCollectionService | ||
328 | +} | ||
329 | + | ||
330 | +const DefaultReceiveSpan = 60 // 60 sec | ||
331 | + | ||
332 | +type DeviceDataInstance struct { | ||
333 | + //deviceDataCache sync.Map | ||
334 | + deviceDataLastTime sync.Map | ||
335 | +} | ||
336 | + | ||
337 | +func NewDeviceDataInstance() *DeviceDataInstance { | ||
338 | + return &DeviceDataInstance{ | ||
339 | + deviceDataLastTime: sync.Map{}, | ||
340 | + } | ||
341 | +} | ||
342 | + | ||
343 | +func (d *DeviceDataInstance) Add(deviceSn, deviceType string, data interface{}) (*domain.DeviceCollection, error) { | ||
344 | + // 获取数据上一次的 | ||
345 | + var v interface{} | ||
346 | + var ok bool | ||
347 | + var now = time.Now().Unix() | ||
348 | + var t = now | ||
349 | + if v, ok = d.deviceDataLastTime.Load(deviceSn); ok { | ||
350 | + t = v.(int64) | ||
351 | + } else { | ||
352 | + d.deviceDataLastTime.Store(deviceSn, t) | ||
353 | + redis.SaveDeviceRealTimeData(deviceSn, data, true) | ||
354 | + return nil, errors.New(fmt.Sprintf("ingnore this record")) | ||
355 | + } | ||
356 | + // 60秒接受一次数据,暂时不用太多数据 | ||
357 | + if now < t+DefaultReceiveSpan { | ||
358 | + return nil, errors.New(fmt.Sprintf("receive too fast wait %v sec", t+DefaultReceiveSpan-now)) | ||
359 | + } | ||
360 | + // 从redis获取最后的数据进行处理 | ||
361 | + var result = &domain.DeviceCollection{} | ||
362 | + if err := redis.GetDeviceRealTimeData(deviceSn, result); err != nil { | ||
363 | + if err == domain.ErrorNotFound { | ||
364 | + redis.SaveDeviceRealTimeData(deviceSn, data, true) | ||
365 | + return nil, nil | ||
366 | + } | ||
367 | + return nil, err | ||
368 | + } | ||
369 | + //log.Logger.Debug("",map[string]interface{}{"t":t,"device":deviceSn}) | ||
370 | + d.deviceDataLastTime.Store(deviceSn, now) | ||
371 | + return result, redis.SaveDeviceRealTimeData(deviceSn, data, false) | ||
372 | +} |
1 | +package service |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "fmt" | ||
6 | + "github.com/beego/beego/v2/core/validation" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type ExportDataCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator *domain.OperateInfo `json:"-"` | ||
13 | + // 业务编码 | ||
14 | + Ids []string `json:"ids"` | ||
15 | + Where json.RawMessage `json:"where"` | ||
16 | + // 业务编码 | ||
17 | + Code string `form:"code"` | ||
18 | +} | ||
19 | + | ||
20 | +func (exportDataCommand *ExportDataCommand) Valid(validation *validation.Validation) { | ||
21 | + | ||
22 | +} | ||
23 | + | ||
24 | +func (exportDataCommand *ExportDataCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(exportDataCommand) | ||
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 | +} | ||
37 | + | ||
38 | +func (exportDataCommand *ExportDataCommand) UnmarshalQuery(query interface{}) error { | ||
39 | + return json.Unmarshal(exportDataCommand.Where, query) | ||
40 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
7 | + "io" | ||
8 | +) | ||
9 | + | ||
10 | +type ImportDataCommand struct { | ||
11 | + //操作人 | ||
12 | + Operator *domain.OperateInfo `json:"-"` | ||
13 | + Reader io.Reader `json:"-"` | ||
14 | + FileExt string `json:"-"` | ||
15 | + // 业务编码 | ||
16 | + Code string `form:"code"` | ||
17 | +} | ||
18 | + | ||
19 | +func (importDataCommand *ImportDataCommand) Valid(validation *validation.Validation) { | ||
20 | + | ||
21 | +} | ||
22 | + | ||
23 | +func (importDataCommand *ImportDataCommand) ValidateCommand() error { | ||
24 | + valid := validation.Validation{} | ||
25 | + b, err := valid.Valid(importDataCommand) | ||
26 | + if err != nil { | ||
27 | + return err | ||
28 | + } | ||
29 | + if !b { | ||
30 | + for _, validErr := range valid.Errors { | ||
31 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
32 | + } | ||
33 | + } | ||
34 | + return nil | ||
35 | +} |
1 | +package query | ||
2 | + | ||
3 | +import () | ||
4 | + | ||
5 | +type CooperationUserListQuery struct { | ||
6 | + //操作人 | ||
7 | + //Operator domain.Operator `json:"-"` | ||
8 | + //用户名称 | ||
9 | + UserName string `json:"userName"` | ||
10 | + //共创公司 | ||
11 | + CooperationCompany string `json:"cooperationCompany"` | ||
12 | + SelectedField []string `json:"selectedField"` | ||
13 | +} |
pkg/application/ecelData/service/export.go
0 → 100644
1 | +package service | ||
2 | + | ||
3 | +// ExportCompanyUser 导出公司用户信息列表 | ||
4 | +//func (srv ExcelDataService) ExportCompanyUser(companyUserListQuery *query.CompanyUserListQuery) (ExportCompanyUserData, error) { | ||
5 | +// creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(companyUserListQuery.Operator) | ||
6 | +// result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
7 | +// Limit: 10000, | ||
8 | +// CompanyId: companyUserListQuery.Operator.CompanyId, | ||
9 | +// OrganizationId: 0, | ||
10 | +// DepartmentId: 0, | ||
11 | +// UserName: companyUserListQuery.UserName, | ||
12 | +// DepName: companyUserListQuery.DepartmentName, | ||
13 | +// Phone: "", | ||
14 | +// UserType: domain.UserTypeEmployee, | ||
15 | +// InOrgIds: companyUserListQuery.Operator.OrgIds, | ||
16 | +// PullRealTime: true, | ||
17 | +// }) | ||
18 | +// if err != nil { | ||
19 | +// return ExportCompanyUserData{}, fmt.Errorf("获取企业用户数据失败:%w", err) | ||
20 | +// } | ||
21 | +// return ExportCompanyUserData{ | ||
22 | +// SourceData: result.Users, | ||
23 | +// SelectedField: companyUserListQuery.SelectedField, | ||
24 | +// }, nil | ||
25 | +//} | ||
26 | + | ||
27 | +// ExportCooperationUser 导出共创用户信息列表 | ||
28 | +//func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.CooperationUserListQuery) (ExportCooperationUserData, error) { | ||
29 | +// creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(companyUserListQuery.Operator) | ||
30 | +// result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
31 | +// Limit: 10000, | ||
32 | +// CompanyId: companyUserListQuery.Operator.CompanyId, | ||
33 | +// OrganizationId: 0, | ||
34 | +// DepartmentId: 0, | ||
35 | +// UserName: companyUserListQuery.UserName, | ||
36 | +// CooperationCompany: companyUserListQuery.CooperationCompany, | ||
37 | +// Phone: "", | ||
38 | +// UserType: domain.UserTypeCooperation, | ||
39 | +// InOrgIds: companyUserListQuery.Operator.OrgIds, | ||
40 | +// }) | ||
41 | +// if err != nil { | ||
42 | +// return ExportCooperationUserData{}, fmt.Errorf("获取企业用户数据失败:%w", err) | ||
43 | +// } | ||
44 | +// return ExportCooperationUserData{SourceData: result.Users, SelectedField: companyUserListQuery.SelectedField}, nil | ||
45 | +//} |
pkg/application/ecelData/service/import.go
0 → 100644
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/linmadan/egglib-go/core/application" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/ecelData/command" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/linmadan/egglib-go/utils/excel" | ||
10 | +) | ||
11 | + | ||
12 | +type ExcelDataService struct { | ||
13 | +} | ||
14 | + | ||
15 | +func NewExcelDataService(param map[string]interface{}) *ExcelDataService { | ||
16 | + return &ExcelDataService{} | ||
17 | +} | ||
18 | + | ||
19 | +// 导入结果 | ||
20 | +func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, failRows []interface{}, totalRow int) interface{} { | ||
21 | + var result = map[string]interface{}{ | ||
22 | + "successCount": 0, | ||
23 | + "fail": struct{}{}, | ||
24 | + } | ||
25 | + if len(failRows) == 0 { | ||
26 | + result["successCount"] = totalRow | ||
27 | + } | ||
28 | + if len(failRows) > 0 { | ||
29 | + fail := map[string]interface{}{ | ||
30 | + "body": failRows, | ||
31 | + } | ||
32 | + var header = make(map[string]string) | ||
33 | + for i := 0; i < len(headers); i++ { | ||
34 | + item := headers[i] | ||
35 | + header[item.EnName] = item.CnName | ||
36 | + } | ||
37 | + fail["header"] = header | ||
38 | + result["fail"] = fail | ||
39 | + } | ||
40 | + return result | ||
41 | +} | ||
42 | + | ||
43 | +func (srv ExcelDataService) fieldValueAllEmpty(param map[string]string) bool { | ||
44 | + isAllEmpty := true | ||
45 | + for _, v := range param { | ||
46 | + value := strings.TrimSpace(v) | ||
47 | + if len(value) > 0 { | ||
48 | + isAllEmpty = false | ||
49 | + } | ||
50 | + } | ||
51 | + return isAllEmpty | ||
52 | +} | ||
53 | + | ||
54 | +//// FileImportTemplate 导入模板 | ||
55 | +func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) { | ||
56 | + var mapTemplate = map[string]string{ | ||
57 | + //domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807485_EaxECeRz23WpzrMZmbwdEPRJ3Pdxpx5X.xlsx", | ||
58 | + //domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210916/object/1631807490_r2XWhGmbWWmpbeePBkZ3EJQFKcZEMpEm.xlsx", | ||
59 | + //domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743206_NPYTKw6RGhXn4TpYNEQhGGdCkXKXTnxM.xlsx", | ||
60 | + //domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210926/object/1632635345_SbfzmkXjQHhCwPw4MB7zb5EBBtdp2MSE.xlsx", | ||
61 | + //domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx", | ||
62 | + } | ||
63 | + var url string | ||
64 | + var ok bool | ||
65 | + if url, ok = mapTemplate[importDataCommand.Code]; !ok { | ||
66 | + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("模板:%v 不存在", importDataCommand.Code)) | ||
67 | + } | ||
68 | + return map[string]string{ | ||
69 | + "url": url, | ||
70 | + }, nil | ||
71 | +} | ||
72 | + | ||
73 | +func (srv ExcelDataService) GetExcelDataFields(code string) (interface{}, error) { | ||
74 | + dataFields := []DataFieldOptions{} | ||
75 | + //switch code { | ||
76 | + //case domain.ExportCompanyUser: | ||
77 | + // dataFileds = (ExportCompanyUserData{}).AllFields() | ||
78 | + //case domain.ExportCooperationUser: | ||
79 | + // dataFileds = (ExportCooperationUserData{}).AllFields() | ||
80 | + //} | ||
81 | + return dataFields, nil | ||
82 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "github.com/linmadan/egglib-go/utils/excel" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/ecelData/command" | ||
7 | + productService "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/product/service" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils/converter" | ||
10 | + "strings" | ||
11 | +) | ||
12 | + | ||
13 | +// ImportProduct 导入生产信息 | ||
14 | +func (srv ExcelDataService) ImportProduct(importDataCommand *command.ImportDataCommand) (interface{}, error) { | ||
15 | + excelImport := excel.NewExcelImport() | ||
16 | + excelImport.RowBegin = 3 //第二行开始读取 | ||
17 | + excelImport.DataFields = []excel.DataField{ | ||
18 | + {EnName: "productCode", CnName: "产品编号"}, | ||
19 | + {EnName: "productName", CnName: "*品名"}, | ||
20 | + {EnName: "unit", CnName: "*规格"}, | ||
21 | + {EnName: "productCategory", CnName: "*类别"}, | ||
22 | + {EnName: "unitWeight", CnName: "投入单份重量"}, | ||
23 | + } | ||
24 | + excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader) | ||
25 | + if err != nil { | ||
26 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
27 | + } | ||
28 | + items := make([]*domain.ImportProductItem, 0) | ||
29 | + for _, v := range excelData { | ||
30 | + item := &domain.ImportProductItem{ | ||
31 | + ProductCode: strings.TrimSpace(v["productCode"]), | ||
32 | + ProductName: strings.TrimSpace(v["productName"]), | ||
33 | + ProductCategory: strings.TrimSpace(v["productCategory"]), | ||
34 | + Unit: strings.TrimSpace(v["unit"]), | ||
35 | + UnitWeight: strings.TrimSpace(v["unitWeight"]), | ||
36 | + } | ||
37 | + items = append(items, item) | ||
38 | + } | ||
39 | + | ||
40 | + svr := productService.NewProductService(nil) | ||
41 | + failRows, err := svr.BatchAddProduct(importDataCommand.Operator, items) | ||
42 | + if err != nil { | ||
43 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
44 | + } | ||
45 | + return srv.importResultWithHeader(excelImport.DataFields, failRows, len(items)), nil | ||
46 | +} |
pkg/application/ecelData/service/types.go
0 → 100644
1 | +package service | ||
2 | + | ||
3 | +type DataFieldOptions struct { | ||
4 | + EnName string `json:"enName"` | ||
5 | + CnName string `json:"cnName"` | ||
6 | + IsDefault bool `json:"isDefault"` | ||
7 | +} | ||
8 | + | ||
9 | +// | ||
10 | +//// ExportCompanyUserData 导出公司用户数据 | ||
11 | +//type ExportCompanyUserData struct { | ||
12 | +// SourceData []allied_creation_user.UserDetail | ||
13 | +// SelectedField []string | ||
14 | +//} | ||
15 | +// | ||
16 | +//var _ excel.ExcelMaker = (*ExportCompanyUserData)(nil) | ||
17 | +// | ||
18 | +//func (data ExportCompanyUserData) AllFields() []DataFieldOptions { | ||
19 | +// return []DataFieldOptions{ | ||
20 | +// {EnName: "UserCode", CnName: "用户编码"}, | ||
21 | +// {EnName: "UserName", CnName: "用户姓名"}, | ||
22 | +// {EnName: "Phone", CnName: "手机号"}, | ||
23 | +// {EnName: "DepartmentName", CnName: "所属部门"}, | ||
24 | +// {EnName: "EnableStatus", CnName: "状态"}, | ||
25 | +// {EnName: "OrgName", CnName: "组织机构"}, | ||
26 | +// } | ||
27 | +//} | ||
28 | +// | ||
29 | +//func (data ExportCompanyUserData) DataFieldList() []excel.DataField { | ||
30 | +// fields := []excel.DataField{} | ||
31 | +// allFields := data.AllFields() | ||
32 | +// for _, value2 := range allFields { | ||
33 | +// if len(data.SelectedField) == 0 || value2.IsDefault { | ||
34 | +// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
35 | +// continue | ||
36 | +// } | ||
37 | +// for _, value3 := range data.SelectedField { | ||
38 | +// if value2.EnName == value3 { | ||
39 | +// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
40 | +// } | ||
41 | +// } | ||
42 | +// } | ||
43 | +// return fields | ||
44 | +//} | ||
45 | +// | ||
46 | +//func (data ExportCompanyUserData) CellValue(index int, enName string) (value interface{}) { | ||
47 | +// if index > data.DataListLen() { | ||
48 | +// return "" | ||
49 | +// } | ||
50 | +// switch enName { | ||
51 | +// case "UserCode": | ||
52 | +// return data.SourceData[index].UserCode | ||
53 | +// case "UserName": | ||
54 | +// return data.SourceData[index].UserInfo.UserName | ||
55 | +// case "Phone": | ||
56 | +// return data.SourceData[index].UserInfo.Phone | ||
57 | +// case "DepartmentName": | ||
58 | +// if data.SourceData[index].Department != nil { | ||
59 | +// return data.SourceData[index].Department.DepartmentName | ||
60 | +// } else { | ||
61 | +// return "" | ||
62 | +// } | ||
63 | +// case "EnableStatus": | ||
64 | +// status := data.SourceData[index].EnableStatus | ||
65 | +// statusName := "" | ||
66 | +// // 状态(1:启用 2:禁用 3:注销) | ||
67 | +// switch status { | ||
68 | +// case 1: | ||
69 | +// statusName = "启用" | ||
70 | +// case 2: | ||
71 | +// statusName = "禁用" | ||
72 | +// case 3: | ||
73 | +// statusName = "注销" | ||
74 | +// } | ||
75 | +// return statusName | ||
76 | +// case "OrgName": | ||
77 | +// if data.SourceData[index].Org != nil { | ||
78 | +// return data.SourceData[index].Org.OrgName | ||
79 | +// } else { | ||
80 | +// return "" | ||
81 | +// } | ||
82 | +// } | ||
83 | +// return nil | ||
84 | +//} | ||
85 | +// | ||
86 | +//func (data ExportCompanyUserData) DataListLen() int { | ||
87 | +// return len(data.SourceData) | ||
88 | +//} | ||
89 | +// | ||
90 | +//func (data ExportCompanyUserData) TableTitle() []string { | ||
91 | +// return nil | ||
92 | +//} | ||
93 | +// | ||
94 | +////ExportCooperationUserData 导出共创用户数据 | ||
95 | +//type ExportCooperationUserData struct { | ||
96 | +// SourceData []allied_creation_user.UserDetail | ||
97 | +// SelectedField []string | ||
98 | +//} | ||
99 | +// | ||
100 | +//var _ excel.ExcelMaker = (*ExportCooperationUserData)(nil) | ||
101 | +// | ||
102 | +//func (data ExportCooperationUserData) AllFields() []DataFieldOptions { | ||
103 | +// return []DataFieldOptions{ | ||
104 | +// {EnName: "UserCode", CnName: "用户编码"}, | ||
105 | +// {EnName: "UserName", CnName: "用户姓名"}, | ||
106 | +// {EnName: "Phone", CnName: "手机号"}, | ||
107 | +// {EnName: "CooperationCompany", CnName: "共创公司"}, | ||
108 | +// {EnName: "CooperationDeadline", CnName: "共创到期"}, | ||
109 | +// {EnName: "EnableStatus", CnName: "状态"}, | ||
110 | +// } | ||
111 | +//} | ||
112 | +// | ||
113 | +//func (data ExportCooperationUserData) DataFieldList() []excel.DataField { | ||
114 | +// fields := []excel.DataField{} | ||
115 | +// allFields := data.AllFields() | ||
116 | +// for _, value2 := range allFields { | ||
117 | +// if len(data.SelectedField) == 0 || value2.IsDefault { | ||
118 | +// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
119 | +// continue | ||
120 | +// } | ||
121 | +// for _, value3 := range data.SelectedField { | ||
122 | +// if value2.EnName == value3 { | ||
123 | +// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName}) | ||
124 | +// } | ||
125 | +// } | ||
126 | +// } | ||
127 | +// return fields | ||
128 | +//} | ||
129 | +// | ||
130 | +//func (data ExportCooperationUserData) CellValue(index int, enName string) (value interface{}) { | ||
131 | +// if index > data.DataListLen() { | ||
132 | +// return "" | ||
133 | +// } | ||
134 | +// switch enName { | ||
135 | +// case "UserCode": | ||
136 | +// return data.SourceData[index].UserCode | ||
137 | +// case "UserName": | ||
138 | +// return data.SourceData[index].UserInfo.UserName | ||
139 | +// case "CooperationCompany": | ||
140 | +// return data.SourceData[index].CooperationInfo.CooperationCompany | ||
141 | +// case "CooperationDeadline": | ||
142 | +// if data.SourceData[index].CooperationInfo.CooperationDeadline.IsZero() || data.SourceData[index].CooperationInfo.CooperationDeadline.Unix() == 0 { | ||
143 | +// return "" | ||
144 | +// } | ||
145 | +// return data.SourceData[index].CooperationInfo.CooperationDeadline.Format("2006-01-02") | ||
146 | +// case "Phone": | ||
147 | +// return data.SourceData[index].UserInfo.Phone | ||
148 | +// case "Email": | ||
149 | +// return data.SourceData[index].UserInfo.Email | ||
150 | +// case "EnableStatus": | ||
151 | +// status := data.SourceData[index].EnableStatus | ||
152 | +// statusName := "" | ||
153 | +// // 状态(1:启用 2:禁用 3:注销) | ||
154 | +// switch status { | ||
155 | +// case 1: | ||
156 | +// statusName = "启用" | ||
157 | +// case 2: | ||
158 | +// statusName = "禁用" | ||
159 | +// case 3: | ||
160 | +// statusName = "注销" | ||
161 | +// } | ||
162 | +// return statusName | ||
163 | +// } | ||
164 | +// return nil | ||
165 | +//} | ||
166 | +// | ||
167 | +//func (data ExportCooperationUserData) DataListLen() int { | ||
168 | +// return len(data.SourceData) | ||
169 | +//} | ||
170 | +// | ||
171 | +//func (data ExportCooperationUserData) TableTitle() []string { | ||
172 | +// return nil | ||
173 | +//} |
1 | +package factory | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | +) | ||
7 | + | ||
8 | +// FastPgWorkshop 快速返回车间对象 | ||
9 | +// | ||
10 | +// transactionContext 事务 | ||
11 | +// id 对象唯一标识 | ||
12 | +func FastPgWorkshop(transactionContext application.TransactionContext, id int, options ...option) (domain.WorkshopRepository, *domain.Workshop, error) { | ||
13 | + var rep domain.WorkshopRepository | ||
14 | + var mod *domain.Workshop | ||
15 | + var err error | ||
16 | + if value, err := CreateWorkshopRepository(map[string]interface{}{ | ||
17 | + "transactionContext": transactionContext, | ||
18 | + }); err != nil { | ||
19 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
20 | + } else { | ||
21 | + rep = value | ||
22 | + } | ||
23 | + if id > 0 { | ||
24 | + if mod, err = rep.FindOne(map[string]interface{}{"workshopId": id}); err != nil { | ||
25 | + if err == domain.ErrorNotFound { | ||
26 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间不存在") | ||
27 | + } | ||
28 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
29 | + } | ||
30 | + } | ||
31 | + //if err = fastPgDataAuth(transactionContext, mod, options...); err != nil { | ||
32 | + // return nil, nil, err | ||
33 | + //} | ||
34 | + return rep, mod, err | ||
35 | +} | ||
36 | + | ||
37 | +// FastPgWorkshop 快速返回车间对象 | ||
38 | +// | ||
39 | +// transactionContext 事务 | ||
40 | +// id 对象唯一标识 | ||
41 | +func FastPgWorkshops(transactionContext application.TransactionContext, companyId int, options ...option) (domain.Workshops, error) { | ||
42 | + var rep domain.WorkshopRepository | ||
43 | + //var mod *domain.Workshop | ||
44 | + var err error | ||
45 | + if value, err := CreateWorkshopRepository(map[string]interface{}{ | ||
46 | + "transactionContext": transactionContext, | ||
47 | + }); err != nil { | ||
48 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
49 | + } else { | ||
50 | + rep = value | ||
51 | + } | ||
52 | + _, workshops, err := rep.Find(map[string]interface{}{"companyId": companyId}) | ||
53 | + if err != nil { | ||
54 | + return nil, err | ||
55 | + } | ||
56 | + if len(workshops) == 0 { | ||
57 | + workshops = make([]*domain.Workshop, 0) | ||
58 | + } | ||
59 | + return workshops, err | ||
60 | +} | ||
61 | + | ||
62 | +// FastPgWorkstation 快速返回工作定位对象 | ||
63 | +// | ||
64 | +// transactionContext 事务 | ||
65 | +// workshopId 车间ID | ||
66 | +// lineId 生产线ID | ||
67 | +// sectionId 对象ID | ||
68 | +func FastPgWorkstation(transactionContext application.TransactionContext, workshopId, lineId, sectionId int, options ...option) (domain.WorkshopRepository, *domain.WorkStation, error) { | ||
69 | + var rep domain.WorkshopRepository | ||
70 | + var mod *domain.Workshop | ||
71 | + var err error | ||
72 | + if value, err := CreateWorkshopRepository(map[string]interface{}{ | ||
73 | + "transactionContext": transactionContext, | ||
74 | + }); err != nil { | ||
75 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
76 | + } else { | ||
77 | + rep = value | ||
78 | + } | ||
79 | + | ||
80 | + if mod, err = rep.FindOne(map[string]interface{}{"workshopId": workshopId}); err != nil { | ||
81 | + if err == domain.ErrorNotFound { | ||
82 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该工作位置不存在") | ||
83 | + } | ||
84 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
85 | + } | ||
86 | + | ||
87 | + workStation, err := mod.FindWorkStation(workshopId, lineId, sectionId) | ||
88 | + if err != nil { | ||
89 | + return rep, nil, err | ||
90 | + } | ||
91 | + o := NewFastOptions(options...) | ||
92 | + if o.SetPrincipal { | ||
93 | + workStation.Principal = mod.Principal | ||
94 | + } | ||
95 | + return rep, workStation, err | ||
96 | +} | ||
97 | + | ||
98 | +// FastPgProductJob 快速返回工位对象 | ||
99 | +// | ||
100 | +// transactionContext 事务 | ||
101 | +// id 对象唯一标识 | ||
102 | +func FastPgProductJob(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductJobRepository, *domain.ProductJob, error) { | ||
103 | + var rep domain.ProductJobRepository | ||
104 | + var mod *domain.ProductJob | ||
105 | + var err error | ||
106 | + if value, err := CreateProductJobRepository(map[string]interface{}{ | ||
107 | + "transactionContext": transactionContext, | ||
108 | + }); err != nil { | ||
109 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
110 | + } else { | ||
111 | + rep = value | ||
112 | + } | ||
113 | + if id > 0 { | ||
114 | + if mod, err = rep.FindOne(map[string]interface{}{"productJobId": id}); err != nil { | ||
115 | + if err == domain.ErrorNotFound { | ||
116 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该工位不存在") | ||
117 | + } | ||
118 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
119 | + } | ||
120 | + } | ||
121 | + //if err = fastPgDataAuth(transactionContext, mod, options...); err != nil { | ||
122 | + // return nil, nil, err | ||
123 | + //} | ||
124 | + return rep, mod, err | ||
125 | +} | ||
126 | + | ||
127 | +// FastPgProductGroup 快速返回生产组对象 | ||
128 | +// | ||
129 | +// transactionContext 事务 | ||
130 | +// id 对象唯一标识 | ||
131 | +func FastPgProductGroup(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductGroupRepository, *domain.ProductGroup, error) { | ||
132 | + var rep domain.ProductGroupRepository | ||
133 | + var mod *domain.ProductGroup | ||
134 | + var err error | ||
135 | + if value, err := CreateProductGroupRepository(map[string]interface{}{ | ||
136 | + "transactionContext": transactionContext, | ||
137 | + }); err != nil { | ||
138 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
139 | + } else { | ||
140 | + rep = value | ||
141 | + } | ||
142 | + if id > 0 { | ||
143 | + if mod, err = rep.FindOne(map[string]interface{}{"productGroupId": id}); err != nil { | ||
144 | + if err == domain.ErrorNotFound { | ||
145 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该生产班组不存在") | ||
146 | + } | ||
147 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
148 | + } | ||
149 | + } | ||
150 | + //if err = fastPgDataAuth(transactionContext, mod, options...); err != nil { | ||
151 | + // return nil, nil, err | ||
152 | + //} | ||
153 | + return rep, mod, err | ||
154 | +} | ||
155 | + | ||
156 | +// FastPgProduct 快速返回产品对象 | ||
157 | +// | ||
158 | +// transactionContext 事务 | ||
159 | +// id 对象唯一标识 | ||
160 | +func FastPgProduct(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductRepository, *domain.Product, error) { | ||
161 | + var rep domain.ProductRepository | ||
162 | + var mod *domain.Product | ||
163 | + var err error | ||
164 | + if value, err := CreateProductRepository(map[string]interface{}{ | ||
165 | + "transactionContext": transactionContext, | ||
166 | + }); err != nil { | ||
167 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
168 | + } else { | ||
169 | + rep = value | ||
170 | + } | ||
171 | + if id > 0 { | ||
172 | + if mod, err = rep.FindOne(map[string]interface{}{"productId": id}); err != nil { | ||
173 | + if err == domain.ErrorNotFound { | ||
174 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该产品不存在") | ||
175 | + } | ||
176 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
177 | + } | ||
178 | + } | ||
179 | + return rep, mod, err | ||
180 | +} | ||
181 | + | ||
182 | +// FastPgDevice 快速返回设备对象 | ||
183 | +// | ||
184 | +// transactionContext 事务 | ||
185 | +// id 对象唯一标识 | ||
186 | +func FastPgDevice(transactionContext application.TransactionContext, id int, options ...option) (domain.DeviceRepository, *domain.Device, error) { | ||
187 | + var rep domain.DeviceRepository | ||
188 | + var mod *domain.Device | ||
189 | + var err error | ||
190 | + if value, err := CreateDeviceRepository(map[string]interface{}{ | ||
191 | + "transactionContext": transactionContext, | ||
192 | + }); err != nil { | ||
193 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
194 | + } else { | ||
195 | + rep = value | ||
196 | + } | ||
197 | + if id > 0 { | ||
198 | + if mod, err = rep.FindOne(map[string]interface{}{"deviceId": id}); err != nil { | ||
199 | + if err == domain.ErrorNotFound { | ||
200 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该设备档案不存在") | ||
201 | + } | ||
202 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
203 | + } | ||
204 | + } | ||
205 | + return rep, mod, err | ||
206 | +} | ||
207 | + | ||
208 | +// FastPgProductCalendar 快速返回设备对象 | ||
209 | +// | ||
210 | +// transactionContext 事务 | ||
211 | +// id 对象唯一标识 | ||
212 | +func FastPgProductCalendar(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductCalendarRepository, *domain.ProductCalendar, error) { | ||
213 | + var rep domain.ProductCalendarRepository | ||
214 | + var mod *domain.ProductCalendar | ||
215 | + var err error | ||
216 | + if value, err := CreateProductCalendarRepository(map[string]interface{}{ | ||
217 | + "transactionContext": transactionContext, | ||
218 | + }); err != nil { | ||
219 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
220 | + } else { | ||
221 | + rep = value | ||
222 | + } | ||
223 | + if id > 0 { | ||
224 | + if mod, err = rep.FindOne(map[string]interface{}{"productCalendarId": id}); err != nil { | ||
225 | + if err == domain.ErrorNotFound { | ||
226 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该车间日历不存在") | ||
227 | + } | ||
228 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
229 | + } | ||
230 | + } | ||
231 | + return rep, mod, err | ||
232 | +} | ||
233 | + | ||
234 | +// FastPgUnitConversion 快速返回单位换算对象 | ||
235 | +// | ||
236 | +// transactionContext 事务 | ||
237 | +// id 对象唯一标识 | ||
238 | +func FastPgUnitConversion(transactionContext application.TransactionContext, id int, options ...option) (domain.UnitConversionRepository, *domain.UnitConversion, error) { | ||
239 | + var rep domain.UnitConversionRepository | ||
240 | + var mod *domain.UnitConversion | ||
241 | + var err error | ||
242 | + if value, err := CreateUnitConversionRepository(map[string]interface{}{ | ||
243 | + "transactionContext": transactionContext, | ||
244 | + }); err != nil { | ||
245 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
246 | + } else { | ||
247 | + rep = value | ||
248 | + } | ||
249 | + if id > 0 { | ||
250 | + if mod, err = rep.FindOne(map[string]interface{}{"unitConversionId": id}); err != nil { | ||
251 | + if err == domain.ErrorNotFound { | ||
252 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该单位换算不存在") | ||
253 | + } | ||
254 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
255 | + } | ||
256 | + } | ||
257 | + return rep, mod, err | ||
258 | +} | ||
259 | + | ||
260 | +// FastPgProductPlan 快速返回生产计划对象 | ||
261 | +// | ||
262 | +// transactionContext 事务 | ||
263 | +// id 对象唯一标识 | ||
264 | +func FastPgProductPlan(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductPlanRepository, *domain.ProductPlan, error) { | ||
265 | + var rep domain.ProductPlanRepository | ||
266 | + var mod *domain.ProductPlan | ||
267 | + var err error | ||
268 | + if value, err := CreateProductPlanRepository(map[string]interface{}{ | ||
269 | + "transactionContext": transactionContext, | ||
270 | + }); err != nil { | ||
271 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
272 | + } else { | ||
273 | + rep = value | ||
274 | + } | ||
275 | + if id > 0 { | ||
276 | + if mod, err = rep.FindOne(map[string]interface{}{"productPlanId": id}); err != nil { | ||
277 | + if err == domain.ErrorNotFound { | ||
278 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该生产计划不存在") | ||
279 | + } | ||
280 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
281 | + } | ||
282 | + } | ||
283 | + return rep, mod, err | ||
284 | +} | ||
285 | + | ||
286 | +// FastPgProductPlan 快速返回生产计划对象 | ||
287 | +// | ||
288 | +// transactionContext 事务 | ||
289 | +// id 对象唯一标识 | ||
290 | +func FastPgProductPlanDispatchRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductPlanDispatchRecordRepository, *domain.ProductPlanDispatchRecord, error) { | ||
291 | + var rep domain.ProductPlanDispatchRecordRepository | ||
292 | + var mod *domain.ProductPlanDispatchRecord | ||
293 | + var err error | ||
294 | + if value, err := CreateProductPlanDispatchRecordRepository(map[string]interface{}{ | ||
295 | + "transactionContext": transactionContext, | ||
296 | + }); err != nil { | ||
297 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
298 | + } else { | ||
299 | + rep = value | ||
300 | + } | ||
301 | + if id > 0 { | ||
302 | + if mod, err = rep.FindOne(map[string]interface{}{"productPlanDispatchRecordId": id}); err != nil { | ||
303 | + if err == domain.ErrorNotFound { | ||
304 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该生产计划调度记录不存在") | ||
305 | + } | ||
306 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
307 | + } | ||
308 | + } | ||
309 | + return rep, mod, err | ||
310 | +} | ||
311 | + | ||
312 | +// FastPgAttendance 快速返回考勤记录 | ||
313 | +// | ||
314 | +// transactionContext 事务 | ||
315 | +// id 对象唯一标识 | ||
316 | +func FastPgAttendance(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductAttendanceRecordRepository, *domain.ProductAttendanceRecord, error) { | ||
317 | + var rep domain.ProductAttendanceRecordRepository | ||
318 | + var mod *domain.ProductAttendanceRecord | ||
319 | + var err error | ||
320 | + if value, err := CreateProductAttendanceRecordRepository(map[string]interface{}{ | ||
321 | + "transactionContext": transactionContext, | ||
322 | + }); err != nil { | ||
323 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
324 | + } else { | ||
325 | + rep = value | ||
326 | + } | ||
327 | + if id > 0 { | ||
328 | + if mod, err = rep.FindOne(map[string]interface{}{"productAttendanceRecordId": id}); err != nil { | ||
329 | + if err == domain.ErrorNotFound { | ||
330 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该考勤记录不存在") | ||
331 | + } | ||
332 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
333 | + } | ||
334 | + } | ||
335 | + return rep, mod, err | ||
336 | +} | ||
337 | + | ||
338 | +// FastPgProductRecord 快速返回生产记录 | ||
339 | +// | ||
340 | +// transactionContext 事务 | ||
341 | +// id 对象唯一标识 | ||
342 | +func FastPgProductRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.ProductRecordRepository, *domain.ProductRecord, error) { | ||
343 | + var rep domain.ProductRecordRepository | ||
344 | + var mod *domain.ProductRecord | ||
345 | + var err error | ||
346 | + if value, err := CreateProductRecordRepository(map[string]interface{}{ | ||
347 | + "transactionContext": transactionContext, | ||
348 | + }); err != nil { | ||
349 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
350 | + } else { | ||
351 | + rep = value | ||
352 | + } | ||
353 | + if id > 0 { | ||
354 | + if mod, err = rep.FindOne(map[string]interface{}{"productRecordId": id}); err != nil { | ||
355 | + if err == domain.ErrorNotFound { | ||
356 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该记录不存在") | ||
357 | + } | ||
358 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
359 | + } | ||
360 | + } | ||
361 | + return rep, mod, err | ||
362 | +} | ||
363 | + | ||
364 | +// FastPgWorkshopWorkTimeRecord 快速返回生产记录 | ||
365 | +// | ||
366 | +// transactionContext 事务 | ||
367 | +// id 对象唯一标识 | ||
368 | +func FastPgWorkshopWorkTimeRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.WorkshopWorkTimeRecordRepository, *domain.WorkshopWorkTimeRecord, error) { | ||
369 | + var rep domain.WorkshopWorkTimeRecordRepository | ||
370 | + var mod *domain.WorkshopWorkTimeRecord | ||
371 | + var err error | ||
372 | + if value, err := CreateWorkshopWorkTimeRecordRepository(map[string]interface{}{ | ||
373 | + "transactionContext": transactionContext, | ||
374 | + }); err != nil { | ||
375 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
376 | + } else { | ||
377 | + rep = value | ||
378 | + } | ||
379 | + if id > 0 { | ||
380 | + if mod, err = rep.FindOne(map[string]interface{}{"workshopWorkTimeRecordId": id}); err != nil { | ||
381 | + if err == domain.ErrorNotFound { | ||
382 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该记录不存在") | ||
383 | + } | ||
384 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
385 | + } | ||
386 | + } | ||
387 | + return rep, mod, err | ||
388 | +} | ||
389 | + | ||
390 | +// FastPgDeviceDailyRunningRecord 快速返回设备每日运行记录 | ||
391 | +// | ||
392 | +// transactionContext 事务 | ||
393 | +// id 对象唯一标识 | ||
394 | +func FastPgDeviceDailyRunningRecord(transactionContext application.TransactionContext, id int, options ...option) (domain.DeviceDailyRunningRecordRepository, *domain.DeviceDailyRunningRecord, error) { | ||
395 | + var rep domain.DeviceDailyRunningRecordRepository | ||
396 | + var mod *domain.DeviceDailyRunningRecord | ||
397 | + var err error | ||
398 | + if value, err := CreateDeviceDailyRunningRecordRepository(map[string]interface{}{ | ||
399 | + "transactionContext": transactionContext, | ||
400 | + }); err != nil { | ||
401 | + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
402 | + } else { | ||
403 | + rep = value | ||
404 | + } | ||
405 | + if id > 0 { | ||
406 | + if mod, err = rep.FindOne(map[string]interface{}{"deviceDailyRunningRecordId": id}); err != nil { | ||
407 | + if err == domain.ErrorNotFound { | ||
408 | + return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该记录不存在") | ||
409 | + } | ||
410 | + return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
411 | + } | ||
412 | + } | ||
413 | + return rep, mod, err | ||
414 | +} | ||
415 | + | ||
416 | +/***** 2.配置 *****/ | ||
417 | + | ||
418 | +type FastOptions struct { | ||
419 | + DataAuthRequired bool | ||
420 | + SetPrincipal bool | ||
421 | + OperateInfo *domain.OperateInfo | ||
422 | +} | ||
423 | + | ||
424 | +func NewFastOptions(options ...option) *FastOptions { | ||
425 | + o := &FastOptions{ | ||
426 | + DataAuthRequired: false, | ||
427 | + } | ||
428 | + for i := 0; i < len(options); i++ { | ||
429 | + options[i](o) | ||
430 | + } | ||
431 | + return o | ||
432 | +} | ||
433 | + | ||
434 | +type option func(options *FastOptions) | ||
435 | + | ||
436 | +// 需要数据权限 | ||
437 | +func WithDataAuthRequired() option { | ||
438 | + return func(options *FastOptions) { | ||
439 | + options.DataAuthRequired = true | ||
440 | + } | ||
441 | +} | ||
442 | + | ||
443 | +// WithOperator 操作人 | ||
444 | +func WithOperator(op *domain.OperateInfo) option { | ||
445 | + return func(options *FastOptions) { | ||
446 | + options.OperateInfo = op | ||
447 | + } | ||
448 | +} | ||
449 | + | ||
450 | +// WithOperator 操作人 | ||
451 | +func WithSetPrincipal() option { | ||
452 | + return func(options *FastOptions) { | ||
453 | + options.SetPrincipal = true | ||
454 | + } | ||
455 | +} |
-
请 注册 或 登录 后发表评论