作者 Your Name

Merge branch 'dev' into test

1 package command 1 package command
2 2
3 //创建事故记录 3 //创建事故记录
4 -type SaveProductTroubleCommand struct { 4 +type CreateProductTroubleCommand struct {
5 Id int `json:"id"` //id 5 Id int `json:"id"` //id
6 WorkshopId int `json:"workshopId" valid:"Required"` //车间id 6 WorkshopId int `json:"workshopId" valid:"Required"` //车间id
7 LineId int `json:"lineId" valid:"Required"` //生产线ID 7 LineId int `json:"lineId" valid:"Required"` //生产线ID
  1 +package command
  2 +
  3 +//保存事故记录
  4 +type SaveProductTroubleCommand struct {
  5 + Id int `json:"id"` //id
  6 + WorkshopId int `json:"workshopId" valid:"Required"` //车间id
  7 + LineId int `json:"lineId" valid:"Required"` //生产线ID
  8 + SectionId int `json:"sectionId" valid:"Required"` //工段ID
  9 + WorkerId int `json:"workerId"` //员工id
  10 + Remark string `json:"remark"` //备注
  11 + AmountLoss float64 `json:"amountLoss"` // 损失的金额
  12 + Types string `json:"types"` // 事故类型 1 安全事故 ,2 质量事故, 3 金属事故 ,4 非金属事故
  13 + RecordDate string `json:"recordDate"` // 事故发生的日期
  14 + SaveAndApprove bool `json:"saveAndApprove"` //保存并审核
  15 +}
@@ -56,16 +56,17 @@ func (srv ProductTroubleService) SaveProductTrouble(operateInfo *domain.OperateI @@ -56,16 +56,17 @@ func (srv ProductTroubleService) SaveProductTrouble(operateInfo *domain.OperateI
56 if err != nil { 56 if err != nil {
57 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 57 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
58 } 58 }
  59 +
  60 + recordDate, err := time.ParseInLocation("2006-01-02", param.RecordDate, time.Local)
  61 + if err != nil {
  62 + return nil, application.ThrowError(application.ARG_ERROR, "日期格式错误")
  63 + }
59 var workerUser *domain.User 64 var workerUser *domain.User
60 userService := domainService.NewUserService() 65 userService := domainService.NewUserService()
61 workerUser, err = userService.User(param.WorkerId) 66 workerUser, err = userService.User(param.WorkerId)
62 if err != nil { 67 if err != nil {
63 return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息失败,"+err.Error()) 68 return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息失败,"+err.Error())
64 } 69 }
65 - recordDate, err := time.ParseInLocation("2006-01-02", param.RecordDate, time.Local)  
66 - if err != nil {  
67 - return nil, application.ThrowError(application.ARG_ERROR, "日期格式错误")  
68 - }  
69 var troubleData *domain.ProductTrouble 70 var troubleData *domain.ProductTrouble
70 if param.Id > 0 { 71 if param.Id > 0 {
71 troubleData, err = productTroubleRepo.FindOne(map[string]interface{}{ 72 troubleData, err = productTroubleRepo.FindOne(map[string]interface{}{
@@ -109,6 +110,7 @@ func (srv ProductTroubleService) SaveProductTrouble(operateInfo *domain.OperateI @@ -109,6 +110,7 @@ func (srv ProductTroubleService) SaveProductTrouble(operateInfo *domain.OperateI
109 if err != nil { 110 if err != nil {
110 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 111 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
111 } 112 }
  113 +
112 if err := transactionContext.CommitTransaction(); err != nil { 114 if err := transactionContext.CommitTransaction(); err != nil {
113 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 115 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
114 } 116 }
@@ -185,7 +185,7 @@ func (svr *CommonStatisticsService) SectionProductInfo() (interface{}, error) { @@ -185,7 +185,7 @@ func (svr *CommonStatisticsService) SectionProductInfo() (interface{}, error) {
185 _ = transactionContext.RollbackTransaction() 185 _ = transactionContext.RollbackTransaction()
186 }() 186 }()
187 boardShowData, _ := dao.NewBoardShowDao(transactionContext.(*pgTransaction.TransactionContext)) 187 boardShowData, _ := dao.NewBoardShowDao(transactionContext.(*pgTransaction.TransactionContext))
188 - result, err := boardShowData.ProportionOfSecondLevel( 188 + result, err := boardShowData.SectionProductInfo(
189 constant.MANUFACTURE_DEFAULT_COMPANYID, 189 constant.MANUFACTURE_DEFAULT_COMPANYID,
190 constant.MANUFACTURE_DEFAULT_ORGID, 190 constant.MANUFACTURE_DEFAULT_ORGID,
191 constant.MANUFACTURE_DEFAULT_WORKSHOPID, 191 constant.MANUFACTURE_DEFAULT_WORKSHOPID,