caipin 2 vuotta sitten
vanhempi
commit
e904f55f36
6 muutettua tiedostoa jossa 62 lisäystä ja 17 poistoa
  1. 10 0
      dao/contract_dao.go
  2. 10 0
      dao/tree_contract_dao.go
  3. 25 4
      services/jl_service.go
  4. 12 13
      web/external/jl_bb.go
  5. 1 0
      web/routes/routes.go
  6. 4 0
      web/viewmodels/jl.go

+ 10 - 0
dao/contract_dao.go

@@ -52,6 +52,16 @@ func (d *ContractDao) GetByCode(projectId int, bidsectionId int, code string, co
 	return datalist
 }
 
+// 根据项目ID和表单ID数组获得数据
+func (d *ContractDao) GetByProjectIdInBidsectionId(bids string, projectId int) []models.CmContracts {
+	datalist := make([]models.CmContracts, 0)
+	d.engine.
+		Asc("id").
+		Where(" project_id=? and bidsection_id IN ("+bids+")", projectId).
+		Find(&datalist)
+	return datalist
+}
+
 // 获得本项目的合同项目节
 func (d *ContractDao) GetType(bidsectionId int, projectId int, contractsType int) []models.CmContracts {
 

+ 10 - 0
dao/tree_contract_dao.go

@@ -59,6 +59,16 @@ func (d *TreeContractDao) GetAll(bidsectionId int, projectId int, treeType int)
 	}
 }
 
+// 根据项目ID和表单ID数组获得数据
+func (d *TreeContractDao) GetByProjectIdInBidsectionId(bids string, projectId int) []models.CmTreeContracts {
+	datalist := make([]models.CmTreeContracts, 0)
+	d.engine.
+		Asc("id").
+		Where(" project_id=? and bidsection_id IN ("+bids+")", projectId).
+		Find(&datalist)
+	return datalist
+}
+
 // 获得项目下的项目节不包含合同
 func (d *TreeContractDao) GetAllNotContract(bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
 

+ 25 - 4
services/jl_service.go

@@ -13,6 +13,7 @@ import (
 	"net/http"
 	"net/url"
 	"strconv"
+	"strings"
 	"time"
 
 	"github.com/dgrijalva/jwt-go"
@@ -27,18 +28,38 @@ import (
 )
 
 type JlService struct {
-	dao        *dao.ProjectDao
-	accountDao *dao.ProjectAccountDao
+	dao             *dao.ProjectDao
+	accountDao      *dao.ProjectAccountDao
+	treeContractDao *dao.TreeContractDao
+	contractDao     *dao.ContractDao
 }
 
 // 创建项目用户service
 func NewJlService() *JlService {
 	return &JlService{
-		dao:        dao.NewProjectDao(datasource.InstanceDbMaster()),
-		accountDao: dao.NewProjectAccountDao(datasource.InstanceDbMaster()),
+		dao:             dao.NewProjectDao(datasource.InstanceDbMaster()),
+		accountDao:      dao.NewProjectAccountDao(datasource.InstanceDbMaster()),
+		treeContractDao: dao.NewTreeContractDao(datasource.InstanceDbMaster()),
+		contractDao:     dao.NewContractDao(datasource.InstanceDbMaster()),
 	}
 }
 
+// 根据表名获得相关数据
+func (s *JlService) GetTableInfo(data *viewmodels.Jl, projectId int) map[string]interface{} {
+	bids := strings.Replace(strings.Trim(fmt.Sprint(data.BidsectionId), "[]"), " ", ",", -1)
+	result := map[string]interface{}{}
+
+	for _, v := range data.Key {
+		// 获得标段下,合同树
+		if v == "treeContracts" {
+			result["treeContracts"] = s.treeContractDao.GetByProjectIdInBidsectionId(bids, projectId)
+		} else if v == "contracts" {
+			result["contracts"] = s.contractDao.GetByProjectIdInBidsectionId(bids, projectId)
+		}
+	}
+	return result
+}
+
 // 是否有项目
 func (s *JlService) IsCode(code string) map[string]interface{} {
 	exist := 0

+ 12 - 13
web/external/jl_bb.go

@@ -10,9 +10,10 @@ import (
 )
 
 type JlBb struct {
-	Ctx            iris.Context
-	ServiceTree    services.TreeService
-	ServiceProject services.ProjectService
+	Ctx             iris.Context
+	ServiceTree     services.TreeService
+	ServiceProject  services.ProjectService
+	ServiceContract services.ContractService
 }
 
 // @Summary 获得合同目录和标段
@@ -75,7 +76,7 @@ func (c *JlBb) GetFolder() {
 // @Param   key     path    string     true        "是一个数组,里面代表的名称"
 // @Success 200 {object} viewmodels.FolderContract "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Router /api/contract/folder [get]
-func (c *JlBb) GetFolder2() {
+func (c *JlBb) GetContract() {
 
 	// 1.获得数据
 	data := &viewmodels.Jl{}
@@ -84,13 +85,8 @@ func (c *JlBb) GetFolder2() {
 		return
 	}
 
-	// 1-1.校验是否存在code
-	if err := data.ValidateCodeAToken(); err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
 	// 1-2.验证jwt
-	_, err := utils.ValidateJwt(data.Token)
+	err := utils.ValidateJwtBB(data.Token)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
@@ -106,12 +102,15 @@ func (c *JlBb) GetFolder2() {
 		return
 	}
 
-	// 获得层级文件夹
-	FolderData := c.ServiceTree.GetAllContractByJL(projectDetail.Id)
+	data.BidsectionId = []string{"57", "58"}
+	data.Key = []string{"treeContracts", "contracts"}
+
+	JlService := services.NewJlService()
+	result := JlService.GetTableInfo(data, projectDetail.Id)
 
 	c.Ctx.JSON(iris.Map{
 		"code": 0,
 		"msg":  "",
-		"data": FolderData,
+		"data": result,
 	})
 }

+ 1 - 0
web/routes/routes.go

@@ -234,6 +234,7 @@ func Configure(b *bootstrap.Bootstrapper) {
 	jlbb := mvc.New(b.Party("/api/external/jlbb"))
 	jlbb.Register(TreeService)
 	jlbb.Register(ProjectService)
+	jlbb.Register(ContractService)
 	jlbb.Handle(new(external.JlBb))
 
 	// 后台相关

+ 4 - 0
web/viewmodels/jl.go

@@ -18,6 +18,10 @@ type Jl struct {
 	Code       string `form:"code" json:"code" `
 	Account    string `form:"account" json:"account" `
 	NewAccount string `form:"newAccount" json:"newAccount" `
+	// 计量-报表使用
+	// 存的是表名key
+	Key          []string `form:"key" json:"key" `
+	BidsectionId []string `form:"bidsectionId" json:"bidsectionId" `
 }
 
 // 校验项目接口