|
@@ -2,8 +2,10 @@ package services
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
"log"
|
|
|
"strconv"
|
|
|
+ "time"
|
|
|
|
|
|
"github.com/kataras/iris/v12"
|
|
|
"go.mod/comm"
|
|
@@ -19,7 +21,7 @@ type SafeService interface {
|
|
|
Post(data models.CmSafe) error
|
|
|
Del(id int) error
|
|
|
GetDetail(id int, pid int) viewmodels.SafeDetail
|
|
|
- GetSurvey(projectId int, bidsectionId int)
|
|
|
+ GetSurvey(projectId int, bidsectionId int) map[string]interface{}
|
|
|
ValidRule(ctx iris.Context) (viewmodels.Safe, error)
|
|
|
}
|
|
|
|
|
@@ -164,11 +166,62 @@ func (s *safeService) GetDetail(id int, pid int) viewmodels.SafeDetail {
|
|
|
}
|
|
|
|
|
|
// 安全概况
|
|
|
-func (s *safeService) GetSurvey(projectId int, bidsectionId int) {
|
|
|
- // 1.获得收入合同
|
|
|
- // year := time.Now().Year()
|
|
|
- // safeList := s.daoSafe.ChangeStatus()
|
|
|
+func (s *safeService) GetSurvey(projectId int, bidsectionId int) map[string]interface{} {
|
|
|
+ // 1.获得安全巡检
|
|
|
+ year := time.Now().Year()
|
|
|
+ safelist := s.daoSafe.GetTypeYear(bidsectionId, year)
|
|
|
+ // 2.初始化
|
|
|
+ rectifylist := make([]models.CmSafe, 0)
|
|
|
+ rectifyTotal := 0
|
|
|
+ approvalTotal := 0
|
|
|
+ rectifyedTotal := 0
|
|
|
+ // 3.当年数据初始化
|
|
|
+ submitData := map[string]float64{
|
|
|
+ fmt.Sprintf("%d-01", year): 0,
|
|
|
+ fmt.Sprintf("%d-02", year): 0,
|
|
|
+ fmt.Sprintf("%d-03", year): 0,
|
|
|
+ fmt.Sprintf("%d-04", year): 0,
|
|
|
+ fmt.Sprintf("%d-05", year): 0,
|
|
|
+ fmt.Sprintf("%d-06", year): 0,
|
|
|
+ fmt.Sprintf("%d-07", year): 0,
|
|
|
+ fmt.Sprintf("%d-08", year): 0,
|
|
|
+ fmt.Sprintf("%d-09", year): 0,
|
|
|
+ fmt.Sprintf("%d-10", year): 0,
|
|
|
+ fmt.Sprintf("%d-11", year): 0,
|
|
|
+ fmt.Sprintf("%d-12", year): 0,
|
|
|
+ }
|
|
|
+ rectifyedData := submitData
|
|
|
+ for _, item := range safelist {
|
|
|
+ if item.Status == 2 {
|
|
|
+ rectifylist = append(rectifylist, item)
|
|
|
+ rectifyTotal++
|
|
|
+ }
|
|
|
+ if item.Status == 1 {
|
|
|
+ approvalTotal++
|
|
|
+ }
|
|
|
+ if item.Status == 4 {
|
|
|
+ rectifyedTotal++
|
|
|
+ }
|
|
|
+
|
|
|
+ if item.Status == 0 {
|
|
|
+ submitData[item.CreateTime.Format(conf.SysTimeformMonth)] = submitData[item.CreateTime.Format(conf.SysTimeformMonth)] + 1
|
|
|
+ }
|
|
|
+ if item.Status == 4 {
|
|
|
+ rectifyedData[item.CreateTime.Format(conf.SysTimeformMonth)] = rectifyedData[item.CreateTime.Format(conf.SysTimeformMonth)] + 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 整改占总数比例 - 完成整改/提交巡检
|
|
|
+ surveryData := map[string]interface{}{
|
|
|
+ "rectifylist": rectifylist,
|
|
|
+ "rectifyTotal": rectifyTotal,
|
|
|
+ "approvalTotal": approvalTotal,
|
|
|
+ "rectifyedTotal": rectifyedTotal,
|
|
|
+ "submitData": submitData,
|
|
|
+ "rectifyedData": rectifyedData,
|
|
|
+ }
|
|
|
|
|
|
+ return surveryData
|
|
|
}
|
|
|
|
|
|
// 规则校验
|