|
@@ -199,6 +199,47 @@ func (srv ExcelDataService) ImportProduct(importDataCommand *command.ImportDataC |
|
@@ -199,6 +199,47 @@ func (srv ExcelDataService) ImportProduct(importDataCommand *command.ImportDataC |
199
|
return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
|
199
|
return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
|
200
|
}
|
200
|
}
|
201
|
|
201
|
|
|
|
202
|
+// ImportProduct 导入生产信息
|
|
|
203
|
+func (srv ExcelDataService) ImportDevice(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
204
|
+ excelImport := excel.NewExcelImport()
|
|
|
205
|
+ excelImport.RowBegin = 3 //第二行开始读取
|
|
|
206
|
+ excelImport.DataFields = []excel.DataField{
|
|
|
207
|
+ {EnName: "deviceCode", CnName: "*设备编号"},
|
|
|
208
|
+ {EnName: "deviceName", CnName: "*设备名称"},
|
|
|
209
|
+ {EnName: "deviceModel", CnName: "*设备型号"},
|
|
|
210
|
+ {EnName: "deviceType", CnName: "*设备类型"},
|
|
|
211
|
+ {EnName: "brand", CnName: "品牌"},
|
|
|
212
|
+ {EnName: "status", CnName: "*状态"},
|
|
|
213
|
+ {EnName: "level", CnName: "*风险等级"},
|
|
|
214
|
+ }
|
|
|
215
|
+ excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
216
|
+ if err != nil {
|
|
|
217
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
218
|
+ }
|
|
|
219
|
+ items := make([]*domain.ImportDeviceItem, 0)
|
|
|
220
|
+ for _, v := range excelData {
|
|
|
221
|
+ item := &domain.ImportDeviceItem{
|
|
|
222
|
+ DeviceCode: strings.TrimSpace(v["deviceCode"]),
|
|
|
223
|
+ DeviceName: strings.TrimSpace(v["deviceName"]),
|
|
|
224
|
+ DeviceModel: strings.TrimSpace(v["deviceModel"]),
|
|
|
225
|
+ DeviceType: strings.TrimSpace(v["deviceType"]),
|
|
|
226
|
+ Brand: strings.TrimSpace(v["brand"]),
|
|
|
227
|
+ Status: strings.TrimSpace(v["status"]),
|
|
|
228
|
+ Level: strings.TrimSpace(v["level"]),
|
|
|
229
|
+ }
|
|
|
230
|
+ items = append(items, item)
|
|
|
231
|
+ }
|
|
|
232
|
+
|
|
|
233
|
+ svr := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(importDataCommand.Operator)
|
|
|
234
|
+ result, err := svr.BatchAddDevice(allied_creation_manufacture.BatchAddDeviceRequest{
|
|
|
235
|
+ List: items,
|
|
|
236
|
+ })
|
|
|
237
|
+ if err != nil {
|
|
|
238
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
239
|
+ }
|
|
|
240
|
+ return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
|
|
|
241
|
+}
|
|
|
242
|
+
|
202
|
// 导入结果
|
243
|
// 导入结果
|
203
|
func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, failRows []interface{}, totalRow int) interface{} {
|
244
|
func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, failRows []interface{}, totalRow int) interface{} {
|
204
|
var result = map[string]interface{}{
|
245
|
var result = map[string]interface{}{
|
|
@@ -242,6 +283,8 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import |
|
@@ -242,6 +283,8 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import |
242
|
domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743206_NPYTKw6RGhXn4TpYNEQhGGdCkXKXTnxM.xlsx",
|
283
|
domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743206_NPYTKw6RGhXn4TpYNEQhGGdCkXKXTnxM.xlsx",
|
243
|
domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210926/object/1632635345_SbfzmkXjQHhCwPw4MB7zb5EBBtdp2MSE.xlsx",
|
284
|
domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210926/object/1632635345_SbfzmkXjQHhCwPw4MB7zb5EBBtdp2MSE.xlsx",
|
244
|
domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx",
|
285
|
domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx",
|
|
|
286
|
+ domain.ImportProducts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220120/object/1642670543_cbraNKjNPHcbN6RNBYQBrwhC7BXGbDWp.xlsx",
|
|
|
287
|
+ domain.ImportDevices: "",
|
245
|
}
|
288
|
}
|
246
|
var url string
|
289
|
var url string
|
247
|
var ok bool
|
290
|
var ok bool
|