sync: 同步 v1.0.4 并脱敏配置与镜像
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Package gen
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2026 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <xxx@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// @AutoGenerate Version
|
||||
package common
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/allocationunits"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/batchmetadata"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/contexts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/exportcenter"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/rabbitmq"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgorm"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgorm/handler"
|
||||
@@ -87,6 +88,8 @@ func validateRequeueBatch(batch *entity.BatchMain) error {
|
||||
return nil
|
||||
case consts.BatchAsyncStatusProcessing:
|
||||
return validateProcessingRequeueBatch(batch)
|
||||
case consts.BatchAsyncStatusReview:
|
||||
return gerror.New("待核查批次不支持安全重投,请先核对上游执行结果")
|
||||
case consts.BatchAsyncStatusFailed, consts.BatchAsyncStatusSuccess, consts.BatchAsyncStatusPartialSuccess:
|
||||
return gerror.New("终态批次不支持安全重投")
|
||||
default:
|
||||
@@ -248,7 +251,17 @@ func (s *sCommonBatchMain) SuccessList(ctx context.Context, in *model.BatchMainS
|
||||
if in.BatchType != 0 {
|
||||
requestedBatchType = &in.BatchType
|
||||
}
|
||||
mod = visibleBatchTypeModel(mod, columns.BatchType, requestedBatchType)
|
||||
mod = successListBatchTypeModel(mod, columns.BatchType, requestedBatchType)
|
||||
|
||||
if chanKey := strings.TrimSpace(in.ChanKey); chanKey != "" {
|
||||
extract := "JSON_UNQUOTE(JSON_EXTRACT(%s, '%s'))"
|
||||
if strings.EqualFold(dao.BatchMain.DB().GetConfig().Type, "sqlite") {
|
||||
extract = "JSON_EXTRACT(%s, '%s')"
|
||||
}
|
||||
nested := fmt.Sprintf(extract, columns.BatchInfo, "$.inboundOptions.chanKey")
|
||||
legacy := fmt.Sprintf(extract, columns.BatchInfo, "$.chanKey")
|
||||
mod = mod.Where(fmt.Sprintf("CASE WHEN JSON_VALID(%s) THEN COALESCE(NULLIF(TRIM(%s), ''), TRIM(%s)) END = ?", columns.BatchInfo, nested, legacy), chanKey)
|
||||
}
|
||||
|
||||
if in.BatchNo != "" {
|
||||
mod = mod.Where(columns.BatchNo+" LIKE ?", "%"+in.BatchNo+"%")
|
||||
@@ -343,6 +356,7 @@ func (s *sCommonBatchMain) ListCards(ctx context.Context, in *model.BatchCardLis
|
||||
}
|
||||
|
||||
details, totalCount, err := s.listBatchDetails(ctx, batch, batchDetailQuery{
|
||||
DetailStatus: in.DetailStatus,
|
||||
BatchNo: in.BatchNo,
|
||||
BatchType: in.BatchType,
|
||||
Iccid: in.Iccid,
|
||||
@@ -370,6 +384,7 @@ func (s *sCommonBatchMain) ListCards(ctx context.Context, in *model.BatchCardLis
|
||||
Msisdn: msisdn,
|
||||
Imsi: imsi,
|
||||
DetailStatus: detail.DetailStatus,
|
||||
ErrorReason: detail.ErrorReason,
|
||||
}
|
||||
if batch.BatchType == consts.BatchTypeAllocate {
|
||||
item.Fields = allocationunits.Resolve(detail.Snapshot, parentUnits.SourceDeptId, parentUnits.TargetDeptId)
|
||||
@@ -439,13 +454,22 @@ func (s *sCommonBatchMain) listBatchDetails(ctx context.Context, batch *entity.B
|
||||
mod = onlyCurrentStockDetails(mod)
|
||||
}
|
||||
|
||||
mod = mod.Page(query.Page, query.PageSize).OrderAsc(columns.RowNo)
|
||||
mod = orderBatchCards(mod.Page(query.Page, query.PageSize), batch.BatchType)
|
||||
if err = mod.ScanAndCount(&list, &totalCount, false); err != nil {
|
||||
return nil, 0, gerror.Wrap(err, "获取批次明细列表失败,请稍后重试")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func orderBatchCards(mod *gdb.Model, batchType int) *gdb.Model {
|
||||
columns := dao.BatchDetail.Columns()
|
||||
if batchType == consts.BatchTypeInbound || batchType == consts.BatchTypeOutbound || batchType == consts.BatchTypeAllocate {
|
||||
order := fmt.Sprintf("CASE WHEN %s = %d AND COALESCE(%s, '') NOT LIKE '本批%%整批未执行%%' AND COALESCE(%s, '') NOT LIKE '同批%%本行未执行%%' AND COALESCE(%s, '') NOT LIKE '同批%%整批未入库%%' THEN 0 ELSE 1 END, %s ASC, %s ASC", columns.DetailStatus, consts.BatchDetailStatusFailed, columns.ErrorReason, columns.ErrorReason, columns.ErrorReason, columns.RowNo, columns.Id)
|
||||
return mod.Order(gdb.Raw(order))
|
||||
}
|
||||
return mod.OrderAsc(columns.RowNo).OrderAsc(columns.Id)
|
||||
}
|
||||
|
||||
func onlyCurrentStockDetails(mod *gdb.Model) *gdb.Model {
|
||||
detailTable := dao.BatchDetail.Table()
|
||||
stockTable := dao.TSimCardStock.Table()
|
||||
@@ -508,6 +532,41 @@ func batchDetailSnapshotCards(detail *entity.BatchDetail) (iccid, msisdn, imsi s
|
||||
return
|
||||
}
|
||||
|
||||
// ExportWarehousing 导出入库批次列表(异步:提交任务后到下载中心取文件)。
|
||||
// 数据来源与入库管理页保持一致:成功批次列表(batch_type=入库)。
|
||||
func (s *sCommonBatchMain) ExportWarehousing(ctx context.Context, in *model.BatchMainSuccessListParam) (err error) {
|
||||
if in == nil {
|
||||
in = &model.BatchMainSuccessListParam{}
|
||||
}
|
||||
// 与页面 WarehousingList 一致:固定只导入库批次,不接受调用方传其它类型
|
||||
in.BatchType = consts.BatchTypeInbound
|
||||
|
||||
_, err = exportcenter.Submit(ctx, &exportcenter.Request{
|
||||
BizKey: "batchMainWarehousing",
|
||||
BizName: "入库管理",
|
||||
PermCode: "cpm:iot:tSimCardStock:export",
|
||||
QueryParam: in,
|
||||
Tags: func() ([]string, error) {
|
||||
return convert.GetEntityDescTags(model.BatchMainSuccessListModel{})
|
||||
},
|
||||
Fetch: func(ctx context.Context, page, pageSize int) (rows []interface{}, total int, err error) {
|
||||
query := *in
|
||||
query.Page = page
|
||||
query.PageSize = pageSize
|
||||
list, count, err := s.SuccessList(ctx, &query)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
rows = make([]interface{}, 0, len(list))
|
||||
for _, item := range list {
|
||||
rows = append(rows, item)
|
||||
}
|
||||
return rows, count, nil
|
||||
},
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// Export 导出批次主表
|
||||
func (s *sCommonBatchMain) Export(ctx context.Context, in *model.BatchMainListParam) (err error) {
|
||||
list, totalCount, err := s.List(ctx, in)
|
||||
|
||||
Reference in New Issue
Block a user