作者 陈爱青

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

@@ -236,6 +236,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb @@ -236,6 +236,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
236 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= 236 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
237 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= 237 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
238 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 238 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
  239 +github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
239 github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= 240 github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
240 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= 241 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
241 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= 242 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
@@ -44,6 +44,10 @@ var SMSCODE_ALL_POWER = "999512" @@ -44,6 +44,10 @@ var SMSCODE_ALL_POWER = "999512"
44 44
45 var EnableBlockChain = true 45 var EnableBlockChain = true
46 46
  47 +// 天联共创 成本结构化
  48 +var COST_STRUCTURED = "http://cost-structured-dev.fjmaimaimai.com"
  49 +//var COST_STRUCTURED = "http://localhost:8085"
  50 +
47 func init() { 51 func init() {
48 if os.Getenv("LOG_LEVEL") != "" { 52 if os.Getenv("LOG_LEVEL") != "" {
49 LOG_LEVEL = os.Getenv("LOG_LEVEL") 53 LOG_LEVEL = os.Getenv("LOG_LEVEL")
  1 +package domain
  2 +
  3 +type BatchCreateCostManagemant struct {
  4 +
  5 + UserId int64 `cname:"操作人id" json:"UserId" valid:"Required"`
  6 + // 公司id
  7 + CompanyId int64 `cname:"公司id" json:"companyId" valid:"Required"`
  8 + // 项目id
  9 + ProjectId int64 `cname:"项目id" json:"projectId,string"`
  10 + // 项目名称
  11 + ProjectName string `cname:"项目名称" json:"projectName" valid:"Required"`
  12 + // 项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌
  13 + Types int `cname:"项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌" json:"types" valid:"Required"`
  14 + //成本數組
  15 + CostManagemants []*CostManagemant `cname:"成本数组" json:"costManagemants" valid:"Required"`
  16 +}
  17 +
  18 +// 成本管理
  19 +type CostManagemant struct {
  20 + // 项目编码
  21 + ProjectCode string `json:"projectCode,string"`
  22 + // 成本管理Id
  23 + CostManagemantId int64 `json:"costManagemantId,string"`
  24 + // 公式id
  25 + CompanyId int64 `json:"companyId,string"`
  26 + // 标杆值,字符串,如果纯数字的时候参与计算
  27 + Benchmark string `json:"benchmark"`
  28 + // 负责人数组
  29 + ChargePersons []string `json:"chargePersons"`
  30 + // 历史最高值,字符串,如果纯数字的时候参与计算
  31 + Highest string `json:"highest"`
  32 + // 细项名称
  33 + ItemName string `json:"itemName"`
  34 + // 级别
  35 + Level int `json:"level"`
  36 + // 父id
  37 + ParentId int64 `json:"parentId,string"`
  38 + // 现状值,字符串,如果纯数字的时候参与计算
  39 + Present string `json:"present"`
  40 +
  41 + // 项目id
  42 + ProjectId int64 `json:"projectId,string"`
  43 + // 项目名称
  44 + ProjectName string `json:"projectName"`
  45 + // 进度计划比,字符串,如果纯数字的时候参与计算
  46 + SchedulePlanPercent string `json:"schedulePlanPercent"`
  47 + // 结构类型
  48 + //StructureType int `json:"structureType"`
  49 + // 目标值 字符串 为数字时 参与计算
  50 + Target string `json:"target"`
  51 + // 目标值期限 1 第一季度 2第二季度 3第三季度 4第四季度 5 年度
  52 + TargetPeriod int `json:"targetPeriod"`
  53 + // 顶级成本管理id
  54 + TopCostManagemantId int64 `json:"topCostManagemantId,string"`
  55 + // 项目分类: 1风险 2成本 3品质 4交期 5服务 6客户关系 7品牌
  56 + Types int `json:"types"`
  57 +
  58 +
  59 +}
  1 +package cost_structured
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
  10 +)
  11 +
  12 +//HttpLibCostStructured 成本结构化
  13 +type HttpLibCostStructured struct {
  14 + service_gateway.BaseServiceGateway
  15 + baseUrL string
  16 +}
  17 +
  18 +func NewHttpLibCostStructured(operator domain.Operator) *HttpLibCostStructured {
  19 + return &HttpLibCostStructured{
  20 + BaseServiceGateway: service_gateway.BaseServiceGateway{
  21 + ConnectTimeout: 100 * time.Second,
  22 + ReadWriteTimeout: 100 * time.Second,
  23 + CompanyId: operator.CompanyId,
  24 + OrgId: operator.OrgId,
  25 + InOrgIds: operator.OrgIds,
  26 + UserId: operator.UserId,
  27 + UserBaseId: operator.UserBaseId,
  28 + },
  29 + baseUrL: constant.COST_STRUCTURED,
  30 + }
  31 +
  32 +}
  33 +
  34 +func (gateway HttpLibCostStructured) BaseUrl() string {
  35 + return gateway.baseUrL
  36 +}
  37 +
  38 +//批量添加成本管理
  39 +func (gateway HttpLibCostStructured) BatchCreateCostManagemant(param BatchAddCostManagemantRequest) (*BatchAddCostManagemantResponse, error) {
  40 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/batch-update-cost-managemants")
  41 + method := "post"
  42 + var data BatchAddCostManagemantResponse
  43 + err := gateway.FastDoRequest(url, method, param, &data)
  44 + return &data, err
  45 +}
  46 +type BatchAddCostManagemantRequest struct {
  47 + *domain.BatchCreateCostManagemant
  48 +}
  49 +type BatchAddCostManagemantResponse interface{}
  50 +
  51 +func (gateway HttpLibCostStructured) ListCostManagemant(param ListCostManagemantRequest) (*ListCostManagemantResponse, error) {
  52 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/cost-managemants/")
  53 + method := "post"
  54 + var data ListCostManagemantResponse
  55 + err := gateway.FastDoRequest(url, method, param, &data)
  56 + return &data, err
  57 +}
  58 +
  59 +
  60 +
  61 +
  62 +
  63 +
  64 +
  65 +type (
  66 + ListCostManagemantRequest struct {
  67 + // 页码
  68 + PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
  69 + // 页数
  70 + PageSize int `cname:"页数" json:"pageSize,omitempty"`
  71 + // 查询项目(结构)类型
  72 + Types int `cname:"查询项目(结构)类型" json:"types" valid:"Required"`
  73 + // 查询项目id
  74 + ProjectId int64 `cname:"查询项目id" json:"projectId"`
  75 + }
  76 + ListCostManagemantResponse struct {
  77 + Grid struct {
  78 + List []SearchProductItem `json:"list"`
  79 + Total int `json:"total"`
  80 + } `json:"grid"`
  81 + }
  82 + SearchProductItem struct {
  83 + ProductID int `json:"productId"`
  84 + ProductCode string `json:"productCode"`
  85 + ProductName string `json:"productName"`
  86 + ProductCategory string `json:"productCategory"`
  87 + Unit string `json:"unit"`
  88 + UnitWeight float64 `json:"unitWeight"`
  89 + }
  90 +)
  91 +
  92 +
  93 +
  94 +
  95 +
  96 +
  97 +
  98 +/*设备*/
  99 +
  100 +
  101 +
  102 +type BatchAddDeviceRequest struct {
  103 + List []*domain.ImportDeviceItem `json:"list"`
  104 +}
  105 +type BatchAddDeviceResponse []interface{}
  106 +
  107 +/**生产记录**/
  108 +//SearchProduct 搜索员工产能统计
  109 +func (gateway HttpLibCostStructured) SearchEmployeeProductive(param SearchEmployeeProductiveRequest) (*SearchEmployeeProductiveResponse, error) {
  110 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/employee-productive/search")
  111 + method := "post"
  112 + var data SearchEmployeeProductiveResponse
  113 + err := gateway.FastDoRequest(url, method, param, &data)
  114 + return &data, err
  115 +}
  116 +
  117 +type (
  118 + SearchEmployeeProductiveRequest struct {
  119 + // 页码
  120 + //PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
  121 + // 页数
  122 + //PageSize int `cname:"页数" json:"pageSize,omitempty"`
  123 + // 车间名称
  124 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  125 + // 生产线名称
  126 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  127 + // 工段名称
  128 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  129 + // 姓名
  130 + UserName string `cname:"姓名" json:"userName"`
  131 + // 员工类型 1:固定 2:派遣 3.临时
  132 + EmployeeType string `cname:"员工类型 1:固定 2:派遣 3.临时" json:"employeeType"`
  133 + // 开始时间
  134 + BeginTime string `cname:"开始时间" json:"beginTime"`
  135 + // 结束时间
  136 + EndTime string `cname:"结束时间" json:"endTime"`
  137 + }
  138 + SearchEmployeeProductiveResponse struct {
  139 + Grid struct {
  140 + List []EmployeeProductiveItem `json:"list"`
  141 + Total int `json:"total"`
  142 + } `json:"grid"`
  143 + }
  144 + EmployeeProductiveItem struct {
  145 + EmployeeProductRecordID int `json:"employeeProductRecordId"`
  146 + ProductWorker struct {
  147 + UserID int `json:"userId"`
  148 + UserName string `json:"userName"`
  149 + Avatar string `json:"avatar"`
  150 + Phone string `json:"phone"`
  151 + EmployeeType int `json:"employeeType"`
  152 + } `json:"productWorker"`
  153 + WorkStationID string `json:"workStationId"`
  154 + WorkshopID int `json:"workshopId"`
  155 + WorkshopName string `json:"workshopName"`
  156 + LineID int `json:"lineId"`
  157 + LineName string `json:"lineName"`
  158 + SectionID int `json:"sectionId"`
  159 + SectionName string `json:"sectionName"`
  160 + WorkOn string `json:"workOn"`
  161 + PlanProductName string `json:"planProductName"`
  162 + BatchNumber string `json:"batchNumber"`
  163 + ParticipateType int `json:"participateType"`
  164 + ProductWeigh float64 `json:"productWeigh"`
  165 + SecondLevelWeigh float64 `json:"secondLevelWeigh"`
  166 + CreatedAt string `json:"createdAt"`
  167 + OrgName string `json:"orgName"`
  168 + AuthFlag bool `json:"authFlag"`
  169 + QualificationRate int `json:"qualificationRate"`
  170 + }
  171 +)
  172 +
  173 +//SearchProduct 搜索员工产能统计
  174 +func (gateway HttpLibCostStructured) SearchWorkshopProductive(param SearchWorkshopProductiveRequest) (*SearchWorkshopProductiveResponse, error) {
  175 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/product-records/workshop-productive/search")
  176 + method := "post"
  177 + var data SearchWorkshopProductiveResponse
  178 + err := gateway.FastDoRequest(url, method, param, &data)
  179 + return &data, err
  180 +}
  181 +
  182 +type (
  183 + SearchWorkshopProductiveRequest struct {
  184 + // 品名
  185 + PlanProductName string `cname:"品名" json:"planProductName,omitempty"`
  186 + // 工段名称
  187 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  188 + // 开始时间
  189 + BeginTime string `cname:"开始时间" json:"beginTime"`
  190 + // 结束时间
  191 + EndTime string `cname:"结束时间" json:"endTime"`
  192 + }
  193 + SearchWorkshopProductiveResponse struct {
  194 + Grid struct {
  195 + List []WorkshopProductiveItem `json:"list"`
  196 + Total int `json:"total"`
  197 + } `json:"grid"`
  198 + }
  199 + WorkshopProductiveItem struct {
  200 + EmployeeProductRecordID int `json:"employeeProductRecordId"`
  201 + ProductWorker struct {
  202 + UserID int `json:"userId"`
  203 + UserName string `json:"userName"`
  204 + Avatar string `json:"avatar"`
  205 + Phone string `json:"phone"`
  206 + EmployeeType int `json:"employeeType"`
  207 + } `json:"productWorker"`
  208 + WorkStationID string `json:"workStationId"`
  209 + WorkshopID int `json:"workshopId"`
  210 + WorkshopName string `json:"workshopName"`
  211 + LineID int `json:"lineId"`
  212 + LineName string `json:"lineName"`
  213 + SectionID int `json:"sectionId"`
  214 + SectionName string `json:"sectionName"`
  215 + WorkOn string `json:"workOn"`
  216 + PlanProductName string `json:"planProductName"`
  217 + BatchNumber string `json:"batchNumber"`
  218 + //ParticipateType int `json:"participateType"`
  219 + // 投入量
  220 + DevotedProductWeigh float64 `json:"devotedProductWeigh"`
  221 + // 产能
  222 + ProductWeigh float64 `json:"productWeigh"`
  223 + // 二级品产能
  224 + SecondLevelWeigh float64 `json:"secondLevelWeigh"`
  225 + CreatedAt string `json:"createdAt"`
  226 + OrgName string `json:"orgName"`
  227 + AuthFlag bool `json:"authFlag"`
  228 + QualificationRate int `json:"qualificationRate"`
  229 + }
  230 +)
  231 +
  232 +/*** 考勤记录 ***/
  233 +//SearchEmployeeAttendanceStatics 搜索员工工时统计
  234 +func (gateway HttpLibCostStructured) SearchEmployeeAttendanceStatics(param SearchEmployeeAttendanceStaticsRequest) (*SearchEmployeeAttendanceStaticsResponse, error) {
  235 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/employee-attendance-statics/search")
  236 + method := "post"
  237 + var data SearchEmployeeAttendanceStaticsResponse
  238 + err := gateway.FastDoRequest(url, method, param, &data)
  239 + return &data, err
  240 +}
  241 +
  242 +type (
  243 + SearchEmployeeAttendanceStaticsRequest struct {
  244 + // 车间名称
  245 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  246 + // 生产线名称
  247 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  248 + // 工段名称
  249 + SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
  250 + // 姓名
  251 + UserName string `cname:"姓名" json:"userName,omitempty"`
  252 + // 考勤状态 1.未审核 2:已审核 4.自动审核
  253 + AttendanceStatus int `cname:"考勤状态 1.未审核 2:已审核 4.自动审核" json:"attendanceStatus,omitempty"`
  254 + // 开始时间
  255 + BeginTime string `cname:"开始时间" json:"beginTime"`
  256 + // 结束时间
  257 + EndTime string `cname:"结束时间" json:"endTime"`
  258 + }
  259 + SearchEmployeeAttendanceStaticsResponse struct {
  260 + Grid struct {
  261 + List []SearchEmployeeAttendanceStaticsItem `json:"list"`
  262 + Total int `json:"total"`
  263 + } `json:"grid"`
  264 + }
  265 + SearchEmployeeAttendanceStaticsItem struct {
  266 + ProductAttendanceID int `json:"productAttendanceId"`
  267 + SignDate string `json:"signDate"`
  268 + WorkStationID string `json:"workStationId"`
  269 + WorkshopID int `json:"workshopId"`
  270 + WorkshopName string `json:"workshopName"`
  271 + LineID int `json:"lineId"`
  272 + LineName string `json:"lineName"`
  273 + SectionID int `json:"sectionId"`
  274 + SectionName string `json:"sectionName"`
  275 + ProductWorker struct {
  276 + UserID int `json:"userId"`
  277 + UserName string `json:"userName"`
  278 + EmployeeType int `json:"employeeType"`
  279 + Avatar string `json:"avatar"`
  280 + Phone string `json:"phone"`
  281 + } `json:"productWorker"`
  282 + AttendanceType int `json:"attendanceType"`
  283 + AttendanceStatus int `json:"attendanceStatus"`
  284 + AttendanceTypeDescription string `json:"attendanceTypeDescription"`
  285 + EmployeeTypeDescription string `json:"employeeTypeDescription"`
  286 + AttendanceStatusDescription string `json:"attendanceStatusDescription"`
  287 + WorkTime float64 `json:"workTime"`
  288 + OrgName string `json:"orgName"`
  289 + AuthFlag bool `json:"authFlag"`
  290 + }
  291 +)
  292 +
  293 +//SearchEmployeeAttendanceStatics 搜索员工工时统计
  294 +func (gateway HttpLibCostStructured) SearchWorkshopWorkTimeStatics(param SearchWorkshopWorkTimeStaticsRequest) (*SearchWorkshopWorkTimeStaticsResponse, error) {
  295 + url := fmt.Sprintf("%s%s", gateway.BaseUrl(), "/attendances/workshop-attendance-statics/search")
  296 + method := "post"
  297 + var data SearchWorkshopWorkTimeStaticsResponse
  298 + err := gateway.FastDoRequest(url, method, param, &data)
  299 + return &data, err
  300 +}
  301 +
  302 +type (
  303 + SearchWorkshopWorkTimeStaticsRequest struct {
  304 + // 车间名称
  305 + WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
  306 + // 生产线名称
  307 + LineName string `cname:"生产线名称" json:"lineName,omitempty"`
  308 + // 开始时间
  309 + BeginTime string `cname:"开始时间" json:"beginTime"`
  310 + // 结束时间
  311 + EndTime string `cname:"结束时间" json:"endTime"`
  312 + }
  313 + SearchWorkshopWorkTimeStaticsResponse struct {
  314 + Grid struct {
  315 + List []SearchWorkshopWorkTimeStaticsItem `json:"list"`
  316 + Total int `json:"total"`
  317 + } `json:"grid"`
  318 + }
  319 + SearchWorkshopWorkTimeStaticsItem struct {
  320 + WorkshopWorkTimeRecordID int `json:"workshopWorkTimeRecordId"`
  321 + WorkStationID string `json:"workStationId"`
  322 + WorkshopID int `json:"workshopId"`
  323 + WorkshopName string `json:"workshopName"`
  324 + LineID int `json:"lineId"`
  325 + LineName string `json:"lineName"`
  326 + SectionID int `json:"sectionId"`
  327 + SectionName string `json:"sectionName"`
  328 + EftWorkTime float64 `json:"eftWorkTime"`
  329 + EdWorkTime int `json:"edWorkTime"`
  330 + EptWorkTime int `json:"eptWorkTime"`
  331 + RecordDate string `json:"recordDate"`
  332 + OrgName string `json:"orgName"`
  333 + AuthFlag bool `json:"authFlag"`
  334 + }
  335 +)
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
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/allied_creation_user" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/cost_structured"
7 "net/http" 8 "net/http"
8 "os" 9 "os"
9 "strconv" 10 "strconv"
@@ -67,6 +68,7 @@ func init() { @@ -67,6 +68,7 @@ func init() {
67 68
68 web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.CheckAccessToken()) 69 web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.CheckAccessToken())
69 web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/manufacture", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{}))) 70 web.InsertFilter("/v1/manufacture/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/manufacture", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{})))
  71 + web.InsertFilter("/v1/cost/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/cost", cost_structured.NewHttpLibCostStructured(domain.Operator{})))
70 } 72 }
71 73
72 func AllowCors() func(ctx *context.Context) { 74 func AllowCors() func(ctx *context.Context) {