|
@@ -79,13 +79,13 @@ func (d *SafeAuditDao) GetAuditHistory(id int, times int) map[int][]viewmodels.H
|
|
|
auditorHistory := make(map[int][]viewmodels.HistorySafeAudit, 0)
|
|
|
for i := 1; i <= times; i++ {
|
|
|
auditors := make([]viewmodels.HistorySafeAudit, 0)
|
|
|
- d.engine.Sql("select ca.`id`, pa.`name`, pa.`position`, ca.`create_time` as createTime, ca.`end_time` as endTime, ca.`progress`, ca.`opinion`, ca.`status` from `cm_project_account` as pa, `cm_safe_audit` as ca where ca.`safe_id` = ? and ca.audit_id = pa.id and times = ? order by `audit_order`", id, i).Find(&auditors)
|
|
|
+ d.engine.Sql("select ca.`id`, pa.`name`, pa.`position`, ca.`create_time`, ca.`end_time`, ca.`progress`, ca.`opinion`, ca.`status` from `cm_project_account` as pa, `cm_safe_audit` as ca where ca.`safe_id` = ? and ca.audit_id = pa.id and times = ? order by `audit_order`", id, i).Find(&auditors)
|
|
|
auditorsArr := make([]viewmodels.HistorySafeAudit, 0)
|
|
|
for _, auditor := range auditors {
|
|
|
auditorVM := viewmodels.HistorySafeAudit{}
|
|
|
id, _ := comm.AesEncrypt(auditor.Id, conf.SignSecret)
|
|
|
auditorVM.Id = id
|
|
|
- auditorVM.Createtime = auditor.Createtime
|
|
|
+ auditorVM.CreateTime = auditor.CreateTime
|
|
|
auditorVM.EndTime = auditor.EndTime
|
|
|
auditorVM.Name = auditor.Name
|
|
|
auditorVM.Position = auditor.Position
|
|
@@ -122,7 +122,6 @@ func (d *SafeAuditDao) CopyAuditors(safeId int, times int, auditType string, uid
|
|
|
}
|
|
|
|
|
|
var copyStatus = true
|
|
|
- fmt.Println("auditType", auditType)
|
|
|
newAuditors := make([]models.CmSafeAudit, 0)
|
|
|
for _, auditor := range oldAuditors {
|
|
|
auditorVM := models.CmSafeAudit{}
|
|
@@ -153,13 +152,13 @@ func (d *SafeAuditDao) CopyAuditors(safeId int, times int, auditType string, uid
|
|
|
}
|
|
|
|
|
|
// 增加整改人
|
|
|
-func (d *SafeAuditDao) AddCheckWorker(id int, auditId int, opinion string) error {
|
|
|
+func (d *SafeAuditDao) AddCheckWorker(id int, auditId int) error {
|
|
|
auditor, err := d.FindById(id)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- data := &models.CmSafeAudit{SafeId: auditor.SafeId, BidsectionId: auditor.BidsectionId, AuditOrder: auditor.AuditOrder + 1, Times: auditor.Times, AuditId: auditId, Status: 0, Progress: 1, CreateTime: time.Now(), Opinion: opinion}
|
|
|
+ data := &models.CmSafeAudit{SafeId: auditor.SafeId, BidsectionId: auditor.BidsectionId, AuditOrder: auditor.AuditOrder + 1, Times: auditor.Times, AuditId: auditId, Status: 0, Progress: 1, CreateTime: time.Now()}
|
|
|
_, err = d.engine.Insert(data)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -177,14 +176,30 @@ func (d *SafeAuditDao) GetLastedOrder(safeId int) ([]viewmodels.CheckOrderVM, er
|
|
|
// 获取当前的审核人
|
|
|
func (d *SafeAuditDao) GetLastedAuditor(times int, safeId int) (*viewmodels.LatestAuditorVM, error) {
|
|
|
data := &viewmodels.LatestAuditorVM{}
|
|
|
- _, err := d.engine.Sql("select audit_id, progress, status from cm_safe_audit where times = ? and safe_id = ? and status = 0 order by `audit_order` limit 1", times, safeId).Get(data)
|
|
|
+ _, err := d.engine.Sql("select id, audit_id, progress, status from cm_safe_audit where times = ? and safe_id = ? and status = 1 order by `audit_order` limit 1", times, safeId).Get(data)
|
|
|
auditId, _ := comm.AesEncrypt(data.AuditId, conf.SignSecret)
|
|
|
data.AuditId = auditId
|
|
|
+ Id, _ := comm.AesEncrypt(data.Id, conf.SignSecret)
|
|
|
+ data.Id = Id
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
+// 插入审批记录
|
|
|
func (d *SafeAuditDao) InsertData(data []models.CmSafeAudit) error {
|
|
|
_, err := d.engine.Insert(&data)
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+// 改变下一条审批记录为待审核状态
|
|
|
+func (d *SafeAuditDao) ChangeNextRecord(times int, audit_order int) error {
|
|
|
+ data := &models.CmSafeAudit{Status: 1}
|
|
|
+ _, err := d.engine.Where("times = ? and audit_order = ?", times, audit_order).Update(data)
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// 获取最后一个审批人
|
|
|
+func (d *SafeAuditDao) GetLastAuditor(times int, safeId int) (*models.CmSafeAudit, error) {
|
|
|
+ data := &models.CmSafeAudit{}
|
|
|
+ _, err := d.engine.Where("times = ? and safe_id = ?", times, safeId).Desc("audit_order").Limit(1).Get(data)
|
|
|
+ return data, err
|
|
|
+}
|