Ver Fonte

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

zhou.xiaoning há 4 anos atrás
pai
commit
ebe3db355f

+ 6 - 2
controllers/ermcp/qryAccMgr.go

@@ -48,7 +48,9 @@ func QueryAccMgrLoginUser(c *gin.Context) {
 // @Tags 企业风险管理(app)
 func QueryAccMgrTaaccount(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
-	req := QryLoginUserReq{}
+	req := struct {
+		UserId int64 `form:"userid" binding:"required"` // 用户id
+	}{}
 	a.DoBindReq(&req)
 	m := models.ErmcpTaAccount{USERID: req.UserId}
 	a.DoGetDataI(&m)
@@ -89,7 +91,9 @@ func QueryAccMgrMainAccountInfo(c *gin.Context) {
 // @Tags 企业风险管理(app)
 func QueryAccMgrRole(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
-	req := QryLoginUserReq{}
+	req := struct {
+		UserId int64 `form:"userid" binding:"required"` // 用户id
+	}{}
 	a.DoBindReq(&req)
 	m := models.ErmcpRole{AREAUSERID: req.UserId}
 	a.DoGetDataI(&m)

+ 3 - 3
controllers/ermcp3/qryErmcp3.go

@@ -29,7 +29,7 @@ func QueryDeliveryGoods(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	req := struct {
 		AreaUserId int64 `form:"areauserid" binding:"required"` // 所属机构id
-		ExcludeCfg int32 `form:"excludecfg"`                    // 排除已配置的商品
+		ExcludeCfg int32 `form:"excludecfg"`                    // 排除已配置的业务类型商品 1-套保 2-套利
 	}{}
 	a.DoBindReq(&req)
 	m := models.ErmcpDeliveryGoods{AREAUSERID: req.AreaUserId, ExcludeCfg: req.ExcludeCfg}
@@ -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 {

+ 12 - 0
docs/docs.go

@@ -13773,6 +13773,10 @@ var doc = `{
                     "description": "现货品种名称",
                     "type": "string"
                 },
+                "detailjson": {
+                    "description": "明细数据",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "现货商品单位名称",
                     "type": "string"
@@ -17091,6 +17095,10 @@ var doc = `{
                     "description": "登录id(LOGINID)",
                     "type": "integer"
                 },
+                "loginname": {
+                    "description": "登录名称(loginaccount表中的accountname字段)",
+                    "type": "string"
+                },
                 "loginstatus": {
                     "description": "登录账户状态 - 1:正常 2:冻结 3:无效",
                     "type": "integer"
@@ -17136,6 +17144,10 @@ var doc = `{
         "models.ErmcpLoginUserEx": {
             "type": "object",
             "properties": {
+                "querytype": {
+                    "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
+                    "type": "integer"
+                },
                 "roleid": {
                     "description": "角色id(交易账户-\u003e用户id)",
                     "type": "integer"

+ 12 - 0
docs/swagger.json

@@ -13757,6 +13757,10 @@
                     "description": "现货品种名称",
                     "type": "string"
                 },
+                "detailjson": {
+                    "description": "明细数据",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "现货商品单位名称",
                     "type": "string"
@@ -17075,6 +17079,10 @@
                     "description": "登录id(LOGINID)",
                     "type": "integer"
                 },
+                "loginname": {
+                    "description": "登录名称(loginaccount表中的accountname字段)",
+                    "type": "string"
+                },
                 "loginstatus": {
                     "description": "登录账户状态 - 1:正常 2:冻结 3:无效",
                     "type": "integer"
@@ -17120,6 +17128,10 @@
         "models.ErmcpLoginUserEx": {
             "type": "object",
             "properties": {
+                "querytype": {
+                    "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
+                    "type": "integer"
+                },
                 "roleid": {
                     "description": "角色id(交易账户-\u003e用户id)",
                     "type": "integer"

+ 9 - 0
docs/swagger.yaml

@@ -3304,6 +3304,9 @@ definitions:
       deliverygoodsname:
         description: 现货品种名称
         type: string
+      detailjson:
+        description: 明细数据
+        type: string
       enumdicname:
         description: 现货商品单位名称
         type: string
@@ -5756,6 +5759,9 @@ definitions:
       loginid:
         description: 登录id(LOGINID)
         type: integer
+      loginname:
+        description: 登录名称(loginaccount表中的accountname字段)
+        type: string
       loginstatus:
         description: 登录账户状态 - 1:正常 2:冻结 3:无效
         type: integer
@@ -5789,6 +5795,9 @@ definitions:
     type: object
   models.ErmcpLoginUserEx:
     properties:
+      querytype:
+        description: 查询类型 1-业务账户 2-交易账户 3-管理账户
+        type: integer
       roleid:
         description: 角色id(交易账户->用户id)
         type: integer

+ 41 - 23
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 现货品种(交割品种)
@@ -33,7 +35,7 @@ type ErmcpDeliveryGoods struct {
 	REMARK            string `json:"remark"  xorm:"'REMARK'"`                       // 备注
 
 	EnumdicName string `json:"enumdicname"` // 现货品种单位名称
-	ExcludeCfg  int32  `json:"-"`           // 排除已配置项 1-排除
+	ExcludeCfg  int32  `json:"-"`           // 排除已配置的业务类型商品 1-套保 2-套利
 }
 
 func (r *ErmcpDeliveryGoods) calc() {
@@ -61,8 +63,8 @@ func (r *ErmcpDeliveryGoods) buildSql() string {
 		" WHERE 1 = 1"
 	sqlId.AndEx("t.AREAUSERID", r.AREAUSERID, r.AREAUSERID > 0)
 	sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
-	if r.ExcludeCfg == 1 {
-		sqlId.Join(" and t.deliverygoodsid not in(select distinct deliverygoodsid from ermcp_bizgroupspotgoods)")
+	if r.ExcludeCfg > 0 {
+		sqlId.Join(fmt.Sprintf(" and t.deliverygoodsid not in(select distinct deliverygoodsid from ermcp_bizgroupspotgoods where biztype = %v)", r.ExcludeCfg))
 	}
 	return sqlId.String()
 }
@@ -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

@@ -36,6 +36,13 @@ func (r *SQLVal) And(fieldName string, val interface{}) {
 // 如果没有bAdd参数,外层就得写if r.areauserid > 0 {...}
 func (r *SQLVal) AndEx(fieldName string, val interface{}, bAdd bool) {
 	if bAdd {
+		r.And(fieldName, val)
+	}
+}
+
+// 类似 AndEx, 但是不会为string类型加单引号
+func (r *SQLVal) AndInterEx(fieldName string, val interface{}, bAdd bool) {
+	if bAdd {
 		*r = *r + SQLVal(fmt.Sprintf(" and %v = %v", fieldName, val))
 	}
 }