home.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  1. package controllers
  2. import (
  3. "fmt"
  4. "math"
  5. "strconv"
  6. "strings"
  7. "time"
  8. // "github.com/astaxie/beego"
  9. //"dashoo.cn/backend/api/business/cellscollection"
  10. //"dashoo.cn/backend/api/business/cellscontract"
  11. "dashoo.cn/backend/api/business/coderule"
  12. "dashoo.cn/backend/api/business/donorsinfo"
  13. "dashoo.cn/backend/api/business/lastordernum"
  14. // "dashoo.cn/backend/api/business/limsdeliver".
  15. //"dashoo.cn/backend/api/business/limsentrust"
  16. //"dashoo.cn/backend/api/business/limspreparation"
  17. // "dashoo.cn/backend/api/business/lissystem"
  18. "dashoo.cn/backend/api/business/material"
  19. "dashoo.cn/backend/api/business/sampleorgan"
  20. "dashoo.cn/backend/api/business/samplesfileinfo"
  21. "dashoo.cn/backend/api/business/samplesinfo"
  22. "dashoo.cn/backend/api/business/sampletype"
  23. "dashoo.cn/utils"
  24. )
  25. type HomeController struct {
  26. BaseController
  27. }
  28. type LablePrePrint struct {
  29. AccCode string
  30. Name string
  31. SampleCode string
  32. BarCode string
  33. SampleTypeCode string
  34. SampleTypeName string
  35. SampleOrgan string
  36. SampleOrganName string
  37. SampleSite string
  38. SampleSiteName string
  39. SourceId string
  40. SourceIdCard string
  41. SourceName string
  42. InnerCode string
  43. ReceiveDate time.Time
  44. ValidityDate time.Time
  45. ZBack11 string
  46. ZBack12 string
  47. ZBack13 string
  48. ZBack14 string
  49. ZBack15 string
  50. ZBack16 string
  51. ZBack17 string
  52. ZBack18 string
  53. ZBack19 string
  54. ZBack20 string
  55. ZBack21 string
  56. ZBack22 string
  57. ZBack23 string
  58. ZBack24 string
  59. ZBack25 string
  60. ZBack26 string
  61. ZBack27 string
  62. ZBack28 string
  63. ZBack29 string
  64. ZBack30 string
  65. ZBack31 string
  66. ZBack32 string
  67. ZBack33 string
  68. ZBack34 string
  69. ZBack35 string
  70. ZBack36 string
  71. ZBack37 string
  72. ZBack38 string
  73. ZBack39 string
  74. ZBack40 string
  75. ZBack41 string
  76. ZBack42 string
  77. ZBack43 string
  78. ZBack44 string
  79. ZBack45 string
  80. ZBack46 string
  81. ZBack47 string
  82. ZBack48 string
  83. ZBack49 string
  84. ZBack50 string
  85. ZBack51 string
  86. ZBack52 string
  87. ZBack53 string
  88. ZBack54 string
  89. ZBack55 string
  90. ZBack56 string
  91. ZBack57 string
  92. ZBack58 string
  93. ZBack59 string
  94. ZBack60 string
  95. }
  96. func spreBarcodeprint(param string) (it samplesinfo.SamplesInfoShow, datas []samplesinfo.SamplesInfoShow) {
  97. param = Base64Decode(param)
  98. params := strings.Split(param, ",")
  99. code := params[1]
  100. acccode := params[2]
  101. where := ""
  102. if code != "" {
  103. where = where + " Id =" + code + ""
  104. }
  105. svc := samplesinfo.GetSamplesInfoService(utils.DBE)
  106. datas = svc.QuerySampleList(acccode, where)
  107. return
  108. }
  109. //样本条码
  110. func sampleBarcodeprint(param string) (it samplesinfo.SamplesInfoShow, datas []samplesinfo.SamplesInfoShow) {
  111. param = Base64Decode(param)
  112. params := strings.Split(param, ",")
  113. code := params[1]
  114. acccode := params[2]
  115. where := ""
  116. if code != "" {
  117. where = where + " Id =" + code + ""
  118. }
  119. svc := samplesinfo.GetSamplesInfoService(utils.DBE)
  120. datas = svc.QuerySampleList(acccode, where)
  121. return
  122. }
  123. //样本条码--蜜蜂所
  124. func animalBarcodeprint(param string) (it samplesinfo.AnimalSamplesInfoShow, datas []samplesinfo.AnimalSamplesInfoShow) {
  125. param = Base64Decode(param)
  126. params := strings.Split(param, ",")
  127. code := params[1]
  128. acccode := params[2]
  129. where := ""
  130. if code != "" {
  131. where = where + " a.Id =" + code + ""
  132. }
  133. svc := samplesinfo.GetSamplesInfoService(utils.DBE)
  134. datas = svc.QueryAnimalSampleList(acccode, where)
  135. return
  136. }
  137. //预录入、已录入、待复存样本条码批量打印--蜜蜂所
  138. func animalBarcodeprintbatch(param string) (it samplesinfo.AnimalSamplesInfoShow, datas []samplesinfo.AnimalSamplesInfoShow) {
  139. param = Base64Decode(param)
  140. params := strings.Split(param, ",")
  141. acccode := params[1]
  142. codes := params[2]
  143. fmt.Println(acccode)
  144. fmt.Println(codes)
  145. codess := strings.Split(codes, ";")
  146. where := ""
  147. if len(codess) > 0 {
  148. where = where + " a.Id in ( "
  149. for i := 0; i < len(codess); i++ {
  150. if codess[i] != "" {
  151. if i == len(codess)-1 {
  152. where = where + codess[i] + ""
  153. } else {
  154. where = where + "" + codess[i] + ","
  155. }
  156. }
  157. }
  158. where = where + " ) "
  159. }
  160. svc := samplesinfo.GetSamplesInfoService(utils.DBE)
  161. datas = svc.QueryAnimalSampleList(acccode, where)
  162. return
  163. }
  164. //已归档样本条码批量打印--蜜蜂所
  165. func animalArchivedSampleBarcode(param string) (it samplesfileinfo.AnimalSamplesFileShow, datas []samplesfileinfo.AnimalSamplesFileShow) {
  166. param = Base64Decode(param)
  167. params := strings.Split(param, ",")
  168. acccode := params[1]
  169. codes := params[2]
  170. fmt.Println(acccode)
  171. fmt.Println(codes)
  172. codess := strings.Split(codes, ";")
  173. where := ""
  174. if len(codess) > 0 {
  175. where = where + " a.Id in ( "
  176. for i := 0; i < len(codess); i++ {
  177. if codess[i] != "" {
  178. if i == len(codess)-1 {
  179. where = where + codess[i] + ""
  180. } else {
  181. where = where + "" + codess[i] + ","
  182. }
  183. }
  184. }
  185. where = where + " ) "
  186. }
  187. svc := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
  188. datas = svc.QueryAnimalSampleList(acccode, where)
  189. return
  190. }
  191. //预录入、已录入、待复存样本条码批量打印
  192. func sampleBarcodeprintbatch(param string) (it samplesinfo.SamplesInfoShow, datas []samplesinfo.SamplesInfoShow) {
  193. param = Base64Decode(param)
  194. params := strings.Split(param, ",")
  195. acccode := params[1]
  196. codes := params[2]
  197. fmt.Println(acccode)
  198. fmt.Println(codes)
  199. codess := strings.Split(codes, ";")
  200. where := ""
  201. if len(codess) > 0 {
  202. where = where + " Id in ( "
  203. for i := 0; i < len(codess); i++ {
  204. if codess[i] != "" {
  205. if i == len(codess)-1 {
  206. where = where + codess[i] + ""
  207. } else {
  208. where = where + "" + codess[i] + ","
  209. }
  210. }
  211. }
  212. where = where + " ) "
  213. }
  214. svc := samplesinfo.GetSamplesInfoService(utils.DBE)
  215. datas = svc.QuerySampleList(acccode, where)
  216. return
  217. }
  218. //已归档样本条码批量打印
  219. func archivedSampleBarcodeprintbatch(param string) (it samplesfileinfo.SamplesFileShow, datas []samplesfileinfo.SamplesFileShow) {
  220. param = Base64Decode(param)
  221. params := strings.Split(param, ",")
  222. acccode := params[1]
  223. codes := params[2]
  224. fmt.Println(acccode)
  225. fmt.Println(codes)
  226. codess := strings.Split(codes, ";")
  227. where := ""
  228. if len(codess) > 0 {
  229. where = where + " Id in ( "
  230. for i := 0; i < len(codess); i++ {
  231. if codess[i] != "" {
  232. if i == len(codess)-1 {
  233. where = where + codess[i] + ""
  234. } else {
  235. where = where + "" + codess[i] + ","
  236. }
  237. }
  238. }
  239. where = where + " ) "
  240. }
  241. svc := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
  242. datas = svc.QuerySampleList(acccode, where)
  243. return
  244. }
  245. func lablepreprint(param string) (it LablePrePrint, datas []LablePrePrint) {
  246. param = Base64Decode(param)
  247. params := strings.Split(param, ",")
  248. fmt.Println("params:")
  249. fmt.Println(params)
  250. acccode := params[1]
  251. copies, _ := utils.StrTo(params[2]).Int()
  252. nums, _ := utils.StrTo(params[3]).Int()
  253. coderules := params[4]
  254. prefix := params[5]
  255. digit, _ := utils.StrTo(params[6]).Int()
  256. start, _ := utils.StrTo(params[7]).Int()
  257. end, _ := utils.StrTo(params[8]).Int()
  258. suffix := params[9]
  259. guize := params[10]
  260. guizes := strings.Split(guize, ";")
  261. fixedinfo := params[11]
  262. fixedinfoarr := strings.Split(fixedinfo, ";")
  263. sampletypeid := fixedinfoarr[0]
  264. organcode := fixedinfoarr[1]
  265. donorskid := fixedinfoarr[2]
  266. svcSample := samplesinfo.GetSamplesInfoService(utils.DBE)
  267. sampletypename := ""
  268. sampletypecode := ""
  269. var stypeentity sampletype.SampleType
  270. if sampletypeid != "" {
  271. svctype := sampletype.GetSampleTypeService(utils.DBE)
  272. wherestype := " AccCode='" + acccode + "' and Id =" + sampletypeid + ""
  273. svctype.GetEntity(&stypeentity, wherestype)
  274. sampletypecode = stypeentity.Code
  275. sampletypename = stypeentity.Name
  276. }
  277. organname := ""
  278. if organcode != "" {
  279. svcorgan := sampleorgan.GetSampleOrganService(utils.DBE)
  280. whereorgan := " AccCode='" + acccode + "' and Item = 1 and Code ='" + organcode + "'"
  281. organname = svcorgan.GetOrganNameByCode(whereorgan)
  282. }
  283. donorname := ""
  284. donoridcard := ""
  285. if donorskid != "" {
  286. svcdonor := donorsinfo.GetDonorsInfoService(utils.DBE)
  287. wheredonor := " Id=" + donorskid
  288. donors_data := svcdonor.QueryDonorEntity(acccode+DonorstbName, wheredonor)
  289. donorname = donors_data.Name
  290. donoridcard = donors_data.IdCard
  291. }
  292. tblmain := acccode + SamplesMaintbName
  293. tbldetail := acccode + SamplesDetailtbName
  294. var datamain samplesinfo.SamplesMain
  295. var datadetail samplesinfo.SamplesDetail
  296. var barcode string
  297. var lastnum lastordernum.LastOrderNum
  298. svc := lastordernum.GetLastOrderNumService(utils.DBE)
  299. if coderules == "1" { //自动生成流水号
  300. for i := 0; i < copies; i++ {
  301. lastdata := svc.GetLastSamplespreinputNum(acccode)
  302. lastnum.LastNum = lastdata
  303. svc.UpdateSamplespreinputNum(lastnum, acccode)
  304. barcode = lastdata
  305. it.AccCode = acccode
  306. it.SampleCode = barcode
  307. it.BarCode = barcode //+ "-1"
  308. it.SampleTypeCode = sampletypecode
  309. it.SampleTypeName = sampletypename
  310. it.SampleOrgan = organcode
  311. it.SampleOrganName = organname
  312. it.SourceIdCard = donoridcard
  313. it.SourceId = donorskid
  314. it.SourceName = donorname
  315. where := " SampleCode='" + it.SampleCode + "' or BarCode = '" + it.BarCode + "'"
  316. flag, _ := svc.ExistsByTableName(tbldetail, where)
  317. if !flag {
  318. datamain.AccCode = it.AccCode
  319. datamain.SampleCode = it.SampleCode
  320. datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
  321. datamain.SampleTypeName = it.SampleTypeName
  322. datamain.SamplingOrgan = it.SampleOrgan
  323. datamain.SamplingOrganName = it.SampleOrganName
  324. datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
  325. datamain.SourceIdCard = it.SourceIdCard
  326. datamain.SourceName = it.SourceName
  327. datadetail.SampleCode = it.SampleCode
  328. datadetail.BarCode = it.BarCode
  329. datadetail.IState = 3
  330. svcSample.InsertEntityBytbl(tblmain, &datamain)
  331. svcSample.InsertEntityBytbl(tbldetail, &datadetail)
  332. for j := 0; j < nums; j++ {
  333. datas = append(datas, it)
  334. }
  335. }
  336. }
  337. } else if coderules == "2" { //前缀加流水号加后缀
  338. for h := start; h <= end; h++ {
  339. barcode = prefix + strconv.FormatFloat(float64(h)*(1/math.Pow(10, float64(digit))), 'f', digit, 64)[2:] + suffix
  340. it.AccCode = acccode
  341. it.SampleCode = barcode
  342. it.BarCode = barcode // + "-1"
  343. it.SampleTypeCode = sampletypecode
  344. it.SampleTypeName = sampletypename
  345. it.SampleOrgan = organcode
  346. it.SampleOrganName = organname
  347. it.SourceIdCard = donoridcard
  348. it.SourceId = donorskid
  349. it.SourceName = donorname
  350. where := " SampleCode='" + it.SampleCode + "' or BarCode = '" + it.BarCode + "'"
  351. flag, _ := svc.ExistsByTableName(tbldetail, where)
  352. if !flag {
  353. datamain.AccCode = it.AccCode
  354. datamain.SampleCode = it.SampleCode
  355. datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
  356. datamain.SampleTypeName = it.SampleTypeName
  357. datamain.SamplingOrgan = it.SampleOrgan
  358. datamain.SamplingOrganName = it.SampleOrganName
  359. datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
  360. datamain.SourceIdCard = it.SourceIdCard
  361. datamain.SourceName = it.SourceName
  362. datadetail.SampleCode = it.SampleCode
  363. datadetail.BarCode = it.BarCode
  364. datadetail.IState = 3
  365. svcSample.InsertEntityBytbl(tblmain, &datamain)
  366. svcSample.InsertEntityBytbl(tbldetail, &datadetail)
  367. for j := 0; j < nums; j++ {
  368. datas = append(datas, it)
  369. }
  370. }
  371. }
  372. } else {
  373. //取编码规则的明细类型
  374. svcCodeRuleDetai := coderule.GetCodeRuleService(utils.DBE)
  375. whereCodeRuleDetai := " AccCode = '" + acccode + "' and MainId = '" + coderules + "'"
  376. CodeRuleDetailList := svcCodeRuleDetai.GetCodeRuleDetailList(whereCodeRuleDetai)
  377. //获取流水号在第几位 liushuihao
  378. //取出管号处于第几位 guanhaoweishu
  379. var liushuihao, guanhaoweishu int
  380. var isHasGuanhao bool //是否含有管号
  381. isHasGuanhao = false
  382. var guanhlen int
  383. for r := 0; r < len(CodeRuleDetailList); r++ {
  384. if CodeRuleDetailList[r].ItemName == "流水号" {
  385. liushuihao = r
  386. }
  387. if CodeRuleDetailList[r].ItemName == "管号" {
  388. guanhaoweishu = r
  389. isHasGuanhao = true //含有管号
  390. }
  391. }
  392. liushuihaows := CodeRuleDetailList[liushuihao].ItemNum //流水号长度
  393. if isHasGuanhao {
  394. guanhlen = CodeRuleDetailList[guanhaoweishu].ItemNum //管号长度
  395. }
  396. //获取编码规则的流水号
  397. svccoderule := coderule.GetCodeRuleService(utils.DBE)
  398. where1 := " (AccCode = '" + acccode + "' and Id = " + coderules + ")"
  399. CodeRuleList := svccoderule.GetCodeRuleList(where1)
  400. lastnum := CodeRuleList[0].LastNum
  401. for i := 0; i < copies; i++ { //样本数量
  402. var codestr string
  403. var codestrpre string
  404. var codestrlast string
  405. if lastnum == "" {
  406. lastnum = strconv.FormatFloat(float64(1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:] //生成相应位数的流水号
  407. } else {
  408. n, _ := utils.StrTo(lastnum).Int()
  409. lastnum = strconv.FormatFloat(float64(n+1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:]
  410. }
  411. if isHasGuanhao {
  412. for k := 0; k < guanhaoweishu; k++ { //拼接管号前面的
  413. if CodeRuleDetailList[k].ItemName == "流水号" { //判断前面这块中有没有流水号
  414. codestrpre = codestrpre + lastnum
  415. } else {
  416. codestrpre = codestrpre + guizes[k]
  417. }
  418. }
  419. for y := guanhaoweishu + 1; y < len(CodeRuleDetailList); y++ { //拼接管号后面的
  420. if CodeRuleDetailList[y].ItemName == "流水号" { //判断后面这块中有没有流水号
  421. codestrlast = codestrlast + lastnum
  422. } else {
  423. codestrlast = codestrlast + guizes[y]
  424. }
  425. }
  426. guanhaos := strings.Split(guizes[guanhaoweishu], "-")
  427. guanhaos0, _ := utils.StrTo(guanhaos[0]).Int()
  428. guanhaos1, _ := utils.StrTo(guanhaos[1]).Int()
  429. it.AccCode = acccode
  430. it.SampleCode = codestrpre + codestrlast
  431. it.SampleTypeCode = sampletypecode
  432. it.SampleTypeName = sampletypename
  433. it.SampleOrgan = organcode
  434. it.SampleOrganName = organname
  435. it.SourceIdCard = donoridcard
  436. it.SourceId = donorskid
  437. it.SourceName = donorname
  438. datamain.AccCode = it.AccCode
  439. datamain.SampleCode = it.SampleCode
  440. datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
  441. datamain.SampleTypeName = it.SampleTypeName
  442. datamain.SamplingOrgan = it.SampleOrgan
  443. datamain.SamplingOrganName = it.SampleOrganName
  444. datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
  445. datamain.SourceIdCard = it.SourceIdCard
  446. datamain.SourceName = it.SourceName
  447. where := " SampleCode='" + it.SampleCode + "'"
  448. flag, _ := svc.ExistsByTableName(tblmain, where)
  449. if !flag {
  450. svcSample.InsertEntityBytbl(tblmain, &datamain)
  451. for g := guanhaos0; g <= guanhaos1; g++ { //加入管号
  452. guanhao := strconv.FormatFloat(float64(g)/math.Pow10(guanhlen), 'f', guanhlen, 64)[2:]
  453. codestr = codestrpre + guanhao + codestrlast
  454. it.BarCode = codestr
  455. where := " BarCode = '" + it.BarCode + "'"
  456. flag, _ := svc.ExistsByTableName(tbldetail, where)
  457. if !flag {
  458. datadetail.SampleCode = it.SampleCode
  459. datadetail.BarCode = it.BarCode
  460. datadetail.IState = 3
  461. svcSample.InsertEntityBytbl(tbldetail, &datadetail)
  462. for j := 0; j < nums; j++ {
  463. datas = append(datas, it)
  464. }
  465. }
  466. }
  467. }
  468. } else {
  469. for n := 0; n < len(CodeRuleDetailList); n++ { //拼接管号前面的
  470. if CodeRuleDetailList[n].ItemName == "流水号" { //判断前面这块中有没有流水号
  471. codestr = codestr + lastnum
  472. } else {
  473. codestr = codestr + guizes[n]
  474. }
  475. }
  476. it.SampleCode = codestr
  477. it.AccCode = acccode
  478. it.BarCode = codestr //+ "-1"
  479. it.SampleTypeCode = sampletypecode
  480. it.SampleTypeName = sampletypename
  481. it.SampleOrgan = organcode
  482. it.SampleOrganName = organname
  483. it.SourceIdCard = donoridcard
  484. it.SourceId = donorskid
  485. it.SourceName = donorname
  486. where := " SampleCode='" + it.SampleCode + "' or BarCode = '" + it.BarCode + "'"
  487. flag, _ := svc.ExistsByTableName(tbldetail, where)
  488. if !flag {
  489. datamain.AccCode = it.AccCode
  490. datamain.SampleCode = it.SampleCode
  491. datamain.SampleType, _ = utils.StrTo(sampletypeid).Int()
  492. datamain.SampleTypeName = it.SampleTypeName
  493. datamain.SamplingOrgan = it.SampleOrgan
  494. datamain.SamplingOrganName = it.SampleOrganName
  495. datamain.SourceId, _ = utils.StrTo(it.SourceId).Int()
  496. datamain.SourceIdCard = it.SourceIdCard
  497. datamain.SourceName = it.SourceName
  498. datadetail.SampleCode = it.SampleCode
  499. datadetail.BarCode = it.BarCode
  500. datadetail.IState = 3
  501. svcSample.InsertEntityBytbl(tblmain, &datamain)
  502. svcSample.InsertEntityBytbl(tbldetail, &datadetail)
  503. for m := 0; m < nums; m++ { //单个打印数量
  504. datas = append(datas, it)
  505. }
  506. }
  507. }
  508. }
  509. svccoderule.UpdateLastNum(lastnum, coderules)
  510. }
  511. return
  512. }
  513. //标签打印,不存入预录入中
  514. func lablepreprintnotinsertsample(param string) (it LablePrePrint, datas []LablePrePrint) {
  515. param = Base64Decode(param)
  516. params := strings.Split(param, ",")
  517. acccode := params[1]
  518. copies, _ := utils.StrTo(params[2]).Int()
  519. nums, _ := utils.StrTo(params[3]).Int()
  520. coderules := params[4]
  521. prefix := params[5]
  522. digit, _ := utils.StrTo(params[6]).Int()
  523. start, _ := utils.StrTo(params[7]).Int()
  524. end, _ := utils.StrTo(params[8]).Int()
  525. suffix := params[9]
  526. guize := params[10]
  527. guizes := strings.Split(guize, ";")
  528. fixedinfo := params[11]
  529. fixedinfoarr := strings.Split(fixedinfo, ";")
  530. sampletypeid := fixedinfoarr[0]
  531. organcode := fixedinfoarr[1]
  532. donorskid := fixedinfoarr[2]
  533. sampletypename := ""
  534. sampletypecode := ""
  535. var stypeentity sampletype.SampleType
  536. if sampletypeid != "" {
  537. svctype := sampletype.GetSampleTypeService(utils.DBE)
  538. wherestype := " AccCode='" + acccode + "' and Id =" + sampletypeid + ""
  539. svctype.GetEntity(&stypeentity, wherestype)
  540. sampletypecode = stypeentity.Code
  541. sampletypename = stypeentity.Name
  542. }
  543. organname := ""
  544. if organcode != "" {
  545. svcorgan := sampleorgan.GetSampleOrganService(utils.DBE)
  546. whereorgan := " AccCode='" + acccode + "' and Item = 1 and Code ='" + organcode + "'"
  547. organname = svcorgan.GetOrganNameByCode(whereorgan)
  548. }
  549. donorname := ""
  550. donoridcard := ""
  551. if donorskid != "" {
  552. svcdonor := donorsinfo.GetDonorsInfoService(utils.DBE)
  553. wheredonor := " Id=" + donorskid
  554. donors_data := svcdonor.QueryDonorEntity(acccode+DonorstbName, wheredonor)
  555. donorname = donors_data.Name
  556. donoridcard = donors_data.IdCard
  557. }
  558. var barcode string
  559. var lastnum lastordernum.LastOrderNum
  560. svc := lastordernum.GetLastOrderNumService(utils.DBE)
  561. if coderules == "1" { //自动生成流水号
  562. for i := 0; i < copies; i++ {
  563. lastdata := svc.GetLastSamplespreinputNum(acccode)
  564. lastnum.LastNum = lastdata
  565. svc.UpdateSamplespreinputNum(lastnum, acccode)
  566. barcode = lastdata
  567. it.AccCode = acccode
  568. it.SampleCode = barcode
  569. it.BarCode = barcode
  570. it.SampleTypeCode = sampletypecode
  571. it.SampleTypeName = sampletypename
  572. it.SampleOrgan = organcode
  573. it.SampleOrganName = organname
  574. it.SourceIdCard = donoridcard
  575. it.SourceId = donorskid
  576. it.SourceName = donorname
  577. for j := 0; j < nums; j++ {
  578. datas = append(datas, it)
  579. }
  580. }
  581. } else if coderules == "2" { //前缀加流水号加后缀
  582. for h := start; h <= end; h++ {
  583. barcode = prefix + strconv.FormatFloat(float64(h)*(1/math.Pow(10, float64(digit))), 'f', digit, 64)[2:] + suffix
  584. it.AccCode = acccode
  585. it.SampleCode = barcode
  586. it.BarCode = barcode
  587. it.SampleTypeCode = sampletypecode
  588. it.SampleTypeName = sampletypename
  589. it.SampleOrgan = organcode
  590. it.SampleOrganName = organname
  591. it.SourceIdCard = donoridcard
  592. it.SourceId = donorskid
  593. it.SourceName = donorname
  594. for j := 0; j < nums; j++ {
  595. datas = append(datas, it)
  596. }
  597. }
  598. } else {
  599. //取编码规则的明细类型
  600. svcCodeRuleDetai := coderule.GetCodeRuleService(utils.DBE)
  601. whereCodeRuleDetai := " AccCode = '" + acccode + "' and MainId = '" + coderules + "'"
  602. CodeRuleDetailList := svcCodeRuleDetai.GetCodeRuleDetailList(whereCodeRuleDetai)
  603. //获取流水号在第几位 liushuihao
  604. //取出管号处于第几位 guanhaoweishu
  605. var liushuihao, guanhaoweishu int
  606. var isHasGuanhao bool //是否含有管号
  607. isHasGuanhao = false
  608. var guanhlen int
  609. for r := 0; r < len(CodeRuleDetailList); r++ {
  610. if CodeRuleDetailList[r].ItemName == "流水号" {
  611. liushuihao = r
  612. }
  613. if CodeRuleDetailList[r].ItemName == "管号" {
  614. guanhaoweishu = r
  615. isHasGuanhao = true //含有管号
  616. }
  617. }
  618. liushuihaows := CodeRuleDetailList[liushuihao].ItemNum //流水号长度
  619. if isHasGuanhao {
  620. guanhlen = CodeRuleDetailList[guanhaoweishu].ItemNum //管号长度
  621. }
  622. //获取编码规则的流水号
  623. svccoderule := coderule.GetCodeRuleService(utils.DBE)
  624. where1 := " (AccCode = '" + acccode + "' and Id = " + coderules + ")"
  625. CodeRuleList := svccoderule.GetCodeRuleList(where1)
  626. lastnum := CodeRuleList[0].LastNum
  627. for i := 0; i < copies; i++ { //样本数量
  628. var codestr string
  629. var codestrpre string
  630. var codestrlast string
  631. if lastnum == "" {
  632. lastnum = strconv.FormatFloat(float64(1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:] //生成相应位数的流水号
  633. } else {
  634. n, _ := utils.StrTo(lastnum).Int()
  635. lastnum = strconv.FormatFloat(float64(n+1)*(1/math.Pow(10, float64(liushuihaows))), 'f', liushuihaows, 64)[2:]
  636. }
  637. if isHasGuanhao {
  638. for k := 0; k < guanhaoweishu; k++ { //拼接管号前面的
  639. if CodeRuleDetailList[k].ItemName == "流水号" { //判断前面这块中有没有流水号
  640. codestrpre = codestrpre + lastnum
  641. } else {
  642. codestrpre = codestrpre + guizes[k]
  643. }
  644. }
  645. for y := guanhaoweishu + 1; y < len(CodeRuleDetailList); y++ { //拼接管号后面的
  646. if CodeRuleDetailList[y].ItemName == "流水号" { //判断后面这块中有没有流水号
  647. codestrlast = codestrlast + lastnum
  648. } else {
  649. codestrlast = codestrlast + guizes[y]
  650. }
  651. }
  652. guanhaos := strings.Split(guizes[guanhaoweishu], "-")
  653. guanhaos0, _ := utils.StrTo(guanhaos[0]).Int()
  654. guanhaos1, _ := utils.StrTo(guanhaos[1]).Int()
  655. it.AccCode = acccode
  656. it.SampleCode = codestrpre + codestrlast
  657. it.SampleTypeCode = sampletypecode
  658. it.SampleTypeName = sampletypename
  659. it.SampleOrgan = organcode
  660. it.SampleOrganName = organname
  661. it.SourceIdCard = donoridcard
  662. it.SourceId = donorskid
  663. it.SourceName = donorname
  664. for g := guanhaos0; g <= guanhaos1; g++ { //加入管号
  665. guanhao := strconv.FormatFloat(float64(g)/math.Pow10(guanhlen), 'f', guanhlen, 64)[2:]
  666. codestr = codestrpre + guanhao + codestrlast
  667. it.BarCode = codestr
  668. for j := 0; j < nums; j++ {
  669. datas = append(datas, it)
  670. }
  671. }
  672. } else {
  673. for n := 0; n < len(CodeRuleDetailList); n++ { //拼接管号前面的
  674. if CodeRuleDetailList[n].ItemName == "流水号" { //判断前面这块中有没有流水号
  675. codestr = codestr + lastnum
  676. } else {
  677. codestr = codestr + guizes[n]
  678. }
  679. }
  680. it.SampleCode = codestr
  681. it.AccCode = acccode
  682. it.BarCode = codestr
  683. it.SampleTypeCode = sampletypecode
  684. it.SampleTypeName = sampletypename
  685. it.SampleOrgan = organcode
  686. it.SampleOrganName = organname
  687. it.SourceIdCard = donoridcard
  688. it.SourceId = donorskid
  689. it.SourceName = donorname
  690. for m := 0; m < nums; m++ { //单个打印数量
  691. datas = append(datas, it)
  692. }
  693. }
  694. }
  695. svccoderule.UpdateLastNum(lastnum, coderules)
  696. }
  697. return
  698. }
  699. //物料入库单打印
  700. func materialRKprint(param string) (it material.MaterialRKPrintModel, datas []material.MaterialRKPrintModel) {
  701. param = Base64Decode(param)
  702. params := strings.Split(param, ",")
  703. RKNo := params[1]
  704. acccode := params[2]
  705. where := ""
  706. if RKNo != "" {
  707. where = where + " a.RKNo=" + RKNo + ""
  708. }
  709. svc := material.GetMaterialService(utils.DBE)
  710. datas = svc.MaterialRKPrint(acccode, where)
  711. return
  712. }
  713. //物料出库单打印
  714. func materialCKprint(param string) (it material.MaterialCKPrintModel, datas []material.MaterialCKPrintModel) {
  715. param = Base64Decode(param)
  716. params := strings.Split(param, ",")
  717. CKNo := params[1]
  718. acccode := params[2]
  719. where := ""
  720. if CKNo != "" {
  721. where = where + " a.CKNo=" + CKNo + ""
  722. }
  723. svc := material.GetMaterialService(utils.DBE)
  724. datas = svc.MaterialCKPrint(acccode, where)
  725. return
  726. }
  727. //物料盘点单打印
  728. func materialPDprint(param string) (it material.MaterialPDPrintModel, datas []material.MaterialPDPrintModel) {
  729. param = Base64Decode(param)
  730. params := strings.Split(param, ",")
  731. PDNo := params[1]
  732. acccode := params[2]
  733. where := ""
  734. if PDNo != "" {
  735. where = where + " a.PDNo=" + PDNo + ""
  736. }
  737. svc := material.GetMaterialService(utils.DBE)
  738. datas = svc.MaterialPDPrint(acccode, where)
  739. return
  740. }
  741. func (this *HomeController) Printservice() {
  742. param := this.Input().Get("param")
  743. paramreal := Base64Decode(param)
  744. paramreals := strings.Split(paramreal, ",") //参数,表ID,AccCode
  745. funcode := paramreals[0]
  746. var item interface{}
  747. var cols []PrintColType
  748. var multiDatas []PrintData
  749. switch funcode {
  750. case "samplespreinput":
  751. it, itema := spreBarcodeprint(param)
  752. cols = AutoColType(&it)
  753. item = itema
  754. case "samples":
  755. it, itema := sampleBarcodeprint(param)
  756. cols = AutoColType(&it)
  757. item = itema
  758. case "animalsamples":
  759. it, itema := animalBarcodeprint(param)
  760. cols = AutoColType(&it)
  761. item = itema
  762. case "animalsamplesbatch":
  763. it, itema := animalBarcodeprintbatch(param)
  764. cols = AutoColType(&it)
  765. item = itema
  766. case "animalarchivedbatch":
  767. it, itema := animalArchivedSampleBarcode(param)
  768. cols = AutoColType(&it)
  769. item = itema
  770. case "lableprint":
  771. it, itema := lablepreprint(param)
  772. cols = AutoColType(&it)
  773. item = itema
  774. case "lableprintnotinsertsample":
  775. it, itema := lablepreprintnotinsertsample(param)
  776. cols = AutoColType(&it)
  777. item = itema
  778. case "samplesbatch":
  779. it, itema := sampleBarcodeprintbatch(param)
  780. cols = AutoColType(&it)
  781. item = itema
  782. case "archivedsamplesbatch":
  783. it, itema := archivedSampleBarcodeprintbatch(param)
  784. cols = AutoColType(&it)
  785. item = itema
  786. // case "testresult":
  787. // it, itema := testResultprint(param)
  788. // cols = AutoColType(&it)
  789. // item = itema
  790. // case "testapplication":
  791. // it, itema := testApplyprint(param)
  792. // cols = AutoColType(&it)
  793. // item = itema
  794. // case "collectionprinting":
  795. // it, itema := testCollectionprint(param)
  796. // cols = AutoColType(&it)
  797. // item = itema
  798. // case "contractprinting":
  799. // it, itema := testContractprint(param)
  800. // cols = AutoColType(&it)
  801. // item = itema
  802. // case "positivereport":
  803. // it, itema := testPositiveReport(param)
  804. // cols = AutoColType(&it)
  805. // item = itema
  806. // case "testtransfer":
  807. // it, itema := testTransferprint(param)
  808. // cols = AutoColType(&it)
  809. // item = itema
  810. // case "testtransferbarcode":
  811. // it, itema := testTransferBarCodeprint(param)
  812. // cols = AutoColType(&it)
  813. // item = itema
  814. // case "testapplybarcode":
  815. // it, itema := testApplyBarCodeprint(param)
  816. // cols = AutoColType(&it)
  817. // item = itema
  818. // case "cellscollectionbarcode":
  819. // it, itema := cellscollectionBarCodeprint(param)
  820. // cols = AutoColType(&it)
  821. // item = itema
  822. // case "hospitalresult":
  823. // it, itema := hospitalResultprint(param)
  824. // cols = AutoColType(&it)
  825. // item = itema
  826. // case "packageresult":
  827. // it, itema := packageResultprint(param)
  828. // cols = AutoColType(&it)
  829. // item = itema
  830. case "materialRKprint":
  831. it, itema := materialRKprint(param)
  832. cols = AutoColType(&it)
  833. item = itema
  834. case "materialCKprint":
  835. it, itema := materialCKprint(param)
  836. cols = AutoColType(&it)
  837. item = itema
  838. case "materialPDprint":
  839. it, itema := materialPDprint(param)
  840. cols = AutoColType(&it)
  841. item = itema
  842. // case "samplelist":
  843. // it, itema := sampleListeprint(param)
  844. // cols = AutoColType(&it)
  845. // item = itema
  846. // case "preparedbarcode":
  847. // fmt.Println("22222222222")
  848. // it, itema := PreparedBarCode(param)
  849. // cols = AutoColType(&it)
  850. // item = itema
  851. // case "entrustprinting":
  852. // it, itema := testEntrustprint(param)
  853. // cols = AutoColType(&it)
  854. // item = itema
  855. // var mydata = PrintData{item, cols}
  856. // multiDatas = append(multiDatas, mydata)
  857. // its, itemas := testDeliverprint(param)
  858. // cols = AutoColType(&its)
  859. // item = itemas
  860. // mydata = PrintData{item, cols}
  861. // multiDatas = append(multiDatas, mydata)
  862. }
  863. var datas []PrintData
  864. if len(multiDatas) <= 0 {
  865. var data = PrintData{item, cols}
  866. datas = append(datas, data)
  867. } else {
  868. datas = multiDatas
  869. }
  870. this.Data["json"] = PrintInfo{datas, []string{"var1", "var2", "var3"}}
  871. this.ServeJSON()
  872. }