作者 yangfu

feat : 成本结构化 - 导出异常记录

  1 +package query
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
  6 +)
  7 +
  8 +type CostDailyFillingAbnormalLogQuery struct {
  9 + *cost_structured.SearchDailyFillingAbnormalLogRequest
  10 + //操作人
  11 + Operator domain.Operator `json:"-"`
  12 + SelectedField []string `json:"selectedField"`
  13 +}
@@ -3,6 +3,7 @@ package service @@ -3,6 +3,7 @@ package service
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
6 7
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
@@ -137,3 +138,15 @@ func (srv ExcelDataService) ExportWorkshopAttendanceStatics(cmd *query.Manufactu @@ -137,3 +138,15 @@ func (srv ExcelDataService) ExportWorkshopAttendanceStatics(cmd *query.Manufactu
137 } 138 }
138 return ExportWorkshopAttendanceStaticsData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil 139 return ExportWorkshopAttendanceStaticsData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
139 } 140 }
  141 +
  142 +// ExportDailyFillingAbnormalLog 导出每日 填报异常日志记录
  143 +func (srv ExcelDataService) ExportDailyFillingAbnormalLog(cmd *query.CostDailyFillingAbnormalLogQuery) (ExportDailyFillingAbnormalLog, error) {
  144 + creationUserGateway := cost_structured.NewHttpLibCostStructured(cmd.Operator)
  145 + cmd.PageNumber = 1
  146 + cmd.PageSize = 10000
  147 + result, err := creationUserGateway.SearchDailyFillingAbnormalLog(*cmd.SearchDailyFillingAbnormalLogRequest)
  148 + if err != nil {
  149 + return ExportDailyFillingAbnormalLog{}, fmt.Errorf("获取每日填报异常日志记录数据失败:%w", err)
  150 + }
  151 + return ExportDailyFillingAbnormalLog{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
  152 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/utils/excel"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
  6 +)
  7 +
  8 +//ExportDailyFillingAbnormalLog 导出每日 填报异常日志记录
  9 +type ExportDailyFillingAbnormalLog struct {
  10 + SourceData []cost_structured.DailyFillingAbnormalLogItem
  11 + SelectedField []string
  12 +}
  13 +
  14 +var _ excel.ExcelMaker = (*ExportWorkshopAttendanceStaticsData)(nil)
  15 +
  16 +func (data ExportDailyFillingAbnormalLog) AllFields() []DataFieldOptions {
  17 + return []DataFieldOptions{
  18 + {EnName: "abnormalTypeDescription", CnName: "异常类型"},
  19 + {EnName: "projectTypeDescription", CnName: "项目分类"},
  20 + {EnName: "projectName", CnName: "项目名称"},
  21 + {EnName: "itemName", CnName: "细项名称"},
  22 + {EnName: "userName", CnName: "负责人"},
  23 + {EnName: "actualValue", CnName: "现状值"},
  24 + {EnName: "targetValue", CnName: "目标值"},
  25 + {EnName: "remark", CnName: "填报说明"},
  26 + {EnName: "createdAt", CnName: "异常日期"},
  27 + }
  28 +}
  29 +
  30 +func (data ExportDailyFillingAbnormalLog) DataFieldList() []excel.DataField {
  31 + fields := []excel.DataField{}
  32 + allFields := data.AllFields()
  33 + for _, value2 := range allFields {
  34 + if len(data.SelectedField) == 0 || value2.IsDefault {
  35 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  36 + continue
  37 + }
  38 + for _, value3 := range data.SelectedField {
  39 + if value2.EnName == value3 {
  40 + fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
  41 + }
  42 + }
  43 + }
  44 + return fields
  45 +}
  46 +
  47 +func (data ExportDailyFillingAbnormalLog) CellValue(index int, enName string) (value interface{}) {
  48 + if index > data.DataListLen() {
  49 + return ""
  50 + }
  51 + switch enName {
  52 + case "abnormalTypeDescription":
  53 + return data.SourceData[index].AbnormalTypeDescription
  54 + case "projectTypeDescription":
  55 + return data.SourceData[index].ProjectTypeDescription
  56 + case "projectName":
  57 + return data.SourceData[index].ProjectName
  58 + case "itemName":
  59 + return data.SourceData[index].ItemName
  60 + case "userName":
  61 + return data.SourceData[index].UserName
  62 + case "actualValue":
  63 + return data.SourceData[index].ActualValue
  64 + case "targetValue":
  65 + return data.SourceData[index].TargetValue
  66 + case "remark":
  67 + return data.SourceData[index].Remark
  68 + case "createdAt":
  69 + return data.SourceData[index].CreatedAt
  70 + }
  71 + return nil
  72 +}
  73 +
  74 +func (data ExportDailyFillingAbnormalLog) DataListLen() int {
  75 + return len(data.SourceData)
  76 +}
  77 +
  78 +func (data ExportDailyFillingAbnormalLog) TableTitle() []string {
  79 + return nil
  80 +}
@@ -91,6 +91,9 @@ const ( @@ -91,6 +91,9 @@ const (
91 ExportManufactureEmployeeAttendanceStatics = "ExportManufactureEmployeeAttendanceStatics" 91 ExportManufactureEmployeeAttendanceStatics = "ExportManufactureEmployeeAttendanceStatics"
92 // 车间工时 92 // 车间工时
93 ExportManufactureWorkshopAttendanceStatics = "ExportManufactureWorkshopAttendanceStatics" 93 ExportManufactureWorkshopAttendanceStatics = "ExportManufactureWorkshopAttendanceStatics"
  94 +
  95 + // 成本结构化 - 每日填报异常日志
  96 + ExportCostStructuredDailyFillingAbnormalLog = "ExportCostStructuredDailyFillingAbnormalLog"
94 ) 97 )
95 98
96 const ( 99 const (
  1 +package cost_structured
  2 +
  3 +import "fmt"
  4 +
  5 +type (
  6 + SearchDailyFillingAbnormalLogRequest struct {
  7 + //页码
  8 + PageNumber int64 `json:"pageNumber" valid:"Required"`
  9 + //每页显示数目
  10 + PageSize int64 `json:"pageSize" valid:"Required"`
  11 + // 1:填报异常 2.结果异常
  12 + AbnormalType int `cname:"1:填报异常 2.结果异常" json:"abnormalType"`
  13 + // 项目分类 风险|成本
  14 + ProjectType int `cname:"项目分类 风险|成本" json:"projectType,omitempty"`
  15 + // 项目id
  16 + ProjectId int64 `cname:"项目id" json:"projectId,string,omitempty"`
  17 + // 细项名称
  18 + ItemName string `cname:"细项名称" json:"itemName,omitempty"`
  19 + // 负责人名称
  20 + PrincipalName string `cname:"负责人名称" json:"principalName,omitempty"`
  21 + //开始时间
  22 + BeginTime string `json:"beginTime,omitempty"`
  23 + //结束时间
  24 + EndTime string `json:"endTime,omitempty"`
  25 + }
  26 + SearchDailyFillingAbnormalLogResponse struct {
  27 + Grid struct {
  28 + List []DailyFillingAbnormalLogItem `json:"list"`
  29 + Total int `json:"total"`
  30 + } `json:"grid"`
  31 + }
  32 + DailyFillingAbnormalLogItem struct {
  33 + DailyFillingAbnormalLogID int `json:"dailyFillingAbnormalLogId"`
  34 + AbnormalType int `json:"abnormalType"`
  35 + ProjectType int `json:"projectType"`
  36 + ProjectID int64 `json:"projectId"`
  37 + CostManagementID int64 `json:"costManagementId"`
  38 + UserName string `json:"userName"`
  39 + ProjectName string `json:"projectName"`
  40 + ItemName string `json:"itemName"`
  41 + TargetValue string `json:"targetValue"`
  42 + ActualValue string `json:"actualValue"`
  43 + Remark string `json:"remark"`
  44 + CreatedAt string `json:"createdAt"`
  45 + AbnormalTypeDescription string `json:"abnormalTypeDescription"`
  46 + ProjectTypeDescription string `json:"projectTypeDescription"`
  47 + }
  48 +)
  49 +
  50 +//SearchEmployeeAttendanceStatics 搜索员工工时统计
  51 +func (gateway HttpLibCostStructured) SearchDailyFillingAbnormalLog(param SearchDailyFillingAbnormalLogRequest) (*SearchDailyFillingAbnormalLogResponse, error) {
  52 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/daily-filling-abnormal-logs/search")
  53 + method := "post"
  54 + var data SearchDailyFillingAbnormalLogResponse
  55 + err := gateway.FastDoRequest(url, method, param, &data)
  56 + return &data, err
  57 +}
@@ -194,7 +194,7 @@ func defaultImport(controller *ExcelDataController) { @@ -194,7 +194,7 @@ func defaultImport(controller *ExcelDataController) {
194 fileName string 194 fileName string
195 ) 195 )
196 excelService := service.NewExcelDataService(nil) 196 excelService := service.NewExcelDataService(nil)
197 - r, ext,fileName, err = controller.GetFileWithExt() 197 + r, ext, fileName, err = controller.GetFileWithExt()
198 if err != nil { 198 if err != nil {
199 controller.Response(nil, err) 199 controller.Response(nil, err)
200 return 200 return
@@ -217,7 +217,7 @@ func defaultImport(controller *ExcelDataController) { @@ -217,7 +217,7 @@ func defaultImport(controller *ExcelDataController) {
217 case domain.ImportDevices: 217 case domain.ImportDevices:
218 data, err = excelService.ImportDevice(cmd) 218 data, err = excelService.ImportDevice(cmd)
219 case domain.ImportCosts: 219 case domain.ImportCosts:
220 - data,err = excelService.ImportCost(cmd) 220 + data, err = excelService.ImportCost(cmd)
221 default: 221 default:
222 err = fmt.Errorf("导入不存在 Code:%v", cmd.Code) 222 err = fmt.Errorf("导入不存在 Code:%v", cmd.Code)
223 } 223 }
@@ -300,6 +300,13 @@ func fileExport(controller *ExcelDataController, code string) { @@ -300,6 +300,13 @@ func fileExport(controller *ExcelDataController, code string) {
300 companyUserListQuery.Operator = exportDataCommand.Operator 300 companyUserListQuery.Operator = exportDataCommand.Operator
301 data, err = excelService.ExportWorkshopAttendanceStatics(companyUserListQuery) 301 data, err = excelService.ExportWorkshopAttendanceStatics(companyUserListQuery)
302 filename = "导出车间工时汇总" 302 filename = "导出车间工时汇总"
  303 +
  304 + case domain.ExportCostStructuredDailyFillingAbnormalLog:
  305 + query := &query.CostDailyFillingAbnormalLogQuery{}
  306 + controllers.Must(exportDataCommand.UnmarshalQuery(query))
  307 + query.Operator = exportDataCommand.Operator
  308 + data, err = excelService.ExportDailyFillingAbnormalLog(query)
  309 + filename = "异常记录"
303 default: 310 default:
304 err = fmt.Errorf("export type :%v not exists", exportDataCommand.Code) 311 err = fmt.Errorf("export type :%v not exists", exportDataCommand.Code)
305 } 312 }
@@ -355,6 +362,10 @@ func (controller *ExcelDataController) ExportManufactureWorkshopAttendanceStatic @@ -355,6 +362,10 @@ func (controller *ExcelDataController) ExportManufactureWorkshopAttendanceStatic
355 fileExport(controller, domain.ExportManufactureWorkshopAttendanceStatics) 362 fileExport(controller, domain.ExportManufactureWorkshopAttendanceStatics)
356 } 363 }
357 364
  365 +func (controller *ExcelDataController) ExportCostStructuredDailyFillingAbnormalLog() {
  366 + fileExport(controller, domain.ExportCostStructuredDailyFillingAbnormalLog)
  367 +}
  368 +
358 //GetExcelDataFields 获取导出excel数据的可选字段 369 //GetExcelDataFields 获取导出excel数据的可选字段
359 func (controller *ExcelDataController) GetExcelDataFields() { 370 func (controller *ExcelDataController) GetExcelDataFields() {
360 code := controller.GetString(":code") 371 code := controller.GetString(":code")
@@ -15,6 +15,8 @@ func init() { @@ -15,6 +15,8 @@ func init() {
15 web.Router("/v1/web/excel/export/manufacture-employee-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureEmployeeAttendanceStatics") 15 web.Router("/v1/web/excel/export/manufacture-employee-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureEmployeeAttendanceStatics")
16 web.Router("/v1/web/excel/export/manufacture-workshop-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureWorkshopAttendanceStatics") 16 web.Router("/v1/web/excel/export/manufacture-workshop-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureWorkshopAttendanceStatics")
17 17
  18 + web.Router("/v1/web/excel/export/cost-structured-daily-filling-abnormal-log", &web_client.ExcelDataController{}, "Post:ExportCostStructuredDailyFillingAbnormalLog")
  19 +
18 web.Router("/v1/web/excel/import/dividends-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsOrder") 20 web.Router("/v1/web/excel/import/dividends-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsOrder")
19 web.Router("/v1/web/excel/import/dividends-returned-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsReturnedOrder") 21 web.Router("/v1/web/excel/import/dividends-returned-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsReturnedOrder")
20 22