Sfoglia il codice sorgente

1. #94757 出入库变更表查询
2. 账号管理查询返回查询类型
3. 查现货合同返回币种id
4. 查交易登录账户过滤空记录

zou.yingbin 4 anni fa
parent
commit
e7f7c9ca9f
7 ha cambiato i file con 94 aggiunte e 40 eliminazioni
  1. 2 2
      controllers/ermcp3/qryErmcp3.go
  2. 8 0
      docs/docs.go
  3. 8 0
      docs/swagger.json
  4. 6 0
      docs/swagger.yaml
  5. 38 20
      models/ermcp3.go
  6. 25 18
      models/ermcpAccMgr.go
  7. 7 0
      utils/sqlUtils.go

+ 2 - 2
controllers/ermcp3/qryErmcp3.go

@@ -433,9 +433,9 @@ func QueryAreaStockReportDetail(c *gin.Context) {
 			WAREHOUSEINFOID: req.WAREHOUSEINFOID, BeginDate: beginDate, EndDate: endDate, APPLYSTATUS: 2}
 		// 出入库类型(可多项,逗号隔开) 1:采购入库 2:销售出库 3:生产入库 4:生产出库"
 		if req.DETAILTYPE == 1 {
-			m.FilterStatus = "1,3"
+			m.FilterType = "1,3"
 		} else if req.DETAILTYPE == 2 {
-			m.FilterStatus = "2,4"
+			m.FilterType = "2,4"
 		}
 		a.DoGetDataI(&m)
 	} else {

+ 8 - 0
docs/docs.go

@@ -13773,6 +13773,10 @@ var doc = `{
                     "description": "现货品种名称",
                     "type": "string"
                 },
+                "detailjson": {
+                    "description": "明细数据",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "现货商品单位名称",
                     "type": "string"
@@ -17140,6 +17144,10 @@ var doc = `{
         "models.ErmcpLoginUserEx": {
             "type": "object",
             "properties": {
+                "querytype": {
+                    "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
+                    "type": "integer"
+                },
                 "roleid": {
                     "description": "角色id(交易账户-\u003e用户id)",
                     "type": "integer"

+ 8 - 0
docs/swagger.json

@@ -13757,6 +13757,10 @@
                     "description": "现货品种名称",
                     "type": "string"
                 },
+                "detailjson": {
+                    "description": "明细数据",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "现货商品单位名称",
                     "type": "string"
@@ -17124,6 +17128,10 @@
         "models.ErmcpLoginUserEx": {
             "type": "object",
             "properties": {
+                "querytype": {
+                    "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
+                    "type": "integer"
+                },
                 "roleid": {
                     "description": "角色id(交易账户-\u003e用户id)",
                     "type": "integer"

+ 6 - 0
docs/swagger.yaml

@@ -3304,6 +3304,9 @@ definitions:
       deliverygoodsname:
         description: 现货品种名称
         type: string
+      detailjson:
+        description: 明细数据
+        type: string
       enumdicname:
         description: 现货商品单位名称
         type: string
@@ -5792,6 +5795,9 @@ definitions:
     type: object
   models.ErmcpLoginUserEx:
     properties:
+      querytype:
+        description: 查询类型 1-业务账户 2-交易账户 3-管理账户
+        type: integer
       roleid:
         description: 角色id(交易账户->用户id)
         type: integer

+ 38 - 20
models/ermcp3.go

@@ -7,11 +7,13 @@
 package models
 
 import (
+	"encoding/json"
 	"fmt"
 	"mtp2_if/db"
 	"mtp2_if/logger"
 	"mtp2_if/mtpcache"
 	"mtp2_if/utils"
+	"strings"
 )
 
 // ErmcpDeliveryGoods 现货品种(交割品种)
@@ -728,6 +730,7 @@ func (r *Ermcp3Contract) buildSql() string {
 		"       t.tradeuserid," +
 		"       t.saleuserid," +
 		"       t.meruserid," +
+		"       t.currencyid," +
 		"       to_char(t.accountid) accountid," +
 		"       t.biztype" +
 		"  FROM ERMCP_SPOTCONTRACT t" +
@@ -1309,7 +1312,6 @@ type Ermcp3AreaStockApply struct {
 	SPOTGOODSBRANDID  int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`   // 现货品牌ID
 	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:已撤回
 	APPLYSRC          int32   `json:"applysrc"  xorm:"'APPLYSRC'"`                   // 申请来源 - 1:管理端 2:终端
 	APPLYID           int64   `json:"applyid"  xorm:"'APPLYID'"`                     // 申请人
@@ -1333,6 +1335,7 @@ type Ermcp3AreaStockApply struct {
 	SELLUSERID        int64   `json:"selluserid"  xorm:"'SELLUSERID'"`               // 销售方userid
 	PRICETYPE         int32   `json:"pricetype"  xorm:"'PRICETYPE'"`                 // 定价类型 - 1:一口价 2:点价 3:暂定价
 	CONTRACTQTY       float64 `json:"contractqty"  xorm:"'CONTRACTQTY'"`             // 合同量
+	DETAILJSON        string  `json:"detailjson"  xorm:"'DETAILJSON'"`               // 明细数据
 	BUYUSERNAME       string  `json:"buyusername"`                                   // 采购方名称
 	SELLUSERNAME      string  `json:"sellusername"`                                  // 销售方名称
 	APPLYNAME         string  `json:"applyname"`                                     // 申请人名称
@@ -1343,6 +1346,7 @@ type Ermcp3AreaStockApply struct {
 	DELIVERYGOODSNAME string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
 	BUYNICKNAME       string  `json:"buynickname"`                                   // 采购方昵称
 	SELLNICKNAME      string  `json:"sellnickname"`                                  // 销售方昵称
+	QTY               float64 `json:"qty"`                                           // 数量
 
 	FilterStatus string `json:"-"` // 查询条件, 申请状态, 逗号隔开
 	FilterType   string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
@@ -1369,22 +1373,32 @@ func (r *Ermcp3AreaStockApply) calc() {
 	}
 	// 单位名称
 	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
+
+	if len(r.DETAILJSON) > 0 {
+		// 解析qty字段
+		req := struct {
+			QTY float64 `json:"qty"` // 数量
+		}{}
+		if json.Unmarshal([]byte(r.DETAILJSON), &req) == nil {
+			r.QTY = req.QTY
+		}
+	}
 }
 
 func (r *Ermcp3AreaStockApply) buildSql() string {
-	var sqlId utils.SQLVal = "SELECT to_char(t.INOUTAPPLYID) INOUTAPPLYID," +
+	var sqlId utils.SQLVal = "SELECT to_char(t.operateapplyid) INOUTAPPLYID," +
 		"       t.USERID," +
-		"       t.INOUTTYPE," +
+		"       t.operateapplytype INOUTTYPE," +
 		"       t.WRSTANDARDID," +
 		"       t.SPOTGOODSBRANDID," +
 		"       t.DELIVERYGOODSID," +
-		"       to_char(t.SPOTCONTRACTID) SPOTCONTRACTID," +
+		"       to_char(t.relatedid) SPOTCONTRACTID," +
 		"       to_char(t.WAREHOUSEINFOID) WAREHOUSEINFOID," +
-		"       t.QTY," +
+		"       to_char(t.detailjson) detailjson," +
 		"       t.APPLYSTATUS," +
 		"       t.APPLYSRC," +
 		"       t.APPLYID," +
-		"       t.APPLYREMARK," +
+		"       t.remark APPLYREMARK," +
 		"       to_char(t.APPLYTIME, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME," +
 		"       t.AUDITSRC," +
 		"       t.AUDITID," +
@@ -1406,7 +1420,7 @@ func (r *Ermcp3AreaStockApply) buildSql() string {
 		"       s.qty CONTRACTQTY," +
 		"       g.deliverygoodscode," +
 		"       g.deliverygoodsname" +
-		"  FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
+		"  FROM ermcp_contractoperateapply t" +
 		"  left join wrstandard w" +
 		"    on t.wrstandardid = w.wrstandardid" +
 		"  left join dgfactoryitem gb" +
@@ -1416,14 +1430,13 @@ func (r *Ermcp3AreaStockApply) buildSql() string {
 		"  left join warehouseinfo h" +
 		"    on t.warehouseinfoid = h.autoid" +
 		"  left join ermcp_spotcontract s" +
-		"    on t.spotcontractid = s.spotcontractid" +
-		" WHERE 1 = 1"
+		"    on t.relatedid = s.spotcontractid" +
+		" WHERE t.operateapplytype in(5,6,7,8)"
 	// 用户id(必要条件)
 	sqlId.And("t.USERID", r.USERID)
 	// 合同id
-	if len(r.SPOTCONTRACTID) > 0 {
-		sqlId.And("t.SPOTCONTRACTID", r.SPOTCONTRACTID)
-	}
+	sqlId.AndInterEx("t.RELATEDID", r.SPOTCONTRACTID, len(r.SPOTCONTRACTID) > 0)
+
 	// 现货品种id
 	if r.DELIVERYGOODSID > 0 {
 		sqlId.And("t.DELIVERYGOODSID", r.DELIVERYGOODSID)
@@ -1437,24 +1450,29 @@ func (r *Ermcp3AreaStockApply) buildSql() string {
 		sqlId.And("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID)
 	}
 	// 仓库id
-	if len(r.WAREHOUSEINFOID) > 0 {
-		sqlId.And("t.WAREHOUSEINFOID", r.WAREHOUSEINFOID)
-	}
+	sqlId.AndInterEx("t.WAREHOUSEINFOID", r.WAREHOUSEINFOID, len(r.WAREHOUSEINFOID) > 0)
 	// 日期范围
 	if len(r.BeginDate) > 0 {
 		if r.BeginDate == r.EndDate {
-			sqlId.And("t.audittradedate", r.BeginDate)
+			sqlId.And("t.tradedate", r.BeginDate)
 		} else if r.EndDate > r.BeginDate {
-			sqlId.BiggerOrEq("t.audittradedate", r.BeginDate)
-			sqlId.LessOrEq("t.audittradedate", r.EndDate)
+			sqlId.BiggerOrEq("t.tradedate", r.BeginDate)
+			sqlId.LessOrEq("t.tradedate", r.EndDate)
 		}
 	}
 	// 出入库类型
 	if len(r.FilterType) > 0 {
+
+		// 原INOUTTYPE 1,2,3,4 转为 新表 5,6,7,8
+		r.FilterType = strings.ReplaceAll(r.FilterType, "1", "5")
+		r.FilterType = strings.ReplaceAll(r.FilterType, "2", "6")
+		r.FilterType = strings.ReplaceAll(r.FilterType, "3", "7")
+		r.FilterType = strings.ReplaceAll(r.FilterType, "4", "8")
+
 		if len(r.FilterType) == 1 {
-			sqlId.And("t.INOUTTYPE", r.FilterType)
+			sqlId.AndInterEx("t.OPERATEAPPLYTYPE", r.FilterType, true)
 		} else {
-			sqlId.Join(fmt.Sprintf(" and t.INOUTTYPE in(%v)", r.FilterType))
+			sqlId.Join(fmt.Sprintf(" and t.OPERATEAPPLYTYPE in(%v)", r.FilterType))
 		}
 	}
 	// 出入库状态

+ 25 - 18
models/ermcpAccMgr.go

@@ -17,10 +17,11 @@ import (
 
 // ErmcpLoginUserEx 登录账号(按角色)
 type ErmcpLoginUserEx struct {
-	ROLENAME string           `json:"rolename"` // 角色名称(交易账户->用户名称)
-	USERTYPE int32            `json:"usertype"` // 用户类型 2-机构 7-企业成员(云平台)
-	UserList []ErmcpLoginUser `json:"userlist"` // 用户列表
-	RoleId   int64            `json:"roleid"`   // 角色id(交易账户->用户id)
+	ROLENAME  string           `json:"rolename"`  // 角色名称(交易账户->用户名称)
+	USERTYPE  int32            `json:"usertype"`  // 用户类型 2-机构 7-企业成员(云平台)
+	UserList  []ErmcpLoginUser `json:"userlist"`  // 用户列表
+	RoleId    int64            `json:"roleid"`    // 角色id(交易账户->用户id)
+	QUERYTYPE int32            `json:"querytype"` // 查询类型 1-业务账户 2-交易账户 3-管理账户
 }
 
 // ErmcpLoginUser 查询登录账户
@@ -190,15 +191,17 @@ func (r *ErmcpLoginUser) hasRoletype(nType int32) bool {
 func (r *ErmcpLoginUser) getBizLoginAcc() ([]ErmcpLoginUserEx, error) {
 	sDataEx := make([]ErmcpLoginUserEx, 0)
 	sDataEx = append(sDataEx, ErmcpLoginUserEx{
-		ROLENAME: "业务员",
-		RoleId:   22,
-		UserList: make([]ErmcpLoginUser, 0),
-		USERTYPE: 7})
+		ROLENAME:  "业务员",
+		RoleId:    22,
+		UserList:  make([]ErmcpLoginUser, 0),
+		USERTYPE:  7,
+		QUERYTYPE: r.QueryType})
 	sDataEx = append(sDataEx, ErmcpLoginUserEx{
-		ROLENAME: "跟单员",
-		RoleId:   23,
-		UserList: make([]ErmcpLoginUser, 0),
-		USERTYPE: 7})
+		ROLENAME:  "跟单员",
+		RoleId:    23,
+		UserList:  make([]ErmcpLoginUser, 0),
+		USERTYPE:  7,
+		QUERYTYPE: r.QueryType})
 	// 查询用户
 	sData := make([]ErmcpLoginUser, 0)
 	err := db.GetEngine().SQL(r.buildSqlRoleAcc()).Find(&sData)
@@ -264,8 +267,11 @@ func (r *ErmcpLoginUser) getTradeLoginAcc() ([]ErmcpLoginUserEx, error) {
 				}
 			}
 			if !bExist {
-				val := ErmcpLoginUserEx{RoleId: v.USERID, ROLENAME: v.ACCOUNTNAME, USERTYPE: 7, UserList: make([]ErmcpLoginUser, 0)}
-				val.UserList = append(val.UserList, v)
+				val := ErmcpLoginUserEx{RoleId: v.USERID, ROLENAME: v.ACCOUNTNAME, USERTYPE: 7,
+					UserList: make([]ErmcpLoginUser, 0), QUERYTYPE: r.QueryType}
+				if v.LOGINID > 0 {
+					val.UserList = append(val.UserList, v)
+				}
 				sDataEx = append(sDataEx, val)
 			}
 		}
@@ -286,10 +292,11 @@ func (r *ErmcpLoginUser) getMangeLoginAcc() ([]ErmcpLoginUserEx, error) {
 	// 初始化角色列表
 	for _, val := range roles {
 		sDataEx = append(sDataEx, ErmcpLoginUserEx{
-			ROLENAME: val.ROLENAME,
-			RoleId:   int64(val.AUTOID),
-			UserList: make([]ErmcpLoginUser, 0),
-			USERTYPE: 2,
+			ROLENAME:  val.ROLENAME,
+			RoleId:    int64(val.AUTOID),
+			UserList:  make([]ErmcpLoginUser, 0),
+			USERTYPE:  2,
+			QUERYTYPE: r.QueryType,
 		})
 	}
 	// 查询用户

+ 7 - 0
utils/sqlUtils.go

@@ -40,6 +40,13 @@ func (r *SQLVal) AndEx(fieldName string, val interface{}, bAdd bool) {
 	}
 }
 
+// 类似 AndEx, 但是不会为string类型加单引号
+func (r *SQLVal) AndInterEx(fieldName string, val interface{}, bAdd bool) {
+	if bAdd {
+		*r = *r + SQLVal(fmt.Sprintf(" and %v = %v", fieldName, val))
+	}
+}
+
 // Bigger 大于
 func (r *SQLVal) Bigger(fieldName string, val interface{}) {
 	*r = *r + SQLVal(fmt.Sprintf(" and %v > %v", fieldName, val))