| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/supplierdataentry"
- "dashoo.cn/backend/api/business/workflow"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- "reflect"
- "strconv"
- )
- type SupplierDataEntryController struct {
- BaseController
- }
- type RequestList struct {
- DocKey string
- DocAddress string
- DocName string
- DataEntryId int
- DocUrl string
- }
- type AddEntry struct {
- EntrustNo string
- ConUserId int
- Remark string
- ConUserBy string
- }
- type CopySheet struct {
- SheetNum int
- }
- type DataEntryCallback struct {
- Id string `json:"Id"`
- DocUrl string `json:"DocUrl"`
- }
- // @Title 从数据录入数据导出到word文档
- // @Description 数据存入word
- // @Success 200 {object} controllers.Request
- // @router /exportword/:tbid [post]
- func (this *SupplierDataEntryController) DocExport() {
- // 填物资类信息表首页信息
- 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 tabledata3 []supplierdataentry.SupplierMajorEquipmentDataEntry
- var tabledata4 []supplierdataentry.SupplierThreeYearsDataEntryView
- var tabledata5 []supplierdataentry.SupplierPatentDataEntryView
- var tabledata6 []supplierdataentry.SupplierWinningDataEntryView
- var tabledata7 []supplierdataentry.SupplierCertSubEntry
- SupplierCertId := strconv.Itoa(model2.Id)
- where3 := "SupplierCertId = '" + SupplierCertId + "'"
- svc.GetEntitysByOrderbyWhere(OilEnterpriseMajorEquipmentName, where3, "1", &tabledata3)
- svc.GetEntitysByOrderbyWhere(OilThreeYearsPerformanceName, where3, "1", &tabledata4)
- svc.GetEntitysByOrderbyWhere(OilPatentStatisticalName, where3, "1", &tabledata5)
- 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" {
- //Url = "http://weed1.labsop.cn:9390/1,248318341f7c"
- Url = utils.Cfg.MustValue("workflow", "goodsModuleHost")
- fileName = "物资类供方准入评审表.docx"
- } else if model2.SupplierTypeCode == "02" {
- //Url = "http://weed1.labsop.cn:9390/5,2479ad04d28b"
- Url = utils.Cfg.MustValue("workflow", "basisModuleHost")
- fileName = "基建类供方准入评审表.docx"
- datamap["TJInNotify"] = model1.TJInNotify
- } else {
- //Url = "http://weed1.labsop.cn:9390/2,247af827d5ac"
- Url = utils.Cfg.MustValue("workflow", "techModuleHost")
- fileName = "技术服务类供方准入评审表.docx"
- }
- //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
- //model2
- datamap["WorkerTotal"] = model2.WorkerTotal
- datamap["ContractNum"] = model2.ContractNum
- datamap["UniversityNum"] = model2.UniversityNum
- datamap["TechnicalNum"] = model2.TechnicalNum
- datamap["AboveProfNum"] = model2.AboveProfNum
- datamap["MiddleProfNum"] = model2.MiddleProfNum
- datamap["NationalRegNum"] = model2.NationalRegNum
- datamap["NationalCertTotal"] = model2.NationalCertTotal
- datamap["DesignerTotal"] = model2.DesignerTotal
- datamap["SkillerTotal"] = model2.SkillerTotal
- if len(tabledata7) != 0 {
- var Name string
- Name = tabledata7[0].Name
- for i := 1; i < len(tabledata7); i++ {
- Name = Name + "," + tabledata7[i].Name
- }
- datamap["Name"] = Name
- } else {
- datamap["Name"] = ""
- }
- var interfaceSlice3 = make([]interface{}, len(tabledata3))
- datamap["MajorEquipments"] = workflow.TableDetailData{
- DataList: interfaceSlice3,
- StartRow: 2,
- NeedDelRow: 1,
- ReverseRow: 4,
- Cols: []string{"MajorEquipment", "Specifications", "Number", "Remark"},
- Merge: []string{},
- ColsNum: 4,
- }
- //起止时间如何全部显示
- var interfaceSlice4 = make([]interface{}, len(tabledata4))
- for i, d := range tabledata4 {
- d.StartTimeStr = d.StopTime.Format("2006-01-02")
- interfaceSlice4[i] = d
- }
- datamap["ThreeYears"] = workflow.TableDetailData{
- DataList: interfaceSlice4,
- StartRow: 2,
- NeedDelRow: 1,
- ReverseRow: 4,
- Cols: []string{"ProjectName", "BearContent", "OwnerUnit", "StartTimeStr", "StartTimeStr", "Tudge"},
- Merge: []string{},
- ColsNum: 5,
- }
- var interfaceSlice5 = make([]interface{}, len(tabledata5))
- for i, d := range tabledata5 {
- d.ApprovalDateStr = d.ApprovalDate.Format("2006-01-02")
- interfaceSlice5[i] = d
- }
- datamap["Patent"] = workflow.TableDetailData{
- DataList: interfaceSlice5,
- StartRow: 2,
- NeedDelRow: 1,
- ReverseRow: 9,
- Cols: []string{"Name", "Content", "ApprovalAuthority", "ApprovalDateStr"},
- Merge: []string{},
- ColsNum: 4,
- }
- var interfaceSlice6 = make([]interface{}, len(tabledata6))
- for i, d := range tabledata6 {
- d.WinningTimeStr = d.WinningTime.Format("2006-01-02")
- interfaceSlice6[i] = d
- }
- datamap["Winning"] = workflow.TableDetailData{
- DataList: interfaceSlice6,
- StartRow: 2,
- NeedDelRow: 1,
- ReverseRow: 8,
- Cols: []string{"AwardName", "WinningTimeStr", "Authorities", "Remark"},
- Merge: []string{},
- ColsNum: 4,
- }
- datamap["TableComment"] = []string{"MajorEquipments", "ThreeYears", "Patent", "Winning"}
- 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()
- }
- 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
- }
|