作者 Your Name

Merge branch 'dev' into test

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