| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911 |
- package controllers
- import (
- "fmt"
- "math"
- "strconv"
- "strings"
- "time"
- // "github.com/astaxie/beego"
- //"dashoo.cn/backend/api/business/cellscollection"
- //"dashoo.cn/backend/api/business/cellscontract"
- "dashoo.cn/backend/api/business/coderule"
- "dashoo.cn/backend/api/business/donorsinfo"
- "dashoo.cn/backend/api/business/lastordernum"
- // "dashoo.cn/backend/api/business/limsdeliver".
- //"dashoo.cn/backend/api/business/limsentrust"
- //"dashoo.cn/backend/api/business/limspreparation"
- // "dashoo.cn/backend/api/business/lissystem"
- "dashoo.cn/backend/api/business/material"
- "dashoo.cn/backend/api/business/sampleorgan"
- "dashoo.cn/backend/api/business/samplesfileinfo"
- "dashoo.cn/backend/api/business/samplesinfo"
- "dashoo.cn/backend/api/business/sampletype"
- "dashoo.cn/utils"
- )
- type HomeController struct {
- BaseController
- }
- type LablePrePrint struct {
- AccCode string
- Name string
- SampleCode string
- BarCode string
- SampleTypeCode string
- SampleTypeName string
- SampleOrgan string
- SampleOrganName string
- SampleSite string
- SampleSiteName string
- SourceId string
- SourceIdCard string
- SourceName string
- InnerCode string
- ReceiveDate time.Time
- ValidityDate time.Time
- ZBack11 string
- ZBack12 string
- ZBack13 string
- ZBack14 string
- ZBack15 string
- ZBack16 string
- ZBack17 string
- ZBack18 string
- ZBack19 string
- ZBack20 string
- ZBack21 string
- ZBack22 string
- ZBack23 string
- ZBack24 string
- ZBack25 string
- ZBack26 string
- ZBack27 string
- ZBack28 string
- ZBack29 string
- ZBack30 string
- ZBack31 string
- ZBack32 string
- ZBack33 string
- ZBack34 string
- ZBack35 string
- ZBack36 string
- ZBack37 string
- ZBack38 string
- ZBack39 string
- ZBack40 string
- ZBack41 string
- ZBack42 string
- ZBack43 string
- ZBack44 string
- ZBack45 string
- ZBack46 string
- ZBack47 string
- ZBack48 string
- ZBack49 string
- ZBack50 string
- ZBack51 string
- ZBack52 string
- ZBack53 string
- ZBack54 string
- ZBack55 string
- ZBack56 string
- ZBack57 string
- ZBack58 string
- ZBack59 string
- ZBack60 string
- }
- func spreBarcodeprint(param string) (it samplesinfo.SamplesInfoShow, datas []samplesinfo.SamplesInfoShow) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- code := params[1]
- acccode := params[2]
- where := ""
- if code != "" {
- where = where + " Id =" + code + ""
- }
- svc := samplesinfo.GetSamplesInfoService(utils.DBE)
- datas = svc.QuerySampleList(acccode, where)
- return
- }
- //样本条码
- func sampleBarcodeprint(param string) (it samplesinfo.SamplesInfoShow, datas []samplesinfo.SamplesInfoShow) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- code := params[1]
- acccode := params[2]
- where := ""
- if code != "" {
- where = where + " Id =" + code + ""
- }
- svc := samplesinfo.GetSamplesInfoService(utils.DBE)
- datas = svc.QuerySampleList(acccode, where)
- return
- }
- //样本条码--蜜蜂所
- func animalBarcodeprint(param string) (it samplesinfo.AnimalSamplesInfoShow, datas []samplesinfo.AnimalSamplesInfoShow) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- code := params[1]
- acccode := params[2]
- where := ""
- if code != "" {
- where = where + " a.Id =" + code + ""
- }
- svc := samplesinfo.GetSamplesInfoService(utils.DBE)
- datas = svc.QueryAnimalSampleList(acccode, where)
- return
- }
- //预录入、已录入、待复存样本条码批量打印--蜜蜂所
- func animalBarcodeprintbatch(param string) (it samplesinfo.AnimalSamplesInfoShow, datas []samplesinfo.AnimalSamplesInfoShow) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- acccode := params[1]
- codes := params[2]
- fmt.Println(acccode)
- fmt.Println(codes)
- codess := strings.Split(codes, ";")
- where := ""
- if len(codess) > 0 {
- where = where + " a.Id in ( "
- for i := 0; i < len(codess); i++ {
- if codess[i] != "" {
- if i == len(codess)-1 {
- where = where + codess[i] + ""
- } else {
- where = where + "" + codess[i] + ","
- }
- }
- }
- where = where + " ) "
- }
- svc := samplesinfo.GetSamplesInfoService(utils.DBE)
- datas = svc.QueryAnimalSampleList(acccode, where)
- return
- }
- //已归档样本条码批量打印--蜜蜂所
- func animalArchivedSampleBarcode(param string) (it samplesfileinfo.AnimalSamplesFileShow, datas []samplesfileinfo.AnimalSamplesFileShow) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- acccode := params[1]
- codes := params[2]
- fmt.Println(acccode)
- fmt.Println(codes)
- codess := strings.Split(codes, ";")
- where := ""
- if len(codess) > 0 {
- where = where + " a.Id in ( "
- for i := 0; i < len(codess); i++ {
- if codess[i] != "" {
- if i == len(codess)-1 {
- where = where + codess[i] + ""
- } else {
- where = where + "" + codess[i] + ","
- }
- }
- }
- where = where + " ) "
- }
- svc := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
- datas = svc.QueryAnimalSampleList(acccode, where)
- return
- }
- //预录入、已录入、待复存样本条码批量打印
- func sampleBarcodeprintbatch(param string) (it samplesinfo.SamplesInfoShow, datas []samplesinfo.SamplesInfoShow) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- acccode := params[1]
- codes := params[2]
- fmt.Println(acccode)
- fmt.Println(codes)
- codess := strings.Split(codes, ";")
- where := ""
- if len(codess) > 0 {
- where = where + " Id in ( "
- for i := 0; i < len(codess); i++ {
- if codess[i] != "" {
- if i == len(codess)-1 {
- where = where + codess[i] + ""
- } else {
- where = where + "" + codess[i] + ","
- }
- }
- }
- where = where + " ) "
- }
- svc := samplesinfo.GetSamplesInfoService(utils.DBE)
- datas = svc.QuerySampleList(acccode, where)
- return
- }
- //已归档样本条码批量打印
- func archivedSampleBarcodeprintbatch(param string) (it samplesfileinfo.SamplesFileShow, datas []samplesfileinfo.SamplesFileShow) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- acccode := params[1]
- codes := params[2]
- fmt.Println(acccode)
- fmt.Println(codes)
- codess := strings.Split(codes, ";")
- where := ""
- if len(codess) > 0 {
- where = where + " Id in ( "
- for i := 0; i < len(codess); i++ {
- if codess[i] != "" {
- if i == len(codess)-1 {
- where = where + codess[i] + ""
- } else {
- where = where + "" + codess[i] + ","
- }
- }
- }
- where = where + " ) "
- }
- svc := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
- datas = svc.QuerySampleList(acccode, where)
- return
- }
- func lablepreprint(param string) (it LablePrePrint, datas []LablePrePrint) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- fmt.Println("params:")
- fmt.Println(params)
- acccode := params[1]
- copies, _ := utils.StrTo(params[2]).Int()
- nums, _ := utils.StrTo(params[3]).Int()
- coderules := params[4]
- prefix := params[5]
- digit, _ := utils.StrTo(params[6]).Int()
- start, _ := utils.StrTo(params[7]).Int()
- end, _ := utils.StrTo(params[8]).Int()
- suffix := params[9]
- guize := params[10]
- guizes := strings.Split(guize, ";")
- fixedinfo := params[11]
- fixedinfoarr := strings.Split(fixedinfo, ";")
- sampletypeid := fixedinfoarr[0]
- organcode := fixedinfoarr[1]
- donorskid := fixedinfoarr[2]
- svcSample := samplesinfo.GetSamplesInfoService(utils.DBE)
- sampletypename := ""
- sampletypecode := ""
- var stypeentity sampletype.SampleType
- if sampletypeid != "" {
- svctype := sampletype.GetSampleTypeService(utils.DBE)
- wherestype := " AccCode='" + acccode + "' and Id =" + sampletypeid + ""
- svctype.GetEntity(&stypeentity, wherestype)
- sampletypecode = stypeentity.Code
- sampletypename = stypeentity.Name
- }
- organname := ""
- if organcode != "" {
- svcorgan := sampleorgan.GetSampleOrganService(utils.DBE)
- whereorgan := " AccCode='" + acccode + "' and Item = 1 and Code ='" + organcode + "'"
- organname = svcorgan.GetOrganNameByCode(whereorgan)
- }
- donorname := ""
- donoridcard := ""
- if donorskid != "" {
- svcdonor := donorsinfo.GetDonorsInfoService(utils.DBE)
- wheredonor := " Id=" + donorskid
- donors_data := svcdonor.QueryDonorEntity(acccode+DonorstbName, wheredonor)
- donorname = donors_data.Name
- donoridcard = donors_data.IdCard
- }
- tblmain := acccode + SamplesMaintbName
- tbldetail := acccode + SamplesDetailtbName
- var datamain samplesinfo.SamplesMain
- var datadetail samplesinfo.SamplesDetail
- var barcode string
- var lastnum lastordernum.LastOrderNum
- svc := lastordernum.GetLastOrderNumService(utils.DBE)
- if coderules == "1" { //自动生成流水号
- for i := 0; i < copies; i++ {
- lastdata := svc.GetLastSamplespreinputNum(acccode)
- lastnum.LastNum = lastdata
- svc.UpdateSamplespreinputNum(lastnum, acccode)
- barcode = lastdata
- it.AccCode = acccode
- it.SampleCode = barcode
- it.BarCode = barcode //+ "-1"
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- where := " SampleCode='" + it.SampleCode + "' or BarCode = '" + it.BarCode + "'"
- flag, _ := svc.ExistsByTableName(tbldetail, where)
- if !flag {
- datamain.AccCode = it.AccCode
- datamain.SampleCode = it.SampleCode
- datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
- datamain.SampleTypeName = it.SampleTypeName
- datamain.SamplingOrgan = it.SampleOrgan
- datamain.SamplingOrganName = it.SampleOrganName
- datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
- datamain.SourceIdCard = it.SourceIdCard
- datamain.SourceName = it.SourceName
- datadetail.SampleCode = it.SampleCode
- datadetail.BarCode = it.BarCode
- datadetail.IState = 3
- svcSample.InsertEntityBytbl(tblmain, &datamain)
- svcSample.InsertEntityBytbl(tbldetail, &datadetail)
- for j := 0; j < nums; j++ {
- datas = append(datas, it)
- }
- }
- }
- } else if coderules == "2" { //前缀加流水号加后缀
- for h := start; h <= end; h++ {
- barcode = prefix + strconv.FormatFloat(float64(h)*(1/math.Pow(10, float64(digit))), 'f', digit, 64)[2:] + suffix
- it.AccCode = acccode
- it.SampleCode = barcode
- it.BarCode = barcode // + "-1"
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- where := " SampleCode='" + it.SampleCode + "' or BarCode = '" + it.BarCode + "'"
- flag, _ := svc.ExistsByTableName(tbldetail, where)
- if !flag {
- datamain.AccCode = it.AccCode
- datamain.SampleCode = it.SampleCode
- datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
- datamain.SampleTypeName = it.SampleTypeName
- datamain.SamplingOrgan = it.SampleOrgan
- datamain.SamplingOrganName = it.SampleOrganName
- datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
- datamain.SourceIdCard = it.SourceIdCard
- datamain.SourceName = it.SourceName
- datadetail.SampleCode = it.SampleCode
- datadetail.BarCode = it.BarCode
- datadetail.IState = 3
- svcSample.InsertEntityBytbl(tblmain, &datamain)
- svcSample.InsertEntityBytbl(tbldetail, &datadetail)
- for j := 0; j < nums; j++ {
- datas = append(datas, it)
- }
- }
- }
- } else {
- //取编码规则的明细类型
- svcCodeRuleDetai := coderule.GetCodeRuleService(utils.DBE)
- whereCodeRuleDetai := " AccCode = '" + acccode + "' and MainId = '" + coderules + "'"
- CodeRuleDetailList := svcCodeRuleDetai.GetCodeRuleDetailList(whereCodeRuleDetai)
- //获取流水号在第几位 liushuihao
- //取出管号处于第几位 guanhaoweishu
- var liushuihao, guanhaoweishu int
- var isHasGuanhao bool //是否含有管号
- isHasGuanhao = false
- var guanhlen int
- for r := 0; r < len(CodeRuleDetailList); r++ {
- if CodeRuleDetailList[r].ItemName == "流水号" {
- liushuihao = r
- }
- if CodeRuleDetailList[r].ItemName == "管号" {
- guanhaoweishu = r
- isHasGuanhao = true //含有管号
- }
- }
- liushuihaows := CodeRuleDetailList[liushuihao].ItemNum //流水号长度
- if isHasGuanhao {
- guanhlen = CodeRuleDetailList[guanhaoweishu].ItemNum //管号长度
- }
- //获取编码规则的流水号
- svccoderule := coderule.GetCodeRuleService(utils.DBE)
- where1 := " (AccCode = '" + acccode + "' and Id = " + coderules + ")"
- CodeRuleList := svccoderule.GetCodeRuleList(where1)
- lastnum := CodeRuleList[0].LastNum
- for i := 0; i < copies; i++ { //样本数量
- var codestr string
- var codestrpre string
- var codestrlast string
- if lastnum == "" {
- lastnum = strconv.FormatFloat(float64(1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:] //生成相应位数的流水号
- } else {
- n, _ := utils.StrTo(lastnum).Int()
- lastnum = strconv.FormatFloat(float64(n+1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:]
- }
- if isHasGuanhao {
- for k := 0; k < guanhaoweishu; k++ { //拼接管号前面的
- if CodeRuleDetailList[k].ItemName == "流水号" { //判断前面这块中有没有流水号
- codestrpre = codestrpre + lastnum
- } else {
- codestrpre = codestrpre + guizes[k]
- }
- }
- for y := guanhaoweishu + 1; y < len(CodeRuleDetailList); y++ { //拼接管号后面的
- if CodeRuleDetailList[y].ItemName == "流水号" { //判断后面这块中有没有流水号
- codestrlast = codestrlast + lastnum
- } else {
- codestrlast = codestrlast + guizes[y]
- }
- }
- guanhaos := strings.Split(guizes[guanhaoweishu], "-")
- guanhaos0, _ := utils.StrTo(guanhaos[0]).Int()
- guanhaos1, _ := utils.StrTo(guanhaos[1]).Int()
- it.AccCode = acccode
- it.SampleCode = codestrpre + codestrlast
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- datamain.AccCode = it.AccCode
- datamain.SampleCode = it.SampleCode
- datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
- datamain.SampleTypeName = it.SampleTypeName
- datamain.SamplingOrgan = it.SampleOrgan
- datamain.SamplingOrganName = it.SampleOrganName
- datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
- datamain.SourceIdCard = it.SourceIdCard
- datamain.SourceName = it.SourceName
- where := " SampleCode='" + it.SampleCode + "'"
- flag, _ := svc.ExistsByTableName(tblmain, where)
- if !flag {
- svcSample.InsertEntityBytbl(tblmain, &datamain)
- for g := guanhaos0; g <= guanhaos1; g++ { //加入管号
- guanhao := strconv.FormatFloat(float64(g)/math.Pow10(guanhlen), 'f', guanhlen, 64)[2:]
- codestr = codestrpre + guanhao + codestrlast
- it.BarCode = codestr
- where := " BarCode = '" + it.BarCode + "'"
- flag, _ := svc.ExistsByTableName(tbldetail, where)
- if !flag {
- datadetail.SampleCode = it.SampleCode
- datadetail.BarCode = it.BarCode
- datadetail.IState = 3
- svcSample.InsertEntityBytbl(tbldetail, &datadetail)
- for j := 0; j < nums; j++ {
- datas = append(datas, it)
- }
- }
- }
- }
- } else {
- for n := 0; n < len(CodeRuleDetailList); n++ { //拼接管号前面的
- if CodeRuleDetailList[n].ItemName == "流水号" { //判断前面这块中有没有流水号
- codestr = codestr + lastnum
- } else {
- codestr = codestr + guizes[n]
- }
- }
- it.SampleCode = codestr
- it.AccCode = acccode
- it.BarCode = codestr //+ "-1"
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- where := " SampleCode='" + it.SampleCode + "' or BarCode = '" + it.BarCode + "'"
- flag, _ := svc.ExistsByTableName(tbldetail, where)
- if !flag {
- datamain.AccCode = it.AccCode
- datamain.SampleCode = it.SampleCode
- datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
- datamain.SampleTypeName = it.SampleTypeName
- datamain.SamplingOrgan = it.SampleOrgan
- datamain.SamplingOrganName = it.SampleOrganName
- datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
- datamain.SourceIdCard = it.SourceIdCard
- datamain.SourceName = it.SourceName
- datadetail.SampleCode = it.SampleCode
- datadetail.BarCode = it.BarCode
- datadetail.IState = 3
- svcSample.InsertEntityBytbl(tblmain, &datamain)
- svcSample.InsertEntityBytbl(tbldetail, &datadetail)
- for m := 0; m < nums; m++ { //单个打印数量
- datas = append(datas, it)
- }
- }
- }
- }
- svccoderule.UpdateLastNum(lastnum, coderules)
- }
- return
- }
- //标签打印,不存入预录入中
- func lablepreprintnotinsertsample(param string) (it LablePrePrint, datas []LablePrePrint) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- acccode := params[1]
- copies, _ := utils.StrTo(params[2]).Int()
- nums, _ := utils.StrTo(params[3]).Int()
- coderules := params[4]
- prefix := params[5]
- digit, _ := utils.StrTo(params[6]).Int()
- start, _ := utils.StrTo(params[7]).Int()
- end, _ := utils.StrTo(params[8]).Int()
- suffix := params[9]
- guize := params[10]
- guizes := strings.Split(guize, ";")
- fixedinfo := params[11]
- fixedinfoarr := strings.Split(fixedinfo, ";")
- sampletypeid := fixedinfoarr[0]
- organcode := fixedinfoarr[1]
- donorskid := fixedinfoarr[2]
- sampletypename := ""
- sampletypecode := ""
- var stypeentity sampletype.SampleType
- if sampletypeid != "" {
- svctype := sampletype.GetSampleTypeService(utils.DBE)
- wherestype := " AccCode='" + acccode + "' and Id =" + sampletypeid + ""
- svctype.GetEntity(&stypeentity, wherestype)
- sampletypecode = stypeentity.Code
- sampletypename = stypeentity.Name
- }
- organname := ""
- if organcode != "" {
- svcorgan := sampleorgan.GetSampleOrganService(utils.DBE)
- whereorgan := " AccCode='" + acccode + "' and Item = 1 and Code ='" + organcode + "'"
- organname = svcorgan.GetOrganNameByCode(whereorgan)
- }
- donorname := ""
- donoridcard := ""
- if donorskid != "" {
- svcdonor := donorsinfo.GetDonorsInfoService(utils.DBE)
- wheredonor := " Id=" + donorskid
- donors_data := svcdonor.QueryDonorEntity(acccode+DonorstbName, wheredonor)
- donorname = donors_data.Name
- donoridcard = donors_data.IdCard
- }
- var barcode string
- var lastnum lastordernum.LastOrderNum
- svc := lastordernum.GetLastOrderNumService(utils.DBE)
- if coderules == "1" { //自动生成流水号
- for i := 0; i < copies; i++ {
- lastdata := svc.GetLastSamplespreinputNum(acccode)
- lastnum.LastNum = lastdata
- svc.UpdateSamplespreinputNum(lastnum, acccode)
- barcode = lastdata
- it.AccCode = acccode
- it.SampleCode = barcode
- it.BarCode = barcode
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- for j := 0; j < nums; j++ {
- datas = append(datas, it)
- }
- }
- } else if coderules == "2" { //前缀加流水号加后缀
- for h := start; h <= end; h++ {
- barcode = prefix + strconv.FormatFloat(float64(h)*(1/math.Pow(10, float64(digit))), 'f', digit, 64)[2:] + suffix
- it.AccCode = acccode
- it.SampleCode = barcode
- it.BarCode = barcode
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- for j := 0; j < nums; j++ {
- datas = append(datas, it)
- }
- }
- } else {
- //取编码规则的明细类型
- svcCodeRuleDetai := coderule.GetCodeRuleService(utils.DBE)
- whereCodeRuleDetai := " AccCode = '" + acccode + "' and MainId = '" + coderules + "'"
- CodeRuleDetailList := svcCodeRuleDetai.GetCodeRuleDetailList(whereCodeRuleDetai)
- //获取流水号在第几位 liushuihao
- //取出管号处于第几位 guanhaoweishu
- var liushuihao, guanhaoweishu int
- var isHasGuanhao bool //是否含有管号
- isHasGuanhao = false
- var guanhlen int
- for r := 0; r < len(CodeRuleDetailList); r++ {
- if CodeRuleDetailList[r].ItemName == "流水号" {
- liushuihao = r
- }
- if CodeRuleDetailList[r].ItemName == "管号" {
- guanhaoweishu = r
- isHasGuanhao = true //含有管号
- }
- }
- liushuihaows := CodeRuleDetailList[liushuihao].ItemNum //流水号长度
- if isHasGuanhao {
- guanhlen = CodeRuleDetailList[guanhaoweishu].ItemNum //管号长度
- }
- //获取编码规则的流水号
- svccoderule := coderule.GetCodeRuleService(utils.DBE)
- where1 := " (AccCode = '" + acccode + "' and Id = " + coderules + ")"
- CodeRuleList := svccoderule.GetCodeRuleList(where1)
- lastnum := CodeRuleList[0].LastNum
- for i := 0; i < copies; i++ { //样本数量
- var codestr string
- var codestrpre string
- var codestrlast string
- if lastnum == "" {
- lastnum = strconv.FormatFloat(float64(1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:] //生成相应位数的流水号
- } else {
- n, _ := utils.StrTo(lastnum).Int()
- lastnum = strconv.FormatFloat(float64(n+1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:]
- }
- if isHasGuanhao {
- for k := 0; k < guanhaoweishu; k++ { //拼接管号前面的
- if CodeRuleDetailList[k].ItemName == "流水号" { //判断前面这块中有没有流水号
- codestrpre = codestrpre + lastnum
- } else {
- codestrpre = codestrpre + guizes[k]
- }
- }
- for y := guanhaoweishu + 1; y < len(CodeRuleDetailList); y++ { //拼接管号后面的
- if CodeRuleDetailList[y].ItemName == "流水号" { //判断后面这块中有没有流水号
- codestrlast = codestrlast + lastnum
- } else {
- codestrlast = codestrlast + guizes[y]
- }
- }
- guanhaos := strings.Split(guizes[guanhaoweishu], "-")
- guanhaos0, _ := utils.StrTo(guanhaos[0]).Int()
- guanhaos1, _ := utils.StrTo(guanhaos[1]).Int()
- it.AccCode = acccode
- it.SampleCode = codestrpre + codestrlast
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- for g := guanhaos0; g <= guanhaos1; g++ { //加入管号
- guanhao := strconv.FormatFloat(float64(g)/math.Pow10(guanhlen), 'f', guanhlen, 64)[2:]
- codestr = codestrpre + guanhao + codestrlast
- it.BarCode = codestr
- for j := 0; j < nums; j++ {
- datas = append(datas, it)
- }
- }
- } else {
- for n := 0; n < len(CodeRuleDetailList); n++ { //拼接管号前面的
- if CodeRuleDetailList[n].ItemName == "流水号" { //判断前面这块中有没有流水号
- codestr = codestr + lastnum
- } else {
- codestr = codestr + guizes[n]
- }
- }
- it.SampleCode = codestr
- it.AccCode = acccode
- it.BarCode = codestr
- it.SampleTypeCode = sampletypecode
- it.SampleTypeName = sampletypename
- it.SampleOrgan = organcode
- it.SampleOrganName = organname
- it.SourceIdCard = donoridcard
- it.SourceId = donorskid
- it.SourceName = donorname
- for m := 0; m < nums; m++ { //单个打印数量
- datas = append(datas, it)
- }
- }
- }
- svccoderule.UpdateLastNum(lastnum, coderules)
- }
- return
- }
- //物料入库单打印
- func materialRKprint(param string) (it material.MaterialRKPrintModel, datas []material.MaterialRKPrintModel) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- RKNo := params[1]
- acccode := params[2]
- where := ""
- if RKNo != "" {
- where = where + " a.RKNo=" + RKNo + ""
- }
- svc := material.GetMaterialService(utils.DBE)
- datas = svc.MaterialRKPrint(acccode, where)
- return
- }
- //物料出库单打印
- func materialCKprint(param string) (it material.MaterialCKPrintModel, datas []material.MaterialCKPrintModel) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- CKNo := params[1]
- acccode := params[2]
- where := ""
- if CKNo != "" {
- where = where + " a.CKNo=" + CKNo + ""
- }
- svc := material.GetMaterialService(utils.DBE)
- datas = svc.MaterialCKPrint(acccode, where)
- return
- }
- //物料盘点单打印
- func materialPDprint(param string) (it material.MaterialPDPrintModel, datas []material.MaterialPDPrintModel) {
- param = Base64Decode(param)
- params := strings.Split(param, ",")
- PDNo := params[1]
- acccode := params[2]
- where := ""
- if PDNo != "" {
- where = where + " a.PDNo=" + PDNo + ""
- }
- svc := material.GetMaterialService(utils.DBE)
- datas = svc.MaterialPDPrint(acccode, where)
- return
- }
- func (this *HomeController) Printservice() {
- param := this.Input().Get("param")
- paramreal := Base64Decode(param)
- paramreals := strings.Split(paramreal, ",") //参数,表ID,AccCode
- funcode := paramreals[0]
- var item interface{}
- var cols []PrintColType
- var multiDatas []PrintData
- switch funcode {
- case "samplespreinput":
- it, itema := spreBarcodeprint(param)
- cols = AutoColType(&it)
- item = itema
- case "samples":
- it, itema := sampleBarcodeprint(param)
- cols = AutoColType(&it)
- item = itema
- case "animalsamples":
- it, itema := animalBarcodeprint(param)
- cols = AutoColType(&it)
- item = itema
- case "animalsamplesbatch":
- it, itema := animalBarcodeprintbatch(param)
- cols = AutoColType(&it)
- item = itema
- case "animalarchivedbatch":
- it, itema := animalArchivedSampleBarcode(param)
- cols = AutoColType(&it)
- item = itema
- case "lableprint":
- it, itema := lablepreprint(param)
- cols = AutoColType(&it)
- item = itema
- case "lableprintnotinsertsample":
- it, itema := lablepreprintnotinsertsample(param)
- cols = AutoColType(&it)
- item = itema
- case "samplesbatch":
- it, itema := sampleBarcodeprintbatch(param)
- cols = AutoColType(&it)
- item = itema
- case "archivedsamplesbatch":
- it, itema := archivedSampleBarcodeprintbatch(param)
- cols = AutoColType(&it)
- item = itema
- // case "testresult":
- // it, itema := testResultprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "testapplication":
- // it, itema := testApplyprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "collectionprinting":
- // it, itema := testCollectionprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "contractprinting":
- // it, itema := testContractprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "positivereport":
- // it, itema := testPositiveReport(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "testtransfer":
- // it, itema := testTransferprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "testtransferbarcode":
- // it, itema := testTransferBarCodeprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "testapplybarcode":
- // it, itema := testApplyBarCodeprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "cellscollectionbarcode":
- // it, itema := cellscollectionBarCodeprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "hospitalresult":
- // it, itema := hospitalResultprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "packageresult":
- // it, itema := packageResultprint(param)
- // cols = AutoColType(&it)
- // item = itema
- case "materialRKprint":
- it, itema := materialRKprint(param)
- cols = AutoColType(&it)
- item = itema
- case "materialCKprint":
- it, itema := materialCKprint(param)
- cols = AutoColType(&it)
- item = itema
- case "materialPDprint":
- it, itema := materialPDprint(param)
- cols = AutoColType(&it)
- item = itema
- // case "samplelist":
- // it, itema := sampleListeprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "preparedbarcode":
- // fmt.Println("22222222222")
- // it, itema := PreparedBarCode(param)
- // cols = AutoColType(&it)
- // item = itema
- // case "entrustprinting":
- // it, itema := testEntrustprint(param)
- // cols = AutoColType(&it)
- // item = itema
- // var mydata = PrintData{item, cols}
- // multiDatas = append(multiDatas, mydata)
- // its, itemas := testDeliverprint(param)
- // cols = AutoColType(&its)
- // item = itemas
- // mydata = PrintData{item, cols}
- // multiDatas = append(multiDatas, mydata)
- }
- var datas []PrintData
- if len(multiDatas) <= 0 {
- var data = PrintData{item, cols}
- datas = append(datas, data)
- } else {
- datas = multiDatas
- }
- this.Data["json"] = PrintInfo{datas, []string{"var1", "var2", "var3"}}
- this.ServeJSON()
- }
|