作者 Your Name

更新产能

package command
type SaveEmployeeProductRecordCmd struct {
type SaveProductRecordCmd struct {
//id
ProductRecordId int `json:"productRecordId"`
// 车间ID
WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"`
// 生产线ID
... ...
... ... @@ -15,7 +15,7 @@ import (
//产能管理
// 产能管理 页面上手动创建员工生产记录
func (productRecordService *ProductRecordService) CreateProductCapacities(operateInfo *domain.OperateInfo, param *command.SaveEmployeeProductRecordCmd) (map[string]interface{}, error) {
func (productRecordService *ProductRecordService) SaveProductCapacities(operateInfo *domain.OperateInfo, param *command.SaveProductRecordCmd) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -81,14 +81,27 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat
productRecordRepo, _ := factory.CreateProductRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
nowTime := time.Now()
if param.ProductRecordId > 0 {
productRecord, err := productRecordRepo.FindOne(map[string]interface{}{
"productRecordId": param.ProductRecordId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取生产记录数据失败"+err.Error())
}
if productRecord.ProductRecordInfo.ApproveStatus != domain.ProductRecordNotApprove {
return nil, application.ThrowError(application.ARG_ERROR, "生产记录不可再被编辑")
}
}
epRecord := &domain.ProductRecord{
UpdatedAt: nowTime,
OrgId: operateInfo.OrgId,
CompanyId: operateInfo.CompanyId,
WorkStation: workstation,
ProductWorker: worker,
CreatedAt: recordDate,
ProductRecordId: param.ProductRecordId,
UpdatedAt: nowTime,
OrgId: operateInfo.OrgId,
CompanyId: operateInfo.CompanyId,
WorkStation: workstation,
ProductWorker: worker,
CreatedAt: recordDate,
Ext: &domain.Ext{
Operator: user,
OrgName: org.OrgName,
... ... @@ -112,7 +125,6 @@ func (productRecordService *ProductRecordService) CreateProductCapacities(operat
epRecord.ProductRecordInfo.ApproveStatus = domain.ProductRecordApproved
epRecord.ProductRecordInfo.ApproveUser = user
}
// epRecord.ParticipateType = param.ParticipateType //参与类型
_, err = productRecordRepo.Save(epRecord)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "保存员工生产记录失败"+err.Error())
... ... @@ -161,7 +173,7 @@ func (productRecordService *ProductRecordService) ListProductCapacities(operateI
condition["limit"] = limit
}
if offset >= 0 {
condition["offset"] = limit
condition["offset"] = offset
}
count, productRecords, err := productRecordRepo.Find(condition)
if err != nil {
... ...
... ... @@ -132,10 +132,22 @@ func (controller *ProductRecordController) SearchWorkshopProductRecord() {
// 产能管理 添加产能
func (controller *ProductRecordController) CreateProductCapacities() {
productRecordService := service.NewProductRecordService(nil)
saveCommand := &command.SaveEmployeeProductRecordCmd{}
saveCommand := &command.SaveProductRecordCmd{}
controller.Unmarshal(saveCommand)
operateInfo := ParseOperateInfo(controller.BaseController)
data, err := productRecordService.CreateProductCapacities(operateInfo, saveCommand)
data, err := productRecordService.SaveProductCapacities(operateInfo, saveCommand)
controller.Response(data, err)
}
// 产能管理 编辑产能
func (controller *ProductRecordController) UpdateProductCapacities() {
productRecordService := service.NewProductRecordService(nil)
saveCommand := &command.SaveProductRecordCmd{}
controller.Unmarshal(saveCommand)
productRecordId, _ := controller.GetInt(":productRecordId")
saveCommand.ProductRecordId = productRecordId
operateInfo := ParseOperateInfo(controller.BaseController)
data, err := productRecordService.SaveProductCapacities(operateInfo, saveCommand)
controller.Response(data, err)
}
... ...
... ... @@ -23,6 +23,8 @@ func init() {
web.Router("/product-records/product-capacities/search", &controllers.ProductRecordController{}, "Post:ListProductCapacities")
//产能管理 添加产能
web.Router("/product-records/product-capacities", &controllers.ProductRecordController{}, "Post:CreateProductCapacities")
//产能管理 编辑产能
web.Router("/product-records/product-capacities/:productRecordId", &controllers.ProductRecordController{}, "Put:UpdateProductCapacities")
//产能管理 列表-产能详情
web.Router("/product-records/product-capacities/:productRecordId", &controllers.ProductRecordController{}, "Get:GetProductCapacities")
//产能管理 列表 -删除产能
... ...