public_api_controller.go 45KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "encoding/json"
  7. "fmt"
  8. "os"
  9. "path"
  10. "runtime"
  11. "strconv"
  12. "strings"
  13. "time"
  14. "github.com/astaxie/beego"
  15. )
  16. type PublicApiController struct {
  17. BaseAPIController
  18. }
  19. //var f_a *os.File
  20. //
  21. //
  22. // func init() {
  23. // org_id, _ := beego.AppConfig.Int64("org_id")
  24. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  25. // Mkdir(miConfig.OrgName+"日志")
  26. // month := time.Unix(1557042972, 0).Format("1")
  27. // year := time.Now().Format("2006")
  28. // month = time.Now().Format("01")
  29. // day := time.Now().Format("02")
  30. // file := strconv.FormatInt( org_id, 10) + "_"+ year + month + day + "_log"
  31. // file_name := file + ".txt"
  32. // file_path := miConfig.OrgName+"日志" + "/" + file_name
  33. // exist, _ := PathExists(file_path)
  34. // if exist {//存在
  35. // f_a, _ := os.OpenFile(file_path,os.O_WRONLY,0644)
  36. // content := "新的日志内容吧"
  37. // n, _ := f_a.Seek(0,2)
  38. // f_a.WriteAt([]byte(content),n)
  39. //
  40. // } else { //不存在
  41. // fmt.Println("文件不存在,创建文件")
  42. // f, err := os.Create(miConfig.OrgName+"日志" + "/" + file_name)
  43. // defer f.Close()
  44. // if err !=nil {
  45. // } else {
  46. // _,err=f.Write([]byte("记录日志"))
  47. // }
  48. // }
  49. //
  50. // }
  51. func PublicApiRegistRouters() {
  52. beego.Router("/api/public/getadviceconfig", &PublicApiController{}, "Get:GetDoctorAdviceConfig")
  53. beego.Router("/api/public/servertime", &PublicApiController{}, "Get:GetServerTime")
  54. beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
  55. beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
  56. beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
  57. beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
  58. beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
  59. beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
  60. beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
  61. beego.Router("/groupno", &PublicApiController{}, "get:HandleGroupNo")
  62. //beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  63. }
  64. func (c *PublicApiController) GetDoctorAdviceConfig() {
  65. drugs, _, _ := service.GetPublicDrugDics()
  66. drugways, _, _ := service.GetPublicDrugWayDics()
  67. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  68. c.ServeSuccessJSON(map[string]interface{}{
  69. "drugs": drugs,
  70. "drugways": drugways,
  71. "efs": efs,
  72. })
  73. }
  74. func (c *PublicApiController) GetServerTime() {
  75. timeNow := time.Now()
  76. timeNowStamp := timeNow.Unix()
  77. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  78. c.ServeSuccessJSON(map[string]interface{}{
  79. "time": timeNowStr,
  80. "timestamp": timeNowStamp,
  81. })
  82. }
  83. func (c *PublicApiController) AppRelease() {
  84. // appId := c.GetString("appid")
  85. version := c.GetString("version")
  86. appType, _ := c.GetInt64("app_type", 0)
  87. appVersion, err := service.GetAppVersionByAppType(appType)
  88. if err != nil {
  89. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  90. return
  91. }
  92. if appVersion == nil {
  93. c.ServeSuccessJSON(map[string]interface{}{
  94. "version": nil,
  95. "state": 2,
  96. })
  97. return
  98. }
  99. state := strings.Compare(version, appVersion.Version)
  100. // state := 1
  101. if state < 0 {
  102. c.ServeSuccessJSON(map[string]interface{}{
  103. "version": appVersion,
  104. "state": appVersion.Status,
  105. })
  106. return
  107. }
  108. c.ServeSuccessJSON(map[string]interface{}{
  109. "version": nil,
  110. "state": 2,
  111. })
  112. return
  113. }
  114. func (this *PublicApiController) GetJson() {
  115. type Global struct {
  116. DeviceSN string
  117. Version string
  118. Timestamp string
  119. InterfaceSource string
  120. }
  121. type RBPResultModel struct {
  122. Sys string
  123. Dia string
  124. HR string
  125. MeasureTime string
  126. }
  127. type ScannerResultModel struct {
  128. Code string
  129. }
  130. type IDCardResultModel struct {
  131. IDCardNo string
  132. UserName string
  133. Age string
  134. Female string
  135. Male string
  136. SocialSecurityNo string
  137. }
  138. type JsonTemp struct {
  139. Global Global
  140. RBPResultModel RBPResultModel
  141. ScannerResultModel ScannerResultModel
  142. IDCardResultModel IDCardResultModel
  143. }
  144. var person JsonTemp
  145. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  146. fmt.Println(err3)
  147. fmt.Println(person.Global)
  148. //temp := JsonTemp{
  149. // Global:Global{
  150. // DeviceSN:"1122",
  151. // Version:"1122",
  152. // Timestamp:"1222",
  153. // InterfaceSource:"1233",
  154. // },
  155. // RBPResultModel: RBPResultModel{
  156. // Sys:"12",
  157. // Dia:"22",
  158. // HR:"23",
  159. // MeasureTime:"123",
  160. // },
  161. // ScannerResultModel:ScannerResultModel{
  162. // Code:"1233",
  163. // },
  164. // IDCardResultModel:IDCardResultModel{
  165. // IDCardNo:"123",
  166. // UserName:"123",
  167. // Age:"123",
  168. // Female:"123",
  169. // Male:"123",
  170. // SocialSecurityNo:"123",
  171. // },
  172. //}
  173. //
  174. //jsonBytes, err := json.Marshal(temp)
  175. //if err != nil {
  176. // fmt.Println(err)
  177. //}
  178. //fmt.Println(string(jsonBytes))
  179. }
  180. func (c *PublicApiController) HandleData() {
  181. //service.HandleData()
  182. org_app, _ := service.GetAllAppOrg()
  183. //org_role, _ := service.GetAllRole()
  184. //
  185. //var org_ids []int64
  186. for _, apps := range org_app {
  187. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  188. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  189. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  190. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  191. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  192. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  193. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  194. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  195. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  196. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  197. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  198. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  199. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  200. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  201. var xt_temp_org_app *models.OrgApp
  202. //var mall_temp_org_app *models.OrgApp
  203. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  204. app, _ := service.GetOrgAppA(0, 3)
  205. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  206. if org == nil || org.Id == 0 {
  207. continue
  208. }
  209. app.Id = 0
  210. app.OrgId = apps.OrgId
  211. app.Creator = int(org.Creator)
  212. app.Number = 0
  213. app.Status = 1
  214. app.ModifyTime = time.Now().Unix()
  215. app.CreateTime = time.Now().Unix()
  216. service.CreateOrgApp(app)
  217. xt_temp_org_app = app
  218. } else {
  219. xt_temp_org_app = xt_org_app
  220. }
  221. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  222. //
  223. // app, _ := service.GetOrgAppA(0, 1)
  224. // //org, _ := service.GetOrgById(int64(12))
  225. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  226. // if org == nil || org.Id == 0 {
  227. // continue
  228. // }
  229. //
  230. //
  231. // app.OrgId = apps.OrgId
  232. // app.Id = 0
  233. //
  234. // app.Creator = int(org.Creator)
  235. // app.Number = 0
  236. // app.Status = 1
  237. // app.ModifyTime = time.Now().Unix()
  238. // app.CreateTime = time.Now().Unix()
  239. // service.CreateOrgApp(app)
  240. //
  241. //}
  242. //
  243. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  244. // app, _ := service.GetOrgAppA(0, 4)
  245. // //org, _ := service.GetOrgById(int64(12))
  246. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  247. // if org == nil || org.Id == 0 {
  248. // continue
  249. // }
  250. //
  251. //
  252. // app.OrgId = apps.OrgId
  253. // app.Creator = int(org.Creator)
  254. // app.Number = 0
  255. // app.Id = 0
  256. //
  257. // app.Status = 1
  258. // app.ModifyTime = time.Now().Unix()
  259. // app.CreateTime = time.Now().Unix()
  260. // service.CreateOrgApp(app)
  261. //}
  262. //
  263. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  264. // app, _ := service.GetOrgAppA(0, 5)
  265. // //org, _ := service.GetOrgById(int64(12))
  266. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  267. //
  268. // if org == nil || org.Id == 0 {
  269. // continue
  270. // }
  271. //
  272. // app.OrgId = apps.OrgId
  273. // app.Creator = int(org.Creator)
  274. // app.Number = 0
  275. // app.Id = 0
  276. //
  277. // app.Status = 1
  278. // app.ModifyTime = time.Now().Unix()
  279. // app.CreateTime = time.Now().Unix()
  280. // service.CreateOrgApp(app)
  281. // mall_temp_org_app = app
  282. //} else {
  283. // mall_temp_org_app = mall_org_app
  284. //}
  285. //
  286. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  287. // app, _ := service.GetOrgAppA(0, 16)
  288. // //org, _ := service.GetOrgById(int64(12))
  289. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  290. // if org == nil || org.Id == 0 {
  291. // continue
  292. // }
  293. //
  294. // app.OrgId = apps.OrgId
  295. // app.Creator = int(org.Creator)
  296. // app.Number = 11
  297. // app.Id = 0
  298. // app.Status = 1
  299. // app.ModifyTime = time.Now().Unix()
  300. // app.CreateTime = time.Now().Unix()
  301. // app.Pid = xt_temp_org_app.Id
  302. // service.CreateOrgApp(app)
  303. //
  304. //}
  305. //
  306. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  307. // app, _ := service.GetOrgAppA(0, 17)
  308. // //org, _ := service.GetOrgById(int64(12))
  309. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  310. // if org == nil || org.Id == 0 {
  311. // continue
  312. // }
  313. //
  314. // app.OrgId = apps.OrgId
  315. // app.Creator = int(org.Creator)
  316. // app.Number = 12
  317. // app.Id = 0
  318. // app.Status = 1
  319. // app.ModifyTime = time.Now().Unix()
  320. // app.CreateTime = time.Now().Unix()
  321. // app.Pid = xt_temp_org_app.Id
  322. // service.CreateOrgApp(app)
  323. //
  324. //}
  325. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  326. app, _ := service.GetOrgAppA(0, 18)
  327. //org, _ := service.GetOrgById(int64(12))
  328. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  329. if org == nil || org.Id == 0 {
  330. continue
  331. }
  332. app.OrgId = apps.OrgId
  333. app.Creator = int(org.Creator)
  334. app.Number = 5
  335. app.Id = 0
  336. app.Status = 1
  337. app.ModifyTime = time.Now().Unix()
  338. app.CreateTime = time.Now().Unix()
  339. app.Pid = xt_temp_org_app.Id
  340. service.CreateOrgApp(app)
  341. }
  342. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  343. // app, _ := service.GetOrgAppA(0, 7)
  344. // //org, _ := service.GetOrgById(int64(12))
  345. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  346. // if org == nil || org.Id == 0 {
  347. // continue
  348. // }
  349. //
  350. //
  351. // app.OrgId = apps.OrgId
  352. // app.Creator = int(org.Creator)
  353. // app.Number = 2
  354. // app.Status = 2
  355. // app.Id = 0
  356. //
  357. // app.ModifyTime = time.Now().Unix()
  358. // app.CreateTime = time.Now().Unix()
  359. // app.Pid = xt_temp_org_app.Id
  360. //
  361. // service.CreateOrgApp(app)
  362. //}
  363. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  364. // app, _ := service.GetOrgAppA(0, 8)
  365. // //org, _ := service.GetOrgById(int64(12))
  366. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  367. // if org == nil || org.Id == 0 {
  368. // continue
  369. // }
  370. //
  371. //
  372. // app.OrgId = apps.OrgId
  373. // app.Creator = int(org.Creator)
  374. // app.Number = 3
  375. // app.Id = 0
  376. //
  377. // app.Pid = mall_temp_org_app.Id
  378. //
  379. // app.Status = 1
  380. // app.ModifyTime = time.Now().Unix()
  381. // app.CreateTime = time.Now().Unix()
  382. // service.CreateOrgApp(app)
  383. //}
  384. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  385. // app, _ := service.GetOrgAppA(0, 9)
  386. // //org, _ := service.GetOrgById(int64(12))
  387. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  388. // if org == nil || org.Id == 0 {
  389. // continue
  390. // }
  391. //
  392. //
  393. // app.OrgId = apps.OrgId
  394. // app.Pid = xt_temp_org_app.Id
  395. //
  396. // app.Creator = int(org.Creator)
  397. // app.Number = 4
  398. // app.Id = 0
  399. //
  400. // app.Status = 1
  401. // app.ModifyTime = time.Now().Unix()
  402. // app.CreateTime = time.Now().Unix()
  403. // service.CreateOrgApp(app)
  404. //
  405. //}
  406. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  407. // app, _ := service.GetOrgAppA(0, 10)
  408. // //org, _ := service.GetOrgById(int64(12))
  409. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  410. // if org == nil || org.Id == 0 {
  411. // continue
  412. // }
  413. //
  414. //
  415. // app.OrgId = apps.OrgId
  416. // app.Creator = int(org.Creator)
  417. // app.Pid = xt_temp_org_app.Id
  418. //
  419. // app.Number = 5
  420. // app.Id = 0
  421. //
  422. // app.Status = 1
  423. // app.ModifyTime = time.Now().Unix()
  424. // app.CreateTime = time.Now().Unix()
  425. // service.CreateOrgApp(app)
  426. //}
  427. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  428. // app, _ := service.GetOrgAppA(0, 11)
  429. // //org, _ := service.GetOrgById(int64(12))
  430. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  431. // if org == nil || org.Id == 0 {
  432. // continue
  433. // }
  434. //
  435. //
  436. // app.OrgId = apps.OrgId
  437. // app.Creator = int(org.Creator)
  438. // app.Pid = xt_temp_org_app.Id
  439. // app.Id = 0
  440. //
  441. // app.Number = 6
  442. // app.Status = 1
  443. // app.ModifyTime = time.Now().Unix()
  444. // app.CreateTime = time.Now().Unix()
  445. // service.CreateOrgApp(app)
  446. //}
  447. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  448. // app, _ := service.GetOrgAppA(0, 12)
  449. // //org, _ := service.GetOrgById(int64(12))
  450. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  451. // if org == nil || org.Id == 0 {
  452. // continue
  453. // }
  454. //
  455. //
  456. // app.OrgId = apps.OrgId
  457. // app.Creator = int(org.Creator)
  458. // app.Pid = xt_temp_org_app.Id
  459. // app.Number = 7
  460. // app.Status = 1
  461. // app.Id = 0
  462. //
  463. // app.ModifyTime = time.Now().Unix()
  464. // app.CreateTime = time.Now().Unix()
  465. // service.CreateOrgApp(app)
  466. //}
  467. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  468. // app, _ := service.GetOrgAppA(0, 13)
  469. // //org, _ := service.GetOrgById(int64(12))
  470. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  471. // if org == nil || org.Id == 0 {
  472. // continue
  473. // }
  474. //
  475. //
  476. // app.OrgId = apps.OrgId
  477. // app.Creator = int(org.Creator)
  478. // app.Pid = xt_temp_org_app.Id
  479. // app.Number = 8
  480. // app.Id = 0
  481. // app.Status = 1
  482. // app.ModifyTime = time.Now().Unix()
  483. // app.CreateTime = time.Now().Unix()
  484. // service.CreateOrgApp(app)
  485. //}
  486. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  487. // app, _ := service.GetOrgAppA(0, 14)
  488. // //org, _ := service.GetOrgById(int64(12))
  489. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  490. // if org == nil || org.Id == 0 {
  491. // continue
  492. // }
  493. //
  494. //
  495. // app.OrgId = apps.OrgId
  496. // app.Creator = int(org.Creator)
  497. // app.Pid = xt_temp_org_app.Id
  498. // app.Id = 0
  499. // app.Number = 9
  500. // app.Status = 1
  501. // app.ModifyTime = time.Now().Unix()
  502. // app.CreateTime = time.Now().Unix()
  503. // service.CreateOrgApp(app)
  504. //}
  505. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  506. // app, _ := service.GetOrgAppA(0, 15)
  507. // //org, _ := service.GetOrgById(int64(12))
  508. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  509. // if org == nil || org.Id == 0 {
  510. // continue
  511. // }
  512. //
  513. // app.OrgId = apps.OrgId
  514. // app.Creator = int(org.Creator)
  515. // app.Pid = xt_temp_org_app.Id
  516. // app.Number = 10
  517. // app.Status = 1
  518. // app.Id = 0
  519. // app.ModifyTime = time.Now().Unix()
  520. // app.CreateTime = time.Now().Unix()
  521. // service.CreateOrgApp(app)
  522. //}
  523. }
  524. //for _, role := range org_role {
  525. // org_ids = append(org_ids, role.OrgId)
  526. //}
  527. //
  528. //
  529. ////创建内置角色
  530. //InitRoleAndPurviews(org_ids)
  531. //var org_id int = 0
  532. //管理员
  533. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  534. //for _, item := range app_roles{
  535. // var ids string
  536. // if len(item.RoleIds) == 0{
  537. // ids = strconv.FormatInt( item.RoleId,10)
  538. // }else{
  539. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  540. // }
  541. // service.UpdateRoleIds(item.Id, ids)
  542. //}
  543. //护士医生
  544. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  545. // for _, item := range app_roles2{
  546. // var ids string
  547. // if len(item.RoleIds) == 0{
  548. // ids = strconv.FormatInt( item.RoleId,10)
  549. // }else{
  550. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  551. // }
  552. // if item.UserType == 2{
  553. // role := service.FindRoleByUserTypeOne(item.OrgId)
  554. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  555. //
  556. // } else if item.UserType == 3{
  557. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  558. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  559. // }
  560. // service.UpdateRoleIds(item.Id, ids)
  561. // }
  562. //c.ServeSuccessJSON(map[string]interface{}{
  563. // "msg": "ok",
  564. //})
  565. }
  566. func (c *PublicApiController) HandleGroupNo() {
  567. pts, _ := service.GetHisPrescriptionTemplateTwo()
  568. for _, item := range pts {
  569. if len(item.HisPrescriptionAdviceTemplate) > 0 {
  570. for index, subItem := range item.HisPrescriptionAdviceTemplate {
  571. subItem.Groupno = int64(index + 1)
  572. service.SaveAdviceTemplate(subItem)
  573. }
  574. }
  575. }
  576. }
  577. func InitRoleAndPurviews(org_ids []int64) {
  578. roles := LoadRoleConfig("./role.json").Roles
  579. for _, org_id := range org_ids {
  580. app, _ := service.GetOrgAppB(org_id, 3)
  581. role, _ := service.GetSystemRole(org_id)
  582. if app == nil || app.Id == 0 {
  583. continue
  584. }
  585. if len(role) == 0 {
  586. for _, item := range roles {
  587. role := &models.Role{
  588. RoleName: item.RoleName,
  589. RoleIntro: item.RoleIntroduction,
  590. Creator: 0,
  591. OrgId: org_id,
  592. AppId: app.Id,
  593. IsSuperAdmin: false,
  594. Status: 1,
  595. CreateTime: time.Now().Unix(),
  596. ModifyTime: time.Now().Unix(),
  597. Number: item.Number,
  598. IsSystem: item.IsSystem,
  599. }
  600. err := service.CreateOrgRoleB(role)
  601. if err == nil {
  602. purview := &models.RolePurview{
  603. RoleId: role.Id,
  604. OrgId: org_id,
  605. AppId: role.AppId,
  606. PurviewIds: item.PurviewIds,
  607. Status: 1,
  608. CreateTime: time.Now().Unix(),
  609. ModifyTime: time.Now().Unix(),
  610. }
  611. func_purview := &models.SgjUserRoleFuncPurview{
  612. RoleId: role.Id,
  613. OrgId: org_id,
  614. AppId: role.AppId,
  615. PurviewIds: item.FuncIds,
  616. Status: 1,
  617. Ctime: time.Now().Unix(),
  618. Mtime: time.Now().Unix(),
  619. }
  620. service.CreateRolePurviewB(purview)
  621. service.CreateFuncRolePurviewB(func_purview)
  622. }
  623. }
  624. }
  625. }
  626. }
  627. type RoleConfig struct {
  628. Roles []*models.VMUserRoleAndPurview "json:roles"
  629. }
  630. func LoadRoleConfig(dataFile string) *RoleConfig {
  631. var config RoleConfig
  632. _, filename, _, _ := runtime.Caller(1)
  633. datapath := path.Join(path.Dir(filename), dataFile)
  634. config_file, err := os.Open(datapath)
  635. if err != nil {
  636. emit("Failed to open config file '%s': %s\n", datapath, err)
  637. return &config
  638. }
  639. fi, _ := config_file.Stat()
  640. buffer := make([]byte, fi.Size())
  641. _, err = config_file.Read(buffer)
  642. buffer, err = StripComments(buffer) //去掉注释
  643. if err != nil {
  644. emit("Failed to strip comments from json: %s\n", err)
  645. return &config
  646. }
  647. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  648. err = json.Unmarshal(buffer, &config) //解析json格式数据
  649. if err != nil {
  650. emit("Failed unmarshalling json: %s\n", err)
  651. return &config
  652. }
  653. return &config
  654. }
  655. type GoodTypesConfig struct {
  656. GoodTypes []*models.VMGoodsType "json:list"
  657. }
  658. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  659. var config GoodTypesConfig
  660. _, filename, _, _ := runtime.Caller(1)
  661. datapath := path.Join(path.Dir(filename), dataFile)
  662. config_file, err := os.Open(datapath)
  663. if err != nil {
  664. emit("Failed to open config file '%s': %s\n", datapath, err)
  665. return &config
  666. }
  667. fi, _ := config_file.Stat()
  668. buffer := make([]byte, fi.Size())
  669. _, err = config_file.Read(buffer)
  670. buffer, err = StripComments(buffer) //去掉注释
  671. if err != nil {
  672. emit("Failed to strip comments from json: %s\n", err)
  673. return &config
  674. }
  675. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  676. err = json.Unmarshal(buffer, &config) //解析json格式数据
  677. if err != nil {
  678. emit("Failed unmarshalling json: %s\n", err)
  679. return &config
  680. }
  681. return &config
  682. }
  683. func (c *PublicApiController) HandleStockData() {
  684. org, _ := service.FindAllOrgByImportType()
  685. for _, item := range org {
  686. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  687. goodTypes := &models.GoodsType{
  688. TypeCode: "14000000",
  689. TypeName: "穿刺针",
  690. Remark: "",
  691. Ctime: time.Now().Unix(),
  692. Mtime: time.Now().Unix(),
  693. Creater: 0,
  694. Modifier: 0,
  695. OrgId: item.Id,
  696. Status: 1,
  697. Type: 1,
  698. Number: 1,
  699. }
  700. service.AddSigleGoodType(goodTypes)
  701. goodTypes1 := &models.GoodsType{
  702. TypeCode: "14000001",
  703. TypeName: "透析器",
  704. Remark: "",
  705. Ctime: time.Now().Unix(),
  706. Mtime: time.Now().Unix(),
  707. Creater: 0,
  708. Modifier: 0,
  709. OrgId: item.Id,
  710. Status: 1,
  711. Type: 1,
  712. Number: 2,
  713. }
  714. service.AddSigleGoodType(goodTypes1)
  715. goodTypes2 := &models.GoodsType{
  716. TypeCode: "14000002",
  717. TypeName: "灌流器",
  718. Remark: "",
  719. Ctime: time.Now().Unix(),
  720. Mtime: time.Now().Unix(),
  721. Creater: 0,
  722. Modifier: 0,
  723. OrgId: item.Id,
  724. Status: 1,
  725. Type: 1,
  726. Number: 3,
  727. }
  728. service.AddSigleGoodType(goodTypes2)
  729. goodTypes3 := &models.GoodsType{
  730. TypeCode: "14000003",
  731. TypeName: "血路管",
  732. Remark: "",
  733. Ctime: time.Now().Unix(),
  734. Mtime: time.Now().Unix(),
  735. Creater: 0,
  736. Modifier: 0,
  737. OrgId: item.Id,
  738. Status: 1,
  739. Type: 1,
  740. Number: 4,
  741. }
  742. service.AddSigleGoodType(goodTypes3)
  743. goodTypes4 := &models.GoodsType{
  744. TypeCode: "14000004",
  745. TypeName: "血滤补液管",
  746. Remark: "",
  747. Ctime: time.Now().Unix(),
  748. Mtime: time.Now().Unix(),
  749. Creater: 0,
  750. Modifier: 0,
  751. OrgId: item.Id,
  752. Status: 1,
  753. Type: 1,
  754. Number: 5,
  755. }
  756. service.AddSigleGoodType(goodTypes4)
  757. goodTypes5 := &models.GoodsType{
  758. TypeCode: "14000005",
  759. TypeName: "注射器",
  760. Remark: "",
  761. Ctime: time.Now().Unix(),
  762. Mtime: time.Now().Unix(),
  763. Creater: 0,
  764. Modifier: 0,
  765. OrgId: item.Id,
  766. Status: 1,
  767. Type: 1,
  768. Number: 6,
  769. }
  770. service.AddSigleGoodType(goodTypes5)
  771. goodTypes6 := &models.GoodsType{
  772. TypeCode: "14000006",
  773. TypeName: "护理包(内瘘穿刺包)",
  774. Remark: "",
  775. Ctime: time.Now().Unix(),
  776. Mtime: time.Now().Unix(),
  777. Creater: 0,
  778. Modifier: 0,
  779. OrgId: item.Id,
  780. Status: 1,
  781. Type: 1,
  782. Number: 7,
  783. }
  784. service.AddSigleGoodType(goodTypes6)
  785. goodTypes7 := &models.GoodsType{
  786. TypeCode: "14000007",
  787. TypeName: "细菌过滤器",
  788. Remark: "",
  789. Ctime: time.Now().Unix(),
  790. Mtime: time.Now().Unix(),
  791. Creater: 0,
  792. Modifier: 0,
  793. OrgId: item.Id,
  794. Status: 1,
  795. Type: 1,
  796. Number: 8,
  797. }
  798. service.AddSigleGoodType(goodTypes7)
  799. goodTypes8 := &models.GoodsType{
  800. TypeCode: "14000008",
  801. TypeName: "血液透析干粉",
  802. Remark: "",
  803. Ctime: time.Now().Unix(),
  804. Mtime: time.Now().Unix(),
  805. Creater: 0,
  806. Modifier: 0,
  807. OrgId: item.Id,
  808. Status: 1,
  809. Type: 1,
  810. Number: 9,
  811. }
  812. service.AddSigleGoodType(goodTypes8)
  813. goodTypes9 := &models.GoodsType{
  814. TypeCode: "14000009",
  815. TypeName: "A液",
  816. Remark: "",
  817. Ctime: time.Now().Unix(),
  818. Mtime: time.Now().Unix(),
  819. Creater: 0,
  820. Modifier: 0,
  821. OrgId: item.Id,
  822. Status: 1,
  823. Type: 1,
  824. Number: 10,
  825. }
  826. service.AddSigleGoodType(goodTypes9)
  827. goodTypes10 := &models.GoodsType{
  828. TypeCode: "14000010",
  829. TypeName: "B液",
  830. Remark: "",
  831. Ctime: time.Now().Unix(),
  832. Mtime: time.Now().Unix(),
  833. Creater: 0,
  834. Modifier: 0,
  835. OrgId: item.Id,
  836. Status: 1,
  837. Type: 1,
  838. Number: 11,
  839. }
  840. service.AddSigleGoodType(goodTypes10)
  841. goodTypes11 := &models.GoodsType{
  842. TypeCode: "14000011",
  843. TypeName: "导管包",
  844. Remark: "",
  845. Ctime: time.Now().Unix(),
  846. Mtime: time.Now().Unix(),
  847. Creater: 0,
  848. Modifier: 0,
  849. OrgId: item.Id,
  850. Status: 1,
  851. Type: 1,
  852. Number: 12,
  853. }
  854. service.AddSigleGoodType(goodTypes11)
  855. goodTypes12 := &models.GoodsType{
  856. TypeCode: "14000012",
  857. TypeName: "血液透析导管",
  858. Remark: "",
  859. Ctime: time.Now().Unix(),
  860. Mtime: time.Now().Unix(),
  861. Creater: 0,
  862. Modifier: 0,
  863. OrgId: item.Id,
  864. Status: 1,
  865. Type: 1,
  866. Number: 13,
  867. }
  868. service.AddSigleGoodType(goodTypes12)
  869. }
  870. }
  871. }
  872. func (c *PublicApiController) HandleComData() {
  873. org_ids := []int64{3907, 9779, 9883}
  874. for _, id := range org_ids {
  875. //查处所有处方记录
  876. prescriptions, _ := service.FindAllPrescription(id)
  877. if id == 3907 {
  878. for _, item := range prescriptions {
  879. if item.Niprocart > 0 {
  880. before := &models.DialysisBeforePrepare{
  881. UserOrgId: id,
  882. PatientId: item.PatientId,
  883. RecordDate: item.RecordDate,
  884. Count: 1,
  885. Ctime: item.RecordDate,
  886. Mtime: item.RecordDate,
  887. Creater: item.Creater,
  888. Modifier: item.Creater,
  889. Status: 1,
  890. }
  891. before.GoodId = item.Niprocart
  892. before.GoodTypeId = 241
  893. service.AddSigleDialysisBeforePre(before)
  894. }
  895. if item.Jms > 0 {
  896. before := &models.DialysisBeforePrepare{
  897. UserOrgId: id,
  898. PatientId: item.PatientId,
  899. RecordDate: item.RecordDate,
  900. Count: 1,
  901. Ctime: item.RecordDate,
  902. Mtime: item.RecordDate,
  903. Creater: item.Creater,
  904. Modifier: item.Creater,
  905. Status: 1,
  906. }
  907. before.GoodId = item.Jms
  908. before.GoodTypeId = 233
  909. service.AddSigleDialysisBeforePre(before)
  910. }
  911. if item.FistulaNeedleSet > 0 {
  912. before := &models.DialysisBeforePrepare{
  913. UserOrgId: id,
  914. PatientId: item.PatientId,
  915. RecordDate: item.RecordDate,
  916. Count: 1,
  917. Ctime: item.RecordDate,
  918. Mtime: item.RecordDate,
  919. Creater: item.Creater,
  920. Modifier: item.Creater,
  921. Status: 1,
  922. }
  923. before.GoodId = item.FistulaNeedleSet
  924. before.GoodTypeId = 233
  925. service.AddSigleDialysisBeforePre(before)
  926. }
  927. if item.FistulaNeedleSet16 > 0 {
  928. before := &models.DialysisBeforePrepare{
  929. UserOrgId: id,
  930. PatientId: item.PatientId,
  931. RecordDate: item.RecordDate,
  932. Count: 1,
  933. Ctime: item.RecordDate,
  934. Mtime: item.RecordDate,
  935. Creater: item.Creater,
  936. Modifier: item.Creater,
  937. Status: 1,
  938. }
  939. before.GoodId = item.FistulaNeedleSet16
  940. before.GoodTypeId = 233
  941. service.AddSigleDialysisBeforePre(before)
  942. }
  943. if item.Hemoperfusion > 0 {
  944. before := &models.DialysisBeforePrepare{
  945. UserOrgId: id,
  946. PatientId: item.PatientId,
  947. RecordDate: item.RecordDate,
  948. Count: 1,
  949. Ctime: item.RecordDate,
  950. Mtime: item.RecordDate,
  951. Creater: item.Creater,
  952. Modifier: item.Creater,
  953. Status: 1,
  954. }
  955. before.GoodId = item.Hemoperfusion
  956. before.GoodTypeId = 235
  957. service.AddSigleDialysisBeforePre(before)
  958. }
  959. if item.DialyserSterilised > 0 {
  960. before := &models.DialysisBeforePrepare{
  961. UserOrgId: id,
  962. PatientId: item.PatientId,
  963. RecordDate: item.RecordDate,
  964. Count: 1,
  965. Ctime: item.RecordDate,
  966. Mtime: item.RecordDate,
  967. Creater: item.Creater,
  968. Modifier: item.Creater,
  969. Status: 1,
  970. }
  971. before.GoodId = item.DialyserSterilised
  972. before.GoodTypeId = 234
  973. service.AddSigleDialysisBeforePre(before)
  974. }
  975. if item.Filtryzer > 0 {
  976. before := &models.DialysisBeforePrepare{
  977. UserOrgId: id,
  978. PatientId: item.PatientId,
  979. RecordDate: item.RecordDate,
  980. Count: 1,
  981. Ctime: item.RecordDate,
  982. Mtime: item.RecordDate,
  983. Creater: item.Creater,
  984. Modifier: item.Creater,
  985. Status: 1,
  986. }
  987. before.GoodId = item.Filtryzer
  988. before.GoodTypeId = 234
  989. service.AddSigleDialysisBeforePre(before)
  990. }
  991. if item.Dialyzers > 0 {
  992. before := &models.DialysisBeforePrepare{
  993. UserOrgId: id,
  994. PatientId: item.PatientId,
  995. RecordDate: item.RecordDate,
  996. Count: 1,
  997. Ctime: item.RecordDate,
  998. Mtime: item.RecordDate,
  999. Creater: item.Creater,
  1000. Modifier: item.Creater,
  1001. Status: 1,
  1002. }
  1003. before.GoodId = item.Dialyzers
  1004. before.GoodTypeId = 234
  1005. service.AddSigleDialysisBeforePre(before)
  1006. }
  1007. if item.Injector > 0 {
  1008. before := &models.DialysisBeforePrepare{
  1009. UserOrgId: id,
  1010. PatientId: item.PatientId,
  1011. RecordDate: item.RecordDate,
  1012. Count: 1,
  1013. Ctime: item.RecordDate,
  1014. Mtime: item.RecordDate,
  1015. Creater: item.Creater,
  1016. Modifier: item.Creater,
  1017. Status: 1,
  1018. }
  1019. before.GoodId = item.Injector
  1020. before.GoodTypeId = 238
  1021. service.AddSigleDialysisBeforePre(before)
  1022. }
  1023. if item.Bloodlines > 0 {
  1024. before := &models.DialysisBeforePrepare{
  1025. UserOrgId: id,
  1026. PatientId: item.PatientId,
  1027. RecordDate: item.RecordDate,
  1028. Count: 1,
  1029. Ctime: item.RecordDate,
  1030. Mtime: item.RecordDate,
  1031. Creater: item.Creater,
  1032. Modifier: item.Creater,
  1033. Status: 1,
  1034. }
  1035. before.GoodId = item.Bloodlines
  1036. before.GoodTypeId = 236
  1037. service.AddSigleDialysisBeforePre(before)
  1038. }
  1039. if item.TubingHemodialysis > 0 {
  1040. before := &models.DialysisBeforePrepare{
  1041. UserOrgId: id,
  1042. PatientId: item.PatientId,
  1043. RecordDate: item.RecordDate,
  1044. Count: 1,
  1045. Ctime: item.RecordDate,
  1046. Mtime: item.RecordDate,
  1047. Creater: item.Creater,
  1048. Modifier: item.Creater,
  1049. Status: 1,
  1050. }
  1051. before.GoodId = item.TubingHemodialysis
  1052. before.GoodTypeId = 237
  1053. service.AddSigleDialysisBeforePre(before)
  1054. }
  1055. if item.Package > 0 {
  1056. before := &models.DialysisBeforePrepare{
  1057. UserOrgId: id,
  1058. PatientId: item.PatientId,
  1059. RecordDate: item.RecordDate,
  1060. Count: 1,
  1061. Ctime: item.RecordDate,
  1062. Mtime: item.RecordDate,
  1063. Creater: item.Creater,
  1064. Modifier: item.Creater,
  1065. Status: 1,
  1066. }
  1067. before.GoodId = item.Package
  1068. before.GoodTypeId = 239
  1069. service.AddSigleDialysisBeforePre(before)
  1070. }
  1071. if item.ALiquid > 0 {
  1072. before := &models.DialysisBeforePrepare{
  1073. UserOrgId: id,
  1074. PatientId: item.PatientId,
  1075. RecordDate: item.RecordDate,
  1076. Count: 1,
  1077. Ctime: item.RecordDate,
  1078. Mtime: item.RecordDate,
  1079. Creater: item.Creater,
  1080. Modifier: item.Creater,
  1081. Status: 1,
  1082. }
  1083. before.GoodId = item.ALiquid
  1084. before.GoodTypeId = 242
  1085. service.AddSigleDialysisBeforePre(before)
  1086. }
  1087. }
  1088. } else if id == 9779 {
  1089. for _, item := range prescriptions {
  1090. if item.Niprocart > 0 {
  1091. before := &models.DialysisBeforePrepare{
  1092. UserOrgId: id,
  1093. PatientId: item.PatientId,
  1094. RecordDate: item.RecordDate,
  1095. Count: 1,
  1096. Ctime: item.RecordDate,
  1097. Mtime: item.RecordDate,
  1098. Creater: item.Creater,
  1099. Modifier: item.Creater,
  1100. Status: 1,
  1101. }
  1102. before.GoodId = item.Niprocart
  1103. before.GoodTypeId = 254
  1104. service.AddSigleDialysisBeforePre(before)
  1105. }
  1106. if item.Jms > 0 {
  1107. before := &models.DialysisBeforePrepare{
  1108. UserOrgId: id,
  1109. PatientId: item.PatientId,
  1110. RecordDate: item.RecordDate,
  1111. Count: 1,
  1112. Ctime: item.RecordDate,
  1113. Mtime: item.RecordDate,
  1114. Creater: item.Creater,
  1115. Modifier: item.Creater,
  1116. Status: 1,
  1117. }
  1118. before.GoodId = item.Jms
  1119. before.GoodTypeId = 246
  1120. service.AddSigleDialysisBeforePre(before)
  1121. }
  1122. if item.FistulaNeedleSet > 0 {
  1123. before := &models.DialysisBeforePrepare{
  1124. UserOrgId: id,
  1125. PatientId: item.PatientId,
  1126. RecordDate: item.RecordDate,
  1127. Count: 1,
  1128. Ctime: item.RecordDate,
  1129. Mtime: item.RecordDate,
  1130. Creater: item.Creater,
  1131. Modifier: item.Creater,
  1132. Status: 1,
  1133. }
  1134. before.GoodId = item.FistulaNeedleSet
  1135. before.GoodTypeId = 246
  1136. service.AddSigleDialysisBeforePre(before)
  1137. }
  1138. if item.FistulaNeedleSet16 > 0 {
  1139. before := &models.DialysisBeforePrepare{
  1140. UserOrgId: id,
  1141. PatientId: item.PatientId,
  1142. RecordDate: item.RecordDate,
  1143. Count: 1,
  1144. Ctime: item.RecordDate,
  1145. Mtime: item.RecordDate,
  1146. Creater: item.Creater,
  1147. Modifier: item.Creater,
  1148. Status: 1,
  1149. }
  1150. before.GoodId = item.FistulaNeedleSet16
  1151. before.GoodTypeId = 246
  1152. service.AddSigleDialysisBeforePre(before)
  1153. }
  1154. if item.Hemoperfusion > 0 {
  1155. before := &models.DialysisBeforePrepare{
  1156. UserOrgId: id,
  1157. PatientId: item.PatientId,
  1158. RecordDate: item.RecordDate,
  1159. Count: 1,
  1160. Ctime: item.RecordDate,
  1161. Mtime: item.RecordDate,
  1162. Creater: item.Creater,
  1163. Modifier: item.Creater,
  1164. Status: 1,
  1165. }
  1166. before.GoodId = item.Hemoperfusion
  1167. before.GoodTypeId = 248
  1168. service.AddSigleDialysisBeforePre(before)
  1169. }
  1170. if item.DialyserSterilised > 0 {
  1171. before := &models.DialysisBeforePrepare{
  1172. UserOrgId: id,
  1173. PatientId: item.PatientId,
  1174. RecordDate: item.RecordDate,
  1175. Count: 1,
  1176. Ctime: item.RecordDate,
  1177. Mtime: item.RecordDate,
  1178. Creater: item.Creater,
  1179. Modifier: item.Creater,
  1180. Status: 1,
  1181. }
  1182. before.GoodId = item.DialyserSterilised
  1183. before.GoodTypeId = 247
  1184. service.AddSigleDialysisBeforePre(before)
  1185. }
  1186. if item.Filtryzer > 0 {
  1187. before := &models.DialysisBeforePrepare{
  1188. UserOrgId: id,
  1189. PatientId: item.PatientId,
  1190. RecordDate: item.RecordDate,
  1191. Count: 1,
  1192. Ctime: item.RecordDate,
  1193. Mtime: item.RecordDate,
  1194. Creater: item.Creater,
  1195. Modifier: item.Creater,
  1196. Status: 1,
  1197. }
  1198. before.GoodId = item.Filtryzer
  1199. before.GoodTypeId = 247
  1200. service.AddSigleDialysisBeforePre(before)
  1201. }
  1202. if item.Dialyzers > 0 {
  1203. before := &models.DialysisBeforePrepare{
  1204. UserOrgId: id,
  1205. PatientId: item.PatientId,
  1206. RecordDate: item.RecordDate,
  1207. Count: 1,
  1208. Ctime: item.RecordDate,
  1209. Mtime: item.RecordDate,
  1210. Creater: item.Creater,
  1211. Modifier: item.Creater,
  1212. Status: 1,
  1213. }
  1214. before.GoodId = item.Dialyzers
  1215. before.GoodTypeId = 247
  1216. service.AddSigleDialysisBeforePre(before)
  1217. }
  1218. if item.Injector > 0 {
  1219. before := &models.DialysisBeforePrepare{
  1220. UserOrgId: id,
  1221. PatientId: item.PatientId,
  1222. RecordDate: item.RecordDate,
  1223. Count: 1,
  1224. Ctime: item.RecordDate,
  1225. Mtime: item.RecordDate,
  1226. Creater: item.Creater,
  1227. Modifier: item.Creater,
  1228. Status: 1,
  1229. }
  1230. before.GoodId = item.Injector
  1231. before.GoodTypeId = 251
  1232. service.AddSigleDialysisBeforePre(before)
  1233. }
  1234. if item.Bloodlines > 0 {
  1235. before := &models.DialysisBeforePrepare{
  1236. UserOrgId: id,
  1237. PatientId: item.PatientId,
  1238. RecordDate: item.RecordDate,
  1239. Count: 1,
  1240. Ctime: item.RecordDate,
  1241. Mtime: item.RecordDate,
  1242. Creater: item.Creater,
  1243. Modifier: item.Creater,
  1244. Status: 1,
  1245. }
  1246. before.GoodId = item.Bloodlines
  1247. before.GoodTypeId = 249
  1248. service.AddSigleDialysisBeforePre(before)
  1249. }
  1250. if item.TubingHemodialysis > 0 {
  1251. before := &models.DialysisBeforePrepare{
  1252. UserOrgId: id,
  1253. PatientId: item.PatientId,
  1254. RecordDate: item.RecordDate,
  1255. Count: 1,
  1256. Ctime: item.RecordDate,
  1257. Mtime: item.RecordDate,
  1258. Creater: item.Creater,
  1259. Modifier: item.Creater,
  1260. Status: 1,
  1261. }
  1262. before.GoodId = item.TubingHemodialysis
  1263. before.GoodTypeId = 250
  1264. service.AddSigleDialysisBeforePre(before)
  1265. }
  1266. if item.Package > 0 {
  1267. before := &models.DialysisBeforePrepare{
  1268. UserOrgId: id,
  1269. PatientId: item.PatientId,
  1270. RecordDate: item.RecordDate,
  1271. Count: 1,
  1272. Ctime: item.RecordDate,
  1273. Mtime: item.RecordDate,
  1274. Creater: item.Creater,
  1275. Modifier: item.Creater,
  1276. Status: 1,
  1277. }
  1278. before.GoodId = item.Package
  1279. before.GoodTypeId = 252
  1280. service.AddSigleDialysisBeforePre(before)
  1281. }
  1282. if item.ALiquid > 0 {
  1283. before := &models.DialysisBeforePrepare{
  1284. UserOrgId: id,
  1285. PatientId: item.PatientId,
  1286. RecordDate: item.RecordDate,
  1287. Count: 1,
  1288. Ctime: item.RecordDate,
  1289. Mtime: item.RecordDate,
  1290. Creater: item.Creater,
  1291. Modifier: item.Creater,
  1292. Status: 1,
  1293. }
  1294. before.GoodId = item.ALiquid
  1295. before.GoodTypeId = 255
  1296. service.AddSigleDialysisBeforePre(before)
  1297. }
  1298. }
  1299. } else if id == 9883 {
  1300. for _, item := range prescriptions {
  1301. if item.Niprocart > 0 {
  1302. before := &models.DialysisBeforePrepare{
  1303. UserOrgId: id,
  1304. PatientId: item.PatientId,
  1305. RecordDate: item.RecordDate,
  1306. Count: 1,
  1307. Ctime: item.RecordDate,
  1308. Mtime: item.RecordDate,
  1309. Creater: item.Creater,
  1310. Modifier: item.Creater,
  1311. Status: 1,
  1312. }
  1313. before.GoodId = item.Niprocart
  1314. before.GoodTypeId = 267
  1315. service.AddSigleDialysisBeforePre(before)
  1316. }
  1317. if item.Jms > 0 {
  1318. before := &models.DialysisBeforePrepare{
  1319. UserOrgId: id,
  1320. PatientId: item.PatientId,
  1321. RecordDate: item.RecordDate,
  1322. Count: 1,
  1323. Ctime: item.RecordDate,
  1324. Mtime: item.RecordDate,
  1325. Creater: item.Creater,
  1326. Modifier: item.Creater,
  1327. Status: 1,
  1328. }
  1329. before.GoodId = item.Jms
  1330. before.GoodTypeId = 259
  1331. service.AddSigleDialysisBeforePre(before)
  1332. }
  1333. if item.FistulaNeedleSet > 0 {
  1334. before := &models.DialysisBeforePrepare{
  1335. UserOrgId: id,
  1336. PatientId: item.PatientId,
  1337. RecordDate: item.RecordDate,
  1338. Count: 1,
  1339. Ctime: item.RecordDate,
  1340. Mtime: item.RecordDate,
  1341. Creater: item.Creater,
  1342. Modifier: item.Creater,
  1343. Status: 1,
  1344. }
  1345. before.GoodId = item.FistulaNeedleSet
  1346. before.GoodTypeId = 259
  1347. service.AddSigleDialysisBeforePre(before)
  1348. }
  1349. if item.FistulaNeedleSet16 > 0 {
  1350. before := &models.DialysisBeforePrepare{
  1351. UserOrgId: id,
  1352. PatientId: item.PatientId,
  1353. RecordDate: item.RecordDate,
  1354. Count: 1,
  1355. Ctime: item.RecordDate,
  1356. Mtime: item.RecordDate,
  1357. Creater: item.Creater,
  1358. Modifier: item.Creater,
  1359. Status: 1,
  1360. }
  1361. before.GoodId = item.FistulaNeedleSet16
  1362. before.GoodTypeId = 259
  1363. service.AddSigleDialysisBeforePre(before)
  1364. }
  1365. if item.Hemoperfusion > 0 {
  1366. before := &models.DialysisBeforePrepare{
  1367. UserOrgId: id,
  1368. PatientId: item.PatientId,
  1369. RecordDate: item.RecordDate,
  1370. Count: 1,
  1371. Ctime: item.RecordDate,
  1372. Mtime: item.RecordDate,
  1373. Creater: item.Creater,
  1374. Modifier: item.Creater,
  1375. Status: 1,
  1376. }
  1377. before.GoodId = item.Hemoperfusion
  1378. before.GoodTypeId = 261
  1379. service.AddSigleDialysisBeforePre(before)
  1380. }
  1381. if item.DialyserSterilised > 0 {
  1382. before := &models.DialysisBeforePrepare{
  1383. UserOrgId: id,
  1384. PatientId: item.PatientId,
  1385. RecordDate: item.RecordDate,
  1386. Count: 1,
  1387. Ctime: item.RecordDate,
  1388. Mtime: item.RecordDate,
  1389. Creater: item.Creater,
  1390. Modifier: item.Creater,
  1391. Status: 1,
  1392. }
  1393. before.GoodId = item.DialyserSterilised
  1394. before.GoodTypeId = 260
  1395. service.AddSigleDialysisBeforePre(before)
  1396. }
  1397. if item.Filtryzer > 0 {
  1398. before := &models.DialysisBeforePrepare{
  1399. UserOrgId: id,
  1400. PatientId: item.PatientId,
  1401. RecordDate: item.RecordDate,
  1402. Count: 1,
  1403. Ctime: item.RecordDate,
  1404. Mtime: item.RecordDate,
  1405. Creater: item.Creater,
  1406. Modifier: item.Creater,
  1407. Status: 1,
  1408. }
  1409. before.GoodId = item.Filtryzer
  1410. before.GoodTypeId = 260
  1411. service.AddSigleDialysisBeforePre(before)
  1412. }
  1413. if item.Dialyzers > 0 {
  1414. before := &models.DialysisBeforePrepare{
  1415. UserOrgId: id,
  1416. PatientId: item.PatientId,
  1417. RecordDate: item.RecordDate,
  1418. Count: 1,
  1419. Ctime: item.RecordDate,
  1420. Mtime: item.RecordDate,
  1421. Creater: item.Creater,
  1422. Modifier: item.Creater,
  1423. Status: 1,
  1424. }
  1425. before.GoodId = item.Dialyzers
  1426. before.GoodTypeId = 260
  1427. service.AddSigleDialysisBeforePre(before)
  1428. }
  1429. if item.Injector > 0 {
  1430. before := &models.DialysisBeforePrepare{
  1431. UserOrgId: id,
  1432. PatientId: item.PatientId,
  1433. RecordDate: item.RecordDate,
  1434. Count: 1,
  1435. Ctime: item.RecordDate,
  1436. Mtime: item.RecordDate,
  1437. Creater: item.Creater,
  1438. Modifier: item.Creater,
  1439. Status: 1,
  1440. }
  1441. before.GoodId = item.Injector
  1442. before.GoodTypeId = 264
  1443. service.AddSigleDialysisBeforePre(before)
  1444. }
  1445. if item.Bloodlines > 0 {
  1446. before := &models.DialysisBeforePrepare{
  1447. UserOrgId: id,
  1448. PatientId: item.PatientId,
  1449. RecordDate: item.RecordDate,
  1450. Count: 1,
  1451. Ctime: item.RecordDate,
  1452. Mtime: item.RecordDate,
  1453. Creater: item.Creater,
  1454. Modifier: item.Creater,
  1455. Status: 1,
  1456. }
  1457. before.GoodId = item.Bloodlines
  1458. before.GoodTypeId = 262
  1459. service.AddSigleDialysisBeforePre(before)
  1460. }
  1461. if item.TubingHemodialysis > 0 {
  1462. before := &models.DialysisBeforePrepare{
  1463. UserOrgId: id,
  1464. PatientId: item.PatientId,
  1465. RecordDate: item.RecordDate,
  1466. Count: 1,
  1467. Ctime: item.RecordDate,
  1468. Mtime: item.RecordDate,
  1469. Creater: item.Creater,
  1470. Modifier: item.Creater,
  1471. Status: 1,
  1472. }
  1473. before.GoodId = item.TubingHemodialysis
  1474. before.GoodTypeId = 263
  1475. service.AddSigleDialysisBeforePre(before)
  1476. }
  1477. if item.Package > 0 {
  1478. before := &models.DialysisBeforePrepare{
  1479. UserOrgId: id,
  1480. PatientId: item.PatientId,
  1481. RecordDate: item.RecordDate,
  1482. Count: 1,
  1483. Ctime: item.RecordDate,
  1484. Mtime: item.RecordDate,
  1485. Creater: item.Creater,
  1486. Modifier: item.Creater,
  1487. Status: 1,
  1488. }
  1489. before.GoodId = item.Package
  1490. before.GoodTypeId = 265
  1491. service.AddSigleDialysisBeforePre(before)
  1492. }
  1493. if item.ALiquid > 0 {
  1494. before := &models.DialysisBeforePrepare{
  1495. UserOrgId: id,
  1496. PatientId: item.PatientId,
  1497. RecordDate: item.RecordDate,
  1498. Count: 1,
  1499. Ctime: item.RecordDate,
  1500. Mtime: item.RecordDate,
  1501. Creater: item.Creater,
  1502. Modifier: item.Creater,
  1503. Status: 1,
  1504. }
  1505. before.GoodId = item.ALiquid
  1506. before.GoodTypeId = 268
  1507. service.AddSigleDialysisBeforePre(before)
  1508. }
  1509. }
  1510. }
  1511. }
  1512. }
  1513. func (c *PublicApiController) HandleHIS() {
  1514. his, _ := service.GetAllHisInfo(9919)
  1515. for _, item := range his {
  1516. fsn := strings.Split(item.FeedetlSn, "-")
  1517. item.FeedetlSn = fsn[0] + "-" + fsn[1] + "-" + strconv.FormatInt(item.ID, 10)
  1518. fmt.Println(item.FeedetlSn)
  1519. service.UpDateHis2(item)
  1520. }
  1521. }
  1522. //func (c *PublicApiController)HandleOrder(){
  1523. // //orders, _ := service.GetAllHisOrder()
  1524. //
  1525. //
  1526. // order, _ := service.GetLastHisOrder()
  1527. //
  1528. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1529. //
  1530. //
  1531. // //fmt.Println(fpNumber)
  1532. //
  1533. // //for index, item := range orders {
  1534. // // item.FaPiaoCode ="144072080589"
  1535. // // var zero string
  1536. // // if 1520 + int64(index) >= 1000{
  1537. // // zero = "0000" + strconv.FormatInt(1520 + int64(index),10)
  1538. // // }else if 1520 + int64(index) >= 10000{
  1539. // // zero = "000" + strconv.FormatInt(1520 + int64(index),10)
  1540. // // } else if 1520 + int64(index) >= 100000{
  1541. // // zero = "00" +strconv.FormatInt(1520 + int64(index),10)
  1542. // // } else if 1520 + int64(index) >= 1000000{
  1543. // // zero = "0" +strconv.FormatInt(1520 + int64(index),10)
  1544. // // }else {
  1545. // // zero = strconv.FormatInt(1520 + int64(index),10)
  1546. // // }
  1547. // // item.FaPiaoNumber = zero
  1548. // // service.SaveOrder(item)
  1549. // //}
  1550. //}
  1551. func Mkdir(dir string) {
  1552. // 创建文件夹
  1553. exist, err := PathExists(dir)
  1554. if err != nil {
  1555. fmt.Println(err.Error())
  1556. } else {
  1557. if exist {
  1558. fmt.Println(dir + "文件夹已存在!")
  1559. } else {
  1560. // 文件夹名称,权限
  1561. err := os.Mkdir(dir, os.ModePerm)
  1562. if err != nil {
  1563. fmt.Println(dir+"文件夹创建失败:", err.Error())
  1564. } else {
  1565. fmt.Println(dir + "文件夹创建成功!")
  1566. }
  1567. }
  1568. }
  1569. }
  1570. func PathExists(path string) (bool, error) {
  1571. _, err := os.Stat(path)
  1572. if err == nil {
  1573. return true, nil
  1574. }
  1575. if os.IsNotExist(err) {
  1576. return false, nil
  1577. }
  1578. return false, err
  1579. }