Bladeren bron

Merge branch 'feature/special_sub' of baishaojie/kpt_xdmy into master

xuyiping 1 jaar geleden
bovenliggende
commit
b1f3184b1a
42 gewijzigde bestanden met toevoegingen van 1707 en 30 verwijderingen
  1. 62 0
      apiserver/model/bigpartpurchase.go
  2. 5 3
      apiserver/model/http/proof.go
  3. 50 0
      apiserver/model/partpurchase.go
  4. 82 4
      apiserver/routers/api/api.go
  5. 4 1
      apiserver/routers/router.go
  6. 24 9
      apiserver/service/proof.go
  7. 40 0
      apiserver/service/purchase.go
  8. 0 0
      cmd/dist-20230821/datas/myMap.json
  9. BIN
      cmd/dist-20230821/favicon.ico
  10. 0 0
      cmd/dist-20230821/index.html
  11. 0 0
      cmd/dist-20230821/static/css/app.e9af8aa7.css
  12. 0 0
      cmd/dist-20230821/static/css/chunk-elementUI.45ab9bc1.css
  13. 0 0
      cmd/dist-20230821/static/css/chunk-libs.2e418612.css
  14. BIN
      cmd/dist-20230821/static/fonts/element-icons.535877f5.woff
  15. BIN
      cmd/dist-20230821/static/fonts/element-icons.732389de.ttf
  16. BIN
      cmd/dist-20230821/static/img/1.1ddf085a.png
  17. BIN
      cmd/dist-20230821/static/img/404.a57b6f31.png
  18. BIN
      cmd/dist-20230821/static/img/404_cloud.0f4bc32b.png
  19. BIN
      cmd/dist-20230821/static/img/cow.3495de2a.jpg
  20. BIN
      cmd/dist-20230821/static/img/login-bg.dfe7c90f.jpg
  21. BIN
      cmd/dist-20230821/static/img/login-bg1.1f1602f0.jpg
  22. BIN
      cmd/dist-20230821/static/img/login-bujian.8695940d.png
  23. BIN
      cmd/dist-20230821/static/img/logo.4a74cb8a.png
  24. BIN
      cmd/dist-20230821/static/img/logo1.d2343c0f.png
  25. BIN
      cmd/dist-20230821/static/img/logo_u3.34a9ffae.png
  26. 0 0
      cmd/dist-20230821/static/js/app.d44661e7.js
  27. 0 0
      cmd/dist-20230821/static/js/chunk-39889fb2.0f71ae7a.js
  28. 0 0
      cmd/dist-20230821/static/js/chunk-581b2547.9d712337.js
  29. 0 0
      cmd/dist-20230821/static/js/chunk-d17f893e.f74a918f.js
  30. 0 0
      cmd/dist-20230821/static/js/chunk-elementUI.1e8908f6.js
  31. 0 0
      cmd/dist-20230821/static/js/chunk-libs.e75daad1.js
  32. BIN
      cmd/dist.zip
  33. 0 0
      cmd/dist/index.html
  34. 0 0
      cmd/dist/static/css/app.3f6f373a.css
  35. 0 0
      cmd/dist/static/js/app.37fab463.js
  36. 0 0
      cmd/dist/static/js/chunk-581b2547.c1efae40.js
  37. 0 0
      cmd/dist/static/js/chunk-d17f893e.56c4d12d.js
  38. 0 0
      cmd/dist/static/js/chunk-libs.f5a7c3c5.js
  39. BIN
      cmd/eq
  40. 7 6
      go.mod
  41. 992 7
      go.sum
  42. 441 0
      migration/v0002_alter_bigpartpurchase.sql

+ 62 - 0
apiserver/model/bigpartpurchase.go

@@ -0,0 +1,62 @@
+package model
+
+import (
+	"fmt"
+	modernPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/xdmy"
+	"time"
+)
+
+type BigPartPurchase struct {
+	Id             int64                      `gorm:"column:id"`
+	PastureId      int64                      `gorm:"column:pastureId"`
+	OrderNumber    string                     `gorm:"column:orderNumber"`
+	DepartmentId   int64                      `gorm:"column:departmentId"`
+	EmployeId      int64                      `gorm:"column:employeId"`
+	CreateTime     time.Time                  `gorm:"column:createTime"`
+	IsUrgent       int32                      `gorm:"column:isUrgent"`
+	WorkflowId     int64                      `gorm:"column:workflowId"`
+	FlowCompeleted int32                      `gorm:"column:flowCompeleted"`
+	FlowWorkNote   string                     `gorm:"column:flowworkNote"`
+	BuyStatue      int32                      `gorm:"column:buyStatu"`
+	KGChargeId     int32                      `gorm:"column:KGChargeId"`
+	KGChargeDate   time.Time                  `gorm:"column:KGChargedate"`
+	ChargeId       int64                      `gorm:"column:chargeId"`
+	ChargeDate     time.Time                  `gorm:"column:chargeDate"`
+	CGChargeId     int64                      `gorm:"column:CGChargeId"`
+	CGChargeDate   time.Time                  `gorm:"column:CGChargeDate"`
+	WorkflowNote   string                     `gorm:"column:workflowNote"`
+	Statue         int32                      `gorm:"column:statue"`
+	MatchCode      string                     `gorm:"column:matchCode"`
+	ProviderId     int64                      `gorm:"column:providerId"`
+	Equipment      string                     `gorm:"column:equipment"`
+	EquipmentDate  time.Time                  `gorm:"column:equipmentDate"`
+	Field          string                     `gorm:"column:field"`
+	FieldDate      time.Time                  `gorm:"column:fieldDate"`
+	PurchaseType   modernPb.PurchaseType_Kind `gorm:"column:purchase_type"`
+}
+
+func (b *BigPartPurchase) TableName() string {
+	return "bigpartpurchase"
+}
+
+func NewBigPartPurchase(pastureId, departmentId, employeeId, providerId int64,
+	purchaseType modernPb.PurchaseType_Kind, orderNumber, createdTime string,
+) *BigPartPurchase {
+	local, _ := time.LoadLocation("Asia/Shanghai")
+	createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", fmt.Sprintf("%s 00:00:00", createdTime), local)
+	return &BigPartPurchase{
+		PastureId:      pastureId,
+		OrderNumber:    orderNumber,
+		DepartmentId:   departmentId,
+		EmployeId:      employeeId,
+		CreateTime:     createTime,
+		IsUrgent:       0,
+		FlowCompeleted: 1,
+		FlowWorkNote:   "",
+		BuyStatue:      0,
+		WorkflowNote:   "",
+		Statue:         2,
+		ProviderId:     providerId,
+		PurchaseType:   purchaseType,
+	}
+}

