| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304 |
- package oilcontract
- import (
- "dashoo.cn/backend/api/business/auditsetting"
- "dashoo.cn/backend/api/business/oilcontract/contractReview"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/organize"
- "dashoo.cn/backend/api/business/workflow"
- "encoding/json"
- "fmt"
- "github.com/tealeg/xlsx"
- "log"
- "os"
- "reflect"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilcontract/contract"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business2/items"
- "dashoo.cn/business2/userRole"
- "dashoo.cn/utils"
- )
- type OilContractController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []oilcontract.OilContract
- // @router /list [get]
- func (this *OilContractController) 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")
- SupplierId := this.GetString("SupplierId")
- SupplierName := this.GetString("SupplierName")
- ImportSupplierName := this.GetString("ImportSupplierName")
- Status := this.GetString("Status")
- SettleStatus := this.GetString("SettleStatus")
- ProjectName := this.GetString("ProjectName")
- ContractNo := this.GetString("ContractNo")
- ProjectPlace := this.GetString("ProjectPlace")
- ProjectOwner := this.GetString("ProjectOwner")
- Telephone := this.GetString("Telephone")
- ProjectType := this.GetString("ProjectType")
- ContractMode := this.GetString("ContractMode")
- Amount := this.GetString("Amount")
- ContractPeriod := this.GetString("ContractPeriod")
- EndDate := this.GetString("EndDate")
- StartDate := this.GetString("StartDate")
- ConstructionUnit := this.GetString("ConstructionUnit")
- ConstructionOwner := this.GetString("ConstructionOwner")
- ConstructionTelphone := this.GetString("ConstructionTelphone")
- BuildUnit := this.GetString("BuildUnit")
- BuildOwner := this.GetString("BuildOwner")
- BuildTelphone := this.GetString("BuildTelphone")
- SuperviseUnit := this.GetString("SuperviseUnit")
- SuperviseOwner := this.GetString("SuperviseOwner")
- SuperviseTelphone := this.GetString("SuperviseTelphone")
- QualityUnit := this.GetString("QualityUnit")
- QualityOwner := this.GetString("QualityOwner")
- QualityTelphone := this.GetString("QualityTelphone")
- 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")
- ContractName := this.GetString("ContractName")
- ContractSonClass := this.GetString("ContractSonClass")
- SmallClass := this.GetString("SmallClass")
- SignedDate := this.GetString("SignedDate")
- People := this.GetString("People")
- Number := this.GetString("Number")
- ChooseWay := this.GetString("ChooseWay")
- ContractMark := this.GetString("ContractMark")
- Currency := this.GetString("Currency")
- BudgetAmount := this.GetString("BudgetAmount")
- PerformAmount := this.GetString("PerformAmount")
- IsInternal := this.GetString("IsInternal")
- IsForeign := this.GetString("IsForeign")
- IsDeal := this.GetString("IsDeal")
- MoneyFlows := this.GetString("MoneyFlows")
- MoneyChannel := this.GetString("MoneyChannel")
- MoneyChannelSon := this.GetString("MoneyChannelSon")
- MoneyChannelSmall := this.GetString("MoneyChannelSmall")
- SingUnit := this.GetString("SingUnit")
- Place := this.GetString("Place")
- DisputeResolution := this.GetString("DisputeResolution")
- SubmitDate := this.GetString("SubmitDate")
- SealName := this.GetString("SealName")
- PoNumber := this.GetString("PoNumber")
- SubPackage := this.GetString("SubPackage")
- ImportStatus := this.GetString("ImportStatus")
- ContractClass := this.GetString("ContractClass")
- if Id != "" {
- where = where + " and Id like '%" + Id + "%'"
- }
- if ContractClass != "" {
- where = where + " and ContractClass='" + ContractClass + "' "
- }
- if SupplierId != "" {
- where = where + " and SupplierId like '%" + SupplierId + "%'"
- }
- if SupplierName != "" {
- where = where + " and SupplierName like '%" + SupplierName + "%'"
- }
- if ImportSupplierName != "" {
- where = where + " and ImportSupplierName like '%" + ImportSupplierName + "%'"
- }
- if Status != "" {
- where = where + " and Status=" + Status + " "
- }
- if SettleStatus != "" {
- where = where + " and SettleStatus='" + SettleStatus + "' "
- }
- if ProjectName != "" {
- where = where + " and ProjectName like '%" + ProjectName + "%'"
- }
- if ContractNo != "" {
- where = where + " and ContractNo like '%" + ContractNo + "%'"
- }
- if ProjectPlace != "" {
- where = where + " and ProjectPlace like '%" + ProjectPlace + "%'"
- }
- if ProjectOwner != "" {
- where = where + " and ProjectOwner like '%" + ProjectOwner + "%'"
- }
- if Telephone != "" {
- where = where + " and Telephone like '%" + Telephone + "%'"
- }
- if ProjectType != "" {
- where = where + " and ProjectType like '%" + ProjectType + "%'"
- }
- if ContractMode != "" {
- where = where + " and ContractMode like '%" + ContractMode + "%'"
- }
- if Amount != "" {
- where = where + " and Amount like '%" + Amount + "%'"
- }
- if ContractPeriod != "" {
- where = where + " and ContractPeriod like '%" + ContractPeriod + "%'"
- }
- if EndDate != "" {
- where = where + " and EndDate like '%" + EndDate + "%'"
- }
- if StartDate != "" {
- where = where + " and StartDate like '%" + StartDate + "%'"
- }
- if ConstructionUnit != "" {
- where = where + " and ConstructionUnit like '%" + ConstructionUnit + "%'"
- }
- if ConstructionOwner != "" {
- where = where + " and ConstructionOwner like '%" + ConstructionOwner + "%'"
- }
- if ConstructionTelphone != "" {
- where = where + " and ConstructionTelphone like '%" + ConstructionTelphone + "%'"
- }
- if BuildUnit != "" {
- where = where + " and BuildUnit like '%" + BuildUnit + "%'"
- }
- if BuildOwner != "" {
- where = where + " and BuildOwner like '%" + BuildOwner + "%'"
- }
- if BuildTelphone != "" {
- where = where + " and BuildTelphone like '%" + BuildTelphone + "%'"
- }
- if SuperviseUnit != "" {
- where = where + " and SuperviseUnit like '%" + SuperviseUnit + "%'"
- }
- if SuperviseOwner != "" {
- where = where + " and SuperviseOwner like '%" + SuperviseOwner + "%'"
- }
- if SuperviseTelphone != "" {
- where = where + " and SuperviseTelphone like '%" + SuperviseTelphone + "%'"
- }
- if QualityUnit != "" {
- where = where + " and QualityUnit like '%" + QualityUnit + "%'"
- }
- if QualityOwner != "" {
- where = where + " and QualityOwner like '%" + QualityOwner + "%'"
- }
- if QualityTelphone != "" {
- where = where + " and QualityTelphone like '%" + QualityTelphone + "%'"
- }
- if Remark != "" {
- where = where + " and Remark like '%" + Remark + "%'"
- }
- if IsDelete != "" {
- where = where + " and IsDelete like '%" + IsDelete + "%'"
- }
- //if CreateOn != "" {
- // where = where + " and CreateOn like '%" + CreateOn + "%'"
- //}
- 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 + "'"
- }
- }
- if SubPackage != "" {
- where = where + " and SubPackage like '%" + SubPackage + "%'"
- }
- if ContractName != "" {
- where = where + " and ContractName like '%" + ContractName + "%'"
- }
- if ContractSonClass != "" {
- where = where + " and ContractSonClass like '%" + ContractSonClass + "%'"
- }
- if SmallClass != "" {
- where = where + " and SmallClass like '%" + SmallClass + "%'"
- }
- if People != "" {
- where = where + " and People like '%" + People + "%'"
- }
- if Number != "" {
- where = where + " and Number like '%" + Number + "%'"
- }
- if ChooseWay != "" {
- where = where + " and ChooseWay like '%" + ChooseWay + "%'"
- }
- if ContractMark != "" {
- where = where + " and ContractMark like '%" + ContractMark + "%'"
- }
- if Currency != "" {
- where = where + " and Currency like '%" + Currency + "%'"
- }
- if BudgetAmount != "" {
- where = where + " and BudgetAmount like '%" + BudgetAmount + "%'"
- }
- if PerformAmount != "" {
- where = where + " and PerformAmount like '%" + PerformAmount + "%'"
- }
- if IsInternal != "" {
- where = where + " and IsInternal like '%" + IsInternal + "%'"
- }
- if IsForeign != "" {
- where = where + " and IsForeign like '%" + IsForeign + "%'"
- }
- if IsDeal != "" {
- where = where + " and IsDeal like '%" + IsDeal + "%'"
- }
- if MoneyFlows != "" {
- where = where + " and MoneyFlows like '%" + MoneyFlows + "%'"
- }
- if MoneyChannel != "" {
- where = where + " and MoneyChannel like '%" + MoneyChannel + "%'"
- }
- if MoneyChannelSon != "" {
- where = where + " and MoneyChannelSon like '%" + MoneyChannelSon + "%'"
- }
- if MoneyChannelSmall != "" {
- where = where + " and MoneyChannelSmall like '%" + MoneyChannelSmall + "%'"
- }
- if SingUnit != "" {
- where = where + " and SingUnit like '%" + SingUnit + "%'"
- }
- if Place != "" {
- where = where + " and Place like '%" + Place + "%'"
- }
- if DisputeResolution != "" {
- where = where + " and DisputeResolution like '%" + DisputeResolution + "%'"
- }
- if SubmitDate != "" {
- where = where + " and SubmitDate like '%" + SubmitDate + "%'"
- }
- if SealName != "" {
- where = where + " and SealName like '%" + SealName + "%'"
- }
- if PoNumber != "" {
- where = where + " and PoNumber like '%" + PoNumber + "%'"
- }
- if SignedDate != "" {
- where = where + " and PoNumber like '%" + SignedDate + "%'"
- }
- if ImportStatus != "" {
- where = where + " and ImportStatus = " + ImportStatus
- } else {
- where = where + " and ImportStatus != 0"
- }
- // 企管法规处可看所有合同, 获取企管法规处人员
- var settingReg auditsetting.Base_OilAuditSetting
- orgSvc := organize.GetOrganizeService(utils.DBE)
- wherePRegAudit := "AuditStepCode='PROF_REGULATION'"
- orgSvc.GetEntity(&settingReg, wherePRegAudit) // PROF_AUDIT
- res1 := orgSvc.UserInRoleById(this.User.Id, strconv.Itoa(settingReg.RoleId))
- // 所有业务处室分办单位可查看所有合同 TODO 待确认
- var settingProf auditsetting.Base_OilAuditSetting
- wherePAudit := "AuditStepCode='PROF_RECE'"
- orgSvc.GetEntity(&settingProf, wherePAudit) // PROF_AUDIT
- res2 := orgSvc.UserInRoleById(this.User.Id, strconv.Itoa(settingProf.RoleId))
- if !res1 && !res2 {
- where = where + " and SecondUnit= " + strconv.Itoa(this.User.UnitId)
- }
- svc := contract.GetOilContractService(utils.DBE)
- var list []contract.OilContract
- 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} map[string]interface{}
- // @router /dictlist [get]
- func (this *OilContractController) 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", "")
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId("", userEntity.Departmentid)
- dictList["ContractClass"] = dictSvc.GetKeyValueItems("ContractClass")
- dictList["ProjectType"] = dictSvc.GetKeyValueItems("ProjectType")
- dictList["ContractMode"] = dictSvc.GetKeyValueItems("ContractMode")
- dictList["CurrencyType"] = dictSvc.GetKeyValueItems("CurrencyType")
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere("" + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 完成合同
- // @Description get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /finish/:id [get]
- //func (this *OilContractController) Finish(){
- // 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 contract.OilContract
- // svc := contract.GetOilContractService(utils.DBE)
- // model.Status = 2
- // cols := []string{
- // "Status",
- // }
- // err := svc.UpdateEntityBytbl(OilContractName, 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 获取实体
- // @Success 200 {object} oilcontract.OilContract
- // @router /get/:id [get]
- func (this *OilContractController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model contract.OilContract
- svc := contract.GetOilContractService(utils.DBE)
- svc.GetEntityByIdBytbl(OilContractName, Id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title get 导入excel
- // @Description 导入excel
- // @Success 200 {object} controllers.Request
- // @router /importexcel [get]
- func (this *OilContractController) ImportExcel() {
- go func() {
- url := this.GetString("ExcelUrl")
- //var errLineNum string
- if url == "" {
- fmt.Println("文件不能为空!")
- }
- _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
- filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
- utils.DownloadFile(url, filename, _dir)
- t := time.Now()
- filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
- xlFile, err := xlsx.OpenFile(filePath)
- //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
- if err != nil {
- fmt.Printf("open failed: %s\n", err)
- }
- var sheet = xlFile.Sheets[0]
- // 插入字段
- //Fstrs := "ContractNo,ContractName,Amount,ContractType,ContractSonClass,SmallClass,SignedDate,Number,ChooseWay,ContractMark,Currency,BudgetAmount,PerformAmount,IsInternal,IsForeign,IsDeal,MoneyFlows,MoneyChannel,MoneyChannelSon,MoneyChannelSmall,SingUnit,Place,StartDate,EndDate,DisputeResolution,Remark,ProjectOwner,SubmitDate,SealName,PoNumber"
- //columnArr := strings.Split(Fstrs, ",")
- //timeTemplate1 := "2006/01/02 15:04:05" //常规类型
- svc := contract.GetOilContractService(utils.DBE)
- for i := 1; i < len(sheet.Rows); i++ {
- var con contract.OilContract
- var con1 contract.OilContract
- lineNo := strconv.Itoa(i + 1)
- fmt.Println(lineNo)
- svc.GetEntityByWhere(OilContractName, "ContractNo = '"+sheet.Rows[i].Cells[0].String()+"'", &con1)
- if con1.Id > 0 {
- con1.ContractName = sheet.Rows[i].Cells[1].String()
- con1.Amount = sheet.Rows[i].Cells[2].String()
- con1.ClassName = sheet.Rows[i].Cells[3].String()
- con1.ContractSonClass = sheet.Rows[i].Cells[4].String()
- con1.SmallClass = sheet.Rows[i].Cells[5].String()
- con1.SignedDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[6].Value), time.Local)
- con1.Number = sheet.Rows[i].Cells[9].String()
- con1.ChooseWay = sheet.Rows[i].Cells[10].String()
- con1.ContractMark = sheet.Rows[i].Cells[11].String()
- con1.Currency = sheet.Rows[i].Cells[12].String()
- con1.BudgetAmount = sheet.Rows[i].Cells[13].String()
- con1.PerformAmount = sheet.Rows[i].Cells[14].String()
- con1.IsYearMoney = con1.PerformAmount
- con1.IsInternal = 0
- if sheet.Rows[i].Cells[15].String() == "是" {
- con1.IsInternal = 1
- }
- con1.IsForeign = 0
- if sheet.Rows[i].Cells[16].String() == "是" {
- con1.IsForeign = 1
- }
- con1.IsDeal = 0
- if sheet.Rows[i].Cells[17].String() == "是" {
- con1.IsDeal = 1
- }
- con1.MoneyFlows = sheet.Rows[i].Cells[18].String()
- con1.MoneyChannel = sheet.Rows[i].Cells[19].String()
- con1.MoneyChannelSon = sheet.Rows[i].Cells[20].String()
- con1.MoneyChannelSmall = sheet.Rows[i].Cells[21].String()
- con1.SingUnit = sheet.Rows[i].Cells[22].String()
- con1.Place = sheet.Rows[i].Cells[23].String()
- con1.StartDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[24].Value), time.Local)
- con1.EndDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
- con1.YearDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
- con1.DisputeResolution = sheet.Rows[i].Cells[26].String()
- con1.Remark = sheet.Rows[i].Cells[27].String()
- if con1.ProjectOwner != sheet.Rows[i].Cells[28].String() {
- con1.ProjectOwner = con1.ProjectOwner + "," + sheet.Rows[i].Cells[28].String()
- }
- con1.SubmitDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[29].Value), time.Local)
- con1.SealName = sheet.Rows[i].Cells[30].String()
- con1.PoNumber = sheet.Rows[i].Cells[31].String()
- con1.ImportStatus = 0
- svc.UpdateEntityById(con1.Id, &con1)
- continue
- }
- con.ContractNo = sheet.Rows[i].Cells[0].String()
- con.ContractName = sheet.Rows[i].Cells[1].String()
- con.Amount = sheet.Rows[i].Cells[2].String()
- con.ClassName = sheet.Rows[i].Cells[3].String()
- con.ContractSonClass = sheet.Rows[i].Cells[4].String()
- con.SmallClass = sheet.Rows[i].Cells[5].String()
- //con.SignedDate = convertToFormatDay(sheet.Rows[i].Cells[6].Value)
- con.SignedDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[6].Value), time.Local)
- con.ImportSecondUnit = sheet.Rows[i].Cells[7].String()
- con.ImportSupplierName = sheet.Rows[i].Cells[8].String()
- var supp supplier.OilSupplier
- svc.GetEntityByWhere(OilSupplierName, "SupplierName = '"+con.ImportSupplierName+"'", &supp)
- if supp.Id > 0 {
- con.SupplierId = supp.Id
- con.SupplierName = supp.SupplierName
- }
- var org organize.Base_Organize
- svc.GetEntityByWhere("Base_Organize", "FullName = '"+sheet.Rows[i].Cells[7].String()+"'", &org)
- if org.Id > 0 {
- con.SecondUnit = org.Id
- con.SecondUnitName = org.Fullname
- }
- con.Number = sheet.Rows[i].Cells[9].String()
- con.ChooseWay = sheet.Rows[i].Cells[10].String()
- con.ContractMark = sheet.Rows[i].Cells[11].String()
- con.Currency = sheet.Rows[i].Cells[12].String()
- con.BudgetAmount = sheet.Rows[i].Cells[13].String()
- con.PerformAmount = sheet.Rows[i].Cells[14].String()
- con.IsYearMoney = con.PerformAmount
- con.IsInternal = 0
- if sheet.Rows[i].Cells[15].String() == "是" {
- con.IsInternal = 1
- }
- con.IsForeign = 0
- if sheet.Rows[i].Cells[16].String() == "是" {
- con.IsForeign = 1
- }
- con.IsDeal = 0
- if sheet.Rows[i].Cells[17].String() == "是" {
- con.IsDeal = 1
- }
- con.MoneyFlows = sheet.Rows[i].Cells[18].String()
- con.MoneyChannel = sheet.Rows[i].Cells[19].String()
- con.MoneyChannelSon = sheet.Rows[i].Cells[20].String()
- con.MoneyChannelSmall = sheet.Rows[i].Cells[21].String()
- con.SingUnit = sheet.Rows[i].Cells[22].String()
- con.Place = sheet.Rows[i].Cells[23].String()
- con.StartDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[24].Value), time.Local)
- con.EndDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
- con.YearDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
- con.DisputeResolution = sheet.Rows[i].Cells[26].String()
- con.Remark = sheet.Rows[i].Cells[27].String()
- con.ProjectOwner = sheet.Rows[i].Cells[28].String()
- con.SubmitDate, _ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[29].Value), time.Local)
- con.SealName = sheet.Rows[i].Cells[30].String()
- con.PoNumber = sheet.Rows[i].Cells[31].String()
- con.ImportStatus = 0
- con.Status = 1
- con.SettleStatus = "1"
- _, err = svc.InsertEntityBytbl(OilContractName, &con)
- if err != nil {
- fmt.Println(err)
- }
- }
- os.Remove(filePath)
- elapsed := time.Since(t)
- log.Println(elapsed)
- }()
- var errorinfo ErrorDataInfo
- errorinfo.Code = 0
- errorinfo.Message = "导入中,请稍后!"
- this.Data["json"] = &errorinfo
- this.ServeJSON()
- }
- // @Title 从数据录入数据导出到word文档
- // @Description 数据存入word
- // @Success 200 {object} controllers.Request
- // @router /exportword/:id [get]
- func (this *OilContractController) DocExport() {
- // 填物资类信息表首页信息
- Id := this.Ctx.Input.Param(":id")
- var Url string
- var fileName string
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var model contract.OilContract
- svc := contract.GetOilContractService(utils.DBE)
- where := "1=1"
- where += " AND Id = '" + Id + "'"
- svc.GetEntityByWhere(OilContractName, where, &model)
- Url = utils.Cfg.MustValue("workflow", "contractUrl")
- fileName = "合同导出模板.docx"
- datamap := structToMapDemo(model)
- //datamap["TableComment"] = []string{"MajorEquipments", "ThreeYears", "Patent", "Winning"}
- retDocUrl := svcActiviti.FillWordTemplate(datamap, Url, fileName)
- //retDocUrl := svcActiviti.FillWordWatermarkTemplate(datamap, Url, fileName, model.SupplierName)
- var datainfo ErrorDataInfo
- datainfo.Code = 0
- datainfo.Item = retDocUrl
- datainfo.Message = "导出成功"
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title get 导入批量保存
- // @Description 数据存入
- // @Success 200 {object} controllers.Request
- // @router /importbatchsave [post]
- func (this *OilContractController) ImportBatchSave() {
- sql := "update OilContract set ImportStatus = 1 where SupplierId != 0 and ContractClass != '' and SecondUnit != 0"
- _, err := utils.DBE.Query(sql)
- var errinfo ErrorInfo
- 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 get 批量修改字段
- // @Description 批量修改字段
- // @Success 200 {object} controllers.Request
- // @router /importUpdate [get]
- func (this *OilContractController) ImportUpdate() {
- Class := this.GetString("Class")
- Value := this.GetString("Value")
- Column := this.GetString("Column")
- Id := this.GetString("Id")
- SupplierId := this.GetString("SupplierId")
- var supp supplier.OilSupplier
- svc := supplier.GetOilSupplierService(utils.DBE)
- svc.GetEntityById(SupplierId, &supp)
- sql := ""
- var err error
- where := "1=1"
- if Column == "ContractClass" {
- if Id != "0" {
- where += " and Id = " + Id + " and ImportStatus = 0 and ClassName = '" + Class + "'"
- sql = "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = '" + Value + "' where " + where
- } else {
- where += " and ImportStatus = 0 and ClassName = '" + Class + "' and " + Column + " = ''"
- sql = "update OilContract set " + Column + " = '" + Value + "' where " + where
- }
- _, err = utils.DBE.Query(sql)
- }
- if Column == "SupplierId" {
- if Id != "0" {
- where += " and Id = " + Id + " and ImportStatus = 0 and ImportSupplierName = '" + Class + "'"
- } else {
- where += " and ImportStatus = 0 and ImportSupplierName = '" + Class + "' and " + Column + " = 0"
- }
- sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
- _, err = utils.DBE.Query(sql)
- }
- if Column == "SecondUnit" {
- var org organize.Base_Organize
- svc.GetEntityByWhere("Base_Organize", "Id = "+Value, &org)
- if Id != "0" {
- where += " and Id = " + Id + " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "'"
- sql = "update OilContract set SecondUnitName = '" + org.Fullname + "',SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
- } else {
- where += " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "' and " + Column + " = 0"
- sql = "update OilContract set SecondUnitName = '" + org.Fullname + "'," + Column + " = " + Value + " where " + where
- }
- _, err = utils.DBE.Query(sql)
- }
- if Column == "Status" {
- where += " and Id = " + Id + " and ImportStatus = 0"
- sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
- _, err = utils.DBE.Query(sql)
- }
- if Column == "SettleStatus" {
- where += " and Id = " + Id + " and ImportStatus = 0"
- sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = '" + Value + "' where " + where
- _, err = utils.DBE.Query(sql)
- }
- var errinfo ErrorInfo
- 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()
- }
- }
- // excel日期字段格式化 yyyy-mm-dd
- func convertToFormatDay(excelDaysString string) string {
- // 2006-01-02 距离 1900-01-01的天数
- baseDiffDay := int64(38719) //在网上工具计算的天数需要加2天,什么原因没弄清楚
- curDiffDay := excelDaysString
- comma := strings.Index(curDiffDay, ".")
- if comma != -1 {
- curDiffDay = curDiffDay[0:comma]
- }
- b, _ := strconv.ParseInt(curDiffDay, 10, 64) //strconv.Atoi(curDiffDay)
- // 获取excel的日期距离2006-01-02的天数
- realDiffDay := b - baseDiffDay
- //fmt.Println("realDiffDay:",realDiffDay)
- // 距离2006-01-02 秒数
- realDiffSecond := realDiffDay * 24 * 3600
- //fmt.Println("realDiffSecond:",realDiffSecond)
- // 2006-01-02 15:04:05距离1970-01-01 08:00:00的秒数 网上工具可查出
- baseOriginSecond := int64(1136185445)
- resultTime := time.Unix((baseOriginSecond + realDiffSecond), 0).Format("2006-01-02")
- return resultTime
- }
- func (this *OilContractController) OperationCell(svc *contract.OilContractSession, lineNo string, columnArr []string, cellsArr []*xlsx.Cell, errLineNum *string) {
- defer func() {
- if err := recover(); err != nil {
- log.Println("err"+lineNo, err)
- *errLineNum += lineNo + ","
- }
- }()
- cellsArrLen := len(cellsArr)
- var valstr = ""
- for i := 0; i < cellsArrLen; i++ {
- valstr += "'" + cellsArr[i].String() + "',"
- }
- valstr = strings.Trim(valstr, ",")
- valstr = strings.Replace(valstr, "是", "1", -1)
- log.Println(cellsArr[6].String() + "==" + valstr)
- var columnstr = ""
- for l := 0; l < cellsArrLen; l++ {
- columnstr += columnArr[l] + ","
- }
- columnstr = strings.Trim(columnstr, ",")
- //err := svc.InsertTmpOilBasisBuild(columnstr, valstr)
- //if err != nil {
- // panic(err)
- //}
- }
- 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 添加
- // @Description 新增
- // @Param body body oilcontract.OilContract
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilContractController) AddEntity() {
- var errinfo ErrorDataInfo
- var model contract.OilContract
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := contract.GetOilContractService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- if model.IsYear == 1 && model.IsYearMoney == "" {
- errinfo.Message = "跨年当年结算金额必填"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- if model.IsYearMoney == "" {
- model.IsYearMoney = model.PerformAmount
- }
- model.ImportStatus = 2
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- model.SecondUnit = this.User.UnitId
- var model1 contract.OilContractMoney
- var contract contract.OilContract
- tempCount, _ := svc.GetCount(&contract, "ContractNo='"+model.ContractNo+"' ")
- if tempCount > 0 {
- errinfo.Message = "合同编号已存在!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- _, err := svc.InsertEntityBytbl(OilContractName, &model)
- if err == nil {
- if model.IsYear == 1 {
- svc.GetEntityByWhere(OilContractName, "ContractNo = '"+model.ContractNo+"'", &model)
- svc.GetEntityByWhere("OilContractMoney", "Year = '"+time.Now().Format("2006")+"' and ContractId = "+strconv.Itoa(model.Id), &model1)
- model1.ContractId = model.Id
- model1.Money = model.IsYearMoney
- model1.Year = time.Now().Format("2006")
- model1.CreateOn = time.Now()
- model1.CreateBy = this.User.Realname
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntityBytbl("OilContractMoney", &model1)
- }
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = model.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 oilcontract.OilContract
- // @Success 200 {object} controllers.Request
- // @router /update/:id [post]
- func (this *OilContractController) 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 contract.OilContract
- var model1 contract.OilContractMoney
- svc := contract.GetOilContractService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- if model.IsYear == 1 && model.IsYearMoney == "" {
- errinfo.Message = "跨年当年结算金额必填"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- if model.IsYearMoney == "" {
- model.IsYearMoney = model.PerformAmount
- }
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "SupplierId",
- "SupplierName",
- "Status",
- "SettleStatus",
- "ProjectName",
- "ContractNo",
- "ProjectPlace",
- "ProjectOwner",
- "Telephone",
- "ProjectType",
- "ContractMode",
- "Amount",
- "ContractPeriod",
- "EndDate",
- "YearDate",
- "StartDate",
- "ConstructionUnit",
- "ConstructionOwner",
- "ConstructionTelphone",
- "BuildUnit",
- "BuildOwner",
- "BuildTelphone",
- "SuperviseUnit",
- "SuperviseOwner",
- "SuperviseTelphone",
- "QualityUnit",
- "QualityOwner",
- "QualityTelphone",
- "Remark",
- "IsDelete",
- "CreateOn",
- "CreateUserId",
- "CreateBy",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- "SubPackage",
- "ContractName",
- "ContractSonClass",
- "SmallClass",
- "SignedDate",
- "People",
- "Number",
- "ChooseWay",
- "ContractMark",
- "Currency",
- "BudgetAmount",
- "PerformAmount",
- "IsInternal",
- "IsForeign",
- "IsDeal",
- "MoneyFlows",
- "MoneyChannelSon",
- "MoneyChannelSmall",
- "SingUnit",
- "Place",
- "DisputeResolution",
- "SubmitDate",
- "SealName",
- "PoNumber",
- "IsYearMoney",
- "IsYear",
- }
- var contract contract.OilContract
- tempCount, _ := svc.GetCount(&contract, "ContractNo='"+model.ContractNo+"' and id <> "+id)
- if tempCount > 0 {
- errinfo.Message = "合同编号已存在!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- date := time.Now().Format("2006-01-02")
- date1 := model.EndDate.Format("2006-01-02")
- if date >= date1 && model.IsYear == 1{
- model.YearDate = model.EndDate.AddDate(1,0,0)
- }
- err := svc.UpdateEntityBytbl(OilContractName, id, &model, cols)
- if err == nil {
- if model.IsYear == 1 && model.IsYearMoney != "" {
- svc.GetEntityByWhere("OilContractMoney", "Year = '"+time.Now().Format("2006")+"' and ContractId = "+id, &model1)
- if model1.Id > 0 {
- model1.Money = model.IsYearMoney
- model1.ModifiedOn = time.Now()
- model1.ModifiedBy = this.User.Realname
- model1.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.UpdateEntityBytbl("OilContractMoney", model1.Id, &model1, []string{"Money"})
- } else {
- model1.ContractId, _ = strconv.Atoi(id)
- model1.Money = model.IsYearMoney
- model1.Year = time.Now().Format("2006")
- model1.CreateOn = time.Now()
- model1.CreateBy = this.User.Realname
- model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntityBytbl("OilContractMoney", &model1)
- }
- }
- 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 *OilContractController) DeleteEntity() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- // 有没有待审核的评价
- itemsSvc := contractReview.GetOilContractReviewService(utils.DBE)
- var review contractReview.OilContractReview
- //tempCount,_:=itemsSvc.GetCount(&review,"ContractId='" + Id +"' and status > 0 and status < 8 ")
- tempCount, _ := itemsSvc.GetCount(&review, "ContractId='"+Id+"' ")
- if tempCount > 0 {
- errinfo.Message = "该合同存在评价不能删除!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model contract.OilContract
- var entityempty contract.OilContract
- svc := contract.GetOilContractService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilContractName, BaseOperationLogName, Id, &model, &entityempty,
- utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "合同表")
- 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 /countMoney/:Id [get]
- func (this *OilContractController) CountMoney() {
- 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 contract.OilContractMoney
- svc := contract.GetOilContractService(utils.DBE)
- svc.GetSum1(&model, "ContractId = " + Id + " and Year != '"+time.Now().Format("2006")+"'")
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取跨年记录
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /yearList/:Id [get]
- func (this *OilContractController) YearList() {
- 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 []contract.OilContractMoney1
- svc := contract.GetOilContractService(utils.DBE)
- svc.GetList(&model, "ContractId = " + Id)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []oilcontract.OilContract
- // @router /need-eva-list [get]
- func (this *OilContractController) GetNeedEvaList() {
- var list []contract.OilContract
- sql := ` select a.* from OilContract a left join OilContractReview b on b.ContractId=a.Id where a.SecondUnit=` + strconv.Itoa(this.User.UnitId) + ` and (b.Status=0 or b.Status=NULL) `
- utils.DBE.Sql(sql).Find(&list)
- var dataInfo DataInfo
- dataInfo.Items = list
- dataInfo.CurrentItemCount = 0
- if list != nil {
- dataInfo.CurrentItemCount = int64(len(list))
- }
- this.Data["json"] = &dataInfo
- this.ServeJSON()
- }
- // @Title 获取上报情况列表
- // @Description
- // @Success 200 {object} ErrorInfo
- // @router /handOnList [post]
- func (this *OilContractController) GetHandOnStatisticsList() {
- var queryParam contract.HandOnStatisticsQuery
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &queryParam)
- var models []contract.HandOnStatisticsEntity
- svc := contract.GetOilContractService(utils.DBE)
- total := svc.GetHandOnStatisticsList(queryParam, &models)
- var dataInfo DataInfo
- dataInfo.Items = models
- dataInfo.CurrentItemCount = total
- this.Data["json"] = &dataInfo
- this.ServeJSON()
- }
- // @Title 清空列表
- // @Description
- // @Success 200 {object} ErrorInfo
- // @router /deleteList [get]
- func (this *OilContractController) DeleteList() {
- svc := contract.GetOilContractService(utils.DBE)
- svc.DeleteEntityBytbl(OilContractName, "ImportStatus = 0")
- var errinfo ErrorInfo
- errinfo.Message = "清空成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- // @Title 一键更新二级单位名称
- // @Description
- // @Success 200 {object} ErrorInfo
- // @router /updateUnitName/:Id [get]
- func (this *OilContractController) UpdateUnitName() {
- Id := this.Ctx.Input.Param(":Id")
- UnitId := this.GetString("UnitId")
- ContractId := this.GetString("ContractId")
- var errinfo ErrorInfo
- if Id == "" || UnitId == ""{
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model contract.OilContract
- svc := contract.GetOilContractService(utils.DBE)
- var org organize.Base_Organize
- svc.GetEntityByWhere("Base_Organize", "Id = " + UnitId, &org)
- model.SecondUnit ,_= strconv.Atoi(UnitId)
- model.SecondUnitName = org.Fullname
- where := "SecondUnit = " + Id
- if ContractId != "" {
- where += " and Id = " + ContractId
- }
- svc.UpdateEntityBywheretbl(OilContractName, &model, []string{"SecondUnit", "SecondUnitName"}, where)
- errinfo.Message = "更新成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
|