Просмотр исходного кода

add:增加验证提交时间和报告提交时间

zoie 2 недель назад
Родитель
Сommit
d49bbf18f9
6 измененных файлов с 83 добавлено и 7 удалено
  1. 1 0
      Nats/Nats.go
  2. 34 0
      controllers/ERP.go
  3. 2 1
      controllers/Task.go
  4. 5 1
      controllers/VerifyTemplate.go
  5. 37 3
      models/Task/Task.go
  6. 4 2
      routers/openapi.go

+ 1 - 0
Nats/Nats.go

@@ -230,6 +230,7 @@ func NatsInit() {
 		_ = lib.Nats.Publish(m.Reply, b)
 
 	})
+
 	_, _ = lib.Nats.QueueSubscribe("ColdVerify_Server_Read_Admin", "Read_Admin", func(m *nats.Msg) {
 		logs.Println("ColdVerify_Server_Read_User message: %+v\n", string(m.Data))
 

+ 34 - 0
controllers/ERP.go

@@ -59,3 +59,37 @@ func (c *TaskController) Task_List_All_For_ERP() {
 	c.ServeJSON()
 	return
 }
+
+func (c *TaskController) Task_List2_All_For_ERP() {
+
+	T_type := c.GetString("T_type")
+	if T_type != "collection" && T_type != "reporting" {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "类型错误!"}
+		c.ServeJSON()
+		return
+	}
+	start_time := c.GetString("T_start_time")
+	end_time := c.GetString("T_end_time")
+	if _, is := lib.TimeStrToTime(start_time); !is {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "开始时间格式错误!"}
+		c.ServeJSON()
+		return
+	}
+	if _, is := lib.TimeStrToTime(end_time); !is {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "结束时间格式错误!"}
+		c.ServeJSON()
+		return
+	}
+
+	var List []Task.Task_
+	if T_type == "collection" {
+		List, _ = Task.Read_Task_List_For_ERP_By_Type(T_type, start_time, end_time)
+	}
+	if T_type == "reporting" {
+		List, _ = Task.Read_Task_List_For_ERP_By_Type(T_type, start_time, end_time)
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: List}
+	c.ServeJSON()
+	return
+}

+ 2 - 1
controllers/Task.go

