package oilsupplier import ( "dashoo.cn/backend/api/business/oilsupplier/suppliercert" "dashoo.cn/backend/api/business/oilsupplier/supplierdataentry" "dashoo.cn/backend/api/business/oilsupplier/supplierpausereason" "dashoo.cn/backend/api/business/oilsupplier/tableheader" "dashoo.cn/backend/api/business/oilsupplier/technologyserviceclass" "dashoo.cn/backend/api/business/workflow" "encoding/json" "fmt" "github.com/tealeg/xlsx" "log" "os" "reflect" "strconv" "strings" "time" "dashoo.cn/backend/api/business/items" "dashoo.cn/backend/api/business/baseUser" "dashoo.cn/business2/userRole" "dashoo.cn/backend/api/business/oilsupplier/goodsaptitude" "dashoo.cn/backend/api/business/oilsupplier/supplier" "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub" "dashoo.cn/backend/api/business/oilsupplier/supplierfile" //"dashoo.cn/backend/api/business/items" "dashoo.cn/backend/api/business/oilsupplier/technologyservice" . "dashoo.cn/backend/api/controllers" "dashoo.cn/business2/parameter" "dashoo.cn/utils" . "github.com/linxGnu/goseaweedfs" ) type OilTechnologyServiceController struct { BaseController } // @Title 获取列表 // @Description get user by token // @Success 200 {object} []technologyservice.OilTechnologyService // @router /list [get] func (this *OilTechnologyServiceController) GetEntityList() { //获取分页信息 page := this.GetPageInfoForm() where := " 1=1 " orderby := "Code" asc := true Order := this.GetString("Order") Prop := this.GetString("Prop") if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } else { asc = false } } CreateOn := this.GetString("CreateOn") Code := this.GetString("Code") Name := this.GetString("Name") Code1 := this.GetString("Code1") Name1 := this.GetString("Name1") Code2 := this.GetString("Code2") Name2 := this.GetString("Name2") Code3 := this.GetString("Code3") Name3 := this.GetString("Name3") Code4 := this.GetString("Code4") Name4 := this.GetString("Name4") if Code != "" { where = where + " and Code like '" + Code + "%'" } if Name != "" { where = where + " and Name like '%" + Name + "%'" } if Code1 != "" { where = where + " and Code1 like '%" + Code1 + "%'" } if Name1 != "" { where = where + " and Name1 like '%" + Name1 + "%'" } if Code2 != "" { where = where + " and Code2 like '%" + Code2 + "%'" } if Name2 != "" { where = where + " and Name2 like '%" + Name2 + "%'" } if Code3 != "" { where = where + " and Code3 like '%" + Code3 + "%'" } if Name3 != "" { where = where + " and Name3 like '%" + Name3 + "%'" } if Code4 != "" { where = where + " and Code4 like '%" + Code4 + "%'" } if Name4 != "" { where = where + " and Name4 like '%" + Name4 + "%'" } 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 := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list []technologyservice.OilTechnologyServiceView total := svc.GetMyPagingEntitiesWithOrderBytbl(OilTechsrvDetailViewName, 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 *OilTechnologyServiceController) 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["AuditStep"] = dictSvc.GetKeyValueItems("AuditStep", this.User.AccCode) //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 获取实体 // @Success 200 {object} technologyservice.OilTechnologyService // @router /get/:id [get] func (this *OilTechnologyServiceController) GetEntity() { Id := this.Ctx.Input.Param(":id") var model technologyservice.OilTechnologyServiceView svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) //svc.GetEntityByIdBytbl(""+OilTechnologyServiceName, Id, &model) where := " Id =" + Id svc.GetEntityByWhere(OilTechsrvDetailViewName, where, &model) this.Data["json"] = &model this.ServeJSON() } // @Title 添加 // @Description 新增 // @Success 200 {object} controllers.Request // @router /add [post] func (this *OilTechnologyServiceController) AddEntity() { //classId := this.Ctx.Input.Param(":id") svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) var model technologyserviceclass.OilTechnologyServiceClass var classmodel technologyserviceclass.OilTechnologyServiceClass var parentedId technologyserviceclass.ParentedId var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &parentedId) json.Unmarshal(jsonBlob, &model) var errinfo ErrorDataInfo where := " Code = " + model.Code code := svc.GetEntityByWhere(OilTechnologyServiceClassName, where, &classmodel) if code { errinfo.Message = "编码不能重复!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } if parentedId.ParentId == 0 { where1 := " Code = " + Substr(model.Code, 0, 2) code1 := svc.GetEntityByWhere(OilTechnologyServiceClassName, where1, &classmodel) if code1 { errinfo.Message = "请选择父节点!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Code = Substr(model.Code, 0, 2) } } //where1 := " Name = " + model.Name //name := svc.GetEntityByWhere(OilGoodsAptitudeClassName, where1, &classmodel) //if name { // errinfo.Message = "名称不能重复!" // errinfo.Code = -1 // this.Data["json"] = &errinfo // this.ServeJSON() // return //} model.ParentId = parentedId.ParentId model.CreateOn = time.Now() model.CreateBy = this.User.Realname model.CreateUserId, _ = utils.StrTo(this.User.Id).Int() _, err := svc.InsertEntityBytbl(""+OilTechnologyServiceClassName, &model) var model2 technologyservice.OilTechnologyService json.Unmarshal(jsonBlob, &model2) model2.ClassId = model.Id model2.CreateOn = time.Now() model2.CreateBy = this.User.Realname model2.CreateUserId, _ = utils.StrTo(this.User.Id).Int() _, err = svc.InsertEntityBytbl(""+OilTechnologyServiceName, &model2) if err == nil { //新增 errinfo.Message = "添加成功!" errinfo.Code = 0 errinfo.Item = model2.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 修改实体 // @Success 200 {object} controllers.Request // @router /update/:id [post] func (this *OilTechnologyServiceController) 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 technologyservice.OilTechnologyService svc := technologyservice.GetOilTechnologyServiceService(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", "Code", "Name", "Code1", "Name1", "Code2", "Name2", "Code3", "Name3", "Code4", "Name4", "OrgId", "OrgName", "F01", "F02", "F03", "F04", "F05", "F06", "F07", "F08", "F09", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "F25", "F26", "F27", "F28", "F29", "F30", "F31", "F32", "F33", "F34", "F35", "F36", "F37", "F38", "F39", "F40", "F41", "F42", "F43", "F44", "F45", "F46", "F47", "F48", "F49", "F50", "F51", "F52", "Remark", "DeletionStateCode", "CreateOn", "CreateUserId", "CreateBy", "ModifiedOn", "ModifiedUserId", "ModifiedBy", } err := svc.UpdateEntityBytbl(""+OilTechnologyServiceName, 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} controllers.Request // @router /updatecode/:id [post] func (this *OilTechnologyServiceController) UpdateCodeEntity() { var errinfo ErrorInfo var err error id := this.Ctx.Input.Param(":id") if id == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } var classall technologyservice.OilTechnologyClassServiceView var model technologyserviceclass.OilTechnologyServiceClass var classmodel []technologyserviceclass.OilTechnologyServiceClass svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &classall) model.ModifiedOn = time.Now() model.ModifiedBy = this.User.Realname model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int() colsName := []string{"Name"} colsCode := []string{"Code"} //svc.GetEntityById(id, &model) if classall.Name1 != "" { where := " Name = '" + classall.Name1 + "' and Id <> " + utils.ToStr(classall.Id1) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "一级名称已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Name = classall.Name1 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id1, &model, colsName) } } if classall.Name2 != "" { where := " Name = '" + classall.Name2 + "' and Id <> " + utils.ToStr(classall.Id2) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "二级名称已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Name = classall.Name2 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id2, &model, colsName) } } if classall.Name3 != "" { where := " Name = '" + classall.Name3 + "' and Id <> " + utils.ToStr(classall.Id3) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "三级名称已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Name = classall.Name3 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id3, &model, colsName) } } if classall.Name4 != "" { where := " Name = '" + classall.Name4 + "' and Id <> " + utils.ToStr(classall.Id4) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "四级名称已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Name = classall.Name4 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id4, &model, colsName) } } if classall.Code1 != "" { where := " Code = " + classall.Code1 + " and Id <> " + utils.ToStr(classall.Id1) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "一级编码已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Code = classall.Code1 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id1, &model, colsCode) } } if classall.Code2 != "" { where := " Code = " + classall.Code2 + " and Id <> " + utils.ToStr(classall.Id2) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "二级编码已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Code = classall.Code2 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id2, &model, colsCode) } } if classall.Code3 != "" { where := " Code = " + classall.Code3 + " and Id <> " + utils.ToStr(classall.Id3) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "三级编码已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Code = classall.Code3 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id3, &model, colsCode) } } if classall.Code4 != "" { where := " Code = " + classall.Code4 + " and Id <> " + utils.ToStr(classall.Id4) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &classmodel) if len(classmodel) > 0 { errinfo.Message = "四级编码已存在,请重新添加!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { model.Code = classall.Code4 err = svc.UpdateEntityBytbl(OilTechnologyServiceClassName, classall.Id4, &model, colsCode) } } 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 *OilTechnologyServiceController) 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 technologyservice.OilTechnologyService var entityempty technologyservice.OilTechnologyService svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) svc.GetEntityById(Id, &model) opdesc := "删除-" + Id err := svc.DeleteOperationAndWriteLogBytbl(""+OilTechnologyServiceName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "服务类准入范围子表删除") var model1 technologyserviceclass.OilTechnologyServiceClass var entityempty1 technologyserviceclass.OilTechnologyServiceClass svc1 := technologyserviceclass.GetOilTechnologyServiceClassService(utils.DBE) opdesc1 := "删除-" + strconv.Itoa(model.ClassId) err1 := svc1.DeleteOperationAndWriteLogBytbl(""+OilTechnologyServiceClassName, BaseOperationLogName, strconv.Itoa(model.ClassId), &model1, &entityempty1, utils.ToStr(this.User.Id), this.User.Username, opdesc1, "", "服务类准入范围删除") if err == nil && err1 == 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 get SampleType by token // @Success 200 {object} sampletype.SampleType // @router /techbuslist [get] func (this *OilTechnologyServiceController) TechbusList() { keyword := this.GetString("keyword") where := " 1 = 1 " if keyword != "" { where = where + " and Code like '%" + keyword + "%' or Name like '%" + keyword + "%'" } svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list []technologyservice.TechnologyBusiness //获取技术服务类资质分类层级信息 list = svc.GetTechList(OilTechnologyServiceClassName, where) var datainfo DataInfo datainfo.Items = list this.Data["json"] = &datainfo this.ServeJSON() } //// @Title get 业务列表 //// @Description get SampleType by token //// @Success 200 {object} sampletype.SampleType //// @router /needfilelist [get] //func (this *OilTechnologyServiceController) NeedFileList() { // svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) // where := " 1 = 1 " // ClassId := this.GetString("ClassId") // if ClassId != "" { // where = where + " and ClassId ='" + ClassId + "' " // } // var model technologyservice.OilTechnologyService // svc.GetEntityByWhere(OilTechnologyServiceName, where, &model) // var datainfo DataInfo // datainfo.Items = model // this.Data["json"] = &datainfo // this.ServeJSON() //} // @Title 获取Code // @Description 根据Id获取Code // @Success 200 {object} technologyservice.TechnologyBusiness // @router /getcode/:id [get] func (this *OilTechnologyServiceController) GetCodeById() { Id := this.Ctx.Input.Param(":id") where := " 1 = 1 " if Id != "" { where = where + " and Id = " + Id } var list []technologyservice.TechnologyBusiness svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) svc.GetEntitysByWhere(OilTechnologyServiceClassName, where, &list) var datainfo DataInfo datainfo.Items = list this.Data["json"] = &datainfo this.ServeJSON() } // @Title get 导出ex // @Description get SampleType by token // @Success 200 {object} sampletype.SampleType // @router /exportexcelall [get] func (this *OilTechnologyServiceController) ExportExcelAll() { //获取分页信息 where := " 1=1 " orderby := "Code" asc := true Order := this.GetString("Order") Prop := this.GetString("Prop") if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } else { asc = false } } t := time.Now() svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list []technologyservice.OilTechnologyServiceView svc.GetMyPagingEntitiesWithOrderBytbl(OilTechsrvDetailViewName, 0, 0, orderby, asc, &list, where) var title []string filetitle := "服务类" //自定义显示列 showcolumnarr := this.GetString("showcolumnarr") showcolumnnamearr := this.GetString("showcolumnnamearr") titlestring := showcolumnnamearr title = strings.Split(titlestring, ",") f := xlsx.NewFile() sheet, _ := f.AddSheet(filetitle) cellname := strings.Split(showcolumnarr, ",") row := sheet.AddRow() row.WriteSlice(&cellname, -1) for _, item := range list { var enumModel technologyservice.OilTechnologyServiceView tmpModel := &item enumModel = *tmpModel immumodel := reflect.ValueOf(&enumModel) elem := immumodel.Elem() row := sheet.AddRow() for _, name := range title { cell := row.AddCell() if strings.HasPrefix(name, "F") { var val = elem.FieldByName(name).String() if val == "1" { cell.Value = "是" } else { cell.Value = "" } } else { cell.Value = elem.FieldByName(name).String() } } } for c, cl := 0, len(sheet.Cols); c < cl; c++ { sheet.Cols[c].Width = 20 } dir := "static/file/excel/report/" + this.GetAccode() SaveDirectory(dir) path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx" f.Save(path) var sw *Seaweed var filer []string if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" { filer = []string{_filer} } sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute) _, _, fID, _ := sw.UploadFile(path, "", "") retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID os.Remove(path) fmt.Println("==retDocWatermarkUrl==", retDocUrl) this.Data["json"] = retDocUrl this.ServeJSON() elapsed := time.Since(t) fmt.Println(elapsed) } // @Title 获取所有 // @Description // @Success 200 {object} // @router /getcompanylist [post] func (this *OilTechnologyServiceController) GetTList() { var model supplier.OilSupplierSelect var model1 supplier.RegCapitalRange //注册资金范围 //var model2 supplier.NeedFileTypeStruct //资质结构体 var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &model) json.Unmarshal(jsonBlob, &model1) //json.Unmarshal(jsonBlob, &model2) // //获取分页信息 page := this.GetPageInfoForm() where := " 1=1 AND b.InFlag in (1,2,3) AND b.Status = '8' and b.SupplierTypeCode = '03' AND t.SupplierId IS NOT NULL " orderby := "a.Id" asc := true Order := this.GetString("Order") Prop := this.GetString("Prop") CheckUId := this.GetString("CheckUId") FullId := this.GetString("FullId") if Order != "" && Prop != "" { orderby = Prop if Order == "desc" { asc = false } } leftjoin := "" //准入证号 if model.AccessCardNo != "" { where = where + " and b.AccessCardNo like '%" + model.AccessCardNo + "%'" } //企业名称 if model.SupplierName != "" { where = where + " and a.SupplierName like '%" + model.SupplierName + "%'" } if model.OldSupplierName != "" { where = where + " and OldSupplierName like '%" + model.OldSupplierName + "%'" } if FullId != "" { where = where + " and f.Id = '" + FullId + "'" } if CheckUId != "" { where = where + " and g.CheckUnitId = '" + CheckUId + "'" } //准入标识 1 准入 2 暂停 3取消 if model.InFlag != "" { where = where + " and b.InFlag = '" + model.InFlag + "'" } //法人 if model.LegalPerson != "" { where = where + " and a.LegalPerson like '%" + model.LegalPerson + "%'" } //联系人 if model.ContactName != "" { where = where + " and a.ContactName like '%" + model.ContactName + "%'" } //统一社会信用代码 if model.CommercialNo != "" { where = where + " and a.CommercialNo like '%" + model.CommercialNo + "%'" } //开户银行 if model.DepositBank != "" { where = where + " and a.DepositBank like '%" + model.DepositBank + "%'" } //HSE审查 if model.HseTraining != "" { where = where + " and a.HseTraining = '" + model.HseTraining + "'" } //公司类型 if model.CompanyType != "" { where = where + " and a.CompanyType like '%" + model.CompanyType + "%'" } //成立时间 SetupTime := this.GetString("SetupTime") if SetupTime != "" { where = where + " and a.SetupTime ='" + SetupTime + "'" } //注册资金范围 if model1.RegCapital1 != "" { where = where + " and a.RegCapital >= '" + model1.RegCapital1 + "'" } if model1.RegCapital2 != "" { where = where + " and a.RegCapital <= '" + model1.RegCapital2 + "'" } //注册省份 if model.Province != "" { where = where + " and a.Province = '" + model.Province + "'" } //注册市 if model.City != "" { where = where + " and a.City = '" + model.City + "'" } //注册区 if model.Street != "" { where = where + " and a.Street = '" + model.Street + "'" } //注册详细地址 if model.Address != "" { where = where + " and a.Address like '%" + model.Address + "%'" } if model.LinkProvince != "" { where = where + " and a.LinkProvince = '" + model.LinkProvince + "'" } if model.LinkCity != "" { where = where + " and a.LinkCity = '" + model.LinkCity + "'" } if model.LinkStreet != "" { where = where + " and a.LinkStreet = '" + model.LinkStreet + "'" } if model.LinkAddress != "" { where = where + " and a.LinkAddress like '%" + model.LinkAddress + "%'" } //营业范围 if model.BusinessScope != "" { where = where + " and a.BusinessScope like '%" + model.BusinessScope + "%'" } CreateOn := this.GetString("CreateOn") 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 + "'" } } a := model.InStyle fmt.Println(a) //准入方式 if model.InStyle != "" { if model.InStyle == "0" { where = where + " and b.InStyle in ('2','3','4','5')" } else { where = where + " and b.InStyle ='" + model.InStyle + "'" } } having := "" //准入范围 if model.CerSubName != "" { having = " having CerSubName like '%" + model.CerSubName + "%' " leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id " } //资质 if model.NeedFileType != "" { having = " having NeedFileType like '%" + model.NeedFileType + "%' " } if model.CerSubName != "" && model.NeedFileType != "" { having = " having CerSubName like '%" + model.CerSubName + "%' and NeedFileType like '%" + model.NeedFileType + "%' " leftjoin = "left join " + OilSupplierCertSubName + " d on d.SupplierCertId = b.Id " } svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE) var list []supplier.OilSupplierSelect total := svc.GetMyPagingDelEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, OilInfoChangeName, OilCorporateInfoName, OilSupplierCertSubName, OilSupplierFileName, page.CurrentPage, page.Size, orderby, asc, &list, where, having, leftjoin) 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} []suppliercertsub.OilSupplierCertSub // @router /deltmpsuppliercertsub [get] func (this *OilTechnologyServiceController) DelTmpSupplierCertSub() { var err error session := utils.DBE.NewSession() session.Begin() defer session.Close() supplierId := this.GetString("SupplierId") id := this.GetString("Id") svc := goodsaptitude.GetOilGoodsAptitudeSession(session) var supplierCertSubList []suppliercertsub.Tmp_OilSupplierCertSub wheredel := "1=1 and SupplierTypeCode = '03'" if supplierId != "" { wheredel += " and SupplierId=" + supplierId } if id != "" { wheredel += " and Id=" + id } svc.GetEntitysByWhere(TmpOilSupplierCertSubName, wheredel, &supplierCertSubList) var errinfo ErrorInfo for _, item := range supplierCertSubList { where := "Id = " + strconv.Itoa(item.Id) err = svc.DeleteEntityBytbl(OilSupplierCertSubName, where) if err != nil { session.Rollback() errinfo.Code = -1 errinfo.Message = "删除失败!" this.Data["json"] = &errinfo this.ServeJSON() } } for _, item := range supplierCertSubList { where := "Id = " + strconv.Itoa(item.Id) err = svc.DeleteEntityBytbl(TmpOilSupplierCertSubName, where) } if err == nil { session.Commit() errinfo.Code = 0 errinfo.Message = "删除成功!" this.Data["json"] = &errinfo this.ServeJSON() } else { session.Rollback() errinfo.Code = -1 errinfo.Message = "删除失败!" this.Data["json"] = &errinfo this.ServeJSON() } } // @Title 修改资质后找出不符合的准入 // @Description 修改实体 // @Success 200 {object} controllers.Request // @router /findinconformity [post] func (this *OilTechnologyServiceController) FindInconformity() { var errinfo ErrorInfo var err error var model technologyservice.OilTechnologyServiceAndCode var companygoodslist []suppliercertsub.OilSupplierCertSub var companygood suppliercertsub.OilSupplierCertSub var SurplusList []supplierfile.FileList var supfilemodel []supplierfile.OilSupplierFile var supfilemodel01 []supplierfile.OilSupplierFile svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE) filesvc := supplierfile.GetSupplierfileService(utils.DBE) paramSvc := baseparameter.GetBaseparameterService(utils.DBE) var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &model) Code := model.Code where := " Code ='" + Code + "' and Type in ('1','3') and SupplierTypeCode = '03'" svc.FindGoodsByCode("OilSupplierCertSub", where, &companygoodslist) SurplusList = filesvc.GetBasicNeedFileList(strconv.Itoa(model.Id)) for _, CertSub := range companygoodslist { companygood = CertSub wherecompany := " SupplierId =" + strconv.Itoa(CertSub.SupplierId) svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel) if len(supfilemodel) < 1 { _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood) } else { var tmplist1 []suppliercertsub.Tmp_OilSupplierCertSub wherecompany = " Id =" + strconv.Itoa(CertSub.Id) svc.FindFileByCompany("tmp_OilSupplierCertSub", wherecompany, &tmplist1) if len(tmplist1) < 1 { wherecompany = " SupplierId ='" + strconv.Itoa(CertSub.SupplierId) + "'" svc.FindFileByCompany("OilSupplierFile", wherecompany, &supfilemodel01) var File01 string for _, Filesub := range supfilemodel01 { File01 = File01 + Filesub.NeedFileType + "," } for _, Filesub := range SurplusList { var supplierModel supplier.OilSupplier svcSupplier := supplier.GetOilSupplierService(utils.DBE) svcSupplier.GetEntityById(strconv.Itoa(CertSub.SupplierId), &supplierModel) //三证合一或五证合一不需要的字段 mergerCertSkipField := paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName") File01 = mergerCertSkipField + File01 if (supplierModel.CredentialFlag == "1" || supplierModel.CredentialFlag == "2") && strings.Contains(File01, Filesub.FileName+",") { //三证合一或五证合一了 continue } if strings.Contains(File01, Filesub.FileName+",") { continue } _, err = svc.InsertEntityBytbl(""+TmpOilSupplierCertSubName, &companygood) break } } } } 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 导入excel // @Description get SampleType by token // @Success 200 {object} sampletype.SampleType // @router /importexcel [get] func (this *OilTechnologyServiceController) ImportExcel() { url := this.GetString("ExcelUrl") var errorinfo ErrorInfo if url == "" { errorinfo.Code = -2 errorinfo.Message = "导入失败!" this.Data["json"] = &errorinfo this.ServeJSON() } session := utils.DBE.NewSession() err := session.Begin() svc := technologyservice.GetOilTechnologySession(session) err = svc.TruncateTable(Tmp_TechnologyName) if err != nil { session.Rollback() errorinfo.Code = -2 errorinfo.Message = "导入失败!" this.Data["json"] = &errorinfo this.ServeJSON() } err = svc.TruncateTable(Tmp_TechnologyClassName) if err != nil { session.Rollback() errorinfo.Code = -2 errorinfo.Message = "导入失败!" this.Data["json"] = &errorinfo this.ServeJSON() } _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) var errLineNum string //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx" if err != nil { fmt.Printf("open failed: %s\n", err) } var sheet = xlFile.Sheets[0] Fstrs := svc.GetFCode() Fstrs = "ClassId, OrgName," + Fstrs columnArr := strings.Split(Fstrs, ",") defer func() { session.Close() }() codemap := make(map[string]int) arrLength := len(sheet.Rows[1].Cells) for i := 1; i < len(sheet.Rows); i++ { lineNo := strconv.Itoa(i + 1) this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum, arrLength) } os.Remove(filePath) if errLineNum != "" { session.Rollback() errorinfo.Code = -1 errorinfo.Message = "导入失败!错误行号:" + errLineNum this.Data["json"] = &errorinfo this.ServeJSON() } else { session.Commit() elapsed := time.Since(t) log.Println(elapsed) errorinfo.Code = 0 errorinfo.Message = "导入成功!" this.Data["json"] = &errorinfo this.ServeJSON() } } func (this *OilTechnologyServiceController) OperationCell(svc *technologyservice.OilTechnologySession, lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string, arrLength int) { defer func() { if err := recover(); err != nil { log.Println("err"+lineNo, err) *errLineNum += lineNo + "," } }() parentId := 0 classId := 0 //cellsArrLen := len(cellsArr) cellsArrLen := arrLength var valstr = "" for i := 0; i < cellsArrLen; { if i < 8 { var entity technologyserviceclass.Tmp_OilTechnologyServiceClass cellval := strings.TrimSpace(cellsArr[i].String()) fmt.Println(cellval) if cellval != "" { _, has := codemap[cellval] if !has { if i > 2 { upcode := cellsArr[i-2].String() parentId = codemap[upcode] } else { upcode := cellsArr[0].String() parentId = codemap[upcode] } entity.Code = cellval entity.Name = strings.TrimSpace(cellsArr[i+1].String()) entity.ParentId = parentId entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() entity.CreateBy = this.User.Realname entity.CreateOn = time.Now() _, err := svc.InsertEntityBytbl(Tmp_TechnologyClassName, &entity) if err != nil { panic(err) break } classId = entity.Id if i <= 6 { codemap[cellval] = entity.Id } } } } if i >= 8 { valstr += "'" + strings.TrimLeft(cellsArr[i].String(), " ") + "'," i++ } else { i += 2 } } valstr = strings.Trim(valstr, ",") valstr = strings.Replace(valstr, "是", "1", -1) log.Println(cellsArr[0].String() + "==" + valstr) var columnstr = "" for l := 0; l < cellsArrLen-7; l++ { columnstr += columnArr[l] + "," } columnstr = strings.Trim(columnstr, ",") valstr = strconv.Itoa(classId) + "," + valstr var err error if classId > 0 { err = svc.InsertTmpTechnology(columnstr, valstr) } if err != nil { panic(err) } } // @Title 获取列表新导入的列表 // @Description get user by token // @Success 200 {object} [] // @router /importlist [get] func (this *OilTechnologyServiceController) GetImportEntityList() { //获取分页信息 page := this.GetPageInfoForm() where := " 1=1 " orderby := "Code" asc := true Order := this.GetString("Order") Prop := this.GetString("Prop") if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } else { asc = false } } CreateOn := this.GetString("CreateOn") Code := this.GetString("Code") Name := this.GetString("Name") Code1 := this.GetString("Code1") Name1 := this.GetString("Name1") Code2 := this.GetString("Code2") Name2 := this.GetString("Name2") Code3 := this.GetString("Code3") Name3 := this.GetString("Name3") Code4 := this.GetString("Code4") Name4 := this.GetString("Name4") if Code != "" { where = where + " and Code like '%" + Code + "%'" } if Name != "" { where = where + " and Name like '%" + Name + "%'" } if Code1 != "" { where = where + " and Code1 like '%" + Code1 + "%'" } if Name1 != "" { where = where + " and Name1 like '%" + Name1 + "%'" } if Code2 != "" { where = where + " and Code2 like '%" + Code2 + "%'" } if Name2 != "" { where = where + " and Name2 like '%" + Name2 + "%'" } if Code3 != "" { where = where + " and Code3 like '%" + Code3 + "%'" } if Name3 != "" { where = where + " and Name3 like '%" + Name3 + "%'" } if Code4 != "" { where = where + " and Code4 like '%" + Code4 + "%'" } if Name4 != "" { where = where + " and Name4 like '%" + Name4 + "%'" } 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 := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list []technologyservice.OilTechnologyServiceView total := svc.GetMyPagingEntitiesWithOrderBytbl(ImportTechsrvDetailViewName, 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 SampleType by token // @Success 200 {object} sampletype.SampleType // @router /insertTechnology [get] func (this *OilTechnologyServiceController) InsertTechnology() { session := utils.DBE.NewSession() err := session.Begin() defer session.Close() svc := technologyservice.GetOilTechnologySession(session) var errinfo ErrorInfo err = svc.TruncateTable(OilTechnologyServiceName) if err != nil { session.Rollback() errinfo.Code = -1 errinfo.Message = "更新失败!" this.Data["json"] = &errinfo this.ServeJSON() } err = svc.TruncateTable(OilTechnologyServiceClassName) if err != nil { session.Rollback() errinfo.Code = -1 errinfo.Message = "更新失败!" this.Data["json"] = &errinfo this.ServeJSON() } err = svc.InsertTechnology(Tmp_TechnologyName, OilTechnologyServiceName) if err != nil { session.Rollback() errinfo.Code = -1 errinfo.Message = "更新失败!" this.Data["json"] = &errinfo this.ServeJSON() } err = svc.InsertTechnology(Tmp_TechnologyClassName, OilTechnologyServiceClassName) if err != nil { session.Rollback() errinfo.Code = -1 errinfo.Message = "更新失败!" this.Data["json"] = &errinfo this.ServeJSON() } session.Commit() errinfo.Code = 0 errinfo.Message = "更新成功,即将操作企业准入范围!" this.Data["json"] = &errinfo this.ServeJSON() } // @Title 更新企业的准入项及资质 // @Description get SampleType by token // @Success 200 {object} sampletype.SampleType // @router /updatasuppiercertsub [get] func (this *OilTechnologyServiceController) UpdataSuppierCertSub() { t := time.Now() technologysvc := technologyservice.GetOilTechnologyServiceService(utils.DBE) technologysvc.DeleteTable(TmpOilSupplierCertSubName, "SupplierTypeCode='03'") supsvc := supplier.GetOilSupplierService(utils.DBE) var suppliercertList []suppliercert.OilSupplierCert where := "SupplierTypeCode='03' AND OutsideFlog = '' AND (InFlag IN ('1','2')) " supsvc.GetEntities(&suppliercertList, where) var technologyClassList []technologyserviceclass.OilTechnologyServiceClass supsvc.GetEntities(&technologyClassList, "") var colsname = []string{"Name"} for _, suppliercert := range suppliercertList { var supplier supplier.OilSupplier wheres := " Id=" + strconv.Itoa(suppliercert.SupplierId) supsvc.GetEntity(&supplier, wheres) log.Println(suppliercert.SupplierId) var supplierCertSubList []suppliercertsub.OilSupplierCertSub wheresup := "SupplierId = " + strconv.Itoa(suppliercert.SupplierId) + " and SupplierTypeCode='03' AND Type IN ('1', '3')" supsvc.GetEntities(&supplierCertSubList, wheresup) fmt.Println(len(supplierCertSubList)) mergerCertSkipField := "" if supplier.CredentialFlag == "1" || supplier.CredentialFlag == "2" { paramSvc := baseparameter.GetBaseparameterService(utils.DBE) //三证合一或五证合一不需要的字段 mergerCertSkipField = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "MergerCertSkipFieldName") } for idx := 0; idx < len(supplierCertSubList); idx++ { supplierCertSub := supplierCertSubList[idx] decCode := supplierCertSub.Code // 物资类的准入编码 for _, technologyClass := range technologyClassList { // 如果编码相同的后 判断有没有改名 然后查询准入项需要哪些资质 去查资质表里有没有这些资质 没有就删除这个准入项 if supplierCertSub.Code == technologyClass.Code { decCode = "" technologyNameArr := this.GetTechnologyName(strconv.Itoa(technologyClass.Id)) for _, val := range technologyNameArr { if strings.Contains(mergerCertSkipField, val) { break } var supplierFile supplierfile.OilSupplierFile where := "SupplierId=" + strconv.Itoa(suppliercert.SupplierId) + " and NeedFileType='" + val + "'" + " and SupplierTypeCode IN ('000', '03')" has := supsvc.GetEntityByWhere(OilSupplierFileName, where, &supplierFile) if !has { log.Println(supplierCertSub.Code + "====" + val) supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub) break } if supplierCertSub.Name != technologyClass.Name { var entity suppliercertsub.OilSupplierCertSub entity.Name = technologyClass.Name where := "Id = " + strconv.Itoa(supplierCertSub.Id) supsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &entity, colsname, where) } } break } } if decCode != "" { supsvc.InsertEntityBytbl(TmpOilSupplierCertSubName, supplierCertSub) } } } elapsed := time.Since(t) log.Println(elapsed) var errinfo ErrorInfo errinfo.Code = 0 errinfo.Message = "更新完成!" this.Data["json"] = &errinfo this.ServeJSON() //xlFile.Save(excelFileName) } func (this *OilTechnologyServiceController) GetTechnologyName(classId string) []string { var goodsAptitudeName string var technologyFList []technologyservice.OilTechnologyF svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) where := "ClassId=" + classId svc.GetOilTechnologyF(&technologyFList, where) for _, goodsAptitude := range technologyFList { t := reflect.TypeOf(goodsAptitude) v := reflect.ValueOf(goodsAptitude) for k := 0; k < t.NumField(); k++ { if v.Field(k).Interface() == "1" { var tableHeader tableheader.BaseTableheader where := "Code='" + t.Field(k).Name + "' and CategoryCode = '03'" has := svc.GetEntityByWhere(BaseTableHeader, where, &tableHeader) if has { goodsAptitudeName += tableHeader.Name + "," } } } } goodsAptitudeName = strings.Trim(goodsAptitudeName, ",") return strings.Split(goodsAptitudeName, ",") } // @Title 导出数据到word,作为导出pdf的中间步骤 // @Description 数据存入word // @Success 200 {object} controllers.Request // @router /exportpdf/:tbid/:typecode [post] func (this *OilTechnologyServiceController) PdfExport() { Id := this.Ctx.Input.Param(":tbid") SupplierTypeCode := this.Ctx.Input.Param(":typecode") 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 + "' and SupplierTypecode='" + SupplierTypeCode + "'" svc.GetEntityByWhere(OilSupplierName, where1, &model1) svc.GetEntityByWhere(OilSupplierCertName, where2, &model2) var tabledata []supplierdataentry.SupplierCertSubEntry where3 := "SupplierId = '" + Id + "' and SupplierTypecode='" + SupplierTypeCode + "' and Type in ('1','3')" //准入状态的准入项 svc.GetEntitysByOrderbyWhere(TmpOilSupplierCertSubName, where3, "1", &tabledata) datamap := structToMapDemo(model1.OilSupplier) 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" } //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 if model1.HseTraining == "1" { datamap["HseTraining"] = "是" } else { datamap["HseTraining"] = "否" } if model1.OperType != "" { if model1.OperType == "1" || model1.OperType == "制造商" { datamap["OperType"] = "√制造商 □代理商 □贸易商" } else if model1.OperType == "2" || model1.OperType == "代理商" { datamap["OperType"] = "□制造商 √代理商 □贸易商" } else if model1.OperType == "3" || model1.OperType == "代理商" { datamap["OperType"] = "□制造商 □代理商 √贸易商" } else { datamap["OperType"] = "□制造商 □代理商 □贸易商" } } if model1.SpecTypeCode != "" { if model1.SpecTypeCode == "1" { datamap["SpecTypeCode"] = "√一般外部 □多元企业" } else if model1.SpecTypeCode == "2" { datamap["SpecTypeCode"] = "□一般外部 √多元企业" } else { datamap["SpecTypeCode"] = "□一般外部 □多元企业" } } if model1.Grade == "1" { datamap["Grade"] = "一级" } else if model1.SpecTypeCode == "2" { datamap["Grade"] = "二级" } datamap["Fax"] = model1.Fax datamap["CompanyTel"] = model1.CompanyTel datamap["SupplierName"] = model1.SupplierName datamap["Country"] = model1.Country datamap["MaunAgent"] = model1.MaunAgent datamap["SupplierCertificate"] = model1.SupplierCertificate datamap["MgrUnit"] = model1.MgrUnit 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"] = strconv.FormatFloat(model1.RegCapital, 'f', 2, 64) + "万元" + model1.Currency 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 datamap["AccessCardNo"] = model2.AccessCardNo datamap["PrintYear"] = time.Now().Year() datamap["PrintMonth"] = time.Now().Month() datamap["PrintDay"] = time.Now().Day() datamap["Name"] = "" if len(tabledata) != 0 { var Name string Name = "\n待删除准入范围:" + tabledata[0].Code Name = Name + " " + tabledata[0].Name var i int for i = 1; i < len(tabledata); i++ { Name += ";" Name += tabledata[i].Code Name = Name + " " + tabledata[i].Name } //if i == 100 { // Name += "(准入范围未完全显示,请到系统查看详情)" //} datamap["Name"] = datamap["Name"].(string) + Name } else { datamap["Name"] = datamap["Name"].(string) } 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 get 清空导入的信息 // @Description get SampleType by token // @Success 200 {object} sampletype.SampleType // @router /truncateimport [get] func (this *OilTechnologyServiceController) TruncateImport() { session := utils.DBE.NewSession() err := session.Begin() defer session.Close() svc := technologyservice.GetOilTechnologySession(session) err = svc.TruncateTable(Tmp_TechnologyName) var errorinfo ErrorInfo if err != nil { session.Rollback() errorinfo.Code = -1 errorinfo.Message = "删除失败!" this.Data["json"] = &errorinfo this.ServeJSON() } err = svc.TruncateTable(Tmp_TechnologyClassName) if err != nil { session.Rollback() errorinfo.Code = -1 errorinfo.Message = "删除失败!" this.Data["json"] = &errorinfo this.ServeJSON() } session.Commit() errorinfo.Code = 0 errorinfo.Message = "删除成功!" this.Data["json"] = &errorinfo this.ServeJSON() } // @Title 导出到execl // @Description 导出到execl // @Success 200 {object} controllers.Request // @router /exportexecl [post] func (this *OilTechnologyServiceController) ExeclExport() { // 填物资类信息表首页信息 svcActiviti := workflow.GetActivitiService(utils.DBE) svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list2 []supplier.OilSupplierContrast where := " 1=1" svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierTecContrast", 0, 0, "Id", false, &list2, where) fileName := "资质导入对比表.xlsx" Url := utils.Cfg.MustValue("workflow", "ContrastExcel") var datamap = make(map[string]interface{}) datamap["data"] = list2 retDocUrl := svcActiviti.ContrastExcel(datamap, Url, fileName) var datainfo ErrorDataInfo datainfo.Code = 0 datainfo.Item = retDocUrl datainfo.Message = "打印成功" this.Data["json"] = &datainfo this.ServeJSON() } // @Title 新导入资质后,比对不合格的准入用户 // @Description 对比列表 // @Success 200 {object} []supplier.OilSupplierSelect // @router /get-compare-tmp-supplier [get] func (this *OilTechnologyServiceController) GetCompareTmpSupplier() { //获取分页信息 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") AccessCardNo := this.GetString("AccessCardNo") SupplierTypeCode := this.GetString("SupplierTypeCode") Code := this.GetString("Code") Name := this.GetString("Name") Conditions := this.GetString("Conditions") 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 AccessCardNo != "" { where = where + " and AccessCardNo like '%" + AccessCardNo + "%'" } if SupplierTypeCode != "" { where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'" } if Code != "" { where = where + " and Code like '%" + Code + "%'" } if Name != "" { where = where + " and Name like '%" + Name + "%'" } if Conditions == "2" { where = where + " and NoSubCnt > 0" } else if Conditions == "3" { where = where + " and Checked = '0'" } else if Conditions == "4" { where = where + " and Checked = '1" } 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 := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list2 []supplier.OilSupplierContrast total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierTecContrast", page.CurrentPage, page.Size, orderby, asc, &list2, where) var datainfo DataInfo datainfo.Items = list2 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} []goodsaptitude.OilGoodsAptitude // @router /comparelist [get] func (this *OilTechnologyServiceController) GetCompareList() { //获取分页信息 page := this.GetPageInfoForm() where := " 1=1 " orderby := "Code" asc := true Order := this.GetString("Order") Prop := this.GetString("Prop") Conditions := this.GetString("Conditions") if Conditions == "1" { // 匹配上 where += " and b.Name = tmpb.Name" } else if Conditions == "4" { // 旧表有新表没 where += " and tmpb.Name is null" } else if Conditions == "5" { // 新表有,旧表没 where += " and tmpb.Name is null" } else if Conditions == "6" { // 资质+级别匹配 where += " and b.Name = tmpb.Name and (a.F01 = tmpa.F01 or (tmpa.F01 = '' && a.F01 is null)) and (a.F02 = tmpa.F02 or (tmpa.F02 = '' && a.F02 is null)) and (a.F03 = tmpa.F03 or (tmpa.F03 = '' && a.F03 is null)) and (a.F04 = tmpa.F04 or (tmpa.F04 = '' && a.F04 is null)) and (a.F05 = tmpa.F05 or (tmpa.F05 = '' && a.F05 is null)) and (a.F06 = tmpa.F06 or (tmpa.F06 = '' && a.F06 is null)) and (a.F07 = tmpa.F07 or (tmpa.F07 = '' && a.F07 is null)) and (a.F08 = tmpa.F08 or (tmpa.F08 = '' && a.F08 is null)) and (a.F09 = tmpa.F09 or (tmpa.F09 = '' && a.F09 is null)) and (a.F10 = tmpa.F10 or (tmpa.F10 = '' && a.F10 is null))" + " and (a.F11 = tmpa.F11 or (tmpa.F11 = '' && a.F11 is null)) and (a.F12 = tmpa.F12 or (tmpa.F12 = '' && a.F12 is null)) and (a.F13 = tmpa.F13 or (tmpa.F13 = '' && a.F13 is null)) and (a.F14 = tmpa.F14 or (tmpa.F14 = '' && a.F14 is null)) and (a.F15 = tmpa.F15 or (tmpa.F15 = '' && a.F15 is null)) and (a.F16 = tmpa.F16 or (tmpa.F16 = '' && a.F16 is null)) and (a.F17 = tmpa.F17 or (tmpa.F17 = '' && a.F17 is null)) and (a.F18 = tmpa.F18 or (tmpa.F18 = '' && a.F18 is null)) and (a.F19 = tmpa.F19 or (tmpa.F19 = '' && a.F19 is null)) and (a.F20 = tmpa.F20 or (tmpa.F20 = '' && a.F20 is null))" + " and (a.F21 = tmpa.F21 or (tmpa.F21 = '' && a.F21 is null)) and (a.F22 = tmpa.F22 or (tmpa.F22 = '' && a.F22 is null)) and (a.F23 = tmpa.F23 or (tmpa.F23 = '' && a.F23 is null)) and (a.F24 = tmpa.F24 or (tmpa.F24 = '' && a.F24 is null)) and (a.F25 = tmpa.F25 or (tmpa.F25 = '' && a.F25 is null)) and (a.F26 = tmpa.F26 or (tmpa.F26 = '' && a.F26 is null)) and (a.F27 = tmpa.F27 or (tmpa.F27 = '' && a.F27 is null)) and (a.F28 = tmpa.F28 or (tmpa.F28 = '' && a.F28 is null)) and (a.F29 = tmpa.F29 or (tmpa.F29 = '' && a.F29 is null)) and (a.F30 = tmpa.F30 or (tmpa.F30 = '' && a.F30 is null))" + " and (a.F31 = tmpa.F31 or (tmpa.F31 = '' && a.F31 is null)) and (a.F32 = tmpa.F32 or (tmpa.F32 = '' && a.F32 is null)) and (a.F33 = tmpa.F33 or (tmpa.F33 = '' && a.F33 is null)) and (a.F34 = tmpa.F34 or (tmpa.F34 = '' && a.F34 is null)) and (a.F35 = tmpa.F35 or (tmpa.F35 = '' && a.F35 is null)) and (a.F36 = tmpa.F36 or (tmpa.F36 = '' && a.F36 is null)) and (a.F37 = tmpa.F37 or (tmpa.F37 = '' && a.F37 is null)) and (a.F38 = tmpa.F38 or (tmpa.F38 = '' && a.F38 is null)) and (a.F39 = tmpa.F39 or (tmpa.F39 = '' && a.F39 is null)) and (a.F40 = tmpa.F40 or (tmpa.F40 = '' && a.F40 is null))" + " and (a.F41 = tmpa.F41 or (tmpa.F41 = '' && a.F41 is null)) and (a.F42 = tmpa.F42 or (tmpa.F42 = '' && a.F42 is null)) and (a.F43 = tmpa.F43 or (tmpa.F43 = '' && a.F43 is null)) and (a.F44 = tmpa.F44 or (tmpa.F44 = '' && a.F44 is null)) and (a.F45 = tmpa.F45 or (tmpa.F45 = '' && a.F45 is null)) and (a.F46 = tmpa.F46 or (tmpa.F46 = '' && a.F46 is null)) and (a.F47 = tmpa.F47 or (tmpa.F47 = '' && a.F47 is null)) and (a.F48 = tmpa.F48 or (tmpa.F48 = '' && a.F48 is null)) and (a.F49 = tmpa.F49 or (tmpa.F49 = '' && a.F49 is null)) and (a.F50 = tmpa.F50 or (tmpa.F50 = '' && a.F50 is null))" + " and (a.F51 = tmpa.F51 or (tmpa.F51 = '' && a.F51 is null)) and (a.F52 = tmpa.F52 or (tmpa.F52 = '' && a.F52 is null))" } if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } else { asc = false } } CreateOn := this.GetString("CreateOn") Code := this.GetString("Code") Name := this.GetString("Name") BigClassName := this.GetString("BigClassName") BigClassCode := this.GetString("BigClassCode") MiddleClassName := this.GetString("MiddleClassName") SmallClassName := this.GetString("SmallClassName") GoodsName := this.GetString("GoodsName") GoodsLevel := this.GetString("GoodsLevel") GoodsDesc := this.GetString("GoodsDesc") Standard := this.GetString("Standard") CompanyType := this.GetString("CompanyType") if Code != "" { where = where + " and b.Code like '%" + Code + "%'" } if Name != "" { where = where + " and b.Name like '%" + Name + "%'" } if BigClassName != "" { where = where + " and Name1 like '%" + BigClassName + "%'" } if BigClassCode != "" { where = where + " and Code1 like '%" + BigClassCode + "%'" } if MiddleClassName != "" { where = where + " and Name2 like '%" + MiddleClassName + "%'" } if SmallClassName != "" { where = where + " and Name3 like '%" + SmallClassName + "%'" } if GoodsName != "" { where = where + " and Name4 like '%" + GoodsName + "%'" } if GoodsLevel != "" { where = where + " and GoodsLevel like '%" + GoodsLevel + "%'" } if GoodsDesc != "" { where = where + " and GoodsDesc like '%" + GoodsDesc + "%'" } if Standard != "" { where = where + " and Standard '%" + Standard + "%'" } if CompanyType != "" { where = where + " and CompanyType '%" + CompanyType + "%'" } 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 := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list []technologyservice.OilTechnologyServiceTmp total := svc.GetPClassEntities(page.CurrentPage, page.Size, orderby, asc, &list, where, Conditions) var datainfo DataInfo datainfo.Items = list datainfo.CurrentItemCount = total datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } // @Title get 生成对比列表 // @Description get SampleType by token // @Success 200 {object} sampletype.SampleType // @router /create-contrast [get] func (this *OilTechnologyServiceController) CreateContrast() { go func() { svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) svc.TruncateTable("OilSupplierTecContrast") // 插入对比列表 var list1 []supplier.OilSupplier svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, 0, 0, "Id", false, &list1, " 1=1") svc.DBE.Query("SET unique_checks=0;") svc.DBE.Query("SET autocommit=0;") for _, item := range list1 { var list []supplier.OilSupplierContrast where := " b.SupplierTypeCode='03' and a.Id = " + strconv.Itoa(item.Id) svc.GetPagingTmpCheckedEntities(&list, where) if list != nil { var supplierCertSubList []suppliercertsub.OilSupplierCertSub total := svc.GetTableTotal(" SupplierTypeCode='03' AND SupplierId = "+strconv.Itoa(item.Id), &supplierCertSubList) total1 := svc.GetNoSubCntTotal("a.SupplierTypeCode = '03' and c.ClassId is null and a.SupplierId = " + strconv.Itoa(item.Id)) list[0].SubCnt = int(total) //list[0].MinClassId = "0" list[0].NoSubCnt = int(total1) //for _, sub := range supplierCertSubList { // var technologyClassList technologyserviceclass.OilTechnologyServiceClass // where2 := "Name = '"+ sub.Name + "'" // svc.GetEntityByWhere(Tmp_TechnologyClassName, where2, &technologyClassList) // if technologyClassList.Id > 0{ // list[0].MinClassId = strconv.Itoa(technologyClassList.Id) // } else { // list[0].MinClassId = "0" // break // } //} list[0].SetupTime = time.Now() svc.InsertEntityBytbl("OilSupplierTecContrast", list[0]) svc.DBE.Query("commit;") } } svc.DBE.Query("SET unique_checks=1;") svc.DBE.Query("SET autocommit=1;") }() var errorinfo ErrorInfo errorinfo.Code = 0 errorinfo.Message = "成功!" this.Data["json"] = &errorinfo this.ServeJSON() } // @Title 查看对比列表的准入范围 2020-12-18 // @Description get user by token // @Success 200 {object} []suppliercertsub.OilSupplierCertSub // @router /delcertsublist [get] func (this *OilTechnologyServiceController) GetDelCertSubList() { //获取分页信息 page := this.GetPageInfoForm() where := " 1=1 " orderby := "a.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") SupplierCertId := this.GetString("SupplierCertId") SupplierTypeCode := this.GetString("SupplierTypeCode") Code := this.GetString("Code") Name := this.GetString("Name") 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 a.Id like '%" + Id + "%'" } if SupplierId != "" { where = where + " and a.SupplierId like '%" + SupplierId + "%'" } if SupplierCertId != "" { where = where + " and a.SupplierCertId = '" + SupplierCertId + "'" } if SupplierTypeCode != "" { where = where + " and a.SupplierTypeCode = '" + SupplierTypeCode + "'" } if Code != "" { where = where + " and a.Code like '%" + Code + "%'" } if Name != "" { where = where + " and a.Name like '%" + Name + "%'" } if Remark != "" { where = where + " and a.Remark like '%" + Remark + "%'" } if IsDelete != "" { where = where + " and a.IsDelete like '%" + IsDelete + "%'" } if CreateUserId != "" { where = where + " and a.CreateUserId like '%" + CreateUserId + "%'" } if CreateBy != "" { where = where + " and a.CreateBy like '%" + CreateBy + "%'" } if ModifiedOn != "" { where = where + " and a.ModifiedOn like '%" + ModifiedOn + "%'" } if ModifiedUserId != "" { where = where + " and a.ModifiedUserId like '%" + ModifiedUserId + "%'" } if ModifiedBy != "" { where = where + " and a.ModifiedBy like '%" + ModifiedBy + "%'" } 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 + "'" } } where = where + " and a.Type in (1, 3)" svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list []suppliercertsub.OilSupplierCertSub1 total := svc.GetPagingTmpSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where) a := 0 for _, item := range list { sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46),IF(ifnull(F47, '') = '', '', F47),IF(ifnull(F48, '') = '', '', F48),IF(ifnull(F49, '') = '', '', F49),IF(ifnull(F50, '') = '', '', F50),IF(ifnull(F51, '') = '', '', F51),IF(ifnull(F52, '') = '', '', F52)) AS Codes FROM Tmp_OilTechnologyService a LEFT JOIN Tmp_OilTechnologyServiceClass class ON a.ClassId = class.Id" sql += " where class.Name = '" + item.Name + "'" model, _ := svc.DBE.QueryString(sql) if model != nil { code := strings.Split(model[0]["Codes"], ",") i := 1 for _, value := range code { if i == 41 || i == 42 || i == 1 { if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[40] == "1" && strings.Index(item.HeaderCodes, "F41") < 0) && (code[41] == "1" && strings.Index(item.HeaderCodes, "F42") < 0) { list[a].Checked = 1 sql1 := "select Name from Base_TableHeader where Code = 'F01' and CategoryCode = '03'" model1, _ := svc.DBE.QueryString(sql1) if strings.Index(list[a].HeaderName, model1[0]["Name"]) == -1 { list[a].HeaderName += model1[0]["Name"] + " " } } } else if i > 10 { if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 { list[a].Checked = 1 sql1 := "select Name from Base_TableHeader where Code = 'F" + strconv.Itoa(i) + "' and CategoryCode = '03'" model1, _ := svc.DBE.QueryString(sql1) list[a].HeaderName += model1[0]["Name"] + " " } } else { if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 { list[a].Checked = 1 sql1 := "select Name from Base_TableHeader where Code = 'F0" + strconv.Itoa(i) + "' and CategoryCode = '03'" model1, _ := svc.DBE.QueryString(sql1) list[a].HeaderName += model1[0]["Name"] + " " } } i += 1 } } else { list[a].MinClassId = "0" } a += 1 } var datainfo DataInfo datainfo.Items = list datainfo.CurrentItemCount = total datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } // @Title 确认更新后的删除/修改 2020-12-18 // @Description 修改实体 // @Success 200 {object} controllers.Request // @router /deleteUpdate [post] func (this *OilTechnologyServiceController) DeleteUpdate() { var errinfo ErrorInfo var err error go func() { svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) var list1 []goodsaptitude.GoodsBusiness2 svc.GetEntityJoin(OilTechnologyServiceName, OilTechnologyServiceClassName, &list1) for _, item := range list1 { var subDelete suppliercertsub.OilSupplierCertSub1 cols := []string{"SubClassId", "Code"} subDelete.Code = item.Code subDelete.SubClassId = item.Id err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "SupplierTypeCode = '03' and Name = '"+item.Name+"'") } //var list []goodsaptitude.Ids //svc.DeleteTableBySelect(OilSupplierCertSubName, OilTechnologyServiceClassName, "a.SupplierTypeCode='03' AND b.Id IS NULL", &list, "Name") //for _,id := range list{ // err = svc.DeleteTable(OilSupplierCertSubName, "Id = " + strconv.Itoa(id.Id)) //} }() errinfo.Message = "更新中,请勿重复更新!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } // @Title 暂停企业准入范围 2020-12-18 // @Description 修改实体 // @Success 200 {object} controllers.Request // @router /suspend [post] func (this *OilTechnologyServiceController) DeleteSuspend() { var errinfo ErrorInfo var err error var list []supplier.OilSupplierContrast svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE) go func() { svc.GetEntitysByWhere("OilSupplierTecContrast", "Checked = '0'", &list) paramSvc := baseparameter.GetBaseparameterService(utils.DBE) DueTimeStr := paramSvc.GetBaseparameterMessage("GFZT", "paramset", "Suspend") for _, item := range list { var sub []suppliercertsub.OilSupplierCertSub svc.GetEntitysByWhere("OilSupplierCertSub", "SupplierTypeCode = '03' and SupplierId = "+strconv.Itoa(item.Id), &sub) for _, itemSub := range sub { sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46),IF(ifnull(F47, '') = '', '', F47),IF(ifnull(F48, '') = '', '', F48),IF(ifnull(F49, '') = '', '', F49),IF(ifnull(F50, '') = '', '', F50),IF(ifnull(F51, '') = '', '', F51),IF(ifnull(F52, '') = '', '', F52)) AS Codes FROM OilTechnologyService a LEFT JOIN OilTechnologyServiceClass class ON a.ClassId = class.Id" sql += " where class.Name = '" + itemSub.Name + "'" model, _ := svc.DBE.QueryString(sql) var subDelete suppliercertsub.OilSupplierCertSub if model != nil { code := strings.Split(model[0]["Codes"], ",") cols := []string{"DueTime", "CertSubStatus"} err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id)) subDelete.CertSubStatus = "2" currentTime := time.Now() days, _ := strconv.Atoi(DueTimeStr) subDelete.DueTime = currentTime.AddDate(0, 0, days) i := 1 //暂停 for _, value := range code { if i == 41 || i == 42 || i == 1 { if (code[0] == "1" && strings.Index(item.HeaderCodes, "F01") < 0) && (code[40] == "1" && strings.Index(item.HeaderCodes, "F41") < 0) && (code[41] == "1" && strings.Index(item.HeaderCodes, "F42") < 0) { err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id)) var model1 supplierpausereason.OilSupplierPauseReason model1.SupplierId = item.Id model1.CertSubId = itemSub.Id model1.CertSubStatus = "2" model1.SupplierCertId = itemSub.SupplierCertId model1.BackReason = "老数据导入缺资质" model1.CreateOn = time.Now() model1.CreateBy = this.User.Realname model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int() svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1) break } } else if i > 10 { if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 { err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id)) var model1 supplierpausereason.OilSupplierPauseReason model1.SupplierId = item.Id model1.CertSubId = itemSub.Id model1.CertSubStatus = "2" model1.SupplierCertId = itemSub.SupplierCertId model1.BackReason = "老数据导入缺资质" model1.CreateOn = time.Now() model1.CreateBy = this.User.Realname model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int() svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1) break } } else { if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 { err = svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &subDelete, cols, "Id = "+strconv.Itoa(itemSub.Id)) var model1 supplierpausereason.OilSupplierPauseReason model1.SupplierId = item.Id model1.CertSubId = itemSub.Id model1.CertSubStatus = "2" model1.SupplierCertId = itemSub.SupplierCertId model1.BackReason = "老数据导入缺资质" model1.CreateOn = time.Now() model1.CreateBy = this.User.Realname model1.CreateUserId, _ = utils.StrTo(this.User.Id).Int() svc.InsertEntityBytbl(OilSupplierPauseReasonName, &model1) break } } i += 1 } } else { // 删除 //err = svc.DeleteEntityById(itemSub.Id, &subDelete) } } //err = svc.DeleteTable("OilSupplierTecContrast", "Id = " + strconv.Itoa(item.Id)) } this.CreateContrast() }() errinfo.Message = "更新中,请勿重复更新!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } // @Title 服务类对比excel手动删除 2020-12-31 // @Description 修改实体 // @Success 200 {object} controllers.Request // @router /manualDelete [get] func (this *OilTechnologyServiceController) ManualDelete() { var errinfo ErrorInfo var list []supplier.ManualDelete svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) where := "1=1" svc.GetEntitysByWhere("TecDifferent", where, &list) for _, value := range list { var sub1 suppliercertsub.OilSupplierCertSub var class technologyserviceclass.OilTechnologyServiceClass if value.Operation == "删除" || value.Operation == "" { svc.DeleteTable(OilSupplierCertSubName, "SupplierTypeCode='03' and Code = '"+value.Code+"' and Name = '"+value.Name+"'") } else if value.Operation == "维持不动" { } else if strings.Index(value.Operation, ",") > 0 { //151508,151509 var sub []suppliercertsub.OilSupplierCertSub svc.GetEntitysByWhere(OilSupplierCertSubName, "SupplierTypeCode='03' and Code = '"+value.Code+"' and Name = '"+value.Name+"'", &sub) code := strings.Split(value.Operation, ",") for _, c := range code { svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '"+c+"'", &class) for _, s := range sub { s.Name = class.Name s.Code = class.Code s.SubClassId = class.Id s.Id = 0 svc.GetEntityByWhere(OilSupplierCertSubName, "SupplierTypeCode='03' and SupplierCertId = "+strconv.Itoa(s.SupplierCertId)+" and Name = '"+class.Name+"'", &sub1) if sub1.Id > 0 { continue } svc.InsertEntityBytbl(OilSupplierCertSubName, &s) } svc.DeleteTable(OilSupplierCertSubName, "SupplierTypeCode='03' and Code = '"+value.Code+"' and Name = '"+value.Name+"'") } } else { //151507 svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '"+value.Operation+"'", &class) where1 := "SupplierTypeCode='03' and Code = '" + value.Code + "' and Name = '" + value.Name + "'" cols := []string{"Name", "Code", "SubClassId"} sub1.Name = class.Name sub1.Code = class.Code sub1.SubClassId = class.Id svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &sub1, cols, where1) //去重 svc.DeleteOilSupplierCertSub("Name = '" + class.Name + "'") } } errinfo.Message = "更新成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } // @Title 2021-01-28 新增准入企业 // @Description 修改实体 // @Success 200 {object} controllers.Request // @router /insertSupplierNew [get] func (this *OilTechnologyServiceController) InsertSupplierNew() { SupplierName := this.GetString("SupplierName") var zcgf supplier.TmpZcgf svc := technologyservice.GetOilTechnologyServiceService(utils.DBE) svc.GetEntityByOrderbyWhere("企业名称 = '" + SupplierName + "'", &zcgf) var errinfo ErrorInfo if zcgf.Sub != ""{ subs := strings.Split(zcgf.Sub, ";") for _,sub := range subs { if sub == "" { continue } s := strings.Split(sub, " ") var tecDifferent supplier.ManualDelete svc.GetEntityByWhere("TecDifferent", "Name = '" + s[1] + "'", &tecDifferent) var supp supplier.OilSupplier svc.GetEntityByWhere (OilSupplierName, "SupplierName = '" + SupplierName + "'", &supp) var cert suppliercert.OilSupplierCert svc.GetEntityByWhere (OilSupplierCertName, "SupplierId = " + strconv.Itoa(supp.Id), &cert) var sub1 suppliercertsub.OilSupplierCertSub if zcgf.Code == "物资类" { var class technologyserviceclass.OilTechnologyServiceClass s1 := strings.TrimLeft (s[0], "BM") svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '" + s1 + "'", &class) } if zcgf.Code == "基建类" { var class technologyserviceclass.OilTechnologyServiceClass svc.GetEntityByWhere(OilTechnologyServiceClassName, "Name = '" + s[1] + "'", &class) } if zcgf.Code == "技术服务类" { var class technologyserviceclass.OilTechnologyServiceClass svc.GetEntityByWhere(OilTechnologyServiceClassName, "Name = '" + s[1] + "'", &class) if tecDifferent.Code == "" { sub1.Code = class.Code sub1.Name = s[1] sub1.SupplierId = supp.Id sub1.SupplierCertId = cert.Id sub1.SupplierTypeCode = "03" sub1.SubClassId = class.Id sub1.CertSubStatus = "1" sub1.Type = "1" sub1.CreateOn = time.Now() sub1.CreateBy = "导入1" svc.InsertEntityBytbl("OilSupplierCertSub", &sub1) } else { var sub1 suppliercertsub.OilSupplierCertSub var class technologyserviceclass.OilTechnologyServiceClass if tecDifferent.Operation == "删除" || tecDifferent.Operation == "" || tecDifferent.Operation == "维持不动" { } else { code := strings.Split(tecDifferent.Operation, ",") for _, c := range code { svc.GetEntityByWhere(OilTechnologyServiceClassName, "Code = '"+c+"'", &class) sub1.Code = class.Code sub1.Name = class.Name sub1.SupplierId = supp.Id sub1.SubClassId = class.Id sub1.SupplierCertId = cert.Id sub1.SupplierTypeCode = "03" sub1.CertSubStatus = "1" sub1.Type = "1" sub1.CreateOn = time.Now() sub1.CreateBy = "导入1" svc.InsertEntityBytbl("OilSupplierCertSub", &sub1) } } } } } } errinfo.Message = "更新成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() }