|
|
@@ -35,6 +35,16 @@ type DataEntryCallback struct {
|
|
|
DocUrl string `json:"DocUrl"`
|
|
|
}
|
|
|
|
|
|
+func StructToMapDemo(obj interface{}) map[string]interface{} {
|
|
|
+ obj1 := reflect.TypeOf(obj)
|
|
|
+ obj2 := reflect.ValueOf(obj)
|
|
|
+ var data = make(map[string]interface{})
|
|
|
+ for i := 0; i < obj1.NumField(); i++ {
|
|
|
+ data[obj1.Field(i).Name] = obj2.Field(i).Interface()
|
|
|
+ }
|
|
|
+ return data
|
|
|
+}
|
|
|
+
|
|
|
// @Title 从数据录入数据导出到word文档
|
|
|
// @Description 数据存入word
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
@@ -68,10 +78,6 @@ func (this *SupplierDataEntryController) DocExport() {
|
|
|
svc.GetEntitysByOrderbyWhere(OilWinningProjectName, where3, "1", &tabledata6)
|
|
|
svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, where3, "1", &tabledata7)
|
|
|
|
|
|
- //wheretable := "MId=" + strconv.Itoa(model.Id)
|
|
|
- //svc.GetEntitysByWhere(this.User.AccCode+LimsHeatingFurnaceItemsName, wheretable, &tabledata)
|
|
|
- //svc.GetEntitysByOrderbyWhere(this.User.AccCode+LimsHeatingFurnaceItemsName, wheretable, "OrderNo desc", &tabledata)
|
|
|
-
|
|
|
datamap := StructToMapDemo(model1)
|
|
|
|
|
|
if model2.SupplierTypeCode == "01" {
|
|
|
@@ -225,12 +231,113 @@ func (this *SupplierDataEntryController) DocExport() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-func StructToMapDemo(obj interface{}) map[string]interface{} {
|
|
|
- obj1 := reflect.TypeOf(obj)
|
|
|
- obj2 := reflect.ValueOf(obj)
|
|
|
- var data = make(map[string]interface{})
|
|
|
- for i := 0; i < obj1.NumField(); i++ {
|
|
|
- data[obj1.Field(i).Name] = obj2.Field(i).Interface()
|
|
|
+// @Title 导出数据到word,作为导出pdf的中间步骤
|
|
|
+// @Description 数据存入word
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /exportpdf/:tbid [post]
|
|
|
+func (this *SupplierDataEntryController) PdfExport() {
|
|
|
+ Id := this.Ctx.Input.Param(":tbid")
|
|
|
+ var Url string
|
|
|
+ var fileName string
|
|
|
+ var model1 supplierdataentry.SupplierDataEntry
|
|
|
+ var model2 supplierdataentry.SupplierCertDataEntry
|
|
|
+
|
|
|
+ svc := supplierdataentry.GetSupplierDataEntryService(utils.DBE)
|
|
|
+ where1 := "1=1"
|
|
|
+ where1 += " AND Id = '" + Id + "'"
|
|
|
+ where2 := "SupplierId = '" + Id + "'"
|
|
|
+ svc.GetEntityByWhere(OilSupplierName, where1, &model1)
|
|
|
+ svc.GetEntityByWhere(OilSupplierCertName, where2, &model2)
|
|
|
+
|
|
|
+ var tabledata []supplierdataentry.SupplierCertSubEntry
|
|
|
+ svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, where2, "1", &tabledata)
|
|
|
+
|
|
|
+ datamap := StructToMapDemo(model1)
|
|
|
+
|
|
|
+ if model2.SupplierTypeCode == "01" {
|
|
|
+ Url = utils.Cfg.MustValue("workflow", "goodsPdfHost")
|
|
|
+ fileName = "物资类准入范围.docx"
|
|
|
+ } else if model2.SupplierTypeCode == "02" {
|
|
|
+ Url = utils.Cfg.MustValue("workflow", "basisPdfHost")
|
|
|
+ fileName = "基建类准入范围.docx"
|
|
|
+ datamap["TJInNotify"] = model1.TJInNotify
|
|
|
+ } else {
|
|
|
+ Url = utils.Cfg.MustValue("workflow", "techPdfHost")
|
|
|
+ fileName = "技术服务类准入范围.docx"
|
|
|
}
|
|
|
- return data
|
|
|
+
|
|
|
+ //model1
|
|
|
+ datamap["SetupTime"] = model1.SetupTime.Format("2006年01月02日")
|
|
|
+ datamap["QualifCert"] = model1.QualifCert
|
|
|
+ datamap["QualifCertLevel"] = model1.QualifCertLevel
|
|
|
+ datamap["SpecIndustryCert"] = model1.SpecIndustryCert
|
|
|
+ datamap["MaunLicense"] = model1.MaunLicense
|
|
|
+ datamap["HseTraining"] = model1.HseTraining
|
|
|
+ datamap["Fax"] = model1.Fax
|
|
|
+ datamap["CompanyTel"] = model1.CompanyTel
|
|
|
+ datamap["SupplierName"] = model1.SupplierName
|
|
|
+ datamap["SpecTypeCode"] = model1.SpecTypeName
|
|
|
+ datamap["Country"] = model1.Country
|
|
|
+ datamap["MaunAgent"] = model1.MaunAgent
|
|
|
+ datamap["SupplierCertificate"] = model1.SupplierCertificate
|
|
|
+ datamap["MgrUnit"] = model1.MgrUnit
|
|
|
+ datamap["Grade"] = model1.Grade
|
|
|
+ datamap["CommercialNo"] = model1.CommercialNo
|
|
|
+ datamap["CountryTaxNo"] = model1.CountryTaxNo
|
|
|
+ datamap["OrganCode"] = model1.OrganCode
|
|
|
+ datamap["Address"] = model1.Address
|
|
|
+ datamap["ZipCode"] = model1.ZipCode
|
|
|
+ datamap["LinkAddress"] = model1.LinkAddress
|
|
|
+ datamap["LinkZipCode"] = model1.LinkZipCode
|
|
|
+ datamap["QualitySystemCert"] = model1.QualitySystemCert
|
|
|
+ datamap["ProductQualityCert"] = model1.ProductQualityCert
|
|
|
+ datamap["MaunLicense"] = model1.MaunLicense
|
|
|
+ datamap["LegalPerson"] = model1.LegalPerson
|
|
|
+ datamap["CompanyType"] = model1.CompanyType
|
|
|
+ datamap["ContactName"] = model1.ContactName
|
|
|
+ datamap["RegCapital"] = model1.RegCapital
|
|
|
+ datamap["DepositBank"] = model1.DepositBank
|
|
|
+ datamap["BankAccount"] = model1.BankAccount
|
|
|
+ datamap["Mobile"] = model1.Mobile
|
|
|
+ datamap["EMail"] = model1.EMail
|
|
|
+ datamap["BankCreditRating"] = model1.BankCreditRating
|
|
|
+ datamap["BusinessScope"] = model1.BusinessScope
|
|
|
+ datamap["Telphone"] = model1.Telphone
|
|
|
+
|
|
|
+ var interfaceSlice2 = make([]interface{}, len(tabledata))
|
|
|
+ datamap["CertSub"] = workflow.TableDetailData{
|
|
|
+ DataList: interfaceSlice2,
|
|
|
+ StartRow: 2,
|
|
|
+ NeedDelRow: 1,
|
|
|
+ ReverseRow: 10,
|
|
|
+ Cols: []string{"Code", "Name"},
|
|
|
+ Merge: []string{},
|
|
|
+ ColsNum: 2,
|
|
|
+ }
|
|
|
+
|
|
|
+ datamap["TableComment"] = []string{"CertSub"}
|
|
|
+
|
|
|
+ svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
+
|
|
|
+
|
|
|
+ retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
|
|
|
+ var datainfo ErrorDataInfo
|
|
|
+ datainfo.Code = 0
|
|
|
+ datainfo.Item = retDocUrl
|
|
|
+ datainfo.Message = "准备导出"
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// @Title post
|
|
|
+// @Description word to pdf
|
|
|
+// @Success 200 {string} pdfurl
|
|
|
+// @router /word-to-pdf [post]
|
|
|
+func (this *SupplierDataEntryController) WordToPdf() {
|
|
|
+ var pdfurl = this.GetString("pdfurl")
|
|
|
+ svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
+ pdfUrl := svcActiviti.WordToPdf(pdfurl)
|
|
|
+ this.Data["json"] = pdfUrl
|
|
|
+ this.ServeJSON()
|
|
|
}
|