caipin 4 роки тому
батько
коміт
a9cd0ade0e

+ 26 - 4
comm/functions.go

@@ -23,6 +23,7 @@ import (
 	"strconv"
 	"strings"
 
+	"github.com/shopspring/decimal"
 	"go.mod/conf"
 	"go.mod/models"
 	"go.mod/web/viewmodels"
@@ -80,10 +81,14 @@ func MakeFolderContract(Data []*viewmodels.FolderContract, node *viewmodels.Fold
 		safeTotal := 0
 		safeTotalRectification := 0
 		safeTotalRectificationIn := 0
+		SafeTotalApproval := 0
+		SafeTotalClose := 0
 		// 1-6 质量巡检
 		qualityTotal := 0
 		qualityTotalRectification := 0
 		qualityTotalRectificationIn := 0
+		QualityTotalApproval := 0
+		QualityTotalClose := 0
 
 		for _, v := range childs { //查询子节点的子节点,并添加到子节点
 			_, has := HaveChildContract(Data, v)
@@ -99,26 +104,38 @@ func MakeFolderContract(Data []*viewmodels.FolderContract, node *viewmodels.Fold
 			}
 			// 2.标段汇总
 			// 2-1收入金额 合计
+
+			// returnDate[item.Time.Format(conf.SysTimeformMonth)], _ = decimal.NewFromFloat(returnDate[item.Time.Format(conf.SysTimeformMonth)]).Add(decimal.NewFromFloat(typePrice)).Float64()
+
 			price, _ := strconv.ParseFloat(v.ContractsIncome, 64)
-			totalIncome = totalIncome + price
+			totalIncome, _ = decimal.NewFromFloat(totalIncome).Add(decimal.NewFromFloat(price)).Float64()
 			// 2-2合同总数 合计
 			totalContractNumber = totalContractNumber + v.Contracts
 			// 2-3 汇款进度
 			price, _ = strconv.ParseFloat(v.ContractsReturned, 64)
-			totalReturn = totalReturn + price
+			totalReturn, _ = decimal.NewFromFloat(totalReturn).Add(decimal.NewFromFloat(price)).Float64()
+			// totalReturn = totalReturn + price
 			//
 			price, _ = strconv.ParseFloat(v.ContractsPay, 64)
-			totalPay = totalPay + price
+			totalPay, _ = decimal.NewFromFloat(totalPay).Add(decimal.NewFromFloat(price)).Float64()
+			// totalPay = totalPay + price
 			price, _ = strconv.ParseFloat(v.ContractsPaid, 64)
-			totalPaid = totalPaid + price
+			totalPaid, _ = decimal.NewFromFloat(totalPaid).Add(decimal.NewFromFloat(price)).Float64()
+			// totalPaid = totalPaid + price
+
 			// 安全巡检
 			safeTotal = safeTotal + v.SafeTotal
 			safeTotalRectification = safeTotalRectification + v.SafeRectification
 			safeTotalRectificationIn = safeTotalRectificationIn + v.SafeRectificationIn
+			SafeTotalApproval = SafeTotalApproval + v.SafeApproval
+			SafeTotalClose = SafeTotalClose + v.SafeClose
+
 			// 1-6 质量巡检
 			qualityTotal = safeTotal + v.QualityTotal
 			qualityTotalRectification = safeTotalRectification + v.QualityRectification
 			qualityTotalRectificationIn = safeTotalRectificationIn + v.QualityRectificationIn
+			QualityTotalApproval = QualityTotalApproval + v.QualityApproval
+			QualityTotalClose = QualityTotalClose + v.QualityClose
 		}
 
 		node.ContractsIncome = fmt.Sprintf("%G", totalIncome)
@@ -141,10 +158,15 @@ func MakeFolderContract(Data []*viewmodels.FolderContract, node *viewmodels.Fold
 		node.SafeTotal = safeTotal
 		node.SafeRectification = safeTotalRectification
 		node.SafeRectificationIn = safeTotalRectificationIn
+		node.SafeApproval = SafeTotalApproval
+		node.SafeClose = SafeTotalClose
+
 		// 质量巡检
 		node.QualityTotal = qualityTotal
 		node.QualityRectification = qualityTotalRectification
 		node.QualityRectificationIn = qualityTotalRectificationIn
+		node.QualityApproval = QualityTotalApproval
+		node.QualityClose = QualityTotalClose
 	}
 }
 

+ 9 - 0
dao/contract_paid_dao.go

@@ -40,6 +40,15 @@ func (d *ContractPaidDao) Get(id int, contractsId int, bidsectionId int) *models
 
 }
 
