...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productTrouble/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService"
|
|
|
)
|
...
|
...
|
@@ -137,6 +138,8 @@ func (srv ProductTroubleService) GetProductTrouble(id int) (*dto.ProductTroubleI |
|
|
ProductDate: troubleData.RecordData.Format("2006-01-02"),
|
|
|
AmountLoss: troubleData.AmountLoss,
|
|
|
Types: int(troubleData.Types),
|
|
|
WorkerId: troubleData.ProductWorker.UserId,
|
|
|
WorkerName: troubleData.ProductWorker.UserName,
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
...
|
...
|
@@ -212,3 +215,68 @@ func (srv ProductTroubleService) ApproveProductTrouble(operateInfo *domain.Opera |
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// ListProductTrouble 事故管理列表
|
|
|
func (srv ProductTroubleService) ListProductTrouble(param *query.ListProductTrouble) (int64, []dto.ProductTroubleList, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
productTroubleRepo, _ := factory.CreateProductTroubleRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
limit := param.PageSize
|
|
|
offset := param.PageSize * (param.PageNumber - 1)
|
|
|
condition := map[string]interface{}{
|
|
|
"limit": limit,
|
|
|
"offsett": offset,
|
|
|
"companyId": param.CompanyId,
|
|
|
"orgId": param.OrgId,
|
|
|
}
|
|
|
|
|
|
if len(param.WorkerName) > 0 {
|
|
|
condition["productWorkerName"] = param.WorkerName
|
|
|
}
|
|
|
|
|
|
if len(param.WorkshopName) > 0 {
|
|
|
condition["workshopName"] = param.WorkshopName
|
|
|
}
|
|
|
cnt, troubleDataList, err := productTroubleRepo.Find(condition)
|
|
|
if err != nil {
|
|
|
return 0, nil, application.ThrowError(application.ARG_ERROR, "事故数据不存在,"+err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
result := []dto.ProductTroubleList{}
|
|
|
var item dto.ProductTroubleList
|
|
|
for _, v := range troubleDataList {
|
|
|
item = dto.ProductTroubleList{
|
|
|
Id: v.Id,
|
|
|
WorkshopId: v.WorkStation.WorkshopId,
|
|
|
WorkshopName: v.WorkStation.WorkshopName,
|
|
|
LineId: v.WorkStation.LineId,
|
|
|
LineName: v.WorkStation.LineName,
|
|
|
SectionId: v.WorkStation.SectionId,
|
|
|
SectionName: v.WorkStation.SectionName,
|
|
|
Remark: v.Remark,
|
|
|
ProductDate: v.RecordData.Format("2006-01-02"),
|
|
|
AmountLoss: v.AmountLoss,
|
|
|
Types: v.GetTypesName(),
|
|
|
WorkerId: v.ProductWorker.UserId,
|
|
|
WorkerName: v.ProductWorker.UserName,
|
|
|
ApproveStatus: int(v.ApproveStatus),
|
|
|
ApproveStatusName: v.GetApproveStatusName(),
|
|
|
}
|
|
|
result = append(result, item)
|
|
|
}
|
|
|
return cnt, result, nil
|
|
|
} |
...
|
...
|
|