...
|
...
|
@@ -199,6 +199,47 @@ func (srv ExcelDataService) ImportProduct(importDataCommand *command.ImportDataC |
|
|
return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
|
|
|
}
|
|
|
|
|
|
// ImportProduct 导入生产信息
|
|
|
func (srv ExcelDataService) ImportDevice(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
excelImport := excel.NewExcelImport()
|
|
|
excelImport.RowBegin = 3 //第二行开始读取
|
|
|
excelImport.DataFields = []excel.DataField{
|
|
|
{EnName: "deviceCode", CnName: "*设备编号"},
|
|
|
{EnName: "deviceName", CnName: "*设备名称"},
|
|
|
{EnName: "deviceModel", CnName: "*设备型号"},
|
|
|
{EnName: "deviceType", CnName: "*设备类型"},
|
|
|
{EnName: "brand", CnName: "品牌"},
|
|
|
{EnName: "status", CnName: "*状态"},
|
|
|
{EnName: "level", CnName: "*风险等级"},
|
|
|
}
|
|
|
excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
items := make([]*domain.ImportDeviceItem, 0)
|
|
|
for _, v := range excelData {
|
|
|
item := &domain.ImportDeviceItem{
|
|
|
DeviceCode: strings.TrimSpace(v["deviceCode"]),
|
|
|
DeviceName: strings.TrimSpace(v["deviceName"]),
|
|
|
DeviceModel: strings.TrimSpace(v["deviceModel"]),
|
|
|
DeviceType: strings.TrimSpace(v["deviceType"]),
|
|
|
Brand: strings.TrimSpace(v["brand"]),
|
|
|
Status: strings.TrimSpace(v["status"]),
|
|
|
Level: strings.TrimSpace(v["level"]),
|
|
|
}
|
|
|
items = append(items, item)
|
|
|
}
|
|
|
|
|
|
svr := allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(importDataCommand.Operator)
|
|
|
result, err := svr.BatchAddDevice(allied_creation_manufacture.BatchAddDeviceRequest{
|
|
|
List: items,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
|
|
|
}
|
|
|
|
|
|
// 导入结果
|
|
|
func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, failRows []interface{}, totalRow int) interface{} {
|
|
|
var result = map[string]interface{}{
|
...
|
...
|
@@ -242,6 +283,8 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import |
|
|
domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743206_NPYTKw6RGhXn4TpYNEQhGGdCkXKXTnxM.xlsx",
|
|
|
domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210926/object/1632635345_SbfzmkXjQHhCwPw4MB7zb5EBBtdp2MSE.xlsx",
|
|
|
domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx",
|
|
|
domain.ImportProducts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220120/object/1642670543_cbraNKjNPHcbN6RNBYQBrwhC7BXGbDWp.xlsx",
|
|
|
domain.ImportDevices: "",
|
|
|
}
|
|
|
var url string
|
|
|
var ok bool
|
...
|
...
|
|