作者 陈爱青

[add] 成本结构化中台接口

... ... @@ -236,6 +236,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
... ...
... ... @@ -44,6 +44,10 @@ var SMSCODE_ALL_POWER = "999512"
var EnableBlockChain = true
// 天联共创 成本结构化
var COST_STRUCTURED = "http://cost-structured-dev.fjmaimaimai.com"
//var COST_STRUCTURED = "http://localhost:8085"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
... ...
package domain
type BatchCreateCostManagemant struct {
UserId int64 `cname:"操作人id" json:"UserId" valid:"Required"`
// 公司id
CompanyId int64 `cname:"公司id" json:"companyId" valid:"Required"`
// 项目id
ProjectId int64 `cname:"项目id" json:"projectId,string"`
// 项目名称
ProjectName string `cname:"项目名称" json:"projectName" valid:"Required"`
// 项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌
Types int `cname:"项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌" json:"types" valid:"Required"`
//成本數組
CostManagemants []*CostManagemant `cname:"成本数组" json:"costManagemants" valid:"Required"`
}
// 成本管理
type CostManagemant struct {
// 项目编码
ProjectCode string `json:"projectCode,string"`
// 成本管理Id
CostManagemantId int64 `json:"costManagemantId,string"`
// 公式id
CompanyId int64 `json:"companyId,string"`
// 标杆值,字符串,如果纯数字的时候参与计算
Benchmark string `json:"benchmark"`
// 负责人数组
ChargePersons []string `json:"chargePersons"`
// 历史最高值,字符串,如果纯数字的时候参与计算
Highest string `json:"highest"`
// 细项名称
ItemName string `json:"itemName"`
// 级别
Level int `json:"level"`
// 父id
ParentId int64 `json:"parentId,string"`
// 现状值,字符串,如果纯数字的时候参与计算
Present string `json:"present"`
// 项目id
ProjectId int64 `json:"projectId,string"`
// 项目名称
ProjectName string `json:"projectName"`
// 进度计划比,字符串,如果纯数字的时候参与计算
SchedulePlanPercent string `json:"schedulePlanPercent"`
// 结构类型
//StructureType int `json:"structureType"`
// 目标值 字符串 为数字时 参与计算
Target string `json:"target"`
// 目标值期限 1 第一季度 2第二季度 3第三季度 4第四季度 5 年度
TargetPeriod int `json:"targetPeriod"`
// 顶级成本管理id
TopCostManagemantId int64 `json:"topCostManagemantId,string"`
// 项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌
Types int `json:"types"`
}
\ No newline at end of file
... ...
package cost_structured
import (
"fmt"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
)
//HttpLibCostStructured 成本结构化
type HttpLibCostStructured struct {
service_gateway.BaseServiceGateway
baseUrL string
}
func NewHttpLibCostStructured(operator domain.Operator) *HttpLibCostStructured {
return &HttpLibCostStructured{
BaseServiceGateway: service_gateway.BaseServiceGateway{
ConnectTimeout: 100 * time.Second,
ReadWriteTimeout: 100 * time.Second,
CompanyId: operator.CompanyId,
OrgId: operator.OrgId,
InOrgIds: operator.OrgIds,
UserId: operator.UserId,
UserBaseId: operator.UserBaseId,
},
baseUrL: constant.COST_STRUCTURED,
}
}
func (gateway HttpLibCostStructured) BaseUrl() string {
return gateway.baseUrL
}
//批量添加成本管理
func (gateway HttpLibCostStructured) BatchCreateCostManagemant(param BatchAddCostManagemantRequest) (*BatchAddCostManagemantResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/batch-update-cost-managemants")
method := "post"
var data BatchAddCostManagemantResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
type BatchAddCostManagemantRequest struct {
*domain.BatchCreateCostManagemant
}
type BatchAddCostManagemantResponse interface{}
func (gateway HttpLibCostStructured) ListCostManagemant(param ListCostManagemantRequest) (*ListCostManagemantResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/")
method := "post"
var data ListCostManagemantResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
type (
ListCostManagemantRequest struct {
// 页码
PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
// 页数
PageSize int `cname:"页数" json:"pageSize,omitempty"`
// 查询项目(结构)类型
Types int `cname:"查询项目(结构)类型" json:"types" valid:"Required"`
// 查询项目id
ProjectId int64 `cname:"查询项目id" json:"projectId"`
}
ListCostManagemantResponse struct {
Grid struct {
List []SearchProductItem `json:"list"`
Total int `json:"total"`
} `json:"grid"`
}
SearchProductItem struct {
ProductID int `json:"productId"`
ProductCode string `json:"productCode"`
ProductName string `json:"productName"`
ProductCategory string `json:"productCategory"`
Unit string `json:"unit"`
UnitWeight float64 `json:"unitWeight"`
}
)
/*设备*/
type BatchAddDeviceRequest struct {
List []*domain.ImportDeviceItem `json:"list"`
}
type BatchAddDeviceResponse []interface{}
/**生产记录**/
//SearchProduct 搜索员工产能统计
func (gateway HttpLibCostStructured) SearchEmployeeProductive(param SearchEmployeeProductiveRequest) (*SearchEmployeeProductiveResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/employee-productive/search")
method := "post"
var data SearchEmployeeProductiveResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
type (
SearchEmployeeProductiveRequest struct {
// 页码
//PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
// 页数
//PageSize int `cname:"页数" json:"pageSize,omitempty"`
// 车间名称
WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
// 生产线名称
LineName string `cname:"生产线名称" json:"lineName,omitempty"`
// 工段名称
SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 姓名
UserName string `cname:"姓名" json:"userName"`
// 员工类型 1:固定 2:派遣 3.临时
EmployeeType string `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
// 开始时间
BeginTime string `cname:"开始时间" json:"beginTime"`
// 结束时间
EndTime string `cname:"结束时间" json:"endTime"`
}
SearchEmployeeProductiveResponse struct {
Grid struct {
List []EmployeeProductiveItem `json:"list"`
Total int `json:"total"`
} `json:"grid"`
}
EmployeeProductiveItem struct {
EmployeeProductRecordID int `json:"employeeProductRecordId"`
ProductWorker struct {
UserID int `json:"userId"`
UserName string `json:"userName"`
Avatar string `json:"avatar"`
Phone string `json:"phone"`
EmployeeType int `json:"employeeType"`
} `json:"productWorker"`
WorkStationID string `json:"workStationId"`
WorkshopID int `json:"workshopId"`
WorkshopName string `json:"workshopName"`
LineID int `json:"lineId"`
LineName string `json:"lineName"`
SectionID int `json:"sectionId"`
SectionName string `json:"sectionName"`
WorkOn string `json:"workOn"`
PlanProductName string `json:"planProductName"`
BatchNumber string `json:"batchNumber"`
ParticipateType int `json:"participateType"`
ProductWeigh float64 `json:"productWeigh"`
SecondLevelWeigh float64 `json:"secondLevelWeigh"`
CreatedAt string `json:"createdAt"`
OrgName string `json:"orgName"`
AuthFlag bool `json:"authFlag"`
QualificationRate int `json:"qualificationRate"`
}
)
//SearchProduct 搜索员工产能统计
func (gateway HttpLibCostStructured) SearchWorkshopProductive(param SearchWorkshopProductiveRequest) (*SearchWorkshopProductiveResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/workshop-productive/search")
method := "post"
var data SearchWorkshopProductiveResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
type (
SearchWorkshopProductiveRequest struct {
// 品名
PlanProductName string `cname:"品名" json:"planProductName,omitempty"`
// 工段名称
SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 开始时间
BeginTime string `cname:"开始时间" json:"beginTime"`
// 结束时间
EndTime string `cname:"结束时间" json:"endTime"`
}
SearchWorkshopProductiveResponse struct {
Grid struct {
List []WorkshopProductiveItem `json:"list"`
Total int `json:"total"`
} `json:"grid"`
}
WorkshopProductiveItem struct {
EmployeeProductRecordID int `json:"employeeProductRecordId"`
ProductWorker struct {
UserID int `json:"userId"`
UserName string `json:"userName"`
Avatar string `json:"avatar"`
Phone string `json:"phone"`
EmployeeType int `json:"employeeType"`
} `json:"productWorker"`
WorkStationID string `json:"workStationId"`
WorkshopID int `json:"workshopId"`
WorkshopName string `json:"workshopName"`
LineID int `json:"lineId"`
LineName string `json:"lineName"`
SectionID int `json:"sectionId"`
SectionName string `json:"sectionName"`
WorkOn string `json:"workOn"`
PlanProductName string `json:"planProductName"`
BatchNumber string `json:"batchNumber"`
//ParticipateType int `json:"participateType"`
// 投入量
DevotedProductWeigh float64 `json:"devotedProductWeigh"`
// 产能
ProductWeigh float64 `json:"productWeigh"`
// 二级品产能
SecondLevelWeigh float64 `json:"secondLevelWeigh"`
CreatedAt string `json:"createdAt"`
OrgName string `json:"orgName"`
AuthFlag bool `json:"authFlag"`
QualificationRate int `json:"qualificationRate"`
}
)
/*** 考勤记录 ***/
//SearchEmployeeAttendanceStatics 搜索员工工时统计
func (gateway HttpLibCostStructured) SearchEmployeeAttendanceStatics(param SearchEmployeeAttendanceStaticsRequest) (*SearchEmployeeAttendanceStaticsResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/employee-attendance-statics/search")
method := "post"
var data SearchEmployeeAttendanceStaticsResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
type (
SearchEmployeeAttendanceStaticsRequest struct {
// 车间名称
WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
// 生产线名称
LineName string `cname:"生产线名称" json:"lineName,omitempty"`
// 工段名称
SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 姓名
UserName string `cname:"姓名" json:"userName,omitempty"`
// 考勤状态 1.未审核 2:已审核 4.自动审核
AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 4.自动审核" json:"attendanceStatus,omitempty"`
// 开始时间
BeginTime string `cname:"开始时间" json:"beginTime"`
// 结束时间
EndTime string `cname:"结束时间" json:"endTime"`
}
SearchEmployeeAttendanceStaticsResponse struct {
Grid struct {
List []SearchEmployeeAttendanceStaticsItem `json:"list"`
Total int `json:"total"`
} `json:"grid"`
}
SearchEmployeeAttendanceStaticsItem struct {
ProductAttendanceID int `json:"productAttendanceId"`
SignDate string `json:"signDate"`
WorkStationID string `json:"workStationId"`
WorkshopID int `json:"workshopId"`
WorkshopName string `json:"workshopName"`
LineID int `json:"lineId"`
LineName string `json:"lineName"`
SectionID int `json:"sectionId"`
SectionName string `json:"sectionName"`
ProductWorker struct {
UserID int `json:"userId"`
UserName string `json:"userName"`
EmployeeType int `json:"employeeType"`
Avatar string `json:"avatar"`
Phone string `json:"phone"`
} `json:"productWorker"`
AttendanceType int `json:"attendanceType"`
AttendanceStatus int `json:"attendanceStatus"`
AttendanceTypeDescription string `json:"attendanceTypeDescription"`
EmployeeTypeDescription string `json:"employeeTypeDescription"`
AttendanceStatusDescription string `json:"attendanceStatusDescription"`
WorkTime float64 `json:"workTime"`
OrgName string `json:"orgName"`
AuthFlag bool `json:"authFlag"`
}
)
//SearchEmployeeAttendanceStatics 搜索员工工时统计
func (gateway HttpLibCostStructured) SearchWorkshopWorkTimeStatics(param SearchWorkshopWorkTimeStaticsRequest) (*SearchWorkshopWorkTimeStaticsResponse, error) {
url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/workshop-attendance-statics/search")
method := "post"
var data SearchWorkshopWorkTimeStaticsResponse
err := gateway.FastDoRequest(url, method, param, &data)
return &data, err
}
type (
SearchWorkshopWorkTimeStaticsRequest struct {
// 车间名称
WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
// 生产线名称
LineName string `cname:"生产线名称" json:"lineName,omitempty"`
// 开始时间
BeginTime string `cname:"开始时间" json:"beginTime"`
// 结束时间
EndTime string `cname:"结束时间" json:"endTime"`
}
SearchWorkshopWorkTimeStaticsResponse struct {
Grid struct {
List []SearchWorkshopWorkTimeStaticsItem `json:"list"`
Total int `json:"total"`
} `json:"grid"`
}
SearchWorkshopWorkTimeStaticsItem struct {
WorkshopWorkTimeRecordID int `json:"workshopWorkTimeRecordId"`
WorkStationID string `json:"workStationId"`
WorkshopID int `json:"workshopId"`
WorkshopName string `json:"workshopName"`
LineID int `json:"lineId"`
LineName string `json:"lineName"`
SectionID int `json:"sectionId"`
SectionName string `json:"sectionName"`
EftWorkTime float64 `json:"eftWorkTime"`
EdWorkTime int `json:"edWorkTime"`
EptWorkTime int `json:"eptWorkTime"`
RecordDate string `json:"recordDate"`
OrgName string `json:"orgName"`
AuthFlag bool `json:"authFlag"`
}
)
... ...
... ... @@ -4,6 +4,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"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/allied_creation_user"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
"net/http"
"os"
"strconv"
... ... @@ -67,6 +68,7 @@ func init() {
web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.CheckAccessToken())
web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/manufacture", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{})))
web.InsertFilter("/v1/cost/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/cost", cost_structured.NewHttpLibCostStructured(domain.Operator{})))
}
func AllowCors() func(ctx *context.Context) {
... ...