Pārlūkot izejas kodu

后端: hse证书模板

baichengfei 4 gadi atpakaļ
vecāks
revīzija
e67df56e76

+ 2 - 1
src/dashoo.cn/backend/api/conf/app.conf

@@ -86,7 +86,8 @@ ContrastExcel=http://weed1.labsop.cn:9390/1,03eb5b7a97b8b0
 callbackHost=http://localhost:10091/api
 
 [HSE]
-HSEUrl=http://weed1.labsop.cn:9390/6,04fc24a640a08b
+#HSEUrl=http://weed1.labsop.cn:9390/6,04fc24a640a08b
+HSEUrl=http://weed1.labsop.cn:9390/2,04fc7ca35309ea
 
 [MsgUrl]
 msgUrl=http://api.dgyt.petrochina/jcfw/duanxin/v1.0/sendmsg

+ 27 - 12
src/dashoo.cn/backend/api/controllers/oilsupplier/hsescore.go

@@ -22,6 +22,14 @@ type HSEScoreController struct {
 	BaseController
 }
 
+type printHseInfo struct {
+	SupplierName string
+	Name         string
+	StartTime    string
+	EndTime      string
+	ApplyTime    string
+}
+
 // @Title 获取列表
 // @Description GetList
 // @Success 200 {object}
@@ -243,7 +251,7 @@ func (this *HSEScoreController) ImportExcel() {
 		} else {
 			supplierName1 = supplierName
 		}
