| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- /**
- * @Author: zou.yingbin
- * @Create : 2021/3/10 15:30
- * @Modify : 2021/3/10 15:30
- */
- package ermcp
- import (
- "github.com/gin-gonic/gin"
- "mtp2_if/global/app"
- "mtp2_if/global/e"
- "mtp2_if/models"
- "net/http"
- "strconv"
- )
- // 查询日期
- type QueryDate string
- // IsNumberic 判断是否为数字,
- func (v QueryDate) IsNumberic(queryType int32) bool {
- if queryType == 1 {
- // 日报表 日期长度YYYYMMDD
- if len(v) != 8 {
- return false
- }
- } else if queryType == 2 {
- // 月报表 日期长度YYYYMM
- if len(v) != 6 {
- return false
- }
- }
- // 判断是否为数字
- if _, err := strconv.ParseInt(string(v), 10, 32); err != nil {
- return false
- }
- return true
- }
- // QryAreaStockApplyReq 查询库存申请请求
- type QryAreaStockApplyReq struct {
- USERID int64 `form:"userid" binding:"required"` // 用户id
- INOUTTYPE string `form:"inouttype"` // 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
- SPOTCONTRACTID string `form:"spotcontractid"` // 合同ID
- WRSTANDARDID string `form:"wrstandardid"` // 现货商品ID
- SPOTGOODSBRANDID int32 `form:"spotgoodsbrandid"` // 品牌ID
- SPOTGOODSMODELID int32 `form:"spotgoodsmodelid"` // 型号ID
- WAREHOUSEINFOID string `form:"warehouseinfoid"` // 仓库ID
- APPLYSTATUS string `form:"applystatus"` // 申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
- }
- // QryAreaStockApplyRsp 查询库存申请响应
- type QryAreaStockApplyRsp models.ErmcpAreaStockApply
- // QueryAreaStockApply
- // @Summary 查询库存申请(出入库记录|库存审核)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户ID"
- // @Param inouttype query string false "出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库"
- // @Param spotcontractid query int false "合同ID"
- // @Param wrstandardid query int false "现货商品ID"
- // @Param spotgoodsbrandid query int false "品牌ID"
- // @Param spotgoodsmodelid query int false "型号ID"
- // @Param warehouseinfoid query int false "仓库ID"
- // @Param applystatus query string false "申请状态(可多项,逗号隔开)1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回"
- // @Success 200 {array} QryAreaStockApplyRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryAreaStockApply [get]
- // @Tags 企业风险管理(app)
- func QueryAreaStockApply(c *gin.Context) {
- a := app.NewGinUtils(c)
- req := QryAreaStockApplyReq{}
- a.DoBindReq(&req)
- m := models.ErmcpAreaStockApply{
- USERID: req.USERID,
- FilterType: req.INOUTTYPE,
- SPOTCONTRACTID: req.SPOTCONTRACTID,
- WRSTANDARDID: req.WRSTANDARDID,
- SPOTGOODSBRANDID: req.SPOTGOODSBRANDID,
- SPOTGOODSMODELID: req.SPOTGOODSMODELID,
- WAREHOUSEINFOID: req.WAREHOUSEINFOID,
- FilterStatus: req.APPLYSTATUS,
- }
- a.DoGetDataEx(&m)
- }
- // QueryAreaStockApplySum 出入库汇总请求
- type QueryAreaStockApplySumReq struct {
- SPOTCONTRACTID string `form:"spotcontractid"` // 合同ID
- }
- // QueryAreaStockApplySumRsp 出入库汇总响应
- type QueryAreaStockApplySumRsp models.ErmcpAreaStockApplySum
- // QueryAreaStockApplySum
- // @Summary 查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param spotcontractid query int false "合同ID"
- // @Success 200 {array} QueryAreaStockApplySumRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryAreaStockApplySum [get]
- // @Tags 企业风险管理(app)
- func QueryAreaStockApplySum(c *gin.Context) {
- a := app.GinUtils{Gin: app.Gin{C: c}}
- req := QueryAreaStockApplySumReq{}
- a.DoBindReq(&req)
- m := models.ErmcpAreaStockApplySum{SPOTCONTRACTID: req.SPOTCONTRACTID}
- a.DoGetDataEx(&m)
- }
- // QueryAreaStockReq 查询库存量请求
- type QueryAreaStockReq struct {
- USERID int64 `form:"userid" binding:"required"` // 用户id
- }
- // QueryAreaStock
- // @Summary 查询机构库存(库存管理/当前库存)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户ID"
- // @Success 200 {array} models.ErmcpAreaStock
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryAreaStock [get]
- // @Tags 企业风险管理(app)
- func QueryAreaStock(c *gin.Context) {
- a := app.GinUtils{Gin: app.Gin{C: c}}
- req := QueryAreaStockReq{}
- a.DoBindReq(&req)
- m := models.ErmcpAreaStock{USERID: req.USERID}
- a.DoGetDataEx(&m)
- }
- type QueryAreaStockReportReq struct {
- USERID int64 `form:"userid" binding:"required"` // 用户id
- DETAILTYPE int32 `form:"detailtype"` // 明细类型 1:入库明细(采购入库+生产入库) 2:出库明细(销售出库+生产出库)
- WRSTANDARDID string `form:"wrstandardid"` // 现货商品ID
- SPOTGOODSBRANDID int32 `form:"spotgoodsbrandid"` // 品牌ID
- SPOTGOODSMODELID int32 `form:"spotgoodsmodelid"` // 型号ID
- WAREHOUSEINFOID string `form:"warehouseinfoid"` // 仓库ID
- QUERYTYPE int32 `form:"querytype" binding:"required"` // 查询类型 1-日报表(或明细) 2-月报表(或明细)
- QUERYDATE string `form:"querydate" binding:"required"` // 查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)
- }
- // QueryAreaStockReport
- // @Summary 查询库存报表
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户ID"
- // @Param querytype query int true "查询类型 1-日报表 2-月报表"
- // @Param querydate query string true "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)"
- // @Param wrstandardid query int false "现货商品ID"
- // @Param spotgoodsbrandid query int false "品牌ID"
- // @Param spotgoodsmodelid query int false "型号ID"
- // @Param warehouseinfoid query int false "仓库ID"
- // @Success 200 {array} models.ErmcpAreaStockReport
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryAreaStockReport [get]
- // @Tags 企业风险管理(app)
- func QueryAreaStockReport(c *gin.Context) {
- a := app.GinUtils{Gin: app.Gin{C: c}}
- req := QueryAreaStockReportReq{}
- a.DoBindReq(&req)
- if QueryDate(req.QUERYDATE).IsNumberic(req.QUERYTYPE) {
- m := models.ErmcpAreaStockReport{USERID: req.USERID, WRSTANDARDID: req.WRSTANDARDID,
- SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, SPOTGOODSMODELID: req.SPOTGOODSMODELID,
- WAREHOUSEINFOID: req.WAREHOUSEINFOID, ReportDate: req.QUERYDATE, ReportType: req.QUERYTYPE}
- a.DoGetDataEx(&m)
- } else {
- a.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- }
- }
- // QueryAreaStockReportDetail
- // @Summary 查询库存报表明细
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户ID"
- // @Param querytype query int true "查询类型 1-日报表明细 2-月报表明细"
- // @Param detailtype query int true "明细类型 1:入库明细(采购入库+生产入库) 2:出库明细(销售出库+生产出库)"
- // @Param querydate query string true "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)"
- // @Param wrstandardid query int false "现货商品ID"
- // @Param spotgoodsbrandid query int false "品牌ID"
- // @Param spotgoodsmodelid query int false "型号ID"
- // @Param warehouseinfoid query int false "仓库ID"
- // @Success 200 {array} models.ErmcpAreaStockApply
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryAreaStockReportDetail [get]
- // @Tags 企业风险管理(app)
- func QueryAreaStockReportDetail(c *gin.Context) {
- a := app.GinUtils{Gin: app.Gin{C: c}}
- req := QueryAreaStockReportReq{}
- a.DoBindReq(&req)
- if QueryDate(req.QUERYDATE).IsNumberic(req.QUERYTYPE) {
- var beginDate, endDate string
- if req.QUERYTYPE == 1 {
- beginDate = req.QUERYDATE
- endDate = beginDate
- } else if req.QUERYTYPE == 2 {
- beginDate = req.QUERYDATE + "01"
- endDate = req.QUERYDATE + "31"
- }
- m := models.ErmcpAreaStockApply{USERID: req.USERID, WRSTANDARDID: req.WRSTANDARDID,
- SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, SPOTGOODSMODELID: req.SPOTGOODSMODELID,
- WAREHOUSEINFOID: req.WAREHOUSEINFOID, BeginDate: beginDate, EndDate: endDate, APPLYSTATUS: 2}
- // 出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库"
- if req.DETAILTYPE == 1 {
- m.FilterStatus = "1,3"
- } else if req.DETAILTYPE == 2 {
- m.FilterStatus = "2,4"
- }
- a.DoGetDataEx(&m)
- } else {
- a.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- }
- }
|