| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451 |
- // @Title 新增样本来源基本信息
- package biobank
- import (
- "encoding/json"
- "fmt"
- "strconv"
- "strings"
- "time"
- "github.com/tealeg/xlsx"
- "dashoo.cn/backend/api/business/codecsequence"
- "dashoo.cn/backend/api/business/donorsinfo"
- "dashoo.cn/backend/api/business/equipment"
- "dashoo.cn/backend/api/business/samplesfileinfo"
- "dashoo.cn/backend/api/business/samplesinfo"
- "dashoo.cn/backend/api/business/samplessource"
- "dashoo.cn/backend/api/business/sampletest"
- //"dashoo.cn/backend/api/business/authcode"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- )
- type SamplesSourceController struct {
- BaseController
- }
- // @Title 获取样本来源列表
- // @Description get user by token
- // @Success 200 {object} models.Userblood
- // @router /samplessourcelist [get]
- func (this *SamplesSourceController) SamplesSourceList() {
- page := this.GetPageInfoForm()
- idcard := this.GetString("idcard")
- name := this.GetString("name")
- telephone := this.GetString("telephone")
- innerno := this.GetString("innerno")
- starttimeint, _ := this.GetInt64("starttimeint")
- endtimeint, _ := this.GetInt64("endtimeint")
- var list []samplessource.DonorsInfo
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " 1=1"
- orderby := "CreateOn"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- if idcard != "" {
- where = where + " and IDCard = '" + idcard + "'"
- }
- if name != "" {
- where = where + " and Name like '%" + name + "%'"
- }
- if telephone != "" {
- where = where + " and Telephone = '" + telephone + "'"
- }
- if innerno != "" {
- where = where + " and InnerNo = '" + innerno + "'"
- }
- if starttimeint > 0 {
- where = where + " and CreateOn >'" + time.Unix(starttimeint/1000, 0).Format("2006-01-02") + "'"
- }
- if endtimeint > 0 {
- where = where + " and CreateOn <'" + time.Unix(endtimeint/1000, 0).Format("2006-01-02") + " 23:59:59'"
- }
- // CreateBy := this.GetString("CreateBy")
- // if CreateBy != "" {
- // where = where + " and CreateBy like '%" + CreateBy + "%'"
- // }
- // CreateUserId := this.GetString("CreateUserId")
- // if CreateUserId != "" {
- // where = where + " and CreateUserId =" + CreateUserId + " "
- // }
- total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 删除样本来源信息
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /deldonors/:id [delete]
- func (this *SamplesSourceController) DelDonors() {
- id := this.Ctx.Input.Param(":id")
- idcard := this.GetString("idcard")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var entity samplessource.DonorsInfo
- var entityempty samplessource.DonorsInfo
- opdesc := "删除样本来源-" + idcard
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- err := svc.DeleteDonorAndWriteLogBytbl(this.User.AccCode+DonorstbName, this.User.AccCode+DonorslogtbName, id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, entity.Name)
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /getbasicinfo [get]
- func (this *SamplesSourceController) GetBasicDetail() {
- Id := this.GetString("Id")
- var entity samplessource.DonorsInfo
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " Id ='" + Id + "'"
- svc.GetEntityByWhere(this.User.AccCode+DonorstbName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 新增样本来源基本信息
- // @Success 200 {object}
- // @router /savebasic [post]
- func (this *SamplesSourceController) AddBasic() {
- var model donorsinfo.DonorsInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.AccCode = this.User.AccCode
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+DonorstbName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 id path string true "需要修改的试管信息"
- // @Success 200 {object} controllers.Request
- // @router /editbasic/:id [put]
- func (this *SamplesSourceController) EditBasic() {
- 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 donorsinfo.DonorsInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- var entity donorsinfo.DonorsInfo
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- var cols []string = []string{"IdCard", "InnerNo", "Name", "CompanyName", "Sex", "Duty", "Birthday",
- "Age", "Telephone", "Email", "Nation", "HomeAddress", "MaritalStatus", "PathologicalNum",
- "IllnessName", "Remark", "ModifiedBy", "ModifiedUserId"}
- // sva := donorsinfo.GetDonorsInfoService(utils.DBE)
- zback := svc.QueryZBackList(this.User.AccCode)
- for i := 0; i < (len(zback)); i++ {
- cols = append(cols, zback[i].Id)
- }
- opdesc := "修改样本来源-" + model.Name
- err := svc.UpdateDonorAndWriteLogBytbl(this.User.AccCode+DonorstbName, this.User.AccCode+DonorslogtbName, id, &model, &entity, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, model.Name)
- if err == nil {
- var list []samplesinfo.SamplesMain
- where_list := "SourceId = '" + strconv.Itoa(model.Id) + "'"
- svc.GetEntitysByWhere(this.User.AccCode+SamplesMaintbName, where_list, &list)
- if len(list) > 0 {
- for i := 0; i < len(list); i++ {
- var SamEntity samplesinfo.SamplesMain
- where_sam := "MId = '" + strconv.Itoa(list[i].MId) + "'"
- SamEntity.SourceName = model.Name
- SamEntity.MCreateBy = this.User.Username
- SamEntity.MCreateUserId, _ = utils.StrTo(this.User.Id).Int()
- var cols_sam []string = []string{"SourceName", "ModifiedBy", "ModifiedUserId"}
- svc.UpdateEntityBywheretbl(this.User.AccCode+SamplesMaintbName, &SamEntity, cols_sam, where_sam)
- }
- }
- }
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /getsampletestlist/:id [get]
- func (this *SamplesSourceController) Getsampletestlist() {
- id := this.Ctx.Input.Param(":id")
- var entity []sampletest.SampleTestMain
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " SourceId ='" + id + "'"
- svc.GetEntitysByWhere(this.User.AccCode+SampleTestMainName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取检测详情
- // @Description get user by token
- // @Success 200 {object} models.Userblood
- // @router /getsampletestdetaillist/:InspectionNum [get]
- func (this *SamplesSourceController) Getsampletestdetaillist() {
- InspectionNum := this.Ctx.Input.Param(":InspectionNum")
- var entity []sampletest.SampleTestDetail
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " InspectionNum ='" + InspectionNum + "'"
- svc.GetEntitysByWhere(this.User.AccCode+SampleTestDetailName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取病理检测信息
- // @Description get user by token
- // @Success 200 {object} models.Userblood
- // @router /pathologylist/:id [get]
- func (this *SamplesSourceController) GetPathologyList() {
- id := this.Ctx.Input.Param(":id")
- var entity []donorsinfo.DonorsDetail
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " ParentId ='" + id + "' and Type = 3"
- svc.GetEntitysByWhere(this.User.AccCode+DonorsDetailName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 添加病理信息
- // @Success 200 {object} controllers.Request
- // @router /addpathology [post]
- func (this *SamplesSourceController) AddPathology() {
- ParentId, _ := this.GetInt("ParentId")
- IdCard := this.GetString("IdCard")
- var model donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ParentId = ParentId
- model.IdCard = IdCard
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+DonorsDetailName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 添加病理信息关联HIS
- // @Success 200 {object} controllers.Request
- // @router /pathologyadd [post]
- func (this *SamplesSourceController) PathologyAdd() {
- Name := this.GetString("Name")
- Sex, _ := this.GetInt("Sex")
- Age, _ := this.GetInt("Age")
- var model donorsinfo.DonorsPathology
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- var entity donorsinfo.DonorsInfo
- entity.Name = Name
- entity.Sex = Sex
- entity.Age = Age
- entity.CreateBy = this.User.Realname
- entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+DonorstbName, &entity)
- if err == nil {
- var entitydetail donorsinfo.DonorsDetail
- entitydetail.ParentId = entity.Id
- entitydetail.PathologicalNum = model.PathologicalNum
- entitydetail.DiagnosticTime = model.DiagnosticTime
- entitydetail.AdmissionNumber = model.AdmissionNumber
- entitydetail.CheckNum = model.CheckNum
- entitydetail.Department = model.Department
- entitydetail.IllnessName = model.IllnessName
- entitydetail.Type = model.Type
- entitydetail.CreateBy = this.User.Realname
- entitydetail.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntityBytbl(this.User.AccCode+DonorsDetailName, &entitydetail)
- }
- var errinfo ErrorDataInfo
- if err == nil {
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- errinfo.Item = entity.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 id path string true
- // @Success 200 {object} controllers.Request
- // @router /editpathology/:id [put]
- func (this *SamplesSourceController) EditPathology() {
- 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 donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " Id ='" + id + "'"
- var cols []string = []string{"PathologicalNum", "CheckPoint", "DiagnosticTime", "Department", "AdmissionNumber", "BedNum", "CheckNum", "ClinicalDiagnosis", "IllnessName", "ModifiedBy", "ModifiedUserId"}
- err := svc.UpdateEntityBywheretbl(this.User.AccCode+DonorsDetailName, &model, cols, where)
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /operationlist/:id [get]
- func (this *SamplesSourceController) GetOperationList() {
- id := this.Ctx.Input.Param(":id")
- var entity []donorsinfo.DonorsDetail
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " ParentId ='" + id + "' and Type = 1"
- svc.GetEntitysByWhere(this.User.AccCode+DonorsDetailName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 添加手术记录
- // @Success 200 {object} controllers.Request
- // @router /addoperation [post]
- func (this *SamplesSourceController) AddOperation() {
- ParentId, _ := this.GetInt("ParentId")
- IdCard := this.GetString("IdCard")
- var model donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ParentId = ParentId
- model.IdCard = IdCard
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+DonorsDetailName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 id path string true
- // @Success 200 {object} controllers.Request
- // @router /editoperation/:id [put]
- func (this *SamplesSourceController) EditOperation() {
- 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 donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " Id ='" + id + "'"
- var cols []string = []string{"OperationName", "OperativeSite", "Diagnosis", "OperationTime", "Leader", "Operator", "Hospital", "Department", "ModifiedBy", "BedNum", "Detail", "ModifiedUserId"}
- err := svc.UpdateEntityBywheretbl(this.User.AccCode+DonorsDetailName, &model, cols, where)
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /screeninglist/:id [get]
- func (this *SamplesSourceController) GetScreeningList() {
- id := this.Ctx.Input.Param(":id")
- var entity []donorsinfo.DonorsDetail
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " ParentId ='" + id + "' and Type = 2"
- svc.GetEntitysByWhere(this.User.AccCode+DonorsDetailName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 添加筛查记录
- // @Success 200 {object} controllers.Request
- // @router /addscreening [post]
- func (this *SamplesSourceController) AddScreening() {
- ParentId, _ := this.GetInt("ParentId")
- IdCard := this.GetString("IdCard")
- var model donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ParentId = ParentId
- model.IdCard = IdCard
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+DonorsDetailName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 id path string true
- // @Success 200 {object} controllers.Request
- // @router /editscreening/:id [put]
- func (this *SamplesSourceController) EditScreening() {
- 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 donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " Id ='" + id + "'"
- var cols []string = []string{"ScreeningSite", "ScreeningType", "ScreeningTime", "Instrument", "Ultrasonic", "Ultrasound", "Record", "Description", "ModifiedBy", "BedNum", "Detail", "ModifiedUserId"}
- err := svc.UpdateEntityBywheretbl(this.User.AccCode+DonorsDetailName, &model, cols, where)
- 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 /delopescr/:Id [delete]
- func (this *SamplesSourceController) DelOpeScr() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- where := " Id= " + Id
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- err := svc.DeleteEntityBytbl(this.User.AccCode+DonorsDetailName, where)
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /imagelist/:id [get]
- func (this *SamplesSourceController) GetImageList() {
- id := this.Ctx.Input.Param(":id")
- var entity []donorsinfo.DonorsDetail
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " ParentId ='" + id + "' and Type = 0"
- svc.GetEntitysByWhere(this.User.AccCode+DonorsDetailName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 添加影像信息
- // @Success 200 {object}
- // @router /addimage [post]
- func (this *SamplesSourceController) AddImage() {
- ParentId, _ := this.GetInt("ParentId")
- IdCard := this.GetString("IdCard")
- var model donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ParentId = ParentId
- model.IdCard = IdCard
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+DonorsDetailName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 id path string true
- // @Success 200 {object} controllers.Request
- // @router /editimage/:id [put]
- func (this *SamplesSourceController) EditImage() {
- 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 donorsinfo.DonorsDetail
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " Id ='" + id + "'"
- var cols []string = []string{"ImageSite", "ImageType", "Office", "ImageTime", "ImageDes", "FileUrl", "ModifiedBy", "ModifiedUserId"}
- err := svc.UpdateEntityBywheretbl(this.User.AccCode+DonorsDetailName, &model, cols, where)
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /animallist [get]
- func (this *SamplesSourceController) AnimalList() {
- page := this.GetPageInfoForm()
- var list []samplessource.AnimalInfo
- genus := this.GetString("Genus")
- name := this.GetString("Name")
- innerno := this.GetString("InnerNo")
- SurveyDate := this.GetString("SurveyDate")
- CreateOn := this.GetString("CreateOn")
- SourceType := this.GetString("SourceType")
- ProjectName := this.GetString("ProjectName")
- Address := this.GetString("Address")
- AuditorStatus := this.GetString("AuditorStatus")
- AuditorName := this.GetString("AuditorName")
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " 1=1"
- orderby := " CreateOn "
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- if genus != "" {
- where = where + " and Genus = '" + genus + "'"
- }
- if name != "" {
- where = where + " and Name like '%" + name + "%'"
- }
- if innerno != "" {
- where = where + " and InnerNo like '%" + innerno + "%'"
- }
- if SurveyDate != "" {
- dates := strings.Split(SurveyDate, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and SurveyDate>='" + minDate + "' and SurveyDate<='" + maxDate + "'"
- }
- }
- 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 SourceType != "" {
- where = where + " and SourceType = '" + SourceType + "'"
- }
- if ProjectName != "" {
- where = where + " and ProjectName = '" + ProjectName + "'"
- }
- if Address != "" {
- where = where + " and ( ProvinceName like '%" + Address + "% or CityName like '%" + Address + "% or StreetName like '%" + Address + "% or Address like '%" + Address + "%)'"
- }
- if AuditorStatus != "" {
- where = where + " and AuditorStatus = '" + AuditorStatus + "'"
- }
- if AuditorName != "" {
- where = where + " and AuditorName = '" + AuditorName + "'"
- }
- total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 判断内部编码存在
- // @Description get user by token
- // @Success 200 {object} models.Userblood
- // @router /innernomakesure [get]
- func (this *SamplesSourceController) InnerNoMakeSure() {
- InnerNo := this.GetString("InnerNo")
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " InnerNo= '" + InnerNo + "'"
- total := svc.GetInnerNo(this.User.AccCode+AnimaltbName, where)
- var datainfo DataInfo
- datainfo.Items = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 新增蜜蜂所来源基本信息
- // @Success 200 {object}
- // @router /savebee [post]
- func (this *SamplesSourceController) SaveBee() {
- var model samplessource.AnimalInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.AccCode = this.User.AccCode
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- svc.InsertEntityBytbl(this.User.AccCode+AnimaltbName, &model)
- var list []codecsequence.CodecSequence
- where_seq := "AccCode = '" + this.User.AccCode + "'"
- where_seq += " and AreaCode = '" + model.AreaCode + "'"
- svc.GetEntitysByWhere(CodecSequenceName, where_seq, &list)
- var entity codecsequence.CodecSequence
- if len(list) == 0 {
- entity.AccCode = this.User.AccCode
- entity.SeqName = strconv.Itoa(model.Id)
- entity.AreaCode = model.AreaCode
- entity.MinValue = 1
- entity.MaxValue = model.Amount
- entity.CurrentVal = 1
- entity.IncrementVal = 1
- entity.CreateBy = this.User.Realname
- entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntity(&entity)
- } else {
- entity.AccCode = this.User.AccCode
- entity.SeqName = strconv.Itoa(model.Id)
- entity.AreaCode = model.AreaCode
- entity.MinValue = list[len(list)-1].MaxValue + 1
- entity.MaxValue = list[len(list)-1].MaxValue + model.Amount
- entity.CurrentVal = list[len(list)-1].MaxValue + 1
- entity.IncrementVal = 1
- entity.CreateBy = this.User.Realname
- entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntity(&entity)
- }
- var sourceModel samplessource.AnimalInfo
- sourceModel.InnerNo = model.AreaCode + "-" + fmt.Sprintf("%04s", strconv.Itoa(entity.MinValue)) + "——" + model.AreaCode + "-" + fmt.Sprintf("%04s", strconv.Itoa(entity.MaxValue))
- where_innor := "Id = '" + strconv.Itoa(model.Id) + "'"
- var cols []string = []string{"InnerNo"}
- err := svc.UpdateEntityBywheretbl(this.User.AccCode+AnimaltbName, &sourceModel, cols, where_innor)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 id path string true "需要修改的试管信息"
- // @Success 200 {object} controllers.Request
- // @router /editbee/:id [put]
- func (this *SamplesSourceController) EditBee() {
- 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 samplessource.AnimalInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- var entity samplessource.AnimalInfo
- model.ModifiedBy = this.User.Username
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- var cols []string = []string{"Genus", "InnerNo", "Name", "Amount", "Unit", "SourceType", "Weight", "Province", "ProvinceName", "City", "CityName", "Street", "StreetName", "Address", "AreaCode", "Longitude", "Latitude", "Altitude", "SurveyDate", "ProjectId", "ProjectName", "Remark", "ModifiedBy", "ModifiedUserId"}
- zback := svc.QueryZBackList(this.User.AccCode)
- for i := 0; i < (len(zback)); i++ {
- cols = append(cols, zback[i].Id)
- }
- opdesc := "修改样本来源-" + model.Name
- err := svc.UpdateDonorAndWriteLogBytbl(this.User.AccCode+AnimaltbName, this.User.AccCode+DonorslogtbName, id, &model, &entity, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, model.Name)
- if err == nil {
- var codemodel codecsequence.CodecSequence
- where_seq := "AccCode = '" + this.User.AccCode + "'"
- where_seq += " and SeqName = '" + strconv.Itoa(model.Id) + "'"
- svc.GetEntityByWhereBytbl(CodecSequenceName, where_seq, &codemodel)
- codemodel.MaxValue = codemodel.MinValue + model.Amount - 1
- codemodel.ModifiedBy = this.User.Username
- codemodel.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- var code_cols []string = []string{"MaxValue", "ModifiedBy", "ModifiedUserId"}
- svc.UpdateEntityBywheretbl(CodecSequenceName, &codemodel, code_cols, where_seq)
- var sourceModel samplessource.AnimalInfo
- sourceModel.InnerNo = model.AreaCode + "-" + fmt.Sprintf("%04s", strconv.Itoa(codemodel.MinValue)) + "——" + model.AreaCode + "-" + fmt.Sprintf("%04s", strconv.Itoa(codemodel.MaxValue))
- where_innor := "Id = '" + strconv.Itoa(model.Id) + "'"
- var cols_source []string = []string{"InnerNo"}
- svc.UpdateEntityBywheretbl(this.User.AccCode+AnimaltbName, &sourceModel, cols_source, where_innor)
- }
- if err == nil {
- var list []samplesinfo.SamplesMain
- where_list := "SourceId = '" + strconv.Itoa(model.Id) + "'"
- svc.GetEntitysByWhere(this.User.AccCode+SamplesMaintbName, where_list, &list)
- if len(list) > 0 {
- for i := 0; i < len(list); i++ {
- var SamEntity samplesinfo.SamplesMain
- where_sam := "MId = '" + strconv.Itoa(list[i].MId) + "'"
- SamEntity.SourceName = model.Name
- SamEntity.MCreateBy = this.User.Username
- SamEntity.MCreateUserId, _ = utils.StrTo(this.User.Id).Int()
- var cols_sam []string = []string{"SourceName", "ModifiedBy", "ModifiedUserId"}
- svc.UpdateEntityBywheretbl(this.User.AccCode+SamplesMaintbName, &SamEntity, cols_sam, where_sam)
- }
- }
- }
- 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 新增动物来源基本信息
- // @Success 200 {object}
- // @router /saveanimal [post]
- func (this *SamplesSourceController) SaveAnimal() {
- var model samplessource.AnimalInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.AccCode = this.User.AccCode
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+AnimaltbName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /getanimalinfo [get]
- func (this *SamplesSourceController) GetAnimalDetail() {
- Id := this.GetString("Id")
- var entity samplessource.AnimalInfo
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " Id ='" + Id + "'"
- svc.GetEntityByWhere(this.User.AccCode+AnimaltbName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 更新动物基本信息
- // @Description 更新动物基本信息
- // @Param id path string true "需要修改的试管信息"
- // @Success 200 {object} controllers.Request
- // @router /editanimal/:id [put]
- func (this *SamplesSourceController) EditAnimal() {
- 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 samplessource.AnimalInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- var entity samplessource.AnimalInfo
- model.ModifiedBy = this.User.Username
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- var cols []string = []string{"Genus", "GenusName", "InnerNo", "Name", "Amount", "Unit", "SourceType", "Weight", "Province", "ProvinceName", "City", "CityName", "Street", "StreetName", "Address", "AreaCode", "Longitude", "Latitude", "Altitude", "SurveyDate", "ProjectId", "ProjectName", "Remark", "ModifiedBy", "ModifiedUserId"}
- zback := svc.QueryZBackList(this.User.AccCode)
- for i := 0; i < (len(zback)); i++ {
- cols = append(cols, zback[i].Id)
- }
- opdesc := "修改样本来源-" + model.Name
- err := svc.UpdateDonorAndWriteLogBytbl(this.User.AccCode+AnimaltbName, this.User.AccCode+DonorslogtbName, id, &model, &entity, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, model.Name)
- if err == nil {
- var list []samplesinfo.SamplesMain
- where_list := "SourceId = '" + strconv.Itoa(model.Id) + "'"
- svc.GetEntitysByWhere(this.User.AccCode+SamplesMaintbName, where_list, &list)
- if len(list) > 0 {
- for i := 0; i < len(list); i++ {
- var SamEntity samplesinfo.SamplesMain
- where_sam := "MId = '" + strconv.Itoa(list[i].MId) + "'"
- SamEntity.SourceName = model.Name
- SamEntity.MCreateBy = this.User.Username
- SamEntity.MCreateUserId, _ = utils.StrTo(this.User.Id).Int()
- var cols_sam []string = []string{"SourceName", "ModifiedBy", "ModifiedUserId"}
- svc.UpdateEntityBywheretbl(this.User.AccCode+SamplesMaintbName, &SamEntity, cols_sam, where_sam)
- }
- }
- }
- 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 /delbioinfo/:id [delete]
- func (this *SamplesSourceController) DelBioInfo() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var entity samplessource.AnimalInfo
- var entityempty samplessource.AnimalInfo
- opdesc := "删除样本来源-" + entity.Name
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- err := svc.DeleteDonorAndWriteLogBytbl(this.User.AccCode+AnimaltbName, this.User.AccCode+DonorslogtbName, id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, entity.Name)
- if err == nil {
- where_code := "SeqName = '" + id + "'"
- svc.DeleteEntityBytbl(CodecSequenceName, where_code)
- }
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 审核生物样本来源信息
- // @Description 审核生物样本来源信息
- // @Param id path string true
- // @Success 200 {object}
- // @router /auditoranimal/:id [put]
- func (this *SamplesSourceController) AuditorAnimal() {
- //进行部分修改
- 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 samplessource.AnimalInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- var entity samplessource.AnimalInfo
- model.AuditorName = this.User.Realname
- model.AuditorId, _ = utils.StrTo(this.User.Id).Int()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- opdesc := "审核样本来源-" + model.Name
- var cols []string = []string{"AuditorStatus", "AuditorId", "AuditorName", "AuditorRemark", "ModifiedBy", "ModifiedUserId"}
- err := svc.UpdateDonorAndWriteLogBytbl(this.User.AccCode+AnimaltbName, this.User.AccCode+DonorslogtbName, id, &model, &entity, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "样本采集")
- if err == nil {
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 获取微生物样本来源列表
- // @Description get user by token
- // @Success 200 {object} models.Userblood
- // @router /microbiallist [get]
- func (this *SamplesSourceController) MicrobialList() {
- page := this.GetPageInfoForm()
- var list []samplessource.MicrobialInfo
- genus := this.GetString("genus")
- name := this.GetString("name")
- tive := this.GetString("tive")
- innerno := this.GetString("innerno")
- weight := this.GetString("weight")
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " 1=1"
- orderby := "CreateOn"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- if genus != "" {
- where = where + " and Genus = '" + genus + "'"
- }
- if name != "" {
- where = where + " and Name like '%" + name + "%'"
- }
- if tive != "" {
- where = where + " and Tive =" + tive + " "
- }
- if innerno != "" {
- where = where + " and InnerNo = '" + innerno + "'"
- }
- if weight != "" {
- where = where + " and Weight = '" + weight + "'"
- }
- total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 新增微生物来源基本信息
- // @Success 200 {object}
- // @router /savemicro [post]
- func (this *SamplesSourceController) SaveMicro() {
- var model samplessource.MicrobialInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.AccCode = this.User.AccCode
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+MicrobialtbName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- 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 get user by token
- // @Success 200 {object} models.Userblood
- // @router /getmicrobialinfo [get]
- func (this *SamplesSourceController) GetMicrobialDetail() {
- Id := this.GetString("Id")
- var entity samplessource.MicrobialInfo
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- where := " Id ='" + Id + "'"
- svc.GetEntityByWhere(this.User.AccCode+MicrobialtbName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 根据样本来源获取群号区间 ----蜜蜂所
- // @Description get sequence by seqName
- // @Success 200 {int} sequence
- // @router /getgroupcode [get]
- func (this *SamplesSourceController) GetGroupCode() {
- SourceId := this.GetString("SourceId")
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- var entity codecsequence.CodecSequence
- where := " 1 = 1 "
- if SourceId != "" {
- where += " and SeqName = '" + SourceId + "'"
- }
- svc.GetEntityByWhere(CodecSequenceName, where, &entity)
- var datainfo DataInfo
- datainfo.Items = &entity
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 更新微生物基本信息
- // @Description 更新微生物基本信息
- // @Param id path string true "需要修改的试管信息"
- // @Success 200 {object} controllers.Request
- // @router /editmicro/:id [put]
- func (this *SamplesSourceController) EditMicro() {
- 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 samplessource.MicrobialInfo
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- var entity samplessource.MicrobialInfo
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- var cols []string = []string{"Genus", "InnerNo", "Name", "Amount", "Unit", "SourceType", "Weight", "Remark", "ModifiedBy", "ModifiedUserId"}
- zback := svc.QueryZBackList(this.User.AccCode)
- for i := 0; i < (len(zback)); i++ {
- cols = append(cols, zback[i].Id)
- }
- opdesc := "修改样本来源-" + model.Name
- err := svc.UpdateDonorAndWriteLogBytbl(this.User.AccCode+MicrobialtbName, this.User.AccCode+DonorslogtbName, id, &model, &entity, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, model.Name)
- 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 /delmicrobial/:id [delete]
- func (this *SamplesSourceController) DelMicrobial() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var entity samplessource.MicrobialInfo
- var entityempty samplessource.MicrobialInfo
- opdesc := "删除生物样本源-" + id
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- err := svc.DeleteOperationAndWriteLogBytbl(this.User.AccCode+MicrobialtbName, BaseOperationLogName, id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "样本来源")
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- type DonorSampleTotalModel struct {
- Samplenum int `json:"samplenum"`
- Sampleprenum int `json:"sampleprenum"`
- Sampleunsavenum int `json:"sampleunsavenum"`
- Samplefilesnum int `json:"samplefilesnum"`
- Allsamplesum int `json:"allsamplesum"`
- }
- // @Title 获取样本统计数据
- // @Description 获取样本统计数据
- // @Success 200 {object} controllers.Request
- // @router /getsampletotal/:id [get]
- func (this *SamplesSourceController) Getsampletotal() {
- id := this.Ctx.Input.Param(":id")
- var model DonorSampleTotalModel
- //设备权限
- svcequip := equipment.GetEquipmentService(utils.DBE)
- poweeids := svcequip.GetPowerEquipmentids(this.User.AccCode, utils.ToStr(this.User.Id))
- //设备中样本总数
- svcsample := samplesinfo.GetSamplesInfoService(utils.DBE)
- wherecout := " DeletionStateCode=0 and SourceId=" + id + " and IState=1 and EquipmentId in(" + strings.Join(poweeids, ",") + ") "
- samplenum := svcsample.GetSampleOwnCountBySourceId(this.User.AccCode, wherecout)
- model.Samplenum = samplenum
- //预录入样本总数
- wherecout = " DeletionStateCode=0 and SourceId=" + id + " and IState in (2,3,4,7,8) "
- sampleprenum := svcsample.GetSampleOwnCountBySourceId(this.User.AccCode, wherecout)
- model.Sampleprenum = sampleprenum
- //待复存样本总数
- wherecout = " DeletionStateCode=0 and SourceId=" + id + " and (IState=6 or ( IState=5 and EquipmentId in(" + strings.Join(poweeids, ",") + ")))"
- sampleunsavenum := svcsample.GetSampleOwnCountBySourceId(this.User.AccCode, wherecout)
- model.Sampleunsavenum = sampleunsavenum
- //归档样本总数
- svcsampleFile := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
- wheresamplefiles := " DeletionStateCode=0 and SourceId=" + id
- samplefilesnum := svcsampleFile.GetSampleFileCount(this.User.AccCode, wheresamplefiles)
- model.Samplefilesnum = samplefilesnum
- //总数
- model.Allsamplesum = samplenum + sampleprenum + sampleunsavenum + samplefilesnum
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取设备中样本信息
- // @Description 获取设备中样本信息
- // @Success 200 {object} business.device.DeviceChannels
- // @router /getdevicesamples/:id [get]
- func (this *SamplesSourceController) Getdevicesamples() {
- id := this.Ctx.Input.Param(":id")
- //获取分页信息
- page := this.GetPageInfoForm()
- svcequip := equipment.GetEquipmentService(utils.DBE)
- poweeids := svcequip.GetPowerEquipmentids(this.User.AccCode, utils.ToStr(this.User.Id))
- svc := samplesinfo.GetSamplesInfoService(utils.DBE)
- wheresourceid := " IState=1 and DeletionStateCode=0 and SourceId=" + id + " and a.EquipmentId in(" + strings.Join(poweeids, ",") + ")"
- total, data := svc.GetPagingEntitiesWithOrderSearch(this.User.AccCode, page.CurrentPage, page.Size, "Id", wheresourceid)
- var datainfo DataInfo
- datainfo.Items = data
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title get 样本来源导出
- // @Description get SampleType by token
- // @Success 200 {object} sampletype.SampleType
- // @router /exportexcel [get]
- func (this *SamplesSourceController) ListToExcel() {
- var title []string
- titlestring := "监护人姓名,身份证号,性别,年龄,出生日期,民族,样本条码,联系号码,邮箱,婚姻状况,所患疾病,职业,工作单位,家庭住址,备注信息,检验单号,病理号,"
- title = strings.Split(titlestring, ",")
- where := " 1=1 "
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- datas := svc.GetSampleSourceInfo(this.User.AccCode+DonorstbName, this.User.AccCode+SampleTestMainName, this.User.AccCode+DonorsDetailName, where)
- f := xlsx.NewFile()
- this.DaySaveXlsxExport("样本来源导出信息", title, datas, f)
- SaveDirectory("static/file/excel/report/" + this.GetAccode())
- f.Save("static/file/excel/report/" + this.GetAccode() + "/" + utils.TimeFormat(time.Now(), "200612") + "样本来源导出信息.xlsx")
- this.Ctx.WriteString("/static/file/excel/report/" + this.GetAccode() + "/" + utils.TimeFormat(time.Now(), "200612") + "样本来源导出信息.xlsx")
- }
- func (this *SamplesSourceController) DaySaveXlsxExport(name string, title []string, datas []samplessource.DonorsInfoWithDetail, f *xlsx.File) {
- sheet, _ := f.AddSheet(name)
- rowhead := sheet.AddRow()
- rowhead.WriteSlice(&title, -1)
- for _, v := range datas {
- strsex := ""
- if v.Sex == 0 {
- strsex = "男"
- } else if v.Sex == 1 {
- strsex = "女"
- } else {
- strsex = ""
- }
- strmarital := ""
- if v.MaritalStatus == 0 {
- strmarital = "未婚"
- } else if v.MaritalStatus == 1 {
- strmarital = "已婚"
- } else if v.MaritalStatus == 2 {
- strmarital = "未知"
- } else {
- strmarital = ""
- }
- datastring := v.Name + "," + v.IdCard + "," + strsex + "," + strconv.Itoa(v.Age) + "," + utils.ToStr(v.Birthday.Format("2006-01-02")) + "," + v.Nation + "," + v.InnerNo + "," + v.Telephone + "," + v.Email + "," + strmarital + "," + v.IllnessName + "," + v.Duty + "," + v.CompanyName + "," + v.HomeAddress + "," + v.Remark + "," + v.InspectionNum + "," + v.PathologicalNum
- cellname := strings.Split(datastring, ",")
- row := sheet.AddRow()
- row.WriteSlice(&cellname, -1)
- }
- sheet.Cols[1].Width = 20
- sheet.Cols[4].Width = 20
- sheet.Cols[6].Width = 20
- sheet.Cols[7].Width = 15
- sheet.Cols[8].Width = 20
- sheet.Cols[12].Width = 20
- sheet.Cols[13].Width = 50
- sheet.Cols[14].Width = 30
- sheet.Cols[15].Width = 20
- sheet.Cols[16].Width = 20
- sheet.Cols[17].Width = 20
- }
- // @Title 导入模板--BEE
- // @Description 下载导入模板
- // @Success 200 {object} controllers.Request
- // @router /exceltosave [put]
- func (this *SamplesSourceController) SaveExcelPost() {
- path := this.GetString("path")
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- uid, _ := utils.StrTo(this.User.Id).Int()
- err, warn1 := svc.InsertExcelAnimal(path, this.User.AccCode+AnimaltbName, this.User.AccCode, this.User.Realname, uid)
- var errinfo ErrorInfo
- if warn1 == "" {
- errinfo.Message = "样本来源数据导入成功!"
- errinfo.Code = 0
- }
- if err != nil {
- errinfo.Message = "样本来源数据导入失败!"
- errinfo.Code = -1
- }
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- // @Title 导入模板
- // @Description 下载导入模板
- // @Success 200 {object} controllers.Request
- // @router /exceltosource [put]
- func (this *SamplesSourceController) SaveExcelSource() {
- path := this.GetString("path")
- svc := samplessource.GetSamplesSourceService(utils.DBE)
- uid, _ := utils.StrTo(this.User.Id).Int()
- err, warn1 := svc.InsertExcelSource(path, this.User.AccCode+DonorstbName, this.User.AccCode, this.User.Realname, uid)
- var errinfo ErrorInfo
- if warn1 == "" {
- errinfo.Message = "样本来源数据导入成功!"
- errinfo.Code = 0
- }
- if err != nil {
- errinfo.Message = "样本来源数据导入失败!"
- errinfo.Code = -1
- }
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
|