Преглед на файлове

Merge branch 'master' of http://192.168.1.41:3000/caipin/construction_management

caipin преди 4 години
родител
ревизия
e2faffeda7
променени са 6 файла, в които са добавени 37 реда и са изтрити 38 реда
  1. 7 16
      dao/safe_audit_dao.go
  2. 15 14
      services/safe_audit.service.go
  3. 9 3
      services/safe_service.go
  4. 2 2
      web/api/safe_audit_api.go
  5. 3 2
      web/viewmodels/safe.go
  6. 1 1
      web/viewmodels/safe_audit.go

+ 7 - 16
dao/safe_audit_dao.go

@@ -62,14 +62,14 @@ func (d *SafeAuditDao) GetAuditorsWithOwner(id int, times int, cur_uid int) []vi
 	auditors := make([]viewmodels.Auditors, 0)
 	auditor := viewmodels.Auditors{Progress: ""}
 
-	_, err := d.engine.Sql("select name, company, position, id as `audit_id` from `cm_project_account` where id = ?", cur_uid).Get(&auditor)
+	_, err := d.engine.Sql("select name, company, position, mobile, id as `audit_id` from `cm_project_account` where id = ?", cur_uid).Get(&auditor)
 
 	if err != nil {
 		fmt.Println(err)
 	}
 	auditors = append(auditors, auditor)
 
-	d.engine.Sql("select pa.`company`, pa.`name`, pa.`account_group`, pa.`position`,ca.`audit_id` as `auditor_id`, ca.`id` as `audit_id`, ca.`status`, ca.`audit_order`, ca.`progress` from `cm_project_account` as pa, `cm_safe_audit` as ca where ca.`safe_id` = ? and ca.`times` = ? and ca.audit_id = pa.id order by `audit_order`", id, times).Find(&auditors)
+	d.engine.Sql("select pa.`company`, pa.`name`, pa.`account_group`,pa.`mobile`, pa.`position`,ca.`audit_id` as `audit_id`, ca.`id`, ca.`status`, ca.`audit_order`, ca.`progress` from `cm_project_account` as pa, `cm_safe_audit` as ca where ca.`safe_id` = ? and ca.`times` = ? and ca.audit_id = pa.id order by `audit_order`", id, times).Find(&auditors)
 	// 原报
 	return auditors
 }
@@ -114,16 +114,15 @@ func (d *SafeAuditDao) ChangeStatusById(id int, opinion string, status int, rect
 }
 
 // 拷贝新的审批流程