+ 5 - 3
apiserver/model/http/proof.go

@@ -20,13 +20,14 @@ type ProofDetail struct {
 	Unit        string `json:"MEINS"` //单位
 	OrderNumber string `json:"EBELN"` //采购订单号,※仅采购入库业务传输,SAP的采购订单号
 	OrderRowNum string `json:"EBPLP"` //采购订单行项目号,※仅采购入库业务传输,SAP的采购订单行项目号
-	MoveType    string `json:"BWART"` //出入库类型 ,"采购入库:101// 退货:161// 领用:201// 退库:202(字典)// 报废:Z19"
+	MoveType    string `json:"BWART"` //出入库类型 ,"采购入库:101// 退货:161// 领用:201// 退库:202(字典)// 报废:Z19 青贮:Z69"
 	SaveType    string `json:"SOBKZ"` //库存类型 特殊库存标识	"自有:空// 寄售:'K' " ,寄售表示零库存,1
 	CostCenter  string `json:"KOSTL"` //成本中心,※仅领用、退库时,输入,编码
 	AssetCode   string `json:"ANLN1"` //资产,※仅领用、退库时,财务资产码
 	AssetSon    string `json:"ANLN2"` //资产子项
 	Provider    string `json:"LIFNR"` //供应商编码,仅寄售入库业务时,输入
 	EXT01       string `json:"EXT01"` //科目
+	AUFNR       string `json:"AUFNR"` //订单编号
 }
 type ProofResp struct {
 	Dest Dest          `json:"DEST"`
@@ -74,8 +75,9 @@ type ProofPartReq struct {
 	ReceiveTime string `json:"receiveTime"` // 出库时间
 	QuitDate    string `json:"quitDate"`    // 退库时间
 
-	PartCode  string
-	SapNumber string `json:"sapNumber"`
+	PartCode          string
+	SapNumber         string `json:"sapNumber"`
+	GreenFodderNumber string `json:"greenFodderNumber"`
 }
 
 func (p *ProofPartReq) Validate() bool {

+ 50 - 0
apiserver/model/partpurchase.go

@@ -0,0 +1,50 @@
+package model
+
+import "fmt"
+
+type PartPurchase struct {
+	Id            int64   `gorm:"column:id"`
+	BigId         int64   `gorm:"column:bigId"`
+	PastureId     int64   `gorm:"column:pastureId"`
+	PartId        int64   `gorm:"column:partId"`
+	PartName      string  `gorm:"column:partName"`
+	PartCode      string  `gorm:"column:partCode"`
+	Amount        int64   `gorm:"column:amount"`
+	Note          string  `gorm:"column:note"`
+	IsStorage     int32   `gorm:"column:isStorage"`
+	Specification string  `gorm:"column:specification"`
+	Purpose       string  `gorm:"column:purpose"`
+	Unit          string  `gorm:"column:unit"`
+	BrandId       int64   `gorm:"column:brandId"`
+	StorageAmount float64 `gorm:"column:storageAmount"`
+	Price         string  `gorm:"column:price"`
+	ContractId    string  `gorm:"column:contractId"`
+}
+
+func (p *PartPurchase) TableName() string {
+	return "partpurchase"
+}
+
+func NewPartPurchase(
+	bigId, pastureId, partId, brandId, amount, contractId int64,
+	partCode, partName, specification, unit, purpose, price string,
+	storageAmount float64,
+) *PartPurchase {
+	return &PartPurchase{
+		BigId:         bigId,
+		PastureId:     pastureId,
+		PartId:        partId,
+		PartName:      partName,
+		PartCode:      partCode,
+		Amount:        amount,
+		Note:          "",
+		IsStorage:     1,
+		Specification: specification,
+		Purpose:       purpose,
+		Unit:          unit,
+		BrandId:       brandId,
+		StorageAmount: storageAmount,
+		Price:         price,
+		ContractId:    fmt.Sprintf("%d", contractId),
+	}
+}

+ 82 - 4
apiserver/routers/api/api.go

@@ -3,12 +3,21 @@ package api
 import (
 	"encoding/json"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
+	"gitee.com/xuyiping_admin/pkg/xerr"
+	"github.com/gin-gonic/gin"
 	"github.com/jmoiron/sqlx"
 	"github.com/pkg/errors"
 	"kpt.xdmy/apiserver/model"
-	"kpt.xdmy/apiserver/model/http"
+	modelHttp "kpt.xdmy/apiserver/model/http"
 	"kpt.xdmy/apiserver/service"
 	"kpt.xdmy/pkg/log"
+	"net/http"
+
+	modernPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/xdmy"
 )
 
 var svc *service.Service
@@ -33,7 +42,7 @@ func NextService(p []map[string]interface{}, tx *sqlx.Tx, vendor int64) error {
 			isTransfer = true
 		} else if sqlname == "insertBigPartUse" {
 			pf := v["parammaps"].(map[string]interface{})
-			if pf["useType"].(float64) != 5 {
+			if pf["useType"].(float64) < 5 {
 				if _, ok := pf["oddCode"]; !ok {
 					return errors.New("oddCode 不能为空 !!!")
 				}
@@ -125,7 +134,7 @@ func NextService(p []map[string]interface{}, tx *sqlx.Tx, vendor int64) error {
 				//case 0:
 				// 入库-申购、采购(申购、线上、寄售)
 				if laidType != 2 {
-					pr := new(http.ProofPartReq)
+					pr := new(modelHttp.ProofPartReq)
 					pr.LaidCode = pf["laidCode"].(string)
 					pr.StorageTime = pf["storageTime"].(string)
 					err := svc.LaidProof(pr, tx)
@@ -139,7 +148,7 @@ func NextService(p []map[string]interface{}, tx *sqlx.Tx, vendor int64) error {
 				//json.Unmarshal(b, &pnext)
 				log.Info(v)
 
-				pr := new(http.ProofPartReq)
+				pr := new(modelHttp.ProofPartReq)
 				pr.UseForm = pf["useForm"].(string)
 				pr.StorageTime = pf["receiveTime"].(string)
 				err := svc.UseProof(pf, tx)
@@ -166,3 +175,72 @@ func NextService(p []map[string]interface{}, tx *sqlx.Tx, vendor int64) error {
 	}
 	return nil
 }
+
+// SparePartsRequisitions 备件申购-特殊申购
+func SparePartsRequisitions(c *gin.Context) {
+
+	var req modernPb.SparePartsRequisitionsRequest
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.OrderNumber, valid.Required, valid.Length(1, 100)),
+		valid.Field(&req.PastureId, valid.Required),
+		valid.Field(&req.DepartmentId, valid.Required),
+		valid.Field(&req.EmployeId, valid.Required),
+		valid.Field(&req.CreateTime, valid.Required),
+		valid.Field(&req.ProviderId, valid.Required),
+		valid.Field(&req.PurchaseType, valid.Required),
+	); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if len(req.SpotList) <= 0 {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, xerr.Custom("备件列表不能为空"))
+		return
+	}
+
+	if err := service.CreateSpecialtyPurchase(c, &req); err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+
+	ginutil.JSONResp(c, &operationPb.CommonOK{
+		Code: http.StatusOK,
+		Msg:  "ok",
+		Data: &operationPb.Success{Success: true},
+	})
+
+}
+
+func GetDieselTypeList(c *gin.Context) {
+	res := &modernPb.DieselTypeListResponse{
+		Code: http.StatusOK,
+		Msg:  "ok",
+		Data: &modernPb.DieselTypeList{
+			DieselType: make([]*modernPb.DieselTypeEnum, 0),
+		},
+	}
+
+	res.Data.DieselType = append(res.Data.DieselType, &modernPb.DieselTypeEnum{
+		Value: modernPb.DieselType_Zero,
+		Label: "0#",
+	}, &modernPb.DieselTypeEnum{
+		Value: modernPb.DieselType_Ten,
+		Label: "-10#",
+	}, &modernPb.DieselTypeEnum{
+		Value: modernPb.DieselType_Twenty,
+		Label: "-20#",
+	}, &modernPb.DieselTypeEnum{
+		Value: modernPb.DieselType_Thirty,
+		Label: "-30#",
+	}, &modernPb.DieselTypeEnum{
+		Value: modernPb.DieselType_Thirty_Five,
+		Label: "-35#",
+	})
+
+	ginutil.JSONResp(c, res)
+}

+ 4 - 1
apiserver/routers/router.go

@@ -143,8 +143,11 @@ func InitRouter() *gin.Engine {
 		apiV1.POST("/partslistSGv2", api.GetPartsListSGv2)
 
 		apiV1.POST("/waterandelectricity", api.GetWaterAndElectricity)
-
+		// 备件申购-特殊申购
+		apiV1.POST("/spare/parts/requisitions", api.SparePartsRequisitions)
+		apiV1.GET("/diesel/type/list", api.GetDieselTypeList)
 	}
+
 	if setting.ServerSetting.NoAuth > 0 {
 
 		apiV2 := r.Group("/data") // restful  接口 tablename 是 表名字

+ 24 - 9
apiserver/service/proof.go

@@ -212,7 +212,7 @@ func (s *Service) LaidProof(p interface{}, tx *sqlx.Tx) error {
 	return nil
 }
 
-// 出库单推送sap,包括了报废出库
+// UseProof 出库单推送sap,包括了报废出库
 func (s *Service) UseProof(p interface{}, tx *sqlx.Tx) error {
 	pr := new(http.ProofPartReq)
 	r := new(http.ProofReq)
@@ -244,12 +244,14 @@ func (s *Service) UseProof(p interface{}, tx *sqlx.Tx) error {
 		bp.ProofCode, _ = data["ProofCode"].(string)
 		bp.DepartmentID, _ = strconv.Atoi(data["departmentId"].(string))
 
-		if _, ok := data["oddCode"]; !ok {
-			return errors.New(fmt.Sprintf("查询出库单 OddCode 出错!!!"))
-		}
-		bp.OddCode = data["oddCode"].(string)
-		if bp.OddCode == "" {
-			return errors.New(fmt.Sprintf("查询出库单 OddCode 出错!!!"))
+		if data["useType"] != "6" {
+			if _, ok := data["oddCode"]; !ok {
+				return errors.New(fmt.Sprintf("查询出库单 OddCode 出错!!!"))
+			}
+			bp.OddCode = data["oddCode"].(string)
+			if bp.OddCode == "" {
+				return errors.New(fmt.Sprintf("查询出库单 OddCode 出错!!!"))
+			}
 		}
 	}
 
@@ -279,8 +281,13 @@ func (s *Service) UseProof(p interface{}, tx *sqlx.Tx) error {
 	//	log.Error(e)
 	//	return errors.New("查询部门信息出错!!!")
 	//}
-	if e := s.d.DB.Raw(` select * from Department where id = (select  departmentId from   bigpartapply where applyCode = ? ) `, bp.OddCode).
-		First(dp).Error; e != nil {
+
+	departmentSqlStr := fmt.Sprintf("select * from Department where id = (select  departmentId from   bigpartapply where applyCode = '%s' )", bp.OddCode)
+	if bp.UseType == 6 {
+		departmentSqlStr = fmt.Sprintf("select * from Department where id = %d", bp.DepartmentID)
+	}
+
+	if e := s.d.DB.Raw(departmentSqlStr).First(dp).Error; e != nil {
 		log.Error(e)
 		return errors.New("查询部门信息出错!!!")
 	}
@@ -356,6 +363,7 @@ func (s *Service) UseProof(p interface{}, tx *sqlx.Tx) error {
 				return errors.New(fmt.Sprintf("寄售不能报废======= errors"))
 			}
 		}
+
 		// 领用出库、手动出库
 		//if pr.UseType == 0 || pr.UseType == 1 {
 		sdetail.MoveType = "201"
@@ -365,6 +373,13 @@ func (s *Service) UseProof(p interface{}, tx *sqlx.Tx) error {
 		//} else {
 		//	sdetail.Factory = dp.Factory
 		//}
+
+		// 青贮技术
+		if pr.UseType == 6 {
+			sdetail.MoveType = "Z69"
+			sdetail.AUFNR = pr.GreenFodderNumber
+		}
+
 		if sdetail.Factory == "M005" && strings.Contains(dp.Name, "二期") {
 			sdetail.Factory = "M017"
 		}

+ 40 - 0
apiserver/service/purchase.go

@@ -0,0 +1,40 @@
+package service
+
+import (
+	"context"
+	modernPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/xdmy"
+	"gitee.com/xuyiping_admin/pkg/xerr"
+	"gorm.io/gorm"
+	"kpt.xdmy/apiserver/model"
+	"strconv"
+)
+
+// CreateSpecialtyPurchase 创建特殊申购信息
+func CreateSpecialtyPurchase(ctx context.Context, req *modernPb.SparePartsRequisitionsRequest) error {
+	return s.d.DB.Transaction(func(tx *gorm.DB) error {
+		newBigPartPurchase := model.NewBigPartPurchase(
+			int64(req.PastureId), int64(req.DepartmentId), int64(req.EmployeId),
+			int64(req.ProviderId), req.PurchaseType, req.OrderNumber, req.CreateTime,
+		)
+
+		if err := tx.Model(new(model.BigPartPurchase)).Create(newBigPartPurchase).Error; err != nil {
+			return xerr.WithStack(err)
+		}
+
+		partPurchaseList := make([]*model.PartPurchase, 0)
+		for _, v := range req.SpotList {
+			amount, _ := strconv.Atoi(v.Amount)
+			partPurchaseList = append(partPurchaseList, model.NewPartPurchase(
+				newBigPartPurchase.Id, int64(req.PastureId), int64(v.PartId), int64(v.BrandId), int64(amount),
+				int64(v.ContractId), v.PartCode, v.PartName, v.Specification, v.Unit, v.Purpose, v.Price,
+				float64(v.StorageAmount)))
+		}
+
+		if len(partPurchaseList) > 0 {
+			if err := tx.Model(new(model.PartPurchase)).Create(partPurchaseList).Error; err != nil {
+				return xerr.WithStack(err)
+			}
+		}
+		return nil
+	})
+}

File diff suppressed because it is too large
+ 0 - 0
cmd/dist-20230821/datas/myMap.json


BIN
cmd/dist-20230821/favicon.ico


File diff suppressed because it is too large
+ 0 - 0
cmd/dist-20230821/index.html


+ 0 - 0
cmd/dist/static/css/app.e9af8aa7.css → cmd/dist-20230821/static/css/app.e9af8aa7.css


File diff suppressed because it is too large
+ 0 - 0
cmd/dist-20230821/static/css/chunk-elementUI.45ab9bc1.css


File diff suppressed because it is too large
+ 0 - 0
cmd/dist-20230821/static/css/chunk-libs.2e418612.css


BIN
cmd/dist-20230821/static/fonts/element-icons.535877f5.woff


BIN
cmd/dist-20230821/static/fonts/element-icons.732389de.ttf


BIN
cmd/dist-20230821/static/img/1.1ddf085a.png


BIN
cmd/dist-20230821/static/img/404.a57b6f31.png


BIN
cmd/dist-20230821/static/img/404_cloud.0f4bc32b.png


BIN
cmd/dist-20230821/static/img/cow.3495de2a.jpg


BIN
cmd/dist-20230821/static/img/login-bg.dfe7c90f.jpg


BIN
cmd/dist-20230821/static/img/login-bg1.1f1602f0.jpg


BIN
cmd/dist-20230821/static/img/login-bujian.8695940d.png


BIN
cmd/dist-20230821/static/img/logo.4a74cb8a.png


BIN
cmd/dist-20230821/static/img/logo1.d2343c0f.png


BIN
cmd/dist-20230821/static/img/logo_u3.34a9ffae.png


+ 0 - 0
cmd/dist/static/js/app.d44661e7.js → cmd/dist-20230821/static/js/app.d44661e7.js


File diff suppressed because it is too large
+ 0 - 0
cmd/dist-20230821/static/js/chunk-39889fb2.0f71ae7a.js


+ 0 - 0
cmd/dist/static/js/chunk-581b2547.9d712337.js → cmd/dist-20230821/static/js/chunk-581b2547.9d712337.js


+ 0 - 0
cmd/dist/static/js/chunk-d17f893e.f74a918f.js → cmd/dist-20230821/static/js/chunk-d17f893e.f74a918f.js


File diff suppressed because it is too large
+ 0 - 0
cmd/dist-20230821/static/js/chunk-elementUI.1e8908f6.js


+ 0 - 0
cmd/dist/static/js/chunk-libs.e75daad1.js → cmd/dist-20230821/static/js/chunk-libs.e75daad1.js


BIN
cmd/dist.zip


File diff suppressed because it is too large
+ 0 - 0
cmd/dist/index.html


File diff suppressed because it is too large
+ 0 - 0
cmd/dist/static/css/app.3f6f373a.css


File diff suppressed because it is too large
+ 0 - 0
cmd/dist/static/js/app.37fab463.js


File diff suppressed because it is too large
+ 0 - 0
cmd/dist/static/js/chunk-581b2547.c1efae40.js


File diff suppressed because it is too large
+ 0 - 0
cmd/dist/static/js/chunk-d17f893e.56c4d12d.js


File diff suppressed because it is too large
+ 0 - 0
cmd/dist/static/js/chunk-libs.f5a7c3c5.js


BIN
cmd/eq


+ 7 - 6
go.mod

@@ -9,9 +9,11 @@ replace (
 )
 
 require (
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20230829090029-dcc108270e61
+	gitee.com/xuyiping_admin/pkg v0.0.0-20230816061144-c1f079802584
 	github.com/360EntSecGroup-Skylar/excelize v1.4.1
 	github.com/Anderson-Lu/gofasion v0.0.0-20190530065914-6a05b679ee48
-	github.com/BurntSushi/toml v1.2.0
+	github.com/BurntSushi/toml v1.2.1
 	github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
 	github.com/astaxie/beego v1.12.3
 	github.com/axetroy/go-fs v1.0.0
@@ -28,7 +30,7 @@ require (
 	github.com/fastwego/wxwork v1.0.0-beta.8
 	github.com/gin-gonic/gin v1.9.0
 	github.com/go-ini/ini v1.66.6
-	github.com/go-sql-driver/mysql v1.6.0
+	github.com/go-sql-driver/mysql v1.7.0
 	github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4
 	github.com/jmoiron/sqlx v1.3.5
 	github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
@@ -41,7 +43,7 @@ require (
 	github.com/pkg/errors v0.9.1
 	github.com/robfig/cron v1.2.0
 	github.com/robfig/cron/v3 v3.0.0
-	github.com/sirupsen/logrus v1.9.0
+	github.com/sirupsen/logrus v1.9.3
 	github.com/swaggo/files v1.0.1
 	github.com/swaggo/gin-swagger v1.6.0
 	github.com/swaggo/swag v1.8.12
@@ -49,9 +51,8 @@ require (
 	github.com/unknwon/com v1.0.1
 	github.com/xormplus/xorm v0.0.0-20210822100304-4e1d4fcc1e67
 	github.com/xuri/excelize/v2 v2.6.1
-	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
-	gorm.io/driver/mysql v1.3.5
+	gorm.io/driver/mysql v1.5.1
 	gorm.io/driver/sqlserver v1.4.3
-	gorm.io/gorm v1.25.0
+	gorm.io/gorm v1.25.2
 
 )

File diff suppressed because it is too large
+ 992 - 7
go.sum


+ 441 - 0
migration/v0002_alter_bigpartpurchase.sql

@@ -0,0 +1,441 @@
+ALTER TABLE `bigpartpurchase`
+    ADD COLUMN `purchase_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '申购类型 0 无效 1 暂估 2 垫付',
+    ADD COLUMN `funder_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '垫资人id';
+
+ALTER TABLE `bigpartuse` ADD COLUMN greenFodderNumber varchar(255) NOT NULL DEFAULT '' COMMENT '青贮单号';
+
+# SELECT * FROM apisql WHERE sqlname = 'insertBigPartUse'
+INSERT INTO bigpartuse (
+    pastureId,
+    departmentId,
+    useForm,
+    listType,
+    applicatId,
+    receiveTime,
+    empId,
+    useType,
+    oddCode,
+    note,
+    greenFodderNumber
+) VALUES ( ?,(select departmentId  from bigpartapply where applyCode = ? ),?,?,?,?,?,?,?,?,?)
+# pastureId,oddCode,useForm,listType,applicatId,receiveTime,empId,useType,oddCode,note,greenFodderNumber
+
+# SELECT * FROM apisql WHERE sqlname = 'getpartpurchaseList'
+SELECT
+    bpp.providerId,
+    pr.providerName,
+    bpp.`buyStatu`,
+    DATE_FORMAT(bpp.`CGChargedate`,'%Y-%m-%d %H:%i:%s') CGChargedate,
+    bpp.`CGChargeId`,
+    DATE_FORMAT(bpp.`chargeDate`,'%Y-%m-%d %H:%i:%s') chargeDate,
+    bpp.`chargeId`,
+    bpp.`createTime`,
+    bpp.`departmentId`,
+    bpp.`employeId`,
+    bpp.`flowCompeleted`,
+    bpp.`flowworkNote`,
+    bpp.`id`,
+    bpp.`isUrgent`,
+    DATE_FORMAT(bpp.`KGChargedate`,'%Y-%m-%d %H:%i:%s') KGChargedate ,
+    bpp.`KGChargeId`,
+    bpp.`orderNumber`,
+    bpp.`pastureId`,
+    bpp.`statue`,
+    bpp.`workflowId`,
+    bpp.`workflowNote`,
+    bpp.purchase_type,  # 这次加字段
+    bpp.funder_id,  # 这次加字段
+    p.`name` pastureName,
+    e.empname ,
+    e6.empname funderName, # 这次加字段
+    e1.empname KGChargePerson,
+    e2.empname chargePerson,
+    e3.empname  CGChargePerson,
+    d.`name` AS departmentName,
+    DATE_FORMAT(bpp.createTime, '%Y-%m-%d') inputTime,
+    e4.empname equipmentPerson,
+    bpp.equipment,
+    DATE_FORMAT(bpp.equipmentdate,'%Y-%m-%d %H:%i:%s') equipmentdate ,
+    e5.empname fieldPerson,
+    DATE_FORMAT(bpp.fielddate,'%Y-%m-%d %H:%i:%s') fielddate,
+    if((select sum(price*amount) from partpurchase where bigid = bpp.id )> 5000 ,1,
+    if((select sum(if(price>3000,1,0)) from partpurchase where bigid = bpp.id)>0,1,0)) as priceClass
+FROM
+    bigpartpurchase bpp
+        LEFT JOIN pasture p
+                  ON p.id = bpp.pastureId
+        LEFT JOIN emp e
+                  ON e.id = bpp.employeId
+        LEFT JOIN department d
+                  ON d.id = bpp.departmentId
+        LEFT JOIN emp e1
+                  ON e1.id = bpp.KGChargeId
+        LEFT JOIN emp e2
+                  ON e2.id = bpp.chargeId
+        LEFT JOIN emp e3
+                  ON e3.id = bpp.CGChargeId
+        LEFT JOIN emp e4
+                  ON e4.id = bpp.equipment
+        LEFT JOIN emp e5
+                  ON e5.id = bpp.field
+        LEFT JOIN emp e6
+                  ON e6.id = bpp.funder_id
+        LEFT JOIN provider pr
+                  ON pr.id = bpp.providerId
+WHERE
+    ((bpp.employeId = ? OR IFNULL((SELECT MAX(r.`datarole`) FROM `user` u
+     LEFT JOIN user_role ur
+               ON ur.`user_id`= u.`id`
+     LEFT JOIN role r
+               ON r.`id` = ur.`role_id`
+     LEFT JOIN role_menu rm
+               ON r.`id` = rm.`role_id`
+     LEFT JOIN menu m
+               ON m.`id` = rm.`menu_id`
+   WHERE u.`empid` = ? AND m.`path`=? ),0) IN (1,2,3))
+
+AND (bpp.departmentId IN (SELECT id FROM department WHERE pastureId =? AND id IN (
+
+    SELECT  SUBSTRING_INDEX(SUBSTRING_INDEX(ss.www,',',b.seq+1),',',-1) AS 'ids'
+    FROM
+    (SELECT @i:=1 i,IFNULL((SELECT GROUP_CONCAT(department_id)SSSS
+        FROM role_department WHERE role_id = (SELECT  MAX(r.id) FROM `user` u
+         LEFT JOIN user_role ur
+                   ON ur.`user_id`= u.`id`
+         LEFT JOIN role r
+                   ON r.`id` = ur.`role_id`
+         LEFT JOIN role_menu rm
+                   ON r.`id` = rm.`role_id`
+         LEFT JOIN role_department rd
+                   ON r.`id` = rd.`role_id`
+         LEFT JOIN menu m
+                   ON m.`id` = rm.`menu_id`
+          WHERE u.`empid` = ? AND m.`path`=?) AND department_id IN (SELECT id FROM department WHERE pastureId = ?)),?) www) ss
+    JOIN   sequence b ON b.seq < (LENGTH(ss.www) - LENGTH(REPLACE(ss.www,',',''))+1)
+    WHERE ss.i =1
+    GROUP BY ids
+)
+        )
+OR bpp.employeId = ?  OR IFNULL((SELECT MAX(r.`datarole`) FROM `user` u
+LEFT JOIN user_role ur
+    ON ur.`user_id`= u.`id`
+LEFT JOIN role r
+    ON r.`id` = ur.`role_id`
+LEFT JOIN role_menu rm
+    ON r.`id` = rm.`role_id`
+LEFT JOIN menu m
+    ON m.`id` = rm.`menu_id`
+ WHERE u.`empid` =? AND m.`path`=?),0) IN (2,3))
+    AND (p.`id` = ? OR IFNULL((SELECT MAX(r.`datarole`) FROM `user` u
+ LEFT JOIN user_role ur
+    ON ur.`user_id`= u.`id`
+ LEFT JOIN role r
+    ON r.`id` = ur.`role_id`
+ LEFT JOIN role_menu rm
+    ON r.`id` = rm.`role_id`
+ LEFT JOIN menu m
+    ON m.`id` = rm.`menu_id`
+WHERE u.`empid` = ? AND m.`path`=? ),0) = 3))
+  AND
+    (
+        bpp.orderNumber LIKE CONCAT("%", ?, "%")
+            OR ? = ''
+        )
+  AND (
+            p.`name` = ?
+        OR ? = '现代牧业'
+    )
+  AND (
+            bpp.departmentId = ?
+        OR ? = ''
+    )AND (
+        (bpp.createTime >= ? AND bpp.createTime <= ? )
+        OR ? = ''
+    )
+  AND (
+    IF (?=0,bpp.statue IN (2,3,5) ,
+        IF(?=1,bpp.statue=7,bpp.statue IN (4,6,8))
+        )
+    OR ? = ''
+    )
+  AND
+    (
+    e.empname LIKE CONCAT("%", ?, "%")
+        OR ? = ''
+    )
+  AND (bpp.purchase_type = ? OR ? = '')
+
+ORDER BY bpp.id DESC
+
+## loginId,loginId,menu,loginpastureId,loginId,menu,loginpastureId,logindeptId,loginId,loginId,menu,loginpastureId,loginId,menu,orderNumber ,orderNumber ,pastureName,pastureName,departmentId ,departmentId,startTime,stopTime,startTime,stuteSH,stuteSH,stuteSH,empName,empName,purchase_type
+
+
+## 合同管理增加两个字段
+
+ALTER TABLE `contract`
+    ADD COLUMN lifeCycle varchar(255) NOT NULL DEFAULT '' COMMENT '使用周期',
+    ADD COLUMN ContractVarianceItem varchar(255) NOT NULL DEFAULT '' COMMENT '合同差异性';
+
+
+INSERT INTO contract(
+    bigId,
+    pastureId,
+    pastureName,
+    partId,
+    partName,
+    partCode,
+    specification,
+    price,
+    brandId,
+    brand,
+    planAmount,
+    remark,
+    unit,
+    enable,
+    changeId,
+    taxcode,
+    lifeCycle,   ## 这次新增的字段
+    contractVarianceItem  ## 这次新增的字段
+)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,0,if(?='',null,?),?,?,?);
+
+## bigId,pastureId,pastureName,partId,partName,partCode,specification,price,brandId,brand,planAmount,remark,unit,contractId,contractId,taxcode,lifeCycle,contractVarianceItem
+
+## SELECT * FROM apisql WHERE sqlname = "getcontratListBybigV2"
+
+SELECT
+    CONCAT('uploads/thumbnail/',ep.`picpath`,'/',ep.`newpicname`) picpath,
+    CONCAT('uploads/image/',ep.`picpath`,'/',ep.`newpicname`) srcpath,
+    b.`brandName`,c.lifeCycle,c.contractVarianceItem,
+    c.id,c.bigId,c.pastureId,c.pastureName,c.partId,c.partName,c.partCode,c.specification,
+    TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM c.price))) price,c.brandId,c.brand,c.inventoryType,c.planAmount,c.remark,c.enable,c.unit,c.isZeroStock
+FROM
+    contract c
+        INNER JOIN bigcontract bc
+                   ON bc.id = c.`bigId`
+        LEFT JOIN brand b
+                  ON b.id = c.`brandId`
+        LEFT JOIN parts ps
+                  ON ps.id = c.`partId`
+        LEFT JOIN eq_pic ep
+                  ON ep.id = ps.picpath
+WHERE bc.`pastureId`=? AND bc.`providerId` = ? AND bc.`stopTime`=? AND bc.`flag` =? AND bc.isZeroStock = ?
+  AND bc.statue =? and c.enable = 1
+  AND (
+            c.partCode LIKE CONCAT("%", ?, "%")
+        OR ? = ''
+    )
+  AND (
+            c.partName LIKE CONCAT("%", ?, "%")
+        OR ? = ''
+    )
+  AND (
+            c.specification LIKE CONCAT("%", ?, "%")
+        OR ? = ''
+    )
+ORDER BY c.partCode;
+
+
+# SELECT * FROM apisql WHERE sqlname = "insertDiesel
+INSERT INTO diesel (pastureId,selTime,oilClass,oilAmount,eqId,eqCode,deptId,note,nowPrice,oilcardId,cardNumber,price,empId,inputId,oilType,oilName)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
+# pastureId,selTime,oilClass,oilAmount,eqId,eqCode,departmentId,note,nowPrice,oilcardId,cardNumber,price,empId,inputId,oilType,oilName
+
+ALTER TABLE `diesel`
+    ADD COLUMN `oilType` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '柴油类型 0: 空 1: 0# 2: -10# 3: -20# 4: -30# 5: -35#',
+    ADD COLUMN `oilName` varchar(255) NOT NULL DEFAULT '' COMMENT '柴油类型名称';
+
+# SELECT * FROM apisql WHERE sqlname = "updateDieselExecData"
+update diesel
+set oilAmount= ?,
+    note = ?,
+    nowPrice = ?,
+    price=?,
+    oilType = ?,
+    oilName = ?
+where id = ?;
+# oilAmount, note, nowPrice, price,oilType,oilName, id
+
+# SELECT * FROM apisql WHERE sqlname = "getDieselList"
+SELECT  (@i:=@i+1) i,d.id,d.oilcardId,p.name pastureName,dp.name departName, d.cardNumber,o.cardType ,DATE_FORMAT(d.selTime,'%Y-%m-%d') as selTime,a.eqCode as assetNumber ,a.eqName assetName,d.empId  employName,d.oilClass,d.empId,
+d.oilName,
+d.oilAmount,d.price,d.nowPrice,d.note,ff.empname  empname,d.inputId
+from   (SELECT @i:=0) AS i,diesel  d
+LEFT  JOIN  oilcard o ON d.oilcardId = o.id
+INNER JOIN  pasture p on d.pastureId = p.id
+left JOIN  department dp on d.deptId= dp.id
+LEFT  JOIN emp ff ON d.inputId = ff.id
+LEFT JOIN equipment a ON a.id= o.eqId
+where  (p.name like concat("%",?,"%") or ?  ='现代牧业')
+  and (dp.name  like concat("%",?,"%") or ?  ='')
+  and (d.cardNumber like concat("%",?,"%") or ?  ='')
+  and (o.cardCode like concat("%",?,"%") or ?  ='')
+  AND (a.eqCode like concat("%",?,"%") or ?  ='') AND (a.eqName like concat("%",?,"%") or ?  ='')
+  AND (d.empId like concat("%",?,"%") or ?  ='') AND (d.oilClass like concat("%",?,"%") or ?  ='')
+  and (d.selTime between ? and ? or ?='')
+ORDER BY d.selTime DESC,d.id DESC;
+
+# SELECT * FROM apisql WHERE sqlname = "getPartuseDetailList"    // 备件出库-出库记录查询修改备件名称模糊查询
+SELECT
+    e1.`empname`,
+    d.`name` AS departmentName,
+    bpu.`listType`,
+    bpu.`useForm`,
+    IFNULL(pv.`providerName`,(SELECT provider.providerName FROM part_repertory
+    INNER JOIN provider ON provider.id = part_repertory.providerId
+    WHERE  part_repertory.contractId = pu.contractId LIMIT 1)) providerName,
+    w.`warehoseCode`,
+    pu.`partCode`,
+    pu.`partName`,
+    b.`brandName`,
+    pu.`specification`,
+    pu.`unit`,
+    (pu.`checkoutNumber`-pu.`quitNumber`)  checkoutNumber,
+    TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM  pu.`price`))) price,
+    round( TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM pu.`price`)))*(pu.`checkoutNumber`-pu.`quitNumber`) ,2)sumPrice,
+    pu.`eqName`,
+    pu.`eqCode`,
+    pu.useTypeV,
+    pu.reportery,
+    p.`name` pastureName,
+    e.empname AS appliname,
+    e.id employeId,
+    DATE_FORMAT(bpu.receiveTime, '%Y/%m/%d') creatTime,pu.note
+FROM
+    partuse pu
+        inner JOIN   bigpartuse bpu
+                     ON pu.`bigId` =bpu.`id`
+        LEFT JOIN pasture p
+                  ON p.id = bpu.pastureId
+        LEFT JOIN emp e
+                  ON e.id = bpu.applicatId
+        LEFT JOIN emp e1
+                  ON e1.id = bpu.`empId`
+        LEFT JOIN department d
+                  ON d.id = bpu.`departmentId`
+        LEFT JOIN contract  c
+                  ON c.`id` = pu.`contractId`
+        LEFT JOIN bigcontract  bc
+                  ON bc.`id` = c.`bigId`
+        LEFT JOIN provider pv
+                  ON bc.`providerId` = pv.`id`
+        LEFT JOIN warehouse w
+                  ON w.id = pu.locationId
+        LEFT JOIN brand b
+                  ON b.id = pu.brandId
+
+WHERE (
+            bpu.useForm LIKE CONCAT("%", ?, "%")
+        OR ? = ''
+    )
+  AND (
+            bpu.`useType` = ?
+        OR ? = ''
+    )
+  AND (
+        (bpu.receiveTime >= ? AND bpu.receiveTime <= ?)
+        OR ? = ''
+    )
+  AND (
+            p.`name` = ?
+        OR ? = '现代牧业'
+    )
+  AND (
+            d.`id` =?
+        OR ? = ''
+    )
+  AND (
+            pu.partCode=?
+        OR ? = ''
+    )
+  AND (
+            pu.partName like concat("%",?,"%") or ?  =''
+    )
+  AND (
+            bc.`providerId`=?
+        OR ? = ''
+    )
+  AND (
+            pu.`eqName`=?
+        OR ? = ''
+    )
+
+  AND (
+    if(?='',
+       ''='',
+       (select assetCode from equipment where equipment.eqcode = pu.eqcode) like concat(?,'%')
+        )
+    )
+ORDER BY bpu.receiveTime DESC,bpu.id desc;
+
+
+SELECT  (@i:=@i+1) i,d.id,d.oilcardId,p.name pastureName,dp.name departName, d.cardNumber,o.cardType ,DATE_FORMAT(d.selTime,'%Y-%m-%d') as selTime,a.eqCode as assetNumber ,a.eqName assetName,d.empId  employName,d.oilClass,d.empId,
+        d.oilName,
+        d.oilAmount,d.price,d.nowPrice,d.note,ff.empname  empname,d.inputId
+from   (SELECT @i:=0) AS i,diesel  d
+                               LEFT  JOIN  oilcard o ON d.oilcardId = o.id
+                               INNER JOIN  pasture p on d.pastureId = p.id
+                               left JOIN  department dp on d.deptId= dp.id
+                               LEFT  JOIN emp ff ON d.inputId = ff.id
+                               LEFT JOIN equipment a ON a.id= o.eqId
+where  (p.name like concat("%",?,"%") or ?  ='现代牧业')
+
+  and (dp.name  like concat("%",?,"%") or ?  ='')
+  and (d.cardNumber like concat("%",?,"%") or ?  ='')
+  and (o.cardCode like concat("%",?,"%") or ?  ='')
+  AND (a.eqCode like concat("%",?,"%") or ?  ='') AND (a.eqName like concat("%",?,"%") or ?  ='')
+  AND (d.empId like concat("%",?,"%") or ?  ='') AND (d.oilClass like concat("%",?,"%") or ?  ='')
+  and (d.selTime between ? and ? or ?='')
+ORDER BY d.selTime DESC,d.id DESC;
+
+
+# SELECT * FROM apisql WHERE sqlname = "getPartlaideDetailList"   // 备件入库-入库记录查询修改备件名称模糊查询
+SELECT
+    emp.empname,
+    b.`brandName`,
+    w.`warehoseCode`,
+    pv.`providerName`,
+    DATE_FORMAT(bpl.storageTime, '%Y/%m/%d') creatTime,
+    p.`name` pastureName,
+    bpl.`laidCode`,
+    pl.`partCode`,
+    pl.`partName`,
+    pl.`specification`,
+    pl.`unit`,
+    pl.storageAmount,
+    TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM pl.`price`))) price ,
+    TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM pl.`sumPrice`))) sumPrice
+FROM
+    partlaid pl
+        inner JOIN bigpartlaid bpl
+                   ON bpl.`id` = pl.`bigId`
+        LEFT JOIN brand b
+                  ON b.id = pl.brandId
+        LEFT JOIN warehouse w
+                  ON w.id = pl.locationId
+        LEFT JOIN pasture p
+                  ON p.id = bpl.`pastureId`
+        left JOIN provider pv
+                  ON pv.id = pl.`providerId`
+        left join emp
+                  on emp.id = bpl.empId
+WHERE (
+            bpl.laidCode LIKE CONCAT("%", ?, "%")
+        OR ? = ''
+    )
+  AND (
+            p.`name` LIKE CONCAT("%", ?, "%")
+        OR ? = '现代牧业'
+    )
+  AND (
+        (bpl.storageTime >= ? AND bpl.storageTime <= ?)
+        OR ? = ''
+    )
+  AND (
+            pl.partCode=?
+        OR ? = ''
+    )
+  AND ( pl.partName like concat("%",?,"%") or ?  ='')
+  AND (
+            pl.providerId=?
+        OR ? = ''
+    )
+ORDER BY bpl.storageTime DESC, bpl.`id` DESC;

Some files were not shown because too many files changed in this diff