Przeglądaj źródła

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

zhou.xiaoning 5 lat temu
rodzic
commit
1d375c8b0a
5 zmienionych plików z 28 dodań i 23 usunięć
  1. 9 4
      controllers/erms3/qryContract.go
  2. 3 3
      docs/docs.go
  3. 3 3
      docs/swagger.json
  4. 3 3
      docs/swagger.yaml
  5. 10 10
      models/contractModel.go

+ 9 - 4
controllers/erms3/qryContract.go

@@ -100,7 +100,7 @@ type DetailJSON struct {
 
 // 查询待审核合同请求
 type QryAuditContractReq struct {
-	AccountId    uint64 `form:"accountid" binding:"required"`    // 请求账号ID
+	AccountIDs   string `form:"accountids" binding:"required"`    // 请求账号ID列表
 	ContractType int32  `form:"contracttype" binding:"required"` // 合同类型
 	ContractMode uint32 `form:"contractmode" binding:"required"` // 合同模式
 }
@@ -241,7 +241,7 @@ func (r *QryAuditContractRsp) ParseFromHGModel(val models.AutditContractHGModel)
 // @Summary 查询待审核合同
 // @Produce json
 // @Security ApiKeyAuth
-// @Param accountid query int true "账号ID"
+// @Param accountids query string true "资金账号ID列表,逗号隔开"
 // @Param contracttype query int true "合同类型 1-采购 -1-销售"
 // @Param contractmode query int true "合同模式 1-普通 2-回购"
 // @Success 200 {array} QryAuditContractRsp
@@ -272,10 +272,15 @@ func QueryPendingAuditContract(c *gin.Context) {
 		}
 	}
 
+	// 去除最后的逗号
+	if len(req.AccountIDs) > 0 && req.AccountIDs[len(req.AccountIDs)-1] == ',' {
+		req.AccountIDs = req.AccountIDs[0 : len(req.AccountIDs)-1]
+	}
+
 	switch req.ContractMode {
 	case 1: // 普通合同
 		var m models.AuditContractModel
-		if d, err := m.GetData(req.AccountId, req.ContractType); err == nil {
+		if d, err := m.GetData(req.AccountIDs, req.ContractType); err == nil {
 			rsp := make([]QryAuditContractRsp, 0)
 			for _, v := range d {
 				var rv QryAuditContractRsp
@@ -290,7 +295,7 @@ func QueryPendingAuditContract(c *gin.Context) {
 		}
 	case 2: // 回购合同
 		var m models.AutditContractHGModel
-		if d, err := m.GetData(req.AccountId); err == nil {
+		if d, err := m.GetData(req.AccountIDs); err == nil {
 			rsp := make([]QryAuditContractRsp, 0)
 			for _, v := range d {
 				var rv QryAuditContractRsp

+ 3 - 3
docs/docs.go

@@ -961,9 +961,9 @@ var doc = `{
                 "summary": "查询待审核合同",
                 "parameters": [
                     {
-                        "type": "integer",
-                        "description": "账号ID",
-                        "name": "accountid",
+                        "type": "string",
+                        "description": "资金账号ID列表,逗号隔开",
+                        "name": "accountids",
                         "in": "query",
                         "required": true
                     },

+ 3 - 3
docs/swagger.json

@@ -945,9 +945,9 @@
                 "summary": "查询待审核合同",
                 "parameters": [
                     {
-                        "type": "integer",
-                        "description": "账号ID",
-                        "name": "accountid",
+                        "type": "string",
+                        "description": "资金账号ID列表,逗号隔开",
+                        "name": "accountids",
                         "in": "query",
                         "required": true
                     },

+ 3 - 3
docs/swagger.yaml

@@ -5232,11 +5232,11 @@ paths:
   /Erms3/QueryPendingAuditContract:
     get:
       parameters:
-      - description: 账号ID
+      - description: 资金账号ID列表,逗号隔开
         in: query
-        name: accountid
+        name: accountids
         required: true
-        type: integer
+        type: string
       - description: 合同类型 1-采购 -1-销售
         in: query
         name: contracttype

+ 10 - 10
models/contractModel.go

@@ -26,7 +26,7 @@ type AuditContractModel struct {
 }
 
 // 组装查询普通待审核合同Sql
-func (r *AuditContractModel) buildSql(accountId uint64, contractType int32) string {
+func (r *AuditContractModel) buildSql(accountIDs string, contractType int32) string {
 	str := "select to_char(s.spotcontractid) spotcontractid," +
 		"       u.customername," +
 		"       s.accountid," +
@@ -42,16 +42,16 @@ func (r *AuditContractModel) buildSql(accountId uint64, contractType int32) stri
 		"    on u2.userid = s.customeruserid" +
 		" where s.contracttype = %v" +
 		"   and s.applystatus in(0,2)" +
-		"   and s.accountid = %v"
+		"   and s.accountid in(%v)"
 
-	return fmt.Sprintf(str, contractType, accountId)
+	return fmt.Sprintf(str, contractType, accountIDs)
 }
 
 // 获取待审核的合同
-func (r *AuditContractModel) GetData(accountId uint64, contractType int32) ([]AuditContractModel, error) {
+func (r *AuditContractModel) GetData(accountIDs string, contractType int32) ([]AuditContractModel, error) {
 	sAC := make([]AuditContractModel, 0)
 	e := db.GetEngine()
-	s := e.SQL(r.buildSql(accountId, contractType))
+	s := e.SQL(r.buildSql(accountIDs, contractType))
 	if err := s.Find(&sAC); err != nil {
 		logger.GetLogger().Errorf("query pending contract fail:%v", err)
 		return sAC, err
@@ -74,7 +74,7 @@ type AutditContractHGModel struct {
 	SignDate          string `json:"signdate"  xorm:"'SIGNDATE'"`                                      // 签订日期
 }
 
-func (r *AutditContractHGModel) buildSql(accountId uint64) string {
+func (r *AutditContractHGModel) buildSql(accountIDs string) string {
 	sqlId := "select to_char(t.wrrcontractid) spotcontractid," +
 		"       t.accountid," +
 		"       t.contractqty," +
@@ -96,16 +96,16 @@ func (r *AutditContractHGModel) buildSql(accountId uint64) string {
 		"  left join enumdicitem ec" +
 		"    on w.unitid = ec.enumitemname" +
 		"   and ec.enumdiccode = 'goodsunit'" +
-		" where t.accountid = %v" +
+		" where t.accountid in(%v)" +
 		"   and t.applystatus in (0, 2)"
 
-	return fmt.Sprintf(sqlId, accountId)
+	return fmt.Sprintf(sqlId, accountIDs)
 }
 
-func (r *AutditContractHGModel) GetData(accountId uint64) ([]AutditContractHGModel, error) {
+func (r *AutditContractHGModel) GetData(accountIDs string) ([]AutditContractHGModel, error) {
 	sAC := make([]AutditContractHGModel, 0)
 	e := db.GetEngine()
-	s := e.SQL(r.buildSql(accountId))
+	s := e.SQL(r.buildSql(accountIDs))
 	if err := s.Find(&sAC); err != nil{
 		logger.GetLogger().Errorf("query hg pending contract fail:%v", err)
 		return sAC, err