作者 yangfu

Merge remote-tracking branch 'origin/dev' into test

# Conflicts:
#	deploy/k8s/test/allied-creation-gateway.yaml
... ... @@ -117,6 +117,8 @@ spec:
value: "http://allied-creation-basic-dev.fjmaimaimai.com"
- name: SMS_SERVE_HOST
value: "https://sms.fjmaimaimai.com:9897"
- name: COST_STRUCTURED
value: "http://cost-structured-dev.fjmaimaimai.com"
- name: SUPLUS_SALE_APP
value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
# - name: REDIS_HOST
... ...
... ... @@ -124,7 +124,7 @@ spec:
- name: SMS_SERVE_HOST
value: "https://sms.fjmaimaimai.com:9897"
- name: COST_STRUCTURED
value: "http://cost-structured-test.fjmaimaimai.com"
value: "https://cost-structured-test.fjmaimaimai.com"
- name: SUPLUS_SALE_APP
value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
- name: MANUFACTURE_WEIGH_DEFAULT_COMPANYID
... ...
... ... @@ -4,6 +4,7 @@ go 1.16
require (
github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2
github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible // indirect
github.com/beego/beego/v2 v2.0.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/disintegration/imaging v1.6.2
... ... @@ -16,5 +17,6 @@ require (
github.com/pdfcpu/pdfcpu v0.3.13
github.com/stretchr/testify v1.7.0
github.com/tal-tech/go-queue v1.0.5
github.com/xuri/excelize/v2 v2.4.1 // indirect
golang.org/x/text v0.3.6
)
... ...
... ... @@ -16,6 +16,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible h1:uuJIwCFhbZy+zdvLy5zrcIToPEQP0s5CFOZ0Zj03O/w=
github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
github.com/beanstalkd/go-beanstalk v0.1.0/go.mod h1:/G8YTyChOtpOArwLTQPY1CHB+i212+av35bkPXXj56Y=
github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE=
... ... @@ -236,6 +238,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=
... ... @@ -483,6 +486,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
... ...
package command
type ImportCostDataCommand struct {
Types int `json:"types"`
}
... ...
... ... @@ -14,6 +14,8 @@ type ImportDataCommand struct {
FileExt string `json:"-"`
// 业务编码
Code string `form:"code"`
// 条件 - 成本结构会增加条件
Where string `form:"where"`
}
func (importDataCommand *ImportDataCommand) Valid(validation *validation.Validation) {
... ...
package service
import (
"bytes"
"encoding/json"
"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/util/converter"
"strings"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/excel"
"github.com/xuri/excelize/v2"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
"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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/converter"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/oss"
"io"
"strconv"
"strings"
)
type ExcelDataService struct {
... ... @@ -245,6 +251,118 @@ func (srv ExcelDataService) ImportDevice(importDataCommand *command.ImportDataCo
return srv.importResultWithHeader(excelImport.DataFields, *result, len(items)), nil
}
// ImportCost 导入成本结构化
func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataCommand) (interface{}, error) {
excelImport := excel.NewExcelImport()
excelImport.RowBegin = 2 //第二行开始读取
excelImport.DataFields = []excel.DataField{
{EnName: "projectCode", CnName: "*项目编码"},
{EnName: "itemName", CnName: "*细项名称"},
{EnName: "choiceId", CnName: "*节点类型"},
{EnName: "text", CnName: "文本(数值)内容"},
{EnName: "image", CnName: "图片"},
{EnName: "formula", CnName: "计算公式"},
{EnName: "chargePersons", CnName: "*负责人"},
{EnName: "target", CnName: "目标值"},
{EnName: "targetPeriod", CnName: "目标值期限"},
{EnName: "present", CnName: "现状值"},
{EnName: "schedulePlanPercent", CnName: "进度计划比"},
{EnName: "benchmark", CnName: "标杆值"},
{EnName: "highest", CnName: "历史最高值"},
{EnName: "yesterdayActual", CnName: "昨日实际值"},
}
var buf bytes.Buffer
tee := io.TeeReader(importDataCommand.Reader, &buf)
excelData, err := converter.OpenImportFileFromIoReader(excelImport, tee, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
importCostCommand := &command.ImportCostDataCommand{}
err = json.Unmarshal([]byte(importDataCommand.Where), importCostCommand)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "风险类型不能为空")
}
if importCostCommand.Types <= 0 {
return nil, application.ThrowError(application.ARG_ERROR, "风险类型不能为空")
}
f, err := excelize.OpenReader(&buf)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
index := f.GetActiveSheetIndex()
//获取公司下所有用户
users, err := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator).UserSearch(allied_creation_user.ReqUserSearch{CompanyId: importDataCommand.Operator.CompanyId, Limit: 10000})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取用户数据失败")
}
userMap := make(map[string]allied_creation_user.UserDetail)
for _, item := range users.Users {
userMap[item.UserInfo.UserName] = item
}
createCostManagemant := cost_structured.BatchAddCostManagemantRequest{
BatchCreateCostManagemant: &domain.BatchCreateCostManagemant{
UserId: importDataCommand.Operator.UserId,
CompanyId: importDataCommand.Operator.CompanyId,
ProjectName: "",
Types: importCostCommand.Types,
CostManagemants: make([]*domain.CostManagemant, 0),
},
}
for key, v := range excelData {
if key == 0 {
createCostManagemant.ProjectName = strings.TrimSpace(v["itemName"])
}
_, mBytes, err := f.GetPicture(f.GetSheetName(index), "E"+fmt.Sprintf("%v", excelImport.RowBegin+key))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
}
var ossFile string
if mBytes != nil {
ossFile, err = oss.UploadOss(mBytes)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
}
}
//choiceId, err := strconv.Atoi(v["choiceId"])
choiceId := domain.NodeType{}.GetIdByName(strings.TrimSpace(v["choiceId"]))
// 负责人
chargePersons := make([]string, 0)
names := strings.Split(strings.TrimSpace(v["chargePersons"]), " ")
for _, userName := range names {
if userName == "" {
continue
}
if user, ok := userMap[userName]; ok {
chargePersons = append(chargePersons, fmt.Sprintf("%v", user.UserId))
}
}
//目标值期限
targetPeriod, _ := strconv.Atoi(strings.TrimSpace(v["targetPeriod"]))
item := &domain.CostManagemant{
ProjectCode: strings.TrimSpace(v["projectCode"]),
ItemName: strings.TrimSpace(v["itemName"]),
ChoiceId: choiceId,
Urls: []string{ossFile},
Formula: strings.TrimSpace(v["formula"]),
ChargePersons: chargePersons,
Target: strings.TrimSpace(v["target"]),
TargetPeriod: targetPeriod,
Present: strings.TrimSpace(v["present"]),
SchedulePlanPercent: strings.TrimSpace(v["schedulePlanPercent"]),
Benchmark: strings.TrimSpace(v["benchmark"]),
Highest: strings.TrimSpace(v["highest"]),
YesterdayActual: strings.TrimSpace(v["yesterdayActual"]),
Types: importCostCommand.Types,
}
createCostManagemant.CostManagemants = append(createCostManagemant.CostManagemants, item)
}
result, err := cost_structured.NewHttpLibCostStructured(importDataCommand.Operator).BatchCreateCostManagemant(createCostManagemant)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return srv.importResultWithHeader(excelImport.DataFields, *result, len(createCostManagemant.CostManagemants)), nil
}
// 导入结果
func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, failRows []interface{}, totalRow int) interface{} {
var result = map[string]interface{}{
... ... @@ -290,6 +408,7 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import
domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx",
domain.ImportProducts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220120/object/1642670543_cbraNKjNPHcbN6RNBYQBrwhC7BXGbDWp.xlsx",
domain.ImportDevices: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220126/object/1643184320_hT6sY5BKHmBa4TynfSGSCGyZ2KTTtzkj.xlsx",
domain.ImportCosts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220311/object/1646977166_ATAD4tJbBDp4WhNFABatTZzkJDeZWB3K.xlsx",
}
var url string
var ok bool
... ...
... ... @@ -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")
... ... @@ -81,4 +85,7 @@ func init() {
if os.Getenv("SUPLUS_SALE_APP") != "" {
SUPLUS_SALE_APP = os.Getenv("SUPLUS_SALE_APP")
}
if os.Getenv("COST_STRUCTURED") != "" {
COST_STRUCTURED = os.Getenv("COST_STRUCTURED")
}
}
... ...
package constant
const OssAccessKey = "LTAI4Fz1LUBW2fXp6QWaJHRS"
const OssSecret = "aLZXwK8pgrs10Ws03qcN7NsrSXFVsg"
var OssBucket = "timeless-world"
const OssDomain = "http://timeless-world.oss-cn-shenzhen.aliyuncs.com"
\ No newline at end of file
... ...
... ... @@ -2,11 +2,18 @@ package constant
import "os"
var POSTGRESQL_DB_NAME = "terms"
//var POSTGRESQL_DB_NAME = "terms"
//var POSTGRESQL_USER = "postgres"
//var POSTGRESQL_PASSWORD = "123456"
//var POSTGRESQL_HOST = "127.0.0.1"
//var POSTGRESQL_PORT = "5432"
//var DISABLE_CREATE_TABLE = false
//var DISABLE_SQL_GENERATE_PRINT = false
var POSTGRESQL_DB_NAME = "allied_creation_dev"
var POSTGRESQL_USER = "postgres"
var POSTGRESQL_PASSWORD = "123456"
var POSTGRESQL_HOST = "127.0.0.1"
var POSTGRESQL_PORT = "5432"
var POSTGRESQL_HOST = "114.55.200.59"
var POSTGRESQL_PORT = "31543"
var DISABLE_CREATE_TABLE = false
var DISABLE_SQL_GENERATE_PRINT = false
... ...
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"`
// 当前选择的节点类型 1、combination 组合框 2、staff 员工选取 3、text 文本框 4、BOM BOM表
// 5、number数值框 6、calculate计算框
ChoiceId int `cname:"当前选择的节点类型 1、combination 组合框 2、staff 员工选取 3、text 文本框 4、BOM BOM表 5、number数值框 6、calculate计算框" json:"choiceId"`
// 图片
Urls []string `cname:"图片" json:"urls"`
// calculate 计算框:计算框公式
Formula string `cname:"calculate 计算框:计算框公式" json:"formula" `
// 项目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"`
// 昨日实际值
YesterdayActual string `json:"yesterdayActual"`
}
type NodeType struct {
TypeId int
TypeName string
}
var NodeTypeGroup = []NodeType{
{TypeId: 1, TypeName: "组合框"},
{TypeId: 2, TypeName: "员工类型"},
{TypeId: 3, TypeName: "文本类型"},
{TypeId: 4, TypeName: "BOM表类型"},
{TypeId: 5, TypeName: "数值框"},
{TypeId: 6, TypeName: "计算框"},
{TypeId: 7, TypeName: "图片框"},
}
func (NodeType) GetIdByName(name string) int {
group := NodeTypeGroup
for _, item := range group {
if item.TypeName == name {
return item.TypeId
}
}
return 0
}
... ...
... ... @@ -68,6 +68,8 @@ const (
ImportProducts = "BUSINESS_ALLIED-MANUFACTURING_BASIC_PRODUCT"
// 导入设备
ImportDevices = "BUSINESS_ALLIED-MANUFACTURING_BASIC_DEVICE"
//导入成本结构
ImportCosts = "BUSINESS_ALLIED-COST"
)
const (
... ...
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,8 @@ 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.CheckAccessToken())
web.InsertFilter("/v1/cost/*", web.BeforeRouter, middleware.RedirectInternalService("/v1/cost", cost_structured.NewHttpLibCostStructured(domain.Operator{})))
}
func AllowCors() func(ctx *context.Context) {
... ...
... ... @@ -214,6 +214,8 @@ func defaultImport(controller *ExcelDataController) {
data, err = excelService.ImportProduct(cmd)
case domain.ImportDevices:
data, err = excelService.ImportDevice(cmd)
case domain.ImportCosts:
data,err = excelService.ImportCost(cmd)
default:
err = fmt.Errorf("导入不存在 Code:%v", cmd.Code)
}
... ...
package oss
import (
"bytes"
"fmt"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/linmadan/egglib-go/utils/snowflake"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
)
var snow, _ = snowflake.NewIdWorker(1)
func UploadOss(data []byte) (string, error) {
client, err := oss.New("oss-cn-shenzhen.aliyuncs.com", constant.OssAccessKey, constant.OssSecret)
if err != nil {
return "", err
}
bucket, err := client.Bucket(constant.OssBucket)
if err != nil {
return "", err
}
fileId, err := snow.NextId()
if err != nil {
return "", err
}
fileName := "costs/" + fmt.Sprintf("%v", fileId)
err = bucket.PutObject(fileName, bytes.NewBuffer(data))
return constant.OssDomain +"/"+ fileName, err
}
\ No newline at end of file
... ...
package oss
import (
"fmt"
"io/ioutil"
"testing"
)
func TestOss(t *testing.T){
mBytes,_:=ioutil.ReadFile("./test.png")
result,err := UploadOss(mBytes)
fmt.Println(result,err)
}
\ No newline at end of file
... ...