-		svc.GetEntityByWhere(OilSupplierName, "SupplierName = '" + supplierName1 + "'", &supplier)
+		svc.GetEntityByWhere(OilSupplierName, "SupplierName = '"+supplierName1+"'", &supplier)
 		if supplier.Id == 0 {
 			if strings.Index(supplierNameStr, supplierName1) == -1 {
 				supplierNameStr += supplierName1 + ","
@@ -251,7 +259,7 @@ func (this *HSEScoreController) ImportExcel() {
 			continue
 		}
 		if supplierName1 != "" {
-			svc.GetEntityByWhere(HSEScoreName, "SupplierName = '" + supplierName1 + "' and TestNumber = " + sheet.Rows[i].Cells[2].String(), &hseUpdate)
+			svc.GetEntityByWhere(HSEScoreName, "SupplierName = '"+supplierName1+"' and TestNumber = "+sheet.Rows[i].Cells[2].String(), &hseUpdate)
 			if hseUpdate.Id > 0 {
 				hseUpdate.EndTime = hseTime.EndTime
 				hseUpdate.ApplyTime = hseTime.ApplyTime
@@ -259,7 +267,7 @@ func (this *HSEScoreController) ImportExcel() {
 				hseUpdate.SupplierId = supplier.Id
 				hseUpdate.Name = sheet.Rows[i].Cells[3].String()
 				hseUpdate.IdNumber = sheet.Rows[i].Cells[4].String()
-				hseUpdate.Score,_ = strconv.Atoi(sheet.Rows[i].Cells[5].String())
+				hseUpdate.Score, _ = strconv.Atoi(sheet.Rows[i].Cells[5].String())
 				hseUpdate.ModifiedOn = time.Now()
 				hseUpdate.ModifiedBy = this.User.Realname
 				hseUpdate.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -272,11 +280,11 @@ func (this *HSEScoreController) ImportExcel() {
 		hse.ApplyTime = hseTime.ApplyTime
 		hse.StartTime = hseTime.StartTime
 		hse.SupplierId = supplier.Id
-		hse.TestNumber,_ = strconv.Atoi(sheet.Rows[i].Cells[2].String())
+		hse.TestNumber, _ = strconv.Atoi(sheet.Rows[i].Cells[2].String())
 		hse.SupplierId = supplier.Id
 		hse.Name = sheet.Rows[i].Cells[3].String()
 		hse.IdNumber = sheet.Rows[i].Cells[4].String()
-		hse.Score,_ = strconv.Atoi(sheet.Rows[i].Cells[5].String())
+		hse.Score, _ = strconv.Atoi(sheet.Rows[i].Cells[5].String())
 		hse.CreateOn = time.Now()
 		hse.CreateBy = this.User.Realname
 		hse.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -350,7 +358,7 @@ func (this *HSEScoreController) AddHSEScore() {
 		return
 	}
 
-	svc.GetEntityByWhere(OilSupplierName, "Id = " + strconv.Itoa(model.SupplierId), &supplier)
+	svc.GetEntityByWhere(OilSupplierName, "Id = "+strconv.Itoa(model.SupplierId), &supplier)
 	if supplier.SupplierName == "" {
 		errinfo.Message = "找不到该企业"
 		errinfo.Code = -2
@@ -367,7 +375,7 @@ func (this *HSEScoreController) AddHSEScore() {
 		this.ServeJSON()
 		return
 	}
-	model.ApplyTime = model.ApplyTime.AddDate(3,0,0)
+	model.ApplyTime = model.ApplyTime.AddDate(3, 0, 0)
 	model.SupplierName = supplier.SupplierName
 	model.CreateOn = time.Now()
 	model.CreateBy = this.User.Realname
@@ -407,7 +415,7 @@ func (this *HSEScoreController) UpdateHSEScore() {
 	svc := hsescore.GetHSEScoreService(utils.DBE)
 	json.Unmarshal(jsonBlob, &model)
 
-	svc.GetEntityByWhere(OilSupplierName, "Id = " + strconv.Itoa(model.SupplierId), &supplier)
+	svc.GetEntityByWhere(OilSupplierName, "Id = "+strconv.Itoa(model.SupplierId), &supplier)
 	if supplier.SupplierName == "" {
 		errinfo.Message = "找不到该企业"
 		errinfo.Code = -2
@@ -435,7 +443,7 @@ func (this *HSEScoreController) UpdateHSEScore() {
 	}
 
 	model.SupplierName = supplier.SupplierName
-	model.ApplyTime = model.ApplyTime.AddDate(3,0,0)
+	model.ApplyTime = model.ApplyTime.AddDate(3, 0, 0)
 	model.ModifiedOn = time.Now()
 	model.ModifiedBy = this.User.Realname
 	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -515,7 +523,14 @@ func (this *HSEScoreController) ExportWord() {
 	var hse hsescore.HSEScore
 	svcActiviti := workflow.GetActivitiService(utils.DBE)
 	svc := hsescore.GetHSEScoreService(utils.DBE) //获得数据库引擎
-	svc.GetEntityByWhere(HSEScoreName, "Id = " + Id + " and SupplierId = " + strconv.Itoa(model.SupplierId), &hse)
+	svc.GetEntityByWhere(HSEScoreName, "Id = "+Id+" and SupplierId = "+strconv.Itoa(model.SupplierId), &hse)
+
+	var printHseInfo printHseInfo
+	printHseInfo.SupplierName = hse.SupplierName
+	printHseInfo.Name = hse.Name
+	printHseInfo.StartTime = hse.StartTime.Format("2006年01月02日")
+	printHseInfo.EndTime = hse.EndTime.Format("2006年01月02日")
+	printHseInfo.ApplyTime = hse.ApplyTime.Format("2006年01月02日")
 	if hse.Id == 0 {
 		errinfo.Message = "打印失败"
 		errinfo.Code = -1
@@ -523,7 +538,7 @@ func (this *HSEScoreController) ExportWord() {
 		this.ServeJSON()
 	}
 
-	dataMap := StructToMapDemo(hse)
+	dataMap := StructToMapDemo(printHseInfo)
 	url := utils.Cfg.MustValue("HSE", "HSEUrl")
 	fileName := "HSE培训合格证书.docx"
 
@@ -560,4 +575,4 @@ func (this *HSEScoreController) SelectNeedSecure() {
 	errinfo.Code = 0
 	this.Data["json"] = &need
 	this.ServeJSON()
-}
+}