@@ -1260,7 +1260,8 @@ func (c *TaskController) Up() {
 		go GetWatermarkPdf(r, T_pdf2, T_pdf2_stamp, "T_pdf2")
 
 		r.T_reporting_state = 5
-		clos = append(clos, "T_reporting_state")
+		r.T_reporting_submit_time = time.Now().Format("2006-01-02 15:04:05")
+		clos = append(clos, "T_reporting_state", "T_reporting_submit_time")
 		// 添加已提交状态验证报告记录
 		auditRecordJson, err := Task.Add_AuditRecord(r.T_reporting_audit_record, "", User_r.T_uuid, r.T_reporting_state, "", "")
 		if err == nil {

+ 5 - 1
controllers/VerifyTemplate.go

@@ -16,6 +16,7 @@ import (
 	"math"
 	"strconv"
 	"strings"
+	"time"
 )
 
 type VerifyTemplateController struct {
@@ -689,14 +690,17 @@ func (c *VerifyTemplateController) Map_Data_Pu() {
 	}
 	T_reporting_state := task.T_reporting_state
 	task.T_step = body.T_step
+	// 点击报告生成时保存
 	if body.T_submit == 2 && T_reporting_state == 0 {
 		task.T_reporting_state = Task.TaskExaminingReportStateClickGenerate
 	}
+	// app 提交
 	if body.T_submit == 1 && task.T_collection_state == Task.TaskCollectionStateWaitSubmit {
 		// 手机app提交修改采集状态为已提交
 		task.T_collection_state = Task.TaskCollectionStateSubmitted
+		task.T_collection_submit_time = time.Now().Format("2006-01-02 15:04:05")
 	}
-	if !Task.Update_Task(task, "T_step", "T_reporting_state", "T_collection_state") {
+	if !Task.Update_Task(task, "T_step", "T_reporting_state", "T_collection_state", "T_collection_submit_time") {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改任务步骤失败!"}
 		c.ServeJSON()
 		return

+ 37 - 3
models/Task/Task.go

@@ -8,13 +8,14 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	"strconv"
+	"strings"
+	"time"
+
 	"github.com/astaxie/beego/cache"
 	"github.com/beego/beego/v2/adapter/orm"
 	orm2 "github.com/beego/beego/v2/client/orm"
 	_ "github.com/go-sql-driver/mysql"
-	"strconv"
-	"strings"
-	"time"
 )
 
 var (
@@ -188,6 +189,9 @@ type Task struct {
 	T_original_record_state  int    `orm:"size(2);default(0)"` // 原始记录 状态 0 未完成 3 已通过(负责人) 4已退回(负责人) 5已提交
 	T_record                 string `orm:"type(text)"`         // 领导备注
 
+	T_collection_submit_time string `orm:"size(256);null"` // 数据采集 提交时间
+	T_reporting_submit_time  string `orm:"size(256);null"` // 报告编写 提交时间
+
 	T_VerifyDeviceDataStartTime string `orm:"size(256);null"` // 验证设备数据开始时间
 	T_VerifyDeviceDataEndTime   string `orm:"size(256);null"` // 验证设备数据结束时间
 	T_BindDeviceDataStartTime   string `orm:"size(256);null"` // 绑定设备数据开始时间
@@ -1269,6 +1273,36 @@ func Read_Task_List_For_ERP(start_time, end_time string) ([]Task_, int) {
 	return TaskList, int(cnt)
 }
 
+// 获取任务列表
+func Read_Task_List_For_ERP_By_Type(T_type string, start_time, end_time string) ([]Task_, int) {
+
+	o := orm.NewOrm()
+
+	qs := o.QueryTable(new(Task))
+	var r []Task
+
+	cond := orm.NewCondition()
+	cond1 := cond.And("T_State", 1)
+
+	if T_type == "collection" {
+		cond1 = cond1.And("T_collection_submit_time__gte", start_time).And("T_collection_submit_time__lte", end_time)
+	}
+	if T_type == "reporting" {
+		cond1 = cond1.And("T_reporting_submit_time__gte", start_time).And("T_reporting_submit_time__lte", end_time)
+	}
+
+	qs.SetCond((*orm2.Condition)(cond1)).OrderBy("-Id").All(&r)
+	cnt, _ := qs.SetCond((*orm2.Condition)(cond1)).Count()
+
+	// 转换
+	var TaskList []Task_
+	for _, v := range r {
+		TaskList = append(TaskList, TaskToTask_(v, map[string]string{}, map[string]string{}))
+	}
+
+	return TaskList, int(cnt)
+}
+
 // GenerateNextT_report_number 生成下一个编号
 func GenerateNextT_report_number(T_device_type string) (string, error) {
 	o := orm.NewOrm()

+ 4 - 2
routers/openapi.go

@@ -9,10 +9,11 @@ import (
 	"crypto/sha256"
 	"encoding/hex"
 	"errors"
-	beego "github.com/beego/beego/v2/server/web"
-	"github.com/beego/beego/v2/server/web/context"
 	"strconv"
 	"time"
+
+	beego "github.com/beego/beego/v2/server/web"
+	"github.com/beego/beego/v2/server/web/context"
 )
 
 const apiKeyHeader = "X-API-KEY"
@@ -79,6 +80,7 @@ func init() {
 		beego.NSRouter("/admin/list", &controllers.AccountController{}, "*:Account_List_All_For_ERP"), // 管理员所有列表
 		beego.NSRouter("/company/list", &controllers.UserController{}, "*:User_List_All_For_ERP"),     // 公司所有列表
 		beego.NSRouter("/task/list", &controllers.TaskController{}, "*:Task_List_All_For_ERP"),        // 公司所有列表
+		beego.NSRouter("/task/list2", &controllers.TaskController{}, "*:Task_List2_All_For_ERP"),      // 公司所有列表
 	)
 	beego.AddNamespace(ns)
 }