| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064 |
- package oilsupplier
- import (
- "encoding/json"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business/userRole"
- "dashoo.cn/utils"
- "github.com/go-xorm/xorm"
- )
- type OilSupplierController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /list [get]
- func (this *OilSupplierController) GetEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierName := this.GetString("SupplierName")
- OilCertificateNo := this.GetString("OilCertificateNo")
- Grade := this.GetString("Grade")
- MgrUnit := this.GetString("MgrUnit")
- OperType := this.GetString("OperType")
- Country := this.GetString("Country")
- MaunAgent := this.GetString("MaunAgent")
- ConstructTeam := this.GetString("ConstructTeam")
- CommercialNo := this.GetString("CommercialNo")
- OrganCode := this.GetString("OrganCode")
- CountryTaxNo := this.GetString("CountryTaxNo")
- LocalTaxNo := this.GetString("LocalTaxNo")
- Address := this.GetString("Address")
- Province := this.GetString("Province")
- City := this.GetString("City")
- Street := this.GetString("Street")
- HouseNo := this.GetString("HouseNo")
- ZipCode := this.GetString("ZipCode")
- QualitySystemCert := this.GetString("QualitySystemCert")
- ProductQualityCert := this.GetString("ProductQualityCert")
- MaunLicense := this.GetString("MaunLicense")
- QualifCert := this.GetString("QualifCert")
- QualifCertLevel := this.GetString("QualifCertLevel")
- SafetyLicense := this.GetString("SafetyLicense")
- TechServiceLic := this.GetString("TechServiceLic")
- TJInNotify := this.GetString("TJInNotify")
- SpecIndustryCert := this.GetString("SpecIndustryCert")
- LegalPerson := this.GetString("LegalPerson")
- CategoryCode := this.GetString("CategoryCode")
- CategoryName := this.GetString("CategoryName")
- RegCapital := this.GetString("RegCapital")
- Currency := this.GetString("Currency")
- ContactName := this.GetString("ContactName")
- CompanyType := this.GetString("CompanyType")
- SetupTime := this.GetString("SetupTime")
- DepositBank := this.GetString("DepositBank")
- BankAccount := this.GetString("BankAccount")
- EMail := this.GetString("EMail")
- BankCreditRating := this.GetString("BankCreditRating")
- Mobile := this.GetString("Mobile")
- Telphone := this.GetString("Telphone")
- Fax := this.GetString("Fax")
- CompanyTel := this.GetString("CompanyTel")
- QQ := this.GetString("QQ")
- CompanyUrl := this.GetString("CompanyUrl")
- SpecSupplier := this.GetString("SpecSupplier")
- SpecTypeCode := this.GetString("SpecTypeCode")
- SpecTypeName := this.GetString("SpecTypeName")
- Remark := this.GetString("Remark")
- IsDelete := this.GetString("IsDelete")
- CreateOn := this.GetString("CreateOn")
- CreateUserId := this.GetString("CreateUserId")
- CreateBy := this.GetString("CreateBy")
- ModifiedOn := this.GetString("ModifiedOn")
- ModifiedUserId := this.GetString("ModifiedUserId")
- ModifiedBy := this.GetString("ModifiedBy")
- if Id != "" {
- where = where + " and Id like '%" + Id + "%'"
- }
- if SupplierName != "" {
- where = where + " and SupplierName like '%" + SupplierName + "%'"
- }
- if OilCertificateNo != "" {
- where = where + " and OilCertificateNo like '%" + OilCertificateNo + "%'"
- }
- if Grade != "" {
- where = where + " and Grade like '%" + Grade + "%'"
- }
- if MgrUnit != "" {
- where = where + " and MgrUnit like '%" + MgrUnit + "%'"
- }
- if OperType != "" {
- where = where + " and OperType like '%" + OperType + "%'"
- }
- if Country != "" {
- where = where + " and Country like '%" + Country + "%'"
- }
- if MaunAgent != "" {
- where = where + " and MaunAgent like '%" + MaunAgent + "%'"
- }
- if ConstructTeam != "" {
- where = where + " and ConstructTeam like '%" + ConstructTeam + "%'"
- }
- if CommercialNo != "" {
- where = where + " and CommercialNo like '%" + CommercialNo + "%'"
- }
- if OrganCode != "" {
- where = where + " and OrganCode like '%" + OrganCode + "%'"
- }
- if CountryTaxNo != "" {
- where = where + " and CountryTaxNo like '%" + CountryTaxNo + "%'"
- }
- if LocalTaxNo != "" {
- where = where + " and LocalTaxNo like '%" + LocalTaxNo + "%'"
- }
- if Address != "" {
- where = where + " and Address like '%" + Address + "%'"
- }
- if Province != "" {
- where = where + " and Province like '%" + Province + "%'"
- }
- if City != "" {
- where = where + " and City like '%" + City + "%'"
- }
- if Street != "" {
- where = where + " and Street like '%" + Street + "%'"
- }
- if HouseNo != "" {
- where = where + " and HouseNo like '%" + HouseNo + "%'"
- }
- if ZipCode != "" {
- where = where + " and ZipCode like '%" + ZipCode + "%'"
- }
- if QualitySystemCert != "" {
- where = where + " and QualitySystemCert like '%" + QualitySystemCert + "%'"
- }
- if ProductQualityCert != "" {
- where = where + " and ProductQualityCert like '%" + ProductQualityCert + "%'"
- }
- if MaunLicense != "" {
- where = where + " and MaunLicense like '%" + MaunLicense + "%'"
- }
- if QualifCert != "" {
- where = where + " and QualifCert like '%" + QualifCert + "%'"
- }
- if QualifCertLevel != "" {
- where = where + " and QualifCertLevel like '%" + QualifCertLevel + "%'"
- }
- if SafetyLicense != "" {
- where = where + " and SafetyLicense like '%" + SafetyLicense + "%'"
- }
- if TechServiceLic != "" {
- where = where + " and TechServiceLic like '%" + TechServiceLic + "%'"
- }
- if TJInNotify != "" {
- where = where + " and TJInNotify like '%" + TJInNotify + "%'"
- }
- if SpecIndustryCert != "" {
- where = where + " and SpecIndustryCert like '%" + SpecIndustryCert + "%'"
- }
- if LegalPerson != "" {
- where = where + " and LegalPerson like '%" + LegalPerson + "%'"
- }
- if CategoryCode != "" {
- where = where + " and CategoryCode like '%" + CategoryCode + "%'"
- }
- if CategoryName != "" {
- where = where + " and CategoryName like '%" + CategoryName + "%'"
- }
- if RegCapital != "" {
- where = where + " and RegCapital like '%" + RegCapital + "%'"
- }
- if Currency != "" {
- where = where + " and Currency like '%" + Currency + "%'"
- }
- if ContactName != "" {
- where = where + " and ContactName like '%" + ContactName + "%'"
- }
- if CompanyType != "" {
- where = where + " and CompanyType like '%" + CompanyType + "%'"
- }
- if SetupTime != "" {
- where = where + " and SetupTime like '%" + SetupTime + "%'"
- }
- if DepositBank != "" {
- where = where + " and DepositBank like '%" + DepositBank + "%'"
- }
- if BankAccount != "" {
- where = where + " and BankAccount like '%" + BankAccount + "%'"
- }
- if EMail != "" {
- where = where + " and EMail like '%" + EMail + "%'"
- }
- if BankCreditRating != "" {
- where = where + " and BankCreditRating like '%" + BankCreditRating + "%'"
- }
- if Mobile != "" {
- where = where + " and Mobile like '%" + Mobile + "%'"
- }
- if Telphone != "" {
- where = where + " and Telphone like '%" + Telphone + "%'"
- }
- if Fax != "" {
- where = where + " and Fax like '%" + Fax + "%'"
- }
- if CompanyTel != "" {
- where = where + " and CompanyTel like '%" + CompanyTel + "%'"
- }
- if QQ != "" {
- where = where + " and QQ like '%" + QQ + "%'"
- }
- if CompanyUrl != "" {
- where = where + " and CompanyUrl like '%" + CompanyUrl + "%'"
- }
- if SpecSupplier != "" {
- where = where + " and SpecSupplier like '%" + SpecSupplier + "%'"
- }
- if SpecTypeCode != "" {
- where = where + " and SpecTypeCode like '%" + SpecTypeCode + "%'"
- }
- if SpecTypeName != "" {
- where = where + " and SpecTypeName like '%" + SpecTypeName + "%'"
- }
- if Remark != "" {
- where = where + " and Remark like '%" + Remark + "%'"
- }
- if IsDelete != "" {
- where = where + " and IsDelete like '%" + IsDelete + "%'"
- }
- if CreateUserId != "" {
- where = where + " and CreateUserId like '%" + CreateUserId + "%'"
- }
- if CreateBy != "" {
- where = where + " and CreateBy like '%" + CreateBy + "%'"
- }
- if ModifiedOn != "" {
- where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
- }
- if ModifiedUserId != "" {
- where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
- }
- if ModifiedBy != "" {
- where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- var list []supplier.OilSupplier
- total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplier
- // @router /certlist [get]
- func (this *OilSupplierController) GetJoinCertEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierName := this.GetString("SupplierName")
- OilCertificateNo := this.GetString("OilCertificateNo")
- Grade := this.GetString("Grade")
- MgrUnit := this.GetString("MgrUnit")
- OperType := this.GetString("OperType")
- Country := this.GetString("Country")
- MaunAgent := this.GetString("MaunAgent")
- ConstructTeam := this.GetString("ConstructTeam")
- CommercialNo := this.GetString("CommercialNo")
- OrganCode := this.GetString("OrganCode")
- CountryTaxNo := this.GetString("CountryTaxNo")
- LocalTaxNo := this.GetString("LocalTaxNo")
- Address := this.GetString("Address")
- Province := this.GetString("Province")
- City := this.GetString("City")
- Street := this.GetString("Street")
- HouseNo := this.GetString("HouseNo")
- ZipCode := this.GetString("ZipCode")
- QualitySystemCert := this.GetString("QualitySystemCert")
- ProductQualityCert := this.GetString("ProductQualityCert")
- MaunLicense := this.GetString("MaunLicense")
- QualifCert := this.GetString("QualifCert")
- QualifCertLevel := this.GetString("QualifCertLevel")
- SafetyLicense := this.GetString("SafetyLicense")
- TechServiceLic := this.GetString("TechServiceLic")
- TJInNotify := this.GetString("TJInNotify")
- SpecIndustryCert := this.GetString("SpecIndustryCert")
- LegalPerson := this.GetString("LegalPerson")
- CategoryCode := this.GetString("CategoryCode")
- CategoryName := this.GetString("CategoryName")
- RegCapital := this.GetString("RegCapital")
- Currency := this.GetString("Currency")
- ContactName := this.GetString("ContactName")
- CompanyType := this.GetString("CompanyType")
- SetupTime := this.GetString("SetupTime")
- DepositBank := this.GetString("DepositBank")
- BankAccount := this.GetString("BankAccount")
- EMail := this.GetString("EMail")
- BankCreditRating := this.GetString("BankCreditRating")
- Mobile := this.GetString("Mobile")
- Telphone := this.GetString("Telphone")
- Fax := this.GetString("Fax")
- CompanyTel := this.GetString("CompanyTel")
- QQ := this.GetString("QQ")
- CompanyUrl := this.GetString("CompanyUrl")
- SpecSupplier := this.GetString("SpecSupplier")
- SpecTypeCode := this.GetString("SpecTypeCode")
- SpecTypeName := this.GetString("SpecTypeName")
- Remark := this.GetString("Remark")
- CreateOn := this.GetString("CreateOn")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- if Id != "" {
- where = where + " and a.Id like '%" + Id + "%'"
- }
- if SupplierName != "" {
- where = where + " and a.SupplierName like '%" + SupplierName + "%'"
- }
- if OilCertificateNo != "" {
- where = where + " and a.OilCertificateNo like '%" + OilCertificateNo + "%'"
- }
- if Grade != "" {
- where = where + " and a.Grade like '%" + Grade + "%'"
- }
- if MgrUnit != "" {
- where = where + " and a.MgrUnit like '%" + MgrUnit + "%'"
- }
- if OperType != "" {
- where = where + " and a.OperType like '%" + OperType + "%'"
- }
- if Country != "" {
- where = where + " and a.Country like '%" + Country + "%'"
- }
- if MaunAgent != "" {
- where = where + " and a.MaunAgent like '%" + MaunAgent + "%'"
- }
- if ConstructTeam != "" {
- where = where + " and a.ConstructTeam like '%" + ConstructTeam + "%'"
- }
- if CommercialNo != "" {
- where = where + " and a.CommercialNo like '%" + CommercialNo + "%'"
- }
- if OrganCode != "" {
- where = where + " and a.OrganCode like '%" + OrganCode + "%'"
- }
- if CountryTaxNo != "" {
- where = where + " and a.CountryTaxNo like '%" + CountryTaxNo + "%'"
- }
- if LocalTaxNo != "" {
- where = where + " and a.LocalTaxNo like '%" + LocalTaxNo + "%'"
- }
- if Address != "" {
- where = where + " and a.Address like '%" + Address + "%'"
- }
- if Province != "" {
- where = where + " and a.Province like '%" + Province + "%'"
- }
- if City != "" {
- where = where + " and a.City like '%" + City + "%'"
- }
- if Street != "" {
- where = where + " and a.Street like '%" + Street + "%'"
- }
- if HouseNo != "" {
- where = where + " and a.HouseNo like '%" + HouseNo + "%'"
- }
- if ZipCode != "" {
- where = where + " and a.ZipCode like '%" + ZipCode + "%'"
- }
- if QualitySystemCert != "" {
- where = where + " and a.QualitySystemCert like '%" + QualitySystemCert + "%'"
- }
- if ProductQualityCert != "" {
- where = where + " and a.ProductQualityCert like '%" + ProductQualityCert + "%'"
- }
- if MaunLicense != "" {
- where = where + " and a.MaunLicense like '%" + MaunLicense + "%'"
- }
- if QualifCert != "" {
- where = where + " and a.QualifCert like '%" + QualifCert + "%'"
- }
- if QualifCertLevel != "" {
- where = where + " and a.QualifCertLevel like '%" + QualifCertLevel + "%'"
- }
- if SafetyLicense != "" {
- where = where + " and a.SafetyLicense like '%" + SafetyLicense + "%'"
- }
- if TechServiceLic != "" {
- where = where + " and a.TechServiceLic like '%" + TechServiceLic + "%'"
- }
- if TJInNotify != "" {
- where = where + " and a.TJInNotify like '%" + TJInNotify + "%'"
- }
- if SpecIndustryCert != "" {
- where = where + " and a.SpecIndustryCert like '%" + SpecIndustryCert + "%'"
- }
- if LegalPerson != "" {
- where = where + " and a.LegalPerson like '%" + LegalPerson + "%'"
- }
- if CategoryCode != "" {
- where = where + " and a.CategoryCode like '%" + CategoryCode + "%'"
- }
- if CategoryName != "" {
- where = where + " and a.CategoryName like '%" + CategoryName + "%'"
- }
- if RegCapital != "" {
- where = where + " and a.RegCapital like '%" + RegCapital + "%'"
- }
- if Currency != "" {
- where = where + " and a.Currency like '%" + Currency + "%'"
- }
- if ContactName != "" {
- where = where + " and a.ContactName like '%" + ContactName + "%'"
- }
- if CompanyType != "" {
- where = where + " and a.CompanyType like '%" + CompanyType + "%'"
- }
- if SetupTime != "" {
- where = where + " and a.SetupTime like '%" + SetupTime + "%'"
- }
- if DepositBank != "" {
- where = where + " and a.DepositBank like '%" + DepositBank + "%'"
- }
- if BankAccount != "" {
- where = where + " and a.BankAccount like '%" + BankAccount + "%'"
- }
- if EMail != "" {
- where = where + " and a.EMail like '%" + EMail + "%'"
- }
- if BankCreditRating != "" {
- where = where + " and a.BankCreditRating like '%" + BankCreditRating + "%'"
- }
- if Mobile != "" {
- where = where + " and a.Mobile like '%" + Mobile + "%'"
- }
- if Telphone != "" {
- where = where + " and a.Telphone like '%" + Telphone + "%'"
- }
- if Fax != "" {
- where = where + " and a.Fax like '%" + Fax + "%'"
- }
- if CompanyTel != "" {
- where = where + " and a.CompanyTel like '%" + CompanyTel + "%'"
- }
- if QQ != "" {
- where = where + " and a.QQ like '%" + QQ + "%'"
- }
- if CompanyUrl != "" {
- where = where + " and a.CompanyUrl like '%" + CompanyUrl + "%'"
- }
- if SpecSupplier != "" {
- where = where + " and a.SpecSupplier like '%" + SpecSupplier + "%'"
- }
- if SpecTypeCode != "" {
- where = where + " and a.SpecTypeCode like '%" + SpecTypeCode + "%'"
- }
- if SpecTypeName != "" {
- where = where + " and a.SpecTypeName like '%" + SpecTypeName + "%'"
- }
- if Remark != "" {
- where = where + " and a.Remark like '%" + Remark + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
- }
- }
- if SupplierTypeCode != "" {
- where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
- }
- svc := supplier.GetOilSupplierService(utils.DBE)
- var list []supplier.OilSupplierView
- var total int64
- if where == "" {
- where = " 1=1 "
- }
- //获取总记录数
- sqlCount := `select count(*) from ` + OilSupplierName + ` a `
- sqlCount += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
- sqlCount += ` where ` + where
- var sql string
- sql = `select a.*, b.Id as CertId, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName from ` + OilSupplierName + ` a `
- sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
- sql += ` where ` + where
- if asc {
- sql += ` order by ` + orderby + ` ASC `
- } else {
- sql += ` order by ` + orderby + ` DESC `
- }
- sql += ` limit ` + utils.ToStr((page.CurrentPage-1)*page.Size) + "," + utils.ToStr(page.Size)
- utils.DBE.SQL(sql).Find(&list)
- resultsSlice, _ := svc.DBE.Query(sqlCount)
- if len(resultsSlice) > 0 {
- results := resultsSlice[0]
- for _, value := range results {
- total, _ = strconv.ParseInt(string(value), 10, 64)
- break
- }
- }
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取字典列表
- // @Description get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /dictlist [get]
- func (this *OilSupplierController) GetDictList() {
- dictList := make(map[string]interface{})
- //dictSvc := items.GetItemsService(utils.DBE)
- userSvc := baseUser.GetBaseUserService(utils.DBE)
- //customerSvc := svccustomer.GetCustomerService(utils.DBE)
- //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /get/:id [get]
- func (this *OilSupplierController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} supplier.OilSupplier
- // @router /getandcert/:certId [get]
- func (this *OilSupplierController) GetEntityAndCert() {
- Id := this.Ctx.Input.Param(":certId")
- var model supplier.OilSupplierView
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntityByIdBytbl(OilSupplierName, Id, &model)
- var sql string
- sql = `select a.*, b.Id as CertId, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName, b.Step, b.WorkerTotal, b.ContractNum, b.UniversityNum, b.TechnicalNum, b.AboveProfNum, b.MiddleProfNum, b.NationalRegNum, b.NationalCertTotal, b.DesignerTotal, b.SkillerTotal from ` + OilSupplierName + ` a `
- sql += ` left join ` + OilSupplierCertName + " b on b.SupplierId = a.Id"
- sql += ` where b.Id ='` + Id + `'`
- utils.DBE.SQL(sql).Get(&model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增
- // @Param body body supplier.OilSupplier
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilSupplierController) AddEntity() {
- var model supplier.OilSupplier
- var modelCert suppliercert.OilSupplierCert
- var modelCertVM suppliercert.OilSupplierVM
- var jsonBlob = this.Ctx.Input.RequestBody
- var session *xorm.Session
- session = utils.DBE.NewSession()
- svc := supplier.GetOilSupplierSession(session)
- svcCert := suppliercert.GetOilSupplierCertSession(session)
- json.Unmarshal(jsonBlob, &model)
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
- defer session.Close()
- err := session.Begin()
- _, err = svc.InsertEntityBytbl(OilSupplierName, &model)
- if err != nil {
- session.Rollback()
- }
- modelCert.SupplierId = model.Id
- json.Unmarshal(jsonBlob, &modelCertVM)
- modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
- modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
- modelCert.Step = 1 //企业信息保存完成
- modelCert.CreateOn = time.Now()
- modelCert.CreateBy = this.User.Realname
- modelCert.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- _, err = svcCert.InsertEntityBytbl(OilSupplierCertName, &modelCert)
- if err != nil {
- session.Rollback()
- }
- // add Commit() after all actions
- err = session.Commit()
- var errinfo ErrorDataInfo
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = strconv.Itoa(model.Id) + "_" + strconv.Itoa(modelCert.Id)
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Param body body supplier.OilSupplier
- // @Success 200 {object} controllers.Request
- // @router /update/:id [post]
- func (this *OilSupplierController) UpdateEntity() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "SupplierName",
- "OilCertificateNo",
- "Grade",
- "MgrUnit",
- "OperType",
- "Country",
- "MaunAgent",
- "ConstructTeam",
- "CommercialNo",
- "OrganCode",
- "CountryTaxNo",
- "LocalTaxNo",
- "Address",
- "Province",
- "City",
- "Street",
- "HouseNo",
- "ZipCode",
- "QualitySystemCert",
- "ProductQualityCert",
- "MaunLicense",
- "QualifCert",
- "QualifCertLevel",
- "SafetyLicense",
- "TechServiceLic",
- "TJInNotify",
- "SpecIndustryCert",
- "LegalPerson",
- "CategoryCode",
- "CategoryName",
- "RegCapital",
- "Currency",
- "ContactName",
- "CompanyType",
- "SetupTime",
- "DepositBank",
- "BankAccount",
- "EMail",
- "BankCreditRating",
- "Mobile",
- "Telphone",
- "Fax",
- "CompanyTel",
- "QQ",
- "CompanyUrl",
- "SpecSupplier",
- "SpecTypeCode",
- "SpecTypeName",
- "WorkerTotal",
- "ContractNum ",
- "UniversityNum",
- "TechnicalNum",
- "AboveProfNum",
- "MiddleProfNum",
- "NationalRegNum",
- "NationalCertTotal",
- "DesignerTotal",
- "SkillerTotal",
- "Remark",
- "IsDelete",
- "CreateOn",
- "CreateUserId",
- "CreateBy",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, cols)
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改企业人员情况实体
- // @Description 修改实体
- // @Param body body supplier.OilSupplier
- // @Success 200 {object} controllers.Request
- // @router /updatenumber/:id [post]
- func (this *OilSupplierController) UpdateNumberEntity() {
- idGroup := this.Ctx.Input.Param(":id")
- //id := strings.Split(idGroup, "_")[0]
- certId := strings.Split(idGroup, "_")[1]
- var errinfo ErrorInfo
- if certId == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var modelCert suppliercert.OilSupplierCert
- svcCert := suppliercert.GetOilSupplierCertService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &modelCert)
- modelCert.ModifiedOn = time.Now()
- modelCert.ModifiedBy = this.User.Realname
- modelCert.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- colcerts := []string{
- "Id",
- "WorkerTotal",
- "ContractNum ",
- "UniversityNum",
- "TechnicalNum",
- "AboveProfNum",
- "MiddleProfNum",
- "NationalRegNum",
- "NationalCertTotal",
- "DesignerTotal",
- "SkillerTotal",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- if modelCert.Step <= 2 {
- modelCert.Step = 2 //完成企业基本信息
- colcerts = append(colcerts, "Step")
- }
- err := svcCert.UpdateEntityBytbl(OilSupplierCertName, certId, &modelCert, colcerts)
- if err == nil {
- errinfo.Message = "保存成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除单条信息
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /delete/:Id [delete]
- func (this *OilSupplierController) DeleteEntity() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model supplier.OilSupplier
- var entityempty supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 启动工作流
- // @Description 启动工作流
- // @Param body body supplier.OilSupplier
- // @Success 200 {object} controllers.Request
- // @router /workflow/:id [post]
- func (this *OilSupplierController) StartAudit() {
- //测试多实例工作流
- svcFlow := supplier.GetOilSupplierService(utils.DBE)
- svcFlow.StartAudit()
- }
|