Procházet zdrojové kódy

Merge branch 'master' of 192.168.30.132:MTP2.0/MTP20_IF

zhou.xiaoning před 4 roky
rodič
revize
ef4af3cb89
3 změnil soubory, kde provedl 46 přidání a 24 odebrání
  1. 22 3
      models/ermcpAreaStock.go
  2. 14 21
      models/ermcpExposure.go
  3. 10 0
      models/ermcpOPLog.go

+ 22 - 3
models/ermcpAreaStock.go

@@ -205,15 +205,34 @@ func (r *ErmcpAreaStockApplySum) buildSql() string {
 		"  from (SELECT t.INOUTTYPE," +
 		"               t.SPOTGOODSMODELID," +
 		"               t.SPOTGOODSBRANDID," +
+		"               t.SPOTCONTRACTID," +
 		"               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" +
+		"         WHERE t.applystatus= 2 and t.spotcontractid = %v" +
+		"         group by t.inouttype, t.spotgoodsbrandid, t.spotgoodsmodelid, t.spotcontractid) 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)
+	sqlId = fmt.Sprintf(sqlId, r.SPOTCONTRACTID)
+
+	// 不关联合同id
+	sqlId2 := "select a.*, gb.brandname, gm.modelname" +
+		"  from (SELECT t.INOUTTYPE," +
+		"               t.SPOTGOODSMODELID," +
+		"               t.SPOTGOODSBRANDID," +
+		"               t.SPOTCONTRACTID," +
+		"               sum(t.QTY) TOTALQTY" +
+		"          FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
+		"         WHERE t.applystatus= 2" +
+		"         group by t.inouttype, t.spotgoodsbrandid, t.spotgoodsmodelid, t.SPOTCONTRACTID) a" +
+		"  left join spotgoodsbrand gb" +
+		"    on a.spotgoodsbrandid = gb.brandid" +
+		"  left join spotgoodsmodel gm" +
+		"    on a.spotgoodsmodelid = gm.modelid"
+	if len(r.SPOTCONTRACTID) == 0 {
+		return sqlId2
+	}
 	return sqlId
 }
 

+ 14 - 21
models/ermcpExposure.go

@@ -235,8 +235,18 @@ type AreaSpotModel struct {
 
 // calc 进行相关字段的值计算
 func (r *AreaSpotModel) calc() {
-	r.IncreaseQty = r.SELLPLANQTY + r.BUYPRICEDQTY
-	r.DecreaseQty = (r.SELLPRICEDQTY + r.BUYPLANQTY) * -1
+	/*
+		增加数量=今日销售计划数量+今日采购已定价数量
+		减少数量=-(今日销售已定价数量+今日采购计划数量)
+
+		其中,
+		今日销售计划数量=期末销售计划数量-期初销售计划数量
+		今日采购已定价数量=期末采购已定价数量-期初采购已定价数量
+		今日销售已定价数量=期末销售已定价数量-期初销售已定价数量
+		今日采购计划数量=期末采购计划数量-期初采购计划数量
+	*/
+	r.IncreaseQty = r.SELLPLANQTY - r.ORISELLPLANQTY + r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
+	r.DecreaseQty = (r.SELLPRICEDQTY - r.ORISELLPRICEDQTY + r.BUYPLANQTY - r.ORIBUYPLANQTY) * -1
 	r.OriToalSpotQty = (r.ORISELLPLANQTY - r.ORISELLPRICEDQTY) - (r.ORIBUYPLANQTY - r.ORIBUYPRICEDQTY)
 }
 
@@ -751,25 +761,8 @@ func (r *ErmcpHedgePositionDetail) buildSql() string {
 		"   and ta.relateduserid = %v" +
 		"  left join goods g" +
 		"    on t.hedgegoodsid = g.goodsid" +
-		" where t.hedgegoodsid = %v" +
-		" union all " +
-		"select t.hedgegoodsid," +
-		"       t.buyorsell," +
-		"       tradeqty," +
-		"       t.channelbuildtype," +
-		"       to_char(t.tradetime, 'yyyy-mm-dd hh24:mi:ss') tradetime," +
-		"       g.goodscode," +
-		"       g.goodsname" +
-		"  from his_hedge_outtradedetail t" +
-		" inner join taaccount ta" +
-		"    on t.accountid = ta.accountid" +
-		"   and ta.ismain = 1" +
-		"   and ta.relateduserid = %v" +
-		"  left join goods g" +
-		"    on t.hedgegoodsid = g.goodsid" +
-		" where t.isvalid = 1" +
-		"   and t.hedgegoodsid = %v"
-	sqlId = fmt.Sprintf(sqlId, r.AREAUSERID, r.HEDGEGOODSID, r.AREAUSERID, r.HEDGEGOODSID)
+		" where t.hedgegoodsid = %v"
+	sqlId = fmt.Sprintf(sqlId, r.AREAUSERID, r.HEDGEGOODSID)
 	return sqlId
 }
 

+ 10 - 0
models/ermcpOPLog.go

@@ -9,6 +9,8 @@ package models
 import (
 	"fmt"
 	"mtp2_if/db"
+	"mtp2_if/mtpcache"
+	"strconv"
 )
 
 // ErmcpOPLogModel 变更变记录
@@ -26,6 +28,13 @@ type ErmcpOPLogModel struct {
 	APPLYNAME          string  `json:"applyname" xorm:"'APPLYNAME'"`            // 操作人名称
 }
 
+func (r *ErmcpOPLogModel) calc() {
+	if r.APPLYNAME == "" {
+		id, _ := strconv.ParseInt(r.APPLYID, 10, 64)
+		r.APPLYNAME = mtpcache.GetSystemmangerLoginCode(id)
+	}
+}
+
 func (r *ErmcpOPLogModel) decodeOperateLogType() {
 	//1:点价价格 2:点价数量 3:结算量 4:其它费用 5:追加保证金 6溢短金额 7:调整金额 8:付款金额 9:收款金额 10:退款金额
 	//11:收票金额 12:开票金额 13:提交审核(合同) 14:审核通过(合同) 15:审核拒绝(合同) 16:合同撤回 17:提交审核(计划)
@@ -67,6 +76,7 @@ func (r *ErmcpOPLogModel) GetData() ([]ErmcpOPLogModel, error) {
 	// 类型解析成中文
 	for i := range sData {
 		sData[i].decodeOperateLogType()
+		sData[i].calc()
 	}
 	return sData, nil
 }