作者 yangfu

fix: 历史记录查询修改(已审核状态)

@@ -41,5 +41,8 @@ func (d *HistoryProductRecord) LoadDto(m *domain.ProductRecord) *HistoryProductR @@ -41,5 +41,8 @@ func (d *HistoryProductRecord) LoadDto(m *domain.ProductRecord) *HistoryProductR
41 //log.Logger.Debug("not equal", map[string]interface{}{"t1": xtime.BeginningOfDay(), "t2": xtime.New(m.CreatedAt.Local()).BeginningOfDay()}) 41 //log.Logger.Debug("not equal", map[string]interface{}{"t1": xtime.BeginningOfDay(), "t2": xtime.New(m.CreatedAt.Local()).BeginningOfDay()})
42 d.Status = domain.ProductRecordLogged 42 d.Status = domain.ProductRecordLogged
43 } 43 }
  44 + if m.ProductRecordType == domain.RecordTypeSecondLevelWeigh && m.ProductRecordInfo.ApproveStatus == domain.ProductRecordAutoApproved {
  45 + d.Status = domain.ProductRecordApproved
  46 + }
44 return d 47 return d
45 } 48 }
@@ -54,6 +54,8 @@ type HistoryProductRecordQuery struct { @@ -54,6 +54,8 @@ type HistoryProductRecordQuery struct {
54 ProductWorkerId int `cname:"生产员工ID" json:"productWorkerId"` 54 ProductWorkerId int `cname:"生产员工ID" json:"productWorkerId"`
55 // 状态 0:全部 1:未审核 2:已审核 3:已撤回 4:已记录 55 // 状态 0:全部 1:未审核 2:已审核 3:已撤回 4:已记录
56 Status int `cname:"状态" json:"status"` 56 Status int `cname:"状态" json:"status"`
  57 + // 状态 0:全部 1:未审核 2:已审核 3:已撤回 4:已记录
  58 + InStatus []int `cname:"匹配多个状态" json:"intStatus"`
57 59
58 // 开始时间 60 // 开始时间
59 ProductBeginTime time.Time `cname:"开始时间" json:"productBeginTime"` 61 ProductBeginTime time.Time `cname:"开始时间" json:"productBeginTime"`
@@ -108,6 +110,10 @@ func (cmd *HistoryProductRecordQuery) Valid(validation *validation.Validation) { @@ -108,6 +110,10 @@ func (cmd *HistoryProductRecordQuery) Valid(validation *validation.Validation) {
108 } 110 }
109 } 111 }
110 } 112 }
  113 + if cmd.ProductRecordType == domain.RecordTypeSecondLevelWeigh && cmd.Status == domain.ProductRecordApproved {
  114 + cmd.Status = 0
  115 + cmd.InStatus = []int{domain.ProductRecordApproved, domain.ProductRecordAutoApproved}
  116 + }
111 } 117 }
112 118
113 func (cmd *HistoryProductRecordQuery) ValidateQuery() error { 119 func (cmd *HistoryProductRecordQuery) ValidateQuery() error {
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/models" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/models"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/transform" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/transform"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
9 "time" 10 "time"
10 11
11 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 12 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
@@ -189,6 +190,9 @@ func (repository *ProductRecordRepository) Find(queryOptions map[string]interfac @@ -189,6 +190,9 @@ func (repository *ProductRecordRepository) Find(queryOptions map[string]interfac
189 if v, ok := queryOptions["status"]; ok && v.(int) > 0 { 190 if v, ok := queryOptions["status"]; ok && v.(int) > 0 {
190 query.Where(fmt.Sprintf(`product_record_info->>'approveStatus' = '%v'`, v)) 191 query.Where(fmt.Sprintf(`product_record_info->>'approveStatus' = '%v'`, v))
191 } 192 }
  193 + if v, ok := queryOptions["inStatus"]; ok && len(v.([]int)) > 0 {
  194 + query.Where(`product_record_info->>'approveStatus' in (?)`, pg.In(utils.ToArrayString(v.([]int))))
  195 + }
192 if v, ok := queryOptions["lastProductRecordId"]; ok && v.(int) > 0 { 196 if v, ok := queryOptions["lastProductRecordId"]; ok && v.(int) > 0 {
193 query.Where(`product_record_id < ?`, v) 197 query.Where(`product_record_id < ?`, v)
194 } 198 }