|
@@ -33,6 +33,7 @@ type TreeService interface {
|
|
|
Create(data viewmodels.Tree) error
|
|
|
GetAllProject(projectId int) *viewmodels.Tree
|
|
|
GetAllContract(projectId int, account *models.CmProjectAccount, bidsectionType int) *viewmodels.FolderContract
|
|
|
+ GetAllContractByJL(projectId int) *viewmodels.FolderContract
|
|
|
Rename(treevm viewmodels.Tree, projectId int) error
|
|
|
GetFolderAndBid(id int, projectId int) ([]models.CmTree, error)
|
|
|
DeleteFolderAndBid(id int, projectId int) error
|
|
@@ -620,6 +621,129 @@ func (s *treeService) Move(id int, moveId int, projectId int) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+// 获得合同管理的目录
|
|
|
+func (s *treeService) GetAllContractByJL(projectId int) *viewmodels.FolderContract {
|
|
|
+ datalist := s.dao.GetAllTree(projectId)
|
|
|
+ folderlist := make([]viewmodels.FolderContract, 0)
|
|
|
+
|
|
|
+ // 生成根
|
|
|
+ folder := viewmodels.FolderContract{}
|
|
|
+ id, _ := comm.AesEncrypt(strconv.Itoa(0), conf.SignSecret)
|
|
|
+ parentId, _ := comm.AesEncrypt(strconv.Itoa(-1), conf.SignSecret)
|
|
|
+ folder.Id = id
|
|
|
+ folder.Name = "root"
|
|
|
+ folder.ParentId = parentId
|
|
|
+ folder.Isfolder = 1
|
|
|
+ // folder.Children = make([]*viewmodels.FolderContract, 0)
|
|
|
+ folderlist = append(folderlist, folder)
|
|
|
+ // 加入数据
|
|
|
+ for _, data := range datalist {
|
|
|
+
|
|
|
+ folder := viewmodels.FolderContract{}
|
|
|
+ id, _ := comm.AesEncrypt(strconv.Itoa(data.Id), conf.SignSecret)
|
|
|
+ parentId, _ := comm.AesEncrypt(strconv.Itoa(data.ParentId), conf.SignSecret)
|
|
|
+ projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret)
|
|
|
+ bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret)
|
|
|
+ folder.Id = id
|
|
|
+ folder.Name = data.Name
|
|
|
+ folder.ParentId = parentId
|
|
|
+ folder.ProjectId = projectId
|
|
|
+ folder.BidsectionId = bidsectionId
|
|
|
+ // 合同数据
|
|
|
+ folder.Contracts = data.Contracts
|
|
|
+
|
|
|
+ contractsIncome, _ := strconv.ParseFloat(data.ContractsIncome, 64)
|
|
|
+ contractsReturned, _ := strconv.ParseFloat(data.ContractsReturned, 64)
|
|
|
+
|
|
|
+ folder.ContractsIncome = utils.PriceToStringFormat(contractsIncome)
|
|
|
+ folder.ContractsReturned = utils.PriceToStringFormat(contractsReturned)
|
|
|
+
|
|
|
+ // 汇款进度
|
|
|
+ ContractsIncome, err := strconv.ParseFloat(data.ContractsIncome, 64)
|
|
|
+ if err != nil {
|
|
|
+ ContractsIncome = 0
|
|
|
+ }
|
|
|
+ ContractsReturned, err := strconv.ParseFloat(data.ContractsReturned, 64)
|
|
|
+ if err != nil || ContractsReturned == 0 {
|
|
|
+ ContractsReturned = 0
|
|
|
+ folder.ContractsIncomeProgress = "0"
|
|
|
+ } else {
|
|
|
+ folder.ContractsIncomeProgress = fmt.Sprintf("%.2f", (ContractsReturned/ContractsIncome)*100)
|
|
|
+ }
|
|
|
+
|
|
|
+ contractsPay, _ := strconv.ParseFloat(data.ContractsPay, 64)
|
|
|
+ contractsPaid, _ := strconv.ParseFloat(data.ContractsPaid, 64)
|
|
|
+
|
|
|
+ folder.ContractsPay = utils.PriceToStringFormat(contractsPay)
|
|
|
+ folder.ContractsPaid = utils.PriceToStringFormat(contractsPaid)
|
|
|
+ // 支付进度
|
|
|
+ ContractsPay, err := strconv.ParseFloat(data.ContractsPay, 64)
|
|
|
+ if err != nil {
|
|
|
+ ContractsPay = 0
|
|
|
+ }
|
|
|
+ ContractsPaid, err := strconv.ParseFloat(data.ContractsPaid, 64)
|
|
|
+ if err != nil || ContractsPaid == 0 {
|
|
|
+ ContractsPaid = 0
|
|
|
+ folder.ContractsPayProgress = "0"
|
|
|
+ } else {
|
|
|
+ folder.ContractsPayProgress = fmt.Sprintf("%.2f", (ContractsPaid/ContractsPay)*100)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 安全
|
|
|
+ folder.SafeTotal = data.SafeTotal
|
|
|
+ folder.SafeRectification = data.SafeRectification
|
|
|
+ folder.SafeRectificationFinish = data.SafeRectificationFinish
|
|
|
+ folder.SafeRectificationIn = data.SafeRectificationIn
|
|
|
+ folder.SafeApproval = data.SafeApproval
|
|
|
+ folder.SafeClose = data.SafeClose
|
|
|
+
|
|
|
+ // 质量
|
|
|
+ folder.QualityTotal = data.QualityTotal
|
|
|
+ folder.QualityApproval = data.QualityApproval
|
|
|
+ folder.QualityRectification = data.QualityRectification
|
|
|
+ folder.QualityRectificationFinish = data.QualityRectificationFinish
|
|
|
+ folder.QualityRectificationIn = data.QualityRectificationIn
|
|
|
+ folder.QualityClose = data.QualityClose
|
|
|
+
|
|
|
+ folder.Isfolder = data.Isfolder
|
|
|
+ folder.IsEnd = false
|
|
|
+
|
|
|
+ folder.HasFolder = false
|
|
|
+ folder.IsBid = false
|
|
|
+ folderlist = append(folderlist, folder)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var data []*viewmodels.FolderContract
|
|
|
+ data = make([]*viewmodels.FolderContract, 0)
|
|
|
+ for i, _ := range folderlist {
|
|
|
+ var a *viewmodels.FolderContract
|
|
|
+ a = &folderlist[i]
|
|
|
+ data = append(data, a)
|
|
|
+ }
|
|
|
+
|
|
|
+ node := &folderlist[0] //父节点
|
|
|
+ comm.MakeFolderContract(data, node)
|
|
|
+
|
|
|
+ // 求和
|
|
|
+ // dataLenght := len(data) + 4
|
|
|
+
|
|
|
+ s.filterFolder(node)
|
|
|
+
|
|
|
+ // 删除空目录
|
|
|
+ ChildrenShow := make([]*viewmodels.FolderContract, 0)
|
|
|
+ for _, item := range node.Children {
|
|
|
+ if item.IsHidden == 0 {
|
|
|
+ ChildrenShow = append(ChildrenShow, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ node.Children = ChildrenShow
|
|
|
+
|
|
|
+ // node.Children = s.copyShowFolder(node.Children)
|
|
|
+ // fmt.Println(node)
|
|
|
+ return node
|
|
|
+}
|
|
|
+
|
|
|
// 创建一颗树...interface{}
|
|
|
func maketree(Data []*viewmodels.Tree, node *viewmodels.Tree) { //参数为父节点,添加父节点的子节点指针切片
|
|
|
childs, _ := havechild(Data, node) //判断节点是否有子节点并返回
|