添加导出接口

This commit is contained in:
JNG 2026-01-09 14:39:42 +08:00
parent 70452455b9
commit 1bdd0eabb2
4 changed files with 117 additions and 2 deletions

View File

@ -1124,6 +1124,8 @@ type SupplierInfo struct {
CreatedAt string `protobuf:"bytes,23,opt,name=createdAt,proto3" json:"createdAt"`
UpdatedAt string `protobuf:"bytes,24,opt,name=updatedAt,proto3" json:"updatedAt"`
SupplierUniqueCode string `protobuf:"bytes,25,opt,name=supplierUniqueCode,proto3" json:"supplierUniqueCode"`
OwningEntityName string `protobuf:"bytes,26,opt,name=owningEntityName,proto3" json:"owningEntityName"`
CountryOrRegionCode string `protobuf:"bytes,27,opt,name=countryOrRegionCode,proto3" json:"countryOrRegionCode"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -1333,6 +1335,20 @@ func (x *SupplierInfo) GetSupplierUniqueCode() string {
return ""
}
func (x *SupplierInfo) GetOwningEntityName() string {
if x != nil {
return x.OwningEntityName
}
return ""
}
func (x *SupplierInfo) GetCountryOrRegionCode() string {
if x != nil {
return x.CountryOrRegionCode
}
return ""
}
type UpdateSupplierRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id"`
@ -1996,7 +2012,7 @@ const file_api_supplier_supplier_proto_rawDesc = "" +
"\x05total\x18\x01 \x01(\x04R\x05total\x12*\n" +
"\x04data\x18\x02 \x03(\v2\x16.supplier.SupplierInfoR\x04data\x12\x12\n" +
"\x04page\x18\x03 \x01(\x04R\x04page\x12\x1a\n" +
"\bpageSize\x18\x04 \x01(\x04R\bpageSize\"\x92\b\n" +
"\bpageSize\x18\x04 \x01(\x04R\bpageSize\"\xf0\b\n" +
"\fSupplierInfo\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x04R\x02id\x12&\n" +
"\x0eowningEntityId\x18\x02 \x01(\x04R\x0eowningEntityId\x12\x1c\n" +
@ -2023,7 +2039,9 @@ const file_api_supplier_supplier_proto_rawDesc = "" +
"\x06status\x18\x16 \x01(\x04R\x06status\x12\x1c\n" +
"\tcreatedAt\x18\x17 \x01(\tR\tcreatedAt\x12\x1c\n" +
"\tupdatedAt\x18\x18 \x01(\tR\tupdatedAt\x12.\n" +
"\x12supplierUniqueCode\x18\x19 \x01(\tR\x12supplierUniqueCode\"\xaf\a\n" +
"\x12supplierUniqueCode\x18\x19 \x01(\tR\x12supplierUniqueCode\x12*\n" +
"\x10owningEntityName\x18\x1a \x01(\tR\x10owningEntityName\x120\n" +
"\x13countryOrRegionCode\x18\x1b \x01(\tR\x13countryOrRegionCode\"\xaf\a\n" +
"\x15UpdateSupplierRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x04R\x02id\x12&\n" +
"\x0eowningEntityId\x18\x02 \x01(\x04R\x0eowningEntityId\x12\x1c\n" +

View File

@ -144,6 +144,8 @@ message SupplierInfo{
string createdAt = 23;
string updatedAt = 24;
string supplierUniqueCode = 25;
string owningEntityName = 26;
string countryOrRegionCode = 27;
}
message UpdateSupplierRequest{
uint64 id = 1;

View File

@ -29,6 +29,7 @@ func SupplierRouter(r *gin.RouterGroup) {
{
supplierRoute.POST("import/record", supplier.CreateImportRecord)
supplierRoute.POST("import/info", supplier.GetImportRecordInfo)
supplierRoute.POST("export/list", supplier.GetExportList)
}
}

View File

@ -8,6 +8,7 @@ import (
"fonchain-fiee/pkg/model/login"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/service/upload"
"fonchain-fiee/pkg/utils"
"fonchain-fiee/pkg/utils/excel"
"os"
"time"
@ -295,3 +296,96 @@ func GetImportRecordInfo(c *gin.Context) {
service.Success(c, res)
return
}
func GetExportList(c *gin.Context) {
req := &supplier.GetSupplierListRequest{}
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
infoRes, err := service.SupplierProvider.GetSupplierList(c, req)
if err != nil {
service.Error(c, err)
return
}
// 定义标题列表
titleList := []string{
"状态/State", "使用组织/Owning Entity", "供应商唯一编码/SupplierUnique Code", "供应商法定全称(英文)/LegalName (English)", "供应商本地名称(如有)/LocalName (if applicable)",
"所在国家或地区/Country or Region", "公司注册编号/Company RegistrationNumber", "供应商类型/Supplier Type", "准入状态/Approval Status", "准入日期/ApprovalDate",
"法律实体形式/Legal Entity Type", "制裁与高风险国家筛查结果/Sanctions & High-RiskCountry Screening Result", "关键财务与付款信息/Key Financial & Payment Information",
"公司地址/Company Address", "主要联系人、职位及联系方式/Primary Contact,Position&Details", "数据维护部门&人员/Data Owner Department/Personnel", "最后更新日期/Last Updated Date",
"公司信息概要/Summary of Basic Company Information",
}
// 定义数据结构
type DataInfo struct {
Status string
OwningEntity string
SupplierUniqueCode string
LegalName string
LocalName string
CountryOrRegion string
CompanyRegistrationNumber string
SupplierType string
ApprovalStatus string
ApprovalDate string
LegalEntityType string
SanctionsCountryScreeningResult string
KeyFinancial string
CompanyAddress string
PrimaryContact string
DataOwnerDepartment string
UpdatedAt string
BasicCompanyInformation string
}
// 创建员工ID到DataInfo的映射
dataMap := make(map[string]*DataInfo)
statusMap := map[uint64]string{
1: "草稿",
2: "审核中",
3: "已驳回",
4: "已成功",
}
for _, info := range infoRes.Data {
dataMap[info.SupplierUniqueCode] = &DataInfo{
Status: statusMap[info.Status],
OwningEntity: info.OwningEntityName,
SupplierUniqueCode: info.SupplierUniqueCode,
LegalName: info.LegalName,
LocalName: info.LocalName,
CountryOrRegion: info.CountryOrRegionCode,
CompanyRegistrationNumber: info.CompanyRegistrationNumber,
SupplierType: info.SupplierType,
ApprovalStatus: info.ApprovalStatus,
ApprovalDate: info.ApprovalDate,
LegalEntityType: info.LegalEntityType,
SanctionsCountryScreeningResult: info.SanctionsCountryScreeningResult,
KeyFinancial: info.KeyFinancial,
CompanyAddress: info.CompanyAddress,
PrimaryContact: info.PrimaryContact,
DataOwnerDepartment: info.DataOwnerDepartment,
UpdatedAt: info.UpdatedAt,
BasicCompanyInformation: info.BasicCompanyInformation,
}
}
// 生成最终数据列表
var dataList []interface{}
for _, data := range dataMap {
dataList = append(dataList, &[]any{
data.Status, data.OwningEntity, data.SupplierUniqueCode, data.LegalName, data.LocalName,
data.CountryOrRegion, data.CompanyRegistrationNumber, data.SupplierType, data.ApprovalStatus, data.ApprovalDate,
data.LegalEntityType, data.SanctionsCountryScreeningResult, data.KeyFinancial, data.CompanyAddress, data.PrimaryContact,
data.DataOwnerDepartment, data.UpdatedAt, data.BasicCompanyInformation,
})
}
// 生成Excel文件
content, err := utils.ToExcelByType(titleList, dataList, "slice", "")
if err != nil {
service.Error(c, err)
return
}
// 返回Excel文件
utils.ResponseXls(c, content, "供应商库")
return
}