|
|
@@ -22,7 +22,7 @@ type ErmcpAreaStockApply struct {
|
|
|
SPOTGOODSMODELID int32 `json:"spotgoodsmodelid" xorm:"'SPOTGOODSMODELID'"` // 现货型号ID
|
|
|
SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID
|
|
|
DELIVERYGOODSID int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
|
|
|
- SPOTCONTRACTID string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 关联现货合同ID [1:采购入库 2:销售出库 ]
|
|
|
+ SPOTCONTRACTID string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 关联现货合同ID
|
|
|
WAREHOUSEINFOID string `json:"warehouseinfoid" xorm:"'WAREHOUSEINFOID'"` // 现货仓库ID
|
|
|
QTY float64 `json:"qty" xorm:"'QTY'"` // 数量
|
|
|
APPLYSTATUS int32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
|
|
|
@@ -56,7 +56,7 @@ type ErmcpAreaStockApply struct {
|
|
|
ENUMDICNAME string `json:"enumdicname"` // 现货商品单位名称
|
|
|
|
|
|
FilterStatus string `json:"-"` // 查询条件, 申请状态, 逗号隔开
|
|
|
- FilterType string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
|
|
|
+ FilterType string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
|
|
|
}
|
|
|
|
|
|
func (r *ErmcpAreaStockApply) calc() {
|
|
|
@@ -67,13 +67,13 @@ func (r *ErmcpAreaStockApply) calc() {
|
|
|
// 申请人名称
|
|
|
if r.APPLYSRC == 1 {
|
|
|
r.APPLYNAME = mtpcache.GetSystemmangerLoginCode(r.APPLYID)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
r.APPLYNAME = mtpcache.GetLoginCodeByLoginId(r.APPLYID)
|
|
|
}
|
|
|
// 审核人名称
|
|
|
if r.AUDITSRC == 1 {
|
|
|
r.AUDITNAME = mtpcache.GetSystemmangerLoginCode(r.AUDITID)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
r.AUDITNAME = mtpcache.GetLoginCodeByLoginId(r.AUDITID)
|
|
|
}
|
|
|
// 单位名称
|
|
|
@@ -170,4 +170,39 @@ func (r *ErmcpAreaStockApply) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
|
}
|
|
|
return sData, err
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+// ErmcpAreaStockApplySum 合同出入库数量汇总
|
|
|
+type ErmcpAreaStockApplySum struct {
|
|
|
+ INOUTTYPE int32 `json:"inouttype" xorm:"'INOUTTYPE'"` // 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
|
|
|
+ SPOTGOODSMODELID int32 `json:"spotgoodsmodelid" xorm:"'SPOTGOODSMODELID'"` // 型号id
|
|
|
+ SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 品牌id
|
|
|
+ BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
|
|
|
+ MODELNAME string `json:"modelname" xorm:"'MODELNAME'"` // 型号名称
|
|
|
+ TOTALQTY float64 `json:"totalqty" xorm:"'TOTALQTY'"` // 总数量
|
|
|
+ SPOTCONTRACTID string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 关联现货合同ID
|
|
|
+}
|
|
|
+
|
|
|
+func (r *ErmcpAreaStockApplySum) buildSql() string {
|
|
|
+ sqlId := "select a.*, gb.brandname, gm.modelname" +
|
|
|
+ " from (SELECT t.INOUTTYPE," +
|
|
|
+ " t.SPOTGOODSMODELID," +
|
|
|
+ " t.SPOTGOODSBRANDID," +
|
|
|
+ " sum(t.QTY) TOTALQTY" +
|
|
|
+ " FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
|
|
|
+ " WHERE t.applystatus= 2 and t.inouttype = %v and t.spotcontractid = %v" +
|
|
|
+ " group by t.inouttype, t.spotgoodsbrandid, t.spotgoodsmodelid) a" +
|
|
|
+ " left join spotgoodsbrand gb" +
|
|
|
+ " on a.spotgoodsbrandid = gb.brandid" +
|
|
|
+ " left join spotgoodsmodel gm" +
|
|
|
+ " on a.spotgoodsmodelid = gm.modelid"
|
|
|
+ sqlId = fmt.Sprintf(sqlId, r.INOUTTYPE, r.SPOTCONTRACTID)
|
|
|
+ return sqlId
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取合同出入库汇总信息
|
|
|
+func (r *ErmcpAreaStockApplySum) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]ErmcpAreaStockApplySum, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ return sData, err
|
|
|
+}
|