-func (d *SafeAuditDao) CopyAuditors(safeId int, times int, auditType string, uid int) error {
+func (d *SafeAuditDao) CopyAuditors(safeId int, times int, uid int) error {
 	oldAuditors := make([]models.CmSafeAudit, 0)
 	err := d.engine.Where("safe_id = ? and times = ?", safeId, times).Find(&oldAuditors)
 	if err != nil {
 		return err
 	}
 
-	var copyStatus = true
 	newAuditors := make([]models.CmSafeAudit, 0)
-	for _, auditor := range oldAuditors {
+	for i, auditor := range oldAuditors {
 		auditorVM := models.CmSafeAudit{}
 		auditorVM.SafeId = auditor.SafeId
 		auditorVM.BidsectionId = auditor.BidsectionId
@@ -132,18 +131,10 @@ func (d *SafeAuditDao) CopyAuditors(safeId int, times int, auditType string, uid
 		auditorVM.AuditOrder = auditor.AuditOrder
 		auditorVM.Progress = auditor.Progress
 		auditorVM.CreateTime = time.Now()
-		auditorVM.Status = auditor.Status
+		auditorVM.Status = 0
 		// 上报人
-		if auditType == "uncheck" {
-			auditorVM.Status = 0
-		} else {
-			if auditor.AuditId == uid {
-				auditorVM.Status = 0
-				copyStatus = false
-			}
-		}
-		if !copyStatus {
-			auditorVM.Status = 0
+		if i == 0 {
+			auditorVM.Status = 1
 		}
 		newAuditors = append(newAuditors, auditorVM)
 	}

+ 15 - 14
services/safe_audit.service.go

@@ -23,7 +23,7 @@ type SafeAuditService interface {
 	ValidStart(ctx iris.Context) (viewmodels.AuditStart, error)
 	AddAuditor(safeId int, bId int, auditId int, times int) error
 	CloseAudit(id int, opinion string, curUid int, saveId int) error
-	BackAudit(id int, opinion string, curUid int, saveId int, auditId int, progress string) error
+	BackAudit(id int, opinion string, curUid int, saveId int, auditId int) error
 	PassAudit(id int, uid int, auditId int, opinion string, rectifiedInfo string) error
 	StartAudit(safeId int, bidsectionId int, times int, auditors []int, reAuditors []int, uid int) error
 }
@@ -78,7 +78,7 @@ func (s *safeAuditService) CloseAudit(id int, opinion string, curUid int, saveId
 }
 
 // 审批退回
-func (s *safeAuditService) BackAudit(id int, opinion string, curUid int, saveId int, auditId int, progress string) error {
+func (s *safeAuditService) BackAudit(id int, opinion string, curUid int, saveId int, auditId int) error {
 	auditor, err := s.daoSafeAudit.FindById(id)
 	if err != nil {
 		return err
@@ -87,27 +87,28 @@ func (s *safeAuditService) BackAudit(id int, opinion string, curUid int, saveId
 		return errors.New("该用户没有审批权限!")
 	}
 	// 更改cm_safe_audit的记录
-	err = s.daoSafeAudit.ChangeStatusById(id, opinion, 2, "")
+	err = s.daoSafeAudit.ChangeStatusById(id, opinion, 3, "")
 	if err != nil {
 		return err
 	}
 
 	safeData := s.daoSafe.FindById(saveId)
-	// 拷贝审批流程
-	// 退回检查人-uncheck
-	// 整改人审批退回-checking
-	// 复查人审批退回-checkNo
-	// 审批组退回-checked
-	err = s.daoSafeAudit.CopyAuditors(saveId, safeData.Times, progress, auditId)
+	err = s.daoSafeAudit.CopyAuditors(saveId, safeData.Times, auditId)
 	if err != nil {
 		return err
 	}
 	// 更改cm_safe的记录
-	err = s.daoSafe.ChangeStatus(saveId, 2, auditor.Times+1)
-	if err != nil {
-		return err
-	}
-	return nil
+	// if progress == "uncheck" {
+	// 	err = s.daoSafe.ChangeStatus(saveId, 0, auditor.Times+1)
+	// } else if progress == "checked" {
+	// 	err = s.daoSafe.ChangeStatus(saveId, 1, auditor.Times+1)
+	// } else if progress == "checking" {
+	// 	err = s.daoSafe.ChangeStatus(saveId, 2, auditor.Times+1)
+	// } else {
+	// 	err = s.daoSafe.ChangeStatus(saveId, 3, auditor.Times+1)
+
+	// }
+	return err
 }
 
 // 审批通过

+ 9 - 3
services/safe_service.go

@@ -128,14 +128,20 @@ func (s *safeService) GetDetail(id int, pid int) viewmodels.SafeDetail {
 	data.File = fileVM
 	auditors := s.daoSafeAudit.GetAuditorsWithOwner(safeData.Id, safeData.Times, account.Id)
 	encryptAuditors := make([]viewmodels.Auditors, 0)
-	for _, item := range auditors {
+	for i, item := range auditors {
 		auditorVM := viewmodels.Auditors{}
-		auditorId, _ := comm.AesEncrypt(item.AuditorId, conf.SignSecret)
 		auditId, _ := comm.AesEncrypt(item.AuditId, conf.SignSecret)
-		auditorVM.AuditorId = auditorId
+		if i == 0 {
+			auditorVM.Id = ""
+
+		} else {
+			id, _ := comm.AesEncrypt(item.Id, conf.SignSecret)
+			auditorVM.Id = id
+		}
 		auditorVM.AuditId = auditId
 		auditorVM.Name = item.Name
 		auditorVM.Position = item.Position
+		auditorVM.Mobile = item.Mobile
 		auditorVM.AuditOrder = item.AuditOrder
 		auditorVM.AccountGroup = item.AccountGroup
 		auditorVM.Progress = item.Progress

+ 2 - 2
web/api/safe_audit_api.go

@@ -182,7 +182,7 @@ func (c *SafeAuditApi) PostClose() {
 // @Param   id     body    string     true        "审批id"
 // @Param   safe_id     body    string     true        "巡检id"
 // @Param   audit_id     body    string     true        "回滚的审批人id"
-// @Param   progress     body    string     true        "退回的类型,0审批,1整改,2复查,不传则为原报"
+// @Param   progress     body    string     true        "退回的类型,uncheck退回检查人,checking整改人,checkNo复查人,checked审批人"
 // @Param   opinion     body    string     true        "审批意见"
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Failure 400 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
@@ -218,7 +218,7 @@ func (c *SafeAuditApi) PostBack() {
 		return
 	}
 	// 5. 执行sql
-	err = c.SafeAuditService.BackAudit(id, safeAuditData.Opinion, uid, safeId, auditId, safeAuditData.Progress)
+	err = c.SafeAuditService.BackAudit(id, safeAuditData.Opinion, uid, safeId, auditId)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return

+ 3 - 2
web/viewmodels/safe.go

@@ -76,13 +76,14 @@ type SafeFile struct {
 type Auditors struct {
 	Name         string `from:"name" json:"name"`
 	Progress     string `from:"progress" json:"progress"`
-	AuditorId    string `from:"auditor_id" json:"auditor_id"`
+	AuditId      string `from:"audit_id" json:"audit_id"`
 	Position     string `from:"position" json:"position"`
 	AuditOrder   int    `from:"audit_order" json:"audit_order"`
 	AccountGroup int    `from:"account_group" json:"account_group"`
 	Company      string `from:"company" json:"company"`
 	Status       int    `from:"status" json:"status"`
-	AuditId      string `from:"audit_id" json:"audit_id"`
+	Id           string `from:"id" json:"id"`
+	Mobile       string `from:"mobile" json:"mobile"`
 }
 
 type SafeListAuditRecord struct {

+ 1 - 1
web/viewmodels/safe_audit.go

@@ -73,7 +73,7 @@ func (l SafeAudit) ValidateBack() error {
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.Id, validation.Required.Error("记录id不能为空")),
 		validation.Field(&l.SafeId, validation.Required.Error("巡检id不能为空")),
-		validation.Field(&l.AuditId, validation.Required.Error("回滚用户不能为空")),
+		validation.Field(&l.AuditId, validation.Required.Error("回滚的记录id不能为空")),
 	)
 }
 func (l SafeAudit) ValidatePass() error {