...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/allied-lib/gateway/byte_bank"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -73,51 +74,51 @@ func (svr *ByteBankService) DeviceOperationEfficiency() (interface{}, error) { |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
//deviceRepository, _ := repository.NewDeviceRepository(transactionContext)
|
|
|
//_, devices, err := deviceRepository.Find(map[string]interface{}{
|
|
|
// "companyId": constant.MANUFACTURE_DEFAULT_COMPANYID,
|
|
|
// "orgId": constant.MANUFACTURE_DEFAULT_ORGID,
|
|
|
// "workshopId": constant.MANUFACTURE_DEFAULT_WORKSHOPID,
|
|
|
// "orderBy": "device_name asc"})
|
|
|
//if err != nil {
|
|
|
// return nil, err
|
|
|
//}
|
|
|
//var response = make([]interface{}, 0)
|
|
|
//for _, d := range devices {
|
|
|
// var deviceSn string
|
|
|
// var productCount, runningTime int64
|
|
|
// for _, item := range queryResult {
|
|
|
// deviceSn = item.Get("device_sn").String()
|
|
|
// if deviceSn == d.DeviceCode {
|
|
|
// productCount = item.Get("product_count").Int()
|
|
|
// runningTime = item.Get("timing").Int()
|
|
|
// break
|
|
|
// }
|
|
|
// }
|
|
|
// response = append(response, map[string]interface{}{
|
|
|
// "deviceName": d.DeviceName,
|
|
|
// "deviceType": d.DeviceType,
|
|
|
// "productCount": productCount,
|
|
|
// "timing": runningTime,
|
|
|
// })
|
|
|
//}
|
|
|
|
|
|
deviceRepository, _ := repository.NewDeviceRepository(transactionContext)
|
|
|
_, devices, err := deviceRepository.Find(map[string]interface{}{
|
|
|
"companyId": constant.MANUFACTURE_DEFAULT_COMPANYID,
|
|
|
"orgId": constant.MANUFACTURE_DEFAULT_ORGID,
|
|
|
"workshopId": constant.MANUFACTURE_DEFAULT_WORKSHOPID,
|
|
|
"orderBy": "device_name asc"})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
var response = make([]interface{}, 0)
|
|
|
for _, d := range devices {
|
|
|
var deviceSn string
|
|
|
var productCount, runningTime int64
|
|
|
for _, item := range queryResult {
|
|
|
deviceSn = item.Get("device_sn").String()
|
|
|
if deviceSn != "" {
|
|
|
if deviceSn == d.DeviceCode {
|
|
|
productCount = item.Get("product_count").Int()
|
|
|
runningTime = item.Get("timing").Int()
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
response = append(response, map[string]interface{}{
|
|
|
"设备名称": deviceSn,
|
|
|
"设备类型": item.Get("device_type").String(),
|
|
|
"运行时长": productCount,
|
|
|
"数量": runningTime,
|
|
|
"device_name": d.DeviceName,
|
|
|
"device_type": d.DeviceType,
|
|
|
"product_count": productCount,
|
|
|
"timing": runningTime,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//var response = make([]interface{}, 0)
|
|
|
//var deviceSn string
|
|
|
//var productCount, runningTime int64
|
|
|
//for _, item := range queryResult {
|
|
|
// deviceSn = item.Get("device_sn").String()
|
|
|
// if deviceSn != "" {
|
|
|
// productCount = item.Get("product_count").Int()
|
|
|
// runningTime = item.Get("timing").Int()
|
|
|
// response = append(response, map[string]interface{}{
|
|
|
// "设备名称": deviceSn,
|
|
|
// "设备类型": item.Get("device_type").String(),
|
|
|
// "运行时长": productCount,
|
|
|
// "数量": runningTime,
|
|
|
// })
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
|