作者 yangfu

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

package query
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
)
type CostDailyFillingAbnormalLogQuery struct {
*cost_structured.SearchDailyFillingAbnormalLogRequest
//操作人
Operator domain.Operator `json:"-"`
SelectedField []string `json:"selectedField"`
}
... ...
... ... @@ -3,6 +3,7 @@ package service
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
... ... @@ -137,3 +138,15 @@ func (srv ExcelDataService) ExportWorkshopAttendanceStatics(cmd *query.Manufactu
}
return ExportWorkshopAttendanceStaticsData{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
}
// ExportDailyFillingAbnormalLog 导出每日 填报异常日志记录
func (srv ExcelDataService) ExportDailyFillingAbnormalLog(cmd *query.CostDailyFillingAbnormalLogQuery) (ExportDailyFillingAbnormalLog, error) {
creationUserGateway := cost_structured.NewHttpLibCostStructured(cmd.Operator)
cmd.PageNumber = 1
cmd.PageSize = 10000
result, err := creationUserGateway.SearchDailyFillingAbnormalLog(*cmd.SearchDailyFillingAbnormalLogRequest)
if err != nil {
return ExportDailyFillingAbnormalLog{}, fmt.Errorf("获取每日填报异常日志记录数据失败:%w", err)
}
return ExportDailyFillingAbnormalLog{SourceData: result.Grid.List, SelectedField: cmd.SelectedField}, nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/utils/excel"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
)
//ExportDailyFillingAbnormalLog 导出每日 填报异常日志记录
type ExportDailyFillingAbnormalLog struct {
SourceData []cost_structured.DailyFillingAbnormalLogItem
SelectedField []string
}
var _ excel.ExcelMaker = (*ExportWorkshopAttendanceStaticsData)(nil)
func (data ExportDailyFillingAbnormalLog) AllFields() []DataFieldOptions {
return []DataFieldOptions{
{EnName: "abnormalTypeDescription", CnName: "异常类型"},
{EnName: "projectTypeDescription", CnName: "项目分类"},
{EnName: "projectName", CnName: "项目名称"},
{EnName: "itemName", CnName: "细项名称"},
{EnName: "userName", CnName: "负责人"},
{EnName: "actualValue", CnName: "现状值"},
{EnName: "targetValue", CnName: "目标值"},
{EnName: "remark", CnName: "填报说明"},
{EnName: "createdAt", CnName: "异常日期"},
}
}
func (data ExportDailyFillingAbnormalLog) DataFieldList() []excel.DataField {
fields := []excel.DataField{}
allFields := data.AllFields()
for _, value2 := range allFields {
if len(data.SelectedField) == 0 || value2.IsDefault {
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
continue
}
for _, value3 := range data.SelectedField {
if value2.EnName == value3 {
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
}
}
}
return fields
}
func (data ExportDailyFillingAbnormalLog) CellValue(index int, enName string) (value interface{}) {
if index > data.DataListLen() {
return ""
}
switch enName {
case "abnormalTypeDescription":
return data.SourceData[index].AbnormalTypeDescription
case "projectTypeDescription":
return data.SourceData[index].ProjectTypeDescription
case "projectName":
return data.SourceData[index].ProjectName
case "itemName":
return data.SourceData[index].ItemName
case "userName":
return data.SourceData[index].UserName
case "actualValue":
return data.SourceData[index].ActualValue
case "targetValue":
return data.SourceData[index].TargetValue
case "remark":
return data.SourceData[index].Remark
case "createdAt":
return data.SourceData[index].CreatedAt
}
return nil
}
func (data ExportDailyFillingAbnormalLog) DataListLen() int {
return len(data.SourceData)
}
func (data ExportDailyFillingAbnormalLog) TableTitle() []string {
return nil
}
... ...
... ... @@ -91,6 +91,9 @@ const (
ExportManufactureEmployeeAttendanceStatics = "ExportManufactureEmployeeAttendanceStatics"
// 车间工时
ExportManufactureWorkshopAttendanceStatics = "ExportManufactureWorkshopAttendanceStatics"
// 成本结构化 - 每日填报异常日志
ExportCostStructuredDailyFillingAbnormalLog = "ExportCostStructuredDailyFillingAbnormalLog"
)
const (
... ...
package cost_structured
import "fmt"
type (
SearchDailyFillingAbnormalLogRequest struct {
//页码
PageNumber int64 `json:"pageNumber" valid:"Required"`
//每页显示数目
PageSize int64 `json:"pageSize" valid:"Required"`
// 1:填报异常 2.结果异常
AbnormalType int `cname:"1:填报异常 2.结果异常" json:"abnormalType"`
// 项目分类 风险|成本
ProjectType int `cname:"项目分类 风险|成本" json:"projectType,omitempty"`
// 项目id
ProjectId int64 `cname:"项目id" json:"projectId,string,omitempty"`
// 细项名称
ItemName string `cname:"细项名称" json:"itemName,omitempty"`
// 负责人名称
PrincipalName string `cname:"负责人名称" json:"principalName,omitempty"`
//开始时间
BeginTime string `json:"beginTime,omitempty"`
//结束时间
EndTime string `json:"endTime,omitempty"`
}
SearchDailyFillingAbnormalLogResponse struct {
Grid struct {
List []DailyFillingAbnormalLogItem `json:"list"`
Total int `json:"total"`
} `json:"grid"`
}
DailyFillingAbnormalLogItem struct {
DailyFillingAbnormalLogID int `json:"dailyFillingAbnormalLogId"`
AbnormalType int `json:"abnormalType"`
ProjectType int `json:"projectType"`
ProjectID int64 `json:"projectId"`
CostManagementID int64 `json:"costManagementId"`
UserName string `json:"userName"`
ProjectName string `json:"projectName"`
ItemName string `json:"itemName"`
TargetValue string `json:"targetValue"`
ActualValue string `json:"actualValue"`
Remark string `json:"remark"`
CreatedAt string `json:"createdAt"`
AbnormalTypeDescription string `json:"abnormalTypeDescription"`
ProjectTypeDescription string `json:"projectTypeDescription"`
}
)
//SearchEmployeeAttendanceStatics 搜索员工工时统计
func (gateway HttpLibCostStructured) SearchDailyFillingAbnormalLog(param SearchDailyFillingAbnormalLogRequest) (*SearchDailyFillingAbnormalLogResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/daily-filling-abnormal-logs/search")
method := "post"
var data SearchDailyFillingAbnormalLogResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
... ...
... ... @@ -187,14 +187,14 @@ func (controller *ExcelDataController) FileImport() {
func defaultImport(controller *ExcelDataController) {
var (
data interface{}
err error
r io.Reader
ext string
data interface{}
err error
r io.Reader
ext string
fileName string
)
excelService := service.NewExcelDataService(nil)
r, ext,fileName, err = controller.GetFileWithExt()
r, ext, fileName, err = controller.GetFileWithExt()
if err != nil {
controller.Response(nil, err)
return
... ... @@ -217,7 +217,7 @@ func defaultImport(controller *ExcelDataController) {
case domain.ImportDevices:
data, err = excelService.ImportDevice(cmd)
case domain.ImportCosts:
data,err = excelService.ImportCost(cmd)
data, err = excelService.ImportCost(cmd)
default:
err = fmt.Errorf("导入不存在 Code:%v", cmd.Code)
}
... ... @@ -300,6 +300,13 @@ func fileExport(controller *ExcelDataController, code string) {
companyUserListQuery.Operator = exportDataCommand.Operator
data, err = excelService.ExportWorkshopAttendanceStatics(companyUserListQuery)
filename = "导出车间工时汇总"
case domain.ExportCostStructuredDailyFillingAbnormalLog:
query := &query.CostDailyFillingAbnormalLogQuery{}
controllers.Must(exportDataCommand.UnmarshalQuery(query))
query.Operator = exportDataCommand.Operator
data, err = excelService.ExportDailyFillingAbnormalLog(query)
filename = "异常记录"
default:
err = fmt.Errorf("export type :%v not exists", exportDataCommand.Code)
}
... ... @@ -355,6 +362,10 @@ func (controller *ExcelDataController) ExportManufactureWorkshopAttendanceStatic
fileExport(controller, domain.ExportManufactureWorkshopAttendanceStatics)
}
func (controller *ExcelDataController) ExportCostStructuredDailyFillingAbnormalLog() {
fileExport(controller, domain.ExportCostStructuredDailyFillingAbnormalLog)
}
//GetExcelDataFields 获取导出excel数据的可选字段
func (controller *ExcelDataController) GetExcelDataFields() {
code := controller.GetString(":code")
... ...
... ... @@ -15,6 +15,8 @@ func init() {
web.Router("/v1/web/excel/export/manufacture-employee-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureEmployeeAttendanceStatics")
web.Router("/v1/web/excel/export/manufacture-workshop-attendance-statics", &web_client.ExcelDataController{}, "Post:ExportManufactureWorkshopAttendanceStatics")
web.Router("/v1/web/excel/export/cost-structured-daily-filling-abnormal-log", &web_client.ExcelDataController{}, "Post:ExportCostStructuredDailyFillingAbnormalLog")
web.Router("/v1/web/excel/import/dividends-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsOrder")
web.Router("/v1/web/excel/import/dividends-returned-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsReturnedOrder")
... ...