+func (d *ContractPaidDao) GetInContractsIds(ids string) []models.CmContractsPaid {
+	datalist := make([]models.CmContractsPaid, 0)
+	d.engine.
+		Where("contracts_id in ( ? ) ", ids).
+		Desc("id").
+		Find(&datalist)
+	return datalist
+}
+
 func (d *ContractPaidDao) GetAll(projectId int, bidsectionId int, contractsId int) []models.CmContractsPaid {
 	datalist := make([]models.CmContractsPaid, 0)
 

+ 9 - 0
dao/contract_return_dao.go

@@ -40,6 +40,15 @@ func (d *ContractReturnDao) Get(id int, contractsId int, bidsectionId int) *mode
 
 }
 
+func (d *ContractReturnDao) GetInContractsIds(ids string) []models.CmContractsReturn {
+	datalist := make([]models.CmContractsReturn, 0)
+	d.engine.
+		Where("contracts_id in ( ? ) ", ids).
+		Desc("id").
+		Find(&datalist)
+	return datalist
+}
+
 func (d *ContractReturnDao) GetAll(projectId int, bidsectionId int, contractsId int) []models.CmContractsReturn {
 	datalist := make([]models.CmContractsReturn, 0)
 

+ 1 - 1
models/cm_rectification.go

@@ -15,5 +15,5 @@ type CmRectification struct {
 	Content       string    `xorm:"comment('内容') VARCHAR(3072)"`
 	RectifiedTime time.Time `xorm:"comment('整改时间') DATETIME"`
 	CreateTime    time.Time `xorm:"comment('创建时间') DATETIME"`
-	UpdateTime    time.Time `xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
+	UpdateTime    time.Time `xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
 }

+ 25 - 21
models/cm_tree.go

@@ -7,29 +7,33 @@ import (
 type CmTree struct {
 	Id                         int       `xorm:"not null pk autoincr comment('自增ID') INT(11)"`
 	Name                       string    `xorm:"not null comment('名称') VARCHAR(64)"`
-	ProjectId                  int       `xorm:"not null default 0 comment('项目ID') INT(11)"`
-	Depth                      int       `xorm:"not null default 0 comment('深度') TINYINT(4)"`
-	Serial                     int       `xorm:"not null default 0 comment('序号') TINYINT(4)"`
+	ProjectId                  int       `xorm:"not null comment('项目ID') INT(11)"`
+	Depth                      int       `xorm:"not null comment('深度') TINYINT(4)"`
+	Serial                     int       `xorm:"not null comment('序号') TINYINT(4)"`
 	Attribution                string    `xorm:"comment('归属') VARCHAR(32)"`
-	Sort                       int       `xorm:"not null default 0 comment('排序') TINYINT(4)"`
-	Isfolder                   int       `xorm:"not null default 1 comment('是否文件夹 1文件夹 0其他') TINYINT(1)"`
+	Sort                       int       `xorm:"not null comment('排序') TINYINT(4)"`
+	Isfolder                   int       `xorm:"not null comment('是否文件夹 1文件夹 0其他') TINYINT(1)"`
 	BidsectionId               int       `xorm:"comment('标段ID') INT(11)"`
-	ParentId                   int       `xorm:"not null default 0 comment('父级ID') INT(11)"`
-	Accounts                   int       `xorm:"not null default 0 comment('账号数') TINYINT(4)"`
-	Contracts                  int       `xorm:"not null default 0 comment('合同数') TINYINT(4)"`
-	ContractsIncome            string    `xorm:"not null default 0.00 comment('合同收入总金额') DECIMAL(12,2)"`
-	ContractsReturned          string    `xorm:"not null default 0.00 comment('合同已收总金额') DECIMAL(12,2)"`
-	ContractsPay               string    `xorm:"not null default 0.00 comment('合同支付总金额') DECIMAL(12,2)"`
-	ContractsPaid              string    `xorm:"not null default 0.00 comment('合同已支付金额') DECIMAL(12,2)"`
-	SafeTotal                  int       `xorm:"not null default 0 comment('安全巡检总数') TINYINT(4)"`
-	SafeRectification          int       `xorm:"not null default 0 comment('安全巡检整改未') TINYINT(4)"`
-	SafeRectificationIn        int       `xorm:"not null default 0 comment('安全巡检整改中') TINYINT(4)"`
-	SafeRectificationFinish    int       `xorm:"not null default 0 comment('安全巡检整改完') TINYINT(4)"`
-	QualityTotal               int       `xorm:"not null default 0 comment('质量总数') TINYINT(4)"`
-	QualityRectification       int       `xorm:"not null default 0 comment('质量未整改') TINYINT(4)"`
-	QualityRectificationIn     int       `xorm:"not null default 0 comment('质量整改中') TINYINT(4)"`
-	QualityRectificationFinish int       `xorm:"not null default 0 comment('质量整改完') TINYINT(4)"`
-	Isdelete                   int       `xorm:"not null default 0 comment('1删除') TINYINT(1)"`
+	ParentId                   int       `xorm:"not null comment('父级ID') INT(11)"`
+	Accounts                   int       `xorm:"not null comment('账号数') TINYINT(4)"`
+	Contracts                  int       `xorm:"not null comment('合同数') TINYINT(4)"`
+	ContractsIncome            string    `xorm:"not null comment('合同收入总金额') DECIMAL(12,2)"`
+	ContractsReturned          string    `xorm:"not null comment('合同已收总金额') DECIMAL(12,2)"`
+	ContractsPay               string    `xorm:"not null comment('合同支付总金额') DECIMAL(12,2)"`
+	ContractsPaid              string    `xorm:"not null comment('合同已支付金额') DECIMAL(12,2)"`
+	SafeTotal                  int       `xorm:"not null comment('安全巡检总数') TINYINT(4)"`
+	SafeApproval               int       `xorm:"not null comment('安全审批中') TINYINT(4)"`
+	SafeClose                  int       `xorm:"not null comment('安全已关闭') TINYINT(4)"`
+	SafeRectification          int       `xorm:"not null comment('安全巡检整改未') TINYINT(4)"`
+	SafeRectificationIn        int       `xorm:"not null comment('安全巡检整改中') TINYINT(4)"`
+	SafeRectificationFinish    int       `xorm:"not null comment('安全巡检整改完') TINYINT(4)"`
+	QualityTotal               int       `xorm:"not null comment('质量总数') TINYINT(4)"`
+	QualityApproval            int       `xorm:"not null comment('质量审批中') TINYINT(4)"`
+	QualityClose               int       `xorm:"not null comment('质量已关闭') TINYINT(4)"`
+	QualityRectification       int       `xorm:"not null comment('质量未整改') TINYINT(4)"`
+	QualityRectificationIn     int       `xorm:"not null comment('质量整改中') TINYINT(4)"`
+	QualityRectificationFinish int       `xorm:"not null comment('质量整改完') TINYINT(4)"`
+	Isdelete                   int       `xorm:"not null comment('1删除') TINYINT(1)"`
 	CreateTime                 time.Time `xorm:"comment('创建时间') DATETIME"`
 	UpdateTime                 time.Time `xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
 }

+ 40 - 9
services/contract_service.go

@@ -12,6 +12,7 @@ import (
 	"html"
 	"log"
 	"strconv"
+	"strings"
 	"time"
 
 	"github.com/kataras/iris/v12"
@@ -575,17 +576,22 @@ func (s *contractService) GetSurvey(bidsectionId int, projectId int, contractsTy
 		fmt.Sprintf("%d-12", year): 0.00,
 	}
 
+	contractIds := []string{}
 	for _, item := range incomeList {
 		contractPrice, _ := strconv.ParseFloat(item.Price, 64)
 		totalContractPrice = totalContractPrice + contractPrice
-		typePrice := 0.00
-		if contractsType == 1 {
-			typePrice, _ = strconv.ParseFloat(item.Returned, 64)
-			totalTypePrice = totalTypePrice + typePrice
-		} else {
-			typePrice, _ = strconv.ParseFloat(item.Paid, 64)
-			totalTypePrice = totalTypePrice + typePrice
-		}
+
+		// 回款金额或已支付金额合计
+		contractIds = append(contractIds, strconv.Itoa(item.Id))
+
+		// typePrice := 0.00
+		// if contractsType == 1 {
+		// 	typePrice, _ = strconv.ParseFloat(item.Returned, 64)
+		// 	totalTypePrice = totalTypePrice + typePrice
+		// } else {
+		// 	typePrice, _ = strconv.ParseFloat(item.Paid, 64)
+		// 	totalTypePrice = totalTypePrice + typePrice
+		// }
 
 		if item.Status == 0 {
 			performNumber = performNumber + 1
@@ -595,8 +601,33 @@ func (s *contractService) GetSurvey(bidsectionId int, projectId int, contractsTy
 			closeNumber = closeNumber + 1
 		}
 
-		returnDate[item.CreateTime.Format(conf.SysTimeformMonth)] = returnDate[item.CreateTime.Format(conf.SysTimeformMonth)] + typePrice
+		// returnDate[item.CreateTime.Format(conf.SysTimeformMonth)] = returnDate[item.CreateTime.Format(conf.SysTimeformMonth)] + typePrice
+	}
+
+	contractInId := strings.Join(contractIds, ",")
+	if contractsType == 1 {
+		list := s.contractReturnDao.GetInContractsIds(contractInId)
+		for _, item := range list {
+			typePrice := 0.00
+			typePrice, _ = strconv.ParseFloat(item.Price, 64)
+			totalTypePrice = totalTypePrice + typePrice
+
+			// :=decimal.NewFromFloat(typePrice)
+
+			returnDate[item.Time.Format(conf.SysTimeformMonth)], _ = decimal.NewFromFloat(returnDate[item.Time.Format(conf.SysTimeformMonth)]).Add(decimal.NewFromFloat(typePrice)).Float64()
+		}
+	} else {
+		list := s.contractPaidDao.GetInContractsIds(contractInId)
+		for _, item := range list {
+			typePrice := 0.00
+			typePrice, _ = strconv.ParseFloat(item.Price, 64)
+			totalTypePrice = totalTypePrice + typePrice
+
+			returnDate[item.Time.Format(conf.SysTimeformMonth)], _ = decimal.NewFromFloat(returnDate[item.Time.Format(conf.SysTimeformMonth)]).Add(decimal.NewFromFloat(typePrice)).Float64()
+
+		}
 	}
+
 	totalContractPrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalContractPrice), 64)
 	totalTypePrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalTypePrice), 64)
 

+ 16 - 2
services/tree_service.go

@@ -253,6 +253,22 @@ func (s *treeService) GetAllContract(projectId int, account *models.CmProjectAcc
 				folder.ContractsPayProgress = fmt.Sprintf("%.0f", (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
 
@@ -263,8 +279,6 @@ func (s *treeService) GetAllContract(projectId int, account *models.CmProjectAcc
 
 	}
 
-	// fmt.Println(folderlist)
-
 	var data []*viewmodels.FolderContract
 	data = make([]*viewmodels.FolderContract, 0)
 	for i, _ := range folderlist {

+ 5 - 0
web/viewmodels/folder_contract.go

@@ -30,11 +30,16 @@ type FolderContract struct {
 	SafeRectification       int `form:"safeRectification" json:"safeRectification"`
 	SafeRectificationIn     int `form:"safeRectificationIn" json:"safeRectificationIn"`
 	SafeRectificationFinish int `form:"safeRectificationFinish" json:"safeRectificationFinish"`
+	SafeApproval            int `form:"safeApproval" json:"safeApproval"`
+	SafeClose               int `form:"safeClose" json:"safeClose"`
+
 	// 质量巡检
 	QualityTotal               int `form:"qualityTotal" json:"qualityTotal"`
 	QualityRectification       int `form:"qualityRectification" json:"qualityRectification"`
 	QualityRectificationIn     int `form:"qualityRectificationIn" json:"qualityRectificationIn"`
 	QualityRectificationFinish int `form:"qualityRectificationFinish" json:"qualityRectificationFinish"`
+	QualityApproval            int `form:"qualityApproval" json:"qualityApproval"`
+	QualityClose               int `form:"qualityClose" json:"qualityClose"`
 
 	Csrf string `form:"csrf" json:"csrf"`
 	// Leaf        bool    `json:"leaf" `