|
@@ -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
|
|
@@ -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,43 @@ 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},
|
|
|
+ })
|
|
|
+
|
|
|
+}
|